@me.jango/signa 0.0.0-stage → 0.4.0

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/index.d.ts ADDED
@@ -0,0 +1,1607 @@
1
+ import { Address, Hex } from 'viem';
2
+
3
+ /** Why a payment reverted, as a stable code apps and agents branch on. */
4
+ type PayFailureReason = "TERMINAL_UNDER_MIN" | "BUYBACK_SLIPPAGE_EXCEEDED" | "BUYBACK_DERIVED_FLOOR_NOT_MET" | "BUYBACK_SWAP_AMOUNT_TOO_HIGH" | "ROUTER_SLIPPAGE_EXCEEDED" | "ROUTER_NO_ROUTE" | "TOKEN_NOT_ACCEPTED" | "PAYMENTS_PAUSED" | "NO_RULESET" | "ALLOWANCE_TOO_LOW" | "ALLOWANCE_EXPIRED" | "BALANCE_TOO_LOW" | "UNEXPECTED_ETH" | "NFT_SOLD_OUT" | "NFT_UNAVAILABLE" | "NFT_PRICE_ABOVE_PAYMENT" | "NFT_OVERSPENDING";
5
+ /**
6
+ * The setting a payer can relax so a retry clears the failing check.
7
+ * `minimum` is the payer's token minimum: the terminal's `minReturnedTokens`
8
+ * (`TERMINAL_UNDER_MIN`) or the buyback hook's explicit minimum in the pay
9
+ * metadata (`BUYBACK_SLIPPAGE_EXCEEDED`). `prepareUserPay` floors both by its
10
+ * `slippageBps`, so the fix is preparing again with the larger tolerance
11
+ * {@link payRetrySlippageBps} gives; lowering only `minReturnedTokens` leaves
12
+ * the hook's minimum where it was. Buyback hooks before 1.4 raise the same
13
+ * error for a floor they derive from their own price oracle, which no
14
+ * tolerance moves: the fresh preparation's simulation shows that. The
15
+ * router's conversion minimum is never adjustable: the router can derive it
16
+ * itself.
17
+ */
18
+ type PayFailureAdjustable = "minimum";
19
+ /**
20
+ * A decoded payment revert. `received` and `minimum` are set when the
21
+ * payment fell short of a minimum, in that check's units (for the router,
22
+ * the token it converts into), and `adjustable` names the setting a retry
23
+ * can relax, if any.
24
+ */
25
+ interface PayFailure$1 {
26
+ reason: PayFailureReason;
27
+ /** What the payment would have settled, in the minimum's units. */
28
+ received?: bigint;
29
+ /** The minimum it fell short of. */
30
+ minimum?: bigint;
31
+ /**
32
+ * Set with `received`: true when the failing check settled nothing, so a
33
+ * lower minimum is no fix and `message` does not suggest one. For the
34
+ * buyback hook that is the part it checked, not always the whole payment.
35
+ * Absent means unknown, not a fill.
36
+ */
37
+ zeroFill?: boolean;
38
+ /**
39
+ * Set only with a nonzero `received` below `minimum`: the setting the payer
40
+ * can relax so a retry clears the failing check. Absent when no setting
41
+ * the payer controls would help; never relax anything without it.
42
+ */
43
+ adjustable?: PayFailureAdjustable;
44
+ /** One plain sentence to show the payer. */
45
+ message: string;
46
+ }
47
+
48
+ /** Browser-safe primitives shared by the existing signed-request client and server. */
49
+ type BotScope = "read" | "plan" | "relay";
50
+
51
+ type RequestClaims = {
52
+ accountId: string;
53
+ signer: Address;
54
+ grantId: string;
55
+ method: string;
56
+ requestTarget: string;
57
+ contentType: string;
58
+ bodyHash: Hex;
59
+ issuedAt: number;
60
+ expiresAt: number;
61
+ nonce: Hex;
62
+ idempotencyKey: string;
63
+ };
64
+ type BotProof = {
65
+ accountId: string;
66
+ botAddress: Address;
67
+ scopes: BotScope[];
68
+ expiresAt: number;
69
+ label: string;
70
+ ownerRequestNonce: Hex;
71
+ };
72
+ declare function buildRequestTypedData(audience: string, claims: RequestClaims): {
73
+ domain: {
74
+ readonly name: "Juicebox Center REST";
75
+ readonly version: "1";
76
+ readonly chainId: number;
77
+ readonly salt: `0x${string}`;
78
+ };
79
+ types: {
80
+ readonly CenterRequest: readonly [{
81
+ readonly name: "audience";
82
+ readonly type: "string";
83
+ }, {
84
+ readonly name: "accountId";
85
+ readonly type: "string";
86
+ }, {
87
+ readonly name: "signer";
88
+ readonly type: "address";
89
+ }, {
90
+ readonly name: "grantId";
91
+ readonly type: "string";
92
+ }, {
93
+ readonly name: "method";
94
+ readonly type: "string";
95
+ }, {
96
+ readonly name: "requestTarget";
97
+ readonly type: "string";
98
+ }, {
99
+ readonly name: "contentType";
100
+ readonly type: "string";
101
+ }, {
102
+ readonly name: "bodyHash";
103
+ readonly type: "bytes32";
104
+ }, {
105
+ readonly name: "issuedAt";
106
+ readonly type: "uint64";
107
+ }, {
108
+ readonly name: "expiresAt";
109
+ readonly type: "uint64";
110
+ }, {
111
+ readonly name: "nonce";
112
+ readonly type: "bytes32";
113
+ }, {
114
+ readonly name: "idempotencyKey";
115
+ readonly type: "string";
116
+ }];
117
+ };
118
+ primaryType: "CenterRequest";
119
+ message: {
120
+ audience: string;
121
+ issuedAt: bigint;
122
+ expiresAt: bigint;
123
+ accountId: string;
124
+ signer: Address;
125
+ grantId: string;
126
+ method: string;
127
+ requestTarget: string;
128
+ contentType: string;
129
+ bodyHash: Hex;
130
+ nonce: Hex;
131
+ idempotencyKey: string;
132
+ };
133
+ };
134
+ declare function buildBotProofTypedData(audience: string, proof: BotProof): {
135
+ domain: {
136
+ readonly name: "Juicebox Center REST";
137
+ readonly version: "1";
138
+ readonly chainId: number;
139
+ readonly salt: `0x${string}`;
140
+ };
141
+ types: {
142
+ readonly CenterBotProof: readonly [{
143
+ readonly name: "audience";
144
+ readonly type: "string";
145
+ }, {
146
+ readonly name: "accountId";
147
+ readonly type: "string";
148
+ }, {
149
+ readonly name: "botAddress";
150
+ readonly type: "address";
151
+ }, {
152
+ readonly name: "scopes";
153
+ readonly type: "string[]";
154
+ }, {
155
+ readonly name: "expiresAt";
156
+ readonly type: "uint64";
157
+ }, {
158
+ readonly name: "label";
159
+ readonly type: "string";
160
+ }, {
161
+ readonly name: "ownerRequestNonce";
162
+ readonly type: "bytes32";
163
+ }];
164
+ };
165
+ primaryType: "CenterBotProof";
166
+ message: {
167
+ audience: string;
168
+ expiresAt: bigint;
169
+ accountId: string;
170
+ botAddress: Address;
171
+ scopes: BotScope[];
172
+ label: string;
173
+ ownerRequestNonce: Hex;
174
+ };
175
+ };
176
+
177
+ /** Identifies one immutable effect, including the exact serialized transaction signature. */
178
+ type TransactionApprovalBinding = {
179
+ accountId: string;
180
+ principalId: string;
181
+ planId: string;
182
+ commitment: Hex;
183
+ stepIndex: number;
184
+ transactionHash: Hex;
185
+ };
186
+ type TransactionApprovalClaims = TransactionApprovalBinding & {
187
+ issuedAt: number;
188
+ expiresAt: number;
189
+ nonce: Hex;
190
+ };
191
+ type TransactionApproval = TransactionApprovalClaims & {
192
+ signature: Hex;
193
+ };
194
+ type SponsorshipApprovalBinding = {
195
+ accountId: string;
196
+ principalId: string;
197
+ sponsorshipId: string;
198
+ commitment: Hex;
199
+ submissionHash: Hex;
200
+ };
201
+ type SponsorshipApprovalClaims = SponsorshipApprovalBinding & {
202
+ issuedAt: number;
203
+ expiresAt: number;
204
+ nonce: Hex;
205
+ };
206
+ type SponsorshipApproval = SponsorshipApprovalClaims & {
207
+ signature: Hex;
208
+ };
209
+ /** Browser-safe owner-wallet signing document; use a fresh cryptographically random nonce. */
210
+ declare function buildTransactionApprovalTypedData(audience: string, input: TransactionApprovalClaims): {
211
+ domain: {
212
+ name: string;
213
+ version: string;
214
+ chainId: number;
215
+ salt: `0x${string}`;
216
+ };
217
+ types: {
218
+ readonly CenterTransactionApproval: readonly [{
219
+ readonly name: "audience";
220
+ readonly type: "string";
221
+ }, {
222
+ readonly name: "accountId";
223
+ readonly type: "string";
224
+ }, {
225
+ readonly name: "principalId";
226
+ readonly type: "string";
227
+ }, {
228
+ readonly name: "planId";
229
+ readonly type: "string";
230
+ }, {
231
+ readonly name: "commitment";
232
+ readonly type: "bytes32";
233
+ }, {
234
+ readonly name: "stepIndex";
235
+ readonly type: "uint32";
236
+ }, {
237
+ readonly name: "transactionHash";
238
+ readonly type: "bytes32";
239
+ }, {
240
+ readonly name: "issuedAt";
241
+ readonly type: "uint64";
242
+ }, {
243
+ readonly name: "expiresAt";
244
+ readonly type: "uint64";
245
+ }, {
246
+ readonly name: "nonce";
247
+ readonly type: "bytes32";
248
+ }];
249
+ };
250
+ primaryType: "CenterTransactionApproval";
251
+ message: {
252
+ audience: string;
253
+ issuedAt: bigint;
254
+ expiresAt: bigint;
255
+ accountId: string;
256
+ principalId: string;
257
+ planId: string;
258
+ commitment: Hex;
259
+ stepIndex: number;
260
+ transactionHash: Hex;
261
+ nonce: Hex;
262
+ };
263
+ };
264
+ /** Approves publishing exact signed forward requests, independently of direct transaction relay. */
265
+ declare function buildSponsorshipApprovalTypedData(audience: string, input: SponsorshipApprovalClaims): {
266
+ domain: {
267
+ name: string;
268
+ version: string;
269
+ chainId: number;
270
+ salt: `0x${string}`;
271
+ };
272
+ types: {
273
+ readonly CenterSponsorshipApproval: readonly [{
274
+ readonly name: "audience";
275
+ readonly type: "string";
276
+ }, {
277
+ readonly name: "accountId";
278
+ readonly type: "string";
279
+ }, {
280
+ readonly name: "principalId";
281
+ readonly type: "string";
282
+ }, {
283
+ readonly name: "sponsorshipId";
284
+ readonly type: "string";
285
+ }, {
286
+ readonly name: "commitment";
287
+ readonly type: "bytes32";
288
+ }, {
289
+ readonly name: "submissionHash";
290
+ readonly type: "bytes32";
291
+ }, {
292
+ readonly name: "issuedAt";
293
+ readonly type: "uint64";
294
+ }, {
295
+ readonly name: "expiresAt";
296
+ readonly type: "uint64";
297
+ }, {
298
+ readonly name: "nonce";
299
+ readonly type: "bytes32";
300
+ }];
301
+ };
302
+ primaryType: "CenterSponsorshipApproval";
303
+ message: {
304
+ audience: string;
305
+ issuedAt: bigint;
306
+ expiresAt: bigint;
307
+ nonce: `0x${string}`;
308
+ accountId: string;
309
+ principalId: string;
310
+ sponsorshipId: string;
311
+ commitment: Hex;
312
+ submissionHash: Hex;
313
+ };
314
+ };
315
+
316
+ interface RestBlockEvidence {
317
+ chainId: number;
318
+ blockNumber: string;
319
+ blockHash: Hex;
320
+ timestamp: string;
321
+ source: "onchain";
322
+ }
323
+ interface RestCall {
324
+ chainId: number;
325
+ to: Address;
326
+ data: Hex;
327
+ value: string;
328
+ label: string;
329
+ dependsOn: number[];
330
+ decoded: unknown;
331
+ }
332
+ /** A reviewable plan contains no key material and conveys no signing authority. */
333
+ interface RestPlanDraft {
334
+ operation: string;
335
+ account: Address;
336
+ project?: {
337
+ chainId: number;
338
+ projectId: string;
339
+ version?: 6;
340
+ };
341
+ calls: RestCall[];
342
+ evidence: RestBlockEvidence[];
343
+ summary: unknown;
344
+ warnings: string[];
345
+ }
346
+ interface RestActor {
347
+ accountId: string;
348
+ /** Bot grant ID, or an owner principal distinguished from every bot. */
349
+ principalId: string;
350
+ }
351
+
352
+ type StepState = "waiting" | "reserved" | "submitted" | "unknown" | "confirming" | "confirmed" | "reverted" | "reorged";
353
+ interface SemanticResult {
354
+ /** Unknown modeled results block dependent steps; unmodeled calls are explicit. */
355
+ status: "verified" | "failed" | "unknown" | "unmodeled";
356
+ details?: unknown;
357
+ }
358
+ interface StoredReceipt {
359
+ transactionHash: Hex;
360
+ blockHash: Hex;
361
+ blockNumber: string;
362
+ status: "success" | "reverted";
363
+ confirmations: number;
364
+ canonical: boolean;
365
+ observedAt: number;
366
+ logs: unknown[];
367
+ /** Persistent records omit logs after semantic verification; these identify the full RPC log list. */
368
+ logCount?: number;
369
+ logsHash?: Hex;
370
+ logsStored?: boolean;
371
+ }
372
+ interface SignedAttempt {
373
+ hash: Hex;
374
+ rawTransaction: Hex;
375
+ sender: Address;
376
+ chainId: number;
377
+ nonce: string;
378
+ type: "legacy" | "eip2930" | "eip1559";
379
+ gas: string;
380
+ maximumFeePerGas: string;
381
+ /** Native value + gas limit * fee cap; excludes additional rollup data/operator charges. */
382
+ maximumCost: string;
383
+ reservedAt: number;
384
+ leaseToken: string;
385
+ leaseUntil: number;
386
+ dispatchCount: number;
387
+ broadcastAt?: number;
388
+ lastError?: {
389
+ code: string;
390
+ message: string;
391
+ };
392
+ }
393
+ interface StoredStep {
394
+ index: number;
395
+ state: StepState;
396
+ attempt?: SignedAttempt;
397
+ /** A forwarded execution is not an owner-signed EOA transaction attempt. */
398
+ externalExecution?: ExternalExecution;
399
+ receipt?: StoredReceipt;
400
+ semantic?: SemanticResult;
401
+ }
402
+ interface ExternalExecution {
403
+ transport: "relayr" | "erc4337";
404
+ bindingId: string;
405
+ chainId: number;
406
+ transactionHash?: Hex;
407
+ }
408
+ interface StoredPlan {
409
+ id: string;
410
+ actor: RestActor;
411
+ draft: RestPlanDraft;
412
+ commitment: Hex;
413
+ createdAt: number;
414
+ expiresAt: number;
415
+ revision: number;
416
+ /** Verified owner binding for a contract wallet. It never grants EOA relay authority. */
417
+ smartAccount?: {
418
+ bindingId: Hex;
419
+ stateHash: Hex;
420
+ chainId: number;
421
+ address: Address;
422
+ manifestRevision: Hex;
423
+ };
424
+ steps: StoredStep[];
425
+ }
426
+
427
+ /** Standard unpacked EntryPoint v0.7 RPC representation. No v0.8/7702 extensions. */
428
+ interface UserOperationV07 {
429
+ sender: Address;
430
+ nonce: Hex;
431
+ factory?: Address;
432
+ factoryData?: Hex;
433
+ callData: Hex;
434
+ callGasLimit: Hex;
435
+ verificationGasLimit: Hex;
436
+ preVerificationGas: Hex;
437
+ maxFeePerGas: Hex;
438
+ maxPriorityFeePerGas: Hex;
439
+ paymaster?: Address;
440
+ paymasterVerificationGasLimit?: Hex;
441
+ paymasterPostOpGasLimit?: Hex;
442
+ paymasterData?: Hex;
443
+ signature: Hex;
444
+ }
445
+ /** Why one payment attempt reverted, as the SDK's `decodePayFailure` reads it from revert data, with
446
+ * amounts as decimal strings in the failing check's units. Advisory and specific to that attempt:
447
+ * `received` and `minimum` are set only for a shortfall, and any changed minimum needs a fresh
448
+ * preparation, simulation and owner review. The message is the SDK's fixed sentence, never node text. */
449
+ interface PayFailure {
450
+ reason: string;
451
+ received?: string;
452
+ minimum?: string;
453
+ message: string;
454
+ }
455
+ interface UserOperationObservation {
456
+ /** `expired`: never included and past its validity window, so it can no longer execute. */
457
+ state: "pending" | "unknown" | "confirming" | "confirmed" | "reverted" | "expired";
458
+ operationHash: Hex;
459
+ transactionHash?: Hex;
460
+ receipt?: StoredReceipt;
461
+ /** Logs are restricted to this operation's execution interval in the EntryPoint bundle. */
462
+ scopedLogs?: readonly unknown[];
463
+ semantic?: SemanticResult;
464
+ reason?: string;
465
+ /** When this observation was made (ms); a poll within moments of it answers from it. */
466
+ observedAt?: number;
467
+ /** The execution block at which the account's authority was verified for this observation. */
468
+ verifiedAtBlock?: Hex;
469
+ /** Why a reverted payment reverted, when its trace shows a known payment revert. */
470
+ payFailure?: PayFailure;
471
+ }
472
+
473
+ interface Safe7579OwnerSigningInput {
474
+ operation: UserOperationV07;
475
+ chainId: number;
476
+ safe7579: Address;
477
+ entryPoint: Address;
478
+ validAfter: string;
479
+ validUntil: string;
480
+ }
481
+ declare function safe7579OwnerSigningPayload(input: Safe7579OwnerSigningInput): {
482
+ scheme: "eip712-safe7579-owner";
483
+ digest: `0x${string}`;
484
+ typedData: {
485
+ domain: {
486
+ chainId: number;
487
+ verifyingContract: `0x${string}`;
488
+ };
489
+ message: {
490
+ nonce: string;
491
+ verificationGasLimit: string;
492
+ callGasLimit: string;
493
+ preVerificationGas: string;
494
+ maxPriorityFeePerGas: string;
495
+ maxFeePerGas: string;
496
+ validAfter: string;
497
+ validUntil: string;
498
+ safe: `0x${string}`;
499
+ initCode: `0x${string}`;
500
+ callData: `0x${string}`;
501
+ paymasterAndData: `0x${string}`;
502
+ entryPoint: `0x${string}`;
503
+ };
504
+ types: {
505
+ readonly EIP712Domain: readonly [{
506
+ readonly name: "chainId";
507
+ readonly type: "uint256";
508
+ }, {
509
+ readonly name: "verifyingContract";
510
+ readonly type: "address";
511
+ }];
512
+ readonly SafeOp: readonly [{
513
+ readonly name: "safe";
514
+ readonly type: "address";
515
+ }, {
516
+ readonly name: "nonce";
517
+ readonly type: "uint256";
518
+ }, {
519
+ readonly name: "initCode";
520
+ readonly type: "bytes";
521
+ }, {
522
+ readonly name: "callData";
523
+ readonly type: "bytes";
524
+ }, {
525
+ readonly name: "verificationGasLimit";
526
+ readonly type: "uint128";
527
+ }, {
528
+ readonly name: "callGasLimit";
529
+ readonly type: "uint128";
530
+ }, {
531
+ readonly name: "preVerificationGas";
532
+ readonly type: "uint256";
533
+ }, {
534
+ readonly name: "maxPriorityFeePerGas";
535
+ readonly type: "uint128";
536
+ }, {
537
+ readonly name: "maxFeePerGas";
538
+ readonly type: "uint128";
539
+ }, {
540
+ readonly name: "paymasterAndData";
541
+ readonly type: "bytes";
542
+ }, {
543
+ readonly name: "validAfter";
544
+ readonly type: "uint48";
545
+ }, {
546
+ readonly name: "validUntil";
547
+ readonly type: "uint48";
548
+ }, {
549
+ readonly name: "entryPoint";
550
+ readonly type: "address";
551
+ }];
552
+ };
553
+ primaryType: "SafeOp";
554
+ };
555
+ validAfter: string;
556
+ validUntil: string;
557
+ };
558
+ interface LegacySessionSigningInput {
559
+ operation: UserOperationV07;
560
+ chainId: number;
561
+ entryPoint: Address;
562
+ smartSessions: Address;
563
+ permissionId: Hex;
564
+ }
565
+ /** ff742c54 OwnableValidator.validateSignatureWithData prefixes the 32-byte UserOp hash. */
566
+ declare function legacySessionSigningPayload(input: LegacySessionSigningInput): {
567
+ scheme: "eip191-legacy-ownable-user-operation";
568
+ operationHash: `0x${string}`;
569
+ digest: `0x${string}`;
570
+ message: {
571
+ raw: `0x${string}`;
572
+ };
573
+ permissionId: `0x${string}`;
574
+ /** The prefix is an envelope selector, not an additional field in the signed UserOp hash. */
575
+ signaturePrefix: `0x${string}`;
576
+ };
577
+
578
+ /** The legacy Safe owner ERC-1271 selector hashes this preimage once, just like checkSignatures. */
579
+ declare function safe7579PasskeyOwnerSigningPayload(input: Safe7579OwnerSigningInput): {
580
+ signedData: `0x${string}`;
581
+ scheme: "eip712-safe7579-owner";
582
+ digest: `0x${string}`;
583
+ typedData: {
584
+ domain: {
585
+ chainId: number;
586
+ verifyingContract: `0x${string}`;
587
+ };
588
+ message: {
589
+ nonce: string;
590
+ verificationGasLimit: string;
591
+ callGasLimit: string;
592
+ preVerificationGas: string;
593
+ maxPriorityFeePerGas: string;
594
+ maxFeePerGas: string;
595
+ validAfter: string;
596
+ validUntil: string;
597
+ safe: `0x${string}`;
598
+ initCode: `0x${string}`;
599
+ callData: `0x${string}`;
600
+ paymasterAndData: `0x${string}`;
601
+ entryPoint: `0x${string}`;
602
+ };
603
+ types: {
604
+ readonly EIP712Domain: readonly [{
605
+ readonly name: "chainId";
606
+ readonly type: "uint256";
607
+ }, {
608
+ readonly name: "verifyingContract";
609
+ readonly type: "address";
610
+ }];
611
+ readonly SafeOp: readonly [{
612
+ readonly name: "safe";
613
+ readonly type: "address";
614
+ }, {
615
+ readonly name: "nonce";
616
+ readonly type: "uint256";
617
+ }, {
618
+ readonly name: "initCode";
619
+ readonly type: "bytes";
620
+ }, {
621
+ readonly name: "callData";
622
+ readonly type: "bytes";
623
+ }, {
624
+ readonly name: "verificationGasLimit";
625
+ readonly type: "uint128";
626
+ }, {
627
+ readonly name: "callGasLimit";
628
+ readonly type: "uint128";
629
+ }, {
630
+ readonly name: "preVerificationGas";
631
+ readonly type: "uint256";
632
+ }, {
633
+ readonly name: "maxPriorityFeePerGas";
634
+ readonly type: "uint128";
635
+ }, {
636
+ readonly name: "maxFeePerGas";
637
+ readonly type: "uint128";
638
+ }, {
639
+ readonly name: "paymasterAndData";
640
+ readonly type: "bytes";
641
+ }, {
642
+ readonly name: "validAfter";
643
+ readonly type: "uint48";
644
+ }, {
645
+ readonly name: "validUntil";
646
+ readonly type: "uint48";
647
+ }, {
648
+ readonly name: "entryPoint";
649
+ readonly type: "address";
650
+ }];
651
+ };
652
+ primaryType: "SafeOp";
653
+ };
654
+ validAfter: string;
655
+ validUntil: string;
656
+ };
657
+
658
+ type Profile = {
659
+ displayName: string;
660
+ bio: string;
661
+ avatarUri: string | null;
662
+ };
663
+ type Account = {
664
+ id: string;
665
+ ownerAddress: Address;
666
+ authorityChainId: number;
667
+ profile: Profile;
668
+ createdAt: number;
669
+ updatedAt: number;
670
+ };
671
+ type BotGrant = {
672
+ id: string;
673
+ accountId: string;
674
+ botAddress: Address;
675
+ scopes: BotScope[];
676
+ label: string;
677
+ createdAt: number;
678
+ expiresAt: number;
679
+ revokedAt: number | null;
680
+ };
681
+
682
+ interface ContractPin {
683
+ address: Address;
684
+ runtimeCodeHash: Hex;
685
+ source: {
686
+ repository: string;
687
+ commit?: string;
688
+ contentSha256?: string;
689
+ artifactSha256: string;
690
+ };
691
+ }
692
+ /** Explicit opt-in; the legacy EOA profile remains the default for existing manifests. */
693
+ interface PasskeyOwnerProfile {
694
+ version: "center-passkey-v1";
695
+ signerFactory: ContractPin;
696
+ signerSingleton: ContractPin;
697
+ /** Reviewed Solidity FCL verifier only. No implicit chain precompile assumption. */
698
+ p256Verifier: ContractPin;
699
+ }
700
+ interface PasskeySignerState {
701
+ address: Address;
702
+ kind: "contract";
703
+ x: Hex;
704
+ y: Hex;
705
+ verifiers: Hex;
706
+ runtimeCodeHash: Hex;
707
+ }
708
+ interface PasskeyOwnerState {
709
+ version: "center-passkey-v1";
710
+ /** The primary passkey: the last contract owner in the Safe's list, which additions never move. */
711
+ signer: PasskeySignerState;
712
+ recoveryOwner: {
713
+ address: Address;
714
+ kind: "ecdsa";
715
+ };
716
+ /** Further passkeys added as devices, in the Safe's owner order. Absent when there are none, so
717
+ * states without devices keep their exact prior shape and digests. */
718
+ devices?: PasskeySignerState[];
719
+ }
720
+ interface PasskeyCreationProfile {
721
+ version: "center-passkey-bootstrap-v1";
722
+ multiSend: ContractPin;
723
+ }
724
+ /** Server-owned reviewed deployment configuration. Never accepted from HTTP request bodies. */
725
+ interface SmartAccountManifest {
726
+ id: string;
727
+ mode: "ownership-only" | "execution-candidate";
728
+ chainId: number;
729
+ revision: Hex;
730
+ safeVersion: "1.4.1";
731
+ proxyRuntimeCodeHash: Hex;
732
+ singleton: ContractPin;
733
+ factory: ContractPin;
734
+ safe7579: ContractPin;
735
+ launchpad: ContractPin;
736
+ /** Omitted for an ownership-binding-only manifest whose EntryPoint source identity is unproved. */
737
+ entryPoint?: ContractPin & {
738
+ version: "0.7";
739
+ };
740
+ smartSessions: ContractPin & {
741
+ generation: "legacy-validator" | "emissary";
742
+ };
743
+ policies: readonly ContractPin[];
744
+ /** Pin the adapter that enumerates validators/executors/hooks/fallbacks/attesters. */
745
+ moduleInspectorId: string;
746
+ ownerProfile?: PasskeyOwnerProfile;
747
+ creationProfile?: PasskeyCreationProfile;
748
+ }
749
+ interface ModuleStateEvidence {
750
+ /** Hash of the complete module/validator/hook/fallback/registry/attester configuration. */
751
+ stateHash: Hex;
752
+ complete: true;
753
+ arbitrarySigningDisabled: true;
754
+ wildcardExecutionDisabled: true;
755
+ details: unknown;
756
+ }
757
+ interface SmartAccountState {
758
+ chainId: number;
759
+ address: Address;
760
+ manifestId: string;
761
+ manifestRevision: Hex;
762
+ owners: Address[];
763
+ threshold: number;
764
+ safeNonce: string;
765
+ stateHash: Hex;
766
+ evidence: RestBlockEvidence;
767
+ codeHashes: {
768
+ address: Address;
769
+ runtimeCodeHash: Hex;
770
+ }[];
771
+ modules: ModuleStateEvidence | null;
772
+ moduleConfigurationVerified: boolean;
773
+ executionVerified: boolean;
774
+ ownerProfile?: PasskeyOwnerState;
775
+ }
776
+ interface SmartAccountBinding {
777
+ id: Hex;
778
+ ownerAccountId: string;
779
+ ownerAddress: Address;
780
+ wallet: {
781
+ chainId: number;
782
+ address: Address;
783
+ };
784
+ manifestId: string;
785
+ authorization: {
786
+ digest: Hex;
787
+ nonce: Hex;
788
+ expiresAt: number;
789
+ method: "safe-current-owner-threshold" | "safe-current-owner-threshold-and-api-grant" | "safe-passkey-owner-threshold-and-api-grant" | "center-wallet-passkey-creation-v1";
790
+ setup?: {
791
+ manifestRevision: Hex;
792
+ initializerHash: Hex;
793
+ issuedAt: number;
794
+ grantId: string;
795
+ botAddress: Address;
796
+ scopes: BotScope[];
797
+ grantExpiresAt: number;
798
+ label: string;
799
+ };
800
+ };
801
+ state: SmartAccountState;
802
+ }
803
+ interface Allocation {
804
+ id: string;
805
+ chainId: number;
806
+ asset: Address;
807
+ limit: string;
808
+ }
809
+ interface AllocationGroup {
810
+ id: string;
811
+ total: string;
812
+ allocations: Allocation[];
813
+ }
814
+ type SessionAction = {
815
+ kind: "v6-project-uri";
816
+ controller: Address;
817
+ projectId: string;
818
+ } | {
819
+ kind: "erc20-transfer";
820
+ allocationId: string;
821
+ beneficiary: Address;
822
+ perCallLimit: string;
823
+ totalLimit: string;
824
+ } | {
825
+ kind: "v6-pay";
826
+ allocationId: string;
827
+ terminal: Address;
828
+ projectId: string;
829
+ beneficiary: Address;
830
+ perCallLimit: string;
831
+ totalLimit: string;
832
+ /** Exact minimum; the bot cannot replace it with zero. */
833
+ minReturnedTokens: string;
834
+ };
835
+ interface SessionPolicyInput {
836
+ bindingId: Hex;
837
+ grantId: string;
838
+ generation: string;
839
+ nonce: Hex;
840
+ validAfter: number;
841
+ durationDays: 7 | 30;
842
+ maximumCalls: string;
843
+ gasBudget?: {
844
+ paymaster: Address;
845
+ maxGasPerOperation: string;
846
+ maxFeePerGas: string;
847
+ maxPriorityFeePerGas: string;
848
+ totalGasLimit: string;
849
+ totalSponsoredCostLimit: string;
850
+ maxPaymasterDataLength: number;
851
+ };
852
+ allocations: AllocationGroup[];
853
+ actions: SessionAction[];
854
+ }
855
+
856
+ type CreationInput = {
857
+ manifest: SmartAccountManifest;
858
+ owners: readonly Address[];
859
+ threshold: number;
860
+ saltNonce: string;
861
+ };
862
+ /** Pure preparation only. The owner signs and funds the factory transaction in their wallet. */
863
+ declare function prepareSafe7579Creation(input: CreationInput): {
864
+ chainId: number;
865
+ manifestId: string;
866
+ manifestRevision: `0x${string}`;
867
+ address: `0x${string}`;
868
+ owners: `0x${string}`[];
869
+ threshold: number;
870
+ saltNonce: string;
871
+ initializer: `0x${string}`;
872
+ initializerHash: `0x${string}`;
873
+ transaction: {
874
+ to: `0x${string}`;
875
+ value: "0";
876
+ data: `0x${string}`;
877
+ };
878
+ initialAuthority: {
879
+ validator: `0x${string}`;
880
+ enabledSessions: number;
881
+ executors: never[];
882
+ hooks: never[];
883
+ fallbacks: never[];
884
+ registryEnforced: false;
885
+ };
886
+ };
887
+
888
+ interface LegacyPolicyData {
889
+ policy: Address;
890
+ initData: Hex;
891
+ }
892
+ interface LegacyActionData {
893
+ actionTargetSelector: Hex;
894
+ actionTarget: Address;
895
+ actionPolicies: LegacyPolicyData[];
896
+ }
897
+ /** Exact f24dddf Session tuple; this type is not accepted as caller-supplied policy authority. */
898
+ interface LegacySession {
899
+ sessionValidator: Address;
900
+ sessionValidatorInitData: Hex;
901
+ salt: Hex;
902
+ userOpPolicies: LegacyPolicyData[];
903
+ erc7739Policies: {
904
+ allowedERC7739Content: [];
905
+ erc1271Policies: [];
906
+ };
907
+ actions: LegacyActionData[];
908
+ permitERC4337Paymaster: boolean;
909
+ }
910
+ interface CompiledPolicyConfiguration {
911
+ kind: "time-frame" | "universal-action" | "value-limit" | "usage-limit" | "gas-budget";
912
+ policy: ContractPin;
913
+ configId: Hex;
914
+ scope: "user-operation" | "action";
915
+ actionId?: Hex;
916
+ initData: Hex;
917
+ decoded: unknown;
918
+ }
919
+ interface CompiledSession {
920
+ schemaVersion: 1;
921
+ stack: "legacy-f24dddf-safe7579-f22a194";
922
+ ownerAccountId: string;
923
+ bindingId: Hex;
924
+ grantId: string;
925
+ sessionKey: Address;
926
+ chainId: number;
927
+ wallet: Address;
928
+ generation: string;
929
+ nonce: Hex;
930
+ validAfter: number;
931
+ validUntil: number;
932
+ salt: Hex;
933
+ policyHash: Hex;
934
+ compiledHash: Hex;
935
+ permissionId: Hex;
936
+ manifestRevision: Hex;
937
+ /** Owner review includes this nonce; revocation must advance it and remove the session. */
938
+ activationEnableNonce: string;
939
+ reviewedPolicy: unknown;
940
+ smartSessions: ContractPin;
941
+ sessionValidator: ContractPin;
942
+ session: LegacySession;
943
+ configurations: CompiledPolicyConfiguration[];
944
+ }
945
+ interface InstalledSessionObservation {
946
+ permissionId: Hex;
947
+ compiledHash: Hex;
948
+ account: Address;
949
+ chainId: number;
950
+ enabled: boolean;
951
+ enableNonce: string;
952
+ configurationHash: Hex;
953
+ evidence: RestBlockEvidence;
954
+ counters: {
955
+ policy: Address;
956
+ configId: Hex;
957
+ name: string;
958
+ used: string;
959
+ limit: string;
960
+ }[];
961
+ /** Complete canonical administration trace evidence attached by the lifecycle service at the same block. */
962
+ administration?: {
963
+ epoch: string;
964
+ hash: Hex;
965
+ lastInitialization?: {
966
+ epoch: string;
967
+ permissionIds: Hex[];
968
+ };
969
+ };
970
+ }
971
+
972
+ type SessionState = "prepared" | "installing" | "active" | "revoking" | "revoked" | "expired" | "stale";
973
+ interface SessionAllocation {
974
+ id: string;
975
+ chainId: number;
976
+ asset: Address;
977
+ limit: string;
978
+ assetReviewId: string;
979
+ }
980
+ interface SessionAllocationGroup {
981
+ id: string;
982
+ assetIdentity: string;
983
+ decimals: number;
984
+ total: string;
985
+ allocations: SessionAllocation[];
986
+ }
987
+ /** Verified server-side consent for this exact owner-approved setup/revocation plan. */
988
+ interface SessionOwnerApproval {
989
+ kind: "activation" | "revocation";
990
+ accountId: string;
991
+ sessionId: string;
992
+ policyHash: Hex;
993
+ compiledHash: Hex;
994
+ planId: string;
995
+ planCommitment: Hex;
996
+ digest: Hex;
997
+ issuedAt: number;
998
+ expiresAt: number;
999
+ }
1000
+ interface SessionCanonicalObservation {
1001
+ /** Comes from the trusted installed-policy verifier, never an HTTP proof body. */
1002
+ installed: InstalledSessionObservation;
1003
+ observedAt: number;
1004
+ /** True only after the host independently verifies chain finality for this exact block. */
1005
+ finalized: boolean;
1006
+ proofHash: Hex;
1007
+ }
1008
+ interface SessionInvalidation {
1009
+ reason: "reorg" | "configuration-changed" | "counter-reset" | "grant-inactive" | "binding-unlinked" | "verification-unavailable";
1010
+ priorProofHash: Hex | null;
1011
+ observedAt: number;
1012
+ }
1013
+ interface StoredSession {
1014
+ id: string;
1015
+ actor: RestActor;
1016
+ compiled: CompiledSession;
1017
+ /** Complete canonical administration baseline from the verified preparation block. Immutable. */
1018
+ preparedAdministration: {
1019
+ epoch: string;
1020
+ hash: Hex;
1021
+ };
1022
+ /** Full normalized approved grouping, including sibling-chain allocations; no shared balance is inferred. */
1023
+ allocationGroups: SessionAllocationGroup[];
1024
+ allocationManifestHash: Hex;
1025
+ createdAt: number;
1026
+ updatedAt: number;
1027
+ revision: number;
1028
+ state: SessionState;
1029
+ activation?: SessionOwnerApproval;
1030
+ revocation?: SessionOwnerApproval;
1031
+ supersededApprovals?: {
1032
+ approval: SessionOwnerApproval;
1033
+ supersededAt: number;
1034
+ }[];
1035
+ observation?: SessionCanonicalObservation;
1036
+ invalidation?: SessionInvalidation;
1037
+ /** Finalized retirement only; identity tombstones remain permanent. */
1038
+ reservationsReleased: boolean;
1039
+ }
1040
+ interface UserOperationSessionBinding {
1041
+ id: string;
1042
+ policyHash: Hex;
1043
+ compiledHash: Hex;
1044
+ generation: string;
1045
+ grantId: string;
1046
+ permissionId: Hex;
1047
+ sessionKey: Address;
1048
+ observationHash: Hex;
1049
+ }
1050
+ interface SessionQuota {
1051
+ sessionId: string;
1052
+ state: SessionState;
1053
+ allocationManifestHash: Hex;
1054
+ approvedGroups: SessionAllocationGroup[];
1055
+ localAllocations: SessionAllocation[];
1056
+ counters: InstalledSessionObservation["counters"] | null;
1057
+ observation: SessionCanonicalObservation | null;
1058
+ reservationsReleased: boolean;
1059
+ executionAuthority: false;
1060
+ balanceSource: "onchain-only";
1061
+ atomicAcrossChains: false;
1062
+ }
1063
+
1064
+ interface UserOperationRecord {
1065
+ id: string;
1066
+ actor: RestActor;
1067
+ planId: string;
1068
+ planCommitment: Hex;
1069
+ stepIndexes: number[];
1070
+ chainId: number;
1071
+ entryPoint: Address;
1072
+ sender: Address;
1073
+ operation: UserOperationV07;
1074
+ operationHash: Hex;
1075
+ preparationKey: string;
1076
+ inputHash: Hex;
1077
+ commitment: Hex;
1078
+ accountBindingId: Hex;
1079
+ accountStateHash: Hex;
1080
+ session?: UserOperationSessionBinding;
1081
+ gasPolicyId: string;
1082
+ providerId: string;
1083
+ createdAt: number;
1084
+ expiresAt: number;
1085
+ revision: number;
1086
+ /** `retired`: approved, never sent, and refused for good; nothing claims or resends it. */
1087
+ state: 'prepared' | 'submitting' | 'submission_unknown' | 'retired' | UserOperationObservation['state'];
1088
+ submission?: {
1089
+ key: string;
1090
+ commitment: Hex;
1091
+ operation: UserOperationV07;
1092
+ startedAt: number;
1093
+ sessionObservationHash?: Hex;
1094
+ };
1095
+ observation?: UserOperationObservation;
1096
+ /** When the chain settled a retired operation: it never ran and never can, or Signa's own operation took its nonce. */
1097
+ retiredSettledAt?: number;
1098
+ }
1099
+
1100
+ interface WalletTypedData {
1101
+ domain: Record<string, unknown>;
1102
+ types: Record<string, readonly {
1103
+ name: string;
1104
+ type: string;
1105
+ }[]>;
1106
+ primaryType: string;
1107
+ message: Record<string, unknown>;
1108
+ }
1109
+ interface SmartAccountCapabilities {
1110
+ deployments: {
1111
+ manifestId: string;
1112
+ chainId: number;
1113
+ mode: string;
1114
+ revision: Hex;
1115
+ moduleGeneration: string;
1116
+ moduleInspectionConfigured: boolean;
1117
+ entryPointSourceVerified: boolean;
1118
+ manifest?: SmartAccountManifest;
1119
+ }[];
1120
+ requirements: string[];
1121
+ walletCreation: boolean;
1122
+ userOperationPreparation?: boolean;
1123
+ userOperationSimulation?: boolean;
1124
+ userOperationRelay?: boolean;
1125
+ sessionDurationsDays: number[];
1126
+ }
1127
+ interface BindingRequest {
1128
+ manifestId: string;
1129
+ address: Address;
1130
+ nonce: Hex;
1131
+ expiresAt: number;
1132
+ }
1133
+ interface BindingChallenge {
1134
+ state: SmartAccountState;
1135
+ typedData: WalletTypedData;
1136
+ digest: Hex;
1137
+ }
1138
+ interface WalletCreationRequest {
1139
+ manifestId: string;
1140
+ owners: Address[];
1141
+ threshold: number;
1142
+ saltNonce: string;
1143
+ }
1144
+ type WalletCreationPreparation = ReturnType<typeof prepareSafe7579Creation> & {
1145
+ deploymentConfirmed: false;
1146
+ evidence: unknown;
1147
+ };
1148
+ type OwnerSigningPayload = ReturnType<typeof safe7579OwnerSigningPayload>;
1149
+ /** Contract owners sign this exact SafeOp digest using a WebAuthn assertion; its dynamic
1150
+ * envelope is distinct from the EOA-only ownerOperationSignature packing helper below.
1151
+ * The profile field describes the prepared encoding, not deployment or provider readiness.
1152
+ */
1153
+ type PasskeyOwnerSigningPayload = ReturnType<typeof safe7579PasskeyOwnerSigningPayload> & {
1154
+ ownerProfile: "center-passkey-v1";
1155
+ };
1156
+ type SessionSigningPayload = ReturnType<typeof legacySessionSigningPayload>;
1157
+ type SmartWalletPlan = Pick<StoredPlan, "id" | "draft" | "commitment" | "createdAt" | "expiresAt" | "revision" | "smartAccount"> & {
1158
+ steps: Pick<StoredPlan["steps"][number], "index" | "state">[];
1159
+ status?: string;
1160
+ };
1161
+ /** The HTTP view deliberately excludes actor, sender (available on operation), and signed bytes. */
1162
+ type PreparedUserOperation = Omit<UserOperationRecord, "actor" | "sender" | "submission" | "preparationKey" | "inputHash"> & {
1163
+ signing: OwnerSigningPayload | PasskeyOwnerSigningPayload | SessionSigningPayload;
1164
+ submission?: {
1165
+ commitment: Hex;
1166
+ startedAt: number;
1167
+ };
1168
+ };
1169
+ /** Public-key material, policies and signatures only. This facade never accepts a private key. */
1170
+ declare class SmartAccountClient {
1171
+ readonly client: SignedRestClient;
1172
+ constructor(client: SignedRestClient);
1173
+ private post;
1174
+ capabilities(): Promise<SmartAccountCapabilities>;
1175
+ prepareCreation(input: WalletCreationRequest, key?: string): Promise<{
1176
+ creation: WalletCreationPreparation;
1177
+ }>;
1178
+ challenge(input: BindingRequest): Promise<BindingChallenge>;
1179
+ bind(input: BindingRequest & {
1180
+ stateHash: Hex;
1181
+ signature: Hex;
1182
+ }, key?: string): Promise<SmartAccountBinding>;
1183
+ bindings(): Promise<{
1184
+ items: Pick<SmartAccountBinding, "id" | "wallet" | "manifestId">[];
1185
+ }>;
1186
+ binding(bindingId: Hex): Promise<SmartAccountBinding>;
1187
+ preparePlan(bindingId: Hex, operation: string, input: unknown, key?: string): Promise<SmartWalletPlan>;
1188
+ prepareSession(input: SessionPolicyInput, key?: string): Promise<StoredSession>;
1189
+ session(sessionId: string): Promise<StoredSession>;
1190
+ quota(sessionId: string): Promise<SessionQuota>;
1191
+ sessionPlan(sessionId: string, kind: "activation" | "revocation", compiledHash: Hex, key?: string): Promise<{
1192
+ session: StoredSession;
1193
+ plan: SmartWalletPlan;
1194
+ installationConfirmed: boolean;
1195
+ }>;
1196
+ prepareUserOperation(input: {
1197
+ planId: string;
1198
+ stepIndexes: number[];
1199
+ sessionId?: string;
1200
+ }, key?: string): Promise<PreparedUserOperation>;
1201
+ /** One call: the plan (idempotent on `plan.idempotencyKey`) and the sponsored operation over every
1202
+ * one of its steps (idempotent on `key`). When the voucher does not cover the plan Center built,
1203
+ * the answer carries the plan alone and `sponsorship: "refused"`, to be sponsored on its own. */
1204
+ prepareSponsoredPayment(plan: {
1205
+ bindingId: Hex;
1206
+ operation: string;
1207
+ input: unknown;
1208
+ idempotencyKey: string;
1209
+ }, sponsorAuthorization: string, key?: string): Promise<{
1210
+ plan: SmartWalletPlan;
1211
+ operation?: PreparedUserOperation;
1212
+ sponsorship: "accepted" | "refused";
1213
+ }>;
1214
+ submitUserOperation(operationId: string, signature: Hex, key?: string): Promise<PreparedUserOperation>;
1215
+ /** With `wait`, the answer is held (up to 20 s) until the operation moves past the revision seen. */
1216
+ /** Retires an operation nothing has sent, so it is never claimed or sent again; one already claimed comes back with its submission. */
1217
+ retireUserOperation(operationId: string): Promise<PreparedUserOperation>;
1218
+ userOperation(operationId: string, wait?: {
1219
+ seconds: number;
1220
+ since: number;
1221
+ }): Promise<PreparedUserOperation>;
1222
+ }
1223
+ declare function assertReviewedOperation(record: PreparedUserOperation, plan: SmartWalletPlan, now?: number): void;
1224
+ /** EOA signing view, also usable by the passkey profile's independent recovery EOA.
1225
+ * Passkey callers use PreparedUserOperation.signing's explicit profile and signedData.
1226
+ */
1227
+ declare function ownerOperationSigning(input: Safe7579OwnerSigningInput & {
1228
+ record: PreparedUserOperation;
1229
+ binding: SmartAccountBinding;
1230
+ }): OwnerSigningPayload;
1231
+ /** Packs EOA signatures only. WebAuthn assertions require the profile's dynamic contract envelope. */
1232
+ declare function ownerOperationSignature(payload: OwnerSigningPayload, binding: SmartAccountBinding, signatures: readonly Hex[]): Promise<`0x${string}`>;
1233
+
1234
+ /** v0.7 required-prefund formula; unlike v0.6 it has separate paymaster gas limits. */
1235
+ declare function userOperationMaximumCost(operation: UserOperationV07): bigint;
1236
+
1237
+ type RestSigner = {
1238
+ address: Address;
1239
+ /** Required only for locally signing operations under an activated bot wallet permission. */
1240
+ signMessage?(input: {
1241
+ message: {
1242
+ raw: Hex;
1243
+ };
1244
+ }): Promise<Hex>;
1245
+ signTypedData: {
1246
+ (document: ReturnType<typeof buildRequestTypedData>): Promise<Hex>;
1247
+ (document: ReturnType<typeof buildBotProofTypedData>): Promise<Hex>;
1248
+ };
1249
+ };
1250
+ type RequestOptions = {
1251
+ method?: string;
1252
+ /** Exact ASCII origin-form path including its already-encoded query. */
1253
+ requestTarget: string;
1254
+ json?: unknown;
1255
+ /** Raw bytes and json are mutually exclusive. Bytes are copied before signing. */
1256
+ body?: Uint8Array;
1257
+ contentType?: string;
1258
+ idempotencyKey?: string;
1259
+ /** Reserved for a bot proof bound to this owner's nonce. Such requests cannot auto-retry. */
1260
+ nonce?: Hex;
1261
+ retries?: number;
1262
+ /** A request the server holds on purpose (a waiting read) gets its own bound, at most 60 s. */
1263
+ timeoutMs?: number;
1264
+ };
1265
+ type ClientOptions = {
1266
+ audience: string;
1267
+ accountId: string;
1268
+ signer: RestSigner;
1269
+ grantId?: string;
1270
+ fetch?: typeof fetch;
1271
+ now?: () => number;
1272
+ timeoutMs?: number;
1273
+ maxResponseBytes?: number;
1274
+ /** Reads a refused request's served payment reason; without it, errors carry none. `CenterClient`
1275
+ * and the wallet client use `payFailureOf`; the served pages, which never show one, leave it out. */
1276
+ payFailure?: (served: unknown) => PayFailure$1 | undefined;
1277
+ };
1278
+ declare class RestClientError extends Error {
1279
+ readonly code: string;
1280
+ readonly status?: number | undefined;
1281
+ /** Why this refused payment attempt would revert, when its calls say. Advisory and for this attempt only; a changed minimum needs a fresh preparation and review. */
1282
+ readonly payFailure?: PayFailure$1;
1283
+ constructor(code: string, message: string, status?: number | undefined, payFailure?: PayFailure$1);
1284
+ }
1285
+ type PreparedRequest = {
1286
+ url: string;
1287
+ method: string;
1288
+ headers: Headers;
1289
+ body: Uint8Array;
1290
+ claims: RequestClaims;
1291
+ };
1292
+ declare class SignedRestClient {
1293
+ private readonly config;
1294
+ constructor(config: ClientOptions);
1295
+ request<T = unknown>(options: RequestOptions): Promise<T>;
1296
+ }
1297
+
1298
+ interface ForwardRequest {
1299
+ from: Address;
1300
+ to: Address;
1301
+ value: string;
1302
+ gas: string;
1303
+ nonce: string;
1304
+ deadline: string;
1305
+ data: Hex;
1306
+ }
1307
+ interface PreparedForwardRequest {
1308
+ stepIndex: number;
1309
+ chainId: number;
1310
+ forwarder: Address;
1311
+ forwarderCodeHash: Hex;
1312
+ targetCodeHash: Hex;
1313
+ domain: {
1314
+ name: string;
1315
+ version: string;
1316
+ chainId: number;
1317
+ verifyingContract: Address;
1318
+ };
1319
+ message: ForwardRequest;
1320
+ evidence: RestBlockEvidence;
1321
+ }
1322
+ interface SponsorshipSubmission {
1323
+ signatures: Hex[];
1324
+ }
1325
+
1326
+ interface Plan {
1327
+ id: string;
1328
+ account: `0x${string}`;
1329
+ operation: string;
1330
+ commitment: Hex;
1331
+ draft: RestPlanDraft;
1332
+ createdAt: number;
1333
+ expiresAt: number;
1334
+ revision: number;
1335
+ status: "prepared" | "pending" | "partial" | "blocked" | "reorged" | "expired" | "transactions_confirmed";
1336
+ steps: {
1337
+ index: number;
1338
+ state: StepState;
1339
+ blockedBy: number[];
1340
+ receipt?: StoredReceipt;
1341
+ semantic?: SemanticResult;
1342
+ transaction?: {
1343
+ hash: Hex;
1344
+ };
1345
+ execution?: {
1346
+ hash?: Hex;
1347
+ };
1348
+ }[];
1349
+ confirmationScope: string;
1350
+ }
1351
+ interface PrepaidPreparation {
1352
+ id: string;
1353
+ planId: string;
1354
+ commitment: Hex;
1355
+ publicationExpiresAt: number;
1356
+ authorizations: PreparedForwardRequest[];
1357
+ state: "prepared" | "submitting" | "submission_unknown" | "quoted";
1358
+ availability: string;
1359
+ observations: {
1360
+ stepIndex: number;
1361
+ chainId: number;
1362
+ state: string;
1363
+ hash?: Hex;
1364
+ }[];
1365
+ quote?: {
1366
+ bundleUuid: string;
1367
+ runtimeVerified: boolean;
1368
+ payments: {
1369
+ chainId: number;
1370
+ value: string;
1371
+ deadline: string;
1372
+ }[];
1373
+ };
1374
+ }
1375
+ type ActionSigner = {
1376
+ address: `0x${string}`;
1377
+ signTypedData: {
1378
+ (document: ReturnType<typeof buildTransactionApprovalTypedData>): Promise<Hex>;
1379
+ (document: ReturnType<typeof buildSponsorshipApprovalTypedData>): Promise<Hex>;
1380
+ };
1381
+ };
1382
+ type TransactionSubmission = {
1383
+ planId: string;
1384
+ stepIndex: number;
1385
+ rawSignedTransaction: Hex;
1386
+ ownerApproval?: TransactionApproval;
1387
+ };
1388
+ type PrepaidSubmission = {
1389
+ sponsorshipId: string;
1390
+ } & SponsorshipSubmission & {
1391
+ ownerApproval?: SponsorshipApproval;
1392
+ };
1393
+ /** Named workflows over the same exact-request signing and authorization protocol. */
1394
+ declare class CenterClient {
1395
+ private readonly options;
1396
+ private readonly client;
1397
+ constructor(options: ClientOptions);
1398
+ request<T = unknown>(options: RequestOptions): Promise<T>;
1399
+ /** Authorizes one exact GET for a relay. Send the returned URL and headers unchanged; this method does not send it. */
1400
+ authorizeRead(requestTarget: string): Promise<PreparedRequest>;
1401
+ /** Uses this connection's existing API identity and grant on every execution network. */
1402
+ smartAccounts(): SmartAccountClient;
1403
+ /** Signs locally with the bot key after checking the exact plan and activated permission. Does not submit. */
1404
+ signSessionOperation(input: {
1405
+ plan: SmartWalletPlan;
1406
+ operation: PreparedUserOperation;
1407
+ session: StoredSession;
1408
+ }): Promise<Hex>;
1409
+ static forOwner(options: Omit<ClientOptions, "accountId" | "grantId"> & {
1410
+ chainId: number;
1411
+ }): CenterClient;
1412
+ static fromConnection(value: unknown, options?: Pick<ClientOptions, "fetch" | "timeoutMs" | "now">): CenterClient;
1413
+ account(): Promise<{
1414
+ account: Account;
1415
+ }>;
1416
+ enroll(): Promise<{
1417
+ account: Account;
1418
+ }>;
1419
+ bots(): Promise<{
1420
+ bots: BotGrant[];
1421
+ }>;
1422
+ revokeBot(grantId: string): Promise<{
1423
+ bot: BotGrant;
1424
+ }>;
1425
+ registerBot(input: {
1426
+ signer: RestSigner;
1427
+ scopes: BotScope[];
1428
+ label: string;
1429
+ expiresAt: number;
1430
+ }): Promise<{
1431
+ bot: BotGrant;
1432
+ client: CenterClient;
1433
+ }>;
1434
+ capabilities<T = Record<string, unknown>>(): Promise<T>;
1435
+ prepare(input: {
1436
+ operation: string;
1437
+ input: unknown;
1438
+ }, idempotencyKey: string): Promise<Plan>;
1439
+ plan(planId: string, options?: {
1440
+ refresh?: boolean;
1441
+ }): Promise<Plan>;
1442
+ simulate(planId: string, stepIndex: number): Promise<{
1443
+ simulated: true;
1444
+ planId: string;
1445
+ commitment: Hex;
1446
+ stepIndex: number;
1447
+ blockHash: Hex;
1448
+ blockNumber: string;
1449
+ result: Hex;
1450
+ }>;
1451
+ /** Call after the owner reviews the plan and the transaction wallet signs the exact bytes. */
1452
+ approveTransaction(input: {
1453
+ plan: Plan;
1454
+ stepIndex: number;
1455
+ rawSignedTransaction: Hex;
1456
+ }, owner: ActionSigner): Promise<TransactionSubmission>;
1457
+ submitTransaction(input: TransactionSubmission, idempotencyKey: string): Promise<{
1458
+ plan: Plan;
1459
+ dispatch: {
1460
+ status: string;
1461
+ hash: Hex;
1462
+ error?: {
1463
+ code: string;
1464
+ message: string;
1465
+ };
1466
+ };
1467
+ }>;
1468
+ preparePrepaid(planId: string, stepIndexes: number[] | undefined, idempotencyKey: string): Promise<PrepaidPreparation>;
1469
+ prepaid(sponsorshipId: string, options?: {
1470
+ refresh?: boolean;
1471
+ }): Promise<PrepaidPreparation>;
1472
+ approvePrepaid(preparation: PrepaidPreparation, signatures: Hex[], owner: ActionSigner): Promise<PrepaidSubmission>;
1473
+ submitPrepaid(input: PrepaidSubmission, idempotencyKey: string): Promise<PrepaidPreparation>;
1474
+ prepareFunding(sponsorshipId: string, chainId: number, payer: `0x${string}`, idempotencyKey: string): Promise<Plan>;
1475
+ private step;
1476
+ private approvalWindow;
1477
+ }
1478
+
1479
+ /** Exact call-derived review facts. Recognition conveys no execution or spending authority. */
1480
+ interface WalletV6UsdcPayment {
1481
+ kind: "v6-usdc-pay";
1482
+ chainId: 8453;
1483
+ account: Address;
1484
+ token: Address;
1485
+ terminal: Address;
1486
+ projectId: string;
1487
+ amount: string;
1488
+ beneficiary: Address;
1489
+ minimumReturnedTokens: string;
1490
+ memo: string;
1491
+ metadata: Hex;
1492
+ stepIndexes: readonly number[];
1493
+ approvalStepIndexes: readonly number[];
1494
+ paymentStepIndex: number;
1495
+ resetAllowance: boolean;
1496
+ }
1497
+
1498
+ type CenterWalletExpectedPayment = Omit<WalletV6UsdcPayment, 'stepIndexes' | 'approvalStepIndexes' | 'paymentStepIndex' | 'resetAllowance'> & {
1499
+ /** Maximum EntryPoint prefund in native wei, excluding separate rollup data fees. */
1500
+ maximumNetworkFee: string;
1501
+ };
1502
+ interface CenterWalletPaymentInput {
1503
+ plan: SmartWalletPlan;
1504
+ operation: PreparedUserOperation;
1505
+ expectedPayment: CenterWalletExpectedPayment;
1506
+ }
1507
+ /** `expired`: published but never included before its signed validity ended; it cannot execute.
1508
+ * `refused`: Signa refused to send it and retired the approval; Signa never sends it, and a fresh payment takes its nonce. */
1509
+ type CenterWalletPaymentState = 'reviewing' | 'approved' | 'submitting' | 'pending' | 'confirming' | 'paid' | 'reverted' | 'cancelled' | 'unknown' | 'expired' | 'refused';
1510
+ interface CenterWalletPaymentStatus {
1511
+ status: CenterWalletPaymentState;
1512
+ accountId: string;
1513
+ chainId: 8453;
1514
+ operationId: string;
1515
+ operationHash: Hex;
1516
+ reviewId: string | null;
1517
+ approvalUrl: string | null;
1518
+ expiresAtMs: number;
1519
+ expectedPayment: CenterWalletExpectedPayment;
1520
+ /** An observed outer transaction identifier, never an alias for operationHash. */
1521
+ transactionHash?: Hex;
1522
+ observation?: UserOperationObservation;
1523
+ /** Why this payment reverted, when its trace says; shown only while it stands reverted. The SDK's own
1524
+ * `PayFailure` (bigint amounts, with `zeroFill` and `adjustable` for a shortfall); `observation.payFailure`
1525
+ * keeps the served form. Advisory: a changed minimum needs a fresh preparation and review. */
1526
+ payFailure?: PayFailure$1;
1527
+ }
1528
+
1529
+ interface CenterWalletStorage {
1530
+ getItem(key: string): string | null;
1531
+ setItem(key: string, value: string): void;
1532
+ removeItem(key: string): void;
1533
+ }
1534
+ interface CenterWalletClientOptions {
1535
+ /** Fixed trusted transport origin; never taken from a callback or discovery response. */
1536
+ issuer: string;
1537
+ audience: string;
1538
+ callbackUri: string;
1539
+ /** Defaults to this tab's sessionStorage. The adapter must preserve exact values across redirects. */
1540
+ storage?: CenterWalletStorage;
1541
+ fetch?: typeof fetch;
1542
+ /** Unix milliseconds. */
1543
+ now?: () => number;
1544
+ timeoutMs?: number;
1545
+ /** replace must remove the query using history.replaceState, without navigating. */
1546
+ location?: {
1547
+ href(): string;
1548
+ replace(url: string): void;
1549
+ };
1550
+ }
1551
+ interface CenterWalletConnection {
1552
+ readonly accountId: string;
1553
+ readonly address: Address;
1554
+ readonly chainId: 8453;
1555
+ /** Unix seconds. This is the original grant expiry, including after receipt recovery. */
1556
+ readonly expiresAt: number;
1557
+ readonly capabilities: readonly ['read', 'plan', 'relay'];
1558
+ /** API access only. Transactions still require fresh owner approval at Center. */
1559
+ readonly client: CenterClient;
1560
+ }
1561
+ interface CenterWalletPreparedConnection {
1562
+ readonly intentId: string;
1563
+ /** Public locator only. Use launch() to establish browser continuity before navigation. */
1564
+ readonly authorizationUrl: string;
1565
+ readonly expiresAtMs: number;
1566
+ /** Navigates this tab, or a window the app opened by name (`target`), to Center. */
1567
+ readonly launch: (options?: {
1568
+ target?: string;
1569
+ }) => void;
1570
+ }
1571
+ /** Redirect continuity and exact receipt recovery for an app's local request key. No wallet owner key is created here. */
1572
+ declare function createCenterWalletClient(options: CenterWalletClientOptions): Readonly<{
1573
+ prepareConnection: () => Promise<CenterWalletPreparedConnection>;
1574
+ completeConnection: (callbackUrl?: string) => Promise<CenterWalletConnection>;
1575
+ retryConnection: () => Promise<CenterWalletConnection>;
1576
+ restoreConnection: () => CenterWalletConnection | null;
1577
+ disconnect: () => void;
1578
+ payments: () => Readonly<{
1579
+ preparePayment: (input: CenterWalletPaymentInput, options?: {
1580
+ reviewId?: string;
1581
+ }) => Promise<CenterWalletPaymentStatus>;
1582
+ reviewUrl: (reviewId: string) => string;
1583
+ completePayment: (callbackUrl?: string) => Promise<CenterWalletPaymentStatus>;
1584
+ submitPayment: () => Promise<CenterWalletPaymentStatus>;
1585
+ refreshPayment: (options?: {
1586
+ waitSeconds?: number;
1587
+ }) => Promise<CenterWalletPaymentStatus>;
1588
+ retirePayment: () => Promise<CenterWalletPaymentStatus>;
1589
+ pendingPayment: () => CenterWalletPaymentStatus | null;
1590
+ clearPayment: () => void;
1591
+ }>;
1592
+ }>;
1593
+
1594
+ type SponsoredCall = {
1595
+ chainId: number;
1596
+ to: string;
1597
+ data: string;
1598
+ value: string;
1599
+ };
1600
+ /** What a sponsorship voucher commits a payment to: the ordered calls, hex lowercased and the value
1601
+ * in decimal, as an array of arrays so no key order can disagree between the issuer and Center.
1602
+ * The issuer (an app such as Beep) imports this from the wallet client package rather than
1603
+ * re-implementing it; a drift here would refuse every sponsored payment. */
1604
+ declare function sponsoredCallsCommitment(calls: readonly SponsoredCall[]): Hex;
1605
+
1606
+ export { RestClientError, assertReviewedOperation, createCenterWalletClient, ownerOperationSignature, ownerOperationSigning, sponsoredCallsCommitment, userOperationMaximumCost };
1607
+ export type { CenterWalletClientOptions, CenterWalletConnection, CenterWalletExpectedPayment, CenterWalletPaymentInput, CenterWalletPaymentState, CenterWalletPaymentStatus, CenterWalletPreparedConnection, CenterWalletStorage, PayFailure$1 as PayFailure, PreparedRequest, PreparedUserOperation, SmartWalletPlan, SponsoredCall };