@clarigen/core 0.3.1 → 1.0.0-next.10

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.
@@ -1,1097 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var transactions = require('@stacks/transactions');
6
-
7
- var TESTNET_BURN_ADDRESS = 'ST000000000000000000002AMW42H';
8
- var MAINNET_BURN_ADDRESS = 'SP000000000000000000002Q6VF78';
9
- var toCamelCase = function toCamelCase(input, titleCase) {
10
- var inputStr = typeof input === 'string' ? input : String(input);
11
-
12
- var _inputStr$replace$rep = inputStr.replace('!', '').replace('?', '').split('-'),
13
- first = _inputStr$replace$rep[0],
14
- parts = _inputStr$replace$rep.slice(1);
15
-
16
- var result = titleCase ? "" + first[0].toUpperCase() + first.slice(1) : first;
17
- parts.forEach(function (part) {
18
- var capitalized = part[0].toUpperCase() + part.slice(1);
19
- result += capitalized;
20
- });
21
- return result;
22
- };
23
- var getContractNameFromPath = function getContractNameFromPath(path) {
24
- var contractPaths = path.split('/');
25
- var filename = contractPaths[contractPaths.length - 1];
26
-
27
- var _filename$split = filename.split('.'),
28
- contractName = _filename$split[0];
29
-
30
- return contractName;
31
- };
32
- var getContractIdentifier = function getContractIdentifier(contract) {
33
- var contractName = getContractNameFromPath(contract.contractFile);
34
- return contract.address + "." + contractName;
35
- };
36
- var getContractPrincipalCV = function getContractPrincipalCV(contract) {
37
- var contractName = getContractNameFromPath(contract.contractFile);
38
- return transactions.contractPrincipalCV(contract.address, contractName);
39
- };
40
- function bootContractIdentifier(name, mainnet) {
41
- var addr = mainnet ? MAINNET_BURN_ADDRESS : TESTNET_BURN_ADDRESS;
42
- return addr + "." + name;
43
- }
44
-
45
- (function (CoreNodeEventType) {
46
- CoreNodeEventType["ContractEvent"] = "contract_event";
47
- CoreNodeEventType["StxTransferEvent"] = "stx_transfer_event";
48
- CoreNodeEventType["StxMintEvent"] = "stx_mint_event";
49
- CoreNodeEventType["StxBurnEvent"] = "stx_burn_event";
50
- CoreNodeEventType["StxLockEvent"] = "stx_lock_event";
51
- CoreNodeEventType["NftTransferEvent"] = "nft_transfer_event";
52
- CoreNodeEventType["NftMintEvent"] = "nft_mint_event";
53
- CoreNodeEventType["NftBurnEvent"] = "nft_burn_event";
54
- CoreNodeEventType["FtTransferEvent"] = "ft_transfer_event";
55
- CoreNodeEventType["FtMintEvent"] = "ft_mint_event";
56
- CoreNodeEventType["FtBurnEvent"] = "ft_burn_event";
57
- })(exports.CoreNodeEventType || (exports.CoreNodeEventType = {}));
58
-
59
- function principalToString(principal) {
60
- if (principal.type === transactions.ClarityType.PrincipalStandard) {
61
- return transactions.addressToString(principal.address);
62
- } else if (principal.type === transactions.ClarityType.PrincipalContract) {
63
- var address = transactions.addressToString(principal.address);
64
- return address + "." + principal.contractName.content;
65
- } else {
66
- throw new Error("Unexpected principal data: " + JSON.stringify(principal));
67
- }
68
- }
69
-
70
- function cvToValue(val) {
71
- switch (val.type) {
72
- case transactions.ClarityType.BoolTrue:
73
- return true;
74
-
75
- case transactions.ClarityType.BoolFalse:
76
- return false;
77
-
78
- case transactions.ClarityType.Int:
79
- return val.value;
80
-
81
- case transactions.ClarityType.UInt:
82
- return val.value;
83
-
84
- case transactions.ClarityType.Buffer:
85
- return val.buffer;
86
-
87
- case transactions.ClarityType.OptionalNone:
88
- return null;
89
-
90
- case transactions.ClarityType.OptionalSome:
91
- return cvToValue(val.value);
92
-
93
- case transactions.ClarityType.ResponseErr:
94
- return cvToValue(val.value);
95
-
96
- case transactions.ClarityType.ResponseOk:
97
- return cvToValue(val.value);
98
-
99
- case transactions.ClarityType.PrincipalStandard:
100
- case transactions.ClarityType.PrincipalContract:
101
- return principalToString(val);
102
-
103
- case transactions.ClarityType.List:
104
- return val.list.map(function (v) {
105
- return cvToValue(v);
106
- });
107
-
108
- case transactions.ClarityType.Tuple:
109
- var result = {};
110
- Object.keys(val.data).forEach(function (key) {
111
- result[key] = cvToValue(val.data[key]);
112
- });
113
- return result;
114
-
115
- case transactions.ClarityType.StringASCII:
116
- return val.data;
117
-
118
- case transactions.ClarityType.StringUTF8:
119
- return val.data;
120
- }
121
- }
122
-
123
- function inputToBigInt(input) {
124
- var isBigInt = typeof input === 'bigint';
125
- var isNumber = typeof input === 'number';
126
- var isString = typeof input === 'string';
127
- var isOk = isBigInt || isNumber || isString;
128
-
129
- if (!isOk) {
130
- throw new Error('Invalid input type for integer');
131
- }
132
-
133
- return BigInt(input);
134
- }
135
-
136
- function parseToCV(input, type) {
137
- if (transactions.isClarityAbiTuple(type)) {
138
- if (typeof input !== 'object') {
139
- throw new Error('Invalid tuple input');
140
- }
141
-
142
- var tuple = {};
143
- type.tuple.forEach(function (key) {
144
- var val = input[key.name];
145
- tuple[key.name] = parseToCV(val, key.type);
146
- });
147
- return transactions.tupleCV(tuple);
148
- } else if (transactions.isClarityAbiList(type)) {
149
- var inputs = input;
150
- var values = inputs.map(function (input) {
151
- return parseToCV(input, type.list.type);
152
- });
153
- return transactions.listCV(values);
154
- } else if (transactions.isClarityAbiOptional(type)) {
155
- if (!input) return transactions.noneCV();
156
- return transactions.someCV(parseToCV(input, type.optional));
157
- } else if (transactions.isClarityAbiStringAscii(type)) {
158
- if (typeof input !== 'string') {
159
- throw new Error('Invalid string-ascii input');
160
- }
161
-
162
- return transactions.stringAsciiCV(input);
163
- } else if (transactions.isClarityAbiStringUtf8(type)) {
164
- if (typeof input !== 'string') {
165
- throw new Error('Invalid string-ascii input');
166
- }
167
-
168
- return transactions.stringUtf8CV(input);
169
- } else if (type === 'bool') {
170
- var inputString = typeof input === 'boolean' ? input.toString() : input;
171
- return transactions.parseToCV(inputString, type);
172
- } else if (type === 'uint128') {
173
- var bigi = inputToBigInt(input);
174
- return transactions.uintCV(bigi.toString());
175
- } else if (type === 'int128') {
176
- var _bigi = inputToBigInt(input);
177
-
178
- return transactions.intCV(_bigi.toString());
179
- }
180
-
181
- return transactions.parseToCV(input, type);
182
- }
183
- function cvToString(val, encoding) {
184
- if (encoding === void 0) {
185
- encoding = 'hex';
186
- }
187
-
188
- switch (val.type) {
189
- case transactions.ClarityType.BoolTrue:
190
- return 'true';
191
-
192
- case transactions.ClarityType.BoolFalse:
193
- return 'false';
194
-
195
- case transactions.ClarityType.Int:
196
- return val.value.toString();
197
-
198
- case transactions.ClarityType.UInt:
199
- return "u" + val.value.toString();
200
-
201
- case transactions.ClarityType.Buffer:
202
- if (encoding === 'tryAscii') {
203
- var str = val.buffer.toString('ascii');
204
-
205
- if (/[ -~]/.test(str)) {
206
- return JSON.stringify(str);
207
- }
208
- }
209
-
210
- return "0x" + val.buffer.toString('hex');
211
-
212
- case transactions.ClarityType.OptionalNone:
213
- return 'none';
214
-
215
- case transactions.ClarityType.OptionalSome:
216
- return "(some " + cvToString(val.value, encoding) + ")";
217
-
218
- case transactions.ClarityType.ResponseErr:
219
- return "(err " + cvToString(val.value, encoding) + ")";
220
-
221
- case transactions.ClarityType.ResponseOk:
222
- return "(ok " + cvToString(val.value, encoding) + ")";
223
-
224
- case transactions.ClarityType.PrincipalStandard:
225
- case transactions.ClarityType.PrincipalContract:
226
- return "'" + principalToString(val);
227
-
228
- case transactions.ClarityType.List:
229
- return "(list " + val.list.map(function (v) {
230
- return cvToString(v, encoding);
231
- }).join(' ') + ")";
232
-
233
- case transactions.ClarityType.Tuple:
234
- return "(tuple " + Object.keys(val.data).map(function (key) {
235
- return "(" + key + " " + cvToString(val.data[key], encoding) + ")";
236
- }).join(' ') + ")";
237
-
238
- case transactions.ClarityType.StringASCII:
239
- return "\"" + val.data + "\"";
240
-
241
- case transactions.ClarityType.StringUTF8:
242
- return "u\"" + val.data + "\"";
243
- }
244
- }
245
-
246
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
247
- try {
248
- var info = gen[key](arg);
249
- var value = info.value;
250
- } catch (error) {
251
- reject(error);
252
- return;
253
- }
254
-
255
- if (info.done) {
256
- resolve(value);
257
- } else {
258
- Promise.resolve(value).then(_next, _throw);
259
- }
260
- }
261
-
262
- function _asyncToGenerator(fn) {
263
- return function () {
264
- var self = this,
265
- args = arguments;
266
- return new Promise(function (resolve, reject) {
267
- var gen = fn.apply(self, args);
268
-
269
- function _next(value) {
270
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
271
- }
272
-
273
- function _throw(err) {
274
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
275
- }
276
-
277
- _next(undefined);
278
- });
279
- };
280
- }
281
-
282
- function createCommonjsModule(fn, module) {
283
- return module = { exports: {} }, fn(module, module.exports), module.exports;
284
- }
285
-
286
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
287
- /**
288
- * Copyright (c) 2014-present, Facebook, Inc.
289
- *
290
- * This source code is licensed under the MIT license found in the
291
- * LICENSE file in the root directory of this source tree.
292
- */
293
- var runtime = function (exports) {
294
-
295
- var Op = Object.prototype;
296
- var hasOwn = Op.hasOwnProperty;
297
- var undefined$1; // More compressible than void 0.
298
-
299
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
300
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
301
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
302
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
303
-
304
- function define(obj, key, value) {
305
- Object.defineProperty(obj, key, {
306
- value: value,
307
- enumerable: true,
308
- configurable: true,
309
- writable: true
310
- });
311
- return obj[key];
312
- }
313
-
314
- try {
315
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
316
- define({}, "");
317
- } catch (err) {
318
- define = function define(obj, key, value) {
319
- return obj[key] = value;
320
- };
321
- }
322
-
323
- function wrap(innerFn, outerFn, self, tryLocsList) {
324
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
325
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
326
- var generator = Object.create(protoGenerator.prototype);
327
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
328
- // .throw, and .return methods.
329
-
330
- generator._invoke = makeInvokeMethod(innerFn, self, context);
331
- return generator;
332
- }
333
-
334
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
335
- // record like context.tryEntries[i].completion. This interface could
336
- // have been (and was previously) designed to take a closure to be
337
- // invoked without arguments, but in all the cases we care about we
338
- // already have an existing method we want to call, so there's no need
339
- // to create a new function object. We can even get away with assuming
340
- // the method takes exactly one argument, since that happens to be true
341
- // in every case, so we don't have to touch the arguments object. The
342
- // only additional allocation required is the completion record, which
343
- // has a stable shape and so hopefully should be cheap to allocate.
344
-
345
- function tryCatch(fn, obj, arg) {
346
- try {
347
- return {
348
- type: "normal",
349
- arg: fn.call(obj, arg)
350
- };
351
- } catch (err) {
352
- return {
353
- type: "throw",
354
- arg: err
355
- };
356
- }
357
- }
358
-
359
- var GenStateSuspendedStart = "suspendedStart";
360
- var GenStateSuspendedYield = "suspendedYield";
361
- var GenStateExecuting = "executing";
362
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
363
- // breaking out of the dispatch switch statement.
364
-
365
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
366
- // .constructor.prototype properties for functions that return Generator
367
- // objects. For full spec compliance, you may wish to configure your
368
- // minifier not to mangle the names of these two functions.
369
-
370
- function Generator() {}
371
-
372
- function GeneratorFunction() {}
373
-
374
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
375
- // don't natively support it.
376
-
377
-
378
- var IteratorPrototype = {};
379
-
380
- IteratorPrototype[iteratorSymbol] = function () {
381
- return this;
382
- };
383
-
384
- var getProto = Object.getPrototypeOf;
385
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
386
-
387
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
388
- // This environment has a native %IteratorPrototype%; use it instead
389
- // of the polyfill.
390
- IteratorPrototype = NativeIteratorPrototype;
391
- }
392
-
393
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
394
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
395
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
396
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
397
- // Iterator interface in terms of a single ._invoke method.
398
-
399
- function defineIteratorMethods(prototype) {
400
- ["next", "throw", "return"].forEach(function (method) {
401
- define(prototype, method, function (arg) {
402
- return this._invoke(method, arg);
403
- });
404
- });
405
- }
406
-
407
- exports.isGeneratorFunction = function (genFun) {
408
- var ctor = typeof genFun === "function" && genFun.constructor;
409
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
410
- // do is to check its .name property.
411
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
412
- };
413
-
414
- exports.mark = function (genFun) {
415
- if (Object.setPrototypeOf) {
416
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
417
- } else {
418
- genFun.__proto__ = GeneratorFunctionPrototype;
419
- define(genFun, toStringTagSymbol, "GeneratorFunction");
420
- }
421
-
422
- genFun.prototype = Object.create(Gp);
423
- return genFun;
424
- }; // Within the body of any async function, `await x` is transformed to
425
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
426
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
427
- // meant to be awaited.
428
-
429
-
430
- exports.awrap = function (arg) {
431
- return {
432
- __await: arg
433
- };
434
- };
435
-
436
- function AsyncIterator(generator, PromiseImpl) {
437
- function invoke(method, arg, resolve, reject) {
438
- var record = tryCatch(generator[method], generator, arg);
439
-
440
- if (record.type === "throw") {
441
- reject(record.arg);
442
- } else {
443
- var result = record.arg;
444
- var value = result.value;
445
-
446
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
447
- return PromiseImpl.resolve(value.__await).then(function (value) {
448
- invoke("next", value, resolve, reject);
449
- }, function (err) {
450
- invoke("throw", err, resolve, reject);
451
- });
452
- }
453
-
454
- return PromiseImpl.resolve(value).then(function (unwrapped) {
455
- // When a yielded Promise is resolved, its final value becomes
456
- // the .value of the Promise<{value,done}> result for the
457
- // current iteration.
458
- result.value = unwrapped;
459
- resolve(result);
460
- }, function (error) {
461
- // If a rejected Promise was yielded, throw the rejection back
462
- // into the async generator function so it can be handled there.
463
- return invoke("throw", error, resolve, reject);
464
- });
465
- }
466
- }
467
-
468
- var previousPromise;
469
-
470
- function enqueue(method, arg) {
471
- function callInvokeWithMethodAndArg() {
472
- return new PromiseImpl(function (resolve, reject) {
473
- invoke(method, arg, resolve, reject);
474
- });
475
- }
476
-
477
- return previousPromise = // If enqueue has been called before, then we want to wait until
478
- // all previous Promises have been resolved before calling invoke,
479
- // so that results are always delivered in the correct order. If
480
- // enqueue has not been called before, then it is important to
481
- // call invoke immediately, without waiting on a callback to fire,
482
- // so that the async generator function has the opportunity to do
483
- // any necessary setup in a predictable way. This predictability
484
- // is why the Promise constructor synchronously invokes its
485
- // executor callback, and why async functions synchronously
486
- // execute code before the first await. Since we implement simple
487
- // async functions in terms of async generators, it is especially
488
- // important to get this right, even though it requires care.
489
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
490
- // invocations of the iterator.
491
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
492
- } // Define the unified helper method that is used to implement .next,
493
- // .throw, and .return (see defineIteratorMethods).
494
-
495
-
496
- this._invoke = enqueue;
497
- }
498
-
499
- defineIteratorMethods(AsyncIterator.prototype);
500
-
501
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
502
- return this;
503
- };
504
-
505
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
506
- // AsyncIterator objects; they just return a Promise for the value of
507
- // the final result produced by the iterator.
508
-
509
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
510
- if (PromiseImpl === void 0) PromiseImpl = Promise;
511
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
512
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
513
- : iter.next().then(function (result) {
514
- return result.done ? result.value : iter.next();
515
- });
516
- };
517
-
518
- function makeInvokeMethod(innerFn, self, context) {
519
- var state = GenStateSuspendedStart;
520
- return function invoke(method, arg) {
521
- if (state === GenStateExecuting) {
522
- throw new Error("Generator is already running");
523
- }
524
-
525
- if (state === GenStateCompleted) {
526
- if (method === "throw") {
527
- throw arg;
528
- } // Be forgiving, per 25.3.3.3.3 of the spec:
529
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
530
-
531
-
532
- return doneResult();
533
- }
534
-
535
- context.method = method;
536
- context.arg = arg;
537
-
538
- while (true) {
539
- var delegate = context.delegate;
540
-
541
- if (delegate) {
542
- var delegateResult = maybeInvokeDelegate(delegate, context);
543
-
544
- if (delegateResult) {
545
- if (delegateResult === ContinueSentinel) continue;
546
- return delegateResult;
547
- }
548
- }
549
-
550
- if (context.method === "next") {
551
- // Setting context._sent for legacy support of Babel's
552
- // function.sent implementation.
553
- context.sent = context._sent = context.arg;
554
- } else if (context.method === "throw") {
555
- if (state === GenStateSuspendedStart) {
556
- state = GenStateCompleted;
557
- throw context.arg;
558
- }
559
-
560
- context.dispatchException(context.arg);
561
- } else if (context.method === "return") {
562
- context.abrupt("return", context.arg);
563
- }
564
-
565
- state = GenStateExecuting;
566
- var record = tryCatch(innerFn, self, context);
567
-
568
- if (record.type === "normal") {
569
- // If an exception is thrown from innerFn, we leave state ===
570
- // GenStateExecuting and loop back for another invocation.
571
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
572
-
573
- if (record.arg === ContinueSentinel) {
574
- continue;
575
- }
576
-
577
- return {
578
- value: record.arg,
579
- done: context.done
580
- };
581
- } else if (record.type === "throw") {
582
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
583
- // context.dispatchException(context.arg) call above.
584
-
585
- context.method = "throw";
586
- context.arg = record.arg;
587
- }
588
- }
589
- };
590
- } // Call delegate.iterator[context.method](context.arg) and handle the
591
- // result, either by returning a { value, done } result from the
592
- // delegate iterator, or by modifying context.method and context.arg,
593
- // setting context.delegate to null, and returning the ContinueSentinel.
594
-
595
-
596
- function maybeInvokeDelegate(delegate, context) {
597
- var method = delegate.iterator[context.method];
598
-
599
- if (method === undefined$1) {
600
- // A .throw or .return when the delegate iterator has no .throw
601
- // method always terminates the yield* loop.
602
- context.delegate = null;
603
-
604
- if (context.method === "throw") {
605
- // Note: ["return"] must be used for ES3 parsing compatibility.
606
- if (delegate.iterator["return"]) {
607
- // If the delegate iterator has a return method, give it a
608
- // chance to clean up.
609
- context.method = "return";
610
- context.arg = undefined$1;
611
- maybeInvokeDelegate(delegate, context);
612
-
613
- if (context.method === "throw") {
614
- // If maybeInvokeDelegate(context) changed context.method from
615
- // "return" to "throw", let that override the TypeError below.
616
- return ContinueSentinel;
617
- }
618
- }
619
-
620
- context.method = "throw";
621
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
622
- }
623
-
624
- return ContinueSentinel;
625
- }
626
-
627
- var record = tryCatch(method, delegate.iterator, context.arg);
628
-
629
- if (record.type === "throw") {
630
- context.method = "throw";
631
- context.arg = record.arg;
632
- context.delegate = null;
633
- return ContinueSentinel;
634
- }
635
-
636
- var info = record.arg;
637
-
638
- if (!info) {
639
- context.method = "throw";
640
- context.arg = new TypeError("iterator result is not an object");
641
- context.delegate = null;
642
- return ContinueSentinel;
643
- }
644
-
645
- if (info.done) {
646
- // Assign the result of the finished delegate to the temporary
647
- // variable specified by delegate.resultName (see delegateYield).
648
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
649
-
650
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
651
- // exception, let the outer generator proceed normally. If
652
- // context.method was "next", forget context.arg since it has been
653
- // "consumed" by the delegate iterator. If context.method was
654
- // "return", allow the original .return call to continue in the
655
- // outer generator.
656
-
657
- if (context.method !== "return") {
658
- context.method = "next";
659
- context.arg = undefined$1;
660
- }
661
- } else {
662
- // Re-yield the result returned by the delegate method.
663
- return info;
664
- } // The delegate iterator is finished, so forget it and continue with
665
- // the outer generator.
666
-
667
-
668
- context.delegate = null;
669
- return ContinueSentinel;
670
- } // Define Generator.prototype.{next,throw,return} in terms of the
671
- // unified ._invoke helper method.
672
-
673
-
674
- defineIteratorMethods(Gp);
675
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
676
- // @@iterator function is called on it. Some browsers' implementations of the
677
- // iterator prototype chain incorrectly implement this, causing the Generator
678
- // object to not be returned from this call. This ensures that doesn't happen.
679
- // See https://github.com/facebook/regenerator/issues/274 for more details.
680
-
681
- Gp[iteratorSymbol] = function () {
682
- return this;
683
- };
684
-
685
- Gp.toString = function () {
686
- return "[object Generator]";
687
- };
688
-
689
- function pushTryEntry(locs) {
690
- var entry = {
691
- tryLoc: locs[0]
692
- };
693
-
694
- if (1 in locs) {
695
- entry.catchLoc = locs[1];
696
- }
697
-
698
- if (2 in locs) {
699
- entry.finallyLoc = locs[2];
700
- entry.afterLoc = locs[3];
701
- }
702
-
703
- this.tryEntries.push(entry);
704
- }
705
-
706
- function resetTryEntry(entry) {
707
- var record = entry.completion || {};
708
- record.type = "normal";
709
- delete record.arg;
710
- entry.completion = record;
711
- }
712
-
713
- function Context(tryLocsList) {
714
- // The root entry object (effectively a try statement without a catch
715
- // or a finally block) gives us a place to store values thrown from
716
- // locations where there is no enclosing try statement.
717
- this.tryEntries = [{
718
- tryLoc: "root"
719
- }];
720
- tryLocsList.forEach(pushTryEntry, this);
721
- this.reset(true);
722
- }
723
-
724
- exports.keys = function (object) {
725
- var keys = [];
726
-
727
- for (var key in object) {
728
- keys.push(key);
729
- }
730
-
731
- keys.reverse(); // Rather than returning an object with a next method, we keep
732
- // things simple and return the next function itself.
733
-
734
- return function next() {
735
- while (keys.length) {
736
- var key = keys.pop();
737
-
738
- if (key in object) {
739
- next.value = key;
740
- next.done = false;
741
- return next;
742
- }
743
- } // To avoid creating an additional object, we just hang the .value
744
- // and .done properties off the next function object itself. This
745
- // also ensures that the minifier will not anonymize the function.
746
-
747
-
748
- next.done = true;
749
- return next;
750
- };
751
- };
752
-
753
- function values(iterable) {
754
- if (iterable) {
755
- var iteratorMethod = iterable[iteratorSymbol];
756
-
757
- if (iteratorMethod) {
758
- return iteratorMethod.call(iterable);
759
- }
760
-
761
- if (typeof iterable.next === "function") {
762
- return iterable;
763
- }
764
-
765
- if (!isNaN(iterable.length)) {
766
- var i = -1,
767
- next = function next() {
768
- while (++i < iterable.length) {
769
- if (hasOwn.call(iterable, i)) {
770
- next.value = iterable[i];
771
- next.done = false;
772
- return next;
773
- }
774
- }
775
-
776
- next.value = undefined$1;
777
- next.done = true;
778
- return next;
779
- };
780
-
781
- return next.next = next;
782
- }
783
- } // Return an iterator with no values.
784
-
785
-
786
- return {
787
- next: doneResult
788
- };
789
- }
790
-
791
- exports.values = values;
792
-
793
- function doneResult() {
794
- return {
795
- value: undefined$1,
796
- done: true
797
- };
798
- }
799
-
800
- Context.prototype = {
801
- constructor: Context,
802
- reset: function reset(skipTempReset) {
803
- this.prev = 0;
804
- this.next = 0; // Resetting context._sent for legacy support of Babel's
805
- // function.sent implementation.
806
-
807
- this.sent = this._sent = undefined$1;
808
- this.done = false;
809
- this.delegate = null;
810
- this.method = "next";
811
- this.arg = undefined$1;
812
- this.tryEntries.forEach(resetTryEntry);
813
-
814
- if (!skipTempReset) {
815
- for (var name in this) {
816
- // Not sure about the optimal order of these conditions:
817
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
818
- this[name] = undefined$1;
819
- }
820
- }
821
- }
822
- },
823
- stop: function stop() {
824
- this.done = true;
825
- var rootEntry = this.tryEntries[0];
826
- var rootRecord = rootEntry.completion;
827
-
828
- if (rootRecord.type === "throw") {
829
- throw rootRecord.arg;
830
- }
831
-
832
- return this.rval;
833
- },
834
- dispatchException: function dispatchException(exception) {
835
- if (this.done) {
836
- throw exception;
837
- }
838
-
839
- var context = this;
840
-
841
- function handle(loc, caught) {
842
- record.type = "throw";
843
- record.arg = exception;
844
- context.next = loc;
845
-
846
- if (caught) {
847
- // If the dispatched exception was caught by a catch block,
848
- // then let that catch block handle the exception normally.
849
- context.method = "next";
850
- context.arg = undefined$1;
851
- }
852
-
853
- return !!caught;
854
- }
855
-
856
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
857
- var entry = this.tryEntries[i];
858
- var record = entry.completion;
859
-
860
- if (entry.tryLoc === "root") {
861
- // Exception thrown outside of any try block that could handle
862
- // it, so set the completion value of the entire function to
863
- // throw the exception.
864
- return handle("end");
865
- }
866
-
867
- if (entry.tryLoc <= this.prev) {
868
- var hasCatch = hasOwn.call(entry, "catchLoc");
869
- var hasFinally = hasOwn.call(entry, "finallyLoc");
870
-
871
- if (hasCatch && hasFinally) {
872
- if (this.prev < entry.catchLoc) {
873
- return handle(entry.catchLoc, true);
874
- } else if (this.prev < entry.finallyLoc) {
875
- return handle(entry.finallyLoc);
876
- }
877
- } else if (hasCatch) {
878
- if (this.prev < entry.catchLoc) {
879
- return handle(entry.catchLoc, true);
880
- }
881
- } else if (hasFinally) {
882
- if (this.prev < entry.finallyLoc) {
883
- return handle(entry.finallyLoc);
884
- }
885
- } else {
886
- throw new Error("try statement without catch or finally");
887
- }
888
- }
889
- }
890
- },
891
- abrupt: function abrupt(type, arg) {
892
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
893
- var entry = this.tryEntries[i];
894
-
895
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
896
- var finallyEntry = entry;
897
- break;
898
- }
899
- }
900
-
901
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
902
- // Ignore the finally entry if control is not jumping to a
903
- // location outside the try/catch block.
904
- finallyEntry = null;
905
- }
906
-
907
- var record = finallyEntry ? finallyEntry.completion : {};
908
- record.type = type;
909
- record.arg = arg;
910
-
911
- if (finallyEntry) {
912
- this.method = "next";
913
- this.next = finallyEntry.finallyLoc;
914
- return ContinueSentinel;
915
- }
916
-
917
- return this.complete(record);
918
- },
919
- complete: function complete(record, afterLoc) {
920
- if (record.type === "throw") {
921
- throw record.arg;
922
- }
923
-
924
- if (record.type === "break" || record.type === "continue") {
925
- this.next = record.arg;
926
- } else if (record.type === "return") {
927
- this.rval = this.arg = record.arg;
928
- this.method = "return";
929
- this.next = "end";
930
- } else if (record.type === "normal" && afterLoc) {
931
- this.next = afterLoc;
932
- }
933
-
934
- return ContinueSentinel;
935
- },
936
- finish: function finish(finallyLoc) {
937
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
938
- var entry = this.tryEntries[i];
939
-
940
- if (entry.finallyLoc === finallyLoc) {
941
- this.complete(entry.completion, entry.afterLoc);
942
- resetTryEntry(entry);
943
- return ContinueSentinel;
944
- }
945
- }
946
- },
947
- "catch": function _catch(tryLoc) {
948
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
949
- var entry = this.tryEntries[i];
950
-
951
- if (entry.tryLoc === tryLoc) {
952
- var record = entry.completion;
953
-
954
- if (record.type === "throw") {
955
- var thrown = record.arg;
956
- resetTryEntry(entry);
957
- }
958
-
959
- return thrown;
960
- }
961
- } // The context.catch method must only be called with a location
962
- // argument that corresponds to a known catch block.
963
-
964
-
965
- throw new Error("illegal catch attempt");
966
- },
967
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
968
- this.delegate = {
969
- iterator: values(iterable),
970
- resultName: resultName,
971
- nextLoc: nextLoc
972
- };
973
-
974
- if (this.method === "next") {
975
- // Deliberately forget the last sent value so that we don't
976
- // accidentally pass it on to the delegate.
977
- this.arg = undefined$1;
978
- }
979
-
980
- return ContinueSentinel;
981
- }
982
- }; // Regardless of whether this script is executing as a CommonJS module
983
- // or not, return the runtime object so that we can declare the variable
984
- // regeneratorRuntime in the outer scope, which allows this module to be
985
- // injected easily by `bin/regenerator --include-runtime script.js`.
986
-
987
- return exports;
988
- }( // If this script is executing as a CommonJS module, use module.exports
989
- // as the regeneratorRuntime namespace. Otherwise create a new empty
990
- // object. Either way, the resulting object will be used to initialize
991
- // the regeneratorRuntime variable at the top of this file.
992
- module.exports );
993
-
994
- try {
995
- regeneratorRuntime = runtime;
996
- } catch (accidentalStrictMode) {
997
- // This module should not be running in strict mode, so the above
998
- // assignment should always work unless something is misconfigured. Just
999
- // in case runtime.js accidentally runs in strict mode, we can escape
1000
- // strict mode using a global Function call. This could conceivably fail
1001
- // if a Content Security Policy forbids using Function, but in that case
1002
- // the proper solution is to fix the accidental strict mode problem. If
1003
- // you've misconfigured your bundler to force strict mode and applied a
1004
- // CSP to forbid Function, and you're not willing to fix either of those
1005
- // problems, please detail your unique predicament in a GitHub issue.
1006
- Function("r", "regeneratorRuntime = r")(runtime);
1007
- }
1008
- });
1009
-
1010
- var BaseProvider = /*#__PURE__*/function () {
1011
- function BaseProvider() {}
1012
-
1013
- var _proto = BaseProvider.prototype;
1014
-
1015
- // eslint-disable-next-line @typescript-eslint/require-await
1016
- _proto.callReadOnly =
1017
- /*#__PURE__*/
1018
- function () {
1019
- var _callReadOnly = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(func, args) {
1020
- return runtime_1.wrap(function _callee$(_context) {
1021
- while (1) {
1022
- switch (_context.prev = _context.next) {
1023
- case 0:
1024
- throw new Error('Not implemented');
1025
-
1026
- case 1:
1027
- case "end":
1028
- return _context.stop();
1029
- }
1030
- }
1031
- }, _callee);
1032
- }));
1033
-
1034
- function callReadOnly(_x, _x2) {
1035
- return _callReadOnly.apply(this, arguments);
1036
- }
1037
-
1038
- return callReadOnly;
1039
- }();
1040
-
1041
- _proto.callPublic = function callPublic(func, args) {
1042
- throw new Error('Not implemented');
1043
- };
1044
-
1045
- return BaseProvider;
1046
- }();
1047
-
1048
- var makeHandler = function makeHandler(provider) {
1049
- var handler = {
1050
- get: function get(contract, property) {
1051
- var foundFunction = contract.functions.find(function (func) {
1052
- return toCamelCase(func.name) === property;
1053
- });
1054
-
1055
- if (foundFunction) {
1056
- if (foundFunction.access === 'read_only') {
1057
- return function () {
1058
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1059
- args[_key] = arguments[_key];
1060
- }
1061
-
1062
- return provider.callReadOnly(foundFunction, args);
1063
- };
1064
- } else if (foundFunction.access === 'public') {
1065
- return function () {
1066
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1067
- args[_key2] = arguments[_key2];
1068
- }
1069
-
1070
- return provider.callPublic(foundFunction, args);
1071
- };
1072
- }
1073
- }
1074
-
1075
- return null;
1076
- }
1077
- };
1078
- return handler;
1079
- };
1080
-
1081
- var proxy = function proxy(target, provider) {
1082
- return new Proxy(target, makeHandler(provider));
1083
- };
1084
-
1085
- exports.BaseProvider = BaseProvider;
1086
- exports.MAINNET_BURN_ADDRESS = MAINNET_BURN_ADDRESS;
1087
- exports.TESTNET_BURN_ADDRESS = TESTNET_BURN_ADDRESS;
1088
- exports.bootContractIdentifier = bootContractIdentifier;
1089
- exports.cvToString = cvToString;
1090
- exports.cvToValue = cvToValue;
1091
- exports.getContractIdentifier = getContractIdentifier;
1092
- exports.getContractNameFromPath = getContractNameFromPath;
1093
- exports.getContractPrincipalCV = getContractPrincipalCV;
1094
- exports.parseToCV = parseToCV;
1095
- exports.proxy = proxy;
1096
- exports.toCamelCase = toCamelCase;
1097
- //# sourceMappingURL=core.cjs.development.js.map