@stellar-registry/perch-contracts 0.0.0-stage → 0.1.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.
@@ -0,0 +1,1168 @@
1
+ /** sha256 of the wasm these bindings were generated from. */
2
+ export declare const WASM_SHA256 = "d6e8bfc3b91f7c15b9738a3425f0c321f1badc0896e9a5f062e6f32646c895b0";
3
+ import { Buffer } from "buffer";
4
+ import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, MethodOptions, Result } from "@stellar/stellar-sdk/contract";
5
+ import type { u32, u64, Option } from "@stellar/stellar-sdk/contract";
6
+ export * from "@stellar/stellar-sdk";
7
+ export * as contract from "@stellar/stellar-sdk/contract";
8
+ export * as rpc from "@stellar/stellar-sdk/rpc";
9
+ /**
10
+ * One lost-key or compromise recovery attempt (spec §6.3 T1).
11
+ */
12
+ export interface Attempt {
13
+ /**
14
+ * `LostKey` or `Compromise`.
15
+ */
16
+ action: RecoveryAction;
17
+ /**
18
+ * Set at authorization; `0` while collecting.
19
+ */
20
+ authorized_at: u32;
21
+ /**
22
+ * Distinct enrolled guardians that approved the cancel statement.
23
+ */
24
+ cancel_guardians: Array<string>;
25
+ /**
26
+ * The `Cancel` statement's freshness bound: never earlier than the
27
+ * attempt's last live ledger.
28
+ */
29
+ cancel_until: u32;
30
+ /**
31
+ * Whether a cancellation proof was accepted.
32
+ */
33
+ cancel_zk: boolean;
34
+ created_at: u32;
35
+ /**
36
+ * The epoch the attempt was opened under; it is dead under any other.
37
+ */
38
+ epoch: u64;
39
+ /**
40
+ * Last ledger (inclusive) initiation evidence is accepted.
41
+ */
42
+ evidence_deadline: u32;
43
+ /**
44
+ * First completable ledger; `0` while collecting.
45
+ */
46
+ executable_after: u32;
47
+ /**
48
+ * First ledger the authorized attempt is no longer live; `0` while
49
+ * collecting.
50
+ */
51
+ expires_at: u32;
52
+ /**
53
+ * Distinct enrolled guardians that approved the initiation statement.
54
+ */
55
+ guardians: Array<string>;
56
+ /**
57
+ * Per-account, never reused.
58
+ */
59
+ id: u64;
60
+ /**
61
+ * The credentials occupying the replaced signer slots in the source
62
+ * (the baseline's, for compromise), keys canonicalized. The completion
63
+ * returns them for the account to revoke (spec §8).
64
+ */
65
+ replaced: Array<Credential>;
66
+ /**
67
+ * `ReplacementSet::hash` of the declared replacements.
68
+ */
69
+ replacements_hash: Buffer;
70
+ /**
71
+ * The source document's identity: lost-key, the account's applied
72
+ * identity at T1; compromise, the enrolled baseline. Read, never
73
+ * computed here, so the controller does not depend on how identities
74
+ * are computed.
75
+ */
76
+ source_doc_hash: Buffer;
77
+ state: AttemptState;
78
+ /**
79
+ * `sha256` of the canonical bytes `derive_target` returned, computed by
80
+ * the controller from the same derivation: what `enforce` requires the
81
+ * completing `apply_doc` argument to hash to. Under CANON v1 it equals
82
+ * `target_doc_hash`; a structured identity would differ (spec §6.3 T1,
83
+ * T5).
84
+ */
85
+ target_bytes_hash: Buffer;
86
+ /**
87
+ * The derived target's recovery `config_hash` (the current one, or the
88
+ * current one with the declared ZK rotation).
89
+ */
90
+ target_config_hash: Buffer;
91
+ /**
92
+ * The derived target's document identity, as the compiler computed it:
93
+ * what the statement names and what the completing `apply_doc` must
94
+ * compile to.
95
+ */
96
+ target_doc_hash: Buffer;
97
+ /**
98
+ * The nullifier of the initiation proof, once one was accepted. A
99
+ * completion spends it.
100
+ */
101
+ zk_nullifier: Option<Buffer>;
102
+ }
103
+ /**
104
+ * What recovery currently restricts for an account (the controller's
105
+ * `activity_gate` view, for clients; the account enforces the freeze from
106
+ * its own mirror).
107
+ */
108
+ export interface ActivityGate {
109
+ /**
110
+ * The authorized, live attempt, if any. While it is set, policy
111
+ * changes and upgrades are refused in both profiles.
112
+ */
113
+ authorized_attempt: Option<u64>;
114
+ /**
115
+ * `Protected` with an authorized attempt: the account authorizes
116
+ * nothing but that attempt's completion.
117
+ */
118
+ frozen: boolean;
119
+ /**
120
+ * The authorized attempt's `expires_at`; `0` when none is authorized.
121
+ */
122
+ until: u32;
123
+ }
124
+ /**
125
+ * An attempt's stored state. `Expired` is not a state, and neither is
126
+ * invalidation by an epoch change or a sibling's authorization: those are
127
+ * derived from the ledger, the account's epoch, and its `invalidate_below`
128
+ * (see `contract::is_live`), so no transition can leave them out of date.
129
+ * Only a stale lost-key source is recorded ([`AttemptState::Invalidated`]).
130
+ */
131
+ export type AttemptState = {
132
+ tag: "Collecting";
133
+ values: void;
134
+ } | {
135
+ tag: "Authorized";
136
+ values: void;
137
+ } | {
138
+ tag: "Completed";
139
+ values: void;
140
+ } | {
141
+ tag: "Cancelled";
142
+ values: void;
143
+ } | {
144
+ tag: "Invalidated";
145
+ values: void;
146
+ };
147
+ /**
148
+ * Evidence recorded for one `Reconfigure` or `Upgrade` statement digest
149
+ * (spec §5). Consumed by `rcv_sync`/`rcv_upgrade`, which rebuild the digest
150
+ * from the change actually being made.
151
+ */
152
+ export interface ChangeApproval {
153
+ guardians: Array<string>;
154
+ zk: boolean;
155
+ }
156
+ /**
157
+ * Which evidence an attempt-bound submission counts toward.
158
+ */
159
+ export declare enum EvidenceDomain {
160
+ Initiate = 0,
161
+ Cancel = 1
162
+ }
163
+ /**
164
+ * What a completion hands back to the account.
165
+ */
166
+ export interface Completion {
167
+ /**
168
+ * The attempt that completed.
169
+ */
170
+ attempt_id: u64;
171
+ /**
172
+ * The credentials that occupied the replaced signer slots **in the
173
+ * attempt's source document**, as derived at T1: the applied document
174
+ * for lost-key, the baseline for compromise. The account fingerprints
175
+ * them over canonical keys and revokes them together with every
176
+ * credential the completion removed from its current document. Without
177
+ * these, a baseline credential replaced by a compromise recovery, and
178
+ * already absent from the current document, would stay unrevoked and
179
+ * could be restored by a later recovery from the same baseline.
180
+ */
181
+ replaced: Array<Credential>;
182
+ }
183
+ /**
184
+ * What `rcv_sync` did, so the account knows which of its own effects to
185
+ * apply (spec §10).
186
+ */
187
+ export type SyncOutcome = {
188
+ tag: "Unchanged";
189
+ values: void;
190
+ } | {
191
+ tag: "Enrolled";
192
+ values: void;
193
+ } | {
194
+ tag: "Reconfigured";
195
+ values: void;
196
+ } | {
197
+ tag: "Removed";
198
+ values: void;
199
+ } | {
200
+ tag: "Completed";
201
+ values: readonly [Completion];
202
+ };
203
+ /**
204
+ * Which phase of an account upgrade `rcv_upgrade` is checking (spec §12).
205
+ */
206
+ export type UpgradeStep = {
207
+ tag: "Schedule";
208
+ values: readonly [UpgradeSubject, u32];
209
+ } | {
210
+ tag: "Execute";
211
+ values: readonly [u64];
212
+ };
213
+ /**
214
+ * Everything a recovery controller can refuse. Codes are sequential from 1
215
+ * in declaration order and are wire format: append new variants at the
216
+ * end, never reorder.
217
+ */
218
+ export declare const RecoveryError: {
219
+ /**
220
+ * No configuration is enrolled for this account at this controller.
221
+ */
222
+ 1: {
223
+ message: string;
224
+ };
225
+ /**
226
+ * An attempt is authorized and live: begin, policy changes, and upgrades are refused until it completes, is cancelled, or expires.
227
+ */
228
+ 2: {
229
+ message: string;
230
+ };
231
+ /**
232
+ * No attempt with this id exists for the account.
233
+ */
234
+ 3: {
235
+ message: string;
236
+ };
237
+ /**
238
+ * The attempt is terminal, expired, from an older epoch, or invalidated by a sibling's authorization.
239
+ */
240
+ 4: {
241
+ message: string;
242
+ };
243
+ /**
244
+ * Initiation evidence for an attempt that is no longer collecting.
245
+ */
246
+ 5: {
247
+ message: string;
248
+ };
249
+ /**
250
+ * Completion before `executable_after`.
251
+ */
252
+ 6: {
253
+ message: string;
254
+ };
255
+ /**
256
+ * The completion context, or the compiled document hash, does not match the authorized attempt's target.
257
+ */
258
+ 7: {
259
+ message: string;
260
+ };
261
+ /**
262
+ * The address is not an enrolled guardian.
263
+ */
264
+ 8: {
265
+ message: string;
266
+ };
267
+ /**
268
+ * This guardian or factor already counted for this statement.
269
+ */
270
+ 9: {
271
+ message: string;
272
+ };
273
+ /**
274
+ * The enrolled mode has no guardian factor.
275
+ */
276
+ 10: {
277
+ message: string;
278
+ };
279
+ /**
280
+ * The enrolled mode has no ZK factor.
281
+ */
282
+ 11: {
283
+ message: string;
284
+ };
285
+ /**
286
+ * The adapter refused the proof (its `ZkAdapterError` says why).
287
+ */
288
+ 12: {
289
+ message: string;
290
+ };
291
+ /**
292
+ * The proof's nullifier is spent.
293
+ */
294
+ 13: {
295
+ message: string;
296
+ };
297
+ /**
298
+ * The statement's freshness bound has passed or reaches too far.
299
+ */
300
+ 14: {
301
+ message: string;
302
+ };
303
+ /**
304
+ * The statement cannot be encoded (a non-contract account or controller).
305
+ */
306
+ 15: {
307
+ message: string;
308
+ };
309
+ /**
310
+ * Recorded approvals do not satisfy the enrolled condition for this reconfiguration or upgrade.
311
+ */
312
+ 16: {
313
+ message: string;
314
+ };
315
+ /**
316
+ * The account's `max-cancels` is used up.
317
+ */
318
+ 17: {
319
+ message: string;
320
+ };
321
+ /**
322
+ * Owner cancellation is only available under `Loss`.
323
+ */
324
+ 18: {
325
+ message: string;
326
+ };
327
+ /**
328
+ * The replacement set breaks a §7.3 rule, or derivation refused it.
329
+ */
330
+ 19: {
331
+ message: string;
332
+ };
333
+ /**
334
+ * The target or a replacement contains a revoked credential.
335
+ */
336
+ 20: {
337
+ message: string;
338
+ };
339
+ /**
340
+ * The ZK enrollment id was enrolled for this account before (the controller checks the account's `is_enrolled_id` at T1; the pure `derive_target` cannot see the account's history).
341
+ */
342
+ 21: {
343
+ message: string;
344
+ };
345
+ /**
346
+ * Compromise recovery with no baseline enrolled.
347
+ */
348
+ 22: {
349
+ message: string;
350
+ };
351
+ /**
352
+ * Compromise recovery before the baseline's content was published.
353
+ */
354
+ 23: {
355
+ message: string;
356
+ };
357
+ /**
358
+ * The published document does not hash to the enrolled baseline.
359
+ */
360
+ 24: {
361
+ message: string;
362
+ };
363
+ /**
364
+ * The adapter's circuit id or tree depth does not match the enrolled factor and pool.
365
+ */
366
+ 25: {
367
+ message: string;
368
+ };
369
+ /**
370
+ * The ZK factor changed without a new enrollment id.
371
+ */
372
+ 26: {
373
+ message: string;
374
+ };
375
+ /**
376
+ * The configuration is malformed (for example, the account is one of its own guardians, or the quorum is out of range).
377
+ */
378
+ 27: {
379
+ message: string;
380
+ };
381
+ /**
382
+ * An upgrade request recorded under an older epoch.
383
+ */
384
+ 28: {
385
+ message: string;
386
+ };
387
+ /**
388
+ * A ledger-sequence computation overflowed `u32`.
389
+ */
390
+ 29: {
391
+ message: string;
392
+ };
393
+ /**
394
+ * The policy was attached to a context rule of the wrong shape.
395
+ */
396
+ 30: {
397
+ message: string;
398
+ };
399
+ /**
400
+ * A credential the replacement set replaces still appears in the target (a swap or a no-op replacement, spec §7.3 rule 8).
401
+ */
402
+ 31: {
403
+ message: string;
404
+ };
405
+ };
406
+ /**
407
+ * A signer credential, shaped like OZ `stellar_accounts::smart_account::Signer`.
408
+ */
409
+ export type Credential = {
410
+ tag: "Delegated";
411
+ values: readonly [string];
412
+ } | {
413
+ tag: "External";
414
+ values: readonly [string, Buffer];
415
+ };
416
+ /**
417
+ * One designated signer slot and the credential that replaces whatever
418
+ * that slot holds in the source document.
419
+ */
420
+ export interface Replacement {
421
+ /**
422
+ * The credential the target document gives that signer id.
423
+ */
424
+ credential: Credential;
425
+ /**
426
+ * A document signer id listed in the enrolled `recovery.replaceable`.
427
+ */
428
+ signer_id: string;
429
+ }
430
+ /**
431
+ * A ZK enrollment a recovery completion installs.
432
+ *
433
+ * The commitment is bound here, not only the id: completion runs under the
434
+ * zero-signer recovery rule, so nothing signs its arguments, and a
435
+ * commitment supplied only at completion could be swapped by whoever
436
+ * submits the completing transaction first — handing them the account's
437
+ * next ZK factor.
438
+ */
439
+ export interface ZkEnrollment {
440
+ /**
441
+ * The new leaf's inner commitment, `Poseidon2(DOM_LEAF, secret)`.
442
+ * Derivation writes `id` and `commitment` into the target document's
443
+ * recovery section, so the target hash binds them, and the completing
444
+ * `apply_doc` inserts the leaf from the compiled target, never from a
445
+ * call argument.
446
+ */
447
+ commitment: Buffer;
448
+ /**
449
+ * The new enrollment id. Must never have been enrolled for this
450
+ * account before.
451
+ */
452
+ id: Buffer;
453
+ }
454
+ /**
455
+ * Everything a `LostKey`/`Compromise` attempt changes about the source
456
+ * document. See `docs/recovery/spec.md` §7.
457
+ */
458
+ export interface ReplacementSet {
459
+ /**
460
+ * Signer replacements in strictly ascending `signer_id` byte order
461
+ * (sorted, no duplicates) — the one canonical order.
462
+ */
463
+ signers: Array<Replacement>;
464
+ /**
465
+ * The fresh ZK enrollment the completion installs, required exactly
466
+ * when the enrolled mode has a ZK factor (a ZK-evidenced completion
467
+ * consumes the enrolled credential, so it must install a fresh one).
468
+ * Empty or one entry — a `Vec` because `#[contracttype]` cannot derive
469
+ * `Option<CustomStruct>`.
470
+ */
471
+ zk_enrollment: Array<ZkEnrollment>;
472
+ }
473
+ /**
474
+ * One ZK proof as submitted.
475
+ */
476
+ export interface ZkEvidence {
477
+ /**
478
+ * The credential's nullifier (the circuit's second public input).
479
+ */
480
+ nullifier: Buffer;
481
+ /**
482
+ * The serialized proof.
483
+ */
484
+ proof: Buffer;
485
+ /**
486
+ * The root the proof was generated against; must be acceptable to the
487
+ * enrolled pool for `tree_id`.
488
+ */
489
+ root: Buffer;
490
+ /**
491
+ * The pool tree the proof's Merkle path is in.
492
+ */
493
+ tree_id: u32;
494
+ }
495
+ /**
496
+ * Who may change the recovery configuration, and whether an authorized
497
+ * attempt freezes ordinary activity (spec §2, §9).
498
+ */
499
+ export type RecoveryProfile = {
500
+ tag: "Loss";
501
+ values: void;
502
+ } | {
503
+ tag: "Protected";
504
+ values: void;
505
+ };
506
+ /**
507
+ * The ZK factor (spec §3.1, §3.4).
508
+ */
509
+ export interface CompiledZkFactor {
510
+ /**
511
+ * The constructorless ZK adapter the controller calls.
512
+ */
513
+ adapter: string;
514
+ /**
515
+ * `sha256` of the adapter's verification key; must equal the adapter's
516
+ * `circuit_id()`.
517
+ */
518
+ circuit_id: Buffer;
519
+ /**
520
+ * The current credential's inner commitment, `Poseidon2(DOM_LEAF,
521
+ * secret)`, from which the account inserts the leaf.
522
+ */
523
+ commitment: Buffer;
524
+ /**
525
+ * The current credential's id, bound into its leaf and nullifier.
526
+ */
527
+ enrollment_id: Buffer;
528
+ /**
529
+ * The membership pool roots are accepted from.
530
+ */
531
+ pool: string;
532
+ }
533
+ /**
534
+ * The guardian factor.
535
+ */
536
+ export interface CompiledGuardianSet {
537
+ /**
538
+ * Guardian addresses (`G...` or `C...`), never the account itself.
539
+ */
540
+ guardians: Array<string>;
541
+ /**
542
+ * `1 <= quorum <= guardians.len()`.
543
+ */
544
+ quorum: u32;
545
+ }
546
+ /**
547
+ * Which factors a statement needs.
548
+ */
549
+ export type CompiledRecoveryMode = {
550
+ tag: "GuardianOnly";
551
+ values: readonly [CompiledGuardianSet];
552
+ } | {
553
+ tag: "ZkOnly";
554
+ values: readonly [CompiledZkFactor];
555
+ } | {
556
+ tag: "Combined";
557
+ values: readonly [CompiledGuardianSet, CompiledZkFactor];
558
+ };
559
+ /**
560
+ * A compiled `recovery` member.
561
+ */
562
+ export interface CompiledRecoveryConfig {
563
+ /**
564
+ * The enrolled baseline's canonical document hash, if compromise
565
+ * recovery is enrolled.
566
+ */
567
+ baseline: Option<Buffer>;
568
+ /**
569
+ * [`config_hash`] of the canonical JSON of the recovery member, computed
570
+ * by the doc compiler (spec §3.2). Configuration
571
+ * identity: two compiled configurations with the same `config_hash` are
572
+ * the same configuration.
573
+ */
574
+ config_hash: Buffer;
575
+ /**
576
+ * The adopted controller instance.
577
+ */
578
+ controller: string;
579
+ delay_ledgers: u32;
580
+ expiry_ledgers: u32;
581
+ max_cancels: u32;
582
+ mode: CompiledRecoveryMode;
583
+ profile: RecoveryProfile;
584
+ /**
585
+ * Signer ids (not credential fingerprints) a recovery may replace, so
586
+ * rotating a key does not change the configuration (#92).
587
+ */
588
+ replaceable: Array<string>;
589
+ }
590
+ /**
591
+ * What a `Reconfigure` statement changes the enrolled configuration to.
592
+ */
593
+ export type ConfigChange = {
594
+ tag: "Remove";
595
+ values: void;
596
+ } | {
597
+ tag: "Set";
598
+ values: readonly [Buffer];
599
+ };
600
+ /**
601
+ * The subject of a `Cancel` statement.
602
+ */
603
+ export interface CancelSubject {
604
+ /**
605
+ * The attempt being cancelled.
606
+ */
607
+ attempt_id: u64;
608
+ /**
609
+ * That attempt's own initiation statement digest, so cancellation
610
+ * evidence names exactly one proposal, not just an id.
611
+ */
612
+ attempt_statement: Buffer;
613
+ }
614
+ /**
615
+ * The enrolled configuration a statement is evaluated against.
616
+ */
617
+ export interface ConfigBinding {
618
+ /**
619
+ * `sha256("perch/recovery/config" || canonical JSON of the enrolled
620
+ * document's recovery member)`, as [`crate::config::config_hash`]
621
+ * computes it (`docs/recovery/spec.md` §3.2). Binds the whole
622
+ * configuration: profile, mode, guardians, quorum, ZK adapter, circuit
623
+ * id, pool, enrollment id and commitment, controller, baseline,
624
+ * replaceable signer ids, and timing.
625
+ */
626
+ config_hash: Buffer;
627
+ /**
628
+ * The controller's per-account configuration epoch. It increments on
629
+ * every enrollment, reconfiguration, removal, completed recovery, and
630
+ * executed account upgrade, so evidence produced under one epoch is
631
+ * dead under every later one.
632
+ */
633
+ epoch: u64;
634
+ }
635
+ /**
636
+ * The subject of a `LostKey` or `Compromise` attempt.
637
+ */
638
+ export interface AttemptSubject {
639
+ /**
640
+ * The controller-assigned, per-account, never-reused attempt id.
641
+ */
642
+ attempt_id: u64;
643
+ /**
644
+ * [`crate::credential::ReplacementSet::hash`] of the declared
645
+ * replacements.
646
+ */
647
+ replacements_hash: Buffer;
648
+ /**
649
+ * `LostKey`: the canonical hash of the account's applied document when
650
+ * the attempt began (the agreed snapshot). `Compromise`: the enrolled
651
+ * baseline's canonical hash.
652
+ */
653
+ source_doc_hash: Buffer;
654
+ /**
655
+ * The canonical hash of the target document, derived on-chain from
656
+ * the source and the replacement set — never caller-chosen.
657
+ */
658
+ target_doc_hash: Buffer;
659
+ }
660
+ /**
661
+ * The action domain a statement authorizes. Evidence for one action never
662
+ * satisfies another: the action code is the encoding's 26th byte and selects
663
+ * the subject layout, so two statements that differ only in action have
664
+ * different digests (and different encoded lengths for most pairs).
665
+ *
666
+ * The numeric codes are part of the wire format.
667
+ */
668
+ export declare enum RecoveryAction {
669
+ LostKey = 1,
670
+ Compromise = 2,
671
+ Cancel = 3,
672
+ Reconfigure = 4,
673
+ Upgrade = 5
674
+ }
675
+ /**
676
+ * The subject of an `Upgrade` statement.
677
+ */
678
+ export interface UpgradeSubject {
679
+ /**
680
+ * The account's per-account, never-reused upgrade request id.
681
+ */
682
+ request_id: u64;
683
+ /**
684
+ * The exact Wasm hash the account would run after the upgrade.
685
+ */
686
+ wasm_hash: Buffer;
687
+ }
688
+ /**
689
+ * Timing terms, all in ledger-sequence units.
690
+ */
691
+ export interface StatementTiming {
692
+ /**
693
+ * The enrolled `delay-ledgers`: ledgers between an attempt becoming
694
+ * authorized and becoming completable.
695
+ */
696
+ delay_ledgers: u32;
697
+ /**
698
+ * The enrolled `expiry-ledgers`: the evidence window for a collecting
699
+ * attempt, the completion window for an authorized one, and the upper
700
+ * bound on how far ahead a provider-chosen `valid_until_ledger` may
701
+ * reach.
702
+ */
703
+ expiry_ledgers: u32;
704
+ /**
705
+ * The last ledger sequence (inclusive) at which this evidence may be
706
+ * accepted. The controller fixes it for attempt-bound actions:
707
+ * `LostKey`/`Compromise` use the attempt's evidence deadline, and
708
+ * `Cancel` the last ledger the attempt could possibly be live, so
709
+ * approvals collected over several transactions all sign one
710
+ * statement. For `Reconfigure`/`Upgrade` the evidence provider chooses
711
+ * it, within `expiry_ledgers` of submission.
712
+ */
713
+ valid_until_ledger: u32;
714
+ }
715
+ /**
716
+ * The action-specific part of a statement. The variant determines
717
+ * [`RecoveryStatement::action`]; there is no separate action field that
718
+ * could disagree with it.
719
+ */
720
+ export type StatementSubject = {
721
+ tag: "LostKey";
722
+ values: readonly [AttemptSubject];
723
+ } | {
724
+ tag: "Compromise";
725
+ values: readonly [AttemptSubject];
726
+ } | {
727
+ tag: "Cancel";
728
+ values: readonly [CancelSubject];
729
+ } | {
730
+ tag: "Reconfigure";
731
+ values: readonly [ConfigChange];
732
+ } | {
733
+ tag: "Upgrade";
734
+ values: readonly [UpgradeSubject];
735
+ };
736
+ /**
737
+ * The one recovery statement. See the module docs.
738
+ */
739
+ export interface RecoveryStatement {
740
+ /**
741
+ * The recovering account. Must be a contract address.
742
+ */
743
+ account: string;
744
+ config: ConfigBinding;
745
+ /**
746
+ * The controller instance evaluating the evidence (for `Reconfigure`,
747
+ * the currently adopted one, even when the change adopts another).
748
+ * Must be a contract address.
749
+ */
750
+ controller: string;
751
+ /**
752
+ * The network id (`sha256` of the network passphrase), as
753
+ * `Env::ledger().network_id()` returns it.
754
+ */
755
+ network_id: Buffer;
756
+ subject: StatementSubject;
757
+ timing: StatementTiming;
758
+ }
759
+ /**
760
+ * Context of a single authorized call performed by an address.
761
+ *
762
+ * Custom account contracts that implement `__check_auth` special function
763
+ * receive a list of `Context` values corresponding to all the calls that
764
+ * need to be authorized.
765
+ */
766
+ export type Context = {
767
+ tag: "Contract";
768
+ values: readonly [ContractContext];
769
+ } | {
770
+ tag: "CreateContractHostFn";
771
+ values: readonly [CreateContractHostFnContext];
772
+ } | {
773
+ tag: "CreateContractWithCtorHostFn";
774
+ values: readonly [CreateContractWithConstructorHostFnContext];
775
+ };
776
+ /**
777
+ * Authorization context of a single contract call.
778
+ *
779
+ * This struct corresponds to a `require_auth_for_args` call for an address
780
+ * from `contract` function with `fn_name` name and `args` arguments.
781
+ */
782
+ export interface ContractContext {
783
+ args: Array<any>;
784
+ contract: string;
785
+ fn_name: string;
786
+ }
787
+ /**
788
+ * Contract executable used for creating a new contract and used in
789
+ * `CreateContractHostFnContext`.
790
+ */
791
+ export type ContractExecutable = {
792
+ tag: "Wasm";
793
+ values: readonly [Buffer];
794
+ };
795
+ /**
796
+ * Authorization context for `create_contract` host function that creates a
797
+ * new contract on behalf of authorizer address.
798
+ */
799
+ export interface CreateContractHostFnContext {
800
+ executable: ContractExecutable;
801
+ salt: Buffer;
802
+ }
803
+ /**
804
+ * Authorization context for `create_contract` host function that creates a
805
+ * new contract on behalf of authorizer address.
806
+ * This is the same as `CreateContractHostFnContext`, but also has
807
+ * contract constructor arguments.
808
+ */
809
+ export interface CreateContractWithConstructorHostFnContext {
810
+ constructor_args: Array<any>;
811
+ executable: ContractExecutable;
812
+ salt: Buffer;
813
+ }
814
+ /**
815
+ * Represents different types of signers in the smart account system.
816
+ */
817
+ export type Signer = {
818
+ tag: "Delegated";
819
+ values: readonly [string];
820
+ } | {
821
+ tag: "External";
822
+ values: readonly [string, Buffer];
823
+ };
824
+ /**
825
+ * A complete context rule defining authorization requirements.
826
+ */
827
+ export interface ContextRule {
828
+ /**
829
+ * The type of context this rule applies to.
830
+ */
831
+ context_type: ContextRuleType;
832
+ /**
833
+ * Unique identifier for the context rule.
834
+ */
835
+ id: u32;
836
+ /**
837
+ * Human-readable name for the context rule.
838
+ */
839
+ name: string;
840
+ /**
841
+ * List of policy contracts that must be satisfied.
842
+ */
843
+ policies: Array<string>;
844
+ /**
845
+ * Global registry IDs for each policy, positionally aligned with
846
+ * `policies`.
847
+ */
848
+ policy_ids: Array<u32>;
849
+ /**
850
+ * Global registry IDs for each signer, positionally aligned with
851
+ * `signers`.
852
+ */
853
+ signer_ids: Array<u32>;
854
+ /**
855
+ * List of signers authorized by this rule.
856
+ */
857
+ signers: Array<Signer>;
858
+ /**
859
+ * Optional expiration ledger sequence for the rule.
860
+ */
861
+ valid_until: Option<u32>;
862
+ }
863
+ /**
864
+ * Types of contexts that can be authorized by smart account rules.
865
+ */
866
+ export type ContextRuleType = {
867
+ tag: "Default";
868
+ values: void;
869
+ } | {
870
+ tag: "CallContract";
871
+ values: readonly [string];
872
+ } | {
873
+ tag: "CreateContract";
874
+ values: readonly [Buffer];
875
+ };
876
+ export interface Client {
877
+ /**
878
+ * Construct and simulate a epoch transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
879
+ * The account's configuration epoch (spec §3.3).
880
+ */
881
+ epoch: ({ account }: {
882
+ account: string;
883
+ }, options?: MethodOptions) => Promise<AssembledTransaction<u64>>;
884
+ /**
885
+ * Construct and simulate a renew transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
886
+ * Extend every persistent entry the account's recovery depends on to
887
+ * the network maximum (spec T10). Permissionless; changes no meaning.
888
+ */
889
+ renew: ({ account }: {
890
+ account: string;
891
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
892
+ /**
893
+ * Construct and simulate a config transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
894
+ * The account's configuration at this controller.
895
+ */
896
+ config: ({ account }: {
897
+ account: string;
898
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Option<CompiledRecoveryConfig>>>;
899
+ /**
900
+ * Construct and simulate a attempt transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
901
+ * An attempt's stored record, live or not.
902
+ */
903
+ attempt: ({ account, attempt_id }: {
904
+ account: string;
905
+ attempt_id: u64;
906
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Option<Attempt>>>;
907
+ /**
908
+ * Construct and simulate a enforce transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
909
+ * T5: authorize the completing `apply_doc`. The recovery rule has no
910
+ * signers, so this is the whole check: the context must be this
911
+ * account's `apply_doc` of the authorized attempt's exact target bytes,
912
+ * inside the completion window. It then leaves a marker that only the
913
+ * same invocation's `rcv_sync` consumes.
914
+ */
915
+ enforce: ({ context, authenticated_signers, context_rule, smart_account }: {
916
+ context: Context;
917
+ authenticated_signers: Array<Signer>;
918
+ context_rule: ContextRule;
919
+ smart_account: string;
920
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
921
+ /**
922
+ * Construct and simulate a install transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
923
+ * Bookkeeping only: `rcv_sync` already wrote the configuration, earlier
924
+ * in the same `apply_doc`. Checks that the recovery rule has the
925
+ * required shape and was installed for the stored configuration.
926
+ */
927
+ install: ({ install_params, context_rule, smart_account }: {
928
+ install_params: Buffer;
929
+ context_rule: ContextRule;
930
+ smart_account: string;
931
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
932
+ /**
933
+ * Construct and simulate a baseline transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
934
+ * The published content of the enrolled baseline, if any.
935
+ */
936
+ baseline: ({ account }: {
937
+ account: string;
938
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Option<Buffer>>>;
939
+ /**
940
+ * Construct and simulate a rcv_sync transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
941
+ * The recovery side of the account's `apply_doc` (spec §10). Called
942
+ * before any context rule changes. Classifies the call as exactly one of
943
+ * completion, no change, enrollment, reconfiguration, or removal, and
944
+ * writes this controller's state for it.
945
+ */
946
+ rcv_sync: ({ account, doc_hash, recovery, approval_valid_until }: {
947
+ account: string;
948
+ doc_hash: Buffer;
949
+ recovery: Array<CompiledRecoveryConfig>;
950
+ approval_valid_until: u32;
951
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<SyncOutcome>>>;
952
+ /**
953
+ * Construct and simulate a statement transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
954
+ * The exact statement evidence for an attempt must sign or prove in
955
+ * `domain`.
956
+ */
957
+ statement: ({ account, attempt_id, domain }: {
958
+ account: string;
959
+ attempt_id: u64;
960
+ domain: EvidenceDomain;
961
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<RecoveryStatement>>>;
962
+ /**
963
+ * Construct and simulate a submit_zk transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
964
+ * T3: a ZK proof for an attempt's statement in `domain`.
965
+ * Permissionless: the proof is the authorization.
966
+ */
967
+ submit_zk: ({ account, attempt_id, domain, evidence }: {
968
+ account: string;
969
+ attempt_id: u64;
970
+ domain: EvidenceDomain;
971
+ evidence: ZkEvidence;
972
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
973
+ /**
974
+ * Construct and simulate a uninstall transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
975
+ * Writes nothing: OZ discards `uninstall` failures, so it can gate
976
+ * nothing, and removal is decided by `rcv_sync`. Invoker-only like every
977
+ * hook, so no signature can call it either.
978
+ */
979
+ uninstall: ({ context_rule, smart_account }: {
980
+ context_rule: ContextRule;
981
+ smart_account: string;
982
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
983
+ /**
984
+ * Construct and simulate a rcv_cancel transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
985
+ * T7: a `Loss` owner cancels an attempt, through the account's
986
+ * `cancel_recovery`. Never counted toward `max-cancels`.
987
+ */
988
+ rcv_cancel: ({ account, attempt_id }: {
989
+ account: string;
990
+ attempt_id: u64;
991
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
992
+ /**
993
+ * Construct and simulate a rcv_upgrade transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
994
+ * The controller's half of the account's upgrade entry points
995
+ * (spec §12). Both steps are refused while an attempt is authorized.
996
+ * `Schedule` checks the recorded condition under `Protected` and
997
+ * returns the epoch the request binds; `Execute` refuses a request
998
+ * recorded under another epoch, then bumps the epoch and returns the
999
+ * new one.
1000
+ */
1001
+ rcv_upgrade: ({ account, step }: {
1002
+ account: string;
1003
+ step: UpgradeStep;
1004
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<u64>>>;
1005
+ /**
1006
+ * Construct and simulate a attempt_live transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1007
+ * Whether an attempt is live (spec §6.2).
1008
+ */
1009
+ attempt_live: ({ account, attempt_id }: {
1010
+ account: string;
1011
+ attempt_id: u64;
1012
+ }, options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
1013
+ /**
1014
+ * Construct and simulate a activity_gate transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1015
+ * What recovery currently restricts for the account.
1016
+ */
1017
+ activity_gate: ({ account }: {
1018
+ account: string;
1019
+ }, options?: MethodOptions) => Promise<AssembledTransaction<ActivityGate>>;
1020
+ /**
1021
+ * Construct and simulate a approve_change transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1022
+ * One guardian's approval of a `Reconfigure` or `Upgrade` statement,
1023
+ * fresh until `valid_until`. Recorded by digest for the consuming
1024
+ * `rcv_sync`/`rcv_upgrade`.
1025
+ */
1026
+ approve_change: ({ account, subject, valid_until, guardian }: {
1027
+ account: string;
1028
+ subject: StatementSubject;
1029
+ valid_until: u32;
1030
+ guardian: string;
1031
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
1032
+ /**
1033
+ * Construct and simulate a begin_lost_key transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1034
+ * T1, lost-key: the target is the applied document with `replacements`
1035
+ * applied. Permissionless. Returns the attempt id.
1036
+ */
1037
+ begin_lost_key: ({ account, replacements }: {
1038
+ account: string;
1039
+ replacements: ReplacementSet;
1040
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<u64>>>;
1041
+ /**
1042
+ * Construct and simulate a change_evidence transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1043
+ * Recorded evidence for a change statement digest.
1044
+ */
1045
+ change_evidence: ({ account, digest }: {
1046
+ account: string;
1047
+ digest: Buffer;
1048
+ }, options?: MethodOptions) => Promise<AssembledTransaction<ChangeApproval>>;
1049
+ /**
1050
+ * Construct and simulate a next_attempt_id transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1051
+ * The id the next `begin_*` will assign.
1052
+ */
1053
+ next_attempt_id: ({ account }: {
1054
+ account: string;
1055
+ }, options?: MethodOptions) => Promise<AssembledTransaction<u64>>;
1056
+ /**
1057
+ * Construct and simulate a nullifier_spent transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1058
+ * Whether `account` spent `nullifier` (spec §11).
1059
+ */
1060
+ nullifier_spent: ({ account, nullifier }: {
1061
+ account: string;
1062
+ nullifier: Buffer;
1063
+ }, options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
1064
+ /**
1065
+ * Construct and simulate a renew_nullifier transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1066
+ * Extend a spent nullifier's record to the network maximum.
1067
+ */
1068
+ renew_nullifier: ({ account, nullifier }: {
1069
+ account: string;
1070
+ nullifier: Buffer;
1071
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
1072
+ /**
1073
+ * Construct and simulate a submit_guardian transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1074
+ * T2: one guardian's approval of an attempt's statement in `domain`.
1075
+ * The guardian authorizes `require_auth_for_args((digest,))` for
1076
+ * exactly that statement.
1077
+ */
1078
+ submit_guardian: ({ account, attempt_id, domain, guardian }: {
1079
+ account: string;
1080
+ attempt_id: u64;
1081
+ domain: EvidenceDomain;
1082
+ guardian: string;
1083
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
1084
+ /**
1085
+ * Construct and simulate a begin_compromise transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1086
+ * T1, compromise: the target is the published baseline's signers and
1087
+ * rules, with the current recovery member and `replacements` applied.
1088
+ * Permissionless. Returns the attempt id.
1089
+ */
1090
+ begin_compromise: ({ account, replacements }: {
1091
+ account: string;
1092
+ replacements: ReplacementSet;
1093
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<u64>>>;
1094
+ /**
1095
+ * Construct and simulate a change_statement transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1096
+ * The exact statement a `Reconfigure` or `Upgrade` approval must sign
1097
+ * or prove.
1098
+ */
1099
+ change_statement: ({ account, subject, valid_until }: {
1100
+ account: string;
1101
+ subject: StatementSubject;
1102
+ valid_until: u32;
1103
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<RecoveryStatement>>>;
1104
+ /**
1105
+ * Construct and simulate a publish_baseline transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1106
+ * Store the enrolled baseline's canonical bytes (spec §3.5).
1107
+ * Permissionless: `doc_json` must compile, through the account's own
1108
+ * compiler, to exactly the enrolled baseline hash and keep an admin
1109
+ * rule. Publishing changes no authority.
1110
+ */
1111
+ publish_baseline: ({ account, doc_json }: {
1112
+ account: string;
1113
+ doc_json: Buffer;
1114
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
1115
+ /**
1116
+ * Construct and simulate a submit_zk_change transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
1117
+ * A ZK proof for a `Reconfigure` or `Upgrade` statement, fresh until
1118
+ * `valid_until`. Permissionless. Does not spend the nullifier.
1119
+ */
1120
+ submit_zk_change: ({ account, subject, valid_until, evidence }: {
1121
+ account: string;
1122
+ subject: StatementSubject;
1123
+ valid_until: u32;
1124
+ evidence: ZkEvidence;
1125
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
1126
+ }
1127
+ export declare class Client extends ContractClient {
1128
+ readonly options: ContractClientOptions;
1129
+ static deploy<T = Client>(
1130
+ /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
1131
+ options: MethodOptions & Omit<ContractClientOptions, "contractId"> & {
1132
+ /** The hash of the Wasm blob, which must already be installed on-chain. */
1133
+ wasmHash: Buffer | string;
1134
+ /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
1135
+ salt?: Buffer | Uint8Array;
1136
+ /** The format used to decode `wasmHash`, if it's provided as a string. */
1137
+ format?: "hex" | "base64";
1138
+ }): Promise<AssembledTransaction<T>>;
1139
+ constructor(options: ContractClientOptions);
1140
+ readonly fromJSON: {
1141
+ epoch: (json: string) => AssembledTransaction<bigint>;
1142
+ renew: (json: string) => AssembledTransaction<null>;
1143
+ config: (json: string) => AssembledTransaction<Option<CompiledRecoveryConfig>>;
1144
+ attempt: (json: string) => AssembledTransaction<Option<Attempt>>;
1145
+ enforce: (json: string) => AssembledTransaction<null>;
1146
+ install: (json: string) => AssembledTransaction<null>;
1147
+ baseline: (json: string) => AssembledTransaction<Option<Buffer<ArrayBufferLike>>>;
1148
+ rcv_sync: (json: string) => AssembledTransaction<Result<SyncOutcome, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1149
+ statement: (json: string) => AssembledTransaction<Result<RecoveryStatement, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1150
+ submit_zk: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1151
+ uninstall: (json: string) => AssembledTransaction<null>;
1152
+ rcv_cancel: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1153
+ rcv_upgrade: (json: string) => AssembledTransaction<Result<bigint, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1154
+ attempt_live: (json: string) => AssembledTransaction<boolean>;
1155
+ activity_gate: (json: string) => AssembledTransaction<ActivityGate>;
1156
+ approve_change: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1157
+ begin_lost_key: (json: string) => AssembledTransaction<Result<bigint, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1158
+ change_evidence: (json: string) => AssembledTransaction<ChangeApproval>;
1159
+ next_attempt_id: (json: string) => AssembledTransaction<bigint>;
1160
+ nullifier_spent: (json: string) => AssembledTransaction<boolean>;
1161
+ renew_nullifier: (json: string) => AssembledTransaction<null>;
1162
+ submit_guardian: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1163
+ begin_compromise: (json: string) => AssembledTransaction<Result<bigint, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1164
+ change_statement: (json: string) => AssembledTransaction<Result<RecoveryStatement, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1165
+ publish_baseline: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1166
+ submit_zk_change: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1167
+ };
1168
+ }