@dappworks/kit 0.4.176 → 0.4.178

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.
Files changed (45) hide show
  1. package/dist/StorageState-qzikHBY8.d.ts +66 -0
  2. package/dist/aiem.mjs +3 -1231
  3. package/dist/aiem.mjs.map +1 -1
  4. package/dist/chunk-2EXDWOHY.mjs +58 -0
  5. package/dist/chunk-3DOB34HY.mjs +292 -0
  6. package/dist/chunk-3DOB34HY.mjs.map +1 -0
  7. package/dist/{chunk-3O7QI47S.mjs → chunk-3HD22664.mjs} +2 -2
  8. package/dist/chunk-5JMONDHE.mjs +436 -0
  9. package/dist/chunk-5JMONDHE.mjs.map +1 -0
  10. package/dist/chunk-L6XS2K2K.mjs +76 -0
  11. package/dist/chunk-L6XS2K2K.mjs.map +1 -0
  12. package/dist/{chunk-AIZ7XDNV.mjs → chunk-TQNAAA4I.mjs} +22 -21
  13. package/dist/chunk-TQNAAA4I.mjs.map +1 -0
  14. package/dist/{chunk-GKK6EXKY.mjs → chunk-XSLAZWOE.mjs} +4 -4
  15. package/dist/dev.d.mts +3 -3
  16. package/dist/dev.mjs +2 -2
  17. package/dist/experimental.d.mts +3 -3
  18. package/dist/experimental.mjs +1 -1
  19. package/dist/form.d.mts +15 -15
  20. package/dist/form.mjs +2 -2
  21. package/dist/form.mjs.map +1 -1
  22. package/dist/index.d.mts +6 -67
  23. package/dist/index.mjs +3 -291
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/inspector.d.mts +2 -2
  26. package/dist/inspector.mjs +1 -1
  27. package/dist/jsontable.d.mts +8 -8
  28. package/dist/jsontable.mjs +4 -4
  29. package/dist/metrics.d.mts +15 -15
  30. package/dist/metrics.mjs +4 -4
  31. package/dist/plugins.d.mts +11 -11
  32. package/dist/plugins.mjs +21 -83
  33. package/dist/plugins.mjs.map +1 -1
  34. package/dist/ui.d.mts +7 -7
  35. package/dist/ui.mjs +3 -3
  36. package/dist/utils.mjs +1 -1
  37. package/dist/wallet.d.mts +160 -0
  38. package/dist/wallet.mjs +3652 -0
  39. package/dist/wallet.mjs.map +1 -0
  40. package/package.json +13 -3
  41. package/dist/chunk-AIZ7XDNV.mjs.map +0 -1
  42. package/dist/chunk-R4SQKVDQ.mjs +0 -35
  43. /package/dist/{chunk-R4SQKVDQ.mjs.map → chunk-2EXDWOHY.mjs.map} +0 -0
  44. /package/dist/{chunk-3O7QI47S.mjs.map → chunk-3HD22664.mjs.map} +0 -0
  45. /package/dist/{chunk-GKK6EXKY.mjs.map → chunk-XSLAZWOE.mjs.map} +0 -0
package/dist/aiem.mjs CHANGED
@@ -1,1235 +1,7 @@
1
+ export { AIem, Cache, Fields } from './chunk-5JMONDHE.mjs';
1
2
  import './chunk-7MDKCI65.mjs';
2
- import { helper } from './chunk-UPGWJHSO.mjs';
3
+ import './chunk-UPGWJHSO.mjs';
3
4
  import './chunk-K7LFG5BA.mjs';
