@stellar-registry/perch-contracts 0.1.2 → 0.2.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/dist/account.d.ts CHANGED
@@ -1,31 +1,152 @@
1
1
  /** sha256 of the wasm these bindings were generated from. */
2
- export declare const WASM_SHA256 = "2c976bfd98678f3b6fcf5514420a81ef5e5b9fc1c5b6c60ec6f2dd64448479d5";
2
+ export declare const WASM_SHA256 = "cc56a2d36669dba65c9089ba9c133e284d4b2f9bff826e2d52876e66b5e14428";
3
+ /** These bindings describe a build no deployment runs yet. */
4
+ export declare const DEPLOYED = false;
3
5
  import { Buffer } from "buffer";
4
6
  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";
7
+ import type { u32, u64, i128, Option } from "@stellar/stellar-sdk/contract";
6
8
  export * from "@stellar/stellar-sdk";
7
9
  export * as contract from "@stellar/stellar-sdk/contract";
8
10
  export * as rpc from "@stellar/stellar-sdk/rpc";
9
11
  /**
10
- * One pending account upgrade (spec §12).
12
+ * Represents different types of signers in the smart account system.
13
+ */
14
+ export type Signer = {
15
+ tag: "Delegated";
16
+ values: readonly [string];
17
+ } | {
18
+ tag: "External";
19
+ values: readonly [string, Buffer];
20
+ };
21
+ /**
22
+ * The authorization payload passed to `__check_auth`, bundling cryptographic
23
+ * proofs with context rule selection.
11
24
  *
12
- * Staleness is judged against the account's own **recovery generation**, a
13
- * `u64` the account keeps in its own storage. It starts at 0 and is never
14
- * reset. It advances on every `rcv_sync` outcome other than `Unchanged`
15
- * (`controller::SyncOutcome::bumps_generation`) and on every executed
16
- * upgrade.
25
+ * This struct carries two distinct pieces of information that are both
26
+ * required for authorization but cannot be derived from each other:
17
27
  *
18
- * The controller's epoch cannot play this role. It belongs to one
19
- * controller and does not exist while the account is unenrolled, so a
20
- * request scheduled unenrolled would survive enrolling recovery and
21
- * removing it again: the final state has no controller, just as at
22
- * scheduling.
28
+ * - `signers` maps each [`Signer`] to its raw signature bytes, providing
29
+ * cryptographic proof that the signer actually signed the transaction
30
+ * payload. A context rule stores which signer *identities* are authorized
31
+ * (via `signer_ids`), but the rule does not contain the signatures
32
+ * themselves — those must be supplied here.
33
+ *
34
+ * - `context_rule_ids` tells the system which rule to validate for each auth
35
+ * context. Because multiple rules can exist for the same context type, the
36
+ * caller must explicitly select one per context rather than relying on
37
+ * auto-discovery. Each entry is aligned by index with the `auth_contexts`
38
+ * passed to `__check_auth`.
39
+ *
40
+ * The length of `context_rule_ids` must equal the number of auth contexts;
41
+ * a mismatch is rejected with
42
+ * [`SmartAccountError::ContextRuleIdsLen
43
+ */
44
+ export interface AuthPayload {
45
+ /**
46
+ * Per-context rule IDs, aligned by index with `auth_contexts`.
47
+ */
48
+ context_rule_ids: Array<u32>;
49
+ /**
50
+ * Signature data mapped to each signer.
51
+ */
52
+ signers: Map<Signer, Buffer>;
53
+ }
54
+ /**
55
+ * A complete context rule defining authorization requirements.
56
+ */
57
+ export interface ContextRule {
58
+ /**
59
+ * The type of context this rule applies to.
60
+ */
61
+ context_type: ContextRuleType;
62
+ /**
63
+ * Unique identifier for the context rule.
64
+ */
65
+ id: u32;
66
+ /**
67
+ * Human-readable name for the context rule.
68
+ */
69
+ name: string;
70
+ /**
71
+ * List of policy contracts that must be satisfied.
72
+ */
73
+ policies: Array<string>;
74
+ /**
75
+ * Global registry IDs for each policy, positionally aligned with
76
+ * `policies`.
77
+ */
78
+ policy_ids: Array<u32>;
79
+ /**
80
+ * Global registry IDs for each signer, positionally aligned with
81
+ * `signers`.
82
+ */
83
+ signer_ids: Array<u32>;
84
+ /**
85
+ * List of signers authorized by this rule.
86
+ */
87
+ signers: Array<Signer>;
88
+ /**
89
+ * Optional expiration ledger sequence for the rule.
90
+ */
91
+ valid_until: Option<u32>;
92
+ }
93
+ /**
94
+ * Types of contexts that can be authorized by smart account rules.
95
+ */
96
+ export type ContextRuleType = {
97
+ tag: "Default";
98
+ values: void;
99
+ } | {
100
+ tag: "CallContract";
101
+ values: readonly [string];
102
+ } | {
103
+ tag: "CreateContract";
104
+ values: readonly [Buffer];
105
+ } | {
106
+ tag: "CreateContractExternalRef";
107
+ values: readonly [string, string];
108
+ };
109
+ /**
110
+ * Error codes for smart account operations.
111
+ */
112
+ export declare const SmartAccountError: {
113
+ /**
114
+ * The specified context rule does not exist.
115
+ */
116
+ 3000: {
117
+ message: string;
118
+ };
119
+ /**
120
+ * The provided context cannot be validated against any rule.
121
+ */
122
+ 3002: {
123
+ message: string;
124
+ };
125
+ /**
126
+ * External signature verification failed.
127
+ */
128
+ 3003: {
129
+ message: string;
130
+ };
131
+ /**
132
+ * context_rule_ids length does not match auth_contexts length.
133
+ */
134
+ 3014: {
135
+ message: string;
136
+ };
137
+ /**
138
+ * A signer in `AuthPayload` is not part of any selected context rule.
139
+ */
140
+ 3016: {
141
+ message: string;
142
+ };
143
+ };
144
+ /**
145
+ * A pending account upgrade.
23
146
  */
