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