@metamask/smart-accounts-kit 0.4.0-beta.0 → 0.4.0-beta.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 +49 -1
- package/dist/actions/index.cjs +5 -5
- package/dist/actions/index.d.cts +2 -2
- package/dist/actions/index.d.ts +2 -2
- package/dist/actions/index.mjs +4 -4
- package/dist/{chunk-S2Q5ZC64.cjs → chunk-23YXLKTX.cjs} +58 -59
- package/dist/chunk-23YXLKTX.cjs.map +1 -0
- package/dist/{chunk-W6ZI7GWI.mjs → chunk-33AMUJBJ.mjs} +49 -52
- package/dist/chunk-33AMUJBJ.mjs.map +1 -0
- package/dist/{chunk-TEH426Y4.mjs → chunk-C5ZEEH2Z.mjs} +283 -184
- package/dist/chunk-C5ZEEH2Z.mjs.map +1 -0
- package/dist/{chunk-NTZ57GNF.cjs → chunk-DLD377CN.cjs} +17 -33
- package/dist/chunk-DLD377CN.cjs.map +1 -0
- package/dist/{chunk-5BYJZGRI.mjs → chunk-NOCLGZGB.mjs} +174 -129
- package/dist/chunk-NOCLGZGB.mjs.map +1 -0
- package/dist/{chunk-EHIZB5U7.mjs → chunk-QCULIK3O.mjs} +211 -97
- package/dist/chunk-QCULIK3O.mjs.map +1 -0
- package/dist/{chunk-YWRHYLKB.cjs → chunk-QMRKCB7T.cjs} +204 -159
- package/dist/chunk-QMRKCB7T.cjs.map +1 -0
- package/dist/{chunk-TXN7GX6Y.cjs → chunk-SOFB2MXG.cjs} +207 -93
- package/dist/chunk-SOFB2MXG.cjs.map +1 -0
- package/dist/{chunk-RAXFJGCS.cjs → chunk-UUOH2WAW.cjs} +19 -19
- package/dist/chunk-UUOH2WAW.cjs.map +1 -0
- package/dist/{chunk-AUCZDOTJ.mjs → chunk-WPVSFOQM.mjs} +11 -27
- package/dist/chunk-WPVSFOQM.mjs.map +1 -0
- package/dist/{chunk-4A5RMDDC.mjs → chunk-WV2R7BXP.mjs} +49 -50
- package/dist/chunk-WV2R7BXP.mjs.map +1 -0
- package/dist/{chunk-YTGYVHDF.cjs → chunk-XN36L4RX.cjs} +144 -147
- package/dist/chunk-XN36L4RX.cjs.map +1 -0
- package/dist/{chunk-MIP7KJYH.cjs → chunk-YDLLC6PP.cjs} +252 -153
- package/dist/chunk-YDLLC6PP.cjs.map +1 -0
- package/dist/{chunk-DPWYECSV.mjs → chunk-YTELOQ4I.mjs} +9 -9
- package/dist/chunk-YTELOQ4I.mjs.map +1 -0
- package/dist/contracts/index.cjs +5 -5
- package/dist/contracts/index.d.cts +3 -3
- package/dist/contracts/index.d.ts +3 -3
- package/dist/contracts/index.mjs +4 -4
- package/dist/{delegation-DHjM_pVa.d.ts → delegation-DGUfyX-C.d.ts} +52 -26
- package/dist/{delegation-BnhAvKt4.d.cts → delegation-D_TY-tAq.d.cts} +52 -26
- package/dist/experimental/index.cjs +4 -4
- package/dist/experimental/index.cjs.map +1 -1
- package/dist/experimental/index.d.cts +1 -1
- package/dist/experimental/index.d.ts +1 -1
- package/dist/experimental/index.mjs +5 -5
- package/dist/experimental/index.mjs.map +1 -1
- package/dist/{index-CX3hrztI.d.cts → index-B9bsjGqI.d.ts} +240 -38
- package/dist/{index-D04LO0vH.d.cts → index-CZes99jV.d.cts} +95 -62
- package/dist/{index-i8cod4JY.d.ts → index-DvcKJcXi.d.cts} +240 -38
- package/dist/{index-BlgCQ80b.d.ts → index-FpCh2419.d.ts} +95 -62
- package/dist/index.cjs +26 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -11
- package/dist/index.d.ts +9 -11
- package/dist/index.mjs +17 -15
- package/dist/index.mjs.map +1 -1
- package/dist/{smartAccountsEnvironment-SVknZ_3f.d.cts → smartAccountsEnvironment-BU8kjlEv.d.cts} +1 -1
- package/dist/{smartAccountsEnvironment-BOhrxEnt.d.ts → smartAccountsEnvironment-egxuflDO.d.ts} +1 -1
- package/dist/{types-Bwksz_U6.d.ts → types-BLYWtcR3.d.cts} +49 -31
- package/dist/{types-Bwksz_U6.d.cts → types-BLYWtcR3.d.ts} +49 -31
- package/dist/utils/index.cjs +7 -5
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +3 -4
- package/dist/utils/index.d.ts +3 -4
- package/dist/utils/index.mjs +12 -10
- package/package.json +6 -11
- package/dist/chunk-4A5RMDDC.mjs.map +0 -1
- package/dist/chunk-5BYJZGRI.mjs.map +0 -1
- package/dist/chunk-AUCZDOTJ.mjs.map +0 -1
- package/dist/chunk-DPWYECSV.mjs.map +0 -1
- package/dist/chunk-EHIZB5U7.mjs.map +0 -1
- package/dist/chunk-MIP7KJYH.cjs.map +0 -1
- package/dist/chunk-NTZ57GNF.cjs.map +0 -1
- package/dist/chunk-RAXFJGCS.cjs.map +0 -1
- package/dist/chunk-S2Q5ZC64.cjs.map +0 -1
- package/dist/chunk-TEH426Y4.mjs.map +0 -1
- package/dist/chunk-TXN7GX6Y.cjs.map +0 -1
- package/dist/chunk-W6ZI7GWI.mjs.map +0 -1
- package/dist/chunk-YTGYVHDF.cjs.map +0 -1
- package/dist/chunk-YWRHYLKB.cjs.map +0 -1
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkUUOH2WAWcjs = require('./chunk-UUOH2WAW.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkSOFB2MXGcjs = require('./chunk-SOFB2MXG.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -19,11 +19,12 @@ var _chunkVLKX4BR6cjs = require('./chunk-VLKX4BR6.cjs');
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
var _chunkYDLLC6PPcjs = require('./chunk-YDLLC6PP.cjs');
|
|
23
24
|
|
|
24
25
|
// src/actions/index.ts
|
|
25
26
|
var actions_exports = {};
|
|
26
|
-
|
|
27
|
+
_chunkYDLLC6PPcjs.__export.call(void 0, actions_exports, {
|
|
27
28
|
caveatEnforcerActions: () => caveatEnforcerActions,
|
|
28
29
|
erc7710BundlerActions: () => erc7710BundlerActions,
|
|
29
30
|
erc7710WalletActions: () => erc7710WalletActions,
|
|
@@ -52,6 +53,16 @@ async function sendTransactionWithDelegationAction(client, args) {
|
|
|
52
53
|
"`to` is required. `sendTransactionWithDelegation` cannot be used to deploy contracts."
|
|
53
54
|
);
|
|
54
55
|
}
|
|
56
|
+
const chainId = _optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]);
|
|
57
|
+
if (!chainId) {
|
|
58
|
+
throw new Error("Chain ID is not set");
|
|
59
|
+
}
|
|
60
|
+
const { DelegationManager: expectedDelegationManager } = _chunkSOFB2MXGcjs.getSmartAccountsEnvironment.call(void 0, chainId);
|
|
61
|
+
if (!_viem.isAddressEqual.call(void 0, args.delegationManager, expectedDelegationManager)) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
`Invalid DelegationManager: expected ${expectedDelegationManager} for chain ${chainId}, but got ${args.delegationManager}`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
55
66
|
const executions = [
|
|
56
67
|
_chunkVLKX4BR6cjs.createExecution.call(void 0, {
|
|
57
68
|
target: args.to,
|
|
@@ -60,17 +71,17 @@ async function sendTransactionWithDelegationAction(client, args) {
|
|
|
60
71
|
})
|
|
61
72
|
];
|
|
62
73
|
const calldata = _viem.encodeFunctionData.call(void 0, {
|
|
63
|
-
abi: _delegationabis.DelegationManager
|
|
74
|
+
abi: _delegationabis.DelegationManager,
|
|
64
75
|
functionName: "redeemDelegations",
|
|
65
76
|
args: [
|
|
66
|
-
[args.
|
|
77
|
+
[_chunkYDLLC6PPcjs.encodeDelegations.call(void 0, args.permissionContext)],
|
|
67
78
|
["0x0000000000000000000000000000000000000000000000000000000000000000" /* SingleDefault */],
|
|
68
79
|
_chunkVLKX4BR6cjs.encodeExecutionCalldatas.call(void 0, [executions])
|
|
69
80
|
]
|
|
70
81
|
});
|
|
71
82
|
const {
|
|
72
83
|
value: _value,
|
|
73
|
-
|
|
84
|
+
permissionContext: _permissionContext,
|
|
74
85
|
delegationManager: _delegationManager,
|
|
75
86
|
...rest
|
|
76
87
|
} = args;
|
|
@@ -82,32 +93,27 @@ async function sendTransactionWithDelegationAction(client, args) {
|
|
|
82
93
|
return hash;
|
|
83
94
|
}
|
|
84
95
|
async function sendUserOperationWithDelegationAction(client, parameters) {
|
|
85
|
-
if (parameters.
|
|
96
|
+
if (parameters.dependencies) {
|
|
86
97
|
const { publicClient } = parameters;
|
|
87
98
|
const includedAccountKeys = {};
|
|
88
|
-
const chainId = _optionalChain([publicClient, 'access',
|
|
99
|
+
const chainId = _optionalChain([publicClient, 'access', _3 => _3.chain, 'optionalAccess', _4 => _4.id]);
|
|
89
100
|
if (!chainId) {
|
|
90
101
|
throw new Error("Chain ID is not set");
|
|
91
102
|
}
|
|
92
|
-
const { SimpleFactory } =
|
|
93
|
-
const
|
|
94
|
-
(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
const accountKey = _viem.concat.call(void 0, [
|
|
101
|
-
accountMetadata.factory,
|
|
102
|
-
accountMetadata.factoryData
|
|
103
|
-
]);
|
|
104
|
-
const isDuplicate = includedAccountKeys[accountKey];
|
|
105
|
-
includedAccountKeys[accountKey] = true;
|
|
106
|
-
return !isDuplicate;
|
|
103
|
+
const { SimpleFactory } = _chunkSOFB2MXGcjs.getSmartAccountsEnvironment.call(void 0, chainId);
|
|
104
|
+
const uniqueDependencies = parameters.dependencies.filter((dependency) => {
|
|
105
|
+
if (!_viem.isAddressEqual.call(void 0, dependency.factory, SimpleFactory)) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
`Invalid dependency: ${dependency.factory} is not allowed.`
|
|
108
|
+
);
|
|
107
109
|
}
|
|
108
|
-
|
|
110
|
+
const accountKey = _viem.concat.call(void 0, [dependency.factory, dependency.factoryData]);
|
|
111
|
+
const isDuplicate = includedAccountKeys[accountKey];
|
|
112
|
+
includedAccountKeys[accountKey] = true;
|
|
113
|
+
return !isDuplicate;
|
|
114
|
+
});
|
|
109
115
|
const factoryCalls = (await Promise.all(
|
|
110
|
-
|
|
116
|
+
uniqueDependencies.map(async ({ factory, factoryData }) => {
|
|
111
117
|
const isDeployed = await publicClient.call({
|
|
112
118
|
to: factory,
|
|
113
119
|
data: factoryData
|
|
@@ -127,63 +133,32 @@ async function sendUserOperationWithDelegationAction(client, parameters) {
|
|
|
127
133
|
...parameters.calls
|
|
128
134
|
];
|
|
129
135
|
}
|
|
136
|
+
parameters.calls = parameters.calls.map((call) => {
|
|
137
|
+
if (!("permissionContext" in call)) {
|
|
138
|
+
return call;
|
|
139
|
+
}
|
|
140
|
+
const { permissionContext } = call;
|
|
141
|
+
if (!permissionContext) {
|
|
142
|
+
return call;
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
...call,
|
|
146
|
+
permissionContext: _chunkYDLLC6PPcjs.encodeDelegations.call(void 0, permissionContext)
|
|
147
|
+
};
|
|
148
|
+
});
|
|
130
149
|
return client.sendUserOperation(
|
|
131
150
|
parameters
|
|
132
151
|
);
|
|
133
152
|
}
|
|
134
153
|
|
|
135
|
-
// src/actions/
|
|
136
|
-
async function erc7715GetGrantedExecutionPermissionsAction(client) {
|
|
137
|
-
const result = await client.request(
|
|
138
|
-
{
|
|
139
|
-
method: "wallet_getGrantedExecutionPermissions",
|
|
140
|
-
params: []
|
|
141
|
-
},
|
|
142
|
-
{ retryCount: 0 }
|
|
143
|
-
);
|
|
144
|
-
if (!result) {
|
|
145
|
-
throw new Error("Failed to get granted execution permissions");
|
|
146
|
-
}
|
|
147
|
-
return result;
|
|
148
|
-
}
|
|
154
|
+
// src/actions/erc7715Mapping.ts
|
|
149
155
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
{
|
|
154
|
-
method: "wallet_getSupportedExecutionPermissions",
|
|
155
|
-
params: []
|
|
156
|
-
},
|
|
157
|
-
{ retryCount: 0 }
|
|
158
|
-
);
|
|
159
|
-
if (!result) {
|
|
160
|
-
throw new Error("Failed to get supported execution permissions");
|
|
161
|
-
}
|
|
162
|
-
return result;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// src/actions/erc7715RequestExecutionPermissionsAction.ts
|
|
166
|
-
|
|
167
|
-
async function erc7715RequestExecutionPermissionsAction(client, parameters) {
|
|
168
|
-
const formattedPermissionRequest = parameters.map(formatPermissionsRequest);
|
|
169
|
-
const result = await client.request(
|
|
170
|
-
{
|
|
171
|
-
method: "wallet_requestExecutionPermissions",
|
|
172
|
-
params: formattedPermissionRequest
|
|
173
|
-
},
|
|
174
|
-
{ retryCount: 0 }
|
|
175
|
-
);
|
|
176
|
-
if (!result) {
|
|
177
|
-
throw new Error("Failed to grant permissions");
|
|
178
|
-
}
|
|
179
|
-
return result;
|
|
180
|
-
}
|
|
181
|
-
function formatPermissionsRequest(parameters) {
|
|
182
|
-
const { chainId, from, expiry, isAdjustmentAllowed } = parameters;
|
|
183
|
-
const permissionFormatter = getPermissionFormatter(
|
|
156
|
+
function permissionRequestToRpc(parameters) {
|
|
157
|
+
const { chainId, from, expiry } = parameters;
|
|
158
|
+
const converter = getPermissionRequestToRpcConverter(
|
|
184
159
|
parameters.permission.type
|
|
185
160
|
);
|
|
186
|
-
const rules =
|
|
161
|
+
const rules = _chunkYDLLC6PPcjs.isDefined.call(void 0, expiry) ? [
|
|
187
162
|
{
|
|
188
163
|
type: "expiry",
|
|
189
164
|
data: {
|
|
@@ -197,49 +172,38 @@ function formatPermissionsRequest(parameters) {
|
|
|
197
172
|
return {
|
|
198
173
|
...optionalFields,
|
|
199
174
|
chainId: _viem.toHex.call(void 0, chainId),
|
|
200
|
-
permission:
|
|
201
|
-
permission: parameters.permission,
|
|
202
|
-
isAdjustmentAllowed
|
|
203
|
-
}),
|
|
175
|
+
permission: converter(parameters.permission),
|
|
204
176
|
to: parameters.to,
|
|
205
177
|
rules
|
|
206
178
|
};
|
|
207
179
|
}
|
|
208
|
-
function
|
|
180
|
+
function getPermissionRequestToRpcConverter(permissionType) {
|
|
209
181
|
switch (permissionType) {
|
|
210
182
|
case "native-token-stream":
|
|
211
|
-
return (
|
|
212
|
-
permission
|
|
213
|
-
|
|
214
|
-
});
|
|
183
|
+
return (permission) => nativeTokenStreamPermissionToRpc(
|
|
184
|
+
permission
|
|
185
|
+
);
|
|
215
186
|
case "erc20-token-stream":
|
|
216
|
-
return (
|
|
217
|
-
permission
|
|
218
|
-
|
|
219
|
-
});
|
|
187
|
+
return (permission) => erc20TokenStreamPermissionToRpc(
|
|
188
|
+
permission
|
|
189
|
+
);
|
|
220
190
|
case "native-token-periodic":
|
|
221
|
-
return (
|
|
222
|
-
permission
|
|
223
|
-
|
|
224
|
-
});
|
|
191
|
+
return (permission) => nativeTokenPeriodicPermissionToRpc(
|
|
192
|
+
permission
|
|
193
|
+
);
|
|
225
194
|
case "erc20-token-periodic":
|
|
226
|
-
return (
|
|
227
|
-
permission
|
|
228
|
-
|
|
229
|
-
});
|
|
195
|
+
return (permission) => erc20TokenPeriodicPermissionToRpc(
|
|
196
|
+
permission
|
|
197
|
+
);
|
|
230
198
|
case "erc20-token-revocation":
|
|
231
|
-
return (
|
|
232
|
-
permission
|
|
233
|
-
|
|
234
|
-
});
|
|
199
|
+
return (permission) => erc20TokenRevocationPermissionToRpc(
|
|
200
|
+
permission
|
|
201
|
+
);
|
|
235
202
|
default:
|
|
236
203
|
throw new Error(`Unsupported permission type: ${permissionType}`);
|
|
237
204
|
}
|
|
238
205
|
}
|
|
239
|
-
function
|
|
240
|
-
permission,
|
|
241
|
-
isAdjustmentAllowed
|
|
242
|
-
}) {
|
|
206
|
+
function nativeTokenStreamPermissionToRpc(permission) {
|
|
243
207
|
const {
|
|
244
208
|
data: {
|
|
245
209
|
initialAmount,
|
|
@@ -247,16 +211,17 @@ function formatNativeTokenStreamPermission({
|
|
|
247
211
|
maxAmount,
|
|
248
212
|
startTime,
|
|
249
213
|
amountPerSecond
|
|
250
|
-
}
|
|
214
|
+
},
|
|
215
|
+
isAdjustmentAllowed
|
|
251
216
|
} = permission;
|
|
252
217
|
const optionalFields = {
|
|
253
|
-
...
|
|
254
|
-
initialAmount:
|
|
218
|
+
..._chunkYDLLC6PPcjs.isDefined.call(void 0, initialAmount) && {
|
|
219
|
+
initialAmount: _chunkYDLLC6PPcjs.toHexOrThrow.call(void 0, initialAmount, "initialAmount")
|
|
255
220
|
},
|
|
256
|
-
...
|
|
257
|
-
maxAmount:
|
|
221
|
+
..._chunkYDLLC6PPcjs.isDefined.call(void 0, maxAmount) && {
|
|
222
|
+
maxAmount: _chunkYDLLC6PPcjs.toHexOrThrow.call(void 0, maxAmount, "maxAmount")
|
|
258
223
|
},
|
|
259
|
-
...
|
|
224
|
+
..._chunkYDLLC6PPcjs.isDefined.call(void 0, startTime) && {
|
|
260
225
|
startTime: Number(startTime)
|
|
261
226
|
},
|
|
262
227
|
...justification ? { justification } : {}
|
|
@@ -264,16 +229,13 @@ function formatNativeTokenStreamPermission({
|
|
|
264
229
|
return {
|
|
265
230
|
type: "native-token-stream",
|
|
266
231
|
data: {
|
|
267
|
-
amountPerSecond:
|
|
232
|
+
amountPerSecond: _chunkYDLLC6PPcjs.toHexOrThrow.call(void 0, amountPerSecond, "amountPerSecond"),
|
|
268
233
|
...optionalFields
|
|
269
234
|
},
|
|
270
235
|
isAdjustmentAllowed
|
|
271
236
|
};
|
|
272
237
|
}
|
|
273
|
-
function
|
|
274
|
-
permission,
|
|
275
|
-
isAdjustmentAllowed
|
|
276
|
-
}) {
|
|
238
|
+
function erc20TokenStreamPermissionToRpc(permission) {
|
|
277
239
|
const {
|
|
278
240
|
data: {
|
|
279
241
|
tokenAddress,
|
|
@@ -282,16 +244,17 @@ function formatErc20TokenStreamPermission({
|
|
|
282
244
|
startTime,
|
|
283
245
|
maxAmount,
|
|
284
246
|
justification
|
|
285
|
-
}
|
|
247
|
+
},
|
|
248
|
+
isAdjustmentAllowed
|
|
286
249
|
} = permission;
|
|
287
250
|
const optionalFields = {
|
|
288
|
-
...
|
|
289
|
-
initialAmount:
|
|
251
|
+
..._chunkYDLLC6PPcjs.isDefined.call(void 0, initialAmount) && {
|
|
252
|
+
initialAmount: _chunkYDLLC6PPcjs.toHexOrThrow.call(void 0, initialAmount, "initialAmount")
|
|
290
253
|
},
|
|
291
|
-
...
|
|
292
|
-
maxAmount:
|
|
254
|
+
..._chunkYDLLC6PPcjs.isDefined.call(void 0, maxAmount) && {
|
|
255
|
+
maxAmount: _chunkYDLLC6PPcjs.toHexOrThrow.call(void 0, maxAmount, "maxAmount")
|
|
293
256
|
},
|
|
294
|
-
...
|
|
257
|
+
..._chunkYDLLC6PPcjs.isDefined.call(void 0, startTime) && {
|
|
295
258
|
startTime: Number(startTime)
|
|
296
259
|
},
|
|
297
260
|
...justification ? { justification } : {}
|
|
@@ -299,22 +262,20 @@ function formatErc20TokenStreamPermission({
|
|
|
299
262
|
return {
|
|
300
263
|
type: "erc20-token-stream",
|
|
301
264
|
data: {
|
|
302
|
-
tokenAddress:
|
|
303
|
-
amountPerSecond:
|
|
265
|
+
tokenAddress: _chunkYDLLC6PPcjs.toHexOrThrow.call(void 0, tokenAddress, "tokenAddress"),
|
|
266
|
+
amountPerSecond: _chunkYDLLC6PPcjs.toHexOrThrow.call(void 0, amountPerSecond, "amountPerSecond"),
|
|
304
267
|
...optionalFields
|
|
305
268
|
},
|
|
306
269
|
isAdjustmentAllowed
|
|
307
270
|
};
|
|
308
271
|
}
|
|
309
|
-
function
|
|
310
|
-
permission,
|
|
311
|
-
isAdjustmentAllowed
|
|
312
|
-
}) {
|
|
272
|
+
function nativeTokenPeriodicPermissionToRpc(permission) {
|
|
313
273
|
const {
|
|
314
|
-
data: { periodAmount, periodDuration, startTime, justification }
|
|
274
|
+
data: { periodAmount, periodDuration, startTime, justification },
|
|
275
|
+
isAdjustmentAllowed
|
|
315
276
|
} = permission;
|
|
316
277
|
const optionalFields = {
|
|
317
|
-
...
|
|
278
|
+
..._chunkYDLLC6PPcjs.isDefined.call(void 0, startTime) && {
|
|
318
279
|
startTime: Number(startTime)
|
|
319
280
|
},
|
|
320
281
|
...justification ? { justification } : {}
|
|
@@ -322,17 +283,14 @@ function formatNativeTokenPeriodicPermission({
|
|
|
322
283
|
return {
|
|
323
284
|
type: "native-token-periodic",
|
|
324
285
|
data: {
|
|
325
|
-
periodAmount:
|
|
286
|
+
periodAmount: _chunkYDLLC6PPcjs.toHexOrThrow.call(void 0, periodAmount, "periodAmount"),
|
|
326
287
|
periodDuration: Number(periodDuration),
|
|
327
288
|
...optionalFields
|
|
328
289
|
},
|
|
329
290
|
isAdjustmentAllowed
|
|
330
291
|
};
|
|
331
292
|
}
|
|
332
|
-
function
|
|
333
|
-
permission,
|
|
334
|
-
isAdjustmentAllowed
|
|
335
|
-
}) {
|
|
293
|
+
function erc20TokenPeriodicPermissionToRpc(permission) {
|
|
336
294
|
const {
|
|
337
295
|
data: {
|
|
338
296
|
tokenAddress,
|
|
@@ -340,10 +298,11 @@ function formatErc20TokenPeriodicPermission({
|
|
|
340
298
|
periodDuration,
|
|
341
299
|
startTime,
|
|
342
300
|
justification
|
|
343
|
-
}
|
|
301
|
+
},
|
|
302
|
+
isAdjustmentAllowed
|
|
344
303
|
} = permission;
|
|
345
304
|
const optionalFields = {
|
|
346
|
-
...
|
|
305
|
+
..._chunkYDLLC6PPcjs.isDefined.call(void 0, startTime) && {
|
|
347
306
|
startTime: Number(startTime)
|
|
348
307
|
},
|
|
349
308
|
...justification ? { justification } : {}
|
|
@@ -351,20 +310,18 @@ function formatErc20TokenPeriodicPermission({
|
|
|
351
310
|
return {
|
|
352
311
|
type: "erc20-token-periodic",
|
|
353
312
|
data: {
|
|
354
|
-
tokenAddress:
|
|
355
|
-
periodAmount:
|
|
313
|
+
tokenAddress: _chunkYDLLC6PPcjs.toHexOrThrow.call(void 0, tokenAddress, "tokenAddress"),
|
|
314
|
+
periodAmount: _chunkYDLLC6PPcjs.toHexOrThrow.call(void 0, periodAmount, "periodAmount"),
|
|
356
315
|
periodDuration: Number(periodDuration),
|
|
357
316
|
...optionalFields
|
|
358
317
|
},
|
|
359
318
|
isAdjustmentAllowed
|
|
360
319
|
};
|
|
361
320
|
}
|
|
362
|
-
function
|
|
363
|
-
permission,
|
|
364
|
-
isAdjustmentAllowed
|
|
365
|
-
}) {
|
|
321
|
+
function erc20TokenRevocationPermissionToRpc(permission) {
|
|
366
322
|
const {
|
|
367
|
-
data: { justification }
|
|
323
|
+
data: { justification },
|
|
324
|
+
isAdjustmentAllowed
|
|
368
325
|
} = permission;
|
|
369
326
|
const data = {
|
|
370
327
|
...justification ? { justification } : {}
|
|
@@ -375,6 +332,94 @@ function formatErc20TokenRevocationPermission({
|
|
|
375
332
|
isAdjustmentAllowed
|
|
376
333
|
};
|
|
377
334
|
}
|
|
335
|
+
function permissionResponsesFromRpc(result) {
|
|
336
|
+
return result.map((permission) => ({
|
|
337
|
+
...permission,
|
|
338
|
+
chainId: _viem.hexToNumber.call(void 0, permission.chainId),
|
|
339
|
+
permission: permissionTypeFromRpc(permission.permission)
|
|
340
|
+
}));
|
|
341
|
+
}
|
|
342
|
+
function permissionTypeFromRpc(permission) {
|
|
343
|
+
const convertedData = { ...permission.data };
|
|
344
|
+
if ("amountPerSecond" in convertedData && convertedData.amountPerSecond) {
|
|
345
|
+
convertedData.amountPerSecond = BigInt(
|
|
346
|
+
convertedData.amountPerSecond
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
if ("periodAmount" in convertedData && convertedData.periodAmount) {
|
|
350
|
+
convertedData.periodAmount = BigInt(
|
|
351
|
+
convertedData.periodAmount
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
if ("initialAmount" in convertedData && convertedData.initialAmount) {
|
|
355
|
+
convertedData.initialAmount = BigInt(
|
|
356
|
+
convertedData.initialAmount
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
if ("maxAmount" in convertedData && convertedData.maxAmount) {
|
|
360
|
+
convertedData.maxAmount = BigInt(convertedData.maxAmount);
|
|
361
|
+
}
|
|
362
|
+
return {
|
|
363
|
+
...permission,
|
|
364
|
+
data: convertedData
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function rpcSupportedPermissionsToDeveloper(result) {
|
|
368
|
+
const converted = {};
|
|
369
|
+
for (const [permissionType, permissionInfo] of Object.entries(result)) {
|
|
370
|
+
converted[permissionType] = {
|
|
371
|
+
chainIds: permissionInfo.chainIds.map((chainId) => _viem.hexToNumber.call(void 0, chainId)),
|
|
372
|
+
ruleTypes: permissionInfo.ruleTypes
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
return converted;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// src/actions/erc7715GetGrantedExecutionPermissionsAction.ts
|
|
379
|
+
async function erc7715GetGrantedExecutionPermissionsAction(client) {
|
|
380
|
+
const result = await client.request(
|
|
381
|
+
{
|
|
382
|
+
method: "wallet_getGrantedExecutionPermissions",
|
|
383
|
+
params: []
|
|
384
|
+
},
|
|
385
|
+
{ retryCount: 0 }
|
|
386
|
+
);
|
|
387
|
+
if (!result) {
|
|
388
|
+
throw new Error("Failed to get granted execution permissions");
|
|
389
|
+
}
|
|
390
|
+
return permissionResponsesFromRpc(result);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// src/actions/erc7715GetSupportedExecutionPermissionsAction.ts
|
|
394
|
+
async function erc7715GetSupportedExecutionPermissionsAction(client) {
|
|
395
|
+
const result = await client.request(
|
|
396
|
+
{
|
|
397
|
+
method: "wallet_getSupportedExecutionPermissions",
|
|
398
|
+
params: []
|
|
399
|
+
},
|
|
400
|
+
{ retryCount: 0 }
|
|
401
|
+
);
|
|
402
|
+
if (!result) {
|
|
403
|
+
throw new Error("Failed to get supported execution permissions");
|
|
404
|
+
}
|
|
405
|
+
return rpcSupportedPermissionsToDeveloper(result);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// src/actions/erc7715RequestExecutionPermissionsAction.ts
|
|
409
|
+
async function erc7715RequestExecutionPermissionsAction(client, parameters) {
|
|
410
|
+
const formattedPermissionRequest = parameters.map(permissionRequestToRpc);
|
|
411
|
+
const result = await client.request(
|
|
412
|
+
{
|
|
413
|
+
method: "wallet_requestExecutionPermissions",
|
|
414
|
+
params: formattedPermissionRequest
|
|
415
|
+
},
|
|
416
|
+
{ retryCount: 0 }
|
|
417
|
+
);
|
|
418
|
+
if (!result) {
|
|
419
|
+
throw new Error("Failed to grant permissions");
|
|
420
|
+
}
|
|
421
|
+
return permissionResponsesFromRpc(result);
|
|
422
|
+
}
|
|
378
423
|
|
|
379
424
|
// src/actions/getCaveatAvailableAmount.ts
|
|
380
425
|
function findMatchingCaveat({
|
|
@@ -422,13 +467,13 @@ async function getErc20PeriodTransferEnforcerAvailableAmount(client, environment
|
|
|
422
467
|
enforcerName,
|
|
423
468
|
environment
|
|
424
469
|
});
|
|
425
|
-
const delegationHash =
|
|
470
|
+
const delegationHash = _chunkYDLLC6PPcjs.hashDelegation.call(void 0, params.delegation);
|
|
426
471
|
const { terms } = findMatchingCaveat({
|
|
427
472
|
delegation: params.delegation,
|
|
428
473
|
enforcerAddress,
|
|
429
474
|
enforcerName
|
|
430
475
|
});
|
|
431
|
-
return
|
|
476
|
+
return _chunkUUOH2WAWcjs.read_exports.getAvailableAmount({
|
|
432
477
|
client,
|
|
433
478
|
contractAddress: enforcerAddress,
|
|
434
479
|
delegationHash,
|
|
@@ -443,13 +488,13 @@ async function getErc20StreamingEnforcerAvailableAmount(client, environment, par
|
|
|
443
488
|
enforcerName,
|
|
444
489
|
environment
|
|
445
490
|
});
|
|
446
|
-
const delegationHash =
|
|
491
|
+
const delegationHash = _chunkYDLLC6PPcjs.hashDelegation.call(void 0, params.delegation);
|
|
447
492
|
const { terms } = findMatchingCaveat({
|
|
448
493
|
delegation: params.delegation,
|
|
449
494
|
enforcerAddress,
|
|
450
495
|
enforcerName
|
|
451
496
|
});
|
|
452
|
-
return
|
|
497
|
+
return _chunkUUOH2WAWcjs.read_exports2.getAvailableAmount({
|
|
453
498
|
client,
|
|
454
499
|
contractAddress: enforcerAddress,
|
|
455
500
|
delegationManager,
|
|
@@ -464,13 +509,13 @@ async function getMultiTokenPeriodEnforcerAvailableAmount(client, environment, p
|
|
|
464
509
|
enforcerName,
|
|
465
510
|
environment
|
|
466
511
|
});
|
|
467
|
-
const delegationHash =
|
|
512
|
+
const delegationHash = _chunkYDLLC6PPcjs.hashDelegation.call(void 0, params.delegation);
|
|
468
513
|
const { terms, args } = findMatchingCaveat({
|
|
469
514
|
delegation: params.delegation,
|
|
470
515
|
enforcerAddress,
|
|
471
516
|
enforcerName
|
|
472
517
|
});
|
|
473
|
-
return
|
|
518
|
+
return _chunkUUOH2WAWcjs.read_exports3.getAvailableAmount({
|
|
474
519
|
client,
|
|
475
520
|
contractAddress: enforcerAddress,
|
|
476
521
|
delegationHash,
|
|
@@ -486,13 +531,13 @@ async function getNativeTokenPeriodTransferEnforcerAvailableAmount(client, envir
|
|
|
486
531
|
enforcerName,
|
|
487
532
|
environment
|
|
488
533
|
});
|
|
489
|
-
const delegationHash =
|
|
534
|
+
const delegationHash = _chunkYDLLC6PPcjs.hashDelegation.call(void 0, params.delegation);
|
|
490
535
|
const { terms } = findMatchingCaveat({
|
|
491
536
|
delegation: params.delegation,
|
|
492
537
|
enforcerAddress,
|
|
493
538
|
enforcerName
|
|
494
539
|
});
|
|
495
|
-
return
|
|
540
|
+
return _chunkUUOH2WAWcjs.read_exports4.getAvailableAmount({
|
|
496
541
|
client,
|
|
497
542
|
contractAddress: enforcerAddress,
|
|
498
543
|
delegationHash,
|
|
@@ -507,13 +552,13 @@ async function getNativeTokenStreamingEnforcerAvailableAmount(client, environmen
|
|
|
507
552
|
enforcerName,
|
|
508
553
|
environment
|
|
509
554
|
});
|
|
510
|
-
const delegationHash =
|
|
555
|
+
const delegationHash = _chunkYDLLC6PPcjs.hashDelegation.call(void 0, params.delegation);
|
|
511
556
|
const { terms } = findMatchingCaveat({
|
|
512
557
|
delegation: params.delegation,
|
|
513
558
|
enforcerAddress,
|
|
514
559
|
enforcerName
|
|
515
560
|
});
|
|
516
|
-
return
|
|
561
|
+
return _chunkUUOH2WAWcjs.read_exports5.getAvailableAmount({
|
|
517
562
|
client,
|
|
518
563
|
contractAddress: enforcerAddress,
|
|
519
564
|
delegationManager,
|
|
@@ -594,7 +639,7 @@ var caveatEnforcerActions = ({ environment }) => (client) => ({
|
|
|
594
639
|
var _actions = require('viem/actions');
|
|
595
640
|
var DELEGATION_PREFIX = "0xef0100";
|
|
596
641
|
function extractDelegatedAddress(code) {
|
|
597
|
-
if (_optionalChain([code, 'optionalAccess',
|
|
642
|
+
if (_optionalChain([code, 'optionalAccess', _5 => _5.length]) !== 48) {
|
|
598
643
|
return null;
|
|
599
644
|
}
|
|
600
645
|
if (!code.toLowerCase().startsWith(DELEGATION_PREFIX.toLowerCase())) {
|
|
@@ -643,7 +688,7 @@ async function signDelegation(client, parameters) {
|
|
|
643
688
|
throw new (0, _viem.BaseError)("Account not found. Please provide an account.");
|
|
644
689
|
}
|
|
645
690
|
const account = _accounts.parseAccount.call(void 0, accountParam);
|
|
646
|
-
const typedData =
|
|
691
|
+
const typedData = _chunkYDLLC6PPcjs.prepareSignDelegationTypedData.call(void 0, {
|
|
647
692
|
delegation,
|
|
648
693
|
delegationManager,
|
|
649
694
|
chainId,
|
|
@@ -660,7 +705,7 @@ function signDelegationActions() {
|
|
|
660
705
|
return (client) => ({
|
|
661
706
|
signDelegation: async (parameters) => signDelegation(client, {
|
|
662
707
|
chainId: _nullishCoalesce(parameters.chainId, () => ( (() => {
|
|
663
|
-
if (!_optionalChain([client, 'access',
|
|
708
|
+
if (!_optionalChain([client, 'access', _6 => _6.chain, 'optionalAccess', _7 => _7.id])) {
|
|
664
709
|
throw new (0, _viem.BaseError)(
|
|
665
710
|
"Chain ID is required. Either provide it in parameters or configure the client with a chain."
|
|
666
711
|
);
|
|
@@ -689,7 +734,7 @@ async function signUserOperation(client, parameters) {
|
|
|
689
734
|
throw new (0, _viem.BaseError)("Account not found. Please provide an account.");
|
|
690
735
|
}
|
|
691
736
|
const account = _accounts.parseAccount.call(void 0, accountParam);
|
|
692
|
-
const typedData =
|
|
737
|
+
const typedData = _chunkSOFB2MXGcjs.prepareSignUserOperationTypedData.call(void 0, {
|
|
693
738
|
userOperation,
|
|
694
739
|
entryPoint,
|
|
695
740
|
chainId,
|
|
@@ -706,7 +751,7 @@ function signUserOperationActions() {
|
|
|
706
751
|
return (client) => ({
|
|
707
752
|
signUserOperation: async (parameters) => signUserOperation(client, {
|
|
708
753
|
chainId: _nullishCoalesce(parameters.chainId, () => ( (() => {
|
|
709
|
-
if (!_optionalChain([client, 'access',
|
|
754
|
+
if (!_optionalChain([client, 'access', _8 => _8.chain, 'optionalAccess', _9 => _9.id])) {
|
|
710
755
|
throw new (0, _viem.BaseError)(
|
|
711
756
|
"Chain ID is required. Either provide it in parameters or configure the client with a chain."
|
|
712
757
|
);
|
|
@@ -764,4 +809,4 @@ var erc7710BundlerActions = () => (client) => ({
|
|
|
764
809
|
|
|
765
810
|
|
|
766
811
|
exports.isValid7702Implementation = isValid7702Implementation; exports.erc7715GetGrantedExecutionPermissionsAction = erc7715GetGrantedExecutionPermissionsAction; exports.erc7715GetSupportedExecutionPermissionsAction = erc7715GetSupportedExecutionPermissionsAction; exports.erc7715RequestExecutionPermissionsAction = erc7715RequestExecutionPermissionsAction; exports.getErc20PeriodTransferEnforcerAvailableAmount = getErc20PeriodTransferEnforcerAvailableAmount; exports.getErc20StreamingEnforcerAvailableAmount = getErc20StreamingEnforcerAvailableAmount; exports.getMultiTokenPeriodEnforcerAvailableAmount = getMultiTokenPeriodEnforcerAvailableAmount; exports.getNativeTokenPeriodTransferEnforcerAvailableAmount = getNativeTokenPeriodTransferEnforcerAvailableAmount; exports.getNativeTokenStreamingEnforcerAvailableAmount = getNativeTokenStreamingEnforcerAvailableAmount; exports.caveatEnforcerActions = caveatEnforcerActions; exports.signDelegation = signDelegation; exports.signDelegationActions = signDelegationActions; exports.signUserOperation = signUserOperation; exports.signUserOperationActions = signUserOperationActions; exports.erc7715ProviderActions = erc7715ProviderActions; exports.erc7710WalletActions = erc7710WalletActions; exports.erc7710BundlerActions = erc7710BundlerActions; exports.actions_exports = actions_exports;
|
|
767
|
-
//# sourceMappingURL=chunk-
|
|
812
|
+
//# sourceMappingURL=chunk-QMRKCB7T.cjs.map
|