@tari-project/ootle 0.11.0 → 0.12.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 +108 -17
- package/dist/index.js +383 -320
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -2,13 +2,14 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { aggregateInputMasks as e, borEncodeTransaction as t, buildStealthInputsStatement as n, createStealthOutputWitness as r, encryptedDataDhKdfAead as i, generateKeypair as a, generateStealthBalanceProofSignature as o, generateStealthOutputsStatement as s, parseOotleAddress as c, sealTransaction as l, stealthDhSecret as ee, unblindOutput as te, validateBalanceProofSignature as ne, validateStealthTransfer as re } from "@tari-project/ootle-wasm";
|
|
5
|
+
import { decodeEvent as ie, decodeExecuteResult as ae, decodeResource as oe, decodeSubstateValue as se, decodeTransactionReceipt as ce, decodeUtxo as le } from "@tari-project/ootle-wasm-bor";
|
|
5
6
|
var u = /* @__PURE__ */ (function(e11) {
|
|
6
7
|
return e11[e11.MainNet = 0] = "MainNet", e11[e11.StageNet = 1] = "StageNet", e11[e11.NextNet = 2] = "NextNet", e11[e11.LocalNet = 16] = "LocalNet", e11[e11.Igor = 36] = "Igor", e11[e11.Esmeralda = 38] = "Esmeralda", e11;
|
|
7
8
|
})({}), d = class extends Error {
|
|
8
9
|
constructor(e11, t2) {
|
|
9
10
|
super(e11, t2), this.name = new.target.name;
|
|
10
11
|
}
|
|
11
|
-
},
|
|
12
|
+
}, ue = class extends d {
|
|
12
13
|
constructor(e11, t2) {
|
|
13
14
|
super(e11, t2);
|
|
14
15
|
__publicField(this, "status");
|
|
@@ -24,7 +25,7 @@ var u = /* @__PURE__ */ (function(e11) {
|
|
|
24
25
|
__publicField(this, "rejectReason");
|
|
25
26
|
this.txId = t2.txId, this.reason = t2.reason, this.rejectReason = t2.rejectReason;
|
|
26
27
|
}
|
|
27
|
-
},
|
|
28
|
+
}, de = class extends d {
|
|
28
29
|
constructor(e11, t2) {
|
|
29
30
|
super(e11, t2);
|
|
30
31
|
__publicField(this, "txId");
|
|
@@ -46,9 +47,9 @@ var u = /* @__PURE__ */ (function(e11) {
|
|
|
46
47
|
this.context = t2 == null ? void 0 : t2.context;
|
|
47
48
|
}
|
|
48
49
|
}, v = class extends d {
|
|
49
|
-
},
|
|
50
|
+
}, fe = class extends d {
|
|
50
51
|
};
|
|
51
|
-
function
|
|
52
|
+
function pe(e11, t2) {
|
|
52
53
|
throw new v(`assertUnreachable${t2 ? ` (${t2})` : ""}: ${JSON.stringify(e11)}`);
|
|
53
54
|
}
|
|
54
55
|
function y(e11, t2, n2) {
|
|
@@ -58,158 +59,158 @@ function y(e11, t2, n2) {
|
|
|
58
59
|
function b(e11) {
|
|
59
60
|
return Array.from(e11, (e12) => e12.toString(16).padStart(2, "0")).join("");
|
|
60
61
|
}
|
|
61
|
-
var
|
|
62
|
+
var me = /^[0-9a-fA-F]*$/;
|
|
62
63
|
function x(e11) {
|
|
63
64
|
if (e11.length % 2 != 0) throw new v(`fromHexStr: hex string must have even length, got ${e11.length}`);
|
|
64
|
-
if (!
|
|
65
|
+
if (!me.test(e11)) throw new v("fromHexStr: hex string contains non-hex characters");
|
|
65
66
|
let t2 = new Uint8Array(e11.length / 2);
|
|
66
67
|
for (let n2 = 0; n2 < t2.length; n2++) t2[n2] = parseInt(e11.substring(n2 * 2, n2 * 2 + 2), 16);
|
|
67
68
|
return t2;
|
|
68
69
|
}
|
|
69
|
-
var S = (1n << 64n) - 1n,
|
|
70
|
-
function
|
|
70
|
+
var S = (1n << 64n) - 1n, he = 2n, C = 32, ge = C * 2, _e = 32, ve = 128, ye = 129, be = 130, w = 131, xe = 132, Se = 136, Ce = 138, we = 141, T = 0, Te = 32, E = 64, Ee = 96, D = 128, De = 160, O = 192;
|
|
71
|
+
function Oe(e11) {
|
|
71
72
|
switch (typeof e11) {
|
|
72
73
|
case "bigint":
|
|
73
|
-
return
|
|
74
|
+
return k(e11);
|
|
74
75
|
case "string":
|
|
75
|
-
return
|
|
76
|
+
return je(e11);
|
|
76
77
|
case "boolean":
|
|
77
|
-
return
|
|
78
|
+
return Me(e11);
|
|
78
79
|
default:
|
|
79
|
-
if (e11 instanceof Uint8Array) return
|
|
80
|
+
if (e11 instanceof Uint8Array) return A(e11);
|
|
80
81
|
throw new v(`literalArg: cannot CBOR-encode value of type ${typeof e11}`);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
+
function k(e11) {
|
|
84
85
|
if (e11 < 0n) throw new v(`amountLiteral: amount must be non-negative, got ${e11}`);
|
|
85
86
|
if (e11 >> 128n != 0n) throw new v(`amountLiteral: amount overflows u128: ${e11}`);
|
|
86
87
|
let t2 = [];
|
|
87
|
-
return e11 <= S ?
|
|
88
|
+
return e11 <= S ? I(t2, T, e11) : ke(t2, e11), L(t2);
|
|
88
89
|
}
|
|
89
|
-
function
|
|
90
|
+
function ke(e11, t2) {
|
|
90
91
|
let n2 = [], r2 = t2;
|
|
91
92
|
for (; r2 > 0n; ) n2.unshift(Number(r2 & 255n)), r2 >>= 8n;
|
|
92
|
-
|
|
93
|
+
I(e11, O, he), I(e11, E, BigInt(n2.length)), F(e11, n2);
|
|
93
94
|
}
|
|
94
|
-
function
|
|
95
|
+
function Ae(e11) {
|
|
95
96
|
let t2 = [];
|
|
96
97
|
if (e11 >= 0n) {
|
|
97
98
|
if (e11 > S) throw new v(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
|
|
98
|
-
|
|
99
|
+
I(t2, T, e11);
|
|
99
100
|
} else {
|
|
100
101
|
let n2 = -1n - e11;
|
|
101
102
|
if (n2 > S) throw new v(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
|
|
102
|
-
|
|
103
|
+
I(t2, Te, n2);
|
|
103
104
|
}
|
|
104
|
-
return
|
|
105
|
+
return L(t2);
|
|
105
106
|
}
|
|
106
|
-
function
|
|
107
|
+
function je(e11) {
|
|
107
108
|
let t2 = [];
|
|
108
|
-
return
|
|
109
|
+
return P(t2, e11), L(t2);
|
|
109
110
|
}
|
|
110
|
-
function
|
|
111
|
+
function A(e11) {
|
|
111
112
|
let t2 = [];
|
|
112
|
-
return
|
|
113
|
+
return I(t2, E, BigInt(e11.length)), F(t2, e11), L(t2);
|
|
113
114
|
}
|
|
114
|
-
function
|
|
115
|
+
function Me(e11) {
|
|
115
116
|
return { Literal: e11 ? "f5" : "f4" };
|
|
116
117
|
}
|
|
117
|
-
function
|
|
118
|
-
return
|
|
118
|
+
function j(e11) {
|
|
119
|
+
return M(w, e11, "resource_");
|
|
119
120
|
}
|
|
120
|
-
function
|
|
121
|
-
return
|
|
121
|
+
function Ne(e11) {
|
|
122
|
+
return M(ve, e11, "component_");
|
|
122
123
|
}
|
|
123
|
-
function
|
|
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
|
+
function Pe(e11) {
|
|
125
|
+
let t2 = e11 instanceof Map ? e11 : new Map(Object.entries(e11)), n2 = new TextEncoder(), r2 = [...t2.entries()].sort(([e12], [t3]) => Ge(n2.encode(e12), n2.encode(t3))), i2 = [];
|
|
126
|
+
I(i2, O, BigInt(ye)), I(i2, De, BigInt(r2.length));
|
|
127
|
+
for (let [e12, t3] of r2) P(i2, e12), P(i2, t3);
|
|
128
|
+
return L(i2);
|
|
128
129
|
}
|
|
129
|
-
function
|
|
130
|
-
return
|
|
130
|
+
function Fe(e11) {
|
|
131
|
+
return M(xe, e11, "vault_");
|
|
131
132
|
}
|
|
132
|
-
function
|
|
133
|
-
return
|
|
133
|
+
function Ie(e11) {
|
|
134
|
+
return A(He(e11, "template_"));
|
|
134
135
|
}
|
|
135
|
-
function
|
|
136
|
-
return
|
|
136
|
+
function Le(e11) {
|
|
137
|
+
return M(Se, e11, "tombstone_");
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
-
return
|
|
139
|
+
function Re(e11) {
|
|
140
|
+
return M(Ce, e11, "vnfp_");
|
|
140
141
|
}
|
|
141
|
-
function
|
|
142
|
+
function ze(e11) {
|
|
142
143
|
let t2 = typeof e11 == "string" ? x(e11) : e11;
|
|
143
|
-
return y(t2,
|
|
144
|
+
return y(t2, _e, "publicKeyLiteral"), A(t2);
|
|
144
145
|
}
|
|
145
|
-
function
|
|
146
|
+
function Be(e11) {
|
|
146
147
|
let t2 = [];
|
|
147
|
-
return
|
|
148
|
+
return I(t2, O, BigInt(be)), I(t2, D, 2n), N(t2, w, e11.resource_address, "resource_"), Ue(t2, e11.id), L(t2);
|
|
148
149
|
}
|
|
149
|
-
function
|
|
150
|
+
function Ve(e11) {
|
|
150
151
|
let t2 = [];
|
|
151
|
-
|
|
152
|
+
I(t2, O, BigInt(we)), I(t2, D, 2n), N(t2, w, e11.resource_address, "resource_");
|
|
152
153
|
let n2 = x(e11.id);
|
|
153
|
-
return y(n2, C, "utxoAddressLiteral: id"),
|
|
154
|
+
return y(n2, C, "utxoAddressLiteral: id"), I(t2, E, BigInt(C)), F(t2, n2), L(t2);
|
|
154
155
|
}
|
|
155
|
-
function
|
|
156
|
+
function M(e11, t2, n2) {
|
|
156
157
|
let r2 = [];
|
|
157
|
-
return
|
|
158
|
+
return N(r2, e11, t2, n2), L(r2);
|
|
158
159
|
}
|
|
159
|
-
function
|
|
160
|
-
let i2 =
|
|
161
|
-
|
|
160
|
+
function N(e11, t2, n2, r2) {
|
|
161
|
+
let i2 = He(n2, r2);
|
|
162
|
+
I(e11, O, BigInt(t2)), I(e11, E, BigInt(C)), F(e11, i2);
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
+
function He(e11, t2) {
|
|
164
165
|
let n2 = e11.startsWith(t2) ? e11.slice(t2.length) : e11;
|
|
165
|
-
if (n2.length !==
|
|
166
|
+
if (n2.length !== ge) throw new v(`${t2}address must be 32 bytes (${ge} hex chars), got ${n2.length}`);
|
|
166
167
|
return x(n2);
|
|
167
168
|
}
|
|
168
|
-
function
|
|
169
|
-
if (
|
|
170
|
-
|
|
169
|
+
function Ue(e11, t2) {
|
|
170
|
+
if (I(e11, D, 2n), "U256" in t2) {
|
|
171
|
+
I(e11, T, 0n), I(e11, D, 1n);
|
|
171
172
|
let n2 = x(t2.U256);
|
|
172
|
-
y(n2, C, "NonFungibleId.U256"),
|
|
173
|
-
} else if ("String" in t2)
|
|
174
|
-
else if ("Uint32" in t2)
|
|
175
|
-
else if ("Uint64" in t2)
|
|
173
|
+
y(n2, C, "NonFungibleId.U256"), I(e11, E, BigInt(C)), F(e11, n2);
|
|
174
|
+
} else if ("String" in t2) I(e11, T, 1n), I(e11, D, 1n), P(e11, t2.String);
|
|
175
|
+
else if ("Uint32" in t2) I(e11, T, 2n), I(e11, D, 1n), We(e11, t2.Uint32, "NonFungibleId.Uint32", (1n << 32n) - 1n);
|
|
176
|
+
else if ("Uint64" in t2) I(e11, T, 3n), I(e11, D, 1n), We(e11, t2.Uint64, "NonFungibleId.Uint64", S);
|
|
176
177
|
else throw new v(`nonFungibleAddressLiteral: unrecognised NonFungibleId variant: ${JSON.stringify(t2)}`);
|
|
177
178
|
}
|
|
178
|
-
function
|
|
179
|
+
function We(e11, t2, n2, r2) {
|
|
179
180
|
if (!Number.isInteger(t2) || t2 < 0) throw new v(`${n2} must be a non-negative integer, got ${t2}`);
|
|
180
181
|
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.`);
|
|
181
182
|
let i2 = BigInt(t2);
|
|
182
183
|
if (i2 > r2) throw new v(`${n2} value ${t2} exceeds its maximum of ${r2}`);
|
|
183
|
-
|
|
184
|
+
I(e11, T, i2);
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
+
function P(e11, t2) {
|
|
186
187
|
let n2 = new TextEncoder().encode(t2);
|
|
187
|
-
|
|
188
|
+
I(e11, Ee, BigInt(n2.length)), F(e11, n2);
|
|
188
189
|
}
|
|
189
|
-
function
|
|
190
|
+
function F(e11, t2) {
|
|
190
191
|
let n2 = e11.length;
|
|
191
192
|
e11.length = n2 + t2.length;
|
|
192
193
|
for (let r2 = 0; r2 < t2.length; r2++) e11[n2 + r2] = t2[r2];
|
|
193
194
|
}
|
|
194
|
-
function
|
|
195
|
+
function Ge(e11, t2) {
|
|
195
196
|
let n2 = Math.min(e11.length, t2.length);
|
|
196
197
|
for (let r2 = 0; r2 < n2; r2++) if (e11[r2] !== t2[r2]) return e11[r2] < t2[r2] ? -1 : 1;
|
|
197
198
|
return e11.length - t2.length;
|
|
198
199
|
}
|
|
199
|
-
function
|
|
200
|
+
function I(e11, t2, n2) {
|
|
200
201
|
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));
|
|
201
202
|
}
|
|
202
|
-
function
|
|
203
|
+
function L(e11) {
|
|
203
204
|
return { Literal: b(Uint8Array.from(e11)) };
|
|
204
205
|
}
|
|
205
|
-
function
|
|
206
|
-
return
|
|
206
|
+
function R(e11) {
|
|
207
|
+
return k(e11);
|
|
207
208
|
}
|
|
208
|
-
function
|
|
209
|
+
function Ke(e11) {
|
|
209
210
|
if (e11 < 0n) throw new v(`microTariString: amount must be non-negative, got ${e11}`);
|
|
210
211
|
return e11.toString();
|
|
211
212
|
}
|
|
212
|
-
function
|
|
213
|
+
function qe(e11) {
|
|
213
214
|
let t2 = e11.split(".");
|
|
214
215
|
if (t2.length > 2) throw new v("Invalid workspace key format. Only one dot is allowed.");
|
|
215
216
|
let n2 = t2[0];
|
|
@@ -224,24 +225,24 @@ function He(e11) {
|
|
|
224
225
|
offset: r2
|
|
225
226
|
};
|
|
226
227
|
}
|
|
227
|
-
var
|
|
228
|
-
async function
|
|
228
|
+
var Je = 2160, Ye = 10;
|
|
229
|
+
async function Xe(e11, t2 = 10) {
|
|
229
230
|
if (!Number.isInteger(t2) || t2 < 1) throw new v(`resolveMaxEpoch: leadEpochs must be a positive integer, got ${t2}`);
|
|
230
|
-
if (t2 > 2160) throw new v(`resolveMaxEpoch: leadEpochs ${t2} exceeds the network's maximum validity window of ${
|
|
231
|
+
if (t2 > 2160) throw new v(`resolveMaxEpoch: leadEpochs ${t2} exceeds the network's maximum validity window of ${Je} epochs`);
|
|
231
232
|
return await e11.getCurrentEpoch() + t2;
|
|
232
233
|
}
|
|
233
|
-
var
|
|
234
|
-
function
|
|
234
|
+
var Ze = (1n << 64n) - 1n;
|
|
235
|
+
function z(e11, t2) {
|
|
235
236
|
if (!Number.isInteger(e11) || e11 < 0) throw new v(`${t2} must be a non-negative integer epoch, got ${e11}`);
|
|
236
237
|
return e11;
|
|
237
238
|
}
|
|
238
|
-
function
|
|
239
|
+
function Qe(e11) {
|
|
239
240
|
return e11.startsWith("template_") ? e11.slice(9) : e11;
|
|
240
241
|
}
|
|
241
|
-
function
|
|
242
|
+
function $e(e11) {
|
|
242
243
|
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;
|
|
243
244
|
}
|
|
244
|
-
var
|
|
245
|
+
var et = class {
|
|
245
246
|
constructor() {
|
|
246
247
|
__publicField(this, "nextId", 0);
|
|
247
248
|
__publicField(this, "ids", /* @__PURE__ */ new Map());
|
|
@@ -265,15 +266,15 @@ var Ye = class {
|
|
|
265
266
|
resetFrom(e11) {
|
|
266
267
|
this.reset();
|
|
267
268
|
for (let t2 of e11) {
|
|
268
|
-
let e12 =
|
|
269
|
+
let e12 = $e(t2);
|
|
269
270
|
e12 !== null && this.observeAllocated(e12);
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
273
|
};
|
|
273
|
-
function
|
|
274
|
+
function tt(e11) {
|
|
274
275
|
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.`);
|
|
275
276
|
}
|
|
276
|
-
var
|
|
277
|
+
var B = class e2 {
|
|
277
278
|
constructor(e11, t2) {
|
|
278
279
|
__publicField(this, "unsignedTransaction");
|
|
279
280
|
__publicField(this, "workspaceIds");
|
|
@@ -284,12 +285,12 @@ var z = class e2 {
|
|
|
284
285
|
instructions: [],
|
|
285
286
|
inputs: [],
|
|
286
287
|
min_epoch: null,
|
|
287
|
-
max_epoch:
|
|
288
|
+
max_epoch: z(t2, "maxEpoch"),
|
|
288
289
|
dry_run: false,
|
|
289
|
-
|
|
290
|
+
main_signer: "None",
|
|
290
291
|
blobs: [],
|
|
291
292
|
nonce: 0
|
|
292
|
-
}, this.workspaceIds = new
|
|
293
|
+
}, this.workspaceIds = new et(), this.feeWorkspaceIds = new et();
|
|
293
294
|
}
|
|
294
295
|
static new(t2, n2) {
|
|
295
296
|
return new e2(t2, n2);
|
|
@@ -297,7 +298,7 @@ var z = class e2 {
|
|
|
297
298
|
callFunction(e11, t2) {
|
|
298
299
|
let n2 = this.resolveArgs(t2);
|
|
299
300
|
return this.addInstruction({ CallFunction: {
|
|
300
|
-
address:
|
|
301
|
+
address: Qe(e11.templateAddress),
|
|
301
302
|
function: e11.functionName,
|
|
302
303
|
args: n2
|
|
303
304
|
} });
|
|
@@ -327,7 +328,7 @@ var z = class e2 {
|
|
|
327
328
|
return this.addInstruction({ CallMethod: {
|
|
328
329
|
call: { Address: e11 },
|
|
329
330
|
method: "create_proof_for_resource",
|
|
330
|
-
args: [
|
|
331
|
+
args: [j(t2)]
|
|
331
332
|
} });
|
|
332
333
|
}
|
|
333
334
|
claimBurn(e11, t2) {
|
|
@@ -351,7 +352,7 @@ var z = class e2 {
|
|
|
351
352
|
return this.addFeeInstruction({ CallMethod: {
|
|
352
353
|
call: { Address: e11 },
|
|
353
354
|
method: "pay_fee",
|
|
354
|
-
args: [
|
|
355
|
+
args: [R(t2)]
|
|
355
356
|
} });
|
|
356
357
|
}
|
|
357
358
|
feeTransactionPayFromComponentConfidential(e11, t2) {
|
|
@@ -360,6 +361,16 @@ var z = class e2 {
|
|
|
360
361
|
dropAllProofsInWorkspace() {
|
|
361
362
|
return this.addInstruction("DropAllProofsInWorkspace");
|
|
362
363
|
}
|
|
364
|
+
authorizeProof(e11) {
|
|
365
|
+
return this.addInstruction({ AuthorizeProof: { proof: this.getOffsetIdFromWorkspaceName(e11) } });
|
|
366
|
+
}
|
|
367
|
+
dropProofAuthorization(e11) {
|
|
368
|
+
return this.addInstruction({ DropProofAuthorization: { proof: this.getOffsetIdFromWorkspaceName(e11) } });
|
|
369
|
+
}
|
|
370
|
+
withAuthorizedProof(e11, t2) {
|
|
371
|
+
let n2 = this.getOffsetIdFromWorkspaceName(e11);
|
|
372
|
+
return this.addInstruction({ AuthorizeProof: { proof: n2 } }), t2(this), this.addInstruction({ DropProofAuthorization: { proof: n2 } });
|
|
373
|
+
}
|
|
363
374
|
publishTemplate(e11, t2 = null) {
|
|
364
375
|
let n2 = this.unsignedTransaction.blobs.length;
|
|
365
376
|
return this.unsignedTransaction.blobs.push(e11), this.addInstruction({ PublishTemplate: {
|
|
@@ -381,7 +392,7 @@ var z = class e2 {
|
|
|
381
392
|
}
|
|
382
393
|
observeAllocations(e11, t2) {
|
|
383
394
|
for (let n2 of t2) {
|
|
384
|
-
let t3 =
|
|
395
|
+
let t3 = $e(n2);
|
|
385
396
|
t3 !== null && e11.observeAllocated(t3);
|
|
386
397
|
}
|
|
387
398
|
}
|
|
@@ -390,21 +401,24 @@ var z = class e2 {
|
|
|
390
401
|
return this.unsignedTransaction.fee_instructions = n2.unsignedTransaction.instructions, this.feeWorkspaceIds.resetFrom(this.unsignedTransaction.fee_instructions), this;
|
|
391
402
|
}
|
|
392
403
|
addInput(e11) {
|
|
393
|
-
return this.unsignedTransaction.inputs.push(
|
|
404
|
+
return this.unsignedTransaction.inputs.push(nt(e11)), this;
|
|
394
405
|
}
|
|
395
406
|
withInputs(e11) {
|
|
396
|
-
return this.unsignedTransaction.inputs.push(...e11.map(
|
|
407
|
+
return this.unsignedTransaction.inputs.push(...e11.map(nt)), this;
|
|
408
|
+
}
|
|
409
|
+
withMainSigner(e11) {
|
|
410
|
+
return this.unsignedTransaction.main_signer = e11, this;
|
|
397
411
|
}
|
|
398
412
|
withMinEpoch(e11) {
|
|
399
|
-
return this.unsignedTransaction.min_epoch =
|
|
413
|
+
return this.unsignedTransaction.min_epoch = z(e11, "minEpoch"), this;
|
|
400
414
|
}
|
|
401
415
|
withMaxEpoch(e11) {
|
|
402
|
-
return this.unsignedTransaction.max_epoch =
|
|
416
|
+
return this.unsignedTransaction.max_epoch = z(e11, "maxEpoch"), this;
|
|
403
417
|
}
|
|
404
418
|
withNonce(e11) {
|
|
405
419
|
if (typeof e11 == "number" && !Number.isInteger(e11)) throw new v(`withNonce: nonce must be an integer, got ${e11}`);
|
|
406
420
|
let t2 = typeof e11 == "bigint" ? e11 : BigInt(e11);
|
|
407
|
-
if (t2 < 0n || t2 >
|
|
421
|
+
if (t2 < 0n || t2 > Ze) throw new v(`withNonce: nonce must fit an unsigned 64-bit integer, got ${e11}`);
|
|
408
422
|
return this.unsignedTransaction.nonce = t2 > BigInt(2 ** 53 - 1) ? t2 : Number(t2), this;
|
|
409
423
|
}
|
|
410
424
|
withUnsignedTransaction(e11) {
|
|
@@ -415,7 +429,7 @@ var z = class e2 {
|
|
|
415
429
|
inputs: [...e11.inputs],
|
|
416
430
|
blobs: [...e11.blobs ?? []],
|
|
417
431
|
nonce: e11.nonce ?? 0,
|
|
418
|
-
max_epoch:
|
|
432
|
+
max_epoch: z(e11.max_epoch, "withUnsignedTransaction: max_epoch")
|
|
419
433
|
}, this.workspaceIds.resetFrom(this.unsignedTransaction.instructions), this.feeWorkspaceIds.resetFrom(this.unsignedTransaction.fee_instructions), this;
|
|
420
434
|
}
|
|
421
435
|
resolveWorkspaceOffsetId(e11) {
|
|
@@ -435,11 +449,11 @@ var z = class e2 {
|
|
|
435
449
|
}
|
|
436
450
|
requireNamedId(e11) {
|
|
437
451
|
let t2 = this.workspaceIds.get(e11);
|
|
438
|
-
if (t2 === void 0) throw
|
|
452
|
+
if (t2 === void 0) throw tt(e11);
|
|
439
453
|
return t2;
|
|
440
454
|
}
|
|
441
455
|
getOffsetIdFromWorkspaceName(e11) {
|
|
442
|
-
let t2 =
|
|
456
|
+
let t2 = qe(e11);
|
|
443
457
|
return {
|
|
444
458
|
id: this.requireNamedId(t2.name),
|
|
445
459
|
offset: t2.offset
|
|
@@ -449,37 +463,67 @@ var z = class e2 {
|
|
|
449
463
|
return e11.map((e12) => typeof e12 == "object" && e12 && "Workspace" in e12 && typeof e12.Workspace == "string" ? { Workspace: this.getOffsetIdFromWorkspaceName(e12.Workspace) } : e12);
|
|
450
464
|
}
|
|
451
465
|
};
|
|
452
|
-
function
|
|
466
|
+
function nt(e11) {
|
|
453
467
|
return {
|
|
454
468
|
substate_id: e11.substate_id,
|
|
455
469
|
version: e11.version,
|
|
456
470
|
is_write: "is_write" in e11 ? e11.is_write : true
|
|
457
471
|
};
|
|
458
472
|
}
|
|
459
|
-
var
|
|
473
|
+
var rt = {
|
|
460
474
|
[u.LocalNet]: "http://localhost:12500",
|
|
461
475
|
[u.Esmeralda]: "https://ootle-indexer-a.tari.com"
|
|
462
476
|
};
|
|
463
|
-
function
|
|
464
|
-
let t2 =
|
|
477
|
+
function it(e11) {
|
|
478
|
+
let t2 = rt[e11];
|
|
465
479
|
if (t2 !== void 0) return t2;
|
|
466
480
|
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]} }).`);
|
|
467
481
|
}
|
|
468
|
-
function
|
|
469
|
-
|
|
482
|
+
function V(e11, t2, n2) {
|
|
483
|
+
let r2;
|
|
484
|
+
try {
|
|
485
|
+
r2 = t2(n2);
|
|
486
|
+
} catch (t3) {
|
|
487
|
+
throw new _(`${e11}: value is not a valid CBOR encoding: ${String(t3)}`, {
|
|
488
|
+
cause: t3,
|
|
489
|
+
context: e11
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
return JSON.parse(r2);
|
|
493
|
+
}
|
|
494
|
+
function at(e11) {
|
|
495
|
+
return V("decodeSubstateValue", se, e11);
|
|
496
|
+
}
|
|
497
|
+
function ot(e11) {
|
|
498
|
+
return V("decodeExecuteResult", ae, e11);
|
|
499
|
+
}
|
|
500
|
+
function st(e11) {
|
|
501
|
+
return V("decodeTransactionReceipt", ce, e11);
|
|
502
|
+
}
|
|
503
|
+
function ct(e11) {
|
|
504
|
+
return V("decodeEvent", ie, e11);
|
|
505
|
+
}
|
|
506
|
+
function lt(e11) {
|
|
507
|
+
return V("decodeResource", oe, e11);
|
|
508
|
+
}
|
|
509
|
+
function ut(e11) {
|
|
510
|
+
return V("decodeUtxo", le, e11);
|
|
511
|
+
}
|
|
512
|
+
function H(e11) {
|
|
513
|
+
return "up" in e11.state ? at(e11.state.up.substate) : null;
|
|
470
514
|
}
|
|
471
|
-
var
|
|
472
|
-
function*
|
|
515
|
+
var dt = 132, ft = 32;
|
|
516
|
+
function* pt(e11) {
|
|
473
517
|
let t2 = /* @__PURE__ */ new Set();
|
|
474
|
-
for (let n2 of
|
|
518
|
+
for (let n2 of U(e11, dt)) n2.length === ft * 2 && !t2.has(n2) && (t2.add(n2), yield `vault_${n2}`);
|
|
475
519
|
}
|
|
476
|
-
async function
|
|
477
|
-
let n2 =
|
|
478
|
-
return
|
|
520
|
+
async function mt(e11, t2) {
|
|
521
|
+
let n2 = H(await e11.getSubstate(t2));
|
|
522
|
+
return gt(n2) ? Array.from(pt(n2.Component.body.state)) : [];
|
|
479
523
|
}
|
|
480
|
-
function*
|
|
524
|
+
function* U(e11, t2) {
|
|
481
525
|
if (Array.isArray(e11)) {
|
|
482
|
-
for (let n3 of e11) yield*
|
|
526
|
+
for (let n3 of e11) yield* U(n3, t2);
|
|
483
527
|
return;
|
|
484
528
|
}
|
|
485
529
|
if (typeof e11 != "object" || !e11) return;
|
|
@@ -488,49 +532,49 @@ function* V(e11, t2) {
|
|
|
488
532
|
if (r2 === "tag") {
|
|
489
533
|
let e12 = n2.value;
|
|
490
534
|
if (n2.tag === t2) {
|
|
491
|
-
let t3 =
|
|
535
|
+
let t3 = ht(e12);
|
|
492
536
|
t3 !== null && (yield t3);
|
|
493
537
|
}
|
|
494
|
-
yield*
|
|
538
|
+
yield* U(e12, t2);
|
|
495
539
|
} else if (r2 === "map") {
|
|
496
540
|
let e12 = n2.entries;
|
|
497
|
-
if (Array.isArray(e12)) for (let n3 of e12) Array.isArray(n3) && n3.length === 2 && (yield*
|
|
541
|
+
if (Array.isArray(e12)) for (let n3 of e12) Array.isArray(n3) && n3.length === 2 && (yield* U(n3[0], t2), yield* U(n3[1], t2));
|
|
498
542
|
}
|
|
499
543
|
return;
|
|
500
544
|
}
|
|
501
|
-
for (let e12 of Object.values(n2)) yield*
|
|
545
|
+
for (let e12 of Object.values(n2)) yield* U(e12, t2);
|
|
502
546
|
}
|
|
503
|
-
function
|
|
547
|
+
function ht(e11) {
|
|
504
548
|
if (typeof e11 != "object" || !e11) return null;
|
|
505
549
|
let t2 = e11;
|
|
506
550
|
if (t2["@cbor"] !== "bytes") return null;
|
|
507
551
|
let n2 = t2.hex;
|
|
508
552
|
return typeof n2 == "string" ? n2 : null;
|
|
509
553
|
}
|
|
510
|
-
function
|
|
554
|
+
function gt(e11) {
|
|
511
555
|
return typeof e11 == "object" && !!e11 && "Component" in e11;
|
|
512
556
|
}
|
|
513
|
-
var
|
|
514
|
-
function
|
|
557
|
+
var _t = "resource_0101010101010101010101010101010101010101010101010101010101010101", vt = "component_0102030000000000000000000000000000000000000000000000000000000000", yt = "vault_0102030000000000000000000000000000000000000000000000000000000001", bt = "resource_0102030000000000000000000000000000000000000000000000000000000002", xt = "__ootleRawJson", St = "stealth_revealed_input", Ct = "stealth_revealed_change";
|
|
558
|
+
function wt(e11, t2) {
|
|
515
559
|
let n2 = e11.revealedInputBucket === null ? null : t2(e11.revealedInputBucket);
|
|
516
560
|
return { StealthTransfer: {
|
|
517
561
|
resource_address_ref: { Address: e11.resourceAddress },
|
|
518
|
-
statement:
|
|
562
|
+
statement: W(e11.statement),
|
|
519
563
|
revealed_input_bucket: n2
|
|
520
564
|
} };
|
|
521
565
|
}
|
|
522
|
-
function
|
|
523
|
-
return { [
|
|
566
|
+
function W(e11) {
|
|
567
|
+
return { [xt]: e11.toCompactJson() };
|
|
524
568
|
}
|
|
525
|
-
function
|
|
569
|
+
function G(e11) {
|
|
526
570
|
return typeof e11 == "object" && !!e11 && "StealthTransfer" in e11;
|
|
527
571
|
}
|
|
528
|
-
function
|
|
572
|
+
function K(e11) {
|
|
529
573
|
let t2 = [], n2 = (e12) => `__ootleRawJson:${e12}__`, r2 = JSON.stringify(e11, (e12, r3) => {
|
|
530
574
|
if (typeof r3 == "bigint") return r3.toString();
|
|
531
575
|
if (typeof r3 == "object" && r3 && "__ootleRawJson" in r3) {
|
|
532
576
|
let e13 = n2(t2.length);
|
|
533
|
-
return t2.push(r3[
|
|
577
|
+
return t2.push(r3[xt]), e13;
|
|
534
578
|
}
|
|
535
579
|
return r3;
|
|
536
580
|
});
|
|
@@ -542,55 +586,63 @@ function W(e11) {
|
|
|
542
586
|
}
|
|
543
587
|
return r2;
|
|
544
588
|
}
|
|
545
|
-
async function
|
|
589
|
+
async function q(e11, t2) {
|
|
546
590
|
let n2 = await e11.resolveInputs(t2.inputs);
|
|
547
591
|
return {
|
|
548
592
|
...t2,
|
|
549
593
|
inputs: n2
|
|
550
594
|
};
|
|
551
595
|
}
|
|
552
|
-
function
|
|
596
|
+
function Tt() {
|
|
553
597
|
let { secret_key: e11, public_key: t2 } = a();
|
|
554
598
|
return {
|
|
555
599
|
secret_key: e11,
|
|
556
600
|
public_key: t2
|
|
557
601
|
};
|
|
558
602
|
}
|
|
559
|
-
function
|
|
603
|
+
function Et(e11, t2) {
|
|
560
604
|
return {
|
|
561
605
|
public_key: b(y(e11, 32, "publicKey")),
|
|
562
|
-
signature:
|
|
563
|
-
public_nonce: b(y(t2.public_nonce, 32, "schnorr.public_nonce")),
|
|
564
|
-
signature: b(y(t2.signature, 32, "schnorr.signature"))
|
|
565
|
-
}
|
|
606
|
+
signature: b(y(t2, 64, "sr25519 signature"))
|
|
566
607
|
};
|
|
567
608
|
}
|
|
568
|
-
async function
|
|
609
|
+
async function J(e11, t2) {
|
|
610
|
+
if (t2.main_signer !== "None" || e11.length === 0) return t2;
|
|
611
|
+
let n2 = y(await e11[0].getPublicKey(), 32, "main signer public key");
|
|
612
|
+
return {
|
|
613
|
+
...t2,
|
|
614
|
+
main_signer: { Authorizer: b(n2) }
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
async function Dt(e11, t2, n2) {
|
|
618
|
+
return Ot(e11, await J(e11, t2), n2);
|
|
619
|
+
}
|
|
620
|
+
async function Ot(e11, t2, n2) {
|
|
569
621
|
let r2 = n2 ?? a(), i2 = y(r2.secret_key, 32, "sealKeypair.secret_key"), o2 = y(r2.public_key, 32, "sealKeypair.public_key"), s2 = [];
|
|
570
622
|
for (let n3 of e11) {
|
|
571
623
|
let e12 = await n3.signTransaction(t2, o2);
|
|
572
624
|
s2.push(...e12);
|
|
573
625
|
}
|
|
574
|
-
let c2 = l(`{"transaction":${
|
|
626
|
+
let c2 = l(`{"transaction":${K(t2)},"signatures":${JSON.stringify(s2)}}`, i2);
|
|
575
627
|
return {
|
|
576
628
|
sealedJson: c2,
|
|
577
629
|
transaction: JSON.parse(c2)
|
|
578
630
|
};
|
|
579
631
|
}
|
|
580
|
-
function
|
|
632
|
+
function Y(e11) {
|
|
581
633
|
return t(e11.sealedJson);
|
|
582
634
|
}
|
|
583
|
-
async function
|
|
635
|
+
async function kt(e11, t2) {
|
|
584
636
|
return (await e11.submitTransaction(t2)).transaction_id;
|
|
585
637
|
}
|
|
586
|
-
function
|
|
587
|
-
var _a
|
|
638
|
+
function At(e11) {
|
|
639
|
+
var _a;
|
|
588
640
|
if (e11 === "Pending" || !("Finalized" in e11)) return null;
|
|
589
641
|
let t2 = e11.Finalized, n2 = t2.final_decision;
|
|
590
642
|
if (n2 === null) return null;
|
|
591
643
|
if (n2 === "Commit") return { outcome: n2 };
|
|
592
644
|
if (typeof n2 == "object" && n2 && "Abort" in n2) {
|
|
593
|
-
let e12 = t2.abort_details ?? JSON.stringify(n2.Abort), r2 =
|
|
645
|
+
let e12 = t2.abort_details ?? JSON.stringify(n2.Abort), r2 = t2.execution_result === null ? void 0 : (_a = ot(t2.execution_result).finalize) == null ? void 0 : _a.result;
|
|
594
646
|
return typeof r2 == "object" && r2 && "AcceptFeeRejectRest" in r2 ? {
|
|
595
647
|
outcome: "FeeIntentCommit",
|
|
596
648
|
reason: e12
|
|
@@ -601,12 +653,12 @@ function _t(e11) {
|
|
|
601
653
|
}
|
|
602
654
|
throw new v(`Unexpected final_decision variant: ${JSON.stringify(n2)}`);
|
|
603
655
|
}
|
|
604
|
-
async function
|
|
656
|
+
async function jt(e11, t2, n2) {
|
|
605
657
|
let r2 = (n2 == null ? void 0 : n2.pollIntervalMs) ?? 500, i2 = (n2 == null ? void 0 : n2.timeoutMs) ?? 6e4, a2 = Date.now() + i2;
|
|
606
658
|
for (; ; ) {
|
|
607
659
|
let n3 = await e11.getTransactionResult(t2), o2 = n3.result;
|
|
608
660
|
if (o2 !== "Pending" && "Finalized" in o2) {
|
|
609
|
-
let { outcome: e12, reason: r3 } =
|
|
661
|
+
let { outcome: e12, reason: r3 } = At(o2) ?? { outcome: "Reject" };
|
|
610
662
|
if (e12 === "Reject") throw new f(`Transaction ${t2} was rejected: ${r3}`, {
|
|
611
663
|
txId: t2,
|
|
612
664
|
reason: r3 ?? ""
|
|
@@ -617,24 +669,24 @@ async function vt(e11, t2, n2) {
|
|
|
617
669
|
});
|
|
618
670
|
return n3;
|
|
619
671
|
}
|
|
620
|
-
if (Date.now() >= a2) throw new
|
|
672
|
+
if (Date.now() >= a2) throw new de(`Transaction ${t2} did not finalize within ${i2}ms`, { txId: t2 });
|
|
621
673
|
await new Promise((e12) => setTimeout(e12, r2));
|
|
622
674
|
}
|
|
623
675
|
}
|
|
624
|
-
async function
|
|
625
|
-
let i2 = await
|
|
626
|
-
return
|
|
676
|
+
async function Mt(e11, t2, n2, r2) {
|
|
677
|
+
let i2 = await q(e11, n2);
|
|
678
|
+
return jt(e11, await kt(e11, Y(await Dt(Array.isArray(t2) ? t2 : [t2], i2))), r2);
|
|
627
679
|
}
|
|
628
|
-
async function
|
|
629
|
-
return
|
|
680
|
+
async function Nt(e11, t2, n2, r2) {
|
|
681
|
+
return Mt(e11, t2, {
|
|
630
682
|
...n2,
|
|
631
683
|
dry_run: true
|
|
632
684
|
}, r2);
|
|
633
685
|
}
|
|
634
|
-
var
|
|
686
|
+
var Pt = class {
|
|
635
687
|
constructor(e11, t2) {
|
|
636
688
|
__publicField(this, "builder");
|
|
637
|
-
this.builder =
|
|
689
|
+
this.builder = B.new(e11, t2);
|
|
638
690
|
}
|
|
639
691
|
withInputs(e11) {
|
|
640
692
|
return this.builder.withInputs(e11), this;
|
|
@@ -646,7 +698,7 @@ var xt = class {
|
|
|
646
698
|
return this.builder.callMethod({
|
|
647
699
|
componentAddress: e11,
|
|
648
700
|
methodName: "withdraw"
|
|
649
|
-
}, [
|
|
701
|
+
}, [j(t2), R(n2)]).saveVar("bucket").callMethod({
|
|
650
702
|
componentAddress: r2,
|
|
651
703
|
methodName: "deposit"
|
|
652
704
|
}, [{ Workspace: "bucket" }]), this;
|
|
@@ -657,11 +709,11 @@ var xt = class {
|
|
|
657
709
|
build() {
|
|
658
710
|
return this.builder.buildUnsignedTransaction();
|
|
659
711
|
}
|
|
660
|
-
},
|
|
712
|
+
}, Ft = class {
|
|
661
713
|
constructor(e11, t2, n2) {
|
|
662
714
|
__publicField(this, "builder");
|
|
663
715
|
__publicField(this, "faucetAddress");
|
|
664
|
-
this.builder =
|
|
716
|
+
this.builder = B.new(e11, t2), this.faucetAddress = n2;
|
|
665
717
|
}
|
|
666
718
|
feeTransactionPayFromComponent(e11, t2) {
|
|
667
719
|
return this.builder.feeTransactionPayFromComponent(e11, t2), this;
|
|
@@ -670,7 +722,7 @@ var xt = class {
|
|
|
670
722
|
return this.builder.callMethod({
|
|
671
723
|
componentAddress: this.faucetAddress,
|
|
672
724
|
methodName: "take_free_coins"
|
|
673
|
-
}, [
|
|
725
|
+
}, [R(t2)]).saveVar("faucet_bucket").callMethod({
|
|
674
726
|
componentAddress: e11,
|
|
675
727
|
methodName: "deposit"
|
|
676
728
|
}, [{ Workspace: "faucet_bucket" }]), this;
|
|
@@ -694,7 +746,7 @@ var xt = class {
|
|
|
694
746
|
build() {
|
|
695
747
|
return this.builder.buildUnsignedTransaction();
|
|
696
748
|
}
|
|
697
|
-
},
|
|
749
|
+
}, It = class {
|
|
698
750
|
constructor() {
|
|
699
751
|
__publicField(this, "keyProviders");
|
|
700
752
|
__publicField(this, "defaultSignerAddress", null);
|
|
@@ -740,7 +792,7 @@ var xt = class {
|
|
|
740
792
|
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 });
|
|
741
793
|
return n2;
|
|
742
794
|
}
|
|
743
|
-
},
|
|
795
|
+
}, Lt = class {
|
|
744
796
|
constructor(e11, t2) {
|
|
745
797
|
__publicField(this, "bytes");
|
|
746
798
|
this.bytes = new Uint8Array(y(e11, 32, t2));
|
|
@@ -751,7 +803,7 @@ var xt = class {
|
|
|
751
803
|
toHex() {
|
|
752
804
|
return b(this.bytes);
|
|
753
805
|
}
|
|
754
|
-
},
|
|
806
|
+
}, X = class e3 extends Lt {
|
|
755
807
|
constructor(e11) {
|
|
756
808
|
super(e11, "Mask");
|
|
757
809
|
}
|
|
@@ -764,7 +816,7 @@ var xt = class {
|
|
|
764
816
|
static fromHex(t2) {
|
|
765
817
|
return new e3(x(t2));
|
|
766
818
|
}
|
|
767
|
-
},
|
|
819
|
+
}, Rt = class e4 {
|
|
768
820
|
constructor(e11) {
|
|
769
821
|
__publicField(this, "bytes");
|
|
770
822
|
this.bytes = new Uint8Array(e11);
|
|
@@ -778,8 +830,8 @@ var xt = class {
|
|
|
778
830
|
toHex() {
|
|
779
831
|
return b(this.bytes);
|
|
780
832
|
}
|
|
781
|
-
},
|
|
782
|
-
function
|
|
833
|
+
}, zt = Object.freeze({ StealthPublicKey: Object.freeze({}) });
|
|
834
|
+
function Bt(e11) {
|
|
783
835
|
if (e11.amount <= 0n) throw new v(`Output amount must be > 0, got ${e11.amount}`);
|
|
784
836
|
return {
|
|
785
837
|
destination: e11.destination,
|
|
@@ -787,19 +839,19 @@ function Dt(e11) {
|
|
|
787
839
|
resourceAddress: e11.resourceAddress,
|
|
788
840
|
resourceViewKey: e11.resourceViewKey === void 0 ? void 0 : new Uint8Array(e11.resourceViewKey),
|
|
789
841
|
memo: e11.memo,
|
|
790
|
-
payTo: e11.payTo ??
|
|
842
|
+
payTo: e11.payTo ?? zt,
|
|
791
843
|
minimumValuePromise: e11.minimumValuePromise ?? 0n
|
|
792
844
|
};
|
|
793
845
|
}
|
|
794
|
-
function
|
|
846
|
+
function Vt(e11, t2) {
|
|
795
847
|
if (e11.trim() === "") throw new v(`${t2} must be a non-empty decimal string`);
|
|
796
848
|
return BigInt(e11);
|
|
797
849
|
}
|
|
798
|
-
function
|
|
850
|
+
function Ht(e11, t2) {
|
|
799
851
|
let n2 = e11.trim();
|
|
800
852
|
if (!n2.startsWith("{") || !n2.endsWith("}")) throw new v(`StealthTransferStatement.toCompactJson: ${t2} fragment is not a JSON object (got: ${e11.slice(0, 60)}...)`);
|
|
801
853
|
}
|
|
802
|
-
var
|
|
854
|
+
var Z = class e5 extends Lt {
|
|
803
855
|
constructor(e11) {
|
|
804
856
|
super(e11, "StealthInput.commitment");
|
|
805
857
|
}
|
|
@@ -812,7 +864,7 @@ var Y = class e5 extends wt {
|
|
|
812
864
|
static fromJSON(t2) {
|
|
813
865
|
return new e5(x(t2.commitment));
|
|
814
866
|
}
|
|
815
|
-
},
|
|
867
|
+
}, Q = class e6 {
|
|
816
868
|
constructor(e11, t2) {
|
|
817
869
|
__publicField(this, "_publicNonce");
|
|
818
870
|
__publicField(this, "_signature");
|
|
@@ -833,7 +885,7 @@ var Y = class e5 extends wt {
|
|
|
833
885
|
static fromJSON(t2) {
|
|
834
886
|
return new e6(x(t2.public_nonce), x(t2.signature));
|
|
835
887
|
}
|
|
836
|
-
},
|
|
888
|
+
}, Ut = class e7 {
|
|
837
889
|
constructor(e11, t2, n2) {
|
|
838
890
|
__publicField(this, "inputs");
|
|
839
891
|
__publicField(this, "revealedAmount");
|
|
@@ -846,13 +898,13 @@ var Y = class e5 extends wt {
|
|
|
846
898
|
toJSON() {
|
|
847
899
|
return {
|
|
848
900
|
inputs: this.inputs.map((e11) => e11.toJSON()),
|
|
849
|
-
revealed_amount:
|
|
901
|
+
revealed_amount: Ke(this.revealedAmount)
|
|
850
902
|
};
|
|
851
903
|
}
|
|
852
904
|
static fromJSON(t2) {
|
|
853
|
-
return new e7(t2.inputs.map(
|
|
905
|
+
return new e7(t2.inputs.map(Z.fromJSON), Vt(t2.revealed_amount, "revealed_amount"));
|
|
854
906
|
}
|
|
855
|
-
},
|
|
907
|
+
}, Wt = class e8 {
|
|
856
908
|
constructor(e11) {
|
|
857
909
|
__publicField(this, "statementJson");
|
|
858
910
|
this.statementJson = e11;
|
|
@@ -866,7 +918,7 @@ var Y = class e5 extends wt {
|
|
|
866
918
|
static fromJSON(t2) {
|
|
867
919
|
return new e8(t2);
|
|
868
920
|
}
|
|
869
|
-
},
|
|
921
|
+
}, $ = class e9 {
|
|
870
922
|
constructor(e11, t2, n2) {
|
|
871
923
|
__publicField(this, "inputsStatement");
|
|
872
924
|
__publicField(this, "outputsStatement");
|
|
@@ -882,15 +934,15 @@ var Y = class e5 extends wt {
|
|
|
882
934
|
}
|
|
883
935
|
toCompactJson() {
|
|
884
936
|
let e11 = this.inputsStatement.statementJson ?? JSON.stringify(this.inputsStatement.toJSON()), t2 = this.outputsStatement.statementJson;
|
|
885
|
-
|
|
937
|
+
Ht(e11, "inputs_statement"), Ht(t2, "outputs_statement");
|
|
886
938
|
let n2 = `{"inputs_statement":${e11},"outputs_statement":${t2},"covenant_claims":[]`;
|
|
887
939
|
return this.balanceProof !== void 0 && (n2 += `,"balance_proof":${JSON.stringify(this.balanceProof.toJSON())}`), n2 + "}";
|
|
888
940
|
}
|
|
889
941
|
static fromJSON(t2) {
|
|
890
|
-
return new e9(
|
|
942
|
+
return new e9(Ut.fromJSON(t2.inputs), Wt.fromJSON(t2.outputs), t2.balance_proof === void 0 ? void 0 : Q.fromJSON(t2.balance_proof));
|
|
891
943
|
}
|
|
892
944
|
};
|
|
893
|
-
function
|
|
945
|
+
function Gt(e11, t2) {
|
|
894
946
|
let n2 = new Uint8Array(e11.length * 32);
|
|
895
947
|
for (let r2 = 0; r2 < e11.length; r2++) {
|
|
896
948
|
let i2 = e11[r2];
|
|
@@ -898,7 +950,7 @@ function jt(e11, t2) {
|
|
|
898
950
|
}
|
|
899
951
|
return n2;
|
|
900
952
|
}
|
|
901
|
-
var
|
|
953
|
+
var Kt = "[]", qt = class {
|
|
902
954
|
constructor(e11 = u.LocalNet) {
|
|
903
955
|
__publicField(this, "network");
|
|
904
956
|
this.network = e11;
|
|
@@ -908,23 +960,23 @@ var Mt = "[]", Nt = class {
|
|
|
908
960
|
t2 !== null && (y(t2.receiver, 32, "revealed output receiver"), r2 = t2.amount, i2 = t2.receiver);
|
|
909
961
|
let a2 = s(n2, r2, i2);
|
|
910
962
|
return y(a2.aggregated_output_mask, 32, "StealthOutputsResult.aggregated_output_mask"), {
|
|
911
|
-
statement:
|
|
912
|
-
outputMask:
|
|
963
|
+
statement: Wt.fromJSON(a2.statement_json),
|
|
964
|
+
outputMask: X.fromBytes(a2.aggregated_output_mask)
|
|
913
965
|
};
|
|
914
966
|
}
|
|
915
967
|
outputWitness(e11) {
|
|
916
|
-
let t2 = c(e11.destination), n2 =
|
|
968
|
+
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;
|
|
917
969
|
return r(this.network, t2.owner_key, t2.view_key, e11.amount, e11.resourceAddress, a2, i2, n2, e11.minimumValuePromise);
|
|
918
970
|
}
|
|
919
971
|
async buildInputsStatement(e11, t2) {
|
|
920
|
-
return new
|
|
972
|
+
return new Ut(e11, t2, n(Gt(e11.map((e12) => e12.commitment), "input commitment"), t2));
|
|
921
973
|
}
|
|
922
974
|
async generateBalanceProofSignature(e11, t2, n2, r2) {
|
|
923
|
-
let i2 = o(e11.toBytes(), t2.toBytes(), n2, r2,
|
|
924
|
-
return y(i2.public_nonce, 32, "balance proof public_nonce"), y(i2.signature, 32, "balance proof signature"), new
|
|
975
|
+
let i2 = o(e11.toBytes(), t2.toBytes(), n2, r2, Kt);
|
|
976
|
+
return y(i2.public_nonce, 32, "balance proof public_nonce"), y(i2.signature, 32, "balance proof signature"), new Q(i2.public_nonce, i2.signature);
|
|
925
977
|
}
|
|
926
978
|
async validateBalanceProofSignature(e11, t2, n2) {
|
|
927
|
-
return ne(e11.publicNonce, e11.signature, t2, n2,
|
|
979
|
+
return ne(e11.publicNonce, e11.signature, t2, n2, Kt);
|
|
928
980
|
}
|
|
929
981
|
async deriveAeadKey(e11, t2) {
|
|
930
982
|
y(e11, 32, "deriveAeadKey privateKey"), y(t2, 32, "deriveAeadKey publicKey");
|
|
@@ -935,67 +987,67 @@ var Mt = "[]", Nt = class {
|
|
|
935
987
|
y(e11, 32, "unblindOutput commitment"), y(n2, 32, "unblindOutput aeadKey");
|
|
936
988
|
let i2 = te(e11, t2, n2, r2);
|
|
937
989
|
return {
|
|
938
|
-
mask:
|
|
990
|
+
mask: X.fromBytes(i2.mask),
|
|
939
991
|
value: i2.value,
|
|
940
992
|
memo: i2.memo_json ?? void 0
|
|
941
993
|
};
|
|
942
994
|
}
|
|
943
995
|
async aggregateInputMasks(t2) {
|
|
944
|
-
let n2 = e(
|
|
945
|
-
return
|
|
996
|
+
let n2 = e(Gt(t2.map((e11) => e11.toBytes()), "input mask"));
|
|
997
|
+
return X.fromBytes(n2);
|
|
946
998
|
}
|
|
947
|
-
async stealthDhSecret(e11, t2, n2) {
|
|
948
|
-
y(t2, 32, "stealthDhSecret ownerSecret"), y(n2, 32, "stealthDhSecret publicNonce");
|
|
949
|
-
let
|
|
950
|
-
return y(
|
|
999
|
+
async stealthDhSecret(e11, t2, n2, r2) {
|
|
1000
|
+
y(t2, 32, "stealthDhSecret ownerSecret"), y(n2, 32, "stealthDhSecret viewSecret"), y(r2, 32, "stealthDhSecret publicNonce");
|
|
1001
|
+
let i2 = ee(e11, t2, n2, r2);
|
|
1002
|
+
return y(i2, 32, "stealth DH secret"), i2;
|
|
951
1003
|
}
|
|
952
1004
|
async validateTransfer(e11) {
|
|
953
1005
|
re(e11.toCompactJson(), null);
|
|
954
1006
|
}
|
|
955
1007
|
};
|
|
956
|
-
function
|
|
1008
|
+
function Jt(e11) {
|
|
957
1009
|
let t2 = Object.keys(e11);
|
|
958
1010
|
if (t2.length !== 1 || t2[0] !== "StealthPublicKey") return false;
|
|
959
1011
|
let n2 = e11.StealthPublicKey;
|
|
960
1012
|
return typeof n2 == "object" && !!n2 && Object.keys(n2).length === 0;
|
|
961
1013
|
}
|
|
962
|
-
var
|
|
963
|
-
function
|
|
964
|
-
return `${
|
|
1014
|
+
var Yt = "utxo";
|
|
1015
|
+
function Xt(e11, t2) {
|
|
1016
|
+
return `${Yt}_${e11.startsWith("resource_") ? e11.slice(9) : e11}_${b(t2)}`;
|
|
965
1017
|
}
|
|
966
|
-
var
|
|
967
|
-
function
|
|
1018
|
+
var Zt = 64;
|
|
1019
|
+
function Qt(e11) {
|
|
968
1020
|
return typeof e11 == "object" && !!e11 && "Utxo" in e11;
|
|
969
1021
|
}
|
|
970
|
-
function
|
|
1022
|
+
function $t(e11) {
|
|
971
1023
|
return e11.length > 0 && /^[0-9a-fA-F]+$/.test(e11);
|
|
972
1024
|
}
|
|
973
|
-
function
|
|
1025
|
+
function en(e11) {
|
|
974
1026
|
let t2 = e11.split("_");
|
|
975
|
-
if (t2.length < 3 || t2[0] !==
|
|
1027
|
+
if (t2.length < 3 || t2[0] !== Yt) return null;
|
|
976
1028
|
let n2 = t2[t2.length - 1];
|
|
977
|
-
return n2.length !==
|
|
1029
|
+
return n2.length !== Zt || !$t(n2) ? null : x(n2);
|
|
978
1030
|
}
|
|
979
|
-
function
|
|
980
|
-
let n2 =
|
|
981
|
-
if (n2 === null || !
|
|
1031
|
+
function tn(e11, t2) {
|
|
1032
|
+
let n2 = H(e11);
|
|
1033
|
+
if (n2 === null || !Qt(n2)) return null;
|
|
982
1034
|
let r2 = n2.Utxo;
|
|
983
1035
|
if (r2.output === null || r2.is_frozen) return null;
|
|
984
|
-
let i2 =
|
|
1036
|
+
let i2 = en(t2);
|
|
985
1037
|
return i2 === null ? null : {
|
|
986
1038
|
commitment: i2,
|
|
987
1039
|
body: r2.output.output
|
|
988
1040
|
};
|
|
989
1041
|
}
|
|
990
|
-
var
|
|
991
|
-
constructor(e11, t2, n2 = new
|
|
1042
|
+
var nn = 0, rn = class {
|
|
1043
|
+
constructor(e11, t2, n2 = new qt(e11.network())) {
|
|
992
1044
|
__publicField(this, "provider");
|
|
993
1045
|
__publicField(this, "crypto");
|
|
994
1046
|
__publicField(this, "builder");
|
|
995
1047
|
__publicField(this, "state");
|
|
996
1048
|
__publicField(this, "maxEpoch", null);
|
|
997
1049
|
__publicField(this, "prepared", false);
|
|
998
|
-
this.provider = e11, this.crypto = n2, this.builder =
|
|
1050
|
+
this.provider = e11, this.crypto = n2, this.builder = B.new(e11.network(), nn), this.state = {
|
|
999
1051
|
resource: t2,
|
|
1000
1052
|
revealedInput: null,
|
|
1001
1053
|
inputsToSpend: /* @__PURE__ */ new Map(),
|
|
@@ -1037,7 +1089,7 @@ var Vt = 0, Ht = class {
|
|
|
1037
1089
|
return this.builder = e11(this.builder), this;
|
|
1038
1090
|
}
|
|
1039
1091
|
spendStealthInput(e11, t2) {
|
|
1040
|
-
let n2 = new
|
|
1092
|
+
let n2 = new Z(t2), r2 = b(n2.commitment), i2 = this.state.inputsToSpend.get(r2);
|
|
1041
1093
|
if (i2 !== void 0) throw new v(`spendStealthInput: duplicate commitment ${r2} \u2014 each commitment is one UTXO and may be spent once (already added for owner ${i2.owner}). A commitment uniquely identifies a UTXO; adding it again (even under a different owner) would self-double-spend.`);
|
|
1042
1094
|
return this.state.inputsToSpend.set(r2, {
|
|
1043
1095
|
input: n2,
|
|
@@ -1048,8 +1100,8 @@ var Vt = 0, Ht = class {
|
|
|
1048
1100
|
var _a;
|
|
1049
1101
|
if (this.prepared) throw new v("StealthTransfer.prepare: already prepared \u2014 create a new StealthTransfer to build again");
|
|
1050
1102
|
this.validate(), this.prepared = true;
|
|
1051
|
-
let { statement: e11, outputMask: t2 } = await this.crypto.generateOutputsStatement(this.state.outputs, this.state.revealedOutput), n2 = new
|
|
1052
|
-
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch ===
|
|
1103
|
+
let { statement: e11, outputMask: t2 } = await this.crypto.generateOutputsStatement(this.state.outputs, this.state.revealedOutput), n2 = new $(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);
|
|
1104
|
+
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch === nn && this.builder.withMaxEpoch(await Xe(this.provider));
|
|
1053
1105
|
let r2 = /* @__PURE__ */ new Set();
|
|
1054
1106
|
if (this.state.revealedInput !== null) {
|
|
1055
1107
|
let e12 = this.state.revealedInput.source;
|
|
@@ -1057,20 +1109,20 @@ var Vt = 0, Ht = class {
|
|
|
1057
1109
|
substate_id: e12,
|
|
1058
1110
|
version: null
|
|
1059
1111
|
}), r2.add(e12);
|
|
1060
|
-
let t3 = await
|
|
1112
|
+
let t3 = await mt(this.provider, e12);
|
|
1061
1113
|
for (let e13 of t3) r2.has(e13) || (this.builder.addInput({
|
|
1062
1114
|
substate_id: e13,
|
|
1063
1115
|
version: null
|
|
1064
1116
|
}), r2.add(e13));
|
|
1065
1117
|
}
|
|
1066
1118
|
for (let { input: e12 } of this.state.inputsToSpend.values()) {
|
|
1067
|
-
let t3 =
|
|
1119
|
+
let t3 = Xt(this.state.resource, e12.commitment);
|
|
1068
1120
|
r2.has(t3) || (this.builder.addInput({
|
|
1069
1121
|
substate_id: t3,
|
|
1070
1122
|
version: null
|
|
1071
1123
|
}), r2.add(t3));
|
|
1072
1124
|
}
|
|
1073
|
-
let i2 = await
|
|
1125
|
+
let i2 = await q(this.provider, this.builder.buildUnsignedTransaction()), a2 = [...this.state.inputsToSpend.values()], o2 = this.collectRequiredSigners(a2);
|
|
1074
1126
|
return {
|
|
1075
1127
|
unsignedTx: i2,
|
|
1076
1128
|
statement: n2,
|
|
@@ -1103,38 +1155,38 @@ var Vt = 0, Ht = class {
|
|
|
1103
1155
|
t2 !== null && (this.builder.callMethod({
|
|
1104
1156
|
componentAddress: t2.source,
|
|
1105
1157
|
methodName: "withdraw"
|
|
1106
|
-
}, [
|
|
1158
|
+
}, [j(this.state.resource), k(t2.amount)]).saveVar(St), n2 = St), this.builder.addInstruction(wt({
|
|
1107
1159
|
resourceAddress: this.state.resource,
|
|
1108
1160
|
revealedInputBucket: n2,
|
|
1109
1161
|
statement: e11
|
|
1110
|
-
}, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutput !== null && t2 !== null && this.builder.saveVar(
|
|
1162
|
+
}, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutput !== null && t2 !== null && this.builder.saveVar(Ct).callMethod({
|
|
1111
1163
|
componentAddress: t2.source,
|
|
1112
1164
|
methodName: "deposit"
|
|
1113
|
-
}, [{ Workspace:
|
|
1165
|
+
}, [{ Workspace: Ct }]);
|
|
1114
1166
|
}
|
|
1115
1167
|
};
|
|
1116
|
-
function
|
|
1117
|
-
if (
|
|
1168
|
+
function an(e11) {
|
|
1169
|
+
if (on(e11) || e11.statementJson !== void 0) return e11.statementJson;
|
|
1118
1170
|
if (e11.inputs.length > 0) throw new _("inputs statement has confidential inputs but no WASM statementJson \u2014 call buildInputsStatement first", { context: "statementJsonFor" });
|
|
1119
1171
|
return JSON.stringify(e11.toJSON());
|
|
1120
1172
|
}
|
|
1121
|
-
function
|
|
1173
|
+
function on(e11) {
|
|
1122
1174
|
return !("inputs" in e11);
|
|
1123
1175
|
}
|
|
1124
|
-
async function
|
|
1125
|
-
let a2 =
|
|
1176
|
+
async function sn(e11, t2, n2, r2, i2) {
|
|
1177
|
+
let a2 = an(r2), o2 = an(i2);
|
|
1126
1178
|
return e11.generateBalanceProofSignature(t2, n2, a2, o2);
|
|
1127
1179
|
}
|
|
1128
|
-
async function
|
|
1180
|
+
async function cn(e11, t2, n2, r2) {
|
|
1129
1181
|
let i2 = await e11.deriveAeadKey(r2.viewSecret, r2.senderPublicNonce);
|
|
1130
1182
|
return e11.unblindOutput(t2, n2, i2, r2.skipMemo);
|
|
1131
1183
|
}
|
|
1132
|
-
async function
|
|
1133
|
-
let i2 =
|
|
1184
|
+
async function ln(e11, t2, n2, r2) {
|
|
1185
|
+
let i2 = tn(n2, r2);
|
|
1134
1186
|
if (i2 === null) return null;
|
|
1135
1187
|
let a2 = x(i2.body.encrypted_data), o2 = x(i2.body.public_nonce);
|
|
1136
1188
|
try {
|
|
1137
|
-
return await
|
|
1189
|
+
return await cn(e11, i2.commitment, a2, {
|
|
1138
1190
|
senderPublicNonce: o2,
|
|
1139
1191
|
viewSecret: t2,
|
|
1140
1192
|
skipMemo: false
|
|
@@ -1143,33 +1195,33 @@ async function qt(e11, t2, n2, r2) {
|
|
|
1143
1195
|
return null;
|
|
1144
1196
|
}
|
|
1145
1197
|
}
|
|
1146
|
-
async function
|
|
1198
|
+
async function un(e11, t2, n2) {
|
|
1147
1199
|
if (t2.length === 0) throw new v("generateOutputsStatement: at least one stealth output is required");
|
|
1148
1200
|
let { statement: r2, outputMask: i2 } = await e11.generateOutputsStatement(t2, n2), a2 = await e11.buildInputsStatement([], 0n);
|
|
1149
|
-
return new
|
|
1201
|
+
return new $(a2, r2, await sn(e11, X.zero(), i2, a2, r2));
|
|
1150
1202
|
}
|
|
1151
|
-
var
|
|
1203
|
+
var dn = class e10 {
|
|
1152
1204
|
constructor(e11, t2, n2, r2, i2) {
|
|
1153
1205
|
this.wallet = e11, this.spec = t2, this.crypto = n2, this.mustSignWithAccountKey = r2, this.viewSecret = i2;
|
|
1154
1206
|
}
|
|
1155
1207
|
static fromSpec(t2, n2, r2 = {}) {
|
|
1156
|
-
return new e10(t2, n2, r2.crypto ?? new
|
|
1208
|
+
return new e10(t2, n2, r2.crypto ?? new qt(), r2.mustSignWithAccountKey ?? true, r2.viewSecret);
|
|
1157
1209
|
}
|
|
1158
1210
|
async prepare(e11) {
|
|
1159
|
-
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ?
|
|
1211
|
+
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ? X.zero() : await this.crypto.aggregateInputMasks(t2.map((e12) => e12.mask)), r2 = await sn(this.crypto, n2, this.spec.outputMask, this.spec.statement.inputsStatement, this.spec.statement.outputsStatement), i2 = new $(this.spec.statement.inputsStatement, this.spec.statement.outputsStatement, r2);
|
|
1160
1212
|
await this.crypto.validateTransfer(i2);
|
|
1161
|
-
let a2 =
|
|
1213
|
+
let a2 = pn(this.spec.unsignedTx, i2), o2 = this.mustSignWithAccountKey ? await J([this.wallet], a2) : a2, s2 = {
|
|
1162
1214
|
...this.spec,
|
|
1163
|
-
unsignedTx:
|
|
1215
|
+
unsignedTx: o2,
|
|
1164
1216
|
statement: i2
|
|
1165
1217
|
};
|
|
1166
|
-
return new
|
|
1218
|
+
return new fn({
|
|
1167
1219
|
wallet: this.wallet,
|
|
1168
1220
|
crypto: this.crypto,
|
|
1169
|
-
spec:
|
|
1221
|
+
spec: s2,
|
|
1170
1222
|
resolvedInputs: t2,
|
|
1171
1223
|
mustSignWithAccountKey: this.mustSignWithAccountKey,
|
|
1172
|
-
sealKeypair:
|
|
1224
|
+
sealKeypair: Tt()
|
|
1173
1225
|
});
|
|
1174
1226
|
}
|
|
1175
1227
|
async resolveViewSecret() {
|
|
@@ -1194,11 +1246,11 @@ var Yt = class e10 {
|
|
|
1194
1246
|
let t2 = await this.resolveViewSecret(), n2 = this.spec.state.resource, r2 = await Promise.allSettled(this.spec.inputs.map(async ({ input: r3, owner: i3 }) => {
|
|
1195
1247
|
let a2 = b(r3.commitment), o2 = await e11.getStealthUtxo(n2, r3.commitment);
|
|
1196
1248
|
if (o2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input UTXO not found (spent or never created) for ${a2}`);
|
|
1197
|
-
let s2 =
|
|
1249
|
+
let s2 = tn(o2, Xt(n2, r3.commitment));
|
|
1198
1250
|
if (s2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input ${a2} is not a live, spendable UTXO`);
|
|
1199
1251
|
let c2 = x(s2.body.public_nonce), l2;
|
|
1200
1252
|
try {
|
|
1201
|
-
l2 = await
|
|
1253
|
+
l2 = await cn(this.crypto, s2.commitment, x(s2.body.encrypted_data), {
|
|
1202
1254
|
senderPublicNonce: c2,
|
|
1203
1255
|
viewSecret: t2,
|
|
1204
1256
|
skipMemo: true
|
|
@@ -1213,13 +1265,14 @@ var Yt = class e10 {
|
|
|
1213
1265
|
ownerAddr: i3,
|
|
1214
1266
|
input: r3,
|
|
1215
1267
|
mask: l2.mask,
|
|
1216
|
-
publicNonce: c2
|
|
1268
|
+
publicNonce: c2,
|
|
1269
|
+
viewSecret: t2
|
|
1217
1270
|
};
|
|
1218
1271
|
})), i2 = r2.find((e12) => e12.status === "rejected");
|
|
1219
1272
|
if (i2 !== void 0) throw i2.reason;
|
|
1220
1273
|
return r2.map((e12) => e12.value);
|
|
1221
1274
|
}
|
|
1222
|
-
},
|
|
1275
|
+
}, fn = class {
|
|
1223
1276
|
constructor(e11) {
|
|
1224
1277
|
__publicField(this, "wallet");
|
|
1225
1278
|
__publicField(this, "crypto");
|
|
@@ -1242,12 +1295,15 @@ var Yt = class e10 {
|
|
|
1242
1295
|
}
|
|
1243
1296
|
async computeAuthorizations() {
|
|
1244
1297
|
if (this.resolvedInputs.length === 0) return [];
|
|
1245
|
-
let e11 =
|
|
1298
|
+
let e11 = K(this.spec.unsignedTx), t2 = this.sealKeypair.public_key, n2 = [];
|
|
1246
1299
|
for (let r2 of this.resolvedInputs) {
|
|
1247
1300
|
let i2 = this.wallet.getKeyProvider(r2.ownerAddr);
|
|
1248
1301
|
if (i2 === void 0) throw new m(`AuthorizedTransfer.createAuthorizations: no signer registered for stealth-input owner ${r2.ownerAddr}. Register it via wallet.registerKeyProvider(owner, signer).`, { address: r2.ownerAddr });
|
|
1249
1302
|
if (i2.addStealthSignature === void 0) throw new g(`AuthorizedTransfer.createAuthorizations: signer for ${r2.ownerAddr} cannot produce one-time stealth signatures. Use a SecretKeyWallet (which holds the owner secret).`);
|
|
1250
|
-
let a2 = await i2.addStealthSignature(e11, r2.publicNonce, t2, {
|
|
1303
|
+
let a2 = await i2.addStealthSignature(e11, r2.publicNonce, t2, {
|
|
1304
|
+
crypto: this.crypto,
|
|
1305
|
+
viewSecret: r2.viewSecret
|
|
1306
|
+
});
|
|
1251
1307
|
n2.push({
|
|
1252
1308
|
signerAddress: r2.ownerAddr,
|
|
1253
1309
|
signatures: [a2]
|
|
@@ -1262,23 +1318,23 @@ var Yt = class e10 {
|
|
|
1262
1318
|
let e11 = (await this.createAuthorizations()).flatMap((e12) => e12.signatures), t2 = [];
|
|
1263
1319
|
this.mustSignWithAccountKey && t2.push(this.wallet);
|
|
1264
1320
|
let n2 = [...e11, ...this.extraSignatures];
|
|
1265
|
-
return n2.length > 0 && t2.push(new
|
|
1321
|
+
return n2.length > 0 && t2.push(new mn(n2)), Y(await Ot(t2, this.spec.unsignedTx, this.sealKeypair));
|
|
1266
1322
|
}
|
|
1267
1323
|
};
|
|
1268
|
-
function
|
|
1269
|
-
let n2 = e11.instructions.findIndex(
|
|
1324
|
+
function pn(e11, t2) {
|
|
1325
|
+
let n2 = e11.instructions.findIndex(G);
|
|
1270
1326
|
if (n2 < 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found 0 (not a stealth tx)");
|
|
1271
|
-
if (e11.instructions.slice(n2 + 1).findIndex(
|
|
1327
|
+
if (e11.instructions.slice(n2 + 1).findIndex(G) >= 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found more than one (malformed)");
|
|
1272
1328
|
let r2 = { StealthTransfer: {
|
|
1273
1329
|
...e11.instructions[n2].StealthTransfer,
|
|
1274
|
-
statement:
|
|
1330
|
+
statement: W(t2)
|
|
1275
1331
|
} }, i2 = [...e11.instructions];
|
|
1276
1332
|
return i2[n2] = r2, {
|
|
1277
1333
|
...e11,
|
|
1278
1334
|
instructions: i2
|
|
1279
1335
|
};
|
|
1280
1336
|
}
|
|
1281
|
-
var
|
|
1337
|
+
var mn = class {
|
|
1282
1338
|
constructor(e11) {
|
|
1283
1339
|
this.signatures = e11;
|
|
1284
1340
|
}
|
|
@@ -1293,88 +1349,95 @@ var Qt = class {
|
|
|
1293
1349
|
}
|
|
1294
1350
|
};
|
|
1295
1351
|
export {
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1352
|
+
Pt as AccountInvokeBuilder,
|
|
1353
|
+
fn as AuthorizedTransfer,
|
|
1354
|
+
Q as BalanceProofSignature,
|
|
1299
1355
|
_ as CryptoBridgeError,
|
|
1300
|
-
|
|
1356
|
+
Ye as DEFAULT_TRANSACTION_VALIDITY_EPOCHS,
|
|
1301
1357
|
h as DefaultSignerNotSetError,
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1358
|
+
Rt as EncryptedData,
|
|
1359
|
+
Ft as FaucetInvokeBuilder,
|
|
1360
|
+
ue as IndexerClientError,
|
|
1305
1361
|
v as InvalidArgumentError,
|
|
1306
1362
|
m as KeyProviderNotFoundError,
|
|
1307
|
-
|
|
1308
|
-
|
|
1363
|
+
Je as MAX_TRANSACTION_VALIDITY_EPOCHS,
|
|
1364
|
+
X as Mask,
|
|
1309
1365
|
u as Network,
|
|
1310
1366
|
d as OotleError,
|
|
1311
|
-
|
|
1312
|
-
|
|
1367
|
+
It as OotleWallet,
|
|
1368
|
+
fe as OperationCancelledError,
|
|
1313
1369
|
g as SignerError,
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1370
|
+
Z as StealthInput,
|
|
1371
|
+
Ut as StealthInputsStatement,
|
|
1372
|
+
Wt as StealthOutputsStatement,
|
|
1373
|
+
rn as StealthTransfer,
|
|
1374
|
+
$ as StealthTransferStatement,
|
|
1375
|
+
_t as TARI_RESOURCE_ADDRESS,
|
|
1376
|
+
B as TransactionBuilder,
|
|
1321
1377
|
f as TransactionRejectedError,
|
|
1322
|
-
|
|
1378
|
+
de as TransactionTimeoutError,
|
|
1323
1379
|
p as WalletError,
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1380
|
+
dn as WalletStealthAuthorizer,
|
|
1381
|
+
qt as WasmStealthCrypto,
|
|
1382
|
+
bt as XTR_FAUCET_CLAIM_RESOURCE_ADDRESS,
|
|
1383
|
+
vt as XTR_FAUCET_COMPONENT_ADDRESS,
|
|
1384
|
+
yt as XTR_FAUCET_VAULT_ADDRESS,
|
|
1385
|
+
k as amountLiteral,
|
|
1330
1386
|
y as assertByteLength,
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1387
|
+
pe as assertUnreachable,
|
|
1388
|
+
Me as boolLiteral,
|
|
1389
|
+
Et as buildTransactionSignature,
|
|
1390
|
+
A as bytesLiteral,
|
|
1391
|
+
Le as claimedOutputTombstoneAddressLiteral,
|
|
1392
|
+
At as classifyOutcome,
|
|
1393
|
+
en as commitmentOf,
|
|
1394
|
+
Ne as componentAddressLiteral,
|
|
1395
|
+
Bt as createOutput,
|
|
1396
|
+
ct as decodeEvent,
|
|
1397
|
+
ot as decodeExecuteResult,
|
|
1398
|
+
lt as decodeResource,
|
|
1399
|
+
at as decodeSubstateValue,
|
|
1400
|
+
st as decodeTransactionReceipt,
|
|
1401
|
+
ut as decodeUtxo,
|
|
1402
|
+
cn as decryptInputData,
|
|
1403
|
+
ln as decryptOwnedUtxo,
|
|
1404
|
+
it as defaultIndexerUrl,
|
|
1343
1405
|
x as fromHexStr,
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1406
|
+
un as generateOutputsStatement,
|
|
1407
|
+
Tt as generateSealKeypair,
|
|
1408
|
+
mt as getVaultIdsForAccount,
|
|
1409
|
+
Ae as intLiteral,
|
|
1410
|
+
G as isStealthTransferInstruction,
|
|
1411
|
+
pt as iterVaultIdsInState,
|
|
1412
|
+
Oe as literalArg,
|
|
1413
|
+
Pe as metadataLiteral,
|
|
1414
|
+
R as microTariLiteral,
|
|
1415
|
+
Ke as microTariString,
|
|
1416
|
+
Be as nonFungibleAddressLiteral,
|
|
1417
|
+
tn as parseSubstateUtxo,
|
|
1418
|
+
qe as parseWorkspaceStringKey,
|
|
1419
|
+
pn as patchStealthStatement,
|
|
1420
|
+
ze as publicKeyLiteral,
|
|
1421
|
+
J as resolveMainSigner,
|
|
1422
|
+
Xe as resolveMaxEpoch,
|
|
1423
|
+
q as resolveTransaction,
|
|
1424
|
+
j as resourceAddressLiteral,
|
|
1425
|
+
Y as sealTransaction,
|
|
1426
|
+
Nt as sendDryRun,
|
|
1427
|
+
Mt as sendTransaction,
|
|
1428
|
+
K as serializeUnsignedTx,
|
|
1429
|
+
sn as signBalanceProof,
|
|
1430
|
+
Dt as signTransaction,
|
|
1431
|
+
W as statementAsWire,
|
|
1432
|
+
wt as stealthTransferInstruction,
|
|
1433
|
+
Xt as stealthUtxoSubstateId,
|
|
1434
|
+
je as stringLiteral,
|
|
1435
|
+
kt as submitTransaction,
|
|
1436
|
+
Ie as templateAddressLiteral,
|
|
1374
1437
|
b as toHexStr,
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1438
|
+
H as upSubstateValue,
|
|
1439
|
+
Ve as utxoAddressLiteral,
|
|
1440
|
+
Re as validatorFeePoolAddressLiteral,
|
|
1441
|
+
Fe as vaultIdLiteral,
|
|
1442
|
+
jt as watchTransaction
|
|
1380
1443
|
};
|