4
- import { __spreadProps, __spreadValues, __objRest } from './chunk-R4SQKVDQ.mjs';
5
- import { createPublicClient, http, getContract, encodeFunctionData } from 'viem';
6
- import { iotexTestnet, mainnet, iotex, bsc, polygon } from 'viem/chains';
7
- import TTLCache from '@isaacs/ttlcache';
8
- import BigNumber from 'bignumber.js';
9
-
10
- // ../../node_modules/reflect-metadata/Reflect.js
11
- var Reflect2;
12
- (function(Reflect3) {
13
- (function(factory) {
14
- var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : Function("return this;")();
15
- var exporter = makeExporter(Reflect3);
16
- if (typeof root.Reflect === "undefined") {
17
- root.Reflect = Reflect3;
18
- } else {
19
- exporter = makeExporter(root.Reflect, exporter);
20
- }
21
- factory(exporter);
22
- function makeExporter(target, previous) {
23
- return function(key, value) {
24
- if (typeof target[key] !== "function") {
25
- Object.defineProperty(target, key, { configurable: true, writable: true, value });
26
- }
27
- if (previous)
28
- previous(key, value);
29
- };
30
- }
31
- })(function(exporter) {
32
- var hasOwn = Object.prototype.hasOwnProperty;
33
- var supportsSymbol = typeof Symbol === "function";
34
- var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
35
- var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
36
- var supportsCreate = typeof Object.create === "function";
37
- var supportsProto = { __proto__: [] } instanceof Array;
38
- var downLevel = !supportsCreate && !supportsProto;
39
- var HashMap = {
40
- // create an object in dictionary mode (a.k.a. "slow" mode in v8)
41
- create: supportsCreate ? function() {
42
- return MakeDictionary(/* @__PURE__ */ Object.create(null));
43
- } : supportsProto ? function() {
44
- return MakeDictionary({ __proto__: null });
45
- } : function() {
46
- return MakeDictionary({});
47
- },
48
- has: downLevel ? function(map, key) {
49
- return hasOwn.call(map, key);
50
- } : function(map, key) {
51
- return key in map;
52
- },
53
- get: downLevel ? function(map, key) {
54
- return hasOwn.call(map, key) ? map[key] : void 0;
55
- } : function(map, key) {
56
- return map[key];
57
- }
58
- };
59
- var functionPrototype = Object.getPrototypeOf(Function);
60
- var usePolyfill = typeof process === "object" && process.env && process.env["REFLECT_METADATA_USE_MAP_POLYFILL"] === "true";
61
- var _Map = !usePolyfill && typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
62
- var _Set = !usePolyfill && typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
63
- var _WeakMap = !usePolyfill && typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
64
- var Metadata = new _WeakMap();
65
- function decorate(decorators, target, propertyKey, attributes) {
66
- if (!IsUndefined(propertyKey)) {
67
- if (!IsArray(decorators))
68
- throw new TypeError();
69
- if (!IsObject(target))
70
- throw new TypeError();
71
- if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))
72
- throw new TypeError();
73
- if (IsNull(attributes))
74
- attributes = void 0;
75
- propertyKey = ToPropertyKey(propertyKey);
76
- return DecorateProperty(decorators, target, propertyKey, attributes);
77
- } else {
78
- if (!IsArray(decorators))
79
- throw new TypeError();
80
- if (!IsConstructor(target))
81
- throw new TypeError();
82
- return DecorateConstructor(decorators, target);
83
- }
84
- }
85
- exporter("decorate", decorate);
86
- function metadata(metadataKey, metadataValue) {
87
- function decorator(target, propertyKey) {
88
- if (!IsObject(target))
89
- throw new TypeError();
90
- if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))
91
- throw new TypeError();
92
- OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
93
- }
94
- return decorator;
95
- }
96
- exporter("metadata", metadata);
97
- function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
98
- if (!IsObject(target))
99
- throw new TypeError();
100
- if (!IsUndefined(propertyKey))
101
- propertyKey = ToPropertyKey(propertyKey);
102
- return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
103
- }
104
- exporter("defineMetadata", defineMetadata);
105
- function hasMetadata(metadataKey, target, propertyKey) {
106
- if (!IsObject(target))
107
- throw new TypeError();
108
- if (!IsUndefined(propertyKey))
109
- propertyKey = ToPropertyKey(propertyKey);
110
- return OrdinaryHasMetadata(metadataKey, target, propertyKey);
111
- }
112
- exporter("hasMetadata", hasMetadata);
113
- function hasOwnMetadata(metadataKey, target, propertyKey) {
114
- if (!IsObject(target))
115
- throw new TypeError();
116
- if (!IsUndefined(propertyKey))
117
- propertyKey = ToPropertyKey(propertyKey);
118
- return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
119
- }
120
- exporter("hasOwnMetadata", hasOwnMetadata);
121
- function getMetadata(metadataKey, target, propertyKey) {
122
- if (!IsObject(target))
123
- throw new TypeError();
124
- if (!IsUndefined(propertyKey))
125
- propertyKey = ToPropertyKey(propertyKey);
126
- return OrdinaryGetMetadata(metadataKey, target, propertyKey);
127
- }
128
- exporter("getMetadata", getMetadata);
129
- function getOwnMetadata(metadataKey, target, propertyKey) {
130
- if (!IsObject(target))
131
- throw new TypeError();
132
- if (!IsUndefined(propertyKey))
133
- propertyKey = ToPropertyKey(propertyKey);
134
- return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
135
- }
136
- exporter("getOwnMetadata", getOwnMetadata);
137
- function getMetadataKeys(target, propertyKey) {
138
- if (!IsObject(target))
139
- throw new TypeError();
140
- if (!IsUndefined(propertyKey))
141
- propertyKey = ToPropertyKey(propertyKey);
142
- return OrdinaryMetadataKeys(target, propertyKey);
143
- }
144
- exporter("getMetadataKeys", getMetadataKeys);
145
- function getOwnMetadataKeys(target, propertyKey) {
146
- if (!IsObject(target))
147
- throw new TypeError();
148
- if (!IsUndefined(propertyKey))
149
- propertyKey = ToPropertyKey(propertyKey);
150
- return OrdinaryOwnMetadataKeys(target, propertyKey);
151
- }
152
- exporter("getOwnMetadataKeys", getOwnMetadataKeys);
153
- function deleteMetadata(metadataKey, target, propertyKey) {
154
- if (!IsObject(target))
155
- throw new TypeError();
156
- if (!IsUndefined(propertyKey))
157
- propertyKey = ToPropertyKey(propertyKey);
158
- var metadataMap = GetOrCreateMetadataMap(
159
- target,
160
- propertyKey,
161
- /*Create*/
162
- false
163
- );
164
- if (IsUndefined(metadataMap))
165
- return false;
166
- if (!metadataMap.delete(metadataKey))
167
- return false;
168
- if (metadataMap.size > 0)
169
- return true;
170
- var targetMetadata = Metadata.get(target);
171
- targetMetadata.delete(propertyKey);
172
- if (targetMetadata.size > 0)
173
- return true;
174
- Metadata.delete(target);
175
- return true;
176
- }
177
- exporter("deleteMetadata", deleteMetadata);
178
- function DecorateConstructor(decorators, target) {
179
- for (var i = decorators.length - 1; i >= 0; --i) {
180
- var decorator = decorators[i];
181
- var decorated = decorator(target);
182
- if (!IsUndefined(decorated) && !IsNull(decorated)) {
183
- if (!IsConstructor(decorated))
184
- throw new TypeError();
185
- target = decorated;
186
- }
187
- }
188
- return target;
189
- }
190
- function DecorateProperty(decorators, target, propertyKey, descriptor) {
191
- for (var i = decorators.length - 1; i >= 0; --i) {
192
- var decorator = decorators[i];
193
- var decorated = decorator(target, propertyKey, descriptor);
194
- if (!IsUndefined(decorated) && !IsNull(decorated)) {
195
- if (!IsObject(decorated))
196
- throw new TypeError();
197
- descriptor = decorated;
198
- }
199
- }
200
- return descriptor;
201
- }
202
- function GetOrCreateMetadataMap(O, P, Create) {
203
- var targetMetadata = Metadata.get(O);
204
- if (IsUndefined(targetMetadata)) {
205
- if (!Create)
206
- return void 0;
207
- targetMetadata = new _Map();
208
- Metadata.set(O, targetMetadata);
209
- }
210
- var metadataMap = targetMetadata.get(P);
211
- if (IsUndefined(metadataMap)) {
212
- if (!Create)
213
- return void 0;
214
- metadataMap = new _Map();
215
- targetMetadata.set(P, metadataMap);
216
- }
217
- return metadataMap;
218
- }
219
- function OrdinaryHasMetadata(MetadataKey, O, P) {
220
- var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
221
- if (hasOwn2)
222
- return true;
223
- var parent = OrdinaryGetPrototypeOf(O);
224
- if (!IsNull(parent))
225
- return OrdinaryHasMetadata(MetadataKey, parent, P);
226
- return false;
227
- }
228
- function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
229
- var metadataMap = GetOrCreateMetadataMap(
230
- O,
231
- P,
232
- /*Create*/
233
- false
234
- );
235
- if (IsUndefined(metadataMap))
236
- return false;
237
- return ToBoolean(metadataMap.has(MetadataKey));
238
- }
239
- function OrdinaryGetMetadata(MetadataKey, O, P) {
240
- var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
241
- if (hasOwn2)
242
- return OrdinaryGetOwnMetadata(MetadataKey, O, P);
243
- var parent = OrdinaryGetPrototypeOf(O);
244
- if (!IsNull(parent))
245
- return OrdinaryGetMetadata(MetadataKey, parent, P);
246
- return void 0;
247
- }
248
- function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
249
- var metadataMap = GetOrCreateMetadataMap(
250
- O,
251
- P,
252
- /*Create*/
253
- false
254
- );
255
- if (IsUndefined(metadataMap))
256
- return void 0;
257
- return metadataMap.get(MetadataKey);
258
- }
259
- function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
260
- var metadataMap = GetOrCreateMetadataMap(
261
- O,
262
- P,
263
- /*Create*/
264
- true
265
- );
266
- metadataMap.set(MetadataKey, MetadataValue);
267
- }
268
- function OrdinaryMetadataKeys(O, P) {
269
- var ownKeys = OrdinaryOwnMetadataKeys(O, P);
270
- var parent = OrdinaryGetPrototypeOf(O);
271
- if (parent === null)
272
- return ownKeys;
273
- var parentKeys = OrdinaryMetadataKeys(parent, P);
274
- if (parentKeys.length <= 0)
275
- return ownKeys;
276
- if (ownKeys.length <= 0)
277
- return parentKeys;
278
- var set = new _Set();
279
- var keys = [];
280
- for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {
281
- var key = ownKeys_1[_i];
282
- var hasKey = set.has(key);
283
- if (!hasKey) {
284
- set.add(key);
285
- keys.push(key);
286
- }
287
- }
288
- for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {
289
- var key = parentKeys_1[_a];
290
- var hasKey = set.has(key);
291
- if (!hasKey) {
292
- set.add(key);
293
- keys.push(key);
294
- }
295
- }
296
- return keys;
297
- }
298
- function OrdinaryOwnMetadataKeys(O, P) {
299
- var keys = [];
300
- var metadataMap = GetOrCreateMetadataMap(
301
- O,
302
- P,
303
- /*Create*/
304
- false
305
- );
306
- if (IsUndefined(metadataMap))
307
- return keys;
308
- var keysObj = metadataMap.keys();
309
- var iterator = GetIterator(keysObj);
310
- var k = 0;
311
- while (true) {
312
- var next = IteratorStep(iterator);
313
- if (!next) {
314
- keys.length = k;
315
- return keys;
316
- }
317
- var nextValue = IteratorValue(next);
318
- try {
319
- keys[k] = nextValue;
320
- } catch (e) {
321
- try {
322
- IteratorClose(iterator);
323
- } finally {
324
- throw e;
325
- }
326
- }
327
- k++;
328
- }
329
- }
330
- function Type(x) {
331
- if (x === null)
332
- return 1;
333
- switch (typeof x) {
334
- case "undefined":
335
- return 0;
336
- case "boolean":
337
- return 2;
338
- case "string":
339
- return 3;
340
- case "symbol":
341
- return 4;
342
- case "number":
343
- return 5;
344
- case "object":
345
- return x === null ? 1 : 6;
346
- default:
347
- return 6;
348
- }
349
- }
350
- function IsUndefined(x) {
351
- return x === void 0;
352
- }
353
- function IsNull(x) {
354
- return x === null;
355
- }
356
- function IsSymbol(x) {
357
- return typeof x === "symbol";
358
- }
359
- function IsObject(x) {
360
- return typeof x === "object" ? x !== null : typeof x === "function";
361
- }
362
- function ToPrimitive(input, PreferredType) {
363
- switch (Type(input)) {
364
- case 0:
365
- return input;
366
- case 1:
367
- return input;
368
- case 2:
369
- return input;
370
- case 3:
371
- return input;
372
- case 4:
373
- return input;
374
- case 5:
375
- return input;
376
- }
377
- var hint = "string" ;
378
- var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
379
- if (exoticToPrim !== void 0) {
380
- var result = exoticToPrim.call(input, hint);
381
- if (IsObject(result))
382
- throw new TypeError();
383
- return result;
384
- }
385
- return OrdinaryToPrimitive(input);
386
- }
387
- function OrdinaryToPrimitive(O, hint) {
388
- var valueOf, result; {
389
- var toString_1 = O.toString;
390
- if (IsCallable(toString_1)) {
391
- var result = toString_1.call(O);
392
- if (!IsObject(result))
393
- return result;
394
- }
395
- var valueOf = O.valueOf;
396
- if (IsCallable(valueOf)) {
397
- var result = valueOf.call(O);
398
- if (!IsObject(result))
399
- return result;
400
- }
401
- }
402
- throw new TypeError();
403
- }
404
- function ToBoolean(argument) {
405
- return !!argument;
406
- }
407
- function ToString(argument) {
408
- return "" + argument;
409
- }
410
- function ToPropertyKey(argument) {
411
- var key = ToPrimitive(
412
- argument);
413
- if (IsSymbol(key))
414
- return key;
415
- return ToString(key);
416
- }
417
- function IsArray(argument) {
418
- return Array.isArray ? Array.isArray(argument) : argument instanceof Object ? argument instanceof Array : Object.prototype.toString.call(argument) === "[object Array]";
419
- }
420
- function IsCallable(argument) {
421
- return typeof argument === "function";
422
- }
423
- function IsConstructor(argument) {
424
- return typeof argument === "function";
425
- }
426
- function IsPropertyKey(argument) {
427
- switch (Type(argument)) {
428
- case 3:
429
- return true;
430
- case 4:
431
- return true;
432
- default:
433
- return false;
434
- }
435
- }
436
- function GetMethod(V, P) {
437
- var func = V[P];
438
- if (func === void 0 || func === null)
439
- return void 0;
440
- if (!IsCallable(func))
441
- throw new TypeError();
442
- return func;
443
- }
444
- function GetIterator(obj) {
445
- var method = GetMethod(obj, iteratorSymbol);
446
- if (!IsCallable(method))
447
- throw new TypeError();
448
- var iterator = method.call(obj);
449
- if (!IsObject(iterator))
450
- throw new TypeError();
451
- return iterator;
452
- }
453
- function IteratorValue(iterResult) {
454
- return iterResult.value;
455
- }
456
- function IteratorStep(iterator) {
457
- var result = iterator.next();
458
- return result.done ? false : result;
459
- }
460
- function IteratorClose(iterator) {
461
- var f = iterator["return"];
462
- if (f)
463
- f.call(iterator);
464
- }
465
- function OrdinaryGetPrototypeOf(O) {
466
- var proto = Object.getPrototypeOf(O);
467
- if (typeof O !== "function" || O === functionPrototype)
468
- return proto;
469
- if (proto !== functionPrototype)
470
- return proto;
471
- var prototype = O.prototype;
472
- var prototypeProto = prototype && Object.getPrototypeOf(prototype);
473
- if (prototypeProto == null || prototypeProto === Object.prototype)
474
- return proto;
475
- var constructor = prototypeProto.constructor;
476
- if (typeof constructor !== "function")
477
- return proto;
478
- if (constructor === O)
479
- return proto;
480
- return constructor;
481
- }
482
- function CreateMapPolyfill() {
483
- var cacheSentinel = {};
484
- var arraySentinel = [];
485
- var MapIterator = (
486
- /** @class */
487
- function() {
488
- function MapIterator2(keys, values, selector) {
489
- this._index = 0;
490
- this._keys = keys;
491
- this._values = values;
492
- this._selector = selector;
493
- }
494
- MapIterator2.prototype["@@iterator"] = function() {
495
- return this;
496
- };
497
- MapIterator2.prototype[iteratorSymbol] = function() {
498
- return this;
499
- };
500
- MapIterator2.prototype.next = function() {
501
- var index = this._index;
502
- if (index >= 0 && index < this._keys.length) {
503
- var result = this._selector(this._keys[index], this._values[index]);
504
- if (index + 1 >= this._keys.length) {
505
- this._index = -1;
506
- this._keys = arraySentinel;
507
- this._values = arraySentinel;
508
- } else {
509
- this._index++;
510
- }
511
- return { value: result, done: false };
512
- }
513
- return { value: void 0, done: true };
514
- };
515
- MapIterator2.prototype.throw = function(error) {
516
- if (this._index >= 0) {
517
- this._index = -1;
518
- this._keys = arraySentinel;
519
- this._values = arraySentinel;
520
- }
521
- throw error;
522
- };
523
- MapIterator2.prototype.return = function(value) {
524
- if (this._index >= 0) {
525
- this._index = -1;
526
- this._keys = arraySentinel;
527
- this._values = arraySentinel;
528
- }
529
- return { value, done: true };
530
- };
531
- return MapIterator2;
532
- }()
533
- );
534
- return (
535
- /** @class */
536
- function() {
537
- function Map2() {
538
- this._keys = [];
539
- this._values = [];
540
- this._cacheKey = cacheSentinel;
541
- this._cacheIndex = -2;
542
- }
543
- Object.defineProperty(Map2.prototype, "size", {
544
- get: function() {
545
- return this._keys.length;
546
- },
547
- enumerable: true,
548
- configurable: true
549
- });
550
- Map2.prototype.has = function(key) {
551
- return this._find(
552
- key,
553
- /*insert*/
554
- false
555
- ) >= 0;
556
- };
557
- Map2.prototype.get = function(key) {
558
- var index = this._find(
559
- key,
560
- /*insert*/
561
- false
562
- );
563
- return index >= 0 ? this._values[index] : void 0;
564
- };
565
- Map2.prototype.set = function(key, value) {
566
- var index = this._find(
567
- key,
568
- /*insert*/
569
- true
570
- );
571
- this._values[index] = value;
572
- return this;
573
- };
574
- Map2.prototype.delete = function(key) {
575
- var index = this._find(
576
- key,
577
- /*insert*/
578
- false
579
- );
580
- if (index >= 0) {
581
- var size = this._keys.length;
582
- for (var i = index + 1; i < size; i++) {
583
- this._keys[i - 1] = this._keys[i];
584
- this._values[i - 1] = this._values[i];
585
- }
586
- this._keys.length--;
587
- this._values.length--;
588
- if (key === this._cacheKey) {
589
- this._cacheKey = cacheSentinel;
590
- this._cacheIndex = -2;
591
- }
592
- return true;
593
- }
594
- return false;
595
- };
596
- Map2.prototype.clear = function() {
597
- this._keys.length = 0;
598
- this._values.length = 0;
599
- this._cacheKey = cacheSentinel;
600
- this._cacheIndex = -2;
601
- };
602
- Map2.prototype.keys = function() {
603
- return new MapIterator(this._keys, this._values, getKey);
604
- };
605
- Map2.prototype.values = function() {
606
- return new MapIterator(this._keys, this._values, getValue);
607
- };
608
- Map2.prototype.entries = function() {
609
- return new MapIterator(this._keys, this._values, getEntry);
610
- };
611
- Map2.prototype["@@iterator"] = function() {
612
- return this.entries();
613
- };
614
- Map2.prototype[iteratorSymbol] = function() {
615
- return this.entries();
616
- };
617
- Map2.prototype._find = function(key, insert) {
618
- if (this._cacheKey !== key) {
619
- this._cacheIndex = this._keys.indexOf(this._cacheKey = key);
620
- }
621
- if (this._cacheIndex < 0 && insert) {
622
- this._cacheIndex = this._keys.length;
623
- this._keys.push(key);
624
- this._values.push(void 0);
625
- }
626
- return this._cacheIndex;
627
- };
628
- return Map2;
629
- }()
630
- );
631
- function getKey(key, _) {
632
- return key;
633
- }
634
- function getValue(_, value) {
635
- return value;
636
- }
637
- function getEntry(key, value) {
638
- return [key, value];
639
- }
640
- }
641
- function CreateSetPolyfill() {
642
- return (
643
- /** @class */
644
- function() {
645
- function Set2() {
646
- this._map = new _Map();
647
- }
648
- Object.defineProperty(Set2.prototype, "size", {
649
- get: function() {
650
- return this._map.size;
651
- },
652
- enumerable: true,
653
- configurable: true
654
- });
655
- Set2.prototype.has = function(value) {
656
- return this._map.has(value);
657
- };
658
- Set2.prototype.add = function(value) {
659
- return this._map.set(value, value), this;
660
- };
661
- Set2.prototype.delete = function(value) {
662
- return this._map.delete(value);
663
- };
664
- Set2.prototype.clear = function() {
665
- this._map.clear();
666
- };
667
- Set2.prototype.keys = function() {
668
- return this._map.keys();
669
- };
670
- Set2.prototype.values = function() {
671
- return this._map.values();
672
- };
673
- Set2.prototype.entries = function() {
674
- return this._map.entries();
675
- };
676
- Set2.prototype["@@iterator"] = function() {
677
- return this.keys();
678
- };
679
- Set2.prototype[iteratorSymbol] = function() {
680
- return this.keys();
681
- };
682
- return Set2;
683
- }()
684
- );
685
- }
686
- function CreateWeakMapPolyfill() {
687
- var UUID_SIZE = 16;
688
- var keys = HashMap.create();
689
- var rootKey = CreateUniqueKey();
690
- return (
691
- /** @class */
692
- function() {
693
- function WeakMap2() {
694
- this._key = CreateUniqueKey();
695
- }
696
- WeakMap2.prototype.has = function(target) {
697
- var table = GetOrCreateWeakMapTable(
698
- target,
699
- /*create*/
700
- false
701
- );
702
- return table !== void 0 ? HashMap.has(table, this._key) : false;
703
- };
704
- WeakMap2.prototype.get = function(target) {
705
- var table = GetOrCreateWeakMapTable(
706
- target,
707
- /*create*/
708
- false
709
- );
710
- return table !== void 0 ? HashMap.get(table, this._key) : void 0;
711
- };
712
- WeakMap2.prototype.set = function(target, value) {
713
- var table = GetOrCreateWeakMapTable(
714
- target,
715
- /*create*/
716
- true
717
- );
718
- table[this._key] = value;
719
- return this;
720
- };
721
- WeakMap2.prototype.delete = function(target) {
722
- var table = GetOrCreateWeakMapTable(
723
- target,
724
- /*create*/
725
- false
726
- );
727
- return table !== void 0 ? delete table[this._key] : false;
728
- };
729
- WeakMap2.prototype.clear = function() {
730
- this._key = CreateUniqueKey();
731
- };
732
- return WeakMap2;
733
- }()
734
- );
735
- function CreateUniqueKey() {
736
- var key;
737
- do
738
- key = "@@WeakMap@@" + CreateUUID();
739
- while (HashMap.has(keys, key));
740
- keys[key] = true;
741
- return key;
742
- }
743
- function GetOrCreateWeakMapTable(target, create) {
744
- if (!hasOwn.call(target, rootKey)) {
745
- if (!create)
746
- return void 0;
747
- Object.defineProperty(target, rootKey, { value: HashMap.create() });
748
- }
749
- return target[rootKey];
750
- }
751
- function FillRandomBytes(buffer, size) {
752
- for (var i = 0; i < size; ++i)
753
- buffer[i] = Math.random() * 255 | 0;
754
- return buffer;
755
- }
756
- function GenRandomBytes(size) {
757
- if (typeof Uint8Array === "function") {
758
- if (typeof crypto !== "undefined")
759
- return crypto.getRandomValues(new Uint8Array(size));
760
- if (typeof msCrypto !== "undefined")
761
- return msCrypto.getRandomValues(new Uint8Array(size));
762
- return FillRandomBytes(new Uint8Array(size), size);
763
- }
764
- return FillRandomBytes(new Array(size), size);
765
- }
766
- function CreateUUID() {
767
- var data = GenRandomBytes(UUID_SIZE);
768
- data[6] = data[6] & 79 | 64;
769
- data[8] = data[8] & 191 | 128;
770
- var result = "";
771
- for (var offset = 0; offset < UUID_SIZE; ++offset) {
772
- var byte = data[offset];
773
- if (offset === 4 || offset === 6 || offset === 8)
774
- result += "-";
775
- if (byte < 16)
776
- result += "0";
777
- result += byte.toString(16).toLowerCase();
778
- }
779
- return result;
780
- }
781
- }
782
- function MakeDictionary(obj) {
783
- obj.__ = void 0;
784
- delete obj.__;
785
- return obj;
786
- }
787
- });
788
- })(Reflect2 || (Reflect2 = {}));
789
-
790
- // lib/decorators.ts
791
- var FIELD_KEY = Symbol("aiem_field");
792
- var metadataCache = /* @__PURE__ */ new WeakMap();
793
- var Fields = class _Fields {
794
- static hide(options = {}) {
795
- return function(target, propertyKey, descriptor) {
796
- _Fields.setMetadata(target, propertyKey, { type: "hide", options });
797
- };
798
- }
799
- static read(options = {}) {
800
- return function(target, propertyKey, descriptor) {
801
- _Fields.setMetadata(target, propertyKey, { type: "read", options });
802
- };
803
- }
804
- static write(options = {}) {
805
- return function(target, propertyKey, descriptor) {
806
- _Fields.setMetadata(target, propertyKey, { type: "write", options });
807
- };
808
- }
809
- static custom(func = {}) {
810
- return function(target, propertyKey, descriptor) {
811
- _Fields.setMetadata(target, propertyKey, { type: "custom", func });
812
- };
813
- }
814
- static relation(entity, options) {
815
- return function(target, propertyKey, descriptor) {
816
- _Fields.setMetadata(target, propertyKey, { type: "entity", entity, targetKey: options });
817
- };
818
- }
819
- static contract(entity, options) {
820
- return function(target, propertyKey, descriptor) {
821
- _Fields.setMetadata(target, propertyKey, { type: "entity", entity, targetKey: options });
822
- };
823
- }
824
- static setMetadata(target, propertyKey, metadata) {
825
- let targetMetadata = metadataCache.get(target);
826
- if (!targetMetadata) {
827
- targetMetadata = /* @__PURE__ */ new Map();
828
- metadataCache.set(target, targetMetadata);
829
- }
830
- targetMetadata.set(propertyKey, metadata);
831
- Reflect.defineMetadata(FIELD_KEY, metadata, target, propertyKey);
832
- }
833
- };
834
- function getFieldMetadata(target, propertyKey) {
835
- const targetMetadata = metadataCache.get(target);
836
- if (targetMetadata) {
837
- return targetMetadata.get(propertyKey);
838
- }
839
- return Reflect.getMetadata(FIELD_KEY, target, propertyKey);
840
- }
841
- BigInt.prototype.toJSON = function() {
842
- return this.toString();
843
- };
844
- iotexTestnet.contracts = {
845
- multicall3: {
846
- address: "0xb5cecd6894c6f473ec726a176f1512399a2e355d",
847
- blockCreated: 24347592
848
- }
849
- }, //@ts-ignore
850
- mainnet.rpcUrls.default.http = ["https://rpc.ankr.com/eth"];
851
- mainnet.rpcUrls.default.webSocket = ["wss://ethereum-rpc.publicnode.com"];
852
- var Cache = class {
853
- constructor() {
854
- this.kv = new TTLCache({ max: 1e4, ttl: 1e3 * 60 });
855
- }
856
- wrap(key, fn, config = {}) {
857
- if (this.kv.has(key)) {
858
- return this.kv.get(key);
859
- }
860
- const result = fn();
861
- if (result instanceof Promise) {
862
- const promiseResult = result.then((res) => {
863
- this.kv.set(key, res, config);
864
- return res;
865
- });
866
- this.kv.set(key, promiseResult, config);
867
- return promiseResult;
868
- } else {
869
- this.kv.set(key, result, config);
870
- return result;
871
- }
872
- }
873
- };
874
- var _AIem = class _AIem {
875
- constructor(args = {}) {
876
- this.cache = new Cache();
877
- //@ts-ignore
878
- this.chainMap = {
879
- [iotex.id]: iotex,
880
- [mainnet.id]: mainnet,
881
- [bsc.id]: bsc,
882
- [polygon.id]: polygon,
883
- [iotexTestnet.id]: iotexTestnet
884
- };
885
- this.funcMap = {};
886
- this.Set(args);
887
- this.contracts = new Proxy(
888
- {},
889
- {
890
- //@ts-ignore
891
- get: (target, contractName) => {
892
- if (target[contractName])
893
- return target[contractName];
894
- if (!this.nameMap[contractName]) {
895
- throw new Error(`Contract ${String(contractName)} not found`);
896
- }
897
- target[contractName] = new Proxy(
898
- {},
899
- {
900
- //@ts-ignore
901
- get: (innerTarget, contractAlias) => {
902
- var _a;
903
- const addressStr = (_a = this.nameMap[contractName]) == null ? void 0 : _a[contractAlias];
904
- if (!addressStr) {
905
- throw new Error(`Alias ${String(contractAlias)} for contract ${String(contractName)} not found`);
906
- }
907
- const [chainId, address] = addressStr.split("-");
908
- return this.Get(contractName, String(chainId), address);
909
- }
910
- }
911
- );
912
- return target[contractName];
913
- }
914
- }
915
- );
916
- }
917
- get _cache() {
918
- return _AIem.cache;
919
- }
920
- static Set(args) {
921
- return this.init().Set(args);
922
- }
923
- Set(args) {
924
- const _a = args || {}, { chainMap = {}, contractMap = {}, funcMap } = _a, rest = __objRest(_a, ["chainMap", "contractMap", "funcMap"]);
925
- this.chainMap = Object.assign({}, this.chainMap || {}, chainMap);
926
- this.contractMap = Object.assign({}, this.contractMap || {}, contractMap);
927
- this.funcMap = Object.assign({}, this.funcMap || {}, funcMap);
928
- Object.assign(this, rest);
929
- return this;
930
- }
931
- // WsClient<C extends keyof Chains>(chainId: C): PublicClient<WebSocketTransport, Chain, any, any> {
932
- // //@ts-ignore
933
- // return this.cache.wrap(`wsClient-${String(chainId)}`, () => {
934
- // // const wsUrl = this.chainMap[chainId]?.rpcUrls?.default?.webSocket?.[0]
935
- // // if (!wsUrl) throw new Error(`rpcUrls.default.webSocket[0] is not defined for chainId ${String(chainId)}`)
936
- // // //@ts-ignore
937
- // return createPublicClient({
938
- // //@ts-ignore
939
- // chain: this.chainMap[chainId],
940
- // transport: webSocket()
941
- // }) as PublicClient<WebSocketTransport, Chain, any, any>
942
- // })
943
- // }
944
- static PubClient(chainId, options = { multicall: true }) {
945
- return this.init().PubClient(chainId, options);
946
- }
947
- PubClient(chainId, options = { multicall: true }) {
948
- const chain = this.chainMap[chainId];
949
- if (options.rpcUrls) {
950
- chain.rpcUrls = options.rpcUrls;
951
- }
952
- return this._cache.wrap(`publicClient-${String(chainId)}-${chain.rpcUrls.default.http}-${options == null ? void 0 : options.multicall}`, () => {
953
- return createPublicClient(__spreadProps(__spreadValues({
954
- //@ts-ignore
955
- chain
956
- }, (options == null ? void 0 : options.multicall) ? {
957
- batch: {
958
- multicall: true
959
- }
960
- } : {}), {
961
- //@ts-ignore
962
- transport: http()
963
- }));
964
- });
965
- }
966
- //@ts-ignore
967
- static Get(abi, chainId, address, wallet, options = { multicall: true }) {
968
- const aiem = this.init();
969
- if (!wallet) {
970
- wallet = aiem.getWallet ? aiem.getWallet() : null;
971
- }
972
- const cacheKey = `contract ${chainId}-${address}-${wallet ? wallet.account.address : null}`;
973
- return aiem._cache.wrap(cacheKey, () => {
974
- const pubClient = aiem.PubClient(chainId, options);
975
- return aiem.getContract({
976
- client: {
977
- //@ts-ignore
978
- public: pubClient,
979
- //@ts-ignore
980
- wallet
981
- },
982
- address,
983
- abi
984
- });
985
- });
986
- }
987
- //@ts-ignore
988
- Get(contractName, chainId, address, options = { multicall: true }) {
989
- const wallet = this.getWallet ? this.getWallet() : null;
990
- const cacheKey = `contract ${chainId}-${address}-${wallet ? wallet.account.address : null}`;
991
- return this._cache.wrap(cacheKey, () => {
992
- const contract = this.contractMap[contractName];
993
- const pubClient = this.PubClient(chainId, options);
994
- return this.getContract({
995
- client: {
996
- //@ts-ignore
997
- public: pubClient,
998
- //@ts-ignore
999
- wallet
1000
- },
1001
- address,
1002
- abi: contract
1003
- });
1004
- });
1005
- }
1006
- getContract({
1007
- client,
1008
- address,
1009
- abi
1010
- }) {
1011
- const handler = {
1012
- get: (target, funcName) => {
1013
- if (funcName == "encode") {
1014
- return new Proxy(
1015
- {},
1016
- {
1017
- get(t1, f1) {
1018
- return async (args) => {
1019
- return encodeFunctionData({
1020
- abi,
1021
- functionName: f1,
1022
- args
1023
- });
1024
- };
1025
- }
1026
- }
1027
- );
1028
- }
1029
- if (typeof target[funcName] === "function") {
1030
- return async (...args) => {
1031
- var _a;
1032
- const methodConfig = (_a = this.funcMap) == null ? void 0 : _a[funcName];
1033
- const cacheKey = `call ${client.public.chain.id}-${address}-${funcName}-${JSON.stringify(args)}`;
1034
- if (methodConfig) {
1035
- return this.cache.wrap(
1036
- cacheKey,
1037
- () => {
1038
- return target[funcName](...args);
1039
- },
1040
- methodConfig
1041
- );
1042
- }
1043
- return target[funcName](...args);
1044
- };
1045
- }
1046
- return new Proxy(target[funcName], handler);
1047
- }
1048
- };
1049
- const contract = getContract({
1050
- //@ts-ignore
1051
- client,
1052
- address,
1053
- abi
1054
- });
1055
- return new Proxy(contract, handler);
1056
- }
1057
- static init() {
1058
- if (!globalThis.aiem) {
1059
- globalThis.aiem = new _AIem();
1060
- }
1061
- return globalThis.aiem;
1062
- }
1063
- static async getPrice({ chainId = "4689", address }) {
1064
- const priceMap = await this.cache.wrap(
1065
- `token-price`,
1066
- async () => {
1067
- const res = await (await fetch("https://api.iopay.me/api/rest/price")).json();
1068
- return Object.values(res).flat().reduce((p, c) => {
1069
- p[`${4689}-${c.platforms.toLowerCase()}`] = c.current_price;
1070
- return p;
1071
- }, {});
1072
- },
1073
- { ttl: 1e3 * 60 }
1074
- );
1075
- return priceMap[`${chainId}-${address}`];
1076
- }
1077
- static QueryMany(entity, select) {
1078
- return async (_entities) => {
1079
- return this.Query(entity, select)(_entities);
1080
- };
1081
- }
1082
- static Query(entity, select) {
1083
- return async (entities) => {
1084
- const isArrayInput = Array.isArray(entities);
1085
- try {
1086
- const results = [];
1087
- if (!isArrayInput) {
1088
- entities = [entities];
1089
- }
1090
- for (const entityData of entities) {
1091
- const instance = Object.assign(new entity(), entityData);
1092
- const fetchFields = async (obj, sel) => {
1093
- var _a, _b;
1094
- const promises = [];
1095
- for (const key in sel) {
1096
- const fieldMetadata = getFieldMetadata(obj, key);
1097
- let call;
1098
- const enableMulticall = entity.multicall == false ? false : true;
1099
- if (sel[key] == false) {
1100
- call = async () => null;
1101
- } else {
1102
- switch (fieldMetadata == null ? void 0 : fieldMetadata.type) {
1103
- case "read":
1104
- if (Array.isArray(sel[key])) {
1105
- call = () => this.Get(entity.abi, instance.chainId, instance.address, null, { multicall: enableMulticall }).read[key](sel[key]);
1106
- } else {
1107
- call = () => this.Get(entity.abi, instance.chainId, instance.address, null, { multicall: enableMulticall }).read[key]();
1108
- }
1109
- break;
1110
- case "write":
1111
- obj[key] = encodeFunctionData({
1112
- //@ts-ignore
1113
- abi: entity.abi,
1114
- functionName: key,
1115
- args: sel[key]
1116
- });
1117
- break;
1118
- case "custom":
1119
- const func = fieldMetadata.func;
1120
- call = () => func(instance);
1121
- break;
1122
- case "entity":
1123
- const targetMetadata = getFieldMetadata(instance, fieldMetadata.targetKey);
1124
- if (typeof fieldMetadata.targetKey == "string") {
1125
- if ((_a = targetMetadata == null ? void 0 : targetMetadata.options) == null ? void 0 : _a.ttl) {
1126
- const cacheKey = `call ${instance.chainId}-${instance.address}-${fieldMetadata.targetKey}`;
1127
- call = () => new Promise(async (resolve) => {
1128
- const address = await this.cache.wrap(
1129
- cacheKey,
1130
- async () => (
1131
- //@ts-ignore
1132
- this.Get(entity.abi, instance.chainId, instance.address, null, { multicall: enableMulticall }).read[fieldMetadata.targetKey]()
1133
- )
1134
- );
1135
- resolve(this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId }));
1136
- });
1137
- } else {
1138
- call = () => (
1139
- //@ts-ignore
1140
- this.Get(entity.abi, instance.chainId, instance.address, null, { multicall: enableMulticall }).read[fieldMetadata.targetKey]().then((address) => {
1141
- return this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId });
1142
- })
1143
- );
1144
- }
1145
- } else {
1146
- call = () => fieldMetadata.targetKey(instance).then((args) => {
1147
- return Array.isArray(args) ? this.QueryMany(fieldMetadata.entity(), sel[key])(args) : this.Query(fieldMetadata.entity(), sel[key])(args);
1148
- });
1149
- }
1150
- break;
1151
- default:
1152
- if (typeof obj[key] == "function") {
1153
- call = () => obj[key](...Array.isArray(sel[key]) ? sel[key] : []);
1154
- }
1155
- break;
1156
- }
1157
- }
1158
- if (call) {
1159
- if ((_b = fieldMetadata == null ? void 0 : fieldMetadata.options) == null ? void 0 : _b.ttl) {
1160
- const cacheKey = `call ${instance.chainId}-${instance.address}-${key}-${JSON.stringify(sel[key])}`;
1161
- promises.push(
1162
- new Promise(async (resolve) => {
1163
- const value = await this.cache.wrap(cacheKey, async () => call().catch((i) => null), fieldMetadata.options);
1164
- obj[key] = value;
1165
- resolve(value);
1166
- })
1167
- );
1168
- } else {
1169
- promises.push(
1170
- call().then((value) => {
1171
- obj[key] = value;
1172
- }).catch((i) => obj[key] = null)
1173
- );
1174
- }
1175
- }
1176
- }
1177
- await Promise.all(promises);
1178
- };
1179
- await fetchFields(instance, select);
1180
- results.push(instance);
1181
- }
1182
- if (isArrayInput) {
1183
- return results;
1184
- } else {
1185
- return results[0];
1186
- }
1187
- } catch (error) {
1188
- if (isArrayInput) {
1189
- return [];
1190
- } else {
1191
- return null;
1192
- }
1193
- }
1194
- };
1195
- }
1196
- };
1197
- _AIem.cache = new Cache();
1198
- _AIem.defaultFuncMap = {
1199
- totalSupply: { ttl: 15 * 1e3 },
1200
- symbol: { ttl: 60 * 1e3 },
1201
- name: { ttl: 60 * 1e3 },
1202
- decimals: { ttl: 60 * 1e3 },
1203
- balanceOf: { ttl: 5 * 1e3 }
1204
- };
1205
- _AIem.utils = {
1206
- autoFormat: async ({ value, decimals, chainId, address }) => {
1207
- const wrap = helper.number.warpBigNumber(value, decimals, { format: "0,0.000000", fallback: "" });
1208
- const price = await _AIem.getPrice({ chainId, address: address.toLowerCase() });
1209
- const usd = new BigNumber(wrap.originFormat).multipliedBy(price || 1).toFixed(2);
1210
- return __spreadProps(__spreadValues({}, wrap), { usd });
1211
- }
1212
- };
1213
- var AIem = _AIem;
1214
- /*! Bundled license information:
1215
-
1216
- reflect-metadata/Reflect.js:
1217
- (*! *****************************************************************************
1218
- Copyright (C) Microsoft. All rights reserved.
1219
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
1220
- this file except in compliance with the License. You may obtain a copy of the
1221
- License at http://www.apache.org/licenses/LICENSE-2.0
1222
-
1223
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1224
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
1225
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
1226
- MERCHANTABLITY OR NON-INFRINGEMENT.
1227
-
1228
- See the Apache Version 2.0 License for specific language governing permissions
1229
- and limitations under the License.
1230
- ***************************************************************************** *)
1231
- */
1232
-
1233
- export { AIem, Cache, Fields };
5
+ import './chunk-2EXDWOHY.mjs';
1234
6
  //# sourceMappingURL=out.js.map
1235
7
  //# sourceMappingURL=aiem.mjs.map