Skip to content

Commit a0143c8

Browse files
committed
featfeat(swift sdk): addressing comments
1 parent a61bf7f commit a0143c8

File tree

7 files changed

+17
-44
lines changed

7 files changed

+17
-44
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# TODOs
2+
3+
[ ] Move `fund` method to seperate module to make
4+
it clear this is not indended for production use
5+
[ ] Use paymaster for deployement rather than rich wallet
6+
[ ] Consider using the `log` crate for debug logging
7+
[ ] Change passkey attestation to `direct`

packages/sdk-platforms/rust/zksync-sso/crates/sdk/src/api/account/balance.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use crate::{config::Config, utils::alloy::conveniences::get_provider};
1+
use crate::config::Config;
22
use alloy::{primitives::Address, providers::Provider};
3+
use alloy_zksync::provider::zksync_provider;
34
use money::{Money, MoneyFormatter};
45

56
#[derive(Debug)]
@@ -13,11 +14,12 @@ pub async fn get_balance(
1314
) -> eyre::Result<GetAccountBalanceResult> {
1415
println!("XDB get_balance - address: {:?}", address);
1516

16-
let provider = get_provider(config)?;
17+
let provider = zksync_provider().on_http(config.node_url.clone());
18+
1719
let balance_uint = provider.get_balance(address).await?;
1820

1921
let money = Money::eth(balance_uint);
20-
22+
2123
let formatter = MoneyFormatter::default().with_display_decimals(6);
2224
let balance = formatter.format(&money);
2325

packages/sdk-platforms/rust/zksync-sso/crates/sdk/src/api/account/fund.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use alloy_zksync::network::transaction_request::TransactionRequest;
99
use money::Money;
1010
use rand::Rng;
1111

12+
// TODO: move this to testing module
1213
pub async fn fund_account(
1314
address: Address,
1415
amount: U256,

packages/sdk-platforms/rust/zksync-sso/crates/sdk/src/client/passkey/actions/deploy/account_factory/create2_address.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use alloy::primitives::{keccak256, Address, Bytes, FixedBytes};
22

3+
// TODO: consider uptreaming this to the `alloy-zksync` crate
34
pub fn create2_address(
45
account_factory_address: Address,
56
smart_account_bytecode_hash: FixedBytes<32>,

packages/sdk-platforms/rust/zksync-sso/crates/sdk/src/utils/alloy.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use alloy::primitives::Address;
22
use eyre::eyre;
33

4-
pub mod conveniences;
54
pub mod extensions;
65
pub mod null_signer;
76
pub mod passkey_raw_signer;
@@ -21,7 +20,7 @@ mod tests {
2120

2221
let invalid = "0x1234";
2322
assert!(parse_address(invalid).is_err());
24-
23+
2524
let invalid = "0xghijk";
2625
assert!(parse_address(invalid).is_err());
2726
}

packages/sdk-platforms/rust/zksync-sso/crates/sdk/src/utils/alloy/conveniences.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

packages/sdk-platforms/rust/zksync-sso/crates/sdk/src/utils/encoding.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ pub fn encode_passkey_module_parameters(
2828
expectedOrigin: passkey.expected_origin,
2929
};
3030

31-
let mut params_bytes = PasskeyParams::abi_encode(&params);
32-
if params_bytes.starts_with(&[
33-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34-
0, 0, 0, 0, 0, 0, 0, 32,
35-
]) {
36-
params_bytes = params_bytes[32..].to_vec();
37-
}
31+
let params_bytes = PasskeyParams::abi_encode_params(&params);
3832

3933
Ok(params_bytes.into())
4034
}
@@ -57,13 +51,7 @@ pub fn encode_module_data(module_data: ModuleData) -> Result<Bytes> {
5751
parameters: module_data.parameters,
5852
};
5953

60-
let mut encoded = ModuleParams::abi_encode(&params);
61-
if encoded.starts_with(&[
62-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
63-
0, 0, 0, 0, 0, 0, 0, 32,
64-
]) {
65-
encoded = encoded[32..].to_vec();
66-
}
54+
let encoded = ModuleParams::abi_encode_params(&params);
6755

6856
Ok(encoded.into())
6957
}

0 commit comments

Comments
 (0)