stxer 0.4.1 → 0.4.3

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,525 +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$apiEndpoint, _options$stacksNodeAP, _options$network;
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.apiEndpoint = (_options$apiEndpoint = options.apiEndpoint) != null ? _options$apiEndpoint : 'https://api.stxer.xyz';
586
- this.stacksNodeAPI = (_options$stacksNodeAP = options.stacksNodeAPI) != null ? _options$stacksNodeAP : 'https://api.hiro.so';
587
- this.network = (_options$network = options.network) != null ? _options$network : 'mainnet';
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;
588
291
  }
589
- SimulationBuilder["new"] = function _new(options) {
590
- return new SimulationBuilder(options);
591
- };
592
- var _proto = SimulationBuilder.prototype;
593
- _proto.useBlockHeight = function useBlockHeight(block) {
594
- this.block = block;
595
- return this;
596
- };
597
- _proto.withSender = function withSender(address) {
598
- this.sender = address;
599
- return this;
292
+ var _proto = BatchProcessor.prototype;
293
+ _proto.getQueueKey = function getQueueKey(tip) {
294
+ return tip != null ? tip : '_undefined';
600
295
  };
601
- _proto.inlineSimulation = function inlineSimulation(simulationId) {
602
- this.steps.push({
603
- 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
+ });
604
304
  });
605
- return this;
606
- };
607
- _proto.addSTXTransfer = function addSTXTransfer(params) {
608
- var _params$sender, _params$fee;
609
- if (params.sender == null && this.sender === '') {
610
- throw new Error('Please specify a sender with useSender or adding a sender paramenter');
611
- }
612
- this.steps.push(_extends({}, params, {
613
- sender: (_params$sender = params.sender) != null ? _params$sender : this.sender,
614
- fee: (_params$fee = params.fee) != null ? _params$fee : 0
615
- }));
616
- return this;
617
305
  };
618
- _proto.addContractCall = function addContractCall(params) {
619
- var _params$sender2, _params$fee2;
620
- if (params.sender == null && this.sender === '') {
621
- 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);
622
313
  }
