@dynamic-labs/ethereum-aa-zksync 4.20.2 → 4.20.3
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 +7 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/connector/ZKsyncConnector.cjs +9 -1
- package/src/connector/ZKsyncConnector.d.ts +6 -1
- package/src/connector/ZKsyncConnector.js +9 -1
- package/src/index.cjs +4 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -0
- package/src/utils/session.cjs +13 -0
- package/src/utils/session.d.ts +3015 -0
- package/src/utils/session.js +14 -2
package/src/utils/session.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { keccak256 } from 'viem';
|
|
2
|
+
import { http, keccak256 } from 'viem';
|
|
3
3
|
import { encodeSession } from 'zksync-sso/utils';
|
|
4
|
+
import { createZksyncSessionClient } from 'zksync-sso/client';
|
|
5
|
+
import { getChain } from '@dynamic-labs/ethereum-core';
|
|
4
6
|
|
|
5
7
|
const DEFAULT_EXPIRATION_TIME = 86400; // 1 day
|
|
6
8
|
const enforceSessionConfigRestrictions = (sessionConfig) => {
|
|
@@ -31,5 +33,15 @@ const stringifySessionConfig = (sessionConfig) => {
|
|
|
31
33
|
});
|
|
32
34
|
return Object.assign(Object.assign({}, sessionConfig), { callPolicies: sessionConfig.callPolicies.map((policy) => (Object.assign(Object.assign({}, policy), { constraints: policy.constraints.map((constraint) => (Object.assign(Object.assign({}, constraint), { index: constraint.index.toString(), limit: stringifyLimit(constraint.limit) }))), maxValuePerUse: policy.maxValuePerUse.toString(), valueLimit: stringifyLimit(policy.valueLimit) }))), expiresAt: sessionConfig.expiresAt.toString(), feeLimit: stringifyLimit(sessionConfig.feeLimit), transferPolicies: sessionConfig.transferPolicies.map((policy) => (Object.assign(Object.assign({}, policy), { maxValuePerUse: policy.maxValuePerUse.toString(), valueLimit: stringifyLimit(policy.valueLimit) }))) });
|
|
33
35
|
};
|
|
36
|
+
const createSessionClient = ({ smartAccountAddress, sessionKeyValidator, sessionConfig, sessionKey, chainId, }) => createZksyncSessionClient({
|
|
37
|
+
address: smartAccountAddress,
|
|
38
|
+
chain: getChain(chainId),
|
|
39
|
+
contracts: {
|
|
40
|
+
session: sessionKeyValidator,
|
|
41
|
+
},
|
|
42
|
+
sessionConfig,
|
|
43
|
+
sessionKey,
|
|
44
|
+
transport: http(),
|
|
45
|
+
});
|
|
34
46
|
|
|
35
|
-
export { enforceSessionConfigRestrictions, getSessionHash, parseSessionConfigJSON, stringifySessionConfig };
|
|
47
|
+
export { createSessionClient, enforceSessionConfigRestrictions, getSessionHash, parseSessionConfigJSON, stringifySessionConfig };
|