@tari-project/ootle 0.11.1 → 0.13.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 +156 -17
- package/dist/index.js +424 -327
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
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
|
-
import { aggregateInputMasks as e,
|
|
4
|
+
import { aggregateInputMasks as e, attachTransactionSignature as t, borEncodeTransaction as n, buildStealthInputsStatement as r, createStealthOutputWitness as i, encryptedDataDhKdfAead as a, generateKeypair as o, generateOotleAddress as s, generateStealthBalanceProofSignature as c, generateStealthOutputsStatement as l, hashUnsignedTransaction as ee, parseOotleAddress as te, sealTransaction as ne, stealthDhSecret as re, unblindOutput as ie, validateBalanceProofSignature as ae, validateStealthTransfer as oe } from "@tari-project/ootle-wasm";
|
|
5
|
+
import { decodeEvent as se, decodeExecuteResult as ce, decodeResource as le, decodeSubstateValue as ue, decodeTransactionReceipt as de, decodeUtxo as fe } 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
|
+
}, pe = 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
|
+
}, me = 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
|
+
}, he = class extends d {
|
|
50
51
|
};
|
|
51
|
-
function
|
|
52
|
+
function ge(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 _e = /^[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 (!_e.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, ve = 2n, C = 32, ye = C * 2, be = 32, xe = 128, Se = 129, Ce = 130, w = 131, we = 132, Te = 136, Ee = 138, De = 141, T = 0, Oe = 32, E = 64, ke = 96, D = 128, Ae = 160, O = 192;
|
|
71
|
+
function je(e11) {
|
|
71
72
|
switch (typeof e11) {
|
|
72
73
|
case "bigint":
|
|
73
|
-
return
|
|
74
|
+
return k(e11);
|
|
74
75
|
case "string":
|
|
75
|
-
return
|
|
76
|
+
return Pe(e11);
|
|
76
77
|
case "boolean":
|
|
77
|
-
return
|
|
78
|
+
return Fe(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) : Me(t2, e11), L(t2);
|
|
88
89
|
}
|
|
89
|
-
function
|
|
90
|
+
function Me(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, ve), I(e11, E, BigInt(n2.length)), F(e11, n2);
|
|
93
94
|
}
|
|
94
|
-
function
|
|
95
|
+
function Ne(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, Oe, n2);
|
|
103
104
|
}
|
|
104
|
-
return
|
|
105
|
+
return L(t2);
|
|
105
106
|
}
|
|
106
|
-
function
|
|
107
|
+
function Pe(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 Fe(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 Ie(e11) {
|
|
122
|
+
return M(xe, 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 Le(e11) {
|
|
125
|
+
let t2 = e11 instanceof Map ? e11 : new Map(Object.entries(e11)), n2 = new TextEncoder(), r2 = [...t2.entries()].sort(([e12], [t3]) => Je(n2.encode(e12), n2.encode(t3))), i2 = [];
|
|
126
|
+
I(i2, O, BigInt(Se)), I(i2, Ae, 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 Re(e11) {
|
|
131
|
+
return M(we, e11, "vault_");
|
|
131
132
|
}
|
|
132
|
-
function
|
|
133
|
-
return
|
|
133
|
+
function ze(e11) {
|
|
134
|
+
return A(Ge(e11, "template_"));
|
|
134
135
|
}
|
|
135
|
-
function
|
|
136
|
-
return
|
|
136
|
+
function Be(e11) {
|
|
137
|
+
return M(Te, e11, "tombstone_");
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
-
return
|
|
139
|
+
function Ve(e11) {
|
|
140
|
+
return M(Ee, e11, "vnfp_");
|
|
140
141
|
}
|
|
141
|
-
function
|
|
142
|
+
function He(e11) {
|
|
142
143
|
let t2 = typeof e11 == "string" ? x(e11) : e11;
|
|
143
|
-
return y(t2,
|
|
144
|
+
return y(t2, be, "publicKeyLiteral"), A(t2);
|
|
144
145
|
}
|
|
145
|
-
function
|
|
146
|
+
function Ue(e11) {
|
|
146
147
|
let t2 = [];
|
|
147
|
-
return
|
|
148
|
+
return I(t2, O, BigInt(Ce)), I(t2, D, 2n), N(t2, w, e11.resource_address, "resource_"), Ke(t2, e11.id), L(t2);
|
|
148
149
|
}
|
|
149
|
-
function
|
|
150
|
+
function We(e11) {
|
|
150
151
|
let t2 = [];
|
|
151
|
-
|
|
152
|
+
I(t2, O, BigInt(De)), 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 = Ge(n2, r2);
|
|
162
|
+
I(e11, O, BigInt(t2)), I(e11, E, BigInt(C)), F(e11, i2);
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
+
function Ge(e11, t2) {
|
|
164
165
|
let n2 = e11.startsWith(t2) ? e11.slice(t2.length) : e11;
|
|
165
|
-
if (n2.length !==
|
|
166
|
+
if (n2.length !== ye) throw new v(`${t2}address must be 32 bytes (${ye} hex chars), got ${n2.length}`);
|
|
166
167
|
return x(n2);
|
|
167
168
|
}
|
|
168
|
-
function
|
|
169
|
-
if (
|
|
170
|
-
|
|
169
|
+
function Ke(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), qe(e11, t2.Uint32, "NonFungibleId.Uint32", (1n << 32n) - 1n);
|
|
176
|
+
else if ("Uint64" in t2) I(e11, T, 3n), I(e11, D, 1n), qe(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 qe(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, ke, 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 Je(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 Ye(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 Xe(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 Ze = 2160, Qe = 10;
|
|
229
|
+
async function $e(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 ${Ze} epochs`);
|
|
231
232
|
return await e11.getCurrentEpoch() + t2;
|
|
232
233
|
}
|
|
233
|
-
var
|
|
234
|
-
function
|
|
234
|
+
var et = (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 tt(e11) {
|
|
239
240
|
return e11.startsWith("template_") ? e11.slice(9) : e11;
|
|
240
241
|
}
|
|
241
|
-
function
|
|
242
|
+
function nt(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 rt = 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 = nt(t2);
|
|
269
270
|
e12 !== null && this.observeAllocated(e12);
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
273
|
};
|
|
273
|
-
function
|
|
274
|
+
function it(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 rt(), this.feeWorkspaceIds = new rt();
|
|
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: tt(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 = nt(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(at(e11)), this;
|
|
394
405
|
}
|
|
395
406
|
withInputs(e11) {
|
|
396
|
-
return this.unsignedTransaction.inputs.push(...e11.map(
|
|
407
|
+
return this.unsignedTransaction.inputs.push(...e11.map(at)), 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 > et) 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 it(e11);
|
|
439
453
|
return t2;
|
|
440
454
|
}
|
|
441
455
|
getOffsetIdFromWorkspaceName(e11) {
|
|
442
|
-
let t2 =
|
|
456
|
+
let t2 = Xe(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 at(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 ot = {
|
|
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 st(e11) {
|
|
478
|
+
let t2 = ot[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 ct(e11) {
|
|
495
|
+
return V("decodeSubstateValue", ue, e11);
|
|
496
|
+
}
|
|
497
|
+
function lt(e11) {
|
|
498
|
+
return V("decodeExecuteResult", ce, e11);
|
|
499
|
+
}
|
|
500
|
+
function ut(e11) {
|
|
501
|
+
return V("decodeTransactionReceipt", de, e11);
|
|
502
|
+
}
|
|
503
|
+
function dt(e11) {
|
|
504
|
+
return V("decodeEvent", se, e11);
|
|
505
|
+
}
|
|
506
|
+
function ft(e11) {
|
|
507
|
+
return V("decodeResource", le, e11);
|
|
470
508
|
}
|
|
471
|
-
|
|
472
|
-
|
|
509
|
+
function pt(e11) {
|
|
510
|
+
return V("decodeUtxo", fe, e11);
|
|
511
|
+
}
|
|
512
|
+
function H(e11) {
|
|
513
|
+
return "up" in e11.state ? ct(e11.state.up.substate) : null;
|
|
514
|
+
}
|
|
515
|
+
var mt = 132, ht = 32;
|
|
516
|
+
function* gt(e11) {
|
|
473
517
|
let t2 = /* @__PURE__ */ new Set();
|
|
474
|
-
for (let n2 of
|
|
518
|
+
for (let n2 of U(e11, mt)) n2.length === ht * 2 && !t2.has(n2) && (t2.add(n2), yield `vault_${n2}`);
|
|
475
519
|
}
|
|
476
|
-
async function
|
|
477
|
-
let n2 =
|
|
478
|
-
return
|
|
520
|
+
async function _t(e11, t2) {
|
|
521
|
+
let n2 = H(await e11.getSubstate(t2));
|
|
522
|
+
return yt(n2) ? Array.from(gt(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 = vt(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 vt(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 yt(e11) {
|
|
511
555
|
return typeof e11 == "object" && !!e11 && "Component" in e11;
|
|
512
556
|
}
|
|
513
|
-
var
|
|
514
|
-
function
|
|
557
|
+
var bt = "resource_0101010101010101010101010101010101010101010101010101010101010101", xt = "component_0102030000000000000000000000000000000000000000000000000000000000", St = "vault_0102030000000000000000000000000000000000000000000000000000000001", Ct = "resource_0102030000000000000000000000000000000000000000000000000000000002", wt = "__ootleRawJson", Tt = "stealth_revealed_input", Et = "stealth_revealed_change";
|
|
558
|
+
function Dt(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 { [wt]: 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[wt]), 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
|
|
553
|
-
let { secret_key: e11, public_key: t2 } =
|
|
596
|
+
function Ot() {
|
|
597
|
+
let { secret_key: e11, public_key: t2 } = o();
|
|
554
598
|
return {
|
|
555
599
|
secret_key: e11,
|
|
556
600
|
public_key: t2
|
|
557
601
|
};
|
|
558
602
|
}
|
|
559
|
-
function
|
|
603
|
+
function kt(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
|
|
569
|
-
|
|
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 At(e11, t2, n2) {
|
|
618
|
+
return jt(e11, await J(e11, t2), n2);
|
|
619
|
+
}
|
|
620
|
+
async function jt(e11, t2, n2) {
|
|
621
|
+
let r2 = n2 ?? o(), i2 = y(r2.secret_key, 32, "sealKeypair.secret_key"), a2 = y(r2.public_key, 32, "sealKeypair.public_key"), s2 = [];
|
|
570
622
|
for (let n3 of e11) {
|
|
571
|
-
let e12 = await n3.signTransaction(t2,
|
|
623
|
+
let e12 = await n3.signTransaction(t2, a2);
|
|
572
624
|
s2.push(...e12);
|
|
573
625
|
}
|
|
574
|
-
let c2 =
|
|
626
|
+
let c2 = ne(`{"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
|
|
581
|
-
return
|
|
632
|
+
function Y(e11) {
|
|
633
|
+
return n(e11.sealedJson);
|
|
582
634
|
}
|
|
583
|
-
async function
|
|
635
|
+
async function Mt(e11, t2) {
|
|
584
636
|
return (await e11.submitTransaction(t2)).transaction_id;
|
|
585
637
|
}
|
|
586
|
-
function
|
|
587
|
-
var _a
|
|
638
|
+
function Nt(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 = lt(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 Pt(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 } = Nt(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,57 @@ 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 me(`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 Ft(e11, t2, n2, r2) {
|
|
677
|
+
let i2 = await q(e11, n2);
|
|
678
|
+
return Pt(e11, await Mt(e11, Y(await At(Array.isArray(t2) ? t2 : [t2], i2))), r2);
|
|
627
679
|
}
|
|
628
|
-
async function
|
|
629
|
-
return
|
|
680
|
+
async function It(e11, t2, n2, r2) {
|
|
681
|
+
return Ft(e11, t2, {
|
|
630
682
|
...n2,
|
|
631
683
|
dry_run: true
|
|
632
684
|
}, r2);
|
|
633
685
|
}
|
|
634
|
-
var
|
|
686
|
+
var Lt = class {
|
|
687
|
+
constructor(e11) {
|
|
688
|
+
__publicField(this, "publicKey");
|
|
689
|
+
__publicField(this, "sign");
|
|
690
|
+
__publicField(this, "address");
|
|
691
|
+
this.publicKey = y(e11.publicKey, 32, "ExternalKeySigner publicKey"), y(e11.viewPublicKey, 32, "ExternalKeySigner viewPublicKey"), this.sign = e11.sign, this.address = s(this.publicKey, e11.viewPublicKey, e11.network);
|
|
692
|
+
}
|
|
693
|
+
async getAddress() {
|
|
694
|
+
return Promise.resolve(this.address);
|
|
695
|
+
}
|
|
696
|
+
async getPublicKey() {
|
|
697
|
+
return Promise.resolve(this.publicKey);
|
|
698
|
+
}
|
|
699
|
+
async signTransaction(e11, n2) {
|
|
700
|
+
y(n2, 32, "ExternalKeySigner.signTransaction sealPublicKey");
|
|
701
|
+
let r2 = K(e11), i2 = ee(r2, n2), a2;
|
|
702
|
+
try {
|
|
703
|
+
a2 = await this.sign(i2);
|
|
704
|
+
} catch (e12) {
|
|
705
|
+
throw new g(`External signer failed: ${Rt(e12)}`, { cause: e12 });
|
|
706
|
+
}
|
|
707
|
+
let o2;
|
|
708
|
+
try {
|
|
709
|
+
o2 = t(r2, this.publicKey, a2, n2);
|
|
710
|
+
} catch (e12) {
|
|
711
|
+
throw new g(`External signature rejected: ${Rt(e12)}`, { cause: e12 });
|
|
712
|
+
}
|
|
713
|
+
return JSON.parse(o2).signatures;
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
function Rt(e11) {
|
|
717
|
+
return e11 instanceof Error ? e11.message : String(e11);
|
|
718
|
+
}
|
|
719
|
+
var zt = class {
|
|
635
720
|
constructor(e11, t2) {
|
|
636
721
|
__publicField(this, "builder");
|
|
637
|
-
this.builder =
|
|
722
|
+
this.builder = B.new(e11, t2);
|
|
638
723
|
}
|
|
639
724
|
withInputs(e11) {
|
|
640
725
|
return this.builder.withInputs(e11), this;
|
|
@@ -646,7 +731,7 @@ var xt = class {
|
|
|
646
731
|
return this.builder.callMethod({
|
|
647
732
|
componentAddress: e11,
|
|
648
733
|
methodName: "withdraw"
|
|
649
|
-
}, [
|
|
734
|
+
}, [j(t2), R(n2)]).saveVar("bucket").callMethod({
|
|
650
735
|
componentAddress: r2,
|
|
651
736
|
methodName: "deposit"
|
|
652
737
|
}, [{ Workspace: "bucket" }]), this;
|
|
@@ -657,11 +742,11 @@ var xt = class {
|
|
|
657
742
|
build() {
|
|
658
743
|
return this.builder.buildUnsignedTransaction();
|
|
659
744
|
}
|
|
660
|
-
},
|
|
745
|
+
}, Bt = class {
|
|
661
746
|
constructor(e11, t2, n2) {
|
|
662
747
|
__publicField(this, "builder");
|
|
663
748
|
__publicField(this, "faucetAddress");
|
|
664
|
-
this.builder =
|
|
749
|
+
this.builder = B.new(e11, t2), this.faucetAddress = n2;
|
|
665
750
|
}
|
|
666
751
|
feeTransactionPayFromComponent(e11, t2) {
|
|
667
752
|
return this.builder.feeTransactionPayFromComponent(e11, t2), this;
|
|
@@ -670,7 +755,7 @@ var xt = class {
|
|
|
670
755
|
return this.builder.callMethod({
|
|
671
756
|
componentAddress: this.faucetAddress,
|
|
672
757
|
methodName: "take_free_coins"
|
|
673
|
-
}, [
|
|
758
|
+
}, [R(t2)]).saveVar("faucet_bucket").callMethod({
|
|
674
759
|
componentAddress: e11,
|
|
675
760
|
methodName: "deposit"
|
|
676
761
|
}, [{ Workspace: "faucet_bucket" }]), this;
|
|
@@ -694,7 +779,7 @@ var xt = class {
|
|
|
694
779
|
build() {
|
|
695
780
|
return this.builder.buildUnsignedTransaction();
|
|
696
781
|
}
|
|
697
|
-
},
|
|
782
|
+
}, Vt = class {
|
|
698
783
|
constructor() {
|
|
699
784
|
__publicField(this, "keyProviders");
|
|
700
785
|
__publicField(this, "defaultSignerAddress", null);
|
|
@@ -740,7 +825,7 @@ var xt = class {
|
|
|
740
825
|
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
826
|
return n2;
|
|
742
827
|
}
|
|
743
|
-
},
|
|
828
|
+
}, Ht = class {
|
|
744
829
|
constructor(e11, t2) {
|
|
745
830
|
__publicField(this, "bytes");
|
|
746
831
|
this.bytes = new Uint8Array(y(e11, 32, t2));
|
|
@@ -751,7 +836,7 @@ var xt = class {
|
|
|
751
836
|
toHex() {
|
|
752
837
|
return b(this.bytes);
|
|
753
838
|
}
|
|
754
|
-
},
|
|
839
|
+
}, X = class e3 extends Ht {
|
|
755
840
|
constructor(e11) {
|
|
756
841
|
super(e11, "Mask");
|
|
757
842
|
}
|
|
@@ -764,7 +849,7 @@ var xt = class {
|
|
|
764
849
|
static fromHex(t2) {
|
|
765
850
|
return new e3(x(t2));
|
|
766
851
|
}
|
|
767
|
-
},
|
|
852
|
+
}, Ut = class e4 {
|
|
768
853
|
constructor(e11) {
|
|
769
854
|
__publicField(this, "bytes");
|
|
770
855
|
this.bytes = new Uint8Array(e11);
|
|
@@ -778,8 +863,8 @@ var xt = class {
|
|
|
778
863
|
toHex() {
|
|
779
864
|
return b(this.bytes);
|
|
780
865
|
}
|
|
781
|
-
},
|
|
782
|
-
function
|
|
866
|
+
}, Wt = Object.freeze({ StealthPublicKey: Object.freeze({}) });
|
|
867
|
+
function Gt(e11) {
|
|
783
868
|
if (e11.amount <= 0n) throw new v(`Output amount must be > 0, got ${e11.amount}`);
|
|
784
869
|
return {
|
|
785
870
|
destination: e11.destination,
|
|
@@ -787,19 +872,19 @@ function Dt(e11) {
|
|
|
787
872
|
resourceAddress: e11.resourceAddress,
|
|
788
873
|
resourceViewKey: e11.resourceViewKey === void 0 ? void 0 : new Uint8Array(e11.resourceViewKey),
|
|
789
874
|
memo: e11.memo,
|
|
790
|
-
payTo: e11.payTo ??
|
|
875
|
+
payTo: e11.payTo ?? Wt,
|
|
791
876
|
minimumValuePromise: e11.minimumValuePromise ?? 0n
|
|
792
877
|
};
|
|
793
878
|
}
|
|
794
|
-
function
|
|
879
|
+
function Kt(e11, t2) {
|
|
795
880
|
if (e11.trim() === "") throw new v(`${t2} must be a non-empty decimal string`);
|
|
796
881
|
return BigInt(e11);
|
|
797
882
|
}
|
|
798
|
-
function
|
|
883
|
+
function qt(e11, t2) {
|
|
799
884
|
let n2 = e11.trim();
|
|
800
885
|
if (!n2.startsWith("{") || !n2.endsWith("}")) throw new v(`StealthTransferStatement.toCompactJson: ${t2} fragment is not a JSON object (got: ${e11.slice(0, 60)}...)`);
|
|
801
886
|
}
|
|
802
|
-
var
|
|
887
|
+
var Jt = class e5 extends Ht {
|
|
803
888
|
constructor(e11) {
|
|
804
889
|
super(e11, "StealthInput.commitment");
|
|
805
890
|
}
|
|
@@ -812,7 +897,7 @@ var Y = class e5 extends wt {
|
|
|
812
897
|
static fromJSON(t2) {
|
|
813
898
|
return new e5(x(t2.commitment));
|
|
814
899
|
}
|
|
815
|
-
},
|
|
900
|
+
}, Z = class e6 {
|
|
816
901
|
constructor(e11, t2) {
|
|
817
902
|
__publicField(this, "_publicNonce");
|
|
818
903
|
__publicField(this, "_signature");
|
|
@@ -833,7 +918,7 @@ var Y = class e5 extends wt {
|
|
|
833
918
|
static fromJSON(t2) {
|
|
834
919
|
return new e6(x(t2.public_nonce), x(t2.signature));
|
|
835
920
|
}
|
|
836
|
-
},
|
|
921
|
+
}, Yt = class e7 {
|
|
837
922
|
constructor(e11, t2, n2) {
|
|
838
923
|
__publicField(this, "inputs");
|
|
839
924
|
__publicField(this, "revealedAmount");
|
|
@@ -846,13 +931,13 @@ var Y = class e5 extends wt {
|
|
|
846
931
|
toJSON() {
|
|
847
932
|
return {
|
|
848
933
|
inputs: this.inputs.map((e11) => e11.toJSON()),
|
|
849
|
-
revealed_amount:
|
|
934
|
+
revealed_amount: Ye(this.revealedAmount)
|
|
850
935
|
};
|
|
851
936
|
}
|
|
852
937
|
static fromJSON(t2) {
|
|
853
|
-
return new e7(t2.inputs.map(
|
|
938
|
+
return new e7(t2.inputs.map(Jt.fromJSON), Kt(t2.revealed_amount, "revealed_amount"));
|
|
854
939
|
}
|
|
855
|
-
},
|
|
940
|
+
}, Xt = class e8 {
|
|
856
941
|
constructor(e11) {
|
|
857
942
|
__publicField(this, "statementJson");
|
|
858
943
|
this.statementJson = e11;
|
|
@@ -882,15 +967,15 @@ var Y = class e5 extends wt {
|
|
|
882
967
|
}
|
|
883
968
|
toCompactJson() {
|
|
884
969
|
let e11 = this.inputsStatement.statementJson ?? JSON.stringify(this.inputsStatement.toJSON()), t2 = this.outputsStatement.statementJson;
|
|
885
|
-
|
|
970
|
+
qt(e11, "inputs_statement"), qt(t2, "outputs_statement");
|
|
886
971
|
let n2 = `{"inputs_statement":${e11},"outputs_statement":${t2},"covenant_claims":[]`;
|
|
887
972
|
return this.balanceProof !== void 0 && (n2 += `,"balance_proof":${JSON.stringify(this.balanceProof.toJSON())}`), n2 + "}";
|
|
888
973
|
}
|
|
889
974
|
static fromJSON(t2) {
|
|
890
|
-
return new e9(
|
|
975
|
+
return new e9(Yt.fromJSON(t2.inputs), Xt.fromJSON(t2.outputs), t2.balance_proof === void 0 ? void 0 : Z.fromJSON(t2.balance_proof));
|
|
891
976
|
}
|
|
892
977
|
};
|
|
893
|
-
function
|
|
978
|
+
function Zt(e11, t2) {
|
|
894
979
|
let n2 = new Uint8Array(e11.length * 32);
|
|
895
980
|
for (let r2 = 0; r2 < e11.length; r2++) {
|
|
896
981
|
let i2 = e11[r2];
|
|
@@ -898,7 +983,7 @@ function jt(e11, t2) {
|
|
|
898
983
|
}
|
|
899
984
|
return n2;
|
|
900
985
|
}
|
|
901
|
-
var
|
|
986
|
+
var Qt = "[]", $t = class {
|
|
902
987
|
constructor(e11 = u.LocalNet) {
|
|
903
988
|
__publicField(this, "network");
|
|
904
989
|
this.network = e11;
|
|
@@ -906,96 +991,96 @@ var Mt = "[]", Nt = class {
|
|
|
906
991
|
async generateOutputsStatement(e11, t2) {
|
|
907
992
|
let n2 = `[${e11.map((e12) => this.outputWitness(e12)).join(",")}]`, r2 = 0n, i2 = new Uint8Array(32);
|
|
908
993
|
t2 !== null && (y(t2.receiver, 32, "revealed output receiver"), r2 = t2.amount, i2 = t2.receiver);
|
|
909
|
-
let a2 =
|
|
994
|
+
let a2 = l(n2, r2, i2);
|
|
910
995
|
return y(a2.aggregated_output_mask, 32, "StealthOutputsResult.aggregated_output_mask"), {
|
|
911
|
-
statement:
|
|
912
|
-
outputMask:
|
|
996
|
+
statement: Xt.fromJSON(a2.statement_json),
|
|
997
|
+
outputMask: X.fromBytes(a2.aggregated_output_mask)
|
|
913
998
|
};
|
|
914
999
|
}
|
|
915
1000
|
outputWitness(e11) {
|
|
916
|
-
let t2 =
|
|
917
|
-
return
|
|
1001
|
+
let t2 = te(e11.destination), n2 = en(e11.payTo) ? null : JSON.stringify(e11.payTo), r2 = e11.memo === void 0 ? null : JSON.stringify(e11.memo), a2 = e11.resourceViewKey ?? null;
|
|
1002
|
+
return i(this.network, t2.owner_key, t2.view_key, e11.amount, e11.resourceAddress, a2, r2, n2, e11.minimumValuePromise);
|
|
918
1003
|
}
|
|
919
1004
|
async buildInputsStatement(e11, t2) {
|
|
920
|
-
return new
|
|
1005
|
+
return new Yt(e11, t2, r(Zt(e11.map((e12) => e12.commitment), "input commitment"), t2));
|
|
921
1006
|
}
|
|
922
1007
|
async generateBalanceProofSignature(e11, t2, n2, r2) {
|
|
923
|
-
let i2 =
|
|
924
|
-
return y(i2.public_nonce, 32, "balance proof public_nonce"), y(i2.signature, 32, "balance proof signature"), new
|
|
1008
|
+
let i2 = c(e11.toBytes(), t2.toBytes(), n2, r2, Qt);
|
|
1009
|
+
return y(i2.public_nonce, 32, "balance proof public_nonce"), y(i2.signature, 32, "balance proof signature"), new Z(i2.public_nonce, i2.signature);
|
|
925
1010
|
}
|
|
926
1011
|
async validateBalanceProofSignature(e11, t2, n2) {
|
|
927
|
-
return
|
|
1012
|
+
return ae(e11.publicNonce, e11.signature, t2, n2, Qt);
|
|
928
1013
|
}
|
|
929
1014
|
async deriveAeadKey(e11, t2) {
|
|
930
1015
|
y(e11, 32, "deriveAeadKey privateKey"), y(t2, 32, "deriveAeadKey publicKey");
|
|
931
|
-
let n2 =
|
|
1016
|
+
let n2 = a(e11, t2);
|
|
932
1017
|
return y(n2, 32, "derived AEAD key"), n2;
|
|
933
1018
|
}
|
|
934
1019
|
async unblindOutput(e11, t2, n2, r2) {
|
|
935
1020
|
y(e11, 32, "unblindOutput commitment"), y(n2, 32, "unblindOutput aeadKey");
|
|
936
|
-
let i2 =
|
|
1021
|
+
let i2 = ie(e11, t2, n2, r2);
|
|
937
1022
|
return {
|
|
938
|
-
mask:
|
|
1023
|
+
mask: X.fromBytes(i2.mask),
|
|
939
1024
|
value: i2.value,
|
|
940
1025
|
memo: i2.memo_json ?? void 0
|
|
941
1026
|
};
|
|
942
1027
|
}
|
|
943
1028
|
async aggregateInputMasks(t2) {
|
|
944
|
-
let n2 = e(
|
|
945
|
-
return
|
|
1029
|
+
let n2 = e(Zt(t2.map((e11) => e11.toBytes()), "input mask"));
|
|
1030
|
+
return X.fromBytes(n2);
|
|
946
1031
|
}
|
|
947
|
-
async stealthDhSecret(e11, t2, n2) {
|
|
948
|
-
y(t2, 32, "stealthDhSecret ownerSecret"), y(n2, 32, "stealthDhSecret publicNonce");
|
|
949
|
-
let
|
|
950
|
-
return y(
|
|
1032
|
+
async stealthDhSecret(e11, t2, n2, r2) {
|
|
1033
|
+
y(t2, 32, "stealthDhSecret ownerSecret"), y(n2, 32, "stealthDhSecret viewSecret"), y(r2, 32, "stealthDhSecret publicNonce");
|
|
1034
|
+
let i2 = re(e11, t2, n2, r2);
|
|
1035
|
+
return y(i2, 32, "stealth DH secret"), i2;
|
|
951
1036
|
}
|
|
952
1037
|
async validateTransfer(e11) {
|
|
953
|
-
|
|
1038
|
+
oe(e11.toCompactJson(), null);
|
|
954
1039
|
}
|
|
955
1040
|
};
|
|
956
|
-
function
|
|
1041
|
+
function en(e11) {
|
|
957
1042
|
let t2 = Object.keys(e11);
|
|
958
1043
|
if (t2.length !== 1 || t2[0] !== "StealthPublicKey") return false;
|
|
959
1044
|
let n2 = e11.StealthPublicKey;
|
|
960
1045
|
return typeof n2 == "object" && !!n2 && Object.keys(n2).length === 0;
|
|
961
1046
|
}
|
|
962
|
-
var
|
|
963
|
-
function
|
|
964
|
-
return `${
|
|
1047
|
+
var tn = "utxo";
|
|
1048
|
+
function nn(e11, t2) {
|
|
1049
|
+
return `${tn}_${e11.startsWith("resource_") ? e11.slice(9) : e11}_${b(t2)}`;
|
|
965
1050
|
}
|
|
966
|
-
var
|
|
967
|
-
function
|
|
1051
|
+
var rn = 64;
|
|
1052
|
+
function an(e11) {
|
|
968
1053
|
return typeof e11 == "object" && !!e11 && "Utxo" in e11;
|
|
969
1054
|
}
|
|
970
|
-
function
|
|
1055
|
+
function on(e11) {
|
|
971
1056
|
return e11.length > 0 && /^[0-9a-fA-F]+$/.test(e11);
|
|
972
1057
|
}
|
|
973
|
-
function
|
|
1058
|
+
function sn(e11) {
|
|
974
1059
|
let t2 = e11.split("_");
|
|
975
|
-
if (t2.length < 3 || t2[0] !==
|
|
1060
|
+
if (t2.length < 3 || t2[0] !== tn) return null;
|
|
976
1061
|
let n2 = t2[t2.length - 1];
|
|
977
|
-
return n2.length !==
|
|
1062
|
+
return n2.length !== rn || !on(n2) ? null : x(n2);
|
|
978
1063
|
}
|
|
979
|
-
function
|
|
980
|
-
let n2 =
|
|
981
|
-
if (n2 === null || !
|
|
1064
|
+
function cn(e11, t2) {
|
|
1065
|
+
let n2 = H(e11);
|
|
1066
|
+
if (n2 === null || !an(n2)) return null;
|
|
982
1067
|
let r2 = n2.Utxo;
|
|
983
1068
|
if (r2.output === null || r2.is_frozen) return null;
|
|
984
|
-
let i2 =
|
|
1069
|
+
let i2 = sn(t2);
|
|
985
1070
|
return i2 === null ? null : {
|
|
986
1071
|
commitment: i2,
|
|
987
1072
|
body: r2.output.output
|
|
988
1073
|
};
|
|
989
1074
|
}
|
|
990
|
-
var
|
|
991
|
-
constructor(e11, t2, n2 = new
|
|
1075
|
+
var ln = 0, un = class {
|
|
1076
|
+
constructor(e11, t2, n2 = new $t(e11.network())) {
|
|
992
1077
|
__publicField(this, "provider");
|
|
993
1078
|
__publicField(this, "crypto");
|
|
994
1079
|
__publicField(this, "builder");
|
|
995
1080
|
__publicField(this, "state");
|
|
996
1081
|
__publicField(this, "maxEpoch", null);
|
|
997
1082
|
__publicField(this, "prepared", false);
|
|
998
|
-
this.provider = e11, this.crypto = n2, this.builder =
|
|
1083
|
+
this.provider = e11, this.crypto = n2, this.builder = B.new(e11.network(), ln), this.state = {
|
|
999
1084
|
resource: t2,
|
|
1000
1085
|
revealedInput: null,
|
|
1001
1086
|
inputsToSpend: /* @__PURE__ */ new Map(),
|
|
@@ -1037,7 +1122,7 @@ var Vt = 0, Ht = class {
|
|
|
1037
1122
|
return this.builder = e11(this.builder), this;
|
|
1038
1123
|
}
|
|
1039
1124
|
spendStealthInput(e11, t2) {
|
|
1040
|
-
let n2 = new
|
|
1125
|
+
let n2 = new Jt(t2), r2 = b(n2.commitment), i2 = this.state.inputsToSpend.get(r2);
|
|
1041
1126
|
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
1127
|
return this.state.inputsToSpend.set(r2, {
|
|
1043
1128
|
input: n2,
|
|
@@ -1049,7 +1134,7 @@ var Vt = 0, Ht = class {
|
|
|
1049
1134
|
if (this.prepared) throw new v("StealthTransfer.prepare: already prepared \u2014 create a new StealthTransfer to build again");
|
|
1050
1135
|
this.validate(), this.prepared = true;
|
|
1051
1136
|
let { statement: e11, outputMask: t2 } = await this.crypto.generateOutputsStatement(this.state.outputs, this.state.revealedOutput), n2 = new Q(await this.crypto.buildInputsStatement([...this.state.inputsToSpend.values()].map((e12) => e12.input), ((_a = this.state.revealedInput) == null ? void 0 : _a.amount) ?? 0n), e11, void 0);
|
|
1052
|
-
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch ===
|
|
1137
|
+
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch === ln && this.builder.withMaxEpoch(await $e(this.provider));
|
|
1053
1138
|
let r2 = /* @__PURE__ */ new Set();
|
|
1054
1139
|
if (this.state.revealedInput !== null) {
|
|
1055
1140
|
let e12 = this.state.revealedInput.source;
|
|
@@ -1057,20 +1142,20 @@ var Vt = 0, Ht = class {
|
|
|
1057
1142
|
substate_id: e12,
|
|
1058
1143
|
version: null
|
|
1059
1144
|
}), r2.add(e12);
|
|
1060
|
-
let t3 = await
|
|
1145
|
+
let t3 = await _t(this.provider, e12);
|
|
1061
1146
|
for (let e13 of t3) r2.has(e13) || (this.builder.addInput({
|
|
1062
1147
|
substate_id: e13,
|
|
1063
1148
|
version: null
|
|
1064
1149
|
}), r2.add(e13));
|
|
1065
1150
|
}
|
|
1066
1151
|
for (let { input: e12 } of this.state.inputsToSpend.values()) {
|
|
1067
|
-
let t3 =
|
|
1152
|
+
let t3 = nn(this.state.resource, e12.commitment);
|
|
1068
1153
|
r2.has(t3) || (this.builder.addInput({
|
|
1069
1154
|
substate_id: t3,
|
|
1070
1155
|
version: null
|
|
1071
1156
|
}), r2.add(t3));
|
|
1072
1157
|
}
|
|
1073
|
-
let i2 = await
|
|
1158
|
+
let i2 = await q(this.provider, this.builder.buildUnsignedTransaction()), a2 = [...this.state.inputsToSpend.values()], o2 = this.collectRequiredSigners(a2);
|
|
1074
1159
|
return {
|
|
1075
1160
|
unsignedTx: i2,
|
|
1076
1161
|
statement: n2,
|
|
@@ -1103,38 +1188,38 @@ var Vt = 0, Ht = class {
|
|
|
1103
1188
|
t2 !== null && (this.builder.callMethod({
|
|
1104
1189
|
componentAddress: t2.source,
|
|
1105
1190
|
methodName: "withdraw"
|
|
1106
|
-
}, [
|
|
1191
|
+
}, [j(this.state.resource), k(t2.amount)]).saveVar(Tt), n2 = Tt), this.builder.addInstruction(Dt({
|
|
1107
1192
|
resourceAddress: this.state.resource,
|
|
1108
1193
|
revealedInputBucket: n2,
|
|
1109
1194
|
statement: e11
|
|
1110
|
-
}, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutput !== null && t2 !== null && this.builder.saveVar(
|
|
1195
|
+
}, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutput !== null && t2 !== null && this.builder.saveVar(Et).callMethod({
|
|
1111
1196
|
componentAddress: t2.source,
|
|
1112
1197
|
methodName: "deposit"
|
|
1113
|
-
}, [{ Workspace:
|
|
1198
|
+
}, [{ Workspace: Et }]);
|
|
1114
1199
|
}
|
|
1115
1200
|
};
|
|
1116
|
-
function
|
|
1117
|
-
if (
|
|
1201
|
+
function dn(e11) {
|
|
1202
|
+
if (fn(e11) || e11.statementJson !== void 0) return e11.statementJson;
|
|
1118
1203
|
if (e11.inputs.length > 0) throw new _("inputs statement has confidential inputs but no WASM statementJson \u2014 call buildInputsStatement first", { context: "statementJsonFor" });
|
|
1119
1204
|
return JSON.stringify(e11.toJSON());
|
|
1120
1205
|
}
|
|
1121
|
-
function
|
|
1206
|
+
function fn(e11) {
|
|
1122
1207
|
return !("inputs" in e11);
|
|
1123
1208
|
}
|
|
1124
|
-
async function
|
|
1125
|
-
let a2 =
|
|
1209
|
+
async function pn(e11, t2, n2, r2, i2) {
|
|
1210
|
+
let a2 = dn(r2), o2 = dn(i2);
|
|
1126
1211
|
return e11.generateBalanceProofSignature(t2, n2, a2, o2);
|
|
1127
1212
|
}
|
|
1128
|
-
async function
|
|
1213
|
+
async function $(e11, t2, n2, r2) {
|
|
1129
1214
|
let i2 = await e11.deriveAeadKey(r2.viewSecret, r2.senderPublicNonce);
|
|
1130
1215
|
return e11.unblindOutput(t2, n2, i2, r2.skipMemo);
|
|
1131
1216
|
}
|
|
1132
|
-
async function
|
|
1133
|
-
let i2 =
|
|
1217
|
+
async function mn(e11, t2, n2, r2) {
|
|
1218
|
+
let i2 = cn(n2, r2);
|
|
1134
1219
|
if (i2 === null) return null;
|
|
1135
1220
|
let a2 = x(i2.body.encrypted_data), o2 = x(i2.body.public_nonce);
|
|
1136
1221
|
try {
|
|
1137
|
-
return await
|
|
1222
|
+
return await $(e11, i2.commitment, a2, {
|
|
1138
1223
|
senderPublicNonce: o2,
|
|
1139
1224
|
viewSecret: t2,
|
|
1140
1225
|
skipMemo: false
|
|
@@ -1143,33 +1228,33 @@ async function qt(e11, t2, n2, r2) {
|
|
|
1143
1228
|
return null;
|
|
1144
1229
|
}
|
|
1145
1230
|
}
|
|
1146
|
-
async function
|
|
1231
|
+
async function hn(e11, t2, n2) {
|
|
1147
1232
|
if (t2.length === 0) throw new v("generateOutputsStatement: at least one stealth output is required");
|
|
1148
1233
|
let { statement: r2, outputMask: i2 } = await e11.generateOutputsStatement(t2, n2), a2 = await e11.buildInputsStatement([], 0n);
|
|
1149
|
-
return new Q(a2, r2, await
|
|
1234
|
+
return new Q(a2, r2, await pn(e11, X.zero(), i2, a2, r2));
|
|
1150
1235
|
}
|
|
1151
|
-
var
|
|
1236
|
+
var gn = class e10 {
|
|
1152
1237
|
constructor(e11, t2, n2, r2, i2) {
|
|
1153
1238
|
this.wallet = e11, this.spec = t2, this.crypto = n2, this.mustSignWithAccountKey = r2, this.viewSecret = i2;
|
|
1154
1239
|
}
|
|
1155
1240
|
static fromSpec(t2, n2, r2 = {}) {
|
|
1156
|
-
return new e10(t2, n2, r2.crypto ?? new
|
|
1241
|
+
return new e10(t2, n2, r2.crypto ?? new $t(), r2.mustSignWithAccountKey ?? true, r2.viewSecret);
|
|
1157
1242
|
}
|
|
1158
1243
|
async prepare(e11) {
|
|
1159
|
-
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ?
|
|
1244
|
+
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ? X.zero() : await this.crypto.aggregateInputMasks(t2.map((e12) => e12.mask)), r2 = await pn(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);
|
|
1160
1245
|
await this.crypto.validateTransfer(i2);
|
|
1161
|
-
let a2 =
|
|
1246
|
+
let a2 = vn(this.spec.unsignedTx, i2), o2 = this.mustSignWithAccountKey ? await J([this.wallet], a2) : a2, s2 = {
|
|
1162
1247
|
...this.spec,
|
|
1163
|
-
unsignedTx:
|
|
1248
|
+
unsignedTx: o2,
|
|
1164
1249
|
statement: i2
|
|
1165
1250
|
};
|
|
1166
|
-
return new
|
|
1251
|
+
return new _n({
|
|
1167
1252
|
wallet: this.wallet,
|
|
1168
1253
|
crypto: this.crypto,
|
|
1169
|
-
spec:
|
|
1254
|
+
spec: s2,
|
|
1170
1255
|
resolvedInputs: t2,
|
|
1171
1256
|
mustSignWithAccountKey: this.mustSignWithAccountKey,
|
|
1172
|
-
sealKeypair:
|
|
1257
|
+
sealKeypair: Ot()
|
|
1173
1258
|
});
|
|
1174
1259
|
}
|
|
1175
1260
|
async resolveViewSecret() {
|
|
@@ -1194,11 +1279,11 @@ var Yt = class e10 {
|
|
|
1194
1279
|
let t2 = await this.resolveViewSecret(), n2 = this.spec.state.resource, r2 = await Promise.allSettled(this.spec.inputs.map(async ({ input: r3, owner: i3 }) => {
|
|
1195
1280
|
let a2 = b(r3.commitment), o2 = await e11.getStealthUtxo(n2, r3.commitment);
|
|
1196
1281
|
if (o2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input UTXO not found (spent or never created) for ${a2}`);
|
|
1197
|
-
let s2 =
|
|
1282
|
+
let s2 = cn(o2, nn(n2, r3.commitment));
|
|
1198
1283
|
if (s2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input ${a2} is not a live, spendable UTXO`);
|
|
1199
1284
|
let c2 = x(s2.body.public_nonce), l2;
|
|
1200
1285
|
try {
|
|
1201
|
-
l2 = await
|
|
1286
|
+
l2 = await $(this.crypto, s2.commitment, x(s2.body.encrypted_data), {
|
|
1202
1287
|
senderPublicNonce: c2,
|
|
1203
1288
|
viewSecret: t2,
|
|
1204
1289
|
skipMemo: true
|
|
@@ -1213,13 +1298,14 @@ var Yt = class e10 {
|
|
|
1213
1298
|
ownerAddr: i3,
|
|
1214
1299
|
input: r3,
|
|
1215
1300
|
mask: l2.mask,
|
|
1216
|
-
publicNonce: c2
|
|
1301
|
+
publicNonce: c2,
|
|
1302
|
+
viewSecret: t2
|
|
1217
1303
|
};
|
|
1218
1304
|
})), i2 = r2.find((e12) => e12.status === "rejected");
|
|
1219
1305
|
if (i2 !== void 0) throw i2.reason;
|
|
1220
1306
|
return r2.map((e12) => e12.value);
|
|
1221
1307
|
}
|
|
1222
|
-
},
|
|
1308
|
+
}, _n = class {
|
|
1223
1309
|
constructor(e11) {
|
|
1224
1310
|
__publicField(this, "wallet");
|
|
1225
1311
|
__publicField(this, "crypto");
|
|
@@ -1242,12 +1328,15 @@ var Yt = class e10 {
|
|
|
1242
1328
|
}
|
|
1243
1329
|
async computeAuthorizations() {
|
|
1244
1330
|
if (this.resolvedInputs.length === 0) return [];
|
|
1245
|
-
let e11 =
|
|
1331
|
+
let e11 = K(this.spec.unsignedTx), t2 = this.sealKeypair.public_key, n2 = [];
|
|
1246
1332
|
for (let r2 of this.resolvedInputs) {
|
|
1247
1333
|
let i2 = this.wallet.getKeyProvider(r2.ownerAddr);
|
|
1248
1334
|
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
1335
|
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, {
|
|
1336
|
+
let a2 = await i2.addStealthSignature(e11, r2.publicNonce, t2, {
|
|
1337
|
+
crypto: this.crypto,
|
|
1338
|
+
viewSecret: r2.viewSecret
|
|
1339
|
+
});
|
|
1251
1340
|
n2.push({
|
|
1252
1341
|
signerAddress: r2.ownerAddr,
|
|
1253
1342
|
signatures: [a2]
|
|
@@ -1262,23 +1351,23 @@ var Yt = class e10 {
|
|
|
1262
1351
|
let e11 = (await this.createAuthorizations()).flatMap((e12) => e12.signatures), t2 = [];
|
|
1263
1352
|
this.mustSignWithAccountKey && t2.push(this.wallet);
|
|
1264
1353
|
let n2 = [...e11, ...this.extraSignatures];
|
|
1265
|
-
return n2.length > 0 && t2.push(new
|
|
1354
|
+
return n2.length > 0 && t2.push(new yn(n2)), Y(await jt(t2, this.spec.unsignedTx, this.sealKeypair));
|
|
1266
1355
|
}
|
|
1267
1356
|
};
|
|
1268
|
-
function
|
|
1269
|
-
let n2 = e11.instructions.findIndex(
|
|
1357
|
+
function vn(e11, t2) {
|
|
1358
|
+
let n2 = e11.instructions.findIndex(G);
|
|
1270
1359
|
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(
|
|
1360
|
+
if (e11.instructions.slice(n2 + 1).findIndex(G) >= 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found more than one (malformed)");
|
|
1272
1361
|
let r2 = { StealthTransfer: {
|
|
1273
1362
|
...e11.instructions[n2].StealthTransfer,
|
|
1274
|
-
statement:
|
|
1363
|
+
statement: W(t2)
|
|
1275
1364
|
} }, i2 = [...e11.instructions];
|
|
1276
1365
|
return i2[n2] = r2, {
|
|
1277
1366
|
...e11,
|
|
1278
1367
|
instructions: i2
|
|
1279
1368
|
};
|
|
1280
1369
|
}
|
|
1281
|
-
var
|
|
1370
|
+
var yn = class {
|
|
1282
1371
|
constructor(e11) {
|
|
1283
1372
|
this.signatures = e11;
|
|
1284
1373
|
}
|
|
@@ -1293,88 +1382,96 @@ var Qt = class {
|
|
|
1293
1382
|
}
|
|
1294
1383
|
};
|
|
1295
1384
|
export {
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1385
|
+
zt as AccountInvokeBuilder,
|
|
1386
|
+
_n as AuthorizedTransfer,
|
|
1387
|
+
Z as BalanceProofSignature,
|
|
1299
1388
|
_ as CryptoBridgeError,
|
|
1300
|
-
|
|
1389
|
+
Qe as DEFAULT_TRANSACTION_VALIDITY_EPOCHS,
|
|
1301
1390
|
h as DefaultSignerNotSetError,
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1391
|
+
Ut as EncryptedData,
|
|
1392
|
+
Lt as ExternalKeySigner,
|
|
1393
|
+
Bt as FaucetInvokeBuilder,
|
|
1394
|
+
pe as IndexerClientError,
|
|
1305
1395
|
v as InvalidArgumentError,
|
|
1306
1396
|
m as KeyProviderNotFoundError,
|
|
1307
|
-
|
|
1308
|
-
|
|
1397
|
+
Ze as MAX_TRANSACTION_VALIDITY_EPOCHS,
|
|
1398
|
+
X as Mask,
|
|
1309
1399
|
u as Network,
|
|
1310
1400
|
d as OotleError,
|
|
1311
|
-
|
|
1312
|
-
|
|
1401
|
+
Vt as OotleWallet,
|
|
1402
|
+
he as OperationCancelledError,
|
|
1313
1403
|
g as SignerError,
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1404
|
+
Jt as StealthInput,
|
|
1405
|
+
Yt as StealthInputsStatement,
|
|
1406
|
+
Xt as StealthOutputsStatement,
|
|
1407
|
+
un as StealthTransfer,
|
|
1318
1408
|
Q as StealthTransferStatement,
|
|
1319
|
-
|
|
1320
|
-
|
|
1409
|
+
bt as TARI_RESOURCE_ADDRESS,
|
|
1410
|
+
B as TransactionBuilder,
|
|
1321
1411
|
f as TransactionRejectedError,
|
|
1322
|
-
|
|
1412
|
+
me as TransactionTimeoutError,
|
|
1323
1413
|
p as WalletError,
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1414
|
+
gn as WalletStealthAuthorizer,
|
|
1415
|
+
$t as WasmStealthCrypto,
|
|
1416
|
+
Ct as XTR_FAUCET_CLAIM_RESOURCE_ADDRESS,
|
|
1417
|
+
xt as XTR_FAUCET_COMPONENT_ADDRESS,
|
|
1418
|
+
St as XTR_FAUCET_VAULT_ADDRESS,
|
|
1419
|
+
k as amountLiteral,
|
|
1330
1420
|
y as assertByteLength,
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1421
|
+
ge as assertUnreachable,
|
|
1422
|
+
Fe as boolLiteral,
|
|
1423
|
+
kt as buildTransactionSignature,
|
|
1424
|
+
A as bytesLiteral,
|
|
1425
|
+
Be as claimedOutputTombstoneAddressLiteral,
|
|
1426
|
+
Nt as classifyOutcome,
|
|
1427
|
+
sn as commitmentOf,
|
|
1428
|
+
Ie as componentAddressLiteral,
|
|
1429
|
+
Gt as createOutput,
|
|
1430
|
+
dt as decodeEvent,
|
|
1431
|
+
lt as decodeExecuteResult,
|
|
1432
|
+
ft as decodeResource,
|
|
1433
|
+
ct as decodeSubstateValue,
|
|
1434
|
+
ut as decodeTransactionReceipt,
|
|
1435
|
+
pt as decodeUtxo,
|
|
1436
|
+
$ as decryptInputData,
|
|
1437
|
+
mn as decryptOwnedUtxo,
|
|
1438
|
+
st as defaultIndexerUrl,
|
|
1343
1439
|
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
|
-
|
|
1440
|
+
hn as generateOutputsStatement,
|
|
1441
|
+
Ot as generateSealKeypair,
|
|
1442
|
+
_t as getVaultIdsForAccount,
|
|
1443
|
+
Ne as intLiteral,
|
|
1444
|
+
G as isStealthTransferInstruction,
|
|
1445
|
+
gt as iterVaultIdsInState,
|
|
1446
|
+
je as literalArg,
|
|
1447
|
+
Le as metadataLiteral,
|
|
1448
|
+
R as microTariLiteral,
|
|
1449
|
+
Ye as microTariString,
|
|
1450
|
+
Ue as nonFungibleAddressLiteral,
|
|
1451
|
+
cn as parseSubstateUtxo,
|
|
1452
|
+
Xe as parseWorkspaceStringKey,
|
|
1453
|
+
vn as patchStealthStatement,
|
|
1454
|
+
He as publicKeyLiteral,
|
|
1455
|
+
J as resolveMainSigner,
|
|
1456
|
+
$e as resolveMaxEpoch,
|
|
1457
|
+
q as resolveTransaction,
|
|
1458
|
+
j as resourceAddressLiteral,
|
|
1459
|
+
Y as sealTransaction,
|
|
1460
|
+
It as sendDryRun,
|
|
1461
|
+
Ft as sendTransaction,
|
|
1462
|
+
K as serializeUnsignedTx,
|
|
1463
|
+
pn as signBalanceProof,
|
|
1464
|
+
At as signTransaction,
|
|
1465
|
+
W as statementAsWire,
|
|
1466
|
+
Dt as stealthTransferInstruction,
|
|
1467
|
+
nn as stealthUtxoSubstateId,
|
|
1468
|
+
Pe as stringLiteral,
|
|
1469
|
+
Mt as submitTransaction,
|
|
1470
|
+
ze as templateAddressLiteral,
|
|
1374
1471
|
b as toHexStr,
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1472
|
+
H as upSubstateValue,
|
|
1473
|
+
We as utxoAddressLiteral,
|
|
1474
|
+
Ve as validatorFeePoolAddressLiteral,
|
|
1475
|
+
Re as vaultIdLiteral,
|
|
1476
|
+
Pt as watchTransaction
|
|
1380
1477
|
};
|