@clarigen/core 0.3.2 → 1.0.0-next.11

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