@tari-project/ootle 0.2.0 → 0.4.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +98 -10
  2. package/dist/index.js +411 -378
  3. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
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, borEncodeTransaction as t, buildStealthInputsStatement as n, createStealthOutputWitness as r, encryptedDataDhKdfAead as i, generateKeypair as a, generateStealthBalanceProofSignature as o, generateStealthOutputsStatement as s, parseOotleAddress as c, sealTransaction as ee, stealthDhSecret as te, unblindOutput as ne, validateBalanceProofSignature as re, validateStealthTransfer as ie } from "@tari-project/ootle-wasm";
5
- var l = /* @__PURE__ */ (function(e11) {
4
+ import { aggregateInputMasks as e, borEncodeTransaction as t, buildStealthInputsStatement as n, createStealthOutputWitness as r, encryptedDataDhKdfAead as i, generateKeypair as a, generateStealthBalanceProofSignature as o, generateStealthOutputsStatement as s, parseOotleAddress as c, sealTransaction as l, stealthDhSecret as ee, unblindOutput as te, validateBalanceProofSignature as ne, validateStealthTransfer as re } from "@tari-project/ootle-wasm";
5
+ var u = /* @__PURE__ */ (function(e11) {
6
6
  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
- })({}), u = class extends Error {
7
+ })({}), d = class extends Error {
8
8
  constructor(e11, t2) {
9
9
  super(e11, t2), this.name = new.target.name;
10
10
  }
11
- }, ae = class extends u {
11
+ }, ie = class extends d {
12
12
  constructor(e11, t2) {
13
13
  super(e11, t2);
14
14
  __publicField(this, "status");
@@ -16,7 +16,7 @@ var l = /* @__PURE__ */ (function(e11) {
16
16
  __publicField(this, "url");
17
17
  this.status = t2 == null ? void 0 : t2.status, this.body = t2 == null ? void 0 : t2.body, this.url = t2 == null ? void 0 : t2.url;
18
18
  }
19
- }, d = class extends u {
19
+ }, f = class extends d {
20
20
  constructor(e11, t2) {
21
21
  super(e11, t2);
22
22
  __publicField(this, "txId");
@@ -24,128 +24,133 @@ var l = /* @__PURE__ */ (function(e11) {
24
24
  __publicField(this, "rejectReason");
25
25
  this.txId = t2.txId, this.reason = t2.reason, this.rejectReason = t2.rejectReason;
26
26
  }
27
- }, oe = class extends u {
27
+ }, ae = class extends d {
28
28
  constructor(e11, t2) {
29
29
  super(e11, t2);
30
30
  __publicField(this, "txId");
31
31
  this.txId = t2.txId;
32
32
  }
33
- }, f = class extends u {
34
- }, p = class extends f {
33
+ }, p = class extends d {
34
+ }, m = class extends p {
35
35
  constructor(e11, t2) {
36
36
  super(e11, t2);
37
37
  __publicField(this, "address");
38
38
  this.address = t2.address;
39
39
  }
40
- }, m = class extends f {
41
- }, h = class extends u {
42
- }, g = class extends u {
40
+ }, h = class extends p {
41
+ }, g = class extends d {
42
+ }, _ = class extends d {
43
43
  constructor(e11, t2) {
44
44
  super(e11, t2);
45
45
  __publicField(this, "context");
46
46
  this.context = t2 == null ? void 0 : t2.context;
47
47
  }
48
- }, _ = class extends u {
49
- }, se = class extends u {
48
+ }, v = class extends d {
49
+ }, oe = class extends d {
50
50
  };
51
- function ce(e11, t2) {
52
- throw new _(`assertUnreachable${t2 ? ` (${t2})` : ""}: ${JSON.stringify(e11)}`);
51
+ function se(e11, t2) {
52
+ throw new v(`assertUnreachable${t2 ? ` (${t2})` : ""}: ${JSON.stringify(e11)}`);
53
53
  }
54
- function v(e11, t2, n2) {
55
- if (e11.length !== t2) throw new _(`${n2} must be ${t2} bytes, got ${e11.length}`);
54
+ function y(e11, t2, n2) {
55
+ if (e11.length !== t2) throw new v(`${n2} must be ${t2} bytes, got ${e11.length}`);
56
56
  return e11;
57
57
  }
58
- function y(e11) {
58
+ function b(e11) {
59
59
  return Array.from(e11, (e12) => e12.toString(16).padStart(2, "0")).join("");
60
60
  }
61
- var le = /^[0-9a-fA-F]*$/;
62
- function b(e11) {
63
- if (e11.length % 2 != 0) throw new _(`fromHexStr: hex string must have even length, got ${e11.length}`);
64
- if (!le.test(e11)) throw new _("fromHexStr: hex string contains non-hex characters");
61
+ var ce = /^[0-9a-fA-F]*$/;
62
+ function x(e11) {
63
+ if (e11.length % 2 != 0) throw new v(`fromHexStr: hex string must have even length, got ${e11.length}`);
64
+ if (!ce.test(e11)) throw new v("fromHexStr: hex string contains non-hex characters");
65
65
  let t2 = new Uint8Array(e11.length / 2);
66
66
  for (let n2 = 0; n2 < t2.length; n2++) t2[n2] = parseInt(e11.substring(n2 * 2, n2 * 2 + 2), 16);
67
67
  return t2;
68
68
  }
69
- var x = (1n << 64n) - 1n, S = 32, ue = S * 2, de = 32, fe = 128, pe = 129, me = 130, C = 131, he = 132, ge = 136, _e = 137, ve = 138, ye = 141, w = 0, be = 32, T = 64, xe = 96, E = 128, Se = 160, D = 192;
69
+ var S = (1n << 64n) - 1n, le = 2n, C = 32, ue = C * 2, de = 32, fe = 128, pe = 129, me = 130, w = 131, he = 132, ge = 136, _e = 137, ve = 138, ye = 141, T = 0, be = 32, E = 64, xe = 96, D = 128, Se = 160, O = 192;
70
70
  function Ce(e11) {
71
71
  switch (typeof e11) {
72
72
  case "bigint":
73
- return O(e11);
73
+ return k(e11);
74
74
  case "string":
75
- return Te(e11);
76
- case "boolean":
77
75
  return Ee(e11);
76
+ case "boolean":
77
+ return Oe(e11);
78
78
  default:
79
- if (e11 instanceof Uint8Array) return k(e11);
80
- throw new _(`literalArg: cannot CBOR-encode value of type ${typeof e11}`);
79
+ if (e11 instanceof Uint8Array) return De(e11);
80
+ throw new v(`literalArg: cannot CBOR-encode value of type ${typeof e11}`);
81
81
  }
82
82
  }
83
- function O(e11) {
84
- if (e11 < 0n) throw new _(`amountLiteral: amount must be non-negative, got ${e11}`);
85
- if (e11 >> 128n != 0n) throw new _(`amountLiteral: amount overflows u128: ${e11}`);
83
+ function k(e11) {
84
+ if (e11 < 0n) throw new v(`amountLiteral: amount must be non-negative, got ${e11}`);
85
+ if (e11 >> 128n != 0n) throw new v(`amountLiteral: amount overflows u128: ${e11}`);
86
86
  let t2 = [];
87
- return F(t2, E, 2n), F(t2, w, e11 & x), F(t2, w, e11 >> 64n & x), I(t2);
87
+ return e11 <= S ? F(t2, T, e11) : we(t2, e11), I(t2);
88
+ }
89
+ function we(e11, t2) {
90
+ let n2 = [], r2 = t2;
91
+ for (; r2 > 0n; ) n2.unshift(Number(r2 & 255n)), r2 >>= 8n;
92
+ F(e11, O, le), F(e11, E, BigInt(n2.length)), P(e11, n2);
88
93
  }
89
- function we(e11) {
94
+ function Te(e11) {
90
95
  let t2 = [];
91
96
  if (e11 >= 0n) {
92
- if (e11 > x) throw new _(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
93
- F(t2, w, e11);
97
+ if (e11 > S) throw new v(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
98
+ F(t2, T, e11);
94
99
  } else {
95
100
  let n2 = -1n - e11;
96
- if (n2 > x) throw new _(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
101
+ if (n2 > S) throw new v(`intLiteral: value exceeds the 64-bit CBOR integer range: ${e11}`);
97
102
  F(t2, be, n2);
98
103
  }
99
104
  return I(t2);
100
105
  }
101
- function Te(e11) {
106
+ function Ee(e11) {
102
107
  let t2 = [];
103
108
  return N(t2, e11), I(t2);
104
109
  }
105
- function k(e11) {
110
+ function De(e11) {
106
111
  let t2 = [];
107
- return F(t2, T, BigInt(e11.length)), P(t2, e11), I(t2);
112
+ return F(t2, E, BigInt(e11.length)), P(t2, e11), I(t2);
108
113
  }
109
- function Ee(e11) {
114
+ function Oe(e11) {
110
115
  return { Literal: e11 ? "f5" : "f4" };
111
116
  }
112
117
  function A(e11) {
113
- return j(C, e11, "resource_");
118
+ return j(w, e11, "resource_");
114
119
  }
115
- function De(e11) {
120
+ function ke(e11) {
116
121
  return j(fe, e11, "component_");
117
122
  }
118
- function Oe(e11) {
119
- let t2 = e11 instanceof Map ? e11 : new Map(Object.entries(e11)), n2 = new TextEncoder(), r2 = [...t2.entries()].sort(([e12], [t3]) => Re(n2.encode(e12), n2.encode(t3))), i2 = [];
120
- F(i2, D, BigInt(pe)), F(i2, Se, BigInt(r2.length));
123
+ function Ae(e11) {
124
+ let t2 = e11 instanceof Map ? e11 : new Map(Object.entries(e11)), n2 = new TextEncoder(), r2 = [...t2.entries()].sort(([e12], [t3]) => Be(n2.encode(e12), n2.encode(t3))), i2 = [];
125
+ F(i2, O, BigInt(pe)), F(i2, Se, BigInt(r2.length));
121
126
  for (let [e12, t3] of r2) N(i2, e12), N(i2, t3);
122
127
  return I(i2);
123
128
  }
124
- function ke(e11) {
129
+ function je(e11) {
125
130
  return j(he, e11, "vault_");
126
131
  }
127
- function Ae(e11) {
132
+ function Me(e11) {
128
133
  return j(_e, e11, "template_");
129
134
  }
130
- function je(e11) {
135
+ function Ne(e11) {
131
136
  return j(ge, e11, "tombstone_");
132
137
  }
133
- function Me(e11) {
138
+ function Pe(e11) {
134
139
  return j(ve, e11, "vnfp_");
135
140
  }
136
- function Ne(e11) {
137
- let t2 = typeof e11 == "string" ? b(e11) : e11;
138
- return v(t2, de, "publicKeyLiteral"), k(t2);
141
+ function Fe(e11) {
142
+ let t2 = typeof e11 == "string" ? x(e11) : e11;
143
+ return y(t2, de, "publicKeyLiteral"), De(t2);
139
144
  }
140
- function Pe(e11) {
145
+ function Ie(e11) {
141
146
  let t2 = [];
142
- return F(t2, D, BigInt(me)), F(t2, E, 2n), M(t2, C, e11.resource_address, "resource_"), Ie(t2, e11.id), I(t2);
147
+ return F(t2, O, BigInt(me)), F(t2, D, 2n), M(t2, w, e11.resource_address, "resource_"), Re(t2, e11.id), I(t2);
143
148
  }
144
- function Fe(e11) {
149
+ function Le(e11) {
145
150
  let t2 = [];
146
- F(t2, D, BigInt(ye)), F(t2, E, 2n), M(t2, C, e11.resource_address, "resource_");
147
- let n2 = b(e11.id);
148
- return v(n2, S, "utxoAddressLiteral: id"), F(t2, T, BigInt(S)), P(t2, n2), I(t2);
151
+ F(t2, O, BigInt(ye)), F(t2, D, 2n), M(t2, w, e11.resource_address, "resource_");
152
+ let n2 = x(e11.id);
153
+ return y(n2, C, "utxoAddressLiteral: id"), F(t2, E, BigInt(C)), P(t2, n2), I(t2);
149
154
  }
150
155
  function j(e11, t2, n2) {
151
156
  let r2 = [];
@@ -153,25 +158,25 @@ function j(e11, t2, n2) {
153
158
  }
154
159
  function M(e11, t2, n2, r2) {
155
160
  let i2 = n2.startsWith(r2) ? n2.slice(r2.length) : n2;
156
- if (i2.length !== ue) throw new _(`${r2}address must be 32 bytes (${ue} hex chars), got ${i2.length}`);
157
- F(e11, D, BigInt(t2)), F(e11, T, BigInt(S)), P(e11, b(i2));
158
- }
159
- function Ie(e11, t2) {
160
- if (F(e11, E, 2n), "U256" in t2) {
161
- F(e11, w, 0n), F(e11, E, 1n);
162
- let n2 = b(t2.U256);
163
- v(n2, S, "NonFungibleId.U256"), F(e11, T, BigInt(S)), P(e11, n2);
164
- } else if ("String" in t2) F(e11, w, 1n), F(e11, E, 1n), N(e11, t2.String);
165
- else if ("Uint32" in t2) F(e11, w, 2n), F(e11, E, 1n), Le(e11, t2.Uint32, "NonFungibleId.Uint32", (1n << 32n) - 1n);
166
- else if ("Uint64" in t2) F(e11, w, 3n), F(e11, E, 1n), Le(e11, t2.Uint64, "NonFungibleId.Uint64", x);
167
- else throw new _(`nonFungibleAddressLiteral: unrecognised NonFungibleId variant: ${JSON.stringify(t2)}`);
168
- }
169
- function Le(e11, t2, n2, r2) {
170
- if (!Number.isInteger(t2) || t2 < 0) throw new _(`${n2} must be a non-negative integer, got ${t2}`);
171
- if (r2 > BigInt(2 ** 53 - 1) && t2 > 2 ** 53 - 1) throw new _(`${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.`);
161
+ if (i2.length !== ue) throw new v(`${r2}address must be 32 bytes (${ue} hex chars), got ${i2.length}`);
162
+ F(e11, O, BigInt(t2)), F(e11, E, BigInt(C)), P(e11, x(i2));
163
+ }
164
+ function Re(e11, t2) {
165
+ if (F(e11, D, 2n), "U256" in t2) {
166
+ F(e11, T, 0n), F(e11, D, 1n);
167
+ let n2 = x(t2.U256);
168
+ y(n2, C, "NonFungibleId.U256"), F(e11, E, BigInt(C)), P(e11, n2);
169
+ } else if ("String" in t2) F(e11, T, 1n), F(e11, D, 1n), N(e11, t2.String);
170
+ else if ("Uint32" in t2) F(e11, T, 2n), F(e11, D, 1n), ze(e11, t2.Uint32, "NonFungibleId.Uint32", (1n << 32n) - 1n);
171
+ else if ("Uint64" in t2) F(e11, T, 3n), F(e11, D, 1n), ze(e11, t2.Uint64, "NonFungibleId.Uint64", S);
172
+ else throw new v(`nonFungibleAddressLiteral: unrecognised NonFungibleId variant: ${JSON.stringify(t2)}`);
173
+ }
174
+ function ze(e11, t2, n2, r2) {
175
+ if (!Number.isInteger(t2) || t2 < 0) throw new v(`${n2} must be a non-negative integer, got ${t2}`);
176
+ if (r2 > BigInt(2 ** 53 - 1) && t2 > 2 ** 53 - 1) throw new v(`${n2} value ${t2} exceeds Number.MAX_SAFE_INTEGER (2^53-1) and cannot be encoded without precision loss \u2014 the binding types this id as a JS number. Use a U256/String id for large values.`);
172
177
  let i2 = BigInt(t2);
173
- if (i2 > r2) throw new _(`${n2} value ${t2} exceeds its maximum of ${r2}`);
174
- F(e11, w, i2);
178
+ if (i2 > r2) throw new v(`${n2} value ${t2} exceeds its maximum of ${r2}`);
179
+ F(e11, T, i2);
175
180
  }
176
181
  function N(e11, t2) {
177
182
  let n2 = new TextEncoder().encode(t2);
@@ -182,7 +187,7 @@ function P(e11, t2) {
182
187
  e11.length = n2 + t2.length;
183
188
  for (let r2 = 0; r2 < t2.length; r2++) e11[n2 + r2] = t2[r2];
184
189
  }
185
- function Re(e11, t2) {
190
+ function Be(e11, t2) {
186
191
  let n2 = Math.min(e11.length, t2.length);
187
192
  for (let r2 = 0; r2 < n2; r2++) if (e11[r2] !== t2[r2]) return e11[r2] < t2[r2] ? -1 : 1;
188
193
  return e11.length - t2.length;
@@ -191,37 +196,48 @@ function F(e11, t2, n2) {
191
196
  n2 < 24n ? e11.push(t2 | Number(n2)) : n2 < 1n << 8n ? e11.push(t2 | 24, Number(n2)) : n2 < 1n << 16n ? e11.push(t2 | 25, Number(n2 >> 8n & 255n), Number(n2 & 255n)) : n2 < 1n << 32n ? e11.push(t2 | 26, Number(n2 >> 24n & 255n), Number(n2 >> 16n & 255n), Number(n2 >> 8n & 255n), Number(n2 & 255n)) : e11.push(t2 | 27, Number(n2 >> 56n & 255n), Number(n2 >> 48n & 255n), Number(n2 >> 40n & 255n), Number(n2 >> 32n & 255n), Number(n2 >> 24n & 255n), Number(n2 >> 16n & 255n), Number(n2 >> 8n & 255n), Number(n2 & 255n));
192
197
  }
193
198
  function I(e11) {
194
- return { Literal: y(Uint8Array.from(e11)) };
199
+ return { Literal: b(Uint8Array.from(e11)) };
195
200
  }
196
201
  function L(e11) {
197
- return O(e11);
202
+ return k(e11);
198
203
  }
199
- function ze(e11) {
200
- if (e11 < 0n) throw new _(`microTariString: amount must be non-negative, got ${e11}`);
204
+ function Ve(e11) {
205
+ if (e11 < 0n) throw new v(`microTariString: amount must be non-negative, got ${e11}`);
201
206
  return e11.toString();
202
207
  }
203
- function Be(e11) {
208
+ function He(e11) {
204
209
  let t2 = e11.split(".");
205
- if (t2.length > 2) throw new _("Invalid workspace key format. Only one dot is allowed.");
210
+ if (t2.length > 2) throw new v("Invalid workspace key format. Only one dot is allowed.");
206
211
  let n2 = t2[0];
207
212
  if (t2[1] === void 0) return {
208
213
  name: n2,
209
214
  offset: null
210
215
  };
211
216
  let r2 = Number.parseInt(t2[1], 10);
212
- if (Number.isNaN(r2) || r2 < 0 || String(r2) !== t2[1]) throw new _(`Invalid workspace key offset: "${t2[1]}"`);
217
+ if (Number.isNaN(r2) || r2 < 0 || String(r2) !== t2[1]) throw new v(`Invalid workspace key offset: "${t2[1]}"`);
213
218
  return {
214
219
  name: n2,
215
220
  offset: r2
216
221
  };
217
222
  }
218
- function Ve(e11) {
223
+ var Ue = 2160, We = 10;
224
+ async function Ge(e11, t2 = 10) {
225
+ if (!Number.isInteger(t2) || t2 < 1) throw new v(`resolveMaxEpoch: leadEpochs must be a positive integer, got ${t2}`);
226
+ if (t2 > 2160) throw new v(`resolveMaxEpoch: leadEpochs ${t2} exceeds the network's maximum validity window of ${Ue} epochs`);
227
+ return await e11.getCurrentEpoch() + t2;
228
+ }
229
+ var Ke = (1n << 64n) - 1n;
230
+ function R(e11, t2) {
231
+ if (!Number.isInteger(e11) || e11 < 0) throw new v(`${t2} must be a non-negative integer epoch, got ${e11}`);
232
+ return e11;
233
+ }
234
+ function qe(e11) {
219
235
  return e11.startsWith("template_") ? e11.slice(9) : e11;
220
236
  }
221
- function He(e11) {
237
+ function Je(e11) {
222
238
  return typeof e11 != "object" || !e11 ? null : "PutLastInstructionOutputOnWorkspace" in e11 ? e11.PutLastInstructionOutputOnWorkspace.key : "TakeFromBucket" in e11 ? e11.TakeFromBucket.output_bucket : "AllocateAddress" in e11 ? e11.AllocateAddress.workspace_id : null;
223
239
  }
224
- var Ue = class {
240
+ var Ye = class {
225
241
  constructor() {
226
242
  __publicField(this, "nextId", 0);
227
243
  __publicField(this, "ids", /* @__PURE__ */ new Map());
@@ -245,16 +261,16 @@ var Ue = class {
245
261
  resetFrom(e11) {
246
262
  this.reset();
247
263
  for (let t2 of e11) {
248
- let e12 = He(t2);
264
+ let e12 = Je(t2);
249
265
  e12 !== null && this.observeAllocated(e12);
250
266
  }
251
267
  }
252
268
  };
253
- function We(e11) {
254
- return new _(`No workspace variable named "${e11}" has been defined. Call builder.saveVar(${JSON.stringify(e11)}) on a preceding instruction whose output you want to reference.`);
269
+ function Xe(e11) {
270
+ return new v(`No workspace variable named "${e11}" has been defined. Call builder.saveVar(${JSON.stringify(e11)}) on a preceding instruction whose output you want to reference.`);
255
271
  }
256
- var R = class e2 {
257
- constructor(e11) {
272
+ var z = class e2 {
273
+ constructor(e11, t2) {
258
274
  __publicField(this, "unsignedTransaction");
259
275
  __publicField(this, "workspaceIds");
260
276
  __publicField(this, "feeWorkspaceIds");
@@ -264,19 +280,20 @@ var R = class e2 {
264
280
  instructions: [],
265
281
  inputs: [],
266
282
  min_epoch: null,
267
- max_epoch: null,
283
+ max_epoch: R(t2, "maxEpoch"),
268
284
  dry_run: false,
269
285
  is_seal_signer_authorized: false,
270
- blobs: []
271
- }, this.workspaceIds = new Ue(), this.feeWorkspaceIds = new Ue();
286
+ blobs: [],
287
+ nonce: 0
288
+ }, this.workspaceIds = new Ye(), this.feeWorkspaceIds = new Ye();
272
289
  }
273
- static new(t2) {
274
- return new e2(t2);
290
+ static new(t2, n2) {
291
+ return new e2(t2, n2);
275
292
  }
276
293
  callFunction(e11, t2) {
277
294
  let n2 = this.resolveArgs(t2);
278
295
  return this.addInstruction({ CallFunction: {
279
- address: Ve(e11.templateAddress),
296
+ address: qe(e11.templateAddress),
280
297
  function: e11.functionName,
281
298
  args: n2
282
299
  } });
@@ -285,7 +302,7 @@ var R = class e2 {
285
302
  let n2;
286
303
  if (e11.componentAddress) n2 = { Address: e11.componentAddress };
287
304
  else if (e11.fromWorkspace) n2 = { Workspace: this.requireNamedId(e11.fromWorkspace) };
288
- else throw new _("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.");
305
+ else throw new v("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.");
289
306
  let r2 = this.resolveArgs(t2);
290
307
  return this.addInstruction({ CallMethod: {
291
308
  call: n2,
@@ -334,7 +351,7 @@ var R = class e2 {
334
351
  } });
335
352
  }
336
353
  feeTransactionPayFromComponentConfidential(e11, t2) {
337
- throw new _("feeTransactionPayFromComponentConfidential is not implemented: a ConfidentialWithdrawProof Literal must be tari_bor-CBOR-encoded, which the TS SDK does not yet support.");
354
+ throw new v("feeTransactionPayFromComponentConfidential is not implemented: a ConfidentialWithdrawProof Literal must be tari_bor-CBOR-encoded, which the TS SDK does not yet support.");
338
355
  }
339
356
  dropAllProofsInWorkspace() {
340
357
  return this.addInstruction("DropAllProofsInWorkspace");
@@ -360,12 +377,12 @@ var R = class e2 {
360
377
  }
361
378
  observeAllocations(e11, t2) {
362
379
  for (let n2 of t2) {
363
- let t3 = He(n2);
380
+ let t3 = Je(n2);
364
381
  t3 !== null && e11.observeAllocated(t3);
365
382
  }
366
383
  }
367
384
  withFeeInstructionsBuilder(t2) {
368
- let n2 = t2(new e2(this.unsignedTransaction.network));
385
+ let n2 = t2(new e2(this.unsignedTransaction.network, this.unsignedTransaction.max_epoch));
369
386
  return this.unsignedTransaction.fee_instructions = n2.unsignedTransaction.instructions, this.feeWorkspaceIds.resetFrom(this.unsignedTransaction.fee_instructions), this;
370
387
  }
371
388
  addInput(e11) {
@@ -375,10 +392,16 @@ var R = class e2 {
375
392
  return this.unsignedTransaction.inputs.push(...e11), this;
376
393
  }
377
394
  withMinEpoch(e11) {
378
- return this.unsignedTransaction.min_epoch = e11, this;
395
+ return this.unsignedTransaction.min_epoch = R(e11, "minEpoch"), this;
379
396
  }
380
397
  withMaxEpoch(e11) {
381
- return this.unsignedTransaction.max_epoch = e11, this;
398
+ return this.unsignedTransaction.max_epoch = R(e11, "maxEpoch"), this;
399
+ }
400
+ withNonce(e11) {
401
+ if (typeof e11 == "number" && !Number.isInteger(e11)) throw new v(`withNonce: nonce must be an integer, got ${e11}`);
402
+ let t2 = typeof e11 == "bigint" ? e11 : BigInt(e11);
403
+ if (t2 < 0n || t2 > Ke) throw new v(`withNonce: nonce must fit an unsigned 64-bit integer, got ${e11}`);
404
+ return this.unsignedTransaction.nonce = t2 > BigInt(2 ** 53 - 1) ? t2 : Number(t2), this;
382
405
  }
383
406
  withUnsignedTransaction(e11) {
384
407
  return this.unsignedTransaction = {
@@ -386,7 +409,9 @@ var R = class e2 {
386
409
  instructions: [...e11.instructions],
387
410
  fee_instructions: [...e11.fee_instructions],
388
411
  inputs: [...e11.inputs],
389
- blobs: [...e11.blobs ?? []]
412
+ blobs: [...e11.blobs ?? []],
413
+ nonce: e11.nonce ?? 0,
414
+ max_epoch: R(e11.max_epoch, "withUnsignedTransaction: max_epoch")
390
415
  }, this.workspaceIds.resetFrom(this.unsignedTransaction.instructions), this.feeWorkspaceIds.resetFrom(this.unsignedTransaction.fee_instructions), this;
391
416
  }
392
417
  resolveWorkspaceOffsetId(e11) {
@@ -406,11 +431,11 @@ var R = class e2 {
406
431
  }
407
432
  requireNamedId(e11) {
408
433
  let t2 = this.workspaceIds.get(e11);
409
- if (t2 === void 0) throw We(e11);
434
+ if (t2 === void 0) throw Xe(e11);
410
435
  return t2;
411
436
  }
412
437
  getOffsetIdFromWorkspaceName(e11) {
413
- let t2 = Be(e11);
438
+ let t2 = He(e11);
414
439
  return {
415
440
  id: this.requireNamedId(t2.name),
416
441
  offset: t2.offset
@@ -419,27 +444,27 @@ var R = class e2 {
419
444
  resolveArgs(e11) {
420
445
  return e11.map((e12) => typeof e12 == "object" && e12 && "Workspace" in e12 && typeof e12.Workspace == "string" ? { Workspace: this.getOffsetIdFromWorkspaceName(e12.Workspace) } : e12);
421
446
  }
422
- }, Ge = {
423
- [l.LocalNet]: "http://localhost:12500",
424
- [l.Esmeralda]: "https://ootle-indexer-a.tari.com"
447
+ }, Ze = {
448
+ [u.LocalNet]: "http://localhost:12500",
449
+ [u.Esmeralda]: "https://ootle-indexer-a.tari.com"
425
450
  };
426
- function Ke(e11) {
427
- let t2 = Ge[e11];
451
+ function Qe(e11) {
452
+ let t2 = Ze[e11];
428
453
  if (t2 !== void 0) return t2;
429
- throw new _(`No default indexer URL is configured for ${l[e11]}. Pass an explicit URL via ProviderBuilder.withUrl(...) or IndexerProvider.connect({ url, network: Network.${l[e11]} }).`);
454
+ throw new v(`No default indexer URL is configured for ${u[e11]}. Pass an explicit URL via ProviderBuilder.withUrl(...) or IndexerProvider.connect({ url, network: Network.${u[e11]} }).`);
430
455
  }
431
- var qe = 132, Je = 32;
432
- function* Ye(e11) {
456
+ var $e = 132, et = 32;
457
+ function* tt(e11) {
433
458
  let t2 = /* @__PURE__ */ new Set();
434
- for (let n2 of z(e11, qe)) n2.length === Je * 2 && !t2.has(n2) && (t2.add(n2), yield `vault_${n2}`);
459
+ for (let n2 of B(e11, $e)) n2.length === et * 2 && !t2.has(n2) && (t2.add(n2), yield `vault_${n2}`);
435
460
  }
436
- async function Xe(e11, t2) {
461
+ async function nt(e11, t2) {
437
462
  let n2 = (await e11.getSubstate(t2)).substate;
438
- return Qe(n2) ? Array.from(Ye(n2.Component.body.state)) : [];
463
+ return it(n2) ? Array.from(tt(n2.Component.body.state)) : [];
439
464
  }
440
- function* z(e11, t2) {
465
+ function* B(e11, t2) {
441
466
  if (Array.isArray(e11)) {
442
- for (let n3 of e11) yield* z(n3, t2);
467
+ for (let n3 of e11) yield* B(n3, t2);
443
468
  return;
444
469
  }
445
470
  if (typeof e11 != "object" || !e11) return;
@@ -448,101 +473,102 @@ function* z(e11, t2) {
448
473
  if (r2 === "tag") {
449
474
  let e12 = n2.value;
450
475
  if (n2.tag === t2) {
451
- let t3 = Ze(e12);
476
+ let t3 = rt(e12);
452
477
  t3 !== null && (yield t3);
453
478
  }
454
- yield* z(e12, t2);
479
+ yield* B(e12, t2);
455
480
  } else if (r2 === "map") {
456
481
  let e12 = n2.entries;
457
- if (Array.isArray(e12)) for (let n3 of e12) Array.isArray(n3) && n3.length === 2 && (yield* z(n3[0], t2), yield* z(n3[1], t2));
482
+ if (Array.isArray(e12)) for (let n3 of e12) Array.isArray(n3) && n3.length === 2 && (yield* B(n3[0], t2), yield* B(n3[1], t2));
458
483
  }
459
484
  return;
460
485
  }
461
- for (let e12 of Object.values(n2)) yield* z(e12, t2);
486
+ for (let e12 of Object.values(n2)) yield* B(e12, t2);
462
487
  }
463
- function Ze(e11) {
488
+ function rt(e11) {
464
489
  if (typeof e11 != "object" || !e11) return null;
465
490
  let t2 = e11;
466
491
  if (t2["@cbor"] !== "bytes") return null;
467
492
  let n2 = t2.hex;
468
493
  return typeof n2 == "string" ? n2 : null;
469
494
  }
470
- function Qe(e11) {
495
+ function it(e11) {
471
496
  return typeof e11 == "object" && !!e11 && "Component" in e11;
472
497
  }
473
- var $e = "resource_0101010101010101010101010101010101010101010101010101010101010101", et = "component_0102030000000000000000000000000000000000000000000000000000000000", tt = "vault_0102030000000000000000000000000000000000000000000000000000000001", nt = "resource_0102030000000000000000000000000000000000000000000000000000000002", rt = "__ootleRawJson", it = "stealth_revealed_input", at = "stealth_revealed_change";
474
- function ot(e11, t2) {
498
+ var at = "resource_0101010101010101010101010101010101010101010101010101010101010101", ot = "component_0102030000000000000000000000000000000000000000000000000000000000", st = "vault_0102030000000000000000000000000000000000000000000000000000000001", ct = "resource_0102030000000000000000000000000000000000000000000000000000000002", lt = "__ootleRawJson", ut = "stealth_revealed_input", dt = "stealth_revealed_change";
499
+ function ft(e11, t2) {
475
500
  let n2 = e11.revealedInputBucket === null ? null : t2(e11.revealedInputBucket);
476
501
  return { StealthTransfer: {
477
502
  resource_address_ref: { Address: e11.resourceAddress },
478
- statement: B(e11.statement),
503
+ statement: V(e11.statement),
479
504
  revealed_input_bucket: n2
480
505
  } };
481
506
  }
482
- function B(e11) {
483
- return { [rt]: e11.toCompactJson() };
484
- }
485
507
  function V(e11) {
486
- return typeof e11 == "object" && !!e11 && "StealthTransfer" in e11;
508
+ return { [lt]: e11.toCompactJson() };
487
509
  }
488
510
  function H(e11) {
511
+ return typeof e11 == "object" && !!e11 && "StealthTransfer" in e11;
512
+ }
513
+ function U(e11) {
489
514
  let t2 = [], n2 = (e12) => `__ootleRawJson:${e12}__`, r2 = JSON.stringify(e11, (e12, r3) => {
515
+ if (typeof r3 == "bigint") return r3.toString();
490
516
  if (typeof r3 == "object" && r3 && "__ootleRawJson" in r3) {
491
517
  let e13 = n2(t2.length);
492
- return t2.push(r3[rt]), e13;
518
+ return t2.push(r3[lt]), e13;
493
519
  }
494
520
  return r3;
495
521
  });
496
522
  for (let e12 = 0; e12 < t2.length; e12++) {
497
523
  let i2 = JSON.stringify(n2(e12)), a2 = r2.indexOf(i2);
498
- if (a2 < 0) throw new _(`serializeUnsignedTx: raw-JSON placeholder ${e12} was not emitted`);
499
- if (r2.indexOf(i2, a2 + i2.length) >= 0) throw new _(`serializeUnsignedTx: raw-JSON placeholder ${e12} collided with transaction data`);
524
+ if (a2 < 0) throw new v(`serializeUnsignedTx: raw-JSON placeholder ${e12} was not emitted`);
525
+ if (r2.indexOf(i2, a2 + i2.length) >= 0) throw new v(`serializeUnsignedTx: raw-JSON placeholder ${e12} collided with transaction data`);
500
526
  r2 = r2.slice(0, a2) + t2[e12] + r2.slice(a2 + i2.length);
501
527
  }
502
528
  return r2;
503
529
  }
504
- async function U(e11, t2) {
530
+ async function W(e11, t2) {
505
531
  let n2 = await e11.resolveInputs(t2.inputs);
506
532
  return {
507
533
  ...t2,
508
534
  inputs: n2
509
535
  };
510
536
  }
511
- function st() {
537
+ function pt() {
512
538
  let { secret_key: e11, public_key: t2 } = a();
513
539
  return {
514
540
  secret_key: e11,
515
541
  public_key: t2
516
542
  };
517
543
  }
518
- function ct(e11, t2) {
544
+ function mt(e11, t2) {
519
545
  return {
520
- public_key: y(v(e11, 32, "publicKey")),
546
+ public_key: b(y(e11, 32, "publicKey")),
521
547
  signature: {
522
- public_nonce: y(v(t2.public_nonce, 32, "schnorr.public_nonce")),
523
- signature: y(v(t2.signature, 32, "schnorr.signature"))
548
+ public_nonce: b(y(t2.public_nonce, 32, "schnorr.public_nonce")),
549
+ signature: b(y(t2.signature, 32, "schnorr.signature"))
524
550
  }
525
551
  };
526
552
  }
527
- async function W(e11, t2, n2) {
528
- let r2 = n2 ?? a(), i2 = v(r2.secret_key, 32, "sealKeypair.secret_key"), o2 = v(r2.public_key, 32, "sealKeypair.public_key"), s2 = [];
553
+ async function G(e11, t2, n2) {
554
+ let r2 = n2 ?? a(), i2 = y(r2.secret_key, 32, "sealKeypair.secret_key"), o2 = y(r2.public_key, 32, "sealKeypair.public_key"), s2 = [];
529
555
  for (let n3 of e11) {
530
556
  let e12 = await n3.signTransaction(t2, o2);
531
557
  s2.push(...e12);
532
558
  }
533
- let c2 = ee(`{"transaction":${H(t2)},"signatures":${JSON.stringify(s2)}}`, i2);
559
+ let c2 = l(`{"transaction":${U(t2)},"signatures":${JSON.stringify(s2)}}`, i2);
534
560
  return {
535
561
  sealedJson: c2,
536
562
  transaction: JSON.parse(c2)
537
563
  };
538
564
  }
539
- function G(e11) {
565
+ function K(e11) {
540
566
  return t(e11.sealedJson);
541
567
  }
542
- async function lt(e11, t2) {
568
+ async function ht(e11, t2) {
543
569
  return (await e11.submitTransaction(t2)).transaction_id;
544
570
  }
545
- function ut(e11) {
571
+ function gt(e11) {
546
572
  var _a, _b;
547
573
  if (e11 === "Pending" || !("Finalized" in e11)) return null;
548
574
  let t2 = e11.Finalized, n2 = t2.final_decision;
@@ -558,42 +584,42 @@ function ut(e11) {
558
584
  reason: e12
559
585
  };
560
586
  }
561
- throw new _(`Unexpected final_decision variant: ${JSON.stringify(n2)}`);
587
+ throw new v(`Unexpected final_decision variant: ${JSON.stringify(n2)}`);
562
588
  }
563
- async function dt(e11, t2, n2) {
589
+ async function _t(e11, t2, n2) {
564
590
  let r2 = (n2 == null ? void 0 : n2.pollIntervalMs) ?? 500, i2 = (n2 == null ? void 0 : n2.timeoutMs) ?? 6e4, a2 = Date.now() + i2;
565
591
  for (; ; ) {
566
592
  let n3 = await e11.getTransactionResult(t2), o2 = n3.result;
567
593
  if (o2 !== "Pending" && "Finalized" in o2) {
568
- let { outcome: e12, reason: r3 } = ut(o2) ?? { outcome: "Reject" };
569
- if (e12 === "Reject") throw new d(`Transaction ${t2} was rejected: ${r3}`, {
594
+ let { outcome: e12, reason: r3 } = gt(o2) ?? { outcome: "Reject" };
595
+ if (e12 === "Reject") throw new f(`Transaction ${t2} was rejected: ${r3}`, {
570
596
  txId: t2,
571
597
  reason: r3 ?? ""
572
598
  });
573
- if (e12 === "FeeIntentCommit") throw new d(`Transaction ${t2} only committed fees (execution aborted): ${r3}`, {
599
+ if (e12 === "FeeIntentCommit") throw new f(`Transaction ${t2} only committed fees (execution aborted): ${r3}`, {
574
600
  txId: t2,
575
601
  reason: `FeeIntentCommit: ${r3 ?? ""}`
576
602
  });
577
603
  return n3;
578
604
  }
579
- if (Date.now() >= a2) throw new oe(`Transaction ${t2} did not finalize within ${i2}ms`, { txId: t2 });
605
+ if (Date.now() >= a2) throw new ae(`Transaction ${t2} did not finalize within ${i2}ms`, { txId: t2 });
580
606
  await new Promise((e12) => setTimeout(e12, r2));
581
607
  }
582
608
  }
583
- async function ft(e11, t2, n2, r2) {
584
- let i2 = await U(e11, n2);
585
- return dt(e11, await lt(e11, G(await W(Array.isArray(t2) ? t2 : [t2], i2))), r2);
609
+ async function vt(e11, t2, n2, r2) {
610
+ let i2 = await W(e11, n2);
611
+ return _t(e11, await ht(e11, K(await G(Array.isArray(t2) ? t2 : [t2], i2))), r2);
586
612
  }
587
- async function pt(e11, t2, n2, r2) {
588
- return ft(e11, t2, {
613
+ async function yt(e11, t2, n2, r2) {
614
+ return vt(e11, t2, {
589
615
  ...n2,
590
616
  dry_run: true
591
617
  }, r2);
592
618
  }
593
- var mt = class {
594
- constructor(e11) {
619
+ var bt = class {
620
+ constructor(e11, t2) {
595
621
  __publicField(this, "builder");
596
- this.builder = R.new(e11);
622
+ this.builder = z.new(e11, t2);
597
623
  }
598
624
  withInputs(e11) {
599
625
  return this.builder.withInputs(e11), this;
@@ -616,11 +642,11 @@ var mt = class {
616
642
  build() {
617
643
  return this.builder.buildUnsignedTransaction();
618
644
  }
619
- }, ht = class {
620
- constructor(e11, t2) {
645
+ }, xt = class {
646
+ constructor(e11, t2, n2) {
621
647
  __publicField(this, "builder");
622
648
  __publicField(this, "faucetAddress");
623
- this.builder = R.new(e11), this.faucetAddress = t2;
649
+ this.builder = z.new(e11, t2), this.faucetAddress = n2;
624
650
  }
625
651
  feeTransactionPayFromComponent(e11, t2) {
626
652
  return this.builder.feeTransactionPayFromComponent(e11, t2), this;
@@ -653,7 +679,7 @@ var mt = class {
653
679
  build() {
654
680
  return this.builder.buildUnsignedTransaction();
655
681
  }
656
- }, gt = class {
682
+ }, St = class {
657
683
  constructor() {
658
684
  __publicField(this, "keyProviders");
659
685
  __publicField(this, "defaultSignerAddress", null);
@@ -666,7 +692,7 @@ var mt = class {
666
692
  return this.requireKeyProvider(e11, "explicit"), this.defaultSignerAddress = e11, this;
667
693
  }
668
694
  async getAddress() {
669
- if (!this.defaultSignerAddress) throw new m("No default signer address set. Call setDefaultSigner() first.");
695
+ if (!this.defaultSignerAddress) throw new h("No default signer address set. Call setDefaultSigner() first.");
670
696
  return Promise.resolve(this.defaultSignerAddress);
671
697
  }
672
698
  async getPublicKey() {
@@ -691,26 +717,26 @@ var mt = class {
691
717
  return [...this.keyProviders.keys()];
692
718
  }
693
719
  getSignerOrThrow() {
694
- if (!this.defaultSignerAddress) throw new m("No default signer address set. Call setDefaultSigner() first.");
720
+ if (!this.defaultSignerAddress) throw new h("No default signer address set. Call setDefaultSigner() first.");
695
721
  return this.requireKeyProvider(this.defaultSignerAddress, "default");
696
722
  }
697
723
  requireKeyProvider(e11, t2) {
698
724
  let n2 = this.keyProviders.get(e11);
699
- if (n2 === void 0) throw new p(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 });
725
+ if (n2 === void 0) throw new m(t2 === "default" ? `No key provider registered for default address: ${e11}. Call wallet.registerKeyProvider(address, signer) for that address, or pick a different default with setDefaultSigner(otherAddress).` : `No key provider registered for address: ${e11}. Call wallet.registerKeyProvider(${JSON.stringify(e11)}, signer) before signing.`, { address: e11 });
700
726
  return n2;
701
727
  }
702
- }, _t = class {
728
+ }, Ct = class {
703
729
  constructor(e11, t2) {
704
730
  __publicField(this, "bytes");
705
- this.bytes = new Uint8Array(v(e11, 32, t2));
731
+ this.bytes = new Uint8Array(y(e11, 32, t2));
706
732
  }
707
733
  toBytes() {
708
734
  return new Uint8Array(this.bytes);
709
735
  }
710
736
  toHex() {
711
- return y(this.bytes);
737
+ return b(this.bytes);
712
738
  }
713
- }, K = class e3 extends _t {
739
+ }, q = class e3 extends Ct {
714
740
  constructor(e11) {
715
741
  super(e11, "Mask");
716
742
  }
@@ -721,44 +747,44 @@ var mt = class {
721
747
  return new e3(t2);
722
748
  }
723
749
  static fromHex(t2) {
724
- return new e3(b(t2));
750
+ return new e3(x(t2));
725
751
  }
726
- }, vt = class e4 {
752
+ }, wt = class e4 {
727
753
  constructor(e11) {
728
754
  __publicField(this, "bytes");
729
755
  this.bytes = new Uint8Array(e11);
730
756
  }
731
757
  static fromHex(t2) {
732
- return new e4(b(t2));
758
+ return new e4(x(t2));
733
759
  }
734
760
  toBytes() {
735
761
  return new Uint8Array(this.bytes);
736
762
  }
737
763
  toHex() {
738
- return y(this.bytes);
764
+ return b(this.bytes);
739
765
  }
740
- }, yt = Object.freeze({ StealthPublicKey: Object.freeze({}) });
741
- function bt(e11) {
742
- if (e11.amount <= 0n) throw new _(`Output amount must be > 0, got ${e11.amount}`);
766
+ }, Tt = Object.freeze({ StealthPublicKey: Object.freeze({}) });
767
+ function Et(e11) {
768
+ if (e11.amount <= 0n) throw new v(`Output amount must be > 0, got ${e11.amount}`);
743
769
  return {
744
770
  destination: e11.destination,
745
771
  amount: e11.amount,
746
772
  resourceAddress: e11.resourceAddress,
747
773
  resourceViewKey: e11.resourceViewKey === void 0 ? void 0 : new Uint8Array(e11.resourceViewKey),
748
774
  memo: e11.memo,
749
- payTo: e11.payTo ?? yt,
775
+ payTo: e11.payTo ?? Tt,
750
776
  minimumValuePromise: e11.minimumValuePromise ?? 0n
751
777
  };
752
778
  }
753
- function xt(e11, t2) {
754
- if (e11.trim() === "") throw new _(`${t2} must be a non-empty decimal string`);
779
+ function Dt(e11, t2) {
780
+ if (e11.trim() === "") throw new v(`${t2} must be a non-empty decimal string`);
755
781
  return BigInt(e11);
756
782
  }
757
- function St(e11, t2) {
783
+ function Ot(e11, t2) {
758
784
  let n2 = e11.trim();
759
- if (!n2.startsWith("{") || !n2.endsWith("}")) throw new _(`StealthTransferStatement.toCompactJson: ${t2} fragment is not a JSON object (got: ${e11.slice(0, 60)}...)`);
785
+ if (!n2.startsWith("{") || !n2.endsWith("}")) throw new v(`StealthTransferStatement.toCompactJson: ${t2} fragment is not a JSON object (got: ${e11.slice(0, 60)}...)`);
760
786
  }
761
- var q = class e5 extends _t {
787
+ var J = class e5 extends Ct {
762
788
  constructor(e11) {
763
789
  super(e11, "StealthInput.commitment");
764
790
  }
@@ -769,13 +795,13 @@ var q = class e5 extends _t {
769
795
  return { commitment: this.toHex() };
770
796
  }
771
797
  static fromJSON(t2) {
772
- return new e5(b(t2.commitment));
798
+ return new e5(x(t2.commitment));
773
799
  }
774
- }, J = class e6 {
800
+ }, Y = class e6 {
775
801
  constructor(e11, t2) {
776
802
  __publicField(this, "_publicNonce");
777
803
  __publicField(this, "_signature");
778
- this._publicNonce = new Uint8Array(v(e11, 32, "BalanceProofSignature.publicNonce")), this._signature = new Uint8Array(v(t2, 32, "BalanceProofSignature.signature"));
804
+ this._publicNonce = new Uint8Array(y(e11, 32, "BalanceProofSignature.publicNonce")), this._signature = new Uint8Array(y(t2, 32, "BalanceProofSignature.signature"));
779
805
  }
780
806
  get publicNonce() {
781
807
  return new Uint8Array(this._publicNonce);
@@ -785,14 +811,14 @@ var q = class e5 extends _t {
785
811
  }
786
812
  toJSON() {
787
813
  return {
788
- public_nonce: y(this._publicNonce),
789
- signature: y(this._signature)
814
+ public_nonce: b(this._publicNonce),
815
+ signature: b(this._signature)
790
816
  };
791
817
  }
792
818
  static fromJSON(t2) {
793
- return new e6(b(t2.public_nonce), b(t2.signature));
819
+ return new e6(x(t2.public_nonce), x(t2.signature));
794
820
  }
795
- }, Y = class e7 {
821
+ }, X = class e7 {
796
822
  constructor(e11, t2, n2) {
797
823
  __publicField(this, "inputs");
798
824
  __publicField(this, "revealedAmount");
@@ -805,13 +831,13 @@ var q = class e5 extends _t {
805
831
  toJSON() {
806
832
  return {
807
833
  inputs: this.inputs.map((e11) => e11.toJSON()),
808
- revealed_amount: ze(this.revealedAmount)
834
+ revealed_amount: Ve(this.revealedAmount)
809
835
  };
810
836
  }
811
837
  static fromJSON(t2) {
812
- return new e7(t2.inputs.map(q.fromJSON), xt(t2.revealed_amount, "revealed_amount"));
838
+ return new e7(t2.inputs.map(J.fromJSON), Dt(t2.revealed_amount, "revealed_amount"));
813
839
  }
814
- }, X = class e8 {
840
+ }, Z = class e8 {
815
841
  constructor(e11) {
816
842
  __publicField(this, "statementJson");
817
843
  this.statementJson = e11;
@@ -825,7 +851,7 @@ var q = class e5 extends _t {
825
851
  static fromJSON(t2) {
826
852
  return new e8(t2);
827
853
  }
828
- }, Z = class e9 {
854
+ }, Q = class e9 {
829
855
  constructor(e11, t2, n2) {
830
856
  __publicField(this, "inputsStatement");
831
857
  __publicField(this, "outputsStatement");
@@ -841,117 +867,118 @@ var q = class e5 extends _t {
841
867
  }
842
868
  toCompactJson() {
843
869
  let e11 = this.inputsStatement.statementJson ?? JSON.stringify(this.inputsStatement.toJSON()), t2 = this.outputsStatement.statementJson;
844
- St(e11, "inputs_statement"), St(t2, "outputs_statement");
870
+ Ot(e11, "inputs_statement"), Ot(t2, "outputs_statement");
845
871
  let n2 = `{"inputs_statement":${e11},"outputs_statement":${t2},"covenant_claims":[]`;
846
872
  return this.balanceProof !== void 0 && (n2 += `,"balance_proof":${JSON.stringify(this.balanceProof.toJSON())}`), n2 + "}";
847
873
  }
848
874
  static fromJSON(t2) {
849
- return new e9(Y.fromJSON(t2.inputs), X.fromJSON(t2.outputs), t2.balance_proof === void 0 ? void 0 : J.fromJSON(t2.balance_proof));
875
+ return new e9(X.fromJSON(t2.inputs), Z.fromJSON(t2.outputs), t2.balance_proof === void 0 ? void 0 : Y.fromJSON(t2.balance_proof));
850
876
  }
851
877
  };
852
- function Ct(e11, t2) {
878
+ function kt(e11, t2) {
853
879
  let n2 = new Uint8Array(e11.length * 32);
854
880
  for (let r2 = 0; r2 < e11.length; r2++) {
855
881
  let i2 = e11[r2];
856
- v(i2, 32, `${t2}[${r2}]`), n2.set(i2, r2 * 32);
882
+ y(i2, 32, `${t2}[${r2}]`), n2.set(i2, r2 * 32);
857
883
  }
858
884
  return n2;
859
885
  }
860
- var Q = class {
861
- constructor(e11 = l.LocalNet) {
886
+ var At = class {
887
+ constructor(e11 = u.LocalNet) {
862
888
  __publicField(this, "network");
863
889
  this.network = e11;
864
890
  }
865
891
  async generateOutputsStatement(e11, t2) {
866
892
  let n2 = s(`[${e11.map((e12) => this.outputWitness(e12)).join(",")}]`, t2);
867
- return v(n2.aggregated_output_mask, 32, "StealthOutputsResult.aggregated_output_mask"), {
868
- statement: X.fromJSON(n2.statement_json),
869
- outputMask: K.fromBytes(n2.aggregated_output_mask)
893
+ return y(n2.aggregated_output_mask, 32, "StealthOutputsResult.aggregated_output_mask"), {
894
+ statement: Z.fromJSON(n2.statement_json),
895
+ outputMask: q.fromBytes(n2.aggregated_output_mask)
870
896
  };
871
897
  }
872
898
  outputWitness(e11) {
873
- let t2 = c(e11.destination), n2 = wt(e11.payTo) ? null : JSON.stringify(e11.payTo), i2 = e11.memo === void 0 ? null : JSON.stringify(e11.memo), a2 = e11.resourceViewKey ?? null;
899
+ let t2 = c(e11.destination), n2 = jt(e11.payTo) ? null : JSON.stringify(e11.payTo), i2 = e11.memo === void 0 ? null : JSON.stringify(e11.memo), a2 = e11.resourceViewKey ?? null;
874
900
  return r(this.network, t2.owner_key, t2.view_key, e11.amount, e11.resourceAddress, a2, i2, n2, e11.minimumValuePromise);
875
901
  }
876
902
  async buildInputsStatement(e11, t2) {
877
- return new Y(e11, t2, n(Ct(e11.map((e12) => e12.commitment), "input commitment"), t2));
903
+ return new X(e11, t2, n(kt(e11.map((e12) => e12.commitment), "input commitment"), t2));
878
904
  }
879
905
  async generateBalanceProofSignature(e11, t2, n2, r2) {
880
906
  let i2 = o(e11.toBytes(), t2.toBytes(), n2, r2);
881
- return v(i2.public_nonce, 32, "balance proof public_nonce"), v(i2.signature, 32, "balance proof signature"), new J(i2.public_nonce, i2.signature);
907
+ return y(i2.public_nonce, 32, "balance proof public_nonce"), y(i2.signature, 32, "balance proof signature"), new Y(i2.public_nonce, i2.signature);
882
908
  }
883
909
  async validateBalanceProofSignature(e11, t2, n2) {
884
- return re(e11.publicNonce, e11.signature, t2, n2);
910
+ return ne(e11.publicNonce, e11.signature, t2, n2);
885
911
  }
886
912
  async deriveAeadKey(e11, t2) {
887
- v(e11, 32, "deriveAeadKey privateKey"), v(t2, 32, "deriveAeadKey publicKey");
913
+ y(e11, 32, "deriveAeadKey privateKey"), y(t2, 32, "deriveAeadKey publicKey");
888
914
  let n2 = i(e11, t2);
889
- return v(n2, 32, "derived AEAD key"), n2;
915
+ return y(n2, 32, "derived AEAD key"), n2;
890
916
  }
891
917
  async unblindOutput(e11, t2, n2, r2) {
892
- v(e11, 32, "unblindOutput commitment"), v(n2, 32, "unblindOutput aeadKey");
893
- let i2 = ne(e11, t2, n2, r2);
918
+ y(e11, 32, "unblindOutput commitment"), y(n2, 32, "unblindOutput aeadKey");
919
+ let i2 = te(e11, t2, n2, r2);
894
920
  return {
895
- mask: K.fromBytes(i2.mask),
921
+ mask: q.fromBytes(i2.mask),
896
922
  value: i2.value,
897
923
  memo: i2.memo_json ?? void 0
898
924
  };
899
925
  }
900
926
  async aggregateInputMasks(t2) {
901
- let n2 = e(Ct(t2.map((e11) => e11.toBytes()), "input mask"));
902
- return K.fromBytes(n2);
927
+ let n2 = e(kt(t2.map((e11) => e11.toBytes()), "input mask"));
928
+ return q.fromBytes(n2);
903
929
  }
904
930
  async stealthDhSecret(e11, t2, n2) {
905
- v(t2, 32, "stealthDhSecret ownerSecret"), v(n2, 32, "stealthDhSecret publicNonce");
906
- let r2 = te(e11, t2, n2);
907
- return v(r2, 32, "stealth DH secret"), r2;
931
+ y(t2, 32, "stealthDhSecret ownerSecret"), y(n2, 32, "stealthDhSecret publicNonce");
932
+ let r2 = ee(e11, t2, n2);
933
+ return y(r2, 32, "stealth DH secret"), r2;
908
934
  }
909
935
  async validateTransfer(e11) {
910
- ie(e11.toCompactJson(), null);
936
+ re(e11.toCompactJson(), null);
911
937
  }
912
938
  };
913
- function wt(e11) {
939
+ function jt(e11) {
914
940
  let t2 = Object.keys(e11);
915
941
  if (t2.length !== 1 || t2[0] !== "StealthPublicKey") return false;
916
942
  let n2 = e11.StealthPublicKey;
917
943
  return typeof n2 == "object" && !!n2 && Object.keys(n2).length === 0;
918
944
  }
919
- var Tt = "utxo";
920
- function $(e11, t2) {
921
- return `${Tt}_${e11.startsWith("resource_") ? e11.slice(9) : e11}_${y(t2)}`;
945
+ var Mt = "utxo";
946
+ function Nt(e11, t2) {
947
+ return `${Mt}_${e11.startsWith("resource_") ? e11.slice(9) : e11}_${b(t2)}`;
922
948
  }
923
- var Et = 64;
924
- function Dt(e11) {
949
+ var Pt = 64;
950
+ function Ft(e11) {
925
951
  return typeof e11 == "object" && !!e11 && "Utxo" in e11;
926
952
  }
927
- function Ot(e11) {
953
+ function It(e11) {
928
954
  return e11.length > 0 && /^[0-9a-fA-F]+$/.test(e11);
929
955
  }
930
- function kt(e11) {
956
+ function Lt(e11) {
931
957
  let t2 = e11.split("_");
932
- if (t2.length < 3 || t2[0] !== Tt) return null;
958
+ if (t2.length < 3 || t2[0] !== Mt) return null;
933
959
  let n2 = t2[t2.length - 1];
934
- return n2.length !== Et || !Ot(n2) ? null : b(n2);
960
+ return n2.length !== Pt || !It(n2) ? null : x(n2);
935
961
  }
936
- function At(e11, t2) {
962
+ function Rt(e11, t2) {
937
963
  let n2 = e11.substate;
938
- if (!Dt(n2)) return null;
964
+ if (!Ft(n2)) return null;
939
965
  let r2 = n2.Utxo;
940
966
  if (r2.output === null || r2.is_frozen) return null;
941
- let i2 = kt(t2);
967
+ let i2 = Lt(t2);
942
968
  return i2 === null ? null : {
943
969
  commitment: i2,
944
970
  body: r2.output.output
945
971
  };
946
972
  }
947
- var jt = class {
948
- constructor(e11, t2, n2 = new Q(e11.network())) {
973
+ var zt = 0, Bt = class {
974
+ constructor(e11, t2, n2 = new At(e11.network())) {
949
975
  __publicField(this, "provider");
950
976
  __publicField(this, "crypto");
951
977
  __publicField(this, "builder");
952
978
  __publicField(this, "state");
979
+ __publicField(this, "maxEpoch", null);
953
980
  __publicField(this, "prepared", false);
954
- this.provider = e11, this.crypto = n2, this.builder = R.new(e11.network()), this.state = {
981
+ this.provider = e11, this.crypto = n2, this.builder = z.new(e11.network(), zt), this.state = {
955
982
  resource: t2,
956
983
  revealedInput: null,
957
984
  inputsToSpend: /* @__PURE__ */ new Map(),
@@ -960,9 +987,9 @@ var jt = class {
960
987
  };
961
988
  }
962
989
  spendRevealedInput(e11, t2) {
963
- if (t2 <= 0n) throw new _(`spendRevealedInput amount must be > 0, got ${t2}`);
990
+ if (t2 <= 0n) throw new v(`spendRevealedInput amount must be > 0, got ${t2}`);
964
991
  let n2 = this.state.revealedInput;
965
- if (n2 !== null && n2.source !== e11) throw new _(`spendRevealedInput: all revealed input must come from one account (${n2.source} != ${e11})`);
992
+ if (n2 !== null && n2.source !== e11) throw new v(`spendRevealedInput: all revealed input must come from one account (${n2.source} != ${e11})`);
966
993
  return this.state.revealedInput = {
967
994
  source: e11,
968
995
  amount: ((n2 == null ? void 0 : n2.amount) ?? 0n) + t2
@@ -972,20 +999,23 @@ var jt = class {
972
999
  return this.state.outputs.push(e11), this;
973
1000
  }
974
1001
  toRevealedOutput(e11) {
975
- if (e11 <= 0n) throw new _(`toRevealedOutput amount must be > 0, got ${e11}`);
1002
+ if (e11 <= 0n) throw new v(`toRevealedOutput amount must be > 0, got ${e11}`);
976
1003
  return this.state.revealedOutputAmount += e11, this;
977
1004
  }
978
1005
  payFeeFromRevealed(e11) {
979
- if (this.state.revealedInput === null) throw new _("payFeeFromRevealed: call spendRevealedInput first to set the source account");
980
- if (e11 <= 0n) throw new _(`payFeeFromRevealed amount must be > 0, got ${e11}`);
1006
+ if (this.state.revealedInput === null) throw new v("payFeeFromRevealed: call spendRevealedInput first to set the source account");
1007
+ if (e11 <= 0n) throw new v(`payFeeFromRevealed amount must be > 0, got ${e11}`);
981
1008
  return this.builder.feeTransactionPayFromComponent(this.state.revealedInput.source, e11), this;
982
1009
  }
1010
+ withMaxEpoch(e11) {
1011
+ return this.builder.withMaxEpoch(e11), this.maxEpoch = e11, this;
1012
+ }
983
1013
  withBuilder(e11) {
984
1014
  return this.builder = e11(this.builder), this;
985
1015
  }
986
1016
  spendStealthInput(e11, t2) {
987
- let n2 = new q(t2), r2 = y(n2.commitment), i2 = this.state.inputsToSpend.get(r2);
988
- if (i2 !== void 0) throw new _(`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.`);
1017
+ let n2 = new J(t2), r2 = b(n2.commitment), i2 = this.state.inputsToSpend.get(r2);
1018
+ 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.`);
989
1019
  return this.state.inputsToSpend.set(r2, {
990
1020
  input: n2,
991
1021
  owner: e11
@@ -993,10 +1023,10 @@ var jt = class {
993
1023
  }
994
1024
  async prepare() {
995
1025
  var _a;
996
- if (this.prepared) throw new _("StealthTransfer.prepare: already prepared \u2014 create a new StealthTransfer to build again");
1026
+ if (this.prepared) throw new v("StealthTransfer.prepare: already prepared \u2014 create a new StealthTransfer to build again");
997
1027
  this.validate(), this.prepared = true;
998
- let { statement: e11, outputMask: t2 } = await this.crypto.generateOutputsStatement(this.state.outputs, this.state.revealedOutputAmount), n2 = new Z(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);
999
- this.emitInstructions(n2);
1028
+ let { statement: e11, outputMask: t2 } = await this.crypto.generateOutputsStatement(this.state.outputs, this.state.revealedOutputAmount), n2 = new Q(await this.crypto.buildInputsStatement([...this.state.inputsToSpend.values()].map((e12) => e12.input), ((_a = this.state.revealedInput) == null ? void 0 : _a.amount) ?? 0n), e11, void 0);
1029
+ this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch === zt && this.builder.withMaxEpoch(await Ge(this.provider));
1000
1030
  let r2 = /* @__PURE__ */ new Set();
1001
1031
  if (this.state.revealedInput !== null) {
1002
1032
  let e12 = this.state.revealedInput.source;
@@ -1004,20 +1034,20 @@ var jt = class {
1004
1034
  substate_id: e12,
1005
1035
  version: null
1006
1036
  }), r2.add(e12);
1007
- let t3 = await Xe(this.provider, e12);
1037
+ let t3 = await nt(this.provider, e12);
1008
1038
  for (let e13 of t3) r2.has(e13) || (this.builder.addInput({
1009
1039
  substate_id: e13,
1010
1040
  version: null
1011
1041
  }), r2.add(e13));
1012
1042
  }
1013
1043
  for (let { input: e12 } of this.state.inputsToSpend.values()) {
1014
- let t3 = $(this.state.resource, e12.commitment);
1044
+ let t3 = Nt(this.state.resource, e12.commitment);
1015
1045
  r2.has(t3) || (this.builder.addInput({
1016
1046
  substate_id: t3,
1017
1047
  version: null
1018
1048
  }), r2.add(t3));
1019
1049
  }
1020
- let i2 = await U(this.provider, this.builder.buildUnsignedTransaction()), a2 = [...this.state.inputsToSpend.values()], o2 = this.collectRequiredSigners(a2);
1050
+ let i2 = await W(this.provider, this.builder.buildUnsignedTransaction()), a2 = [...this.state.inputsToSpend.values()], o2 = this.collectRequiredSigners(a2);
1021
1051
  return {
1022
1052
  unsignedTx: i2,
1023
1053
  statement: n2,
@@ -1036,13 +1066,13 @@ var jt = class {
1036
1066
  validate() {
1037
1067
  var _a;
1038
1068
  let e11 = this.state.inputsToSpend.size > 0, t2 = ((_a = this.state.revealedInput) == null ? void 0 : _a.amount) ?? 0n;
1039
- if (!(t2 > 0n || e11)) throw new _("StealthTransfer.prepare: no inputs \u2014 call spendRevealedInput or spendStealthInput first");
1040
- if (this.state.outputs.length === 0 && this.state.revealedOutputAmount === 0n) throw new _("StealthTransfer.prepare: no outputs \u2014 call toStealthOutput or toRevealedOutput first");
1041
- if (this.state.outputs.length === 0) throw new _("StealthTransfer.prepare: at least one stealth output is required");
1042
- if (this.state.revealedOutputAmount > 0n && this.state.revealedInput === null) throw new _("StealthTransfer.prepare: revealed change requires a revealed source account to deposit into");
1069
+ if (!(t2 > 0n || e11)) throw new v("StealthTransfer.prepare: no inputs \u2014 call spendRevealedInput or spendStealthInput first");
1070
+ if (this.state.outputs.length === 0 && this.state.revealedOutputAmount === 0n) throw new v("StealthTransfer.prepare: no outputs \u2014 call toStealthOutput or toRevealedOutput first");
1071
+ if (this.state.outputs.length === 0) throw new v("StealthTransfer.prepare: at least one stealth output is required");
1072
+ if (this.state.revealedOutputAmount > 0n && this.state.revealedInput === null) throw new v("StealthTransfer.prepare: revealed change requires a revealed source account to deposit into");
1043
1073
  if (!e11) {
1044
1074
  let e12 = this.state.outputs.reduce((e13, t3) => e13 + t3.amount, 0n), n2 = e12 + this.state.revealedOutputAmount, r2 = t2;
1045
- if (r2 !== n2) throw new _(`StealthTransfer.prepare: unbalanced transfer \u2014 revealed input ${r2} != stealth out ${e12} + revealed out ${this.state.revealedOutputAmount} (= ${n2})`);
1075
+ if (r2 !== n2) throw new v(`StealthTransfer.prepare: unbalanced transfer \u2014 revealed input ${r2} != stealth out ${e12} + revealed out ${this.state.revealedOutputAmount} (= ${n2})`);
1046
1076
  }
1047
1077
  }
1048
1078
  emitInstructions(e11) {
@@ -1050,38 +1080,38 @@ var jt = class {
1050
1080
  t2 !== null && (this.builder.callMethod({
1051
1081
  componentAddress: t2.source,
1052
1082
  methodName: "withdraw"
1053
- }, [A(this.state.resource), O(t2.amount)]).saveVar(it), n2 = it), this.builder.addInstruction(ot({
1083
+ }, [A(this.state.resource), k(t2.amount)]).saveVar(ut), n2 = ut), this.builder.addInstruction(ft({
1054
1084
  resourceAddress: this.state.resource,
1055
1085
  revealedInputBucket: n2,
1056
1086
  statement: e11
1057
- }, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutputAmount > 0n && t2 !== null && this.builder.saveVar(at).callMethod({
1087
+ }, (e12) => this.builder.resolveWorkspaceOffsetId(e12))), this.state.revealedOutputAmount > 0n && t2 !== null && this.builder.saveVar(dt).callMethod({
1058
1088
  componentAddress: t2.source,
1059
1089
  methodName: "deposit"
1060
- }, [{ Workspace: at }]);
1090
+ }, [{ Workspace: dt }]);
1061
1091
  }
1062
1092
  };
1063
- function Mt(e11) {
1064
- if (Nt(e11) || e11.statementJson !== void 0) return e11.statementJson;
1065
- if (e11.inputs.length > 0) throw new g("inputs statement has confidential inputs but no WASM statementJson \u2014 call buildInputsStatement first", { context: "statementJsonFor" });
1093
+ function Vt(e11) {
1094
+ if (Ht(e11) || e11.statementJson !== void 0) return e11.statementJson;
1095
+ if (e11.inputs.length > 0) throw new _("inputs statement has confidential inputs but no WASM statementJson \u2014 call buildInputsStatement first", { context: "statementJsonFor" });
1066
1096
  return JSON.stringify(e11.toJSON());
1067
1097
  }
1068
- function Nt(e11) {
1098
+ function Ht(e11) {
1069
1099
  return !("inputs" in e11);
1070
1100
  }
1071
- async function Pt(e11, t2, n2, r2, i2) {
1072
- let a2 = Mt(r2), o2 = Mt(i2);
1101
+ async function Ut(e11, t2, n2, r2, i2) {
1102
+ let a2 = Vt(r2), o2 = Vt(i2);
1073
1103
  return e11.generateBalanceProofSignature(t2, n2, a2, o2);
1074
1104
  }
1075
- async function Ft(e11, t2, n2, r2) {
1105
+ async function $(e11, t2, n2, r2) {
1076
1106
  let i2 = await e11.deriveAeadKey(r2.viewSecret, r2.senderPublicNonce);
1077
1107
  return e11.unblindOutput(t2, n2, i2, r2.skipMemo);
1078
1108
  }
1079
- async function It(e11, t2, n2, r2) {
1080
- let i2 = At(n2, r2);
1109
+ async function Wt(e11, t2, n2, r2) {
1110
+ let i2 = Rt(n2, r2);
1081
1111
  if (i2 === null) return null;
1082
- let a2 = b(i2.body.encrypted_data), o2 = b(i2.body.public_nonce);
1112
+ let a2 = x(i2.body.encrypted_data), o2 = x(i2.body.public_nonce);
1083
1113
  try {
1084
- return await Ft(e11, i2.commitment, a2, {
1114
+ return await $(e11, i2.commitment, a2, {
1085
1115
  senderPublicNonce: o2,
1086
1116
  viewSecret: t2,
1087
1117
  skipMemo: false
@@ -1090,33 +1120,33 @@ async function It(e11, t2, n2, r2) {
1090
1120
  return null;
1091
1121
  }
1092
1122
  }
1093
- async function Lt(e11, t2, n2) {
1094
- if (t2.length === 0) throw new _("generateOutputsStatement: at least one stealth output is required");
1123
+ async function Gt(e11, t2, n2) {
1124
+ if (t2.length === 0) throw new v("generateOutputsStatement: at least one stealth output is required");
1095
1125
  let { statement: r2, outputMask: i2 } = await e11.generateOutputsStatement(t2, n2), a2 = await e11.buildInputsStatement([], 0n);
1096
- return new Z(a2, r2, await Pt(e11, K.zero(), i2, a2, r2));
1126
+ return new Q(a2, r2, await Ut(e11, q.zero(), i2, a2, r2));
1097
1127
  }
1098
- var Rt = class e10 {
1128
+ var Kt = class e10 {
1099
1129
  constructor(e11, t2, n2, r2, i2) {
1100
1130
  this.wallet = e11, this.spec = t2, this.crypto = n2, this.mustSignWithAccountKey = r2, this.viewSecret = i2;
1101
1131
  }
1102
1132
  static fromSpec(t2, n2, r2 = {}) {
1103
- return new e10(t2, n2, r2.crypto ?? new Q(), r2.mustSignWithAccountKey ?? true, r2.viewSecret);
1133
+ return new e10(t2, n2, r2.crypto ?? new At(), r2.mustSignWithAccountKey ?? true, r2.viewSecret);
1104
1134
  }
1105
1135
  async prepare(e11) {
1106
- let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ? K.zero() : await this.crypto.aggregateInputMasks(t2.map((e12) => e12.mask)), r2 = await Pt(this.crypto, n2, this.spec.outputMask, this.spec.statement.inputsStatement, this.spec.statement.outputsStatement), i2 = new Z(this.spec.statement.inputsStatement, this.spec.statement.outputsStatement, r2);
1136
+ let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ? q.zero() : await this.crypto.aggregateInputMasks(t2.map((e12) => e12.mask)), r2 = await Ut(this.crypto, n2, this.spec.outputMask, this.spec.statement.inputsStatement, this.spec.statement.outputsStatement), i2 = new Q(this.spec.statement.inputsStatement, this.spec.statement.outputsStatement, r2);
1107
1137
  await this.crypto.validateTransfer(i2);
1108
- let a2 = Bt(this.spec.unsignedTx, i2), o2 = {
1138
+ let a2 = Jt(this.spec.unsignedTx, i2), o2 = {
1109
1139
  ...this.spec,
1110
1140
  unsignedTx: a2,
1111
1141
  statement: i2
1112
1142
  };
1113
- return new zt({
1143
+ return new qt({
1114
1144
  wallet: this.wallet,
1115
1145
  crypto: this.crypto,
1116
1146
  spec: o2,
1117
1147
  resolvedInputs: t2,
1118
1148
  mustSignWithAccountKey: this.mustSignWithAccountKey,
1119
- sealKeypair: st()
1149
+ sealKeypair: pt()
1120
1150
  });
1121
1151
  }
1122
1152
  async resolveViewSecret() {
@@ -1125,9 +1155,9 @@ var Rt = class e10 {
1125
1155
  if ((e11 == null ? void 0 : e11.getViewSecret) !== void 0) try {
1126
1156
  return await e11.getViewSecret();
1127
1157
  } catch (e12) {
1128
- throw e12 instanceof f ? e12 : new f("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 });
1158
+ throw e12 instanceof p ? e12 : new p("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 });
1129
1159
  }
1130
- throw new f("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.");
1160
+ throw new p("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.");
1131
1161
  }
1132
1162
  async safeDefaultAddress() {
1133
1163
  try {
@@ -1139,19 +1169,19 @@ var Rt = class e10 {
1139
1169
  async resolveStealthInputs(e11) {
1140
1170
  if (this.spec.inputs.length === 0) return [];
1141
1171
  let t2 = await this.resolveViewSecret(), n2 = this.spec.state.resource, r2 = await Promise.allSettled(this.spec.inputs.map(async ({ input: r3, owner: i3 }) => {
1142
- let a2 = y(r3.commitment), o2 = await e11.getStealthUtxo(n2, r3.commitment);
1143
- if (o2 === null) throw new f(`WalletStealthAuthorizer.prepare: stealth input UTXO not found (spent or never created) for ${a2}`);
1144
- let s2 = At(o2, $(n2, r3.commitment));
1145
- if (s2 === null) throw new f(`WalletStealthAuthorizer.prepare: stealth input ${a2} is not a live, spendable UTXO`);
1146
- let c2 = b(s2.body.public_nonce), ee2;
1172
+ let a2 = b(r3.commitment), o2 = await e11.getStealthUtxo(n2, r3.commitment);
1173
+ if (o2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input UTXO not found (spent or never created) for ${a2}`);
1174
+ let s2 = Rt(o2, Nt(n2, r3.commitment));
1175
+ if (s2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input ${a2} is not a live, spendable UTXO`);
1176
+ let c2 = x(s2.body.public_nonce), l2;
1147
1177
  try {
1148
- ee2 = await Ft(this.crypto, s2.commitment, b(s2.body.encrypted_data), {
1178
+ l2 = await $(this.crypto, s2.commitment, x(s2.body.encrypted_data), {
1149
1179
  senderPublicNonce: c2,
1150
1180
  viewSecret: t2,
1151
1181
  skipMemo: true
1152
1182
  });
1153
1183
  } catch (e12) {
1154
- throw new g(`WalletStealthAuthorizer.prepare: failed to decrypt stealth input with commitment ${y(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.`, {
1184
+ throw new _(`WalletStealthAuthorizer.prepare: failed to decrypt stealth input with commitment ${b(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.`, {
1155
1185
  cause: e12,
1156
1186
  context: "unblindOutput"
1157
1187
  });
@@ -1159,14 +1189,14 @@ var Rt = class e10 {
1159
1189
  return {
1160
1190
  ownerAddr: i3,
1161
1191
  input: r3,
1162
- mask: ee2.mask,
1192
+ mask: l2.mask,
1163
1193
  publicNonce: c2
1164
1194
  };
1165
1195
  })), i2 = r2.find((e12) => e12.status === "rejected");
1166
1196
  if (i2 !== void 0) throw i2.reason;
1167
1197
  return r2.map((e12) => e12.value);
1168
1198
  }
1169
- }, zt = class {
1199
+ }, qt = class {
1170
1200
  constructor(e11) {
1171
1201
  __publicField(this, "wallet");
1172
1202
  __publicField(this, "crypto");
@@ -1189,11 +1219,11 @@ var Rt = class e10 {
1189
1219
  }
1190
1220
  async computeAuthorizations() {
1191
1221
  if (this.resolvedInputs.length === 0) return [];
1192
- let e11 = H(this.spec.unsignedTx), t2 = this.sealKeypair.public_key, n2 = [];
1222
+ let e11 = U(this.spec.unsignedTx), t2 = this.sealKeypair.public_key, n2 = [];
1193
1223
  for (let r2 of this.resolvedInputs) {
1194
1224
  let i2 = this.wallet.getKeyProvider(r2.ownerAddr);
1195
- if (i2 === void 0) throw new p(`AuthorizedTransfer.createAuthorizations: no signer registered for stealth-input owner ${r2.ownerAddr}. Register it via wallet.registerKeyProvider(owner, signer).`, { address: r2.ownerAddr });
1196
- if (i2.addStealthSignature === void 0) throw new h(`AuthorizedTransfer.createAuthorizations: signer for ${r2.ownerAddr} cannot produce one-time stealth signatures. Use a SecretKeyWallet (which holds the owner secret).`);
1225
+ 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 });
1226
+ 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).`);
1197
1227
  let a2 = await i2.addStealthSignature(e11, r2.publicNonce, t2, { crypto: this.crypto });
1198
1228
  n2.push({
1199
1229
  signerAddress: r2.ownerAddr,
@@ -1209,115 +1239,118 @@ var Rt = class e10 {
1209
1239
  let e11 = (await this.createAuthorizations()).flatMap((e12) => e12.signatures), t2 = [];
1210
1240
  this.mustSignWithAccountKey && t2.push(this.wallet);
1211
1241
  let n2 = [...e11, ...this.extraSignatures];
1212
- return n2.length > 0 && t2.push(new Vt(n2)), G(await W(t2, this.spec.unsignedTx, this.sealKeypair));
1242
+ return n2.length > 0 && t2.push(new Yt(n2)), K(await G(t2, this.spec.unsignedTx, this.sealKeypair));
1213
1243
  }
1214
1244
  };
1215
- function Bt(e11, t2) {
1216
- let n2 = e11.instructions.findIndex(V);
1217
- if (n2 < 0) throw new _("patchStealthStatement: expected exactly one StealthTransfer instruction, found 0 (not a stealth tx)");
1218
- if (e11.instructions.slice(n2 + 1).findIndex(V) >= 0) throw new _("patchStealthStatement: expected exactly one StealthTransfer instruction, found more than one (malformed)");
1245
+ function Jt(e11, t2) {
1246
+ let n2 = e11.instructions.findIndex(H);
1247
+ if (n2 < 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found 0 (not a stealth tx)");
1248
+ if (e11.instructions.slice(n2 + 1).findIndex(H) >= 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found more than one (malformed)");
1219
1249
  let r2 = { StealthTransfer: {
1220
1250
  ...e11.instructions[n2].StealthTransfer,
1221
- statement: B(t2)
1251
+ statement: V(t2)
1222
1252
  } }, i2 = [...e11.instructions];
1223
1253
  return i2[n2] = r2, {
1224
1254
  ...e11,
1225
1255
  instructions: i2
1226
1256
  };
1227
1257
  }
1228
- var Vt = class {
1258
+ var Yt = class {
1229
1259
  constructor(e11) {
1230
1260
  this.signatures = e11;
1231
1261
  }
1232
1262
  async getAddress() {
1233
- throw new h("StaticSignatureSigner has no address");
1263
+ throw new g("StaticSignatureSigner has no address");
1234
1264
  }
1235
1265
  async getPublicKey() {
1236
- throw new h("StaticSignatureSigner has no public key");
1266
+ throw new g("StaticSignatureSigner has no public key");
1237
1267
  }
1238
1268
  async signTransaction(e11, t2) {
1239
1269
  return this.signatures;
1240
1270
  }
1241
1271
  };
1242
1272
  export {
1243
- mt as AccountInvokeBuilder,
1244
- zt as AuthorizedTransfer,
1245
- J as BalanceProofSignature,
1246
- g as CryptoBridgeError,
1247
- m as DefaultSignerNotSetError,
1248
- vt as EncryptedData,
1249
- ht as FaucetInvokeBuilder,
1250
- ae as IndexerClientError,
1251
- _ as InvalidArgumentError,
1252
- p as KeyProviderNotFoundError,
1253
- K as Mask,
1254
- l as Network,
1255
- u as OotleError,
1256
- gt as OotleWallet,
1257
- se as OperationCancelledError,
1258
- h as SignerError,
1259
- q as StealthInput,
1260
- Y as StealthInputsStatement,
1261
- X as StealthOutputsStatement,
1262
- jt as StealthTransfer,
1263
- Z as StealthTransferStatement,
1264
- $e as TARI_RESOURCE_ADDRESS,
1265
- R as TransactionBuilder,
1266
- d as TransactionRejectedError,
1267
- oe as TransactionTimeoutError,
1268
- f as WalletError,
1269
- Rt as WalletStealthAuthorizer,
1270
- Q as WasmStealthCrypto,
1271
- nt as XTR_FAUCET_CLAIM_RESOURCE_ADDRESS,
1272
- et as XTR_FAUCET_COMPONENT_ADDRESS,
1273
- tt as XTR_FAUCET_VAULT_ADDRESS,
1274
- O as amountLiteral,
1275
- v as assertByteLength,
1276
- ce as assertUnreachable,
1277
- Ee as boolLiteral,
1278
- ct as buildTransactionSignature,
1279
- k as bytesLiteral,
1280
- je as claimedOutputTombstoneAddressLiteral,
1281
- ut as classifyOutcome,
1282
- kt as commitmentOf,
1283
- De as componentAddressLiteral,
1284
- bt as createOutput,
1285
- Ft as decryptInputData,
1286
- It as decryptOwnedUtxo,
1287
- Ke as defaultIndexerUrl,
1288
- b as fromHexStr,
1289
- Lt as generateOutputsStatement,
1290
- st as generateSealKeypair,
1291
- Xe as getVaultIdsForAccount,
1292
- we as intLiteral,
1293
- V as isStealthTransferInstruction,
1294
- Ye as iterVaultIdsInState,
1273
+ bt as AccountInvokeBuilder,
1274
+ qt as AuthorizedTransfer,
1275
+ Y as BalanceProofSignature,
1276
+ _ as CryptoBridgeError,
1277
+ We as DEFAULT_TRANSACTION_VALIDITY_EPOCHS,
1278
+ h as DefaultSignerNotSetError,
1279
+ wt as EncryptedData,
1280
+ xt as FaucetInvokeBuilder,
1281
+ ie as IndexerClientError,
1282
+ v as InvalidArgumentError,
1283
+ m as KeyProviderNotFoundError,
1284
+ Ue as MAX_TRANSACTION_VALIDITY_EPOCHS,
1285
+ q as Mask,
1286
+ u as Network,
1287
+ d as OotleError,
1288
+ St as OotleWallet,
1289
+ oe as OperationCancelledError,
1290
+ g as SignerError,
1291
+ J as StealthInput,
1292
+ X as StealthInputsStatement,
1293
+ Z as StealthOutputsStatement,
1294
+ Bt as StealthTransfer,
1295
+ Q as StealthTransferStatement,
1296
+ at as TARI_RESOURCE_ADDRESS,
1297
+ z as TransactionBuilder,
1298
+ f as TransactionRejectedError,
1299
+ ae as TransactionTimeoutError,
1300
+ p as WalletError,
1301
+ Kt as WalletStealthAuthorizer,
1302
+ At as WasmStealthCrypto,
1303
+ ct as XTR_FAUCET_CLAIM_RESOURCE_ADDRESS,
1304
+ ot as XTR_FAUCET_COMPONENT_ADDRESS,
1305
+ st as XTR_FAUCET_VAULT_ADDRESS,
1306
+ k as amountLiteral,
1307
+ y as assertByteLength,
1308
+ se as assertUnreachable,
1309
+ Oe as boolLiteral,
1310
+ mt as buildTransactionSignature,
1311
+ De as bytesLiteral,
1312
+ Ne as claimedOutputTombstoneAddressLiteral,
1313
+ gt as classifyOutcome,
1314
+ Lt as commitmentOf,
1315
+ ke as componentAddressLiteral,
1316
+ Et as createOutput,
1317
+ $ as decryptInputData,
1318
+ Wt as decryptOwnedUtxo,
1319
+ Qe as defaultIndexerUrl,
1320
+ x as fromHexStr,
1321
+ Gt as generateOutputsStatement,
1322
+ pt as generateSealKeypair,
1323
+ nt as getVaultIdsForAccount,
1324
+ Te as intLiteral,
1325
+ H as isStealthTransferInstruction,
1326
+ tt as iterVaultIdsInState,
1295
1327
  Ce as literalArg,
1296
- Oe as metadataLiteral,
1328
+ Ae as metadataLiteral,
1297
1329
  L as microTariLiteral,
1298
- ze as microTariString,
1299
- Pe as nonFungibleAddressLiteral,
1300
- At as parseSubstateUtxo,
1301
- Be as parseWorkspaceStringKey,
1302
- Bt as patchStealthStatement,
1303
- Ne as publicKeyLiteral,
1304
- U as resolveTransaction,
1330
+ Ve as microTariString,
1331
+ Ie as nonFungibleAddressLiteral,
1332
+ Rt as parseSubstateUtxo,
1333
+ He as parseWorkspaceStringKey,
1334
+ Jt as patchStealthStatement,
1335
+ Fe as publicKeyLiteral,
1336
+ Ge as resolveMaxEpoch,
1337
+ W as resolveTransaction,
1305
1338
  A as resourceAddressLiteral,
1306
- G as sealTransaction,
1307
- pt as sendDryRun,
1308
- ft as sendTransaction,
1309
- H as serializeUnsignedTx,
1310
- Pt as signBalanceProof,
1311
- W as signTransaction,
1312
- B as statementAsWire,
1313
- ot as stealthTransferInstruction,
1314
- $ as stealthUtxoSubstateId,
1315
- Te as stringLiteral,
1316
- lt as submitTransaction,
1317
- Ae as templateAddressLiteral,
1318
- y as toHexStr,
1319
- Fe as utxoAddressLiteral,
1320
- Me as validatorFeePoolAddressLiteral,
1321
- ke as vaultIdLiteral,
1322
- dt as watchTransaction
1339
+ K as sealTransaction,
1340
+ yt as sendDryRun,
1341
+ vt as sendTransaction,
1342
+ U as serializeUnsignedTx,
1343
+ Ut as signBalanceProof,
1344
+ G as signTransaction,
1345
+ V as statementAsWire,
1346
+ ft as stealthTransferInstruction,
1347
+ Nt as stealthUtxoSubstateId,
1348
+ Ee as stringLiteral,
1349
+ ht as submitTransaction,
1350
+ Me as templateAddressLiteral,
1351
+ b as toHexStr,
1352
+ Le as utxoAddressLiteral,
1353
+ Pe as validatorFeePoolAddressLiteral,
1354
+ je as vaultIdLiteral,
1355
+ _t as watchTransaction
1323
1356
  };