stxer 0.4.2 → 0.4.5

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/stxer.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- import { serializeCV, deserializeCV, tupleCV, uintCV, bufferCV, serializeCVBytes, contractPrincipalCV, stringAsciiCV, ClarityVersion, makeUnsignedContractDeploy, PostConditionMode, makeUnsignedSTXTokenTransfer, makeUnsignedContractCall, deserializeTransaction, ClarityType } from '@stacks/transactions';
2
- import { richFetch, getNodeInfo, encodeAbi, decodeAbi } from 'ts-clarity';
3
- import { STACKS_MAINNET, STACKS_TESTNET } from '@stacks/network';
1
+ import { serializeCV, deserializeCV, contractPrincipalCV, ClarityType, tupleCV, uintCV, bufferCV, serializeCVBytes, stringAsciiCV, ClarityVersion, makeUnsignedContractDeploy, PostConditionMode, makeUnsignedSTXTokenTransfer, makeUnsignedContractCall, deserializeTransaction, AddressHashMode } from '@stacks/transactions';
2
+ import { encodeAbi, decodeAbi, richFetch, getNodeInfo } from 'ts-clarity';
3
+ import { AddressVersion, STACKS_MAINNET, STACKS_TESTNET } from '@stacks/network';
4
4
  import { c32addressDecode } from 'c32check';
5
5
 
6
6
  function _arrayLikeToArray(r, a) {
@@ -59,306 +59,130 @@ function _extends() {
59
59
  return n;
60
60
  }, _extends.apply(null, arguments);
61
61
  }
62
- function _regeneratorRuntime() {
63
- _regeneratorRuntime = function () {
64
- return e;
65
- };
66
- var t,
67
- e = {},
68
- r = Object.prototype,
69
- n = r.hasOwnProperty,
70
- o = Object.defineProperty || function (t, e, r) {
71
- t[e] = r.value;
72
- },
73
- i = "function" == typeof Symbol ? Symbol : {},
74
- a = i.iterator || "@@iterator",
75
- c = i.asyncIterator || "@@asyncIterator",
76
- u = i.toStringTag || "@@toStringTag";
77
- function define(t, e, r) {
78
- return Object.defineProperty(t, e, {
79
- value: r,
80
- enumerable: !0,
81
- configurable: !0,
82
- writable: !0
83
- }), t[e];
84
- }
85
- try {
86
- define({}, "");
87
- } catch (t) {
88
- define = function (t, e, r) {
89
- return t[e] = r;
90
- };
91
- }
92
- function wrap(t, e, r, n) {
93
- var i = e && e.prototype instanceof Generator ? e : Generator,
94
- a = Object.create(i.prototype),
95
- c = new Context(n || []);
96
- return o(a, "_invoke", {
97
- value: makeInvokeMethod(t, r, c)
98
- }), a;
99
- }
100
- function tryCatch(t, e, r) {
101
- try {
102
- return {
103
- type: "normal",
104
- arg: t.call(e, r)
105
- };
106
- } catch (t) {
107
- return {
108
- type: "throw",
109
- arg: t
110
- };
111
- }
112
- }
113
- e.wrap = wrap;
114
- var h = "suspendedStart",
115
- l = "suspendedYield",
116
- f = "executing",
117
- s = "completed",
118
- y = {};
119
- function Generator() {}
120
- function GeneratorFunction() {}
121
- function GeneratorFunctionPrototype() {}
122
- var p = {};
123
- define(p, a, function () {
124
- return this;
125
- });
126
- var d = Object.getPrototypeOf,
127
- v = d && d(d(values([])));
128
- v && v !== r && n.call(v, a) && (p = v);
129
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
130
- function defineIteratorMethods(t) {
131
- ["next", "throw", "return"].forEach(function (e) {
132
- define(t, e, function (t) {
133
- return this._invoke(e, t);
134
- });
135
- });
136
- }
137
- function AsyncIterator(t, e) {
138
- function invoke(r, o, i, a) {
139
- var c = tryCatch(t[r], t, o);
140
- if ("throw" !== c.type) {
141
- var u = c.arg,
142
- h = u.value;
143
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
144
- invoke("next", t, i, a);
145
- }, function (t) {
146
- invoke("throw", t, i, a);
147
- }) : e.resolve(h).then(function (t) {
148
- u.value = t, i(u);
149
- }, function (t) {
150
- return invoke("throw", t, i, a);
151
- });
152
- }
153
- a(c.arg);
154
- }
155
- var r;
156
- o(this, "_invoke", {
157
- value: function (t, n) {
158
- function callInvokeWithMethodAndArg() {
159
- return new e(function (e, r) {
160
- invoke(t, n, e, r);
161
- });
62
+ function _regenerator() {
63
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
64
+ var e,
65
+ t,
66
+ r = "function" == typeof Symbol ? Symbol : {},
67
+ n = r.iterator || "@@iterator",
68
+ o = r.toStringTag || "@@toStringTag";
69
+ function i(r, n, o, i) {
70
+ var c = n && n.prototype instanceof Generator ? n : Generator,
71
+ u = Object.create(c.prototype);
72
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
73
+ var i,
74
+ c,
75
+ u,
76
+ f = 0,
77
+ p = o || [],
78
+ y = !1,
79
+ G = {
80
+ p: 0,
81
+ n: 0,
82
+ v: e,
83
+ a: d,
84
+ f: d.bind(e, 4),
85
+ d: function (t, r) {
86
+ return i = t, c = 0, u = e, G.n = r, a;
87
+ }
88
+ };
89
+ function d(r, n) {
90
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
91
+ var o,
92
+ i = p[t],
93
+ d = G.p,
94
+ l = i[2];
95
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
162
96
  }
163
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
97
+ if (o || r > 1) return a;
98
+ throw y = !0, n;
164
99
  }
165
- });
166
- }
167
- function makeInvokeMethod(e, r, n) {
168
- var o = h;
169
- return function (i, a) {
170
- if (o === f) throw Error("Generator is already running");
171
- if (o === s) {
172
- if ("throw" === i) throw a;
100
+ return function (o, p, l) {
101
+ if (f > 1) throw TypeError("Generator is already running");
102
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
103
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
104
+ try {
105
+ if (f = 2, i) {
106
+ if (c || (o = "next"), t = i[o]) {
107
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
108
+ if (!t.done) return t;
109
+ u = t.value, c < 2 && (c = 0);
110
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
111
+ i = e;
112
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
113
+ } catch (t) {
114
+ i = e, c = 1, u = t;
115
+ } finally {
116
+ f = 1;
117
+ }
118
+ }
173
119
  return {
174
120
  value: t,
175
- done: !0
121
+ done: y
176
122
  };
177
- }
178
- for (n.method = i, n.arg = a;;) {
179
- var c = n.delegate;
180
- if (c) {
181
- var u = maybeInvokeDelegate(c, n);
182
- if (u) {
183
- if (u === y) continue;
184
- return u;
185
- }
186
- }
187
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
188
- if (o === h) throw o = s, n.arg;
189
- n.dispatchException(n.arg);
190
- } else "return" === n.method && n.abrupt("return", n.arg);
191
- o = f;
192
- var p = tryCatch(e, r, n);
193
- if ("normal" === p.type) {
194
- if (o = n.done ? s : l, p.arg === y) continue;
195
- return {
196
- value: p.arg,
197
- done: n.done
198
- };
199
- }
200
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
201
- }
202
- };
123
+ };
124
+ }(r, o, i), !0), u;
203
125
  }
204
- function maybeInvokeDelegate(e, r) {
205
- var n = r.method,
206
- o = e.iterator[n];
207
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
208
- var i = tryCatch(o, e.iterator, r.arg);
209
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
210
- var a = i.arg;
211
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
126
+ var a = {};
127
+ function Generator() {}
128
+ function GeneratorFunction() {}
129
+ function GeneratorFunctionPrototype() {}
130
+ t = Object.getPrototypeOf;
131
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
132
+ return this;
133
+ }), t),
134
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
135
+ function f(e) {
136
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
212
137
  }
