@dappworks/kit 0.4.118 → 0.4.120
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/{PromiseState-yojg0WLR.d.ts → PromiseState-b0cc408e.d.ts} +3 -3
- package/dist/aiem.d.mts +7 -13
- package/dist/aiem.mjs +163 -117
- package/dist/aiem.mjs.map +1 -1
- package/dist/{chunk-R4SQKVDQ.mjs → chunk-6F7H4PAA.mjs} +1 -1
- package/dist/{chunk-SVPD6PC6.mjs → chunk-7FF4BCFW.mjs} +4 -4
- package/dist/{chunk-WS43BV7Y.mjs → chunk-DZMNL4BZ.mjs} +2 -2
- package/dist/{chunk-XJMRAPHI.mjs → chunk-HRWHDF2F.mjs} +7 -7
- package/dist/{chunk-XJMRAPHI.mjs.map → chunk-HRWHDF2F.mjs.map} +1 -1
- package/dist/{chunk-QWHU3HBK.mjs → chunk-PPYYRQDD.mjs} +2 -2
- package/dist/{chunk-46XF5IRX.mjs → chunk-Q3AD5RHQ.mjs} +4 -3
- package/dist/chunk-Q3AD5RHQ.mjs.map +1 -0
- package/dist/{chunk-HRYH37UI.mjs → chunk-WT2ARRCR.mjs} +2 -2
- package/dist/{chunk-AIZ7XDNV.mjs → chunk-WYGQ3Y4R.mjs} +14 -14
- package/dist/chunk-WYGQ3Y4R.mjs.map +1 -0
- package/dist/dev.d.mts +1 -1
- package/dist/dev.mjs +3 -3
- package/dist/experimental.d.mts +2 -2
- package/dist/experimental.mjs +3 -3
- package/dist/form.d.mts +13 -7
- package/dist/form.mjs +21 -18
- package/dist/form.mjs.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +6 -6
- package/dist/inspector.d.mts +1 -1
- package/dist/inspector.mjs +1 -1
- package/dist/jsontable.d.mts +2 -2
- package/dist/jsontable.mjs +4 -4
- package/dist/metrics.d.mts +1 -1
- package/dist/metrics.mjs +4 -4
- package/dist/plugins.d.mts +2 -2
- package/dist/plugins.mjs +4 -4
- package/dist/{root-C3lZnoCI.d.ts → root-766ae985.d.ts} +1 -1
- package/dist/ui.mjs +3 -3
- package/dist/utils.d.mts +4 -15
- package/dist/utils.mjs +2 -2
- package/package.json +2 -2
- package/dist/chunk-46XF5IRX.mjs.map +0 -1
- package/dist/chunk-AIZ7XDNV.mjs.map +0 -1
- /package/dist/{PaginationState-Bmrrw0ky.d.ts → PaginationState-c19e621a.d.ts} +0 -0
- /package/dist/{chunk-R4SQKVDQ.mjs.map → chunk-6F7H4PAA.mjs.map} +0 -0
- /package/dist/{chunk-SVPD6PC6.mjs.map → chunk-7FF4BCFW.mjs.map} +0 -0
- /package/dist/{chunk-WS43BV7Y.mjs.map → chunk-DZMNL4BZ.mjs.map} +0 -0
- /package/dist/{chunk-QWHU3HBK.mjs.map → chunk-PPYYRQDD.mjs.map} +0 -0
- /package/dist/{chunk-HRYH37UI.mjs.map → chunk-WT2ARRCR.mjs.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { c as BooleanState, B as BaseState } from './root-
|
|
2
|
+
import { c as BooleanState, B as BaseState } from './root-766ae985.js';
|
|
3
3
|
|
|
4
4
|
interface Events {
|
|
5
5
|
data: (data: any) => void;
|
|
@@ -22,10 +22,10 @@ declare class PromiseState<T extends (...args: any[]) => Promise<any>, U = Retur
|
|
|
22
22
|
successMsg: string;
|
|
23
23
|
errMsg: string;
|
|
24
24
|
loadingLock: boolean;
|
|
25
|
-
event: EventEmitter
|
|
25
|
+
event: EventEmitter;
|
|
26
26
|
on<E extends keyof Events>(event: E, listener: Events[E]): this;
|
|
27
27
|
once<E extends keyof Events>(event: E, listener: Events[E]): this;
|
|
28
|
-
use<E extends keyof Events>(event: E, listener: Events[E]): () => EventEmitter
|
|
28
|
+
use<E extends keyof Events>(event: E, listener: Events[E]): () => EventEmitter;
|
|
29
29
|
emit<E extends keyof Events>(event: E, ...args: Parameters<Events[E]>): void;
|
|
30
30
|
init: () => Promise<void>;
|
|
31
31
|
currentIndex: BaseState;
|
package/dist/aiem.d.mts
CHANGED
|
@@ -73,7 +73,7 @@ declare class AIem<Contracts extends Record<string, Abi>, Chains extends Record<
|
|
|
73
73
|
constructor(args?: Pick<AIem<Contracts, Chains, Addrs>, "contractMap" | "chainMap" | "nameMap" | "getWallet" | "cache" | "funcMap">);
|
|
74
74
|
PubClient<C extends keyof Chains>(chainId: C): PublicClient<HttpTransport, Chain, any, any>;
|
|
75
75
|
Get<K extends keyof Contracts, C extends keyof Chains, Addr extends `0x${string}`>(contractName: K, chainId: C, address: Addr): GetContractReturnType<Contracts[K], PublicClient<HttpTransport, Chain, any, any>>;
|
|
76
|
-
getContract({ client, address, abi }: {
|
|
76
|
+
getContract({ client, address, abi, }: {
|
|
77
77
|
client: {
|
|
78
78
|
public: PublicClient<HttpTransport, Chain, any, any>;
|
|
79
79
|
wallet?: WalletClient;
|
|
@@ -83,7 +83,6 @@ declare class AIem<Contracts extends Record<string, Abi>, Chains extends Record<
|
|
|
83
83
|
}): any;
|
|
84
84
|
static init(): AIem<any, any, any>;
|
|
85
85
|
static Get<TAbi extends Abi = any>(abi: TAbi, chainId: any, address: any, wallet?: WalletClient): GetContractReturnType<TAbi, PublicClient<HttpTransport, Chain, any, any>>;
|
|
86
|
-
static Query: <E, S extends QuerySelect<E>>(entity: ClassType<E>, select: S) => ((entities: Partial<E> | Partial<E>[]) => Promise<QueryResult<E, S>>);
|
|
87
86
|
static getPrice({ chainId, address }: {
|
|
88
87
|
chainId?: string;
|
|
89
88
|
address: string;
|
|
@@ -98,25 +97,20 @@ declare class AIem<Contracts extends Record<string, Abi>, Chains extends Record<
|
|
|
98
97
|
usd: string;
|
|
99
98
|
value: string;
|
|
100
99
|
format: string;
|
|
101
|
-
decimals: string;
|
|
102
|
-
isZero: boolean;
|
|
103
|
-
originFormat?: undefined;
|
|
104
|
-
} | {
|
|
105
|
-
usd: string;
|
|
106
|
-
value: string;
|
|
107
100
|
originFormat: string;
|
|
108
|
-
format: string;
|
|
109
101
|
decimals: string;
|
|
110
|
-
isZero
|
|
102
|
+
isZero: boolean;
|
|
111
103
|
}>;
|
|
112
104
|
};
|
|
105
|
+
static QueryMany<E, S extends QuerySelect<E>>(entity: ClassType<E>, select: S): (_entities: Partial<E>[]) => Promise<QueryReturnType<E, S>[]>;
|
|
106
|
+
static Query<E, S extends QuerySelect<E>>(entity: ClassType<E>, select: S): (entities: Partial<E>) => Promise<QueryReturnType<E, S>>;
|
|
113
107
|
}
|
|
114
|
-
type
|
|
108
|
+
type Item<T> = T extends (infer U)[] ? U : T;
|
|
115
109
|
type QuerySelect<E> = {
|
|
116
|
-
[K in keyof E]?: E[K] extends (...args: any[]) => any ? Parameters<E[K]> | true : E[K] extends object ? QuerySelect<E[K]>
|
|
110
|
+
[K in keyof E]?: E[K] extends (...args: any[]) => any ? Parameters<E[K]> | true : E[K] extends object ? QuerySelect<E[K]> : true;
|
|
117
111
|
};
|
|
118
112
|
type QueryReturnType<E, S extends QuerySelect<E>> = {
|
|
119
113
|
[K in keyof E]: K extends keyof S ? E[K] extends (...args: any[]) => any ? Awaited<ReturnType<E[K]>> : E[K] extends object ? S[K] extends object ? QueryReturnType<E[K], S[K]> : E[K] : E[K] : E[K];
|
|
120
114
|
};
|
|
121
115
|
|
|
122
|
-
export { AIem, Cache, Fields,
|
|
116
|
+
export { AIem, Cache, Fields, Item, QueryReturnType };
|
package/dist/aiem.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './chunk-7MDKCI65.mjs';
|
|
2
|
-
import { helper } from './chunk-
|
|
2
|
+
import { helper } from './chunk-Q3AD5RHQ.mjs';
|
|
3
3
|
import './chunk-MGU3KYGC.mjs';
|
|
4
|
-
import { __spreadProps, __spreadValues, __objRest } from './chunk-
|
|
4
|
+
import { __spreadProps, __spreadValues, __objRest } from './chunk-6F7H4PAA.mjs';
|
|
5
5
|
import { createPublicClient, http, getContract, encodeFunctionData } from 'viem';
|
|
6
6
|
import { mainnet, iotex, bsc, polygon, iotexTestnet } from 'viem/chains';
|
|
7
7
|
import TTLCache from '@isaacs/ttlcache';
|
|
@@ -374,7 +374,7 @@ var Reflect2;
|
|
|
374
374
|
case 5:
|
|
375
375
|
return input;
|
|
376
376
|
}
|
|
377
|
-
var hint = "string" ;
|
|
377
|
+
var hint = PreferredType === 3 ? "string" : PreferredType === 5 ? "number" : "default";
|
|
378
378
|
var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
|
|
379
379
|
if (exoticToPrim !== void 0) {
|
|
380
380
|
var result = exoticToPrim.call(input, hint);
|
|
@@ -382,10 +382,10 @@ var Reflect2;
|
|
|
382
382
|
throw new TypeError();
|
|
383
383
|
return result;
|
|
384
384
|
}
|
|
385
|
-
return OrdinaryToPrimitive(input);
|
|
385
|
+
return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint);
|
|
386
386
|
}
|
|
387
387
|
function OrdinaryToPrimitive(O, hint) {
|
|
388
|
-
|
|
388
|
+
if (hint === "string") {
|
|
389
389
|
var toString_1 = O.toString;
|
|
390
390
|
if (IsCallable(toString_1)) {
|
|
391
391
|
var result = toString_1.call(O);
|
|
@@ -398,6 +398,19 @@ var Reflect2;
|
|
|
398
398
|
if (!IsObject(result))
|
|
399
399
|
return result;
|
|
400
400
|
}
|
|
401
|
+
} else {
|
|
402
|
+
var valueOf = O.valueOf;
|
|
403
|
+
if (IsCallable(valueOf)) {
|
|
404
|
+
var result = valueOf.call(O);
|
|
405
|
+
if (!IsObject(result))
|
|
406
|
+
return result;
|
|
407
|
+
}
|
|
408
|
+
var toString_2 = O.toString;
|
|
409
|
+
if (IsCallable(toString_2)) {
|
|
410
|
+
var result = toString_2.call(O);
|
|
411
|
+
if (!IsObject(result))
|
|
412
|
+
return result;
|
|
413
|
+
}
|
|
401
414
|
}
|
|
402
415
|
throw new TypeError();
|
|
403
416
|
}
|
|
@@ -409,7 +422,10 @@ var Reflect2;
|
|
|
409
422
|
}
|
|
410
423
|
function ToPropertyKey(argument) {
|
|
411
424
|
var key = ToPrimitive(
|
|
412
|
-
argument
|
|
425
|
+
argument,
|
|
426
|
+
3
|
|
427
|
+
/* String */
|
|
428
|
+
);
|
|
413
429
|
if (IsSymbol(key))
|
|
414
430
|
return key;
|
|
415
431
|
return ToString(key);
|
|
@@ -856,29 +872,35 @@ var _AIem = class _AIem {
|
|
|
856
872
|
};
|
|
857
873
|
this.funcMap = {};
|
|
858
874
|
this.Set(args);
|
|
859
|
-
this.contracts = new Proxy(
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
875
|
+
this.contracts = new Proxy(
|
|
876
|
+
{},
|
|
877
|
+
{
|
|
878
|
+
//@ts-ignore
|
|
879
|
+
get: (target, contractName) => {
|
|
880
|
+
if (target[contractName])
|
|
881
|
+
return target[contractName];
|
|
882
|
+
if (!this.nameMap[contractName]) {
|
|
883
|
+
throw new Error(`Contract ${String(contractName)} not found`);
|
|
884
|
+
}
|
|
885
|
+
target[contractName] = new Proxy(
|
|
886
|
+
{},
|
|
887
|
+
{
|
|
888
|
+
//@ts-ignore
|
|
889
|
+
get: (innerTarget, contractAlias) => {
|
|
890
|
+
var _a;
|
|
891
|
+
const addressStr = (_a = this.nameMap[contractName]) == null ? void 0 : _a[contractAlias];
|
|
892
|
+
if (!addressStr) {
|
|
893
|
+
throw new Error(`Alias ${String(contractAlias)} for contract ${String(contractName)} not found`);
|
|
894
|
+
}
|
|
895
|
+
const [chainId, address] = addressStr.split("-");
|
|
896
|
+
return this.Get(contractName, String(chainId), address);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
);
|
|
863
900
|
return target[contractName];
|
|
864
|
-
if (!this.nameMap[contractName]) {
|
|
865
|
-
throw new Error(`Contract ${String(contractName)} not found`);
|
|
866
901
|
}
|
|
867
|
-
target[contractName] = new Proxy({}, {
|
|
868
|
-
//@ts-ignore
|
|
869
|
-
get: (innerTarget, contractAlias) => {
|
|
870
|
-
var _a;
|
|
871
|
-
const addressStr = (_a = this.nameMap[contractName]) == null ? void 0 : _a[contractAlias];
|
|
872
|
-
if (!addressStr) {
|
|
873
|
-
throw new Error(`Alias ${String(contractAlias)} for contract ${String(contractName)} not found`);
|
|
874
|
-
}
|
|
875
|
-
const [chainId, address] = addressStr.split("-");
|
|
876
|
-
return this.Get(contractName, String(chainId), address);
|
|
877
|
-
}
|
|
878
|
-
});
|
|
879
|
-
return target[contractName];
|
|
880
902
|
}
|
|
881
|
-
|
|
903
|
+
);
|
|
882
904
|
}
|
|
883
905
|
get _cache() {
|
|
884
906
|
return _AIem.cache;
|
|
@@ -948,9 +970,13 @@ var _AIem = class _AIem {
|
|
|
948
970
|
const methodConfig = (_a = this.funcMap) == null ? void 0 : _a[funcName];
|
|
949
971
|
const cacheKey = `call ${client.public.chain.id}-${address}-${funcName}-${JSON.stringify(args)}`;
|
|
950
972
|
if (methodConfig) {
|
|
951
|
-
return this.cache.wrap(
|
|
952
|
-
|
|
953
|
-
|
|
973
|
+
return this.cache.wrap(
|
|
974
|
+
cacheKey,
|
|
975
|
+
() => {
|
|
976
|
+
return target[funcName](...args);
|
|
977
|
+
},
|
|
978
|
+
methodConfig
|
|
979
|
+
);
|
|
954
980
|
}
|
|
955
981
|
return target[funcName](...args);
|
|
956
982
|
};
|
|
@@ -991,101 +1017,121 @@ var _AIem = class _AIem {
|
|
|
991
1017
|
});
|
|
992
1018
|
}
|
|
993
1019
|
static async getPrice({ chainId = "4689", address }) {
|
|
994
|
-
const priceMap = await this.cache.wrap(
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
return p
|
|
999
|
-
|
|
1000
|
-
|
|
1020
|
+
const priceMap = await this.cache.wrap(
|
|
1021
|
+
`token-price`,
|
|
1022
|
+
async () => {
|
|
1023
|
+
const res = await (await fetch("https://api.iopay.me/api/rest/price")).json();
|
|
1024
|
+
return Object.values(res).flat().reduce((p, c) => {
|
|
1025
|
+
p[`${4689}-${c.platforms.toLowerCase()}`] = c.current_price;
|
|
1026
|
+
return p;
|
|
1027
|
+
}, {});
|
|
1028
|
+
},
|
|
1029
|
+
{ ttl: 1e3 * 60 }
|
|
1030
|
+
);
|
|
1001
1031
|
return priceMap[`${chainId}-${address}`];
|
|
1002
1032
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
switch (fieldMetadata.type) {
|
|
1029
|
-
case "read":
|
|
1030
|
-
if (Array.isArray(sel[key])) {
|
|
1031
|
-
call = () => _AIem.Get(entity.abi, instance.chainId, instance.address).read[key](sel[key]);
|
|
1032
|
-
} else {
|
|
1033
|
-
call = () => _AIem.Get(entity.abi, instance.chainId, instance.address).read[key]();
|
|
1034
|
-
}
|
|
1035
|
-
break;
|
|
1036
|
-
case "write":
|
|
1037
|
-
obj[key] = encodeFunctionData({
|
|
1038
|
-
//@ts-ignore
|
|
1039
|
-
abi: entity.abi,
|
|
1040
|
-
functionName: key,
|
|
1041
|
-
args: sel[key]
|
|
1042
|
-
});
|
|
1043
|
-
break;
|
|
1044
|
-
case "custom":
|
|
1045
|
-
call = () => obj[key](...Array.isArray(sel[key]) ? sel[key] : []);
|
|
1046
|
-
break;
|
|
1047
|
-
case "contract":
|
|
1048
|
-
if (fieldMetadata.targetKey) {
|
|
1049
|
-
const targetMetadata = getFieldMetadata(instance, fieldMetadata.targetKey);
|
|
1050
|
-
if ((_a = targetMetadata == null ? void 0 : targetMetadata.options) == null ? void 0 : _a.ttl) {
|
|
1051
|
-
const cacheKey = `call ${instance.chainId}-${instance.address}-${fieldMetadata.targetKey}`;
|
|
1052
|
-
call = () => new Promise(async (resolve) => {
|
|
1053
|
-
const address = await _AIem.cache.wrap(cacheKey, async () => _AIem.Get(entity.abi, instance.chainId, instance.address).read[fieldMetadata.targetKey]());
|
|
1054
|
-
resolve(_AIem.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId }));
|
|
1055
|
-
});
|
|
1033
|
+
static QueryMany(entity, select) {
|
|
1034
|
+
return async (_entities) => {
|
|
1035
|
+
return this.Query(entity, select)(_entities);
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
static Query(entity, select) {
|
|
1039
|
+
return async (entities) => {
|
|
1040
|
+
const results = [];
|
|
1041
|
+
const isArrayInput = Array.isArray(entities);
|
|
1042
|
+
if (!isArrayInput) {
|
|
1043
|
+
entities = [entities];
|
|
1044
|
+
}
|
|
1045
|
+
for (const entityData of entities) {
|
|
1046
|
+
const instance = Object.assign(new entity(), entityData);
|
|
1047
|
+
const fetchFields = async (obj, sel) => {
|
|
1048
|
+
var _a, _b;
|
|
1049
|
+
const promises = [];
|
|
1050
|
+
for (const key in sel) {
|
|
1051
|
+
const fieldMetadata = getFieldMetadata(obj, key);
|
|
1052
|
+
let call;
|
|
1053
|
+
if (fieldMetadata) {
|
|
1054
|
+
switch (fieldMetadata.type) {
|
|
1055
|
+
case "read":
|
|
1056
|
+
if (Array.isArray(sel[key])) {
|
|
1057
|
+
call = () => this.Get(entity.abi, instance.chainId, instance.address).read[key](sel[key]);
|
|
1056
1058
|
} else {
|
|
1057
|
-
call = () =>
|
|
1058
|
-
return _AIem.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId });
|
|
1059
|
-
});
|
|
1059
|
+
call = () => this.Get(entity.abi, instance.chainId, instance.address).read[key]();
|
|
1060
1060
|
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1061
|
+
break;
|
|
1062
|
+
case "write":
|
|
1063
|
+
obj[key] = encodeFunctionData({
|
|
1064
|
+
//@ts-ignore
|
|
1065
|
+
abi: entity.abi,
|
|
1066
|
+
functionName: key,
|
|
1067
|
+
args: sel[key]
|
|
1068
|
+
});
|
|
1069
|
+
break;
|
|
1070
|
+
case "custom":
|
|
1071
|
+
call = () => obj[key](...Array.isArray(sel[key]) ? sel[key] : []);
|
|
1072
|
+
break;
|
|
1073
|
+
case "contract":
|
|
1074
|
+
if (fieldMetadata.targetKey) {
|
|
1075
|
+
const targetMetadata = getFieldMetadata(instance, fieldMetadata.targetKey);
|
|
1076
|
+
if ((_a = targetMetadata == null ? void 0 : targetMetadata.options) == null ? void 0 : _a.ttl) {
|
|
1077
|
+
const cacheKey = `call ${instance.chainId}-${instance.address}-${fieldMetadata.targetKey}`;
|
|
1078
|
+
call = () => new Promise(async (resolve) => {
|
|
1079
|
+
const address = await this.cache.wrap(cacheKey, async () => this.Get(entity.abi, instance.chainId, instance.address).read[fieldMetadata.targetKey]());
|
|
1080
|
+
resolve(this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId }));
|
|
1081
|
+
});
|
|
1082
|
+
} else {
|
|
1083
|
+
call = () => (
|
|
1084
|
+
//@ts-ignore
|
|
1085
|
+
this.Get(entity.abi, instance.chainId, instance.address).read[fieldMetadata.targetKey]().then((address) => {
|
|
1086
|
+
return this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId });
|
|
1087
|
+
})
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
break;
|
|
1092
|
+
}
|
|
1093
|
+
} else if (sel[key] === true) {
|
|
1094
|
+
obj[key] = obj[key];
|
|
1063
1095
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1096
|
+
if (call) {
|
|
1097
|
+
if ((_b = fieldMetadata == null ? void 0 : fieldMetadata.options) == null ? void 0 : _b.ttl) {
|
|
1098
|
+
const cacheKey = `call ${instance.chainId}-${instance.address}-${key}-${JSON.stringify(sel[key])}`;
|
|
1099
|
+
promises.push(
|
|
1100
|
+
new Promise(async (resolve) => {
|
|
1101
|
+
const value = await this.cache.wrap(cacheKey, async () => call(), fieldMetadata.options);
|
|
1102
|
+
obj[key] = value;
|
|
1103
|
+
resolve(value);
|
|
1104
|
+
})
|
|
1105
|
+
);
|
|
1106
|
+
} else {
|
|
1107
|
+
promises.push(
|
|
1108
|
+
call().then((value) => {
|
|
1109
|
+
obj[key] = value;
|
|
1110
|
+
})
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1079
1113
|
}
|
|
1080
1114
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1115
|
+
await Promise.all(promises);
|
|
1116
|
+
};
|
|
1117
|
+
await fetchFields(instance, select);
|
|
1118
|
+
results.push(instance);
|
|
1119
|
+
}
|
|
1120
|
+
if (isArrayInput) {
|
|
1121
|
+
return results;
|
|
1122
|
+
} else {
|
|
1123
|
+
return results[0];
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
_AIem.cache = new Cache();
|
|
1129
|
+
_AIem.defaultFuncMap = {
|
|
1130
|
+
totalSupply: { ttl: 15 * 1e3 },
|
|
1131
|
+
symbol: { ttl: 60 * 1e3 },
|
|
1132
|
+
name: { ttl: 60 * 1e3 },
|
|
1133
|
+
decimals: { ttl: 60 * 1e3 },
|
|
1134
|
+
balanceOf: { ttl: 5 * 1e3 }
|
|
1089
1135
|
};
|
|
1090
1136
|
_AIem.utils = {
|
|
1091
1137
|
autoFormat: async ({ value, decimals, chainId, address }) => {
|