@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/README.md +26 -7
- package/dist/account.d.ts +840 -358
- package/dist/account.js +333 -71
- package/dist/adapter.d.ts +2 -525
- package/dist/adapter.js +1 -197
- package/dist/deployment.d.ts +26 -1
- package/dist/deployment.js +2 -1
- package/dist/deployments.js +68 -45
- package/dist/doc-compiler.d.ts +188 -132
- package/dist/doc-compiler.js +31 -20
- package/dist/factory.d.ts +3 -2
- package/dist/factory.js +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/legacy-account.d.ts +723 -0
- package/dist/legacy-account.js +181 -0
- package/dist/legacy-doc-compiler.d.ts +600 -0
- package/dist/legacy-doc-compiler.js +126 -0
- package/dist/pool.d.ts +1 -861
- package/dist/pool.js +2 -270
- package/dist/recovery.d.ts +76 -118
- package/dist/recovery.js +16 -19
- package/dist/webauthn-verifier.d.ts +1 -1
- package/dist/webauthn-verifier.js +1 -1
- package/package.json +10 -2
package/dist/pool.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** sha256 of the wasm these bindings were generated from. */
|
|
2
|
-
export declare const WASM_SHA256 = "
|
|
2
|
+
export declare const WASM_SHA256 = "6960dc976a75366829d2a1dfd90654c713b4cd1c12324bf352fb45e4b754a2a1";
|
|
3
3
|
import { Buffer } from "buffer";
|
|
4
4
|
import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, MethodOptions, Result } from "@stellar/stellar-sdk/contract";
|
|
5
5
|
import type { u32, u64, Option } from "@stellar/stellar-sdk/contract";
|
|
@@ -28,20 +28,6 @@ export interface TreeInfo {
|
|
|
28
28
|
size: u64;
|
|
29
29
|
tree_id: u32;
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Where an insertion landed (the `LeafInserted` event's payload).
|
|
33
|
-
* `(tree_id, index)` is the leaf's permanent position; `root` is the
|
|
34
|
-
* tree's root right after the insertion.
|
|
35
|
-
*/
|
|
36
|
-
export interface Insertion {
|
|
37
|
-
index: u64;
|
|
38
|
-
/**
|
|
39
|
-
* The stored leaf, `H(DOM_BIND, account, enrollment_id, inner)`.
|
|
40
|
-
*/
|
|
41
|
-
leaf: Buffer;
|
|
42
|
-
root: Buffer;
|
|
43
|
-
tree_id: u32;
|
|
44
|
-
}
|
|
45
31
|
/**
|
|
46
32
|
* Everything the pool can refuse.
|
|
47
33
|
*/
|
|
@@ -96,852 +82,6 @@ export interface LeafPosition {
|
|
|
96
82
|
*/
|
|
97
83
|
tree_id: u32;
|
|
98
84
|
}
|
|
99
|
-
/**
|
|
100
|
-
* The pool's storage keys (see the layout table in the module docs).
|
|
101
|
-
*/
|
|
102
|
-
export type PoolKey = {
|
|
103
|
-
tag: "CurrentTree";
|
|
104
|
-
values: void;
|
|
105
|
-
} | {
|
|
106
|
-
tag: "Tree";
|
|
107
|
-
values: readonly [u32];
|
|
108
|
-
} | {
|
|
109
|
-
tag: "Root";
|
|
110
|
-
values: readonly [u32, Buffer];
|
|
111
|
-
} | {
|
|
112
|
-
tag: "Leaf";
|
|
113
|
-
values: readonly [u32, u64];
|
|
114
|
-
} | {
|
|
115
|
-
tag: "Enrollment";
|
|
116
|
-
values: readonly [string, Buffer];
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* A tree's incremental-Merkle state.
|
|
120
|
-
*/
|
|
121
|
-
export interface TreeState {
|
|
122
|
-
/**
|
|
123
|
-
* `frontier[level]` is the most recent node at `level` that was a left
|
|
124
|
-
* child: the left sibling the next right child at that level hashes
|
|
125
|
-
* with. Entries are written before they are ever read.
|
|
126
|
-
*/
|
|
127
|
-
frontier: Array<Buffer>;
|
|
128
|
-
/**
|
|
129
|
-
* The root after the latest insertion.
|
|
130
|
-
*/
|
|
131
|
-
root: Buffer;
|
|
132
|
-
/**
|
|
133
|
-
* Leaves inserted so far; also the index the next insertion takes.
|
|
134
|
-
*/
|
|
135
|
-
size: u64;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* What a completion hands back to the account.
|
|
139
|
-
*/
|
|
140
|
-
export interface Completion {
|
|
141
|
-
/**
|
|
142
|
-
* The attempt that completed.
|
|
143
|
-
*/
|
|
144
|
-
attempt_id: u64;
|
|
145
|
-
/**
|
|
146
|
-
* The credentials that occupied the replaced signer slots **in the
|
|
147
|
-
* attempt's source document**, as derived at T1: the applied document
|
|
148
|
-
* for lost-key, the baseline for compromise. The account fingerprints
|
|
149
|
-
* them over canonical keys and revokes them together with every
|
|
150
|
-
* credential the completion removed from its current document. Without
|
|
151
|
-
* these, a baseline credential replaced by a compromise recovery, and
|
|
152
|
-
* already absent from the current document, would stay unrevoked and
|
|
153
|
-
* could be restored by a later recovery from the same baseline.
|
|
154
|
-
*/
|
|
155
|
-
replaced: Array<Credential>;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* What `rcv_sync` did, so the account knows which of its own effects to
|
|
159
|
-
* apply (spec §10).
|
|
160
|
-
*/
|
|
161
|
-
export type SyncOutcome = {
|
|
162
|
-
tag: "Unchanged";
|
|
163
|
-
values: void;
|
|
164
|
-
} | {
|
|
165
|
-
tag: "Enrolled";
|
|
166
|
-
values: void;
|
|
167
|
-
} | {
|
|
168
|
-
tag: "Reconfigured";
|
|
169
|
-
values: void;
|
|
170
|
-
} | {
|
|
171
|
-
tag: "Removed";
|
|
172
|
-
values: void;
|
|
173
|
-
} | {
|
|
174
|
-
tag: "Completed";
|
|
175
|
-
values: readonly [Completion];
|
|
176
|
-
};
|
|
177
|
-
/**
|
|
178
|
-
* Which phase of an account upgrade `rcv_upgrade` is checking (spec §12).
|
|
179
|
-
*/
|
|
180
|
-
export type UpgradeStep = {
|
|
181
|
-
tag: "Schedule";
|
|
182
|
-
values: readonly [UpgradeSubject, u32];
|
|
183
|
-
} | {
|
|
184
|
-
tag: "Execute";
|
|
185
|
-
values: readonly [u64];
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* Everything a recovery controller can refuse. Codes are sequential from 1
|
|
189
|
-
* in declaration order and are wire format: append new variants at the
|
|
190
|
-
* end, never reorder.
|
|
191
|
-
*/
|
|
192
|
-
export declare const RecoveryError: {
|
|
193
|
-
/**
|
|
194
|
-
* No configuration is enrolled for this account at this controller.
|
|
195
|
-
*/
|
|
196
|
-
1: {
|
|
197
|
-
message: string;
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* An attempt is authorized and live: begin, policy changes, and upgrades are refused until it completes, is cancelled, or expires.
|
|
201
|
-
*/
|
|
202
|
-
2: {
|
|
203
|
-
message: string;
|
|
204
|
-
};
|
|
205
|
-
/**
|
|
206
|
-
* No attempt with this id exists for the account.
|
|
207
|
-
*/
|
|
208
|
-
3: {
|
|
209
|
-
message: string;
|
|
210
|
-
};
|
|
211
|
-
/**
|
|
212
|
-
* The attempt is terminal, expired, from an older epoch, or invalidated by a sibling's authorization.
|
|
213
|
-
*/
|
|
214
|
-
4: {
|
|
215
|
-
message: string;
|
|
216
|
-
};
|
|
217
|
-
/**
|
|
218
|
-
* Initiation evidence for an attempt that is no longer collecting.
|
|
219
|
-
*/
|
|
220
|
-
5: {
|
|
221
|
-
message: string;
|
|
222
|
-
};
|
|
223
|
-
/**
|
|
224
|
-
* Completion before `executable_after`.
|
|
225
|
-
*/
|
|
226
|
-
6: {
|
|
227
|
-
message: string;
|
|
228
|
-
};
|
|
229
|
-
/**
|
|
230
|
-
* The completion context, or the compiled document hash, does not match the authorized attempt's target.
|
|
231
|
-
*/
|
|
232
|
-
7: {
|
|
233
|
-
message: string;
|
|
234
|
-
};
|
|
235
|
-
/**
|
|
236
|
-
* The address is not an enrolled guardian.
|
|
237
|
-
*/
|
|
238
|
-
8: {
|
|
239
|
-
message: string;
|
|
240
|
-
};
|
|
241
|
-
/**
|
|
242
|
-
* This guardian or factor already counted for this statement.
|
|
243
|
-
*/
|
|
244
|
-
9: {
|
|
245
|
-
message: string;
|
|
246
|
-
};
|
|
247
|
-
/**
|
|
248
|
-
* The enrolled mode has no guardian factor.
|
|
249
|
-
*/
|
|
250
|
-
10: {
|
|
251
|
-
message: string;
|
|
252
|
-
};
|
|
253
|
-
/**
|
|
254
|
-
* The enrolled mode has no ZK factor.
|
|
255
|
-
*/
|
|
256
|
-
11: {
|
|
257
|
-
message: string;
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* The adapter refused the proof (its `ZkAdapterError` says why).
|
|
261
|
-
*/
|
|
262
|
-
12: {
|
|
263
|
-
message: string;
|
|
264
|
-
};
|
|
265
|
-
/**
|
|
266
|
-
* The proof's nullifier is spent.
|
|
267
|
-
*/
|
|
268
|
-
13: {
|
|
269
|
-
message: string;
|
|
270
|
-
};
|
|
271
|
-
/**
|
|
272
|
-
* The statement's freshness bound has passed or reaches too far.
|
|
273
|
-
*/
|
|
274
|
-
14: {
|
|
275
|
-
message: string;
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* The statement cannot be encoded (a non-contract account or controller).
|
|
279
|
-
*/
|
|
280
|
-
15: {
|
|
281
|
-
message: string;
|
|
282
|
-
};
|
|
283
|
-
/**
|
|
284
|
-
* Recorded approvals do not satisfy the enrolled condition for this reconfiguration or upgrade.
|
|
285
|
-
*/
|
|
286
|
-
16: {
|
|
287
|
-
message: string;
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* The account's `max-cancels` is used up.
|
|
291
|
-
*/
|
|
292
|
-
17: {
|
|
293
|
-
message: string;
|
|
294
|
-
};
|
|
295
|
-
/**
|
|
296
|
-
* Owner cancellation is only available under `Loss`.
|
|
297
|
-
*/
|
|
298
|
-
18: {
|
|
299
|
-
message: string;
|
|
300
|
-
};
|
|
301
|
-
/**
|
|
302
|
-
* The replacement set breaks a §7.3 rule, or derivation refused it.
|
|
303
|
-
*/
|
|
304
|
-
19: {
|
|
305
|
-
message: string;
|
|
306
|
-
};
|
|
307
|
-
/**
|
|
308
|
-
* The target or a replacement contains a revoked credential.
|
|
309
|
-
*/
|
|
310
|
-
20: {
|
|
311
|
-
message: string;
|
|
312
|
-
};
|
|
313
|
-
/**
|
|
314
|
-
* The ZK enrollment id was enrolled for this account before (the controller checks the account's `is_enrolled_id` at T1; the pure `derive_target` cannot see the account's history).
|
|
315
|
-
*/
|
|
316
|
-
21: {
|
|
317
|
-
message: string;
|
|
318
|
-
};
|
|
319
|
-
/**
|
|
320
|
-
* Compromise recovery with no baseline enrolled.
|
|
321
|
-
*/
|
|
322
|
-
22: {
|
|
323
|
-
message: string;
|
|
324
|
-
};
|
|
325
|
-
/**
|
|
326
|
-
* Compromise recovery before the baseline's content was published.
|
|
327
|
-
*/
|
|
328
|
-
23: {
|
|
329
|
-
message: string;
|
|
330
|
-
};
|
|
331
|
-
/**
|
|
332
|
-
* The published document does not hash to the enrolled baseline.
|
|
333
|
-
*/
|
|
334
|
-
24: {
|
|
335
|
-
message: string;
|
|
336
|
-
};
|
|
337
|
-
/**
|
|
338
|
-
* The adapter's circuit id or tree depth does not match the enrolled factor and pool.
|
|
339
|
-
*/
|
|
340
|
-
25: {
|
|
341
|
-
message: string;
|
|
342
|
-
};
|
|
343
|
-
/**
|
|
344
|
-
* The ZK factor changed without a new enrollment id.
|
|
345
|
-
*/
|
|
346
|
-
26: {
|
|
347
|
-
message: string;
|
|
348
|
-
};
|
|
349
|
-
/**
|
|
350
|
-
* The configuration is malformed (for example, the account is one of its own guardians, or the quorum is out of range).
|
|
351
|
-
*/
|
|
352
|
-
27: {
|
|
353
|
-
message: string;
|
|
354
|
-
};
|
|
355
|
-
/**
|
|
356
|
-
* An upgrade request recorded under an older epoch.
|
|
357
|
-
*/
|
|
358
|
-
28: {
|
|
359
|
-
message: string;
|
|
360
|
-
};
|
|
361
|
-
/**
|
|
362
|
-
* A ledger-sequence computation overflowed `u32`.
|
|
363
|
-
*/
|
|
364
|
-
29: {
|
|
365
|
-
message: string;
|
|
366
|
-
};
|
|
367
|
-
/**
|
|
368
|
-
* The policy was attached to a context rule of the wrong shape.
|
|
369
|
-
*/
|
|
370
|
-
30: {
|
|
371
|
-
message: string;
|
|
372
|
-
};
|
|
373
|
-
/**
|
|
374
|
-
* A credential the replacement set replaces still appears in the target (a swap or a no-op replacement, spec §7.3 rule 8).
|
|
375
|
-
*/
|
|
376
|
-
31: {
|
|
377
|
-
message: string;
|
|
378
|
-
};
|
|
379
|
-
};
|
|
380
|
-
/**
|
|
381
|
-
* A signer credential, shaped like OZ `stellar_accounts::smart_account::Signer`.
|
|
382
|
-
*/
|
|
383
|
-
export type Credential = {
|
|
384
|
-
tag: "Delegated";
|
|
385
|
-
values: readonly [string];
|
|
386
|
-
} | {
|
|
387
|
-
tag: "External";
|
|
388
|
-
values: readonly [string, Buffer];
|
|
389
|
-
};
|
|
390
|
-
/**
|
|
391
|
-
* One designated signer slot and the credential that replaces whatever
|
|
392
|
-
* that slot holds in the source document.
|
|
393
|
-
*/
|
|
394
|
-
export interface Replacement {
|
|
395
|
-
/**
|
|
396
|
-
* The credential the target document gives that signer id.
|
|
397
|
-
*/
|
|
398
|
-
credential: Credential;
|
|
399
|
-
/**
|
|
400
|
-
* A document signer id listed in the enrolled `recovery.replaceable`.
|
|
401
|
-
*/
|
|
402
|
-
signer_id: string;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* A ZK enrollment a recovery completion installs.
|
|
406
|
-
*
|
|
407
|
-
* The commitment is bound here, not only the id: completion runs under the
|
|
408
|
-
* zero-signer recovery rule, so nothing signs its arguments, and a
|
|
409
|
-
* commitment supplied only at completion could be swapped by whoever
|
|
410
|
-
* submits the completing transaction first — handing them the account's
|
|
411
|
-
* next ZK factor.
|
|
412
|
-
*/
|
|
413
|
-
export interface ZkEnrollment {
|
|
414
|
-
/**
|
|
415
|
-
* The new leaf's inner commitment, `Poseidon2(DOM_LEAF, secret)`.
|
|
416
|
-
* Derivation writes `id` and `commitment` into the target document's
|
|
417
|
-
* recovery section, so the target hash binds them, and the completing
|
|
418
|
-
* `apply_doc` inserts the leaf from the compiled target, never from a
|
|
419
|
-
* call argument.
|
|
420
|
-
*/
|
|
421
|
-
commitment: Buffer;
|
|
422
|
-
/**
|
|
423
|
-
* The new enrollment id. Must never have been enrolled for this
|
|
424
|
-
* account before.
|
|
425
|
-
*/
|
|
426
|
-
id: Buffer;
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Everything a `LostKey`/`Compromise` attempt changes about the source
|
|
430
|
-
* document. See `docs/recovery/spec.md` §7.
|
|
431
|
-
*/
|
|
432
|
-
export interface ReplacementSet {
|
|
433
|
-
/**
|
|
434
|
-
* Signer replacements in strictly ascending `signer_id` byte order
|
|
435
|
-
* (sorted, no duplicates) — the one canonical order.
|
|
436
|
-
*/
|
|
437
|
-
signers: Array<Replacement>;
|
|
438
|
-
/**
|
|
439
|
-
* The fresh ZK enrollment the completion installs, required exactly
|
|
440
|
-
* when the enrolled mode has a ZK factor (a ZK-evidenced completion
|
|
441
|
-
* consumes the enrolled credential, so it must install a fresh one).
|
|
442
|
-
* Empty or one entry — a `Vec` because `#[contracttype]` cannot derive
|
|
443
|
-
* `Option<CustomStruct>`.
|
|
444
|
-
*/
|
|
445
|
-
zk_enrollment: Array<ZkEnrollment>;
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Which enrolled ZK factor a statement is checked against. The controller
|
|
449
|
-
* builds this from its stored configuration — never from caller input.
|
|
450
|
-
*/
|
|
451
|
-
export interface ZkBinding {
|
|
452
|
-
/**
|
|
453
|
-
* The circuit identity the enrolling document named. The adapter
|
|
454
|
-
* refuses any binding whose `circuit_id` is not its own.
|
|
455
|
-
*/
|
|
456
|
-
circuit_id: Buffer;
|
|
457
|
-
/**
|
|
458
|
-
* The enrolled credential's id, bound into its leaf and its nullifier.
|
|
459
|
-
* A leaf enrolled under any other id — including the account's own
|
|
460
|
-
* earlier enrollments — cannot satisfy a proof for this binding.
|
|
461
|
-
*/
|
|
462
|
-
enrollment_id: Buffer;
|
|
463
|
-
/**
|
|
464
|
-
* The enrolled membership pool. Roots are accepted only from this pool.
|
|
465
|
-
*/
|
|
466
|
-
pool: string;
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* One ZK proof as submitted.
|
|
470
|
-
*/
|
|
471
|
-
export interface ZkEvidence {
|
|
472
|
-
/**
|
|
473
|
-
* The credential's nullifier (the circuit's second public input).
|
|
474
|
-
*/
|
|
475
|
-
nullifier: Buffer;
|
|
476
|
-
/**
|
|
477
|
-
* The serialized proof.
|
|
478
|
-
*/
|
|
479
|
-
proof: Buffer;
|
|
480
|
-
/**
|
|
481
|
-
* The root the proof was generated against; must be acceptable to the
|
|
482
|
-
* enrolled pool for `tree_id`.
|
|
483
|
-
*/
|
|
484
|
-
root: Buffer;
|
|
485
|
-
/**
|
|
486
|
-
* The pool tree the proof's Merkle path is in.
|
|
487
|
-
*/
|
|
488
|
-
tree_id: u32;
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Everything [`ZkAdapterInterface::verify`] can refuse. Each is a refusal
|
|
492
|
-
* of this evidence only; none is a statement about the account.
|
|
493
|
-
*/
|
|
494
|
-
export declare const ZkAdapterError: {
|
|
495
|
-
/**
|
|
496
|
-
* The binding names a circuit this adapter does not verify.
|
|
497
|
-
*/
|
|
498
|
-
1: {
|
|
499
|
-
message: string;
|
|
500
|
-
};
|
|
501
|
-
/**
|
|
502
|
-
* The statement cannot be projected (its account or controller is not a contract address).
|
|
503
|
-
*/
|
|
504
|
-
2: {
|
|
505
|
-
message: string;
|
|
506
|
-
};
|
|
507
|
-
/**
|
|
508
|
-
* The root or nullifier is not a canonical field element.
|
|
509
|
-
*/
|
|
510
|
-
3: {
|
|
511
|
-
message: string;
|
|
512
|
-
};
|
|
513
|
-
/**
|
|
514
|
-
* The enrolled pool does not accept `(tree_id, root)`.
|
|
515
|
-
*/
|
|
516
|
-
4: {
|
|
517
|
-
message: string;
|
|
518
|
-
};
|
|
519
|
-
/**
|
|
520
|
-
* The enrolled pool could not be called.
|
|
521
|
-
*/
|
|
522
|
-
5: {
|
|
523
|
-
message: string;
|
|
524
|
-
};
|
|
525
|
-
/**
|
|
526
|
-
* The proof is not the length/shape the circuit produces.
|
|
527
|
-
*/
|
|
528
|
-
6: {
|
|
529
|
-
message: string;
|
|
530
|
-
};
|
|
531
|
-
/**
|
|
532
|
-
* The verifier rejected the proof.
|
|
533
|
-
*/
|
|
534
|
-
7: {
|
|
535
|
-
message: string;
|
|
536
|
-
};
|
|
537
|
-
/**
|
|
538
|
-
* The verifier could not be called or failed to parse its own key.
|
|
539
|
-
*/
|
|
540
|
-
8: {
|
|
541
|
-
message: string;
|
|
542
|
-
};
|
|
543
|
-
};
|
|
544
|
-
/**
|
|
545
|
-
* A backend verifier's refusals. Same names, order, and codes (1, 2, 3)
|
|
546
|
-
* as Nido's constructorless `nido-recovery-verifier`, so either can sit
|
|
547
|
-
* behind an adapter unchanged.
|
|
548
|
-
*/
|
|
549
|
-
export declare const ProofVerifierError: {
|
|
550
|
-
/**
|
|
551
|
-
* The verification key could not be parsed.
|
|
552
|
-
*/
|
|
553
|
-
1: {
|
|
554
|
-
message: string;
|
|
555
|
-
};
|
|
556
|
-
/**
|
|
557
|
-
* The proof could not be parsed (for example, it has the wrong length).
|
|
558
|
-
*/
|
|
559
|
-
2: {
|
|
560
|
-
message: string;
|
|
561
|
-
};
|
|
562
|
-
/**
|
|
563
|
-
* The proof does not verify against the public inputs.
|
|
564
|
-
*/
|
|
565
|
-
3: {
|
|
566
|
-
message: string;
|
|
567
|
-
};
|
|
568
|
-
};
|
|
569
|
-
/**
|
|
570
|
-
* Who may change the recovery configuration, and whether an authorized
|
|
571
|
-
* attempt freezes ordinary activity (spec §2, §9).
|
|
572
|
-
*/
|
|
573
|
-
export type RecoveryProfile = {
|
|
574
|
-
tag: "Loss";
|
|
575
|
-
values: void;
|
|
576
|
-
} | {
|
|
577
|
-
tag: "Protected";
|
|
578
|
-
values: void;
|
|
579
|
-
};
|
|
580
|
-
/**
|
|
581
|
-
* The ZK factor (spec §3.1, §3.4).
|
|
582
|
-
*/
|
|
583
|
-
export interface CompiledZkFactor {
|
|
584
|
-
/**
|
|
585
|
-
* The constructorless ZK adapter the controller calls.
|
|
586
|
-
*/
|
|
587
|
-
adapter: string;
|
|
588
|
-
/**
|
|
589
|
-
* `sha256` of the adapter's verification key; must equal the adapter's
|
|
590
|
-
* `circuit_id()`.
|
|
591
|
-
*/
|
|
592
|
-
circuit_id: Buffer;
|
|
593
|
-
/**
|
|
594
|
-
* The current credential's inner commitment, `Poseidon2(DOM_LEAF,
|
|
595
|
-
* secret)`, from which the account inserts the leaf.
|
|
596
|
-
*/
|
|
597
|
-
commitment: Buffer;
|
|
598
|
-
/**
|
|
599
|
-
* The current credential's id, bound into its leaf and nullifier.
|
|
600
|
-
*/
|
|
601
|
-
enrollment_id: Buffer;
|
|
602
|
-
/**
|
|
603
|
-
* The membership pool roots are accepted from.
|
|
604
|
-
*/
|
|
605
|
-
pool: string;
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* The guardian factor.
|
|
609
|
-
*/
|
|
610
|
-
export interface CompiledGuardianSet {
|
|
611
|
-
/**
|
|
612
|
-
* Guardian addresses (`G...` or `C...`), never the account itself.
|
|
613
|
-
*/
|
|
614
|
-
guardians: Array<string>;
|
|
615
|
-
/**
|
|
616
|
-
* `1 <= quorum <= guardians.len()`.
|
|
617
|
-
*/
|
|
618
|
-
quorum: u32;
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Which factors a statement needs.
|
|
622
|
-
*/
|
|
623
|
-
export type CompiledRecoveryMode = {
|
|
624
|
-
tag: "GuardianOnly";
|
|
625
|
-
values: readonly [CompiledGuardianSet];
|
|
626
|
-
} | {
|
|
627
|
-
tag: "ZkOnly";
|
|
628
|
-
values: readonly [CompiledZkFactor];
|
|
629
|
-
} | {
|
|
630
|
-
tag: "Combined";
|
|
631
|
-
values: readonly [CompiledGuardianSet, CompiledZkFactor];
|
|
632
|
-
};
|
|
633
|
-
/**
|
|
634
|
-
* A compiled `recovery` member.
|
|
635
|
-
*/
|
|
636
|
-
export interface CompiledRecoveryConfig {
|
|
637
|
-
/**
|
|
638
|
-
* The enrolled baseline's canonical document hash, if compromise
|
|
639
|
-
* recovery is enrolled.
|
|
640
|
-
*/
|
|
641
|
-
baseline: Option<Buffer>;
|
|
642
|
-
/**
|
|
643
|
-
* [`config_hash`] of the canonical JSON of the recovery member, computed
|
|
644
|
-
* by the doc compiler (spec §3.2). Configuration
|
|
645
|
-
* identity: two compiled configurations with the same `config_hash` are
|
|
646
|
-
* the same configuration.
|
|
647
|
-
*/
|
|
648
|
-
config_hash: Buffer;
|
|
649
|
-
/**
|
|
650
|
-
* The adopted controller instance.
|
|
651
|
-
*/
|
|
652
|
-
controller: string;
|
|
653
|
-
/**
|
|
654
|
-
* Ledgers from an attempt's authorization until it can complete.
|
|
655
|
-
*/
|
|
656
|
-
delay_ledgers: u32;
|
|
657
|
-
/**
|
|
658
|
-
* The evidence window of a collecting attempt and the completion
|
|
659
|
-
* window of an authorized one, in ledgers.
|
|
660
|
-
*/
|
|
661
|
-
expiry_ledgers: u32;
|
|
662
|
-
/**
|
|
663
|
-
* Lifetime cap on evidence-based cancellations of authorized attempts.
|
|
664
|
-
*/
|
|
665
|
-
max_cancels: u32;
|
|
666
|
-
/**
|
|
667
|
-
* The factors evidence must satisfy.
|
|
668
|
-
*/
|
|
669
|
-
mode: CompiledRecoveryMode;
|
|
670
|
-
/**
|
|
671
|
-
* Who may change the configuration, and whether an authorized attempt
|
|
672
|
-
* freezes the account.
|
|
673
|
-
*/
|
|
674
|
-
profile: RecoveryProfile;
|
|
675
|
-
/**
|
|
676
|
-
* Signer ids (not credential fingerprints) a recovery may replace, so
|
|
677
|
-
* rotating a key does not change the configuration (#92).
|
|
678
|
-
*/
|
|
679
|
-
replaceable: Array<string>;
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* One pending account upgrade (spec §12).
|
|
683
|
-
*
|
|
684
|
-
* Staleness is judged against the account's own **recovery generation**, a
|
|
685
|
-
* `u64` the account keeps in its own storage. It starts at 0 and is never
|
|
686
|
-
* reset. It advances on every `rcv_sync` outcome other than `Unchanged`
|
|
687
|
-
* (`controller::SyncOutcome::bumps_generation`) and on every executed
|
|
688
|
-
* upgrade.
|
|
689
|
-
*
|
|
690
|
-
* The controller's epoch cannot play this role. It belongs to one
|
|
691
|
-
* controller and does not exist while the account is unenrolled, so a
|
|
692
|
-
* request scheduled unenrolled would survive enrolling recovery and
|
|
693
|
-
* removing it again: the final state has no controller, just as at
|
|
694
|
-
* scheduling.
|
|
695
|
-
*/
|
|
696
|
-
export interface UpgradeRequest {
|
|
697
|
-
/**
|
|
698
|
-
* The adopted controller's epoch when scheduled, if a controller was
|
|
699
|
-
* adopted. Passed back as `UpgradeStep::Execute` so the controller can
|
|
700
|
-
* check it too.
|
|
701
|
-
*/
|
|
702
|
-
controller_epoch: Option<u64>;
|
|
703
|
-
/**
|
|
704
|
-
* The first ledger at which the request may execute.
|
|
705
|
-
*/
|
|
706
|
-
executable_at: u32;
|
|
707
|
-
/**
|
|
708
|
-
* The account's recovery generation when the request was scheduled.
|
|
709
|
-
*/
|
|
710
|
-
generation: u64;
|
|
711
|
-
/**
|
|
712
|
-
* Per-account, never reused.
|
|
713
|
-
*/
|
|
714
|
-
request_id: u64;
|
|
715
|
-
/**
|
|
716
|
-
* The exact Wasm the account will run.
|
|
717
|
-
*/
|
|
718
|
-
wasm_hash: Buffer;
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* What a `Reconfigure` statement changes the enrolled configuration to.
|
|
722
|
-
*/
|
|
723
|
-
export type ConfigChange = {
|
|
724
|
-
tag: "Remove";
|
|
725
|
-
values: void;
|
|
726
|
-
} | {
|
|
727
|
-
tag: "Set";
|
|
728
|
-
values: readonly [Buffer];
|
|
729
|
-
};
|
|
730
|
-
/**
|
|
731
|
-
* The subject of a `Cancel` statement.
|
|
732
|
-
*/
|
|
733
|
-
export interface CancelSubject {
|
|
734
|
-
/**
|
|
735
|
-
* The attempt being cancelled.
|
|
736
|
-
*/
|
|
737
|
-
attempt_id: u64;
|
|
738
|
-
/**
|
|
739
|
-
* That attempt's own initiation statement digest, so cancellation
|
|
740
|
-
* evidence names exactly one proposal, not just an id.
|
|
741
|
-
*/
|
|
742
|
-
attempt_statement: Buffer;
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* The enrolled configuration a statement is evaluated against.
|
|
746
|
-
*/
|
|
747
|
-
export interface ConfigBinding {
|
|
748
|
-
/**
|
|
749
|
-
* `sha256("perch/recovery/config" || canonical JSON of the enrolled
|
|
750
|
-
* document's recovery member)`, as [`crate::config::config_hash`]
|
|
751
|
-
* computes it (`docs/recovery/spec.md` §3.2). Binds the whole
|
|
752
|
-
* configuration: profile, mode, guardians, quorum, ZK adapter, circuit
|
|
753
|
-
* id, pool, enrollment id and commitment, controller, baseline,
|
|
754
|
-
* replaceable signer ids, and timing.
|
|
755
|
-
*/
|
|
756
|
-
config_hash: Buffer;
|
|
757
|
-
/**
|
|
758
|
-
* The controller's per-account configuration epoch. It increments on
|
|
759
|
-
* every enrollment, reconfiguration, removal, completed recovery, and
|
|
760
|
-
* executed account upgrade, so evidence produced under one epoch is
|
|
761
|
-
* dead under every later one.
|
|
762
|
-
*/
|
|
763
|
-
epoch: u64;
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
766
|
-
* The subject of a `LostKey` or `Compromise` attempt.
|
|
767
|
-
*/
|
|
768
|
-
export interface AttemptSubject {
|
|
769
|
-
/**
|
|
770
|
-
* The controller-assigned, per-account, never-reused attempt id.
|
|
771
|
-
*/
|
|
772
|
-
attempt_id: u64;
|
|
773
|
-
/**
|
|
774
|
-
* [`crate::credential::ReplacementSet::hash`] of the declared
|
|
775
|
-
* replacements.
|
|
776
|
-
*/
|
|
777
|
-
replacements_hash: Buffer;
|
|
778
|
-
/**
|
|
779
|
-
* `LostKey`: the canonical hash of the account's applied document when
|
|
780
|
-
* the attempt began (the agreed snapshot). `Compromise`: the enrolled
|
|
781
|
-
* baseline's canonical hash.
|
|
782
|
-
*/
|
|
783
|
-
source_doc_hash: Buffer;
|
|
784
|
-
/**
|
|
785
|
-
* The canonical hash of the target document, derived on-chain from
|
|
786
|
-
* the source and the replacement set — never caller-chosen.
|
|
787
|
-
*/
|
|
788
|
-
target_doc_hash: Buffer;
|
|
789
|
-
}
|
|
790
|
-
/**
|
|
791
|
-
* The action domain a statement authorizes. Evidence for one action never
|
|
792
|
-
* satisfies another: the action code is the encoding's 26th byte and selects
|
|
793
|
-
* the subject layout, so two statements that differ only in action have
|
|
794
|
-
* different digests (and different encoded lengths for most pairs).
|
|
795
|
-
*
|
|
796
|
-
* The numeric codes are part of the wire format.
|
|
797
|
-
*/
|
|
798
|
-
export declare enum RecoveryAction {
|
|
799
|
-
LostKey = 1,
|
|
800
|
-
Compromise = 2,
|
|
801
|
-
Cancel = 3,
|
|
802
|
-
Reconfigure = 4,
|
|
803
|
-
Upgrade = 5
|
|
804
|
-
}
|
|
805
|
-
/**
|
|
806
|
-
* Everything encoding a statement or its parts can refuse.
|
|
807
|
-
*/
|
|
808
|
-
export declare const StatementError: {
|
|
809
|
-
/**
|
|
810
|
-
* `account` is not a contract (`C...`) address.
|
|
811
|
-
*/
|
|
812
|
-
1: {
|
|
813
|
-
message: string;
|
|
814
|
-
};
|
|
815
|
-
/**
|
|
816
|
-
* `controller` is not a contract (`C...`) address.
|
|
817
|
-
*/
|
|
818
|
-
2: {
|
|
819
|
-
message: string;
|
|
820
|
-
};
|
|
821
|
-
/**
|
|
822
|
-
* A credential names an address shape the recovery stack does not accept (muxed, claimable-balance, liquidity-pool, ...).
|
|
823
|
-
*/
|
|
824
|
-
3: {
|
|
825
|
-
message: string;
|
|
826
|
-
};
|
|
827
|
-
/**
|
|
828
|
-
* A replacement set's signer ids are not strictly ascending (sorted, no duplicates), so it has no single canonical encoding.
|
|
829
|
-
*/
|
|
830
|
-
4: {
|
|
831
|
-
message: string;
|
|
832
|
-
};
|
|
833
|
-
/**
|
|
834
|
-
* A replacement set replaces nothing.
|
|
835
|
-
*/
|
|
836
|
-
5: {
|
|
837
|
-
message: string;
|
|
838
|
-
};
|
|
839
|
-
/**
|
|
840
|
-
* The current ledger is past the statement's `valid_until_ledger`.
|
|
841
|
-
*/
|
|
842
|
-
6: {
|
|
843
|
-
message: string;
|
|
844
|
-
};
|
|
845
|
-
/**
|
|
846
|
-
* A provider-chosen `valid_until_ledger` reaches further past the current ledger than the enrolled `expiry_ledgers` allows.
|
|
847
|
-
*/
|
|
848
|
-
7: {
|
|
849
|
-
message: string;
|
|
850
|
-
};
|
|
851
|
-
};
|
|
852
|
-
/**
|
|
853
|
-
* The subject of an `Upgrade` statement.
|
|
854
|
-
*/
|
|
855
|
-
export interface UpgradeSubject {
|
|
856
|
-
/**
|
|
857
|
-
* The account's per-account, never-reused upgrade request id.
|
|
858
|
-
*/
|
|
859
|
-
request_id: u64;
|
|
860
|
-
/**
|
|
861
|
-
* The exact Wasm hash the account would run after the upgrade.
|
|
862
|
-
*/
|
|
863
|
-
wasm_hash: Buffer;
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* Timing terms, all in ledger-sequence units.
|
|
867
|
-
*/
|
|
868
|
-
export interface StatementTiming {
|
|
869
|
-
/**
|
|
870
|
-
* The enrolled `delay-ledgers`: ledgers between an attempt becoming
|
|
871
|
-
* authorized and becoming completable.
|
|
872
|
-
*/
|
|
873
|
-
delay_ledgers: u32;
|
|
874
|
-
/**
|
|
875
|
-
* The enrolled `expiry-ledgers`: the evidence window for a collecting
|
|
876
|
-
* attempt, the completion window for an authorized one, and the upper
|
|
877
|
-
* bound on how far ahead a provider-chosen `valid_until_ledger` may
|
|
878
|
-
* reach.
|
|
879
|
-
*/
|
|
880
|
-
expiry_ledgers: u32;
|
|
881
|
-
/**
|
|
882
|
-
* The last ledger sequence (inclusive) at which this evidence may be
|
|
883
|
-
* accepted. The controller fixes it for attempt-bound actions:
|
|
884
|
-
* `LostKey`/`Compromise` use the attempt's evidence deadline, and
|
|
885
|
-
* `Cancel` the last ledger the attempt could possibly be live, so
|
|
886
|
-
* approvals collected over several transactions all sign one
|
|
887
|
-
* statement. For `Reconfigure`/`Upgrade` the evidence provider chooses
|
|
888
|
-
* it, within `expiry_ledgers` of submission.
|
|
889
|
-
*/
|
|
890
|
-
valid_until_ledger: u32;
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* The action-specific part of a statement. The variant determines
|
|
894
|
-
* [`RecoveryStatement::action`]; there is no separate action field that
|
|
895
|
-
* could disagree with it.
|
|
896
|
-
*/
|
|
897
|
-
export type StatementSubject = {
|
|
898
|
-
tag: "LostKey";
|
|
899
|
-
values: readonly [AttemptSubject];
|
|
900
|
-
} | {
|
|
901
|
-
tag: "Compromise";
|
|
902
|
-
values: readonly [AttemptSubject];
|
|
903
|
-
} | {
|
|
904
|
-
tag: "Cancel";
|
|
905
|
-
values: readonly [CancelSubject];
|
|
906
|
-
} | {
|
|
907
|
-
tag: "Reconfigure";
|
|
908
|
-
values: readonly [ConfigChange];
|
|
909
|
-
} | {
|
|
910
|
-
tag: "Upgrade";
|
|
911
|
-
values: readonly [UpgradeSubject];
|
|
912
|
-
};
|
|
913
|
-
/**
|
|
914
|
-
* The one recovery statement. See the module docs.
|
|
915
|
-
*/
|
|
916
|
-
export interface RecoveryStatement {
|
|
917
|
-
/**
|
|
918
|
-
* The recovering account. Must be a contract address.
|
|
919
|
-
*/
|
|
920
|
-
account: string;
|
|
921
|
-
/**
|
|
922
|
-
* The enrolled configuration and epoch the evidence is for.
|
|
923
|
-
*/
|
|
924
|
-
config: ConfigBinding;
|
|
925
|
-
/**
|
|
926
|
-
* The controller instance evaluating the evidence (for `Reconfigure`,
|
|
927
|
-
* the currently adopted one, even when the change adopts another).
|
|
928
|
-
* Must be a contract address.
|
|
929
|
-
*/
|
|
930
|
-
controller: string;
|
|
931
|
-
/**
|
|
932
|
-
* The network id (`sha256` of the network passphrase), as
|
|
933
|
-
* `Env::ledger().network_id()` returns it.
|
|
934
|
-
*/
|
|
935
|
-
network_id: Buffer;
|
|
936
|
-
/**
|
|
937
|
-
* What the evidence approves.
|
|
938
|
-
*/
|
|
939
|
-
subject: StatementSubject;
|
|
940
|
-
/**
|
|
941
|
-
* The enrolled timing terms and the evidence's freshness bound.
|
|
942
|
-
*/
|
|
943
|
-
timing: StatementTiming;
|
|
944
|
-
}
|
|
945
85
|
export interface Client {
|
|
946
86
|
/**
|
|
947
87
|
* Construct and simulate a tree 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.
|