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