Skip to content

Commit 792c594

Browse files
authored
chore: fix rn & swift demos (#134)
1 parent e0e65e0 commit 792c594

File tree

27 files changed

+572
-286
lines changed

27 files changed

+572
-286
lines changed

.github/workflows/scripts/install-anvil-zksync.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -euo pipefail
44

55
REPO_URL="https://github.com/matter-labs/anvil-zksync.git"
6-
RELEASE_VERSION="v0.3.2"
6+
RELEASE_VERSION="v0.6.1"
77
RELEASE_FILE_NAME="anvil-zksync-${RELEASE_VERSION}-aarch64-apple-darwin.tar.gz"
88
RELEASE_URL="https://github.com/matter-labs/anvil-zksync/releases/download/${RELEASE_VERSION}/${RELEASE_FILE_NAME}"
99
INSTALL_DIR="/usr/local/bin"

packages/sdk-platforms/react-native/react-native-zksync-sso/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ const config = {
2323
session: "0x...",
2424
accountPaymaster: "0x..."
2525
},
26-
nodeUrl: "https://..."
26+
nodeUrl: "https://...",
27+
deployWallet: {
28+
privateKeyHex: "..."
29+
}
2730
};
2831

2932
const accountInfo = {
@@ -34,8 +37,6 @@ const accountInfo = {
3437

3538
const challenge = generateRandomChallenge();
3639

37-
const secretAccountSalt = ...;
38-
3940
const deployedAccount = await registerAccountWithUniqueId(
4041
{
4142
name: accountInfo.name,
@@ -45,7 +46,6 @@ const deployedAccount = await registerAccountWithUniqueId(
4546
id: accountInfo.domain
4647
}
4748
},
48-
secretAccountSalt,
4949
challenge,
5050
config
5151
);

packages/sdk-platforms/react-native/react-native-zksync-sso/cpp/generated/ffi.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ extern "C" {
191191
/*handle*/ uint64_t uniffi_ffi_fn_func_deploy_account_with_unique_id(
192192
RustBuffer passkey_parameters,
193193
RustBuffer unique_account_id,
194-
RustBuffer secret_account_salt,
195194
RustBuffer config
196195
);
197196
/*handle*/ uint64_t uniffi_ffi_fn_func_fetch_account(
@@ -207,7 +206,6 @@ extern "C" {
207206
);
208207
/*handle*/ uint64_t uniffi_ffi_fn_func_get_account_by_user_id(
209208
RustBuffer unique_account_id,
210-
RustBuffer secret_account_salt,
211209
RustBuffer config
212210
);
213211
/*handle*/ uint64_t uniffi_ffi_fn_func_get_balance(
@@ -216,7 +214,6 @@ extern "C" {
216214
);
217215
/*handle*/ uint64_t uniffi_ffi_fn_func_prepare_send_transaction(
218216
RustBuffer transaction,
219-
RustBuffer from,
220217
RustBuffer config
221218
);
222219
/*handle*/ uint64_t uniffi_ffi_fn_func_send_transaction(
@@ -2638,7 +2635,7 @@ NativeFfi::NativeFfi(
26382635
props["ubrn_uniffi_ffi_fn_func_deploy_account_with_unique_id"] = jsi::Function::createFromHostFunction(
26392636
rt,
26402637
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ffi_fn_func_deploy_account_with_unique_id"),
2641-
4,
2638+
3,
26422639
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
26432640
return this->cpp_uniffi_ffi_fn_func_deploy_account_with_unique_id(rt, thisVal, args, count);
26442641
}
@@ -2670,7 +2667,7 @@ NativeFfi::NativeFfi(
26702667
props["ubrn_uniffi_ffi_fn_func_get_account_by_user_id"] = jsi::Function::createFromHostFunction(
26712668
rt,
26722669
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ffi_fn_func_get_account_by_user_id"),
2673-
3,
2670+
2,
26742671
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
26752672
return this->cpp_uniffi_ffi_fn_func_get_account_by_user_id(rt, thisVal, args, count);
26762673
}
@@ -2686,7 +2683,7 @@ NativeFfi::NativeFfi(
26862683
props["ubrn_uniffi_ffi_fn_func_prepare_send_transaction"] = jsi::Function::createFromHostFunction(
26872684
rt,
26882685
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ffi_fn_func_prepare_send_transaction"),
2689-
3,
2686+
2,
26902687
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
26912688
return this->cpp_uniffi_ffi_fn_func_prepare_send_transaction(rt, thisVal, args, count);
26922689
}
@@ -3403,7 +3400,7 @@ jsi::Value NativeFfi::cpp_uniffi_ffi_fn_func_deploy_account(jsi::Runtime& rt, co
34033400
return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker, value);
34043401
}
34053402
jsi::Value NativeFfi::cpp_uniffi_ffi_fn_func_deploy_account_with_unique_id(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
3406-
auto value = uniffi_ffi_fn_func_deploy_account_with_unique_id(uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]), uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[2]), uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[3])
3403+
auto value = uniffi_ffi_fn_func_deploy_account_with_unique_id(uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]), uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[2])
34073404
);
34083405

34093406

@@ -3433,7 +3430,7 @@ jsi::Value NativeFfi::cpp_uniffi_ffi_fn_func_generate_random_challenge(jsi::Runt
34333430
return uniffi::ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
34343431
}
34353432
jsi::Value NativeFfi::cpp_uniffi_ffi_fn_func_get_account_by_user_id(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
3436-
auto value = uniffi_ffi_fn_func_get_account_by_user_id(uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]), uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[2])
3433+
auto value = uniffi_ffi_fn_func_get_account_by_user_id(uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1])
34373434
);
34383435

