@midnight-ntwrk/ledger-v7 7.0.0-alpha.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/ledger-v7.d.ts +2997 -0
- package/midnight_ledger_wasm.js +5 -0
- package/midnight_ledger_wasm_bg.js +9770 -0
- package/midnight_ledger_wasm_bg.wasm +0 -0
- package/midnight_ledger_wasm_fs.js +69 -0
- package/package-lock.json +12 -0
- package/package.json +34 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline0.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline1.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline10.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline11.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline12.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline13.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline14.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline15.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline16.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline17.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline18.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline19.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline2.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline20.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline21.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline22.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline23.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline3.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline4.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline5.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline6.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline7.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline8.js +1 -0
- package/snippets/midnight-ledger-wasm-825a4bfeabd72985/inline9.js +1 -0
package/ledger-v7.d.ts
ADDED
|
@@ -0,0 +1,2997 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An onchain data value, in field-aligned binary format.
|
|
3
|
+
*/
|
|
4
|
+
export type Value = Array<Uint8Array>;
|
|
5
|
+
/**
|
|
6
|
+
* The alignment of an onchain field-aligned binary data value.
|
|
7
|
+
*/
|
|
8
|
+
export type Alignment = AlignmentSegment[];
|
|
9
|
+
/**
|
|
10
|
+
* A segment in a larger {@link Alignment}.
|
|
11
|
+
*/
|
|
12
|
+
export type AlignmentSegment = { tag: 'option', value: Alignment[] } | { tag: 'atom', value: AlignmentAtom };
|
|
13
|
+
/**
|
|
14
|
+
* A atom in a larger {@link Alignment}.
|
|
15
|
+
*/
|
|
16
|
+
export type AlignmentAtom = { tag: 'compress' } | { tag: 'field' } | { tag: 'bytes', length: number };
|
|
17
|
+
/**
|
|
18
|
+
* An onchain data value, in field-aligned binary format, annotated with its
|
|
19
|
+
* alignment.
|
|
20
|
+
*/
|
|
21
|
+
export type AlignedValue = { value: Value, alignment: Alignment };
|
|
22
|
+
/**
|
|
23
|
+
* A Zswap nullifier, as a hex-encoded 256-bit bitstring
|
|
24
|
+
*/
|
|
25
|
+
export type Nullifier = string;
|
|
26
|
+
/**
|
|
27
|
+
* A Zswap coin commitment, as a hex-encoded 256-bit bitstring
|
|
28
|
+
*/
|
|
29
|
+
export type CoinCommitment = string;
|
|
30
|
+
/**
|
|
31
|
+
* A contract address, as a hex-encoded 35-byte string
|
|
32
|
+
*/
|
|
33
|
+
export type ContractAddress = string;
|
|
34
|
+
/**
|
|
35
|
+
* A user public key address, as a hex-encoded 35-byte string
|
|
36
|
+
*/
|
|
37
|
+
export type UserAddress = string;
|
|
38
|
+
/**
|
|
39
|
+
* The internal identifier attached to a {@link TokenType}, as a hex-encoded string.
|
|
40
|
+
*/
|
|
41
|
+
export type RawTokenType = string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Unshielded token type (or color), as a hex-encoded 35-byte string
|
|
45
|
+
*/
|
|
46
|
+
export type UnshieldedTokenType = { tag: 'unshielded', raw: RawTokenType };
|
|
47
|
+
/**
|
|
48
|
+
* Shielded token type (or color), as a hex-encoded 35-byte string
|
|
49
|
+
*/
|
|
50
|
+
export type ShieldedTokenType = { tag: 'shielded', raw: RawTokenType };
|
|
51
|
+
/**
|
|
52
|
+
* Dust token type
|
|
53
|
+
*/
|
|
54
|
+
export type DustTokenType = { tag: 'dust' };
|
|
55
|
+
/**
|
|
56
|
+
* A token type (or color), as a hex-encoded 35-byte string, shielded, unshielded, or Dust
|
|
57
|
+
*/
|
|
58
|
+
export type TokenType = UnshieldedTokenType | ShieldedTokenType | DustTokenType;
|
|
59
|
+
/**
|
|
60
|
+
* A token domain seperator, the pre-stage of `TokenType`, as 32-byte bytearray
|
|
61
|
+
*/
|
|
62
|
+
export type DomainSeparator = Uint8Array;
|
|
63
|
+
/**
|
|
64
|
+
* A user public key capable of receiving Zswap coins, as a hex-encoded 35-byte
|
|
65
|
+
* string
|
|
66
|
+
*/
|
|
67
|
+
export type CoinPublicKey = string;
|
|
68
|
+
/**
|
|
69
|
+
* A running tally of synthetic resource costs.
|
|
70
|
+
*/
|
|
71
|
+
export type RunningCost = {
|
|
72
|
+
/**
|
|
73
|
+
* The amount of (modelled) time spent reading from disk, measured in picoseconds.
|
|
74
|
+
*/
|
|
75
|
+
readTime: bigint,
|
|
76
|
+
/**
|
|
77
|
+
* The amount of (modelled) time spent in single-threaded compute, measured in picoseconds.
|
|
78
|
+
*/
|
|
79
|
+
computeTime: bigint,
|
|
80
|
+
/**
|
|
81
|
+
* The number of (modelled) bytes written.
|
|
82
|
+
*/
|
|
83
|
+
bytesWritten: bigint,
|
|
84
|
+
/**
|
|
85
|
+
* The number of (modelled) bytes deleted.
|
|
86
|
+
*/
|
|
87
|
+
bytesDeleted: bigint,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The fee prices for transaction
|
|
92
|
+
*/
|
|
93
|
+
export type FeePrices = {
|
|
94
|
+
/**
|
|
95
|
+
* The overall price of a full block in an average cost dimension.
|
|
96
|
+
*/
|
|
97
|
+
overallPrice: number,
|
|
98
|
+
/**
|
|
99
|
+
* The price factor of time spent reading from disk.
|
|
100
|
+
*/
|
|
101
|
+
readFactor: number,
|
|
102
|
+
/**
|
|
103
|
+
* The price factor of time spent in single-threaded compute.
|
|
104
|
+
*/
|
|
105
|
+
computeFactor: number,
|
|
106
|
+
/**
|
|
107
|
+
* The price factor of block usage.
|
|
108
|
+
*/
|
|
109
|
+
blockUsageFactor: number,
|
|
110
|
+
/**
|
|
111
|
+
* The price factor of time spent writing to disk.
|
|
112
|
+
*/
|
|
113
|
+
writeFactor: number,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Holds the coin secret key of a user, serialized as a hex-encoded 32-byte string
|
|
118
|
+
*/
|
|
119
|
+
export class CoinSecretKey {
|
|
120
|
+
private constructor();
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Clears the coin secret key, so that it is no longer usable nor held in memory
|
|
124
|
+
*/
|
|
125
|
+
clear(): void;
|
|
126
|
+
|
|
127
|
+
yesIKnowTheSecurityImplicationsOfThis_serialize(): Uint8Array;
|
|
128
|
+
|
|
129
|
+
static deserialize(raw: Uint8Array): CoinSecretKey
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* A Zswap nonce, as a hex-encoded 256-bit string
|
|
134
|
+
*/
|
|
135
|
+
export type Nonce = string;
|
|
136
|
+
/**
|
|
137
|
+
* A hex-encoded signature BIP-340 verifying key, with a 3-byte version prefix
|
|
138
|
+
*/
|
|
139
|
+
export type SignatureVerifyingKey = string;
|
|
140
|
+
/**
|
|
141
|
+
* A hex-encoded signature BIP-340 signing key, with a 3-byte version prefix
|
|
142
|
+
*/
|
|
143
|
+
export type SigningKey = string;
|
|
144
|
+
/**
|
|
145
|
+
* A hex-encoded signature BIP-340 signature, with a 3-byte version prefix
|
|
146
|
+
*/
|
|
147
|
+
export type Signature = string;
|
|
148
|
+
/**
|
|
149
|
+
* An internal encoding of a value of the proof systems scalar field
|
|
150
|
+
*/
|
|
151
|
+
export type Fr = Uint8Array;
|
|
152
|
+
/**
|
|
153
|
+
* Information required to create a new coin, alongside details about the
|
|
154
|
+
* recipient
|
|
155
|
+
*/
|
|
156
|
+
export type ShieldedCoinInfo = {
|
|
157
|
+
/**
|
|
158
|
+
* The coin's type, identifying the currency it represents
|
|
159
|
+
*/
|
|
160
|
+
type: RawTokenType,
|
|
161
|
+
/**
|
|
162
|
+
* The coin's randomness, preventing it from colliding with other coins
|
|
163
|
+
*/
|
|
164
|
+
nonce: Nonce,
|
|
165
|
+
/**
|
|
166
|
+
* The coin's value, in atomic units dependent on the currency
|
|
167
|
+
*
|
|
168
|
+
* Bounded to be a non-negative 64-bit integer
|
|
169
|
+
*/
|
|
170
|
+
value: bigint,
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Information required to spend an existing coin, alongside authorization of
|
|
174
|
+
* the owner
|
|
175
|
+
*/
|
|
176
|
+
export type QualifiedShieldedCoinInfo = {
|
|
177
|
+
/**
|
|
178
|
+
* The coin's type, identifying the currency it represents
|
|
179
|
+
*/
|
|
180
|
+
type: RawTokenType,
|
|
181
|
+
/**
|
|
182
|
+
* The coin's randomness, preventing it from colliding with other coins
|
|
183
|
+
*/
|
|
184
|
+
nonce: Nonce,
|
|
185
|
+
/**
|
|
186
|
+
* The coin's value, in atomic units dependent on the currency
|
|
187
|
+
*
|
|
188
|
+
* Bounded to be a non-negative 64-bit integer
|
|
189
|
+
*/
|
|
190
|
+
value: bigint,
|
|
191
|
+
/**
|
|
192
|
+
* The coin's location in the chain's Merkle tree of coin commitments
|
|
193
|
+
*
|
|
194
|
+
* Bounded to be a non-negative 64-bit integer
|
|
195
|
+
*/
|
|
196
|
+
mt_index: bigint,
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* A key used to index into an array or map in the onchain VM
|
|
201
|
+
*/
|
|
202
|
+
export type Key = { tag: 'value', value: AlignedValue } | { tag: 'stack' };
|
|
203
|
+
/**
|
|
204
|
+
* An individual operation in the onchain VM
|
|
205
|
+
*
|
|
206
|
+
* @typeParam R - `null` or {@link AlignedValue}, for gathering and verifying
|
|
207
|
+
* mode respectively
|
|
208
|
+
*/
|
|
209
|
+
export type Op<R> = { noop: { n: number } } |
|
|
210
|
+
'lt' |
|
|
211
|
+
'eq' |
|
|
212
|
+
'type' |
|
|
213
|
+
'size' |
|
|
214
|
+
'new' |
|
|
215
|
+
'and' |
|
|
216
|
+
'or' |
|
|
217
|
+
'neg' |
|
|
218
|
+
'log' |
|
|
219
|
+
'root' |
|
|
220
|
+
'pop' |
|
|
221
|
+
{ popeq: { cached: boolean, result: R } } |
|
|
222
|
+
{ addi: { immediate: number } } |
|
|
223
|
+
{ subi: { immediate: number } } |
|
|
224
|
+
{ push: { storage: boolean, value: EncodedStateValue } } |
|
|
225
|
+
{ branch: { skip: number } } |
|
|
226
|
+
{ jmp: { skip: number } } |
|
|
227
|
+
'add' |
|
|
228
|
+
'sub' |
|
|
229
|
+
{ concat: { cached: boolean, n: number } } |
|
|
230
|
+
'member' |
|
|
231
|
+
{ rem: { cached: boolean } } |
|
|
232
|
+
{ dup: { n: number } } |
|
|
233
|
+
{ swap: { n: number } } |
|
|
234
|
+
{ idx: { cached: boolean, pushPath: boolean, path: Key[] } } |
|
|
235
|
+
{ ins: { cached: boolean, n: number } } |
|
|
236
|
+
'ckpt';
|
|
237
|
+
/**
|
|
238
|
+
* An individual result of observing the results of a non-verifying VM program
|
|
239
|
+
* execution
|
|
240
|
+
*/
|
|
241
|
+
export type GatherResult = { tag: 'read', content: AlignedValue } |
|
|
242
|
+
{ tag: 'log', content: EncodedStateValue };
|
|
243
|
+
/**
|
|
244
|
+
* An alternative encoding of {@link StateValue} for use in {@link Op} for
|
|
245
|
+
* technical reasons
|
|
246
|
+
*/
|
|
247
|
+
export type EncodedStateValue = { tag: 'null' } |
|
|
248
|
+
{ tag: 'cell', content: AlignedValue } |
|
|
249
|
+
{ tag: 'map', content: Map<AlignedValue, EncodedStateValue> } |
|
|
250
|
+
{ tag: 'array', content: EncodedStateValue[] } |
|
|
251
|
+
{ tag: 'boundedMerkleTree', content: [number, Map<bigint, [Uint8Array, undefined]>] };
|
|
252
|
+
/**
|
|
253
|
+
* A transcript of operations, to be recorded in a transaction
|
|
254
|
+
*/
|
|
255
|
+
export type Transcript<R> = {
|
|
256
|
+
/**
|
|
257
|
+
* The execution budget for this transcript, which {@link program} must not
|
|
258
|
+
* exceed
|
|
259
|
+
*/
|
|
260
|
+
gas: RunningCost,
|
|
261
|
+
/**
|
|
262
|
+
* The effects of the transcript, which are checked before execution, and
|
|
263
|
+
* must match those constructed by {@link program}
|
|
264
|
+
*/
|
|
265
|
+
effects: Effects,
|
|
266
|
+
/**
|
|
267
|
+
* The sequence of operations that this transcript captured
|
|
268
|
+
*/
|
|
269
|
+
program: Op<R>[],
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* A public address that an entity can be identified by
|
|
273
|
+
*/
|
|
274
|
+
export type PublicAddress = { tag: 'user', address: UserAddress } | { tag: 'contract', address: ContractAddress }
|
|
275
|
+
/**
|
|
276
|
+
* The context information of a call provided to the VM.
|
|
277
|
+
*/
|
|
278
|
+
export type CallContext = {
|
|
279
|
+
ownAddress: ContractAddress,
|
|
280
|
+
/**
|
|
281
|
+
* The commitment indices map accessible to the contract.
|
|
282
|
+
*/
|
|
283
|
+
comIndices: Map<CoinCommitment, number>
|
|
284
|
+
/**
|
|
285
|
+
* The seconds since the UNIX epoch that have elapsed
|
|
286
|
+
*/
|
|
287
|
+
secondsSinceEpoch: bigint,
|
|
288
|
+
/**
|
|
289
|
+
* The maximum error on {@link secondsSinceEpoch} that should occur, as a
|
|
290
|
+
* positive seconds value
|
|
291
|
+
*/
|
|
292
|
+
secondsSinceEpochErr: number,
|
|
293
|
+
/**
|
|
294
|
+
* The hash of the block prior to this transaction, as a hex-encoded string
|
|
295
|
+
*/
|
|
296
|
+
parentBlockHash: string,
|
|
297
|
+
/**
|
|
298
|
+
* The balances held by the called contract at the time it was called.
|
|
299
|
+
*/
|
|
300
|
+
balance: Map<TokenType, bigint>,
|
|
301
|
+
/**
|
|
302
|
+
* A public address identifying an entity.
|
|
303
|
+
*/
|
|
304
|
+
caller?: PublicAddress,
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Context information about the block forwarded to {@link CallContext}.
|
|
308
|
+
*/
|
|
309
|
+
export type BlockContext = {
|
|
310
|
+
/**
|
|
311
|
+
* The seconds since the UNIX epoch that have elapsed
|
|
312
|
+
*/
|
|
313
|
+
secondsSinceEpoch: bigint,
|
|
314
|
+
/**
|
|
315
|
+
* The maximum error on {@link secondsSinceEpoch} that should occur, as a
|
|
316
|
+
* positive seconds value
|
|
317
|
+
*/
|
|
318
|
+
secondsSinceEpochErr: number,
|
|
319
|
+
/**
|
|
320
|
+
* The hash of the block prior to this transaction, as a hex-encoded string
|
|
321
|
+
*/
|
|
322
|
+
parentBlockHash: string,
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* The contract-external effects of a transcript.
|
|
326
|
+
*/
|
|
327
|
+
export type Effects = {
|
|
328
|
+
/**
|
|
329
|
+
* The nullifiers (spends) this contract call requires
|
|
330
|
+
*/
|
|
331
|
+
claimedNullifiers: Nullifier[],
|
|
332
|
+
/**
|
|
333
|
+
* The coin commitments (outputs) this contract call requires, as coins
|
|
334
|
+
* received
|
|
335
|
+
*/
|
|
336
|
+
claimedShieldedReceives: CoinCommitment[],
|
|
337
|
+
/**
|
|
338
|
+
* The coin commitments (outputs) this contract call requires, as coins
|
|
339
|
+
* sent
|
|
340
|
+
*/
|
|
341
|
+
claimedShieldedSpends: CoinCommitment[],
|
|
342
|
+
/**
|
|
343
|
+
* The contracts called from this contract. The values are, in order:
|
|
344
|
+
*
|
|
345
|
+
* - The sequence number of this call
|
|
346
|
+
* - The contract being called
|
|
347
|
+
* - The entry point being called
|
|
348
|
+
* - The communications commitment
|
|
349
|
+
*/
|
|
350
|
+
claimedContractCalls: Array<[bigint, ContractAddress, string, Fr]>,
|
|
351
|
+
/**
|
|
352
|
+
* The shielded tokens minted in this call, as a map from hex-encoded 256-bit domain
|
|
353
|
+
* separators to unsigned 64-bit integers.
|
|
354
|
+
*/
|
|
355
|
+
shieldedMints: Map<string, bigint>,
|
|
356
|
+
/**
|
|
357
|
+
* The unshielded tokens minted in this call, as a map from hex-encoded 256-bit domain
|
|
358
|
+
* separators to unsigned 64-bit integers.
|
|
359
|
+
*/
|
|
360
|
+
unshieldedMints: Map<string, bigint>,
|
|
361
|
+
/**
|
|
362
|
+
* The unshielded inputs this contract expects.
|
|
363
|
+
*/
|
|
364
|
+
unshieldedInputs: Map<TokenType, bigint>,
|
|
365
|
+
/**
|
|
366
|
+
* The unshielded outputs this contract authorizes.
|
|
367
|
+
*/
|
|
368
|
+
unshieldedOutputs: Map<TokenType, bigint>,
|
|
369
|
+
/**
|
|
370
|
+
* The unshielded UTXO outputs this contract expects to be present.
|
|
371
|
+
*/
|
|
372
|
+
claimedUnshieldedSpends: Map<[TokenType, PublicAddress], bigint>,
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* A hex-encoded commitment of data shared between two contracts in a call
|
|
377
|
+
*/
|
|
378
|
+
export type CommunicationCommitment = string;
|
|
379
|
+
/**
|
|
380
|
+
* The hex-encoded randomness to {@link CommunicationCommitment}
|
|
381
|
+
*/
|
|
382
|
+
export type CommunicationCommitmentRand = string;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Samples a new {@link CommunicationCommitmentRand} uniformly
|
|
386
|
+
*/
|
|
387
|
+
export function communicationCommitmentRandomness(): CommunicationCommitmentRand;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Computes the communication commitment corresponding to an input/output pair and randomness.
|
|
391
|
+
*/
|
|
392
|
+
export function communicationCommitment(input: AlignedValue, output: AlignedValue, rand: CommunicationCommitmentRand): CommunicationCommitment;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Computes the (hex-encoded) hash of a given contract entry point. Used in
|
|
396
|
+
* composable contracts to reference the called contract's entry point ID
|
|
397
|
+
* in-circuit.
|
|
398
|
+
*/
|
|
399
|
+
export function entryPointHash(entryPoint: string | Uint8Array): string;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Randomly samples a {@link SigningKey}.
|
|
403
|
+
*/
|
|
404
|
+
export function sampleSigningKey(): SigningKey;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Creates a {@link SigningKey} from provided Bip340 private key.
|
|
408
|
+
*/
|
|
409
|
+
export function signingKeyFromBip340(data: Uint8Array): SigningKey;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Signs arbitrary data with the given signing key.
|
|
413
|
+
*
|
|
414
|
+
* WARNING: Do not expose access to this function for valuable keys for data
|
|
415
|
+
* that is not strictly controlled!
|
|
416
|
+
*/
|
|
417
|
+
export function signData(key: SigningKey, data: Uint8Array): Signature;
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Returns the verifying key for a given signing key
|
|
421
|
+
*/
|
|
422
|
+
export function signatureVerifyingKey(sk: SigningKey): SignatureVerifyingKey;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Verifies if a signature is correct
|
|
426
|
+
*/
|
|
427
|
+
export function verifySignature(vk: SignatureVerifyingKey, data: Uint8Array, signature: Signature): boolean;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Encode a raw {@link RawTokenType} into a `Uint8Array` for use in Compact's
|
|
431
|
+
* `RawTokenType` type
|
|
432
|
+
*/
|
|
433
|
+
export function encodeRawTokenType(tt: RawTokenType): Uint8Array;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Decode a raw {@link RawTokenType} from a `Uint8Array` originating from Compact's
|
|
437
|
+
* `RawTokenType` type
|
|
438
|
+
*/
|
|
439
|
+
export function decodeRawTokenType(tt: Uint8Array): RawTokenType;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Encode a {@link ContractAddress} into a `Uint8Array` for use in Compact's
|
|
443
|
+
* `ContractAddress` type
|
|
444
|
+
*/
|
|
445
|
+
export function encodeContractAddress(addr: ContractAddress): Uint8Array;
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Decode a {@link ContractAddress} from a `Uint8Array` originating from
|
|
449
|
+
* Compact's `ContractAddress` type
|
|
450
|
+
*/
|
|
451
|
+
export function decodeContractAddress(addr: Uint8Array): ContractAddress;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Encode a {@link UserAddress} into a `Uint8Array` for use in Compact's
|
|
455
|
+
* `UserAddress` type
|
|
456
|
+
*/
|
|
457
|
+
export function encodeUserAddress(addr: UserAddress): Uint8Array;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Decode a {@link UserAddress} from a `Uint8Array` originating from
|
|
461
|
+
* Compact's `UserAddress` type
|
|
462
|
+
*/
|
|
463
|
+
export function decodeUserAddress(addr: Uint8Array): UserAddress;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Encode a {@link CoinPublicKey} into a `Uint8Array` for use in Compact's
|
|
467
|
+
* `CoinPublicKey` type
|
|
468
|
+
*/
|
|
469
|
+
export function encodeCoinPublicKey(pk: CoinPublicKey): Uint8Array;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Decode a {@link CoinPublicKey} from a `Uint8Array` originating from Compact's
|
|
473
|
+
* `CoinPublicKey` type
|
|
474
|
+
*/
|
|
475
|
+
export function decodeCoinPublicKey(pk: Uint8Array): CoinPublicKey;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Encode a {@link ShieldedCoinInfo} into a Compact's `ShieldedCoinInfo` TypeScript
|
|
479
|
+
* representation
|
|
480
|
+
*/
|
|
481
|
+
export function encodeShieldedCoinInfo(coin: ShieldedCoinInfo): { color: Uint8Array, nonce: Uint8Array, value: bigint };
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Encode a {@link QualifiedShieldedCoinInfo} into a Compact's `QualifiedShieldedCoinInfo`
|
|
485
|
+
* TypeScript representation
|
|
486
|
+
*/
|
|
487
|
+
export function encodeQualifiedShieldedCoinInfo(coin: QualifiedShieldedCoinInfo): {
|
|
488
|
+
color: Uint8Array,
|
|
489
|
+
nonce: Uint8Array,
|
|
490
|
+
value: bigint,
|
|
491
|
+
mt_index: bigint
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Decode a {@link ShieldedCoinInfo} from Compact's `ShieldedCoinInfo` TypeScript representation
|
|
496
|
+
*/
|
|
497
|
+
export function decodeShieldedCoinInfo(coin: { color: Uint8Array, nonce: Uint8Array, value: bigint }): ShieldedCoinInfo;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Decode a {@link QualifiedShieldedCoinInfo} from Compact's `QualifiedShieldedCoinInfo`
|
|
501
|
+
* TypeScript representation
|
|
502
|
+
*/
|
|
503
|
+
export function decodeQualifiedShieldedCoinInfo(coin: {
|
|
504
|
+
color: Uint8Array,
|
|
505
|
+
nonce: Uint8Array,
|
|
506
|
+
value: bigint,
|
|
507
|
+
mt_index: bigint
|
|
508
|
+
}): QualifiedShieldedCoinInfo;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Derives the raw {@link RawTokenType} associated with a particular
|
|
512
|
+
* {@link DomainSeparator} and contract.
|
|
513
|
+
*/
|
|
514
|
+
export function rawTokenType(domain_sep: DomainSeparator, contract: ContractAddress): RawTokenType;
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Samples a uniform contract address, for use in testing
|
|
518
|
+
*/
|
|
519
|
+
export function sampleContractAddress(): ContractAddress;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Samples a uniform user address, for use in testing
|
|
523
|
+
*/
|
|
524
|
+
export function sampleUserAddress(): UserAddress;
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Samples a uniform raw token type, for use in testing to construct
|
|
528
|
+
* both the shielded and unshielded token types.
|
|
529
|
+
*/
|
|
530
|
+
export function sampleRawTokenType(): RawTokenType;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* A sample contract address
|
|
534
|
+
*/
|
|
535
|
+
export function dummyContractAddress(): ContractAddress;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* A sample user address
|
|
539
|
+
*/
|
|
540
|
+
export function dummyUserAddress(): UserAddress;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Internal implementation of the runtime's coin commitment primitive.
|
|
544
|
+
* @internal
|
|
545
|
+
*/
|
|
546
|
+
export function runtimeCoinCommitment(coin: AlignedValue, recipient: AlignedValue): AlignedValue;
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Internal implementation of the runtime's coin nullifier primitive.
|
|
550
|
+
* @internal
|
|
551
|
+
*/
|
|
552
|
+
export function runtimeCoinNullifier(coin: AlignedValue, sender_evidence: AlignedValue): AlignedValue;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Internal implementation of the Merkle tree leaf hash primitive.
|
|
556
|
+
* @internal
|
|
557
|
+
*/
|
|
558
|
+
export function leafHash(value: AlignedValue): AlignedValue;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Internal implementation of the max aligned size primitive.
|
|
562
|
+
* @internal
|
|
563
|
+
*/
|
|
564
|
+
export function maxAlignedSize(alignment: Alignment): bigint;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Returns the maximum representable value in the proof systems scalar field
|
|
568
|
+
* (that is, 1 less than the prime modulus)
|
|
569
|
+
*/
|
|
570
|
+
export function maxField(): bigint;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Converts input, output, and transcript information into a proof preimage
|
|
574
|
+
* suitable to pass to a `ProvingProvider`.
|
|
575
|
+
*
|
|
576
|
+
* The `key_location` parameter is a string used to identify the circuit by
|
|
577
|
+
* proving machinery, for backwards-compatibility, if unset it defaults to
|
|
578
|
+
* `'dummy'`.
|
|
579
|
+
*/
|
|
580
|
+
export function proofDataIntoSerializedPreimage(
|
|
581
|
+
input: AlignedValue,
|
|
582
|
+
output: AlignedValue,
|
|
583
|
+
public_transcript: Op<AlignedValue>[],
|
|
584
|
+
private_transcript_outputs: AlignedValue[],
|
|
585
|
+
key_location?: string,
|
|
586
|
+
): Uint8Array;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Takes a bigint modulus the proof systems scalar field
|
|
590
|
+
*/
|
|
591
|
+
export function bigIntModFr(x: bigint): bigint;
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Internal conversion between field-aligned binary values and bigints within
|
|
595
|
+
* the scalar field
|
|
596
|
+
* @internal
|
|
597
|
+
* @throws If the value does not encode a field element
|
|
598
|
+
*/
|
|
599
|
+
export function valueToBigInt(x: Value): bigint;
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Internal conversion between bigints and their field-aligned binary
|
|
603
|
+
* representation
|
|
604
|
+
* @internal
|
|
605
|
+
*/
|
|
606
|
+
export function bigIntToValue(x: bigint): Value;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Internal implementation of the transient hash primitive
|
|
610
|
+
* @internal
|
|
611
|
+
* @throws If {@link val} does not have alignment {@link align}
|
|
612
|
+
*/
|
|
613
|
+
export function transientHash(align: Alignment, val: Value): Value;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Internal implementation of the transient commitment primitive
|
|
617
|
+
* @internal
|
|
618
|
+
* @throws If {@link val} does not have alignment {@link align}, or
|
|
619
|
+
* {@link opening} does not encode a field element
|
|
620
|
+
*/
|
|
621
|
+
export function transientCommit(align: Alignment, val: Value, opening: Value): Value;
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Internal implementation of the persistent hash primitive
|
|
625
|
+
* @internal
|
|
626
|
+
* @throws If {@link val} does not have alignment {@link align}, or any
|
|
627
|
+
* component has a compress alignment
|
|
628
|
+
*/
|
|
629
|
+
export function persistentHash(align: Alignment, val: Value): Value;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Internal implementation of the persistent commitment primitive
|
|
633
|
+
* @internal
|
|
634
|
+
* @throws If {@link val} does not have alignment {@link align},
|
|
635
|
+
* {@link opening} does not encode a 32-byte bytestring, or any component has a
|
|
636
|
+
* compress alignment
|
|
637
|
+
*/
|
|
638
|
+
export function persistentCommit(align: Alignment, val: Value, opening: Value): Value;
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Internal implementation of the degrade to transient primitive
|
|
642
|
+
* @internal
|
|
643
|
+
* @throws If {@link persistent} does not encode a 32-byte bytestring
|
|
644
|
+
*/
|
|
645
|
+
export function degradeToTransient(persistent: Value): Value;
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Internal implementation of the upgrade from transient primitive
|
|
649
|
+
* @internal
|
|
650
|
+
* @throws If {@link transient} does not encode a field element
|
|
651
|
+
*/
|
|
652
|
+
export function upgradeFromTransient(transient: Value): Value;
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Internal implementation of the hash to curve primitive
|
|
656
|
+
* @internal
|
|
657
|
+
* @throws If {@link val} does not have alignment {@link align}
|
|
658
|
+
*/
|
|
659
|
+
export function hashToCurve(align: Alignment, val: Value): Value;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Internal implementation of the elliptic curve addition primitive
|
|
663
|
+
* @internal
|
|
664
|
+
* @throws If either input does not encode an elliptic curve point
|
|
665
|
+
*/
|
|
666
|
+
export function ecAdd(a: Value, b: Value): Value;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Internal implementation of the elliptic curve multiplication primitive
|
|
670
|
+
* @internal
|
|
671
|
+
* @throws If {@link a} does not encode an elliptic curve point or {@link b}
|
|
672
|
+
* does not encode a field element
|
|
673
|
+
*/
|
|
674
|
+
export function ecMul(a: Value, b: Value): Value;
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Internal implementation of the elliptic curve generator multiplication
|
|
678
|
+
* primitive
|
|
679
|
+
* @internal
|
|
680
|
+
* @throws if {@link val} does not encode a field element
|
|
681
|
+
*/
|
|
682
|
+
export function ecMulGenerator(val: Value): Value;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Runs a VM program against an initial stack, with an optional gas limit
|
|
686
|
+
*/
|
|
687
|
+
export function runProgram(initial: VmStack, ops: Op<null>[], cost_model: CostModel, gas_limit?: RunningCost): VmResults;
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* An individual operation, or entry point of a contract, consisting primarily
|
|
691
|
+
* of a ZK verifier keys, potentially for different versions of the proving
|
|
692
|
+
* system.
|
|
693
|
+
*
|
|
694
|
+
* Only the latest available version is exposed to this API.
|
|
695
|
+
*
|
|
696
|
+
* Note that the serialized form of the key is checked on initialization
|
|
697
|
+
*/
|
|
698
|
+
export class ContractOperation {
|
|
699
|
+
constructor();
|
|
700
|
+
|
|
701
|
+
verifierKey: Uint8Array;
|
|
702
|
+
|
|
703
|
+
serialize(): Uint8Array;
|
|
704
|
+
|
|
705
|
+
static deserialize(raw: Uint8Array): ContractOperation;
|
|
706
|
+
|
|
707
|
+
toString(compact?: boolean): string;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* A committee permitted to make changes to this contract. If a threshold of
|
|
712
|
+
* the public keys in this committee sign off, they can change the rules of
|
|
713
|
+
* this contract, or recompile it for a new version.
|
|
714
|
+
*
|
|
715
|
+
* If the threshold is greater than the number of committee members, it is
|
|
716
|
+
* impossible for them to sign anything.
|
|
717
|
+
*/
|
|
718
|
+
export class ContractMaintenanceAuthority {
|
|
719
|
+
/**
|
|
720
|
+
* Constructs a new authority from its components
|
|
721
|
+
*
|
|
722
|
+
* If not supplied, `counter` will default to `0n`. Values should be
|
|
723
|
+
* non-negative, and at most 2^32 - 1.
|
|
724
|
+
*
|
|
725
|
+
* At deployment, `counter` must be `0n`, and any subsequent update should
|
|
726
|
+
* set counter to exactly one greater than the current value.
|
|
727
|
+
*/
|
|
728
|
+
constructor(committee: Array<SignatureVerifyingKey>, threshold: number, counter?: bigint);
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* The committee public keys
|
|
732
|
+
*/
|
|
733
|
+
readonly committee: Array<SignatureVerifyingKey>;
|
|
734
|
+
/**
|
|
735
|
+
* How many keys must sign rule changes
|
|
736
|
+
*/
|
|
737
|
+
readonly threshold: number;
|
|
738
|
+
/**
|
|
739
|
+
* The replay protection counter
|
|
740
|
+
*/
|
|
741
|
+
readonly counter: bigint;
|
|
742
|
+
|
|
743
|
+
serialize(): Uint8Array;
|
|
744
|
+
|
|
745
|
+
static deserialize(raw: Uint8Array): ContractState;
|
|
746
|
+
|
|
747
|
+
toString(compact?: boolean): string;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* The state of a contract, consisting primarily of the {@link data} accessible
|
|
752
|
+
* directly to the contract, and the map of {@link ContractOperation}s that can
|
|
753
|
+
* be called on it, the keys of which can be accessed with {@link operations},
|
|
754
|
+
* and the individual operations can be read with {@link operation} and written
|
|
755
|
+
* to with {@link setOperation}.
|
|
756
|
+
*/
|
|
757
|
+
export class ContractState {
|
|
758
|
+
/**
|
|
759
|
+
* Creates a blank contract state
|
|
760
|
+
*/
|
|
761
|
+
constructor();
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Return a list of the entry points currently registered on this contract
|
|
765
|
+
*/
|
|
766
|
+
operations(): Array<string | Uint8Array>
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Get the operation at a specific entry point name
|
|
770
|
+
*/
|
|
771
|
+
operation(operation: string | Uint8Array): ContractOperation | undefined;
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Set a specific entry point name to contain a given operation
|
|
775
|
+
*/
|
|
776
|
+
setOperation(operation: string | Uint8Array, value: ContractOperation): void;
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Runs a series of operations against the current state, and returns the
|
|
780
|
+
* results
|
|
781
|
+
*/
|
|
782
|
+
query(query: Op<null>[], cost_model: CostModel): GatherResult[];
|
|
783
|
+
|
|
784
|
+
serialize(): Uint8Array;
|
|
785
|
+
|
|
786
|
+
static deserialize(raw: Uint8Array): ContractState;
|
|
787
|
+
|
|
788
|
+
toString(compact?: boolean): string;
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* The current value of the primary state of the contract
|
|
792
|
+
*/
|
|
793
|
+
data: ChargedState;
|
|
794
|
+
/**
|
|
795
|
+
* The maintenance authority associated with this contract
|
|
796
|
+
*/
|
|
797
|
+
maintenanceAuthority: ContractMaintenanceAuthority;
|
|
798
|
+
/**
|
|
799
|
+
* The public balances held by this contract
|
|
800
|
+
*/
|
|
801
|
+
balance: Map<TokenType, bigint>;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Provides the information needed to fully process a transaction, including
|
|
806
|
+
* information about the rest of the transaction, and the state of the chain at
|
|
807
|
+
* the time of execution.
|
|
808
|
+
*/
|
|
809
|
+
export class QueryContext {
|
|
810
|
+
/**
|
|
811
|
+
* Construct a basic context from a contract's address and current state
|
|
812
|
+
* value
|
|
813
|
+
*/
|
|
814
|
+
constructor(state: ChargedState, address: ContractAddress);
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Register a given coin commitment as being accessible at a specific index,
|
|
818
|
+
* for use when receiving coins in-contract, and needing to record their
|
|
819
|
+
* index to later spend them
|
|
820
|
+
*/
|
|
821
|
+
insertCommitment(comm: CoinCommitment, index: bigint): QueryContext;
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Internal counterpart to {@link insertCommitment}; upgrades an encoded
|
|
825
|
+
* {@link ShieldedCoinInfo} to an encoded {@link QualifiedShieldedCoinInfo} using the
|
|
826
|
+
* inserted commitments
|
|
827
|
+
* @internal
|
|
828
|
+
*/
|
|
829
|
+
qualify(coin: Value): Value | undefined;
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Runs a transcript in verifying mode against the current query context,
|
|
833
|
+
* outputting a new query context, with the {@link state} and {@link effects}
|
|
834
|
+
* from after the execution.
|
|
835
|
+
*/
|
|
836
|
+
runTranscript(transcript: Transcript<AlignedValue>, cost_model: CostModel): QueryContext;
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Runs a sequence of operations in gather mode, returning the results of the
|
|
840
|
+
* gather.
|
|
841
|
+
*/
|
|
842
|
+
query(ops: Op<null>[], cost_model: CostModel, gas_limit?: RunningCost): QueryResults;
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Converts the QueryContext to {@link VmStack}.
|
|
846
|
+
*/
|
|
847
|
+
toVmStack(): VmStack;
|
|
848
|
+
|
|
849
|
+
toString(compact?: boolean): string;
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* The address of the contract
|
|
853
|
+
*/
|
|
854
|
+
readonly address: ContractAddress;
|
|
855
|
+
/**
|
|
856
|
+
* The block-level information accessible to the contract
|
|
857
|
+
*/
|
|
858
|
+
block: CallContext;
|
|
859
|
+
/**
|
|
860
|
+
* The commitment indices map accessible to the contract, primarily via
|
|
861
|
+
* {@link qualify}
|
|
862
|
+
*/
|
|
863
|
+
readonly comIndices: Map<CoinCommitment, bigint>;
|
|
864
|
+
/**
|
|
865
|
+
* The effects that occurred during execution against this context, should
|
|
866
|
+
* match those declared in a {@link Transcript}
|
|
867
|
+
*/
|
|
868
|
+
effects: Effects;
|
|
869
|
+
/**
|
|
870
|
+
* The current contract state retained in the context
|
|
871
|
+
*/
|
|
872
|
+
readonly state: ChargedState;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* A cost model for calculating transaction fees
|
|
877
|
+
*/
|
|
878
|
+
export class CostModel {
|
|
879
|
+
private constructor();
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* The initial cost model of Midnight
|
|
883
|
+
*/
|
|
884
|
+
static initialCostModel(): CostModel;
|
|
885
|
+
|
|
886
|
+
toString(compact?: boolean): string;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* The results of making a query against a specific state or context
|
|
891
|
+
*/
|
|
892
|
+
export class QueryResults {
|
|
893
|
+
private constructor();
|
|
894
|
+
|
|
895
|
+
toString(compact?: boolean): string;
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* The context state after executing the query. This can be used to execute
|
|
899
|
+
* further queries
|
|
900
|
+
*/
|
|
901
|
+
readonly context: QueryContext;
|
|
902
|
+
/**
|
|
903
|
+
* Any events/results that occurred during or from the query
|
|
904
|
+
*/
|
|
905
|
+
readonly events: GatherResult[];
|
|
906
|
+
/**
|
|
907
|
+
* The measured cost of executing the query
|
|
908
|
+
*/
|
|
909
|
+
readonly gasCost: RunningCost;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* Represents a fixed-depth Merkle tree storing hashed data, whose preimages
|
|
914
|
+
* are unknown
|
|
915
|
+
*/
|
|
916
|
+
export class StateBoundedMerkleTree {
|
|
917
|
+
/**
|
|
918
|
+
* Create a blank tree with the given height
|
|
919
|
+
*/
|
|
920
|
+
constructor(height: number);
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Internal implementation of the merkle tree root primitive.
|
|
924
|
+
* Returns undefined if the tree has not been fully hashed.
|
|
925
|
+
* @internal
|
|
926
|
+
*/
|
|
927
|
+
root(): AlignedValue | undefined;
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* Internal implementation of the finding path primitive.
|
|
931
|
+
* Returns undefined if the leaf is not in the tree.
|
|
932
|
+
* @internal
|
|
933
|
+
*/
|
|
934
|
+
findPathForLeaf(leaf: AlignedValue): AlignedValue | undefined;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Internal implementation of the path construction primitive
|
|
938
|
+
* @internal
|
|
939
|
+
* @throws If the index is out-of-bounds for the tree
|
|
940
|
+
*/
|
|
941
|
+
pathForLeaf(index: bigint, leaf: AlignedValue): AlignedValue;
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* Inserts a value into the Merkle tree, returning the updated tree
|
|
945
|
+
* @throws If the index is out-of-bounds for the tree
|
|
946
|
+
*/
|
|
947
|
+
update(index: bigint, leaf: AlignedValue): StateBoundedMerkleTree;
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Rehashes the tree, updating all internal hashes and ensuring all
|
|
951
|
+
* node hashes are present. Necessary because the onchain runtime does
|
|
952
|
+
* not automatically rehash trees.
|
|
953
|
+
*/
|
|
954
|
+
rehash(): StateBoundedMerkleTree;
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Erases all but necessary hashes between, and inclusive of, `start` and
|
|
958
|
+
* `end` inidices @internal
|
|
959
|
+
* @throws If the indices are out-of-bounds for the tree, or `end < start`
|
|
960
|
+
*/
|
|
961
|
+
collapse(start: bigint, end: bigint): StateBoundedMerkleTree;
|
|
962
|
+
|
|
963
|
+
toString(compact?: boolean): string;
|
|
964
|
+
|
|
965
|
+
readonly height: number;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Represents a key-value map, where keys are {@link AlignedValue}s, and values
|
|
970
|
+
* are {@link StateValue}s.
|
|
971
|
+
*/
|
|
972
|
+
export class StateMap {
|
|
973
|
+
constructor();
|
|
974
|
+
|
|
975
|
+
keys(): AlignedValue[];
|
|
976
|
+
|
|
977
|
+
get(key: AlignedValue): StateValue | undefined;
|
|
978
|
+
|
|
979
|
+
insert(key: AlignedValue, value: StateValue): StateMap;
|
|
980
|
+
|
|
981
|
+
remove(key: AlignedValue): StateMap;
|
|
982
|
+
|
|
983
|
+
toString(compact?: boolean): string;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Represents a {@link StateValue} with storage annotations.
|
|
988
|
+
*
|
|
989
|
+
* These track the state usage that has been charged for so far.
|
|
990
|
+
*/
|
|
991
|
+
export class ChargedState {
|
|
992
|
+
constructor(state: StateValue);
|
|
993
|
+
readonly state: StateValue;
|
|
994
|
+
toString(compact?: boolean): string;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* Represents the core of a contract's state, and recursively represents each
|
|
999
|
+
* of its components.
|
|
1000
|
+
*
|
|
1001
|
+
* There are different *classes* of state values:
|
|
1002
|
+
* - `null`
|
|
1003
|
+
* - Cells of {@link AlignedValue}s
|
|
1004
|
+
* - Maps from {@link AlignedValue}s to state values
|
|
1005
|
+
* - Bounded Merkle trees containing {@link AlignedValue} leaves
|
|
1006
|
+
* - Short (\<= 15 element) arrays of state values
|
|
1007
|
+
*
|
|
1008
|
+
* State values are *immutable*, any operations that mutate states will return
|
|
1009
|
+
* a new state instead.
|
|
1010
|
+
*/
|
|
1011
|
+
export class StateValue {
|
|
1012
|
+
private constructor();
|
|
1013
|
+
|
|
1014
|
+
type(): 'null' | 'cell' | 'map' | 'array' | 'boundedMerkleTree';
|
|
1015
|
+
|
|
1016
|
+
static newNull(): StateValue;
|
|
1017
|
+
|
|
1018
|
+
static newCell(value: AlignedValue): StateValue;
|
|
1019
|
+
|
|
1020
|
+
static newMap(map: StateMap): StateValue;
|
|
1021
|
+
|
|
1022
|
+
static newBoundedMerkleTree(tree: StateBoundedMerkleTree): StateValue;
|
|
1023
|
+
|
|
1024
|
+
static newArray(): StateValue;
|
|
1025
|
+
|
|
1026
|
+
arrayPush(value: StateValue): StateValue;
|
|
1027
|
+
|
|
1028
|
+
asCell(): AlignedValue;
|
|
1029
|
+
|
|
1030
|
+
asMap(): StateMap | undefined;
|
|
1031
|
+
|
|
1032
|
+
asBoundedMerkleTree(): StateBoundedMerkleTree | undefined;
|
|
1033
|
+
|
|
1034
|
+
asArray(): StateValue[] | undefined;
|
|
1035
|
+
|
|
1036
|
+
logSize(): number;
|
|
1037
|
+
|
|
1038
|
+
toString(compact?: boolean): string;
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* @internal
|
|
1042
|
+
*/
|
|
1043
|
+
encode(): EncodedStateValue;
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* @internal
|
|
1047
|
+
*/
|
|
1048
|
+
static decode(value: EncodedStateValue): StateValue;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* Represents the results of a VM call
|
|
1053
|
+
*/
|
|
1054
|
+
export class VmResults {
|
|
1055
|
+
private constructor();
|
|
1056
|
+
|
|
1057
|
+
toString(compact?: boolean): string;
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* The events that got emitted by this VM invocation
|
|
1061
|
+
*/
|
|
1062
|
+
readonly events: GatherResult[];
|
|
1063
|
+
/**
|
|
1064
|
+
* The computed gas cost of running this VM invocation
|
|
1065
|
+
*/
|
|
1066
|
+
readonly gasCost: RunningCost;
|
|
1067
|
+
/**
|
|
1068
|
+
* The VM stack at the end of the VM invocation
|
|
1069
|
+
*/
|
|
1070
|
+
readonly stack: VmStack;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
/**
|
|
1074
|
+
* Represents the state of the VM's stack at a specific point. The stack is an
|
|
1075
|
+
* array of {@link StateValue}s, each of which is also annotated with whether
|
|
1076
|
+
* it is "strong" or "weak"; that is, whether it is permitted to be stored
|
|
1077
|
+
* on-chain or not.
|
|
1078
|
+
*/
|
|
1079
|
+
export class VmStack {
|
|
1080
|
+
constructor();
|
|
1081
|
+
|
|
1082
|
+
push(value: StateValue, is_strong: boolean): void;
|
|
1083
|
+
|
|
1084
|
+
removeLast(): void;
|
|
1085
|
+
|
|
1086
|
+
length(): number;
|
|
1087
|
+
|
|
1088
|
+
get(idx: number): StateValue | undefined;
|
|
1089
|
+
|
|
1090
|
+
isStrong(idx: number): boolean | undefined;
|
|
1091
|
+
|
|
1092
|
+
toString(compact?: boolean): string;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* A zero-knowledge proof.
|
|
1098
|
+
*/
|
|
1099
|
+
export class Proof {
|
|
1100
|
+
constructor(data: String);
|
|
1101
|
+
serialize(): Uint8Array;
|
|
1102
|
+
static deserialize(raw: Uint8Array): Proof;
|
|
1103
|
+
toString(compact?: boolean): string;
|
|
1104
|
+
instance: 'proof';
|
|
1105
|
+
private type_: 'proof';
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* The preimage, or data required to produce, a {@link Proof}.
|
|
1110
|
+
*/
|
|
1111
|
+
export class PreProof {
|
|
1112
|
+
constructor(data: String);
|
|
1113
|
+
serialize(): Uint8Array;
|
|
1114
|
+
static deserialize(raw: Uint8Array): PreProof;
|
|
1115
|
+
toString(compact?: boolean): string;
|
|
1116
|
+
instance: 'pre-proof';
|
|
1117
|
+
private type_: 'pre-proof';
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* A unit type used to indicate the absence of proofs.
|
|
1122
|
+
*/
|
|
1123
|
+
export class NoProof {
|
|
1124
|
+
constructor();
|
|
1125
|
+
toString(compact?: boolean): string;
|
|
1126
|
+
instance: 'no-proof';
|
|
1127
|
+
private type_: 'no-proof';
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* How proofs are currently being represented, between:
|
|
1132
|
+
* - Actual zero-knowledge proofs, as should be transmitted to the network
|
|
1133
|
+
* - The data required to *produce* proofs, for constructing and preparing
|
|
1134
|
+
* transactions.
|
|
1135
|
+
* - Proofs not being provided, largely for testing use or replaying already
|
|
1136
|
+
* validated transactions.
|
|
1137
|
+
*/
|
|
1138
|
+
export type Proofish = Proof | PreProof | NoProof;
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* A Fiat-Shamir proof of exponent binding (or ephemerally signing) an
|
|
1142
|
+
* {@link Intent}.
|
|
1143
|
+
*/
|
|
1144
|
+
export class Binding {
|
|
1145
|
+
constructor(data: String);
|
|
1146
|
+
serialize(): Uint8Array;
|
|
1147
|
+
static deserialize(raw: Uint8Array): Binding;
|
|
1148
|
+
toString(compact?: boolean): string;
|
|
1149
|
+
instance: 'binding';
|
|
1150
|
+
private type_: 'binding';
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* Information that will be used to bind an {@link Intent} in the future, but
|
|
1155
|
+
* does not yet prevent modification of it.
|
|
1156
|
+
*/
|
|
1157
|
+
export class PreBinding {
|
|
1158
|
+
constructor(data: String);
|
|
1159
|
+
serialize(): Uint8Array;
|
|
1160
|
+
static deserialize(raw: Uint8Array): PreBinding;
|
|
1161
|
+
toString(compact?: boolean): string;
|
|
1162
|
+
instance: 'pre-binding';
|
|
1163
|
+
private type_: 'pre-binding';
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
export class NoBinding {
|
|
1167
|
+
constructor(data: String);
|
|
1168
|
+
serialize(): Uint8Array;
|
|
1169
|
+
static deserialize(raw: Uint8Array): NoBinding;
|
|
1170
|
+
toString(compact?: boolean): string;
|
|
1171
|
+
instance: 'no-binding';
|
|
1172
|
+
private type_: 'no-binding';
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* Whether an intent has binding cryptography applied or not. An intent's
|
|
1177
|
+
* content can no longer be modified after it is {@link Binding}.
|
|
1178
|
+
*/
|
|
1179
|
+
export type Bindingish = Binding | PreBinding | NoBinding;
|
|
1180
|
+
|
|
1181
|
+
export class SignatureEnabled {
|
|
1182
|
+
constructor(data: Signature);
|
|
1183
|
+
serialize(): Uint8Array;
|
|
1184
|
+
static deserialize(raw: Uint8Array): SignatureEnabled;
|
|
1185
|
+
toString(compact?: boolean): string;
|
|
1186
|
+
readonly instance: 'signature';
|
|
1187
|
+
private type_: 'signature';
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
export class SignatureErased {
|
|
1191
|
+
constructor();
|
|
1192
|
+
toString(compact?: boolean): string;
|
|
1193
|
+
readonly instance: 'signature-erased';
|
|
1194
|
+
private type_: 'signature-erased';
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
export type Signaturish = SignatureEnabled | SignatureErased;
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* A type representing a transaction that has not been proven yet
|
|
1201
|
+
*/
|
|
1202
|
+
export type UnprovenInput = ZswapInput<PreProof>;
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* A type representing a transaction output that has not been proven yet.
|
|
1206
|
+
*/
|
|
1207
|
+
export type UnprovenOutput = ZswapOutput<PreProof>;
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* A type representing a transaction transient that has not been proven yet.
|
|
1211
|
+
*/
|
|
1212
|
+
export type UnprovenTransient = ZswapTransient<PreProof>;
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* A type representing an offer that has not been proven yet.
|
|
1216
|
+
*/
|
|
1217
|
+
export type UnprovenOffer = ZswapOffer<PreProof>;
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* A type representing an intent that has not been proven yet.
|
|
1221
|
+
*/
|
|
1222
|
+
export type UnprovenIntent = Intent<SignatureEnabled, PreProof, PreBinding>;
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* An interactions with a contract
|
|
1226
|
+
*/
|
|
1227
|
+
export type ContractAction<P extends Proofish> = ContractCall<P> | ContractDeploy | MaintenanceUpdate;
|
|
1228
|
+
|
|
1229
|
+
/**
|
|
1230
|
+
* Strictness criteria for evaluating transaction well-formedness, used for
|
|
1231
|
+
* disabling parts of transaction validation for testing.
|
|
1232
|
+
*/
|
|
1233
|
+
export class WellFormedStrictness {
|
|
1234
|
+
constructor();
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* Whether to require the transaction to have a non-negative balance
|
|
1238
|
+
*/
|
|
1239
|
+
enforceBalancing: boolean;
|
|
1240
|
+
/**
|
|
1241
|
+
* Whether to validate Midnight-native (non-contract) proofs in the transaction
|
|
1242
|
+
*/
|
|
1243
|
+
verifyNativeProofs: boolean;
|
|
1244
|
+
/**
|
|
1245
|
+
* Whether to validate contract proofs in the transaction
|
|
1246
|
+
*/
|
|
1247
|
+
verifyContractProofs: boolean;
|
|
1248
|
+
/**
|
|
1249
|
+
* Whether to enforce the transaction byte limit
|
|
1250
|
+
*/
|
|
1251
|
+
enforceLimits: boolean;
|
|
1252
|
+
/**
|
|
1253
|
+
* Whether to enforce the signature verification
|
|
1254
|
+
*/
|
|
1255
|
+
verifySignatures: boolean;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Contains the raw file contents required for proving
|
|
1260
|
+
*/
|
|
1261
|
+
export type ProvingKeyMaterial = {
|
|
1262
|
+
proverKey: Uint8Array,
|
|
1263
|
+
verifierKey: Uint8Array,
|
|
1264
|
+
ir: Uint8Array,
|
|
1265
|
+
};
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* A modelled cost of a transaction or block.
|
|
1269
|
+
*/
|
|
1270
|
+
export type SyntheticCost = {
|
|
1271
|
+
/**
|
|
1272
|
+
* The amount of (modelled) time spent reading from disk, measured in picoseconds.
|
|
1273
|
+
*/
|
|
1274
|
+
readTime: bigint,
|
|
1275
|
+
/**
|
|
1276
|
+
* The amount of (modelled) time spent in single-threaded compute, measured in picoseconds.
|
|
1277
|
+
*/
|
|
1278
|
+
computeTime: bigint,
|
|
1279
|
+
/**
|
|
1280
|
+
* The number of bytes of blockspace used
|
|
1281
|
+
*/
|
|
1282
|
+
blockUsage: bigint,
|
|
1283
|
+
/**
|
|
1284
|
+
* The net number of (modelled) bytes written, i.e. max(0, absolute written bytes less deleted bytes).
|
|
1285
|
+
*/
|
|
1286
|
+
bytesWritten: bigint,
|
|
1287
|
+
/**
|
|
1288
|
+
* The number of (modelled) bytes written temporarily or overwritten.
|
|
1289
|
+
*/
|
|
1290
|
+
bytesChurned: bigint,
|
|
1291
|
+
};
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* A normalized form of {@link SyntheticCost}.
|
|
1295
|
+
*/
|
|
1296
|
+
export type NormalizedCost = {
|
|
1297
|
+
/**
|
|
1298
|
+
* The amount of (modelled) time spent reading from disk, measured in picoseconds.
|
|
1299
|
+
*/
|
|
1300
|
+
readTime: number,
|
|
1301
|
+
/**
|
|
1302
|
+
* The amount of (modelled) time spent in single-threaded compute, measured in picoseconds.
|
|
1303
|
+
*/
|
|
1304
|
+
computeTime: number,
|
|
1305
|
+
/**
|
|
1306
|
+
* The number of bytes of blockspace used
|
|
1307
|
+
*/
|
|
1308
|
+
blockUsage: number,
|
|
1309
|
+
/**
|
|
1310
|
+
* The net number of (modelled) bytes written, i.e. max(0, absolute written bytes less deleted bytes).
|
|
1311
|
+
*/
|
|
1312
|
+
bytesWritten: number,
|
|
1313
|
+
/**
|
|
1314
|
+
* The number of (modelled) bytes written temporarily or overwritten.
|
|
1315
|
+
*/
|
|
1316
|
+
bytesChurned: number,
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* An event emitted by the ledger
|
|
1321
|
+
*/
|
|
1322
|
+
export class Event {
|
|
1323
|
+
private constructor();
|
|
1324
|
+
serialize(): Uint8Array;
|
|
1325
|
+
static deserialize(raw: Uint8Array): Event;
|
|
1326
|
+
toString(compact?: boolean): string;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
/**
|
|
1330
|
+
* A secret key for the Dust, used to derive Dust UTxO nonces and prove credentials to spend Dust UTxOs
|
|
1331
|
+
*/
|
|
1332
|
+
export class DustSecretKey {
|
|
1333
|
+
private constructor();
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
* Temporary method to create an instance of {@link DustSecretKey} from a bigint (its natural representation)
|
|
1337
|
+
* @param bigint
|
|
1338
|
+
*/
|
|
1339
|
+
static fromBigint(bigint: bigint): DustSecretKey;
|
|
1340
|
+
|
|
1341
|
+
/**
|
|
1342
|
+
* Create an instance of {@link DustSecretKey} from a seed.
|
|
1343
|
+
* @param seed
|
|
1344
|
+
*/
|
|
1345
|
+
static fromSeed(seed: Uint8Array): DustSecretKey;
|
|
1346
|
+
|
|
1347
|
+
publicKey: DustPublicKey;
|
|
1348
|
+
|
|
1349
|
+
/**
|
|
1350
|
+
* Clears the dust secret key, so that it is no longer usable nor held in memory
|
|
1351
|
+
*/
|
|
1352
|
+
clear(): void;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
// TODO: Doc comments
|
|
1356
|
+
export type DustPublicKey = bigint;
|
|
1357
|
+
export type DustInitialNonce = string;
|
|
1358
|
+
export type DustNonce = bigint;
|
|
1359
|
+
export type DustCommitment = bigint;
|
|
1360
|
+
export type DustNullifier = bigint;
|
|
1361
|
+
|
|
1362
|
+
export function sampleDustSecretKey(): DustSecretKey;
|
|
1363
|
+
|
|
1364
|
+
export function updatedValue(ctime: Date, initialValue: bigint, genInfo: DustGenerationInfo, now: Date, params: DustParameters): bigint;
|
|
1365
|
+
|
|
1366
|
+
export type DustOutput = {
|
|
1367
|
+
initialValue: bigint,
|
|
1368
|
+
owner: DustPublicKey,
|
|
1369
|
+
nonce: DustNonce,
|
|
1370
|
+
seq: number,
|
|
1371
|
+
ctime: Date,
|
|
1372
|
+
backingNight: DustInitialNonce,
|
|
1373
|
+
};
|
|
1374
|
+
|
|
1375
|
+
export type QualifiedDustOutput = {
|
|
1376
|
+
initialValue: bigint,
|
|
1377
|
+
owner: DustPublicKey,
|
|
1378
|
+
nonce: DustNonce,
|
|
1379
|
+
seq: number,
|
|
1380
|
+
ctime: Date,
|
|
1381
|
+
backingNight: DustInitialNonce,
|
|
1382
|
+
mtIndex: bigint,
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
export type DustGenerationInfo = {
|
|
1386
|
+
value: bigint,
|
|
1387
|
+
owner: DustPublicKey,
|
|
1388
|
+
nonce: DustInitialNonce,
|
|
1389
|
+
dtime: Date | undefined,
|
|
1390
|
+
};
|
|
1391
|
+
|
|
1392
|
+
export type DustGenerationUniquenessInfo = {
|
|
1393
|
+
value: bigint,
|
|
1394
|
+
owner: DustPublicKey,
|
|
1395
|
+
nonce: DustInitialNonce,
|
|
1396
|
+
};
|
|
1397
|
+
|
|
1398
|
+
export class DustSpend<P extends Proofish> {
|
|
1399
|
+
private constructor();
|
|
1400
|
+
serialize(): Uint8Array;
|
|
1401
|
+
static deserialize<P extends Proofish>(markerP: P['instance'], raw: Uint8Array): DustSpend<P>;
|
|
1402
|
+
toString(compact?: boolean): string;
|
|
1403
|
+
readonly vFee: bigint;
|
|
1404
|
+
readonly oldNullifier: DustNullifier;
|
|
1405
|
+
readonly newCommitment: DustCommitment;
|
|
1406
|
+
readonly proof: P;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
export class DustRegistration<S extends Signaturish> {
|
|
1410
|
+
constructor(markerS: S['instance'], nightKey: SignatureVerifyingKey, dustAddress: DustPublicKey | undefined, allowFeePayment: bigint, signature?: S);
|
|
1411
|
+
serialize(): Uint8Array;
|
|
1412
|
+
static deserialize<S extends Signaturish>(markerS: S['instance'], raw: Uint8Array): DustRegistration<S>;
|
|
1413
|
+
toString(compact?: boolean): string;
|
|
1414
|
+
nightKey: SignatureVerifyingKey;
|
|
1415
|
+
dustAddress: DustPublicKey | undefined;
|
|
1416
|
+
allowFeePayment: bigint;
|
|
1417
|
+
signature: S;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
export class DustActions<S extends Signaturish, P extends Proofish> {
|
|
1421
|
+
constructor(markerS: S['instance'], markerP: P['instance'], ctime: Date, spends?: DustSpend<P>[], registrations?: DustRegistration<S>[]);
|
|
1422
|
+
serialize(): Uint8Array;
|
|
1423
|
+
static deserialize<S extends Signaturish, P extends Proofish>(markerS: S['instance'], markerP: P['instance'], raw: Uint8Array): DustActions<S, P>;
|
|
1424
|
+
toString(compact?: boolean): string;
|
|
1425
|
+
spends: DustSpend<P>[];
|
|
1426
|
+
registrations: DustRegistration<S>[];
|
|
1427
|
+
ctime: Date;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
export class DustParameters {
|
|
1431
|
+
constructor(nightDustRatio: bigint, generationDecayRate: bigint, dustGracePeriodSeconds: bigint);
|
|
1432
|
+
serialize(): Uint8Array;
|
|
1433
|
+
static deserialize(raw: Uint8Array): DustParameters;
|
|
1434
|
+
toString(compact?: boolean): string;
|
|
1435
|
+
nightDustRatio: bigint;
|
|
1436
|
+
generationDecayRate: bigint;
|
|
1437
|
+
dustGracePeriodSeconds: bigint;
|
|
1438
|
+
readonly timeToCapSeconds: bigint;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
export class DustUtxoState {
|
|
1442
|
+
constructor();
|
|
1443
|
+
serialize(): Uint8Array;
|
|
1444
|
+
static deserialize(raw: Uint8Array): DustUtxoState;
|
|
1445
|
+
toString(compact?: boolean): string;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
export class DustGenerationState {
|
|
1449
|
+
constructor();
|
|
1450
|
+
serialize(): Uint8Array;
|
|
1451
|
+
static deserialize(raw: Uint8Array): DustGenerationState;
|
|
1452
|
+
toString(compact?: boolean): string;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
export class DustState {
|
|
1456
|
+
constructor();
|
|
1457
|
+
serialize(): Uint8Array;
|
|
1458
|
+
static deserialize(raw: Uint8Array): DustState;
|
|
1459
|
+
toString(compact?: boolean): string;
|
|
1460
|
+
readonly utxo: DustUtxoState;
|
|
1461
|
+
readonly generation: DustGenerationState;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
export class DustLocalState {
|
|
1465
|
+
constructor(params: DustParameters);
|
|
1466
|
+
walletBalance(time: Date): bigint;
|
|
1467
|
+
generationInfo(qdo: QualifiedDustOutput): DustGenerationInfo | undefined;
|
|
1468
|
+
spend(sk: DustSecretKey, utxo: QualifiedDustOutput, vFee: bigint, ctime: Date): [DustLocalState, DustSpend<PreProof>];
|
|
1469
|
+
processTtls(time: Date): DustLocalState;
|
|
1470
|
+
replayEvents(sk: DustSecretKey, events: Event[]): DustLocalState;
|
|
1471
|
+
serialize(): Uint8Array;
|
|
1472
|
+
static deserialize(raw: Uint8Array): DustLocalState;
|
|
1473
|
+
toString(compact?: boolean): string;
|
|
1474
|
+
readonly utxos: QualifiedDustOutput[];
|
|
1475
|
+
readonly params: DustParameters;
|
|
1476
|
+
readonly syncTime: Date;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* Creates a payload for proving a specific transaction through the proof server
|
|
1481
|
+
* @deprecated Use `Transaction.prove` instead.
|
|
1482
|
+
*/
|
|
1483
|
+
export function createProvingTransactionPayload(
|
|
1484
|
+
transaction: UnprovenTransaction,
|
|
1485
|
+
proving_data: Map<string, ProvingKeyMaterial>,
|
|
1486
|
+
): Uint8Array;
|
|
1487
|
+
|
|
1488
|
+
/**
|
|
1489
|
+
* Creates a payload for proving a specific proof through the proof server
|
|
1490
|
+
*/
|
|
1491
|
+
export function createProvingPayload(
|
|
1492
|
+
serializedPreimage: Uint8Array,
|
|
1493
|
+
overwriteBindingInput: bigint | undefined,
|
|
1494
|
+
keyMaterial?: ProvingKeyMaterial,
|
|
1495
|
+
): Uint8Array;
|
|
1496
|
+
|
|
1497
|
+
/**
|
|
1498
|
+
* Creates a payload for checking a specific proof through the proof server
|
|
1499
|
+
*/
|
|
1500
|
+
export function createCheckPayload(
|
|
1501
|
+
serializedPreimage: Uint8Array,
|
|
1502
|
+
ir?: Uint8Array,
|
|
1503
|
+
): Uint8Array;
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* Parses the result of a proof-server check call
|
|
1507
|
+
*/
|
|
1508
|
+
export function parseCheckResult(result: Uint8Array): (bigint | undefined)[]
|
|
1509
|
+
|
|
1510
|
+
/**
|
|
1511
|
+
* The state of the Midnight ledger
|
|
1512
|
+
*/
|
|
1513
|
+
export class LedgerState {
|
|
1514
|
+
/**
|
|
1515
|
+
* Intializes from a Zswap state, with an empty contract set
|
|
1516
|
+
*/
|
|
1517
|
+
constructor(network_id: string, zswap: ZswapChainState);
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* A fully blank state
|
|
1521
|
+
*/
|
|
1522
|
+
static blank(network_id: string): LedgerState;
|
|
1523
|
+
|
|
1524
|
+
/**
|
|
1525
|
+
* Applies a {@link Transaction}
|
|
1526
|
+
*/
|
|
1527
|
+
apply(
|
|
1528
|
+
transaction: VerifiedTransaction,
|
|
1529
|
+
context: TransactionContext
|
|
1530
|
+
): [LedgerState, TransactionResult];
|
|
1531
|
+
|
|
1532
|
+
/**
|
|
1533
|
+
* Applies a system transaction to this ledger state.
|
|
1534
|
+
*/
|
|
1535
|
+
applySystemTx(transaction: SystemTransaction, tblock: Date): [LedgerState, Event[]];
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* Indexes into the contract state map with a given contract address
|
|
1539
|
+
*/
|
|
1540
|
+
index(address: ContractAddress): ContractState | undefined;
|
|
1541
|
+
|
|
1542
|
+
/**
|
|
1543
|
+
* Sets the state of a given contract address from a {@link ChargedState}
|
|
1544
|
+
*/
|
|
1545
|
+
updateIndex(address: ContractAddress, state: ChargedState, balance: Map<TokenType, bigint>): LedgerState;
|
|
1546
|
+
|
|
1547
|
+
serialize(): Uint8Array;
|
|
1548
|
+
|
|
1549
|
+
static deserialize(raw: Uint8Array): LedgerState;
|
|
1550
|
+
|
|
1551
|
+
toString(compact?: boolean): string;
|
|
1552
|
+
|
|
1553
|
+
/**
|
|
1554
|
+
* Carries out a post-block update, which does amortized bookkeeping that
|
|
1555
|
+
* only needs to be done once per state change.
|
|
1556
|
+
*
|
|
1557
|
+
* Typically, `postBlockUpdate` should be run after any (sequence of)
|
|
1558
|
+
* (system)-transaction application(s).
|
|
1559
|
+
*/
|
|
1560
|
+
postBlockUpdate(tblock: Date, detailedBlockFullness?: NormalizedCost, overallBlockFullness?: number): LedgerState;
|
|
1561
|
+
|
|
1562
|
+
/**
|
|
1563
|
+
* Retrieves the balance of the treasury for a specific token type.
|
|
1564
|
+
*/
|
|
1565
|
+
treasuryBalance(token_type: TokenType): bigint;
|
|
1566
|
+
|
|
1567
|
+
/**
|
|
1568
|
+
* How much in block rewards a recipient is owed and can claim.
|
|
1569
|
+
*/
|
|
1570
|
+
unclaimedBlockRewards(recipient: UserAddress): bigint;
|
|
1571
|
+
|
|
1572
|
+
/**
|
|
1573
|
+
* How much in bridged night a recipient is owed and can claim.
|
|
1574
|
+
*/
|
|
1575
|
+
bridgeReceiving(recipient: UserAddress): bigint;
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* Allows distributing the specified amount of Night to the recipient's address.
|
|
1579
|
+
* Use is for testing purposes only.
|
|
1580
|
+
*/
|
|
1581
|
+
testingDistributeNight(recipient: UserAddress, amount: bigint, tblock: Date): LedgerState;
|
|
1582
|
+
|
|
1583
|
+
/**
|
|
1584
|
+
* The remaining size of the locked Night pool.
|
|
1585
|
+
*/
|
|
1586
|
+
readonly lockedPool: bigint;
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* The size of the reserve Night pool
|
|
1590
|
+
*/
|
|
1591
|
+
readonly reservePool: bigint;
|
|
1592
|
+
|
|
1593
|
+
/**
|
|
1594
|
+
* How much in bridged night a recipient is owed and can claim.
|
|
1595
|
+
*/
|
|
1596
|
+
bridgeReceiving(recipient: UserAddress): bigint;
|
|
1597
|
+
|
|
1598
|
+
/**
|
|
1599
|
+
* The remaining unrewarded supply of native tokens.
|
|
1600
|
+
*/
|
|
1601
|
+
readonly blockRewardPool: bigint;
|
|
1602
|
+
/**
|
|
1603
|
+
* The Zswap part of the ledger state
|
|
1604
|
+
*/
|
|
1605
|
+
readonly zswap: ZswapChainState;
|
|
1606
|
+
/**
|
|
1607
|
+
* The unshielded utxos present
|
|
1608
|
+
*/
|
|
1609
|
+
readonly utxo: UtxoState;
|
|
1610
|
+
/**
|
|
1611
|
+
* The dust subsystem state
|
|
1612
|
+
*/
|
|
1613
|
+
readonly dust: DustState;
|
|
1614
|
+
/**
|
|
1615
|
+
* The parameters of the ledger
|
|
1616
|
+
*/
|
|
1617
|
+
parameters: LedgerParameters;
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
/**
|
|
1621
|
+
* An unspent transaction output
|
|
1622
|
+
*/
|
|
1623
|
+
export type Utxo = {
|
|
1624
|
+
/**
|
|
1625
|
+
* The amount of tokens this UTXO represents
|
|
1626
|
+
*/
|
|
1627
|
+
value: bigint,
|
|
1628
|
+
/**
|
|
1629
|
+
* The address owning these tokens.
|
|
1630
|
+
*/
|
|
1631
|
+
owner: UserAddress,
|
|
1632
|
+
/**
|
|
1633
|
+
* The token type of this UTXO
|
|
1634
|
+
*/
|
|
1635
|
+
type: RawTokenType,
|
|
1636
|
+
/**
|
|
1637
|
+
* The hash of the intent outputting this UTXO
|
|
1638
|
+
*/
|
|
1639
|
+
intentHash: IntentHash,
|
|
1640
|
+
/**
|
|
1641
|
+
* The output number of this UTXO in its parent {@link Intent}.
|
|
1642
|
+
*/
|
|
1643
|
+
outputNo: number,
|
|
1644
|
+
};
|
|
1645
|
+
|
|
1646
|
+
/**
|
|
1647
|
+
* An output appearing in an {@link Intent}.
|
|
1648
|
+
*/
|
|
1649
|
+
export type UtxoOutput = {
|
|
1650
|
+
/**
|
|
1651
|
+
* The amount of tokens this UTXO represents
|
|
1652
|
+
*/
|
|
1653
|
+
value: bigint,
|
|
1654
|
+
/**
|
|
1655
|
+
* The address owning these tokens.
|
|
1656
|
+
*/
|
|
1657
|
+
owner: UserAddress,
|
|
1658
|
+
/**
|
|
1659
|
+
* The token type of this UTXO
|
|
1660
|
+
*/
|
|
1661
|
+
type: RawTokenType,
|
|
1662
|
+
};
|
|
1663
|
+
|
|
1664
|
+
/**
|
|
1665
|
+
* Converts a bare signature public key to its corresponding address.
|
|
1666
|
+
*/
|
|
1667
|
+
export function addressFromKey(key: SignatureVerifyingKey): UserAddress;
|
|
1668
|
+
|
|
1669
|
+
/**
|
|
1670
|
+
* An input appearing in an {@link Intent}, or a user's local book-keeping.
|
|
1671
|
+
*/
|
|
1672
|
+
export type UtxoSpend = {
|
|
1673
|
+
/**
|
|
1674
|
+
* The amount of tokens this UTXO represents
|
|
1675
|
+
*/
|
|
1676
|
+
value: bigint,
|
|
1677
|
+
/**
|
|
1678
|
+
* The signing key owning these tokens.
|
|
1679
|
+
*/
|
|
1680
|
+
owner: SignatureVerifyingKey,
|
|
1681
|
+
/**
|
|
1682
|
+
* The token type of this UTXO
|
|
1683
|
+
*/
|
|
1684
|
+
type: RawTokenType,
|
|
1685
|
+
/**
|
|
1686
|
+
* The hash of the intent outputting this UTXO
|
|
1687
|
+
*/
|
|
1688
|
+
intentHash: IntentHash,
|
|
1689
|
+
/**
|
|
1690
|
+
* The output number of this UTXO in its parent {@link Intent}.
|
|
1691
|
+
*/
|
|
1692
|
+
outputNo: number,
|
|
1693
|
+
};
|
|
1694
|
+
|
|
1695
|
+
/**
|
|
1696
|
+
* Metadata about a specific UTXO
|
|
1697
|
+
*/
|
|
1698
|
+
export class UtxoMeta {
|
|
1699
|
+
constructor(ctime: Date);
|
|
1700
|
+
/**
|
|
1701
|
+
* The creation time of the UTXO, that is, when it was inserted into the state.
|
|
1702
|
+
*/
|
|
1703
|
+
ctime: Date;
|
|
1704
|
+
}
|
|
1705
|
+
/**
|
|
1706
|
+
* The sub-state for unshielded UTXOs
|
|
1707
|
+
*/
|
|
1708
|
+
export class UtxoState {
|
|
1709
|
+
static new(utxos: Map<Utxo, UtxoMeta>): UtxoState;
|
|
1710
|
+
/**
|
|
1711
|
+
* Lookup the metadata for a specific UTXO.
|
|
1712
|
+
*/
|
|
1713
|
+
lookupMeta(utxo: Utxo): UtxoMeta | undefined;
|
|
1714
|
+
|
|
1715
|
+
/**
|
|
1716
|
+
* The set of valid UTXOs
|
|
1717
|
+
*/
|
|
1718
|
+
readonly utxos: Set<Utxo>;
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
* Filters out the UTXOs owned by a specific user address
|
|
1722
|
+
*/
|
|
1723
|
+
filter(addr: UserAddress): Set<Utxo>;
|
|
1724
|
+
|
|
1725
|
+
/**
|
|
1726
|
+
* Given a prior UTXO state, produce the set differences `this \ prior`, and
|
|
1727
|
+
* `prior \ this`, optionally filtered by a further condition.
|
|
1728
|
+
*
|
|
1729
|
+
* Note that this should be more efficient than iterating or manifesting the
|
|
1730
|
+
* {@link utxos} value, as the low-level implementation can avoid traversing
|
|
1731
|
+
* shared sub-structures.
|
|
1732
|
+
*/
|
|
1733
|
+
delta(prior: UtxoState, filterBy?: (utxo: Utxo) => boolean): [Set<Utxo>, Set<Utxo>];
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
/**
|
|
1737
|
+
* A single contract call segment
|
|
1738
|
+
*/
|
|
1739
|
+
export class ContractCall<P extends Proofish> {
|
|
1740
|
+
private constructor();
|
|
1741
|
+
|
|
1742
|
+
toString(compact?: boolean): string;
|
|
1743
|
+
|
|
1744
|
+
/**
|
|
1745
|
+
* The address being called
|
|
1746
|
+
*/
|
|
1747
|
+
readonly address: ContractAddress;
|
|
1748
|
+
/**
|
|
1749
|
+
* The communication commitment of this call
|
|
1750
|
+
*/
|
|
1751
|
+
readonly communicationCommitment: CommunicationCommitment;
|
|
1752
|
+
/**
|
|
1753
|
+
* The entry point being called
|
|
1754
|
+
*/
|
|
1755
|
+
readonly entryPoint: Uint8Array | string;
|
|
1756
|
+
/**
|
|
1757
|
+
* The fallible execution stage transcript
|
|
1758
|
+
*/
|
|
1759
|
+
readonly fallibleTranscript: Transcript<AlignedValue> | undefined;
|
|
1760
|
+
/**
|
|
1761
|
+
* The guaranteed execution stage transcript
|
|
1762
|
+
*/
|
|
1763
|
+
readonly guaranteedTranscript: Transcript<AlignedValue> | undefined;
|
|
1764
|
+
/**
|
|
1765
|
+
* The proof attached to this call
|
|
1766
|
+
*/
|
|
1767
|
+
readonly proof: P;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
/**
|
|
1771
|
+
* A {@link ContractCall} prior to being partitioned into guarnateed and
|
|
1772
|
+
* fallible parts, for use with {@link Transaction.addCalls}.
|
|
1773
|
+
*
|
|
1774
|
+
* Note that this is similar, but not the same as {@link ContractCall}, which
|
|
1775
|
+
* assumes {@link partitionTranscripts} was already used. {@link
|
|
1776
|
+
* Transaction.addCalls} is a replacement for this that also handles
|
|
1777
|
+
* Zswap components, and creates relevant intents when needed.
|
|
1778
|
+
*/
|
|
1779
|
+
export class PrePartitionContractCall {
|
|
1780
|
+
constructor(
|
|
1781
|
+
address: ContractAddress,
|
|
1782
|
+
entry_point: Uint8Array | string,
|
|
1783
|
+
op: ContractOperation,
|
|
1784
|
+
pre_transcript: PreTranscript,
|
|
1785
|
+
private_transcript_outputs: AlignedValue[],
|
|
1786
|
+
input: AlignedValue,
|
|
1787
|
+
output: AlignedValue,
|
|
1788
|
+
communication_commitment_rand: CommunicationCommitmentRand,
|
|
1789
|
+
key_location: string
|
|
1790
|
+
);
|
|
1791
|
+
toString(compact?: boolean): string;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
/**
|
|
1795
|
+
* A {@link ContractCall} still being assembled
|
|
1796
|
+
*/
|
|
1797
|
+
export class ContractCallPrototype {
|
|
1798
|
+
/**
|
|
1799
|
+
* @param address - The address being called
|
|
1800
|
+
* @param entry_point - The entry point being called
|
|
1801
|
+
* @param op - The operation expected at this entry point
|
|
1802
|
+
* @param guaranteed_public_transcript - The guaranteed transcript computed
|
|
1803
|
+
* for this call
|
|
1804
|
+
* @param fallible_public_transcript - The fallible transcript computed for
|
|
1805
|
+
* this call
|
|
1806
|
+
* @param private_transcript_outputs - The private transcript recorded for
|
|
1807
|
+
* this call
|
|
1808
|
+
* @param input - The input(s) provided to this call
|
|
1809
|
+
* @param output - The output(s) computed from this call
|
|
1810
|
+
* @param communication_commitment_rand - The communication randomness used
|
|
1811
|
+
* for this call
|
|
1812
|
+
* @param key_location - An identifier for how the key for this call may be
|
|
1813
|
+
* looked up
|
|
1814
|
+
*/
|
|
1815
|
+
constructor(
|
|
1816
|
+
address: ContractAddress,
|
|
1817
|
+
entry_point: Uint8Array | string,
|
|
1818
|
+
op: ContractOperation,
|
|
1819
|
+
guaranteed_public_transcript: Transcript<AlignedValue> | undefined,
|
|
1820
|
+
fallible_public_transcript: Transcript<AlignedValue> | undefined,
|
|
1821
|
+
private_transcript_outputs: AlignedValue[],
|
|
1822
|
+
input: AlignedValue,
|
|
1823
|
+
output: AlignedValue,
|
|
1824
|
+
communication_commitment_rand: CommunicationCommitmentRand,
|
|
1825
|
+
key_location: string
|
|
1826
|
+
);
|
|
1827
|
+
|
|
1828
|
+
toString(compact?: boolean): string;
|
|
1829
|
+
|
|
1830
|
+
intoCall(parentBinding: PreBinding): ContractCall<PreProof>;
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
/**
|
|
1834
|
+
* An intent is a potentially unbalanced partial transaction, that may be
|
|
1835
|
+
* combined with other intents to form a whole.
|
|
1836
|
+
*/
|
|
1837
|
+
export class Intent<S extends Signaturish, P extends Proofish, B extends Bindingish> {
|
|
1838
|
+
private constructor();
|
|
1839
|
+
|
|
1840
|
+
static new(ttl: Date): UnprovenIntent;
|
|
1841
|
+
|
|
1842
|
+
serialize(): Uint8Array;
|
|
1843
|
+
|
|
1844
|
+
static deserialize<S extends Signaturish, P extends Proofish, B extends Bindingish>(
|
|
1845
|
+
markerS: S['instance'],
|
|
1846
|
+
markerP: P['instance'],
|
|
1847
|
+
markerB: B['instance'],
|
|
1848
|
+
raw: Uint8Array,
|
|
1849
|
+
|
|
1850
|
+
): Intent<S, P, B>;
|
|
1851
|
+
|
|
1852
|
+
toString(compact?: boolean): string;
|
|
1853
|
+
|
|
1854
|
+
/**
|
|
1855
|
+
* Returns the hash of this intent, for it's given segment ID.
|
|
1856
|
+
*/
|
|
1857
|
+
intentHash(segmentId: number): IntentHash;
|
|
1858
|
+
|
|
1859
|
+
/**
|
|
1860
|
+
* Adds a contract call to this intent.
|
|
1861
|
+
*/
|
|
1862
|
+
addCall(call: ContractCallPrototype): Intent<S, PreProof, PreBinding>;
|
|
1863
|
+
|
|
1864
|
+
/**
|
|
1865
|
+
* Adds a contract deploy to this intent.
|
|
1866
|
+
*/
|
|
1867
|
+
addDeploy(deploy: ContractDeploy): Intent<S, PreProof, PreBinding>;
|
|
1868
|
+
|
|
1869
|
+
/**
|
|
1870
|
+
* Adds a maintenance update to this intent.
|
|
1871
|
+
*/
|
|
1872
|
+
addMaintenanceUpdate(update: MaintenanceUpdate): Intent<S, PreProof, PreBinding>;
|
|
1873
|
+
|
|
1874
|
+
/**
|
|
1875
|
+
* Enforces binding for this intent. This is irreversible.
|
|
1876
|
+
* @throws If `segmentId` is not a valid segment ID.
|
|
1877
|
+
*/
|
|
1878
|
+
bind(segmentId: number): Intent<S, P, Binding>;
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* Removes proofs from this intent.
|
|
1882
|
+
*/
|
|
1883
|
+
eraseProofs(): Intent<S, NoProof, NoBinding>;
|
|
1884
|
+
|
|
1885
|
+
/**
|
|
1886
|
+
* Removes signatures from this intent.
|
|
1887
|
+
*/
|
|
1888
|
+
eraseSignatures(): Intent<SignatureErased, P, B>;
|
|
1889
|
+
|
|
1890
|
+
/**
|
|
1891
|
+
* The raw data that is signed for unshielded inputs in this intent.
|
|
1892
|
+
*/
|
|
1893
|
+
signatureData(segmentId: number): Uint8Array;
|
|
1894
|
+
|
|
1895
|
+
/**
|
|
1896
|
+
* The UTXO inputs and outputs in the guaranteed section of this intent.
|
|
1897
|
+
* @throws Writing throws if `B` is {@link Binding}, unless the only change
|
|
1898
|
+
* is in the signature set.
|
|
1899
|
+
*/
|
|
1900
|
+
guaranteedUnshieldedOffer: UnshieldedOffer<S> | undefined;
|
|
1901
|
+
/**
|
|
1902
|
+
* The UTXO inputs and outputs in the fallible section of this intent.
|
|
1903
|
+
* @throws Writing throws if `B` is {@link Binding}, unless the only change
|
|
1904
|
+
* is in the signature set.
|
|
1905
|
+
*/
|
|
1906
|
+
fallibleUnshieldedOffer: UnshieldedOffer<S> | undefined;
|
|
1907
|
+
/**
|
|
1908
|
+
* The action sequence of this intent.
|
|
1909
|
+
* @throws Writing throws if `B` is {@link Binding}.
|
|
1910
|
+
*/
|
|
1911
|
+
actions: ContractAction<P>[];
|
|
1912
|
+
/**
|
|
1913
|
+
* The DUST interactions made by this intent
|
|
1914
|
+
* @throws Writing throws if `B` is {@link Binding}.
|
|
1915
|
+
*/
|
|
1916
|
+
dustActions: DustActions<S, P> | undefined;
|
|
1917
|
+
/**
|
|
1918
|
+
* The time this intent expires.
|
|
1919
|
+
* @throws Writing throws if `B` is {@link Binding}.
|
|
1920
|
+
*/
|
|
1921
|
+
ttl: Date;
|
|
1922
|
+
readonly binding: B;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
/**
|
|
1926
|
+
* An unshielded offer consists of inputs, outputs, and signatures that
|
|
1927
|
+
* authorize the inputs. The data the signatures sign is provided by {@link
|
|
1928
|
+
* Intent.signatureData}.
|
|
1929
|
+
*/
|
|
1930
|
+
export class UnshieldedOffer<S extends Signaturish> {
|
|
1931
|
+
private constructor();
|
|
1932
|
+
|
|
1933
|
+
static new(inputs: UtxoSpend[], outputs: UtxoOutput[], signatures: Signature[]): UnshieldedOffer<SignatureEnabled>;
|
|
1934
|
+
|
|
1935
|
+
addSignatures(signatures: Signature[]): UnshieldedOffer<S>;
|
|
1936
|
+
|
|
1937
|
+
eraseSignatures(): UnshieldedOffer<SignatureErased>;
|
|
1938
|
+
|
|
1939
|
+
toString(compact?: boolean): string;
|
|
1940
|
+
|
|
1941
|
+
readonly inputs: UtxoSpend[];
|
|
1942
|
+
readonly outputs: UtxoOutput[];
|
|
1943
|
+
readonly signatures: Signature[];
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
/**
|
|
1947
|
+
* The context against which a transaction is run.
|
|
1948
|
+
*/
|
|
1949
|
+
export class TransactionContext {
|
|
1950
|
+
/**
|
|
1951
|
+
* @param ref_state - A past ledger state that is used as a reference point
|
|
1952
|
+
* for 'static' data.
|
|
1953
|
+
* @param block_context - Information about the block this transaction is, or
|
|
1954
|
+
* will be, contained in.
|
|
1955
|
+
* @param whitelist - A list of contracts that are being tracked, or
|
|
1956
|
+
* `undefined` to track all contracts.
|
|
1957
|
+
*/
|
|
1958
|
+
constructor(ref_state: LedgerState, block_context: BlockContext, whitelist?: Set<ContractAddress>);
|
|
1959
|
+
|
|
1960
|
+
toString(compact?: boolean): string;
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
/**
|
|
1964
|
+
* The result status of applying a transaction.
|
|
1965
|
+
* Includes an error message if the transaction failed, or partially failed.
|
|
1966
|
+
*/
|
|
1967
|
+
export class TransactionResult {
|
|
1968
|
+
private constructor();
|
|
1969
|
+
|
|
1970
|
+
readonly type: 'success' | 'partialSuccess' | 'failure';
|
|
1971
|
+
readonly successfulSegments?: Map<number, boolean>;
|
|
1972
|
+
readonly error?: string;
|
|
1973
|
+
readonly events: Event[];
|
|
1974
|
+
|
|
1975
|
+
toString(compact?: boolean): string;
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* The result status of applying a transaction, without error message
|
|
1980
|
+
*/
|
|
1981
|
+
export type ErasedTransactionResult = {
|
|
1982
|
+
type: 'success' | 'partialSuccess' | 'failure',
|
|
1983
|
+
successfulSegments?: Map<number, boolean>,
|
|
1984
|
+
};
|
|
1985
|
+
|
|
1986
|
+
/**
|
|
1987
|
+
* A single update instruction in a {@link MaintenanceUpdate}.
|
|
1988
|
+
*/
|
|
1989
|
+
export type SingleUpdate = ReplaceAuthority | VerifierKeyRemove | VerifierKeyInsert;
|
|
1990
|
+
|
|
1991
|
+
/**
|
|
1992
|
+
* The version associated with a {@link ContractOperation}
|
|
1993
|
+
*/
|
|
1994
|
+
export class ContractOperationVersion {
|
|
1995
|
+
constructor(version: 'v3');
|
|
1996
|
+
|
|
1997
|
+
readonly version: 'v3';
|
|
1998
|
+
|
|
1999
|
+
toString(compact?: boolean): string;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
/**
|
|
2003
|
+
* A versioned verifier key to be associated with a {@link ContractOperation}.
|
|
2004
|
+
*/
|
|
2005
|
+
export class ContractOperationVersionedVerifierKey {
|
|
2006
|
+
constructor(version: 'v3', rawVk: Uint8Array);
|
|
2007
|
+
|
|
2008
|
+
readonly version: 'v3';
|
|
2009
|
+
readonly rawVk: Uint8Array;
|
|
2010
|
+
|
|
2011
|
+
toString(compact?: boolean): string;
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
/**
|
|
2015
|
+
* An update instruction to replace the current contract maintenance authority
|
|
2016
|
+
* with a new one.
|
|
2017
|
+
*/
|
|
2018
|
+
export class ReplaceAuthority {
|
|
2019
|
+
constructor(authority: ContractMaintenanceAuthority);
|
|
2020
|
+
|
|
2021
|
+
readonly authority: ContractMaintenanceAuthority;
|
|
2022
|
+
|
|
2023
|
+
toString(compact?: boolean): string;
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
/**
|
|
2027
|
+
* An update instruction to remove a verifier key of a specific operation and
|
|
2028
|
+
* version.
|
|
2029
|
+
*/
|
|
2030
|
+
export class VerifierKeyRemove {
|
|
2031
|
+
constructor(operation: string | Uint8Array, version: ContractOperationVersion);
|
|
2032
|
+
|
|
2033
|
+
readonly operation: string | Uint8Array;
|
|
2034
|
+
readonly version: ContractOperationVersion;
|
|
2035
|
+
|
|
2036
|
+
toString(compact?: boolean): string;
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
/**
|
|
2040
|
+
* An update instruction to insert a verifier key at a specific operation and
|
|
2041
|
+
* version.
|
|
2042
|
+
*/
|
|
2043
|
+
export class VerifierKeyInsert {
|
|
2044
|
+
constructor(operation: string | Uint8Array, vk: ContractOperationVersionedVerifierKey);
|
|
2045
|
+
|
|
2046
|
+
readonly operation: string | Uint8Array;
|
|
2047
|
+
readonly vk: ContractOperationVersionedVerifierKey;
|
|
2048
|
+
|
|
2049
|
+
toString(compact?: boolean): string;
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
/**
|
|
2053
|
+
* A contract maintenance update, updating associated operations, or
|
|
2054
|
+
* changing the maintenance authority.
|
|
2055
|
+
*/
|
|
2056
|
+
export class MaintenanceUpdate {
|
|
2057
|
+
constructor(address: ContractAddress, updates: SingleUpdate[], counter: bigint);
|
|
2058
|
+
|
|
2059
|
+
/**
|
|
2060
|
+
* Adds a new signature to this update
|
|
2061
|
+
*/
|
|
2062
|
+
addSignature(idx: bigint, signature: Signature): MaintenanceUpdate;
|
|
2063
|
+
|
|
2064
|
+
toString(compact?: boolean): string;
|
|
2065
|
+
|
|
2066
|
+
/**
|
|
2067
|
+
* The raw data any valid signature must be over to approve this update.
|
|
2068
|
+
*/
|
|
2069
|
+
readonly dataToSign: Uint8Array;
|
|
2070
|
+
/**
|
|
2071
|
+
* The address this deployment will attempt to create
|
|
2072
|
+
*/
|
|
2073
|
+
readonly address: ContractAddress;
|
|
2074
|
+
/**
|
|
2075
|
+
* The updates to carry out
|
|
2076
|
+
*/
|
|
2077
|
+
readonly updates: SingleUpdate[];
|
|
2078
|
+
/**
|
|
2079
|
+
* The counter this update is valid against
|
|
2080
|
+
*/
|
|
2081
|
+
readonly counter: bigint;
|
|
2082
|
+
/**
|
|
2083
|
+
* The signatures on this update
|
|
2084
|
+
*/
|
|
2085
|
+
readonly signatures: [bigint, Signature][];
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
/**
|
|
2089
|
+
* A contract deployment segment, instructing the creation of a new contract
|
|
2090
|
+
* address, if not already present
|
|
2091
|
+
*/
|
|
2092
|
+
export class ContractDeploy {
|
|
2093
|
+
/**
|
|
2094
|
+
* Creates a deployment for an arbitrary contract state
|
|
2095
|
+
*
|
|
2096
|
+
* The deployment and its address are randomised.
|
|
2097
|
+
*/
|
|
2098
|
+
constructor(initial_state: ContractState);
|
|
2099
|
+
|
|
2100
|
+
toString(compact?: boolean): string;
|
|
2101
|
+
|
|
2102
|
+
/**
|
|
2103
|
+
* The address this deployment will attempt to create
|
|
2104
|
+
*/
|
|
2105
|
+
readonly address: ContractAddress;
|
|
2106
|
+
readonly initialState: ContractState;
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
export type ProvingProvider = {
|
|
2110
|
+
check(
|
|
2111
|
+
serializedPreimage: Uint8Array,
|
|
2112
|
+
keyLocation: string,
|
|
2113
|
+
): Promise<(bigint | undefined)[]>;
|
|
2114
|
+
prove(
|
|
2115
|
+
serializedPreimage: Uint8Array,
|
|
2116
|
+
keyLocation: string,
|
|
2117
|
+
overwriteBindingInput?: bigint,
|
|
2118
|
+
): Promise<Uint8Array>;
|
|
2119
|
+
};
|
|
2120
|
+
|
|
2121
|
+
/**
|
|
2122
|
+
* Specifies where something should execute in a transaction.
|
|
2123
|
+
*
|
|
2124
|
+
* Options are:
|
|
2125
|
+
* - As the first thing (alias for `{ tag: 'specific', value: 1 }`)
|
|
2126
|
+
* - In any physical segment, but only utilising the guaranteed logical segment
|
|
2127
|
+
* - In a random segment (ideal for merging with other intents)
|
|
2128
|
+
* - In a specific directly provided segment (in the range 1..65535)
|
|
2129
|
+
*/
|
|
2130
|
+
export type SegmentSpecifier = { tag: 'first' } | { tag: 'guaranteedOnly' } | { tag: 'random' } | { tag: 'specific', value: number };
|
|
2131
|
+
|
|
2132
|
+
/**
|
|
2133
|
+
* A transaction that has been validated with `wellFormed`.
|
|
2134
|
+
**/
|
|
2135
|
+
export class VerifiedTransaction {
|
|
2136
|
+
private constructor();
|
|
2137
|
+
|
|
2138
|
+
/**
|
|
2139
|
+
* The actual underlying transaction
|
|
2140
|
+
**/
|
|
2141
|
+
readonly transaction: Transaction<SignatureErased, NoProof, NoBinding>;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
/**
|
|
2145
|
+
* A Midnight transaction, consisting a section of {@link
|
|
2146
|
+
* ContractAction}s, and a guaranteed and fallible {@link ZswapOffer}.
|
|
2147
|
+
*
|
|
2148
|
+
* The guaranteed section are run first, and fee payment is taken during this
|
|
2149
|
+
* part. If it succeeds, the fallible section is also run, and atomically
|
|
2150
|
+
* rolled back if it fails.
|
|
2151
|
+
*/
|
|
2152
|
+
export class Transaction<S extends Signaturish, P extends Proofish, B extends Bindingish> {
|
|
2153
|
+
private constructor();
|
|
2154
|
+
|
|
2155
|
+
/**
|
|
2156
|
+
* Creates a transaction from its parts.
|
|
2157
|
+
*/
|
|
2158
|
+
static fromParts(network_id: string, guaranteed?: UnprovenOffer, fallible?: UnprovenOffer, intent?: UnprovenIntent): UnprovenTransaction;
|
|
2159
|
+
|
|
2160
|
+
/**
|
|
2161
|
+
* Creates a transaction from its parts, randomizing the segment ID to better
|
|
2162
|
+
* allow merging.
|
|
2163
|
+
*/
|
|
2164
|
+
static fromPartsRandomized(network_id: string, guaranteed?: UnprovenOffer, fallible?: UnprovenOffer, intent?: UnprovenIntent): UnprovenTransaction;
|
|
2165
|
+
|
|
2166
|
+
/**
|
|
2167
|
+
* Creates a rewards claim transaction, the funds claimed must have been
|
|
2168
|
+
* legitimately rewarded previously.
|
|
2169
|
+
*/
|
|
2170
|
+
static fromRewards<S extends Signaturish>(rewards: ClaimRewardsTransaction<S>): Transaction<S, PreProof, Binding>;
|
|
2171
|
+
|
|
2172
|
+
/**
|
|
2173
|
+
* Mocks proving, producing a 'proven' transaction that, while it will
|
|
2174
|
+
* *not* verify, is accurate for fee computation purposes.
|
|
2175
|
+
*
|
|
2176
|
+
* Due to the variability in proof sizes, this *only* works for transactions
|
|
2177
|
+
* that do not contain unproven contract calls.
|
|
2178
|
+
*
|
|
2179
|
+
* @throws If called on bound, proven, or proof-erased transactions, or if the
|
|
2180
|
+
* transaction contains unproven contract calls.
|
|
2181
|
+
*/
|
|
2182
|
+
mockProve(): Transaction<S, Proof, B>;
|
|
2183
|
+
/**
|
|
2184
|
+
* Proves the transaction, with access to a low-level proving provider.
|
|
2185
|
+
* This may *only* be called for `P = PreProof`.
|
|
2186
|
+
*
|
|
2187
|
+
* @throws If called on bound, proven, or proof-erased transactions.
|
|
2188
|
+
*/
|
|
2189
|
+
prove(provider: ProvingProvider, cost_model: CostModel): Promise<Transaction<S, Proof, B>>;
|
|
2190
|
+
|
|
2191
|
+
/**
|
|
2192
|
+
* Adds a set of new calls to the transaction.
|
|
2193
|
+
*
|
|
2194
|
+
* In contrast to {@link Intent.addCall}, this takes calls *before*
|
|
2195
|
+
* transcript partitioning ({@link partitionTranscripts}), will create the
|
|
2196
|
+
* target intent where needed, and will ensure that relevant Zswap parts are
|
|
2197
|
+
* placed in the same section as contract interactions with them.
|
|
2198
|
+
*
|
|
2199
|
+
* @throws If called on bound, proven, or proof-erased transactions.
|
|
2200
|
+
*/
|
|
2201
|
+
addCalls(
|
|
2202
|
+
segment: SegmentSpecifier,
|
|
2203
|
+
calls: PrePartitionContractCall[],
|
|
2204
|
+
params: LedgerParameters,
|
|
2205
|
+
ttl: Date,
|
|
2206
|
+
zswapInputs?: ZswapInput<PreProof>[],
|
|
2207
|
+
zswapOutputs?: ZswapOutput<PreProof>[],
|
|
2208
|
+
zswapTransient?: ZswapTransient<PreProof>[],
|
|
2209
|
+
): Transaction<S, P, B>;
|
|
2210
|
+
|
|
2211
|
+
/**
|
|
2212
|
+
* Erases the proofs contained in this transaction
|
|
2213
|
+
*/
|
|
2214
|
+
eraseProofs(): Transaction<S, NoProof, NoBinding>;
|
|
2215
|
+
|
|
2216
|
+
/**
|
|
2217
|
+
* Removes signatures from this transaction.
|
|
2218
|
+
*/
|
|
2219
|
+
eraseSignatures(): Transaction<SignatureErased, P, B>;
|
|
2220
|
+
|
|
2221
|
+
/**
|
|
2222
|
+
* Enforces binding for this transaction. This is irreversible.
|
|
2223
|
+
*/
|
|
2224
|
+
bind(): Transaction<S, P, Binding>;
|
|
2225
|
+
|
|
2226
|
+
/**
|
|
2227
|
+
* Tests well-formedness criteria, optionally including transaction balancing
|
|
2228
|
+
*
|
|
2229
|
+
* @throws If the transaction is not well-formed for any reason
|
|
2230
|
+
*/
|
|
2231
|
+
wellFormed(ref_state: LedgerState, strictness: WellFormedStrictness, tblock: Date): VerifiedTransaction;
|
|
2232
|
+
|
|
2233
|
+
/**
|
|
2234
|
+
* Returns the hash associated with this transaction. Due to the ability to
|
|
2235
|
+
* merge transactions, this should not be used to watch for a specific
|
|
2236
|
+
* transaction.
|
|
2237
|
+
*/
|
|
2238
|
+
transactionHash(): TransactionHash;
|
|
2239
|
+
|
|
2240
|
+
/**
|
|
2241
|
+
* Returns the set of identifiers contained within this transaction. Any of
|
|
2242
|
+
* these *may* be used to watch for a specific transaction.
|
|
2243
|
+
*/
|
|
2244
|
+
identifiers(): TransactionId[];
|
|
2245
|
+
|
|
2246
|
+
/**
|
|
2247
|
+
* Merges this transaction with another
|
|
2248
|
+
*
|
|
2249
|
+
* @throws If both transactions have contract interactions, or they spend the
|
|
2250
|
+
* same coins
|
|
2251
|
+
*/
|
|
2252
|
+
merge(other: Transaction<S, P, B>): Transaction<S, P, B>;
|
|
2253
|
+
|
|
2254
|
+
serialize(): Uint8Array;
|
|
2255
|
+
|
|
2256
|
+
static deserialize<S extends Signaturish, P extends Proofish, B extends Bindingish>(
|
|
2257
|
+
markerS: S['instance'],
|
|
2258
|
+
markerP: P['instance'],
|
|
2259
|
+
markerB: B['instance'],
|
|
2260
|
+
raw: Uint8Array,
|
|
2261
|
+
|
|
2262
|
+
): Transaction<S, P, B>;
|
|
2263
|
+
|
|
2264
|
+
/**
|
|
2265
|
+
* For given fees, and a given section (guaranteed/fallible), what the
|
|
2266
|
+
* surplus or deficit of this transaction in any token type is.
|
|
2267
|
+
*
|
|
2268
|
+
* @throws If `segment` is not a valid segment ID
|
|
2269
|
+
*/
|
|
2270
|
+
imbalances(segment: number, fees?: bigint): Map<TokenType, bigint>;
|
|
2271
|
+
|
|
2272
|
+
/**
|
|
2273
|
+
* The underlying resource cost of this transaction.
|
|
2274
|
+
*/
|
|
2275
|
+
cost(params: LedgerParameters, enforceTimeToDismiss?: boolean): SyntheticCost;
|
|
2276
|
+
|
|
2277
|
+
/**
|
|
2278
|
+
* The cost of this transaction, in SPECKs.
|
|
2279
|
+
*
|
|
2280
|
+
* Note that this is *only* accurate when called with proven transactions.
|
|
2281
|
+
*/
|
|
2282
|
+
fees(params: LedgerParameters, enforceTimeToDismiss?: boolean): bigint;
|
|
2283
|
+
|
|
2284
|
+
/**
|
|
2285
|
+
* The cost of this transaction, in SPECKs, with a safety margin of `n` blocks applied.
|
|
2286
|
+
*
|
|
2287
|
+
* As with {@link fees}, this is only accurate for proven transactions.
|
|
2288
|
+
*
|
|
2289
|
+
* Warning: `n` must be a non-negative integer, and it is an exponent, it is
|
|
2290
|
+
* very easy to get a completely unreasonable margin here!
|
|
2291
|
+
*/
|
|
2292
|
+
feesWithMargin(params: LedgerParameters, margin: number): bigint;
|
|
2293
|
+
|
|
2294
|
+
toString(compact?: boolean): string;
|
|
2295
|
+
|
|
2296
|
+
/**
|
|
2297
|
+
* The rewards this transaction represents, if applicable
|
|
2298
|
+
*/
|
|
2299
|
+
readonly rewards: ClaimRewardsTransaction<S> | undefined;
|
|
2300
|
+
/**
|
|
2301
|
+
* The intents contained in this transaction
|
|
2302
|
+
*
|
|
2303
|
+
* Note that writing to this re-computes binding information if and only if
|
|
2304
|
+
* this transaction is unbound *and* unproven. If this is not the case,
|
|
2305
|
+
* creating or removing intents will lead to a binding error down the line,
|
|
2306
|
+
* but modifying existing intents will succeed.
|
|
2307
|
+
*
|
|
2308
|
+
* @throws On writing if `B` is {@link Binding} or this is not a standard
|
|
2309
|
+
* transaction
|
|
2310
|
+
*/
|
|
2311
|
+
intents: Map<number, Intent<S, P, B>> | undefined;
|
|
2312
|
+
/**
|
|
2313
|
+
* The fallible Zswap offer
|
|
2314
|
+
*
|
|
2315
|
+
* Note that writing to this re-computes binding information if and only if
|
|
2316
|
+
* this transaction is unbound *and* unproven. If this is not the case,
|
|
2317
|
+
* creating or removing offer components will lead to a binding error down
|
|
2318
|
+
* the line.
|
|
2319
|
+
*
|
|
2320
|
+
* @throws On writing if `B` is {@link Binding} or this is not a standard
|
|
2321
|
+
* transaction
|
|
2322
|
+
*/
|
|
2323
|
+
fallibleOffer: Map<number, ZswapOffer<P>> | undefined;
|
|
2324
|
+
/**
|
|
2325
|
+
* The guaranteed Zswap offer
|
|
2326
|
+
*
|
|
2327
|
+
* Note that writing to this re-computes binding information if and only if
|
|
2328
|
+
* this transaction is unbound *and* unproven. If this is not the case,
|
|
2329
|
+
* creating or removing offer components will lead to a binding error down
|
|
2330
|
+
* the line.
|
|
2331
|
+
*
|
|
2332
|
+
* @throws On writing if `B` is {@link Binding} or this is not a standard
|
|
2333
|
+
* transaction
|
|
2334
|
+
*/
|
|
2335
|
+
guaranteedOffer: ZswapOffer<P> | undefined;
|
|
2336
|
+
/**
|
|
2337
|
+
* The binding randomness associated with this transaction
|
|
2338
|
+
*/
|
|
2339
|
+
readonly bindingRandomness: bigint;
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
/**
|
|
2343
|
+
* A transcript prior to partitioning, consisting of the context to run it in, the program that
|
|
2344
|
+
* will make up the transcript, and optionally a communication commitment to bind calls together.
|
|
2345
|
+
*/
|
|
2346
|
+
export class PreTranscript {
|
|
2347
|
+
constructor(context: QueryContext, program: Op<AlignedValue>[], comm_comm?: CommunicationCommitment);
|
|
2348
|
+
|
|
2349
|
+
toString(compact?: boolean): string;
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
export type PartitionedTranscript = [Transcript<AlignedValue> | undefined, Transcript<AlignedValue> | undefined];
|
|
2353
|
+
|
|
2354
|
+
/**
|
|
2355
|
+
* Computes the communication commitment corresponding to an input/output pair and randomness.
|
|
2356
|
+
*/
|
|
2357
|
+
export function communicationCommitment(input: AlignedValue, output: AlignedValue, rand: CommunicationCommitmentRand): CommunicationCommitment;
|
|
2358
|
+
|
|
2359
|
+
/**
|
|
2360
|
+
* Finalizes a set of programs against their initial contexts,
|
|
2361
|
+
* resulting in guaranteed and fallible {@link Transcript}s, optimally
|
|
2362
|
+
* allocated, and heuristically covered for gas fees.
|
|
2363
|
+
*/
|
|
2364
|
+
export function partitionTranscripts(calls: PreTranscript[], params: LedgerParameters): PartitionedTranscript[];
|
|
2365
|
+
|
|
2366
|
+
/**
|
|
2367
|
+
* The hash of a transaction, as a hex-encoded 256-bit bytestring
|
|
2368
|
+
*/
|
|
2369
|
+
export type TransactionHash = string;
|
|
2370
|
+
/**
|
|
2371
|
+
* The hash of an intent, as a hex-encoded 256-bit bytestring
|
|
2372
|
+
*/
|
|
2373
|
+
export type IntentHash = string;
|
|
2374
|
+
/**
|
|
2375
|
+
* A transaction identifier, used to index merged transactions
|
|
2376
|
+
*/
|
|
2377
|
+
export type TransactionId = string;
|
|
2378
|
+
/**
|
|
2379
|
+
* An encryption public key, used to inform users of new coins sent to them
|
|
2380
|
+
*/
|
|
2381
|
+
export type EncPublicKey = string;
|
|
2382
|
+
|
|
2383
|
+
/**
|
|
2384
|
+
* Samples a dummy user coin public key, for use in testing
|
|
2385
|
+
*/
|
|
2386
|
+
export function sampleCoinPublicKey(): CoinPublicKey;
|
|
2387
|
+
|
|
2388
|
+
/**
|
|
2389
|
+
* Samples a dummy user encryption public key, for use in testing
|
|
2390
|
+
*/
|
|
2391
|
+
export function sampleEncryptionPublicKey(): EncPublicKey;
|
|
2392
|
+
|
|
2393
|
+
/**
|
|
2394
|
+
* Samples a dummy user intent hash, for use in testing
|
|
2395
|
+
*/
|
|
2396
|
+
export function sampleIntentHash(): IntentHash;
|
|
2397
|
+
|
|
2398
|
+
/**
|
|
2399
|
+
* Creates a new {@link ShieldedCoinInfo}, sampling a uniform nonce
|
|
2400
|
+
*/
|
|
2401
|
+
export function createShieldedCoinInfo(type_: RawTokenType, value: bigint): ShieldedCoinInfo;
|
|
2402
|
+
|
|
2403
|
+
/**
|
|
2404
|
+
* The base/system token type
|
|
2405
|
+
*/
|
|
2406
|
+
export function nativeToken(): UnshieldedTokenType;
|
|
2407
|
+
|
|
2408
|
+
/**
|
|
2409
|
+
* The system token type for fees
|
|
2410
|
+
*/
|
|
2411
|
+
export function feeToken(): DustTokenType;
|
|
2412
|
+
|
|
2413
|
+
/**
|
|
2414
|
+
* Default shielded token type for testing
|
|
2415
|
+
*/
|
|
2416
|
+
export function shieldedToken(): ShieldedTokenType;
|
|
2417
|
+
|
|
2418
|
+
/**
|
|
2419
|
+
* Default unshielded token type for testing
|
|
2420
|
+
*/
|
|
2421
|
+
export function unshieldedToken(): UnshieldedTokenType;
|
|
2422
|
+
|
|
2423
|
+
/**
|
|
2424
|
+
* Calculate commitment of a coin owned by a user
|
|
2425
|
+
*/
|
|
2426
|
+
export function coinCommitment(coin: ShieldedCoinInfo, coinPublicKey: CoinPublicKey): CoinCommitment;
|
|
2427
|
+
|
|
2428
|
+
/**
|
|
2429
|
+
* Calculate nullifier of a coin owned by a user
|
|
2430
|
+
*/
|
|
2431
|
+
export function coinNullifier(coin: ShieldedCoinInfo, coinSecretKey: CoinSecretKey): Nullifier;
|
|
2432
|
+
|
|
2433
|
+
/**
|
|
2434
|
+
* Parameters used by the Midnight ledger, including transaction fees and
|
|
2435
|
+
* bounds
|
|
2436
|
+
*/
|
|
2437
|
+
export class LedgerParameters {
|
|
2438
|
+
private constructor();
|
|
2439
|
+
|
|
2440
|
+
/**
|
|
2441
|
+
* The initial parameters of Midnight
|
|
2442
|
+
*/
|
|
2443
|
+
static initialParameters(): LedgerParameters;
|
|
2444
|
+
|
|
2445
|
+
/**
|
|
2446
|
+
* The cost model used for transaction fees contained in these parameters
|
|
2447
|
+
*/
|
|
2448
|
+
readonly transactionCostModel: TransactionCostModel;
|
|
2449
|
+
/**
|
|
2450
|
+
* The parameters associated with DUST.
|
|
2451
|
+
*/
|
|
2452
|
+
readonly dust: DustParameters;
|
|
2453
|
+
|
|
2454
|
+
/**
|
|
2455
|
+
* The maximum price adjustment per block with the current parameters, as a multiplicative
|
|
2456
|
+
* factor (that is: 1.1 would indicate a 10% adjustment). Will always return the positive (>1)
|
|
2457
|
+
* adjustment factor. Note that negative adjustments are the additive inverse (1.1 has a
|
|
2458
|
+
* corresponding 0.9 downward adjustment), *not* the multiplicative as might reasonably be
|
|
2459
|
+
* assumed.
|
|
2460
|
+
*/
|
|
2461
|
+
maxPriceAdjustment(): number;
|
|
2462
|
+
|
|
2463
|
+
serialize(): Uint8Array;
|
|
2464
|
+
|
|
2465
|
+
static deserialize(raw: Uint8Array): LedgerParameters;
|
|
2466
|
+
|
|
2467
|
+
toString(compact?: boolean): string;
|
|
2468
|
+
|
|
2469
|
+
/**
|
|
2470
|
+
* Normalizes a detailed block fullness cost to the block limits.
|
|
2471
|
+
*
|
|
2472
|
+
* @throws if any of the block limits is exceeded
|
|
2473
|
+
*/
|
|
2474
|
+
normalizeFullness(fullness: SyntheticCost): NormalizedCost;
|
|
2475
|
+
|
|
2476
|
+
/**
|
|
2477
|
+
* The fee prices for transaction
|
|
2478
|
+
*/
|
|
2479
|
+
readonly feePrices: FeePrices;
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
export class TransactionCostModel {
|
|
2483
|
+
private constructor();
|
|
2484
|
+
|
|
2485
|
+
/**
|
|
2486
|
+
* The initial cost model of Midnight
|
|
2487
|
+
*/
|
|
2488
|
+
static initialTransactionCostModel(): TransactionCostModel;
|
|
2489
|
+
|
|
2490
|
+
/**
|
|
2491
|
+
* The increase in fees to expect from adding a new input to a transaction
|
|
2492
|
+
*/
|
|
2493
|
+
readonly inputFeeOverhead: bigint;
|
|
2494
|
+
/**
|
|
2495
|
+
* The increase in fees to expect from adding a new output to a transaction
|
|
2496
|
+
*/
|
|
2497
|
+
readonly outputFeeOverhead: bigint;
|
|
2498
|
+
|
|
2499
|
+
serialize(): Uint8Array;
|
|
2500
|
+
|
|
2501
|
+
static deserialize(raw: Uint8Array): TransactionCostModel;
|
|
2502
|
+
|
|
2503
|
+
toString(compact?: boolean): string;
|
|
2504
|
+
|
|
2505
|
+
/**
|
|
2506
|
+
* A cost model for calculating transaction fees
|
|
2507
|
+
*/
|
|
2508
|
+
readonly runtimeCostModel: CostModel;
|
|
2509
|
+
|
|
2510
|
+
/**
|
|
2511
|
+
* A baseline cost to begin with
|
|
2512
|
+
*/
|
|
2513
|
+
readonly baselineCost: RunningCost;
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
|
|
2517
|
+
/**
|
|
2518
|
+
* A compact delta on the coin commitments Merkle tree, used to keep local
|
|
2519
|
+
* spending trees in sync with the global state without requiring receiving all
|
|
2520
|
+
* transactions.
|
|
2521
|
+
*/
|
|
2522
|
+
export class MerkleTreeCollapsedUpdate {
|
|
2523
|
+
/**
|
|
2524
|
+
* Create a new compact update from a non-compact state, and inclusive
|
|
2525
|
+
* `start` and `end` indices
|
|
2526
|
+
*
|
|
2527
|
+
* @throws If the indices are out-of-bounds for the state, or `end < start`
|
|
2528
|
+
*/
|
|
2529
|
+
constructor(state: ZswapChainState, start: bigint, end: bigint);
|
|
2530
|
+
|
|
2531
|
+
serialize(): Uint8Array;
|
|
2532
|
+
|
|
2533
|
+
static deserialize(raw: Uint8Array): MerkleTreeCollapsedUpdate;
|
|
2534
|
+
|
|
2535
|
+
toString(compact?: boolean): string;
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
/**
|
|
2539
|
+
* Holds the encryption secret key of a user, which may be used to determine if
|
|
2540
|
+
* a given offer contains outputs addressed to this user
|
|
2541
|
+
*/
|
|
2542
|
+
export class EncryptionSecretKey {
|
|
2543
|
+
private constructor();
|
|
2544
|
+
|
|
2545
|
+
/**
|
|
2546
|
+
* Clears the encryption secret key, so that it is no longer usable nor held in memory
|
|
2547
|
+
*/
|
|
2548
|
+
clear(): void;
|
|
2549
|
+
|
|
2550
|
+
test<P extends Proofish>(offer: ZswapOffer<P>): boolean;
|
|
2551
|
+
|
|
2552
|
+
yesIKnowTheSecurityImplicationsOfThis_serialize(): Uint8Array;
|
|
2553
|
+
yesIKnowTheSecurityImplicationsOfThis_taggedSerialize(): Uint8Array;
|
|
2554
|
+
|
|
2555
|
+
static deserialize(raw: Uint8Array): EncryptionSecretKey
|
|
2556
|
+
static taggedDeserialize(raw: Uint8Array): EncryptionSecretKey
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
export class ZswapSecretKeys {
|
|
2560
|
+
private constructor();
|
|
2561
|
+
|
|
2562
|
+
/**
|
|
2563
|
+
* Derives secret keys from a 32-byte seed
|
|
2564
|
+
*/
|
|
2565
|
+
static fromSeed(seed: Uint8Array): ZswapSecretKeys;
|
|
2566
|
+
|
|
2567
|
+
/**
|
|
2568
|
+
* Derives secret keys from a 32-byte seed using deprecated implementation.
|
|
2569
|
+
* Use only for compatibility purposes
|
|
2570
|
+
*/
|
|
2571
|
+
static fromSeedRng(seed: Uint8Array): ZswapSecretKeys;
|
|
2572
|
+
|
|
2573
|
+
|
|
2574
|
+
/**
|
|
2575
|
+
* Clears the secret keys, so that they are no longer usable nor held in memory
|
|
2576
|
+
* Note: it does not clear copies of the keys - which is particularly relevant for proof preimages
|
|
2577
|
+
* Note: this will cause all other operations to fail
|
|
2578
|
+
*/
|
|
2579
|
+
clear(): void;
|
|
2580
|
+
|
|
2581
|
+
readonly coinPublicKey: CoinPublicKey;
|
|
2582
|
+
readonly coinSecretKey: CoinSecretKey;
|
|
2583
|
+
readonly encryptionPublicKey: EncPublicKey;
|
|
2584
|
+
readonly encryptionSecretKey: EncryptionSecretKey;
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
/**
|
|
2588
|
+
* The on-chain state of Zswap, consisting of a Merkle tree of coin
|
|
2589
|
+
* commitments, a set of nullifiers, an index into the Merkle tree, and a set
|
|
2590
|
+
* of valid past Merkle tree roots
|
|
2591
|
+
*/
|
|
2592
|
+
export class ZswapChainState {
|
|
2593
|
+
constructor();
|
|
2594
|
+
|
|
2595
|
+
serialize(): Uint8Array;
|
|
2596
|
+
|
|
2597
|
+
/**
|
|
2598
|
+
* The first free index in the coin commitment tree
|
|
2599
|
+
*/
|
|
2600
|
+
readonly firstFree: bigint;
|
|
2601
|
+
|
|
2602
|
+
static deserialize(raw: Uint8Array): ZswapChainState;
|
|
2603
|
+
|
|
2604
|
+
/**
|
|
2605
|
+
* Given a whole ledger serialized state, deserialize only the Zswap portion
|
|
2606
|
+
*/
|
|
2607
|
+
static deserializeFromLedgerState(raw: Uint8Array): ZswapChainState;
|
|
2608
|
+
|
|
2609
|
+
/**
|
|
2610
|
+
* Carries out a post-block update, which does amortized bookkeeping that
|
|
2611
|
+
* only needs to be done once per state change.
|
|
2612
|
+
*
|
|
2613
|
+
* Typically, `postBlockUpdate` should be run after any (sequence of)
|
|
2614
|
+
* (system)-transaction application(s).
|
|
2615
|
+
*/
|
|
2616
|
+
postBlockUpdate(tblock: Date): ZswapChainState;
|
|
2617
|
+
|
|
2618
|
+
/**
|
|
2619
|
+
* Try to apply an {@link ZswapOffer} to the state, returning the updated state
|
|
2620
|
+
* and a map on newly inserted coin commitments to their inserted indices.
|
|
2621
|
+
*
|
|
2622
|
+
* @param whitelist - A set of contract addresses that are of interest. If
|
|
2623
|
+
* set, *only* these addresses are tracked, and all other information is
|
|
2624
|
+
* discarded.
|
|
2625
|
+
*/
|
|
2626
|
+
tryApply<P extends Proofish>(offer: ZswapOffer<P>, whitelist?: Set<ContractAddress>): [ZswapChainState, Map<CoinCommitment, bigint>];
|
|
2627
|
+
|
|
2628
|
+
toString(compact?: boolean): string;
|
|
2629
|
+
|
|
2630
|
+
/**
|
|
2631
|
+
* Filters the state to only include coins that are relevant to a given
|
|
2632
|
+
* contract address.
|
|
2633
|
+
*
|
|
2634
|
+
* @param contractAddress
|
|
2635
|
+
*/
|
|
2636
|
+
filter(contractAddress: ContractAddress): ZswapChainState;
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
/**
|
|
2640
|
+
* The local state of a user/wallet, consisting of a set
|
|
2641
|
+
* of unspent coins
|
|
2642
|
+
*
|
|
2643
|
+
* It also keeps track of coins that are in-flight, either expecting to spend
|
|
2644
|
+
* or expecting to receive, and a local copy of the global coin commitment
|
|
2645
|
+
* Merkle tree to generate proofs against.
|
|
2646
|
+
*
|
|
2647
|
+
* It does not store keys internally, but accepts them as arguments to various operations.
|
|
2648
|
+
*/
|
|
2649
|
+
export class ZswapLocalState {
|
|
2650
|
+
/**
|
|
2651
|
+
* Creates a new, empty state
|
|
2652
|
+
*/
|
|
2653
|
+
constructor();
|
|
2654
|
+
|
|
2655
|
+
/**
|
|
2656
|
+
* Applies a collapsed Merkle tree update to the current local state, fast
|
|
2657
|
+
* forwarding through the indices included in it, if it is a correct update.
|
|
2658
|
+
*
|
|
2659
|
+
* The general flow for usage if Alice is in state A, and wants to ask Bob how to reach the new state B, is:
|
|
2660
|
+
* - Find where she left off – what's her firstFree?
|
|
2661
|
+
* - Find out where she's going – ask for Bob's firstFree.
|
|
2662
|
+
* - Find what contents she does care about – ask Bob for the filtered
|
|
2663
|
+
* entries she want to include proper in her tree.
|
|
2664
|
+
* - In order, of Merkle tree indices:
|
|
2665
|
+
* - Insert (with `apply` offers Alice cares about).
|
|
2666
|
+
* - Skip (with this method) sections Alice does not care about, obtaining
|
|
2667
|
+
* the collapsed update covering the gap from Bob.
|
|
2668
|
+
* Note that `firstFree` is not included in the tree itself, and both ends of
|
|
2669
|
+
* updates *are* included.
|
|
2670
|
+
*/
|
|
2671
|
+
applyCollapsedUpdate(update: MerkleTreeCollapsedUpdate): ZswapLocalState;
|
|
2672
|
+
|
|
2673
|
+
/**
|
|
2674
|
+
* Replays observed events against the current local state. These *must* be replayed
|
|
2675
|
+
* in the same order as emitted by the chain being followed.
|
|
2676
|
+
*/
|
|
2677
|
+
replayEvents(secretKeys: ZswapSecretKeys, events: Event[]): ZswapLocalState;
|
|
2678
|
+
/**
|
|
2679
|
+
* Locally applies an offer to the current state, returning the updated state
|
|
2680
|
+
*/
|
|
2681
|
+
apply<P extends Proofish>(secretKeys: ZswapSecretKeys, offer: ZswapOffer<P>): ZswapLocalState;
|
|
2682
|
+
|
|
2683
|
+
/**
|
|
2684
|
+
* Clears pending outputs / spends that have passed their TTL without being included in
|
|
2685
|
+
* a block.
|
|
2686
|
+
*
|
|
2687
|
+
* Note that as TTLs are *from a block perspective*, and there is some
|
|
2688
|
+
* latency between the block and the wallet, the time passed in here should
|
|
2689
|
+
* not be the current time, but incorporate a latency buffer.
|
|
2690
|
+
*/
|
|
2691
|
+
clearPending(time: Date): ZswapLocalState;
|
|
2692
|
+
|
|
2693
|
+
/**
|
|
2694
|
+
* Initiates a new spend of a specific coin, outputting the corresponding
|
|
2695
|
+
* {@link ZswapInput}, and the updated state marking this coin as
|
|
2696
|
+
* in-flight.
|
|
2697
|
+
*/
|
|
2698
|
+
spend(secretKeys: ZswapSecretKeys, coin: QualifiedShieldedCoinInfo, segment: number | undefined, ttl?: Date): [ZswapLocalState, UnprovenInput];
|
|
2699
|
+
|
|
2700
|
+
/**
|
|
2701
|
+
* Initiates a new spend of a new-yet-received output, outputting the
|
|
2702
|
+
* corresponding {@link ZswapTransient}, and the updated state marking
|
|
2703
|
+
* this coin as in-flight.
|
|
2704
|
+
*/
|
|
2705
|
+
spendFromOutput(secretKeys: ZswapSecretKeys, coin: QualifiedShieldedCoinInfo, segment: number | undefined, output: UnprovenOutput, ttl?: Date): [ZswapLocalState, UnprovenTransient];
|
|
2706
|
+
|
|
2707
|
+
/**
|
|
2708
|
+
* Adds a coin to the list of coins that are expected to be received
|
|
2709
|
+
*
|
|
2710
|
+
* This should be used if an output is creating a coin for this wallet, which
|
|
2711
|
+
* does not contain a ciphertext to detect it. In this case, the wallet must
|
|
2712
|
+
* know the commitment ahead of time to notice the receipt.
|
|
2713
|
+
*/
|
|
2714
|
+
watchFor(coinPublicKey: CoinPublicKey, coin: ShieldedCoinInfo): ZswapLocalState;
|
|
2715
|
+
|
|
2716
|
+
serialize(): Uint8Array;
|
|
2717
|
+
|
|
2718
|
+
static deserialize(raw: Uint8Array): ZswapLocalState;
|
|
2719
|
+
|
|
2720
|
+
toString(compact?: boolean): string;
|
|
2721
|
+
|
|
2722
|
+
/**
|
|
2723
|
+
* The set of *spendable* coins of this wallet
|
|
2724
|
+
*/
|
|
2725
|
+
readonly coins: Set<QualifiedShieldedCoinInfo>;
|
|
2726
|
+
/**
|
|
2727
|
+
* The first free index in the internal coin commitments Merkle tree.
|
|
2728
|
+
* This may be used to identify which merkle tree updates are necessary.
|
|
2729
|
+
*/
|
|
2730
|
+
readonly firstFree: bigint;
|
|
2731
|
+
/**
|
|
2732
|
+
* The outputs that this wallet is expecting to receive in the future, with
|
|
2733
|
+
* an optional TTL attached.
|
|
2734
|
+
*/
|
|
2735
|
+
readonly pendingOutputs: Map<CoinCommitment, [ShieldedCoinInfo, Date | undefined]>;
|
|
2736
|
+
/**
|
|
2737
|
+
* The spends that this wallet is expecting to be finalized on-chain in the
|
|
2738
|
+
* future. Each has an optional TTL attached.
|
|
2739
|
+
*/
|
|
2740
|
+
readonly pendingSpends: Map<Nullifier, [QualifiedShieldedCoinInfo, Date | undefined]>;
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
/**
|
|
2744
|
+
* A shielded transaction input
|
|
2745
|
+
*/
|
|
2746
|
+
export class ZswapInput<P extends Proofish> {
|
|
2747
|
+
private constructor();
|
|
2748
|
+
|
|
2749
|
+
static newContractOwned(coin: QualifiedShieldedCoinInfo, segment: number | undefined, contract: ContractAddress, state: ZswapChainState): UnprovenInput;
|
|
2750
|
+
|
|
2751
|
+
serialize(): Uint8Array;
|
|
2752
|
+
|
|
2753
|
+
static deserialize<P extends Proofish>(markerP: P['instance'], raw: Uint8Array): ZswapInput<P>;
|
|
2754
|
+
|
|
2755
|
+
toString(compact?: boolean): string;
|
|
2756
|
+
|
|
2757
|
+
/**
|
|
2758
|
+
* The contract address receiving the input, if the sender is a contract
|
|
2759
|
+
*/
|
|
2760
|
+
readonly contractAddress: ContractAddress | undefined;
|
|
2761
|
+
/**
|
|
2762
|
+
* The nullifier of the input
|
|
2763
|
+
*/
|
|
2764
|
+
readonly nullifier: Nullifier;
|
|
2765
|
+
/**
|
|
2766
|
+
* The proof of this input
|
|
2767
|
+
*/
|
|
2768
|
+
readonly proof: P;
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
/**
|
|
2772
|
+
* A shielded transaction output
|
|
2773
|
+
*/
|
|
2774
|
+
export class ZswapOutput<P extends Proofish> {
|
|
2775
|
+
private constructor();
|
|
2776
|
+
|
|
2777
|
+
/**
|
|
2778
|
+
* Creates a new output, targeted to a user's coin public key.
|
|
2779
|
+
*
|
|
2780
|
+
* Optionally the output contains a ciphertext encrypted to the user's
|
|
2781
|
+
* encryption public key, which may be omitted *only* if the {@link ShieldedCoinInfo}
|
|
2782
|
+
* is transferred to the recipient another way
|
|
2783
|
+
*/
|
|
2784
|
+
static new(coin: ShieldedCoinInfo, segment: number | undefined, target_cpk: CoinPublicKey, target_epk: EncPublicKey): UnprovenOutput;
|
|
2785
|
+
|
|
2786
|
+
/**
|
|
2787
|
+
* Creates a new output, targeted to a smart contract
|
|
2788
|
+
*
|
|
2789
|
+
* A contract must *also* explicitly receive a coin created in this way for
|
|
2790
|
+
* the output to be valid
|
|
2791
|
+
*/
|
|
2792
|
+
static newContractOwned(coin: ShieldedCoinInfo, segment: number | undefined, contract: ContractAddress): UnprovenOutput;
|
|
2793
|
+
|
|
2794
|
+
serialize(): Uint8Array;
|
|
2795
|
+
|
|
2796
|
+
static deserialize<P extends Proofish>(markerP: P['instance'], raw: Uint8Array): ZswapOutput<P>;
|
|
2797
|
+
|
|
2798
|
+
toString(compact?: boolean): string;
|
|
2799
|
+
|
|
2800
|
+
/**
|
|
2801
|
+
* The commitment of the output
|
|
2802
|
+
*/
|
|
2803
|
+
readonly commitment: CoinCommitment;
|
|
2804
|
+
/**
|
|
2805
|
+
* The contract address receiving the output, if the recipient is a contract
|
|
2806
|
+
*/
|
|
2807
|
+
readonly contractAddress: ContractAddress | undefined;
|
|
2808
|
+
/**
|
|
2809
|
+
* The proof of this output
|
|
2810
|
+
*/
|
|
2811
|
+
readonly proof: P;
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
/**
|
|
2815
|
+
* A shielded "transient"; an output that is immediately spent within the same
|
|
2816
|
+
* transaction
|
|
2817
|
+
*/
|
|
2818
|
+
export class ZswapTransient<P extends Proofish> {
|
|
2819
|
+
private constructor();
|
|
2820
|
+
|
|
2821
|
+
/**
|
|
2822
|
+
* Creates a new contract-owned transient, from a given output and its coin.
|
|
2823
|
+
*
|
|
2824
|
+
* The {@link QualifiedShieldedCoinInfo} should have an `mt_index` of `0`
|
|
2825
|
+
*/
|
|
2826
|
+
static newFromContractOwnedOutput(coin: QualifiedShieldedCoinInfo, segment: number | undefined, output: UnprovenOutput): UnprovenTransient;
|
|
2827
|
+
|
|
2828
|
+
serialize(): Uint8Array;
|
|
2829
|
+
|
|
2830
|
+
static deserialize<P extends Proofish>(markerP: P['instance'], raw: Uint8Array): ZswapTransient<P>;
|
|
2831
|
+
|
|
2832
|
+
toString(compact?: boolean): string;
|
|
2833
|
+
|
|
2834
|
+
/**
|
|
2835
|
+
* The commitment of the transient
|
|
2836
|
+
*/
|
|
2837
|
+
readonly commitment: CoinCommitment;
|
|
2838
|
+
/**
|
|
2839
|
+
* The contract address creating the transient, if applicable
|
|
2840
|
+
*/
|
|
2841
|
+
readonly contractAddress: ContractAddress | undefined;
|
|
2842
|
+
/**
|
|
2843
|
+
* The nullifier of the transient
|
|
2844
|
+
*/
|
|
2845
|
+
readonly nullifier: Nullifier;
|
|
2846
|
+
/**
|
|
2847
|
+
* The input proof of this transient
|
|
2848
|
+
*/
|
|
2849
|
+
readonly inputProof: P;
|
|
2850
|
+
/**
|
|
2851
|
+
* The output proof of this transient
|
|
2852
|
+
*/
|
|
2853
|
+
readonly outputProof: P;
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
export type ClaimKind = "Reward" | "CardanoBridge";
|
|
2857
|
+
|
|
2858
|
+
/**
|
|
2859
|
+
* A request to allocate rewards, authorized by the reward's recipient
|
|
2860
|
+
*/
|
|
2861
|
+
export class ClaimRewardsTransaction<S extends Signaturish> {
|
|
2862
|
+
constructor(markerS: S['instance'], network_id: string, value: bigint, owner: SignatureVerifyingKey, nonce: Nonce, signature: S, kind?: ClaimKind);
|
|
2863
|
+
|
|
2864
|
+
static new(network_id: string, value: bigint, owner: SignatureVerifyingKey, nonce: Nonce, kind: ClaimKind): ClaimRewardsTransaction<SignatureErased>;
|
|
2865
|
+
|
|
2866
|
+
addSignature(signature: Signature): ClaimRewardsTransaction<SignatureEnabled>;
|
|
2867
|
+
|
|
2868
|
+
eraseSignatures(): ClaimRewardsTransaction<SignatureErased>;
|
|
2869
|
+
|
|
2870
|
+
serialize(): Uint8Array;
|
|
2871
|
+
|
|
2872
|
+
static deserialize<S extends Signaturish>(markerS: S['instance'], raw: Uint8Array): ClaimRewardsTransaction<S>;
|
|
2873
|
+
|
|
2874
|
+
toString(compact?: boolean): string;
|
|
2875
|
+
|
|
2876
|
+
/**
|
|
2877
|
+
* The raw data any valid signature must be over to approve this transaction.
|
|
2878
|
+
*/
|
|
2879
|
+
readonly dataToSign: Uint8Array;
|
|
2880
|
+
|
|
2881
|
+
/**
|
|
2882
|
+
* The rewarded coin's value, in atomic units dependent on the currency
|
|
2883
|
+
*
|
|
2884
|
+
* Bounded to be a non-negative 64-bit integer
|
|
2885
|
+
*/
|
|
2886
|
+
readonly value: bigint;
|
|
2887
|
+
|
|
2888
|
+
/**
|
|
2889
|
+
* The signing key owning this coin.
|
|
2890
|
+
*/
|
|
2891
|
+
readonly owner: SignatureVerifyingKey;
|
|
2892
|
+
|
|
2893
|
+
/**
|
|
2894
|
+
* The rewarded coin's randomness, preventing it from colliding with other coins.
|
|
2895
|
+
*/
|
|
2896
|
+
readonly nonce: Nonce;
|
|
2897
|
+
|
|
2898
|
+
/**
|
|
2899
|
+
* The signature on this request.
|
|
2900
|
+
*/
|
|
2901
|
+
readonly signature: S;
|
|
2902
|
+
|
|
2903
|
+
/**
|
|
2904
|
+
* The kind of claim being made, either a `Reward` or a `CardanoBridge` claim.
|
|
2905
|
+
*/
|
|
2906
|
+
readonly kind: ClaimKind
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2909
|
+
/**
|
|
2910
|
+
* A full Zswap offer; the zswap part of a transaction
|
|
2911
|
+
*
|
|
2912
|
+
* Consists of sets of {@link ZswapInput}s, {@link ZswapOutput}s, and {@link ZswapTransient}s,
|
|
2913
|
+
* as well as a {@link deltas} vector of the transaction value
|
|
2914
|
+
*/
|
|
2915
|
+
export class ZswapOffer<P extends Proofish> {
|
|
2916
|
+
private constructor();
|
|
2917
|
+
|
|
2918
|
+
/**
|
|
2919
|
+
* Creates a singleton offer, from an {@link ZswapInput} and its value
|
|
2920
|
+
* vector
|
|
2921
|
+
*
|
|
2922
|
+
* The `type_` and `value` parameters are deprecated and will be ignored.
|
|
2923
|
+
*/
|
|
2924
|
+
static fromInput<P extends Proofish>(input: ZswapInput<P>, type_?: RawTokenType, value?: bigint): ZswapOffer<P>;
|
|
2925
|
+
|
|
2926
|
+
/**
|
|
2927
|
+
* Creates a singleton offer, from an {@link ZswapOutput} and its value
|
|
2928
|
+
* vector
|
|
2929
|
+
*
|
|
2930
|
+
* The `type_` and `value` parameters are deprecated and will be ignored.
|
|
2931
|
+
*/
|
|
2932
|
+
static fromOutput<P extends Proofish>(output: ZswapOutput<P>, type_?: RawTokenType, value?: bigint): ZswapOffer<P>;
|
|
2933
|
+
|
|
2934
|
+
/**
|
|
2935
|
+
* Creates a singleton offer, from a {@link ZswapTransient}
|
|
2936
|
+
*/
|
|
2937
|
+
static fromTransient<P extends Proofish>(transient: ZswapTransient<P>): ZswapOffer<P>;
|
|
2938
|
+
|
|
2939
|
+
/**
|
|
2940
|
+
* Combine this offer with another
|
|
2941
|
+
*/
|
|
2942
|
+
merge(other: ZswapOffer<P>): ZswapOffer<P>;
|
|
2943
|
+
|
|
2944
|
+
serialize(): Uint8Array;
|
|
2945
|
+
|
|
2946
|
+
static deserialize<P extends Proofish>(markerP: P['instance'], raw: Uint8Array): ZswapOffer<P>;
|
|
2947
|
+
|
|
2948
|
+
toString(compact?: boolean): string;
|
|
2949
|
+
|
|
2950
|
+
/**
|
|
2951
|
+
* The value of this offer for each token type; note that this may be
|
|
2952
|
+
* negative
|
|
2953
|
+
*
|
|
2954
|
+
* This is input coin values - output coin values, for value vectors
|
|
2955
|
+
*/
|
|
2956
|
+
readonly deltas: Map<RawTokenType, bigint>;
|
|
2957
|
+
/**
|
|
2958
|
+
* The inputs this offer is composed of
|
|
2959
|
+
*/
|
|
2960
|
+
readonly inputs: ZswapInput<P>[];
|
|
2961
|
+
/**
|
|
2962
|
+
* The outputs this offer is composed of
|
|
2963
|
+
*/
|
|
2964
|
+
readonly outputs: ZswapOutput<P>[];
|
|
2965
|
+
/**
|
|
2966
|
+
* The transients this offer is composed of
|
|
2967
|
+
*/
|
|
2968
|
+
readonly transients: ZswapTransient<P>[];
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
/**
|
|
2972
|
+
* A privileged transaction issued by the system.
|
|
2973
|
+
*/
|
|
2974
|
+
export class SystemTransaction {
|
|
2975
|
+
private constructor();
|
|
2976
|
+
|
|
2977
|
+
serialize(): Uint8Array;
|
|
2978
|
+
|
|
2979
|
+
static deserialize(raw: Uint8Array): SystemTransaction;
|
|
2980
|
+
|
|
2981
|
+
toString(compact?: boolean): string;
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
/**
|
|
2985
|
+
* A transaction that has not yet been proven.
|
|
2986
|
+
*/
|
|
2987
|
+
export type UnprovenTransaction = Transaction<SignatureEnabled, PreProof, PreBinding>;
|
|
2988
|
+
|
|
2989
|
+
/**
|
|
2990
|
+
* A transaction that has been proven and finalized.
|
|
2991
|
+
*/
|
|
2992
|
+
export type FinalizedTransaction = Transaction<SignatureEnabled, Proof, Binding>;
|
|
2993
|
+
|
|
2994
|
+
/**
|
|
2995
|
+
* A transaction with proofs erased.
|
|
2996
|
+
*/
|
|
2997
|
+
export type ProofErasedTransaction = Transaction<Signaturish, NoProof, NoBinding>;
|