213
- function pushTryEntry(t) {
214
- var e = {
215
- tryLoc: t[0]
138
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
139
+ return this;
140
+ }), _regeneratorDefine(u, "toString", function () {
141
+ return "[object Generator]";
142
+ }), (_regenerator = function () {
143
+ return {
144
+ w: i,
145
+ m: f
216
146
  };
217
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
218
- }
219
- function resetTryEntry(t) {
220
- var e = t.completion || {};
221
- e.type = "normal", delete e.arg, t.completion = e;
222
- }
223
- function Context(t) {
224
- this.tryEntries = [{
225
- tryLoc: "root"
226
- }], t.forEach(pushTryEntry, this), this.reset(!0);
147
+ })();
148
+ }
149
+ function _regeneratorDefine(e, r, n, t) {
150
+ var i = Object.defineProperty;
151
+ try {
152
+ i({}, "", {});
153
+ } catch (e) {
154
+ i = 0;
227
155
  }
228
- function values(e) {
229
- if (e || "" === e) {
230
- var r = e[a];
231
- if (r) return r.call(e);
232
- if ("function" == typeof e.next) return e;
233
- if (!isNaN(e.length)) {
234
- var o = -1,
235
- i = function next() {
236
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
237
- return next.value = t, next.done = !0, next;
238
- };
239
- return i.next = i;
240
- }
156
+ _regeneratorDefine = function (e, r, n, t) {
157
+ function o(r, n) {
158
+ _regeneratorDefine(e, r, function (e) {
159
+ return this._invoke(r, n, e);
160
+ });
241
161
  }
242
- throw new TypeError(typeof e + " is not iterable");
243
- }
244
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
245
- value: GeneratorFunctionPrototype,
246
- configurable: !0
247
- }), o(GeneratorFunctionPrototype, "constructor", {
248
- value: GeneratorFunction,
249
- configurable: !0
250
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
251
- var e = "function" == typeof t && t.constructor;
252
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
253
- }, e.mark = function (t) {
254
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
255
- }, e.awrap = function (t) {
256
- return {
257
- __await: t
258
- };
259
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
260
- return this;
261
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
262
- void 0 === i && (i = Promise);
263
- var a = new AsyncIterator(wrap(t, r, n, o), i);
264
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
265
- return t.done ? t.value : a.next();
266
- });
267
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
268
- return this;
269
- }), define(g, "toString", function () {
270
- return "[object Generator]";
271
- }), e.keys = function (t) {
272
- var e = Object(t),
273
- r = [];
274
- for (var n in e) r.push(n);
275
- return r.reverse(), function next() {
276
- for (; r.length;) {
277
- var t = r.pop();
278
- if (t in e) return next.value = t, next.done = !1, next;
162
+ r ? i ? i(e, r, {
163
+ value: n,
164
+ enumerable: !t,
165
+ configurable: !t,
166
+ writable: !t
167
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
168
+ }, _regeneratorDefine(e, r, n, t);
169
+ }
170
+ function _regeneratorValues(e) {
171
+ if (null != e) {
172
+ var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
173
+ r = 0;
174
+ if (t) return t.call(e);
175
+ if ("function" == typeof e.next) return e;
176
+ if (!isNaN(e.length)) return {
177
+ next: function () {
178
+ return e && r >= e.length && (e = void 0), {
179
+ value: e && e[r++],
180
+ done: !e
181
+ };
279
182
  }
280
- return next.done = !0, next;
281
183
  };
282
- }, e.values = values, Context.prototype = {
283
- constructor: Context,
284
- reset: function (e) {
285
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
286
- },
287
- stop: function () {
288
- this.done = !0;
289
- var t = this.tryEntries[0].completion;
290
- if ("throw" === t.type) throw t.arg;
291
- return this.rval;
292
- },
293
- dispatchException: function (e) {
294
- if (this.done) throw e;
295
- var r = this;
296
- function handle(n, o) {
297
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
298
- }
299
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
300
- var i = this.tryEntries[o],
301
- a = i.completion;
302
- if ("root" === i.tryLoc) return handle("end");
303
- if (i.tryLoc <= this.prev) {
304
- var c = n.call(i, "catchLoc"),
305
- u = n.call(i, "finallyLoc");
306
- if (c && u) {
307
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
308
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
309
- } else if (c) {
310
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
311
- } else {
312
- if (!u) throw Error("try statement without catch or finally");
313
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
314
- }
315
- }
316
- }
317
- },
318
- abrupt: function (t, e) {
319
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
320
- var o = this.tryEntries[r];
321
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
322
- var i = o;
323
- break;
324
- }
325
- }
326
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
327
- var a = i ? i.completion : {};
328
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
329
- },
330
- complete: function (t, e) {
331
- if ("throw" === t.type) throw t.arg;
332
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
333
- },
334
- finish: function (t) {
335
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
336
- var r = this.tryEntries[e];
337
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
338
- }
339
- },
340
- catch: function (t) {
341
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
342
- var r = this.tryEntries[e];
343
- if (r.tryLoc === t) {
344
- var n = r.completion;
345
- if ("throw" === n.type) {
346
- var o = n.arg;
347
- resetTryEntry(r);
348
- }
349
- return o;
350
- }
351
- }
352
- throw Error("illegal catch attempt");
353
- },
354
- delegateYield: function (e, r, n) {
355
- return this.delegate = {
356
- iterator: values(e),
357
- resultName: r,
358
- nextLoc: n
359
- }, "next" === this.method && (this.arg = t), y;
360
- }
361
- }, e;
184
+ }
185
+ throw new TypeError(typeof e + " is not iterable");
362
186
  }
