-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move transaction preview analysis (#231)
* Extract tx signers. Request tx preview from gw * Handle more tx preview request errors * Compute transaction fees * Expose transaction fee mutation functions * Remove transaction fees from review analysis * Remove fee models * Take notary private key and nonce generation from hosts * Add unit tests * Fix tests * Improve coverage * Version bump * Improve coverage * Update file structure * Version bump * Split tx submit and poll status in two files * Fix test * Address PR comments * Fix swift and kotlin tests * Fix swift tests * Add test * Fmt * Address PR comments * Address PR comments * Version bump * Revert unnecessary changes * Update naming * Code cleanup * Add docs and tests --------- Co-authored-by: Matias Bzurovski <[email protected]>
- Loading branch information
1 parent
8540902
commit cebe60c
Showing
34 changed files
with
1,338 additions
and
305 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "sargon" | ||
version = "1.1.29" | ||
version = "1.1.30" | ||
edition = "2021" | ||
build = "build.rs" | ||
|
||
|
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
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
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
4 changes: 4 additions & 0 deletions
4
crates/sargon/src/gateway_api/models/types/response/transaction/preview/mod.rs
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
mod logs_inner; | ||
mod transaction_preview_response; | ||
mod transaction_receipt; | ||
mod transaction_receipt_status; | ||
|
||
pub use logs_inner::*; | ||
pub use transaction_preview_response::*; | ||
pub use transaction_receipt::*; | ||
pub use transaction_receipt_status::*; |
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
54 changes: 54 additions & 0 deletions
54
...s/sargon/src/gateway_api/models/types/response/transaction/preview/transaction_receipt.rs
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,54 @@ | ||
use crate::prelude::*; | ||
|
||
/// This is part of the response to a transaction preview request, and contains the status of the transaction. | ||
/// Error message is only present if status is `Failed` or `Rejected`. | ||
#[derive( | ||
Deserialize, | ||
Serialize, | ||
Clone, | ||
PartialEq, | ||
Eq, | ||
Debug, | ||
derive_more::Display, | ||
uniffi::Record, | ||
)] | ||
#[display("{status}")] | ||
pub struct TransactionReceipt { | ||
pub status: TransactionReceiptStatus, | ||
pub error_message: Option<String>, | ||
} | ||
|
||
impl HasSampleValues for TransactionReceipt { | ||
fn sample() -> Self { | ||
Self { | ||
status: TransactionReceiptStatus::Succeeded, | ||
error_message: None, | ||
} | ||
} | ||
|
||
fn sample_other() -> Self { | ||
Self { | ||
status: TransactionReceiptStatus::Failed, | ||
error_message: Some("An error occurred".to_string()), | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[allow(clippy::upper_case_acronyms)] | ||
type SUT = TransactionReceipt; | ||
|
||
#[test] | ||
fn equality() { | ||
assert_eq!(SUT::sample(), SUT::sample()); | ||
assert_eq!(SUT::sample_other(), SUT::sample_other()); | ||
} | ||
|
||
#[test] | ||
fn inequality() { | ||
assert_ne!(SUT::sample(), SUT::sample_other()); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...n/src/gateway_api/models/types/response/transaction/preview/transaction_receipt_status.rs
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,17 @@ | ||
use crate::prelude::*; | ||
|
||
#[derive( | ||
Deserialize, | ||
Serialize, | ||
Clone, | ||
PartialEq, | ||
Eq, | ||
Debug, | ||
derive_more::Display, | ||
uniffi::Enum, | ||
)] | ||
pub enum TransactionReceiptStatus { | ||
Succeeded, | ||
Failed, | ||
Rejected, | ||
} |
Oops, something went wrong.