@tari-project/ootle 0.17.0 → 0.19.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 +138 -11
- package/dist/index.js +521 -444
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
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, 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
|
|
5
|
-
import { decodeEvent as
|
|
6
|
-
|
|
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 u, parseOotleAddress as d, sealTransaction as ee, stealthDhSecret as te, unblindOutput as ne, validateBalanceProofSignature as re, validateStealthTransfer as ie } from "@tari-project/ootle-wasm";
|
|
5
|
+
import { decodeEvent as ae, decodeExecuteResult as oe, decodeResource as se, decodeSubstateValue as ce, decodeTransactionReceipt as le, decodeUtxo as ue } from "@tari-project/ootle-wasm-bor";
|
|
6
|
+
import { transactionBody as de, transactionSchemaVersion as fe } from "@tari-project/ootle-ts-bindings";
|
|
7
|
+
var f = /* @__PURE__ */ (function(e11) {
|
|
7
8
|
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;
|
|
8
|
-
})({}),
|
|
9
|
+
})({}), p = class extends Error {
|
|
9
10
|
constructor(e11, t2) {
|
|
10
11
|
super(e11, t2), this.name = new.target.name;
|
|
11
12
|
}
|
|
12
|
-
}, pe = class extends
|
|
13
|
+
}, pe = class extends p {
|
|
13
14
|
constructor(e11, t2) {
|
|
14
15
|
super(e11, t2);
|
|
15
16
|
__publicField(this, "status");
|
|
@@ -17,7 +18,7 @@ var u = /* @__PURE__ */ (function(e11) {
|
|
|
17
18
|
__publicField(this, "url");
|
|
18
19
|
this.status = t2 == null ? void 0 : t2.status, this.body = t2 == null ? void 0 : t2.body, this.url = t2 == null ? void 0 : t2.url;
|
|
19
20
|
}
|
|
20
|
-
},
|
|
21
|
+
}, m = class extends p {
|
|
21
22
|
constructor(e11, t2) {
|
|
22
23
|
super(e11, t2);
|
|
23
24
|
__publicField(this, "txId");
|
|
@@ -25,224 +26,224 @@ var u = /* @__PURE__ */ (function(e11) {
|
|
|
25
26
|
__publicField(this, "rejectReason");
|
|
26
27
|
this.txId = t2.txId, this.reason = t2.reason, this.rejectReason = t2.rejectReason;
|
|
27
28
|
}
|
|
28
|
-
}, me = class extends
|
|
29
|
+
}, me = class extends p {
|
|
29
30
|
constructor(e11, t2) {
|
|
30
31
|
super(e11, t2);
|
|
31
32
|
__publicField(this, "txId");
|
|
32
33
|
this.txId = t2.txId;
|
|
33
34
|
}
|
|
34
|
-
},
|
|
35
|
-
},
|
|
35
|
+
}, h = class extends p {
|
|
36
|
+
}, g = class extends h {
|
|
36
37
|
constructor(e11, t2) {
|
|
37
38
|
super(e11, t2);
|
|
38
39
|
__publicField(this, "address");
|
|
39
40
|
this.address = t2.address;
|
|
40
41
|
}
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
42
|
+
}, _ = class extends h {
|
|
43
|
+
}, v = class extends p {
|
|
44
|
+
}, y = class extends p {
|
|
44
45
|
constructor(e11, t2) {
|
|
45
46
|
super(e11, t2);
|
|
46
47
|
__publicField(this, "context");
|
|
47
48
|
this.context = t2 == null ? void 0 : t2.context;
|
|
48
49
|
}
|
|
49
|
-
},
|
|
50
|
-
}, he = class extends
|
|
50
|
+
}, b = class extends p {
|
|
51
|
+
}, he = class extends p {
|
|
51
52
|
};
|
|
52
53
|
function ge(e11, t2) {
|
|
53
|
-
throw new
|
|
54
|
+
throw new b(`assertUnreachable${t2 ? ` (${t2})` : ""}: ${JSON.stringify(e11)}`);
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
-
if (e11.length !== t2) throw new
|
|
56
|
+
function x(e11, t2, n2) {
|
|
57
|
+
if (e11.length !== t2) throw new b(`${n2} must be ${t2} bytes, got ${e11.length}`);
|
|
57
58
|
return e11;
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
+
function S(e11) {
|
|
60
61
|
return Array.from(e11, (e12) => e12.toString(16).padStart(2, "0")).join("");
|
|
61
62
|
}
|
|
62
63
|
var _e = /^[0-9a-fA-F]*$/;
|
|
63
|
-
function
|
|
64
|
-
if (e11.length % 2 != 0) throw new
|
|
65
|
-
if (!_e.test(e11)) throw new
|
|
64
|
+
function C(e11) {
|
|
65
|
+
if (e11.length % 2 != 0) throw new b(`fromHexStr: hex string must have even length, got ${e11.length}`);
|
|
66
|
+
if (!_e.test(e11)) throw new b("fromHexStr: hex string contains non-hex characters");
|
|
66
67
|
let t2 = new Uint8Array(e11.length / 2);
|
|
67
68
|
for (let n2 = 0; n2 < t2.length; n2++) t2[n2] = parseInt(e11.substring(n2 * 2, n2 * 2 + 2), 16);
|
|
68
69
|
return t2;
|
|
69
70
|
}
|
|
70
|
-
var
|
|
71
|
+
var w = (1n << 64n) - 1n, ve = 2n, T = 32, ye = T * 2, be = 32, xe = 128, Se = 129, Ce = 130, E = 131, we = 132, Te = 136, Ee = 138, De = 141, D = 0, Oe = 32, O = 64, ke = 96, k = 128, Ae = 160, A = 192;
|
|
71
72
|
function je(e11) {
|
|
72
73
|
switch (typeof e11) {
|
|
73
74
|
case "bigint":
|
|
74
|
-
return
|
|
75
|
+
return j(e11);
|
|
75
76
|
case "string":
|
|
76
77
|
return Pe(e11);
|
|
77
78
|
case "boolean":
|
|
78
79
|
return Fe(e11);
|
|
79
80
|
default:
|
|
80
|
-
if (e11 instanceof Uint8Array) return
|
|
81
|
-
throw new
|
|
81
|
+
if (e11 instanceof Uint8Array) return M(e11);
|
|
82
|
+
throw new b(`literalArg: cannot CBOR-encode value of type ${typeof e11}`);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
|
-
function
|
|
85
|
-
if (e11 < 0n) throw new
|
|
86
|
-
if (e11 >> 128n != 0n) throw new
|
|
85
|
+
function j(e11) {
|
|
86
|
+
if (e11 < 0n) throw new b(`amountLiteral: amount must be non-negative, got ${e11}`);
|
|
87
|
+
if (e11 >> 128n != 0n) throw new b(`amountLiteral: amount overflows u128: ${e11}`);
|
|
87
88
|
let t2 = [];
|
|
88
|
-
return e11 <=
|
|
89
|
+
return e11 <= w ? L(t2, D, e11) : Me(t2, e11), R(t2);
|
|
89
90
|
}
|
|
90
91
|
function Me(e11, t2) {
|
|
91
92
|
let n2 = [], r2 = t2;
|
|
92
93
|
for (; r2 > 0n; ) n2.unshift(Number(r2 & 255n)), r2 >>= 8n;
|
|
93
|
-
|
|
94
|
+
L(e11, A, ve), L(e11, O, BigInt(n2.length)), I(e11, n2);
|
|
94
95
|
}
|
|
95
96
|
function Ne(e11) {
|
|
96
97
|
let t2 = [];
|
|
97
98
|
if (e11 >= 0n) {
|
|
98
|
-
if (e11 >
|
|
99
|
-
|
|
99
|
+
if (e11 > w) throw new b(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
|
|
100
|
+
L(t2, D, e11);
|
|
100
101
|
} else {
|
|
101
102
|
let n2 = -1n - e11;
|
|
102
|
-
if (n2 >
|
|
103
|
-
|
|
103
|
+
if (n2 > w) throw new b(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
|
|
104
|
+
L(t2, Oe, n2);
|
|
104
105
|
}
|
|
105
|
-
return
|
|
106
|
+
return R(t2);
|
|
106
107
|
}
|
|
107
108
|
function Pe(e11) {
|
|
108
109
|
let t2 = [];
|
|
109
|
-
return
|
|
110
|
+
return F(t2, e11), R(t2);
|
|
110
111
|
}
|
|
111
|
-
function
|
|
112
|
+
function M(e11) {
|
|
112
113
|
let t2 = [];
|
|
113
|
-
return
|
|
114
|
+
return L(t2, O, BigInt(e11.length)), I(t2, e11), R(t2);
|
|
114
115
|
}
|
|
115
116
|
function Fe(e11) {
|
|
116
117
|
return { Literal: e11 ? "f5" : "f4" };
|
|
117
118
|
}
|
|
118
|
-
function
|
|
119
|
-
return
|
|
119
|
+
function N(e11) {
|
|
120
|
+
return P(E, e11, "resource_");
|
|
120
121
|
}
|
|
121
122
|
function Ie(e11) {
|
|
122
|
-
return
|
|
123
|
+
return P(xe, e11, "component_");
|
|
123
124
|
}
|
|
124
125
|
function Le(e11) {
|
|
125
|
-
let t2 = e11 instanceof Map ? e11 : new Map(Object.entries(e11)), n2 = new TextEncoder(), r2 = [...t2.entries()].sort(([e12], [t3]) =>
|
|
126
|
-
|
|
127
|
-
for (let [e12, t3] of r2)
|
|
128
|
-
return
|
|
126
|
+
let t2 = e11 instanceof Map ? e11 : new Map(Object.entries(e11)), n2 = new TextEncoder(), r2 = [...t2.entries()].sort(([e12], [t3]) => Ye(n2.encode(e12), n2.encode(t3))), i2 = [];
|
|
127
|
+
L(i2, A, BigInt(Se)), L(i2, Ae, BigInt(r2.length));
|
|
128
|
+
for (let [e12, t3] of r2) F(i2, e12), F(i2, t3);
|
|
129
|
+
return R(i2);
|
|
129
130
|
}
|
|
130
131
|
function Re(e11) {
|
|
131
|
-
return
|
|
132
|
+
return P(we, e11, "vault_");
|
|
132
133
|
}
|
|
133
134
|
function ze(e11) {
|
|
134
|
-
return
|
|
135
|
+
return M(Ke(e11, "template_"));
|
|
135
136
|
}
|
|
136
137
|
function Be(e11) {
|
|
137
|
-
return
|
|
138
|
+
return P(Te, e11, "tombstone_");
|
|
138
139
|
}
|
|
139
140
|
function Ve(e11) {
|
|
140
|
-
return
|
|
141
|
+
return P(Ee, e11, "vnfp_");
|
|
141
142
|
}
|
|
142
143
|
function He(e11) {
|
|
143
|
-
let t2 = typeof e11 == "string" ?
|
|
144
|
-
return
|
|
144
|
+
let t2 = typeof e11 == "string" ? C(e11) : e11;
|
|
145
|
+
return x(t2, be, "publicKeyLiteral"), M(t2);
|
|
145
146
|
}
|
|
146
147
|
function Ue(e11) {
|
|
147
148
|
let t2 = [];
|
|
148
|
-
return
|
|
149
|
+
return L(t2, A, BigInt(Ce)), L(t2, k, 2n), Ge(t2, E, e11.resource_address, "resource_"), qe(t2, e11.id), R(t2);
|
|
149
150
|
}
|
|
150
151
|
function We(e11) {
|
|
151
152
|
let t2 = [];
|
|
152
|
-
|
|
153
|
-
let n2 =
|
|
154
|
-
return
|
|
153
|
+
L(t2, A, BigInt(De)), L(t2, k, 2n), Ge(t2, E, e11.resource_address, "resource_");
|
|
154
|
+
let n2 = C(e11.id);
|
|
155
|
+
return x(n2, T, "utxoAddressLiteral: id"), L(t2, O, BigInt(T)), I(t2, n2), R(t2);
|
|
155
156
|
}
|
|
156
|
-
function
|
|
157
|
+
function P(e11, t2, n2) {
|
|
157
158
|
let r2 = [];
|
|
158
|
-
return
|
|
159
|
-
}
|
|
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);
|
|
159
|
+
return Ge(r2, e11, t2, n2), R(r2);
|
|
163
160
|
}
|
|
164
|
-
function Ge(e11, t2) {
|
|
165
|
-
let
|
|
166
|
-
|
|
167
|
-
return x(n2);
|
|
161
|
+
function Ge(e11, t2, n2, r2) {
|
|
162
|
+
let i2 = Ke(n2, r2);
|
|
163
|
+
L(e11, A, BigInt(t2)), L(e11, O, BigInt(T)), I(e11, i2);
|
|
168
164
|
}
|
|
169
165
|
function Ke(e11, t2) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (
|
|
181
|
-
if (
|
|
166
|
+
let n2 = e11.startsWith(t2) ? e11.slice(t2.length) : e11;
|
|
167
|
+
if (n2.length !== ye) throw new b(`${t2}address must be 32 bytes (${ye} hex chars), got ${n2.length}`);
|
|
168
|
+
return C(n2);
|
|
169
|
+
}
|
|
170
|
+
function qe(e11, t2) {
|
|
171
|
+
if (L(e11, k, 2n), "U256" in t2) {
|
|
172
|
+
L(e11, D, 0n), L(e11, k, 1n);
|
|
173
|
+
let n2 = C(t2.U256);
|
|
174
|
+
x(n2, T, "NonFungibleId.U256"), L(e11, O, BigInt(T)), I(e11, n2);
|
|
175
|
+
} else if ("String" in t2) L(e11, D, 1n), L(e11, k, 1n), F(e11, t2.String);
|
|
176
|
+
else if ("Uint32" in t2) L(e11, D, 2n), L(e11, k, 1n), Je(e11, t2.Uint32, "NonFungibleId.Uint32", (1n << 32n) - 1n);
|
|
177
|
+
else if ("Uint64" in t2) L(e11, D, 3n), L(e11, k, 1n), Je(e11, t2.Uint64, "NonFungibleId.Uint64", w);
|
|
178
|
+
else throw new b(`nonFungibleAddressLiteral: unrecognised NonFungibleId variant: ${JSON.stringify(t2)}`);
|
|
179
|
+
}
|
|
180
|
+
function Je(e11, t2, n2, r2) {
|
|
181
|
+
if (!Number.isInteger(t2) || t2 < 0) throw new b(`${n2} must be a non-negative integer, got ${t2}`);
|
|
182
|
+
if (r2 > BigInt(2 ** 53 - 1) && t2 > 2 ** 53 - 1) throw new b(`${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.`);
|
|
182
183
|
let i2 = BigInt(t2);
|
|
183
|
-
if (i2 > r2) throw new
|
|
184
|
-
|
|
184
|
+
if (i2 > r2) throw new b(`${n2} value ${t2} exceeds its maximum of ${r2}`);
|
|
185
|
+
L(e11, D, i2);
|
|
185
186
|
}
|
|
186
|
-
function
|
|
187
|
+
function F(e11, t2) {
|
|
187
188
|
let n2 = new TextEncoder().encode(t2);
|
|
188
|
-
|
|
189
|
+
L(e11, ke, BigInt(n2.length)), I(e11, n2);
|
|
189
190
|
}
|
|
190
|
-
function
|
|
191
|
+
function I(e11, t2) {
|
|
191
192
|
let n2 = e11.length;
|
|
192
193
|
e11.length = n2 + t2.length;
|
|
193
194
|
for (let r2 = 0; r2 < t2.length; r2++) e11[n2 + r2] = t2[r2];
|
|
194
195
|
}
|
|
195
|
-
function
|
|
196
|
+
function Ye(e11, t2) {
|
|
196
197
|
let n2 = Math.min(e11.length, t2.length);
|
|
197
198
|
for (let r2 = 0; r2 < n2; r2++) if (e11[r2] !== t2[r2]) return e11[r2] < t2[r2] ? -1 : 1;
|
|
198
199
|
return e11.length - t2.length;
|
|
199
200
|
}
|
|
200
|
-
function
|
|
201
|
+
function L(e11, t2, n2) {
|
|
201
202
|
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));
|
|
202
203
|
}
|
|
203
|
-
function L(e11) {
|
|
204
|
-
return { Literal: b(Uint8Array.from(e11)) };
|
|
205
|
-
}
|
|
206
204
|
function R(e11) {
|
|
207
|
-
return
|
|
205
|
+
return { Literal: S(Uint8Array.from(e11)) };
|
|
208
206
|
}
|
|
209
|
-
function
|
|
210
|
-
|
|
211
|
-
return e11.toString();
|
|
207
|
+
function z(e11) {
|
|
208
|
+
return j(e11);
|
|
212
209
|
}
|
|
213
210
|
function Xe(e11) {
|
|
211
|
+
if (e11 < 0n) throw new b(`microTariString: amount must be non-negative, got ${e11}`);
|
|
212
|
+
return e11.toString();
|
|
213
|
+
}
|
|
214
|
+
function Ze(e11) {
|
|
214
215
|
let t2 = e11.split(".");
|
|
215
|
-
if (t2.length > 2) throw new
|
|
216
|
+
if (t2.length > 2) throw new b("Invalid workspace key format. Only one dot is allowed.");
|
|
216
217
|
let n2 = t2[0];
|
|
217
218
|
if (t2[1] === void 0) return {
|
|
218
219
|
name: n2,
|
|
219
220
|
offset: null
|
|
220
221
|
};
|
|
221
222
|
let r2 = Number.parseInt(t2[1], 10);
|
|
222
|
-
if (Number.isNaN(r2) || r2 < 0 || String(r2) !== t2[1]) throw new
|
|
223
|
+
if (Number.isNaN(r2) || r2 < 0 || String(r2) !== t2[1]) throw new b(`Invalid workspace key offset: "${t2[1]}"`);
|
|
223
224
|
return {
|
|
224
225
|
name: n2,
|
|
225
226
|
offset: r2
|
|
226
227
|
};
|
|
227
228
|
}
|
|
228
|
-
var
|
|
229
|
-
async function
|
|
230
|
-
if (!Number.isInteger(t2) || t2 < 1) throw new
|
|
231
|
-
if (t2 > 2160) throw new
|
|
229
|
+
var Qe = 2160, $e = 10;
|
|
230
|
+
async function et(e11, t2 = 10) {
|
|
231
|
+
if (!Number.isInteger(t2) || t2 < 1) throw new b(`resolveMaxEpoch: leadEpochs must be a positive integer, got ${t2}`);
|
|
232
|
+
if (t2 > 2160) throw new b(`resolveMaxEpoch: leadEpochs ${t2} exceeds the network's maximum validity window of ${Qe} epochs`);
|
|
232
233
|
return await e11.getCurrentEpoch() + t2;
|
|
233
234
|
}
|
|
234
|
-
var
|
|
235
|
-
function
|
|
236
|
-
if (!Number.isInteger(e11) || e11 < 0) throw new
|
|
235
|
+
var tt = (1n << 64n) - 1n;
|
|
236
|
+
function B(e11, t2) {
|
|
237
|
+
if (!Number.isInteger(e11) || e11 < 0) throw new b(`${t2} must be a non-negative integer epoch, got ${e11}`);
|
|
237
238
|
return e11;
|
|
238
239
|
}
|
|
239
|
-
function
|
|
240
|
+
function nt(e11) {
|
|
240
241
|
return e11.startsWith("template_") ? e11.slice(9) : e11;
|
|
241
242
|
}
|
|
242
|
-
function
|
|
243
|
+
function rt(e11) {
|
|
243
244
|
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;
|
|
244
245
|
}
|
|
245
|
-
var
|
|
246
|
+
var it = class {
|
|
246
247
|
constructor() {
|
|
247
248
|
__publicField(this, "nextId", 0);
|
|
248
249
|
__publicField(this, "ids", /* @__PURE__ */ new Map());
|
|
@@ -266,15 +267,15 @@ var rt = class {
|
|
|
266
267
|
resetFrom(e11) {
|
|
267
268
|
this.reset();
|
|
268
269
|
for (let t2 of e11) {
|
|
269
|
-
let e12 =
|
|
270
|
+
let e12 = rt(t2);
|
|
270
271
|
e12 !== null && this.observeAllocated(e12);
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
};
|
|
274
|
-
function
|
|
275
|
-
return new
|
|
275
|
+
function at(e11) {
|
|
276
|
+
return new b(`No workspace variable named "${e11}" has been defined. Call builder.saveVar(${JSON.stringify(e11)}) on a preceding instruction whose output you want to reference.`);
|
|
276
277
|
}
|
|
277
|
-
var
|
|
278
|
+
var V = class e2 {
|
|
278
279
|
constructor(e11, t2) {
|
|
279
280
|
__publicField(this, "unsignedTransaction");
|
|
280
281
|
__publicField(this, "workspaceIds");
|
|
@@ -285,12 +286,12 @@ var B = class e2 {
|
|
|
285
286
|
instructions: [],
|
|
286
287
|
inputs: [],
|
|
287
288
|
min_epoch: null,
|
|
288
|
-
max_epoch:
|
|
289
|
+
max_epoch: B(t2, "maxEpoch"),
|
|
289
290
|
dry_run: false,
|
|
290
291
|
main_signer: "None",
|
|
291
292
|
blobs: [],
|
|
292
293
|
nonce: 0
|
|
293
|
-
}, this.workspaceIds = new
|
|
294
|
+
}, this.workspaceIds = new it(), this.feeWorkspaceIds = new it();
|
|
294
295
|
}
|
|
295
296
|
static new(t2, n2) {
|
|
296
297
|
return new e2(t2, n2);
|
|
@@ -298,7 +299,7 @@ var B = class e2 {
|
|
|
298
299
|
callFunction(e11, t2) {
|
|
299
300
|
let n2 = this.resolveArgs(t2);
|
|
300
301
|
return this.addInstruction({ CallFunction: {
|
|
301
|
-
address:
|
|
302
|
+
address: nt(e11.templateAddress),
|
|
302
303
|
function: e11.functionName,
|
|
303
304
|
args: n2
|
|
304
305
|
} });
|
|
@@ -307,7 +308,7 @@ var B = class e2 {
|
|
|
307
308
|
let n2;
|
|
308
309
|
if (e11.componentAddress) n2 = { Address: e11.componentAddress };
|
|
309
310
|
else if (e11.fromWorkspace) n2 = { Workspace: this.requireNamedId(e11.fromWorkspace) };
|
|
310
|
-
else throw new
|
|
311
|
+
else throw new b("callMethod requires either `componentAddress` or `fromWorkspace` to be set on the method definition. Use `fromWorkspace` to call a method on a component returned by a previous saveVar; use `componentAddress` for an on-chain component.");
|
|
311
312
|
let r2 = this.resolveArgs(t2);
|
|
312
313
|
return this.addInstruction({ CallMethod: {
|
|
313
314
|
call: n2,
|
|
@@ -328,12 +329,24 @@ var B = class e2 {
|
|
|
328
329
|
return this.addInstruction({ CallMethod: {
|
|
329
330
|
call: { Address: e11 },
|
|
330
331
|
method: "create_proof_for_resource",
|
|
331
|
-
args: [
|
|
332
|
+
args: [N(t2)]
|
|
332
333
|
} });
|
|
333
334
|
}
|
|
334
335
|
claimBurn(e11) {
|
|
335
336
|
return this.addInstruction({ ClaimBurn: { claim: e11 } });
|
|
336
337
|
}
|
|
338
|
+
setComponentAccessRules(e11, t2) {
|
|
339
|
+
return this.addInstruction({ SetComponentAccessRules: {
|
|
340
|
+
component: { Address: e11 },
|
|
341
|
+
access_rules: t2
|
|
342
|
+
} });
|
|
343
|
+
}
|
|
344
|
+
setComponentOwnerRule(e11, t2) {
|
|
345
|
+
return this.addInstruction({ SetComponentOwnerRule: {
|
|
346
|
+
component: { Address: e11 },
|
|
347
|
+
owner_rule: t2
|
|
348
|
+
} });
|
|
349
|
+
}
|
|
337
350
|
allocateAddress(e11, t2) {
|
|
338
351
|
let n2 = this.addNamedId(t2);
|
|
339
352
|
return this.addInstruction({ AllocateAddress: {
|
|
@@ -349,11 +362,11 @@ var B = class e2 {
|
|
|
349
362
|
return this.addFeeInstruction({ CallMethod: {
|
|
350
363
|
call: { Address: e11 },
|
|
351
364
|
method: "pay_fee",
|
|
352
|
-
args: [
|
|
365
|
+
args: [z(t2)]
|
|
353
366
|
} });
|
|
354
367
|
}
|
|
355
368
|
feeTransactionPayFromComponentConfidential(e11, t2) {
|
|
356
|
-
throw new
|
|
369
|
+
throw new b("feeTransactionPayFromComponentConfidential is not implemented: a ConfidentialWithdrawProof Literal must be tari_bor-CBOR-encoded, which the TS SDK does not yet support.");
|
|
357
370
|
}
|
|
358
371
|
dropAllProofsInWorkspace() {
|
|
359
372
|
return this.addInstruction("DropAllProofsInWorkspace");
|
|
@@ -389,7 +402,7 @@ var B = class e2 {
|
|
|
389
402
|
}
|
|
390
403
|
observeAllocations(e11, t2) {
|
|
391
404
|
for (let n2 of t2) {
|
|
392
|
-
let t3 =
|
|
405
|
+
let t3 = rt(n2);
|
|
393
406
|
t3 !== null && e11.observeAllocated(t3);
|
|
394
407
|
}
|
|
395
408
|
}
|
|
@@ -398,24 +411,24 @@ var B = class e2 {
|
|
|
398
411
|
return this.unsignedTransaction.fee_instructions = n2.unsignedTransaction.instructions, this.feeWorkspaceIds.resetFrom(this.unsignedTransaction.fee_instructions), this;
|
|
399
412
|
}
|
|
400
413
|
addInput(e11) {
|
|
401
|
-
return this.unsignedTransaction.inputs.push(
|
|
414
|
+
return this.unsignedTransaction.inputs.push(ot(e11)), this;
|
|
402
415
|
}
|
|
403
416
|
withInputs(e11) {
|
|
404
|
-
return this.unsignedTransaction.inputs.push(...e11.map(
|
|
417
|
+
return this.unsignedTransaction.inputs.push(...e11.map(ot)), this;
|
|
405
418
|
}
|
|
406
419
|
withMainSigner(e11) {
|
|
407
420
|
return this.unsignedTransaction.main_signer = e11, this;
|
|
408
421
|
}
|
|
409
422
|
withMinEpoch(e11) {
|
|
410
|
-
return this.unsignedTransaction.min_epoch =
|
|
423
|
+
return this.unsignedTransaction.min_epoch = B(e11, "minEpoch"), this;
|
|
411
424
|
}
|
|
412
425
|
withMaxEpoch(e11) {
|
|
413
|
-
return this.unsignedTransaction.max_epoch =
|
|
426
|
+
return this.unsignedTransaction.max_epoch = B(e11, "maxEpoch"), this;
|
|
414
427
|
}
|
|
415
428
|
withNonce(e11) {
|
|
416
|
-
if (typeof e11 == "number" && !Number.isInteger(e11)) throw new
|
|
429
|
+
if (typeof e11 == "number" && !Number.isInteger(e11)) throw new b(`withNonce: nonce must be an integer, got ${e11}`);
|
|
417
430
|
let t2 = typeof e11 == "bigint" ? e11 : BigInt(e11);
|
|
418
|
-
if (t2 < 0n || t2 >
|
|
431
|
+
if (t2 < 0n || t2 > tt) throw new b(`withNonce: nonce must fit an unsigned 64-bit integer, got ${e11}`);
|
|
419
432
|
return this.unsignedTransaction.nonce = t2 > BigInt(2 ** 53 - 1) ? t2 : Number(t2), this;
|
|
420
433
|
}
|
|
421
434
|
withUnsignedTransaction(e11) {
|
|
@@ -426,7 +439,7 @@ var B = class e2 {
|
|
|
426
439
|
inputs: [...e11.inputs],
|
|
427
440
|
blobs: [...e11.blobs ?? []],
|
|
428
441
|
nonce: e11.nonce ?? 0,
|
|
429
|
-
max_epoch:
|
|
442
|
+
max_epoch: B(e11.max_epoch, "withUnsignedTransaction: max_epoch")
|
|
430
443
|
}, this.workspaceIds.resetFrom(this.unsignedTransaction.instructions), this.feeWorkspaceIds.resetFrom(this.unsignedTransaction.fee_instructions), this;
|
|
431
444
|
}
|
|
432
445
|
resolveWorkspaceOffsetId(e11) {
|
|
@@ -446,11 +459,11 @@ var B = class e2 {
|
|
|
446
459
|
}
|
|
447
460
|
requireNamedId(e11) {
|
|
448
461
|
let t2 = this.workspaceIds.get(e11);
|
|
449
|
-
if (t2 === void 0) throw
|
|
462
|
+
if (t2 === void 0) throw at(e11);
|
|
450
463
|
return t2;
|
|
451
464
|
}
|
|
452
465
|
getOffsetIdFromWorkspaceName(e11) {
|
|
453
|
-
let t2 =
|
|
466
|
+
let t2 = Ze(e11);
|
|
454
467
|
return {
|
|
455
468
|
id: this.requireNamedId(t2.name),
|
|
456
469
|
offset: t2.offset
|
|
@@ -460,63 +473,72 @@ var B = class e2 {
|
|
|
460
473
|
return e11.map((e12) => typeof e12 == "object" && e12 && "Workspace" in e12 && typeof e12.Workspace == "string" ? { Workspace: this.getOffsetIdFromWorkspaceName(e12.Workspace) } : e12);
|
|
461
474
|
}
|
|
462
475
|
};
|
|
463
|
-
function
|
|
476
|
+
function ot(e11) {
|
|
464
477
|
return {
|
|
465
478
|
substate_id: e11.substate_id,
|
|
466
479
|
version: e11.version,
|
|
467
480
|
is_write: "is_write" in e11 ? e11.is_write : true
|
|
468
481
|
};
|
|
469
482
|
}
|
|
470
|
-
var
|
|
471
|
-
|
|
472
|
-
|
|
483
|
+
var st = 12n;
|
|
484
|
+
function ct(e11) {
|
|
485
|
+
let t2 = 0n;
|
|
486
|
+
for (let n2 of Object.values(e11.cost_breakdown.breakdown)) n2 !== void 0 && (t2 += BigInt(n2));
|
|
487
|
+
return t2;
|
|
488
|
+
}
|
|
489
|
+
function lt(e11) {
|
|
490
|
+
return ct(e11) + st;
|
|
491
|
+
}
|
|
492
|
+
var ut = {
|
|
493
|
+
[f.LocalNet]: "http://localhost:12500",
|
|
494
|
+
[f.Esmeralda]: "https://ootle-indexer-a.tari.com"
|
|
473
495
|
};
|
|
474
|
-
function
|
|
475
|
-
let t2 =
|
|
496
|
+
function dt(e11) {
|
|
497
|
+
let t2 = ut[e11];
|
|
476
498
|
if (t2 !== void 0) return t2;
|
|
477
|
-
throw new
|
|
499
|
+
throw new b(`No default indexer URL is configured for ${f[e11]}. Pass an explicit URL via ProviderBuilder.withUrl(...) or IndexerProvider.connect({ url, network: Network.${f[e11]} }).`);
|
|
478
500
|
}
|
|
479
|
-
function
|
|
501
|
+
function H(e11, t2, n2) {
|
|
480
502
|
let r2;
|
|
481
503
|
try {
|
|
482
504
|
r2 = t2(n2);
|
|
483
505
|
} catch (t3) {
|
|
484
|
-
throw new
|
|
506
|
+
throw new y(`${e11}: value is not a valid CBOR encoding: ${String(t3)}`, {
|
|
485
507
|
cause: t3,
|
|
486
508
|
context: e11
|
|
487
509
|
});
|
|
488
510
|
}
|
|
489
511
|
return JSON.parse(r2);
|
|
490
512
|
}
|
|
491
|
-
function
|
|
492
|
-
return
|
|
513
|
+
function ft(e11) {
|
|
514
|
+
return H("decodeSubstateValue", ce, e11);
|
|
493
515
|
}
|
|
494
|
-
function
|
|
495
|
-
return
|
|
516
|
+
function pt(e11) {
|
|
517
|
+
return H("decodeExecuteResult", oe, e11);
|
|
496
518
|
}
|
|
497
|
-
function
|
|
498
|
-
return
|
|
519
|
+
function mt(e11) {
|
|
520
|
+
return H("decodeTransactionReceipt", le, e11);
|
|
499
521
|
}
|
|
500
|
-
function
|
|
501
|
-
return
|
|
522
|
+
function ht(e11) {
|
|
523
|
+
return H("decodeEvent", ae, e11);
|
|
502
524
|
}
|
|
503
|
-
function
|
|
504
|
-
return
|
|
525
|
+
function gt(e11) {
|
|
526
|
+
return H("decodeResource", se, e11);
|
|
505
527
|
}
|
|
506
|
-
function
|
|
507
|
-
return
|
|
528
|
+
function _t(e11) {
|
|
529
|
+
return H("decodeUtxo", ue, e11);
|
|
508
530
|
}
|
|
509
|
-
function
|
|
510
|
-
return "up" in e11.state ?
|
|
531
|
+
function vt(e11) {
|
|
532
|
+
return "up" in e11.state ? ft(e11.state.up.substate) : null;
|
|
511
533
|
}
|
|
512
|
-
var
|
|
513
|
-
function*
|
|
534
|
+
var yt = 132, bt = 32;
|
|
535
|
+
function* xt(e11) {
|
|
514
536
|
let t2 = /* @__PURE__ */ new Set();
|
|
515
|
-
for (let n2 of U(e11,
|
|
537
|
+
for (let n2 of U(e11, yt)) n2.length === bt * 2 && !t2.has(n2) && (t2.add(n2), yield `vault_${n2}`);
|
|
516
538
|
}
|
|
517
|
-
async function
|
|
518
|
-
let n2 =
|
|
519
|
-
return
|
|
539
|
+
async function St(e11, t2) {
|
|
540
|
+
let n2 = vt(await e11.getSubstate(t2));
|
|
541
|
+
return wt(n2) ? Array.from(xt(n2.Component.body.state)) : [];
|
|
520
542
|
}
|
|
521
543
|
function* U(e11, t2) {
|
|
522
544
|
if (Array.isArray(e11)) {
|
|
@@ -529,7 +551,7 @@ function* U(e11, t2) {
|
|
|
529
551
|
if (r2 === "tag") {
|
|
530
552
|
let e12 = n2.value;
|
|
531
553
|
if (n2.tag === t2) {
|
|
532
|
-
let t3 =
|
|
554
|
+
let t3 = Ct(e12);
|
|
533
555
|
t3 !== null && (yield t3);
|
|
534
556
|
}
|
|
535
557
|
yield* U(e12, t2);
|
|
@@ -541,105 +563,124 @@ function* U(e11, t2) {
|
|
|
541
563
|
}
|
|
542
564
|
for (let e12 of Object.values(n2)) yield* U(e12, t2);
|
|
543
565
|
}
|
|
544
|
-
function
|
|
566
|
+
function Ct(e11) {
|
|
545
567
|
if (typeof e11 != "object" || !e11) return null;
|
|
546
568
|
let t2 = e11;
|
|
547
569
|
if (t2["@cbor"] !== "bytes") return null;
|
|
548
570
|
let n2 = t2.hex;
|
|
549
571
|
return typeof n2 == "string" ? n2 : null;
|
|
550
572
|
}
|
|
551
|
-
function
|
|
573
|
+
function wt(e11) {
|
|
552
574
|
return typeof e11 == "object" && !!e11 && "Component" in e11;
|
|
553
575
|
}
|
|
554
|
-
var
|
|
555
|
-
function
|
|
576
|
+
var Tt = "resource_0101010101010101010101010101010101010101010101010101010101010101", Et = "component_0102030000000000000000000000000000000000000000000000000000000000", Dt = "vault_0102030000000000000000000000000000000000000000000000000000000001", Ot = "resource_0102030000000000000000000000000000000000000000000000000000000002", kt = "__ootleRawJson", At = "stealth_revealed_input", jt = "stealth_revealed_change";
|
|
577
|
+
function Mt(e11, t2) {
|
|
556
578
|
let n2 = e11.revealedInputBucket === null ? null : t2(e11.revealedInputBucket);
|
|
557
579
|
return { StealthTransfer: {
|
|
558
580
|
resource_address_ref: { Address: e11.resourceAddress },
|
|
559
|
-
statement:
|
|
581
|
+
statement: Nt(e11.statement),
|
|
560
582
|
revealed_input_bucket: n2
|
|
561
583
|
} };
|
|
562
584
|
}
|
|
563
|
-
function
|
|
564
|
-
return { [
|
|
585
|
+
function Nt(e11) {
|
|
586
|
+
return { [kt]: e11.toCompactJson() };
|
|
565
587
|
}
|
|
566
|
-
function
|
|
588
|
+
function W(e11) {
|
|
567
589
|
return typeof e11 == "object" && !!e11 && "StealthTransfer" in e11;
|
|
568
590
|
}
|
|
569
|
-
function
|
|
591
|
+
function G(e11) {
|
|
570
592
|
let t2 = [], n2 = (e12) => `__ootleRawJson:${e12}__`, r2 = JSON.stringify(e11, (e12, r3) => {
|
|
571
593
|
if (typeof r3 == "bigint") return r3.toString();
|
|
572
594
|
if (typeof r3 == "object" && r3 && "__ootleRawJson" in r3) {
|
|
573
595
|
let e13 = n2(t2.length);
|
|
574
|
-
return t2.push(r3[
|
|
596
|
+
return t2.push(r3[kt]), e13;
|
|
575
597
|
}
|
|
576
598
|
return r3;
|
|
577
599
|
});
|
|
578
600
|
for (let e12 = 0; e12 < t2.length; e12++) {
|
|
579
601
|
let i2 = JSON.stringify(n2(e12)), a2 = r2.indexOf(i2);
|
|
580
|
-
if (a2 < 0) throw new
|
|
581
|
-
if (r2.indexOf(i2, a2 + i2.length) >= 0) throw new
|
|
602
|
+
if (a2 < 0) throw new b(`serializeUnsignedTx: raw-JSON placeholder ${e12} was not emitted`);
|
|
603
|
+
if (r2.indexOf(i2, a2 + i2.length) >= 0) throw new b(`serializeUnsignedTx: raw-JSON placeholder ${e12} collided with transaction data`);
|
|
582
604
|
r2 = r2.slice(0, a2) + t2[e12] + r2.slice(a2 + i2.length);
|
|
583
605
|
}
|
|
584
606
|
return r2;
|
|
585
607
|
}
|
|
586
|
-
async function
|
|
608
|
+
async function K(e11, t2) {
|
|
587
609
|
let n2 = await e11.resolveInputs(t2.inputs);
|
|
588
610
|
return {
|
|
589
611
|
...t2,
|
|
590
612
|
inputs: n2
|
|
591
613
|
};
|
|
592
614
|
}
|
|
593
|
-
function
|
|
615
|
+
function Pt() {
|
|
594
616
|
let { secret_key: e11, public_key: t2 } = o();
|
|
595
617
|
return {
|
|
596
618
|
secret_key: e11,
|
|
597
619
|
public_key: t2
|
|
598
620
|
};
|
|
599
621
|
}
|
|
600
|
-
function
|
|
622
|
+
function Ft(e11, t2) {
|
|
601
623
|
return {
|
|
602
|
-
public_key:
|
|
603
|
-
signature:
|
|
624
|
+
public_key: S(x(e11, 32, "publicKey")),
|
|
625
|
+
signature: S(x(t2, 64, "sr25519 signature"))
|
|
604
626
|
};
|
|
605
627
|
}
|
|
606
|
-
|
|
628
|
+
function q(e11) {
|
|
629
|
+
let t2 = /* @__PURE__ */ new Map();
|
|
630
|
+
for (let [n2, r2] of e11.entries()) t2.set(S(x(r2, 32, `authorizers[${n2}]`)), r2);
|
|
631
|
+
return [...t2.keys()].sort().map((e12) => t2.get(e12));
|
|
632
|
+
}
|
|
633
|
+
function It(e11) {
|
|
634
|
+
let t2 = q(e11), n2 = new Uint8Array(t2.length * 32);
|
|
635
|
+
return t2.forEach((e12, t3) => n2.set(e12, t3 * 32)), n2;
|
|
636
|
+
}
|
|
637
|
+
async function J(e11) {
|
|
638
|
+
let t2 = [];
|
|
639
|
+
for (let n2 of e11) n2.getAuthorizerPublicKeys === void 0 ? t2.push(await n2.getPublicKey()) : t2.push(...await n2.getAuthorizerPublicKeys());
|
|
640
|
+
return q(t2);
|
|
641
|
+
}
|
|
642
|
+
async function Y(e11, t2) {
|
|
607
643
|
if (t2.main_signer !== "None" || e11.length === 0) return t2;
|
|
608
|
-
let n2 =
|
|
644
|
+
let n2 = x(await e11[0].getPublicKey(), 32, "main signer public key");
|
|
609
645
|
return {
|
|
610
646
|
...t2,
|
|
611
|
-
main_signer: { Authorizer:
|
|
647
|
+
main_signer: { Authorizer: S(n2) }
|
|
612
648
|
};
|
|
613
649
|
}
|
|
614
|
-
async function
|
|
615
|
-
return
|
|
650
|
+
async function Lt(e11, t2, n2) {
|
|
651
|
+
return Rt(e11, await Y(e11, t2), n2);
|
|
616
652
|
}
|
|
617
|
-
async function
|
|
618
|
-
let
|
|
653
|
+
async function Rt(e11, t2, n2, r2) {
|
|
654
|
+
let i2 = n2 ?? o(), a2 = x(i2.secret_key, 32, "sealKeypair.secret_key"), s2 = x(i2.public_key, 32, "sealKeypair.public_key"), c2 = r2 === void 0 ? await J(e11) : q(r2), l2 = [];
|
|
619
655
|
for (let n3 of e11) {
|
|
620
|
-
let e12 = await n3.signTransaction(t2,
|
|
621
|
-
|
|
656
|
+
let e12 = await n3.signTransaction(t2, s2, c2);
|
|
657
|
+
l2.push(...e12);
|
|
622
658
|
}
|
|
623
|
-
let c2 =
|
|
659
|
+
let u2 = zt(l2, c2), d2 = ee(`{"transaction":${G(t2)},"signatures":${JSON.stringify(u2)}}`, a2);
|
|
624
660
|
return {
|
|
625
|
-
sealedJson:
|
|
626
|
-
transaction: JSON.parse(
|
|
661
|
+
sealedJson: d2,
|
|
662
|
+
transaction: JSON.parse(d2)
|
|
627
663
|
};
|
|
628
664
|
}
|
|
629
|
-
function
|
|
665
|
+
function zt(e11, t2) {
|
|
666
|
+
let n2 = t2.map(S), r2 = [...e11].sort((e12, t3) => e12.public_key.toLowerCase() < t3.public_key.toLowerCase() ? -1 : e12.public_key.toLowerCase() > t3.public_key.toLowerCase() ? 1 : 0), i2 = r2.map((e12) => e12.public_key.toLowerCase());
|
|
667
|
+
if (i2.length !== n2.length || i2.some((e12, t3) => e12 !== n2[t3])) throw new v(`signTransaction: the signatures (${i2.join(", ") || "none"}) do not match the authorizer set (${n2.join(", ") || "none"}). Every authorizer must sign exactly once over the full set.`);
|
|
668
|
+
return r2;
|
|
669
|
+
}
|
|
670
|
+
function X(e11) {
|
|
630
671
|
return n(e11.sealedJson);
|
|
631
672
|
}
|
|
632
|
-
async function
|
|
673
|
+
async function Bt(e11, t2) {
|
|
633
674
|
return (await e11.submitTransaction(t2)).transaction_id;
|
|
634
675
|
}
|
|
635
|
-
function
|
|
676
|
+
function Vt(e11) {
|
|
636
677
|
var _a;
|
|
637
678
|
if (e11 === "Pending" || !("Finalized" in e11)) return null;
|
|
638
679
|
let t2 = e11.Finalized, n2 = t2.final_decision;
|
|
639
680
|
if (n2 === null) return null;
|
|
640
681
|
if (n2 === "Commit") return { outcome: n2 };
|
|
641
682
|
if (typeof n2 == "object" && n2 && "Abort" in n2) {
|
|
642
|
-
let e12 = t2.abort_details ?? JSON.stringify(n2.Abort), r2 = t2.execution_result === null ? void 0 : (_a =
|
|
683
|
+
let e12 = t2.abort_details ?? JSON.stringify(n2.Abort), r2 = t2.execution_result === null ? void 0 : (_a = pt(t2.execution_result).finalize) == null ? void 0 : _a.result;
|
|
643
684
|
return typeof r2 == "object" && r2 && "AcceptFeeRejectRest" in r2 ? {
|
|
644
685
|
outcome: "FeeIntentCommit",
|
|
645
686
|
reason: e12
|
|
@@ -648,19 +689,19 @@ function Nt(e11) {
|
|
|
648
689
|
reason: e12
|
|
649
690
|
};
|
|
650
691
|
}
|
|
651
|
-
throw new
|
|
692
|
+
throw new b(`Unexpected final_decision variant: ${JSON.stringify(n2)}`);
|
|
652
693
|
}
|
|
653
|
-
async function
|
|
694
|
+
async function Ht(e11, t2, n2) {
|
|
654
695
|
let r2 = (n2 == null ? void 0 : n2.pollIntervalMs) ?? 500, i2 = (n2 == null ? void 0 : n2.timeoutMs) ?? 6e4, a2 = Date.now() + i2;
|
|
655
696
|
for (; ; ) {
|
|
656
697
|
let n3 = await e11.getTransactionResult(t2), o2 = n3.result;
|
|
657
698
|
if (o2 !== "Pending" && "Finalized" in o2) {
|
|
658
|
-
let { outcome: e12, reason: r3 } =
|
|
659
|
-
if (e12 === "Reject") throw new
|
|
699
|
+
let { outcome: e12, reason: r3 } = Vt(o2) ?? { outcome: "Reject" };
|
|
700
|
+
if (e12 === "Reject") throw new m(`Transaction ${t2} was rejected: ${r3}`, {
|
|
660
701
|
txId: t2,
|
|
661
702
|
reason: r3 ?? ""
|
|
662
703
|
});
|
|
663
|
-
if (e12 === "FeeIntentCommit") throw new
|
|
704
|
+
if (e12 === "FeeIntentCommit") throw new m(`Transaction ${t2} only committed fees (execution aborted): ${r3}`, {
|
|
664
705
|
txId: t2,
|
|
665
706
|
reason: `FeeIntentCommit: ${r3 ?? ""}`
|
|
666
707
|
});
|
|
@@ -670,22 +711,22 @@ async function Pt(e11, t2, n2) {
|
|
|
670
711
|
await new Promise((e12) => setTimeout(e12, r2));
|
|
671
712
|
}
|
|
672
713
|
}
|
|
673
|
-
async function
|
|
674
|
-
let i2 = await
|
|
675
|
-
return
|
|
714
|
+
async function Ut(e11, t2, n2, r2) {
|
|
715
|
+
let i2 = await K(e11, n2);
|
|
716
|
+
return Ht(e11, await Bt(e11, X(await Lt(Array.isArray(t2) ? t2 : [t2], i2))), r2);
|
|
676
717
|
}
|
|
677
|
-
async function
|
|
678
|
-
return
|
|
718
|
+
async function Wt(e11, t2, n2, r2) {
|
|
719
|
+
return Ut(e11, t2, {
|
|
679
720
|
...n2,
|
|
680
721
|
dry_run: true
|
|
681
722
|
}, r2);
|
|
682
723
|
}
|
|
683
|
-
var
|
|
724
|
+
var Gt = class {
|
|
684
725
|
constructor(e11) {
|
|
685
726
|
__publicField(this, "publicKey");
|
|
686
727
|
__publicField(this, "sign");
|
|
687
728
|
__publicField(this, "address");
|
|
688
|
-
this.publicKey =
|
|
729
|
+
this.publicKey = x(e11.publicKey, 32, "ExternalKeySigner publicKey"), x(e11.viewPublicKey, 32, "ExternalKeySigner viewPublicKey"), this.sign = e11.sign, this.address = s(this.publicKey, e11.viewPublicKey, e11.network);
|
|
689
730
|
}
|
|
690
731
|
async getAddress() {
|
|
691
732
|
return Promise.resolve(this.address);
|
|
@@ -693,30 +734,30 @@ var Lt = class {
|
|
|
693
734
|
async getPublicKey() {
|
|
694
735
|
return Promise.resolve(this.publicKey);
|
|
695
736
|
}
|
|
696
|
-
async signTransaction(e11, n2) {
|
|
697
|
-
|
|
698
|
-
let
|
|
737
|
+
async signTransaction(e11, n2, r2) {
|
|
738
|
+
x(n2, 32, "ExternalKeySigner.signTransaction sealPublicKey");
|
|
739
|
+
let i2 = G(e11), a2 = It(r2), o2 = u(i2, n2, a2), s2;
|
|
699
740
|
try {
|
|
700
|
-
|
|
741
|
+
s2 = await this.sign(o2);
|
|
701
742
|
} catch (e12) {
|
|
702
|
-
throw new
|
|
743
|
+
throw new v(`External signer failed: ${Kt(e12)}`, { cause: e12 });
|
|
703
744
|
}
|
|
704
|
-
let
|
|
745
|
+
let c2;
|
|
705
746
|
try {
|
|
706
|
-
|
|
747
|
+
c2 = t(i2, this.publicKey, s2, n2, a2);
|
|
707
748
|
} catch (e12) {
|
|
708
|
-
throw new
|
|
749
|
+
throw new v(`External signature rejected: ${Kt(e12)}`, { cause: e12 });
|
|
709
750
|
}
|
|
710
|
-
return JSON.parse(
|
|
751
|
+
return JSON.parse(c2).signatures;
|
|
711
752
|
}
|
|
712
753
|
};
|
|
713
|
-
function
|
|
754
|
+
function Kt(e11) {
|
|
714
755
|
return e11 instanceof Error ? e11.message : String(e11);
|
|
715
756
|
}
|
|
716
|
-
var
|
|
757
|
+
var qt = class {
|
|
717
758
|
constructor(e11, t2) {
|
|
718
759
|
__publicField(this, "builder");
|
|
719
|
-
this.builder =
|
|
760
|
+
this.builder = V.new(e11, t2);
|
|
720
761
|
}
|
|
721
762
|
withInputs(e11) {
|
|
722
763
|
return this.builder.withInputs(e11), this;
|
|
@@ -728,7 +769,7 @@ var zt = class {
|
|
|
728
769
|
return this.builder.callMethod({
|
|
729
770
|
componentAddress: e11,
|
|
730
771
|
methodName: "withdraw"
|
|
731
|
-
}, [
|
|
772
|
+
}, [N(t2), z(n2)]).saveVar("bucket").callMethod({
|
|
732
773
|
componentAddress: r2,
|
|
733
774
|
methodName: "deposit"
|
|
734
775
|
}, [{ Workspace: "bucket" }]), this;
|
|
@@ -739,11 +780,11 @@ var zt = class {
|
|
|
739
780
|
build() {
|
|
740
781
|
return this.builder.buildUnsignedTransaction();
|
|
741
782
|
}
|
|
742
|
-
},
|
|
783
|
+
}, Jt = class {
|
|
743
784
|
constructor(e11, t2, n2) {
|
|
744
785
|
__publicField(this, "builder");
|
|
745
786
|
__publicField(this, "faucetAddress");
|
|
746
|
-
this.builder =
|
|
787
|
+
this.builder = V.new(e11, t2), this.faucetAddress = n2;
|
|
747
788
|
}
|
|
748
789
|
feeTransactionPayFromComponent(e11, t2) {
|
|
749
790
|
return this.builder.feeTransactionPayFromComponent(e11, t2), this;
|
|
@@ -752,7 +793,7 @@ var zt = class {
|
|
|
752
793
|
return this.builder.callMethod({
|
|
753
794
|
componentAddress: this.faucetAddress,
|
|
754
795
|
methodName: "take_free_coins"
|
|
755
|
-
}, [
|
|
796
|
+
}, [z(t2)]).saveVar("faucet_bucket").callMethod({
|
|
756
797
|
componentAddress: e11,
|
|
757
798
|
methodName: "deposit"
|
|
758
799
|
}, [{ Workspace: "faucet_bucket" }]), this;
|
|
@@ -776,7 +817,7 @@ var zt = class {
|
|
|
776
817
|
build() {
|
|
777
818
|
return this.builder.buildUnsignedTransaction();
|
|
778
819
|
}
|
|
779
|
-
},
|
|
820
|
+
}, Yt = class {
|
|
780
821
|
constructor() {
|
|
781
822
|
__publicField(this, "keyProviders");
|
|
782
823
|
__publicField(this, "defaultSignerAddress", null);
|
|
@@ -789,23 +830,27 @@ var zt = class {
|
|
|
789
830
|
return this.requireKeyProvider(e11, "explicit"), this.defaultSignerAddress = e11, this;
|
|
790
831
|
}
|
|
791
832
|
async getAddress() {
|
|
792
|
-
if (!this.defaultSignerAddress) throw new
|
|
833
|
+
if (!this.defaultSignerAddress) throw new _("No default signer address set. Call setDefaultSigner() first.");
|
|
793
834
|
return Promise.resolve(this.defaultSignerAddress);
|
|
794
835
|
}
|
|
795
836
|
async getPublicKey() {
|
|
796
837
|
return this.getSignerOrThrow().getPublicKey();
|
|
797
838
|
}
|
|
798
|
-
async signTransaction(e11, t2) {
|
|
799
|
-
return this.getSignerOrThrow().signTransaction(e11, t2);
|
|
839
|
+
async signTransaction(e11, t2, n2) {
|
|
840
|
+
return this.getSignerOrThrow().signTransaction(e11, t2, n2);
|
|
841
|
+
}
|
|
842
|
+
async getAuthorizerPublicKeys() {
|
|
843
|
+
return J([this.getSignerOrThrow()]);
|
|
800
844
|
}
|
|
801
|
-
async authorizeTransaction(e11, t2, n2) {
|
|
845
|
+
async authorizeTransaction(e11, t2, n2, r2) {
|
|
802
846
|
return {
|
|
803
847
|
signerAddress: e11,
|
|
804
|
-
signatures: await this.requireKeyProvider(e11, "explicit").signTransaction(t2, n2)
|
|
848
|
+
signatures: await this.requireKeyProvider(e11, "explicit").signTransaction(t2, n2, r2)
|
|
805
849
|
};
|
|
806
850
|
}
|
|
807
|
-
async authorizeTransactionAll(e11, t2) {
|
|
808
|
-
|
|
851
|
+
async authorizeTransactionAll(e11, t2, n2) {
|
|
852
|
+
let r2 = n2 ?? await J([...this.keyProviders.values()]);
|
|
853
|
+
return Promise.all([...this.keyProviders.keys()].map((n3) => this.authorizeTransaction(n3, e11, t2, r2)));
|
|
809
854
|
}
|
|
810
855
|
getKeyProvider(e11) {
|
|
811
856
|
return this.keyProviders.get(e11);
|
|
@@ -814,26 +859,26 @@ var zt = class {
|
|
|
814
859
|
return [...this.keyProviders.keys()];
|
|
815
860
|
}
|
|
816
861
|
getSignerOrThrow() {
|
|
817
|
-
if (!this.defaultSignerAddress) throw new
|
|
862
|
+
if (!this.defaultSignerAddress) throw new _("No default signer address set. Call setDefaultSigner() first.");
|
|
818
863
|
return this.requireKeyProvider(this.defaultSignerAddress, "default");
|
|
819
864
|
}
|
|
820
865
|
requireKeyProvider(e11, t2) {
|
|
821
866
|
let n2 = this.keyProviders.get(e11);
|
|
822
|
-
if (n2 === void 0) throw new
|
|
867
|
+
if (n2 === void 0) throw new g(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 });
|
|
823
868
|
return n2;
|
|
824
869
|
}
|
|
825
|
-
},
|
|
870
|
+
}, Xt = class {
|
|
826
871
|
constructor(e11, t2) {
|
|
827
872
|
__publicField(this, "bytes");
|
|
828
|
-
this.bytes = new Uint8Array(
|
|
873
|
+
this.bytes = new Uint8Array(x(e11, 32, t2));
|
|
829
874
|
}
|
|
830
875
|
toBytes() {
|
|
831
876
|
return new Uint8Array(this.bytes);
|
|
832
877
|
}
|
|
833
878
|
toHex() {
|
|
834
|
-
return
|
|
879
|
+
return S(this.bytes);
|
|
835
880
|
}
|
|
836
|
-
},
|
|
881
|
+
}, Z = class e3 extends Xt {
|
|
837
882
|
constructor(e11) {
|
|
838
883
|
super(e11, "Mask");
|
|
839
884
|
}
|
|
@@ -844,44 +889,44 @@ var zt = class {
|
|
|
844
889
|
return new e3(t2);
|
|
845
890
|
}
|
|
846
891
|
static fromHex(t2) {
|
|
847
|
-
return new e3(
|
|
892
|
+
return new e3(C(t2));
|
|
848
893
|
}
|
|
849
|
-
},
|
|
894
|
+
}, Zt = class e4 {
|
|
850
895
|
constructor(e11) {
|
|
851
896
|
__publicField(this, "bytes");
|
|
852
897
|
this.bytes = new Uint8Array(e11);
|
|
853
898
|
}
|
|
854
899
|
static fromHex(t2) {
|
|
855
|
-
return new e4(
|
|
900
|
+
return new e4(C(t2));
|
|
856
901
|
}
|
|
857
902
|
toBytes() {
|
|
858
903
|
return new Uint8Array(this.bytes);
|
|
859
904
|
}
|
|
860
905
|
toHex() {
|
|
861
|
-
return
|
|
906
|
+
return S(this.bytes);
|
|
862
907
|
}
|
|
863
|
-
},
|
|
864
|
-
function
|
|
865
|
-
if (e11.amount <= 0n) throw new
|
|
908
|
+
}, Qt = Object.freeze({ StealthPublicKey: Object.freeze({}) });
|
|
909
|
+
function $t(e11) {
|
|
910
|
+
if (e11.amount <= 0n) throw new b(`Output amount must be > 0, got ${e11.amount}`);
|
|
866
911
|
return {
|
|
867
912
|
destination: e11.destination,
|
|
868
913
|
amount: e11.amount,
|
|
869
914
|
resourceAddress: e11.resourceAddress,
|
|
870
915
|
resourceViewKey: e11.resourceViewKey === void 0 ? void 0 : new Uint8Array(e11.resourceViewKey),
|
|
871
916
|
memo: e11.memo,
|
|
872
|
-
payTo: e11.payTo ??
|
|
917
|
+
payTo: e11.payTo ?? Qt,
|
|
873
918
|
minimumValuePromise: e11.minimumValuePromise ?? 0n
|
|
874
919
|
};
|
|
875
920
|
}
|
|
876
|
-
function
|
|
877
|
-
if (e11.trim() === "") throw new
|
|
921
|
+
function en(e11, t2) {
|
|
922
|
+
if (e11.trim() === "") throw new b(`${t2} must be a non-empty decimal string`);
|
|
878
923
|
return BigInt(e11);
|
|
879
924
|
}
|
|
880
|
-
function
|
|
925
|
+
function tn(e11, t2) {
|
|
881
926
|
let n2 = e11.trim();
|
|
882
|
-
if (!n2.startsWith("{") || !n2.endsWith("}")) throw new
|
|
927
|
+
if (!n2.startsWith("{") || !n2.endsWith("}")) throw new b(`StealthTransferStatement.toCompactJson: ${t2} fragment is not a JSON object (got: ${e11.slice(0, 60)}...)`);
|
|
883
928
|
}
|
|
884
|
-
var
|
|
929
|
+
var nn = class e5 extends Xt {
|
|
885
930
|
constructor(e11) {
|
|
886
931
|
super(e11, "StealthInput.commitment");
|
|
887
932
|
}
|
|
@@ -892,13 +937,13 @@ var Jt = class e5 extends Ht {
|
|
|
892
937
|
return { commitment: this.toHex() };
|
|
893
938
|
}
|
|
894
939
|
static fromJSON(t2) {
|
|
895
|
-
return new e5(
|
|
940
|
+
return new e5(C(t2.commitment));
|
|
896
941
|
}
|
|
897
|
-
},
|
|
942
|
+
}, rn = class e6 {
|
|
898
943
|
constructor(e11, t2) {
|
|
899
944
|
__publicField(this, "_publicNonce");
|
|
900
945
|
__publicField(this, "_signature");
|
|
901
|
-
this._publicNonce = new Uint8Array(
|
|
946
|
+
this._publicNonce = new Uint8Array(x(e11, 32, "BalanceProofSignature.publicNonce")), this._signature = new Uint8Array(x(t2, 32, "BalanceProofSignature.signature"));
|
|
902
947
|
}
|
|
903
948
|
get publicNonce() {
|
|
904
949
|
return new Uint8Array(this._publicNonce);
|
|
@@ -908,14 +953,14 @@ var Jt = class e5 extends Ht {
|
|
|
908
953
|
}
|
|
909
954
|
toJSON() {
|
|
910
955
|
return {
|
|
911
|
-
public_nonce:
|
|
912
|
-
signature:
|
|
956
|
+
public_nonce: S(this._publicNonce),
|
|
957
|
+
signature: S(this._signature)
|
|
913
958
|
};
|
|
914
959
|
}
|
|
915
960
|
static fromJSON(t2) {
|
|
916
|
-
return new e6(
|
|
961
|
+
return new e6(C(t2.public_nonce), C(t2.signature));
|
|
917
962
|
}
|
|
918
|
-
},
|
|
963
|
+
}, an = class e7 {
|
|
919
964
|
constructor(e11, t2, n2) {
|
|
920
965
|
__publicField(this, "inputs");
|
|
921
966
|
__publicField(this, "revealedAmount");
|
|
@@ -928,13 +973,13 @@ var Jt = class e5 extends Ht {
|
|
|
928
973
|
toJSON() {
|
|
929
974
|
return {
|
|
930
975
|
inputs: this.inputs.map((e11) => e11.toJSON()),
|
|
931
|
-
revealed_amount:
|
|
976
|
+
revealed_amount: Xe(this.revealedAmount)
|
|
932
977
|
};
|
|
933
978
|
}
|
|
934
979
|
static fromJSON(t2) {
|
|
935
|
-
return new e7(t2.inputs.map(
|
|
980
|
+
return new e7(t2.inputs.map(nn.fromJSON), en(t2.revealed_amount, "revealed_amount"));
|
|
936
981
|
}
|
|
937
|
-
},
|
|
982
|
+
}, on = class e8 {
|
|
938
983
|
constructor(e11) {
|
|
939
984
|
__publicField(this, "statementJson");
|
|
940
985
|
this.statementJson = e11;
|
|
@@ -964,120 +1009,121 @@ var Jt = class e5 extends Ht {
|
|
|
964
1009
|
}
|
|
965
1010
|
toCompactJson() {
|
|
966
1011
|
let e11 = this.inputsStatement.statementJson ?? JSON.stringify(this.inputsStatement.toJSON()), t2 = this.outputsStatement.statementJson;
|
|
967
|
-
|
|
1012
|
+
tn(e11, "inputs_statement"), tn(t2, "outputs_statement");
|
|
968
1013
|
let n2 = `{"inputs_statement":${e11},"outputs_statement":${t2},"covenant_claims":[]`;
|
|
969
1014
|
return this.balanceProof !== void 0 && (n2 += `,"balance_proof":${JSON.stringify(this.balanceProof.toJSON())}`), n2 + "}";
|
|
970
1015
|
}
|
|
971
1016
|
static fromJSON(t2) {
|
|
972
|
-
return new e9(
|
|
1017
|
+
return new e9(an.fromJSON(t2.inputs), on.fromJSON(t2.outputs), t2.balance_proof === void 0 ? void 0 : rn.fromJSON(t2.balance_proof));
|
|
973
1018
|
}
|
|
974
1019
|
};
|
|
975
|
-
function
|
|
1020
|
+
function sn(e11, t2) {
|
|
976
1021
|
let n2 = new Uint8Array(e11.length * 32);
|
|
977
1022
|
for (let r2 = 0; r2 < e11.length; r2++) {
|
|
978
1023
|
let i2 = e11[r2];
|
|
979
|
-
|
|
1024
|
+
x(i2, 32, `${t2}[${r2}]`), n2.set(i2, r2 * 32);
|
|
980
1025
|
}
|
|
981
1026
|
return n2;
|
|
982
1027
|
}
|
|
983
|
-
var
|
|
984
|
-
constructor(e11 =
|
|
1028
|
+
var cn = "[]", $ = class {
|
|
1029
|
+
constructor(e11 = f.LocalNet) {
|
|
985
1030
|
__publicField(this, "network");
|
|
986
1031
|
this.network = e11;
|
|
987
1032
|
}
|
|
988
1033
|
async generateOutputsStatement(e11, t2) {
|
|
989
1034
|
let n2 = `[${e11.map((e12) => this.outputWitness(e12)).join(",")}]`, r2 = 0n, i2 = new Uint8Array(32);
|
|
990
|
-
t2 !== null && (
|
|
1035
|
+
t2 !== null && (x(t2.receiver, 32, "revealed output receiver"), r2 = t2.amount, i2 = t2.receiver);
|
|
991
1036
|
let a2 = l(n2, r2, i2);
|
|
992
|
-
return
|
|
993
|
-
statement:
|
|
994
|
-
outputMask:
|
|
1037
|
+
return x(a2.aggregated_output_mask, 32, "StealthOutputsResult.aggregated_output_mask"), {
|
|
1038
|
+
statement: on.fromJSON(a2.statement_json),
|
|
1039
|
+
outputMask: Z.fromBytes(a2.aggregated_output_mask)
|
|
995
1040
|
};
|
|
996
1041
|
}
|
|
997
1042
|
outputWitness(e11) {
|
|
998
|
-
let t2 =
|
|
1043
|
+
let t2 = d(e11.destination), n2 = ln(e11.payTo) ? null : JSON.stringify(e11.payTo), r2 = e11.memo === void 0 ? null : JSON.stringify(e11.memo), a2 = e11.resourceViewKey ?? null;
|
|
999
1044
|
return i(this.network, t2.owner_key, t2.view_key, e11.amount, e11.resourceAddress, a2, r2, n2, e11.minimumValuePromise);
|
|
1000
1045
|
}
|
|
1001
1046
|
async buildInputsStatement(e11, t2) {
|
|
1002
|
-
return new
|
|
1047
|
+
return new an(e11, t2, r(sn(e11.map((e12) => e12.commitment), "input commitment"), t2));
|
|
1003
1048
|
}
|
|
1004
1049
|
async generateBalanceProofSignature(e11, t2, n2, r2) {
|
|
1005
|
-
let i2 = c(e11.toBytes(), t2.toBytes(), n2, r2,
|
|
1006
|
-
return
|
|
1050
|
+
let i2 = c(e11.toBytes(), t2.toBytes(), n2, r2, cn);
|
|
1051
|
+
return x(i2.public_nonce, 32, "balance proof public_nonce"), x(i2.signature, 32, "balance proof signature"), new rn(i2.public_nonce, i2.signature);
|
|
1007
1052
|
}
|
|
1008
1053
|
async validateBalanceProofSignature(e11, t2, n2) {
|
|
1009
|
-
return
|
|
1054
|
+
return re(e11.publicNonce, e11.signature, t2, n2, cn);
|
|
1010
1055
|
}
|
|
1011
1056
|
async deriveAeadKey(e11, t2) {
|
|
1012
|
-
|
|
1057
|
+
x(e11, 32, "deriveAeadKey privateKey"), x(t2, 32, "deriveAeadKey publicKey");
|
|
1013
1058
|
let n2 = a(e11, t2);
|
|
1014
|
-
return
|
|
1059
|
+
return x(n2, 32, "derived AEAD key"), n2;
|
|
1015
1060
|
}
|
|
1016
1061
|
async unblindOutput(e11, t2, n2, r2) {
|
|
1017
|
-
|
|
1018
|
-
let i2 =
|
|
1062
|
+
x(e11, 32, "unblindOutput commitment"), x(n2, 32, "unblindOutput aeadKey");
|
|
1063
|
+
let i2 = ne(e11, t2, n2, r2);
|
|
1019
1064
|
return {
|
|
1020
|
-
mask:
|
|
1065
|
+
mask: Z.fromBytes(i2.mask),
|
|
1021
1066
|
value: i2.value,
|
|
1022
1067
|
memo: i2.memo_json ?? void 0
|
|
1023
1068
|
};
|
|
1024
1069
|
}
|
|
1025
1070
|
async aggregateInputMasks(t2) {
|
|
1026
|
-
let n2 = e(
|
|
1027
|
-
return
|
|
1071
|
+
let n2 = e(sn(t2.map((e11) => e11.toBytes()), "input mask"));
|
|
1072
|
+
return Z.fromBytes(n2);
|
|
1028
1073
|
}
|
|
1029
1074
|
async stealthDhSecret(e11, t2, n2, r2) {
|
|
1030
|
-
|
|
1031
|
-
let i2 =
|
|
1032
|
-
return
|
|
1075
|
+
x(t2, 32, "stealthDhSecret ownerSecret"), x(n2, 32, "stealthDhSecret viewSecret"), x(r2, 32, "stealthDhSecret publicNonce");
|
|
1076
|
+
let i2 = te(e11, t2, n2, r2);
|
|
1077
|
+
return x(i2, 32, "stealth DH secret"), i2;
|
|
1033
1078
|
}
|
|
1034
1079
|
async validateTransfer(e11) {
|
|
1035
|
-
|
|
1080
|
+
ie(e11.toCompactJson(), null);
|
|
1036
1081
|
}
|
|
1037
1082
|
};
|
|
1038
|
-
function
|
|
1083
|
+
function ln(e11) {
|
|
1039
1084
|
let t2 = Object.keys(e11);
|
|
1040
1085
|
if (t2.length !== 1 || t2[0] !== "StealthPublicKey") return false;
|
|
1041
1086
|
let n2 = e11.StealthPublicKey;
|
|
1042
1087
|
return typeof n2 == "object" && !!n2 && Object.keys(n2).length === 0;
|
|
1043
1088
|
}
|
|
1044
|
-
var
|
|
1045
|
-
function
|
|
1046
|
-
return `${
|
|
1089
|
+
var un = "utxo";
|
|
1090
|
+
function dn(e11, t2) {
|
|
1091
|
+
return `${un}_${e11.startsWith("resource_") ? e11.slice(9) : e11}_${S(t2)}`;
|
|
1047
1092
|
}
|
|
1048
|
-
var
|
|
1049
|
-
function
|
|
1093
|
+
var fn = 64;
|
|
1094
|
+
function pn(e11) {
|
|
1050
1095
|
return typeof e11 == "object" && !!e11 && "Utxo" in e11;
|
|
1051
1096
|
}
|
|
1052
|
-
function
|
|
1097
|
+
function mn(e11) {
|
|
1053
1098
|
return e11.length > 0 && /^[0-9a-fA-F]+$/.test(e11);
|
|
1054
1099
|
}
|
|
1055
|
-
function
|
|
1100
|
+
function hn(e11) {
|
|
1056
1101
|
let t2 = e11.split("_");
|
|
1057
|
-
if (t2.length < 3 || t2[0] !==
|
|
1102
|
+
if (t2.length < 3 || t2[0] !== un) return null;
|
|
1058
1103
|
let n2 = t2[t2.length - 1];
|
|
1059
|
-
return n2.length !==
|
|
1104
|
+
return n2.length !== fn || !mn(n2) ? null : C(n2);
|
|
1060
1105
|
}
|
|
1061
|
-
function
|
|
1062
|
-
let n2 =
|
|
1063
|
-
if (n2 === null || !
|
|
1106
|
+
function gn(e11, t2) {
|
|
1107
|
+
let n2 = vt(e11);
|
|
1108
|
+
if (n2 === null || !pn(n2)) return null;
|
|
1064
1109
|
let r2 = n2.Utxo;
|
|
1065
1110
|
if (r2.output === null || r2.is_frozen) return null;
|
|
1066
|
-
let i2 =
|
|
1111
|
+
let i2 = hn(t2);
|
|
1067
1112
|
return i2 === null ? null : {
|
|
1068
1113
|
commitment: i2,
|
|
1069
|
-
body: r2.output.output
|
|
1114
|
+
body: r2.output.output,
|
|
1115
|
+
auth: r2.output.auth
|
|
1070
1116
|
};
|
|
1071
1117
|
}
|
|
1072
|
-
var
|
|
1073
|
-
constructor(e11, t2, n2 = new $
|
|
1118
|
+
var _n = 0, vn = class {
|
|
1119
|
+
constructor(e11, t2, n2 = new $(e11.network())) {
|
|
1074
1120
|
__publicField(this, "provider");
|
|
1075
1121
|
__publicField(this, "crypto");
|
|
1076
1122
|
__publicField(this, "builder");
|
|
1077
1123
|
__publicField(this, "state");
|
|
1078
1124
|
__publicField(this, "maxEpoch", null);
|
|
1079
1125
|
__publicField(this, "prepared", false);
|
|
1080
|
-
this.provider = e11, this.crypto = n2, this.builder =
|
|
1126
|
+
this.provider = e11, this.crypto = n2, this.builder = V.new(e11.network(), _n), this.state = {
|
|
1081
1127
|
resource: t2,
|
|
1082
1128
|
revealedInput: null,
|
|
1083
1129
|
inputsToSpend: /* @__PURE__ */ new Map(),
|
|
@@ -1086,9 +1132,9 @@ var ln = 0, un = class {
|
|
|
1086
1132
|
};
|
|
1087
1133
|
}
|
|
1088
1134
|
spendRevealedInput(e11, t2) {
|
|
1089
|
-
if (t2 <= 0n) throw new
|
|
1135
|
+
if (t2 <= 0n) throw new b(`spendRevealedInput amount must be > 0, got ${t2}`);
|
|
1090
1136
|
let n2 = this.state.revealedInput;
|
|
1091
|
-
if (n2 !== null && n2.source !== e11) throw new
|
|
1137
|
+
if (n2 !== null && n2.source !== e11) throw new b(`spendRevealedInput: all revealed input must come from one account (${n2.source} != ${e11})`);
|
|
1092
1138
|
return this.state.revealedInput = {
|
|
1093
1139
|
source: e11,
|
|
1094
1140
|
amount: ((n2 == null ? void 0 : n2.amount) ?? 0n) + t2
|
|
@@ -1098,18 +1144,18 @@ var ln = 0, un = class {
|
|
|
1098
1144
|
return this.state.outputs.push(e11), this;
|
|
1099
1145
|
}
|
|
1100
1146
|
toRevealedOutput(e11, t2) {
|
|
1101
|
-
if (e11 <= 0n) throw new
|
|
1102
|
-
|
|
1147
|
+
if (e11 <= 0n) throw new b(`toRevealedOutput amount must be > 0, got ${e11}`);
|
|
1148
|
+
x(t2, 32, "toRevealedOutput receiver");
|
|
1103
1149
|
let n2 = this.state.revealedOutput;
|
|
1104
|
-
if (n2 !== null &&
|
|
1150
|
+
if (n2 !== null && S(n2.receiver) !== S(t2)) throw new b(`toRevealedOutput: all revealed output must go to one receiver (${S(n2.receiver)} != ${S(t2)})`);
|
|
1105
1151
|
return this.state.revealedOutput = {
|
|
1106
1152
|
amount: ((n2 == null ? void 0 : n2.amount) ?? 0n) + e11,
|
|
1107
1153
|
receiver: (n2 == null ? void 0 : n2.receiver) ?? new Uint8Array(t2)
|
|
1108
1154
|
}, this;
|
|
1109
1155
|
}
|
|
1110
1156
|
payFeeFromRevealed(e11) {
|
|
1111
|
-
if (this.state.revealedInput === null) throw new
|
|
1112
|
-
if (e11 <= 0n) throw new
|
|
1157
|
+
if (this.state.revealedInput === null) throw new b("payFeeFromRevealed: call spendRevealedInput first to set the source account");
|
|
1158
|
+
if (e11 <= 0n) throw new b(`payFeeFromRevealed amount must be > 0, got ${e11}`);
|
|
1113
1159
|
return this.builder.feeTransactionPayFromComponent(this.state.revealedInput.source, e11), this;
|
|
1114
1160
|
}
|
|
1115
1161
|
withMaxEpoch(e11) {
|
|
@@ -1119,8 +1165,8 @@ var ln = 0, un = class {
|
|
|
1119
1165
|
return this.builder = e11(this.builder), this;
|
|
1120
1166
|
}
|
|
1121
1167
|
spendStealthInput(e11, t2) {
|
|
1122
|
-
let n2 = new
|
|
1123
|
-
if (i2 !== void 0) throw new
|
|
1168
|
+
let n2 = new nn(t2), r2 = S(n2.commitment), i2 = this.state.inputsToSpend.get(r2);
|
|
1169
|
+
if (i2 !== void 0) throw new b(`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.`);
|
|
1124
1170
|
return this.state.inputsToSpend.set(r2, {
|
|
1125
1171
|
input: n2,
|
|
1126
1172
|
owner: e11
|
|
@@ -1128,10 +1174,10 @@ var ln = 0, un = class {
|
|
|
1128
1174
|
}
|
|
1129
1175
|
async prepare() {
|
|
1130
1176
|
var _a;
|
|
1131
|
-
if (this.prepared) throw new
|
|
1177
|
+
if (this.prepared) throw new b("StealthTransfer.prepare: already prepared \u2014 create a new StealthTransfer to build again");
|
|
1132
1178
|
this.validate(), this.prepared = true;
|
|
1133
1179
|
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);
|
|
1134
|
-
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch ===
|
|
1180
|
+
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch === _n && this.builder.withMaxEpoch(await et(this.provider));
|
|
1135
1181
|
let r2 = /* @__PURE__ */ new Set();
|
|
1136
1182
|
if (this.state.revealedInput !== null) {
|
|
1137
1183
|
let e12 = this.state.revealedInput.source;
|
|
@@ -1139,20 +1185,20 @@ var ln = 0, un = class {
|
|
|
1139
1185
|
substate_id: e12,
|
|
1140
1186
|
version: null
|
|
1141
1187
|
}), r2.add(e12);
|
|
1142
|
-
let t3 = await
|
|
1188
|
+
let t3 = await St(this.provider, e12);
|
|
1143
1189
|
for (let e13 of t3) r2.has(e13) || (this.builder.addInput({
|
|
1144
1190
|
substate_id: e13,
|
|
1145
1191
|
version: null
|
|
1146
1192
|
}), r2.add(e13));
|
|
1147
1193
|
}
|
|
1148
1194
|
for (let { input: e12 } of this.state.inputsToSpend.values()) {
|
|
1149
|
-
let t3 =
|
|
1195
|
+
let t3 = dn(this.state.resource, e12.commitment);
|
|
1150
1196
|
r2.has(t3) || (this.builder.addInput({
|
|
1151
1197
|
substate_id: t3,
|
|
1152
1198
|
version: null
|
|
1153
1199
|
}), r2.add(t3));
|
|
1154
1200
|
}
|
|
1155
|
-
let i2 = await
|
|
1201
|
+
let i2 = await K(this.provider, this.builder.buildUnsignedTransaction()), a2 = [...this.state.inputsToSpend.values()], o2 = this.collectRequiredSigners(a2);
|
|
1156
1202
|
return {
|
|
1157
1203
|
unsignedTx: i2,
|
|
1158
1204
|
statement: n2,
|
|
@@ -1171,13 +1217,13 @@ var ln = 0, un = class {
|
|
|
1171
1217
|
validate() {
|
|
1172
1218
|
var _a, _b;
|
|
1173
1219
|
let e11 = this.state.inputsToSpend.size > 0, t2 = ((_a = this.state.revealedInput) == null ? void 0 : _a.amount) ?? 0n, n2 = t2 > 0n || e11, r2 = ((_b = this.state.revealedOutput) == null ? void 0 : _b.amount) ?? 0n;
|
|
1174
|
-
if (!n2) throw new
|
|
1175
|
-
if (this.state.outputs.length === 0 && this.state.revealedOutput === null) throw new
|
|
1176
|
-
if (this.state.outputs.length === 0) throw new
|
|
1177
|
-
if (this.state.revealedOutput !== null && this.state.revealedInput === null) throw new
|
|
1220
|
+
if (!n2) throw new b("StealthTransfer.prepare: no inputs \u2014 call spendRevealedInput or spendStealthInput first");
|
|
1221
|
+
if (this.state.outputs.length === 0 && this.state.revealedOutput === null) throw new b("StealthTransfer.prepare: no outputs \u2014 call toStealthOutput or toRevealedOutput first");
|
|
1222
|
+
if (this.state.outputs.length === 0) throw new b("StealthTransfer.prepare: at least one stealth output is required");
|
|
1223
|
+
if (this.state.revealedOutput !== null && this.state.revealedInput === null) throw new b("StealthTransfer.prepare: revealed change requires a revealed source account to deposit into");
|
|
1178
1224
|
if (!e11) {
|
|
1179
1225
|
let e12 = this.state.outputs.reduce((e13, t3) => e13 + t3.amount, 0n), n3 = e12 + r2, i2 = t2;
|
|
1180
|
-
if (i2 !== n3) throw new
|
|
1226
|
+
if (i2 !== n3) throw new b(`StealthTransfer.prepare: unbalanced transfer \u2014 revealed input ${i2} != stealth out ${e12} + revealed out ${r2} (= ${n3})`);
|
|
1181
1227
|
}
|
|
1182
1228
|
}
|
|
1183
1229
|
emitInstructions(e11) {
|
|
@@ -1185,38 +1231,38 @@ var ln = 0, un = class {
|
|
|
1185
1231
|
t2 !== null && (this.builder.callMethod({
|
|
1186
1232
|
componentAddress: t2.source,
|
|
1187
1233
|
methodName: "withdraw"
|
|
1188
|
-
}, [
|
|
1234
|
+
}, [N(this.state.resource), j(t2.amount)]).saveVar(At), n2 = At), this.builder.addInstruction(Mt({
|
|
1189
1235
|
resourceAddress: this.state.resource,
|
|
1190
1236
|
revealedInputBucket: n2,
|
|
1191
1237
|
statement: e11
|
|
1192
|
-
}, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutput !== null && t2 !== null && this.builder.saveVar(
|
|
1238
|
+
}, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutput !== null && t2 !== null && this.builder.saveVar(jt).callMethod({
|
|
1193
1239
|
componentAddress: t2.source,
|
|
1194
1240
|
methodName: "deposit"
|
|
1195
|
-
}, [{ Workspace:
|
|
1241
|
+
}, [{ Workspace: jt }]);
|
|
1196
1242
|
}
|
|
1197
1243
|
};
|
|
1198
|
-
function
|
|
1199
|
-
if (
|
|
1200
|
-
if (e11.inputs.length > 0) throw new
|
|
1244
|
+
function yn(e11) {
|
|
1245
|
+
if (bn(e11) || e11.statementJson !== void 0) return e11.statementJson;
|
|
1246
|
+
if (e11.inputs.length > 0) throw new y("inputs statement has confidential inputs but no WASM statementJson \u2014 call buildInputsStatement first", { context: "statementJsonFor" });
|
|
1201
1247
|
return JSON.stringify(e11.toJSON());
|
|
1202
1248
|
}
|
|
1203
|
-
function
|
|
1249
|
+
function bn(e11) {
|
|
1204
1250
|
return !("inputs" in e11);
|
|
1205
1251
|
}
|
|
1206
|
-
async function
|
|
1207
|
-
let a2 =
|
|
1252
|
+
async function xn(e11, t2, n2, r2, i2) {
|
|
1253
|
+
let a2 = yn(r2), o2 = yn(i2);
|
|
1208
1254
|
return e11.generateBalanceProofSignature(t2, n2, a2, o2);
|
|
1209
1255
|
}
|
|
1210
|
-
async function
|
|
1256
|
+
async function Sn(e11, t2, n2, r2) {
|
|
1211
1257
|
let i2 = await e11.deriveAeadKey(r2.viewSecret, r2.senderPublicNonce);
|
|
1212
1258
|
return e11.unblindOutput(t2, n2, i2, r2.skipMemo);
|
|
1213
1259
|
}
|
|
1214
|
-
async function
|
|
1215
|
-
let i2 =
|
|
1260
|
+
async function Cn(e11, t2, n2, r2) {
|
|
1261
|
+
let i2 = gn(n2, r2);
|
|
1216
1262
|
if (i2 === null) return null;
|
|
1217
|
-
let a2 =
|
|
1263
|
+
let a2 = C(i2.body.encrypted_data), o2 = C(i2.body.public_nonce);
|
|
1218
1264
|
try {
|
|
1219
|
-
return await
|
|
1265
|
+
return await Sn(e11, i2.commitment, a2, {
|
|
1220
1266
|
senderPublicNonce: o2,
|
|
1221
1267
|
viewSecret: t2,
|
|
1222
1268
|
skipMemo: false
|
|
@@ -1225,33 +1271,33 @@ async function mn(e11, t2, n2, r2) {
|
|
|
1225
1271
|
return null;
|
|
1226
1272
|
}
|
|
1227
1273
|
}
|
|
1228
|
-
async function
|
|
1229
|
-
if (t2.length === 0) throw new
|
|
1274
|
+
async function wn(e11, t2, n2) {
|
|
1275
|
+
if (t2.length === 0) throw new b("generateOutputsStatement: at least one stealth output is required");
|
|
1230
1276
|
let { statement: r2, outputMask: i2 } = await e11.generateOutputsStatement(t2, n2), a2 = await e11.buildInputsStatement([], 0n);
|
|
1231
|
-
return new Q(a2, r2, await
|
|
1277
|
+
return new Q(a2, r2, await xn(e11, Z.zero(), i2, a2, r2));
|
|
1232
1278
|
}
|
|
1233
|
-
var
|
|
1279
|
+
var Tn = class e10 {
|
|
1234
1280
|
constructor(e11, t2, n2, r2, i2) {
|
|
1235
1281
|
this.wallet = e11, this.spec = t2, this.crypto = n2, this.mustSignWithAccountKey = r2, this.viewSecret = i2;
|
|
1236
1282
|
}
|
|
1237
1283
|
static fromSpec(t2, n2, r2 = {}) {
|
|
1238
|
-
return new e10(t2, n2, r2.crypto ?? new $
|
|
1284
|
+
return new e10(t2, n2, r2.crypto ?? new $(), r2.mustSignWithAccountKey ?? true, r2.viewSecret);
|
|
1239
1285
|
}
|
|
1240
1286
|
async prepare(e11) {
|
|
1241
|
-
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ?
|
|
1287
|
+
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ? Z.zero() : await this.crypto.aggregateInputMasks(t2.map((e12) => e12.mask)), r2 = await xn(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);
|
|
1242
1288
|
await this.crypto.validateTransfer(i2);
|
|
1243
|
-
let a2 =
|
|
1289
|
+
let a2 = Dn(this.spec.unsignedTx, i2), o2 = this.mustSignWithAccountKey ? await Y([this.wallet], a2) : a2, s2 = {
|
|
1244
1290
|
...this.spec,
|
|
1245
1291
|
unsignedTx: o2,
|
|
1246
1292
|
statement: i2
|
|
1247
1293
|
};
|
|
1248
|
-
return new
|
|
1294
|
+
return new En({
|
|
1249
1295
|
wallet: this.wallet,
|
|
1250
1296
|
crypto: this.crypto,
|
|
1251
1297
|
spec: s2,
|
|
1252
1298
|
resolvedInputs: t2,
|
|
1253
1299
|
mustSignWithAccountKey: this.mustSignWithAccountKey,
|
|
1254
|
-
sealKeypair:
|
|
1300
|
+
sealKeypair: Pt()
|
|
1255
1301
|
});
|
|
1256
1302
|
}
|
|
1257
1303
|
async resolveViewSecret() {
|
|
@@ -1260,9 +1306,9 @@ var gn = class e10 {
|
|
|
1260
1306
|
if ((e11 == null ? void 0 : e11.getViewSecret) !== void 0) try {
|
|
1261
1307
|
return await e11.getViewSecret();
|
|
1262
1308
|
} catch (e12) {
|
|
1263
|
-
throw e12 instanceof
|
|
1309
|
+
throw e12 instanceof h ? e12 : new h("WalletStealthAuthorizer: spending stealth inputs needs a view secret to unblind them, but the wallet's default signer could not provide one. Pass `fromSpec(wallet, spec, { viewSecret })` or use a SecretKeyWallet (created with a view key) as the default signer.", { cause: e12 });
|
|
1264
1310
|
}
|
|
1265
|
-
throw new
|
|
1311
|
+
throw new h("WalletStealthAuthorizer: spending stealth inputs needs a view secret to unblind them, but none was supplied and the wallet's default signer cannot provide one. Pass `fromSpec(wallet, spec, { viewSecret })` or use a SecretKeyWallet (created with a view key) as the default signer.");
|
|
1266
1312
|
}
|
|
1267
1313
|
async safeDefaultAddress() {
|
|
1268
1314
|
try {
|
|
@@ -1274,35 +1320,38 @@ var gn = class e10 {
|
|
|
1274
1320
|
async resolveStealthInputs(e11) {
|
|
1275
1321
|
if (this.spec.inputs.length === 0) return [];
|
|
1276
1322
|
let t2 = await this.resolveViewSecret(), n2 = this.spec.state.resource, r2 = await Promise.allSettled(this.spec.inputs.map(async ({ input: r3, owner: i3 }) => {
|
|
1277
|
-
let a2 =
|
|
1278
|
-
if (o2 === null) throw new
|
|
1279
|
-
let s2 =
|
|
1280
|
-
if (s2 === null) throw new
|
|
1281
|
-
let c2 =
|
|
1323
|
+
let a2 = S(r3.commitment), o2 = await e11.getStealthUtxo(n2, r3.commitment);
|
|
1324
|
+
if (o2 === null) throw new h(`WalletStealthAuthorizer.prepare: stealth input UTXO not found (spent or never created) for ${a2}`);
|
|
1325
|
+
let s2 = gn(o2, dn(n2, r3.commitment));
|
|
1326
|
+
if (s2 === null) throw new h(`WalletStealthAuthorizer.prepare: stealth input ${a2} is not a live, spendable UTXO`);
|
|
1327
|
+
let c2 = C(s2.body.public_nonce), l2;
|
|
1282
1328
|
try {
|
|
1283
|
-
l2 = await
|
|
1329
|
+
l2 = await Sn(this.crypto, s2.commitment, C(s2.body.encrypted_data), {
|
|
1284
1330
|
senderPublicNonce: c2,
|
|
1285
1331
|
viewSecret: t2,
|
|
1286
1332
|
skipMemo: true
|
|
1287
1333
|
});
|
|
1288
1334
|
} catch (e12) {
|
|
1289
|
-
throw new
|
|
1335
|
+
throw new y(`WalletStealthAuthorizer.prepare: failed to decrypt stealth input with commitment ${S(r3.commitment)} (owner ${i3}). This usually means the supplied view secret does not own this UTXO. Pass the correct \`viewSecret\` via \`fromSpec(wallet, spec, { viewSecret })\`, or use the owning SecretKeyWallet (with its view key) as the default signer. Note: a single view secret is resolved for all inputs \u2014 spending UTXOs owned by distinct view keys in one transfer is not supported.`, {
|
|
1290
1336
|
cause: e12,
|
|
1291
1337
|
context: "unblindOutput"
|
|
1292
1338
|
});
|
|
1293
1339
|
}
|
|
1340
|
+
let u2 = kn(s2.auth);
|
|
1341
|
+
if (u2 === null) throw new h(`WalletStealthAuthorizer.prepare: stealth input ${a2} is spent by script only, which this authorizer does not support`);
|
|
1294
1342
|
return {
|
|
1295
1343
|
ownerAddr: i3,
|
|
1296
1344
|
input: r3,
|
|
1297
1345
|
mask: l2.mask,
|
|
1298
1346
|
publicNonce: c2,
|
|
1299
|
-
viewSecret: t2
|
|
1347
|
+
viewSecret: t2,
|
|
1348
|
+
oneTimePublicKey: u2
|
|
1300
1349
|
};
|
|
1301
1350
|
})), i2 = r2.find((e12) => e12.status === "rejected");
|
|
1302
1351
|
if (i2 !== void 0) throw i2.reason;
|
|
1303
1352
|
return r2.map((e12) => e12.value);
|
|
1304
1353
|
}
|
|
1305
|
-
},
|
|
1354
|
+
}, En = class {
|
|
1306
1355
|
constructor(e11) {
|
|
1307
1356
|
__publicField(this, "wallet");
|
|
1308
1357
|
__publicField(this, "crypto");
|
|
@@ -1311,12 +1360,25 @@ var gn = class e10 {
|
|
|
1311
1360
|
__publicField(this, "mustSignWithAccountKey");
|
|
1312
1361
|
__publicField(this, "sealKeypair");
|
|
1313
1362
|
__publicField(this, "extraSignatures", []);
|
|
1363
|
+
__publicField(this, "coSignerKeys", []);
|
|
1364
|
+
__publicField(this, "authorizerSet");
|
|
1314
1365
|
__publicField(this, "cachedAuthorizations");
|
|
1315
1366
|
this.wallet = e11.wallet, this.crypto = e11.crypto, this.spec = e11.spec, this.resolvedInputs = e11.resolvedInputs, this.mustSignWithAccountKey = e11.mustSignWithAccountKey, this.sealKeypair = e11.sealKeypair;
|
|
1316
1367
|
}
|
|
1317
1368
|
getSealPublicKey() {
|
|
1318
1369
|
return this.sealKeypair.public_key;
|
|
1319
1370
|
}
|
|
1371
|
+
addAuthorizer(e11) {
|
|
1372
|
+
if (this.authorizerSet !== void 0) throw new h("AuthorizedTransfer.addAuthorizer: the authorizer set is already fixed; declare co-signers before getAuthorizerPublicKeys(), createAuthorizations() or seal()");
|
|
1373
|
+
return this.coSignerKeys.push(e11), this;
|
|
1374
|
+
}
|
|
1375
|
+
async getAuthorizerPublicKeys() {
|
|
1376
|
+
return this.authorizerSet === void 0 && (this.authorizerSet = q([
|
|
1377
|
+
...this.mustSignWithAccountKey ? await this.wallet.getAuthorizerPublicKeys() : [],
|
|
1378
|
+
...this.resolvedInputs.map((e11) => e11.oneTimePublicKey),
|
|
1379
|
+
...this.coSignerKeys
|
|
1380
|
+
])), this.authorizerSet;
|
|
1381
|
+
}
|
|
1320
1382
|
getSpec() {
|
|
1321
1383
|
return this.spec;
|
|
1322
1384
|
}
|
|
@@ -1325,21 +1387,22 @@ var gn = class e10 {
|
|
|
1325
1387
|
}
|
|
1326
1388
|
async computeAuthorizations() {
|
|
1327
1389
|
if (this.resolvedInputs.length === 0) return [];
|
|
1328
|
-
let e11 =
|
|
1329
|
-
for (let
|
|
1330
|
-
let
|
|
1331
|
-
if (
|
|
1332
|
-
if (
|
|
1333
|
-
let
|
|
1390
|
+
let e11 = G(this.spec.unsignedTx), t2 = this.sealKeypair.public_key, n2 = await this.getAuthorizerPublicKeys(), r2 = [];
|
|
1391
|
+
for (let i2 of this.resolvedInputs) {
|
|
1392
|
+
let a2 = this.wallet.getKeyProvider(i2.ownerAddr);
|
|
1393
|
+
if (a2 === void 0) throw new g(`AuthorizedTransfer.createAuthorizations: no signer registered for stealth-input owner ${i2.ownerAddr}. Register it via wallet.registerKeyProvider(owner, signer).`, { address: i2.ownerAddr });
|
|
1394
|
+
if (a2.addStealthSignature === void 0) throw new v(`AuthorizedTransfer.createAuthorizations: signer for ${i2.ownerAddr} cannot produce one-time stealth signatures. Use a SecretKeyWallet (which holds the owner secret).`);
|
|
1395
|
+
let o2 = await a2.addStealthSignature(e11, i2.publicNonce, t2, {
|
|
1334
1396
|
crypto: this.crypto,
|
|
1335
|
-
viewSecret:
|
|
1397
|
+
viewSecret: i2.viewSecret,
|
|
1398
|
+
authorizers: n2
|
|
1336
1399
|
});
|
|
1337
|
-
|
|
1338
|
-
signerAddress:
|
|
1339
|
-
signatures: [
|
|
1400
|
+
r2.push({
|
|
1401
|
+
signerAddress: i2.ownerAddr,
|
|
1402
|
+
signatures: [o2]
|
|
1340
1403
|
});
|
|
1341
1404
|
}
|
|
1342
|
-
return
|
|
1405
|
+
return r2;
|
|
1343
1406
|
}
|
|
1344
1407
|
addSignature(e11) {
|
|
1345
1408
|
return this.extraSignatures.push(e11), this;
|
|
@@ -1348,127 +1411,141 @@ var gn = class e10 {
|
|
|
1348
1411
|
let e11 = (await this.createAuthorizations()).flatMap((e12) => e12.signatures), t2 = [];
|
|
1349
1412
|
this.mustSignWithAccountKey && t2.push(this.wallet);
|
|
1350
1413
|
let n2 = [...e11, ...this.extraSignatures];
|
|
1351
|
-
return n2.length > 0 && t2.push(new
|
|
1414
|
+
return n2.length > 0 && t2.push(new On(n2)), X(await Rt(t2, this.spec.unsignedTx, this.sealKeypair, await this.getAuthorizerPublicKeys()));
|
|
1352
1415
|
}
|
|
1353
1416
|
};
|
|
1354
|
-
function
|
|
1355
|
-
let n2 = e11.instructions.findIndex(
|
|
1356
|
-
if (n2 < 0) throw new
|
|
1357
|
-
if (e11.instructions.slice(n2 + 1).findIndex(
|
|
1417
|
+
function Dn(e11, t2) {
|
|
1418
|
+
let n2 = e11.instructions.findIndex(W);
|
|
1419
|
+
if (n2 < 0) throw new b("patchStealthStatement: expected exactly one StealthTransfer instruction, found 0 (not a stealth tx)");
|
|
1420
|
+
if (e11.instructions.slice(n2 + 1).findIndex(W) >= 0) throw new b("patchStealthStatement: expected exactly one StealthTransfer instruction, found more than one (malformed)");
|
|
1358
1421
|
let r2 = { StealthTransfer: {
|
|
1359
1422
|
...e11.instructions[n2].StealthTransfer,
|
|
1360
|
-
statement:
|
|
1423
|
+
statement: Nt(t2)
|
|
1361
1424
|
} }, i2 = [...e11.instructions];
|
|
1362
1425
|
return i2[n2] = r2, {
|
|
1363
1426
|
...e11,
|
|
1364
1427
|
instructions: i2
|
|
1365
1428
|
};
|
|
1366
1429
|
}
|
|
1367
|
-
var
|
|
1430
|
+
var On = class {
|
|
1368
1431
|
constructor(e11) {
|
|
1369
1432
|
this.signatures = e11;
|
|
1370
1433
|
}
|
|
1371
1434
|
async getAddress() {
|
|
1372
|
-
throw new
|
|
1435
|
+
throw new v("StaticSignatureSigner has no address");
|
|
1373
1436
|
}
|
|
1374
1437
|
async getPublicKey() {
|
|
1375
|
-
throw new
|
|
1438
|
+
throw new v("StaticSignatureSigner has no public key");
|
|
1439
|
+
}
|
|
1440
|
+
async getAuthorizerPublicKeys() {
|
|
1441
|
+
return this.signatures.map((e11) => C(e11.public_key));
|
|
1376
1442
|
}
|
|
1377
|
-
async signTransaction(e11, t2) {
|
|
1443
|
+
async signTransaction(e11, t2, n2) {
|
|
1378
1444
|
return this.signatures;
|
|
1379
1445
|
}
|
|
1380
1446
|
};
|
|
1447
|
+
function kn(e11) {
|
|
1448
|
+
return "Key" in e11 ? C(e11.Key) : "KeyAndScript" in e11 ? C(e11.KeyAndScript.spend_key) : null;
|
|
1449
|
+
}
|
|
1381
1450
|
export {
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1451
|
+
qt as AccountInvokeBuilder,
|
|
1452
|
+
En as AuthorizedTransfer,
|
|
1453
|
+
rn as BalanceProofSignature,
|
|
1454
|
+
y as CryptoBridgeError,
|
|
1455
|
+
$e as DEFAULT_TRANSACTION_VALIDITY_EPOCHS,
|
|
1456
|
+
_ as DefaultSignerNotSetError,
|
|
1457
|
+
Zt as EncryptedData,
|
|
1458
|
+
Gt as ExternalKeySigner,
|
|
1459
|
+
st as FEE_ESTIMATE_ALLOWANCE,
|
|
1460
|
+
Jt as FaucetInvokeBuilder,
|
|
1391
1461
|
pe as IndexerClientError,
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1462
|
+
b as InvalidArgumentError,
|
|
1463
|
+
g as KeyProviderNotFoundError,
|
|
1464
|
+
Qe as MAX_TRANSACTION_VALIDITY_EPOCHS,
|
|
1465
|
+
Z as Mask,
|
|
1466
|
+
f as Network,
|
|
1467
|
+
p as OotleError,
|
|
1468
|
+
Yt as OotleWallet,
|
|
1399
1469
|
he as OperationCancelledError,
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1470
|
+
v as SignerError,
|
|
1471
|
+
nn as StealthInput,
|
|
1472
|
+
an as StealthInputsStatement,
|
|
1473
|
+
on as StealthOutputsStatement,
|
|
1474
|
+
vn as StealthTransfer,
|
|
1405
1475
|
Q as StealthTransferStatement,
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1476
|
+
Tt as TARI_RESOURCE_ADDRESS,
|
|
1477
|
+
V as TransactionBuilder,
|
|
1478
|
+
m as TransactionRejectedError,
|
|
1409
1479
|
me as TransactionTimeoutError,
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
$
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1480
|
+
h as WalletError,
|
|
1481
|
+
Tn as WalletStealthAuthorizer,
|
|
1482
|
+
$ as WasmStealthCrypto,
|
|
1483
|
+
Ot as XTR_FAUCET_CLAIM_RESOURCE_ADDRESS,
|
|
1484
|
+
Et as XTR_FAUCET_COMPONENT_ADDRESS,
|
|
1485
|
+
Dt as XTR_FAUCET_VAULT_ADDRESS,
|
|
1486
|
+
j as amountLiteral,
|
|
1487
|
+
x as assertByteLength,
|
|
1418
1488
|
ge as assertUnreachable,
|
|
1419
1489
|
Fe as boolLiteral,
|
|
1420
|
-
|
|
1421
|
-
|
|
1490
|
+
Ft as buildTransactionSignature,
|
|
1491
|
+
M as bytesLiteral,
|
|
1492
|
+
q as canonicalAuthorizers,
|
|
1422
1493
|
Be as claimedOutputTombstoneAddressLiteral,
|
|
1423
|
-
|
|
1424
|
-
|
|
1494
|
+
Vt as classifyOutcome,
|
|
1495
|
+
J as collectAuthorizers,
|
|
1496
|
+
hn as commitmentOf,
|
|
1425
1497
|
Ie as componentAddressLiteral,
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1498
|
+
$t as createOutput,
|
|
1499
|
+
ht as decodeEvent,
|
|
1500
|
+
pt as decodeExecuteResult,
|
|
1501
|
+
gt as decodeResource,
|
|
1502
|
+
ft as decodeSubstateValue,
|
|
1503
|
+
mt as decodeTransactionReceipt,
|
|
1504
|
+
_t as decodeUtxo,
|
|
1505
|
+
Sn as decryptInputData,
|
|
1506
|
+
Cn as decryptOwnedUtxo,
|
|
1507
|
+
dt as defaultIndexerUrl,
|
|
1508
|
+
It as encodeAuthorizerSet,
|
|
1509
|
+
lt as estimatedFee,
|
|
1510
|
+
ct as feesCharged,
|
|
1511
|
+
C as fromHexStr,
|
|
1512
|
+
wn as generateOutputsStatement,
|
|
1513
|
+
Pt as generateSealKeypair,
|
|
1514
|
+
St as getVaultIdsForAccount,
|
|
1440
1515
|
Ne as intLiteral,
|
|
1441
|
-
|
|
1442
|
-
|
|
1516
|
+
W as isStealthTransferInstruction,
|
|
1517
|
+
xt as iterVaultIdsInState,
|
|
1443
1518
|
je as literalArg,
|
|
1444
1519
|
Le as metadataLiteral,
|
|
1445
|
-
|
|
1446
|
-
|
|
1520
|
+
z as microTariLiteral,
|
|
1521
|
+
Xe as microTariString,
|
|
1447
1522
|
Ue as nonFungibleAddressLiteral,
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1523
|
+
gn as parseSubstateUtxo,
|
|
1524
|
+
Ze as parseWorkspaceStringKey,
|
|
1525
|
+
Dn as patchStealthStatement,
|
|
1451
1526
|
He as publicKeyLiteral,
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1527
|
+
Y as resolveMainSigner,
|
|
1528
|
+
et as resolveMaxEpoch,
|
|
1529
|
+
K as resolveTransaction,
|
|
1530
|
+
N as resourceAddressLiteral,
|
|
1531
|
+
X as sealTransaction,
|
|
1532
|
+
Wt as sendDryRun,
|
|
1533
|
+
Ut as sendTransaction,
|
|
1534
|
+
G as serializeUnsignedTx,
|
|
1535
|
+
xn as signBalanceProof,
|
|
1536
|
+
Lt as signTransaction,
|
|
1537
|
+
Nt as statementAsWire,
|
|
1538
|
+
Mt as stealthTransferInstruction,
|
|
1539
|
+
dn as stealthUtxoSubstateId,
|
|
1465
1540
|
Pe as stringLiteral,
|
|
1466
|
-
|
|
1541
|
+
Bt as submitTransaction,
|
|
1467
1542
|
ze as templateAddressLiteral,
|
|
1468
|
-
|
|
1469
|
-
|
|
1543
|
+
S as toHexStr,
|
|
1544
|
+
de as transactionBody,
|
|
1545
|
+
fe as transactionSchemaVersion,
|
|
1546
|
+
vt as upSubstateValue,
|
|
1470
1547
|
We as utxoAddressLiteral,
|
|
1471
1548
|
Ve as validatorFeePoolAddressLiteral,
|
|
1472
1549
|
Re as vaultIdLiteral,
|
|
1473
|
-
|
|
1550
|
+
Ht as watchTransaction
|
|
1474
1551
|
};
|