@rhinestone/sdk 0.12.2 → 0.12.4
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/dist/src/accounts/index.d.ts +5 -3
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +16 -15
- package/dist/src/accounts/kernel.d.ts +2 -1
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +7 -1
- package/dist/src/accounts/nexus.d.ts +2 -1
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +7 -1
- package/dist/src/accounts/safe.d.ts +2 -1
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +7 -1
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +15 -2
- package/dist/src/actions/index.d.ts +3 -1
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +5 -0
- package/dist/src/actions/registry.d.ts +7 -0
- package/dist/src/actions/registry.d.ts.map +1 -0
- package/dist/src/actions/registry.js +7 -0
- package/dist/src/actions/registry.test.d.ts +2 -0
- package/dist/src/actions/registry.test.d.ts.map +1 -0
- package/dist/src/actions/registry.test.js +25 -0
- package/dist/src/actions/smart-session.d.ts +5 -0
- package/dist/src/actions/smart-session.d.ts.map +1 -0
- package/dist/src/actions/smart-session.js +7 -0
- package/dist/src/execution/index.d.ts +2 -2
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +4 -1
- package/dist/src/execution/smart-session.d.ts +11 -1
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +264 -0
- package/dist/src/execution/smart-session.test.js +28 -0
- package/dist/src/execution/utils.d.ts +3 -3
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +78 -8
- package/dist/src/index.d.ts +11 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +25 -1
- package/dist/src/modules/index.d.ts +6 -1
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +15 -6
- package/dist/src/modules/read.d.ts +10 -0
- package/dist/src/modules/read.d.ts.map +1 -0
- package/dist/src/modules/read.js +152 -0
- package/dist/src/modules/validators/core.d.ts +2 -1
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +2 -1
- package/dist/src/modules/validators/smart-sessions.d.ts +49 -5
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +176 -4
- package/dist/src/orchestrator/registry.d.ts +1 -1
- package/dist/src/types.d.ts +11 -2
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -3,12 +3,276 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.enableSmartSession = enableSmartSession;
|
|
4
4
|
exports.hashErc7739 = hashErc7739;
|
|
5
5
|
exports.getSessionSignature = getSessionSignature;
|
|
6
|
+
exports.getSessionDetails = getSessionDetails;
|
|
7
|
+
exports.getMultichainDigest = getMultichainDigest;
|
|
6
8
|
const viem_1 = require("viem");
|
|
7
9
|
const accounts_1 = require("../accounts");
|
|
8
10
|
const utils_1 = require("../accounts/utils");
|
|
9
11
|
const modules_1 = require("../modules");
|
|
10
12
|
const validators_1 = require("../modules/validators");
|
|
13
|
+
const smart_sessions_1 = require("../modules/validators/smart-sessions");
|
|
11
14
|
const utils_2 = require("../orchestrator/utils");
|
|
15
|
+
async function getSessionDetails(config, sessions, sessionIndex, signature) {
|
|
16
|
+
const account = (0, accounts_1.getAccountProvider)(config);
|
|
17
|
+
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
18
|
+
const sessionDetails = await getEnableSessionDetails(account.type, sessions, sessionIndex, accountAddress);
|
|
19
|
+
const chain = sessions[sessionIndex].chain;
|
|
20
|
+
if (!chain) {
|
|
21
|
+
throw new Error('Session chain is required');
|
|
22
|
+
}
|
|
23
|
+
const validator = {
|
|
24
|
+
address: sessionDetails.enableSessionData.validator,
|
|
25
|
+
isRoot: true,
|
|
26
|
+
};
|
|
27
|
+
sessionDetails.enableSessionData.signature =
|
|
28
|
+
signature ??
|
|
29
|
+
(await (0, accounts_1.getPackedSignature)(config, config.owners, chain, validator, sessionDetails.permissionEnableHash));
|
|
30
|
+
return sessionDetails;
|
|
31
|
+
}
|
|
32
|
+
async function getEnableSessionDetails(accountType, sessions, sessionIndex, accountAddress) {
|
|
33
|
+
const chainDigests = [];
|
|
34
|
+
const chainSessions = [];
|
|
35
|
+
for (const session of sessions) {
|
|
36
|
+
const permissionId = (0, validators_1.getPermissionId)(session);
|
|
37
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
38
|
+
chain: session.chain,
|
|
39
|
+
transport: (0, viem_1.http)(),
|
|
40
|
+
});
|
|
41
|
+
const sessionChain = session.chain;
|
|
42
|
+
if (!sessionChain) {
|
|
43
|
+
throw new Error('Session chain is required');
|
|
44
|
+
}
|
|
45
|
+
const sessionNonce = await getSessionNonce(publicClient, accountAddress, permissionId);
|
|
46
|
+
const sessionData = await (0, smart_sessions_1.getSessionData)(sessionChain, session);
|
|
47
|
+
const sessionDigest = await getSessionDigest(publicClient, accountAddress, sessionData, permissionId, validators_1.SMART_SESSION_MODE_ENABLE);
|
|
48
|
+
chainDigests.push({
|
|
49
|
+
chainId: BigInt(sessionChain.id),
|
|
50
|
+
sessionDigest,
|
|
51
|
+
});
|
|
52
|
+
chainSessions.push({
|
|
53
|
+
chainId: BigInt(sessionChain.id),
|
|
54
|
+
session: {
|
|
55
|
+
permissions: {
|
|
56
|
+
permitGenericPolicy: false,
|
|
57
|
+
permitAdminAccess: false,
|
|
58
|
+
ignoreSecurityAttestations: false,
|
|
59
|
+
permitERC4337Paymaster: sessionData.permitERC4337Paymaster,
|
|
60
|
+
userOpPolicies: sessionData.userOpPolicies,
|
|
61
|
+
erc7739Policies: sessionData.erc7739Policies,
|
|
62
|
+
actions: sessionData.actions,
|
|
63
|
+
},
|
|
64
|
+
salt: sessionData.salt,
|
|
65
|
+
sessionValidator: sessionData.sessionValidator,
|
|
66
|
+
sessionValidatorInitData: sessionData.sessionValidatorInitData,
|
|
67
|
+
account: accountAddress,
|
|
68
|
+
smartSession: validators_1.SMART_SESSIONS_VALIDATOR_ADDRESS,
|
|
69
|
+
nonce: sessionNonce,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const permissionEnableHash = getMultichainDigest(chainDigests);
|
|
74
|
+
const sessionToEnable = sessions[sessionIndex || 0];
|
|
75
|
+
const sessionChain = sessionToEnable.chain;
|
|
76
|
+
if (!sessionChain) {
|
|
77
|
+
throw new Error('Session chain is required');
|
|
78
|
+
}
|
|
79
|
+
const sessionData = await (0, smart_sessions_1.getSessionData)(sessionChain, sessionToEnable);
|
|
80
|
+
return {
|
|
81
|
+
permissionEnableHash,
|
|
82
|
+
mode: validators_1.SMART_SESSION_MODE_ENABLE,
|
|
83
|
+
hashesAndChainIds: chainDigests,
|
|
84
|
+
enableSessionData: {
|
|
85
|
+
permissionId: (0, validators_1.getPermissionId)(sessionToEnable),
|
|
86
|
+
validator: sessionData.sessionValidator,
|
|
87
|
+
accountType,
|
|
88
|
+
chainDigestIndex: sessionIndex,
|
|
89
|
+
hashesAndChainIds: chainDigests,
|
|
90
|
+
sessionToEnable: sessionData,
|
|
91
|
+
signature: '0x',
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function getMultichainDigest(chainDigests) {
|
|
96
|
+
function hashChainDigestMimicRPC(chainDigest) {
|
|
97
|
+
const CHAIN_SESSION_TYPEHASH = '0x1ea7e4bc398fa0ccd68d92b5d8931a3fd93eebe1cf0391b4ba28935801af7c80';
|
|
98
|
+
return (0, viem_1.keccak256)((0, viem_1.encodePacked)(['bytes32', 'uint256', 'bytes32'], [
|
|
99
|
+
CHAIN_SESSION_TYPEHASH,
|
|
100
|
+
chainDigest.chainId,
|
|
101
|
+
chainDigest.sessionDigest,
|
|
102
|
+
]));
|
|
103
|
+
}
|
|
104
|
+
function hashChainDigestArray(chainDigests) {
|
|
105
|
+
const hashes = chainDigests.map((digest) => hashChainDigestMimicRPC(digest));
|
|
106
|
+
return (0, viem_1.keccak256)((0, viem_1.concat)(hashes));
|
|
107
|
+
}
|
|
108
|
+
const MULTICHAIN_SESSION_TYPEHASH = '0x0c9d02fb89a1da34d66ea2088dc9ee6a58efee71cef6f1bb849ed74fc6003d98';
|
|
109
|
+
const MULTICHAIN_DOMAIN_SEPARATOR = '0x057501e891776d1482927e5f094ae44049a4d893ba2d7b334dd7db8d38d3a0e1';
|
|
110
|
+
const structHash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['bytes32', 'bytes32'], [MULTICHAIN_SESSION_TYPEHASH, hashChainDigestArray(chainDigests)]));
|
|
111
|
+
return (0, viem_1.keccak256)((0, viem_1.concat)(['0x1901', MULTICHAIN_DOMAIN_SEPARATOR, structHash]));
|
|
112
|
+
}
|
|
113
|
+
async function getSessionNonce(client, account, permissionId) {
|
|
114
|
+
return (await client.readContract({
|
|
115
|
+
address: validators_1.SMART_SESSIONS_VALIDATOR_ADDRESS,
|
|
116
|
+
abi: [
|
|
117
|
+
{
|
|
118
|
+
type: 'function',
|
|
119
|
+
name: 'getNonce',
|
|
120
|
+
inputs: [
|
|
121
|
+
{
|
|
122
|
+
name: 'permissionId',
|
|
123
|
+
type: 'bytes32',
|
|
124
|
+
internalType: 'PermissionId',
|
|
125
|
+
},
|
|
126
|
+
{ name: 'account', type: 'address', internalType: 'address' },
|
|
127
|
+
],
|
|
128
|
+
outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],
|
|
129
|
+
stateMutability: 'view',
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
functionName: 'getNonce',
|
|
133
|
+
args: [permissionId, account],
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
async function getSessionDigest(client, account, session, permissionId, mode) {
|
|
137
|
+
return (await client.readContract({
|
|
138
|
+
address: validators_1.SMART_SESSIONS_VALIDATOR_ADDRESS,
|
|
139
|
+
abi: [
|
|
140
|
+
{
|
|
141
|
+
type: 'function',
|
|
142
|
+
name: 'getSessionDigest',
|
|
143
|
+
inputs: [
|
|
144
|
+
{
|
|
145
|
+
name: 'permissionId',
|
|
146
|
+
type: 'bytes32',
|
|
147
|
+
internalType: 'PermissionId',
|
|
148
|
+
},
|
|
149
|
+
{ name: 'account', type: 'address', internalType: 'address' },
|
|
150
|
+
{
|
|
151
|
+
name: 'data',
|
|
152
|
+
type: 'tuple',
|
|
153
|
+
internalType: 'struct Session',
|
|
154
|
+
components: [
|
|
155
|
+
{
|
|
156
|
+
name: 'sessionValidator',
|
|
157
|
+
type: 'address',
|
|
158
|
+
internalType: 'contract ISessionValidator',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'sessionValidatorInitData',
|
|
162
|
+
type: 'bytes',
|
|
163
|
+
internalType: 'bytes',
|
|
164
|
+
},
|
|
165
|
+
{ name: 'salt', type: 'bytes32', internalType: 'bytes32' },
|
|
166
|
+
{
|
|
167
|
+
name: 'userOpPolicies',
|
|
168
|
+
type: 'tuple[]',
|
|
169
|
+
internalType: 'struct PolicyData[]',
|
|
170
|
+
components: [
|
|
171
|
+
{
|
|
172
|
+
name: 'policy',
|
|
173
|
+
type: 'address',
|
|
174
|
+
internalType: 'address',
|
|
175
|
+
},
|
|
176
|
+
{ name: 'initData', type: 'bytes', internalType: 'bytes' },
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: 'erc7739Policies',
|
|
181
|
+
type: 'tuple',
|
|
182
|
+
internalType: 'struct ERC7739Data',
|
|
183
|
+
components: [
|
|
184
|
+
{
|
|
185
|
+
name: 'allowedERC7739Content',
|
|
186
|
+
type: 'tuple[]',
|
|
187
|
+
internalType: 'struct ERC7739Context[]',
|
|
188
|
+
components: [
|
|
189
|
+
{
|
|
190
|
+
name: 'appDomainSeparator',
|
|
191
|
+
type: 'bytes32',
|
|
192
|
+
internalType: 'bytes32',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: 'contentName',
|
|
196
|
+
type: 'string[]',
|
|
197
|
+
internalType: 'string[]',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: 'erc1271Policies',
|
|
203
|
+
type: 'tuple[]',
|
|
204
|
+
internalType: 'struct PolicyData[]',
|
|
205
|
+
components: [
|
|
206
|
+
{
|
|
207
|
+
name: 'policy',
|
|
208
|
+
type: 'address',
|
|
209
|
+
internalType: 'address',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: 'initData',
|
|
213
|
+
type: 'bytes',
|
|
214
|
+
internalType: 'bytes',
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: 'actions',
|
|
222
|
+
type: 'tuple[]',
|
|
223
|
+
internalType: 'struct ActionData[]',
|
|
224
|
+
components: [
|
|
225
|
+
{
|
|
226
|
+
name: 'actionTargetSelector',
|
|
227
|
+
type: 'bytes4',
|
|
228
|
+
internalType: 'bytes4',
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: 'actionTarget',
|
|
232
|
+
type: 'address',
|
|
233
|
+
internalType: 'address',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: 'actionPolicies',
|
|
237
|
+
type: 'tuple[]',
|
|
238
|
+
internalType: 'struct PolicyData[]',
|
|
239
|
+
components: [
|
|
240
|
+
{
|
|
241
|
+
name: 'policy',
|
|
242
|
+
type: 'address',
|
|
243
|
+
internalType: 'address',
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: 'initData',
|
|
247
|
+
type: 'bytes',
|
|
248
|
+
internalType: 'bytes',
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: 'permitERC4337Paymaster',
|
|
256
|
+
type: 'bool',
|
|
257
|
+
internalType: 'bool',
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: 'mode',
|
|
263
|
+
type: 'uint8',
|
|
264
|
+
internalType: 'enum SmartSessionMode',
|
|
265
|
+
},
|
|
266
|
+
],
|
|
267
|
+
outputs: [{ name: '', type: 'bytes32', internalType: 'bytes32' }],
|
|
268
|
+
stateMutability: 'view',
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
functionName: 'getSessionDigest',
|
|
272
|
+
// @ts-ignore Viem fails to infer the type of "session"
|
|
273
|
+
args: [permissionId, account, session, Number(mode)],
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
12
276
|
async function enableSmartSession(chain, config, session) {
|
|
13
277
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
14
278
|
chain,
|
|
@@ -133,4 +133,32 @@ const hash = (0, viem_1.keccak256)('0xabcd');
|
|
|
133
133
|
(0, vitest_1.expect)(structHash).toEqual('0x6622d2a44c958ffed7b7b3746f4fc9c2e39543858f6f176cc58ccf7741c65b4a');
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
|
+
(0, vitest_1.describe)('Multichain Digest', () => {
|
|
137
|
+
(0, vitest_1.test)('Single', () => {
|
|
138
|
+
const digest = (0, smart_session_1.getMultichainDigest)([
|
|
139
|
+
{
|
|
140
|
+
chainId: 421614n,
|
|
141
|
+
sessionDigest: '0x971daa09e9deb42457fb008fce5a63987379b31fd67ec6c16ff8b52517bfb373',
|
|
142
|
+
},
|
|
143
|
+
]);
|
|
144
|
+
(0, vitest_1.expect)(digest).toEqual('0xc0f5a263b2af5a01bc221835faf49b77459a5696f881c25fea9f8144c43f2326');
|
|
145
|
+
});
|
|
146
|
+
(0, vitest_1.test)('Multiple', () => {
|
|
147
|
+
const digest = (0, smart_session_1.getMultichainDigest)([
|
|
148
|
+
{
|
|
149
|
+
chainId: 84532n,
|
|
150
|
+
sessionDigest: '0xad3139c2b3ca57ba02e86ba3ad86dd18a05ba53650e3088ebd4fed71166d4bdd',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
chainId: 84532n,
|
|
154
|
+
sessionDigest: '0x1e6cc59dee4aca4a0d9b1fccd6fde197c831d5bd51163746f1947b352732f3db',
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
chainId: 11155420n,
|
|
158
|
+
sessionDigest: '0x9b14ad37022e97faf4d9824c8d7e85b97f304839d24a3cd582575753df7d9239',
|
|
159
|
+
},
|
|
160
|
+
]);
|
|
161
|
+
(0, vitest_1.expect)(digest).toEqual('0x02f738c7e916839b958b21cbf8bf3697ca06fcb7d5fd5eba85ad49c8f2756adb');
|
|
162
|
+
});
|
|
163
|
+
});
|
|
136
164
|
});
|
|
@@ -15,7 +15,7 @@ type TransactionResult = {
|
|
|
15
15
|
};
|
|
16
16
|
interface BundleData {
|
|
17
17
|
hash: Hex;
|
|
18
|
-
orderPath
|
|
18
|
+
orderPath?: OrderPath;
|
|
19
19
|
userOp?: UserOperation;
|
|
20
20
|
}
|
|
21
21
|
interface PreparedTransactionData {
|
|
@@ -30,8 +30,8 @@ declare function signTransaction(config: RhinestoneAccountConfig, preparedTransa
|
|
|
30
30
|
declare function submitTransaction(config: RhinestoneAccountConfig, signedTransaction: SignedTransactionData): Promise<TransactionResult>;
|
|
31
31
|
declare function prepareTransactionAsIntent(config: RhinestoneAccountConfig, sourceChain: Chain | undefined, targetChain: Chain, calls: Call[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], accountAddress: Address): Promise<BundleData>;
|
|
32
32
|
declare function signIntent(config: RhinestoneAccountConfig, sourceChain: Chain | undefined, targetChain: Chain, bundleHash: Hex, signers?: SignerSet): Promise<`0x${string}`>;
|
|
33
|
-
declare function signUserOp(config: RhinestoneAccountConfig, sourceChain: Chain, targetChain: Chain, accountAddress: Address, signers: SignerSet | undefined, userOp: UserOperation, orderPath
|
|
34
|
-
declare function submitUserOp(config: RhinestoneAccountConfig, sourceChain: Chain, targetChain: Chain, userOp: UserOperation,
|
|
33
|
+
declare function signUserOp(config: RhinestoneAccountConfig, sourceChain: Chain, targetChain: Chain, accountAddress: Address, signers: SignerSet | undefined, userOp: UserOperation, orderPath?: OrderPath): Promise<`0x${string}`>;
|
|
34
|
+
declare function submitUserOp(config: RhinestoneAccountConfig, sourceChain: Chain, targetChain: Chain, userOp: UserOperation, signature: Hex, orderPath?: OrderPath): Promise<TransactionResult>;
|
|
35
35
|
declare function getOrchestratorByChain(chainId: number, apiKey: string): import("../orchestrator").Orchestrator;
|
|
36
36
|
declare function getUserOpOrderPath(sourceChain: Chain, targetChain: Chain, tokenRequests: TokenRequest[], accountAddress: Address, gasLimit: bigint | undefined, rhinestoneApiKey: string): Promise<OrderPath>;
|
|
37
37
|
declare function getUserOp(config: RhinestoneAccountConfig, targetChain: Chain, signers: SignerSet | undefined, orderPath: OrderPath, calls: Call[], tokenRequests: TokenRequest[], accountAddress: Address): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,EAGL,GAAG,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,EAGL,GAAG,EAOJ,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,aAAa,EACd,MAAM,0BAA0B,CAAA;AA6BjC,OAAO,EAEL,SAAS,EAGV,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,IAAI,EAEJ,uBAAuB,EACvB,SAAS,EACT,YAAY,EACZ,WAAW,EACZ,MAAM,UAAU,CAAA;AAGjB,KAAK,iBAAiB,GAClB;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M,EAAE,uBAAuB,EAC/B,OAAO,EAAE,SAAS,GAAG,SAAS,EAC9B,YAAY,EAAE,GAAG,EACjB,KAAK,EAAE,KAAK,yKAuBb;AA0FD,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,GACpB,CAAA;AACD,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACtB,CAAA"}
|
|
@@ -26,7 +26,8 @@ async function prepareTransaction(config, transaction) {
|
|
|
26
26
|
const { sourceChain, targetChain, tokenRequests, signers } = getTransactionParams(transaction);
|
|
27
27
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
28
28
|
let bundleData;
|
|
29
|
-
|
|
29
|
+
const asUserOp = signers?.type === 'guardians' || signers?.type === 'session';
|
|
30
|
+
if (asUserOp) {
|
|
30
31
|
if (!sourceChain) {
|
|
31
32
|
throw new Error(`Specifying source chain is required when using smart sessions or guardians`);
|
|
32
33
|
}
|
|
@@ -80,10 +81,14 @@ async function submitTransaction(config, signedTransaction) {
|
|
|
80
81
|
throw new Error(`User operation is required when using smart sessions`);
|
|
81
82
|
}
|
|
82
83
|
// Smart sessions require a UserOp flow
|
|
83
|
-
return await submitUserOp(config, sourceChain, targetChain, userOp, bundleData.orderPath
|
|
84
|
+
return await submitUserOp(config, sourceChain, targetChain, userOp, signature, bundleData.orderPath);
|
|
84
85
|
}
|
|
85
86
|
else {
|
|
86
|
-
|
|
87
|
+
const orderPath = bundleData.orderPath;
|
|
88
|
+
if (!orderPath) {
|
|
89
|
+
throw new Error('Order path is required when using intents');
|
|
90
|
+
}
|
|
91
|
+
return await submitIntent(config, sourceChain, targetChain, orderPath, signature);
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
94
|
function getTransactionParams(transaction) {
|
|
@@ -109,7 +114,29 @@ function getTransactionParams(transaction) {
|
|
|
109
114
|
}
|
|
110
115
|
async function prepareTransactionAsUserOp(config, sourceChain, targetChain, calls, gasLimit, tokenRequests, accountAddress, signers) {
|
|
111
116
|
if (sourceChain.id === targetChain.id) {
|
|
112
|
-
|
|
117
|
+
const chain = sourceChain;
|
|
118
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
119
|
+
chain,
|
|
120
|
+
transport: (0, viem_1.http)(),
|
|
121
|
+
});
|
|
122
|
+
const validatorAccount = await getValidatorAccount(config, signers, publicClient, chain);
|
|
123
|
+
if (!validatorAccount) {
|
|
124
|
+
throw new Error('No validator account found');
|
|
125
|
+
}
|
|
126
|
+
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
127
|
+
const userOp = await bundlerClient.prepareUserOperation({
|
|
128
|
+
account: validatorAccount,
|
|
129
|
+
calls,
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
userOp,
|
|
133
|
+
hash: (0, account_abstraction_1.getUserOperationHash)({
|
|
134
|
+
userOperation: userOp,
|
|
135
|
+
chainId: chain.id,
|
|
136
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
137
|
+
entryPointVersion: '0.7',
|
|
138
|
+
}),
|
|
139
|
+
};
|
|
113
140
|
}
|
|
114
141
|
const orderPath = await getUserOpOrderPath(sourceChain, targetChain, tokenRequests, accountAddress, gasLimit, config.rhinestoneApiKey);
|
|
115
142
|
const userOp = await getUserOp(config, targetChain, signers, orderPath, calls, tokenRequests, accountAddress);
|
|
@@ -189,6 +216,9 @@ async function signUserOp(config, sourceChain, targetChain, accountAddress, sign
|
|
|
189
216
|
throw new Error('No account found');
|
|
190
217
|
}
|
|
191
218
|
userOp.signature = await targetAccount.signUserOperation(userOp);
|
|
219
|
+
if (!orderPath) {
|
|
220
|
+
return userOp.signature;
|
|
221
|
+
}
|
|
192
222
|
const userOpHash = (0, account_abstraction_1.getUserOperationHash)({
|
|
193
223
|
userOperation: userOp,
|
|
194
224
|
chainId: targetChain.id,
|
|
@@ -212,7 +242,47 @@ async function signUserOp(config, sourceChain, targetChain, accountAddress, sign
|
|
|
212
242
|
});
|
|
213
243
|
return signature;
|
|
214
244
|
}
|
|
215
|
-
async function submitUserOp(config, sourceChain, targetChain, userOp,
|
|
245
|
+
async function submitUserOp(config, sourceChain, targetChain, userOp, signature, orderPath) {
|
|
246
|
+
if (!orderPath) {
|
|
247
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
248
|
+
chain: sourceChain,
|
|
249
|
+
transport: (0, viem_1.http)(),
|
|
250
|
+
});
|
|
251
|
+
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
252
|
+
const hash = await bundlerClient.request({
|
|
253
|
+
method: 'eth_sendUserOperation',
|
|
254
|
+
params: [
|
|
255
|
+
{
|
|
256
|
+
sender: userOp.sender,
|
|
257
|
+
nonce: (0, viem_1.toHex)(userOp.nonce),
|
|
258
|
+
factory: userOp.factory,
|
|
259
|
+
factoryData: userOp.factoryData,
|
|
260
|
+
callData: userOp.callData,
|
|
261
|
+
callGasLimit: (0, viem_1.toHex)(userOp.callGasLimit),
|
|
262
|
+
verificationGasLimit: (0, viem_1.toHex)(userOp.verificationGasLimit),
|
|
263
|
+
preVerificationGas: (0, viem_1.toHex)(userOp.preVerificationGas),
|
|
264
|
+
maxPriorityFeePerGas: (0, viem_1.toHex)(userOp.maxPriorityFeePerGas),
|
|
265
|
+
maxFeePerGas: (0, viem_1.toHex)(userOp.maxFeePerGas),
|
|
266
|
+
paymaster: userOp.paymaster,
|
|
267
|
+
paymasterVerificationGasLimit: userOp.paymasterVerificationGasLimit
|
|
268
|
+
? (0, viem_1.toHex)(userOp.paymasterVerificationGasLimit)
|
|
269
|
+
: undefined,
|
|
270
|
+
paymasterPostOpGasLimit: userOp.paymasterPostOpGasLimit
|
|
271
|
+
? (0, viem_1.toHex)(userOp.paymasterPostOpGasLimit)
|
|
272
|
+
: undefined,
|
|
273
|
+
paymasterData: userOp.paymasterData,
|
|
274
|
+
signature,
|
|
275
|
+
},
|
|
276
|
+
account_abstraction_1.entryPoint07Address,
|
|
277
|
+
],
|
|
278
|
+
});
|
|
279
|
+
return {
|
|
280
|
+
type: 'userop',
|
|
281
|
+
hash,
|
|
282
|
+
sourceChain: sourceChain.id,
|
|
283
|
+
targetChain: targetChain.id,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
216
286
|
const signedOrderBundle = {
|
|
217
287
|
...orderPath[0].orderBundle,
|
|
218
288
|
originSignatures: Array(orderPath[0].orderBundle.segments.length).fill(signature),
|
|
@@ -280,7 +350,7 @@ async function getUserOp(config, targetChain, signers, orderPath, calls, tokenRe
|
|
|
280
350
|
const rootBalanceSlot = (0, registry_1.getTokenRootBalanceSlot)(targetChain, request.address);
|
|
281
351
|
const balanceSlot = rootBalanceSlot
|
|
282
352
|
? (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'uint256' }], [accountAddress, rootBalanceSlot]))
|
|
283
|
-
:
|
|
353
|
+
: viem_1.zeroHash;
|
|
284
354
|
return {
|
|
285
355
|
address: request.address,
|
|
286
356
|
stateDiff: [
|
|
@@ -322,10 +392,10 @@ async function getValidatorAccount(config, signers, publicClient, chain) {
|
|
|
322
392
|
if (!signers) {
|
|
323
393
|
return undefined;
|
|
324
394
|
}
|
|
325
|
-
const withSession = signers.type === 'session' ? signers
|
|
395
|
+
const withSession = signers.type === 'session' ? signers : null;
|
|
326
396
|
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
327
397
|
return withSession
|
|
328
|
-
? await (0, accounts_1.getSmartSessionSmartAccount)(config, publicClient, chain, withSession)
|
|
398
|
+
? await (0, accounts_1.getSmartSessionSmartAccount)(config, publicClient, chain, withSession.session, withSession.enableData || null)
|
|
329
399
|
: withGuardians
|
|
330
400
|
? await (0, accounts_1.getGuardianSmartAccount)(config, publicClient, chain, {
|
|
331
401
|
type: 'ecdsa',
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Address, Chain } from 'viem';
|
|
1
|
+
import type { Address, Chain, Hex } from 'viem';
|
|
2
2
|
import { UserOperationReceipt } from 'viem/account-abstraction';
|
|
3
|
-
import { addOwner, changeThreshold, disableEcdsa, disablePasskeys, enableEcdsa, enablePasskeys, recover, removeOwner, setUpRecovery } from './actions';
|
|
3
|
+
import { addOwner, changeThreshold, disableEcdsa, disablePasskeys, enableEcdsa, enablePasskeys, encodeSmartSessionSignature, recover, removeOwner, setUpRecovery, trustAttester } from './actions';
|
|
4
4
|
import type { TransactionResult } from './execution';
|
|
5
|
+
import { SessionDetails } from './execution/smart-session';
|
|
5
6
|
import { BundleData, PreparedTransactionData, SignedTransactionData } from './execution/utils';
|
|
6
7
|
import type { BundleResult, BundleStatus, MetaIntent, MultiChainCompact, PostOrderBundleResult, SignedMultiChainCompact, UserTokenBalance } from './orchestrator';
|
|
7
8
|
import type { Call, Execution, RhinestoneAccountConfig, Session, Transaction } from './types';
|
|
@@ -16,6 +17,13 @@ interface RhinestoneAccount {
|
|
|
16
17
|
getAddress: () => Address;
|
|
17
18
|
getPortfolio: (onTestnets?: boolean) => Promise<UserTokenBalance[]>;
|
|
18
19
|
getMaxSpendableAmount: (chain: Chain, tokenAddress: Address, gasUnits: bigint) => Promise<bigint>;
|
|
20
|
+
getSessionDetails: (sessions: Session[], sessionIndex: number, signature?: Hex) => Promise<SessionDetails>;
|
|
21
|
+
areAttestersTrusted: (chain: Chain) => Promise<boolean>;
|
|
22
|
+
getOwners: (chain: Chain) => Promise<{
|
|
23
|
+
accounts: Address[];
|
|
24
|
+
threshold: number;
|
|
25
|
+
} | null>;
|
|
26
|
+
getValidators: (chain: Chain) => Promise<Address[]>;
|
|
19
27
|
}
|
|
20
28
|
/**
|
|
21
29
|
* Initialize a Rhinestone account
|
|
@@ -24,6 +32,6 @@ interface RhinestoneAccount {
|
|
|
24
32
|
* @returns account
|
|
25
33
|
*/
|
|
26
34
|
declare function createRhinestoneAccount(config: RhinestoneAccountConfig): Promise<RhinestoneAccount>;
|
|
27
|
-
export { createRhinestoneAccount, addOwner, changeThreshold, disableEcdsa, disablePasskeys, enableEcdsa, enablePasskeys, recover, removeOwner, setUpRecovery, };
|
|
35
|
+
export { createRhinestoneAccount, addOwner, changeThreshold, disableEcdsa, disablePasskeys, enableEcdsa, enablePasskeys, recover, removeOwner, setUpRecovery, encodeSmartSessionSignature, trustAttester, };
|
|
28
36
|
export type { RhinestoneAccount, BundleStatus, Session, Call, Execution, MetaIntent, MultiChainCompact, PostOrderBundleResult, SignedMultiChainCompact, BundleData, PreparedTransactionData, SignedTransactionData, TransactionResult, };
|
|
29
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAK/D,OAAO,EACL,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,eAAe,EACf,WAAW,EACX,cAAc,EACd,2BAA2B,EAC3B,OAAO,EACP,WAAW,EACX,aAAa,EACb,aAAa,EACd,MAAM,WAAW,CAAA;AAClB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAOpD,OAAO,EAEL,cAAc,EACf,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,UAAU,EACV,uBAAuB,EAEvB,qBAAqB,EAGtB,MAAM,mBAAmB,CAAA;AAM1B,OAAO,KAAK,EACV,YAAY,EAC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CAAA;IAC5B,mBAAmB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IACvD,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;QACnC,QAAQ,EAAE,OAAO,EAAE,CAAA;QACnB,SAAS,EAAE,MAAM,CAAA;KAClB,GAAG,IAAI,CAAC,CAAA;IACT,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;CACpD;AAED;;;;;GAKG;AACH,iBAAe,uBAAuB,CACpC,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,iBAAiB,CAAC,CA+G5B;AAED,OAAO,EACL,uBAAuB,EACvB,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,eAAe,EACf,WAAW,EACX,cAAc,EACd,OAAO,EACP,WAAW,EACX,aAAa,EACb,2BAA2B,EAC3B,aAAa,GACd,CAAA;AACD,YAAY,EACV,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,IAAI,EACJ,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,EACV,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,GAClB,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setUpRecovery = exports.removeOwner = exports.recover = exports.enablePasskeys = exports.enableEcdsa = exports.disablePasskeys = exports.disableEcdsa = exports.changeThreshold = exports.addOwner = void 0;
|
|
3
|
+
exports.trustAttester = exports.encodeSmartSessionSignature = exports.setUpRecovery = exports.removeOwner = exports.recover = exports.enablePasskeys = exports.enableEcdsa = exports.disablePasskeys = exports.disableEcdsa = exports.changeThreshold = exports.addOwner = void 0;
|
|
4
4
|
exports.createRhinestoneAccount = createRhinestoneAccount;
|
|
5
5
|
const accounts_1 = require("./accounts");
|
|
6
6
|
const actions_1 = require("./actions");
|
|
@@ -10,11 +10,15 @@ Object.defineProperty(exports, "disableEcdsa", { enumerable: true, get: function
|
|
|
10
10
|
Object.defineProperty(exports, "disablePasskeys", { enumerable: true, get: function () { return actions_1.disablePasskeys; } });
|
|
11
11
|
Object.defineProperty(exports, "enableEcdsa", { enumerable: true, get: function () { return actions_1.enableEcdsa; } });
|
|
12
12
|
Object.defineProperty(exports, "enablePasskeys", { enumerable: true, get: function () { return actions_1.enablePasskeys; } });
|
|
13
|
+
Object.defineProperty(exports, "encodeSmartSessionSignature", { enumerable: true, get: function () { return actions_1.encodeSmartSessionSignature; } });
|
|
13
14
|
Object.defineProperty(exports, "recover", { enumerable: true, get: function () { return actions_1.recover; } });
|
|
14
15
|
Object.defineProperty(exports, "removeOwner", { enumerable: true, get: function () { return actions_1.removeOwner; } });
|
|
15
16
|
Object.defineProperty(exports, "setUpRecovery", { enumerable: true, get: function () { return actions_1.setUpRecovery; } });
|
|
17
|
+
Object.defineProperty(exports, "trustAttester", { enumerable: true, get: function () { return actions_1.trustAttester; } });
|
|
16
18
|
const execution_1 = require("./execution");
|
|
19
|
+
const smart_session_1 = require("./execution/smart-session");
|
|
17
20
|
const utils_1 = require("./execution/utils");
|
|
21
|
+
const modules_1 = require("./modules");
|
|
18
22
|
/**
|
|
19
23
|
* Initialize a Rhinestone account
|
|
20
24
|
* Note: accounts are deployed onchain only when the first transaction is sent.
|
|
@@ -76,6 +80,22 @@ async function createRhinestoneAccount(config) {
|
|
|
76
80
|
function getMaxSpendableAmount(chain, tokenAddress, gasUnits) {
|
|
77
81
|
return (0, execution_1.getMaxSpendableAmount)(config, chain, tokenAddress, gasUnits);
|
|
78
82
|
}
|
|
83
|
+
function getSessionDetails(sessions, sessionIndex, signature) {
|
|
84
|
+
return (0, smart_session_1.getSessionDetails)(config, sessions, sessionIndex, signature);
|
|
85
|
+
}
|
|
86
|
+
function areAttestersTrusted(chain) {
|
|
87
|
+
const account = getAddress();
|
|
88
|
+
return (0, modules_1.areAttestersTrusted)(account, chain);
|
|
89
|
+
}
|
|
90
|
+
function getOwners(chain) {
|
|
91
|
+
const account = getAddress();
|
|
92
|
+
return (0, modules_1.getOwners)(account, chain);
|
|
93
|
+
}
|
|
94
|
+
function getValidators(chain) {
|
|
95
|
+
const accountType = config.account?.type || 'nexus';
|
|
96
|
+
const account = getAddress();
|
|
97
|
+
return (0, modules_1.getValidators)(accountType, account, chain);
|
|
98
|
+
}
|
|
79
99
|
return {
|
|
80
100
|
config,
|
|
81
101
|
deploy,
|
|
@@ -87,5 +107,9 @@ async function createRhinestoneAccount(config) {
|
|
|
87
107
|
getAddress,
|
|
88
108
|
getPortfolio,
|
|
89
109
|
getMaxSpendableAmount,
|
|
110
|
+
getSessionDetails,
|
|
111
|
+
areAttestersTrusted,
|
|
112
|
+
getOwners,
|
|
113
|
+
getValidators,
|
|
90
114
|
};
|
|
91
115
|
}
|
|
@@ -2,6 +2,7 @@ import { type Address, type Chain, type Hex } from 'viem';
|
|
|
2
2
|
import type { RhinestoneAccountConfig } from '../types';
|
|
3
3
|
import { type Module } from './common';
|
|
4
4
|
import { HOOK_ADDRESS } from './omni-account';
|
|
5
|
+
import { areAttestersTrusted, getOwners, getValidators } from './read';
|
|
5
6
|
import { getTrustAttesterCall, getTrustedAttesters } from './registry';
|
|
6
7
|
import { getOwnerValidator } from './validators';
|
|
7
8
|
interface WebAuthnData {
|
|
@@ -30,5 +31,9 @@ interface ModeleSetup {
|
|
|
30
31
|
declare function getSetup(config: RhinestoneAccountConfig): ModeleSetup;
|
|
31
32
|
declare function getWebauthnValidatorSignature({ webauthn, signature, usePrecompiled, }: WebauthnValidatorSignature): `0x${string}`;
|
|
32
33
|
declare function isRip7212SupportedNetwork(chain: Chain): boolean;
|
|
33
|
-
|
|
34
|
+
declare function getAttesters(): {
|
|
35
|
+
list: Address[];
|
|
36
|
+
threshold: number;
|
|
37
|
+
};
|
|
38
|
+
export { HOOK_ADDRESS, getSetup, getTrustAttesterCall, getTrustedAttesters, getOwnerValidator, getWebauthnValidatorSignature, getAttesters, areAttestersTrusted, getOwners, getValidators, isRip7212SupportedNetwork, };
|
|
34
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,KAAK,EAEV,KAAK,GAAG,EAET,MAAM,MAAM,CAAA;AAYb,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAEvD,OAAO,EAGL,KAAK,MAAM,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,YAAY,EAMb,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAA4B,MAAM,cAAc,CAAA;AAM1E,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;CAC3B;AAED,UAAU,0BAA0B;IAClC,QAAQ,EAAE,YAAY,CAAA;IACtB,SAAS,EAAE,iBAAiB,GAAG,GAAG,GAAG,UAAU,CAAA;IAC/C,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,UAAU,iBAAiB;IACzB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,UAAU,WAAW;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,EAAE,CAAA;IACpB,SAAS,EAAE,MA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