@tari-project/ootle 0.1.0 → 0.3.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 +132 -20
- package/dist/index.js +312 -239
- package/package.json +11 -3
package/dist/index.js
CHANGED
|
@@ -66,17 +66,17 @@ 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, C = 32,
|
|
70
|
-
function
|
|
69
|
+
var S = (1n << 64n) - 1n, le = 2n, C = 32, ue = C * 2, de = 32, fe = 128, pe = 129, me = 130, w = 131, he = 132, ge = 136, _e = 137, ve = 138, ye = 141, T = 0, be = 32, E = 64, xe = 96, D = 128, Se = 160, O = 192;
|
|
70
|
+
function Ce(e11) {
|
|
71
71
|
switch (typeof e11) {
|
|
72
72
|
case "bigint":
|
|
73
73
|
return k(e11);
|
|
74
74
|
case "string":
|
|
75
|
-
return
|
|
75
|
+
return Ee(e11);
|
|
76
76
|
case "boolean":
|
|
77
|
-
return
|
|
77
|
+
return Oe(e11);
|
|
78
78
|
default:
|
|
79
|
-
if (e11 instanceof Uint8Array) return
|
|
79
|
+
if (e11 instanceof Uint8Array) return De(e11);
|
|
80
80
|
throw new v(`literalArg: cannot CBOR-encode value of type ${typeof e11}`);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -84,123 +84,128 @@ function k(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
|
|
87
|
+
return e11 <= S ? F(t2, T, e11) : we(t2, e11), I(t2);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function we(e11, t2) {
|
|
90
|
+
let n2 = [], r2 = t2;
|
|
91
|
+
for (; r2 > 0n; ) n2.unshift(Number(r2 & 255n)), r2 >>= 8n;
|
|
92
|
+
F(e11, O, le), F(e11, E, BigInt(n2.length)), P(e11, n2);
|
|
93
|
+
}
|
|
94
|
+
function Te(e11) {
|
|
90
95
|
let t2 = [];
|
|
91
96
|
if (e11 >= 0n) {
|
|
92
97
|
if (e11 > S) throw new v(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
|
|
93
|
-
|
|
98
|
+
F(t2, T, e11);
|
|
94
99
|
} else {
|
|
95
100
|
let n2 = -1n - e11;
|
|
96
101
|
if (n2 > S) throw new v(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
|
|
97
|
-
|
|
102
|
+
F(t2, be, n2);
|
|
98
103
|
}
|
|
99
|
-
return
|
|
104
|
+
return I(t2);
|
|
100
105
|
}
|
|
101
|
-
function
|
|
106
|
+
function Ee(e11) {
|
|
102
107
|
let t2 = [];
|
|
103
|
-
return
|
|
108
|
+
return N(t2, e11), I(t2);
|
|
104
109
|
}
|
|
105
|
-
function
|
|
110
|
+
function De(e11) {
|
|
106
111
|
let t2 = [];
|
|
107
|
-
return
|
|
112
|
+
return F(t2, E, BigInt(e11.length)), P(t2, e11), I(t2);
|
|
108
113
|
}
|
|
109
|
-
function
|
|
114
|
+
function Oe(e11) {
|
|
110
115
|
return { Literal: e11 ? "f5" : "f4" };
|
|
111
116
|
}
|
|
112
|
-
function
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
function Ee(e11) {
|
|
116
|
-
return M(de, e11, "component_");
|
|
117
|
-
}
|
|
118
|
-
function De(e11) {
|
|
119
|
-
let t2 = e11 instanceof Map ? e11 : new Map(Object.entries(e11)), n2 = new TextEncoder(), r2 = [...t2.entries()].sort(([e12], [t3]) => Le(n2.encode(e12), n2.encode(t3))), i2 = [];
|
|
120
|
-
I(i2, O, BigInt(fe)), I(i2, xe, BigInt(r2.length));
|
|
121
|
-
for (let [e12, t3] of r2) P(i2, e12), P(i2, t3);
|
|
122
|
-
return L(i2);
|
|
123
|
-
}
|
|
124
|
-
function Oe(e11) {
|
|
125
|
-
return M(me, e11, "vault_");
|
|
117
|
+
function A(e11) {
|
|
118
|
+
return j(w, e11, "resource_");
|
|
126
119
|
}
|
|
127
120
|
function ke(e11) {
|
|
128
|
-
return
|
|
121
|
+
return j(fe, e11, "component_");
|
|
129
122
|
}
|
|
130
123
|
function Ae(e11) {
|
|
131
|
-
|
|
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, O, 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);
|
|
132
128
|
}
|
|
133
129
|
function je(e11) {
|
|
134
|
-
return
|
|
130
|
+
return j(he, e11, "vault_");
|
|
135
131
|
}
|
|
136
132
|
function Me(e11) {
|
|
137
|
-
|
|
138
|
-
return y(t2, ue, "publicKeyLiteral"), A(t2);
|
|
133
|
+
return j(_e, e11, "template_");
|
|
139
134
|
}
|
|
140
135
|
function Ne(e11) {
|
|
141
|
-
|
|
142
|
-
return I(t2, O, BigInt(pe)), I(t2, D, 2n), N(t2, w, e11.resource_address, "resource_"), Fe(t2, e11.id), L(t2);
|
|
136
|
+
return j(ge, e11, "tombstone_");
|
|
143
137
|
}
|
|
144
138
|
function Pe(e11) {
|
|
139
|
+
return j(ve, e11, "vnfp_");
|
|
140
|
+
}
|
|
141
|
+
function Fe(e11) {
|
|
142
|
+
let t2 = typeof e11 == "string" ? x(e11) : e11;
|
|
143
|
+
return y(t2, de, "publicKeyLiteral"), De(t2);
|
|
144
|
+
}
|
|
145
|
+
function Ie(e11) {
|
|
146
|
+
let t2 = [];
|
|
147
|
+
return F(t2, O, BigInt(me)), F(t2, D, 2n), M(t2, w, e11.resource_address, "resource_"), Re(t2, e11.id), I(t2);
|
|
148
|
+
}
|
|
149
|
+
function Le(e11) {
|
|
145
150
|
let t2 = [];
|
|
146
|
-
|
|
151
|
+
F(t2, O, BigInt(ye)), F(t2, D, 2n), M(t2, w, e11.resource_address, "resource_");
|
|
147
152
|
let n2 = x(e11.id);
|
|
148
|
-
return y(n2, C, "utxoAddressLiteral: id"),
|
|
153
|
+
return y(n2, C, "utxoAddressLiteral: id"), F(t2, E, BigInt(C)), P(t2, n2), I(t2);
|
|
149
154
|
}
|
|
150
|
-
function
|
|
155
|
+
function j(e11, t2, n2) {
|
|
151
156
|
let r2 = [];
|
|
152
|
-
return
|
|
157
|
+
return M(r2, e11, t2, n2), I(r2);
|
|
153
158
|
}
|
|
154
|
-
function
|
|
159
|
+
function M(e11, t2, n2, r2) {
|
|
155
160
|
let i2 = n2.startsWith(r2) ? n2.slice(r2.length) : n2;
|
|
156
|
-
if (i2.length !==
|
|
157
|
-
|
|
161
|
+
if (i2.length !== ue) throw new v(`${r2}address must be 32 bytes (${ue} hex chars), got ${i2.length}`);
|
|
162
|
+
F(e11, O, BigInt(t2)), F(e11, E, BigInt(C)), P(e11, x(i2));
|
|
158
163
|
}
|
|
159
|
-
function
|
|
160
|
-
if (
|
|
161
|
-
|
|
164
|
+
function Re(e11, t2) {
|
|
165
|
+
if (F(e11, D, 2n), "U256" in t2) {
|
|
166
|
+
F(e11, T, 0n), F(e11, D, 1n);
|
|
162
167
|
let n2 = x(t2.U256);
|
|
163
|
-
y(n2, C, "NonFungibleId.U256"),
|
|
164
|
-
} else if ("String" in t2)
|
|
165
|
-
else if ("Uint32" in t2)
|
|
166
|
-
else if ("Uint64" in t2)
|
|
168
|
+
y(n2, C, "NonFungibleId.U256"), F(e11, E, BigInt(C)), P(e11, n2);
|
|
169
|
+
} else if ("String" in t2) F(e11, T, 1n), F(e11, D, 1n), N(e11, t2.String);
|
|
170
|
+
else if ("Uint32" in t2) F(e11, T, 2n), F(e11, D, 1n), ze(e11, t2.Uint32, "NonFungibleId.Uint32", (1n << 32n) - 1n);
|
|
171
|
+
else if ("Uint64" in t2) F(e11, T, 3n), F(e11, D, 1n), ze(e11, t2.Uint64, "NonFungibleId.Uint64", S);
|
|
167
172
|
else throw new v(`nonFungibleAddressLiteral: unrecognised NonFungibleId variant: ${JSON.stringify(t2)}`);
|
|
168
173
|
}
|
|
169
|
-
function
|
|
174
|
+
function ze(e11, t2, n2, r2) {
|
|
170
175
|
if (!Number.isInteger(t2) || t2 < 0) throw new v(`${n2} must be a non-negative integer, got ${t2}`);
|
|
171
176
|
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.`);
|
|
172
177
|
let i2 = BigInt(t2);
|
|
173
178
|
if (i2 > r2) throw new v(`${n2} value ${t2} exceeds its maximum of ${r2}`);
|
|
174
|
-
|
|
179
|
+
F(e11, T, i2);
|
|
175
180
|
}
|
|
176
|
-
function
|
|
181
|
+
function N(e11, t2) {
|
|
177
182
|
let n2 = new TextEncoder().encode(t2);
|
|
178
|
-
|
|
183
|
+
F(e11, xe, BigInt(n2.length)), P(e11, n2);
|
|
179
184
|
}
|
|
180
|
-
function
|
|
185
|
+
function P(e11, t2) {
|
|
181
186
|
let n2 = e11.length;
|
|
182
187
|
e11.length = n2 + t2.length;
|
|
183
188
|
for (let r2 = 0; r2 < t2.length; r2++) e11[n2 + r2] = t2[r2];
|
|
184
189
|
}
|
|
185
|
-
function
|
|
190
|
+
function Be(e11, t2) {
|
|
186
191
|
let n2 = Math.min(e11.length, t2.length);
|
|
187
192
|
for (let r2 = 0; r2 < n2; r2++) if (e11[r2] !== t2[r2]) return e11[r2] < t2[r2] ? -1 : 1;
|
|
188
193
|
return e11.length - t2.length;
|
|
189
194
|
}
|
|
190
|
-
function
|
|
195
|
+
function F(e11, t2, n2) {
|
|
191
196
|
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));
|
|
192
197
|
}
|
|
193
|
-
function
|
|
198
|
+
function I(e11) {
|
|
194
199
|
return { Literal: b(Uint8Array.from(e11)) };
|
|
195
200
|
}
|
|
196
|
-
function
|
|
201
|
+
function L(e11) {
|
|
197
202
|
return k(e11);
|
|
198
203
|
}
|
|
199
|
-
function
|
|
204
|
+
function Ve(e11) {
|
|
200
205
|
if (e11 < 0n) throw new v(`microTariString: amount must be non-negative, got ${e11}`);
|
|
201
206
|
return e11.toString();
|
|
202
207
|
}
|
|
203
|
-
function
|
|
208
|
+
function He(e11) {
|
|
204
209
|
let t2 = e11.split(".");
|
|
205
210
|
if (t2.length > 2) throw new v("Invalid workspace key format. Only one dot is allowed.");
|
|
206
211
|
let n2 = t2[0];
|
|
@@ -215,36 +220,80 @@ function ze(e11) {
|
|
|
215
220
|
offset: r2
|
|
216
221
|
};
|
|
217
222
|
}
|
|
218
|
-
|
|
223
|
+
var Ue = 2160, We = 10;
|
|
224
|
+
async function Ge(e11, t2 = 10) {
|
|
225
|
+
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 ${Ue} epochs`);
|
|
227
|
+
return await e11.getCurrentEpoch() + t2;
|
|
228
|
+
}
|
|
229
|
+
var Ke = (1n << 64n) - 1n;
|
|
230
|
+
function R(e11, t2) {
|
|
231
|
+
if (!Number.isInteger(e11) || e11 < 0) throw new v(`${t2} must be a non-negative integer epoch, got ${e11}`);
|
|
232
|
+
return e11;
|
|
233
|
+
}
|
|
234
|
+
function qe(e11) {
|
|
219
235
|
return e11.startsWith("template_") ? e11.slice(9) : e11;
|
|
220
236
|
}
|
|
221
|
-
function
|
|
237
|
+
function Je(e11) {
|
|
238
|
+
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
|
+
}
|
|
240
|
+
var Ye = class {
|
|
241
|
+
constructor() {
|
|
242
|
+
__publicField(this, "nextId", 0);
|
|
243
|
+
__publicField(this, "ids", /* @__PURE__ */ new Map());
|
|
244
|
+
}
|
|
245
|
+
insert(e11) {
|
|
246
|
+
let t2 = this.nextId;
|
|
247
|
+
return this.ids.set(e11, t2), this.nextId += 1, t2;
|
|
248
|
+
}
|
|
249
|
+
get(e11) {
|
|
250
|
+
return this.ids.get(e11);
|
|
251
|
+
}
|
|
252
|
+
get next() {
|
|
253
|
+
return this.nextId;
|
|
254
|
+
}
|
|
255
|
+
observeAllocated(e11) {
|
|
256
|
+
e11 + 1 > this.nextId && (this.nextId = e11 + 1);
|
|
257
|
+
}
|
|
258
|
+
reset() {
|
|
259
|
+
this.nextId = 0, this.ids.clear();
|
|
260
|
+
}
|
|
261
|
+
resetFrom(e11) {
|
|
262
|
+
this.reset();
|
|
263
|
+
for (let t2 of e11) {
|
|
264
|
+
let e12 = Je(t2);
|
|
265
|
+
e12 !== null && this.observeAllocated(e12);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
function Xe(e11) {
|
|
222
270
|
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.`);
|
|
223
271
|
}
|
|
224
272
|
var z = class e2 {
|
|
225
|
-
constructor(e11) {
|
|
273
|
+
constructor(e11, t2) {
|
|
226
274
|
__publicField(this, "unsignedTransaction");
|
|
227
|
-
__publicField(this, "
|
|
228
|
-
__publicField(this, "
|
|
275
|
+
__publicField(this, "workspaceIds");
|
|
276
|
+
__publicField(this, "feeWorkspaceIds");
|
|
229
277
|
this.unsignedTransaction = {
|
|
230
278
|
network: e11,
|
|
231
279
|
fee_instructions: [],
|
|
232
280
|
instructions: [],
|
|
233
281
|
inputs: [],
|
|
234
282
|
min_epoch: null,
|
|
235
|
-
max_epoch:
|
|
283
|
+
max_epoch: R(t2, "maxEpoch"),
|
|
236
284
|
dry_run: false,
|
|
237
285
|
is_seal_signer_authorized: false,
|
|
238
|
-
blobs: []
|
|
239
|
-
|
|
286
|
+
blobs: [],
|
|
287
|
+
nonce: 0
|
|
288
|
+
}, this.workspaceIds = new Ye(), this.feeWorkspaceIds = new Ye();
|
|
240
289
|
}
|
|
241
|
-
static new(t2) {
|
|
242
|
-
return new e2(t2);
|
|
290
|
+
static new(t2, n2) {
|
|
291
|
+
return new e2(t2, n2);
|
|
243
292
|
}
|
|
244
293
|
callFunction(e11, t2) {
|
|
245
294
|
let n2 = this.resolveArgs(t2);
|
|
246
295
|
return this.addInstruction({ CallFunction: {
|
|
247
|
-
address:
|
|
296
|
+
address: qe(e11.templateAddress),
|
|
248
297
|
function: e11.functionName,
|
|
249
298
|
args: n2
|
|
250
299
|
} });
|
|
@@ -274,7 +323,7 @@ var z = class e2 {
|
|
|
274
323
|
return this.addInstruction({ CallMethod: {
|
|
275
324
|
call: { Address: e11 },
|
|
276
325
|
method: "create_proof_for_resource",
|
|
277
|
-
args: [
|
|
326
|
+
args: [A(t2)]
|
|
278
327
|
} });
|
|
279
328
|
}
|
|
280
329
|
claimBurn(e11, t2) {
|
|
@@ -298,7 +347,7 @@ var z = class e2 {
|
|
|
298
347
|
return this.addFeeInstruction({ CallMethod: {
|
|
299
348
|
call: { Address: e11 },
|
|
300
349
|
method: "pay_fee",
|
|
301
|
-
args: [
|
|
350
|
+
args: [L(t2)]
|
|
302
351
|
} });
|
|
303
352
|
}
|
|
304
353
|
feeTransactionPayFromComponentConfidential(e11, t2) {
|
|
@@ -315,20 +364,26 @@ var z = class e2 {
|
|
|
315
364
|
} });
|
|
316
365
|
}
|
|
317
366
|
addInstruction(e11) {
|
|
318
|
-
return this.unsignedTransaction.instructions.push(e11), this;
|
|
367
|
+
return this.observeAllocations(this.workspaceIds, [e11]), this.unsignedTransaction.instructions.push(e11), this;
|
|
319
368
|
}
|
|
320
369
|
addFeeInstruction(e11) {
|
|
321
|
-
return this.unsignedTransaction.fee_instructions.push(e11), this;
|
|
370
|
+
return this.observeAllocations(this.feeWorkspaceIds, [e11]), this.unsignedTransaction.fee_instructions.push(e11), this;
|
|
322
371
|
}
|
|
323
372
|
withInstructions(e11) {
|
|
324
|
-
return this.unsignedTransaction.instructions.push(...e11), this;
|
|
373
|
+
return this.observeAllocations(this.workspaceIds, e11), this.unsignedTransaction.instructions.push(...e11), this;
|
|
325
374
|
}
|
|
326
375
|
withFeeInstructions(e11) {
|
|
327
|
-
return this.unsignedTransaction.fee_instructions.push(...e11), this;
|
|
376
|
+
return this.observeAllocations(this.feeWorkspaceIds, e11), this.unsignedTransaction.fee_instructions.push(...e11), this;
|
|
377
|
+
}
|
|
378
|
+
observeAllocations(e11, t2) {
|
|
379
|
+
for (let n2 of t2) {
|
|
380
|
+
let t3 = Je(n2);
|
|
381
|
+
t3 !== null && e11.observeAllocated(t3);
|
|
382
|
+
}
|
|
328
383
|
}
|
|
329
384
|
withFeeInstructionsBuilder(t2) {
|
|
330
|
-
let n2 = t2(new e2(this.unsignedTransaction.network));
|
|
331
|
-
return this.unsignedTransaction.fee_instructions = n2.unsignedTransaction.instructions, this;
|
|
385
|
+
let n2 = t2(new e2(this.unsignedTransaction.network, this.unsignedTransaction.max_epoch));
|
|
386
|
+
return this.unsignedTransaction.fee_instructions = n2.unsignedTransaction.instructions, this.feeWorkspaceIds.resetFrom(this.unsignedTransaction.fee_instructions), this;
|
|
332
387
|
}
|
|
333
388
|
addInput(e11) {
|
|
334
389
|
return this.unsignedTransaction.inputs.push(e11), this;
|
|
@@ -337,16 +392,27 @@ var z = class e2 {
|
|
|
337
392
|
return this.unsignedTransaction.inputs.push(...e11), this;
|
|
338
393
|
}
|
|
339
394
|
withMinEpoch(e11) {
|
|
340
|
-
return this.unsignedTransaction.min_epoch = e11, this;
|
|
395
|
+
return this.unsignedTransaction.min_epoch = R(e11, "minEpoch"), this;
|
|
341
396
|
}
|
|
342
397
|
withMaxEpoch(e11) {
|
|
343
|
-
return this.unsignedTransaction.max_epoch = e11, this;
|
|
398
|
+
return this.unsignedTransaction.max_epoch = R(e11, "maxEpoch"), this;
|
|
399
|
+
}
|
|
400
|
+
withNonce(e11) {
|
|
401
|
+
if (typeof e11 == "number" && !Number.isInteger(e11)) throw new v(`withNonce: nonce must be an integer, got ${e11}`);
|
|
402
|
+
let t2 = typeof e11 == "bigint" ? e11 : BigInt(e11);
|
|
403
|
+
if (t2 < 0n || t2 > Ke) throw new v(`withNonce: nonce must fit an unsigned 64-bit integer, got ${e11}`);
|
|
404
|
+
return this.unsignedTransaction.nonce = t2 > BigInt(2 ** 53 - 1) ? t2 : Number(t2), this;
|
|
344
405
|
}
|
|
345
406
|
withUnsignedTransaction(e11) {
|
|
346
407
|
return this.unsignedTransaction = {
|
|
347
408
|
...e11,
|
|
348
|
-
|
|
349
|
-
|
|
409
|
+
instructions: [...e11.instructions],
|
|
410
|
+
fee_instructions: [...e11.fee_instructions],
|
|
411
|
+
inputs: [...e11.inputs],
|
|
412
|
+
blobs: [...e11.blobs ?? []],
|
|
413
|
+
nonce: e11.nonce ?? 0,
|
|
414
|
+
max_epoch: R(e11.max_epoch, "withUnsignedTransaction: max_epoch")
|
|
415
|
+
}, this.workspaceIds.resetFrom(this.unsignedTransaction.instructions), this.feeWorkspaceIds.resetFrom(this.unsignedTransaction.fee_instructions), this;
|
|
350
416
|
}
|
|
351
417
|
resolveWorkspaceOffsetId(e11) {
|
|
352
418
|
return this.getOffsetIdFromWorkspaceName(e11);
|
|
@@ -361,16 +427,15 @@ var z = class e2 {
|
|
|
361
427
|
};
|
|
362
428
|
}
|
|
363
429
|
addNamedId(e11) {
|
|
364
|
-
|
|
365
|
-
return this.allocatedIds.set(e11, t2), this.currentId += 1, t2;
|
|
430
|
+
return this.workspaceIds.insert(e11);
|
|
366
431
|
}
|
|
367
432
|
requireNamedId(e11) {
|
|
368
|
-
let t2 = this.
|
|
369
|
-
if (t2 === void 0) throw
|
|
433
|
+
let t2 = this.workspaceIds.get(e11);
|
|
434
|
+
if (t2 === void 0) throw Xe(e11);
|
|
370
435
|
return t2;
|
|
371
436
|
}
|
|
372
437
|
getOffsetIdFromWorkspaceName(e11) {
|
|
373
|
-
let t2 =
|
|
438
|
+
let t2 = He(e11);
|
|
374
439
|
return {
|
|
375
440
|
id: this.requireNamedId(t2.name),
|
|
376
441
|
offset: t2.offset
|
|
@@ -379,23 +444,23 @@ var z = class e2 {
|
|
|
379
444
|
resolveArgs(e11) {
|
|
380
445
|
return e11.map((e12) => typeof e12 == "object" && e12 && "Workspace" in e12 && typeof e12.Workspace == "string" ? { Workspace: this.getOffsetIdFromWorkspaceName(e12.Workspace) } : e12);
|
|
381
446
|
}
|
|
382
|
-
},
|
|
447
|
+
}, Ze = {
|
|
383
448
|
[u.LocalNet]: "http://localhost:12500",
|
|
384
449
|
[u.Esmeralda]: "https://ootle-indexer-a.tari.com"
|
|
385
450
|
};
|
|
386
|
-
function
|
|
387
|
-
let t2 =
|
|
451
|
+
function Qe(e11) {
|
|
452
|
+
let t2 = Ze[e11];
|
|
388
453
|
if (t2 !== void 0) return t2;
|
|
389
454
|
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]} }).`);
|
|
390
455
|
}
|
|
391
|
-
var
|
|
392
|
-
function*
|
|
456
|
+
var $e = 132, et = 32;
|
|
457
|
+
function* tt(e11) {
|
|
393
458
|
let t2 = /* @__PURE__ */ new Set();
|
|
394
|
-
for (let n2 of B(e11,
|
|
459
|
+
for (let n2 of B(e11, $e)) n2.length === et * 2 && !t2.has(n2) && (t2.add(n2), yield `vault_${n2}`);
|
|
395
460
|
}
|
|
396
|
-
async function
|
|
461
|
+
async function nt(e11, t2) {
|
|
397
462
|
let n2 = (await e11.getSubstate(t2)).substate;
|
|
398
|
-
return
|
|
463
|
+
return it(n2) ? Array.from(tt(n2.Component.body.state)) : [];
|
|
399
464
|
}
|
|
400
465
|
function* B(e11, t2) {
|
|
401
466
|
if (Array.isArray(e11)) {
|
|
@@ -408,7 +473,7 @@ function* B(e11, t2) {
|
|
|
408
473
|
if (r2 === "tag") {
|
|
409
474
|
let e12 = n2.value;
|
|
410
475
|
if (n2.tag === t2) {
|
|
411
|
-
let t3 =
|
|
476
|
+
let t3 = rt(e12);
|
|
412
477
|
t3 !== null && (yield t3);
|
|
413
478
|
}
|
|
414
479
|
yield* B(e12, t2);
|
|
@@ -420,18 +485,18 @@ function* B(e11, t2) {
|
|
|
420
485
|
}
|
|
421
486
|
for (let e12 of Object.values(n2)) yield* B(e12, t2);
|
|
422
487
|
}
|
|
423
|
-
function
|
|
488
|
+
function rt(e11) {
|
|
424
489
|
if (typeof e11 != "object" || !e11) return null;
|
|
425
490
|
let t2 = e11;
|
|
426
491
|
if (t2["@cbor"] !== "bytes") return null;
|
|
427
492
|
let n2 = t2.hex;
|
|
428
493
|
return typeof n2 == "string" ? n2 : null;
|
|
429
494
|
}
|
|
430
|
-
function
|
|
495
|
+
function it(e11) {
|
|
431
496
|
return typeof e11 == "object" && !!e11 && "Component" in e11;
|
|
432
497
|
}
|
|
433
|
-
var
|
|
434
|
-
function
|
|
498
|
+
var at = "resource_0101010101010101010101010101010101010101010101010101010101010101", ot = "component_0102030000000000000000000000000000000000000000000000000000000000", st = "vault_0102030000000000000000000000000000000000000000000000000000000001", ct = "resource_0102030000000000000000000000000000000000000000000000000000000002", lt = "__ootleRawJson", ut = "stealth_revealed_input", dt = "stealth_revealed_change";
|
|
499
|
+
function ft(e11, t2) {
|
|
435
500
|
let n2 = e11.revealedInputBucket === null ? null : t2(e11.revealedInputBucket);
|
|
436
501
|
return { StealthTransfer: {
|
|
437
502
|
resource_address_ref: { Address: e11.resourceAddress },
|
|
@@ -440,16 +505,17 @@ function rt(e11, t2) {
|
|
|
440
505
|
} };
|
|
441
506
|
}
|
|
442
507
|
function V(e11) {
|
|
443
|
-
return { [
|
|
508
|
+
return { [lt]: e11.toCompactJson() };
|
|
444
509
|
}
|
|
445
510
|
function H(e11) {
|
|
446
511
|
return typeof e11 == "object" && !!e11 && "StealthTransfer" in e11;
|
|
447
512
|
}
|
|
448
513
|
function U(e11) {
|
|
449
514
|
let t2 = [], n2 = (e12) => `__ootleRawJson:${e12}__`, r2 = JSON.stringify(e11, (e12, r3) => {
|
|
515
|
+
if (typeof r3 == "bigint") return r3.toString();
|
|
450
516
|
if (typeof r3 == "object" && r3 && "__ootleRawJson" in r3) {
|
|
451
517
|
let e13 = n2(t2.length);
|
|
452
|
-
return t2.push(r3[
|
|
518
|
+
return t2.push(r3[lt]), e13;
|
|
453
519
|
}
|
|
454
520
|
return r3;
|
|
455
521
|
});
|
|
@@ -468,14 +534,14 @@ async function W(e11, t2) {
|
|
|
468
534
|
inputs: n2
|
|
469
535
|
};
|
|
470
536
|
}
|
|
471
|
-
function
|
|
537
|
+
function pt() {
|
|
472
538
|
let { secret_key: e11, public_key: t2 } = a();
|
|
473
539
|
return {
|
|
474
540
|
secret_key: e11,
|
|
475
541
|
public_key: t2
|
|
476
542
|
};
|
|
477
543
|
}
|
|
478
|
-
function
|
|
544
|
+
function mt(e11, t2) {
|
|
479
545
|
return {
|
|
480
546
|
public_key: b(y(e11, 32, "publicKey")),
|
|
481
547
|
signature: {
|
|
@@ -499,10 +565,10 @@ async function G(e11, t2, n2) {
|
|
|
499
565
|
function K(e11) {
|
|
500
566
|
return t(e11.sealedJson);
|
|
501
567
|
}
|
|
502
|
-
async function
|
|
568
|
+
async function ht(e11, t2) {
|
|
503
569
|
return (await e11.submitTransaction(t2)).transaction_id;
|
|
504
570
|
}
|
|
505
|
-
function
|
|
571
|
+
function gt(e11) {
|
|
506
572
|
var _a, _b;
|
|
507
573
|
if (e11 === "Pending" || !("Finalized" in e11)) return null;
|
|
508
574
|
let t2 = e11.Finalized, n2 = t2.final_decision;
|
|
@@ -520,12 +586,12 @@ function st(e11) {
|
|
|
520
586
|
}
|
|
521
587
|
throw new v(`Unexpected final_decision variant: ${JSON.stringify(n2)}`);
|
|
522
588
|
}
|
|
523
|
-
async function
|
|
589
|
+
async function _t(e11, t2, n2) {
|
|
524
590
|
let r2 = (n2 == null ? void 0 : n2.pollIntervalMs) ?? 500, i2 = (n2 == null ? void 0 : n2.timeoutMs) ?? 6e4, a2 = Date.now() + i2;
|
|
525
591
|
for (; ; ) {
|
|
526
592
|
let n3 = await e11.getTransactionResult(t2), o2 = n3.result;
|
|
527
593
|
if (o2 !== "Pending" && "Finalized" in o2) {
|
|
528
|
-
let { outcome: e12, reason: r3 } =
|
|
594
|
+
let { outcome: e12, reason: r3 } = gt(o2) ?? { outcome: "Reject" };
|
|
529
595
|
if (e12 === "Reject") throw new f(`Transaction ${t2} was rejected: ${r3}`, {
|
|
530
596
|
txId: t2,
|
|
531
597
|
reason: r3 ?? ""
|
|
@@ -540,20 +606,20 @@ async function ct(e11, t2, n2) {
|
|
|
540
606
|
await new Promise((e12) => setTimeout(e12, r2));
|
|
541
607
|
}
|
|
542
608
|
}
|
|
543
|
-
async function
|
|
609
|
+
async function vt(e11, t2, n2, r2) {
|
|
544
610
|
let i2 = await W(e11, n2);
|
|
545
|
-
return
|
|
611
|
+
return _t(e11, await ht(e11, K(await G(Array.isArray(t2) ? t2 : [t2], i2))), r2);
|
|
546
612
|
}
|
|
547
|
-
async function
|
|
548
|
-
return
|
|
613
|
+
async function yt(e11, t2, n2, r2) {
|
|
614
|
+
return vt(e11, t2, {
|
|
549
615
|
...n2,
|
|
550
616
|
dry_run: true
|
|
551
617
|
}, r2);
|
|
552
618
|
}
|
|
553
|
-
var
|
|
554
|
-
constructor(e11) {
|
|
619
|
+
var bt = class {
|
|
620
|
+
constructor(e11, t2) {
|
|
555
621
|
__publicField(this, "builder");
|
|
556
|
-
this.builder = z.new(e11);
|
|
622
|
+
this.builder = z.new(e11, t2);
|
|
557
623
|
}
|
|
558
624
|
withInputs(e11) {
|
|
559
625
|
return this.builder.withInputs(e11), this;
|
|
@@ -565,7 +631,7 @@ var dt = class {
|
|
|
565
631
|
return this.builder.callMethod({
|
|
566
632
|
componentAddress: e11,
|
|
567
633
|
methodName: "withdraw"
|
|
568
|
-
}, [
|
|
634
|
+
}, [A(t2), L(n2)]).saveVar("bucket").callMethod({
|
|
569
635
|
componentAddress: r2,
|
|
570
636
|
methodName: "deposit"
|
|
571
637
|
}, [{ Workspace: "bucket" }]), this;
|
|
@@ -576,11 +642,11 @@ var dt = class {
|
|
|
576
642
|
build() {
|
|
577
643
|
return this.builder.buildUnsignedTransaction();
|
|
578
644
|
}
|
|
579
|
-
},
|
|
580
|
-
constructor(e11, t2) {
|
|
645
|
+
}, xt = class {
|
|
646
|
+
constructor(e11, t2, n2) {
|
|
581
647
|
__publicField(this, "builder");
|
|
582
648
|
__publicField(this, "faucetAddress");
|
|
583
|
-
this.builder = z.new(e11), this.faucetAddress =
|
|
649
|
+
this.builder = z.new(e11, t2), this.faucetAddress = n2;
|
|
584
650
|
}
|
|
585
651
|
feeTransactionPayFromComponent(e11, t2) {
|
|
586
652
|
return this.builder.feeTransactionPayFromComponent(e11, t2), this;
|
|
@@ -589,7 +655,7 @@ var dt = class {
|
|
|
589
655
|
return this.builder.callMethod({
|
|
590
656
|
componentAddress: this.faucetAddress,
|
|
591
657
|
methodName: "take_free_coins"
|
|
592
|
-
}, [
|
|
658
|
+
}, [L(t2)]).saveVar("faucet_bucket").callMethod({
|
|
593
659
|
componentAddress: e11,
|
|
594
660
|
methodName: "deposit"
|
|
595
661
|
}, [{ Workspace: "faucet_bucket" }]), this;
|
|
@@ -613,7 +679,7 @@ var dt = class {
|
|
|
613
679
|
build() {
|
|
614
680
|
return this.builder.buildUnsignedTransaction();
|
|
615
681
|
}
|
|
616
|
-
},
|
|
682
|
+
}, St = class {
|
|
617
683
|
constructor() {
|
|
618
684
|
__publicField(this, "keyProviders");
|
|
619
685
|
__publicField(this, "defaultSignerAddress", null);
|
|
@@ -659,7 +725,7 @@ var dt = class {
|
|
|
659
725
|
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 });
|
|
660
726
|
return n2;
|
|
661
727
|
}
|
|
662
|
-
},
|
|
728
|
+
}, Ct = class {
|
|
663
729
|
constructor(e11, t2) {
|
|
664
730
|
__publicField(this, "bytes");
|
|
665
731
|
this.bytes = new Uint8Array(y(e11, 32, t2));
|
|
@@ -670,7 +736,7 @@ var dt = class {
|
|
|
670
736
|
toHex() {
|
|
671
737
|
return b(this.bytes);
|
|
672
738
|
}
|
|
673
|
-
}, q = class e3 extends
|
|
739
|
+
}, q = class e3 extends Ct {
|
|
674
740
|
constructor(e11) {
|
|
675
741
|
super(e11, "Mask");
|
|
676
742
|
}
|
|
@@ -683,7 +749,7 @@ var dt = class {
|
|
|
683
749
|
static fromHex(t2) {
|
|
684
750
|
return new e3(x(t2));
|
|
685
751
|
}
|
|
686
|
-
},
|
|
752
|
+
}, wt = class e4 {
|
|
687
753
|
constructor(e11) {
|
|
688
754
|
__publicField(this, "bytes");
|
|
689
755
|
this.bytes = new Uint8Array(e11);
|
|
@@ -697,8 +763,8 @@ var dt = class {
|
|
|
697
763
|
toHex() {
|
|
698
764
|
return b(this.bytes);
|
|
699
765
|
}
|
|
700
|
-
},
|
|
701
|
-
function
|
|
766
|
+
}, Tt = Object.freeze({ StealthPublicKey: Object.freeze({}) });
|
|
767
|
+
function Et(e11) {
|
|
702
768
|
if (e11.amount <= 0n) throw new v(`Output amount must be > 0, got ${e11.amount}`);
|
|
703
769
|
return {
|
|
704
770
|
destination: e11.destination,
|
|
@@ -706,19 +772,19 @@ function _t(e11) {
|
|
|
706
772
|
resourceAddress: e11.resourceAddress,
|
|
707
773
|
resourceViewKey: e11.resourceViewKey === void 0 ? void 0 : new Uint8Array(e11.resourceViewKey),
|
|
708
774
|
memo: e11.memo,
|
|
709
|
-
payTo: e11.payTo ??
|
|
775
|
+
payTo: e11.payTo ?? Tt,
|
|
710
776
|
minimumValuePromise: e11.minimumValuePromise ?? 0n
|
|
711
777
|
};
|
|
712
778
|
}
|
|
713
|
-
function
|
|
779
|
+
function Dt(e11, t2) {
|
|
714
780
|
if (e11.trim() === "") throw new v(`${t2} must be a non-empty decimal string`);
|
|
715
781
|
return BigInt(e11);
|
|
716
782
|
}
|
|
717
|
-
function
|
|
783
|
+
function Ot(e11, t2) {
|
|
718
784
|
let n2 = e11.trim();
|
|
719
785
|
if (!n2.startsWith("{") || !n2.endsWith("}")) throw new v(`StealthTransferStatement.toCompactJson: ${t2} fragment is not a JSON object (got: ${e11.slice(0, 60)}...)`);
|
|
720
786
|
}
|
|
721
|
-
var J = class e5 extends
|
|
787
|
+
var J = class e5 extends Ct {
|
|
722
788
|
constructor(e11) {
|
|
723
789
|
super(e11, "StealthInput.commitment");
|
|
724
790
|
}
|
|
@@ -765,13 +831,13 @@ var J = class e5 extends mt {
|
|
|
765
831
|
toJSON() {
|
|
766
832
|
return {
|
|
767
833
|
inputs: this.inputs.map((e11) => e11.toJSON()),
|
|
768
|
-
revealed_amount:
|
|
834
|
+
revealed_amount: Ve(this.revealedAmount)
|
|
769
835
|
};
|
|
770
836
|
}
|
|
771
837
|
static fromJSON(t2) {
|
|
772
|
-
return new e7(t2.inputs.map(J.fromJSON),
|
|
838
|
+
return new e7(t2.inputs.map(J.fromJSON), Dt(t2.revealed_amount, "revealed_amount"));
|
|
773
839
|
}
|
|
774
|
-
},
|
|
840
|
+
}, Z = class e8 {
|
|
775
841
|
constructor(e11) {
|
|
776
842
|
__publicField(this, "statementJson");
|
|
777
843
|
this.statementJson = e11;
|
|
@@ -785,7 +851,7 @@ var J = class e5 extends mt {
|
|
|
785
851
|
static fromJSON(t2) {
|
|
786
852
|
return new e8(t2);
|
|
787
853
|
}
|
|
788
|
-
},
|
|
854
|
+
}, Q = class e9 {
|
|
789
855
|
constructor(e11, t2, n2) {
|
|
790
856
|
__publicField(this, "inputsStatement");
|
|
791
857
|
__publicField(this, "outputsStatement");
|
|
@@ -801,15 +867,15 @@ var J = class e5 extends mt {
|
|
|
801
867
|
}
|
|
802
868
|
toCompactJson() {
|
|
803
869
|
let e11 = this.inputsStatement.statementJson ?? JSON.stringify(this.inputsStatement.toJSON()), t2 = this.outputsStatement.statementJson;
|
|
804
|
-
|
|
805
|
-
let n2 = `{"inputs_statement":${e11},"outputs_statement":${t2}`;
|
|
870
|
+
Ot(e11, "inputs_statement"), Ot(t2, "outputs_statement");
|
|
871
|
+
let n2 = `{"inputs_statement":${e11},"outputs_statement":${t2},"covenant_claims":[]`;
|
|
806
872
|
return this.balanceProof !== void 0 && (n2 += `,"balance_proof":${JSON.stringify(this.balanceProof.toJSON())}`), n2 + "}";
|
|
807
873
|
}
|
|
808
874
|
static fromJSON(t2) {
|
|
809
|
-
return new e9(X.fromJSON(t2.inputs),
|
|
875
|
+
return new e9(X.fromJSON(t2.inputs), Z.fromJSON(t2.outputs), t2.balance_proof === void 0 ? void 0 : Y.fromJSON(t2.balance_proof));
|
|
810
876
|
}
|
|
811
877
|
};
|
|
812
|
-
function
|
|
878
|
+
function kt(e11, t2) {
|
|
813
879
|
let n2 = new Uint8Array(e11.length * 32);
|
|
814
880
|
for (let r2 = 0; r2 < e11.length; r2++) {
|
|
815
881
|
let i2 = e11[r2];
|
|
@@ -817,7 +883,7 @@ function xt(e11, t2) {
|
|
|
817
883
|
}
|
|
818
884
|
return n2;
|
|
819
885
|
}
|
|
820
|
-
var
|
|
886
|
+
var At = class {
|
|
821
887
|
constructor(e11 = u.LocalNet) {
|
|
822
888
|
__publicField(this, "network");
|
|
823
889
|
this.network = e11;
|
|
@@ -825,16 +891,16 @@ var St = class {
|
|
|
825
891
|
async generateOutputsStatement(e11, t2) {
|
|
826
892
|
let n2 = s(`[${e11.map((e12) => this.outputWitness(e12)).join(",")}]`, t2);
|
|
827
893
|
return y(n2.aggregated_output_mask, 32, "StealthOutputsResult.aggregated_output_mask"), {
|
|
828
|
-
statement:
|
|
894
|
+
statement: Z.fromJSON(n2.statement_json),
|
|
829
895
|
outputMask: q.fromBytes(n2.aggregated_output_mask)
|
|
830
896
|
};
|
|
831
897
|
}
|
|
832
898
|
outputWitness(e11) {
|
|
833
|
-
let t2 = c(e11.destination), n2 =
|
|
899
|
+
let t2 = c(e11.destination), n2 = jt(e11.payTo) ? null : JSON.stringify(e11.payTo), i2 = e11.memo === void 0 ? null : JSON.stringify(e11.memo), a2 = e11.resourceViewKey ?? null;
|
|
834
900
|
return r(this.network, t2.owner_key, t2.view_key, e11.amount, e11.resourceAddress, a2, i2, n2, e11.minimumValuePromise);
|
|
835
901
|
}
|
|
836
902
|
async buildInputsStatement(e11, t2) {
|
|
837
|
-
return new X(e11, t2, n(
|
|
903
|
+
return new X(e11, t2, n(kt(e11.map((e12) => e12.commitment), "input commitment"), t2));
|
|
838
904
|
}
|
|
839
905
|
async generateBalanceProofSignature(e11, t2, n2, r2) {
|
|
840
906
|
let i2 = o(e11.toBytes(), t2.toBytes(), n2, r2);
|
|
@@ -858,7 +924,7 @@ var St = class {
|
|
|
858
924
|
};
|
|
859
925
|
}
|
|
860
926
|
async aggregateInputMasks(t2) {
|
|
861
|
-
let n2 = e(
|
|
927
|
+
let n2 = e(kt(t2.map((e11) => e11.toBytes()), "input mask"));
|
|
862
928
|
return q.fromBytes(n2);
|
|
863
929
|
}
|
|
864
930
|
async stealthDhSecret(e11, t2, n2) {
|
|
@@ -870,48 +936,49 @@ var St = class {
|
|
|
870
936
|
re(e11.toCompactJson(), null);
|
|
871
937
|
}
|
|
872
938
|
};
|
|
873
|
-
function
|
|
939
|
+
function jt(e11) {
|
|
874
940
|
let t2 = Object.keys(e11);
|
|
875
941
|
if (t2.length !== 1 || t2[0] !== "StealthPublicKey") return false;
|
|
876
942
|
let n2 = e11.StealthPublicKey;
|
|
877
943
|
return typeof n2 == "object" && !!n2 && Object.keys(n2).length === 0;
|
|
878
944
|
}
|
|
879
|
-
var
|
|
880
|
-
function
|
|
881
|
-
return `${
|
|
945
|
+
var Mt = "utxo";
|
|
946
|
+
function Nt(e11, t2) {
|
|
947
|
+
return `${Mt}_${e11.startsWith("resource_") ? e11.slice(9) : e11}_${b(t2)}`;
|
|
882
948
|
}
|
|
883
|
-
var
|
|
884
|
-
function
|
|
949
|
+
var Pt = 64;
|
|
950
|
+
function Ft(e11) {
|
|
885
951
|
return typeof e11 == "object" && !!e11 && "Utxo" in e11;
|
|
886
952
|
}
|
|
887
|
-
function
|
|
953
|
+
function It(e11) {
|
|
888
954
|
return e11.length > 0 && /^[0-9a-fA-F]+$/.test(e11);
|
|
889
955
|
}
|
|
890
|
-
function
|
|
956
|
+
function Lt(e11) {
|
|
891
957
|
let t2 = e11.split("_");
|
|
892
|
-
if (t2.length < 3 || t2[0] !==
|
|
958
|
+
if (t2.length < 3 || t2[0] !== Mt) return null;
|
|
893
959
|
let n2 = t2[t2.length - 1];
|
|
894
|
-
return n2.length !==
|
|
960
|
+
return n2.length !== Pt || !It(n2) ? null : x(n2);
|
|
895
961
|
}
|
|
896
|
-
function
|
|
962
|
+
function Rt(e11, t2) {
|
|
897
963
|
let n2 = e11.substate;
|
|
898
|
-
if (!
|
|
964
|
+
if (!Ft(n2)) return null;
|
|
899
965
|
let r2 = n2.Utxo;
|
|
900
966
|
if (r2.output === null || r2.is_frozen) return null;
|
|
901
|
-
let i2 =
|
|
967
|
+
let i2 = Lt(t2);
|
|
902
968
|
return i2 === null ? null : {
|
|
903
969
|
commitment: i2,
|
|
904
970
|
body: r2.output.output
|
|
905
971
|
};
|
|
906
972
|
}
|
|
907
|
-
var
|
|
908
|
-
constructor(e11, t2, n2 = new
|
|
973
|
+
var zt = 0, Bt = class {
|
|
974
|
+
constructor(e11, t2, n2 = new At(e11.network())) {
|
|
909
975
|
__publicField(this, "provider");
|
|
910
976
|
__publicField(this, "crypto");
|
|
911
977
|
__publicField(this, "builder");
|
|
912
978
|
__publicField(this, "state");
|
|
979
|
+
__publicField(this, "maxEpoch", null);
|
|
913
980
|
__publicField(this, "prepared", false);
|
|
914
|
-
this.provider = e11, this.crypto = n2, this.builder = z.new(e11.network()), this.state = {
|
|
981
|
+
this.provider = e11, this.crypto = n2, this.builder = z.new(e11.network(), zt), this.state = {
|
|
915
982
|
resource: t2,
|
|
916
983
|
revealedInput: null,
|
|
917
984
|
inputsToSpend: /* @__PURE__ */ new Map(),
|
|
@@ -940,6 +1007,9 @@ var jt = class {
|
|
|
940
1007
|
if (e11 <= 0n) throw new v(`payFeeFromRevealed amount must be > 0, got ${e11}`);
|
|
941
1008
|
return this.builder.feeTransactionPayFromComponent(this.state.revealedInput.source, e11), this;
|
|
942
1009
|
}
|
|
1010
|
+
withMaxEpoch(e11) {
|
|
1011
|
+
return this.builder.withMaxEpoch(e11), this.maxEpoch = e11, this;
|
|
1012
|
+
}
|
|
943
1013
|
withBuilder(e11) {
|
|
944
1014
|
return this.builder = e11(this.builder), this;
|
|
945
1015
|
}
|
|
@@ -955,8 +1025,8 @@ var jt = class {
|
|
|
955
1025
|
var _a;
|
|
956
1026
|
if (this.prepared) throw new v("StealthTransfer.prepare: already prepared \u2014 create a new StealthTransfer to build again");
|
|
957
1027
|
this.validate(), this.prepared = true;
|
|
958
|
-
let { statement: e11, outputMask: t2 } = await this.crypto.generateOutputsStatement(this.state.outputs, this.state.revealedOutputAmount), n2 = new
|
|
959
|
-
this.emitInstructions(n2);
|
|
1028
|
+
let { statement: e11, outputMask: t2 } = await this.crypto.generateOutputsStatement(this.state.outputs, this.state.revealedOutputAmount), 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);
|
|
1029
|
+
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch === zt && this.builder.withMaxEpoch(await Ge(this.provider));
|
|
960
1030
|
let r2 = /* @__PURE__ */ new Set();
|
|
961
1031
|
if (this.state.revealedInput !== null) {
|
|
962
1032
|
let e12 = this.state.revealedInput.source;
|
|
@@ -964,14 +1034,14 @@ var jt = class {
|
|
|
964
1034
|
substate_id: e12,
|
|
965
1035
|
version: null
|
|
966
1036
|
}), r2.add(e12);
|
|
967
|
-
let t3 = await
|
|
1037
|
+
let t3 = await nt(this.provider, e12);
|
|
968
1038
|
for (let e13 of t3) r2.has(e13) || (this.builder.addInput({
|
|
969
1039
|
substate_id: e13,
|
|
970
1040
|
version: null
|
|
971
1041
|
}), r2.add(e13));
|
|
972
1042
|
}
|
|
973
1043
|
for (let { input: e12 } of this.state.inputsToSpend.values()) {
|
|
974
|
-
let t3 =
|
|
1044
|
+
let t3 = Nt(this.state.resource, e12.commitment);
|
|
975
1045
|
r2.has(t3) || (this.builder.addInput({
|
|
976
1046
|
substate_id: t3,
|
|
977
1047
|
version: null
|
|
@@ -1010,34 +1080,34 @@ var jt = class {
|
|
|
1010
1080
|
t2 !== null && (this.builder.callMethod({
|
|
1011
1081
|
componentAddress: t2.source,
|
|
1012
1082
|
methodName: "withdraw"
|
|
1013
|
-
}, [
|
|
1083
|
+
}, [A(this.state.resource), k(t2.amount)]).saveVar(ut), n2 = ut), this.builder.addInstruction(ft({
|
|
1014
1084
|
resourceAddress: this.state.resource,
|
|
1015
1085
|
revealedInputBucket: n2,
|
|
1016
1086
|
statement: e11
|
|
1017
|
-
}, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutputAmount > 0n && t2 !== null && this.builder.saveVar(
|
|
1087
|
+
}, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutputAmount > 0n && t2 !== null && this.builder.saveVar(dt).callMethod({
|
|
1018
1088
|
componentAddress: t2.source,
|
|
1019
1089
|
methodName: "deposit"
|
|
1020
|
-
}, [{ Workspace:
|
|
1090
|
+
}, [{ Workspace: dt }]);
|
|
1021
1091
|
}
|
|
1022
1092
|
};
|
|
1023
|
-
function
|
|
1024
|
-
if (
|
|
1093
|
+
function Vt(e11) {
|
|
1094
|
+
if (Ht(e11) || e11.statementJson !== void 0) return e11.statementJson;
|
|
1025
1095
|
if (e11.inputs.length > 0) throw new _("inputs statement has confidential inputs but no WASM statementJson \u2014 call buildInputsStatement first", { context: "statementJsonFor" });
|
|
1026
1096
|
return JSON.stringify(e11.toJSON());
|
|
1027
1097
|
}
|
|
1028
|
-
function
|
|
1098
|
+
function Ht(e11) {
|
|
1029
1099
|
return !("inputs" in e11);
|
|
1030
1100
|
}
|
|
1031
|
-
async function
|
|
1032
|
-
let a2 =
|
|
1101
|
+
async function Ut(e11, t2, n2, r2, i2) {
|
|
1102
|
+
let a2 = Vt(r2), o2 = Vt(i2);
|
|
1033
1103
|
return e11.generateBalanceProofSignature(t2, n2, a2, o2);
|
|
1034
1104
|
}
|
|
1035
1105
|
async function $(e11, t2, n2, r2) {
|
|
1036
1106
|
let i2 = await e11.deriveAeadKey(r2.viewSecret, r2.senderPublicNonce);
|
|
1037
1107
|
return e11.unblindOutput(t2, n2, i2, r2.skipMemo);
|
|
1038
1108
|
}
|
|
1039
|
-
async function
|
|
1040
|
-
let i2 =
|
|
1109
|
+
async function Wt(e11, t2, n2, r2) {
|
|
1110
|
+
let i2 = Rt(n2, r2);
|
|
1041
1111
|
if (i2 === null) return null;
|
|
1042
1112
|
let a2 = x(i2.body.encrypted_data), o2 = x(i2.body.public_nonce);
|
|
1043
1113
|
try {
|
|
@@ -1050,33 +1120,33 @@ async function Pt(e11, t2, n2, r2) {
|
|
|
1050
1120
|
return null;
|
|
1051
1121
|
}
|
|
1052
1122
|
}
|
|
1053
|
-
async function
|
|
1123
|
+
async function Gt(e11, t2, n2) {
|
|
1054
1124
|
if (t2.length === 0) throw new v("generateOutputsStatement: at least one stealth output is required");
|
|
1055
1125
|
let { statement: r2, outputMask: i2 } = await e11.generateOutputsStatement(t2, n2), a2 = await e11.buildInputsStatement([], 0n);
|
|
1056
|
-
return new
|
|
1126
|
+
return new Q(a2, r2, await Ut(e11, q.zero(), i2, a2, r2));
|
|
1057
1127
|
}
|
|
1058
|
-
var
|
|
1128
|
+
var Kt = class e10 {
|
|
1059
1129
|
constructor(e11, t2, n2, r2, i2) {
|
|
1060
1130
|
this.wallet = e11, this.spec = t2, this.crypto = n2, this.mustSignWithAccountKey = r2, this.viewSecret = i2;
|
|
1061
1131
|
}
|
|
1062
1132
|
static fromSpec(t2, n2, r2 = {}) {
|
|
1063
|
-
return new e10(t2, n2, r2.crypto ?? new
|
|
1133
|
+
return new e10(t2, n2, r2.crypto ?? new At(), r2.mustSignWithAccountKey ?? true, r2.viewSecret);
|
|
1064
1134
|
}
|
|
1065
1135
|
async prepare(e11) {
|
|
1066
|
-
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ? q.zero() : await this.crypto.aggregateInputMasks(t2.map((e12) => e12.mask)), r2 = await
|
|
1136
|
+
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ? q.zero() : await this.crypto.aggregateInputMasks(t2.map((e12) => e12.mask)), r2 = await Ut(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);
|
|
1067
1137
|
await this.crypto.validateTransfer(i2);
|
|
1068
|
-
let a2 =
|
|
1138
|
+
let a2 = Jt(this.spec.unsignedTx, i2), o2 = {
|
|
1069
1139
|
...this.spec,
|
|
1070
1140
|
unsignedTx: a2,
|
|
1071
1141
|
statement: i2
|
|
1072
1142
|
};
|
|
1073
|
-
return new
|
|
1143
|
+
return new qt({
|
|
1074
1144
|
wallet: this.wallet,
|
|
1075
1145
|
crypto: this.crypto,
|
|
1076
1146
|
spec: o2,
|
|
1077
1147
|
resolvedInputs: t2,
|
|
1078
1148
|
mustSignWithAccountKey: this.mustSignWithAccountKey,
|
|
1079
|
-
sealKeypair:
|
|
1149
|
+
sealKeypair: pt()
|
|
1080
1150
|
});
|
|
1081
1151
|
}
|
|
1082
1152
|
async resolveViewSecret() {
|
|
@@ -1101,7 +1171,7 @@ var It = class e10 {
|
|
|
1101
1171
|
let t2 = await this.resolveViewSecret(), n2 = this.spec.state.resource, r2 = await Promise.allSettled(this.spec.inputs.map(async ({ input: r3, owner: i3 }) => {
|
|
1102
1172
|
let a2 = b(r3.commitment), o2 = await e11.getStealthUtxo(n2, r3.commitment);
|
|
1103
1173
|
if (o2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input UTXO not found (spent or never created) for ${a2}`);
|
|
1104
|
-
let s2 =
|
|
1174
|
+
let s2 = Rt(o2, Nt(n2, r3.commitment));
|
|
1105
1175
|
if (s2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input ${a2} is not a live, spendable UTXO`);
|
|
1106
1176
|
let c2 = x(s2.body.public_nonce), l2;
|
|
1107
1177
|
try {
|
|
@@ -1126,7 +1196,7 @@ var It = class e10 {
|
|
|
1126
1196
|
if (i2 !== void 0) throw i2.reason;
|
|
1127
1197
|
return r2.map((e12) => e12.value);
|
|
1128
1198
|
}
|
|
1129
|
-
},
|
|
1199
|
+
}, qt = class {
|
|
1130
1200
|
constructor(e11) {
|
|
1131
1201
|
__publicField(this, "wallet");
|
|
1132
1202
|
__publicField(this, "crypto");
|
|
@@ -1169,10 +1239,10 @@ var It = class e10 {
|
|
|
1169
1239
|
let e11 = (await this.createAuthorizations()).flatMap((e12) => e12.signatures), t2 = [];
|
|
1170
1240
|
this.mustSignWithAccountKey && t2.push(this.wallet);
|
|
1171
1241
|
let n2 = [...e11, ...this.extraSignatures];
|
|
1172
|
-
return n2.length > 0 && t2.push(new
|
|
1242
|
+
return n2.length > 0 && t2.push(new Yt(n2)), K(await G(t2, this.spec.unsignedTx, this.sealKeypair));
|
|
1173
1243
|
}
|
|
1174
1244
|
};
|
|
1175
|
-
function
|
|
1245
|
+
function Jt(e11, t2) {
|
|
1176
1246
|
let n2 = e11.instructions.findIndex(H);
|
|
1177
1247
|
if (n2 < 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found 0 (not a stealth tx)");
|
|
1178
1248
|
if (e11.instructions.slice(n2 + 1).findIndex(H) >= 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found more than one (malformed)");
|
|
@@ -1185,7 +1255,7 @@ function Rt(e11, t2) {
|
|
|
1185
1255
|
instructions: i2
|
|
1186
1256
|
};
|
|
1187
1257
|
}
|
|
1188
|
-
var
|
|
1258
|
+
var Yt = class {
|
|
1189
1259
|
constructor(e11) {
|
|
1190
1260
|
this.signatures = e11;
|
|
1191
1261
|
}
|
|
@@ -1200,84 +1270,87 @@ var zt = class {
|
|
|
1200
1270
|
}
|
|
1201
1271
|
};
|
|
1202
1272
|
export {
|
|
1203
|
-
|
|
1204
|
-
|
|
1273
|
+
bt as AccountInvokeBuilder,
|
|
1274
|
+
qt as AuthorizedTransfer,
|
|
1205
1275
|
Y as BalanceProofSignature,
|
|
1206
1276
|
_ as CryptoBridgeError,
|
|
1277
|
+
We as DEFAULT_TRANSACTION_VALIDITY_EPOCHS,
|
|
1207
1278
|
h as DefaultSignerNotSetError,
|
|
1208
|
-
|
|
1209
|
-
|
|
1279
|
+
wt as EncryptedData,
|
|
1280
|
+
xt as FaucetInvokeBuilder,
|
|
1210
1281
|
ie as IndexerClientError,
|
|
1211
1282
|
v as InvalidArgumentError,
|
|
1212
1283
|
m as KeyProviderNotFoundError,
|
|
1284
|
+
Ue as MAX_TRANSACTION_VALIDITY_EPOCHS,
|
|
1213
1285
|
q as Mask,
|
|
1214
1286
|
u as Network,
|
|
1215
1287
|
d as OotleError,
|
|
1216
|
-
|
|
1288
|
+
St as OotleWallet,
|
|
1217
1289
|
oe as OperationCancelledError,
|
|
1218
1290
|
g as SignerError,
|
|
1219
1291
|
J as StealthInput,
|
|
1220
1292
|
X as StealthInputsStatement,
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1293
|
+
Z as StealthOutputsStatement,
|
|
1294
|
+
Bt as StealthTransfer,
|
|
1295
|
+
Q as StealthTransferStatement,
|
|
1296
|
+
at as TARI_RESOURCE_ADDRESS,
|
|
1225
1297
|
z as TransactionBuilder,
|
|
1226
1298
|
f as TransactionRejectedError,
|
|
1227
1299
|
ae as TransactionTimeoutError,
|
|
1228
1300
|
p as WalletError,
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1301
|
+
Kt as WalletStealthAuthorizer,
|
|
1302
|
+
At as WasmStealthCrypto,
|
|
1303
|
+
ct as XTR_FAUCET_CLAIM_RESOURCE_ADDRESS,
|
|
1304
|
+
ot as XTR_FAUCET_COMPONENT_ADDRESS,
|
|
1305
|
+
st as XTR_FAUCET_VAULT_ADDRESS,
|
|
1234
1306
|
k as amountLiteral,
|
|
1235
1307
|
y as assertByteLength,
|
|
1236
1308
|
se as assertUnreachable,
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1309
|
+
Oe as boolLiteral,
|
|
1310
|
+
mt as buildTransactionSignature,
|
|
1311
|
+
De as bytesLiteral,
|
|
1312
|
+
Ne as claimedOutputTombstoneAddressLiteral,
|
|
1313
|
+
gt as classifyOutcome,
|
|
1314
|
+
Lt as commitmentOf,
|
|
1315
|
+
ke as componentAddressLiteral,
|
|
1316
|
+
Et as createOutput,
|
|
1245
1317
|
$ as decryptInputData,
|
|
1246
|
-
|
|
1247
|
-
|
|
1318
|
+
Wt as decryptOwnedUtxo,
|
|
1319
|
+
Qe as defaultIndexerUrl,
|
|
1248
1320
|
x as fromHexStr,
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1321
|
+
Gt as generateOutputsStatement,
|
|
1322
|
+
pt as generateSealKeypair,
|
|
1323
|
+
nt as getVaultIdsForAccount,
|
|
1324
|
+
Te as intLiteral,
|
|
1253
1325
|
H as isStealthTransferInstruction,
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1326
|
+
tt as iterVaultIdsInState,
|
|
1327
|
+
Ce as literalArg,
|
|
1328
|
+
Ae as metadataLiteral,
|
|
1329
|
+
L as microTariLiteral,
|
|
1330
|
+
Ve as microTariString,
|
|
1331
|
+
Ie as nonFungibleAddressLiteral,
|
|
1332
|
+
Rt as parseSubstateUtxo,
|
|
1333
|
+
He as parseWorkspaceStringKey,
|
|
1334
|
+
Jt as patchStealthStatement,
|
|
1335
|
+
Fe as publicKeyLiteral,
|
|
1336
|
+
Ge as resolveMaxEpoch,
|
|
1264
1337
|
W as resolveTransaction,
|
|
1265
|
-
|
|
1338
|
+
A as resourceAddressLiteral,
|
|
1266
1339
|
K as sealTransaction,
|
|
1267
|
-
|
|
1268
|
-
|
|
1340
|
+
yt as sendDryRun,
|
|
1341
|
+
vt as sendTransaction,
|
|
1269
1342
|
U as serializeUnsignedTx,
|
|
1270
|
-
|
|
1343
|
+
Ut as signBalanceProof,
|
|
1271
1344
|
G as signTransaction,
|
|
1272
1345
|
V as statementAsWire,
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1346
|
+
ft as stealthTransferInstruction,
|
|
1347
|
+
Nt as stealthUtxoSubstateId,
|
|
1348
|
+
Ee as stringLiteral,
|
|
1349
|
+
ht as submitTransaction,
|
|
1350
|
+
Me as templateAddressLiteral,
|
|
1278
1351
|
b as toHexStr,
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1352
|
+
Le as utxoAddressLiteral,
|
|
1353
|
+
Pe as validatorFeePoolAddressLiteral,
|
|
1354
|
+
je as vaultIdLiteral,
|
|
1355
|
+
_t as watchTransaction
|
|
1283
1356
|
};
|