@dynamic-labs/ethereum-aa-zksync 4.20.0 → 4.20.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 +22 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/connector/ZKsyncConnector.cjs +13 -7
- package/src/connector/ZKsyncConnector.d.ts +2 -1
- package/src/connector/ZKsyncConnector.js +13 -7
- package/src/utils/module.cjs +7 -1
- package/src/utils/module.js +7 -1
- package/src/utils/session.cjs +1 -2
- package/src/utils/session.js +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.20.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.1...v4.20.2) (2025-06-11)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* auto-creation for only missing v3 wallets ([#8928](https://github.com/dynamic-labs/dynamic-auth/issues/8928)) ([845a01b](https://github.com/dynamic-labs/dynamic-auth/commit/845a01b1c7661d4858913006b2dd303ded19b462))
|
|
8
|
+
* don't logout when unlinking last wallet ([#8932](https://github.com/dynamic-labs/dynamic-auth/issues/8932)) ([ae91d68](https://github.com/dynamic-labs/dynamic-auth/commit/ae91d682ac69a267be3b1f9ae4cf2bb46cae8c6b))
|
|
9
|
+
* fetch nonce before attempting zksync account upgrade to avoid nonce collision ([#8924](https://github.com/dynamic-labs/dynamic-auth/issues/8924)) ([12aa982](https://github.com/dynamic-labs/dynamic-auth/commit/12aa98224c30ded0f7b83f3eabc6fa9a923b72cd))
|
|
10
|
+
* remove max session expiration restraint for zksync sessions ([#8922](https://github.com/dynamic-labs/dynamic-auth/issues/8922)) ([abb92e0](https://github.com/dynamic-labs/dynamic-auth/commit/abb92e009ff9c5485e4856a39d03c4035b7a6ee2))
|
|
11
|
+
|
|
12
|
+
### [4.20.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.0...v4.20.1) (2025-06-09)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **global-wallet:** new createKernelClient method to native api ([#8883](https://github.com/dynamic-labs/dynamic-auth/issues/8883)) ([005b34c](https://github.com/dynamic-labs/dynamic-auth/commit/005b34c230ceb5e945547e129231c108a6cec444))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* default embedded wallet chain enum ([#8917](https://github.com/dynamic-labs/dynamic-auth/issues/8917)) ([e9fd715](https://github.com/dynamic-labs/dynamic-auth/commit/e9fd715506598bfabbc71454421885d05a06a3ec))
|
|
23
|
+
|
|
2
24
|
## [4.20.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.7...v4.20.0) (2025-06-09)
|
|
3
25
|
|
|
4
26
|
|
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-zksync",
|
|
3
|
-
"version": "4.20.
|
|
3
|
+
"version": "4.20.2",
|
|
4
4
|
"description": "Core package for Ethereum Account Abstraction utilities and types",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@dynamic-labs/sdk-api-core": "0.0.681",
|
|
22
22
|
"zksync-sso": "0.2.0",
|
|
23
|
-
"@dynamic-labs/assert-package-version": "4.20.
|
|
24
|
-
"@dynamic-labs/ethereum-aa-core": "4.20.
|
|
25
|
-
"@dynamic-labs/ethereum-core": "4.20.
|
|
26
|
-
"@dynamic-labs/types": "4.20.
|
|
27
|
-
"@dynamic-labs/utils": "4.20.
|
|
28
|
-
"@dynamic-labs/wallet-book": "4.20.
|
|
29
|
-
"@dynamic-labs/wallet-connector-core": "4.20.
|
|
23
|
+
"@dynamic-labs/assert-package-version": "4.20.2",
|
|
24
|
+
"@dynamic-labs/ethereum-aa-core": "4.20.2",
|
|
25
|
+
"@dynamic-labs/ethereum-core": "4.20.2",
|
|
26
|
+
"@dynamic-labs/types": "4.20.2",
|
|
27
|
+
"@dynamic-labs/utils": "4.20.2",
|
|
28
|
+
"@dynamic-labs/wallet-book": "4.20.2",
|
|
29
|
+
"@dynamic-labs/wallet-connector-core": "4.20.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"viem": "^2.28.4"
|
|
@@ -103,11 +103,12 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
103
103
|
deleteSession(sessionId) {
|
|
104
104
|
return storage.deleteSessionFromStorage(sessionId);
|
|
105
105
|
}
|
|
106
|
-
getAccountAbstractionProvider({ sessionId } = {}) {
|
|
106
|
+
getAccountAbstractionProvider({ sessionId, origin, } = {}) {
|
|
107
|
+
var _a;
|
|
107
108
|
if (sessionId && this.sessionKeyAddress) {
|
|
108
109
|
const session = this.getSessionFromStorage(sessionId);
|
|
109
|
-
const
|
|
110
|
-
|
|
110
|
+
const originURI = (_a = utils.PlatformService.getTLD(origin)) !== null && _a !== void 0 ? _a : utils.PlatformService.getHostname();
|
|
111
|
+
const isSessionRequestValid = session && (!session.origin || originURI === session.origin);
|
|
111
112
|
if (isSessionRequestValid) {
|
|
112
113
|
return client.createZksyncSessionClient({
|
|
113
114
|
address: this.smartAccountAddress,
|
|
@@ -629,12 +630,19 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
629
630
|
};
|
|
630
631
|
}
|
|
631
632
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
632
|
-
|
|
633
|
+
try {
|
|
634
|
+
yield this.smartAccount.revokeSession(params);
|
|
635
|
+
}
|
|
636
|
+
catch (error) {
|
|
637
|
+
walletConnectorCore.logger.error('[ZKsyncConnector] Error revoking session: ', error);
|
|
638
|
+
throw new Error('Failed to revoke session');
|
|
639
|
+
}
|
|
633
640
|
this.deleteSession(sessionId);
|
|
634
641
|
});
|
|
635
642
|
}
|
|
636
643
|
createSession(_a) {
|
|
637
644
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ sessionConfig, origin, addModuleWithPaymaster = false, }) {
|
|
645
|
+
var _b;
|
|
638
646
|
if (!this.smartAccount) {
|
|
639
647
|
throw new Error('Smart account is not initialized');
|
|
640
648
|
}
|
|
@@ -649,9 +657,7 @@ class ZKsyncConnector extends ethereumAaCore.AccountAbstractionBaseConnector {
|
|
|
649
657
|
const params = {
|
|
650
658
|
sessionConfig: Object.assign(Object.assign({}, safeSessionConfig), { signer: signer.address }),
|
|
651
659
|
};
|
|
652
|
-
const originURI = origin
|
|
653
|
-
? new URL(origin).hostname
|
|
654
|
-
: utils.PlatformService.getHostname();
|
|
660
|
+
const originURI = (_b = utils.PlatformService.getTLD(origin)) !== null && _b !== void 0 ? _b : utils.PlatformService.getHostname();
|
|
655
661
|
if (this.paymasterAddress) {
|
|
656
662
|
params.paymaster = {
|
|
657
663
|
address: this.paymasterAddress,
|
|
@@ -68,8 +68,9 @@ export declare class ZKsyncConnector extends AccountAbstractionBaseConnector imp
|
|
|
68
68
|
private getSessionFromStorage;
|
|
69
69
|
private setSession;
|
|
70
70
|
private deleteSession;
|
|
71
|
-
getAccountAbstractionProvider<T = ZksyncSsoEcdsaClient<Transport, ViemChain, RpcSchema> | ZksyncSsoSessionClient<Transport, ViemChain, RpcSchema>>({ sessionId }?: {
|
|
71
|
+
getAccountAbstractionProvider<T = ZksyncSsoEcdsaClient<Transport, ViemChain, RpcSchema> | ZksyncSsoSessionClient<Transport, ViemChain, RpcSchema>>({ sessionId, origin, }?: {
|
|
72
72
|
sessionId?: string;
|
|
73
|
+
origin?: string;
|
|
73
74
|
withSponsorship?: boolean;
|
|
74
75
|
}): T;
|
|
75
76
|
getWalletClient(chainId?: string): WalletClient<Transport, ViemChain, Account> | undefined;
|
|
@@ -99,11 +99,12 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
|
|
|
99
99
|
deleteSession(sessionId) {
|
|
100
100
|
return deleteSessionFromStorage(sessionId);
|
|
101
101
|
}
|
|
102
|
-
getAccountAbstractionProvider({ sessionId } = {}) {
|
|
102
|
+
getAccountAbstractionProvider({ sessionId, origin, } = {}) {
|
|
103
|
+
var _a;
|
|
103
104
|
if (sessionId && this.sessionKeyAddress) {
|
|
104
105
|
const session = this.getSessionFromStorage(sessionId);
|
|
105
|
-
const
|
|
106
|
-
|
|
106
|
+
const originURI = (_a = PlatformService.getTLD(origin)) !== null && _a !== void 0 ? _a : PlatformService.getHostname();
|
|
107
|
+
const isSessionRequestValid = session && (!session.origin || originURI === session.origin);
|
|
107
108
|
if (isSessionRequestValid) {
|
|
108
109
|
return createZksyncSessionClient({
|
|
109
110
|
address: this.smartAccountAddress,
|
|
@@ -625,12 +626,19 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
|
|
|
625
626
|
};
|
|
626
627
|
}
|
|
627
628
|
this._walletUiUtils.disabledConfirmationOnce();
|
|
628
|
-
|
|
629
|
+
try {
|
|
630
|
+
yield this.smartAccount.revokeSession(params);
|
|
631
|
+
}
|
|
632
|
+
catch (error) {
|
|
633
|
+
logger.error('[ZKsyncConnector] Error revoking session: ', error);
|
|
634
|
+
throw new Error('Failed to revoke session');
|
|
635
|
+
}
|
|
629
636
|
this.deleteSession(sessionId);
|
|
630
637
|
});
|
|
631
638
|
}
|
|
632
639
|
createSession(_a) {
|
|
633
640
|
return __awaiter(this, arguments, void 0, function* ({ sessionConfig, origin, addModuleWithPaymaster = false, }) {
|
|
641
|
+
var _b;
|
|
634
642
|
if (!this.smartAccount) {
|
|
635
643
|
throw new Error('Smart account is not initialized');
|
|
636
644
|
}
|
|
@@ -645,9 +653,7 @@ class ZKsyncConnector extends AccountAbstractionBaseConnector {
|
|
|
645
653
|
const params = {
|
|
646
654
|
sessionConfig: Object.assign(Object.assign({}, safeSessionConfig), { signer: signer.address }),
|
|
647
655
|
};
|
|
648
|
-
const originURI = origin
|
|
649
|
-
? new URL(origin).hostname
|
|
650
|
-
: PlatformService.getHostname();
|
|
656
|
+
const originURI = (_b = PlatformService.getTLD(origin)) !== null && _b !== void 0 ? _b : PlatformService.getHostname();
|
|
651
657
|
if (this.paymasterAddress) {
|
|
652
658
|
params.paymaster = {
|
|
653
659
|
address: this.paymasterAddress,
|
package/src/utils/module.cjs
CHANGED
|
@@ -21,7 +21,7 @@ const isModuleInstalled = (_a) => _tslib.__awaiter(void 0, [_a], void 0, functio
|
|
|
21
21
|
return sessionValidatorInstalled;
|
|
22
22
|
});
|
|
23
23
|
const installModule = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ module, smartAddress, publicClient, ecdsaClient, paymaster, }) {
|
|
24
|
-
var _c;
|
|
24
|
+
var _c, _d;
|
|
25
25
|
const { address: moduleAddress, initData } = module;
|
|
26
26
|
if (!paymaster) {
|
|
27
27
|
const gasEstimate = yield publicClient.estimateContractGas({
|
|
@@ -40,12 +40,18 @@ const installModule = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* (
|
|
|
40
40
|
throw new Error(`Insufficient balance to upgrade smart account, balance: ${balance} required: ${requiredBalance}`);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
// In certain circumstances, the nonce is not updated before this call is made
|
|
44
|
+
const nonce = yield publicClient.getTransactionCount({
|
|
45
|
+
address: (_d = ecdsaClient.account) === null || _d === void 0 ? void 0 : _d.address,
|
|
46
|
+
blockTag: 'pending',
|
|
47
|
+
});
|
|
43
48
|
const simulatedSessionModuleAddition = yield publicClient.simulateContract({
|
|
44
49
|
abi: abi.SsoAccountAbi,
|
|
45
50
|
account: ecdsaClient.account,
|
|
46
51
|
address: smartAddress,
|
|
47
52
|
args: [moduleAddress, initData],
|
|
48
53
|
functionName: 'addModuleValidator',
|
|
54
|
+
nonce,
|
|
49
55
|
});
|
|
50
56
|
let request = Object.assign({}, simulatedSessionModuleAddition.request);
|
|
51
57
|
if (paymaster) {
|
package/src/utils/module.js
CHANGED
|
@@ -17,7 +17,7 @@ const isModuleInstalled = (_a) => __awaiter(void 0, [_a], void 0, function* ({ m
|
|
|
17
17
|
return sessionValidatorInstalled;
|
|
18
18
|
});
|
|
19
19
|
const installModule = (_b) => __awaiter(void 0, [_b], void 0, function* ({ module, smartAddress, publicClient, ecdsaClient, paymaster, }) {
|
|
20
|
-
var _c;
|
|
20
|
+
var _c, _d;
|
|
21
21
|
const { address: moduleAddress, initData } = module;
|
|
22
22
|
if (!paymaster) {
|
|
23
23
|
const gasEstimate = yield publicClient.estimateContractGas({
|
|
@@ -36,12 +36,18 @@ const installModule = (_b) => __awaiter(void 0, [_b], void 0, function* ({ modul
|
|
|
36
36
|
throw new Error(`Insufficient balance to upgrade smart account, balance: ${balance} required: ${requiredBalance}`);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
// In certain circumstances, the nonce is not updated before this call is made
|
|
40
|
+
const nonce = yield publicClient.getTransactionCount({
|
|
41
|
+
address: (_d = ecdsaClient.account) === null || _d === void 0 ? void 0 : _d.address,
|
|
42
|
+
blockTag: 'pending',
|
|
43
|
+
});
|
|
39
44
|
const simulatedSessionModuleAddition = yield publicClient.simulateContract({
|
|
40
45
|
abi: SsoAccountAbi,
|
|
41
46
|
account: ecdsaClient.account,
|
|
42
47
|
address: smartAddress,
|
|
43
48
|
args: [moduleAddress, initData],
|
|
44
49
|
functionName: 'addModuleValidator',
|
|
50
|
+
nonce,
|
|
45
51
|
});
|
|
46
52
|
let request = Object.assign({}, simulatedSessionModuleAddition.request);
|
|
47
53
|
if (paymaster) {
|
package/src/utils/session.cjs
CHANGED
|
@@ -10,8 +10,7 @@ const DEFAULT_EXPIRATION_TIME = 86400; // 1 day
|
|
|
10
10
|
const enforceSessionConfigRestrictions = (sessionConfig) => {
|
|
11
11
|
const now = Math.floor(Date.now() / 1000);
|
|
12
12
|
const maxExpirationTime = now + DEFAULT_EXPIRATION_TIME;
|
|
13
|
-
if (!sessionConfig.expiresAt
|
|
14
|
-
Number(sessionConfig.expiresAt) > maxExpirationTime) {
|
|
13
|
+
if (!sessionConfig.expiresAt) {
|
|
15
14
|
sessionConfig.expiresAt = BigInt(maxExpirationTime);
|
|
16
15
|
}
|
|
17
16
|
return sessionConfig;
|
package/src/utils/session.js
CHANGED
|
@@ -6,8 +6,7 @@ const DEFAULT_EXPIRATION_TIME = 86400; // 1 day
|
|
|
6
6
|
const enforceSessionConfigRestrictions = (sessionConfig) => {
|
|
7
7
|
const now = Math.floor(Date.now() / 1000);
|
|
8
8
|
const maxExpirationTime = now + DEFAULT_EXPIRATION_TIME;
|
|
9
|
-
if (!sessionConfig.expiresAt
|
|
10
|
-
Number(sessionConfig.expiresAt) > maxExpirationTime) {
|
|
9
|
+
if (!sessionConfig.expiresAt) {
|
|
11
10
|
sessionConfig.expiresAt = BigInt(maxExpirationTime);
|
|
12
11
|
}
|
|
13
12
|
return sessionConfig;
|