@tari-project/ootle 0.10.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 +3 -2
- package/dist/index.js +142 -138
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1732,8 +1732,9 @@ export declare interface TariMethodDefinition {
|
|
|
1732
1732
|
}
|
|
1733
1733
|
|
|
1734
1734
|
/**
|
|
1735
|
-
* CBOR-encode a
|
|
1736
|
-
*
|
|
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.
|
|
1737
1738
|
*
|
|
1738
1739
|
* @throws {InvalidArgumentError} if the address body is not 32 bytes (64 hex chars).
|
|
1739
1740
|
*/
|
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,37 +449,37 @@ 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
|
-
function
|
|
468
|
+
function B(e11) {
|
|
465
469
|
return "up" in e11.state ? e11.state.up.substate : null;
|
|
466
470
|
}
|
|
467
|
-
var
|
|
468
|
-
function*
|
|
471
|
+
var et = 132, tt = 32;
|
|
472
|
+
function* nt(e11) {
|
|
469
473
|
let t2 = /* @__PURE__ */ new Set();
|
|
470
|
-
for (let n2 of
|
|
474
|
+
for (let n2 of V(e11, et)) n2.length === tt * 2 && !t2.has(n2) && (t2.add(n2), yield `vault_${n2}`);
|
|
471
475
|
}
|
|
472
|
-
async function
|
|
473
|
-
let n2 =
|
|
474
|
-
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)) : [];
|
|
475
479
|
}
|
|
476
|
-
function*
|
|
480
|
+
function* V(e11, t2) {
|
|
477
481
|
if (Array.isArray(e11)) {
|
|
478
|
-
for (let n3 of e11) yield*
|
|
482
|
+
for (let n3 of e11) yield* V(n3, t2);
|
|
479
483
|
return;
|
|
480
484
|
}
|
|
481
485
|
if (typeof e11 != "object" || !e11) return;
|
|
@@ -484,41 +488,41 @@ function* H(e11, t2) {
|
|
|
484
488
|
if (r2 === "tag") {
|
|
485
489
|
let e12 = n2.value;
|
|
486
490
|
if (n2.tag === t2) {
|
|
487
|
-
let t3 =
|
|
491
|
+
let t3 = it(e12);
|
|
488
492
|
t3 !== null && (yield t3);
|
|
489
493
|
}
|
|
490
|
-
yield*
|
|
494
|
+
yield* V(e12, t2);
|
|
491
495
|
} else if (r2 === "map") {
|
|
492
496
|
let e12 = n2.entries;
|
|
493
|
-
if (Array.isArray(e12)) for (let n3 of e12) Array.isArray(n3) && n3.length === 2 && (yield*
|
|
497
|
+
if (Array.isArray(e12)) for (let n3 of e12) Array.isArray(n3) && n3.length === 2 && (yield* V(n3[0], t2), yield* V(n3[1], t2));
|
|
494
498
|
}
|
|
495
499
|
return;
|
|
496
500
|
}
|
|
497
|
-
for (let e12 of Object.values(n2)) yield*
|
|
501
|
+
for (let e12 of Object.values(n2)) yield* V(e12, t2);
|
|
498
502
|
}
|
|
499
|
-
function
|
|
503
|
+
function it(e11) {
|
|
500
504
|
if (typeof e11 != "object" || !e11) return null;
|
|
501
505
|
let t2 = e11;
|
|
502
506
|
if (t2["@cbor"] !== "bytes") return null;
|
|
503
507
|
let n2 = t2.hex;
|
|
504
508
|
return typeof n2 == "string" ? n2 : null;
|
|
505
509
|
}
|
|
506
|
-
function
|
|
510
|
+
function at(e11) {
|
|
507
511
|
return typeof e11 == "object" && !!e11 && "Component" in e11;
|
|
508
512
|
}
|
|
509
|
-
var
|
|
510
|
-
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) {
|
|
511
515
|
let n2 = e11.revealedInputBucket === null ? null : t2(e11.revealedInputBucket);
|
|
512
516
|
return { StealthTransfer: {
|
|
513
517
|
resource_address_ref: { Address: e11.resourceAddress },
|
|
514
|
-
statement:
|
|
518
|
+
statement: H(e11.statement),
|
|
515
519
|
revealed_input_bucket: n2
|
|
516
520
|
} };
|
|
517
521
|
}
|
|
518
|
-
function
|
|
519
|
-
return { [
|
|
522
|
+
function H(e11) {
|
|
523
|
+
return { [ut]: e11.toCompactJson() };
|
|
520
524
|
}
|
|
521
|
-
function
|
|
525
|
+
function U(e11) {
|
|
522
526
|
return typeof e11 == "object" && !!e11 && "StealthTransfer" in e11;
|
|
523
527
|
}
|
|
524
528
|
function W(e11) {
|
|
@@ -526,7 +530,7 @@ function W(e11) {
|
|
|
526
530
|
if (typeof r3 == "bigint") return r3.toString();
|
|
527
531
|
if (typeof r3 == "object" && r3 && "__ootleRawJson" in r3) {
|
|
528
532
|
let e13 = n2(t2.length);
|
|
529
|
-
return t2.push(r3[
|
|
533
|
+
return t2.push(r3[ut]), e13;
|
|
530
534
|
}
|
|
531
535
|
return r3;
|
|
532
536
|
});
|
|
@@ -630,7 +634,7 @@ async function bt(e11, t2, n2, r2) {
|
|
|
630
634
|
var xt = class {
|
|
631
635
|
constructor(e11, t2) {
|
|
632
636
|
__publicField(this, "builder");
|
|
633
|
-
this.builder =
|
|
637
|
+
this.builder = z.new(e11, t2);
|
|
634
638
|
}
|
|
635
639
|
withInputs(e11) {
|
|
636
640
|
return this.builder.withInputs(e11), this;
|
|
@@ -642,7 +646,7 @@ var xt = class {
|
|
|
642
646
|
return this.builder.callMethod({
|
|
643
647
|
componentAddress: e11,
|
|
644
648
|
methodName: "withdraw"
|
|
645
|
-
}, [
|
|
649
|
+
}, [A(t2), L(n2)]).saveVar("bucket").callMethod({
|
|
646
650
|
componentAddress: r2,
|
|
647
651
|
methodName: "deposit"
|
|
648
652
|
}, [{ Workspace: "bucket" }]), this;
|
|
@@ -657,7 +661,7 @@ var xt = class {
|
|
|
657
661
|
constructor(e11, t2, n2) {
|
|
658
662
|
__publicField(this, "builder");
|
|
659
663
|
__publicField(this, "faucetAddress");
|
|
660
|
-
this.builder =
|
|
664
|
+
this.builder = z.new(e11, t2), this.faucetAddress = n2;
|
|
661
665
|
}
|
|
662
666
|
feeTransactionPayFromComponent(e11, t2) {
|
|
663
667
|
return this.builder.feeTransactionPayFromComponent(e11, t2), this;
|
|
@@ -666,7 +670,7 @@ var xt = class {
|
|
|
666
670
|
return this.builder.callMethod({
|
|
667
671
|
componentAddress: this.faucetAddress,
|
|
668
672
|
methodName: "take_free_coins"
|
|
669
|
-
}, [
|
|
673
|
+
}, [L(t2)]).saveVar("faucet_bucket").callMethod({
|
|
670
674
|
componentAddress: e11,
|
|
671
675
|
methodName: "deposit"
|
|
672
676
|
}, [{ Workspace: "faucet_bucket" }]), this;
|
|
@@ -842,7 +846,7 @@ var Y = class e5 extends wt {
|
|
|
842
846
|
toJSON() {
|
|
843
847
|
return {
|
|
844
848
|
inputs: this.inputs.map((e11) => e11.toJSON()),
|
|
845
|
-
revealed_amount:
|
|
849
|
+
revealed_amount: Ve(this.revealedAmount)
|
|
846
850
|
};
|
|
847
851
|
}
|
|
848
852
|
static fromJSON(t2) {
|
|
@@ -973,7 +977,7 @@ function Bt(e11) {
|
|
|
973
977
|
return n2.length !== Lt || !zt(n2) ? null : x(n2);
|
|
974
978
|
}
|
|
975
979
|
function $(e11, t2) {
|
|
976
|
-
let n2 =
|
|
980
|
+
let n2 = B(e11);
|
|
977
981
|
if (n2 === null || !Rt(n2)) return null;
|
|
978
982
|
let r2 = n2.Utxo;
|
|
979
983
|
if (r2.output === null || r2.is_frozen) return null;
|
|
@@ -991,7 +995,7 @@ var Vt = 0, Ht = class {
|
|
|
991
995
|
__publicField(this, "state");
|
|
992
996
|
__publicField(this, "maxEpoch", null);
|
|
993
997
|
__publicField(this, "prepared", false);
|
|
994
|
-
this.provider = e11, this.crypto = n2, this.builder =
|
|
998
|
+
this.provider = e11, this.crypto = n2, this.builder = z.new(e11.network(), Vt), this.state = {
|
|
995
999
|
resource: t2,
|
|
996
1000
|
revealedInput: null,
|
|
997
1001
|
inputsToSpend: /* @__PURE__ */ new Map(),
|
|
@@ -1045,7 +1049,7 @@ var Vt = 0, Ht = class {
|
|
|
1045
1049
|
if (this.prepared) throw new v("StealthTransfer.prepare: already prepared \u2014 create a new StealthTransfer to build again");
|
|
1046
1050
|
this.validate(), this.prepared = true;
|
|
1047
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);
|
|
1048
|
-
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch === Vt && this.builder.withMaxEpoch(await
|
|
1052
|
+
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch === Vt && this.builder.withMaxEpoch(await Ge(this.provider));
|
|
1049
1053
|
let r2 = /* @__PURE__ */ new Set();
|
|
1050
1054
|
if (this.state.revealedInput !== null) {
|
|
1051
1055
|
let e12 = this.state.revealedInput.source;
|
|
@@ -1053,7 +1057,7 @@ var Vt = 0, Ht = class {
|
|
|
1053
1057
|
substate_id: e12,
|
|
1054
1058
|
version: null
|
|
1055
1059
|
}), r2.add(e12);
|
|
1056
|
-
let t3 = await
|
|
1060
|
+
let t3 = await rt(this.provider, e12);
|
|
1057
1061
|
for (let e13 of t3) r2.has(e13) || (this.builder.addInput({
|
|
1058
1062
|
substate_id: e13,
|
|
1059
1063
|
version: null
|
|
@@ -1099,14 +1103,14 @@ var Vt = 0, Ht = class {
|
|
|
1099
1103
|
t2 !== null && (this.builder.callMethod({
|
|
1100
1104
|
componentAddress: t2.source,
|
|
1101
1105
|
methodName: "withdraw"
|
|
1102
|
-
}, [
|
|
1106
|
+
}, [A(this.state.resource), O(t2.amount)]).saveVar(dt), n2 = dt), this.builder.addInstruction(pt({
|
|
1103
1107
|
resourceAddress: this.state.resource,
|
|
1104
1108
|
revealedInputBucket: n2,
|
|
1105
1109
|
statement: e11
|
|
1106
|
-
}, (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({
|
|
1107
1111
|
componentAddress: t2.source,
|
|
1108
1112
|
methodName: "deposit"
|
|
1109
|
-
}, [{ Workspace:
|
|
1113
|
+
}, [{ Workspace: ft }]);
|
|
1110
1114
|
}
|
|
1111
1115
|
};
|
|
1112
1116
|
function Ut(e11) {
|
|
@@ -1262,12 +1266,12 @@ var Yt = class e10 {
|
|
|
1262
1266
|
}
|
|
1263
1267
|
};
|
|
1264
1268
|
function Zt(e11, t2) {
|
|
1265
|
-
let n2 = e11.instructions.findIndex(
|
|
1269
|
+
let n2 = e11.instructions.findIndex(U);
|
|
1266
1270
|
if (n2 < 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found 0 (not a stealth tx)");
|
|
1267
|
-
if (e11.instructions.slice(n2 + 1).findIndex(
|
|
1271
|
+
if (e11.instructions.slice(n2 + 1).findIndex(U) >= 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found more than one (malformed)");
|
|
1268
1272
|
let r2 = { StealthTransfer: {
|
|
1269
1273
|
...e11.instructions[n2].StealthTransfer,
|
|
1270
|
-
statement:
|
|
1274
|
+
statement: H(t2)
|
|
1271
1275
|
} }, i2 = [...e11.instructions];
|
|
1272
1276
|
return i2[n2] = r2, {
|
|
1273
1277
|
...e11,
|
|
@@ -1293,14 +1297,14 @@ export {
|
|
|
1293
1297
|
Xt as AuthorizedTransfer,
|
|
1294
1298
|
X as BalanceProofSignature,
|
|
1295
1299
|
_ as CryptoBridgeError,
|
|
1296
|
-
|
|
1300
|
+
We as DEFAULT_TRANSACTION_VALIDITY_EPOCHS,
|
|
1297
1301
|
h as DefaultSignerNotSetError,
|
|
1298
1302
|
Tt as EncryptedData,
|
|
1299
1303
|
St as FaucetInvokeBuilder,
|
|
1300
1304
|
ie as IndexerClientError,
|
|
1301
1305
|
v as InvalidArgumentError,
|
|
1302
1306
|
m as KeyProviderNotFoundError,
|
|
1303
|
-
|
|
1307
|
+
Ue as MAX_TRANSACTION_VALIDITY_EPOCHS,
|
|
1304
1308
|
J as Mask,
|
|
1305
1309
|
u as Network,
|
|
1306
1310
|
d as OotleError,
|
|
@@ -1312,22 +1316,22 @@ export {
|
|
|
1312
1316
|
At as StealthOutputsStatement,
|
|
1313
1317
|
Ht as StealthTransfer,
|
|
1314
1318
|
Q as StealthTransferStatement,
|
|
1315
|
-
|
|
1316
|
-
|
|
1319
|
+
ot as TARI_RESOURCE_ADDRESS,
|
|
1320
|
+
z as TransactionBuilder,
|
|
1317
1321
|
f as TransactionRejectedError,
|
|
1318
1322
|
ae as TransactionTimeoutError,
|
|
1319
1323
|
p as WalletError,
|
|
1320
1324
|
Yt as WalletStealthAuthorizer,
|
|
1321
1325
|
Nt as WasmStealthCrypto,
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
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,
|
|
1326
1330
|
y as assertByteLength,
|
|
1327
1331
|
se as assertUnreachable,
|
|
1328
1332
|
De as boolLiteral,
|
|
1329
1333
|
ht as buildTransactionSignature,
|
|
1330
|
-
|
|
1334
|
+
k as bytesLiteral,
|
|
1331
1335
|
Me as claimedOutputTombstoneAddressLiteral,
|
|
1332
1336
|
_t as classifyOutcome,
|
|
1333
1337
|
Bt as commitmentOf,
|
|
@@ -1335,40 +1339,40 @@ export {
|
|
|
1335
1339
|
Dt as createOutput,
|
|
1336
1340
|
Kt as decryptInputData,
|
|
1337
1341
|
qt as decryptOwnedUtxo,
|
|
1338
|
-
|
|
1342
|
+
$e as defaultIndexerUrl,
|
|
1339
1343
|
x as fromHexStr,
|
|
1340
1344
|
Jt as generateOutputsStatement,
|
|
1341
1345
|
mt as generateSealKeypair,
|
|
1342
|
-
|
|
1346
|
+
rt as getVaultIdsForAccount,
|
|
1343
1347
|
Te as intLiteral,
|
|
1344
|
-
|
|
1345
|
-
|
|
1348
|
+
U as isStealthTransferInstruction,
|
|
1349
|
+
nt as iterVaultIdsInState,
|
|
1346
1350
|
Ce as literalArg,
|
|
1347
1351
|
ke as metadataLiteral,
|
|
1348
|
-
|
|
1349
|
-
|
|
1352
|
+
L as microTariLiteral,
|
|
1353
|
+
Ve as microTariString,
|
|
1350
1354
|
Fe as nonFungibleAddressLiteral,
|
|
1351
1355
|
$ as parseSubstateUtxo,
|
|
1352
|
-
|
|
1356
|
+
He as parseWorkspaceStringKey,
|
|
1353
1357
|
Zt as patchStealthStatement,
|
|
1354
1358
|
Pe as publicKeyLiteral,
|
|
1355
|
-
|
|
1359
|
+
Ge as resolveMaxEpoch,
|
|
1356
1360
|
G as resolveTransaction,
|
|
1357
|
-
|
|
1361
|
+
A as resourceAddressLiteral,
|
|
1358
1362
|
q as sealTransaction,
|
|
1359
1363
|
bt as sendDryRun,
|
|
1360
1364
|
yt as sendTransaction,
|
|
1361
1365
|
W as serializeUnsignedTx,
|
|
1362
1366
|
Gt as signBalanceProof,
|
|
1363
1367
|
K as signTransaction,
|
|
1364
|
-
|
|
1365
|
-
|
|
1368
|
+
H as statementAsWire,
|
|
1369
|
+
pt as stealthTransferInstruction,
|
|
1366
1370
|
It as stealthUtxoSubstateId,
|
|
1367
1371
|
Ee as stringLiteral,
|
|
1368
1372
|
gt as submitTransaction,
|
|
1369
1373
|
je as templateAddressLiteral,
|
|
1370
1374
|
b as toHexStr,
|
|
1371
|
-
|
|
1375
|
+
B as upSubstateValue,
|
|
1372
1376
|
Ie as utxoAddressLiteral,
|
|
1373
1377
|
Ne as validatorFeePoolAddressLiteral,
|
|
1374
1378
|
Ae as vaultIdLiteral,
|