Skip to content

Commit

Permalink
Remove special handling for virtual accounts (#301)
Browse files Browse the repository at this point in the history
remove special handling for 2 endpoints
  • Loading branch information
matiasbzurovski authored Dec 10, 2024
1 parent 723d183 commit 217f10a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 56 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/sargon-uniffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sargon-uniffi"
# Don't forget to update version in crates/sargon/Cargo.toml
version = "1.1.80"
version = "1.1.81"
edition = "2021"
build = "build.rs"

Expand Down
2 changes: 1 addition & 1 deletion crates/sargon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sargon"
# Don't forget to update version in crates/sargon-uniffi/Cargo.toml
version = "1.1.80"
version = "1.1.81"
edition = "2021"
build = "build.rs"

Expand Down
78 changes: 28 additions & 50 deletions crates/sargon/src/gateway_api/methods/state_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,31 +172,20 @@ impl GatewayClient {
account_address: AccountAddress,
ledger_state_selector: LedgerStateSelector,
) -> Result<Vec<AccountResourcePreference>> {
let result = self
.load_all_pages(
None,
ledger_state_selector,
|cursor, ledger_state_selector| {
let request = AccountPageResourcePreferencesRequest::new(
account_address,
ledger_state_selector,
cursor,
GATEWAY_PAGE_REQUEST_LIMIT,
);
self.account_page_resource_preferences(request)
},
)
.await;
match result {
Ok(response) => Ok(response),
Err(CommonError::NetworkResponseBadCode { code: 404 }) => {
// The GW is currently returning a 404 when this endpoint is called with a virtual account.
// This is a temporary workaround until the GW is fixed.
// More info on thread: https://rdxworks.slack.com/archives/C06EBEA0SGY/p1731686360114749
Ok(vec![])
}
Err(e) => Err(e),
}
self.load_all_pages(
None,
ledger_state_selector,
|cursor, ledger_state_selector| {
let request = AccountPageResourcePreferencesRequest::new(
account_address,
ledger_state_selector,
cursor,
GATEWAY_PAGE_REQUEST_LIMIT,
);
self.account_page_resource_preferences(request)
},
)
.await
}

/// Fetches all the account's authorized depositors.
Expand All @@ -205,31 +194,20 @@ impl GatewayClient {
account_address: AccountAddress,
ledger_state_selector: LedgerStateSelector,
) -> Result<Vec<AccountAuthorizedDepositor>> {
let result = self
.load_all_pages(
None,
ledger_state_selector,
|cursor, ledger_state_selector| {
let request = AccountPageAuthorizedDepositorsRequest::new(
account_address,
ledger_state_selector,
cursor,
GATEWAY_PAGE_REQUEST_LIMIT,
);
self.account_page_authorized_depositors(request)
},
)
.await;
match result {
Ok(response) => Ok(response),
Err(CommonError::NetworkResponseBadCode { code: 404 }) => {
// The GW is currently returning a 404 when this endpoint is called with a virtual account.
// This is a temporary workaround until the GW is fixed.
// More info on thread: https://rdxworks.slack.com/archives/C06EBEA0SGY/p1731686360114749
Ok(vec![])
}
Err(e) => Err(e),
}
self.load_all_pages(
None,
ledger_state_selector,
|cursor, ledger_state_selector| {
let request = AccountPageAuthorizedDepositorsRequest::new(
account_address,
ledger_state_selector,
cursor,
GATEWAY_PAGE_REQUEST_LIMIT,
);
self.account_page_authorized_depositors(request)
},
)
.await
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/sargon/src/system/sargon_os/sargon_os_signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ mod test {
.unwrap();

let signature_with_public_key = SignatureWithPublicKey::from((
signed.public_key.as_ed25519().unwrap().clone(),
signed.signature.as_ed25519().unwrap().clone(),
*signed.public_key.as_ed25519().unwrap(),
*signed.signature.as_ed25519().unwrap(),
));

assert!(signature_with_public_key
Expand Down

0 comments on commit 217f10a

Please sign in to comment.