363
187
  function _unsupportedIterableToArray(r, a) {
364
188
  if (r) {
@@ -385,11 +209,11 @@ function batchRead(_x, _x2) {
385
209
  return _batchRead.apply(this, arguments);
386
210
  }
387
211
  function _batchRead() {
388
- _batchRead = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(reads, options) {
212
+ _batchRead = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(reads, options) {
389
213
  var _options$stxerApi;
390
214
  var ibh, payload, _iterator2, _step2, variable, _iterator3, _step3, map, _iterator4, _step4, ro, url, data, text, rs;
391
- return _regeneratorRuntime().wrap(function _callee$(_context) {
392
- while (1) switch (_context.prev = _context.next) {
215
+ return _regenerator().w(function (_context) {
216
+ while (1) switch (_context.n) {
393
217
  case 0:
394
218
  if (options === void 0) {
395
219
  options = {};
@@ -422,7 +246,7 @@ function _batchRead() {
422
246
  }
423
247
  }
424
248
  url = ((_options$stxerApi = options.stxerApi) != null ? _options$stxerApi : DEFAULT_STXER_API) + "/sidecar/v2/batch";
425
- _context.next = 9;
249
+ _context.n = 1;
426
250
  return fetch(url, {
427
251
  method: 'POST',
428
252
  body: JSON.stringify(payload),
@@ -430,526 +254,77 @@ function _batchRead() {
430
254
  'Content-Type': 'application/json'
431
255
  }
432
256
  });
433
- case 9:
434
- data = _context.sent;
435
- _context.next = 12;
257
+ case 1:
258
+ data = _context.v;
259
+ _context.n = 2;
436
260
  return data.text();
437
- case 12:
438
- text = _context.sent;
261
+ case 2:
262
+ text = _context.v;
439
263
  if (!(!text.includes('Ok') && !text.includes('Err'))) {
440
- _context.next = 15;
264
+ _context.n = 3;
441
265
  break;
442
266
  }
443
267
  throw new Error("Requesting batch reads failed: " + text + ", url: " + url + ", payload: " + JSON.stringify(payload));
444
- case 15:
268
+ case 3:
445
269
  rs = JSON.parse(text);
446
- return _context.abrupt("return", {
270
+ return _context.a(2, {
447
271
  tip: rs.tip,
448
272
  vars: convertResults(rs.vars),
449
273
  maps: convertResults(rs.maps),
450
274
  readonly: convertResults(rs.readonly)
451
275
  });
452
- case 17:
453
- case "end":
454
- return _context.stop();
455
276
  }
456
277
  }, _callee);
457
278
  }));
458
279
  return _batchRead.apply(this, arguments);
459
280
  }
460
281
 
461
- function runTx(tx) {
462
- // type 0: run transaction
463
- return tupleCV({
464
- type: uintCV(0),
465
- data: bufferCV(tx.serializeBytes())
466
- });
467
- }
468
- function runEval(_ref) {
469
- var contract_id = _ref.contract_id,
470
- code = _ref.code;
471
- var _contract_id$split = contract_id.split('.'),
472
- contract_address = _contract_id$split[0],
473
- contract_name = _contract_id$split[1];
474
- // type 1: eval arbitrary code inside a contract
475
- return tupleCV({
476
- type: uintCV(1),
477
- data: bufferCV(serializeCVBytes(tupleCV({
478
- contract: contractPrincipalCV(contract_address, contract_name),
479
- code: stringAsciiCV(code)
480
- })))
481
- });
482
- }
483
- function runSimulation(_x, _x2, _x3, _x4) {
484
- return _runSimulation.apply(this, arguments);
485
- }
486
- function _runSimulation() {
487
- _runSimulation = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(apiEndpoint, block_hash, block_height, txs) {
488
- var header, heightBytes, view, hashHex, matches, hashBytes, txBytes, totalLength, body, offset, _iterator3, _step4, tx, rs;
489
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
490
- while (1) switch (_context5.prev = _context5.next) {
491
- case 0:
492
- // Convert 'sim-v1' to Uint8Array
493
- header = new TextEncoder().encode('sim-v1'); // Create 8 bytes for block height
494
- heightBytes = new Uint8Array(8); // Convert block height to bytes
495
- view = new DataView(heightBytes.buffer);
496
- view.setBigUint64(0, BigInt(block_height), false); // false for big-endian
497
- // Convert block hash to bytes
498
- hashHex = block_hash.startsWith('0x') ? block_hash.substring(2) : block_hash; // Replace non-null assertion with null check
499
- matches = hashHex.match(/.{1,2}/g);
500
- if (matches) {
501
- _context5.next = 8;
502
- break;
503
- }
504
- throw new Error('Invalid block hash format');
505
- case 8:
506
- hashBytes = new Uint8Array(matches.map(function (_byte) {
507
- return Number.parseInt(_byte, 16);
508
- })); // Convert transactions to bytes
509
- txBytes = txs.map(function (t) {
510
- return 'contract_id' in t && 'code' in t ? runEval(t) : runTx(t);
511
- }).map(function (t) {
512
- return serializeCVBytes(t);
513
- }); // Combine all byte arrays
514
- totalLength = header.length + heightBytes.length + hashBytes.length + txBytes.reduce(function (acc, curr) {
515
- return acc + curr.length;
516
- }, 0);
517
- body = new Uint8Array(totalLength);
518
- offset = 0;
519
- body.set(header, offset);
520
- offset += header.length;
521
- body.set(heightBytes, offset);
522
- offset += heightBytes.length;
523
- body.set(hashBytes, offset);
524
- offset += hashBytes.length;
525
- for (_iterator3 = _createForOfIteratorHelperLoose(txBytes); !(_step4 = _iterator3()).done;) {
526
- tx = _step4.value;
527
- body.set(tx, offset);
528
- offset += tx.length;
529
- }
530
- _context5.next = 22;
531
- return fetch(apiEndpoint, {
532
- method: 'POST',
533
- body: body
534
- }).then(/*#__PURE__*/function () {
535
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(rs) {
536
- var response;
537
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
538
- while (1) switch (_context4.prev = _context4.next) {
539
- case 0:
540
- _context4.next = 2;
541
- return rs.text();
542
- case 2:
543
- response = _context4.sent;
544
- if (response.startsWith('{')) {
545
- _context4.next = 5;
546
- break;
547
- }
548
- throw new Error("failed to submit simulation: " + response);
549
- case 5:
550
- return _context4.abrupt("return", JSON.parse(response));
551
- case 6:
552
- case "end":
553
- return _context4.stop();
554
- }
555
- }, _callee4);
556
- }));
557
- return function (_x6) {
558
- return _ref3.apply(this, arguments);
559
- };
560
- }());
561
- case 22:
562
- rs = _context5.sent;
563
- return _context5.abrupt("return", rs.id);
564
- case 24:
565
- case "end":
566
- return _context5.stop();
567
- }
568
- }, _callee5);
569
- }));
570
- return _runSimulation.apply(this, arguments);
571
- }
572
- var SimulationBuilder = /*#__PURE__*/function () {
573
- function SimulationBuilder(options) {
574
- var _options$network, _options$apiEndpoint, _options$stacksNodeAP;
575
- if (options === void 0) {
576
- options = {};
577
- }
578
- this.apiEndpoint = void 0;
579
- this.stacksNodeAPI = void 0;
580
- this.network = void 0;
581
- // biome-ignore lint/style/useNumberNamespace: <explanation>
582
- this.block = NaN;
583
- this.sender = '';
584
- this.steps = [];
585
- this.network = (_options$network = options.network) != null ? _options$network : 'mainnet';
586
- var isTestnet = this.network === 'testnet';
587
- this.apiEndpoint = (_options$apiEndpoint = options.apiEndpoint) != null ? _options$apiEndpoint : isTestnet ? 'https://testnet-api.stxer.xyz' : 'https://api.stxer.xyz';
588
- this.stacksNodeAPI = (_options$stacksNodeAP = options.stacksNodeAPI) != null ? _options$stacksNodeAP : isTestnet ? 'https://api.testnet.hiro.so' : 'https://api.hiro.so';
282
+ var BatchProcessor = /*#__PURE__*/function () {
283
+ function BatchProcessor(options) {
284
+ var _options$stxerAPIEndp;
285
+ this.queues = new Map();
286
+ this.timeoutIds = new Map();
287
+ this.stxerAPIEndpoint = void 0;
288
+ this.batchDelayMs = void 0;
289
+ this.stxerAPIEndpoint = (_options$stxerAPIEndp = options.stxerAPIEndpoint) != null ? _options$stxerAPIEndp : 'https://api.stxer.xyz';
290
+ this.batchDelayMs = options.batchDelayMs;
589
291
  }
590
- SimulationBuilder["new"] = function _new(options) {
591
- return new SimulationBuilder(options);
592
- };
593
- var _proto = SimulationBuilder.prototype;
594
- _proto.useBlockHeight = function useBlockHeight(block) {
595
- this.block = block;
596
- return this;
597
- };
598
- _proto.withSender = function withSender(address) {
599
- this.sender = address;
600
- return this;
292
+ var _proto = BatchProcessor.prototype;
293
+ _proto.getQueueKey = function getQueueKey(tip) {
294
+ return tip != null ? tip : '_undefined';
601
295
  };
602
- _proto.inlineSimulation = function inlineSimulation(simulationId) {
603
- this.steps.push({
604
- simulationId: simulationId
296
+ _proto.read = function read(request) {
297
+ var _this = this;
298
+ return new Promise(function (resolve, reject) {
299
+ _this.enqueue({
300
+ request: request,
301
+ resolve: resolve,
302
+ reject: reject
303
+ });
605
304
  });
606
- return this;
607
- };
608
- _proto.addSTXTransfer = function addSTXTransfer(params) {
609
- var _params$sender, _params$fee;
610
- if (params.sender == null && this.sender === '') {
611
- throw new Error('Please specify a sender with useSender or adding a sender paramenter');
612
- }
613
- this.steps.push(_extends({}, params, {
614
- sender: (_params$sender = params.sender) != null ? _params$sender : this.sender,
615
- fee: (_params$fee = params.fee) != null ? _params$fee : 0
616
- }));
617
- return this;
618
305
  };
619
- _proto.addContractCall = function addContractCall(params) {
620
- var _params$sender2, _params$fee2;
621
- if (params.sender == null && this.sender === '') {
622
- throw new Error('Please specify a sender with useSender or adding a sender paramenter');
306
+ _proto.enqueue = function enqueue(request) {
307
+ var _this$queues$get,
308
+ _this2 = this;
309
+ var queueKey = this.getQueueKey(request.tip);
310
+ var queue = (_this$queues$get = this.queues.get(queueKey)) != null ? _this$queues$get : [];
311
+ if (!this.queues.has(queueKey)) {
312
+ this.queues.set(queueKey, queue);
623
313
  }
624
- this.steps.push(_extends({}, params, {
625
- sender: (_params$sender2 = params.sender) != null ? _params$sender2 : this.sender,
626
- fee: (_params$fee2 = params.fee) != null ? _params$fee2 : 0
627
- }));
628
- return this;
629
- };
630
- _proto.addContractDeploy = function addContractDeploy(params) {
631
- var _params$deployer, _params$fee3, _params$clarity_versi;
632
- if (params.deployer == null && this.sender === '') {
633
- throw new Error('Please specify a deployer with useSender or adding a deployer paramenter');
634
- }
635
- this.steps.push(_extends({}, params, {
636
- deployer: (_params$deployer = params.deployer) != null ? _params$deployer : this.sender,
637
- fee: (_params$fee3 = params.fee) != null ? _params$fee3 : 0,
638
- clarity_version: (_params$clarity_versi = params.clarity_version) != null ? _params$clarity_versi : ClarityVersion.Clarity3
639
- }));
640
- return this;
641
- };
642
- _proto.addEvalCode = function addEvalCode(inside_contract_id, code) {
643
- this.steps.push({
644
- contract_id: inside_contract_id,
645
- code: code
646
- });
647
- return this;
648
- };
649
- _proto.addMapRead = function addMapRead(contract_id, map, key) {
650
- this.steps.push({
651
- contract_id: contract_id,
652
- code: "(map-get " + map + " " + key + ")"
653
- });
654
- return this;
655
- };
656
- _proto.addVarRead = function addVarRead(contract_id, variable) {
657
- this.steps.push({
658
- contract_id: contract_id,
659
- code: "(var-get " + variable + ")"
660
- });
661
- return this;
662
- };
663
- _proto.getBlockInfo = /*#__PURE__*/function () {
664
- var _getBlockInfo = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
665
- var _yield$getNodeInfo, stacks_tip_height, info;
666
- return _regeneratorRuntime().wrap(function _callee$(_context) {
667
- while (1) switch (_context.prev = _context.next) {
668
- case 0:
669
- if (!Number.isNaN(this.block)) {
670
- _context.next = 6;
671
- break;
672
- }
673
- _context.next = 3;
674
- return getNodeInfo({
675
- stacksEndpoint: this.stacksNodeAPI
676
- });
677
- case 3:
678
- _yield$getNodeInfo = _context.sent;
679
- stacks_tip_height = _yield$getNodeInfo.stacks_tip_height;
680
- this.block = stacks_tip_height;
681
- case 6:
682
- _context.next = 8;
683
- return richFetch(this.stacksNodeAPI + "/extended/v1/block/by_height/" + this.block + "?unanchored=true").then(function (r) {
684
- return r.json();
685
- });
686
- case 8:
687
- info = _context.sent;
688
- if (!(info.height !== this.block || typeof info.hash !== 'string' || !info.hash.startsWith('0x'))) {
689
- _context.next = 11;
690
- break;
691
- }
692
- throw new Error("failed to get block info for block height " + this.block);
693
- case 11:
694
- return _context.abrupt("return", {
695
- block_height: this.block,
696
- block_hash: info.hash.substring(2),
697
- index_block_hash: info.index_block_hash.substring(2)
698
- });
699
- case 12:
700
- case "end":
701
- return _context.stop();
702
- }
703
- }, _callee, this);
704
- }));
705
- function getBlockInfo() {
706
- return _getBlockInfo.apply(this, arguments);
707
- }
708
- return getBlockInfo;
709
- }();
710
- _proto.run = /*#__PURE__*/function () {
711
- var _run = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
712
- var _this = this;
713
- var block, txs, nonce_by_address, nextNonce, network, _iterator, _step, step, previousSimulation, _iterator2, _step2, _step3, _step$function_args, nonce, _step$contract_id$spl, contractAddress, contractName, tx, _nonce, _tx, _nonce2, _tx2, id;
714
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
715
- while (1) switch (_context3.prev = _context3.next) {
716
- case 0:
717
- console.log("--------------------------------\nThis product can never exist without your support!\n\nWe receive sponsorship funds with:\nSP212Y5JKN59YP3GYG07K3S8W5SSGE4KH6B5STXER\n\nFeedbacks and feature requests are welcome.\nTo get in touch: contact@stxer.xyz\n--------------------------------");
718
- _context3.next = 3;
719
- return this.getBlockInfo();
720
- case 3:
721
- block = _context3.sent;
722
- console.log("Using block height " + block.block_height + " hash 0x" + block.block_hash + " to run simulation.");
723
- txs = [];
724
- nonce_by_address = new Map();
725
- nextNonce = /*#__PURE__*/function () {
726
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sender) {
727
- var nonce, url, account;
728
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
729
- while (1) switch (_context2.prev = _context2.next) {
730
- case 0:
731
- nonce = nonce_by_address.get(sender);
732
- if (!(nonce == null)) {
733
- _context2.next = 8;
734
- break;
735
- }
736
- url = _this.stacksNodeAPI + "/v2/accounts/" + sender + "?proof=" + false + "&tip=" + block.index_block_hash;
737
- _context2.next = 5;
738
- return richFetch(url).then(function (r) {
739
- return r.json();
740
- });
741
- case 5:
742
- account = _context2.sent;
743
- nonce_by_address.set(sender, account.nonce + 1);
744
- return _context2.abrupt("return", account.nonce);
745
- case 8:
746
- nonce_by_address.set(sender, nonce + 1);
747
- return _context2.abrupt("return", nonce);
748
- case 10:
749
- case "end":
750
- return _context2.stop();
751
- }
752
- }, _callee2);
753
- }));
754
- return function nextNonce(_x5) {
755
- return _ref2.apply(this, arguments);
756
- };
757
- }();
758
- network = this.network === 'mainnet' ? STACKS_MAINNET : STACKS_TESTNET;
759
- if (this.stacksNodeAPI) {
760
- network = _extends({}, network, {
761
- client: _extends({}, network.client, {
762
- baseUrl: this.stacksNodeAPI
763
- })
764
- });
765
- }
766
- _iterator = _createForOfIteratorHelperLoose(this.steps);
767
- case 11:
768
- if ((_step = _iterator()).done) {
769
- _context3.next = 57;
770
- break;
771
- }
772
- step = _step.value;
773
- if (!('simulationId' in step)) {
774
- _context3.next = 20;
775
- break;
776
- }
777
- _context3.next = 16;
778
- return fetch("https://api.stxer.xyz/simulations/" + step.simulationId + "/request").then(function (x) {
779
- return x.json();
780
- });
781
- case 16:
782
- previousSimulation = _context3.sent;
783
- for (_iterator2 = _createForOfIteratorHelperLoose(previousSimulation.steps); !(_step2 = _iterator2()).done;) {
784
- _step3 = _step2.value;
785
- if ('tx' in _step3) {
786
- txs.push(deserializeTransaction(_step3.tx));
787
- } else if ('code' in _step3 && 'contract' in _step3) {
788
- txs.push({
789
- contract_id: _step3.contract,
790
- code: _step3.code
791
- });
792
- }
793
- }
794
- _context3.next = 55;
795
- break;
796
- case 20:
797
- if (!('sender' in step && 'function_name' in step)) {
798
- _context3.next = 32;
799
- break;
800
- }
801
- _context3.next = 23;
802
- return nextNonce(step.sender);
803
- case 23:
804
- nonce = _context3.sent;
805
- _step$contract_id$spl = step.contract_id.split('.'), contractAddress = _step$contract_id$spl[0], contractName = _step$contract_id$spl[1];
806
- _context3.next = 27;
807
- return makeUnsignedContractCall({
808
- contractAddress: contractAddress,
809
- contractName: contractName,
810
- functionName: step.function_name,
811
- functionArgs: (_step$function_args = step.function_args) != null ? _step$function_args : [],
812
- nonce: nonce,
813
- network: network,
814
- publicKey: '',
815
- postConditionMode: PostConditionMode.Allow,
816
- fee: step.fee
817
- });
818
- case 27:
819
- tx = _context3.sent;
820
- tx.auth.spendingCondition.signer = c32addressDecode(step.sender)[1];
821
- txs.push(tx);
822
- _context3.next = 55;
823
- break;
824
- case 32:
825
- if (!('sender' in step && 'recipient' in step)) {
826
- _context3.next = 43;
827
- break;
828
- }
829
- _context3.next = 35;
830
- return nextNonce(step.sender);
831
- case 35:
832
- _nonce = _context3.sent;
833
- _context3.next = 38;
834
- return makeUnsignedSTXTokenTransfer({
835
- recipient: step.recipient,
836
- amount: step.amount,
837
- nonce: _nonce,
838
- network: network,
839
- publicKey: '',
840
- fee: step.fee
841
- });
842
- case 38:
843
- _tx = _context3.sent;
844
- _tx.auth.spendingCondition.signer = c32addressDecode(step.sender)[1];
845
- txs.push(_tx);
846
- _context3.next = 55;
847
- break;
848
- case 43:
849
- if (!('deployer' in step)) {
850
- _context3.next = 54;
851
- break;
852
- }
853
- _context3.next = 46;
854
- return nextNonce(step.deployer);
855
- case 46:
856
- _nonce2 = _context3.sent;
857
- _context3.next = 49;
858
- return makeUnsignedContractDeploy({
859
- contractName: step.contract_name,
860
- codeBody: step.source_code,
861
- nonce: _nonce2,
862
- network: network,
863
- publicKey: '',
864
- postConditionMode: PostConditionMode.Allow,
865
- fee: step.fee
866
- });
867
- case 49:
868
- _tx2 = _context3.sent;
869
- _tx2.auth.spendingCondition.signer = c32addressDecode(step.deployer)[1];
870
- txs.push(_tx2);
871
- _context3.next = 55;
872
- break;
873
- case 54:
874
- if ('code' in step) {
875
- txs.push(step);
876
- } else {
877
- // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
878
- console.log("Invalid simulation step:", step);
879
- }
880
- case 55:
881
- _context3.next = 11;
882
- break;
883
- case 57:
884
- _context3.next = 59;
885
- return runSimulation(this.apiEndpoint + "/simulations", block.block_hash, block.block_height, txs);
886
- case 59:
887
- id = _context3.sent;
888
- console.log("Simulation will be available at: https://stxer.xyz/simulations/" + this.network + "/" + id);
889
- return _context3.abrupt("return", id);
890
- case 62:
891
- case "end":
892
- return _context3.stop();
893
- }
894
- }, _callee3, this);
895
- }));
896
- function run() {
897
- return _run.apply(this, arguments);
898
- }
899
- return run;
900
- }();
901
- _proto.pipe = function pipe(transform) {
902
- return transform(this);
903
- };
904
- return SimulationBuilder;
905
- }();
906
-
907
- var BatchProcessor = /*#__PURE__*/function () {
908
- function BatchProcessor(options) {
909
- var _options$stxerAPIEndp;
910
- this.queues = new Map();
911
- this.timeoutIds = new Map();
912
- this.stxerAPIEndpoint = void 0;
913
- this.batchDelayMs = void 0;
914
- this.stxerAPIEndpoint = (_options$stxerAPIEndp = options.stxerAPIEndpoint) != null ? _options$stxerAPIEndp : 'https://api.stxer.xyz';
915
- this.batchDelayMs = options.batchDelayMs;
916
- }
917
- var _proto = BatchProcessor.prototype;
918
- _proto.getQueueKey = function getQueueKey(tip) {
919
- return tip != null ? tip : '_undefined';
920
- };
921
- _proto.read = function read(request) {
922
- var _this = this;
923
- return new Promise(function (resolve, reject) {
924
- _this.enqueue({
925
- request: request,
926
- resolve: resolve,
927
- reject: reject
928
- });
929
- });
930
- };
931
- _proto.enqueue = function enqueue(request) {
932
- var _this$queues$get,
933
- _this2 = this;
934
- var queueKey = this.getQueueKey(request.tip);
935
- var queue = (_this$queues$get = this.queues.get(queueKey)) != null ? _this$queues$get : [];
936
- if (!this.queues.has(queueKey)) {
937
- this.queues.set(queueKey, queue);
938
- }
939
- queue.push(request);
940
- if (!this.timeoutIds.has(queueKey)) {
941
- var timeoutId = setTimeout(function () {
942
- return _this2.processBatch(queueKey);
943
- }, this.batchDelayMs);
944
- this.timeoutIds.set(queueKey, timeoutId);
314
+ queue.push(request);
315
+ if (!this.timeoutIds.has(queueKey)) {
316
+ var timeoutId = setTimeout(function () {
317
+ return _this2.processBatch(queueKey);
318
+ }, this.batchDelayMs);
319
+ this.timeoutIds.set(queueKey, timeoutId);
945
320
  }
946
321
  };
947
322
  _proto.processBatch = /*#__PURE__*/function () {
948
- var _processBatch = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(queueKey) {
323
+ var _processBatch = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(queueKey) {
949
324
  var _this$queues$get2;
950
- var currentQueue, timeoutId, readonlyRequests, mapRequests, variableRequests, tip, batchRequest, results, _iterator, _step, _step$value, index, result, _iterator2, _step2, _step2$value, _index, _result, _iterator3, _step3, _step3$value, _index2, _result2, _iterator4, _step4, item;
951
- return _regeneratorRuntime().wrap(function _callee$(_context) {
952
- while (1) switch (_context.prev = _context.next) {
325
+ var currentQueue, timeoutId, readonlyRequests, mapRequests, variableRequests, tip, batchRequest, results, _iterator, _step, _step$value, index, result, _iterator2, _step2, _step2$value, _index, _result, _iterator3, _step3, _step3$value, _index2, _result2, _iterator4, _step4, item, _t;
326
+ return _regenerator().w(function (_context) {
327
+ while (1) switch (_context.p = _context.n) {
953
328
  case 0:
954
329
  currentQueue = (_this$queues$get2 = this.queues.get(queueKey)) != null ? _this$queues$get2 : [];
955
330
  this.queues["delete"](queueKey);
@@ -959,12 +334,12 @@ var BatchProcessor = /*#__PURE__*/function () {
959
334
  this.timeoutIds["delete"](queueKey);
960
335
  }
961
336
  if (!(currentQueue.length === 0)) {
962
- _context.next = 6;
337
+ _context.n = 1;
963
338
  break;
964
339
  }
965
- return _context.abrupt("return");
966
- case 6:
967
- _context.prev = 6;
340
+ return _context.a(2);
341
+ case 1:
342
+ _context.p = 1;
968
343
  readonlyRequests = currentQueue.filter(function (q) {
969
344
  return q.request.mode === 'readonly';
970
345
  });
@@ -1001,12 +376,12 @@ var BatchProcessor = /*#__PURE__*/function () {
1001
376
  }),
1002
377
  index_block_hash: tip
1003
378
  };
1004
- _context.next = 14;
379
+ _context.n = 2;
1005
380
  return batchRead(batchRequest, {
1006
381
  stxerApi: this.stxerAPIEndpoint
1007
382
  });
1008
- case 14:
1009
- results = _context.sent;
383
+ case 2:
384
+ results = _context.v;
1010
385
  // Handle readonly results
1011
386
  for (_iterator = _createForOfIteratorHelperLoose(results.readonly.entries()); !(_step = _iterator()).done;) {
1012
387
  _step$value = _step.value, index = _step$value[0], result = _step$value[1];
@@ -1034,20 +409,19 @@ var BatchProcessor = /*#__PURE__*/function () {
1034
409
  mapRequests[_index2].resolve(_result2);
1035
410
  }
1036
411
  }
1037
- _context.next = 23;
412
+ _context.n = 4;
1038
413
  break;
1039
- case 20:
1040
- _context.prev = 20;
1041
- _context.t0 = _context["catch"](6);
414
+ case 3:
415
+ _context.p = 3;
416
+ _t = _context.v;
1042
417
  for (_iterator4 = _createForOfIteratorHelperLoose(currentQueue); !(_step4 = _iterator4()).done;) {
1043
418
  item = _step4.value;
1044
- item.reject(_context.t0);
419
+ item.reject(_t);
1045
420
  }
1046
- case 23:
1047
- case "end":
1048
- return _context.stop();
421
+ case 4:
422
+ return _context.a(2);
1049
423
  }
1050
- }, _callee, this, [[6, 20]]);
424
+ }, _callee, this, [[1, 3]]);
1051
425
  }));
1052
426
  function processBatch(_x) {
1053
427
  return _processBatch.apply(this, arguments);
@@ -1065,11 +439,11 @@ function callReadonly(_x) {
1065
439
  return _callReadonly.apply(this, arguments);
1066
440
  }
1067
441
  function _callReadonly() {
1068
- _callReadonly = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
442
+ _callReadonly = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
1069
443
  var _params$batchProcesso;
1070
444
  var processor, _params$contract$spli, deployer, contractName, fn, functionDef, argsKV, args, _iterator, _step, argDef;
1071
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1072
- while (1) switch (_context.prev = _context.next) {
445
+ return _regenerator().w(function (_context) {
446
+ while (1) switch (_context.n) {
1073
447
  case 0:
1074
448
  processor = (_params$batchProcesso = params.batchProcessor) != null ? _params$batchProcesso : defaultProcessor;
1075
449
  _params$contract$spli = params.contract.split('.', 2), deployer = _params$contract$spli[0], contractName = _params$contract$spli[1];
@@ -1078,18 +452,18 @@ function _callReadonly() {
1078
452
  return def.name === params.functionName;
1079
453
  });
1080
454
  if (functionDef) {
1081
- _context.next = 6;
455
+ _context.n = 1;
1082
456
  break;
1083
457
  }
1084
458
  throw new Error("failed to find function definition for " + params.functionName);
1085
- case 6:
459
+ case 1:
1086
460
  argsKV = params.args;
1087
461
  args = [];
1088
462
  for (_iterator = _createForOfIteratorHelperLoose(functionDef.args); !(_step = _iterator()).done;) {
1089
463
  argDef = _step.value;
1090
464
  args.push(encodeAbi(argDef.type, argsKV[argDef.name]));
1091
465
  }
1092
- return _context.abrupt("return", new Promise(function (_resolve, reject) {
466
+ return _context.a(2, new Promise(function (_resolve, reject) {
1093
467
  processor.enqueue({
1094
468
  request: {
1095
469
  mode: 'readonly',
@@ -1110,9 +484,6 @@ function _callReadonly() {
1110
484
  reject: reject
1111
485
  });
1112
486
  }));
1113
- case 10:
1114
- case "end":
1115
- return _context.stop();
1116
487
  }
1117
488
  }, _callee);
1118
489
  }));
@@ -1122,11 +493,11 @@ function readMap(_x2) {
1122
493
  return _readMap.apply(this, arguments);
1123
494
  }
1124
495
  function _readMap() {
1125
- _readMap = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
496
+ _readMap = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(params) {
1126
497
  var _params$batchProcesso2;
1127
498
  var processor, _params$contract$spli2, deployer, contractName, mapDef, key;
1128
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1129
- while (1) switch (_context2.prev = _context2.next) {
499
+ return _regenerator().w(function (_context2) {
500
+ while (1) switch (_context2.n) {
1130
501
  case 0:
1131
502
  processor = (_params$batchProcesso2 = params.batchProcessor) != null ? _params$batchProcesso2 : defaultProcessor;
1132
503
  _params$contract$spli2 = params.contract.split('.', 2), deployer = _params$contract$spli2[0], contractName = _params$contract$spli2[1];
@@ -1134,13 +505,13 @@ function _readMap() {
1134
505
  return m.name === params.mapName;
1135
506
  });
1136
507
  if (mapDef) {
1137
- _context2.next = 5;
508
+ _context2.n = 1;
1138
509
  break;
1139
510
  }
1140
511
  throw new Error("failed to find map definition for " + params.mapName);
1141
- case 5:
512
+ case 1:
1142
513
  key = encodeAbi(mapDef.key, params.key);
1143
- return _context2.abrupt("return", new Promise(function (_resolve2, reject) {
514
+ return _context2.a(2, new Promise(function (_resolve2, reject) {
1144
515
  processor.enqueue({
1145
516
  request: {
1146
517
  mode: 'mapEntry',
@@ -1169,9 +540,6 @@ function _readMap() {
1169
540
  reject: reject
1170
541
  });
1171
542
  }));
1172
- case 7:
1173
- case "end":
1174
- return _context2.stop();
1175
543
  }
1176
544
  }, _callee2);
1177
545
  }));
@@ -1181,11 +549,11 @@ function readVariable(_x3) {
1181
549
  return _readVariable.apply(this, arguments);
1182
550
  }
1183
551
  function _readVariable() {
1184
- _readVariable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
552
+ _readVariable = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(params) {
1185
553
  var _params$batchProcesso3;
1186
554
  var processor, _params$contract$spli3, deployer, contractName, varDef;
1187
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1188
- while (1) switch (_context3.prev = _context3.next) {
555
+ return _regenerator().w(function (_context3) {
556
+ while (1) switch (_context3.n) {
1189
557
  case 0:
1190
558
  processor = (_params$batchProcesso3 = params.batchProcessor) != null ? _params$batchProcesso3 : defaultProcessor;
1191
559
  _params$contract$spli3 = params.contract.split('.', 2), deployer = _params$contract$spli3[0], contractName = _params$contract$spli3[1];
@@ -1193,12 +561,12 @@ function _readVariable() {
1193
561
  return def.name === params.variableName;
1194
562
  });
1195
563
  if (varDef) {
1196
- _context3.next = 5;
564
+ _context3.n = 1;
1197
565
  break;
1198
566
  }
1199
567
  throw new Error("failed to find variable definition for " + params.variableName);
1200
- case 5:
1201
- return _context3.abrupt("return", new Promise(function (_resolve3, reject) {
568
+ case 1:
569
+ return _context3.a(2, new Promise(function (_resolve3, reject) {
1202
570
  processor.enqueue({
1203
571
  request: {
1204
572
  mode: 'variable',
@@ -1218,14 +586,501 @@ function _readVariable() {
1218
586
  reject: reject
1219
587
  });
1220
588
  }));
1221
- case 6:
1222
- case "end":
1223
- return _context3.stop();
1224
589
  }
1225
590
  }, _callee3);
1226
591
  }));
1227
592
  return _readVariable.apply(this, arguments);
1228
593
  }
1229
594
 
595
+ function setSender(tx, sender) {
596
+ var _c32addressDecode = c32addressDecode(sender),
597
+ addressVersion = _c32addressDecode[0],
598
+ signer = _c32addressDecode[1];
599
+ switch (addressVersion) {
600
+ case AddressVersion.MainnetSingleSig:
601
+ case AddressVersion.TestnetSingleSig:
602
+ tx.auth.spendingCondition.hashMode = AddressHashMode.P2PKH;
603
+ tx.auth.spendingCondition.signer = signer;
604
+ break;
605
+ case AddressVersion.MainnetMultiSig:
606
+ case AddressVersion.TestnetMultiSig:
607
+ {
608
+ var sc = tx.auth.spendingCondition;
609
+ tx.auth.spendingCondition = {
610
+ hashMode: AddressHashMode.P2SH,
611
+ signer: signer,
612
+ fields: [],
613
+ signaturesRequired: 0,
614
+ nonce: sc.nonce,
615
+ fee: sc.fee
616
+ };
617
+ break;
618
+ }
619
+ }
620
+ return tx;
621
+ }
622
+ function runTx(tx) {
623
+ // type 0: run transaction
624
+ return tupleCV({
625
+ type: uintCV(0),
626
+ data: bufferCV(tx.serializeBytes())
627
+ });
628
+ }
629
+ function runEval(_ref) {
630
+ var contract_id = _ref.contract_id,
631
+ code = _ref.code;
632
+ var _contract_id$split = contract_id.split('.'),
633
+ contract_address = _contract_id$split[0],
634
+ contract_name = _contract_id$split[1];
635
+ // type 1: eval arbitrary code inside a contract
636
+ return tupleCV({
637
+ type: uintCV(1),
638
+ data: bufferCV(serializeCVBytes(tupleCV({
639
+ contract: contractPrincipalCV(contract_address, contract_name),
640
+ code: stringAsciiCV(code)
641
+ })))
642
+ });
643
+ }
644
+ function runSimulation(_x, _x2, _x3, _x4) {
645
+ return _runSimulation.apply(this, arguments);
646
+ }
647
+ function _runSimulation() {
648
+ _runSimulation = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(apiEndpoint, block_hash, block_height, txs) {
649
+ var header, heightBytes, view, hashHex, matches, hashBytes, txBytes, totalLength, body, offset, _iterator3, _step4, tx, rs;
650
+ return _regenerator().w(function (_context7) {
651
+ while (1) switch (_context7.n) {
652
+ case 0:
653
+ // Convert 'sim-v1' to Uint8Array
654
+ header = new TextEncoder().encode('sim-v1'); // Create 8 bytes for block height
655
+ heightBytes = new Uint8Array(8); // Convert block height to bytes
656
+ view = new DataView(heightBytes.buffer);
657
+ view.setBigUint64(0, BigInt(block_height), false); // false for big-endian
658
+ // Convert block hash to bytes
659
+ hashHex = block_hash.startsWith('0x') ? block_hash.substring(2) : block_hash; // Replace non-null assertion with null check
660
+ matches = hashHex.match(/.{1,2}/g);
661
+ if (matches) {
662
+ _context7.n = 1;
663
+ break;
664
+ }
665
+ throw new Error('Invalid block hash format');
666
+ case 1:
667
+ hashBytes = new Uint8Array(matches.map(function (_byte) {
668
+ return Number.parseInt(_byte, 16);
669
+ })); // Convert transactions to bytes
670
+ txBytes = txs.map(function (t) {
671
+ return 'contract_id' in t && 'code' in t ? runEval(t) : runTx(t);
672
+ }).map(function (t) {
673
+ return serializeCVBytes(t);
674
+ }); // Combine all byte arrays
675
+ totalLength = header.length + heightBytes.length + hashBytes.length + txBytes.reduce(function (acc, curr) {
676
+ return acc + curr.length;
677
+ }, 0);
678
+ body = new Uint8Array(totalLength);
679
+ offset = 0;
680
+ body.set(header, offset);
681
+ offset += header.length;
682
+ body.set(heightBytes, offset);
683
+ offset += heightBytes.length;
684
+ body.set(hashBytes, offset);
685
+ offset += hashBytes.length;
686
+ for (_iterator3 = _createForOfIteratorHelperLoose(txBytes); !(_step4 = _iterator3()).done;) {
687
+ tx = _step4.value;
688
+ body.set(tx, offset);
689
+ offset += tx.length;
690
+ }
691
+ _context7.n = 2;
692
+ return fetch(apiEndpoint, {
693
+ method: 'POST',
694
+ body: body
695
+ }).then(/*#__PURE__*/function () {
696
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(rs) {
697
+ var response;
698
+ return _regenerator().w(function (_context6) {
699
+ while (1) switch (_context6.n) {
700
+ case 0:
701
+ _context6.n = 1;
702
+ return rs.text();
703
+ case 1:
704
+ response = _context6.v;
705
+ if (response.startsWith('{')) {
706
+ _context6.n = 2;
707
+ break;
708
+ }
709
+ throw new Error("failed to submit simulation: " + response);
710
+ case 2:
711
+ return _context6.a(2, JSON.parse(response));
712
+ }
713
+ }, _callee5);
714
+ }));
715
+ return function (_x7) {
716
+ return _ref4.apply(this, arguments);
717
+ };
718
+ }());
719
+ case 2:
720
+ rs = _context7.v;
721
+ return _context7.a(2, rs.id);
722
+ }
723
+ }, _callee6);
724
+ }));
725
+ return _runSimulation.apply(this, arguments);
726
+ }
727
+ var SimulationBuilder = /*#__PURE__*/function () {
728
+ function SimulationBuilder(options) {
729
+ var _options$network, _options$apiEndpoint, _options$stacksNodeAP;
730
+ if (options === void 0) {
731
+ options = {};
732
+ }
733
+ this.apiEndpoint = void 0;
734
+ this.stacksNodeAPI = void 0;
735
+ this.network = void 0;
736
+ // biome-ignore lint/style/useNumberNamespace: ignore this
737
+ this.block = NaN;
738
+ this.sender = '';
739
+ this.steps = [];
740
+ this.network = (_options$network = options.network) != null ? _options$network : 'mainnet';
741
+ var isTestnet = this.network === 'testnet';
742
+ this.apiEndpoint = (_options$apiEndpoint = options.apiEndpoint) != null ? _options$apiEndpoint : isTestnet ? 'https://testnet-api.stxer.xyz' : 'https://api.stxer.xyz';
743
+ this.stacksNodeAPI = (_options$stacksNodeAP = options.stacksNodeAPI) != null ? _options$stacksNodeAP : isTestnet ? 'https://api.testnet.hiro.so' : 'https://api.hiro.so';
744
+ }
745
+ SimulationBuilder["new"] = function _new(options) {
746
+ return new SimulationBuilder(options);
747
+ };
748
+ var _proto = SimulationBuilder.prototype;
749
+ _proto.useBlockHeight = function useBlockHeight(block) {
750
+ this.block = block;
751
+ return this;
752
+ };
753
+ _proto.withSender = function withSender(address) {
754
+ this.sender = address;
755
+ return this;
756
+ };
757
+ _proto.inlineSimulation = function inlineSimulation(simulationId) {
758
+ this.steps.push({
759
+ simulationId: simulationId
760
+ });
761
+ return this;
762
+ };
763
+ _proto.addSTXTransfer = function addSTXTransfer(params) {
764
+ var _params$sender, _params$fee;
765
+ if (params.sender == null && this.sender === '') {
766
+ throw new Error('Please specify a sender with useSender or adding a sender paramenter');
767
+ }
768
+ this.steps.push(_extends({}, params, {
769
+ sender: (_params$sender = params.sender) != null ? _params$sender : this.sender,
770
+ fee: (_params$fee = params.fee) != null ? _params$fee : 0
771
+ }));
772
+ return this;
773
+ };
774
+ _proto.addContractCall = function addContractCall(params) {
775
+ var _params$sender2, _params$fee2;
776
+ if (params.sender == null && this.sender === '') {
777
+ throw new Error('Please specify a sender with useSender or adding a sender paramenter');
778
+ }
779
+ this.steps.push(_extends({}, params, {
780
+ sender: (_params$sender2 = params.sender) != null ? _params$sender2 : this.sender,
781
+ fee: (_params$fee2 = params.fee) != null ? _params$fee2 : 0
782
+ }));
783
+ return this;
784
+ };
785
+ _proto.addContractDeploy = function addContractDeploy(params) {
786
+ var _params$deployer, _params$fee3, _params$clarity_versi;
787
+ if (params.deployer == null && this.sender === '') {
788
+ throw new Error('Please specify a deployer with useSender or adding a deployer paramenter');
789
+ }
790
+ this.steps.push(_extends({}, params, {
791
+ deployer: (_params$deployer = params.deployer) != null ? _params$deployer : this.sender,
792
+ fee: (_params$fee3 = params.fee) != null ? _params$fee3 : 0,
793
+ clarity_version: (_params$clarity_versi = params.clarity_version) != null ? _params$clarity_versi : ClarityVersion.Clarity4
794
+ }));
795
+ return this;
796
+ };
797
+ _proto.addEvalCode = function addEvalCode(inside_contract_id, code) {
798
+ this.steps.push({
799
+ contract_id: inside_contract_id,
800
+ code: code
801
+ });
802
+ return this;
803
+ };
804
+ _proto.addMapRead = function addMapRead(contract_id, map, key) {
805
+ this.steps.push({
806
+ contract_id: contract_id,
807
+ code: "(map-get " + map + " " + key + ")"
808
+ });
809
+ return this;
810
+ };
811
+ _proto.addVarRead = function addVarRead(contract_id, variable) {
812
+ this.steps.push({
813
+ contract_id: contract_id,
814
+ code: "(var-get " + variable + ")"
815
+ });
816
+ return this;
817
+ };
818
+ _proto.getBlockInfo = /*#__PURE__*/function () {
819
+ var _getBlockInfo = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
820
+ var _yield$getNodeInfo, stacks_tip_height, info;
821
+ return _regenerator().w(function (_context) {
822
+ while (1) switch (_context.n) {
823
+ case 0:
824
+ if (!Number.isNaN(this.block)) {
825
+ _context.n = 2;
826
+ break;
827
+ }
828
+ _context.n = 1;
829
+ return getNodeInfo({
830
+ stacksEndpoint: this.stacksNodeAPI
831
+ });
832
+ case 1:
833
+ _yield$getNodeInfo = _context.v;
834
+ stacks_tip_height = _yield$getNodeInfo.stacks_tip_height;
835
+ this.block = stacks_tip_height;
836
+ case 2:
837
+ _context.n = 3;
838
+ return richFetch(this.stacksNodeAPI + "/extended/v1/block/by_height/" + this.block + "?unanchored=true").then(function (r) {
839
+ return r.json();
840
+ });
841
+ case 3:
842
+ info = _context.v;
843
+ if (!(info.height !== this.block || typeof info.hash !== 'string' || !info.hash.startsWith('0x'))) {
844
+ _context.n = 4;
845
+ break;
846
+ }
847
+ throw new Error("failed to get block info for block height " + this.block);
848
+ case 4:
849
+ return _context.a(2, {
850
+ block_height: this.block,
851
+ block_hash: info.hash.substring(2),
852
+ index_block_hash: info.index_block_hash.substring(2)
853
+ });
854
+ }
855
+ }, _callee, this);
856
+ }));
857
+ function getBlockInfo() {
858
+ return _getBlockInfo.apply(this, arguments);
859
+ }
860
+ return getBlockInfo;
861
+ }();
862
+ _proto.run = /*#__PURE__*/function () {
863
+ var _run = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
864
+ var _this = this;
865
+ var block, txs, nonce_by_address, nextNonce, network, _loop, _iterator, _step, id;
866
+ return _regenerator().w(function (_context5) {
867
+ while (1) switch (_context5.n) {
868
+ case 0:
869
+ console.log("--------------------------------\nThis product can never exist without your support!\n\nWe receive sponsorship funds with:\nSP212Y5JKN59YP3GYG07K3S8W5SSGE4KH6B5STXER\n\nFeedbacks and feature requests are welcome.\nTo get in touch: contact@stxer.xyz\n--------------------------------");
870
+ _context5.n = 1;
871
+ return this.getBlockInfo();
872
+ case 1:
873
+ block = _context5.v;
874
+ console.log("Using block height " + block.block_height + " hash 0x" + block.block_hash + " to run simulation.");
875
+ txs = [];
876
+ nonce_by_address = new Map();
877
+ nextNonce = /*#__PURE__*/function () {
878
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(sender) {
879
+ var nonce, url, account;
880
+ return _regenerator().w(function (_context2) {
881
+ while (1) switch (_context2.n) {
882
+ case 0:
883
+ nonce = nonce_by_address.get(sender);
884
+ if (!(nonce == null)) {
885
+ _context2.n = 2;
886
+ break;
887
+ }
888
+ url = _this.stacksNodeAPI + "/v2/accounts/" + sender + "?proof=" + false + "&tip=" + block.index_block_hash;
889
+ _context2.n = 1;
890
+ return richFetch(url).then(function (r) {
891
+ return r.json();
892
+ });
893
+ case 1:
894
+ account = _context2.v;
895
+ nonce_by_address.set(sender, account.nonce + 1);
896
+ return _context2.a(2, account.nonce);
897
+ case 2:
898
+ nonce_by_address.set(sender, nonce + 1);
899
+ return _context2.a(2, nonce);
900
+ }
901
+ }, _callee2);
902
+ }));
903
+ return function nextNonce(_x5) {
904
+ return _ref2.apply(this, arguments);
905
+ };
906
+ }();
907
+ network = this.network === 'mainnet' ? STACKS_MAINNET : STACKS_TESTNET;
908
+ if (this.stacksNodeAPI) {
909
+ network = _extends({}, network, {
910
+ client: _extends({}, network.client, {
911
+ baseUrl: this.stacksNodeAPI
912
+ })
913
+ });
914
+ }
915
+ _loop = /*#__PURE__*/_regenerator().m(function _loop() {
916
+ var step, previousSimulation, _iterator2, _step2, _step3, _step$function_args, nonce, _step$contract_id$spl, contractAddress, contractName, tx, _nonce, _tx, _nonce2, _tx2;
917
+ return _regenerator().w(function (_context4) {
918
+ while (1) switch (_context4.n) {
919
+ case 0:
920
+ step = _step.value;
921
+ if (!('simulationId' in step)) {
922
+ _context4.n = 2;
923
+ break;
924
+ }
925
+ _context4.n = 1;
926
+ return fetch("https://api.stxer.xyz/simulations/" + step.simulationId + "/request").then(/*#__PURE__*/function () {
927
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(rs) {
928
+ var body;
929
+ return _regenerator().w(function (_context3) {
930
+ while (1) switch (_context3.n) {
931
+ case 0:
932
+ _context3.n = 1;
933
+ return rs.text();
934
+ case 1:
935
+ body = _context3.v;
936
+ if (body.startsWith('{')) {
937
+ _context3.n = 2;
938
+ break;
939
+ }
940
+ throw new Error("failed to get simulation " + step.simulationId + ": " + body);
941
+ case 2:
942
+ return _context3.a(2, JSON.parse(body));
943
+ }
944
+ }, _callee3);
945
+ }));
946
+ return function (_x6) {
947
+ return _ref3.apply(this, arguments);
948
+ };
949
+ }());
950
+ case 1:
951
+ previousSimulation = _context4.v;
952
+ for (_iterator2 = _createForOfIteratorHelperLoose(previousSimulation.steps); !(_step2 = _iterator2()).done;) {
953
+ _step3 = _step2.value;
954
+ if ('tx' in _step3) {
955
+ txs.push(deserializeTransaction(_step3.tx));
956
+ } else if ('code' in _step3 && 'contract' in _step3) {
957
+ txs.push({
958
+ contract_id: _step3.contract,
959
+ code: _step3.code
960
+ });
961
+ }
962
+ }
963
+ _context4.n = 12;
964
+ break;
965
+ case 2:
966
+ if (!('sender' in step && 'function_name' in step)) {
967
+ _context4.n = 5;
968
+ break;
969
+ }
970
+ _context4.n = 3;
971
+ return nextNonce(step.sender);
972
+ case 3:
973
+ nonce = _context4.v;
974
+ _step$contract_id$spl = step.contract_id.split('.'), contractAddress = _step$contract_id$spl[0], contractName = _step$contract_id$spl[1];
975
+ _context4.n = 4;
976
+ return makeUnsignedContractCall({
977
+ contractAddress: contractAddress,
978
+ contractName: contractName,
979
+ functionName: step.function_name,
980
+ functionArgs: (_step$function_args = step.function_args) != null ? _step$function_args : [],
981
+ nonce: nonce,
982
+ network: network,
983
+ publicKey: '',
984
+ postConditionMode: PostConditionMode.Allow,
985
+ fee: step.fee
986
+ });
987
+ case 4:
988
+ tx = _context4.v;
989
+ setSender(tx, step.sender);
990
+ txs.push(tx);
991
+ _context4.n = 12;
992
+ break;
993
+ case 5:
994
+ if (!('sender' in step && 'recipient' in step)) {
995
+ _context4.n = 8;
996
+ break;
997
+ }
998
+ _context4.n = 6;
999
+ return nextNonce(step.sender);
1000
+ case 6:
1001
+ _nonce = _context4.v;
1002
+ _context4.n = 7;
1003
+ return makeUnsignedSTXTokenTransfer({
1004
+ recipient: step.recipient,
1005
+ amount: step.amount,
1006
+ nonce: _nonce,
1007
+ network: network,
1008
+ publicKey: '',
1009
+ fee: step.fee
1010
+ });
1011
+ case 7:
1012
+ _tx = _context4.v;
1013
+ setSender(_tx, step.sender);
1014
+ txs.push(_tx);
1015
+ _context4.n = 12;
1016
+ break;
1017
+ case 8:
1018
+ if (!('deployer' in step)) {
1019
+ _context4.n = 11;
1020
+ break;
1021
+ }
1022
+ _context4.n = 9;
1023
+ return nextNonce(step.deployer);
1024
+ case 9:
1025
+ _nonce2 = _context4.v;
1026
+ _context4.n = 10;
1027
+ return makeUnsignedContractDeploy({
1028
+ contractName: step.contract_name,
1029
+ codeBody: step.source_code,
1030
+ nonce: _nonce2,
1031
+ network: network,
1032
+ publicKey: '',
1033
+ postConditionMode: PostConditionMode.Allow,
1034
+ fee: step.fee,
1035
+ clarityVersion: step.clarity_version
1036
+ });
1037
+ case 10:
1038
+ _tx2 = _context4.v;
1039
+ setSender(_tx2, step.deployer);
1040
+ txs.push(_tx2);
1041
+ _context4.n = 12;
1042
+ break;
1043
+ case 11:
1044
+ if ('code' in step) {
1045
+ txs.push(step);
1046
+ } else {
1047
+ console.log("Invalid simulation step: " + step);
1048
+ }
1049
+ case 12:
1050
+ return _context4.a(2);
1051
+ }
1052
+ }, _loop);
1053
+ });
1054
+ _iterator = _createForOfIteratorHelperLoose(this.steps);
1055
+ case 2:
1056
+ if ((_step = _iterator()).done) {
1057
+ _context5.n = 4;
1058
+ break;
1059
+ }
1060
+ return _context5.d(_regeneratorValues(_loop()), 3);
1061
+ case 3:
1062
+ _context5.n = 2;
1063
+ break;
1064
+ case 4:
1065
+ _context5.n = 5;
1066
+ return runSimulation(this.apiEndpoint + "/simulations", block.block_hash, block.block_height, txs);
1067
+ case 5:
1068
+ id = _context5.v;
1069
+ console.log("Simulation will be available at: https://stxer.xyz/simulations/" + this.network + "/" + id);
1070
+ return _context5.a(2, id);
1071
+ }
1072
+ }, _callee4, this);
1073
+ }));
1074
+ function run() {
1075
+ return _run.apply(this, arguments);
1076
+ }
1077
+ return run;
1078
+ }();
1079
+ _proto.pipe = function pipe(transform) {
1080
+ return transform(this);
1081
+ };
1082
+ return SimulationBuilder;
1083
+ }();
1084
+
1230
1085
  export { SimulationBuilder, batchRead, callReadonly, readMap, readVariable, runEval, runSimulation };
1231
1086
  //# sourceMappingURL=stxer.esm.js.map