34393436

@@ -3447,7 +3444,7 @@ jsi::Value NativeFfi::cpp_uniffi_ffi_fn_func_get_balance(jsi::Runtime& rt, const
34473444
return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker, value);
34483445
}
34493446
jsi::Value NativeFfi::cpp_uniffi_ffi_fn_func_prepare_send_transaction(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
3450-
auto value = uniffi_ffi_fn_func_prepare_send_transaction(uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]), uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[2])
3447+
auto value = uniffi_ffi_fn_func_prepare_send_transaction(uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1])
34513448
);
34523449

34533450

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
# gem "rails"
6+
gem "cocoapods"
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
CFPropertyList (3.0.7)
5+
base64
6+
nkf
7+
rexml
8+
activesupport (7.2.2.1)
9+
base64
10+
benchmark (>= 0.3)
11+
bigdecimal
12+
concurrent-ruby (~> 1.0, >= 1.3.1)
13+
connection_pool (>= 2.2.5)
14+
drb
15+
i18n (>= 1.6, < 2)
16+
logger (>= 1.4.2)
17+
minitest (>= 5.1)
18+
securerandom (>= 0.3)
19+
tzinfo (~> 2.0, >= 2.0.5)
20+
addressable (2.8.7)
21+
public_suffix (>= 2.0.2, < 7.0)
22+
algoliasearch (1.27.5)
23+
httpclient (~> 2.8, >= 2.8.3)
24+
json (>= 1.5.1)
25+
atomos (0.1.3)
26+
base64 (0.2.0)
27+
benchmark (0.4.0)
28+
bigdecimal (3.1.9)
29+
claide (1.1.0)
30+
cocoapods (1.16.2)
31+
addressable (~> 2.8)
32+
claide (>= 1.0.2, < 2.0)
33+
cocoapods-core (= 1.16.2)
34+
cocoapods-deintegrate (>= 1.0.3, < 2.0)
35+
cocoapods-downloader (>= 2.1, < 3.0)
36+
cocoapods-plugins (>= 1.0.0, < 2.0)
37+
cocoapods-search (>= 1.0.0, < 2.0)
38+
cocoapods-trunk (>= 1.6.0, < 2.0)
39+
cocoapods-try (>= 1.1.0, < 2.0)
40+
colored2 (~> 3.1)
41+
escape (~> 0.0.4)
42+
fourflusher (>= 2.3.0, < 3.0)
43+
gh_inspector (~> 1.0)
44+
molinillo (~> 0.8.0)
45+
nap (~> 1.0)
46+
ruby-macho (>= 2.3.0, < 3.0)
47+
xcodeproj (>= 1.27.0, < 2.0)
48+
cocoapods-core (1.16.2)
49+
activesupport (>= 5.0, < 8)
50+
addressable (~> 2.8)
51+
algoliasearch (~> 1.0)
52+
concurrent-ruby (~> 1.1)
53+
fuzzy_match (~> 2.0.4)
54+
nap (~> 1.0)
55+
netrc (~> 0.11)
56+
public_suffix (~> 4.0)
57+
typhoeus (~> 1.0)
58+
cocoapods-deintegrate (1.0.5)
59+
cocoapods-downloader (2.1)
60+
cocoapods-plugins (1.0.0)
61+
nap
62+
cocoapods-search (1.0.1)
63+
cocoapods-trunk (1.6.0)
64+
nap (>= 0.8, < 2.0)
65+
netrc (~> 0.11)
66+
cocoapods-try (1.2.0)
67+
colored2 (3.1.2)
68+
concurrent-ruby (1.3.5)
69+
connection_pool (2.5.3)
70+
drb (2.2.1)
71+
escape (0.0.4)
72+
ethon (0.16.0)
73+
ffi (>= 1.15.0)
74+
ffi (1.17.2)
75+
ffi (1.17.2-aarch64-linux-gnu)
76+
ffi (1.17.2-aarch64-linux-musl)
77+
ffi (1.17.2-arm-linux-gnu)
78+
ffi (1.17.2-arm-linux-musl)
79+
ffi (1.17.2-arm64-darwin)
80+
ffi (1.17.2-x86-linux-gnu)
81+
ffi (1.17.2-x86-linux-musl)
82+
ffi (1.17.2-x86_64-darwin)
83+
ffi (1.17.2-x86_64-linux-gnu)
84+
ffi (1.17.2-x86_64-linux-musl)
85+
fourflusher (2.3.1)
86+
fuzzy_match (2.0.4)
87+
gh_inspector (1.1.3)
88+
httpclient (2.9.0)
89+
mutex_m
90+
i18n (1.14.7)
91+
concurrent-ruby (~> 1.0)
92+
json (2.12.0)
93+
logger (1.7.0)
94+
minitest (5.25.5)
95+
molinillo (0.8.0)
96+
mutex_m (0.3.0)
97+
nanaimo (0.4.0)
98+
nap (1.1.0)
99+
netrc (0.11.0)
100+
nkf (0.2.0)
101+
public_suffix (4.0.7)
102+
rexml (3.4.1)
103+
ruby-macho (2.5.1)
104+
securerandom (0.4.1)
105+
typhoeus (1.4.1)
106+
ethon (>= 0.9.0)
107+
tzinfo (2.0.6)
108+
concurrent-ruby (~> 1.0)
109+
xcodeproj (1.27.0)
110+
CFPropertyList (>= 2.3.3, < 4.0)
111+
atomos (~> 0.1.3)
112+
claide (>= 1.0.2, < 2.0)
113+
colored2 (~> 3.1)
114+
nanaimo (~> 0.4.0)
115+
rexml (>= 3.3.6, < 4.0)
116+
117+
PLATFORMS
118+
aarch64-linux-gnu
119+
aarch64-linux-musl
120+
arm-linux-gnu
121+
arm-linux-musl
122+
arm64-darwin
123+
ruby
124+
x86-linux-gnu
125+
x86-linux-musl
126+
x86_64-darwin
127+
x86_64-linux-gnu
128+
x86_64-linux-musl
129+
130+
DEPENDENCIES
131+
cocoapods
132+
133+
BUNDLED WITH
134+
2.5.22

