@dynamic-labs/ethereum-aa 4.10.4-preview.1 → 4.10.4-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -10
- package/src/ZKsyncConnector.cjs +64 -10
- package/src/ZKsyncConnector.d.ts +17 -19
- package/src/ZKsyncConnector.js +61 -7
- package/src/ZKsync/client.cjs +0 -31
- package/src/ZKsync/client.d.ts +0 -25
- package/src/ZKsync/client.js +0 -27
- package/src/ZKsync/ecdsaAccount.cjs +0 -32
- package/src/ZKsync/ecdsaAccount.d.ts +0 -13
- package/src/ZKsync/ecdsaAccount.js +0 -28
- package/src/ZKsync/getEip712Domain.cjs +0 -62
- package/src/ZKsync/getEip712Domain.d.ts +0 -2
- package/src/ZKsync/getEip712Domain.js +0 -58
- package/src/ZKsync/session.cjs +0 -1218
- package/src/ZKsync/session.d.ts +0 -904
- package/src/ZKsync/session.js +0 -1211
- package/src/ZKsync/types.cjs +0 -52
- package/src/ZKsync/types.d.ts +0 -9
- package/src/ZKsync/types.js +0 -48
- package/src/ZKsync/walletActions.cjs +0 -93
- package/src/ZKsync/walletActions.d.ts +0 -15
- package/src/ZKsync/walletActions.js +0 -87
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.10.4-preview.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.10.4...v4.10.4-preview.2) (2025-04-09)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add session key client ([#8463](https://github.com/dynamic-labs/dynamic-auth/issues/8463)) ([d08019c](https://github.com/dynamic-labs/dynamic-auth/commit/d08019ccf82bfc75b26a24170bfa6086d80df69a))
|
|
8
|
+
* add zk sync aa connector ([baf6241](https://github.com/dynamic-labs/dynamic-auth/commit/baf6241119dde2c3ce6c4ae3ac5467d50e1b3953))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **QNTM-3113:** fix network switcher fallback logic ([#8478](https://github.com/dynamic-labs/dynamic-auth/issues/8478)) ([173c4f7](https://github.com/dynamic-labs/dynamic-auth/commit/173c4f7a66e130dd8d5f9726596807489609bf14))
|
|
14
|
+
* retrieval of walletclient for zksync connector ([0707bc3](https://github.com/dynamic-labs/dynamic-auth/commit/0707bc39049c54bf5fe10953faf5486bcf317f20))
|
|
15
|
+
|
|
2
16
|
### [4.10.4-preview.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.10.4...v4.10.4-preview.1) (2025-04-08)
|
|
3
17
|
|
|
4
18
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum-aa",
|
|
3
|
-
"version": "4.10.4-preview.
|
|
3
|
+
"version": "4.10.4-preview.2",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,15 +22,14 @@
|
|
|
22
22
|
"@zerodev/ecdsa-validator": "5.4.4",
|
|
23
23
|
"@zerodev/multi-chain-ecdsa-validator": "5.4.3",
|
|
24
24
|
"@zerodev/sdk": "5.4.26",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"@dynamic-labs/
|
|
28
|
-
"@dynamic-labs/
|
|
29
|
-
"@dynamic-labs/
|
|
30
|
-
"@dynamic-labs/
|
|
31
|
-
"@dynamic-labs/
|
|
32
|
-
"@dynamic-labs/wallet-
|
|
33
|
-
"@dynamic-labs/wallet-connector-core": "4.10.4-preview.1"
|
|
25
|
+
"zksync-sso": "0.0.0-beta.14",
|
|
26
|
+
"@dynamic-labs/assert-package-version": "4.10.4-preview.2",
|
|
27
|
+
"@dynamic-labs/ethereum-core": "4.10.4-preview.2",
|
|
28
|
+
"@dynamic-labs/logger": "4.10.4-preview.2",
|
|
29
|
+
"@dynamic-labs/types": "4.10.4-preview.2",
|
|
30
|
+
"@dynamic-labs/utils": "4.10.4-preview.2",
|
|
31
|
+
"@dynamic-labs/wallet-book": "4.10.4-preview.2",
|
|
32
|
+
"@dynamic-labs/wallet-connector-core": "4.10.4-preview.2"
|
|
34
33
|
},
|
|
35
34
|
"peerDependencies": {
|
|
36
35
|
"viem": "^2.21.55"
|
package/src/ZKsyncConnector.cjs
CHANGED
|
@@ -8,13 +8,12 @@ var viem = require('viem');
|
|
|
8
8
|
var zksync = require('viem/zksync');
|
|
9
9
|
var passkey = require('zksync-sso/client/passkey');
|
|
10
10
|
var utils$1 = require('zksync-sso/utils');
|
|
11
|
-
var client
|
|
11
|
+
var client = require('zksync-sso/client');
|
|
12
|
+
var ecdsa = require('zksync-sso/client/ecdsa');
|
|
12
13
|
var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
13
14
|
var utils = require('@dynamic-labs/utils');
|
|
14
15
|
var AccountAbstractionConnector = require('./AccountAbstractionConnector.cjs');
|
|
15
16
|
var abi = require('./utils/abi.cjs');
|
|
16
|
-
var client = require('./ZKsync/client.cjs');
|
|
17
|
-
var walletActions = require('./ZKsync/walletActions.cjs');
|
|
18
17
|
|
|
19
18
|
class ZKsyncConnector extends AccountAbstractionConnector.AccountAbstractionConnector {
|
|
20
19
|
constructor(props) {
|
|
@@ -88,12 +87,67 @@ class ZKsyncConnector extends AccountAbstractionConnector.AccountAbstractionConn
|
|
|
88
87
|
getAccountAbstractionProvider() {
|
|
89
88
|
return this.smartAccount;
|
|
90
89
|
}
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
92
90
|
getWalletClient() {
|
|
93
|
-
|
|
91
|
+
const smartAccountClient = this.smartAccount;
|
|
92
|
+
if (!smartAccountClient) {
|
|
94
93
|
return undefined;
|
|
95
94
|
}
|
|
96
|
-
|
|
95
|
+
const transport = this.getWalletClientTransport(smartAccountClient);
|
|
96
|
+
return viem.createWalletClient({
|
|
97
|
+
account: smartAccountClient.account,
|
|
98
|
+
chain: smartAccountClient.chain,
|
|
99
|
+
transport,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
getWalletClientTransport(smartAccountClient) {
|
|
103
|
+
return viem.custom({
|
|
104
|
+
request: (_a) => _tslib.__awaiter(this, [_a], void 0, function* ({ method, params, }) {
|
|
105
|
+
const handleRequest = () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
var _b;
|
|
107
|
+
switch (method) {
|
|
108
|
+
case 'personal_sign':
|
|
109
|
+
// Delegate signing to the smart account client instance
|
|
110
|
+
return smartAccountClient.signMessage({ message: params[0] });
|
|
111
|
+
case 'eth_signTypedData_v4': {
|
|
112
|
+
// Delegate typed data signing to the smart account client instance
|
|
113
|
+
// Note: ZKsync usually expects JSON string for EIP712, but viem standard passes object.
|
|
114
|
+
// The smartAccountClient's signTypedData should handle the expected format internally.
|
|
115
|
+
const signTypedDataParams = params[1]; // Assuming standard viem format
|
|
116
|
+
return smartAccountClient.signTypedData(signTypedDataParams);
|
|
117
|
+
}
|
|
118
|
+
case 'eth_sendTransaction':
|
|
119
|
+
// Delegate transaction sending to the smart account client instance.
|
|
120
|
+
// This ensures deployment checks, paymaster logic, etc., are handled.
|
|
121
|
+
return smartAccountClient.sendTransaction(params[0]);
|
|
122
|
+
case 'eth_accounts':
|
|
123
|
+
case 'eth_requestAccounts':
|
|
124
|
+
// Return the smart account address
|
|
125
|
+
return ((_b = smartAccountClient.account) === null || _b === void 0 ? void 0 : _b.address)
|
|
126
|
+
? [smartAccountClient.account.address]
|
|
127
|
+
: [];
|
|
128
|
+
case 'eth_chainId': {
|
|
129
|
+
// Return chainId from the smart account client
|
|
130
|
+
const chainId = yield smartAccountClient.getChainId();
|
|
131
|
+
return viem.toHex(chainId);
|
|
132
|
+
}
|
|
133
|
+
default: {
|
|
134
|
+
// For other read-only methods, delegate to a basic public client transport.
|
|
135
|
+
// Avoid creating a new client/transport on every call if possible,
|
|
136
|
+
// but for simplicity here, we create it transiently.
|
|
137
|
+
// Consider caching this public client if performance becomes an issue.
|
|
138
|
+
const publicClient = viem.createPublicClient({
|
|
139
|
+
chain: smartAccountClient.chain,
|
|
140
|
+
transport: viem.http(undefined, this.providersConfig.httpTransportConfig), // Use configured transport if available
|
|
141
|
+
});
|
|
142
|
+
return publicClient.request({ method, params });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
// The internal confirmationTransport used by smartAccountClient via its 'owner'
|
|
147
|
+
// should handle the UI prompts. We don't need to add extra prompts here.
|
|
148
|
+
return handleRequest();
|
|
149
|
+
}),
|
|
150
|
+
});
|
|
97
151
|
}
|
|
98
152
|
getTransport(provider) {
|
|
99
153
|
const transport = ethereumCore.confirmationTransport({
|
|
@@ -147,7 +201,7 @@ class ZKsyncConnector extends AccountAbstractionConnector.AccountAbstractionConn
|
|
|
147
201
|
}
|
|
148
202
|
const transport = this.getTransport(eoaSigner);
|
|
149
203
|
const ownerWithTransport = viem.createWalletClient(Object.assign(Object.assign({}, eoaSigner), { transport }));
|
|
150
|
-
const walletClient = yield
|
|
204
|
+
const walletClient = yield ecdsa.createZksyncEcdsaClient({
|
|
151
205
|
address: this.smartAccountAddress,
|
|
152
206
|
chain: ethereumCore.getOrMapViemChain(this.evmNetworks[0]),
|
|
153
207
|
contracts: {
|
|
@@ -155,7 +209,7 @@ class ZKsyncConnector extends AccountAbstractionConnector.AccountAbstractionConn
|
|
|
155
209
|
session: this.sessionKeyAddress,
|
|
156
210
|
},
|
|
157
211
|
owner: ownerWithTransport,
|
|
158
|
-
transport: viem.
|
|
212
|
+
transport: viem.custom(ownerWithTransport),
|
|
159
213
|
});
|
|
160
214
|
return walletClient;
|
|
161
215
|
});
|
|
@@ -183,7 +237,7 @@ class ZKsyncConnector extends AccountAbstractionConnector.AccountAbstractionConn
|
|
|
183
237
|
if (!this.smartAccountAddress) {
|
|
184
238
|
throw new Error('Smart account address is not initialized');
|
|
185
239
|
}
|
|
186
|
-
return client
|
|
240
|
+
return client.createZksyncSessionClient({
|
|
187
241
|
address: this.smartAccountAddress,
|
|
188
242
|
chain: ethereumCore.getOrMapViemChain(this.evmNetworks[0]),
|
|
189
243
|
contracts: {
|
|
@@ -334,7 +388,7 @@ class ZKsyncConnector extends AccountAbstractionConnector.AccountAbstractionConn
|
|
|
334
388
|
.extend(viem.publicActions)
|
|
335
389
|
.extend(viem.walletActions)
|
|
336
390
|
.extend(zksync.eip712WalletActions())
|
|
337
|
-
.extend(
|
|
391
|
+
.extend(ecdsa.zksyncSsoEcdsaWalletActions);
|
|
338
392
|
});
|
|
339
393
|
}
|
|
340
394
|
/**
|
package/src/ZKsyncConnector.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Account, RpcSchema, SignTypedDataParameters, Transport, type PublicClient, type Chain as ViemChain, type WalletClient } from 'viem';
|
|
1
|
+
import { Account, CustomTransport, RpcSchema, SignTypedDataParameters, Transport, type PublicClient, type Chain as ViemChain, type WalletClient } from 'viem';
|
|
2
2
|
import { ZksyncSsoPasskeyClient } from 'zksync-sso/client/passkey';
|
|
3
3
|
import { SessionConfig } from 'zksync-sso/utils';
|
|
4
4
|
import { ZksyncSsoSessionClient } from 'zksync-sso/client';
|
|
5
|
+
import { ZksyncSsoEcdsaClient } from 'zksync-sso/client/ecdsa';
|
|
5
6
|
import { EthereumWallet, RegisterEvmProvidersConfig } from '@dynamic-labs/ethereum-core';
|
|
6
7
|
import { ProjectSettings, Provider, ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
7
8
|
import { EvmNetwork, GenericNetwork, IUITransaction, WalletUiUtils } from '@dynamic-labs/types';
|
|
8
9
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
9
10
|
import { Chain, InternalWalletConnector, IZKsyncConnector, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
10
11
|
import { AccountAbstractionConnector, AccountAbstractionConnectorProps } from './AccountAbstractionConnector';
|
|
11
|
-
import { ZksyncSsoEcdsaClient } from './ZKsync/client';
|
|
12
12
|
type ZKsyncConnectorProps = AccountAbstractionConnectorProps & {
|
|
13
13
|
apiProviders: {
|
|
14
14
|
[key in ProviderEnum]?: Provider;
|
|
@@ -67,6 +67,7 @@ export declare class ZKsyncConnector extends AccountAbstractionConnector impleme
|
|
|
67
67
|
canSponsorTransactionGas(): Promise<boolean>;
|
|
68
68
|
getAccountAbstractionProvider<T = ZksyncSsoEcdsaClient<Transport, ViemChain, RpcSchema>>(): T;
|
|
69
69
|
getWalletClient(): WalletClient | undefined;
|
|
70
|
+
private getWalletClientTransport;
|
|
70
71
|
private getTransport;
|
|
71
72
|
getSigner(): Promise<{
|
|
72
73
|
account: Account | undefined;
|
|
@@ -8077,10 +8078,7 @@ export declare class ZKsyncConnector extends AccountAbstractionConnector impleme
|
|
|
8077
8078
|
Parameters: import("viem").WatchAssetParams;
|
|
8078
8079
|
ReturnType: boolean;
|
|
8079
8080
|
}]>;
|
|
8080
|
-
transport: import("viem").TransportConfig<"
|
|
8081
|
-
fetchOptions?: Omit<RequestInit, "body"> | undefined;
|
|
8082
|
-
url?: string | undefined;
|
|
8083
|
-
};
|
|
8081
|
+
transport: import("viem").TransportConfig<"custom", import("viem").EIP1193RequestFn>;
|
|
8084
8082
|
type: string;
|
|
8085
8083
|
uid: string;
|
|
8086
8084
|
call: (parameters: import("viem").CallParameters<{
|
|
@@ -22447,7 +22445,7 @@ export declare class ZKsyncConnector extends AccountAbstractionConnector impleme
|
|
|
22447
22445
|
testnet?: boolean | undefined;
|
|
22448
22446
|
} & import("viem").ChainConfig<import("viem").ChainFormatters | undefined, Record<string, unknown> | undefined>>) => Promise<import("viem").TransactionReceipt>;
|
|
22449
22447
|
watchBlockNumber: (args: import("viem").WatchBlockNumberParameters) => import("viem").WatchBlockNumberReturnType;
|
|
22450
|
-
watchBlocks: <includeTransactions_1 extends boolean = false, blockTag_2 extends import("viem").BlockTag = "latest">(args: import("viem").WatchBlocksParameters<
|
|
22448
|
+
watchBlocks: <includeTransactions_1 extends boolean = false, blockTag_2 extends import("viem").BlockTag = "latest">(args: import("viem").WatchBlocksParameters<CustomTransport, {
|
|
22451
22449
|
blockExplorers?: {
|
|
22452
22450
|
[key: string]: {
|
|
22453
22451
|
name: string;
|
|
@@ -22489,9 +22487,9 @@ export declare class ZKsyncConnector extends AccountAbstractionConnector impleme
|
|
|
22489
22487
|
sourceId?: number | undefined;
|
|
22490
22488
|
testnet?: boolean | undefined;
|
|
22491
22489
|
} & import("viem").ChainConfig<import("viem").ChainFormatters | undefined, Record<string, unknown> | undefined>, includeTransactions_1, blockTag_2>) => import("viem").WatchBlocksReturnType;
|
|
22492
|
-
watchContractEvent: <const abi_7 extends import("viem").Abi | readonly unknown[], eventName_4 extends import("viem").ContractEventName<abi_7>, strict_6 extends boolean | undefined = undefined>(args: import("viem").WatchContractEventParameters<abi_7, eventName_4, strict_6,
|
|
22493
|
-
watchEvent: <const abiEvent_2 extends import("viem").AbiEvent | undefined = undefined, const abiEvents_2 extends readonly unknown[] | readonly import("viem").AbiEvent[] | undefined = abiEvent_2 extends import("viem").AbiEvent ? [abiEvent_2] : undefined, strict_7 extends boolean | undefined = undefined>(args: import("viem").WatchEventParameters<abiEvent_2, abiEvents_2, strict_7,
|
|
22494
|
-
watchPendingTransactions: (args: import("viem").WatchPendingTransactionsParameters<
|
|
22490
|
+
watchContractEvent: <const abi_7 extends import("viem").Abi | readonly unknown[], eventName_4 extends import("viem").ContractEventName<abi_7>, strict_6 extends boolean | undefined = undefined>(args: import("viem").WatchContractEventParameters<abi_7, eventName_4, strict_6, CustomTransport>) => import("viem").WatchContractEventReturnType;
|
|
22491
|
+
watchEvent: <const abiEvent_2 extends import("viem").AbiEvent | undefined = undefined, const abiEvents_2 extends readonly unknown[] | readonly import("viem").AbiEvent[] | undefined = abiEvent_2 extends import("viem").AbiEvent ? [abiEvent_2] : undefined, strict_7 extends boolean | undefined = undefined>(args: import("viem").WatchEventParameters<abiEvent_2, abiEvents_2, strict_7, CustomTransport>) => import("viem").WatchEventReturnType;
|
|
22492
|
+
watchPendingTransactions: (args: import("viem").WatchPendingTransactionsParameters<CustomTransport>) => import("viem").WatchPendingTransactionsReturnType;
|
|
22495
22493
|
addChain: (args: import("viem").AddChainParameters) => Promise<void>;
|
|
22496
22494
|
deployContract: <const abi_8 extends import("viem").Abi | readonly unknown[], chainOverride_5 extends ViemChain | undefined>(args: import("viem").DeployContractParameters<abi_8, {
|
|
22497
22495
|
blockExplorers?: {
|
|
@@ -23893,8 +23891,8 @@ export declare class ZKsyncConnector extends AccountAbstractionConnector impleme
|
|
|
23893
23891
|
sourceId?: number | undefined;
|
|
23894
23892
|
testnet?: boolean | undefined;
|
|
23895
23893
|
} & import("viem").ChainConfig<import("viem").ChainFormatters | undefined, Record<string, unknown> | undefined>, Account, chainOverride_8>) => Promise<`0x${string}`>;
|
|
23896
|
-
createSession: (args: Omit<import("
|
|
23897
|
-
revokeSession: (args: Omit<import("
|
|
23894
|
+
createSession: (args: Omit<import("node_modules/zksync-sso/dist/_types/client/session/actions/session").CreateSessionArgs, "contracts">) => Promise<import("node_modules/zksync-sso/dist/_types/client/session/actions/session").CreateSessionReturnType>;
|
|
23895
|
+
revokeSession: (args: Omit<import("node_modules/zksync-sso/dist/_types/client/session/actions/session").RevokeSessionArgs, "contracts">) => Promise<import("node_modules/zksync-sso/dist/_types/client/session/actions/session").RevokeSessionReturnType>;
|
|
23898
23896
|
extend: <const client extends {
|
|
23899
23897
|
[x: string]: unknown;
|
|
23900
23898
|
account?: undefined;
|
|
@@ -23909,7 +23907,7 @@ export declare class ZKsyncConnector extends AccountAbstractionConnector impleme
|
|
|
23909
23907
|
transport?: undefined;
|
|
23910
23908
|
type?: undefined;
|
|
23911
23909
|
uid?: undefined;
|
|
23912
|
-
} & import("viem").ExactPartial<Pick<import("viem").PublicActions<
|
|
23910
|
+
} & import("viem").ExactPartial<Pick<import("viem").PublicActions<CustomTransport, {
|
|
23913
23911
|
blockExplorers?: {
|
|
23914
23912
|
[key: string]: {
|
|
23915
23913
|
name: string;
|
|
@@ -23991,7 +23989,7 @@ export declare class ZKsyncConnector extends AccountAbstractionConnector impleme
|
|
|
23991
23989
|
};
|
|
23992
23990
|
sourceId?: number | undefined;
|
|
23993
23991
|
testnet?: boolean | undefined;
|
|
23994
|
-
} & import("viem").ChainConfig<import("viem").ChainFormatters | undefined, Record<string, unknown> | undefined>, Account>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<
|
|
23992
|
+
} & import("viem").ChainConfig<import("viem").ChainFormatters | undefined, Record<string, unknown> | undefined>, Account>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<CustomTransport, {
|
|
23995
23993
|
blockExplorers?: {
|
|
23996
23994
|
[key: string]: {
|
|
23997
23995
|
name: string;
|
|
@@ -24326,7 +24324,7 @@ export declare class ZKsyncConnector extends AccountAbstractionConnector impleme
|
|
|
24326
24324
|
Method: "wallet_watchAsset";
|
|
24327
24325
|
Parameters: import("viem").WatchAssetParams;
|
|
24328
24326
|
ReturnType: boolean;
|
|
24329
|
-
}], import("viem").PublicActions<
|
|
24327
|
+
}], import("viem").PublicActions<CustomTransport, {
|
|
24330
24328
|
blockExplorers?: {
|
|
24331
24329
|
[key: string]: {
|
|
24332
24330
|
name: string;
|
|
@@ -24408,7 +24406,7 @@ export declare class ZKsyncConnector extends AccountAbstractionConnector impleme
|
|
|
24408
24406
|
};
|
|
24409
24407
|
sourceId?: number | undefined;
|
|
24410
24408
|
testnet?: boolean | undefined;
|
|
24411
|
-
} & import("viem").ChainConfig<import("viem").ChainFormatters | undefined, Record<string, unknown> | undefined>, Account> & import("
|
|
24409
|
+
} & import("viem").ChainConfig<import("viem").ChainFormatters | undefined, Record<string, unknown> | undefined>, Account> & import("zksync-sso/client/ecdsa").ZksyncSsoEcdsaActions>) => client) => import("viem").Client<CustomTransport, {
|
|
24412
24410
|
blockExplorers?: {
|
|
24413
24411
|
[key: string]: {
|
|
24414
24412
|
name: string;
|
|
@@ -24743,7 +24741,7 @@ export declare class ZKsyncConnector extends AccountAbstractionConnector impleme
|
|
|
24743
24741
|
Method: "wallet_watchAsset";
|
|
24744
24742
|
Parameters: import("viem").WatchAssetParams;
|
|
24745
24743
|
ReturnType: boolean;
|
|
24746
|
-
}], { [K_3 in keyof client]: client[K_3]; } & import("viem").PublicActions<
|
|
24744
|
+
}], { [K_3 in keyof client]: client[K_3]; } & import("viem").PublicActions<CustomTransport, {
|
|
24747
24745
|
blockExplorers?: {
|
|
24748
24746
|
[key: string]: {
|
|
24749
24747
|
name: string;
|
|
@@ -24825,8 +24823,8 @@ export declare class ZKsyncConnector extends AccountAbstractionConnector impleme
|
|
|
24825
24823
|
};
|
|
24826
24824
|
sourceId?: number | undefined;
|
|
24827
24825
|
testnet?: boolean | undefined;
|
|
24828
|
-
} & import("viem").ChainConfig<import("viem").ChainFormatters | undefined, Record<string, unknown> | undefined>, Account> & import("
|
|
24829
|
-
contracts: import("
|
|
24826
|
+
} & import("viem").ChainConfig<import("viem").ChainFormatters | undefined, Record<string, unknown> | undefined>, Account> & import("zksync-sso/client/ecdsa").ZksyncSsoEcdsaActions>;
|
|
24827
|
+
contracts: import("zksync-sso/client/ecdsa").EcdsaRequiredContracts;
|
|
24830
24828
|
paymasterHandler?: import("zksync-sso/paymaster").CustomPaymasterHandler | undefined;
|
|
24831
24829
|
}>;
|
|
24832
24830
|
/**
|
package/src/ZKsyncConnector.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
3
|
-
import { createPublicClient, http,
|
|
3
|
+
import { createPublicClient, http, createWalletClient, custom, publicActions, walletActions, toBytes, keccak256, toHex } from 'viem';
|
|
4
4
|
import { getGeneralPaymasterInput, eip712WalletActions } from 'viem/zksync';
|
|
5
5
|
import { createZksyncPasskeyClient, registerNewPasskey } from 'zksync-sso/client/passkey';
|
|
6
6
|
import { encodeModuleData, getPublicKeyBytesFromPasskeySignature, encodePasskeyModuleParameters } from 'zksync-sso/utils';
|
|
7
7
|
import { createZksyncSessionClient } from 'zksync-sso/client';
|
|
8
|
+
import { createZksyncEcdsaClient, zksyncSsoEcdsaWalletActions } from 'zksync-sso/client/ecdsa';
|
|
8
9
|
import { EthereumWallet, getOrMapViemChain, confirmationTransport, createViemUiTransaction } from '@dynamic-labs/ethereum-core';
|
|
9
10
|
import { parseEvmNetworks, DeferredPromise, StorageService, DynamicError } from '@dynamic-labs/utils';
|
|
10
11
|
import { AccountAbstractionConnector } from './AccountAbstractionConnector.js';
|
|
11
12
|
import { AAFactoryABI } from './utils/abi.js';
|
|
12
|
-
import { createZksyncEcdsaClient } from './ZKsync/client.js';
|
|
13
|
-
import { zksyncSsoEcdsaWalletActions } from './ZKsync/walletActions.js';
|
|
14
13
|
|
|
15
14
|
class ZKsyncConnector extends AccountAbstractionConnector {
|
|
16
15
|
constructor(props) {
|
|
@@ -84,12 +83,67 @@ class ZKsyncConnector extends AccountAbstractionConnector {
|
|
|
84
83
|
getAccountAbstractionProvider() {
|
|
85
84
|
return this.smartAccount;
|
|
86
85
|
}
|
|
87
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
88
86
|
getWalletClient() {
|
|
89
|
-
|
|
87
|
+
const smartAccountClient = this.smartAccount;
|
|
88
|
+
if (!smartAccountClient) {
|
|
90
89
|
return undefined;
|
|
91
90
|
}
|
|
92
|
-
|
|
91
|
+
const transport = this.getWalletClientTransport(smartAccountClient);
|
|
92
|
+
return createWalletClient({
|
|
93
|
+
account: smartAccountClient.account,
|
|
94
|
+
chain: smartAccountClient.chain,
|
|
95
|
+
transport,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
getWalletClientTransport(smartAccountClient) {
|
|
99
|
+
return custom({
|
|
100
|
+
request: (_a) => __awaiter(this, [_a], void 0, function* ({ method, params, }) {
|
|
101
|
+
const handleRequest = () => __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
var _b;
|
|
103
|
+
switch (method) {
|
|
104
|
+
case 'personal_sign':
|
|
105
|
+
// Delegate signing to the smart account client instance
|
|
106
|
+
return smartAccountClient.signMessage({ message: params[0] });
|
|
107
|
+
case 'eth_signTypedData_v4': {
|
|
108
|
+
// Delegate typed data signing to the smart account client instance
|
|
109
|
+
// Note: ZKsync usually expects JSON string for EIP712, but viem standard passes object.
|
|
110
|
+
// The smartAccountClient's signTypedData should handle the expected format internally.
|
|
111
|
+
const signTypedDataParams = params[1]; // Assuming standard viem format
|
|
112
|
+
return smartAccountClient.signTypedData(signTypedDataParams);
|
|
113
|
+
}
|
|
114
|
+
case 'eth_sendTransaction':
|
|
115
|
+
// Delegate transaction sending to the smart account client instance.
|
|
116
|
+
// This ensures deployment checks, paymaster logic, etc., are handled.
|
|
117
|
+
return smartAccountClient.sendTransaction(params[0]);
|
|
118
|
+
case 'eth_accounts':
|
|
119
|
+
case 'eth_requestAccounts':
|
|
120
|
+
// Return the smart account address
|
|
121
|
+
return ((_b = smartAccountClient.account) === null || _b === void 0 ? void 0 : _b.address)
|
|
122
|
+
? [smartAccountClient.account.address]
|
|
123
|
+
: [];
|
|
124
|
+
case 'eth_chainId': {
|
|
125
|
+
// Return chainId from the smart account client
|
|
126
|
+
const chainId = yield smartAccountClient.getChainId();
|
|
127
|
+
return toHex(chainId);
|
|
128
|
+
}
|
|
129
|
+
default: {
|
|
130
|
+
// For other read-only methods, delegate to a basic public client transport.
|
|
131
|
+
// Avoid creating a new client/transport on every call if possible,
|
|
132
|
+
// but for simplicity here, we create it transiently.
|
|
133
|
+
// Consider caching this public client if performance becomes an issue.
|
|
134
|
+
const publicClient = createPublicClient({
|
|
135
|
+
chain: smartAccountClient.chain,
|
|
136
|
+
transport: http(undefined, this.providersConfig.httpTransportConfig), // Use configured transport if available
|
|
137
|
+
});
|
|
138
|
+
return publicClient.request({ method, params });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
// The internal confirmationTransport used by smartAccountClient via its 'owner'
|
|
143
|
+
// should handle the UI prompts. We don't need to add extra prompts here.
|
|
144
|
+
return handleRequest();
|
|
145
|
+
}),
|
|
146
|
+
});
|
|
93
147
|
}
|
|
94
148
|
getTransport(provider) {
|
|
95
149
|
const transport = confirmationTransport({
|
|
@@ -151,7 +205,7 @@ class ZKsyncConnector extends AccountAbstractionConnector {
|
|
|
151
205
|
session: this.sessionKeyAddress,
|
|
152
206
|
},
|
|
153
207
|
owner: ownerWithTransport,
|
|
154
|
-
transport:
|
|
208
|
+
transport: custom(ownerWithTransport),
|
|
155
209
|
});
|
|
156
210
|
return walletClient;
|
|
157
211
|
});
|
package/src/ZKsync/client.cjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
-
var viem = require('viem');
|
|
8
|
-
var zksync = require('viem/zksync');
|
|
9
|
-
var ecdsaAccount = require('./ecdsaAccount.cjs');
|
|
10
|
-
var walletActions = require('./walletActions.cjs');
|
|
11
|
-
var session = require('./session.cjs');
|
|
12
|
-
|
|
13
|
-
const createZksyncEcdsaClient = (_parameters) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
const parameters = Object.assign(Object.assign({}, _parameters), { address: viem.getAddress(_parameters.address), key: _parameters.key || 'zksync-sso-ecdsa-wallet', name: _parameters.name || 'ZKsync SSO ECDSA Client' });
|
|
15
|
-
const account = yield ecdsaAccount.toEcdsaAccount({
|
|
16
|
-
address: parameters.address,
|
|
17
|
-
owner: parameters.owner,
|
|
18
|
-
});
|
|
19
|
-
const client = viem.createClient(Object.assign(Object.assign({}, parameters), { account, type: 'walletClient' }))
|
|
20
|
-
.extend(() => ({
|
|
21
|
-
contracts: parameters.contracts,
|
|
22
|
-
}))
|
|
23
|
-
.extend(viem.publicActions)
|
|
24
|
-
.extend(viem.walletActions)
|
|
25
|
-
.extend(zksync.eip712WalletActions())
|
|
26
|
-
.extend(walletActions.zksyncSsoEcdsaWalletActions)
|
|
27
|
-
.extend(session.zksyncSsoEcdsaActions);
|
|
28
|
-
return client;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
exports.createZksyncEcdsaClient = createZksyncEcdsaClient;
|
package/src/ZKsync/client.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type Account, type Address, type Chain, type Client, type Prettify, type PublicActions, type PublicRpcSchema, type RpcSchema, type Transport, type WalletActions, type WalletClientConfig, type WalletRpcSchema } from 'viem';
|
|
2
|
-
import { CustomPaymasterHandler } from 'zksync-sso/paymaster';
|
|
3
|
-
import { Signer } from './types';
|
|
4
|
-
import { ZksyncSsoEcdsaActions } from './session';
|
|
5
|
-
export declare const createZksyncEcdsaClient: <transport extends Transport, chain extends Chain, rpcSchema extends RpcSchema | undefined = undefined>(_parameters: ZksyncSsoEcdsaClientConfig<transport, chain, rpcSchema>) => Promise<ZksyncSsoEcdsaClient<transport, chain, rpcSchema>>;
|
|
6
|
-
export type EcdsaRequiredContracts = {
|
|
7
|
-
session: Address;
|
|
8
|
-
accountFactory?: Address;
|
|
9
|
-
};
|
|
10
|
-
type ZksyncSsoEcdsaData = {
|
|
11
|
-
contracts: EcdsaRequiredContracts;
|
|
12
|
-
paymasterHandler?: CustomPaymasterHandler;
|
|
13
|
-
};
|
|
14
|
-
export type ClientWithZksyncSsoEcdsaData<transport extends Transport = Transport, chain extends Chain = Chain> = Client<transport, chain, Account> & ZksyncSsoEcdsaData;
|
|
15
|
-
export type ZksyncSsoEcdsaClient<transport extends Transport = Transport, chain extends Chain = Chain, rpcSchema extends RpcSchema | undefined = undefined, account extends Account = Account> = Prettify<Client<transport, chain, account, rpcSchema extends RpcSchema ? [...PublicRpcSchema, ...WalletRpcSchema, ...rpcSchema] : [...PublicRpcSchema, ...WalletRpcSchema], PublicActions<transport, chain, account> & WalletActions<chain, account> & ZksyncSsoEcdsaActions> & ZksyncSsoEcdsaData>;
|
|
16
|
-
export interface ZksyncSsoEcdsaClientConfig<transport extends Transport = Transport, chain extends Chain = Chain, rpcSchema extends RpcSchema | undefined = undefined> extends Omit<WalletClientConfig<transport, chain, Account, rpcSchema>, 'account'> {
|
|
17
|
-
chain: NonNullable<chain>;
|
|
18
|
-
address: Address;
|
|
19
|
-
owner: Signer;
|
|
20
|
-
contracts: EcdsaRequiredContracts;
|
|
21
|
-
key?: string;
|
|
22
|
-
name?: string;
|
|
23
|
-
paymasterHandler?: CustomPaymasterHandler;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
package/src/ZKsync/client.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
-
import { getAddress, createClient, publicActions, walletActions } from 'viem';
|
|
4
|
-
import { eip712WalletActions } from 'viem/zksync';
|
|
5
|
-
import { toEcdsaAccount } from './ecdsaAccount.js';
|
|
6
|
-
import { zksyncSsoEcdsaWalletActions } from './walletActions.js';
|
|
7
|
-
import { zksyncSsoEcdsaActions } from './session.js';
|
|
8
|
-
|
|
9
|
-
const createZksyncEcdsaClient = (_parameters) => __awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
-
const parameters = Object.assign(Object.assign({}, _parameters), { address: getAddress(_parameters.address), key: _parameters.key || 'zksync-sso-ecdsa-wallet', name: _parameters.name || 'ZKsync SSO ECDSA Client' });
|
|
11
|
-
const account = yield toEcdsaAccount({
|
|
12
|
-
address: parameters.address,
|
|
13
|
-
owner: parameters.owner,
|
|
14
|
-
});
|
|
15
|
-
const client = createClient(Object.assign(Object.assign({}, parameters), { account, type: 'walletClient' }))
|
|
16
|
-
.extend(() => ({
|
|
17
|
-
contracts: parameters.contracts,
|
|
18
|
-
}))
|
|
19
|
-
.extend(publicActions)
|
|
20
|
-
.extend(walletActions)
|
|
21
|
-
.extend(eip712WalletActions())
|
|
22
|
-
.extend(zksyncSsoEcdsaWalletActions)
|
|
23
|
-
.extend(zksyncSsoEcdsaActions);
|
|
24
|
-
return client;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export { createZksyncEcdsaClient };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
-
var accounts = require('viem/accounts');
|
|
8
|
-
var zksync = require('viem/zksync');
|
|
9
|
-
var types = require('./types.cjs');
|
|
10
|
-
var getEip712Domain = require('./getEip712Domain.cjs');
|
|
11
|
-
|
|
12
|
-
const toEcdsaAccount = (parameters) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
-
const { address, owner } = parameters;
|
|
14
|
-
const localOwner = yield types.toOwner({ address, owner });
|
|
15
|
-
if (!address) {
|
|
16
|
-
throw new Error('Address is required');
|
|
17
|
-
}
|
|
18
|
-
const account = accounts.toAccount({
|
|
19
|
-
address,
|
|
20
|
-
signMessage: (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ message }) { return localOwner.signMessage({ message }); }),
|
|
21
|
-
signTransaction: (transaction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
const signableTransaction = Object.assign(Object.assign({}, transaction), { from: address, type: 'eip712' });
|
|
23
|
-
const eip712DomainAndMessage = getEip712Domain.getEip712Domain(signableTransaction);
|
|
24
|
-
const signature = yield localOwner.signTypedData(eip712DomainAndMessage);
|
|
25
|
-
return zksync.serializeTransaction(Object.assign(Object.assign({}, signableTransaction), { customSignature: signature }));
|
|
26
|
-
}),
|
|
27
|
-
signTypedData: (typedData) => localOwner.signTypedData(typedData),
|
|
28
|
-
});
|
|
29
|
-
return Object.assign(Object.assign({}, account), { source: 'ssoEcdsaAccount' });
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
exports.toEcdsaAccount = toEcdsaAccount;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Address } from 'abitype';
|
|
2
|
-
import { type CustomSource, type LocalAccount } from 'viem';
|
|
3
|
-
import { type Signer } from './types';
|
|
4
|
-
export type ToEcdsaAccountParameters = {
|
|
5
|
-
/** Address of the deployed SSO Wallet */
|
|
6
|
-
address: Address;
|
|
7
|
-
/** Owner of the EOA */
|
|
8
|
-
owner: Signer;
|
|
9
|
-
};
|
|
10
|
-
export type EcdsaAccount = LocalAccount<'ssoEcdsaAccount'> & {
|
|
11
|
-
sign: NonNullable<CustomSource['sign']>;
|
|
12
|
-
};
|
|
13
|
-
export declare const toEcdsaAccount: (parameters: ToEcdsaAccountParameters) => Promise<EcdsaAccount>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
-
import { toAccount } from 'viem/accounts';
|
|
4
|
-
import { serializeTransaction } from 'viem/zksync';
|
|
5
|
-
import { toOwner } from './types.js';
|
|
6
|
-
import { getEip712Domain } from './getEip712Domain.js';
|
|
7
|
-
|
|
8
|
-
const toEcdsaAccount = (parameters) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
-
const { address, owner } = parameters;
|
|
10
|
-
const localOwner = yield toOwner({ address, owner });
|
|
11
|
-
if (!address) {
|
|
12
|
-
throw new Error('Address is required');
|
|
13
|
-
}
|
|
14
|
-
const account = toAccount({
|
|
15
|
-
address,
|
|
16
|
-
signMessage: (_a) => __awaiter(void 0, [_a], void 0, function* ({ message }) { return localOwner.signMessage({ message }); }),
|
|
17
|
-
signTransaction: (transaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const signableTransaction = Object.assign(Object.assign({}, transaction), { from: address, type: 'eip712' });
|
|
19
|
-
const eip712DomainAndMessage = getEip712Domain(signableTransaction);
|
|
20
|
-
const signature = yield localOwner.signTypedData(eip712DomainAndMessage);
|
|
21
|
-
return serializeTransaction(Object.assign(Object.assign({}, signableTransaction), { customSignature: signature }));
|
|
22
|
-
}),
|
|
23
|
-
signTypedData: (typedData) => localOwner.signTypedData(typedData),
|
|
24
|
-
});
|
|
25
|
-
return Object.assign(Object.assign({}, account), { source: 'ssoEcdsaAccount' });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export { toEcdsaAccount };
|