-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Refactor transaction result handling with TxResult and TxStatus Replaced Constant class with a new TxResult class and TxStatus enum for better transaction result representation and status tracking. Updated QuickTxBuilder methods to return TxResult instead of Result<String>, incorporating status metadata. Adjusted related test cases and methods to align with the new structure.
- Loading branch information
Showing
6 changed files
with
225 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
quicktx/src/main/java/com/bloxbean/cardano/client/quicktx/Constant.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
quicktx/src/main/java/com/bloxbean/cardano/client/quicktx/TxResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.bloxbean.cardano.client.quicktx; | ||
|
||
import com.bloxbean.cardano.client.api.model.Result; | ||
|
||
/** | ||
* Represents the result of a transaction. | ||
* | ||
* This class extends the Result class specialized with the String type, providing | ||
* additional transaction-specific functionality, such as associating a transaction | ||
* status and retrieving transaction-specific details like transaction hash. | ||
*/ | ||
public class TxResult extends Result<String> { | ||
private TxStatus txStatus; | ||
|
||
protected TxResult(boolean successful) { | ||
super(successful); | ||
} | ||
|
||
protected TxResult(boolean successful, String response) { | ||
super(successful, response); | ||
} | ||
|
||
public TxResult withTxStatus(TxStatus status) { | ||
this.txStatus = status; | ||
return this; | ||
} | ||
|
||
public TxStatus getTxStatus() { | ||
return txStatus; | ||
} | ||
|
||
public String getTxHash() { | ||
return getValue(); | ||
} | ||
|
||
public static TxResult fromResult(Result<String> result) { | ||
var txResult = new TxResult(result.isSuccessful(), result.getResponse()); | ||
txResult.withValue(result.getValue()); | ||
|
||
return txResult; | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
quicktx/src/main/java/com/bloxbean/cardano/client/quicktx/TxStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.bloxbean.cardano.client.quicktx; | ||
|
||
public enum TxStatus { | ||
SUBMITTED, | ||
FAILED, | ||
PENDING, | ||
TIMEOUT, | ||
CONFIRMED | ||
} |