623
- this.steps.push(_extends({}, params, {
624
- sender: (_params$sender2 = params.sender) != null ? _params$sender2 : this.sender,
625
- fee: (_params$fee2 = params.fee) != null ? _params$fee2 : 0
626
- }));
627
- return this;
628
- };
629
- _proto.addContractDeploy = function addContractDeploy(params) {
630
- var _params$deployer, _params$fee3, _params$clarity_versi;
631
- if (params.deployer == null && this.sender === '') {
632
- throw new Error('Please specify a deployer with useSender or adding a deployer paramenter');
633
- }
634
- this.steps.push(_extends({}, params, {
635
- deployer: (_params$deployer = params.deployer) != null ? _params$deployer : this.sender,
636
- fee: (_params$fee3 = params.fee) != null ? _params$fee3 : 0,
637
- clarity_version: (_params$clarity_versi = params.clarity_version) != null ? _params$clarity_versi : ClarityVersion.Clarity3
638
- }));
639
- return this;
640
- };
641
- _proto.addEvalCode = function addEvalCode(inside_contract_id, code) {
642
- this.steps.push({
643
- contract_id: inside_contract_id,
644
- code: code
645
- });
646
- return this;
647
- };
648
- _proto.addMapRead = function addMapRead(contract_id, map, key) {
649
- this.steps.push({
650
- contract_id: contract_id,
651
- code: "(map-get " + map + " " + key + ")"
652
- });
653
- return this;
654
- };
655
- _proto.addVarRead = function addVarRead(contract_id, variable) {
656
- this.steps.push({
657
- contract_id: contract_id,
658
- code: "(var-get " + variable + ")"
659
- });
660
- return this;
661
- };
662
- _proto.getBlockInfo = /*#__PURE__*/function () {
663
- var _getBlockInfo = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
664
- var _yield$getNodeInfo, stacks_tip_height, info;
665
- return _regeneratorRuntime().wrap(function _callee$(_context) {
666
- while (1) switch (_context.prev = _context.next) {
667
- case 0:
668
- if (!Number.isNaN(this.block)) {
669
- _context.next = 6;
670
- break;
671
- }
672
- _context.next = 3;
673
- return getNodeInfo({
674
- stacksEndpoint: this.stacksNodeAPI
675
- });
676
- case 3:
677
- _yield$getNodeInfo = _context.sent;
678
- stacks_tip_height = _yield$getNodeInfo.stacks_tip_height;
679
- this.block = stacks_tip_height;
680
- case 6:
681
- _context.next = 8;
682
- return richFetch(this.stacksNodeAPI + "/extended/v1/block/by_height/" + this.block + "?unanchored=true").then(function (r) {
683
- return r.json();
684
- });
685
- case 8:
686
- info = _context.sent;
687
- if (!(info.height !== this.block || typeof info.hash !== 'string' || !info.hash.startsWith('0x'))) {
688
- _context.next = 11;
689
- break;
690
- }
691
- throw new Error("failed to get block info for block height " + this.block);
692
- case 11:
693
- return _context.abrupt("return", {
694
- block_height: this.block,
695
- block_hash: info.hash.substring(2),
696
- index_block_hash: info.index_block_hash.substring(2)
697
- });
698
- case 12:
699
- case "end":
700
- return _context.stop();
701
- }
702
- }, _callee, this);
703
- }));
704
- function getBlockInfo() {
705
- return _getBlockInfo.apply(this, arguments);
706
- }
707
- return getBlockInfo;
708
- }();
709
- _proto.run = /*#__PURE__*/function () {
710
- var _run = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
711
- var _this = this;
712
- 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;
713
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
714
- while (1) switch (_context3.prev = _context3.next) {
715
- case 0:
716
- 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--------------------------------");
717
- _context3.next = 3;
718
- return this.getBlockInfo();
719
- case 3:
720
- block = _context3.sent;
721
- console.log("Using block height " + block.block_height + " hash 0x" + block.block_hash + " to run simulation.");
722
- txs = [];
723
- nonce_by_address = new Map();
724
- nextNonce = /*#__PURE__*/function () {
725
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sender) {
726
- var nonce, url, account;
727
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
728
- while (1) switch (_context2.prev = _context2.next) {
729
- case 0:
730
- nonce = nonce_by_address.get(sender);
731
- if (!(nonce == null)) {
732
- _context2.next = 8;
733
- break;
734
- }
735
- url = _this.stacksNodeAPI + "/v2/accounts/" + sender + "?proof=" + false + "&tip=" + block.index_block_hash;
736
- _context2.next = 5;
737
- return richFetch(url).then(function (r) {
738
- return r.json();
739
- });
740
- case 5:
741
- account = _context2.sent;
742
- nonce_by_address.set(sender, account.nonce + 1);
743
- return _context2.abrupt("return", account.nonce);
744
- case 8:
745
- nonce_by_address.set(sender, nonce + 1);
746
- return _context2.abrupt("return", nonce);
747
- case 10:
748
- case "end":
749
- return _context2.stop();
750
- }
751
- }, _callee2);
752
- }));
753
- return function nextNonce(_x5) {
754
- return _ref2.apply(this, arguments);
755
- };
756
- }();
757
- network = this.network === 'mainnet' ? STACKS_MAINNET : STACKS_TESTNET;
758
- if (this.stacksNodeAPI) {
759
- network = _extends({}, network, {
760
- client: _extends({}, network.client, {
761
- baseUrl: this.stacksNodeAPI
762
- })
763
- });
764
- }
765
- _iterator = _createForOfIteratorHelperLoose(this.steps);
766
- case 11:
767
- if ((_step = _iterator()).done) {
768
- _context3.next = 57;
769
- break;
770
- }
771
- step = _step.value;
772
- if (!('simulationId' in step)) {
773
- _context3.next = 20;
774
- break;
775
- }
776
- _context3.next = 16;
777
- return fetch("https://api.stxer.xyz/simulations/" + step.simulationId + "/request").then(function (x) {
778
- return x.json();
779
- });
780
- case 16:
781
- previousSimulation = _context3.sent;
782
- for (_iterator2 = _createForOfIteratorHelperLoose(previousSimulation.steps); !(_step2 = _iterator2()).done;) {
783
- _step3 = _step2.value;
784
- if ('tx' in _step3) {
785
- txs.push(deserializeTransaction(_step3.tx));
786
- } else if ('code' in _step3 && 'contract' in _step3) {
787
- txs.push({
788
- contract_id: _step3.contract,
789
- code: _step3.code
790
- });
791
- }
792
- }
793
- _context3.next = 55;
794
- break;
795
- case 20:
796
- if (!('sender' in step && 'function_name' in step)) {
797
- _context3.next = 32;
798
- break;
799
- }
800
- _context3.next = 23;
801
- return nextNonce(step.sender);
802
- case 23:
803
- nonce = _context3.sent;
804
- _step$contract_id$spl = step.contract_id.split('.'), contractAddress = _step$contract_id$spl[0], contractName = _step$contract_id$spl[1];
805
- _context3.next = 27;
806
- return makeUnsignedContractCall({
807
- contractAddress: contractAddress,
808
- contractName: contractName,
809
- functionName: step.function_name,
810
- functionArgs: (_step$function_args = step.function_args) != null ? _step$function_args : [],
811
- nonce: nonce,
812
- network: network,
813
- publicKey: '',
814
- postConditionMode: PostConditionMode.Allow,
815
- fee: step.fee
816
- });
817
- case 27:
818
- tx = _context3.sent;
819
- tx.auth.spendingCondition.signer = c32addressDecode(step.sender)[1];
820
- txs.push(tx);
821
- _context3.next = 55;
822
- break;
823
- case 32:
824
- if (!('sender' in step && 'recipient' in step)) {
825
- _context3.next = 43;
826
- break;
827
- }
828
- _context3.next = 35;
829
- return nextNonce(step.sender);
830
- case 35:
831
- _nonce = _context3.sent;
832
- _context3.next = 38;
833
- return makeUnsignedSTXTokenTransfer({
834
- recipient: step.recipient,
835
- amount: step.amount,
836
- nonce: _nonce,
837
- network: network,
838
- publicKey: '',
839
- fee: step.fee
840
- });
841
- case 38:
842
- _tx = _context3.sent;
843
- _tx.auth.spendingCondition.signer = c32addressDecode(step.sender)[1];
844
- txs.push(_tx);
845
- _context3.next = 55;
846
- break;
847
- case 43:
848
- if (!('deployer' in step)) {
849
- _context3.next = 54;
850
- break;
851
- }
852
- _context3.next = 46;
853
- return nextNonce(step.deployer);
854
- case 46:
855
- _nonce2 = _context3.sent;
856
- _context3.next = 49;
857
- return makeUnsignedContractDeploy({
858
- contractName: step.contract_name,
859
- codeBody: step.source_code,
860
- nonce: _nonce2,
861
- network: network,
862
- publicKey: '',
863
- postConditionMode: PostConditionMode.Allow,
864
- fee: step.fee
865
- });
866
- case 49:
867
- _tx2 = _context3.sent;
868
- _tx2.auth.spendingCondition.signer = c32addressDecode(step.deployer)[1];
869
- txs.push(_tx2);
870
- _context3.next = 55;
871
- break;
872
- case 54:
873
- if ('code' in step) {
874
- txs.push(step);
875
- } else {
876
- // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>
877
- console.log("Invalid simulation step:", step);
878
- }
879
- case 55:
880
- _context3.next = 11;
881
- break;
882
- case 57:
883
- _context3.next = 59;
884
- return runSimulation(this.apiEndpoint + "/simulations", block.block_hash, block.block_height, txs);
885
- case 59:
886
- id = _context3.sent;
887
- console.log("Simulation will be available at: https://stxer.xyz/simulations/" + this.network + "/" + id);
888
- return _context3.abrupt("return", id);
889
- case 62:
890
- case "end":
891
- return _context3.stop();
892
- }
893
- }, _callee3, this);
894
- }));
895
- function run() {
896
- return _run.apply(this, arguments);
897
- }
898
- return run;
899
- }();
900
- _proto.pipe = function pipe(transform) {
901
- return transform(this);
902
- };
903
- return SimulationBuilder;
904
- }();
905
-
906
- var BatchProcessor = /*#__PURE__*/function () {
907
- function BatchProcessor(options) {
908
- var _options$stxerAPIEndp;
909
- this.queues = new Map();
910
- this.timeoutIds = new Map();
911
- this.stxerAPIEndpoint = void 0;
912
- this.batchDelayMs = void 0;
913
- this.stxerAPIEndpoint = (_options$stxerAPIEndp = options.stxerAPIEndpoint) != null ? _options$stxerAPIEndp : 'https://api.stxer.xyz';
914
- this.batchDelayMs = options.batchDelayMs;
915
- }
916
- var _proto = BatchProcessor.prototype;
917
- _proto.getQueueKey = function getQueueKey(tip) {
918
- return tip != null ? tip : '_undefined';
919
- };
920
- _proto.read = function read(request) {
921
- var _this = this;
922
- return new Promise(function (resolve, reject) {
923
- _this.enqueue({
924
- request: request,
925
- resolve: resolve,
926
- reject: reject
927
- });
928
- });
929
- };
930
- _proto.enqueue = function enqueue(request) {
931
- var _this$queues$get,
932
- _this2 = this;
933
- var queueKey = this.getQueueKey(request.tip);
934
- var queue = (_this$queues$get = this.queues.get(queueKey)) != null ? _this$queues$get : [];
935
- if (!this.queues.has(queueKey)) {
936
- this.queues.set(queueKey, queue);
937
- }
938
- queue.push(request);
939
- if (!this.timeoutIds.has(queueKey)) {
940
- var timeoutId = setTimeout(function () {
941
- return _this2.processBatch(queueKey);
942
- }, this.batchDelayMs);
943
- 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);
944
320
  }
945
321
  };