24
147
  export interface UpgradeRequest {
25
148
  /**
26
- * The adopted controller's epoch when scheduled, if a controller was
27
- * adopted. Passed back as `UpgradeStep::Execute` so the controller can
28
- * check it too.
149
+ * The adopted controller's epoch when scheduled, if any.
29
150
  */
30
151
  controller_epoch: Option<u64>;
31
152
  /**
@@ -46,8 +167,85 @@ export interface UpgradeRequest {
46
167
  wasm_hash: Buffer;
47
168
  }
48
169
  /**
49
- * The shared infra an account resolves, pinned when it was built (see
50
- * [`infra`]): what a deployment check compares with its manifest.
170
+ * `rule_eval::Cap`: its limit, its period in ledgers, and the argument
171
+ * holding the amount.
172
+ */
173
+ export type StoredCap = readonly [i128, u32, u32];
174
+ /**
175
+ * `rule_eval::Val`.
176
+ */
177
+ export type StoredVal = {
178
+ tag: "I128";
179
+ values: readonly [i128];
180
+ } | {
181
+ tag: "U64";
182
+ values: readonly [u64];
183
+ } | {
184
+ tag: "Bool";
185
+ values: readonly [boolean];
186
+ } | {
187
+ tag: "Bytes";
188
+ values: readonly [Buffer];
189
+ } | {
190
+ tag: "Address";
191
+ values: readonly [string];
192
+ } | {
193
+ tag: "Symbol";
194
+ values: readonly [string];
195
+ } | {
196
+ tag: "String";
197
+ values: readonly [string];
198
+ } | {
199
+ tag: "Other";
200
+ values: readonly [Buffer];
201
+ };
202
+ /**
203
+ * `rule_eval::Cond`. An `ArgIn` holds its values as strings, the one form
204
+ * a document's `string-in` lowers to: [`StoredCond::from_cond`] refuses an
205
+ * `ArgIn` of any other value.
206
+ */
207
+ export type StoredCond = {
208
+ tag: "ArgEq";
209
+ values: readonly [u32, StoredVal];
210
+ } | {
211
+ tag: "ArgI128AtMost";
212
+ values: readonly [u32, i128];
213
+ } | {
214
+ tag: "ArgIn";
215
+ values: readonly [u32, Array<string>];
216
+ } | {
217
+ tag: "ArgStrPrefix";
218
+ values: readonly [u32, string];
219
+ };
220
+ /**
221
+ * `rule_eval::Rule`, as a tuple of its fields in this order: its contract,
222
+ * functions, conditions, signers, threshold, cap (zero or one: a
223
+ * `#[contracttype]` has no `Option` of a `#[contracttype]` struct), last
224
+ * ledger, grant generation, and exact root (a singleton when it has one).
225
+ * Its signers are positions in the signer table of the record that holds
226
+ * it ([`StoredRule::from_rule`], [`StoredRule::to_rule`]). The accessors
227
+ * name the fields.
228
+ */
229
+ export type StoredRule = readonly [string, StoredFunctions, Array<StoredCond>, Array<u32>, u32, Array<StoredCap>, Option<u32>, Option<u64>, Option<Array<StoredAuthRoot>>];
230
+ /**
231
+ * Exact authorization-entry root in host form.
232
+ */
233
+ export interface StoredAuthRoot {
234
+ contract: string;
235
+ function: string;
236
+ }
237
+ /**
238
+ * `rule_eval::Functions`.
239
+ */
240
+ export type StoredFunctions = {
241
+ tag: "AnyExcept";
242
+ values: readonly [Array<string>];
243
+ } | {
244
+ tag: "Only";
245
+ values: readonly [Array<string>];
246
+ };
247
+ /**
248
+ * The shared infra contracts this account pins at build time.
51
249
  */
52
250
  export interface InfraPins {
53
251
  doc_compiler: string;
@@ -55,73 +253,478 @@ export interface InfraPins {
55
253
  spending_limit: string;
56
254
  }
57
255
  /**
58
- * The `Protected` freeze, mirrored from the adopted controller through
59
- * [`PerchSmartAccount::rcv_gate`]: while `ledger < until`, the account
60
- * authorizes nothing but `attempt_id`'s completion.
256
+ * The `Protected` freeze: while `ledger < until`, the account authorizes
257
+ * only `attempt_id`'s completion.
61
258
  */
62
259
  export interface FreezeGate {
63
260
  /**
64
- * The authorized attempt, the only one whose completion the account
65
- * authorizes while frozen.
66
- */
67
- attempt_id: u64;
261
+ * The authorized attempt.
262
+ */
263
+ attempt_id: u64;
264
+ /**
265
+ * The authorized attempt's `expires_at`.
266
+ */
267
+ until: u32;
268
+ }
269
+ /**
270
+ * A grant document as applied.
271
+ */
272
+ export interface GrantRecord {
273
+ /**
274
+ * Its canonical `doc_hash`.
275
+ */
276
+ doc_hash: Buffer;
277
+ /**
278
+ * The grant generation it was applied under; wiped once
279
+ * `grant_generation` moves past it.
280
+ */
281
+ gen: u64;
282
+ /**
283
+ * Every context rule it installed, with its id.
284
+ */
285
+ rules: Array<InstalledRule>;
286
+ }
287
+ /**
288
+ * Everything the account's entry points can refuse. Compiler and controller failures flatten in via `#[from_contract_client]`, converted by `??`.
289
+ */
290
+ export declare const PerchAccountError: {
291
+ /**
292
+ * The document keeps no constraint-free, never-expiring self-admin rule with a signer (anti-brick).
293
+ */
294
+ 1: {
295
+ message: string;
296
+ };
297
+ /**
298
+ * The document names a revoked credential.
299
+ */
300
+ 2: {
301
+ message: string;
302
+ };
303
+ /**
304
+ * The document reuses a ZK enrollment id this account enrolled before.
305
+ */
306
+ 3: {
307
+ message: string;
308
+ };
309
+ /**
310
+ * The document changes the ZK factor without a new enrollment id.
311
+ */
312
+ 4: {
313
+ message: string;
314
+ };
315
+ /**
316
+ * `execute` was asked to call an invoker-only hook.
317
+ */
318
+ 5: {
319
+ message: string;
320
+ };
321
+ /**
322
+ * The account has no adopted recovery controller.
323
+ */
324
+ 6: {
325
+ message: string;
326
+ };
327
+ /**
328
+ * No upgrade is scheduled.
329
+ */
330
+ 7: {
331
+ message: string;
332
+ };
333
+ /**
334
+ * The request id is not the pending upgrade's.
335
+ */
336
+ 8: {
337
+ message: string;
338
+ };
339
+ /**
340
+ * The upgrade delay has not elapsed.
341
+ */
342
+ 9: {
343
+ message: string;
344
+ };
345
+ /**
346
+ * A ledger computation overflowed `u32`.
347
+ */
348
+ 10: {
349
+ message: string;
350
+ };
351
+ /**
352
+ * A completion returned a credential that cannot be fingerprinted.
353
+ */
354
+ 11: {
355
+ message: string;
356
+ };
357
+ /**
358
+ * The recovery generation moved since scheduling; the request can never execute.
359
+ */
360
+ 12: {
361
+ message: string;
362
+ };
363
+ /**
364
+ * The submitted document bytes are not UTF-8.
365
+ */
366
+ 13: {
367
+ message: string;
368
+ };
369
+ /**
370
+ * The document failed fail-closed parsing (unknown field, bad shape, unsupported version, duplicate key, …).
371
+ */
372
+ 14: {
373
+ message: string;
374
+ };
375
+ /**
376
+ * The document failed semantic validation (dangling signer ref, malformed address or key, ambiguous empty list, …) or names its verifiers as the compiler does not take.
377
+ */
378
+ 15: {
379
+ message: string;
380
+ };
381
+ /**
382
+ * The document names no network, or a network that is not this chain.
383
+ */
384
+ 16: {
385
+ message: string;
386
+ };
387
+ /**
388
+ * The document cannot be lowered to rules: a rule with self-authenticating principals, or too many constraints.
389
+ */
390
+ 17: {
391
+ message: string;
392
+ };
393
+ /**
394
+ * The document exceeds a cap on signers, rules, bytes, or name length.
395
+ */
396
+ 18: {
397
+ message: string;
398
+ };
399
+ /**
400
+ * A signer's external `key` is not its verifier-canonical form.
401
+ */
402
+ 19: {
403
+ message: string;
404
+ };
405
+ /**
406
+ * `derive_target`: the current document enrolls no recovery.
407
+ */
408
+ 20: {
409
+ message: string;
410
+ };
411
+ /**
412
+ * `derive_target`: the replacement set breaks spec §7.3 rules 1-3, or the action is not a recovery attempt.
413
+ */
414
+ 21: {
415
+ message: string;
416
+ };
417
+ /**
418
+ * `derive_target`: the ZK enrollment is missing, unexpected, or reuses the enrolled id.
419
+ */
420
+ 22: {
421
+ message: string;
422
+ };
423
+ /**
424
+ * `derive_target`: the target has no constraint-free self-admin rule with a signer (the anti-brick check).
425
+ */
426
+ 23: {
427
+ message: string;
428
+ };
429
+ /**
430
+ * No configuration is enrolled for this account at this controller.
431
+ */
432
+ 24: {
433
+ message: string;
434
+ };
435
+ /**
436
+ * An attempt is authorized and live, which blocks begin, policy changes, and upgrades.
437
+ */
438
+ 25: {
439
+ message: string;
440
+ };
441
+ /**
442
+ * No attempt with this id exists for the account.
443
+ */
444
+ 26: {
445
+ message: string;
446
+ };
447
+ /**
448
+ * The attempt is terminal, expired, from an older epoch, or invalidated by a sibling's authorization.
449
+ */
450
+ 27: {
451
+ message: string;
452
+ };
453
+ /**
454
+ * Initiation evidence for an attempt that is no longer collecting.
455
+ */
456
+ 28: {
457
+ message: string;
458
+ };
459
+ /**
460
+ * Completion before `executable_after`.
461
+ */
462
+ 29: {
463
+ message: string;
464
+ };
465
+ /**
466
+ * The completion context, or the compiled document hash, does not match the authorized attempt's target.
467
+ */
468
+ 30: {
469
+ message: string;
470
+ };
471
+ /**
472
+ * The address is not an enrolled guardian.
473
+ */
474
+ 31: {
475
+ message: string;
476
+ };
477
+ /**
478
+ * This guardian or factor already counted for this statement.
479
+ */
480
+ 32: {
481
+ message: string;
482
+ };
483
+ /**
484
+ * The enrolled mode has no guardian factor.
485
+ */
486
+ 33: {
487
+ message: string;
488
+ };
489
+ /**
490
+ * The enrolled mode has no ZK factor.
491
+ */
492
+ 34: {
493
+ message: string;
494
+ };
495
+ /**
496
+ * The adapter refused the proof (its `ZkAdapterError` says why).
497
+ */
498
+ 35: {
499
+ message: string;
500
+ };
501
+ /**
502
+ * The proof's nullifier is spent.
503
+ */
504
+ 36: {
505
+ message: string;
506
+ };
507
+ /**
508
+ * The statement's freshness bound has passed or reaches too far.
509
+ */
510
+ 37: {
511
+ message: string;
512
+ };
513
+ /**
514
+ * The statement cannot be encoded (a non-contract account or controller).
515
+ */
516
+ 38: {
517
+ message: string;
518
+ };
519
+ /**
520
+ * Recorded approvals do not satisfy the enrolled condition for this reconfiguration or upgrade.
521
+ */
522
+ 39: {
523
+ message: string;
524
+ };
525
+ /**
526
+ * The account's `max-cancels` is used up.
527
+ */
528
+ 40: {
529
+ message: string;
530
+ };
531
+ /**
532
+ * Owner cancellation is only available under `Loss`.
533
+ */
534
+ 41: {
535
+ message: string;
536
+ };
537
+ /**
538
+ * The replacement set breaks a §7.3 rule, or derivation refused it.
539
+ */
540
+ 42: {
541
+ message: string;
542
+ };
543
+ /**
544
+ * The target or a replacement contains a revoked credential.
545
+ */
546
+ 43: {
547
+ message: string;
548
+ };
549
+ /**
550
+ * The ZK enrollment id was enrolled for this account before.
551
+ */
552
+ 44: {
553
+ message: string;
554
+ };
555
+ /**
556
+ * Compromise recovery with no baseline enrolled.
557
+ */
558
+ 45: {
559
+ message: string;
560
+ };
561
+ /**
562
+ * Compromise recovery before the baseline's content was published.
563
+ */
564
+ 46: {
565
+ message: string;
566
+ };
567
+ /**
568
+ * The published document does not hash to the enrolled baseline.
569
+ */
570
+ 47: {
571
+ message: string;
572
+ };
573
+ /**
574
+ * The adapter's circuit id or tree depth does not match the enrolled factor and pool.
575
+ */
576
+ 48: {
577
+ message: string;
578
+ };
579
+ /**
580
+ * The ZK factor changed without a new enrollment id.
581
+ */
582
+ 49: {
583
+ message: string;
584
+ };
585
+ /**
586
+ * The configuration is malformed.
587
+ */
588
+ 50: {
589
+ message: string;
590
+ };
591
+ /**
592
+ * An upgrade request recorded under an older epoch.
593
+ */
594
+ 51: {
595
+ message: string;
596
+ };
597
+ /**
598
+ * A ledger-sequence computation overflowed `u32`.
599
+ */
600
+ 52: {
601
+ message: string;
602
+ };
603
+ /**
604
+ * A hook was called for a recovery rule of the wrong shape.
605
+ */
606
+ 53: {
607
+ message: string;
608
+ };
609
+ /**
610
+ * The target keeps a credential the replacement set replaces.
611
+ */
612
+ 54: {
613
+ message: string;
614
+ };
615
+ /**
616
+ * The account is not at `apply_doc`'s `expected_revision`.
617
+ */
618
+ 55: {
619
+ message: string;
620
+ };
621
+ /**
622
+ * A completed recovery would overflow the grant generation.
623
+ */
624
+ 56: {
625
+ message: string;
626
+ };
627
+ /**
628
+ * A grant document has a `recovery` member, a self-admin rule, a rule on the account or its recovery contracts, a guardian approval, or a token-admin function.
629
+ */
630
+ 57: {
631
+ message: string;
632
+ };
633
+ /**
634
+ * No grant document has this grant id.
635
+ */
636
+ 58: {
637
+ message: string;
638
+ };
639
+ /**
640
+ * `gc_grant` was given a live grant; `remove_grant` removes it.
641
+ */
642
+ 59: {
643
+ message: string;
644
+ };
645
+ /**
646
+ * The document names a credential from a grant a recovery has wiped.
647
+ */
648
+ 60: {
649
+ message: string;
650
+ };
651
+ /**
652
+ * The compiled document's model is missing, duplicated, unreadable, or does not match its rules.
653
+ */
654
+ 61: {
655
+ message: string;
656
+ };
657
+ /**
658
+ * A rule other than the recovery rule asks for no signer (INV-1).
659
+ */
660
+ 62: {
661
+ message: string;
662
+ };
68
663
  /**
69
- * The authorized attempt's `expires_at`.
70
- */
71
- until: u32;
72
- }
664
+ * A grant document is not in normal form, or has a rule already expired.
665
+ */
666
+ 63: {
667
+ message: string;
668
+ };
669
+ /**
670
+ * A constructor admin signer's verifier is not one `perch/verifiers` deployed.
671
+ */
672
+ 64: {
673
+ message: string;
674
+ };
675
+ /**
676
+ * Cross-contract call aborted
677
+ */
678
+ 0: {
679
+ message: string;
680
+ };
681
+ /**
682
+ * Unknown error from cross-contract call
683
+ */
684
+ 2147483647: {
685
+ message: string;
686
+ };
687
+ };
73
688
  /**
74
- * Constants of the deployed account wasm a wallet checks before it builds
75
- * anything for this account: what [`PerchSmartAccount::capabilities`]
76
- * returns.
689
+ * Constants of this wasm a wallet checks before building for the account.
77
690
  */
78
691
  export interface AccountCapabilities {
79
692
  /**
80
- * How a document is applied: `one_tx`, one `apply_doc` transaction.
693
+ * `one_tx` (account document) and `grant_v1` (grant documents).
81
694
  */
82
695
  apply_modes: Array<string>;
83
696
  /**
84
- * What a signer signs: `addr_oz_v1`, OZ's
85
- * `sha256(bound_payload || context_rule_ids.to_xdr())`, where
86
- * `bound_payload = sha256(AUTH_ADDR_DOMAIN || account_id ||
87
- * signature_payload)` binds the account's own address so a signature
88
- * cannot be replayed on another account ([`AUTH_ADDR_DOMAIN`]). The
89
- * earlier `oz_rule_ids` scheme omitted the account address; a client
90
- * reads this symbol to tell which digest an account expects.
697
+ * What signers sign: `addr_oz_v1`, bound to the account's address.
91
698
  */
92
699
  auth_digest: string;
93
700
  /**
94
- * How the applied `doc_hash` is computed: `canon_v1`, `sha256` of the
95
- * CANON v1 canonical bytes.
701
+ * How `doc_hash` is computed: `canon_v1`.
96
702
  */
97
703
  doc_identity: string;
98
704
  /**
99
- * [`INTERFACE_VERSION`].
705
+ * The interface version.
100
706
  */
101
707
  interface_version: u32;
102
708
  /**
103
- * [`SNAPSHOT_VERSION`].
709
+ * The `AccountConfiguration` layout version.
104
710
  */
105
711
  snapshot_version: u32;
106
712
  }
107
713
  /**
108
- * Everything rule selection and signing need, read at one ledger: what
109
- * [`PerchSmartAccount::configuration`] returns.
714
+ * What rule selection and signing need for the account document, read at one
715
+ * ledger.
110
716
  */
111
717
  export interface AccountConfiguration {
112
718
  /**
113
- * The applied document's `doc_hash`, or `None` before the first apply.
719
+ * The applied document's `doc_hash`, if any.
114
720
  */
115
721
  doc_hash: Option<Buffer>;
116
722
  /**
117
- * The `Protected` freeze: zero or one entries (a `Vec` because
118
- * `#[contracttype]` has no conversion for `Option` of a custom struct).
119
- * It is in force while the ledger is below its `until`.
723
+ * The `Protected` freeze: zero or one entries.
120
724
  */
121
725
  gate: Array<FreezeGate>;
122
726
  /**
123
- * The shared infra the account pins, as [`PerchSmartAccount::infra`]
124
- * returns it.
727
+ * The shared infra the account pins.
125
728
  */
126
729
  infra: InfraPins;
127
730
  /**
@@ -129,20 +732,19 @@ export interface AccountConfiguration {
129
732
  */
130
733
  recovery_controller: Option<string>;
131
734
  /**
132
- * The recovery generation (spec §12), as
133
- * [`PerchSmartAccount::recovery_generation`] returns it.
735
+ * The recovery generation.
134
736
  */
135
737
  recovery_generation: u64;
136
738
  /**
137
- * The zero-signer recovery rule's OZ id, if one is installed.
739
+ * The recovery rule's id, if installed.
138
740
  */
139
741
  recovery_rule: Option<u32>;
140
742
  /**
141
- * The configuration revision every other field belongs to.
743
+ * The revision every other field belongs to.
142
744
  */
143
745
  revision: u64;
144
746
  /**
145
- * Every installed context rule, with its OZ id.
747
+ * Every installed admin context rule, with its id.
146
748
  */
147
749
  rules: Array<InstalledRule>;
148
750
  }
@@ -151,16 +753,19 @@ export interface AccountConfiguration {
151
753
  */
152
754
  export interface InstalledRule {
153
755
  /**
154
- * The rule's OZ scope.
756
+ * Exact root of this account's authorization entry, if constrained.
757
+ */
758
+ auth_root: Option<Array<StoredAuthRoot>>;
759
+ /**
760
+ * The contract the rule authorizes calls to.
155
761
  */
156
762
  context_type: ContextRuleType;
157
763
  /**
158
- * The OZ context-rule id.
764
+ * The rule id.
159
765
  */
160
766
  id: u32;
161
767
  /**
162
- * The rule's name: the document rule's, `admin` for the constructor's,
163
- * `recovery` for the recovery rule.
768
+ * The rule's name.
164
769
  */
165
770
  name: string;
166
771
  /**
@@ -168,9 +773,7 @@ export interface InstalledRule {
168
773
  */
169
774
  policies: Array<InstalledPolicy>;
170
775
  /**
171
- * The zero-signer recovery rule. Document rules are matched by name;
172
- * the recovery rule by this flag, so a document rule that happens to be
173
- * named `recovery` is never confused with it.
776
+ * Whether this is the zero-signer recovery rule.
174
777
  */
175
778
  recovery: boolean;
176
779
  /**
@@ -178,7 +781,7 @@ export interface InstalledRule {
178
781
  */
179
782
  signers: Array<Signer>;
180
783
  /**
181
- * OZ's inclusive last valid ledger, if bounded.
784
+ * The inclusive last valid ledger, if bounded.
182
785
  */
183
786
  valid_until: Option<u32>;
184
787
  }
@@ -187,9 +790,7 @@ export interface InstalledRule {
187
790
  */
188
791
  export interface InstalledPolicy {
189
792
  /**
190
- * `sha256` of the install parameters' XDR. A policy whose parameters
191
- * change is uninstalled and installed again; one whose parameters are
192
- * unchanged is left alone.
793
+ * `sha256` of the install parameters' XDR.
193
794
  */
194
795
  params: Buffer;
195
796
  /**
@@ -197,6 +798,27 @@ export interface InstalledPolicy {
197
798
  */
198
799
  policy: string;
199
800
  }
801
+ /**
802
+ * Contract executable used for creating a new contract and used in
803
+ * `CreateContractHostFnContext`.
804
+ */
805
+ export type ContractExecutable = {
806
+ tag: "Wasm";
807
+ values: readonly [Buffer];
808
+ } | {
809
+ tag: "ExternalRef";
810
+ values: readonly [ContractExecutableRef];
811
+ };
812
+ /**
813
+ * Executable referenced via a persistent storage entry owned by a contract,
814
+ * either this contract or another contract.
815
+ *
816
+ * The persistent storage entry owned by the `owner` has the `tag` as its key.
817
+ */
818
+ export interface ContractExecutableRef {
819
+ owner: string;
820
+ tag: string;
821
+ }
200
822
  /**
201
823
  * Context of a single authorized call performed by an address.
202
824
  *
@@ -225,14 +847,6 @@ export interface ContractContext {
225
847
  contract: string;
226
848
  fn_name: string;
227
849
  }
228
- /**
229
- * Contract executable used for creating a new contract and used in
230
- * `CreateContractHostFnContext`.
231
- */
232
- export type ContractExecutable = {
233
- tag: "Wasm";
234
- values: readonly [Buffer];
235
- };
236
850
  /**
237
851
  * Authorization context for `create_contract` host function that creates a
238
852
  * new contract on behalf of authorizer address.
@@ -252,204 +866,14 @@ export interface CreateContractWithConstructorHostFnContext {
252
866
  executable: ContractExecutable;
253
867
  salt: Buffer;
254
868
  }
255
- /**
256
- * Error codes for smart account operations.
257
- */
258
- export declare const SmartAccountError: {
259
- /**
260
- * The specified context rule does not exist.
261
- */
262
- 3000: {
263
- message: string;
264
- };
265
- /**
266
- * The provided context cannot be validated against any rule.
267
- */
268
- 3002: {
269
- message: string;
270
- };
271
- /**
272
- * External signature verification failed.
273
- */
274
- 3003: {
275
- message: string;
276
- };
277
- /**
278
- * Context rule must have at least one signer or policy.
279
- */
280
- 3004: {
281
- message: string;
282
- };
283
- /**
284
- * The valid_until timestamp is in the past.
285
- */
286
- 3005: {
287
- message: string;
288
- };
289
- /**
290
- * The specified signer was not found.
291
- */
292
- 3006: {
293
- message: string;
294
- };
295
- /**
296
- * The signer already exists in the context rule.
297
- */
298
- 3007: {
299
- message: string;
300
- };
301
- /**
302
- * The specified policy was not found.
303
- */
304
- 3008: {
305
- message: string;
306
- };
307
- /**
308
- * The policy already exists in the context rule.
309
- */
310
- 3009: {
311
- message: string;
312
- };
313
- /**
314
- * Too many signers in the context rule.
315
- */
316
- 3010: {
317
- message: string;
318
- };
319
- /**
320
- * Too many policies in the context rule.
321
- */
322
- 3011: {
323
- message: string;
324
- };
325
- /**
326
- * An internal ID counter (context rule, signer, or policy) has reached
327
- * its maximum value (`u32::MAX`) and cannot be incremented further.
328
- */
329
- 3012: {
330
- message: string;
331
- };
332
- /**
333
- * External signer key data exceeds the maximum allowed size.
334
- */
335
- 3013: {
336
- message: string;
337
- };
338
- /**
339
- * context_rule_ids length does not match auth_contexts length.
340
- */
341
- 3014: {
342
- message: string;
343
- };
344
- /**
345
- * Context rule name exceeds the maximum allowed length.
346
- */
347
- 3015: {
348
- message: string;
349
- };
869
+ export interface Client {
350
870
  /**
351
- * A signer in `AuthPayload` is not part of any selected context rule.
871
+ * Construct and simulate a grant 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.
872
+ * The grant document under `grant` as applied, if any.
352
873
  */
353
- 3016: {
354
- message: string;
355
- };
356
- };
357
- /**
358
- * Represents different types of signers in the smart account system.
359
- */
360
- export type Signer = {
361
- tag: "Delegated";
362
- values: readonly [string];
363
- } | {
364
- tag: "External";
365
- values: readonly [string, Buffer];
366
- };
367
- /**
368
- * The authorization payload passed to `__check_auth`, bundling cryptographic
369
- * proofs with context rule selection.
370
- *
371
- * This struct carries two distinct pieces of information that are both
372
- * required for authorization but cannot be derived from each other:
373
- *
374
- * - `signers` maps each [`Signer`] to its raw signature bytes, providing
375
- * cryptographic proof that the signer actually signed the transaction
376
- * payload. A context rule stores which signer *identities* are authorized
377
- * (via `signer_ids`), but the rule does not contain the signatures
378
- * themselves — those must be supplied here.
379
- *
380
- * - `context_rule_ids` tells the system which rule to validate for each auth
381
- * context. Because multiple rules can exist for the same context type, the
382
- * caller must explicitly select one per context rather than relying on
383
- * auto-discovery. Each entry is aligned by index with the `auth_contexts`
384
- * passed to `__check_auth`.
385
- *
386
- * The length of `context_rule_ids` must equal the number of auth contexts;
387
- * a mismatch is rejected with
388
- * [`SmartAccountError::ContextRuleIdsLen
389
- */
390
- export interface AuthPayload {
391
- /**
392
- * Per-context rule IDs, aligned by index with `auth_contexts`.
393
- */
394
- context_rule_ids: Array<u32>;
395
- /**
396
- * Signature data mapped to each signer.
397
- */
398
- signers: Map<Signer, Buffer>;
399
- }
400
- /**
401
- * A complete context rule defining authorization requirements.
402
- */
403
- export interface ContextRule {
404
- /**
405
- * The type of context this rule applies to.
406
- */
407
- context_type: ContextRuleType;
408
- /**
409
- * Unique identifier for the context rule.
410
- */
411
- id: u32;
412
- /**
413
- * Human-readable name for the context rule.
414
- */
415
- name: string;
416
- /**
417
- * List of policy contracts that must be satisfied.
418
- */
419
- policies: Array<string>;
420
- /**
421
- * Global registry IDs for each policy, positionally aligned with
422
- * `policies`.
423
- */
424
- policy_ids: Array<u32>;
425
- /**
426
- * Global registry IDs for each signer, positionally aligned with
427
- * `signers`.
428
- */
429
- signer_ids: Array<u32>;
430
- /**
431
- * List of signers authorized by this rule.
432
- */
433
- signers: Array<Signer>;
434
- /**
435
- * Optional expiration ledger sequence for the rule.
436
- */
437
- valid_until: Option<u32>;
438
- }
439
- /**
440
- * Types of contexts that can be authorized by smart account rules.
441
- */
442
- export type ContextRuleType = {
443
- tag: "Default";
444
- values: void;
445
- } | {
446
- tag: "CallContract";
447
- values: readonly [string];
448
- } | {
449
- tag: "CreateContract";
450
- values: readonly [Buffer];
451
- };
452
- export interface Client {
874
+ grant: ({ grant }: {
875
+ grant: u32;
876
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Option<GrantRecord>>>;
453
877
  /**
454
878
  * Construct and simulate a infra 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.
455
879
  * Every shared contract this account pins at build time.
@@ -457,22 +881,26 @@ export interface Client {
457
881
  infra: (options?: MethodOptions) => Promise<AssembledTransaction<InfraPins>>;
458
882
  /**
459
883
  * 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.
460
- * Extend the account's instance, the applied document and its credential
461
- * fingerprints, and the named revoked-set and enrolled-id entries to the
462
- * network maximum. Permissionless; changes no meaning.
884
+ * Extend the account's instance, document, and the named revoked and
885
+ * enrolled entries to the maximum TTL. Permissionless.
463
886
  */
464
887
  renew: ({ fingerprints, enrollment_ids }: {
465
888
  fingerprints: Array<Buffer>;
466
889
  enrollment_ids: Array<Buffer>;
467
890
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
891
+ /**
892
+ * Construct and simulate a grants 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.
893
+ * The grant ids at index positions `start..start + count`, wiped ones
894
+ * included.
895
+ */
896
+ grants: ({ start, count }: {
897
+ start: u32;
898
+ count: u32;
899
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Array<u32>>>;
468
900
  /**
469
901
  * Construct and simulate a execute 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.
470
- * Call `target_fn` on `target` as this account (the account becomes
471
- * the invoker, so `target`'s `require_auth` of this account passes).
472
- * Requires the account's authorization of this exact call. Refuses the
473
- * invoker-only hook names: otherwise whoever can authorize `execute`
474
- * could reach a controller, policy, or pool hook as the account
475
- * (spec §15).
902
+ * Call `target_fn` on `target` as this account. Owner authorization;
903
+ * refuses invoker-only hooks.
476
904
  */
477
905
  execute: ({ target, target_fn, target_args }: {
478
906
  target: string;
@@ -481,18 +909,22 @@ export interface Client {
481
909
  }, options?: MethodOptions) => Promise<AssembledTransaction<Result<any>>>;
482
910
  /**
483
911
  * Construct and simulate a document 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.
484
- * The applied document's canonical bytes with the revision they belong
485
- * to; `None` before the first `apply_doc`.
912
+ * The applied account document's canonical bytes, with the revision they
913
+ * belong to.
486
914
  */
487
915
  document: (options?: MethodOptions) => Promise<AssembledTransaction<readonly [u64, Option<Buffer>]>>;
916
+ /**
917
+ * Construct and simulate a gc_grant 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.
918
+ * Remove a grant document a recovery wiped, and its rules.
919
+ * Permissionless.
920
+ */
921
+ gc_grant: ({ grant }: {
922
+ grant: u32;
923
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
488
924
  /**
489
925
  * Construct and simulate a rcv_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.
490
- * Invoker-only: the adopted controller sets (`frozen_until > 0`) or
491
- * clears (`0`) the `Protected` freeze for `attempt_id`. The account
492
- * mirrors the freeze rather than asking the controller from
493
- * `__check_auth`, because an account approving as a guardian through
494
- * the same controller instance runs `__check_auth` while that
495
- * controller is on the call stack, and the host refuses re-entry.
926
+ * Invoker-only: the adopted controller sets (`frozen_until > 0`) or clears
927
+ * (`0`) the `Protected` freeze.
496
928
  */
497
929
  rcv_gate: ({ attempt_id, frozen_until }: {
498
930
  attempt_id: u64;
@@ -500,35 +932,22 @@ export interface Client {
500
932
  }, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
501
933
  /**
502
934
  * Construct and simulate a revision 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.
503
- * The configuration revision: 0 after the constructor, advanced by one
504
- * in every successful `apply_doc` (whatever it changes, a re-apply of
505
- * the same document included) and every executed upgrade. Freeze
506
- * changes, recovery attempts, evidence, and cancellations do not
507
- * advance it. Never decreases and never repeats, so unlike `doc_hash` it
508
- * tells A -> B -> A apart.
935
+ * The configuration revision: advanced by every `apply_doc` and executed
936
+ * upgrade; never repeats.
509
937
  */
510
938
  revision: (options?: MethodOptions) => Promise<AssembledTransaction<u64>>;
939
+ /**
940
+ * Construct and simulate a rule_set 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 rule-eval rules `__check_auth` evaluates, aligned with
942
+ * `installed_rules`, their signers positions in `rule_signers`.
943
+ */
944
+ rule_set: (options?: MethodOptions) => Promise<AssembledTransaction<Array<StoredRule>>>;
511
945
  /**
512
946
  * Construct and simulate a apply_doc 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.
513
- * Apply a policy document — **the only way authorization changes**.
514
- * The shared, immutable infra it uses (the doc compiler, the
515
- * interpreter, and the spending limit) is derived from build-time pins
516
- * (see [`infra`]), never passed in. Brings the installed rules to the
517
- * document in one invocation, changing only the rules that differ, and
518
- * returns the canonical `doc_hash`.
519
- *
520
- * Authorized by the owner (any ordinary rule scoped to the account),
521
- * or, for a recovery completion only, by the zero-signer recovery rule
522
- * whose controller checks the exact target. On an account with an
523
- * adopted controller, the controller's `rcv_sync` classifies the call
524
- * before any rule changes and refuses what the profile does not allow
525
- * (`docs/recovery/spec.md` §10). `approval_valid_until` is the
526
- * freshness bound a `Protected` reconfiguration's recorded approvals
527
- * were given for; it is ignored otherwise.
528
- *
529
- * With `expected_revision`, the call refuses with `StaleRevision`
530
- * unless the account is still at that [`Self::revision`], so a document
531
- * prepared agains
947
+ * Apply the account document and return its `doc_hash`. Owner
948
+ * authorization, or the recovery rule for a completion. Refuses
949
+ * `StaleRevision` unless the account is at `expected_revision`, if given.
950
+ * `approval_valid_until` bounds a `Protected` reconfiguration's approvals.
532
951
  */
533
952
  apply_doc: ({ doc_json, approval_valid_until, expected_revision }: {
534
953
  doc_json: Buffer;
@@ -544,16 +963,27 @@ export interface Client {
544
963
  }, options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
545
964
  /**
546
965
  * Construct and simulate a applied_doc 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.
547
- * The applied document's canonical bytes, or `None` before the first
548
- * `apply_doc`. Under CANON v1, `sha256` of them is
549
- * [`Self::applied_doc_hash`].
966
+ * The applied account document's canonical bytes, if any.
550
967
  */
551
968
  applied_doc: (options?: MethodOptions) => Promise<AssembledTransaction<Option<Buffer>>>;
969
+ /**
970
+ * Construct and simulate a apply_grant 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.
971
+ * Apply a grant document under `grant` and return its `doc_hash`. Owner
972
+ * authorization.
973
+ */
974
+ apply_grant: ({ grant, doc_json }: {
975
+ grant: u32;
976
+ doc_json: Buffer;
977
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<Buffer>>>;
978
+ /**
979
+ * Construct and simulate a grant_count 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.
980
+ * How many grant ids have a record, wiped ones included.
981
+ */
982
+ grant_count: (options?: MethodOptions) => Promise<AssembledTransaction<u32>>;
552
983
  /**
553
984
  * Construct and simulate a capabilities 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.
554
- * Constants of this account's wasm: interface and snapshot versions,
555
- * the document identity and authorization digest schemes, and the apply
556
- * modes.
985
+ * Constants of this wasm: interface and snapshot versions, digest schemes,
986
+ * and apply modes.
557
987
  */
558
988
  capabilities: (options?: MethodOptions) => Promise<AssembledTransaction<AccountCapabilities>>;
559
989
  /**
@@ -561,16 +991,38 @@ export interface Client {
561
991
  * The doc compiler this account pins at build time.
562
992
  */
563
993
  doc_compiler: (options?: MethodOptions) => Promise<AssembledTransaction<string>>;
994
+ /**
995
+ * Construct and simulate a remove_grant 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.
996
+ * Remove the grant document under `grant` and its rules. Owner
997
+ * authorization.
998
+ */
999
+ remove_grant: ({ grant }: {
1000
+ grant: u32;
1001
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
1002
+ /**
1003
+ * Construct and simulate a rule_signers 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.
1004
+ * The signer table of the account document's stored rules: each signer
1005
+ * once, at the position `rule_set` names it by.
1006
+ */
1007
+ rule_signers: (options?: MethodOptions) => Promise<AssembledTransaction<Array<Signer>>>;
564
1008
  /**
565
1009
  * Construct and simulate a configuration 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.
566
- * Everything rule selection and signing need, read at one ledger, with
567
- * the revision it belongs to.
1010
+ * The account document's configuration, read at one ledger.
568
1011
  */
569
1012
  configuration: (options?: MethodOptions) => Promise<AssembledTransaction<AccountConfiguration>>;
1013
+ /**
1014
+ * Construct and simulate a grant_signers 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
+ * The signer table of the grant document under `grant`, if any: each
1016
+ * signer once, at the position `grant_rule_set` names it by, in the
1017
+ * order its rules first name them.
1018
+ */
1019
+ grant_signers: ({ grant }: {
1020
+ grant: u32;
1021
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Option<Array<Signer>>>>;
570
1022
  /**
571
1023
  * Construct and simulate a recovery_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.
572
- * The `Protected` freeze, if one was set and has not been cleared. It
573
- * is in force while the current ledger is below `until`.
1024
+ * The `Protected` freeze, if set; in force while the ledger is below
1025
+ * `until`.
574
1026
  */
575
1027
  recovery_gate: (options?: MethodOptions) => Promise<AssembledTransaction<Option<FreezeGate>>>;
576
1028
  /**
@@ -578,6 +1030,14 @@ export interface Client {
578
1030
  * Cancel the pending upgrade. Owner authorization.
579
1031
  */
580
1032
  cancel_upgrade: (options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
1033
+ /**
1034
+ * Construct and simulate a grant_rule_set 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.
1035
+ * The rule-eval rules of the grant document under `grant`, aligned with
1036
+ * its record's rules, their signers positions in `grant_signers`.
1037
+ */
1038
+ grant_rule_set: ({ grant }: {
1039
+ grant: u32;
1040
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Array<StoredRule>>>;
581
1041
  /**
582
1042
  * Construct and simulate a is_enrolled_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.
583
1043
  * Whether this account ever enrolled a ZK enrollment id.
@@ -587,34 +1047,23 @@ export interface Client {
587
1047
  }, options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
588
1048
  /**
589
1049
  * Construct and simulate a cancel_recovery 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.
590
- * A `Loss` owner's cancellation of a recovery attempt (spec T7). The
591
- * controller refuses it under `Protected`.
1050
+ * A `Loss` owner's cancellation of a recovery attempt.
592
1051
  */
593
1052
  cancel_recovery: ({ attempt_id }: {
594
1053
  attempt_id: u64;
595
1054
  }, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
596
1055
  /**
597
1056
  * Construct and simulate a execute_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.
598
- * Execute the pending upgrade once its delay has elapsed. Owner
599
- * authorization. If the recovery generation moved since scheduling
600
- * (any enrollment, reconfiguration, removal, controller switch,
601
- * completed recovery, or executed upgrade), the request is stale and
602
- * the call refuses with `StaleUpgrade`. The refusal leaves the request
603
- * in place, since a failed invocation keeps none of its writes; it can
604
- * never execute, because the generation never decreases, and stays
605
- * until `schedule_upgrade` replaces it, `cancel_upgrade` removes it, or
606
- * a completion clears it. Otherwise the controller, if one is adopted,
607
- * checks its epoch and bumps it (refusing during an authorized
608
- * attempt), the generation advances, and the Wasm is replaced after
609
- * this invocation.
1057
+ * Execute the pending upgrade once its delay has passed. Owner
1058
+ * authorization. Refuses `StaleUpgrade` if the recovery generation moved
1059
+ * since scheduling.
610
1060
  */
611
1061
  execute_upgrade: ({ request_id }: {
612
1062
  request_id: u64;
613
1063
  }, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
614
1064
  /**
615
1065
  * Construct and simulate a installed_rules 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.
616
- * Every context rule the account has installed, with its OZ id. The
617
- * document's rules are matched against these by `apply_doc`.
1066
+ * Every context rule the account document installed, with its id.
618
1067
  */
619
1068
  installed_rules: (options?: MethodOptions) => Promise<AssembledTransaction<Array<InstalledRule>>>;
620
1069
  /**
@@ -624,28 +1073,35 @@ export interface Client {
624
1073
  pending_upgrade: (options?: MethodOptions) => Promise<AssembledTransaction<Option<UpgradeRequest>>>;
625
1074
  /**
626
1075
  * Construct and simulate a applied_doc_hash 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.
627
- * The canonical `doc_hash` of the currently applied policy document, or
628
- * `None` before the first `apply_doc` (only the constructor's admin rule
629
- * exists then). Anyone can check installed == reviewed.
1076
+ * The applied account document's canonical `doc_hash`, if any.
630
1077
  */
631
1078
  applied_doc_hash: (options?: MethodOptions) => Promise<AssembledTransaction<Option<Buffer>>>;
632
1079
  /**
633
1080
  * Construct and simulate a get_context_rule 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.
634
- * The OZ context rule with this id; panics if there is none. Re-exposed
635
- * like [`Self::get_context_rules_count`].
1081
+ * The context rule with this id; panics if there is none.
636
1082
  */
637
1083
  get_context_rule: ({ context_rule_id }: {
638
1084
  context_rule_id: u32;
639
1085
  }, options?: MethodOptions) => Promise<AssembledTransaction<ContextRule>>;
1086
+ /**
1087
+ * Construct and simulate a grant_generation 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.
1088
+ * The grant generation: advanced only by completed recoveries. A grant
1089
+ * applied under another is wiped.
1090
+ */
1091
+ grant_generation: (options?: MethodOptions) => Promise<AssembledTransaction<u64>>;
1092
+ /**
1093
+ * Construct and simulate a grant_signer_ids 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.
1094
+ * The signer ids of the grant document under `grant`, in declaration
1095
+ * order, if any: with its rules, they give back its canonical text.
1096
+ */
1097
+ grant_signer_ids: ({ grant }: {
1098
+ grant: u32;
1099
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Option<Array<string>>>>;
640
1100
  /**
641
1101
  * Construct and simulate a schedule_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.
642
- * Schedule an upgrade to `wasm_hash`, executable after
643
- * [`ACCOUNT_UPGRADE_DELAY_LEDGERS`] (spec §12). Owner authorization;
644
- * under `Protected` also the condition's recorded approval of
645
- * `Upgrade { request_id, wasm_hash }` fresh until
646
- * `approval_valid_until` (`next_upgrade_request_id` names the id to
647
- * approve). Refused while a recovery attempt is authorized. Replaces any
648
- * earlier request. Returns the request id.
1102
+ * Schedule an upgrade to `wasm_hash` after the upgrade delay, replacing
1103
+ * any pending one, and return its id. Owner authorization; under
1104
+ * `Protected`, also approvals fresh until `approval_valid_until`.
649
1105
  */
650
1106
  schedule_upgrade: ({ wasm_hash, approval_valid_until }: {
651
1107
  wasm_hash: Buffer;
@@ -658,20 +1114,34 @@ export interface Client {
658
1114
  recovery_controller: (options?: MethodOptions) => Promise<AssembledTransaction<Option<string>>>;
659
1115
  /**
660
1116
  * Construct and simulate a recovery_generation 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.
661
- * The account's recovery generation (spec §12).
1117
+ * The account's recovery generation.
662
1118
  */
663
1119
  recovery_generation: (options?: MethodOptions) => Promise<AssembledTransaction<u64>>;
1120
+ /**
1121
+ * Construct and simulate a grant_verifier_names 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.
1122
+ * Each signer's `verifier-name` in the grant document under `grant`,
1123
+ * aligned with `grant_signer_ids`, if any: empty where a signer has
1124
+ * none, and no entries when no signer has one.
1125
+ */
1126
+ grant_verifier_names: ({ grant }: {
1127
+ grant: u32;
1128
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Option<Array<string>>>>;
1129
+ /**
1130
+ * Construct and simulate a credential_generation 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.
1131
+ * The last grant generation a grant document named this credential under,
1132
+ * if any.
1133
+ */
1134
+ credential_generation: ({ fingerprint }: {
1135
+ fingerprint: Buffer;
1136
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Option<u64>>>;
664
1137
  /**
665
1138
  * Construct and simulate a get_context_rules_count 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.
666
- * OZ's count of the account's context rules, expired ones included.
667
- * Read-only rule surface, re-exposed here because `SmartAccount` itself
668
- * is deliberately not exported by doc-only accounts.
1139
+ * The count of context rules, grants' and expired ones included.
669
1140
  */
670
1141
  get_context_rules_count: (options?: MethodOptions) => Promise<AssembledTransaction<u32>>;
671
1142
  /**
672
1143
  * Construct and simulate a next_upgrade_request_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.
673
- * The id the next `schedule_upgrade` will assign: what `Protected`
674
- * approvers approve.
1144
+ * The id the next `schedule_upgrade` assigns.
675
1145
  */
676
1146
  next_upgrade_request_id: (options?: MethodOptions) => Promise<AssembledTransaction<u64>>;
677
1147
  }
@@ -693,20 +1163,30 @@ export declare class Client extends ContractClient {
693
1163
  }): Promise<AssembledTransaction<T>>;
694
1164
  constructor(options: ContractClientOptions);
695
1165
  readonly fromJSON: {
1166
+ grant: (json: string) => AssembledTransaction<Option<GrantRecord>>;
696
1167
  infra: (json: string) => AssembledTransaction<InfraPins>;
697
1168
  renew: (json: string) => AssembledTransaction<null>;
1169
+ grants: (json: string) => AssembledTransaction<number[]>;
698
1170
  execute: (json: string) => AssembledTransaction<Result<any, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
699
1171
  document: (json: string) => AssembledTransaction<readonly [bigint, Option<Buffer<ArrayBufferLike>>]>;
1172
+ gc_grant: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
700
1173
  rcv_gate: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
701
1174
  revision: (json: string) => AssembledTransaction<bigint>;
1175
+ rule_set: (json: string) => AssembledTransaction<StoredRule[]>;
702
1176
  apply_doc: (json: string) => AssembledTransaction<Result<Buffer<ArrayBufferLike>, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
703
1177
  is_revoked: (json: string) => AssembledTransaction<boolean>;
704
1178
  applied_doc: (json: string) => AssembledTransaction<Option<Buffer<ArrayBufferLike>>>;
1179
+ apply_grant: (json: string) => AssembledTransaction<Result<Buffer<ArrayBufferLike>, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1180
+ grant_count: (json: string) => AssembledTransaction<number>;
705
1181
  capabilities: (json: string) => AssembledTransaction<AccountCapabilities>;
706
1182
  doc_compiler: (json: string) => AssembledTransaction<string>;
1183
+ remove_grant: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1184
+ rule_signers: (json: string) => AssembledTransaction<Signer[]>;
707
1185
  configuration: (json: string) => AssembledTransaction<AccountConfiguration>;
1186
+ grant_signers: (json: string) => AssembledTransaction<Option<Signer[]>>;
708
1187
  recovery_gate: (json: string) => AssembledTransaction<Option<FreezeGate>>;
709
1188
  cancel_upgrade: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
1189
+ grant_rule_set: (json: string) => AssembledTransaction<StoredRule[]>;
710
1190
  is_enrolled_id: (json: string) => AssembledTransaction<boolean>;
711
1191
  cancel_recovery: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
712
1192
  execute_upgrade: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
@@ -714,9 +1194,13 @@ export declare class Client extends ContractClient {
714
1194
  pending_upgrade: (json: string) => AssembledTransaction<Option<UpgradeRequest>>;
715
1195
  applied_doc_hash: (json: string) => AssembledTransaction<Option<Buffer<ArrayBufferLike>>>;
716
1196
  get_context_rule: (json: string) => AssembledTransaction<ContextRule>;
1197
+ grant_generation: (json: string) => AssembledTransaction<bigint>;
1198
+ grant_signer_ids: (json: string) => AssembledTransaction<Option<string[]>>;
717
1199
  schedule_upgrade: (json: string) => AssembledTransaction<Result<bigint, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
718
1200
  recovery_controller: (json: string) => AssembledTransaction<Option<string>>;
719
1201
  recovery_generation: (json: string) => AssembledTransaction<bigint>;
1202
+ grant_verifier_names: (json: string) => AssembledTransaction<Option<string[]>>;
1203
+ credential_generation: (json: string) => AssembledTransaction<Option<bigint>>;
720
1204
  get_context_rules_count: (json: string) => AssembledTransaction<number>;
721
1205
  next_upgrade_request_id: (json: string) => AssembledTransaction<bigint>;
722
1206
  };