packages/sdk-platforms/react-native/react-native-zksync-sso/example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1852,4 +1852,4 @@ SPEC CHECKSUMS:
18521852

18531853
PODFILE CHECKSUM: 10cd32dac43f22dc58cfcba0feff6c8710711bd5
18541854

1855-
COCOAPODS: 1.15.2
1855+
COCOAPODS: 1.16.2

packages/sdk-platforms/react-native/react-native-zksync-sso/example/src/components/SendTransactionView.tsx

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import TransactionFormFields from './TransactionFormFields';
1111
import TransactionFeeView from './TransactionFeeView';
1212
import ToastView from './ToastView';
1313
import ActionButton, { ButtonStyle } from './ActionButton';
14-
import { type PreparedTransaction } from '../../../src';
14+
import { type Transaction, type PreparedTransaction } from '../../../src';
1515
import { AccountClient } from '../../../src/passkey/authenticate/account_client';
1616
import { loadConfig } from './helpers/loadConfig';
1717

@@ -64,12 +64,21 @@ const SendTransactionView: React.FC<SendTransactionViewProps> = ({
6464

6565
try {
6666
const config = loadConfig();
67-
const accountClient = new AccountClient({
68-
address: fromAccount.address,
69-
uniqueAccountId: fromAccount.uniqueAccountId
70-
}, fromAccount.info.domain, config);
71-
72-
const prepared = await accountClient.prepareTransaction(toAddress, amountInWei);
67+
const accountClient = new AccountClient(
68+
{
69+
address: fromAccount.address,
70+
uniqueAccountId: fromAccount.uniqueAccountId
71+
},
72+
fromAccount.info.domain,
73+
config
74+
);
75+
const transaction: Transaction = {
76+
to: toAddress,
77+
value: amountInWei,
78+
from: fromAccount.address,
79+
input: undefined
80+
};
81+
const prepared = await accountClient.prepareTransaction(transaction);
7382
console.log("Prepared transaction:", prepared);
7483
setPreparedTransaction(prepared);
7584
} catch (err) {
@@ -97,7 +106,14 @@ const SendTransactionView: React.FC<SendTransactionViewProps> = ({
97106
uniqueAccountId: fromAccount.uniqueAccountId
98107
}, fromAccount.info.domain, config);
99108

100-
await accountClient.sendTransaction(toAddress, amountInWei);
109+
const transaction: Transaction = {
110+
to: toAddress,
111+
value: amountInWei,
112+
from: fromAccount.address,
113+
input: undefined
114+
};
115+
116+
await accountClient.sendTransaction(transaction);
101117
setShowingSuccess(true);
102118
onTransactionSent();
103119

@@ -156,7 +172,7 @@ const SendTransactionView: React.FC<SendTransactionViewProps> = ({
156172
action={confirmTransaction}
157173
/>
158174
</ScrollView>
159-
175+
160176
{showingSuccess && (
161177
<View style={styles.toastOverlay}>
162178
<ToastView

packages/sdk-platforms/react-native/react-native-zksync-sso/example/src/components/helpers/createPasskey.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { loadConfig } from './loadConfig';
22
import sdk from '../../../../src';
33
import type { AccountInfo, DeployedAccount } from '../types';
4-
import { createSecretAccountSalt } from './createSecretAccountSalt';
54

65
/**
76
* Creates a passkey for the given account info
@@ -13,7 +12,6 @@ export const createPasskey = async (
1312
): Promise<DeployedAccount> => {
1413
const config = loadConfig();
1514
const challenge = sdk.ffi.generateRandomChallenge();
16-
const secretAccountSalt = createSecretAccountSalt();
1715
const account = await sdk.register.registerAccountWithUniqueId(
1816
{
1917
name: accountInfo.name,
@@ -23,7 +21,6 @@ export const createPasskey = async (
2321
id: accountInfo.domain
2422
}
2523
},
26-
secretAccountSalt,
2724
challenge,
2825
config
2926
);

packages/sdk-platforms/react-native/react-native-zksync-sso/example/src/components/helpers/createSecretAccountSalt.ts

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

packages/sdk-platforms/react-native/react-native-zksync-sso/example/src/components/helpers/getAccountByUserId.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import { type Account, getAccountByUserId } from '../../../../src';
2-
import { createSecretAccountSalt } from './createSecretAccountSalt';
32
import { loadConfig } from './loadConfig';
43

54
export const getAccountByUserIdWrapper = async (
65
uniqueAccountId: string
76
): Promise<Account> => {
87
const config = loadConfig();
9-
const secretAccountSalt = createSecretAccountSalt();
108
const account: Account = await getAccountByUserId(
119
uniqueAccountId,
12-
secretAccountSalt,
1310
config
1411
);
1512
console.log('Account implementation returned:', account);

0 commit comments

Comments
 (0)