946
322
  _proto.processBatch = /*#__PURE__*/function () {
947
- var _processBatch = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(queueKey) {
323
+ var _processBatch = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(queueKey) {
948
324
  var _this$queues$get2;
949
- 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;
950
- return _regeneratorRuntime().wrap(function _callee$(_context) {
951
- 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) {
952
328
  case 0:
953
329
  currentQueue = (_this$queues$get2 = this.queues.get(queueKey)) != null ? _this$queues$get2 : [];
954
330
  this.queues["delete"](queueKey);
@@ -958,12 +334,12 @@ var BatchProcessor = /*#__PURE__*/function () {
958
334
  this.timeoutIds["delete"](queueKey);
959
335
  }
960
336
  if (!(currentQueue.length === 0)) {
961
- _context.next = 6;
337
+ _context.n = 1;
962
338
  break;
963
339
  }
964
- return _context.abrupt("return");
965
- case 6:
966
- _context.prev = 6;
340
+ return _context.a(2);
341
+ case 1:
342
+ _context.p = 1;
967
343
  readonlyRequests = currentQueue.filter(function (q) {
968
344
  return q.request.mode === 'readonly';
969
345
  });
@@ -1000,12 +376,12 @@ var BatchProcessor = /*#__PURE__*/function () {
1000
376
  }),
1001
377
  index_block_hash: tip
1002
378
  };
1003
- _context.next = 14;
379
+ _context.n = 2;
1004
380
  return batchRead(batchRequest, {
1005
381
  stxerApi: this.stxerAPIEndpoint
1006
382
  });
1007
- case 14:
1008
- results = _context.sent;
383
+ case 2:
384
+ results = _context.v;
1009
385
  // Handle readonly results
1010
386
  for (_iterator = _createForOfIteratorHelperLoose(results.readonly.entries()); !(_step = _iterator()).done;) {
1011
387
  _step$value = _step.value, index = _step$value[0], result = _step$value[1];
@@ -1033,20 +409,19 @@ var BatchProcessor = /*#__PURE__*/function () {
1033
409
  mapRequests[_index2].resolve(_result2);
1034
410
  }
1035
411
  }
1036
- _context.next = 23;
412
+ _context.n = 4;
1037
413
  break;
1038
- case 20:
1039
- _context.prev = 20;
1040
- _context.t0 = _context["catch"](6);
414
+ case 3:
415
+ _context.p = 3;
416
+ _t = _context.v;
1041
417
  for (_iterator4 = _createForOfIteratorHelperLoose(currentQueue); !(_step4 = _iterator4()).done;) {
1042
418
  item = _step4.value;
1043
- item.reject(_context.t0);
419
+ item.reject(_t);
1044
420
  }
1045
- case 23:
1046
- case "end":
1047
- return _context.stop();
421
+ case 4:
422
+ return _context.a(2);
1048
423
  }
1049
- }, _callee, this, [[6, 20]]);
424
+ }, _callee, this, [[1, 3]]);
1050
425
  }));
