@stellar-registry/perch-contracts 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -7
- package/dist/account.d.ts +842 -358
- package/dist/account.js +339 -73
- package/dist/deployment.d.ts +26 -1
- package/dist/deployment.js +2 -1
- package/dist/doc-compiler.d.ts +190 -132
- package/dist/doc-compiler.js +37 -22
- 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/package.json +10 -2
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
/** sha256 of the wasm these bindings were generated from. */
|
|
2
|
+
export declare const WASM_SHA256 = "2730a7d39d619579bb7873818900fa5f9150d69d49fa1ee3b4a38f61ba768a16";
|
|
3
|
+
import { Buffer } from "buffer";
|
|
4
|
+
import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, MethodOptions, Result } from "@stellar/stellar-sdk/contract";
|
|
5
|
+
import type { u32, i128, Option } from "@stellar/stellar-sdk/contract";
|
|
6
|
+
export * from "@stellar/stellar-sdk";
|
|
7
|
+
export * as contract from "@stellar/stellar-sdk/contract";
|
|
8
|
+
export * as rpc from "@stellar/stellar-sdk/rpc";
|
|
9
|
+
/**
|
|
10
|
+
* The document caps a compiler enforces, as [`PerchDocCompiler::limits`]
|
|
11
|
+
* returns them. Versioned: a later budget (a complexity-weighted one, say)
|
|
12
|
+
* is a new variant, which a consumer that does not know it refuses rather
|
|
13
|
+
* than misreads.
|
|
14
|
+
*/
|
|
15
|
+
export type DocLimits = {
|
|
16
|
+
tag: "V1";
|
|
17
|
+
values: readonly [FlatDocLimits];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Where a compiled rule applies. `SelfAdmin` is account-agnostic: the
|
|
21
|
+
* applying account resolves it to its own address.
|
|
22
|
+
*/
|
|
23
|
+
export type RuleScope = {
|
|
24
|
+
tag: "SelfAdmin";
|
|
25
|
+
values: void;
|
|
26
|
+
} | {
|
|
27
|
+
tag: "Contract";
|
|
28
|
+
values: readonly [string];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* A cumulative spend cap lowered to OZ `spending_limit`'s install params
|
|
32
|
+
* (`SpendingLimitAccountParams`). The tracked token is the rule's scope
|
|
33
|
+
* contract, so it is not carried here.
|
|
34
|
+
*/
|
|
35
|
+
export interface CompiledCap {
|
|
36
|
+
/**
|
|
37
|
+
* Rolling-window length in ledgers.
|
|
38
|
+
*/
|
|
39
|
+
period_ledgers: u32;
|
|
40
|
+
/**
|
|
41
|
+
* Cumulative amount ceiling over the rolling window.
|
|
42
|
+
*/
|
|
43
|
+
spending_limit: i128;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A compiled document: its canonical identity and the rules it becomes.
|
|
47
|
+
*/
|
|
48
|
+
export interface CompiledDoc {
|
|
49
|
+
/**
|
|
50
|
+
* The canonical bytes `doc_hash` is the hash of. The account stores
|
|
51
|
+
* them so anyone, including the recovery controller, can read back the
|
|
52
|
+
* full applied document.
|
|
53
|
+
*/
|
|
54
|
+
canonical: Buffer;
|
|
55
|
+
/**
|
|
56
|
+
* `sha256(canonical bytes)` — the hash the reviewer approved. Formatting
|
|
57
|
+
* of the submitted JSON is irrelevant: a pretty-printed file and its
|
|
58
|
+
* minified twin compile to the same hash.
|
|
59
|
+
*/
|
|
60
|
+
doc_hash: Buffer;
|
|
61
|
+
/**
|
|
62
|
+
* The fingerprint (`perch_recovery_interface::credential::Credential::
|
|
63
|
+
* fingerprint`) of every declared signer's credential, with external
|
|
64
|
+
* keys canonicalized by their verifier. What revocation compares
|
|
65
|
+
* (spec §8).
|
|
66
|
+
*/
|
|
67
|
+
fingerprints: Array<Buffer>;
|
|
68
|
+
/**
|
|
69
|
+
* The compiled `recovery` member: zero or one entries (a `Vec` for the
|
|
70
|
+
* same reason as [`CompiledRule::install`]). Present ⇒ the document
|
|
71
|
+
* enrolls account recovery, and the applier syncs this configuration to
|
|
72
|
+
* the controller instance it names (`docs/recovery/`).
|
|
73
|
+
*/
|
|
74
|
+
recovery: Array<CompiledRecoveryConfig>;
|
|
75
|
+
/**
|
|
76
|
+
* One compiled rule per document rule, in the submitted order.
|
|
77
|
+
*/
|
|
78
|
+
rules: Array<CompiledRule>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* One rule, compiled to the exact shapes OZ's `add_context_rule` takes:
|
|
82
|
+
* resolved addresses, OZ `Signer`s, and (for constrained rules) the
|
|
83
|
+
* interpreter program as `InstallParams`.
|
|
84
|
+
*/
|
|
85
|
+
export interface CompiledRule {
|
|
86
|
+
/**
|
|
87
|
+
* Zero or one entries (a `Vec` for the same reason as `install`).
|
|
88
|
+
* Present ⇒ also attach OZ `spending_limit` with these params — the
|
|
89
|
+
* cumulative cap the stateless interpreter cannot express. The applier
|
|
90
|
+
* resolves the policy's content-addressed address and keys it into the
|
|
91
|
+
* rule's policy map beside the interpreter; the tracked token is the
|
|
92
|
+
* rule's `Contract` scope (validation pins `token == scope`).
|
|
93
|
+
*/
|
|
94
|
+
cap: Array<CompiledCap>;
|
|
95
|
+
/**
|
|
96
|
+
* The interpreter program to attach: zero or one entries. A `Vec`
|
|
97
|
+
* because `#[contracttype]` has no conversion for `Option` of a custom
|
|
98
|
+
* struct (`Option<u32>` on `valid_until` works because `u32` is a host
|
|
99
|
+
* type). Empty ⇒ a policy-free rule.
|
|
100
|
+
*/
|
|
101
|
+
install: Array<InstallParams>;
|
|
102
|
+
/**
|
|
103
|
+
* The rule's name in the document. The account matches installed rules
|
|
104
|
+
* by name and scope.
|
|
105
|
+
*/
|
|
106
|
+
name: string;
|
|
107
|
+
scope: RuleScope;
|
|
108
|
+
/**
|
|
109
|
+
* The rule's signers, with external keys as declared (already
|
|
110
|
+
* verifier-canonical).
|
|
111
|
+
*/
|
|
112
|
+
signers: Array<Signer>;
|
|
113
|
+
/**
|
|
114
|
+
* The last ledger the rule authorizes, if bounded: OZ's inclusive
|
|
115
|
+
* `valid_until`, one below the document's `not-after-ledger`.
|
|
116
|
+
*/
|
|
117
|
+
valid_until: Option<u32>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* What `derive_target` returns: the recovery target the controller binds
|
|
121
|
+
* into an attempt's statement (spec §7.1).
|
|
122
|
+
*/
|
|
123
|
+
export interface DerivedTarget {
|
|
124
|
+
/**
|
|
125
|
+
* The target's canonical bytes: exactly what the completing `apply_doc`
|
|
126
|
+
* must submit.
|
|
127
|
+
*/
|
|
128
|
+
canonical: Buffer;
|
|
129
|
+
/**
|
|
130
|
+
* The target's recovery `config_hash` (the current one, or the current
|
|
131
|
+
* one with the declared ZK rotation).
|
|
132
|
+
*/
|
|
133
|
+
config_hash: Buffer;
|
|
134
|
+
/**
|
|
135
|
+
* `sha256` of `canonical`: the target's `doc_hash`.
|
|
136
|
+
*/
|
|
137
|
+
doc_hash: Buffer;
|
|
138
|
+
/**
|
|
139
|
+
* Fingerprints of every credential in the target (spec §7.3 rule 7).
|
|
140
|
+
*/
|
|
141
|
+
fingerprints: Array<Buffer>;
|
|
142
|
+
/**
|
|
143
|
+
* The credentials occupying the replaced signer slots in the source:
|
|
144
|
+
* the applied document's for lost-key, the baseline's for compromise.
|
|
145
|
+
* External keys are canonicalized by their verifier, so a credential's
|
|
146
|
+
* `fingerprint` is the one revocation compares. The controller records
|
|
147
|
+
* them at T1 and the completion revokes them (spec §8).
|
|
148
|
+
*/
|
|
149
|
+
replaced: Array<Credential>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Flat per-document caps: [`MAX_DOC_SIGNERS`], [`MAX_DOC_RULES`],
|
|
153
|
+
* [`MAX_DOC_CANONICAL_BYTES`], [`MAX_RULE_NAME_BYTES`].
|
|
154
|
+
*/
|
|
155
|
+
export interface FlatDocLimits {
|
|
156
|
+
max_canonical_bytes: u32;
|
|
157
|
+
max_rule_name_bytes: u32;
|
|
158
|
+
max_rules: u32;
|
|
159
|
+
max_signers: u32;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Everything `compile_doc` can refuse. (`#[scerr]` assigns sequential codes
|
|
163
|
+
* from 1, in variant order.)
|
|
164
|
+
*/
|
|
165
|
+
export declare const DocCompilerError: {
|
|
166
|
+
/**
|
|
167
|
+
* The submitted document bytes are not UTF-8.
|
|
168
|
+
*/
|
|
169
|
+
1: {
|
|
170
|
+
message: string;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* The document failed fail-closed parsing (unknown field, bad shape, unsupported version, duplicate key, …).
|
|
174
|
+
*/
|
|
175
|
+
2: {
|
|
176
|
+
message: string;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* The document failed semantic validation (dangling signer ref, malformed address or key, ambiguous empty list, …).
|
|
180
|
+
*/
|
|
181
|
+
3: {
|
|
182
|
+
message: string;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* The document names no network, or a network that is not this chain.
|
|
186
|
+
*/
|
|
187
|
+
4: {
|
|
188
|
+
message: string;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* The document cannot be lowered to rules (unsupported rule shape).
|
|
192
|
+
*/
|
|
193
|
+
5: {
|
|
194
|
+
message: string;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* The document exceeds a document cap ([`MAX_DOC_SIGNERS`], [`MAX_DOC_RULES`], [`MAX_DOC_CANONICAL_BYTES`], [`MAX_RULE_NAME_BYTES`]).
|
|
198
|
+
*/
|
|
199
|
+
6: {
|
|
200
|
+
message: string;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* A signer's external `key` is not its verifier-canonical form: either the verifier could not canonicalize it at all, or the declared bytes differ from the canonical form the verifier returns (e.g. a WebAuthn key carrying a credential-id suffix the verifier drops, or a non-canonical point encoding). The compiler refuses it rather than silently canonicalizing, so the bytes the document hash — and a recovery attempt's `replacements_hash` — bind are exactly the bytes the installed credential uses, and two signers cannot hide one physical key under two spellings.
|
|
204
|
+
*/
|
|
205
|
+
7: {
|
|
206
|
+
message: string;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* `derive_target`: the current document enrolls no recovery.
|
|
210
|
+
*/
|
|
211
|
+
8: {
|
|
212
|
+
message: string;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* `derive_target`: the replacement set breaks spec §7.3 rules 1-3 (not canonical, empty for lost-key, a signer id that is not replaceable or not declared in the source, or a change of credential kind or verifier), or the action is not a recovery attempt.
|
|
216
|
+
*/
|
|
217
|
+
9: {
|
|
218
|
+
message: string;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* `derive_target`: the ZK enrollment is missing for a ZK mode, present for a guardian-only mode, or reuses the enrolled id.
|
|
222
|
+
*/
|
|
223
|
+
10: {
|
|
224
|
+
message: string;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* `derive_target`: the target has no policy-free self-admin rule with a signer (the anti-brick check).
|
|
228
|
+
*/
|
|
229
|
+
11: {
|
|
230
|
+
message: string;
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* The canonical form and fragment hashes a compiler produces, as
|
|
235
|
+
* [`PerchDocCompiler::capabilities`] returns them.
|
|
236
|
+
*/
|
|
237
|
+
export interface CompilerCapabilities {
|
|
238
|
+
/**
|
|
239
|
+
* The CANON version `doc_hash` is `sha256` of (`CANONICAL.md`).
|
|
240
|
+
*/
|
|
241
|
+
canon_version: u32;
|
|
242
|
+
/**
|
|
243
|
+
* The domain tag of a recovery member's `config_hash` (spec §3.2).
|
|
244
|
+
*/
|
|
245
|
+
config_hash_tag: string;
|
|
246
|
+
/**
|
|
247
|
+
* The domain tag of a rule's `rule_hash` (spec §3.2).
|
|
248
|
+
*/
|
|
249
|
+
rule_hash_tag: string;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* One op of a postfix-encoded constraint program.
|
|
253
|
+
*/
|
|
254
|
+
export type Op = {
|
|
255
|
+
tag: "All";
|
|
256
|
+
values: readonly [u32];
|
|
257
|
+
} | {
|
|
258
|
+
tag: "Any";
|
|
259
|
+
values: readonly [u32];
|
|
260
|
+
} | {
|
|
261
|
+
tag: "Not";
|
|
262
|
+
values: void;
|
|
263
|
+
} | {
|
|
264
|
+
tag: "MinSigners";
|
|
265
|
+
values: readonly [u32];
|
|
266
|
+
} | {
|
|
267
|
+
tag: "FnIn";
|
|
268
|
+
values: readonly [Array<string>];
|
|
269
|
+
} | {
|
|
270
|
+
tag: "ArgAddrEq";
|
|
271
|
+
values: readonly [u32, string];
|
|
272
|
+
} | {
|
|
273
|
+
tag: "ArgAddrIsSelf";
|
|
274
|
+
values: readonly [u32];
|
|
275
|
+
} | {
|
|
276
|
+
tag: "ArgSymEq";
|
|
277
|
+
values: readonly [u32, string];
|
|
278
|
+
} | {
|
|
279
|
+
tag: "ArgStrIn";
|
|
280
|
+
values: readonly [u32, Array<string>];
|
|
281
|
+
} | {
|
|
282
|
+
tag: "ArgStrPrefix";
|
|
283
|
+
values: readonly [u32, string];
|
|
284
|
+
} | {
|
|
285
|
+
tag: "ArgBytesEq";
|
|
286
|
+
values: readonly [u32, Buffer];
|
|
287
|
+
} | {
|
|
288
|
+
tag: "ArgI128Eq";
|
|
289
|
+
values: readonly [u32, i128];
|
|
290
|
+
} | {
|
|
291
|
+
tag: "ArgU32Eq";
|
|
292
|
+
values: readonly [u32, u32];
|
|
293
|
+
} | {
|
|
294
|
+
tag: "ArgCount";
|
|
295
|
+
values: readonly [u32];
|
|
296
|
+
} | {
|
|
297
|
+
tag: "LedgerBefore";
|
|
298
|
+
values: readonly [u32];
|
|
299
|
+
} | {
|
|
300
|
+
tag: "LedgerAtOrAfter";
|
|
301
|
+
values: readonly [u32];
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* A postfix-encoded constraint program. The last op produces the root
|
|
305
|
+
* verdict.
|
|
306
|
+
*/
|
|
307
|
+
export interface RpnProgram {
|
|
308
|
+
/**
|
|
309
|
+
* The ops, evaluated left to right.
|
|
310
|
+
*/
|
|
311
|
+
ops: Array<Op>;
|
|
312
|
+
/**
|
|
313
|
+
* The wire-format version; only [`PROGRAM_VERSION`] validates.
|
|
314
|
+
*/
|
|
315
|
+
version: u32;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* What the compiler stores in the interpreter for one `(account, rule)`: the
|
|
319
|
+
* program plus the provenance hash of the rule it was compiled from. Sharing
|
|
320
|
+
* this `#[contracttype]` between the compiler and the interpreter is what
|
|
321
|
+
* keeps install params from ever being a hand-built `ScVal` — both sides
|
|
322
|
+
* encode and decode through exactly these types.
|
|
323
|
+
*/
|
|
324
|
+
export interface InstallParams {
|
|
325
|
+
/**
|
|
326
|
+
* The source rule's `perch_ir::rule_hash`, not the whole document's
|
|
327
|
+
* hash (the field keeps its original name). It binds the on-chain
|
|
328
|
+
* program to the reviewed rule (provenance for lift/diff).
|
|
329
|
+
*/
|
|
330
|
+
doc_hash: Buffer;
|
|
331
|
+
program: RpnProgram;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* A signer credential, shaped like OZ `stellar_accounts::smart_account::Signer`.
|
|
335
|
+
*/
|
|
336
|
+
export type Credential = {
|
|
337
|
+
tag: "Delegated";
|
|
338
|
+
values: readonly [string];
|
|
339
|
+
} | {
|
|
340
|
+
tag: "External";
|
|
341
|
+
values: readonly [string, Buffer];
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* One designated signer slot and the credential that replaces whatever
|
|
345
|
+
* that slot holds in the source document.
|
|
346
|
+
*/
|
|
347
|
+
export interface Replacement {
|
|
348
|
+
/**
|
|
349
|
+
* The credential the target document gives that signer id.
|
|
350
|
+
*/
|
|
351
|
+
credential: Credential;
|
|
352
|
+
/**
|
|
353
|
+
* A document signer id listed in the enrolled `recovery.replaceable`.
|
|
354
|
+
*/
|
|
355
|
+
signer_id: string;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* A ZK enrollment a recovery completion installs.
|
|
359
|
+
*
|
|
360
|
+
* The commitment is bound here, not only the id: completion runs under the
|
|
361
|
+
* zero-signer recovery rule, so nothing signs its arguments, and a
|
|
362
|
+
* commitment supplied only at completion could be swapped by whoever
|
|
363
|
+
* submits the completing transaction first — handing them the account's
|
|
364
|
+
* next ZK factor.
|
|
365
|
+
*/
|
|
366
|
+
export interface ZkEnrollment {
|
|
367
|
+
/**
|
|
368
|
+
* The new leaf's inner commitment, `Poseidon2(DOM_LEAF, secret)`.
|
|
369
|
+
* Derivation writes `id` and `commitment` into the target document's
|
|
370
|
+
* recovery section, so the target hash binds them, and the completing
|
|
371
|
+
* `apply_doc` inserts the leaf from the compiled target, never from a
|
|
372
|
+
* call argument.
|
|
373
|
+
*/
|
|
374
|
+
commitment: Buffer;
|
|
375
|
+
/**
|
|
376
|
+
* The new enrollment id. Must never have been enrolled for this
|
|
377
|
+
* account before.
|
|
378
|
+
*/
|
|
379
|
+
id: Buffer;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Everything a `LostKey`/`Compromise` attempt changes about the source
|
|
383
|
+
* document. See `docs/recovery/spec.md` §7.
|
|
384
|
+
*/
|
|
385
|
+
export interface ReplacementSet {
|
|
386
|
+
/**
|
|
387
|
+
* Signer replacements in strictly ascending `signer_id` byte order
|
|
388
|
+
* (sorted, no duplicates) — the one canonical order.
|
|
389
|
+
*/
|
|
390
|
+
signers: Array<Replacement>;
|
|
391
|
+
/**
|
|
392
|
+
* The fresh ZK enrollment the completion installs, required exactly
|
|
393
|
+
* when the enrolled mode has a ZK factor (a ZK-evidenced completion
|
|
394
|
+
* consumes the enrolled credential, so it must install a fresh one).
|
|
395
|
+
* Empty or one entry — a `Vec` because `#[contracttype]` cannot derive
|
|
396
|
+
* `Option<CustomStruct>`.
|
|
397
|
+
*/
|
|
398
|
+
zk_enrollment: Array<ZkEnrollment>;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Who may change the recovery configuration, and whether an authorized
|
|
402
|
+
* attempt freezes ordinary activity (spec §2, §9).
|
|
403
|
+
*/
|
|
404
|
+
export type RecoveryProfile = {
|
|
405
|
+
tag: "Loss";
|
|
406
|
+
values: void;
|
|
407
|
+
} | {
|
|
408
|
+
tag: "Protected";
|
|
409
|
+
values: void;
|
|
410
|
+
};
|
|
411
|
+
/**
|
|
412
|
+
* The ZK factor (spec §3.1, §3.4).
|
|
413
|
+
*/
|
|
414
|
+
export interface CompiledZkFactor {
|
|
415
|
+
/**
|
|
416
|
+
* The constructorless ZK adapter the controller calls.
|
|
417
|
+
*/
|
|
418
|
+
adapter: string;
|
|
419
|
+
/**
|
|
420
|
+
* `sha256` of the adapter's verification key; must equal the adapter's
|
|
421
|
+
* `circuit_id()`.
|
|
422
|
+
*/
|
|
423
|
+
circuit_id: Buffer;
|
|
424
|
+
/**
|
|
425
|
+
* The current credential's inner commitment, `Poseidon2(DOM_LEAF,
|
|
426
|
+
* secret)`, from which the account inserts the leaf.
|
|
427
|
+
*/
|
|
428
|
+
commitment: Buffer;
|
|
429
|
+
/**
|
|
430
|
+
* The current credential's id, bound into its leaf and nullifier.
|
|
431
|
+
*/
|
|
432
|
+
enrollment_id: Buffer;
|
|
433
|
+
/**
|
|
434
|
+
* The membership pool roots are accepted from.
|
|
435
|
+
*/
|
|
436
|
+
pool: string;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* The guardian factor.
|
|
440
|
+
*/
|
|
441
|
+
export interface CompiledGuardianSet {
|
|
442
|
+
/**
|
|
443
|
+
* Guardian addresses (`G...` or `C...`), never the account itself.
|
|
444
|
+
*/
|
|
445
|
+
guardians: Array<string>;
|
|
446
|
+
/**
|
|
447
|
+
* `1 <= quorum <= guardians.len()`.
|
|
448
|
+
*/
|
|
449
|
+
quorum: u32;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Which factors a statement needs.
|
|
453
|
+
*/
|
|
454
|
+
export type CompiledRecoveryMode = {
|
|
455
|
+
tag: "GuardianOnly";
|
|
456
|
+
values: readonly [CompiledGuardianSet];
|
|
457
|
+
} | {
|
|
458
|
+
tag: "ZkOnly";
|
|
459
|
+
values: readonly [CompiledZkFactor];
|
|
460
|
+
} | {
|
|
461
|
+
tag: "Combined";
|
|
462
|
+
values: readonly [CompiledGuardianSet, CompiledZkFactor];
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* A compiled `recovery` member.
|
|
466
|
+
*/
|
|
467
|
+
export interface CompiledRecoveryConfig {
|
|
468
|
+
/**
|
|
469
|
+
* The enrolled baseline's canonical document hash, if compromise
|
|
470
|
+
* recovery is enrolled.
|
|
471
|
+
*/
|
|
472
|
+
baseline: Option<Buffer>;
|
|
473
|
+
/**
|
|
474
|
+
* [`config_hash`] of the canonical JSON of the recovery member, computed
|
|
475
|
+
* by the doc compiler (spec §3.2). Configuration
|
|
476
|
+
* identity: two compiled configurations with the same `config_hash` are
|
|
477
|
+
* the same configuration.
|
|
478
|
+
*/
|
|
479
|
+
config_hash: Buffer;
|
|
480
|
+
/**
|
|
481
|
+
* The adopted controller instance.
|
|
482
|
+
*/
|
|
483
|
+
controller: string;
|
|
484
|
+
/**
|
|
485
|
+
* Ledgers from an attempt's authorization until it can complete.
|
|
486
|
+
*/
|
|
487
|
+
delay_ledgers: u32;
|
|
488
|
+
/**
|
|
489
|
+
* The evidence window of a collecting attempt and the completion
|
|
490
|
+
* window of an authorized one, in ledgers.
|
|
491
|
+
*/
|
|
492
|
+
expiry_ledgers: u32;
|
|
493
|
+
/**
|
|
494
|
+
* Lifetime cap on evidence-based cancellations of authorized attempts.
|
|
495
|
+
*/
|
|
496
|
+
max_cancels: u32;
|
|
497
|
+
/**
|
|
498
|
+
* The factors evidence must satisfy.
|
|
499
|
+
*/
|
|
500
|
+
mode: CompiledRecoveryMode;
|
|
501
|
+
/**
|
|
502
|
+
* Who may change the configuration, and whether an authorized attempt
|
|
503
|
+
* freezes the account.
|
|
504
|
+
*/
|
|
505
|
+
profile: RecoveryProfile;
|
|
506
|
+
/**
|
|
507
|
+
* Signer ids (not credential fingerprints) a recovery may replace, so
|
|
508
|
+
* rotating a key does not change the configuration (#92).
|
|
509
|
+
*/
|
|
510
|
+
replaceable: Array<string>;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* The action domain a statement authorizes. Evidence for one action never
|
|
514
|
+
* satisfies another: the action code is the encoding's 26th byte and selects
|
|
515
|
+
* the subject layout, so two statements that differ only in action have
|
|
516
|
+
* different digests (and different encoded lengths for most pairs).
|
|
517
|
+
*
|
|
518
|
+
* The numeric codes are part of the wire format.
|
|
519
|
+
*/
|
|
520
|
+
export declare enum RecoveryAction {
|
|
521
|
+
LostKey = 1,
|
|
522
|
+
Compromise = 2,
|
|
523
|
+
Cancel = 3,
|
|
524
|
+
Reconfigure = 4,
|
|
525
|
+
Upgrade = 5
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Represents different types of signers in the smart account system.
|
|
529
|
+
*/
|
|
530
|
+
export type Signer = {
|
|
531
|
+
tag: "Delegated";
|
|
532
|
+
values: readonly [string];
|
|
533
|
+
} | {
|
|
534
|
+
tag: "External";
|
|
535
|
+
values: readonly [string, Buffer];
|
|
536
|
+
};
|
|
537
|
+
export interface Client {
|
|
538
|
+
/**
|
|
539
|
+
* Construct and simulate a limits 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.
|
|
540
|
+
* The document caps every `compile_doc` and `derive_target` enforces.
|
|
541
|
+
*/
|
|
542
|
+
limits: (options?: MethodOptions) => Promise<AssembledTransaction<DocLimits>>;
|
|
543
|
+
/**
|
|
544
|
+
* Construct and simulate a compile_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.
|
|
545
|
+
* JSON bytes in → compiled rules + canonical `doc_hash` out. Pure:
|
|
546
|
+
* no auth, no storage. The document must name THIS network (its
|
|
547
|
+
* `network` string must hash to the chain's network id), so a testnet
|
|
548
|
+
* document can never compile on mainnet or vice versa. It must also fit
|
|
549
|
+
* the document caps ([`Self::limits`]), and every external signer key
|
|
550
|
+
* must already be its verifier-canonical form: the compiler calls each
|
|
551
|
+
* named verifier's `batch_canonicalize_key` to check.
|
|
552
|
+
*/
|
|
553
|
+
compile_doc: ({ doc_json }: {
|
|
554
|
+
doc_json: Buffer;
|
|
555
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<Result<CompiledDoc>>>;
|
|
556
|
+
/**
|
|
557
|
+
* 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.
|
|
558
|
+
* The CANON version and the fragment hash domain tags this compiler
|
|
559
|
+
* produces.
|
|
560
|
+
*/
|
|
561
|
+
capabilities: (options?: MethodOptions) => Promise<AssembledTransaction<CompilerCapabilities>>;
|
|
562
|
+
/**
|
|
563
|
+
* Construct and simulate a derive_target 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.
|
|
564
|
+
* Derive a recovery target (`docs/recovery/spec.md` §7): `source_json`
|
|
565
|
+
* is the account's applied document (lost-key) or the published
|
|
566
|
+
* baseline (compromise); `current_json` is the applied document, whose
|
|
567
|
+
* recovery member the target keeps. The target is the source with
|
|
568
|
+
* exactly the declared replacements and ZK rotation, then validated,
|
|
569
|
+
* network-bound, capped, compiled, and anti-brick-checked like any
|
|
570
|
+
* applied document. Pure: no auth, no storage. The controller calls it
|
|
571
|
+
* when an attempt begins, and completers simulate it to obtain the
|
|
572
|
+
* canonical bytes.
|
|
573
|
+
*/
|
|
574
|
+
derive_target: ({ source_json, current_json, action, replacements }: {
|
|
575
|
+
source_json: Buffer;
|
|
576
|
+
current_json: Buffer;
|
|
577
|
+
action: RecoveryAction;
|
|
578
|
+
replacements: ReplacementSet;
|
|
579
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<Result<DerivedTarget>>>;
|
|
580
|
+
}
|
|
581
|
+
export declare class Client extends ContractClient {
|
|
582
|
+
readonly options: ContractClientOptions;
|
|
583
|
+
static deploy<T = Client>(
|
|
584
|
+
/** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
|
|
585
|
+
options: MethodOptions & Omit<ContractClientOptions, "contractId"> & {
|
|
586
|
+
/** The hash of the Wasm blob, which must already be installed on-chain. */
|
|
587
|
+
wasmHash: Buffer | string;
|
|
588
|
+
/** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
|
|
589
|
+
salt?: Buffer | Uint8Array;
|
|
590
|
+
/** The format used to decode `wasmHash`, if it's provided as a string. */
|
|
591
|
+
format?: "hex" | "base64";
|
|
592
|
+
}): Promise<AssembledTransaction<T>>;
|
|
593
|
+
constructor(options: ContractClientOptions);
|
|
594
|
+
readonly fromJSON: {
|
|
595
|
+
limits: (json: string) => AssembledTransaction<DocLimits>;
|
|
596
|
+
compile_doc: (json: string) => AssembledTransaction<Result<CompiledDoc, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
|
|
597
|
+
capabilities: (json: string) => AssembledTransaction<CompilerCapabilities>;
|
|
598
|
+
derive_target: (json: string) => AssembledTransaction<Result<DerivedTarget, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
|
|
599
|
+
};
|
|
600
|
+
}
|