@tari-project/ootle 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +11 -2
- package/dist/index.js +232 -224
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { RistrettoPublicKeyBytes } from '@tari-project/ootle-ts-bindings';
|
|
|
32
32
|
import { StealthTransferStatement as StealthTransferStatement_2 } from '@tari-project/ootle-ts-bindings';
|
|
33
33
|
import { SubstateId } from '@tari-project/ootle-ts-bindings';
|
|
34
34
|
import { SubstateRequirement } from '@tari-project/ootle-ts-bindings';
|
|
35
|
+
import { SubstateValue } from '@tari-project/ootle-ts-bindings';
|
|
35
36
|
import { Transaction } from '@tari-project/ootle-ts-bindings';
|
|
36
37
|
import { TransactionEnvelope } from '@tari-project/ootle-ts-bindings';
|
|
37
38
|
import { TransactionSignature } from '@tari-project/ootle-ts-bindings';
|
|
@@ -1731,8 +1732,9 @@ export declare interface TariMethodDefinition {
|
|
|
1731
1732
|
}
|
|
1732
1733
|
|
|
1733
1734
|
/**
|
|
1734
|
-
* CBOR-encode a
|
|
1735
|
-
*
|
|
1735
|
+
* CBOR-encode a template address as an untagged `bytes(32)`, the encoding of a
|
|
1736
|
+
* template's `TemplateAddress` (`Hash32`) parameter. Accepts either the
|
|
1737
|
+
* `template_<hex>` form or the bare 64-hex-char tail.
|
|
1736
1738
|
*
|
|
1737
1739
|
* @throws {InvalidArgumentError} if the address body is not 32 bytes (64 hex chars).
|
|
1738
1740
|
*/
|
|
@@ -1956,6 +1958,13 @@ export { UnsignedTransactionV1 }
|
|
|
1956
1958
|
*/
|
|
1957
1959
|
export declare type UnsignedTransactionWithBlobs = UnsignedTransactionV1;
|
|
1958
1960
|
|
|
1961
|
+
/**
|
|
1962
|
+
* The value of a fetched substate, or `null` if the indexer answered that the
|
|
1963
|
+
* requested version is down (only possible for a request with `include_proof`
|
|
1964
|
+
* that names the version).
|
|
1965
|
+
*/
|
|
1966
|
+
export declare function upSubstateValue(response: IndexerGetSubstateResponse): SubstateValue | null;
|
|
1967
|
+
|
|
1959
1968
|
/**
|
|
1960
1969
|
* CBOR-encode a `UtxoAddress` as `Tag(141, [ResourceAddress, UtxoId])`, where the
|
|
1961
1970
|
* `UtxoId` is the 32-byte commitment byte string.
|
package/dist/index.js
CHANGED
|
@@ -66,146 +66,150 @@ function x(e11) {
|
|
|
66
66
|
for (let n2 = 0; n2 < t2.length; n2++) t2[n2] = parseInt(e11.substring(n2 * 2, n2 * 2 + 2), 16);
|
|
67
67
|
return t2;
|
|
68
68
|
}
|
|
69
|
-
var S = (1n << 64n) - 1n, le = 2n, C = 32, ue = C * 2, de = 32, fe = 128, pe = 129, me = 130,
|
|
69
|
+
var S = (1n << 64n) - 1n, le = 2n, C = 32, ue = C * 2, de = 32, fe = 128, pe = 129, me = 130, he = 131, ge = 132, _e = 136, ve = 138, ye = 141, w = 0, be = 32, T = 64, xe = 96, E = 128, Se = 160, D = 192;
|
|
70
70
|
function Ce(e11) {
|
|
71
71
|
switch (typeof e11) {
|
|
72
72
|
case "bigint":
|
|
73
|
-
return
|
|
73
|
+
return O(e11);
|
|
74
74
|
case "string":
|
|
75
75
|
return Ee(e11);
|
|
76
76
|
case "boolean":
|
|
77
77
|
return De(e11);
|
|
78
78
|
default:
|
|
79
|
-
if (e11 instanceof Uint8Array) return
|
|
79
|
+
if (e11 instanceof Uint8Array) return k(e11);
|
|
80
80
|
throw new v(`literalArg: cannot CBOR-encode value of type ${typeof e11}`);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function O(e11) {
|
|
84
84
|
if (e11 < 0n) throw new v(`amountLiteral: amount must be non-negative, got ${e11}`);
|
|
85
85
|
if (e11 >> 128n != 0n) throw new v(`amountLiteral: amount overflows u128: ${e11}`);
|
|
86
86
|
let t2 = [];
|
|
87
|
-
return e11 <= S ?
|
|
87
|
+
return e11 <= S ? F(t2, w, e11) : we(t2, e11), I(t2);
|
|
88
88
|
}
|
|
89
89
|
function we(e11, t2) {
|
|
90
90
|
let n2 = [], r2 = t2;
|
|
91
91
|
for (; r2 > 0n; ) n2.unshift(Number(r2 & 255n)), r2 >>= 8n;
|
|
92
|
-
|
|
92
|
+
F(e11, D, le), F(e11, T, BigInt(n2.length)), P(e11, n2);
|
|
93
93
|
}
|
|
94
94
|
function Te(e11) {
|
|
95
95
|
let t2 = [];
|
|
96
96
|
if (e11 >= 0n) {
|
|
97
97
|
if (e11 > S) throw new v(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
|
|
98
|
-
|
|
98
|
+
F(t2, w, e11);
|
|
99
99
|
} else {
|
|
100
100
|
let n2 = -1n - e11;
|
|
101
101
|
if (n2 > S) throw new v(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
|
|
102
|
-
|
|
102
|
+
F(t2, be, n2);
|
|
103
103
|
}
|
|
104
|
-
return
|
|
104
|
+
return I(t2);
|
|
105
105
|
}
|
|
106
106
|
function Ee(e11) {
|
|
107
107
|
let t2 = [];
|
|
108
|
-
return
|
|
108
|
+
return N(t2, e11), I(t2);
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function k(e11) {
|
|
111
111
|
let t2 = [];
|
|
112
|
-
return
|
|
112
|
+
return F(t2, T, BigInt(e11.length)), P(t2, e11), I(t2);
|
|
113
113
|
}
|
|
114
114
|
function De(e11) {
|
|
115
115
|
return { Literal: e11 ? "f5" : "f4" };
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
return
|
|
117
|
+
function A(e11) {
|
|
118
|
+
return j(he, e11, "resource_");
|
|
119
119
|
}
|
|
120
120
|
function Oe(e11) {
|
|
121
|
-
return
|
|
121
|
+
return j(fe, e11, "component_");
|
|
122
122
|
}
|
|
123
123
|
function ke(e11) {
|
|
124
|
-
let t2 = e11 instanceof Map ? e11 : new Map(Object.entries(e11)), n2 = new TextEncoder(), r2 = [...t2.entries()].sort(([e12], [t3]) =>
|
|
125
|
-
|
|
126
|
-
for (let [e12, t3] of r2)
|
|
127
|
-
return
|
|
124
|
+
let t2 = e11 instanceof Map ? e11 : new Map(Object.entries(e11)), n2 = new TextEncoder(), r2 = [...t2.entries()].sort(([e12], [t3]) => Be(n2.encode(e12), n2.encode(t3))), i2 = [];
|
|
125
|
+
F(i2, D, BigInt(pe)), F(i2, Se, BigInt(r2.length));
|
|
126
|
+
for (let [e12, t3] of r2) N(i2, e12), N(i2, t3);
|
|
127
|
+
return I(i2);
|
|
128
128
|
}
|
|
129
129
|
function Ae(e11) {
|
|
130
|
-
return
|
|
130
|
+
return j(ge, e11, "vault_");
|
|
131
131
|
}
|
|
132
132
|
function je(e11) {
|
|
133
|
-
return
|
|
133
|
+
return k(Le(e11, "template_"));
|
|
134
134
|
}
|
|
135
135
|
function Me(e11) {
|
|
136
|
-
return
|
|
136
|
+
return j(_e, e11, "tombstone_");
|
|
137
137
|
}
|
|
138
138
|
function Ne(e11) {
|
|
139
|
-
return
|
|
139
|
+
return j(ve, e11, "vnfp_");
|
|
140
140
|
}
|
|
141
141
|
function Pe(e11) {
|
|
142
142
|
let t2 = typeof e11 == "string" ? x(e11) : e11;
|
|
143
|
-
return y(t2, de, "publicKeyLiteral"),
|
|
143
|
+
return y(t2, de, "publicKeyLiteral"), k(t2);
|
|
144
144
|
}
|
|
145
145
|
function Fe(e11) {
|
|
146
146
|
let t2 = [];
|
|
147
|
-
return
|
|
147
|
+
return F(t2, D, BigInt(me)), F(t2, E, 2n), M(t2, he, e11.resource_address, "resource_"), Re(t2, e11.id), I(t2);
|
|
148
148
|
}
|
|
149
149
|
function Ie(e11) {
|
|
150
150
|
let t2 = [];
|
|
151
|
-
|
|
151
|
+
F(t2, D, BigInt(ye)), F(t2, E, 2n), M(t2, he, e11.resource_address, "resource_");
|
|
152
152
|
let n2 = x(e11.id);
|
|
153
|
-
return y(n2, C, "utxoAddressLiteral: id"),
|
|
153
|
+
return y(n2, C, "utxoAddressLiteral: id"), F(t2, T, BigInt(C)), P(t2, n2), I(t2);
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function j(e11, t2, n2) {
|
|
156
156
|
let r2 = [];
|
|
157
|
-
return
|
|
157
|
+
return M(r2, e11, t2, n2), I(r2);
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
let i2 = n2
|
|
161
|
-
|
|
162
|
-
I(e11, O, BigInt(t2)), I(e11, E, BigInt(C)), F(e11, x(i2));
|
|
159
|
+
function M(e11, t2, n2, r2) {
|
|
160
|
+
let i2 = Le(n2, r2);
|
|
161
|
+
F(e11, D, BigInt(t2)), F(e11, T, BigInt(C)), P(e11, i2);
|
|
163
162
|
}
|
|
164
163
|
function Le(e11, t2) {
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
let n2 = e11.startsWith(t2) ? e11.slice(t2.length) : e11;
|
|
165
|
+
if (n2.length !== ue) throw new v(`${t2}address must be 32 bytes (${ue} hex chars), got ${n2.length}`);
|
|
166
|
+
return x(n2);
|
|
167
|
+
}
|
|
168
|
+
function Re(e11, t2) {
|
|
169
|
+
if (F(e11, E, 2n), "U256" in t2) {
|
|
170
|
+
F(e11, w, 0n), F(e11, E, 1n);
|
|
167
171
|
let n2 = x(t2.U256);
|
|
168
|
-
y(n2, C, "NonFungibleId.U256"),
|
|
169
|
-
} else if ("String" in t2)
|
|
170
|
-
else if ("Uint32" in t2)
|
|
171
|
-
else if ("Uint64" in t2)
|
|
172
|
+
y(n2, C, "NonFungibleId.U256"), F(e11, T, BigInt(C)), P(e11, n2);
|
|
173
|
+
} else if ("String" in t2) F(e11, w, 1n), F(e11, E, 1n), N(e11, t2.String);
|
|
174
|
+
else if ("Uint32" in t2) F(e11, w, 2n), F(e11, E, 1n), ze(e11, t2.Uint32, "NonFungibleId.Uint32", (1n << 32n) - 1n);
|
|
175
|
+
else if ("Uint64" in t2) F(e11, w, 3n), F(e11, E, 1n), ze(e11, t2.Uint64, "NonFungibleId.Uint64", S);
|
|
172
176
|
else throw new v(`nonFungibleAddressLiteral: unrecognised NonFungibleId variant: ${JSON.stringify(t2)}`);
|
|
173
177
|
}
|
|
174
|
-
function
|
|
178
|
+
function ze(e11, t2, n2, r2) {
|
|
175
179
|
if (!Number.isInteger(t2) || t2 < 0) throw new v(`${n2} must be a non-negative integer, got ${t2}`);
|
|
176
180
|
if (r2 > BigInt(2 ** 53 - 1) && t2 > 2 ** 53 - 1) throw new v(`${n2} value ${t2} exceeds Number.MAX_SAFE_INTEGER (2^53-1) and cannot be encoded without precision loss \u2014 the binding types this id as a JS number. Use a U256/String id for large values.`);
|
|
177
181
|
let i2 = BigInt(t2);
|
|
178
182
|
if (i2 > r2) throw new v(`${n2} value ${t2} exceeds its maximum of ${r2}`);
|
|
179
|
-
|
|
183
|
+
F(e11, w, i2);
|
|
180
184
|
}
|
|
181
|
-
function
|
|
185
|
+
function N(e11, t2) {
|
|
182
186
|
let n2 = new TextEncoder().encode(t2);
|
|
183
|
-
|
|
187
|
+
F(e11, xe, BigInt(n2.length)), P(e11, n2);
|
|
184
188
|
}
|
|
185
|
-
function
|
|
189
|
+
function P(e11, t2) {
|
|
186
190
|
let n2 = e11.length;
|
|
187
191
|
e11.length = n2 + t2.length;
|
|
188
192
|
for (let r2 = 0; r2 < t2.length; r2++) e11[n2 + r2] = t2[r2];
|
|
189
193
|
}
|
|
190
|
-
function
|
|
194
|
+
function Be(e11, t2) {
|
|
191
195
|
let n2 = Math.min(e11.length, t2.length);
|
|
192
196
|
for (let r2 = 0; r2 < n2; r2++) if (e11[r2] !== t2[r2]) return e11[r2] < t2[r2] ? -1 : 1;
|
|
193
197
|
return e11.length - t2.length;
|
|
194
198
|
}
|
|
195
|
-
function
|
|
199
|
+
function F(e11, t2, n2) {
|
|
196
200
|
n2 < 24n ? e11.push(t2 | Number(n2)) : n2 < 1n << 8n ? e11.push(t2 | 24, Number(n2)) : n2 < 1n << 16n ? e11.push(t2 | 25, Number(n2 >> 8n & 255n), Number(n2 & 255n)) : n2 < 1n << 32n ? e11.push(t2 | 26, Number(n2 >> 24n & 255n), Number(n2 >> 16n & 255n), Number(n2 >> 8n & 255n), Number(n2 & 255n)) : e11.push(t2 | 27, Number(n2 >> 56n & 255n), Number(n2 >> 48n & 255n), Number(n2 >> 40n & 255n), Number(n2 >> 32n & 255n), Number(n2 >> 24n & 255n), Number(n2 >> 16n & 255n), Number(n2 >> 8n & 255n), Number(n2 & 255n));
|
|
197
201
|
}
|
|
198
|
-
function
|
|
202
|
+
function I(e11) {
|
|
199
203
|
return { Literal: b(Uint8Array.from(e11)) };
|
|
200
204
|
}
|
|
201
|
-
function
|
|
202
|
-
return
|
|
205
|
+
function L(e11) {
|
|
206
|
+
return O(e11);
|
|
203
207
|
}
|
|
204
|
-
function
|
|
208
|
+
function Ve(e11) {
|
|
205
209
|
if (e11 < 0n) throw new v(`microTariString: amount must be non-negative, got ${e11}`);
|
|
206
210
|
return e11.toString();
|
|
207
211
|
}
|
|
208
|
-
function
|
|
212
|
+
function He(e11) {
|
|
209
213
|
let t2 = e11.split(".");
|
|
210
214
|
if (t2.length > 2) throw new v("Invalid workspace key format. Only one dot is allowed.");
|
|
211
215
|
let n2 = t2[0];
|
|
@@ -220,24 +224,24 @@ function Ve(e11) {
|
|
|
220
224
|
offset: r2
|
|
221
225
|
};
|
|
222
226
|
}
|
|
223
|
-
var
|
|
224
|
-
async function
|
|
227
|
+
var Ue = 2160, We = 10;
|
|
228
|
+
async function Ge(e11, t2 = 10) {
|
|
225
229
|
if (!Number.isInteger(t2) || t2 < 1) throw new v(`resolveMaxEpoch: leadEpochs must be a positive integer, got ${t2}`);
|
|
226
|
-
if (t2 > 2160) throw new v(`resolveMaxEpoch: leadEpochs ${t2} exceeds the network's maximum validity window of ${
|
|
230
|
+
if (t2 > 2160) throw new v(`resolveMaxEpoch: leadEpochs ${t2} exceeds the network's maximum validity window of ${Ue} epochs`);
|
|
227
231
|
return await e11.getCurrentEpoch() + t2;
|
|
228
232
|
}
|
|
229
|
-
var
|
|
230
|
-
function
|
|
233
|
+
var Ke = (1n << 64n) - 1n;
|
|
234
|
+
function R(e11, t2) {
|
|
231
235
|
if (!Number.isInteger(e11) || e11 < 0) throw new v(`${t2} must be a non-negative integer epoch, got ${e11}`);
|
|
232
236
|
return e11;
|
|
233
237
|
}
|
|
234
|
-
function
|
|
238
|
+
function qe(e11) {
|
|
235
239
|
return e11.startsWith("template_") ? e11.slice(9) : e11;
|
|
236
240
|
}
|
|
237
|
-
function
|
|
241
|
+
function Je(e11) {
|
|
238
242
|
return typeof e11 != "object" || !e11 ? null : "PutLastInstructionOutputOnWorkspace" in e11 ? e11.PutLastInstructionOutputOnWorkspace.key : "TakeFromBucket" in e11 ? e11.TakeFromBucket.output_bucket : "AllocateAddress" in e11 ? e11.AllocateAddress.workspace_id : null;
|
|
239
243
|
}
|
|
240
|
-
var
|
|
244
|
+
var Ye = class {
|
|
241
245
|
constructor() {
|
|
242
246
|
__publicField(this, "nextId", 0);
|
|
243
247
|
__publicField(this, "ids", /* @__PURE__ */ new Map());
|
|
@@ -261,15 +265,15 @@ var Je = class {
|
|
|
261
265
|
resetFrom(e11) {
|
|
262
266
|
this.reset();
|
|
263
267
|
for (let t2 of e11) {
|
|
264
|
-
let e12 =
|
|
268
|
+
let e12 = Je(t2);
|
|
265
269
|
e12 !== null && this.observeAllocated(e12);
|
|
266
270
|
}
|
|
267
271
|
}
|
|
268
272
|
};
|
|
269
|
-
function
|
|
273
|
+
function Xe(e11) {
|
|
270
274
|
return new v(`No workspace variable named "${e11}" has been defined. Call builder.saveVar(${JSON.stringify(e11)}) on a preceding instruction whose output you want to reference.`);
|
|
271
275
|
}
|
|
272
|
-
var
|
|
276
|
+
var z = class e2 {
|
|
273
277
|
constructor(e11, t2) {
|
|
274
278
|
__publicField(this, "unsignedTransaction");
|
|
275
279
|
__publicField(this, "workspaceIds");
|
|
@@ -280,12 +284,12 @@ var B = class e2 {
|
|
|
280
284
|
instructions: [],
|
|
281
285
|
inputs: [],
|
|
282
286
|
min_epoch: null,
|
|
283
|
-
max_epoch:
|
|
287
|
+
max_epoch: R(t2, "maxEpoch"),
|
|
284
288
|
dry_run: false,
|
|
285
289
|
is_seal_signer_authorized: false,
|
|
286
290
|
blobs: [],
|
|
287
291
|
nonce: 0
|
|
288
|
-
}, this.workspaceIds = new
|
|
292
|
+
}, this.workspaceIds = new Ye(), this.feeWorkspaceIds = new Ye();
|
|
289
293
|
}
|
|
290
294
|
static new(t2, n2) {
|
|
291
295
|
return new e2(t2, n2);
|
|
@@ -293,7 +297,7 @@ var B = class e2 {
|
|
|
293
297
|
callFunction(e11, t2) {
|
|
294
298
|
let n2 = this.resolveArgs(t2);
|
|
295
299
|
return this.addInstruction({ CallFunction: {
|
|
296
|
-
address:
|
|
300
|
+
address: qe(e11.templateAddress),
|
|
297
301
|
function: e11.functionName,
|
|
298
302
|
args: n2
|
|
299
303
|
} });
|
|
@@ -323,7 +327,7 @@ var B = class e2 {
|
|
|
323
327
|
return this.addInstruction({ CallMethod: {
|
|
324
328
|
call: { Address: e11 },
|
|
325
329
|
method: "create_proof_for_resource",
|
|
326
|
-
args: [
|
|
330
|
+
args: [A(t2)]
|
|
327
331
|
} });
|
|
328
332
|
}
|
|
329
333
|
claimBurn(e11, t2) {
|
|
@@ -347,7 +351,7 @@ var B = class e2 {
|
|
|
347
351
|
return this.addFeeInstruction({ CallMethod: {
|
|
348
352
|
call: { Address: e11 },
|
|
349
353
|
method: "pay_fee",
|
|
350
|
-
args: [
|
|
354
|
+
args: [L(t2)]
|
|
351
355
|
} });
|
|
352
356
|
}
|
|
353
357
|
feeTransactionPayFromComponentConfidential(e11, t2) {
|
|
@@ -377,7 +381,7 @@ var B = class e2 {
|
|
|
377
381
|
}
|
|
378
382
|
observeAllocations(e11, t2) {
|
|
379
383
|
for (let n2 of t2) {
|
|
380
|
-
let t3 =
|
|
384
|
+
let t3 = Je(n2);
|
|
381
385
|
t3 !== null && e11.observeAllocated(t3);
|
|
382
386
|
}
|
|
383
387
|
}
|
|
@@ -386,21 +390,21 @@ var B = class e2 {
|
|
|
386
390
|
return this.unsignedTransaction.fee_instructions = n2.unsignedTransaction.instructions, this.feeWorkspaceIds.resetFrom(this.unsignedTransaction.fee_instructions), this;
|
|
387
391
|
}
|
|
388
392
|
addInput(e11) {
|
|
389
|
-
return this.unsignedTransaction.inputs.push(
|
|
393
|
+
return this.unsignedTransaction.inputs.push(Ze(e11)), this;
|
|
390
394
|
}
|
|
391
395
|
withInputs(e11) {
|
|
392
|
-
return this.unsignedTransaction.inputs.push(...e11.map(
|
|
396
|
+
return this.unsignedTransaction.inputs.push(...e11.map(Ze)), this;
|
|
393
397
|
}
|
|
394
398
|
withMinEpoch(e11) {
|
|
395
|
-
return this.unsignedTransaction.min_epoch =
|
|
399
|
+
return this.unsignedTransaction.min_epoch = R(e11, "minEpoch"), this;
|
|
396
400
|
}
|
|
397
401
|
withMaxEpoch(e11) {
|
|
398
|
-
return this.unsignedTransaction.max_epoch =
|
|
402
|
+
return this.unsignedTransaction.max_epoch = R(e11, "maxEpoch"), this;
|
|
399
403
|
}
|
|
400
404
|
withNonce(e11) {
|
|
401
405
|
if (typeof e11 == "number" && !Number.isInteger(e11)) throw new v(`withNonce: nonce must be an integer, got ${e11}`);
|
|
402
406
|
let t2 = typeof e11 == "bigint" ? e11 : BigInt(e11);
|
|
403
|
-
if (t2 < 0n || t2 >
|
|
407
|
+
if (t2 < 0n || t2 > Ke) throw new v(`withNonce: nonce must fit an unsigned 64-bit integer, got ${e11}`);
|
|
404
408
|
return this.unsignedTransaction.nonce = t2 > BigInt(2 ** 53 - 1) ? t2 : Number(t2), this;
|
|
405
409
|
}
|
|
406
410
|
withUnsignedTransaction(e11) {
|
|
@@ -411,7 +415,7 @@ var B = class e2 {
|
|
|
411
415
|
inputs: [...e11.inputs],
|
|
412
416
|
blobs: [...e11.blobs ?? []],
|
|
413
417
|
nonce: e11.nonce ?? 0,
|
|
414
|
-
max_epoch:
|
|
418
|
+
max_epoch: R(e11.max_epoch, "withUnsignedTransaction: max_epoch")
|
|
415
419
|
}, this.workspaceIds.resetFrom(this.unsignedTransaction.instructions), this.feeWorkspaceIds.resetFrom(this.unsignedTransaction.fee_instructions), this;
|
|
416
420
|
}
|
|
417
421
|
resolveWorkspaceOffsetId(e11) {
|
|
@@ -431,11 +435,11 @@ var B = class e2 {
|
|
|
431
435
|
}
|
|
432
436
|
requireNamedId(e11) {
|
|
433
437
|
let t2 = this.workspaceIds.get(e11);
|
|
434
|
-
if (t2 === void 0) throw
|
|
438
|
+
if (t2 === void 0) throw Xe(e11);
|
|
435
439
|
return t2;
|
|
436
440
|
}
|
|
437
441
|
getOffsetIdFromWorkspaceName(e11) {
|
|
438
|
-
let t2 =
|
|
442
|
+
let t2 = He(e11);
|
|
439
443
|
return {
|
|
440
444
|
id: this.requireNamedId(t2.name),
|
|
441
445
|
offset: t2.offset
|
|
@@ -445,30 +449,33 @@ var B = class e2 {
|
|
|
445
449
|
return e11.map((e12) => typeof e12 == "object" && e12 && "Workspace" in e12 && typeof e12.Workspace == "string" ? { Workspace: this.getOffsetIdFromWorkspaceName(e12.Workspace) } : e12);
|
|
446
450
|
}
|
|
447
451
|
};
|
|
448
|
-
function
|
|
452
|
+
function Ze(e11) {
|
|
449
453
|
return {
|
|
450
454
|
substate_id: e11.substate_id,
|
|
451
455
|
version: e11.version,
|
|
452
456
|
is_write: "is_write" in e11 ? e11.is_write : true
|
|
453
457
|
};
|
|
454
458
|
}
|
|
455
|
-
var
|
|
459
|
+
var Qe = {
|
|
456
460
|
[u.LocalNet]: "http://localhost:12500",
|
|
457
461
|
[u.Esmeralda]: "https://ootle-indexer-a.tari.com"
|
|
458
462
|
};
|
|
459
|
-
function
|
|
460
|
-
let t2 =
|
|
463
|
+
function $e(e11) {
|
|
464
|
+
let t2 = Qe[e11];
|
|
461
465
|
if (t2 !== void 0) return t2;
|
|
462
466
|
throw new v(`No default indexer URL is configured for ${u[e11]}. Pass an explicit URL via ProviderBuilder.withUrl(...) or IndexerProvider.connect({ url, network: Network.${u[e11]} }).`);
|
|
463
467
|
}
|
|
464
|
-
|
|
465
|
-
|
|
468
|
+
function B(e11) {
|
|
469
|
+
return "up" in e11.state ? e11.state.up.substate : null;
|
|
470
|
+
}
|
|
471
|
+
var et = 132, tt = 32;
|
|
472
|
+
function* nt(e11) {
|
|
466
473
|
let t2 = /* @__PURE__ */ new Set();
|
|
467
|
-
for (let n2 of V(e11,
|
|
474
|
+
for (let n2 of V(e11, et)) n2.length === tt * 2 && !t2.has(n2) && (t2.add(n2), yield `vault_${n2}`);
|
|
468
475
|
}
|
|
469
|
-
async function
|
|
470
|
-
let n2 = (await e11.getSubstate(t2))
|
|
471
|
-
return
|
|
476
|
+
async function rt(e11, t2) {
|
|
477
|
+
let n2 = B(await e11.getSubstate(t2));
|
|
478
|
+
return at(n2) ? Array.from(nt(n2.Component.body.state)) : [];
|
|
472
479
|
}
|
|
473
480
|
function* V(e11, t2) {
|
|
474
481
|
if (Array.isArray(e11)) {
|
|
@@ -481,7 +488,7 @@ function* V(e11, t2) {
|
|
|
481
488
|
if (r2 === "tag") {
|
|
482
489
|
let e12 = n2.value;
|
|
483
490
|
if (n2.tag === t2) {
|
|
484
|
-
let t3 =
|
|
491
|
+
let t3 = it(e12);
|
|
485
492
|
t3 !== null && (yield t3);
|
|
486
493
|
}
|
|
487
494
|
yield* V(e12, t2);
|
|
@@ -493,18 +500,18 @@ function* V(e11, t2) {
|
|
|
493
500
|
}
|
|
494
501
|
for (let e12 of Object.values(n2)) yield* V(e12, t2);
|
|
495
502
|
}
|
|
496
|
-
function
|
|
503
|
+
function it(e11) {
|
|
497
504
|
if (typeof e11 != "object" || !e11) return null;
|
|
498
505
|
let t2 = e11;
|
|
499
506
|
if (t2["@cbor"] !== "bytes") return null;
|
|
500
507
|
let n2 = t2.hex;
|
|
501
508
|
return typeof n2 == "string" ? n2 : null;
|
|
502
509
|
}
|
|
503
|
-
function
|
|
510
|
+
function at(e11) {
|
|
504
511
|
return typeof e11 == "object" && !!e11 && "Component" in e11;
|
|
505
512
|
}
|
|
506
|
-
var
|
|
507
|
-
function
|
|
513
|
+
var ot = "resource_0101010101010101010101010101010101010101010101010101010101010101", st = "component_0102030000000000000000000000000000000000000000000000000000000000", ct = "vault_0102030000000000000000000000000000000000000000000000000000000001", lt = "resource_0102030000000000000000000000000000000000000000000000000000000002", ut = "__ootleRawJson", dt = "stealth_revealed_input", ft = "stealth_revealed_change";
|
|
514
|
+
function pt(e11, t2) {
|
|
508
515
|
let n2 = e11.revealedInputBucket === null ? null : t2(e11.revealedInputBucket);
|
|
509
516
|
return { StealthTransfer: {
|
|
510
517
|
resource_address_ref: { Address: e11.resourceAddress },
|
|
@@ -513,7 +520,7 @@ function ft(e11, t2) {
|
|
|
513
520
|
} };
|
|
514
521
|
}
|
|
515
522
|
function H(e11) {
|
|
516
|
-
return { [
|
|
523
|
+
return { [ut]: e11.toCompactJson() };
|
|
517
524
|
}
|
|
518
525
|
function U(e11) {
|
|
519
526
|
return typeof e11 == "object" && !!e11 && "StealthTransfer" in e11;
|
|
@@ -523,7 +530,7 @@ function W(e11) {
|
|
|
523
530
|
if (typeof r3 == "bigint") return r3.toString();
|
|
524
531
|
if (typeof r3 == "object" && r3 && "__ootleRawJson" in r3) {
|
|
525
532
|
let e13 = n2(t2.length);
|
|
526
|
-
return t2.push(r3[
|
|
533
|
+
return t2.push(r3[ut]), e13;
|
|
527
534
|
}
|
|
528
535
|
return r3;
|
|
529
536
|
});
|
|
@@ -542,14 +549,14 @@ async function G(e11, t2) {
|
|
|
542
549
|
inputs: n2
|
|
543
550
|
};
|
|
544
551
|
}
|
|
545
|
-
function
|
|
552
|
+
function mt() {
|
|
546
553
|
let { secret_key: e11, public_key: t2 } = a();
|
|
547
554
|
return {
|
|
548
555
|
secret_key: e11,
|
|
549
556
|
public_key: t2
|
|
550
557
|
};
|
|
551
558
|
}
|
|
552
|
-
function
|
|
559
|
+
function ht(e11, t2) {
|
|
553
560
|
return {
|
|
554
561
|
public_key: b(y(e11, 32, "publicKey")),
|
|
555
562
|
signature: {
|
|
@@ -573,10 +580,10 @@ async function K(e11, t2, n2) {
|
|
|
573
580
|
function q(e11) {
|
|
574
581
|
return t(e11.sealedJson);
|
|
575
582
|
}
|
|
576
|
-
async function
|
|
583
|
+
async function gt(e11, t2) {
|
|
577
584
|
return (await e11.submitTransaction(t2)).transaction_id;
|
|
578
585
|
}
|
|
579
|
-
function
|
|
586
|
+
function _t(e11) {
|
|
580
587
|
var _a, _b;
|
|
581
588
|
if (e11 === "Pending" || !("Finalized" in e11)) return null;
|
|
582
589
|
let t2 = e11.Finalized, n2 = t2.final_decision;
|
|
@@ -594,12 +601,12 @@ function gt(e11) {
|
|
|
594
601
|
}
|
|
595
602
|
throw new v(`Unexpected final_decision variant: ${JSON.stringify(n2)}`);
|
|
596
603
|
}
|
|
597
|
-
async function
|
|
604
|
+
async function vt(e11, t2, n2) {
|
|
598
605
|
let r2 = (n2 == null ? void 0 : n2.pollIntervalMs) ?? 500, i2 = (n2 == null ? void 0 : n2.timeoutMs) ?? 6e4, a2 = Date.now() + i2;
|
|
599
606
|
for (; ; ) {
|
|
600
607
|
let n3 = await e11.getTransactionResult(t2), o2 = n3.result;
|
|
601
608
|
if (o2 !== "Pending" && "Finalized" in o2) {
|
|
602
|
-
let { outcome: e12, reason: r3 } =
|
|
609
|
+
let { outcome: e12, reason: r3 } = _t(o2) ?? { outcome: "Reject" };
|
|
603
610
|
if (e12 === "Reject") throw new f(`Transaction ${t2} was rejected: ${r3}`, {
|
|
604
611
|
txId: t2,
|
|
605
612
|
reason: r3 ?? ""
|
|
@@ -614,20 +621,20 @@ async function _t(e11, t2, n2) {
|
|
|
614
621
|
await new Promise((e12) => setTimeout(e12, r2));
|
|
615
622
|
}
|
|
616
623
|
}
|
|
617
|
-
async function
|
|
624
|
+
async function yt(e11, t2, n2, r2) {
|
|
618
625
|
let i2 = await G(e11, n2);
|
|
619
|
-
return
|
|
626
|
+
return vt(e11, await gt(e11, q(await K(Array.isArray(t2) ? t2 : [t2], i2))), r2);
|
|
620
627
|
}
|
|
621
|
-
async function
|
|
622
|
-
return
|
|
628
|
+
async function bt(e11, t2, n2, r2) {
|
|
629
|
+
return yt(e11, t2, {
|
|
623
630
|
...n2,
|
|
624
631
|
dry_run: true
|
|
625
632
|
}, r2);
|
|
626
633
|
}
|
|
627
|
-
var
|
|
634
|
+
var xt = class {
|
|
628
635
|
constructor(e11, t2) {
|
|
629
636
|
__publicField(this, "builder");
|
|
630
|
-
this.builder =
|
|
637
|
+
this.builder = z.new(e11, t2);
|
|
631
638
|
}
|
|
632
639
|
withInputs(e11) {
|
|
633
640
|
return this.builder.withInputs(e11), this;
|
|
@@ -639,7 +646,7 @@ var bt = class {
|
|
|
639
646
|
return this.builder.callMethod({
|
|
640
647
|
componentAddress: e11,
|
|
641
648
|
methodName: "withdraw"
|
|
642
|
-
}, [
|
|
649
|
+
}, [A(t2), L(n2)]).saveVar("bucket").callMethod({
|
|
643
650
|
componentAddress: r2,
|
|
644
651
|
methodName: "deposit"
|
|
645
652
|
}, [{ Workspace: "bucket" }]), this;
|
|
@@ -650,11 +657,11 @@ var bt = class {
|
|
|
650
657
|
build() {
|
|
651
658
|
return this.builder.buildUnsignedTransaction();
|
|
652
659
|
}
|
|
653
|
-
},
|
|
660
|
+
}, St = class {
|
|
654
661
|
constructor(e11, t2, n2) {
|
|
655
662
|
__publicField(this, "builder");
|
|
656
663
|
__publicField(this, "faucetAddress");
|
|
657
|
-
this.builder =
|
|
664
|
+
this.builder = z.new(e11, t2), this.faucetAddress = n2;
|
|
658
665
|
}
|
|
659
666
|
feeTransactionPayFromComponent(e11, t2) {
|
|
660
667
|
return this.builder.feeTransactionPayFromComponent(e11, t2), this;
|
|
@@ -663,7 +670,7 @@ var bt = class {
|
|
|
663
670
|
return this.builder.callMethod({
|
|
664
671
|
componentAddress: this.faucetAddress,
|
|
665
672
|
methodName: "take_free_coins"
|
|
666
|
-
}, [
|
|
673
|
+
}, [L(t2)]).saveVar("faucet_bucket").callMethod({
|
|
667
674
|
componentAddress: e11,
|
|
668
675
|
methodName: "deposit"
|
|
669
676
|
}, [{ Workspace: "faucet_bucket" }]), this;
|
|
@@ -687,7 +694,7 @@ var bt = class {
|
|
|
687
694
|
build() {
|
|
688
695
|
return this.builder.buildUnsignedTransaction();
|
|
689
696
|
}
|
|
690
|
-
},
|
|
697
|
+
}, Ct = class {
|
|
691
698
|
constructor() {
|
|
692
699
|
__publicField(this, "keyProviders");
|
|
693
700
|
__publicField(this, "defaultSignerAddress", null);
|
|
@@ -733,7 +740,7 @@ var bt = class {
|
|
|
733
740
|
if (n2 === void 0) throw new m(t2 === "default" ? `No key provider registered for default address: ${e11}. Call wallet.registerKeyProvider(address, signer) for that address, or pick a different default with setDefaultSigner(otherAddress).` : `No key provider registered for address: ${e11}. Call wallet.registerKeyProvider(${JSON.stringify(e11)}, signer) before signing.`, { address: e11 });
|
|
734
741
|
return n2;
|
|
735
742
|
}
|
|
736
|
-
},
|
|
743
|
+
}, wt = class {
|
|
737
744
|
constructor(e11, t2) {
|
|
738
745
|
__publicField(this, "bytes");
|
|
739
746
|
this.bytes = new Uint8Array(y(e11, 32, t2));
|
|
@@ -744,7 +751,7 @@ var bt = class {
|
|
|
744
751
|
toHex() {
|
|
745
752
|
return b(this.bytes);
|
|
746
753
|
}
|
|
747
|
-
}, J = class e3 extends
|
|
754
|
+
}, J = class e3 extends wt {
|
|
748
755
|
constructor(e11) {
|
|
749
756
|
super(e11, "Mask");
|
|
750
757
|
}
|
|
@@ -757,7 +764,7 @@ var bt = class {
|
|
|
757
764
|
static fromHex(t2) {
|
|
758
765
|
return new e3(x(t2));
|
|
759
766
|
}
|
|
760
|
-
},
|
|
767
|
+
}, Tt = class e4 {
|
|
761
768
|
constructor(e11) {
|
|
762
769
|
__publicField(this, "bytes");
|
|
763
770
|
this.bytes = new Uint8Array(e11);
|
|
@@ -771,8 +778,8 @@ var bt = class {
|
|
|
771
778
|
toHex() {
|
|
772
779
|
return b(this.bytes);
|
|
773
780
|
}
|
|
774
|
-
},
|
|
775
|
-
function
|
|
781
|
+
}, Et = Object.freeze({ StealthPublicKey: Object.freeze({}) });
|
|
782
|
+
function Dt(e11) {
|
|
776
783
|
if (e11.amount <= 0n) throw new v(`Output amount must be > 0, got ${e11.amount}`);
|
|
777
784
|
return {
|
|
778
785
|
destination: e11.destination,
|
|
@@ -780,19 +787,19 @@ function Et(e11) {
|
|
|
780
787
|
resourceAddress: e11.resourceAddress,
|
|
781
788
|
resourceViewKey: e11.resourceViewKey === void 0 ? void 0 : new Uint8Array(e11.resourceViewKey),
|
|
782
789
|
memo: e11.memo,
|
|
783
|
-
payTo: e11.payTo ??
|
|
790
|
+
payTo: e11.payTo ?? Et,
|
|
784
791
|
minimumValuePromise: e11.minimumValuePromise ?? 0n
|
|
785
792
|
};
|
|
786
793
|
}
|
|
787
|
-
function
|
|
794
|
+
function Ot(e11, t2) {
|
|
788
795
|
if (e11.trim() === "") throw new v(`${t2} must be a non-empty decimal string`);
|
|
789
796
|
return BigInt(e11);
|
|
790
797
|
}
|
|
791
|
-
function
|
|
798
|
+
function kt(e11, t2) {
|
|
792
799
|
let n2 = e11.trim();
|
|
793
800
|
if (!n2.startsWith("{") || !n2.endsWith("}")) throw new v(`StealthTransferStatement.toCompactJson: ${t2} fragment is not a JSON object (got: ${e11.slice(0, 60)}...)`);
|
|
794
801
|
}
|
|
795
|
-
var Y = class e5 extends
|
|
802
|
+
var Y = class e5 extends wt {
|
|
796
803
|
constructor(e11) {
|
|
797
804
|
super(e11, "StealthInput.commitment");
|
|
798
805
|
}
|
|
@@ -839,13 +846,13 @@ var Y = class e5 extends Ct {
|
|
|
839
846
|
toJSON() {
|
|
840
847
|
return {
|
|
841
848
|
inputs: this.inputs.map((e11) => e11.toJSON()),
|
|
842
|
-
revealed_amount:
|
|
849
|
+
revealed_amount: Ve(this.revealedAmount)
|
|
843
850
|
};
|
|
844
851
|
}
|
|
845
852
|
static fromJSON(t2) {
|
|
846
|
-
return new e7(t2.inputs.map(Y.fromJSON),
|
|
853
|
+
return new e7(t2.inputs.map(Y.fromJSON), Ot(t2.revealed_amount, "revealed_amount"));
|
|
847
854
|
}
|
|
848
|
-
},
|
|
855
|
+
}, At = class e8 {
|
|
849
856
|
constructor(e11) {
|
|
850
857
|
__publicField(this, "statementJson");
|
|
851
858
|
this.statementJson = e11;
|
|
@@ -859,7 +866,7 @@ var Y = class e5 extends Ct {
|
|
|
859
866
|
static fromJSON(t2) {
|
|
860
867
|
return new e8(t2);
|
|
861
868
|
}
|
|
862
|
-
},
|
|
869
|
+
}, Q = class e9 {
|
|
863
870
|
constructor(e11, t2, n2) {
|
|
864
871
|
__publicField(this, "inputsStatement");
|
|
865
872
|
__publicField(this, "outputsStatement");
|
|
@@ -875,15 +882,15 @@ var Y = class e5 extends Ct {
|
|
|
875
882
|
}
|
|
876
883
|
toCompactJson() {
|
|
877
884
|
let e11 = this.inputsStatement.statementJson ?? JSON.stringify(this.inputsStatement.toJSON()), t2 = this.outputsStatement.statementJson;
|
|
878
|
-
|
|
885
|
+
kt(e11, "inputs_statement"), kt(t2, "outputs_statement");
|
|
879
886
|
let n2 = `{"inputs_statement":${e11},"outputs_statement":${t2},"covenant_claims":[]`;
|
|
880
887
|
return this.balanceProof !== void 0 && (n2 += `,"balance_proof":${JSON.stringify(this.balanceProof.toJSON())}`), n2 + "}";
|
|
881
888
|
}
|
|
882
889
|
static fromJSON(t2) {
|
|
883
|
-
return new e9(Z.fromJSON(t2.inputs),
|
|
890
|
+
return new e9(Z.fromJSON(t2.inputs), At.fromJSON(t2.outputs), t2.balance_proof === void 0 ? void 0 : X.fromJSON(t2.balance_proof));
|
|
884
891
|
}
|
|
885
892
|
};
|
|
886
|
-
function
|
|
893
|
+
function jt(e11, t2) {
|
|
887
894
|
let n2 = new Uint8Array(e11.length * 32);
|
|
888
895
|
for (let r2 = 0; r2 < e11.length; r2++) {
|
|
889
896
|
let i2 = e11[r2];
|
|
@@ -891,7 +898,7 @@ function kt(e11, t2) {
|
|
|
891
898
|
}
|
|
892
899
|
return n2;
|
|
893
900
|
}
|
|
894
|
-
var
|
|
901
|
+
var Mt = "[]", Nt = class {
|
|
895
902
|
constructor(e11 = u.LocalNet) {
|
|
896
903
|
__publicField(this, "network");
|
|
897
904
|
this.network = e11;
|
|
@@ -901,23 +908,23 @@ var At = "[]", jt = class {
|
|
|
901
908
|
t2 !== null && (y(t2.receiver, 32, "revealed output receiver"), r2 = t2.amount, i2 = t2.receiver);
|
|
902
909
|
let a2 = s(n2, r2, i2);
|
|
903
910
|
return y(a2.aggregated_output_mask, 32, "StealthOutputsResult.aggregated_output_mask"), {
|
|
904
|
-
statement:
|
|
911
|
+
statement: At.fromJSON(a2.statement_json),
|
|
905
912
|
outputMask: J.fromBytes(a2.aggregated_output_mask)
|
|
906
913
|
};
|
|
907
914
|
}
|
|
908
915
|
outputWitness(e11) {
|
|
909
|
-
let t2 = c(e11.destination), n2 =
|
|
916
|
+
let t2 = c(e11.destination), n2 = Pt(e11.payTo) ? null : JSON.stringify(e11.payTo), i2 = e11.memo === void 0 ? null : JSON.stringify(e11.memo), a2 = e11.resourceViewKey ?? null;
|
|
910
917
|
return r(this.network, t2.owner_key, t2.view_key, e11.amount, e11.resourceAddress, a2, i2, n2, e11.minimumValuePromise);
|
|
911
918
|
}
|
|
912
919
|
async buildInputsStatement(e11, t2) {
|
|
913
|
-
return new Z(e11, t2, n(
|
|
920
|
+
return new Z(e11, t2, n(jt(e11.map((e12) => e12.commitment), "input commitment"), t2));
|
|
914
921
|
}
|
|
915
922
|
async generateBalanceProofSignature(e11, t2, n2, r2) {
|
|
916
|
-
let i2 = o(e11.toBytes(), t2.toBytes(), n2, r2,
|
|
923
|
+
let i2 = o(e11.toBytes(), t2.toBytes(), n2, r2, Mt);
|
|
917
924
|
return y(i2.public_nonce, 32, "balance proof public_nonce"), y(i2.signature, 32, "balance proof signature"), new X(i2.public_nonce, i2.signature);
|
|
918
925
|
}
|
|
919
926
|
async validateBalanceProofSignature(e11, t2, n2) {
|
|
920
|
-
return ne(e11.publicNonce, e11.signature, t2, n2,
|
|
927
|
+
return ne(e11.publicNonce, e11.signature, t2, n2, Mt);
|
|
921
928
|
}
|
|
922
929
|
async deriveAeadKey(e11, t2) {
|
|
923
930
|
y(e11, 32, "deriveAeadKey privateKey"), y(t2, 32, "deriveAeadKey publicKey");
|
|
@@ -934,7 +941,7 @@ var At = "[]", jt = class {
|
|
|
934
941
|
};
|
|
935
942
|
}
|
|
936
943
|
async aggregateInputMasks(t2) {
|
|
937
|
-
let n2 = e(
|
|
944
|
+
let n2 = e(jt(t2.map((e11) => e11.toBytes()), "input mask"));
|
|
938
945
|
return J.fromBytes(n2);
|
|
939
946
|
}
|
|
940
947
|
async stealthDhSecret(e11, t2, n2) {
|
|
@@ -946,49 +953,49 @@ var At = "[]", jt = class {
|
|
|
946
953
|
re(e11.toCompactJson(), null);
|
|
947
954
|
}
|
|
948
955
|
};
|
|
949
|
-
function
|
|
956
|
+
function Pt(e11) {
|
|
950
957
|
let t2 = Object.keys(e11);
|
|
951
958
|
if (t2.length !== 1 || t2[0] !== "StealthPublicKey") return false;
|
|
952
959
|
let n2 = e11.StealthPublicKey;
|
|
953
960
|
return typeof n2 == "object" && !!n2 && Object.keys(n2).length === 0;
|
|
954
961
|
}
|
|
955
|
-
var
|
|
956
|
-
function
|
|
957
|
-
return `${
|
|
962
|
+
var Ft = "utxo";
|
|
963
|
+
function It(e11, t2) {
|
|
964
|
+
return `${Ft}_${e11.startsWith("resource_") ? e11.slice(9) : e11}_${b(t2)}`;
|
|
958
965
|
}
|
|
959
|
-
var
|
|
960
|
-
function
|
|
966
|
+
var Lt = 64;
|
|
967
|
+
function Rt(e11) {
|
|
961
968
|
return typeof e11 == "object" && !!e11 && "Utxo" in e11;
|
|
962
969
|
}
|
|
963
|
-
function
|
|
970
|
+
function zt(e11) {
|
|
964
971
|
return e11.length > 0 && /^[0-9a-fA-F]+$/.test(e11);
|
|
965
972
|
}
|
|
966
|
-
function
|
|
973
|
+
function Bt(e11) {
|
|
967
974
|
let t2 = e11.split("_");
|
|
968
|
-
if (t2.length < 3 || t2[0] !==
|
|
975
|
+
if (t2.length < 3 || t2[0] !== Ft) return null;
|
|
969
976
|
let n2 = t2[t2.length - 1];
|
|
970
|
-
return n2.length !==
|
|
977
|
+
return n2.length !== Lt || !zt(n2) ? null : x(n2);
|
|
971
978
|
}
|
|
972
|
-
function
|
|
973
|
-
let n2 = e11
|
|
974
|
-
if (!
|
|
979
|
+
function $(e11, t2) {
|
|
980
|
+
let n2 = B(e11);
|
|
981
|
+
if (n2 === null || !Rt(n2)) return null;
|
|
975
982
|
let r2 = n2.Utxo;
|
|
976
983
|
if (r2.output === null || r2.is_frozen) return null;
|
|
977
|
-
let i2 =
|
|
984
|
+
let i2 = Bt(t2);
|
|
978
985
|
return i2 === null ? null : {
|
|
979
986
|
commitment: i2,
|
|
980
987
|
body: r2.output.output
|
|
981
988
|
};
|
|
982
989
|
}
|
|
983
|
-
var
|
|
984
|
-
constructor(e11, t2, n2 = new
|
|
990
|
+
var Vt = 0, Ht = class {
|
|
991
|
+
constructor(e11, t2, n2 = new Nt(e11.network())) {
|
|
985
992
|
__publicField(this, "provider");
|
|
986
993
|
__publicField(this, "crypto");
|
|
987
994
|
__publicField(this, "builder");
|
|
988
995
|
__publicField(this, "state");
|
|
989
996
|
__publicField(this, "maxEpoch", null);
|
|
990
997
|
__publicField(this, "prepared", false);
|
|
991
|
-
this.provider = e11, this.crypto = n2, this.builder =
|
|
998
|
+
this.provider = e11, this.crypto = n2, this.builder = z.new(e11.network(), Vt), this.state = {
|
|
992
999
|
resource: t2,
|
|
993
1000
|
revealedInput: null,
|
|
994
1001
|
inputsToSpend: /* @__PURE__ */ new Map(),
|
|
@@ -1041,8 +1048,8 @@ var Bt = 0, Vt = class {
|
|
|
1041
1048
|
var _a;
|
|
1042
1049
|
if (this.prepared) throw new v("StealthTransfer.prepare: already prepared \u2014 create a new StealthTransfer to build again");
|
|
1043
1050
|
this.validate(), this.prepared = true;
|
|
1044
|
-
let { statement: e11, outputMask: t2 } = await this.crypto.generateOutputsStatement(this.state.outputs, this.state.revealedOutput), n2 = new
|
|
1045
|
-
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch ===
|
|
1051
|
+
let { statement: e11, outputMask: t2 } = await this.crypto.generateOutputsStatement(this.state.outputs, this.state.revealedOutput), n2 = new Q(await this.crypto.buildInputsStatement([...this.state.inputsToSpend.values()].map((e12) => e12.input), ((_a = this.state.revealedInput) == null ? void 0 : _a.amount) ?? 0n), e11, void 0);
|
|
1052
|
+
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch === Vt && this.builder.withMaxEpoch(await Ge(this.provider));
|
|
1046
1053
|
let r2 = /* @__PURE__ */ new Set();
|
|
1047
1054
|
if (this.state.revealedInput !== null) {
|
|
1048
1055
|
let e12 = this.state.revealedInput.source;
|
|
@@ -1050,14 +1057,14 @@ var Bt = 0, Vt = class {
|
|
|
1050
1057
|
substate_id: e12,
|
|
1051
1058
|
version: null
|
|
1052
1059
|
}), r2.add(e12);
|
|
1053
|
-
let t3 = await
|
|
1060
|
+
let t3 = await rt(this.provider, e12);
|
|
1054
1061
|
for (let e13 of t3) r2.has(e13) || (this.builder.addInput({
|
|
1055
1062
|
substate_id: e13,
|
|
1056
1063
|
version: null
|
|
1057
1064
|
}), r2.add(e13));
|
|
1058
1065
|
}
|
|
1059
1066
|
for (let { input: e12 } of this.state.inputsToSpend.values()) {
|
|
1060
|
-
let t3 =
|
|
1067
|
+
let t3 = It(this.state.resource, e12.commitment);
|
|
1061
1068
|
r2.has(t3) || (this.builder.addInput({
|
|
1062
1069
|
substate_id: t3,
|
|
1063
1070
|
version: null
|
|
@@ -1096,38 +1103,38 @@ var Bt = 0, Vt = class {
|
|
|
1096
1103
|
t2 !== null && (this.builder.callMethod({
|
|
1097
1104
|
componentAddress: t2.source,
|
|
1098
1105
|
methodName: "withdraw"
|
|
1099
|
-
}, [
|
|
1106
|
+
}, [A(this.state.resource), O(t2.amount)]).saveVar(dt), n2 = dt), this.builder.addInstruction(pt({
|
|
1100
1107
|
resourceAddress: this.state.resource,
|
|
1101
1108
|
revealedInputBucket: n2,
|
|
1102
1109
|
statement: e11
|
|
1103
|
-
}, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutput !== null && t2 !== null && this.builder.saveVar(
|
|
1110
|
+
}, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutput !== null && t2 !== null && this.builder.saveVar(ft).callMethod({
|
|
1104
1111
|
componentAddress: t2.source,
|
|
1105
1112
|
methodName: "deposit"
|
|
1106
|
-
}, [{ Workspace:
|
|
1113
|
+
}, [{ Workspace: ft }]);
|
|
1107
1114
|
}
|
|
1108
1115
|
};
|
|
1109
|
-
function
|
|
1110
|
-
if (
|
|
1116
|
+
function Ut(e11) {
|
|
1117
|
+
if (Wt(e11) || e11.statementJson !== void 0) return e11.statementJson;
|
|
1111
1118
|
if (e11.inputs.length > 0) throw new _("inputs statement has confidential inputs but no WASM statementJson \u2014 call buildInputsStatement first", { context: "statementJsonFor" });
|
|
1112
1119
|
return JSON.stringify(e11.toJSON());
|
|
1113
1120
|
}
|
|
1114
|
-
function
|
|
1121
|
+
function Wt(e11) {
|
|
1115
1122
|
return !("inputs" in e11);
|
|
1116
1123
|
}
|
|
1117
|
-
async function
|
|
1118
|
-
let a2 =
|
|
1124
|
+
async function Gt(e11, t2, n2, r2, i2) {
|
|
1125
|
+
let a2 = Ut(r2), o2 = Ut(i2);
|
|
1119
1126
|
return e11.generateBalanceProofSignature(t2, n2, a2, o2);
|
|
1120
1127
|
}
|
|
1121
|
-
async function
|
|
1128
|
+
async function Kt(e11, t2, n2, r2) {
|
|
1122
1129
|
let i2 = await e11.deriveAeadKey(r2.viewSecret, r2.senderPublicNonce);
|
|
1123
1130
|
return e11.unblindOutput(t2, n2, i2, r2.skipMemo);
|
|
1124
1131
|
}
|
|
1125
|
-
async function
|
|
1126
|
-
let i2 =
|
|
1132
|
+
async function qt(e11, t2, n2, r2) {
|
|
1133
|
+
let i2 = $(n2, r2);
|
|
1127
1134
|
if (i2 === null) return null;
|
|
1128
1135
|
let a2 = x(i2.body.encrypted_data), o2 = x(i2.body.public_nonce);
|
|
1129
1136
|
try {
|
|
1130
|
-
return await
|
|
1137
|
+
return await Kt(e11, i2.commitment, a2, {
|
|
1131
1138
|
senderPublicNonce: o2,
|
|
1132
1139
|
viewSecret: t2,
|
|
1133
1140
|
skipMemo: false
|
|
@@ -1136,33 +1143,33 @@ async function Kt(e11, t2, n2, r2) {
|
|
|
1136
1143
|
return null;
|
|
1137
1144
|
}
|
|
1138
1145
|
}
|
|
1139
|
-
async function
|
|
1146
|
+
async function Jt(e11, t2, n2) {
|
|
1140
1147
|
if (t2.length === 0) throw new v("generateOutputsStatement: at least one stealth output is required");
|
|
1141
1148
|
let { statement: r2, outputMask: i2 } = await e11.generateOutputsStatement(t2, n2), a2 = await e11.buildInputsStatement([], 0n);
|
|
1142
|
-
return new
|
|
1149
|
+
return new Q(a2, r2, await Gt(e11, J.zero(), i2, a2, r2));
|
|
1143
1150
|
}
|
|
1144
|
-
var
|
|
1151
|
+
var Yt = class e10 {
|
|
1145
1152
|
constructor(e11, t2, n2, r2, i2) {
|
|
1146
1153
|
this.wallet = e11, this.spec = t2, this.crypto = n2, this.mustSignWithAccountKey = r2, this.viewSecret = i2;
|
|
1147
1154
|
}
|
|
1148
1155
|
static fromSpec(t2, n2, r2 = {}) {
|
|
1149
|
-
return new e10(t2, n2, r2.crypto ?? new
|
|
1156
|
+
return new e10(t2, n2, r2.crypto ?? new Nt(), r2.mustSignWithAccountKey ?? true, r2.viewSecret);
|
|
1150
1157
|
}
|
|
1151
1158
|
async prepare(e11) {
|
|
1152
|
-
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ? J.zero() : await this.crypto.aggregateInputMasks(t2.map((e12) => e12.mask)), r2 = await
|
|
1159
|
+
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ? J.zero() : await this.crypto.aggregateInputMasks(t2.map((e12) => e12.mask)), r2 = await Gt(this.crypto, n2, this.spec.outputMask, this.spec.statement.inputsStatement, this.spec.statement.outputsStatement), i2 = new Q(this.spec.statement.inputsStatement, this.spec.statement.outputsStatement, r2);
|
|
1153
1160
|
await this.crypto.validateTransfer(i2);
|
|
1154
|
-
let a2 =
|
|
1161
|
+
let a2 = Zt(this.spec.unsignedTx, i2), o2 = {
|
|
1155
1162
|
...this.spec,
|
|
1156
1163
|
unsignedTx: a2,
|
|
1157
1164
|
statement: i2
|
|
1158
1165
|
};
|
|
1159
|
-
return new
|
|
1166
|
+
return new Xt({
|
|
1160
1167
|
wallet: this.wallet,
|
|
1161
1168
|
crypto: this.crypto,
|
|
1162
1169
|
spec: o2,
|
|
1163
1170
|
resolvedInputs: t2,
|
|
1164
1171
|
mustSignWithAccountKey: this.mustSignWithAccountKey,
|
|
1165
|
-
sealKeypair:
|
|
1172
|
+
sealKeypair: mt()
|
|
1166
1173
|
});
|
|
1167
1174
|
}
|
|
1168
1175
|
async resolveViewSecret() {
|
|
@@ -1187,11 +1194,11 @@ var Jt = class e10 {
|
|
|
1187
1194
|
let t2 = await this.resolveViewSecret(), n2 = this.spec.state.resource, r2 = await Promise.allSettled(this.spec.inputs.map(async ({ input: r3, owner: i3 }) => {
|
|
1188
1195
|
let a2 = b(r3.commitment), o2 = await e11.getStealthUtxo(n2, r3.commitment);
|
|
1189
1196
|
if (o2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input UTXO not found (spent or never created) for ${a2}`);
|
|
1190
|
-
let s2 =
|
|
1197
|
+
let s2 = $(o2, It(n2, r3.commitment));
|
|
1191
1198
|
if (s2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input ${a2} is not a live, spendable UTXO`);
|
|
1192
1199
|
let c2 = x(s2.body.public_nonce), l2;
|
|
1193
1200
|
try {
|
|
1194
|
-
l2 = await
|
|
1201
|
+
l2 = await Kt(this.crypto, s2.commitment, x(s2.body.encrypted_data), {
|
|
1195
1202
|
senderPublicNonce: c2,
|
|
1196
1203
|
viewSecret: t2,
|
|
1197
1204
|
skipMemo: true
|
|
@@ -1212,7 +1219,7 @@ var Jt = class e10 {
|
|
|
1212
1219
|
if (i2 !== void 0) throw i2.reason;
|
|
1213
1220
|
return r2.map((e12) => e12.value);
|
|
1214
1221
|
}
|
|
1215
|
-
},
|
|
1222
|
+
}, Xt = class {
|
|
1216
1223
|
constructor(e11) {
|
|
1217
1224
|
__publicField(this, "wallet");
|
|
1218
1225
|
__publicField(this, "crypto");
|
|
@@ -1255,10 +1262,10 @@ var Jt = class e10 {
|
|
|
1255
1262
|
let e11 = (await this.createAuthorizations()).flatMap((e12) => e12.signatures), t2 = [];
|
|
1256
1263
|
this.mustSignWithAccountKey && t2.push(this.wallet);
|
|
1257
1264
|
let n2 = [...e11, ...this.extraSignatures];
|
|
1258
|
-
return n2.length > 0 && t2.push(new
|
|
1265
|
+
return n2.length > 0 && t2.push(new Qt(n2)), q(await K(t2, this.spec.unsignedTx, this.sealKeypair));
|
|
1259
1266
|
}
|
|
1260
1267
|
};
|
|
1261
|
-
function
|
|
1268
|
+
function Zt(e11, t2) {
|
|
1262
1269
|
let n2 = e11.instructions.findIndex(U);
|
|
1263
1270
|
if (n2 < 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found 0 (not a stealth tx)");
|
|
1264
1271
|
if (e11.instructions.slice(n2 + 1).findIndex(U) >= 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found more than one (malformed)");
|
|
@@ -1271,7 +1278,7 @@ function Xt(e11, t2) {
|
|
|
1271
1278
|
instructions: i2
|
|
1272
1279
|
};
|
|
1273
1280
|
}
|
|
1274
|
-
var
|
|
1281
|
+
var Qt = class {
|
|
1275
1282
|
constructor(e11) {
|
|
1276
1283
|
this.signatures = e11;
|
|
1277
1284
|
}
|
|
@@ -1286,87 +1293,88 @@ var Zt = class {
|
|
|
1286
1293
|
}
|
|
1287
1294
|
};
|
|
1288
1295
|
export {
|
|
1289
|
-
|
|
1290
|
-
|
|
1296
|
+
xt as AccountInvokeBuilder,
|
|
1297
|
+
Xt as AuthorizedTransfer,
|
|
1291
1298
|
X as BalanceProofSignature,
|
|
1292
1299
|
_ as CryptoBridgeError,
|
|
1293
|
-
|
|
1300
|
+
We as DEFAULT_TRANSACTION_VALIDITY_EPOCHS,
|
|
1294
1301
|
h as DefaultSignerNotSetError,
|
|
1295
|
-
|
|
1296
|
-
|
|
1302
|
+
Tt as EncryptedData,
|
|
1303
|
+
St as FaucetInvokeBuilder,
|
|
1297
1304
|
ie as IndexerClientError,
|
|
1298
1305
|
v as InvalidArgumentError,
|
|
1299
1306
|
m as KeyProviderNotFoundError,
|
|
1300
|
-
|
|
1307
|
+
Ue as MAX_TRANSACTION_VALIDITY_EPOCHS,
|
|
1301
1308
|
J as Mask,
|
|
1302
1309
|
u as Network,
|
|
1303
1310
|
d as OotleError,
|
|
1304
|
-
|
|
1311
|
+
Ct as OotleWallet,
|
|
1305
1312
|
oe as OperationCancelledError,
|
|
1306
1313
|
g as SignerError,
|
|
1307
1314
|
Y as StealthInput,
|
|
1308
1315
|
Z as StealthInputsStatement,
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1316
|
+
At as StealthOutputsStatement,
|
|
1317
|
+
Ht as StealthTransfer,
|
|
1318
|
+
Q as StealthTransferStatement,
|
|
1319
|
+
ot as TARI_RESOURCE_ADDRESS,
|
|
1320
|
+
z as TransactionBuilder,
|
|
1314
1321
|
f as TransactionRejectedError,
|
|
1315
1322
|
ae as TransactionTimeoutError,
|
|
1316
1323
|
p as WalletError,
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1324
|
+
Yt as WalletStealthAuthorizer,
|
|
1325
|
+
Nt as WasmStealthCrypto,
|
|
1326
|
+
lt as XTR_FAUCET_CLAIM_RESOURCE_ADDRESS,
|
|
1327
|
+
st as XTR_FAUCET_COMPONENT_ADDRESS,
|
|
1328
|
+
ct as XTR_FAUCET_VAULT_ADDRESS,
|
|
1329
|
+
O as amountLiteral,
|
|
1323
1330
|
y as assertByteLength,
|
|
1324
1331
|
se as assertUnreachable,
|
|
1325
1332
|
De as boolLiteral,
|
|
1326
|
-
|
|
1327
|
-
|
|
1333
|
+
ht as buildTransactionSignature,
|
|
1334
|
+
k as bytesLiteral,
|
|
1328
1335
|
Me as claimedOutputTombstoneAddressLiteral,
|
|
1329
|
-
|
|
1330
|
-
|
|
1336
|
+
_t as classifyOutcome,
|
|
1337
|
+
Bt as commitmentOf,
|
|
1331
1338
|
Oe as componentAddressLiteral,
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1339
|
+
Dt as createOutput,
|
|
1340
|
+
Kt as decryptInputData,
|
|
1341
|
+
qt as decryptOwnedUtxo,
|
|
1342
|
+
$e as defaultIndexerUrl,
|
|
1336
1343
|
x as fromHexStr,
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1344
|
+
Jt as generateOutputsStatement,
|
|
1345
|
+
mt as generateSealKeypair,
|
|
1346
|
+
rt as getVaultIdsForAccount,
|
|
1340
1347
|
Te as intLiteral,
|
|
1341
1348
|
U as isStealthTransferInstruction,
|
|
1342
|
-
|
|
1349
|
+
nt as iterVaultIdsInState,
|
|
1343
1350
|
Ce as literalArg,
|
|
1344
1351
|
ke as metadataLiteral,
|
|
1345
|
-
|
|
1346
|
-
|
|
1352
|
+
L as microTariLiteral,
|
|
1353
|
+
Ve as microTariString,
|
|
1347
1354
|
Fe as nonFungibleAddressLiteral,
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1355
|
+
$ as parseSubstateUtxo,
|
|
1356
|
+
He as parseWorkspaceStringKey,
|
|
1357
|
+
Zt as patchStealthStatement,
|
|
1351
1358
|
Pe as publicKeyLiteral,
|
|
1352
|
-
|
|
1359
|
+
Ge as resolveMaxEpoch,
|
|
1353
1360
|
G as resolveTransaction,
|
|
1354
|
-
|
|
1361
|
+
A as resourceAddressLiteral,
|
|
1355
1362
|
q as sealTransaction,
|
|
1356
|
-
|
|
1357
|
-
|
|
1363
|
+
bt as sendDryRun,
|
|
1364
|
+
yt as sendTransaction,
|
|
1358
1365
|
W as serializeUnsignedTx,
|
|
1359
|
-
|
|
1366
|
+
Gt as signBalanceProof,
|
|
1360
1367
|
K as signTransaction,
|
|
1361
1368
|
H as statementAsWire,
|
|
1362
|
-
|
|
1363
|
-
|
|
1369
|
+
pt as stealthTransferInstruction,
|
|
1370
|
+
It as stealthUtxoSubstateId,
|
|
1364
1371
|
Ee as stringLiteral,
|
|
1365
|
-
|
|
1372
|
+
gt as submitTransaction,
|
|
1366
1373
|
je as templateAddressLiteral,
|
|
1367
1374
|
b as toHexStr,
|
|
1375
|
+
B as upSubstateValue,
|
|
1368
1376
|
Ie as utxoAddressLiteral,
|
|
1369
1377
|
Ne as validatorFeePoolAddressLiteral,
|
|
1370
1378
|
Ae as vaultIdLiteral,
|
|
1371
|
-
|
|
1379
|
+
vt as watchTransaction
|
|
1372
1380
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/ootle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/tari-project/ootle.ts.git",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tari-project/ootle-ts-bindings": "^1.
|
|
29
|
-
"@tari-project/ootle-wasm": "^0.
|
|
28
|
+
"@tari-project/ootle-ts-bindings": "^1.60.0",
|
|
29
|
+
"@tari-project/ootle-wasm": "^0.47.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^25.5.0",
|