1051
426
  function processBatch(_x) {
1052
427
  return _processBatch.apply(this, arguments);
@@ -1064,11 +439,11 @@ function callReadonly(_x) {
1064
439
  return _callReadonly.apply(this, arguments);
1065
440
  }
1066
441
  function _callReadonly() {
1067
- _callReadonly = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
442
+ _callReadonly = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
1068
443
  var _params$batchProcesso;
1069
444
  var processor, _params$contract$spli, deployer, contractName, fn, functionDef, argsKV, args, _iterator, _step, argDef;
1070
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1071
- while (1) switch (_context.prev = _context.next) {
445
+ return _regenerator().w(function (_context) {
446
+ while (1) switch (_context.n) {
1072
447
  case 0:
1073
448
  processor = (_params$batchProcesso = params.batchProcessor) != null ? _params$batchProcesso : defaultProcessor;
1074
449
  _params$contract$spli = params.contract.split('.', 2), deployer = _params$contract$spli[0], contractName = _params$contract$spli[1];
@@ -1077,18 +452,18 @@ function _callReadonly() {
1077
452
  return def.name === params.functionName;
1078
453
  });
1079
454
  if (functionDef) {
1080
- _context.next = 6;
455
+ _context.n = 1;
1081
456
  break;
1082
457
  }
1083
458
  throw new Error("failed to find function definition for " + params.functionName);
1084
- case 6:
459
+ case 1:
1085
460
  argsKV = params.args;
1086
461
  args = [];
1087
462
  for (_iterator = _createForOfIteratorHelperLoose(functionDef.args); !(_step = _iterator()).done;) {
1088
463
  argDef = _step.value;
1089
464
  args.push(encodeAbi(argDef.type, argsKV[argDef.name]));
1090
465
  }
1091
- return _context.abrupt("return", new Promise(function (_resolve, reject) {
466
+ return _context.a(2, new Promise(function (_resolve, reject) {
1092
467
  processor.enqueue({
1093
468
  request: {
1094
469
  mode: 'readonly',
@@ -1109,9 +484,6 @@ function _callReadonly() {
1109
484
  reject: reject
1110
485
  });
1111
486
  }));
1112
- case 10:
1113
- case "end":
1114
- return _context.stop();
1115
487
  }
1116
488
  }, _callee);
1117
489
  }));
@@ -1121,11 +493,11 @@ function readMap(_x2) {
1121
493
  return _readMap.apply(this, arguments);
1122
494
  }
1123
495
  function _readMap() {
1124
- _readMap = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
496
+ _readMap = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(params) {
1125
497
  var _params$batchProcesso2;
1126
498
  var processor, _params$contract$spli2, deployer, contractName, mapDef, key;
1127
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1128
- while (1) switch (_context2.prev = _context2.next) {
499
+ return _regenerator().w(function (_context2) {
500
+ while (1) switch (_context2.n) {
1129
501
  case 0:
1130
502
  processor = (_params$batchProcesso2 = params.batchProcessor) != null ? _params$batchProcesso2 : defaultProcessor;
1131
503
  _params$contract$spli2 = params.contract.split('.', 2), deployer = _params$contract$spli2[0], contractName = _params$contract$spli2[1];
@@ -1133,13 +505,13 @@ function _readMap() {
1133
505
  return m.name === params.mapName;
1134
506
  });
1135
507
  if (mapDef) {
1136
- _context2.next = 5;
508
+ _context2.n = 1;
1137
509
  break;
1138
510
  }
1139
511
  throw new Error("failed to find map definition for " + params.mapName);
1140
- case 5:
512
+ case 1:
1141
513
  key = encodeAbi(mapDef.key, params.key);
1142
- return _context2.abrupt("return", new Promise(function (_resolve2, reject) {
514
+ return _context2.a(2, new Promise(function (_resolve2, reject) {
1143
515
  processor.enqueue({
1144
516
  request: {
1145
517
  mode: 'mapEntry',
@@ -1168,9 +540,6 @@ function _readMap() {
1168
540
  reject: reject
1169
541
  });
1170
542
  }));
1171
- case 7:
1172
- case "end":
1173
- return _context2.stop();
1174
543
  }
1175
544
  }, _callee2);
1176
545
  }));
@@ -1180,11 +549,11 @@ function readVariable(_x3) {
1180
549
  return _readVariable.apply(this, arguments);
1181
550
  }
1182
551
  function _readVariable() {
1183
- _readVariable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
552
+ _readVariable = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(params) {
1184
553
  var _params$batchProcesso3;
1185
554
  var processor, _params$contract$spli3, deployer, contractName, varDef;
1186
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1187
- while (1) switch (_context3.prev = _context3.next) {
555
+ return _regenerator().w(function (_context3) {
556
+ while (1) switch (_context3.n) {
1188
557
  case 0:
1189
558
  processor = (_params$batchProcesso3 = params.batchProcessor) != null ? _params$batchProcesso3 : defaultProcessor;
1190
559
  _params$contract$spli3 = params.contract.split('.', 2), deployer = _params$contract$spli3[0], contractName = _params$contract$spli3[1];
@@ -1192,12 +561,12 @@ function _readVariable() {
1192
561
  return def.name === params.variableName;
1193
562
  });
1194
563
  if (varDef) {
1195
- _context3.next = 5;
564
+ _context3.n = 1;
1196
565
  break;
1197
566
  }
1198
567
  throw new Error("failed to find variable definition for " + params.variableName);
1199
- case 5:
1200
- return _context3.abrupt("return", new Promise(function (_resolve3, reject) {
568
+ case 1:
569
+ return _context3.a(2, new Promise(function (_resolve3, reject) {
1201
570
  processor.enqueue({
1202
571
  request: {
1203
572
  mode: 'variable',
@@ -1217,14 +586,500 @@ function _readVariable() {
1217
586
  reject: reject
1218
587
  });
1219
588
  }));
1220
- case 6:
1221
- case "end":
1222
- return _context3.stop();
1223
589
  }
1224
590
  }, _callee3);
1225
591
  }));
1226
592
  return _readVariable.apply(this, arguments);
1227
593
  }
1228
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.Clarity3
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
+ });
1036
+ case 10:
1037
+ _tx2 = _context4.v;
1038
+ setSender(_tx2, step.deployer);
1039
+ txs.push(_tx2);
1040
+ _context4.n = 12;
1041
+ break;
1042
+ case 11:
1043
+ if ('code' in step) {
1044
+ txs.push(step);
1045
+ } else {
1046
+ console.log("Invalid simulation step: " + step);
1047
+ }
1048
+ case 12:
1049
+ return _context4.a(2);
1050
+ }
1051
+ }, _loop);
1052
+ });
1053
+ _iterator = _createForOfIteratorHelperLoose(this.steps);
1054
+ case 2:
1055
+ if ((_step = _iterator()).done) {
1056
+ _context5.n = 4;
1057
+ break;
1058
+ }
1059
+ return _context5.d(_regeneratorValues(_loop()), 3);
1060
+ case 3:
1061
+ _context5.n = 2;
1062
+ break;
1063
+ case 4:
1064
+ _context5.n = 5;
1065
+ return runSimulation(this.apiEndpoint + "/simulations", block.block_hash, block.block_height, txs);
1066
+ case 5:
1067
+ id = _context5.v;
1068
+ console.log("Simulation will be available at: https://stxer.xyz/simulations/" + this.network + "/" + id);
1069
+ return _context5.a(2, id);
1070
+ }
1071
+ }, _callee4, this);
1072
+ }));
1073
+ function run() {
1074
+ return _run.apply(this, arguments);
1075
+ }
1076
+ return run;
1077
+ }();
1078
+ _proto.pipe = function pipe(transform) {
1079
+ return transform(this);
1080
+ };
1081
+ return SimulationBuilder;
1082
+ }();
1083
+
1229
1084
  export { SimulationBuilder, batchRead, callReadonly, readMap, readVariable, runEval, runSimulation };
1230
1085
  //# sourceMappingURL=stxer.esm.js.map