@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
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
/** sha256 of the wasm these bindings were generated from. */
|
|
2
|
+
export declare const WASM_SHA256 = "2c976bfd98678f3b6fcf5514420a81ef5e5b9fc1c5b6c60ec6f2dd64448479d5";
|
|
3
|
+
import { Buffer } from "buffer";
|
|
4
|
+
import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, MethodOptions, Result } from "@stellar/stellar-sdk/contract";
|
|
5
|
+
import type { u32, u64, Option } from "@stellar/stellar-sdk/contract";
|
|
6
|
+
export * from "@stellar/stellar-sdk";
|
|
7
|
+
export * as contract from "@stellar/stellar-sdk/contract";
|
|
8
|
+
export * as rpc from "@stellar/stellar-sdk/rpc";
|
|
9
|
+
/**
|
|
10
|
+
* One pending account upgrade (spec §12).
|
|
11
|
+
*
|
|
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.
|
|
17
|
+
*
|
|
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.
|
|
23
|
+
*/
|
|
24
|
+
export interface UpgradeRequest {
|
|
25
|
+
/**
|
|
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.
|
|
29
|
+
*/
|
|
30
|
+
controller_epoch: Option<u64>;
|
|
31
|
+
/**
|
|
32
|
+
* The first ledger at which the request may execute.
|
|
33
|
+
*/
|
|
34
|
+
executable_at: u32;
|
|
35
|
+
/**
|
|
36
|
+
* The account's recovery generation when the request was scheduled.
|
|
37
|
+
*/
|
|
38
|
+
generation: u64;
|
|
39
|
+
/**
|
|
40
|
+
* Per-account, never reused.
|
|
41
|
+
*/
|
|
42
|
+
request_id: u64;
|
|
43
|
+
/**
|
|
44
|
+
* The exact Wasm the account will run.
|
|
45
|
+
*/
|
|
46
|
+
wasm_hash: Buffer;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The shared infra an account resolves, pinned when it was built (see
|
|
50
|
+
* [`infra`]): what a deployment check compares with its manifest.
|
|
51
|
+
*/
|
|
52
|
+
export interface InfraPins {
|
|
53
|
+
doc_compiler: string;
|
|
54
|
+
interpreter: string;
|
|
55
|
+
spending_limit: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
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.
|
|
61
|
+
*/
|
|
62
|
+
export interface FreezeGate {
|
|
63
|
+
/**
|
|
64
|
+
* The authorized attempt, the only one whose completion the account
|
|
65
|
+
* authorizes while frozen.
|
|
66
|
+
*/
|
|
67
|
+
attempt_id: u64;
|
|
68
|
+
/**
|
|
69
|
+
* The authorized attempt's `expires_at`.
|
|
70
|
+
*/
|
|
71
|
+
until: u32;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Constants of the deployed account wasm a wallet checks before it builds
|
|
75
|
+
* anything for this account: what [`PerchSmartAccount::capabilities`]
|
|
76
|
+
* returns.
|
|
77
|
+
*/
|
|
78
|
+
export interface AccountCapabilities {
|
|
79
|
+
/**
|
|
80
|
+
* How a document is applied: `one_tx`, one `apply_doc` transaction.
|
|
81
|
+
*/
|
|
82
|
+
apply_modes: Array<string>;
|
|
83
|
+
/**
|
|
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.
|
|
91
|
+
*/
|
|
92
|
+
auth_digest: string;
|
|
93
|
+
/**
|
|
94
|
+
* How the applied `doc_hash` is computed: `canon_v1`, `sha256` of the
|
|
95
|
+
* CANON v1 canonical bytes.
|
|
96
|
+
*/
|
|
97
|
+
doc_identity: string;
|
|
98
|
+
/**
|
|
99
|
+
* [`INTERFACE_VERSION`].
|
|
100
|
+
*/
|
|
101
|
+
interface_version: u32;
|
|
102
|
+
/**
|
|
103
|
+
* [`SNAPSHOT_VERSION`].
|
|
104
|
+
*/
|
|
105
|
+
snapshot_version: u32;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Everything rule selection and signing need, read at one ledger: what
|
|
109
|
+
* [`PerchSmartAccount::configuration`] returns.
|
|
110
|
+
*/
|
|
111
|
+
export interface AccountConfiguration {
|
|
112
|
+
/**
|
|
113
|
+
* The applied document's `doc_hash`, or `None` before the first apply.
|
|
114
|
+
*/
|
|
115
|
+
doc_hash: Option<Buffer>;
|
|
116
|
+
/**
|
|
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`.
|
|
120
|
+
*/
|
|
121
|
+
gate: Array<FreezeGate>;
|
|
122
|
+
/**
|
|
123
|
+
* The shared infra the account pins, as [`PerchSmartAccount::infra`]
|
|
124
|
+
* returns it.
|
|
125
|
+
*/
|
|
126
|
+
infra: InfraPins;
|
|
127
|
+
/**
|
|
128
|
+
* The adopted recovery controller, if any.
|
|
129
|
+
*/
|
|
130
|
+
recovery_controller: Option<string>;
|
|
131
|
+
/**
|
|
132
|
+
* The recovery generation (spec §12), as
|
|
133
|
+
* [`PerchSmartAccount::recovery_generation`] returns it.
|
|
134
|
+
*/
|
|
135
|
+
recovery_generation: u64;
|
|
136
|
+
/**
|
|
137
|
+
* The zero-signer recovery rule's OZ id, if one is installed.
|
|
138
|
+
*/
|
|
139
|
+
recovery_rule: Option<u32>;
|
|
140
|
+
/**
|
|
141
|
+
* The configuration revision every other field belongs to.
|
|
142
|
+
*/
|
|
143
|
+
revision: u64;
|
|
144
|
+
/**
|
|
145
|
+
* Every installed context rule, with its OZ id.
|
|
146
|
+
*/
|
|
147
|
+
rules: Array<InstalledRule>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* One context rule as the account installed it.
|
|
151
|
+
*/
|
|
152
|
+
export interface InstalledRule {
|
|
153
|
+
/**
|
|
154
|
+
* The rule's OZ scope.
|
|
155
|
+
*/
|
|
156
|
+
context_type: ContextRuleType;
|
|
157
|
+
/**
|
|
158
|
+
* The OZ context-rule id.
|
|
159
|
+
*/
|
|
160
|
+
id: u32;
|
|
161
|
+
/**
|
|
162
|
+
* The rule's name: the document rule's, `admin` for the constructor's,
|
|
163
|
+
* `recovery` for the recovery rule.
|
|
164
|
+
*/
|
|
165
|
+
name: string;
|
|
166
|
+
/**
|
|
167
|
+
* The policies attached to the rule.
|
|
168
|
+
*/
|
|
169
|
+
policies: Array<InstalledPolicy>;
|
|
170
|
+
/**
|
|
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.
|
|
174
|
+
*/
|
|
175
|
+
recovery: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* The rule's signers.
|
|
178
|
+
*/
|
|
179
|
+
signers: Array<Signer>;
|
|
180
|
+
/**
|
|
181
|
+
* OZ's inclusive last valid ledger, if bounded.
|
|
182
|
+
*/
|
|
183
|
+
valid_until: Option<u32>;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* One policy attached to an installed rule.
|
|
187
|
+
*/
|
|
188
|
+
export interface InstalledPolicy {
|
|
189
|
+
/**
|
|
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.
|
|
193
|
+
*/
|
|
194
|
+
params: Buffer;
|
|
195
|
+
/**
|
|
196
|
+
* The policy contract.
|
|
197
|
+
*/
|
|
198
|
+
policy: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Context of a single authorized call performed by an address.
|
|
202
|
+
*
|
|
203
|
+
* Custom account contracts that implement `__check_auth` special function
|
|
204
|
+
* receive a list of `Context` values corresponding to all the calls that
|
|
205
|
+
* need to be authorized.
|
|
206
|
+
*/
|
|
207
|
+
export type Context = {
|
|
208
|
+
tag: "Contract";
|
|
209
|
+
values: readonly [ContractContext];
|
|
210
|
+
} | {
|
|
211
|
+
tag: "CreateContractHostFn";
|
|
212
|
+
values: readonly [CreateContractHostFnContext];
|
|
213
|
+
} | {
|
|
214
|
+
tag: "CreateContractWithCtorHostFn";
|
|
215
|
+
values: readonly [CreateContractWithConstructorHostFnContext];
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Authorization context of a single contract call.
|
|
219
|
+
*
|
|
220
|
+
* This struct corresponds to a `require_auth_for_args` call for an address
|
|
221
|
+
* from `contract` function with `fn_name` name and `args` arguments.
|
|
222
|
+
*/
|
|
223
|
+
export interface ContractContext {
|
|
224
|
+
args: Array<any>;
|
|
225
|
+
contract: string;
|
|
226
|
+
fn_name: string;
|
|
227
|
+
}
|
|
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
|
+
/**
|
|
237
|
+
* Authorization context for `create_contract` host function that creates a
|
|
238
|
+
* new contract on behalf of authorizer address.
|
|
239
|
+
*/
|
|
240
|
+
export interface CreateContractHostFnContext {
|
|
241
|
+
executable: ContractExecutable;
|
|
242
|
+
salt: Buffer;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Authorization context for `create_contract` host function that creates a
|
|
246
|
+
* new contract on behalf of authorizer address.
|
|
247
|
+
* This is the same as `CreateContractHostFnContext`, but also has
|
|
248
|
+
* contract constructor arguments.
|
|
249
|
+
*/
|
|
250
|
+
export interface CreateContractWithConstructorHostFnContext {
|
|
251
|
+
constructor_args: Array<any>;
|
|
252
|
+
executable: ContractExecutable;
|
|
253
|
+
salt: Buffer;
|
|
254
|
+
}
|
|
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
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* A signer in `AuthPayload` is not part of any selected context rule.
|
|
352
|
+
*/
|
|
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 {
|
|
453
|
+
/**
|
|
454
|
+
* 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
|
+
* Every shared contract this account pins at build time.
|
|
456
|
+
*/
|
|
457
|
+
infra: (options?: MethodOptions) => Promise<AssembledTransaction<InfraPins>>;
|
|
458
|
+
/**
|
|
459
|
+
* 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.
|
|
463
|
+
*/
|
|
464
|
+
renew: ({ fingerprints, enrollment_ids }: {
|
|
465
|
+
fingerprints: Array<Buffer>;
|
|
466
|
+
enrollment_ids: Array<Buffer>;
|
|
467
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
468
|
+
/**
|
|
469
|
+
* 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).
|
|
476
|
+
*/
|
|
477
|
+
execute: ({ target, target_fn, target_args }: {
|
|
478
|
+
target: string;
|
|
479
|
+
target_fn: string;
|
|
480
|
+
target_args: Array<any>;
|
|
481
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<Result<any>>>;
|
|
482
|
+
/**
|
|
483
|
+
* 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`.
|
|
486
|
+
*/
|
|
487
|
+
document: (options?: MethodOptions) => Promise<AssembledTransaction<readonly [u64, Option<Buffer>]>>;
|
|
488
|
+
/**
|
|
489
|
+
* 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.
|
|
496
|
+
*/
|
|
497
|
+
rcv_gate: ({ attempt_id, frozen_until }: {
|
|
498
|
+
attempt_id: u64;
|
|
499
|
+
frozen_until: u32;
|
|
500
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
|
|
501
|
+
/**
|
|
502
|
+
* 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.
|
|
509
|
+
*/
|
|
510
|
+
revision: (options?: MethodOptions) => Promise<AssembledTransaction<u64>>;
|
|
511
|
+
/**
|
|
512
|
+
* 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
|
|
532
|
+
*/
|
|
533
|
+
apply_doc: ({ doc_json, approval_valid_until, expected_revision }: {
|
|
534
|
+
doc_json: Buffer;
|
|
535
|
+
approval_valid_until: u32;
|
|
536
|
+
expected_revision: Option<u64>;
|
|
537
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<Result<Buffer>>>;
|
|
538
|
+
/**
|
|
539
|
+
* Construct and simulate a is_revoked 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
|
+
* Whether a credential fingerprint is permanently revoked.
|
|
541
|
+
*/
|
|
542
|
+
is_revoked: ({ fingerprint }: {
|
|
543
|
+
fingerprint: Buffer;
|
|
544
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
|
|
545
|
+
/**
|
|
546
|
+
* 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`].
|
|
550
|
+
*/
|
|
551
|
+
applied_doc: (options?: MethodOptions) => Promise<AssembledTransaction<Option<Buffer>>>;
|
|
552
|
+
/**
|
|
553
|
+
* 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.
|
|
557
|
+
*/
|
|
558
|
+
capabilities: (options?: MethodOptions) => Promise<AssembledTransaction<AccountCapabilities>>;
|
|
559
|
+
/**
|
|
560
|
+
* Construct and simulate a doc_compiler 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.
|
|
561
|
+
* The doc compiler this account pins at build time.
|
|
562
|
+
*/
|
|
563
|
+
doc_compiler: (options?: MethodOptions) => Promise<AssembledTransaction<string>>;
|
|
564
|
+
/**
|
|
565
|
+
* 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.
|
|
568
|
+
*/
|
|
569
|
+
configuration: (options?: MethodOptions) => Promise<AssembledTransaction<AccountConfiguration>>;
|
|
570
|
+
/**
|
|
571
|
+
* 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`.
|
|
574
|
+
*/
|
|
575
|
+
recovery_gate: (options?: MethodOptions) => Promise<AssembledTransaction<Option<FreezeGate>>>;
|
|
576
|
+
/**
|
|
577
|
+
* Construct and simulate a cancel_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.
|
|
578
|
+
* Cancel the pending upgrade. Owner authorization.
|
|
579
|
+
*/
|
|
580
|
+
cancel_upgrade: (options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
|
|
581
|
+
/**
|
|
582
|
+
* 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
|
+
* Whether this account ever enrolled a ZK enrollment id.
|
|
584
|
+
*/
|
|
585
|
+
is_enrolled_id: ({ enrollment_id }: {
|
|
586
|
+
enrollment_id: Buffer;
|
|
587
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
|
|
588
|
+
/**
|
|
589
|
+
* 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`.
|
|
592
|
+
*/
|
|
593
|
+
cancel_recovery: ({ attempt_id }: {
|
|
594
|
+
attempt_id: u64;
|
|
595
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
|
|
596
|
+
/**
|
|
597
|
+
* 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.
|
|
610
|
+
*/
|
|
611
|
+
execute_upgrade: ({ request_id }: {
|
|
612
|
+
request_id: u64;
|
|
613
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<Result<void>>>;
|
|
614
|
+
/**
|
|
615
|
+
* 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`.
|
|
618
|
+
*/
|
|
619
|
+
installed_rules: (options?: MethodOptions) => Promise<AssembledTransaction<Array<InstalledRule>>>;
|
|
620
|
+
/**
|
|
621
|
+
* Construct and simulate a pending_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.
|
|
622
|
+
* The scheduled upgrade, if any.
|
|
623
|
+
*/
|
|
624
|
+
pending_upgrade: (options?: MethodOptions) => Promise<AssembledTransaction<Option<UpgradeRequest>>>;
|
|
625
|
+
/**
|
|
626
|
+
* 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.
|
|
630
|
+
*/
|
|
631
|
+
applied_doc_hash: (options?: MethodOptions) => Promise<AssembledTransaction<Option<Buffer>>>;
|
|
632
|
+
/**
|
|
633
|
+
* 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`].
|
|
636
|
+
*/
|
|
637
|
+
get_context_rule: ({ context_rule_id }: {
|
|
638
|
+
context_rule_id: u32;
|
|
639
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<ContextRule>>;
|
|
640
|
+
/**
|
|
641
|
+
* 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.
|
|
649
|
+
*/
|
|
650
|
+
schedule_upgrade: ({ wasm_hash, approval_valid_until }: {
|
|
651
|
+
wasm_hash: Buffer;
|
|
652
|
+
approval_valid_until: u32;
|
|
653
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<Result<u64>>>;
|
|
654
|
+
/**
|
|
655
|
+
* Construct and simulate a recovery_controller 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.
|
|
656
|
+
* The adopted recovery controller, if any.
|
|
657
|
+
*/
|
|
658
|
+
recovery_controller: (options?: MethodOptions) => Promise<AssembledTransaction<Option<string>>>;
|
|
659
|
+
/**
|
|
660
|
+
* 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).
|
|
662
|
+
*/
|
|
663
|
+
recovery_generation: (options?: MethodOptions) => Promise<AssembledTransaction<u64>>;
|
|
664
|
+
/**
|
|
665
|
+
* 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.
|
|
669
|
+
*/
|
|
670
|
+
get_context_rules_count: (options?: MethodOptions) => Promise<AssembledTransaction<u32>>;
|
|
671
|
+
/**
|
|
672
|
+
* 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.
|
|
675
|
+
*/
|
|
676
|
+
next_upgrade_request_id: (options?: MethodOptions) => Promise<AssembledTransaction<u64>>;
|
|
677
|
+
}
|
|
678
|
+
export declare class Client extends ContractClient {
|
|
679
|
+
readonly options: ContractClientOptions;
|
|
680
|
+
static deploy<T = Client>(
|
|
681
|
+
/** Constructor/Initialization Args for the contract's `__constructor` method */
|
|
682
|
+
{ admin_signers }: {
|
|
683
|
+
admin_signers: Array<Signer>;
|
|
684
|
+
},
|
|
685
|
+
/** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
|
|
686
|
+
options: MethodOptions & Omit<ContractClientOptions, "contractId"> & {
|
|
687
|
+
/** The hash of the Wasm blob, which must already be installed on-chain. */
|
|
688
|
+
wasmHash: Buffer | string;
|
|
689
|
+
/** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
|
|
690
|
+
salt?: Buffer | Uint8Array;
|
|
691
|
+
/** The format used to decode `wasmHash`, if it's provided as a string. */
|
|
692
|
+
format?: "hex" | "base64";
|
|
693
|
+
}): Promise<AssembledTransaction<T>>;
|
|
694
|
+
constructor(options: ContractClientOptions);
|
|
695
|
+
readonly fromJSON: {
|
|
696
|
+
infra: (json: string) => AssembledTransaction<InfraPins>;
|
|
697
|
+
renew: (json: string) => AssembledTransaction<null>;
|
|
698
|
+
execute: (json: string) => AssembledTransaction<Result<any, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
|
|
699
|
+
document: (json: string) => AssembledTransaction<readonly [bigint, Option<Buffer<ArrayBufferLike>>]>;
|
|
700
|
+
rcv_gate: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
|
|
701
|
+
revision: (json: string) => AssembledTransaction<bigint>;
|
|
702
|
+
apply_doc: (json: string) => AssembledTransaction<Result<Buffer<ArrayBufferLike>, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
|
|
703
|
+
is_revoked: (json: string) => AssembledTransaction<boolean>;
|
|
704
|
+
applied_doc: (json: string) => AssembledTransaction<Option<Buffer<ArrayBufferLike>>>;
|
|
705
|
+
capabilities: (json: string) => AssembledTransaction<AccountCapabilities>;
|
|
706
|
+
doc_compiler: (json: string) => AssembledTransaction<string>;
|
|
707
|
+
configuration: (json: string) => AssembledTransaction<AccountConfiguration>;
|
|
708
|
+
recovery_gate: (json: string) => AssembledTransaction<Option<FreezeGate>>;
|
|
709
|
+
cancel_upgrade: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
|
|
710
|
+
is_enrolled_id: (json: string) => AssembledTransaction<boolean>;
|
|
711
|
+
cancel_recovery: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
|
|
712
|
+
execute_upgrade: (json: string) => AssembledTransaction<Result<void, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
|
|
713
|
+
installed_rules: (json: string) => AssembledTransaction<InstalledRule[]>;
|
|
714
|
+
pending_upgrade: (json: string) => AssembledTransaction<Option<UpgradeRequest>>;
|
|
715
|
+
applied_doc_hash: (json: string) => AssembledTransaction<Option<Buffer<ArrayBufferLike>>>;
|
|
716
|
+
get_context_rule: (json: string) => AssembledTransaction<ContextRule>;
|
|
717
|
+
schedule_upgrade: (json: string) => AssembledTransaction<Result<bigint, import("@stellar/stellar-sdk/contract").ErrorMessage>>;
|
|
718
|
+
recovery_controller: (json: string) => AssembledTransaction<Option<string>>;
|
|
719
|
+
recovery_generation: (json: string) => AssembledTransaction<bigint>;
|
|
720
|
+
get_context_rules_count: (json: string) => AssembledTransaction<number>;
|
|
721
|
+
next_upgrade_request_id: (json: string) => AssembledTransaction<bigint>;
|
|
722
|
+
};
|
|
723
|
+
}
|