@vaultum/sdk 0.1.5
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/README.md +56 -0
- package/dist/index.d.mts +2203 -0
- package/dist/index.d.ts +2203 -0
- package/dist/index.js +2019 -0
- package/dist/index.mjs +1982 -0
- package/package.json +63 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2019 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
API: () => API,
|
|
24
|
+
CONTRACTS: () => CONTRACTS,
|
|
25
|
+
ENTRYPOINT_V07: () => ENTRYPOINT_V07,
|
|
26
|
+
FEATURE_IDS: () => FEATURE_IDS,
|
|
27
|
+
FEATURE_ID_STRINGS: () => FEATURE_ID_STRINGS,
|
|
28
|
+
GOVERNANCE_DOMAIN_NAME: () => GOVERNANCE_DOMAIN_NAME,
|
|
29
|
+
GOVERNANCE_DOMAIN_VERSION: () => GOVERNANCE_DOMAIN_VERSION,
|
|
30
|
+
UserOpBuilder: () => UserOpBuilder,
|
|
31
|
+
VERSION: () => VERSION,
|
|
32
|
+
VaultumClient: () => VaultumClient,
|
|
33
|
+
VaultumError: () => VaultumError,
|
|
34
|
+
buildCrossChainRootTypedData: () => buildCrossChainRootTypedData,
|
|
35
|
+
createUserOpBuilder: () => createUserOpBuilder,
|
|
36
|
+
getUserOpHash: () => getUserOpHash,
|
|
37
|
+
hashCrossChainRootTypedData: () => hashCrossChainRootTypedData,
|
|
38
|
+
packGasFees: () => packGasFees,
|
|
39
|
+
packGasLimits: () => packGasLimits,
|
|
40
|
+
parseQuoteResponse: () => parseQuoteResponse,
|
|
41
|
+
unpackGasFees: () => unpackGasFees,
|
|
42
|
+
unpackGasLimits: () => unpackGasLimits
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(index_exports);
|
|
45
|
+
|
|
46
|
+
// src/api.ts
|
|
47
|
+
var e = encodeURIComponent;
|
|
48
|
+
var API = {
|
|
49
|
+
op: {
|
|
50
|
+
submit: "/api/op/submit",
|
|
51
|
+
simulate: "/api/op/simulate",
|
|
52
|
+
capabilities: "/api/op/capabilities",
|
|
53
|
+
status: (id) => `/api/op/${e(id)}`,
|
|
54
|
+
wait: (id) => `/api/op/${e(id)}/wait`
|
|
55
|
+
},
|
|
56
|
+
auth: {
|
|
57
|
+
register: "/api/auth/register",
|
|
58
|
+
login: "/api/auth/login",
|
|
59
|
+
walletChallenge: "/api/auth/wallet/challenge",
|
|
60
|
+
walletVerify: "/api/auth/wallet/verify",
|
|
61
|
+
walletRegisterChallenge: "/api/auth/wallet/register/challenge",
|
|
62
|
+
walletRegisterVerify: "/api/auth/wallet/register/verify",
|
|
63
|
+
logout: "/api/auth/logout",
|
|
64
|
+
logoutAll: "/api/auth/logout-all",
|
|
65
|
+
me: "/api/auth/me",
|
|
66
|
+
walletLinkChallenge: "/api/auth/wallet/link/challenge",
|
|
67
|
+
walletLinkVerify: "/api/auth/wallet/link/verify",
|
|
68
|
+
wallets: "/api/auth/wallets"
|
|
69
|
+
},
|
|
70
|
+
accounts: {
|
|
71
|
+
create: "/api/accounts",
|
|
72
|
+
verify: "/api/accounts/verify",
|
|
73
|
+
operations: "/api/accounts/operations"
|
|
74
|
+
},
|
|
75
|
+
vault: {
|
|
76
|
+
state: (wallet) => `/api/vault/${e(wallet)}/state`,
|
|
77
|
+
features: (wallet) => `/api/vault/${e(wallet)}/features`,
|
|
78
|
+
feature: (wallet, featureId) => `/api/vault/${e(wallet)}/feature/${e(featureId)}`,
|
|
79
|
+
opNonce: (wallet) => `/api/vault/${e(wallet)}/op-nonce`,
|
|
80
|
+
securityCouncil: (wallet) => `/api/vault/${e(wallet)}/security-council`,
|
|
81
|
+
fallbackSigner: (wallet) => `/api/vault/${e(wallet)}/fallback-signer`,
|
|
82
|
+
paused: (wallet) => `/api/vault/${e(wallet)}/paused`,
|
|
83
|
+
l2Receiver: (wallet) => `/api/vault/${e(wallet)}/l2-receiver`,
|
|
84
|
+
tryExecute: "/api/vault/try-execute",
|
|
85
|
+
pause: "/api/vault/pause",
|
|
86
|
+
unpause: "/api/vault/unpause",
|
|
87
|
+
setSecurityCouncil: "/api/vault/security-council",
|
|
88
|
+
setFallbackSigner: "/api/vault/fallback-signer",
|
|
89
|
+
overrideGlobalPause: "/api/vault/override-global-pause"
|
|
90
|
+
},
|
|
91
|
+
sessionKey: {
|
|
92
|
+
grant: "/api/sessionkey/grant",
|
|
93
|
+
revoke: "/api/sessionkey/revoke",
|
|
94
|
+
revokeAll: "/api/sessionkey/revoke-all",
|
|
95
|
+
tokenLimits: "/api/sessionkey/token-limits",
|
|
96
|
+
maxValuePerCall: "/api/sessionkey/max-value-per-call",
|
|
97
|
+
sync: "/api/sessionkey/sync",
|
|
98
|
+
list: (wallet) => `/api/sessionkey/${e(wallet)}/list`,
|
|
99
|
+
info: (wallet, key) => `/api/sessionkey/${e(wallet)}/${e(key)}`,
|
|
100
|
+
count: (wallet) => `/api/sessionkey/${e(wallet)}/count`,
|
|
101
|
+
policySigner: (wallet) => `/api/sessionkey/${e(wallet)}/policy-signer`,
|
|
102
|
+
roles: (wallet, key) => `/api/sessionkey/${e(wallet)}/${e(key)}/roles`,
|
|
103
|
+
tokenLimit: (wallet, key, token) => `/api/sessionkey/${e(wallet)}/${e(key)}/token/${e(token)}/limit`
|
|
104
|
+
},
|
|
105
|
+
feature: {
|
|
106
|
+
enable: "/api/feature/enable",
|
|
107
|
+
disable: "/api/feature/disable",
|
|
108
|
+
reset: "/api/feature/reset",
|
|
109
|
+
spendingLimits: (wallet) => `/api/feature/spending-limits/${e(wallet)}`,
|
|
110
|
+
allowlist: (wallet) => `/api/feature/allowlist/${e(wallet)}`,
|
|
111
|
+
guardians: (wallet) => `/api/feature/guardians/${e(wallet)}`,
|
|
112
|
+
recovery: (wallet) => `/api/feature/recovery/${e(wallet)}`,
|
|
113
|
+
roles: (wallet) => `/api/feature/roles/${e(wallet)}`,
|
|
114
|
+
accountRoles: (wallet, account) => `/api/feature/roles/${e(wallet)}/${e(account)}`
|
|
115
|
+
},
|
|
116
|
+
spendingLimit: {
|
|
117
|
+
enable: "/api/spending-limit/enable",
|
|
118
|
+
disable: "/api/spending-limit/disable",
|
|
119
|
+
update: "/api/spending-limit/update",
|
|
120
|
+
enableToken: "/api/spending-limit/token/enable",
|
|
121
|
+
disableToken: "/api/spending-limit/token/disable",
|
|
122
|
+
updateToken: "/api/spending-limit/token/update",
|
|
123
|
+
setSpendValidator: "/api/spending-limit/validator/set",
|
|
124
|
+
status: (wallet) => `/api/spending-limit/${e(wallet)}/status`,
|
|
125
|
+
nativeSummaries: (wallet) => `/api/spending-limit/${e(wallet)}/native/summaries`,
|
|
126
|
+
tokenSummaries: (wallet, token) => `/api/spending-limit/${e(wallet)}/token/${e(token)}/summaries`,
|
|
127
|
+
preview: (wallet) => `/api/spending-limit/${e(wallet)}/preview`,
|
|
128
|
+
bucket: (wallet, windowStart) => `/api/spending-limit/${e(wallet)}/bucket/${windowStart}`,
|
|
129
|
+
nativeLimit: (wallet, window) => `/api/spending-limit/${e(wallet)}/native/${window}`,
|
|
130
|
+
nativeStatus: (wallet, window) => `/api/spending-limit/${e(wallet)}/native/${window}/status`,
|
|
131
|
+
tokenLimit: (wallet, token, window) => `/api/spending-limit/${e(wallet)}/token/${e(token)}/${window}`,
|
|
132
|
+
tokenStatus: (wallet, token, window) => `/api/spending-limit/${e(wallet)}/token/${e(token)}/${window}/status`
|
|
133
|
+
},
|
|
134
|
+
allowlist: {
|
|
135
|
+
enable: "/api/allowlist/enable",
|
|
136
|
+
disable: "/api/allowlist/disable",
|
|
137
|
+
contractOnly: "/api/allowlist/contract-only",
|
|
138
|
+
roots: "/api/allowlist/roots",
|
|
139
|
+
sync: "/api/allowlist/sync",
|
|
140
|
+
transferLimit: "/api/allowlist/transfer-limit",
|
|
141
|
+
actorPermissions: "/api/allowlist/actor/permissions",
|
|
142
|
+
getRoots: (wallet) => `/api/allowlist/${e(wallet)}/roots`,
|
|
143
|
+
getActorPermissions: (wallet, actor) => `/api/allowlist/${e(wallet)}/actor/${e(actor)}/permissions`,
|
|
144
|
+
tokenMaxTransfer: (wallet, token) => `/api/allowlist/${e(wallet)}/token/${e(token)}/max-transfer`
|
|
145
|
+
},
|
|
146
|
+
guardians: {
|
|
147
|
+
configure: "/api/guardians/configure"
|
|
148
|
+
},
|
|
149
|
+
recovery: {
|
|
150
|
+
initiate: "/api/recovery/initiate",
|
|
151
|
+
support: "/api/recovery/support",
|
|
152
|
+
execute: "/api/recovery/execute",
|
|
153
|
+
cancel: "/api/recovery/cancel",
|
|
154
|
+
status: (wallet) => `/api/recovery/${e(wallet)}/status`,
|
|
155
|
+
guardians: (wallet) => `/api/recovery/${e(wallet)}/guardians`,
|
|
156
|
+
proposal: (wallet) => `/api/recovery/${e(wallet)}/proposal`,
|
|
157
|
+
proposalState: (wallet) => `/api/recovery/${e(wallet)}/proposal-state`,
|
|
158
|
+
guardianApproved: (wallet, guardian) => `/api/recovery/${e(wallet)}/guardian/${e(guardian)}/approved`,
|
|
159
|
+
isGuardian: (wallet, guardian) => `/api/recovery/${e(wallet)}/guardian/${e(guardian)}`
|
|
160
|
+
},
|
|
161
|
+
recoveryAggregated: {
|
|
162
|
+
initiate: "/api/recovery/aggregated/initiate",
|
|
163
|
+
signature: "/api/recovery/aggregated/signature",
|
|
164
|
+
status: (wallet, proposedOwner) => `/api/recovery/aggregated/status/${e(wallet)}/${e(proposedOwner)}`,
|
|
165
|
+
prepare: "/api/recovery/aggregated/prepare"
|
|
166
|
+
},
|
|
167
|
+
roles: {
|
|
168
|
+
create: "/api/roles/create",
|
|
169
|
+
createBatch: "/api/roles/create-batch",
|
|
170
|
+
grant: "/api/roles/grant",
|
|
171
|
+
revoke: "/api/roles/revoke",
|
|
172
|
+
grantBatch: "/api/roles/grant-batch",
|
|
173
|
+
revokeBatch: "/api/roles/revoke-batch",
|
|
174
|
+
update: "/api/roles/update",
|
|
175
|
+
grantMulti: "/api/roles/grant-multi",
|
|
176
|
+
arm: "/api/roles/arm",
|
|
177
|
+
armed: (wallet) => `/api/roles/${e(wallet)}/armed`,
|
|
178
|
+
targetIndex: (wallet, target) => `/api/roles/${e(wallet)}/target/${e(target)}/index`,
|
|
179
|
+
selectorIndex: (wallet, selector) => `/api/roles/${e(wallet)}/selector/${e(selector)}/index`,
|
|
180
|
+
hasRole: (wallet, account, roleId) => `/api/roles/${e(wallet)}/${e(account)}/has-role/${e(roleId)}`,
|
|
181
|
+
budget: (wallet, roleId) => `/api/roles/${e(wallet)}/${e(roleId)}/budget`,
|
|
182
|
+
setBudget: (wallet, roleId) => `/api/roles/${e(wallet)}/${e(roleId)}/budget`,
|
|
183
|
+
show: (wallet, roleId) => `/api/roles/${e(wallet)}/${e(roleId)}`
|
|
184
|
+
},
|
|
185
|
+
proposals: {
|
|
186
|
+
list: "/api/proposals",
|
|
187
|
+
due: "/api/proposals/due",
|
|
188
|
+
create: "/api/proposals",
|
|
189
|
+
show: (id) => `/api/proposals/${e(id)}`,
|
|
190
|
+
digest: (id) => `/api/proposals/${e(id)}/digest`,
|
|
191
|
+
sign: (id) => `/api/proposals/${e(id)}/sign`,
|
|
192
|
+
finalize: (id) => `/api/proposals/${e(id)}/finalize`,
|
|
193
|
+
cancel: (id) => `/api/proposals/${e(id)}/cancel`
|
|
194
|
+
},
|
|
195
|
+
crosschain: {
|
|
196
|
+
config: (wallet) => `/api/crosschain/${e(wallet)}/config`,
|
|
197
|
+
pendingProposals: (wallet) => `/api/crosschain/${e(wallet)}/pending-proposals`,
|
|
198
|
+
receiverStateFresh: (wallet) => `/api/crosschain/l2-receiver/${e(wallet)}/state-fresh`,
|
|
199
|
+
receiverSkipProposal: (wallet) => `/api/crosschain/l2-receiver/${e(wallet)}/skip-proposal`,
|
|
200
|
+
gasLimit: (chainId) => `/api/crosschain/gas-limits/${chainId}`,
|
|
201
|
+
proposeOwnerUpdate: "/api/crosschain/propose-owner-update",
|
|
202
|
+
executeOwnerUpdate: "/api/crosschain/execute-owner-update",
|
|
203
|
+
resync: "/api/crosschain/resync"
|
|
204
|
+
},
|
|
205
|
+
settlement: {
|
|
206
|
+
tokens: "/api/settlement/tokens",
|
|
207
|
+
quote: "/api/settlement/quote",
|
|
208
|
+
prepare: "/api/settlement/prepare"
|
|
209
|
+
},
|
|
210
|
+
swap: {
|
|
211
|
+
quote: "/api/swap/quote",
|
|
212
|
+
build: "/api/swap/build"
|
|
213
|
+
},
|
|
214
|
+
addressBook: {
|
|
215
|
+
list: "/api/address-book",
|
|
216
|
+
create: "/api/address-book",
|
|
217
|
+
update: (id) => `/api/address-book/${id}`,
|
|
218
|
+
delete: (id) => `/api/address-book/${id}`
|
|
219
|
+
},
|
|
220
|
+
automations: {
|
|
221
|
+
list: "/api/automations",
|
|
222
|
+
create: "/api/automations",
|
|
223
|
+
show: (id) => `/api/automations/${e(id)}`,
|
|
224
|
+
update: (id) => `/api/automations/${e(id)}`,
|
|
225
|
+
delete: (id) => `/api/automations/${e(id)}`,
|
|
226
|
+
pause: (id) => `/api/automations/${e(id)}/pause`,
|
|
227
|
+
resume: (id) => `/api/automations/${e(id)}/resume`,
|
|
228
|
+
trigger: (id) => `/api/automations/${e(id)}/trigger`
|
|
229
|
+
},
|
|
230
|
+
addresses: {
|
|
231
|
+
capabilities: "/api/addresses/capabilities",
|
|
232
|
+
all: (chainId) => `/api/addresses/${chainId}`,
|
|
233
|
+
get: (chainId, name) => `/api/addresses/${chainId}/${e(name)}`
|
|
234
|
+
},
|
|
235
|
+
signature: {
|
|
236
|
+
timing: "/api/signature/timing",
|
|
237
|
+
userOpTemplate: "/api/signature/userop-template",
|
|
238
|
+
eip712Template: "/api/signature/eip712-template",
|
|
239
|
+
validateTimestamp: "/api/signature/validate-timestamp"
|
|
240
|
+
},
|
|
241
|
+
registry: {
|
|
242
|
+
features: "/api/registry/features",
|
|
243
|
+
version: "/api/registry/version",
|
|
244
|
+
isInternal: (featureId) => `/api/registry/feature/${e(featureId)}/internal`,
|
|
245
|
+
canValidatorHandleSelector: (validatorId, selector) => `/api/registry/validator/${e(validatorId)}/selector/${e(selector)}/permitted`,
|
|
246
|
+
coreModuleId: (key) => `/api/registry/core-module-id/${e(key)}`,
|
|
247
|
+
slotAccess: (featureId, slot) => `/api/registry/slot-access/${e(featureId)}/${e(slot)}`,
|
|
248
|
+
supportsMigration: (featureId) => `/api/registry/supports-migration/${e(featureId)}`,
|
|
249
|
+
isFeatureImplementation: (impl) => `/api/registry/is-feature-implementation/${e(impl)}`,
|
|
250
|
+
featureImplementation: (featureId) => `/api/registry/feature-implementation/${e(featureId)}`,
|
|
251
|
+
featureImplementationForWallet: (wallet, featureId) => `/api/registry/feature-implementation-for-wallet/${e(wallet)}/${e(featureId)}`,
|
|
252
|
+
isMandatoryFeature: (featureId) => `/api/registry/is-mandatory/${e(featureId)}`,
|
|
253
|
+
ecdsaModule: "/api/registry/ecdsa-module",
|
|
254
|
+
sessionKeyManager: "/api/registry/session-key-manager",
|
|
255
|
+
spendingLimitManager: "/api/registry/spending-limit-manager",
|
|
256
|
+
permissionsManager: "/api/registry/permissions-manager",
|
|
257
|
+
globallyPaused: (wallet) => `/api/registry/${e(wallet)}/globally-paused`,
|
|
258
|
+
canaryOptIn: (wallet) => `/api/registry/${e(wallet)}/canary-opt-in`,
|
|
259
|
+
capabilitySnapshot: (wallet) => `/api/registry/${e(wallet)}/capability-snapshot`,
|
|
260
|
+
mandatoryInitData: (wallet, featureId) => `/api/registry/${e(wallet)}/mandatory-init-data/${e(featureId)}`,
|
|
261
|
+
setCanaryOptIn: "/api/registry/canary/opt-in",
|
|
262
|
+
setMandatoryInitData: "/api/registry/mandatory-init-data",
|
|
263
|
+
updateCapabilitySnapshot: "/api/registry/capability-snapshot"
|
|
264
|
+
},
|
|
265
|
+
paymaster: {
|
|
266
|
+
banStatus: (account) => `/api/paymaster/ban-status/${e(account)}`,
|
|
267
|
+
refundCredit: (wallet, token) => `/api/paymaster/refund-credit/${e(wallet)}/${e(token)}`,
|
|
268
|
+
claimRefundCredit: "/api/paymaster/refund-credit/claim"
|
|
269
|
+
},
|
|
270
|
+
config: {
|
|
271
|
+
gasLimits: "/api/config/gas-limits"
|
|
272
|
+
},
|
|
273
|
+
relay: {
|
|
274
|
+
estimate: "/api/relay/estimate",
|
|
275
|
+
preview: "/api/relay/preview"
|
|
276
|
+
},
|
|
277
|
+
health: "/api/health"
|
|
278
|
+
};
|
|
279
|
+
function parseQuoteResponse(raw) {
|
|
280
|
+
return {
|
|
281
|
+
gasLimits: {
|
|
282
|
+
verificationGasLimit: BigInt(raw.gasLimits.verificationGasLimit),
|
|
283
|
+
callGasLimit: BigInt(raw.gasLimits.callGasLimit),
|
|
284
|
+
preVerificationGas: BigInt(raw.gasLimits.preVerificationGas),
|
|
285
|
+
maxFeePerGas: BigInt(raw.gasLimits.maxFeePerGas),
|
|
286
|
+
maxPriorityFeePerGas: BigInt(raw.gasLimits.maxPriorityFeePerGas)
|
|
287
|
+
},
|
|
288
|
+
paymasterAndData: raw.paymasterAndData,
|
|
289
|
+
sponsored: raw.sponsored
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// src/userOpBuilder.ts
|
|
294
|
+
var import_viem2 = require("viem");
|
|
295
|
+
|
|
296
|
+
// src/constants.ts
|
|
297
|
+
var import_viem = require("viem");
|
|
298
|
+
var ENTRYPOINT_V07 = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
|
|
299
|
+
var FEATURE_ID_STRINGS = {
|
|
300
|
+
MODULE_ECDSA_VALIDATION: "module.validation.ecdsa",
|
|
301
|
+
MODULE_SESSION_KEY_VALIDATION: "module.validation.session_key",
|
|
302
|
+
FEATURE_SESSION_KEYS: "feature.session_keys",
|
|
303
|
+
FEATURE_SPENDING_LIMIT: "feature.spending_limit",
|
|
304
|
+
FEATURE_APPROVAL_LIMIT: "feature.approval_limit",
|
|
305
|
+
FEATURE_PERMISSIONS: "feature.permissions",
|
|
306
|
+
FEATURE_SOCIAL_RECOVERY: "feature.social_recovery",
|
|
307
|
+
FEATURE_PAYMASTER_GUARD: "feature.paymaster_guard"
|
|
308
|
+
};
|
|
309
|
+
var FEATURE_IDS = {
|
|
310
|
+
MODULE_ECDSA_VALIDATION: (0, import_viem.keccak256)((0, import_viem.toHex)("module.validation.ecdsa")),
|
|
311
|
+
MODULE_SESSION_KEY_VALIDATION: (0, import_viem.keccak256)((0, import_viem.toHex)("module.validation.session_key")),
|
|
312
|
+
FEATURE_SESSION_KEYS: (0, import_viem.keccak256)((0, import_viem.toHex)("feature.session_keys")),
|
|
313
|
+
FEATURE_SPENDING_LIMIT: (0, import_viem.keccak256)((0, import_viem.toHex)("feature.spending_limit")),
|
|
314
|
+
FEATURE_APPROVAL_LIMIT: (0, import_viem.keccak256)((0, import_viem.toHex)("feature.approval_limit")),
|
|
315
|
+
FEATURE_PERMISSIONS: (0, import_viem.keccak256)((0, import_viem.toHex)("feature.permissions")),
|
|
316
|
+
FEATURE_SOCIAL_RECOVERY: (0, import_viem.keccak256)((0, import_viem.toHex)("feature.social_recovery")),
|
|
317
|
+
FEATURE_PAYMASTER_GUARD: (0, import_viem.keccak256)((0, import_viem.toHex)("feature.paymaster_guard"))
|
|
318
|
+
};
|
|
319
|
+
var CONTRACTS = {
|
|
320
|
+
VAULTUM_CORE: "VaultumCore",
|
|
321
|
+
VAULTUM_FACTORY: "VaultumAccountFactory",
|
|
322
|
+
FEATURE_REGISTRY: "FeatureRegistry",
|
|
323
|
+
IMPLEMENTATION_REGISTRY: "ImplementationRegistry",
|
|
324
|
+
SESSION_KEY_MANAGER: "SessionKeyManager",
|
|
325
|
+
SPENDING_LIMIT_MANAGER: "SpendingLimitManager",
|
|
326
|
+
PERMISSIONS_MANAGER: "PermissionsManager",
|
|
327
|
+
SOCIAL_RECOVERY_MANAGER: "SocialRecoveryManager",
|
|
328
|
+
PAYMASTER_GUARD: "PaymasterGuard",
|
|
329
|
+
ECDSA_VALIDATION_MODULE: "ECDSAValidationModuleSingleton",
|
|
330
|
+
SESSION_KEY_VALIDATION_MODULE: "SessionKeyValidationModuleSingleton",
|
|
331
|
+
VAULTUM_SETTLEMENT_PAYMASTER: "VaultumSettlementPaymaster"
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// src/userOpBuilder.ts
|
|
335
|
+
function packGasLimits(verificationGasLimit, callGasLimit) {
|
|
336
|
+
return (0, import_viem2.concat)([
|
|
337
|
+
(0, import_viem2.pad)((0, import_viem2.toHex)(verificationGasLimit), { size: 16 }),
|
|
338
|
+
(0, import_viem2.pad)((0, import_viem2.toHex)(callGasLimit), { size: 16 })
|
|
339
|
+
]);
|
|
340
|
+
}
|
|
341
|
+
function unpackGasLimits(packed) {
|
|
342
|
+
const bytes = (0, import_viem2.toBytes)(packed);
|
|
343
|
+
return {
|
|
344
|
+
verificationGasLimit: BigInt((0, import_viem2.toHex)(bytes.slice(0, 16))),
|
|
345
|
+
callGasLimit: BigInt((0, import_viem2.toHex)(bytes.slice(16, 32)))
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function packGasFees(maxPriorityFeePerGas, maxFeePerGas) {
|
|
349
|
+
return (0, import_viem2.concat)([
|
|
350
|
+
(0, import_viem2.pad)((0, import_viem2.toHex)(maxPriorityFeePerGas), { size: 16 }),
|
|
351
|
+
(0, import_viem2.pad)((0, import_viem2.toHex)(maxFeePerGas), { size: 16 })
|
|
352
|
+
]);
|
|
353
|
+
}
|
|
354
|
+
function unpackGasFees(packed) {
|
|
355
|
+
const bytes = (0, import_viem2.toBytes)(packed);
|
|
356
|
+
return {
|
|
357
|
+
maxPriorityFeePerGas: BigInt((0, import_viem2.toHex)(bytes.slice(0, 16))),
|
|
358
|
+
maxFeePerGas: BigInt((0, import_viem2.toHex)(bytes.slice(16, 32)))
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function getUserOpHash(userOp, entryPoint, chainId) {
|
|
362
|
+
const packed = (0, import_viem2.encodeAbiParameters)(
|
|
363
|
+
(0, import_viem2.parseAbiParameters)("address, uint256, bytes32, bytes32, bytes32, uint256, bytes32, bytes32"),
|
|
364
|
+
[
|
|
365
|
+
userOp.sender,
|
|
366
|
+
userOp.nonce,
|
|
367
|
+
(0, import_viem2.keccak256)(userOp.initCode),
|
|
368
|
+
(0, import_viem2.keccak256)(userOp.callData),
|
|
369
|
+
userOp.accountGasLimits,
|
|
370
|
+
userOp.preVerificationGas,
|
|
371
|
+
userOp.gasFees,
|
|
372
|
+
(0, import_viem2.keccak256)(userOp.paymasterAndData)
|
|
373
|
+
]
|
|
374
|
+
);
|
|
375
|
+
return (0, import_viem2.keccak256)(
|
|
376
|
+
(0, import_viem2.encodeAbiParameters)(
|
|
377
|
+
(0, import_viem2.parseAbiParameters)("bytes32, address, uint256"),
|
|
378
|
+
[(0, import_viem2.keccak256)(packed), entryPoint, BigInt(chainId)]
|
|
379
|
+
)
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
var EXECUTE_ABI = [{
|
|
383
|
+
name: "execute",
|
|
384
|
+
type: "function",
|
|
385
|
+
inputs: [
|
|
386
|
+
{ name: "target", type: "address" },
|
|
387
|
+
{ name: "value", type: "uint256" },
|
|
388
|
+
{ name: "data", type: "bytes" }
|
|
389
|
+
],
|
|
390
|
+
outputs: []
|
|
391
|
+
}];
|
|
392
|
+
var EXECUTE_BATCH_ABI = [{
|
|
393
|
+
name: "executeBatch",
|
|
394
|
+
type: "function",
|
|
395
|
+
inputs: [{
|
|
396
|
+
name: "calls",
|
|
397
|
+
type: "tuple[]",
|
|
398
|
+
components: [
|
|
399
|
+
{ name: "to", type: "address" },
|
|
400
|
+
{ name: "value", type: "uint256" },
|
|
401
|
+
{ name: "data", type: "bytes" }
|
|
402
|
+
]
|
|
403
|
+
}],
|
|
404
|
+
outputs: []
|
|
405
|
+
}];
|
|
406
|
+
var ENABLE_FEATURE_ABI = [{
|
|
407
|
+
name: "enableFeature",
|
|
408
|
+
type: "function",
|
|
409
|
+
inputs: [
|
|
410
|
+
{ name: "featureId", type: "bytes32" },
|
|
411
|
+
{ name: "initData", type: "bytes" }
|
|
412
|
+
],
|
|
413
|
+
outputs: []
|
|
414
|
+
}];
|
|
415
|
+
var DISABLE_FEATURE_ABI = [{
|
|
416
|
+
name: "disableFeature",
|
|
417
|
+
type: "function",
|
|
418
|
+
inputs: [{ name: "featureId", type: "bytes32" }],
|
|
419
|
+
outputs: []
|
|
420
|
+
}];
|
|
421
|
+
var UserOpBuilder = class {
|
|
422
|
+
account;
|
|
423
|
+
chainId;
|
|
424
|
+
entryPoint;
|
|
425
|
+
constructor(config) {
|
|
426
|
+
this.account = config.account;
|
|
427
|
+
this.chainId = config.chainId;
|
|
428
|
+
this.entryPoint = config.entryPoint ?? ENTRYPOINT_V07;
|
|
429
|
+
}
|
|
430
|
+
create(callData, nonce) {
|
|
431
|
+
return {
|
|
432
|
+
sender: this.account,
|
|
433
|
+
nonce,
|
|
434
|
+
initCode: "0x",
|
|
435
|
+
callData,
|
|
436
|
+
accountGasLimits: "0x" + "0".repeat(64),
|
|
437
|
+
preVerificationGas: 0n,
|
|
438
|
+
gasFees: "0x" + "0".repeat(64),
|
|
439
|
+
paymasterAndData: "0x",
|
|
440
|
+
signature: "0x"
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
encodeExecute(call) {
|
|
444
|
+
return (0, import_viem2.encodeFunctionData)({
|
|
445
|
+
abi: EXECUTE_ABI,
|
|
446
|
+
functionName: "execute",
|
|
447
|
+
args: [call.target, call.value, call.data]
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
encodeExecuteBatch(calls) {
|
|
451
|
+
return (0, import_viem2.encodeFunctionData)({
|
|
452
|
+
abi: EXECUTE_BATCH_ABI,
|
|
453
|
+
functionName: "executeBatch",
|
|
454
|
+
args: [calls.map((c) => ({ to: c.target, value: c.value, data: c.data }))]
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
encodeEnableFeature(featureId, initData) {
|
|
458
|
+
return (0, import_viem2.encodeFunctionData)({
|
|
459
|
+
abi: ENABLE_FEATURE_ABI,
|
|
460
|
+
functionName: "enableFeature",
|
|
461
|
+
args: [featureId, initData]
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
encodeDisableFeature(featureId) {
|
|
465
|
+
return (0, import_viem2.encodeFunctionData)({
|
|
466
|
+
abi: DISABLE_FEATURE_ABI,
|
|
467
|
+
functionName: "disableFeature",
|
|
468
|
+
args: [featureId]
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
buildExecute(call, nonce) {
|
|
472
|
+
return this.create(this.encodeExecute(call), nonce);
|
|
473
|
+
}
|
|
474
|
+
buildExecuteBatch(calls, nonce) {
|
|
475
|
+
return this.create(this.encodeExecuteBatch(calls), nonce);
|
|
476
|
+
}
|
|
477
|
+
buildEnableFeature(featureId, initData, nonce) {
|
|
478
|
+
return this.create(this.encodeEnableFeature(featureId, initData), nonce);
|
|
479
|
+
}
|
|
480
|
+
buildDisableFeature(featureId, nonce) {
|
|
481
|
+
return this.create(this.encodeDisableFeature(featureId), nonce);
|
|
482
|
+
}
|
|
483
|
+
withGas(userOp, gas) {
|
|
484
|
+
const currentLimits = unpackGasLimits(userOp.accountGasLimits);
|
|
485
|
+
const currentFees = unpackGasFees(userOp.gasFees);
|
|
486
|
+
return {
|
|
487
|
+
...userOp,
|
|
488
|
+
accountGasLimits: packGasLimits(
|
|
489
|
+
gas.verificationGasLimit ?? currentLimits.verificationGasLimit,
|
|
490
|
+
gas.callGasLimit ?? currentLimits.callGasLimit
|
|
491
|
+
),
|
|
492
|
+
preVerificationGas: gas.preVerificationGas ?? userOp.preVerificationGas,
|
|
493
|
+
gasFees: packGasFees(
|
|
494
|
+
gas.maxPriorityFeePerGas ?? currentFees.maxPriorityFeePerGas,
|
|
495
|
+
gas.maxFeePerGas ?? currentFees.maxFeePerGas
|
|
496
|
+
)
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
withPaymaster(userOp, paymasterAndData) {
|
|
500
|
+
return { ...userOp, paymasterAndData };
|
|
501
|
+
}
|
|
502
|
+
withSignature(userOp, signature) {
|
|
503
|
+
return { ...userOp, signature };
|
|
504
|
+
}
|
|
505
|
+
getHash(userOp) {
|
|
506
|
+
return getUserOpHash(userOp, this.entryPoint, this.chainId);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
function createUserOpBuilder(config) {
|
|
510
|
+
return new UserOpBuilder(config);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// src/client.ts
|
|
514
|
+
var DEFAULT_RETRY = {
|
|
515
|
+
maxAttempts: 3,
|
|
516
|
+
baseDelayMs: 200,
|
|
517
|
+
maxDelayMs: 5e3
|
|
518
|
+
};
|
|
519
|
+
function computeBackoff(attempt, base, max) {
|
|
520
|
+
const delay = base * Math.pow(2, attempt) + Math.random() * 100;
|
|
521
|
+
return Math.min(delay, max);
|
|
522
|
+
}
|
|
523
|
+
var RETRYABLE_CODES = /* @__PURE__ */ new Set([
|
|
524
|
+
"RATE_LIMITED",
|
|
525
|
+
"BUNDLER_ERROR",
|
|
526
|
+
"TIMEOUT"
|
|
527
|
+
]);
|
|
528
|
+
var RETRYABLE_STATUS = /* @__PURE__ */ new Set([408, 425, 429, 500, 502, 503, 504]);
|
|
529
|
+
var VaultumError = class extends Error {
|
|
530
|
+
constructor(message, code, status, details, retryable = false) {
|
|
531
|
+
super(message);
|
|
532
|
+
this.code = code;
|
|
533
|
+
this.status = status;
|
|
534
|
+
this.details = details;
|
|
535
|
+
this.retryable = retryable;
|
|
536
|
+
this.name = "VaultumError";
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
function serializeBody(body) {
|
|
540
|
+
return JSON.stringify(
|
|
541
|
+
body,
|
|
542
|
+
(_, value) => typeof value === "bigint" ? `0x${value.toString(16)}` : value
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
function nowUnix() {
|
|
546
|
+
return Math.floor(Date.now() / 1e3);
|
|
547
|
+
}
|
|
548
|
+
function fnv1a64Hex(input) {
|
|
549
|
+
let hash = 0xcbf29ce484222325n;
|
|
550
|
+
const prime = 0x100000001b3n;
|
|
551
|
+
for (let i = 0; i < input.length; i++) {
|
|
552
|
+
hash ^= BigInt(input.charCodeAt(i));
|
|
553
|
+
hash = hash * prime & 0xffffffffffffffffn;
|
|
554
|
+
}
|
|
555
|
+
return hash.toString(16).padStart(16, "0");
|
|
556
|
+
}
|
|
557
|
+
function autoIdempotencyKey(body) {
|
|
558
|
+
return `v1_${fnv1a64Hex(serializeBody(body))}`;
|
|
559
|
+
}
|
|
560
|
+
function bigintToHex(value) {
|
|
561
|
+
return `0x${value.toString(16)}`;
|
|
562
|
+
}
|
|
563
|
+
function isRecord(value) {
|
|
564
|
+
return typeof value === "object" && value !== null;
|
|
565
|
+
}
|
|
566
|
+
function isUserOperation(value) {
|
|
567
|
+
if (!isRecord(value)) return false;
|
|
568
|
+
return typeof value.sender === "string" && typeof value.nonce === "string" && typeof value.initCode === "string" && typeof value.callData === "string" && typeof value.callGasLimit === "string" && typeof value.verificationGasLimit === "string" && typeof value.preVerificationGas === "string" && typeof value.maxFeePerGas === "string" && typeof value.maxPriorityFeePerGas === "string" && typeof value.paymasterAndData === "string" && typeof value.signature === "string";
|
|
569
|
+
}
|
|
570
|
+
function isPackedUserOp(value) {
|
|
571
|
+
if (!isRecord(value)) return false;
|
|
572
|
+
return typeof value.sender === "string" && typeof value.nonce === "bigint" && typeof value.initCode === "string" && typeof value.callData === "string" && typeof value.accountGasLimits === "string" && typeof value.preVerificationGas === "bigint" && typeof value.gasFees === "string" && typeof value.paymasterAndData === "string" && typeof value.signature === "string";
|
|
573
|
+
}
|
|
574
|
+
function normalizeUserOperation(userOp) {
|
|
575
|
+
return {
|
|
576
|
+
sender: userOp.sender.toLowerCase(),
|
|
577
|
+
nonce: userOp.nonce.toLowerCase(),
|
|
578
|
+
initCode: userOp.initCode.toLowerCase(),
|
|
579
|
+
callData: userOp.callData.toLowerCase(),
|
|
580
|
+
callGasLimit: userOp.callGasLimit.toLowerCase(),
|
|
581
|
+
verificationGasLimit: userOp.verificationGasLimit.toLowerCase(),
|
|
582
|
+
preVerificationGas: userOp.preVerificationGas.toLowerCase(),
|
|
583
|
+
maxFeePerGas: userOp.maxFeePerGas.toLowerCase(),
|
|
584
|
+
maxPriorityFeePerGas: userOp.maxPriorityFeePerGas.toLowerCase(),
|
|
585
|
+
paymasterAndData: userOp.paymasterAndData.toLowerCase(),
|
|
586
|
+
signature: userOp.signature.toLowerCase()
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
function packedToUserOperation(userOp) {
|
|
590
|
+
const limits = unpackGasLimits(userOp.accountGasLimits);
|
|
591
|
+
const fees = unpackGasFees(userOp.gasFees);
|
|
592
|
+
return normalizeUserOperation({
|
|
593
|
+
sender: userOp.sender,
|
|
594
|
+
nonce: bigintToHex(userOp.nonce),
|
|
595
|
+
initCode: userOp.initCode,
|
|
596
|
+
callData: userOp.callData,
|
|
597
|
+
callGasLimit: bigintToHex(limits.callGasLimit),
|
|
598
|
+
verificationGasLimit: bigintToHex(limits.verificationGasLimit),
|
|
599
|
+
preVerificationGas: bigintToHex(userOp.preVerificationGas),
|
|
600
|
+
maxFeePerGas: bigintToHex(fees.maxFeePerGas),
|
|
601
|
+
maxPriorityFeePerGas: bigintToHex(fees.maxPriorityFeePerGas),
|
|
602
|
+
paymasterAndData: userOp.paymasterAndData,
|
|
603
|
+
signature: userOp.signature
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
607
|
+
function asString(value) {
|
|
608
|
+
return typeof value === "string" ? value : null;
|
|
609
|
+
}
|
|
610
|
+
function asNumber(value) {
|
|
611
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
612
|
+
if (typeof value === "string" && value !== "" && /^[0-9]+$/.test(value)) {
|
|
613
|
+
const n = Number(value);
|
|
614
|
+
return Number.isFinite(n) ? n : null;
|
|
615
|
+
}
|
|
616
|
+
return null;
|
|
617
|
+
}
|
|
618
|
+
function asAddress(value) {
|
|
619
|
+
const s = asString(value);
|
|
620
|
+
if (!s) return null;
|
|
621
|
+
const v = s.toLowerCase();
|
|
622
|
+
return /^0x[a-f0-9]{40}$/.test(v) ? v : null;
|
|
623
|
+
}
|
|
624
|
+
function asHex(value) {
|
|
625
|
+
const s = asString(value);
|
|
626
|
+
if (!s) return null;
|
|
627
|
+
const v = s.toLowerCase();
|
|
628
|
+
return /^0x[a-f0-9]*$/.test(v) ? v : null;
|
|
629
|
+
}
|
|
630
|
+
function isAutomationType(value) {
|
|
631
|
+
return value === "recurring_payment" || value === "stop_loss" || value === "dca" || value === "rebalance";
|
|
632
|
+
}
|
|
633
|
+
function isAutomationStatus(value) {
|
|
634
|
+
return value === "active" || value === "paused" || value === "completed" || value === "failed";
|
|
635
|
+
}
|
|
636
|
+
function isAutomationExecutionStatus(value) {
|
|
637
|
+
return value === "pending" || value === "success" || value === "failed";
|
|
638
|
+
}
|
|
639
|
+
function mapAutomation(raw) {
|
|
640
|
+
const obj = isRecord(raw) ? raw : {};
|
|
641
|
+
return {
|
|
642
|
+
id: asString(obj.id) ?? "",
|
|
643
|
+
wallet: asAddress(obj.wallet) ?? ZERO_ADDRESS,
|
|
644
|
+
type: isAutomationType(obj.type) ? obj.type : "recurring_payment",
|
|
645
|
+
status: isAutomationStatus(obj.status) ? obj.status : "active",
|
|
646
|
+
sessionKey: asAddress(obj.session_key),
|
|
647
|
+
config: isRecord(obj.config) ? obj.config : {},
|
|
648
|
+
executionCount: asNumber(obj.execution_count) ?? 0,
|
|
649
|
+
failureCount: asNumber(obj.failure_count) ?? 0,
|
|
650
|
+
lastExecutedAt: asString(obj.last_executed_at),
|
|
651
|
+
nextExecutionAt: asString(obj.next_execution_at),
|
|
652
|
+
lastTxHash: asHex(obj.last_tx_hash),
|
|
653
|
+
lastError: asString(obj.last_error),
|
|
654
|
+
createdAt: asString(obj.created_at) ?? "",
|
|
655
|
+
updatedAt: asString(obj.updated_at) ?? ""
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
function mapAutomationExecution(raw) {
|
|
659
|
+
const obj = isRecord(raw) ? raw : {};
|
|
660
|
+
return {
|
|
661
|
+
id: asString(obj.id) ?? "",
|
|
662
|
+
status: isAutomationExecutionStatus(obj.status) ? obj.status : "pending",
|
|
663
|
+
txHash: asHex(obj.tx_hash),
|
|
664
|
+
error: asString(obj.error),
|
|
665
|
+
gasUsed: asString(obj.gas_used) ?? (typeof obj.gas_used === "number" ? String(obj.gas_used) : null),
|
|
666
|
+
createdAt: asString(obj.created_at) ?? ""
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
var VaultumClient = class {
|
|
670
|
+
baseURL;
|
|
671
|
+
headers;
|
|
672
|
+
timeout;
|
|
673
|
+
chain;
|
|
674
|
+
retry;
|
|
675
|
+
onRequest;
|
|
676
|
+
onResponse;
|
|
677
|
+
constructor(config) {
|
|
678
|
+
this.baseURL = normalizeURL(config.baseURL, Boolean(config.apiKey || config.bearer));
|
|
679
|
+
this.timeout = config.timeout ?? 3e4;
|
|
680
|
+
this.chain = config.chain;
|
|
681
|
+
this.headers = {
|
|
682
|
+
"Content-Type": "application/json",
|
|
683
|
+
Accept: "application/json"
|
|
684
|
+
};
|
|
685
|
+
if (config.apiKey) this.headers["X-API-Key"] = config.apiKey;
|
|
686
|
+
if (config.bearer) this.headers["Authorization"] = `Bearer ${config.bearer}`;
|
|
687
|
+
this.retry = config.retry === false ? null : { ...DEFAULT_RETRY, ...typeof config.retry === "object" ? config.retry : {} };
|
|
688
|
+
this.onRequest = config.onRequest;
|
|
689
|
+
this.onResponse = config.onResponse;
|
|
690
|
+
}
|
|
691
|
+
setBearer(token) {
|
|
692
|
+
const t = typeof token === "string" ? token.trim() : "";
|
|
693
|
+
if (t === "") {
|
|
694
|
+
delete this.headers["Authorization"];
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
this.headers["Authorization"] = `Bearer ${t}`;
|
|
698
|
+
}
|
|
699
|
+
setApiKey(key) {
|
|
700
|
+
const t = typeof key === "string" ? key.trim() : "";
|
|
701
|
+
if (t === "") {
|
|
702
|
+
delete this.headers["X-API-Key"];
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
this.headers["X-API-Key"] = t;
|
|
706
|
+
}
|
|
707
|
+
setDefaultChain(chain) {
|
|
708
|
+
const t = typeof chain === "string" ? chain.trim() : "";
|
|
709
|
+
this.chain = t === "" ? void 0 : t;
|
|
710
|
+
}
|
|
711
|
+
async request(method, path, body, options) {
|
|
712
|
+
const maxAttempts = options?.retry !== false && this.retry ? this.retry.maxAttempts : 1;
|
|
713
|
+
let lastError;
|
|
714
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
715
|
+
const controller = new AbortController();
|
|
716
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
717
|
+
const signal = options?.signal ? anySignal([options.signal, controller.signal]) : controller.signal;
|
|
718
|
+
try {
|
|
719
|
+
let ctx = {
|
|
720
|
+
method,
|
|
721
|
+
path,
|
|
722
|
+
headers: { ...this.headers, ...options?.headers || {} },
|
|
723
|
+
body
|
|
724
|
+
};
|
|
725
|
+
if (options?.idempotencyKey) ctx.headers["Idempotency-Key"] = options.idempotencyKey;
|
|
726
|
+
if (typeof options?.timestamp === "number") ctx.headers["X-Vaultum-Timestamp"] = String(options.timestamp);
|
|
727
|
+
if (this.onRequest) ctx = await this.onRequest(ctx);
|
|
728
|
+
const res = await fetch(`${this.baseURL}${ctx.path}`, {
|
|
729
|
+
method: ctx.method,
|
|
730
|
+
headers: ctx.headers,
|
|
731
|
+
body: ctx.body ? serializeBody(ctx.body) : void 0,
|
|
732
|
+
signal
|
|
733
|
+
});
|
|
734
|
+
clearTimeout(timer);
|
|
735
|
+
const data = await res.json().catch(() => ({}));
|
|
736
|
+
if (!res.ok) {
|
|
737
|
+
const errBody = data;
|
|
738
|
+
const code = mapErrorCode(errBody.code ?? errBody.error, res.status);
|
|
739
|
+
throw new VaultumError(
|
|
740
|
+
errBody.message ?? errBody.error ?? `Request failed: ${res.status}`,
|
|
741
|
+
code,
|
|
742
|
+
res.status,
|
|
743
|
+
errBody.details,
|
|
744
|
+
RETRYABLE_CODES.has(code) || RETRYABLE_STATUS.has(res.status)
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
let responseCtx = { status: res.status, headers: res.headers, data };
|
|
748
|
+
if (this.onResponse) responseCtx = await this.onResponse(responseCtx);
|
|
749
|
+
return responseCtx.data;
|
|
750
|
+
} catch (err) {
|
|
751
|
+
clearTimeout(timer);
|
|
752
|
+
if (err instanceof VaultumError) {
|
|
753
|
+
lastError = err;
|
|
754
|
+
if (err.retryable && attempt < maxAttempts - 1 && this.retry) {
|
|
755
|
+
await sleep(computeBackoff(attempt, this.retry.baseDelayMs, this.retry.maxDelayMs), options?.signal);
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
throw err;
|
|
759
|
+
}
|
|
760
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
761
|
+
throw new VaultumError("Request aborted", "TIMEOUT", void 0, void 0, true);
|
|
762
|
+
}
|
|
763
|
+
const networkError = new VaultumError(err instanceof Error ? err.message : "Unknown error", void 0, void 0, void 0, true);
|
|
764
|
+
lastError = networkError;
|
|
765
|
+
if (attempt < maxAttempts - 1 && this.retry) {
|
|
766
|
+
await sleep(computeBackoff(attempt, this.retry.baseDelayMs, this.retry.maxDelayMs), options?.signal);
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
throw networkError;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
throw lastError ?? new VaultumError("Request failed after retries");
|
|
773
|
+
}
|
|
774
|
+
async submit(userOp, options) {
|
|
775
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
776
|
+
const normalized = isPackedUserOp(userOp) ? packedToUserOperation(userOp) : normalizeUserOperation(userOp);
|
|
777
|
+
const body = { chain, userOp: normalized };
|
|
778
|
+
const idempotencyKey = options?.idempotencyKey ?? autoIdempotencyKey(body);
|
|
779
|
+
const timestamp = options?.timestamp ?? nowUnix();
|
|
780
|
+
return this.request("POST", API.op.submit, body, {
|
|
781
|
+
idempotencyKey,
|
|
782
|
+
timestamp,
|
|
783
|
+
signal: options?.signal
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
async simulate(userOp, options) {
|
|
787
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
788
|
+
const normalized = isPackedUserOp(userOp) ? packedToUserOperation(userOp) : normalizeUserOperation(userOp);
|
|
789
|
+
return this.request("POST", API.op.simulate, { chain, userOp: normalized }, { signal: options?.signal });
|
|
790
|
+
}
|
|
791
|
+
async authRegister(params) {
|
|
792
|
+
const r = await this.request("POST", API.auth.register, params, { signal: params.signal });
|
|
793
|
+
this.setBearer(r.token);
|
|
794
|
+
return r;
|
|
795
|
+
}
|
|
796
|
+
async authLogin(params) {
|
|
797
|
+
const r = await this.request("POST", API.auth.login, params, { signal: params.signal });
|
|
798
|
+
this.setBearer(r.token);
|
|
799
|
+
return r;
|
|
800
|
+
}
|
|
801
|
+
async authMe(signal) {
|
|
802
|
+
return this.request("GET", API.auth.me, void 0, { signal });
|
|
803
|
+
}
|
|
804
|
+
async authLogout(signal) {
|
|
805
|
+
const r = await this.request("POST", API.auth.logout, void 0, { signal });
|
|
806
|
+
this.setBearer(null);
|
|
807
|
+
return r;
|
|
808
|
+
}
|
|
809
|
+
async authLogoutAll(signal) {
|
|
810
|
+
const r = await this.request("POST", API.auth.logoutAll, void 0, { signal });
|
|
811
|
+
this.setBearer(null);
|
|
812
|
+
return r;
|
|
813
|
+
}
|
|
814
|
+
async walletChallenge(params) {
|
|
815
|
+
return this.request("POST", API.auth.walletChallenge, {
|
|
816
|
+
chain: params.chain,
|
|
817
|
+
address: params.address.toLowerCase()
|
|
818
|
+
}, { signal: params.signal });
|
|
819
|
+
}
|
|
820
|
+
async walletVerify(params) {
|
|
821
|
+
const r = await this.request("POST", API.auth.walletVerify, {
|
|
822
|
+
chain: params.chain,
|
|
823
|
+
address: params.address.toLowerCase(),
|
|
824
|
+
signature: params.signature.toLowerCase()
|
|
825
|
+
}, { signal: params.signal });
|
|
826
|
+
this.setBearer(r.token);
|
|
827
|
+
return r;
|
|
828
|
+
}
|
|
829
|
+
async walletRegisterChallenge(params) {
|
|
830
|
+
return this.request("POST", API.auth.walletRegisterChallenge, {
|
|
831
|
+
chain: params.chain,
|
|
832
|
+
address: params.address.toLowerCase()
|
|
833
|
+
}, { signal: params.signal });
|
|
834
|
+
}
|
|
835
|
+
async walletRegisterVerify(params) {
|
|
836
|
+
const r = await this.request("POST", API.auth.walletRegisterVerify, {
|
|
837
|
+
chain: params.chain,
|
|
838
|
+
address: params.address.toLowerCase(),
|
|
839
|
+
signature: params.signature.toLowerCase(),
|
|
840
|
+
name: params.name,
|
|
841
|
+
email: params.email
|
|
842
|
+
}, { signal: params.signal });
|
|
843
|
+
this.setBearer(r.token);
|
|
844
|
+
return r;
|
|
845
|
+
}
|
|
846
|
+
async walletLinkChallenge(params) {
|
|
847
|
+
return this.request("POST", API.auth.walletLinkChallenge, {
|
|
848
|
+
chain: params.chain,
|
|
849
|
+
address: params.address.toLowerCase()
|
|
850
|
+
}, { signal: params.signal });
|
|
851
|
+
}
|
|
852
|
+
async walletLinkVerify(params) {
|
|
853
|
+
const raw = await this.request(
|
|
854
|
+
"POST",
|
|
855
|
+
API.auth.walletLinkVerify,
|
|
856
|
+
{
|
|
857
|
+
chain: params.chain,
|
|
858
|
+
address: params.address.toLowerCase(),
|
|
859
|
+
signature: params.signature.toLowerCase()
|
|
860
|
+
},
|
|
861
|
+
{ signal: params.signal }
|
|
862
|
+
);
|
|
863
|
+
return {
|
|
864
|
+
wallets: (raw.wallets || []).map((w) => ({
|
|
865
|
+
address: w.address.toLowerCase(),
|
|
866
|
+
chainId: w.chain_id,
|
|
867
|
+
type: w.type
|
|
868
|
+
}))
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
async wallets(signal) {
|
|
872
|
+
const raw = await this.request(
|
|
873
|
+
"GET",
|
|
874
|
+
API.auth.wallets,
|
|
875
|
+
void 0,
|
|
876
|
+
{ signal }
|
|
877
|
+
);
|
|
878
|
+
return {
|
|
879
|
+
wallets: (raw.wallets || []).map((w) => ({
|
|
880
|
+
address: w.address.toLowerCase(),
|
|
881
|
+
chainId: w.chain_id,
|
|
882
|
+
type: w.type
|
|
883
|
+
}))
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
async getOperation(id, signal) {
|
|
887
|
+
return this.request("GET", API.op.status(id), void 0, { signal });
|
|
888
|
+
}
|
|
889
|
+
async waitForOperation(id, options) {
|
|
890
|
+
const timeout = options?.timeout ?? 12e4;
|
|
891
|
+
const interval = options?.interval ?? 2e3;
|
|
892
|
+
const start = Date.now();
|
|
893
|
+
while (Date.now() - start < timeout) {
|
|
894
|
+
if (options?.signal?.aborted) {
|
|
895
|
+
throw new VaultumError("Operation cancelled", "TIMEOUT");
|
|
896
|
+
}
|
|
897
|
+
const result = await this.getOperation(id, options?.signal);
|
|
898
|
+
options?.onProgress?.(result);
|
|
899
|
+
if (result.state === "success" || result.state === "failed") return result;
|
|
900
|
+
await sleep(interval, options?.signal);
|
|
901
|
+
}
|
|
902
|
+
throw new VaultumError("Operation timeout", "TIMEOUT");
|
|
903
|
+
}
|
|
904
|
+
async getCapabilities(signal) {
|
|
905
|
+
return this.request("GET", API.op.capabilities, void 0, { signal });
|
|
906
|
+
}
|
|
907
|
+
async createAccount(options) {
|
|
908
|
+
return this.request("POST", API.accounts.create, {
|
|
909
|
+
sessionKeyAddress: options.sessionKeyAddress.toLowerCase(),
|
|
910
|
+
type: "create",
|
|
911
|
+
chain: options.chain ?? this.chain,
|
|
912
|
+
salt: options.salt,
|
|
913
|
+
owners: options.owners?.map((a) => a.toLowerCase()),
|
|
914
|
+
threshold: options.threshold,
|
|
915
|
+
securityCouncil: options.securityCouncil?.toLowerCase(),
|
|
916
|
+
modules: options.modules?.map((a) => a.toLowerCase()),
|
|
917
|
+
featureInits: options.featureInits?.map((f) => ({
|
|
918
|
+
featureId: f.featureId.toLowerCase(),
|
|
919
|
+
initData: f.initData?.toLowerCase()
|
|
920
|
+
}))
|
|
921
|
+
}, { signal: options.signal });
|
|
922
|
+
}
|
|
923
|
+
async verifyAccount(address, options) {
|
|
924
|
+
return this.request("POST", API.accounts.verify, {
|
|
925
|
+
address: address.toLowerCase(),
|
|
926
|
+
chain: options?.chain ?? this.chain
|
|
927
|
+
}, { signal: options?.signal });
|
|
928
|
+
}
|
|
929
|
+
async getVaultState(wallet, options) {
|
|
930
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
931
|
+
return this.request("GET", `${API.vault.state(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
932
|
+
}
|
|
933
|
+
async getNonce(wallet, options) {
|
|
934
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
935
|
+
const result = await this.request(
|
|
936
|
+
"GET",
|
|
937
|
+
`${API.vault.opNonce(wallet)}?chain=${chain}`,
|
|
938
|
+
void 0,
|
|
939
|
+
{ signal: options?.signal }
|
|
940
|
+
);
|
|
941
|
+
return result.nonce;
|
|
942
|
+
}
|
|
943
|
+
async getBanStatus(account, options) {
|
|
944
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
945
|
+
return this.request("GET", `${API.paymaster.banStatus(account)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
946
|
+
}
|
|
947
|
+
async getRefundCredit(wallet, token, options) {
|
|
948
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
949
|
+
return this.request("GET", `${API.paymaster.refundCredit(wallet, token)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
950
|
+
}
|
|
951
|
+
async buildClaimRefundCredit(params) {
|
|
952
|
+
return this.request("POST", API.paymaster.claimRefundCredit, {
|
|
953
|
+
wallet: params.wallet.toLowerCase(),
|
|
954
|
+
token: params.token.toLowerCase(),
|
|
955
|
+
chain: params.chain
|
|
956
|
+
}, { signal: params.signal });
|
|
957
|
+
}
|
|
958
|
+
async getSessionKeyInfo(wallet, key, options) {
|
|
959
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
960
|
+
return this.request("GET", `${API.sessionKey.info(wallet, key)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
961
|
+
}
|
|
962
|
+
async getSpendingLimitStatus(wallet, options) {
|
|
963
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
964
|
+
return this.request("GET", `${API.spendingLimit.status(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
965
|
+
}
|
|
966
|
+
async getAllowlistStatus(wallet, options) {
|
|
967
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
968
|
+
return this.request("GET", `${API.feature.allowlist(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
969
|
+
}
|
|
970
|
+
async getGuardians(wallet, options) {
|
|
971
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
972
|
+
return this.request("GET", `${API.feature.guardians(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
973
|
+
}
|
|
974
|
+
async getRecoveryStatus(wallet, options) {
|
|
975
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
976
|
+
return this.request("GET", `${API.feature.recovery(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
977
|
+
}
|
|
978
|
+
async getRecoveryStatusHint(account, options) {
|
|
979
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
980
|
+
return this.request("GET", `${API.recovery.status(account)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
981
|
+
}
|
|
982
|
+
async initiateAggregatedRecovery(params) {
|
|
983
|
+
return this.request("POST", API.recoveryAggregated.initiate, {
|
|
984
|
+
wallet: params.wallet.toLowerCase(),
|
|
985
|
+
proposedOwner: params.proposedOwner.toLowerCase(),
|
|
986
|
+
chain: params.chain,
|
|
987
|
+
validUntil: params.validUntil
|
|
988
|
+
}, { signal: params.signal });
|
|
989
|
+
}
|
|
990
|
+
async submitRecoverySignature(params) {
|
|
991
|
+
return this.request("POST", API.recoveryAggregated.signature, {
|
|
992
|
+
wallet: params.wallet.toLowerCase(),
|
|
993
|
+
proposedOwner: params.proposedOwner.toLowerCase(),
|
|
994
|
+
guardian: params.guardian.toLowerCase(),
|
|
995
|
+
signature: params.signature,
|
|
996
|
+
chain: params.chain
|
|
997
|
+
}, { signal: params.signal });
|
|
998
|
+
}
|
|
999
|
+
async getAggregatedRecoveryStatus(wallet, proposedOwner, options) {
|
|
1000
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1001
|
+
return this.request("GET", `${API.recoveryAggregated.status(wallet, proposedOwner)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1002
|
+
}
|
|
1003
|
+
async prepareAggregatedRecovery(params) {
|
|
1004
|
+
return this.request("POST", API.recoveryAggregated.prepare, {
|
|
1005
|
+
wallet: params.wallet.toLowerCase(),
|
|
1006
|
+
proposedOwner: params.proposedOwner.toLowerCase(),
|
|
1007
|
+
chain: params.chain
|
|
1008
|
+
}, { signal: params.signal });
|
|
1009
|
+
}
|
|
1010
|
+
async getProposals(options) {
|
|
1011
|
+
const params = new URLSearchParams();
|
|
1012
|
+
if (options?.wallet) params.set("wallet", options.wallet.toLowerCase());
|
|
1013
|
+
if (options?.status) params.set("status", options.status);
|
|
1014
|
+
if (typeof options?.limit === "number") params.set("limit", String(options.limit));
|
|
1015
|
+
if (options?.cursor) params.set("cursor", options.cursor);
|
|
1016
|
+
const query = params.toString();
|
|
1017
|
+
return this.request("GET", `${API.proposals.list}${query ? `?${query}` : ""}`, void 0, { signal: options?.signal });
|
|
1018
|
+
}
|
|
1019
|
+
async getDueProposals(options) {
|
|
1020
|
+
const params = new URLSearchParams();
|
|
1021
|
+
if (typeof options?.limit === "number") params.set("limit", String(options.limit));
|
|
1022
|
+
if (options?.cursor) params.set("cursor", options.cursor);
|
|
1023
|
+
const query = params.toString();
|
|
1024
|
+
return this.request("GET", `${API.proposals.due}${query ? `?${query}` : ""}`, void 0, { signal: options?.signal });
|
|
1025
|
+
}
|
|
1026
|
+
async createProposal(params) {
|
|
1027
|
+
return this.request("POST", API.proposals.create, {
|
|
1028
|
+
wallet: params.wallet.toLowerCase(),
|
|
1029
|
+
chain: params.chain,
|
|
1030
|
+
calls: params.calls,
|
|
1031
|
+
executeAfter: params.executeAfter,
|
|
1032
|
+
executeBefore: params.executeBefore
|
|
1033
|
+
}, { signal: params.signal });
|
|
1034
|
+
}
|
|
1035
|
+
async getProposal(id, signal) {
|
|
1036
|
+
return this.request("GET", API.proposals.show(id), void 0, { signal });
|
|
1037
|
+
}
|
|
1038
|
+
async getProposalDigest(id, signal) {
|
|
1039
|
+
return this.request("GET", API.proposals.digest(id), void 0, { signal });
|
|
1040
|
+
}
|
|
1041
|
+
async signProposal(params) {
|
|
1042
|
+
return this.request("POST", API.proposals.sign(params.id), {
|
|
1043
|
+
signer: params.signer.toLowerCase(),
|
|
1044
|
+
signature: params.signature
|
|
1045
|
+
}, { signal: params.signal });
|
|
1046
|
+
}
|
|
1047
|
+
async finalizeProposal(id, signal) {
|
|
1048
|
+
return this.request("POST", API.proposals.finalize(id), void 0, { signal });
|
|
1049
|
+
}
|
|
1050
|
+
async cancelProposal(id, signal) {
|
|
1051
|
+
return this.request("POST", API.proposals.cancel(id), void 0, { signal });
|
|
1052
|
+
}
|
|
1053
|
+
async getSettlementTokens(options) {
|
|
1054
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1055
|
+
return this.request("GET", `${API.settlement.tokens}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1056
|
+
}
|
|
1057
|
+
async getSettlementQuote(params) {
|
|
1058
|
+
return this.request("POST", API.settlement.quote, {
|
|
1059
|
+
chain: params.chain,
|
|
1060
|
+
sender: params.sender.toLowerCase(),
|
|
1061
|
+
token: params.token,
|
|
1062
|
+
maxGasCost: params.maxGasCost,
|
|
1063
|
+
maxFeePerGas: params.maxFeePerGas
|
|
1064
|
+
}, { signal: params.signal });
|
|
1065
|
+
}
|
|
1066
|
+
async prepareSettlement(params) {
|
|
1067
|
+
const userOp = isPackedUserOp(params.userOp) ? packedToUserOperation(params.userOp) : isUserOperation(params.userOp) ? normalizeUserOperation(params.userOp) : params.userOp;
|
|
1068
|
+
const body = {
|
|
1069
|
+
chain: params.chain,
|
|
1070
|
+
token: params.token,
|
|
1071
|
+
userOp
|
|
1072
|
+
};
|
|
1073
|
+
const idempotencyKey = params.idempotencyKey ?? autoIdempotencyKey(body);
|
|
1074
|
+
const timestamp = params.timestamp ?? nowUnix();
|
|
1075
|
+
return this.request("POST", API.settlement.prepare, body, {
|
|
1076
|
+
idempotencyKey,
|
|
1077
|
+
timestamp,
|
|
1078
|
+
signal: params.signal
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
async swapQuote(params) {
|
|
1082
|
+
return this.request("POST", API.swap.quote, {
|
|
1083
|
+
wallet: params.wallet.toLowerCase(),
|
|
1084
|
+
fromChain: params.fromChain,
|
|
1085
|
+
toChain: params.toChain,
|
|
1086
|
+
fromToken: params.fromToken.toLowerCase(),
|
|
1087
|
+
toToken: params.toToken.toLowerCase(),
|
|
1088
|
+
amount: params.amount,
|
|
1089
|
+
slippageBps: params.slippageBps,
|
|
1090
|
+
deadlineSeconds: params.deadlineSeconds,
|
|
1091
|
+
allowBridges: params.allowBridges,
|
|
1092
|
+
allowDexes: params.allowDexes
|
|
1093
|
+
}, { signal: params.signal });
|
|
1094
|
+
}
|
|
1095
|
+
async swapBuild(params) {
|
|
1096
|
+
return this.request("POST", API.swap.build, {
|
|
1097
|
+
wallet: params.wallet.toLowerCase(),
|
|
1098
|
+
fromChain: params.fromChain,
|
|
1099
|
+
toChain: params.toChain,
|
|
1100
|
+
quoteId: params.quoteId,
|
|
1101
|
+
routeId: params.routeId,
|
|
1102
|
+
slippageBps: params.slippageBps
|
|
1103
|
+
}, { signal: params.signal });
|
|
1104
|
+
}
|
|
1105
|
+
async getCrossChainConfig(wallet, options) {
|
|
1106
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1107
|
+
return this.request("GET", `${API.crosschain.config(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1108
|
+
}
|
|
1109
|
+
async getCrossChainPendingProposals(wallet, options) {
|
|
1110
|
+
const params = new URLSearchParams();
|
|
1111
|
+
params.set("chain", options?.chain ?? this.chain ?? "sepolia");
|
|
1112
|
+
if (options?.lookbackBlocks) params.set("lookbackBlocks", String(options.lookbackBlocks));
|
|
1113
|
+
if (options?.max) params.set("max", String(options.max));
|
|
1114
|
+
return this.request("GET", `${API.crosschain.pendingProposals(wallet)}?${params.toString()}`, void 0, { signal: options?.signal });
|
|
1115
|
+
}
|
|
1116
|
+
async buildSessionKeyGrant(params) {
|
|
1117
|
+
return this.request("POST", API.sessionKey.grant, {
|
|
1118
|
+
wallet: params.wallet.toLowerCase(),
|
|
1119
|
+
sessionKey: params.sessionKey.toLowerCase(),
|
|
1120
|
+
chain: params.chain,
|
|
1121
|
+
expiry: params.expiry,
|
|
1122
|
+
startTime: params.startTime,
|
|
1123
|
+
targets: params.targets?.map((t) => t.toLowerCase()),
|
|
1124
|
+
selectors: params.selectors,
|
|
1125
|
+
roles: params.roles
|
|
1126
|
+
}, { signal: params.signal });
|
|
1127
|
+
}
|
|
1128
|
+
async buildSessionKeyRevoke(params) {
|
|
1129
|
+
return this.request("POST", API.sessionKey.revoke, {
|
|
1130
|
+
wallet: params.wallet.toLowerCase(),
|
|
1131
|
+
sessionKey: params.sessionKey.toLowerCase(),
|
|
1132
|
+
chain: params.chain
|
|
1133
|
+
}, { signal: params.signal });
|
|
1134
|
+
}
|
|
1135
|
+
async buildEnableFeature(params) {
|
|
1136
|
+
return this.request("POST", API.feature.enable, {
|
|
1137
|
+
wallet: params.wallet.toLowerCase(),
|
|
1138
|
+
featureId: params.featureId,
|
|
1139
|
+
chain: params.chain,
|
|
1140
|
+
initData: params.initData
|
|
1141
|
+
}, { signal: params.signal });
|
|
1142
|
+
}
|
|
1143
|
+
async buildDisableFeature(params) {
|
|
1144
|
+
return this.request("POST", API.feature.disable, {
|
|
1145
|
+
wallet: params.wallet.toLowerCase(),
|
|
1146
|
+
featureId: params.featureId,
|
|
1147
|
+
chain: params.chain
|
|
1148
|
+
}, { signal: params.signal });
|
|
1149
|
+
}
|
|
1150
|
+
async buildResetFeatureInitialization(params) {
|
|
1151
|
+
return this.request("POST", API.feature.reset, {
|
|
1152
|
+
wallet: params.wallet.toLowerCase(),
|
|
1153
|
+
featureId: params.featureId,
|
|
1154
|
+
chain: params.chain
|
|
1155
|
+
}, { signal: params.signal });
|
|
1156
|
+
}
|
|
1157
|
+
async buildTryExecute(params) {
|
|
1158
|
+
return this.request("POST", API.vault.tryExecute, {
|
|
1159
|
+
wallet: params.wallet.toLowerCase(),
|
|
1160
|
+
chain: params.chain,
|
|
1161
|
+
calls: params.calls
|
|
1162
|
+
}, { signal: params.signal });
|
|
1163
|
+
}
|
|
1164
|
+
async buildConfigureGuardians(params) {
|
|
1165
|
+
return this.request("POST", API.guardians.configure, {
|
|
1166
|
+
wallet: params.wallet.toLowerCase(),
|
|
1167
|
+
chain: params.chain,
|
|
1168
|
+
guardians: params.guardians.map((g) => g.toLowerCase()),
|
|
1169
|
+
threshold: params.threshold,
|
|
1170
|
+
timelock: params.timelock
|
|
1171
|
+
}, { signal: params.signal });
|
|
1172
|
+
}
|
|
1173
|
+
async getAddressBook(options) {
|
|
1174
|
+
const params = new URLSearchParams();
|
|
1175
|
+
if (options?.chain) params.set("chain", options.chain);
|
|
1176
|
+
if (typeof options?.limit === "number") params.set("limit", String(options.limit));
|
|
1177
|
+
if (options?.cursor) params.set("cursor", options.cursor);
|
|
1178
|
+
const query = params.toString();
|
|
1179
|
+
return this.request("GET", `${API.addressBook.list}${query ? `?${query}` : ""}`, void 0, { signal: options?.signal });
|
|
1180
|
+
}
|
|
1181
|
+
async createAddressBookEntry(params) {
|
|
1182
|
+
const r = await this.request("POST", API.addressBook.create, {
|
|
1183
|
+
chain: params.chain,
|
|
1184
|
+
label: params.label,
|
|
1185
|
+
address: params.address.toLowerCase(),
|
|
1186
|
+
tags: params.tags,
|
|
1187
|
+
notes: params.notes
|
|
1188
|
+
}, { signal: params.signal });
|
|
1189
|
+
return r.entry;
|
|
1190
|
+
}
|
|
1191
|
+
async updateAddressBookEntry(id, params) {
|
|
1192
|
+
const r = await this.request("PUT", API.addressBook.update(id), {
|
|
1193
|
+
label: params.label,
|
|
1194
|
+
tags: params.tags,
|
|
1195
|
+
notes: params.notes
|
|
1196
|
+
}, { signal: params.signal });
|
|
1197
|
+
return r.entry;
|
|
1198
|
+
}
|
|
1199
|
+
async deleteAddressBookEntry(id, signal) {
|
|
1200
|
+
await this.request("DELETE", API.addressBook.delete(id), void 0, { signal });
|
|
1201
|
+
}
|
|
1202
|
+
async getAutomations(params) {
|
|
1203
|
+
const q = new URLSearchParams();
|
|
1204
|
+
q.set("wallet", params.wallet.toLowerCase());
|
|
1205
|
+
if (typeof params.limit === "number") q.set("limit", String(params.limit));
|
|
1206
|
+
if (params.cursor) q.set("cursor", params.cursor);
|
|
1207
|
+
const r = await this.request(
|
|
1208
|
+
"GET",
|
|
1209
|
+
`${API.automations.list}?${q.toString()}`,
|
|
1210
|
+
void 0,
|
|
1211
|
+
{ signal: params.signal }
|
|
1212
|
+
);
|
|
1213
|
+
return {
|
|
1214
|
+
automations: (r.automations || []).map(mapAutomation),
|
|
1215
|
+
nextCursor: r.nextCursor ?? null,
|
|
1216
|
+
hasMore: Boolean(r.hasMore)
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
async createAutomation(params) {
|
|
1220
|
+
const r = await this.request("POST", API.automations.create, {
|
|
1221
|
+
wallet: params.wallet.toLowerCase(),
|
|
1222
|
+
type: params.type,
|
|
1223
|
+
session_key: params.sessionKey?.toLowerCase(),
|
|
1224
|
+
config: params.config
|
|
1225
|
+
}, { signal: params.signal });
|
|
1226
|
+
return mapAutomation(r.automation);
|
|
1227
|
+
}
|
|
1228
|
+
async getAutomation(id, signal) {
|
|
1229
|
+
const r = await this.request("GET", API.automations.show(id), void 0, { signal });
|
|
1230
|
+
return {
|
|
1231
|
+
automation: mapAutomation(r.automation),
|
|
1232
|
+
executions: (r.executions || []).map(mapAutomationExecution)
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
async pauseAutomation(id, signal) {
|
|
1236
|
+
const r = await this.request("POST", API.automations.pause(id), void 0, { signal });
|
|
1237
|
+
return mapAutomation(r.automation);
|
|
1238
|
+
}
|
|
1239
|
+
async resumeAutomation(id, signal) {
|
|
1240
|
+
const r = await this.request("POST", API.automations.resume(id), void 0, { signal });
|
|
1241
|
+
return mapAutomation(r.automation);
|
|
1242
|
+
}
|
|
1243
|
+
async deleteAutomation(id, signal) {
|
|
1244
|
+
await this.request("DELETE", API.automations.delete(id), void 0, { signal });
|
|
1245
|
+
}
|
|
1246
|
+
async getContractAddresses(chainId, signal) {
|
|
1247
|
+
return this.request("GET", API.addresses.all(chainId), void 0, { signal });
|
|
1248
|
+
}
|
|
1249
|
+
async getContractAddress(chainId, name, signal) {
|
|
1250
|
+
return this.request("GET", API.addresses.get(chainId, name), void 0, { signal });
|
|
1251
|
+
}
|
|
1252
|
+
async getTimingConfig(signal) {
|
|
1253
|
+
return this.request("GET", API.signature.timing, void 0, { signal });
|
|
1254
|
+
}
|
|
1255
|
+
async getGasLimits(signal) {
|
|
1256
|
+
return this.request("GET", API.config.gasLimits, void 0, { signal });
|
|
1257
|
+
}
|
|
1258
|
+
async getAccountOperations(options) {
|
|
1259
|
+
const params = new URLSearchParams();
|
|
1260
|
+
params.set("account", options.account.toLowerCase());
|
|
1261
|
+
if (options.chain) params.set("chain", options.chain);
|
|
1262
|
+
if (options.state) params.set("state", options.state);
|
|
1263
|
+
if (typeof options.limit === "number") params.set("limit", String(options.limit));
|
|
1264
|
+
if (options.cursor) params.set("cursor", options.cursor);
|
|
1265
|
+
return this.request("GET", `${API.accounts.operations}?${params.toString()}`, void 0, { signal: options.signal });
|
|
1266
|
+
}
|
|
1267
|
+
async getEnabledFeatures(wallet, options) {
|
|
1268
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1269
|
+
return this.request("GET", `${API.vault.features(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1270
|
+
}
|
|
1271
|
+
async getFeatureConfig(wallet, featureId, options) {
|
|
1272
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1273
|
+
return this.request("GET", `${API.vault.feature(wallet, featureId)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1274
|
+
}
|
|
1275
|
+
async getSecurityCouncil(wallet, options) {
|
|
1276
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1277
|
+
return this.request("GET", `${API.vault.securityCouncil(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1278
|
+
}
|
|
1279
|
+
async getFallbackSigner(wallet, options) {
|
|
1280
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1281
|
+
return this.request("GET", `${API.vault.fallbackSigner(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1282
|
+
}
|
|
1283
|
+
async isPaused(wallet, options) {
|
|
1284
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1285
|
+
return this.request("GET", `${API.vault.paused(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1286
|
+
}
|
|
1287
|
+
async getL2Receiver(wallet, options) {
|
|
1288
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1289
|
+
return this.request("GET", `${API.vault.l2Receiver(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1290
|
+
}
|
|
1291
|
+
async buildPauseCore(params) {
|
|
1292
|
+
return this.request("POST", API.vault.pause, {
|
|
1293
|
+
wallet: params.wallet.toLowerCase(),
|
|
1294
|
+
chain: params.chain
|
|
1295
|
+
}, { signal: params.signal });
|
|
1296
|
+
}
|
|
1297
|
+
async buildUnpauseCore(params) {
|
|
1298
|
+
return this.request("POST", API.vault.unpause, {
|
|
1299
|
+
wallet: params.wallet.toLowerCase(),
|
|
1300
|
+
chain: params.chain
|
|
1301
|
+
}, { signal: params.signal });
|
|
1302
|
+
}
|
|
1303
|
+
async buildSetSecurityCouncil(params) {
|
|
1304
|
+
return this.request("POST", API.vault.setSecurityCouncil, {
|
|
1305
|
+
wallet: params.wallet.toLowerCase(),
|
|
1306
|
+
chain: params.chain,
|
|
1307
|
+
securityCouncil: params.securityCouncil.toLowerCase()
|
|
1308
|
+
}, { signal: params.signal });
|
|
1309
|
+
}
|
|
1310
|
+
async buildSetFallbackSigner(params) {
|
|
1311
|
+
return this.request("POST", API.vault.setFallbackSigner, {
|
|
1312
|
+
wallet: params.wallet.toLowerCase(),
|
|
1313
|
+
chain: params.chain,
|
|
1314
|
+
fallbackSigner: params.fallbackSigner.toLowerCase()
|
|
1315
|
+
}, { signal: params.signal });
|
|
1316
|
+
}
|
|
1317
|
+
async buildOverrideGlobalPause(params) {
|
|
1318
|
+
return this.request("POST", API.vault.overrideGlobalPause, {
|
|
1319
|
+
wallet: params.wallet.toLowerCase(),
|
|
1320
|
+
chain: params.chain,
|
|
1321
|
+
override: params.override
|
|
1322
|
+
}, { signal: params.signal });
|
|
1323
|
+
}
|
|
1324
|
+
async getSessionKeyCount(wallet, options) {
|
|
1325
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1326
|
+
return this.request("GET", `${API.sessionKey.count(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1327
|
+
}
|
|
1328
|
+
async getSessionKeyPolicySigner(wallet, options) {
|
|
1329
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1330
|
+
return this.request("GET", `${API.sessionKey.policySigner(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1331
|
+
}
|
|
1332
|
+
async getSessionKeyRoles(wallet, sessionKey, options) {
|
|
1333
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1334
|
+
return this.request("GET", `${API.sessionKey.roles(wallet, sessionKey)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1335
|
+
}
|
|
1336
|
+
async getSessionKeyTokenLimit(wallet, sessionKey, token, options) {
|
|
1337
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1338
|
+
return this.request("GET", `${API.sessionKey.tokenLimit(wallet, sessionKey, token)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1339
|
+
}
|
|
1340
|
+
async buildRevokeAllSessionKeys(params) {
|
|
1341
|
+
return this.request("POST", API.sessionKey.revokeAll, {
|
|
1342
|
+
wallet: params.wallet.toLowerCase(),
|
|
1343
|
+
chain: params.chain
|
|
1344
|
+
}, { signal: params.signal });
|
|
1345
|
+
}
|
|
1346
|
+
async buildSetSessionKeyTokenLimits(params) {
|
|
1347
|
+
return this.request("POST", API.sessionKey.tokenLimits, {
|
|
1348
|
+
wallet: params.wallet.toLowerCase(),
|
|
1349
|
+
sessionKey: params.sessionKey.toLowerCase(),
|
|
1350
|
+
chain: params.chain,
|
|
1351
|
+
limits: params.limits.map((l) => ({ token: l.token.toLowerCase(), limit: l.limit }))
|
|
1352
|
+
}, { signal: params.signal });
|
|
1353
|
+
}
|
|
1354
|
+
async buildSetMaxValuePerCall(params) {
|
|
1355
|
+
return this.request("POST", API.sessionKey.maxValuePerCall, {
|
|
1356
|
+
wallet: params.wallet.toLowerCase(),
|
|
1357
|
+
sessionKey: params.sessionKey.toLowerCase(),
|
|
1358
|
+
chain: params.chain,
|
|
1359
|
+
maxValue: params.maxValue
|
|
1360
|
+
}, { signal: params.signal });
|
|
1361
|
+
}
|
|
1362
|
+
async buildSyncSessionKey(params) {
|
|
1363
|
+
return this.request("POST", API.sessionKey.sync, {
|
|
1364
|
+
wallet: params.wallet.toLowerCase(),
|
|
1365
|
+
sessionKey: params.sessionKey.toLowerCase(),
|
|
1366
|
+
chain: params.chain
|
|
1367
|
+
}, { signal: params.signal });
|
|
1368
|
+
}
|
|
1369
|
+
async getFeatureSessionKeys(wallet, options) {
|
|
1370
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1371
|
+
return this.request("GET", `${API.sessionKey.list(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1372
|
+
}
|
|
1373
|
+
async getFeatureSpendingLimits(wallet, options) {
|
|
1374
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1375
|
+
return this.request("GET", `${API.feature.spendingLimits(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1376
|
+
}
|
|
1377
|
+
async getFeatureRoles(wallet, options) {
|
|
1378
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1379
|
+
return this.request("GET", `${API.feature.roles(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1380
|
+
}
|
|
1381
|
+
async getAccountRoles(wallet, account, options) {
|
|
1382
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1383
|
+
return this.request("GET", `${API.feature.accountRoles(wallet, account)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1384
|
+
}
|
|
1385
|
+
async getNativeSpendingSummaries(wallet, options) {
|
|
1386
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1387
|
+
return this.request("GET", `${API.spendingLimit.nativeSummaries(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1388
|
+
}
|
|
1389
|
+
async getTokenSpendingSummaries(wallet, token, options) {
|
|
1390
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1391
|
+
return this.request("GET", `${API.spendingLimit.tokenSummaries(wallet, token)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1392
|
+
}
|
|
1393
|
+
async getSpendingPreview(wallet, options) {
|
|
1394
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1395
|
+
return this.request("GET", `${API.spendingLimit.preview(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1396
|
+
}
|
|
1397
|
+
async getSpendingBucket(wallet, windowStart, options) {
|
|
1398
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1399
|
+
return this.request("GET", `${API.spendingLimit.bucket(wallet, windowStart)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1400
|
+
}
|
|
1401
|
+
async getNativeLimit(wallet, window, options) {
|
|
1402
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1403
|
+
return this.request("GET", `${API.spendingLimit.nativeLimit(wallet, window)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1404
|
+
}
|
|
1405
|
+
async getNativeLimitStatus(wallet, window, options) {
|
|
1406
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1407
|
+
return this.request("GET", `${API.spendingLimit.nativeStatus(wallet, window)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1408
|
+
}
|
|
1409
|
+
async getTokenLimit(wallet, token, window, options) {
|
|
1410
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1411
|
+
return this.request("GET", `${API.spendingLimit.tokenLimit(wallet, token, window)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1412
|
+
}
|
|
1413
|
+
async getTokenLimitStatus(wallet, token, window, options) {
|
|
1414
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1415
|
+
return this.request("GET", `${API.spendingLimit.tokenStatus(wallet, token, window)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1416
|
+
}
|
|
1417
|
+
async buildEnableSpendingLimit(params) {
|
|
1418
|
+
return this.request("POST", API.spendingLimit.enable, {
|
|
1419
|
+
wallet: params.wallet.toLowerCase(),
|
|
1420
|
+
chain: params.chain,
|
|
1421
|
+
window: params.window,
|
|
1422
|
+
limit: params.limit
|
|
1423
|
+
}, { signal: params.signal });
|
|
1424
|
+
}
|
|
1425
|
+
async buildDisableSpendingLimit(params) {
|
|
1426
|
+
return this.request("POST", API.spendingLimit.disable, {
|
|
1427
|
+
wallet: params.wallet.toLowerCase(),
|
|
1428
|
+
chain: params.chain,
|
|
1429
|
+
window: params.window
|
|
1430
|
+
}, { signal: params.signal });
|
|
1431
|
+
}
|
|
1432
|
+
async buildUpdateSpendingLimit(params) {
|
|
1433
|
+
return this.request("POST", API.spendingLimit.update, {
|
|
1434
|
+
wallet: params.wallet.toLowerCase(),
|
|
1435
|
+
chain: params.chain,
|
|
1436
|
+
window: params.window,
|
|
1437
|
+
limit: params.limit
|
|
1438
|
+
}, { signal: params.signal });
|
|
1439
|
+
}
|
|
1440
|
+
async buildEnableTokenSpendingLimit(params) {
|
|
1441
|
+
return this.request("POST", API.spendingLimit.enableToken, {
|
|
1442
|
+
wallet: params.wallet.toLowerCase(),
|
|
1443
|
+
chain: params.chain,
|
|
1444
|
+
token: params.token.toLowerCase(),
|
|
1445
|
+
window: params.window,
|
|
1446
|
+
limit: params.limit
|
|
1447
|
+
}, { signal: params.signal });
|
|
1448
|
+
}
|
|
1449
|
+
async buildDisableTokenSpendingLimit(params) {
|
|
1450
|
+
return this.request("POST", API.spendingLimit.disableToken, {
|
|
1451
|
+
wallet: params.wallet.toLowerCase(),
|
|
1452
|
+
chain: params.chain,
|
|
1453
|
+
token: params.token.toLowerCase(),
|
|
1454
|
+
window: params.window
|
|
1455
|
+
}, { signal: params.signal });
|
|
1456
|
+
}
|
|
1457
|
+
async buildUpdateTokenSpendingLimit(params) {
|
|
1458
|
+
return this.request("POST", API.spendingLimit.updateToken, {
|
|
1459
|
+
wallet: params.wallet.toLowerCase(),
|
|
1460
|
+
chain: params.chain,
|
|
1461
|
+
token: params.token.toLowerCase(),
|
|
1462
|
+
window: params.window,
|
|
1463
|
+
limit: params.limit
|
|
1464
|
+
}, { signal: params.signal });
|
|
1465
|
+
}
|
|
1466
|
+
async buildSetSpendValidator(params) {
|
|
1467
|
+
return this.request("POST", API.spendingLimit.setSpendValidator, {
|
|
1468
|
+
wallet: params.wallet.toLowerCase(),
|
|
1469
|
+
chain: params.chain,
|
|
1470
|
+
target: params.target.toLowerCase(),
|
|
1471
|
+
selector: params.selector.toLowerCase(),
|
|
1472
|
+
module: params.module.toLowerCase()
|
|
1473
|
+
}, { signal: params.signal });
|
|
1474
|
+
}
|
|
1475
|
+
async getAllowlistRoots(wallet, options) {
|
|
1476
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1477
|
+
return this.request("GET", `${API.allowlist.getRoots(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1478
|
+
}
|
|
1479
|
+
async getActorPermissions(wallet, actor, options) {
|
|
1480
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1481
|
+
return this.request("GET", `${API.allowlist.getActorPermissions(wallet, actor)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1482
|
+
}
|
|
1483
|
+
async getTokenMaxTransfer(wallet, token, options) {
|
|
1484
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1485
|
+
return this.request("GET", `${API.allowlist.tokenMaxTransfer(wallet, token)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1486
|
+
}
|
|
1487
|
+
async buildEnableAllowlist(params) {
|
|
1488
|
+
return this.request("POST", API.allowlist.enable, {
|
|
1489
|
+
wallet: params.wallet.toLowerCase(),
|
|
1490
|
+
chain: params.chain
|
|
1491
|
+
}, { signal: params.signal });
|
|
1492
|
+
}
|
|
1493
|
+
async buildDisableAllowlist(params) {
|
|
1494
|
+
return this.request("POST", API.allowlist.disable, {
|
|
1495
|
+
wallet: params.wallet.toLowerCase(),
|
|
1496
|
+
chain: params.chain
|
|
1497
|
+
}, { signal: params.signal });
|
|
1498
|
+
}
|
|
1499
|
+
async buildEnableContractOnly(params) {
|
|
1500
|
+
return this.request("POST", API.allowlist.contractOnly, {
|
|
1501
|
+
wallet: params.wallet.toLowerCase(),
|
|
1502
|
+
chain: params.chain,
|
|
1503
|
+
enabled: params.enabled
|
|
1504
|
+
}, { signal: params.signal });
|
|
1505
|
+
}
|
|
1506
|
+
async buildSetAllowlistRoots(params) {
|
|
1507
|
+
return this.request("POST", API.allowlist.roots, {
|
|
1508
|
+
wallet: params.wallet.toLowerCase(),
|
|
1509
|
+
chain: params.chain,
|
|
1510
|
+
addressRoot: params.addressRoot,
|
|
1511
|
+
selectorRoot: params.selectorRoot
|
|
1512
|
+
}, { signal: params.signal });
|
|
1513
|
+
}
|
|
1514
|
+
async buildSyncAllowlist(params) {
|
|
1515
|
+
return this.request("POST", API.allowlist.sync, {
|
|
1516
|
+
wallet: params.wallet.toLowerCase(),
|
|
1517
|
+
chain: params.chain
|
|
1518
|
+
}, { signal: params.signal });
|
|
1519
|
+
}
|
|
1520
|
+
async buildSetMaxTransferAmount(params) {
|
|
1521
|
+
return this.request("POST", API.allowlist.transferLimit, {
|
|
1522
|
+
wallet: params.wallet.toLowerCase(),
|
|
1523
|
+
chain: params.chain,
|
|
1524
|
+
token: params.token.toLowerCase(),
|
|
1525
|
+
maxAmount: params.maxAmount
|
|
1526
|
+
}, { signal: params.signal });
|
|
1527
|
+
}
|
|
1528
|
+
async buildSetActorPermissions(params) {
|
|
1529
|
+
return this.request("POST", API.allowlist.actorPermissions, {
|
|
1530
|
+
wallet: params.wallet.toLowerCase(),
|
|
1531
|
+
chain: params.chain,
|
|
1532
|
+
actor: params.actor.toLowerCase(),
|
|
1533
|
+
permissions: params.permissions
|
|
1534
|
+
}, { signal: params.signal });
|
|
1535
|
+
}
|
|
1536
|
+
async getRecoveryGuardians(wallet, options) {
|
|
1537
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1538
|
+
return this.request("GET", `${API.recovery.guardians(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1539
|
+
}
|
|
1540
|
+
async getRecoveryProposal(wallet, options) {
|
|
1541
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1542
|
+
return this.request("GET", `${API.recovery.proposal(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1543
|
+
}
|
|
1544
|
+
async getRecoveryProposalState(wallet, options) {
|
|
1545
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1546
|
+
return this.request("GET", `${API.recovery.proposalState(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1547
|
+
}
|
|
1548
|
+
async hasGuardianApproved(wallet, guardian, options) {
|
|
1549
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1550
|
+
return this.request("GET", `${API.recovery.guardianApproved(wallet, guardian)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1551
|
+
}
|
|
1552
|
+
async isGuardian(wallet, guardian, options) {
|
|
1553
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1554
|
+
return this.request("GET", `${API.recovery.isGuardian(wallet, guardian)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1555
|
+
}
|
|
1556
|
+
async buildInitiateRecovery(params) {
|
|
1557
|
+
return this.request("POST", API.recovery.initiate, {
|
|
1558
|
+
wallet: params.wallet.toLowerCase(),
|
|
1559
|
+
chain: params.chain,
|
|
1560
|
+
proposedOwner: params.proposedOwner.toLowerCase()
|
|
1561
|
+
}, { signal: params.signal });
|
|
1562
|
+
}
|
|
1563
|
+
async buildSupportRecovery(params) {
|
|
1564
|
+
return this.request("POST", API.recovery.support, {
|
|
1565
|
+
wallet: params.wallet.toLowerCase(),
|
|
1566
|
+
chain: params.chain,
|
|
1567
|
+
guardian: params.guardian.toLowerCase(),
|
|
1568
|
+
signature: params.signature
|
|
1569
|
+
}, { signal: params.signal });
|
|
1570
|
+
}
|
|
1571
|
+
async buildExecuteRecovery(params) {
|
|
1572
|
+
return this.request("POST", API.recovery.execute, {
|
|
1573
|
+
wallet: params.wallet.toLowerCase(),
|
|
1574
|
+
chain: params.chain
|
|
1575
|
+
}, { signal: params.signal });
|
|
1576
|
+
}
|
|
1577
|
+
async buildCancelRecovery(params) {
|
|
1578
|
+
return this.request("POST", API.recovery.cancel, {
|
|
1579
|
+
wallet: params.wallet.toLowerCase(),
|
|
1580
|
+
chain: params.chain
|
|
1581
|
+
}, { signal: params.signal });
|
|
1582
|
+
}
|
|
1583
|
+
async getArmedStatus(wallet, options) {
|
|
1584
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1585
|
+
return this.request("GET", `${API.roles.armed(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1586
|
+
}
|
|
1587
|
+
async getTargetIndex(wallet, target, options) {
|
|
1588
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1589
|
+
return this.request("GET", `${API.roles.targetIndex(wallet, target)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1590
|
+
}
|
|
1591
|
+
async getSelectorIndex(wallet, selector, options) {
|
|
1592
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1593
|
+
return this.request("GET", `${API.roles.selectorIndex(wallet, selector)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1594
|
+
}
|
|
1595
|
+
async hasRole(wallet, account, roleId, options) {
|
|
1596
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1597
|
+
return this.request("GET", `${API.roles.hasRole(wallet, account, roleId)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1598
|
+
}
|
|
1599
|
+
async getRoleBudget(wallet, roleId, options) {
|
|
1600
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1601
|
+
return this.request("GET", `${API.roles.budget(wallet, roleId)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1602
|
+
}
|
|
1603
|
+
async getRole(wallet, roleId, options) {
|
|
1604
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1605
|
+
const raw = await this.request("GET", `${API.roles.show(wallet, roleId)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1606
|
+
const role = raw.role;
|
|
1607
|
+
if (!role || typeof role !== "object") {
|
|
1608
|
+
throw new VaultumError("Invalid role response", "BUNDLER_ERROR", 502, raw);
|
|
1609
|
+
}
|
|
1610
|
+
return {
|
|
1611
|
+
wallet: (raw.wallet ?? wallet).toLowerCase(),
|
|
1612
|
+
roleId: (raw.roleId ?? roleId).toLowerCase(),
|
|
1613
|
+
chain: typeof raw.chain === "string" && raw.chain !== "" ? raw.chain : chain,
|
|
1614
|
+
name: typeof role.name === "string" ? role.name : "",
|
|
1615
|
+
targetBitmap: typeof role.targetBitmap === "string" ? role.targetBitmap : "0",
|
|
1616
|
+
selectorBitmap: typeof role.selectorBitmap === "string" ? role.selectorBitmap : "0",
|
|
1617
|
+
maxValue: typeof role.maxValue === "string" ? role.maxValue : "0"
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
async buildCreateRole(params) {
|
|
1621
|
+
return this.request("POST", API.roles.create, {
|
|
1622
|
+
wallet: params.wallet.toLowerCase(),
|
|
1623
|
+
chain: params.chain,
|
|
1624
|
+
roleId: params.roleId,
|
|
1625
|
+
name: params.name,
|
|
1626
|
+
targetBitmap: params.targetBitmap,
|
|
1627
|
+
selectorBitmap: params.selectorBitmap,
|
|
1628
|
+
maxValue: typeof params.maxValue === "number" ? params.maxValue : void 0
|
|
1629
|
+
}, { signal: params.signal });
|
|
1630
|
+
}
|
|
1631
|
+
async buildCreateRolesBatch(params) {
|
|
1632
|
+
return this.request("POST", API.roles.createBatch, {
|
|
1633
|
+
wallet: params.wallet.toLowerCase(),
|
|
1634
|
+
chain: params.chain,
|
|
1635
|
+
roles: params.roles.map((r) => ({
|
|
1636
|
+
roleId: r.roleId,
|
|
1637
|
+
name: r.name,
|
|
1638
|
+
targetBitmap: r.targetBitmap,
|
|
1639
|
+
selectorBitmap: r.selectorBitmap,
|
|
1640
|
+
maxValue: typeof r.maxValue === "number" ? String(r.maxValue) : r.maxValue ?? "0"
|
|
1641
|
+
}))
|
|
1642
|
+
}, { signal: params.signal });
|
|
1643
|
+
}
|
|
1644
|
+
async buildGrantRole(params) {
|
|
1645
|
+
return this.request("POST", API.roles.grant, {
|
|
1646
|
+
wallet: params.wallet.toLowerCase(),
|
|
1647
|
+
chain: params.chain,
|
|
1648
|
+
account: params.account.toLowerCase(),
|
|
1649
|
+
roleId: params.roleId
|
|
1650
|
+
}, { signal: params.signal });
|
|
1651
|
+
}
|
|
1652
|
+
async buildRevokeRole(params) {
|
|
1653
|
+
return this.request("POST", API.roles.revoke, {
|
|
1654
|
+
wallet: params.wallet.toLowerCase(),
|
|
1655
|
+
chain: params.chain,
|
|
1656
|
+
account: params.account.toLowerCase(),
|
|
1657
|
+
roleId: params.roleId
|
|
1658
|
+
}, { signal: params.signal });
|
|
1659
|
+
}
|
|
1660
|
+
async buildGrantRolesBatch(params) {
|
|
1661
|
+
return this.request("POST", API.roles.grantBatch, {
|
|
1662
|
+
wallet: params.wallet.toLowerCase(),
|
|
1663
|
+
chain: params.chain,
|
|
1664
|
+
grants: params.grants.map((g) => ({
|
|
1665
|
+
account: g.account.toLowerCase(),
|
|
1666
|
+
roleId: g.roleId
|
|
1667
|
+
}))
|
|
1668
|
+
}, { signal: params.signal });
|
|
1669
|
+
}
|
|
1670
|
+
async buildRevokeRolesBatch(params) {
|
|
1671
|
+
return this.request("POST", API.roles.revokeBatch, {
|
|
1672
|
+
wallet: params.wallet.toLowerCase(),
|
|
1673
|
+
chain: params.chain,
|
|
1674
|
+
revokes: params.revokes.map((r) => ({
|
|
1675
|
+
account: r.account.toLowerCase(),
|
|
1676
|
+
roleId: r.roleId
|
|
1677
|
+
}))
|
|
1678
|
+
}, { signal: params.signal });
|
|
1679
|
+
}
|
|
1680
|
+
async buildUpdateRole(params) {
|
|
1681
|
+
return this.request("POST", API.roles.update, {
|
|
1682
|
+
wallet: params.wallet.toLowerCase(),
|
|
1683
|
+
chain: params.chain,
|
|
1684
|
+
roleId: params.roleId,
|
|
1685
|
+
name: params.name,
|
|
1686
|
+
targetBitmap: params.targetBitmap,
|
|
1687
|
+
selectorBitmap: params.selectorBitmap,
|
|
1688
|
+
maxValue: params.maxValue
|
|
1689
|
+
}, { signal: params.signal });
|
|
1690
|
+
}
|
|
1691
|
+
async buildSetRoleBitmap(params) {
|
|
1692
|
+
const current = await this.getRole(params.wallet, params.roleId, { chain: params.chain, signal: params.signal });
|
|
1693
|
+
return this.buildUpdateRole({
|
|
1694
|
+
wallet: params.wallet,
|
|
1695
|
+
chain: params.chain,
|
|
1696
|
+
roleId: params.roleId,
|
|
1697
|
+
name: current.name,
|
|
1698
|
+
targetBitmap: params.targetBitmap,
|
|
1699
|
+
selectorBitmap: params.selectorBitmap,
|
|
1700
|
+
maxValue: current.maxValue,
|
|
1701
|
+
signal: params.signal
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
async buildGrantRolesMultiAccount(params) {
|
|
1705
|
+
return this.request("POST", API.roles.grantMulti, {
|
|
1706
|
+
wallet: params.wallet.toLowerCase(),
|
|
1707
|
+
chain: params.chain,
|
|
1708
|
+
accounts: params.accounts.map((a) => a.toLowerCase()),
|
|
1709
|
+
roleIds: params.roleIds
|
|
1710
|
+
}, { signal: params.signal });
|
|
1711
|
+
}
|
|
1712
|
+
async buildArmRoles(params) {
|
|
1713
|
+
return this.request("POST", API.roles.arm, {
|
|
1714
|
+
wallet: params.wallet.toLowerCase(),
|
|
1715
|
+
chain: params.chain,
|
|
1716
|
+
armed: params.armed
|
|
1717
|
+
}, { signal: params.signal });
|
|
1718
|
+
}
|
|
1719
|
+
async buildSetRoleBudget(params) {
|
|
1720
|
+
return this.request("POST", API.roles.setBudget(params.wallet, params.roleId), {
|
|
1721
|
+
wallet: params.wallet.toLowerCase(),
|
|
1722
|
+
chain: params.chain,
|
|
1723
|
+
budget: params.budget
|
|
1724
|
+
}, { signal: params.signal });
|
|
1725
|
+
}
|
|
1726
|
+
async getCrossChainReceiverState(wallet, options) {
|
|
1727
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1728
|
+
return this.request("GET", `${API.crosschain.receiverStateFresh(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1729
|
+
}
|
|
1730
|
+
async getCrossChainSkipProposal(wallet, options) {
|
|
1731
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1732
|
+
return this.request("GET", `${API.crosschain.receiverSkipProposal(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1733
|
+
}
|
|
1734
|
+
async getCrossChainGasLimit(chainId, signal) {
|
|
1735
|
+
return this.request("GET", API.crosschain.gasLimit(chainId), void 0, { signal });
|
|
1736
|
+
}
|
|
1737
|
+
async buildProposeOwnerUpdate(params) {
|
|
1738
|
+
return this.request("POST", API.crosschain.proposeOwnerUpdate, {
|
|
1739
|
+
wallet: params.wallet.toLowerCase(),
|
|
1740
|
+
chain: params.chain,
|
|
1741
|
+
newOwners: params.newOwners.map((o) => o.toLowerCase()),
|
|
1742
|
+
newThreshold: params.newThreshold,
|
|
1743
|
+
targetChains: params.targetChains
|
|
1744
|
+
}, { signal: params.signal });
|
|
1745
|
+
}
|
|
1746
|
+
async buildExecuteOwnerUpdate(params) {
|
|
1747
|
+
return this.request("POST", API.crosschain.executeOwnerUpdate, {
|
|
1748
|
+
wallet: params.wallet.toLowerCase(),
|
|
1749
|
+
chain: params.chain,
|
|
1750
|
+
proposalId: params.proposalId
|
|
1751
|
+
}, { signal: params.signal });
|
|
1752
|
+
}
|
|
1753
|
+
async buildResyncL2(params) {
|
|
1754
|
+
return this.request("POST", API.crosschain.resync, {
|
|
1755
|
+
wallet: params.wallet.toLowerCase(),
|
|
1756
|
+
chain: params.chain,
|
|
1757
|
+
targetChain: params.targetChain
|
|
1758
|
+
}, { signal: params.signal });
|
|
1759
|
+
}
|
|
1760
|
+
async updateAutomation(id, params) {
|
|
1761
|
+
const r = await this.request("PUT", API.automations.update(id), {
|
|
1762
|
+
session_key: params.sessionKey ? params.sessionKey.toLowerCase() : params.sessionKey,
|
|
1763
|
+
config: params.config
|
|
1764
|
+
}, { signal: params.signal });
|
|
1765
|
+
return mapAutomation(r.automation);
|
|
1766
|
+
}
|
|
1767
|
+
async triggerAutomation(id, signal) {
|
|
1768
|
+
const r = await this.request(
|
|
1769
|
+
"POST",
|
|
1770
|
+
API.automations.trigger(id),
|
|
1771
|
+
void 0,
|
|
1772
|
+
{ signal }
|
|
1773
|
+
);
|
|
1774
|
+
return {
|
|
1775
|
+
automation: mapAutomation(r.automation),
|
|
1776
|
+
message: r.message
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
async getAddressCapabilities(signal) {
|
|
1780
|
+
return this.request("GET", API.addresses.capabilities, void 0, { signal });
|
|
1781
|
+
}
|
|
1782
|
+
async getUserOpTemplate(options) {
|
|
1783
|
+
const params = new URLSearchParams();
|
|
1784
|
+
if (options?.chain) params.set("chain", options.chain);
|
|
1785
|
+
const query = params.toString();
|
|
1786
|
+
return this.request("GET", `${API.signature.userOpTemplate}${query ? `?${query}` : ""}`, void 0, { signal: options?.signal });
|
|
1787
|
+
}
|
|
1788
|
+
async getEIP712Template(options) {
|
|
1789
|
+
const params = new URLSearchParams();
|
|
1790
|
+
if (options?.chain) params.set("chain", options.chain);
|
|
1791
|
+
const query = params.toString();
|
|
1792
|
+
return this.request("GET", `${API.signature.eip712Template}${query ? `?${query}` : ""}`, void 0, { signal: options?.signal });
|
|
1793
|
+
}
|
|
1794
|
+
async validateTimestamp(params) {
|
|
1795
|
+
return this.request("POST", API.signature.validateTimestamp, {
|
|
1796
|
+
validAfter: params.validAfter,
|
|
1797
|
+
validUntil: params.validUntil
|
|
1798
|
+
}, { signal: params.signal });
|
|
1799
|
+
}
|
|
1800
|
+
async getRegistryFeatures(options) {
|
|
1801
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1802
|
+
return this.request("GET", `${API.registry.features}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1803
|
+
}
|
|
1804
|
+
async getRegistryVersion(options) {
|
|
1805
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1806
|
+
return this.request("GET", `${API.registry.version}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1807
|
+
}
|
|
1808
|
+
async isFeatureInternal(featureId, options) {
|
|
1809
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1810
|
+
return this.request("GET", `${API.registry.isInternal(featureId)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1811
|
+
}
|
|
1812
|
+
async canValidatorHandleSelector(validatorId, selector, options) {
|
|
1813
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1814
|
+
return this.request("GET", `${API.registry.canValidatorHandleSelector(validatorId, selector)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1815
|
+
}
|
|
1816
|
+
async getRegistryCoreModuleId(key, options) {
|
|
1817
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1818
|
+
return this.request("GET", `${API.registry.coreModuleId(key)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1819
|
+
}
|
|
1820
|
+
async canAccessRegistrySlot(featureId, slot, options) {
|
|
1821
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1822
|
+
return this.request("GET", `${API.registry.slotAccess(featureId, slot)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1823
|
+
}
|
|
1824
|
+
async registrySupportsMigration(featureId, options) {
|
|
1825
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1826
|
+
return this.request("GET", `${API.registry.supportsMigration(featureId)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1827
|
+
}
|
|
1828
|
+
async isRegistryFeatureImplementation(impl, options) {
|
|
1829
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1830
|
+
return this.request("GET", `${API.registry.isFeatureImplementation(impl)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1831
|
+
}
|
|
1832
|
+
async getRegistryFeatureImplementation(featureId, options) {
|
|
1833
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1834
|
+
return this.request("GET", `${API.registry.featureImplementation(featureId)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1835
|
+
}
|
|
1836
|
+
async getRegistryFeatureImplementationForWallet(wallet, featureId, options) {
|
|
1837
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1838
|
+
return this.request("GET", `${API.registry.featureImplementationForWallet(wallet, featureId)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1839
|
+
}
|
|
1840
|
+
async isRegistryMandatoryFeature(featureId, options) {
|
|
1841
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1842
|
+
return this.request("GET", `${API.registry.isMandatoryFeature(featureId)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1843
|
+
}
|
|
1844
|
+
async getRegistryEcdsaModule(options) {
|
|
1845
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1846
|
+
return this.request("GET", `${API.registry.ecdsaModule}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1847
|
+
}
|
|
1848
|
+
async getRegistrySessionKeyManager(options) {
|
|
1849
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1850
|
+
return this.request("GET", `${API.registry.sessionKeyManager}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1851
|
+
}
|
|
1852
|
+
async getRegistrySpendingLimitManager(options) {
|
|
1853
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1854
|
+
return this.request("GET", `${API.registry.spendingLimitManager}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1855
|
+
}
|
|
1856
|
+
async getRegistryPermissionsManager(options) {
|
|
1857
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1858
|
+
return this.request("GET", `${API.registry.permissionsManager}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1859
|
+
}
|
|
1860
|
+
async getRegistryCapabilitySnapshot(wallet, options) {
|
|
1861
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1862
|
+
return this.request("GET", `${API.registry.capabilitySnapshot(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1863
|
+
}
|
|
1864
|
+
async getRegistryMandatoryInitData(wallet, featureId, options) {
|
|
1865
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1866
|
+
return this.request("GET", `${API.registry.mandatoryInitData(wallet, featureId)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1867
|
+
}
|
|
1868
|
+
async buildSetRegistryCanaryOptIn(params) {
|
|
1869
|
+
return this.request("POST", API.registry.setCanaryOptIn, {
|
|
1870
|
+
wallet: params.wallet.toLowerCase(),
|
|
1871
|
+
chain: params.chain,
|
|
1872
|
+
optIn: params.optIn
|
|
1873
|
+
}, { signal: params.signal });
|
|
1874
|
+
}
|
|
1875
|
+
async buildSetRegistryMandatoryInitData(params) {
|
|
1876
|
+
return this.request("POST", API.registry.setMandatoryInitData, {
|
|
1877
|
+
wallet: params.wallet.toLowerCase(),
|
|
1878
|
+
chain: params.chain,
|
|
1879
|
+
featureId: params.featureId,
|
|
1880
|
+
initData: params.initData
|
|
1881
|
+
}, { signal: params.signal });
|
|
1882
|
+
}
|
|
1883
|
+
async buildUpdateRegistryCapabilitySnapshot(params) {
|
|
1884
|
+
return this.request("POST", API.registry.updateCapabilitySnapshot, {
|
|
1885
|
+
wallet: params.wallet.toLowerCase(),
|
|
1886
|
+
chain: params.chain,
|
|
1887
|
+
snapshot: params.snapshot
|
|
1888
|
+
}, { signal: params.signal });
|
|
1889
|
+
}
|
|
1890
|
+
async isGloballyPaused(wallet, options) {
|
|
1891
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1892
|
+
return this.request("GET", `${API.registry.globallyPaused(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1893
|
+
}
|
|
1894
|
+
async isCanaryOptIn(wallet, options) {
|
|
1895
|
+
const chain = options?.chain ?? this.chain ?? "sepolia";
|
|
1896
|
+
return this.request("GET", `${API.registry.canaryOptIn(wallet)}?chain=${chain}`, void 0, { signal: options?.signal });
|
|
1897
|
+
}
|
|
1898
|
+
async estimateRelay(params) {
|
|
1899
|
+
return this.request("POST", API.relay.estimate, {
|
|
1900
|
+
chain: params.chain,
|
|
1901
|
+
userOp: params.userOp
|
|
1902
|
+
}, { signal: params.signal });
|
|
1903
|
+
}
|
|
1904
|
+
async previewRelay(params) {
|
|
1905
|
+
return this.request("POST", API.relay.preview, {
|
|
1906
|
+
chain: params.chain,
|
|
1907
|
+
userOp: params.userOp
|
|
1908
|
+
}, { signal: params.signal });
|
|
1909
|
+
}
|
|
1910
|
+
async getHealth(signal) {
|
|
1911
|
+
return this.request("GET", API.health, void 0, { signal });
|
|
1912
|
+
}
|
|
1913
|
+
};
|
|
1914
|
+
function normalizeURL(url, hasCredentials) {
|
|
1915
|
+
const trimmed = url.trim();
|
|
1916
|
+
if (!trimmed) throw new VaultumError("Base URL required", "INVALID_CONFIG");
|
|
1917
|
+
let parsed;
|
|
1918
|
+
try {
|
|
1919
|
+
parsed = new URL(trimmed);
|
|
1920
|
+
} catch {
|
|
1921
|
+
throw new VaultumError("Invalid base URL", "INVALID_CONFIG");
|
|
1922
|
+
}
|
|
1923
|
+
const isHttps = parsed.protocol === "https:";
|
|
1924
|
+
const isLocal = parsed.protocol === "http:" && (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1");
|
|
1925
|
+
if (!isHttps && !isLocal) throw new VaultumError("Base URL must use https or localhost", "INVALID_CONFIG");
|
|
1926
|
+
if (hasCredentials && !isHttps) throw new VaultumError("Credentials require https", "INVALID_CONFIG");
|
|
1927
|
+
return trimmed.replace(/\/$/, "");
|
|
1928
|
+
}
|
|
1929
|
+
function mapErrorCode(code, status) {
|
|
1930
|
+
if (code === "INVALID_USEROP") return "INVALID_USEROP";
|
|
1931
|
+
if (code === "INVALID_CONFIG") return "INVALID_CONFIG";
|
|
1932
|
+
if (code === "RATE_LIMITED" || status === 429) return "RATE_LIMITED";
|
|
1933
|
+
if (code === "UNAUTHORIZED" || status === 401) return "UNAUTHORIZED";
|
|
1934
|
+
if (code === "FORBIDDEN" || status === 403) return "FORBIDDEN";
|
|
1935
|
+
if (code === "NOT_FOUND" || status === 404) return "NOT_FOUND";
|
|
1936
|
+
if (status === 422) return "VALIDATION_ERROR";
|
|
1937
|
+
return "BUNDLER_ERROR";
|
|
1938
|
+
}
|
|
1939
|
+
function anySignal(signals) {
|
|
1940
|
+
const controller = new AbortController();
|
|
1941
|
+
for (const signal of signals) {
|
|
1942
|
+
if (signal.aborted) {
|
|
1943
|
+
controller.abort(signal.reason);
|
|
1944
|
+
return controller.signal;
|
|
1945
|
+
}
|
|
1946
|
+
signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
|
|
1947
|
+
}
|
|
1948
|
+
return controller.signal;
|
|
1949
|
+
}
|
|
1950
|
+
function sleep(ms, signal) {
|
|
1951
|
+
return new Promise((resolve, reject) => {
|
|
1952
|
+
if (signal?.aborted) {
|
|
1953
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
1954
|
+
return;
|
|
1955
|
+
}
|
|
1956
|
+
const timer = setTimeout(resolve, ms);
|
|
1957
|
+
signal?.addEventListener("abort", () => {
|
|
1958
|
+
clearTimeout(timer);
|
|
1959
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
1960
|
+
}, { once: true });
|
|
1961
|
+
});
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
// src/governance.ts
|
|
1965
|
+
var import_viem3 = require("viem");
|
|
1966
|
+
var GOVERNANCE_DOMAIN_NAME = "VaultumGovernance";
|
|
1967
|
+
var GOVERNANCE_DOMAIN_VERSION = "1";
|
|
1968
|
+
function buildCrossChainRootTypedData(params) {
|
|
1969
|
+
return {
|
|
1970
|
+
domain: {
|
|
1971
|
+
name: GOVERNANCE_DOMAIN_NAME,
|
|
1972
|
+
version: GOVERNANCE_DOMAIN_VERSION,
|
|
1973
|
+
chainId: params.chainId,
|
|
1974
|
+
verifyingContract: params.registry
|
|
1975
|
+
},
|
|
1976
|
+
types: {
|
|
1977
|
+
CrossChainRoot: [
|
|
1978
|
+
{ name: "merkleRoot", type: "bytes32" },
|
|
1979
|
+
{ name: "nonce", type: "uint256" },
|
|
1980
|
+
{ name: "validUntil", type: "uint64" }
|
|
1981
|
+
]
|
|
1982
|
+
},
|
|
1983
|
+
primaryType: "CrossChainRoot",
|
|
1984
|
+
message: {
|
|
1985
|
+
merkleRoot: params.merkleRoot,
|
|
1986
|
+
nonce: params.nonce,
|
|
1987
|
+
validUntil: params.validUntil
|
|
1988
|
+
}
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1991
|
+
function hashCrossChainRootTypedData(params) {
|
|
1992
|
+
return (0, import_viem3.hashTypedData)(buildCrossChainRootTypedData(params));
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
// src/index.ts
|
|
1996
|
+
var VERSION = "0.1.5";
|
|
1997
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1998
|
+
0 && (module.exports = {
|
|
1999
|
+
API,
|
|
2000
|
+
CONTRACTS,
|
|
2001
|
+
ENTRYPOINT_V07,
|
|
2002
|
+
FEATURE_IDS,
|
|
2003
|
+
FEATURE_ID_STRINGS,
|
|
2004
|
+
GOVERNANCE_DOMAIN_NAME,
|
|
2005
|
+
GOVERNANCE_DOMAIN_VERSION,
|
|
2006
|
+
UserOpBuilder,
|
|
2007
|
+
VERSION,
|
|
2008
|
+
VaultumClient,
|
|
2009
|
+
VaultumError,
|
|
2010
|
+
buildCrossChainRootTypedData,
|
|
2011
|
+
createUserOpBuilder,
|
|
2012
|
+
getUserOpHash,
|
|
2013
|
+
hashCrossChainRootTypedData,
|
|
2014
|
+
packGasFees,
|
|
2015
|
+
packGasLimits,
|
|
2016
|
+
parseQuoteResponse,
|
|
2017
|
+
unpackGasFees,
|
|
2018
|
+
unpackGasLimits
|
|
2019
|
+
});
|