@stellar-registry/perch-contracts 0.1.2 → 0.2.1

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