@dappworks/kit 0.4.155 → 0.4.157
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-23a1c20b.d.ts → PromiseState-DdfQCVl2.d.ts} +3 -3
- package/dist/aiem.d.mts +7 -4
- package/dist/aiem.mjs +109 -112
- package/dist/aiem.mjs.map +1 -1
- package/dist/{chunk-J5PZWR2P.mjs → chunk-3O7QI47S.mjs} +2 -2
- package/dist/{chunk-SYQNMCVQ.mjs → chunk-5BJM6R2E.mjs} +4 -4
- package/dist/{chunk-WYGQ3Y4R.mjs → chunk-AIZ7XDNV.mjs} +14 -14
- package/dist/chunk-AIZ7XDNV.mjs.map +1 -0
- package/dist/{chunk-ISMCID4L.mjs → chunk-NWJBLIGQ.mjs} +2 -2
- package/dist/{chunk-6F7H4PAA.mjs → chunk-R4SQKVDQ.mjs} +1 -1
- package/dist/{chunk-IDKGZ5T4.mjs → chunk-XSGTWROT.mjs} +7 -7
- package/dist/{chunk-IDKGZ5T4.mjs.map → chunk-XSGTWROT.mjs.map} +1 -1
- package/dist/dev.d.mts +1 -1
- package/dist/dev.mjs +2 -2
- package/dist/experimental.d.mts +2 -2
- package/dist/experimental.mjs +3 -3
- package/dist/form.d.mts +5 -5
- package/dist/form.mjs +3 -3
- package/dist/{index-38be834f.d.ts → index-CUKoRIdy.d.ts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- 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 +3 -3
- package/dist/plugins.mjs +3 -3
- package/dist/{root-766ae985.d.ts → root-C3lZnoCI.d.ts} +1 -1
- package/dist/ui.mjs +3 -3
- package/dist/utils.d.mts +8 -3
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-WYGQ3Y4R.mjs.map +0 -1
- /package/dist/{PaginationState-c19e621a.d.ts → PaginationState-Bmrrw0ky.d.ts} +0 -0
- /package/dist/{chunk-J5PZWR2P.mjs.map → chunk-3O7QI47S.mjs.map} +0 -0
- /package/dist/{chunk-SYQNMCVQ.mjs.map → chunk-5BJM6R2E.mjs.map} +0 -0
- /package/dist/{chunk-ISMCID4L.mjs.map → chunk-NWJBLIGQ.mjs.map} +0 -0
- /package/dist/{chunk-6F7H4PAA.mjs.map → chunk-R4SQKVDQ.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-C3lZnoCI.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<[never]>;
|
|
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<[never]>;
|
|
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
|
@@ -18,6 +18,9 @@ declare class Cache {
|
|
|
18
18
|
kv: TTLCache<string, any>;
|
|
19
19
|
wrap<T>(key: string, fn: () => T | Promise<T>, config?: TTLCache.Options<any, any>): T | Promise<T>;
|
|
20
20
|
}
|
|
21
|
+
type GetOptions = {
|
|
22
|
+
multicall?: boolean;
|
|
23
|
+
};
|
|
21
24
|
declare class AIem<Contracts extends Record<string, Abi>, Chains extends Record<string, Chain>, Addrs extends {
|
|
22
25
|
[K in keyof Contracts]?: {
|
|
23
26
|
[key: string]: `${string}-0x${string}`;
|
|
@@ -69,8 +72,8 @@ declare class AIem<Contracts extends Record<string, Abi>, Chains extends Record<
|
|
|
69
72
|
}>(args: Pick<AIem<Contracts, Chains, Addrs>, "contractMap" | "chainMap" | "nameMap" | "getWallet" | "cache" | "funcMap">): AIem<Contracts, Chains, Addrs>;
|
|
70
73
|
constructor(args?: Pick<AIem<Contracts, Chains, Addrs>, "contractMap" | "chainMap" | "nameMap" | "getWallet" | "cache" | "funcMap">);
|
|
71
74
|
static PubClient(chainId: string): PublicClient<HttpTransport, Chain, any, any>;
|
|
72
|
-
PubClient<C extends keyof Chains>(chainId: C): PublicClient<HttpTransport, Chain, any, any>;
|
|
73
|
-
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>> & {
|
|
75
|
+
PubClient<C extends keyof Chains>(chainId: C, options?: GetOptions): PublicClient<HttpTransport, Chain, any, any>;
|
|
76
|
+
Get<K extends keyof Contracts, C extends keyof Chains, Addr extends `0x${string}`>(contractName: K, chainId: C, address: Addr, options?: GetOptions): GetContractReturnType<Contracts[K], PublicClient<HttpTransport, Chain, any, any>> & {
|
|
74
77
|
encode: GetContractReturnType<Contracts[K], WalletClient<HttpTransport, Chain, Account, any>>["write"];
|
|
75
78
|
};
|
|
76
79
|
getContract({ client, address, abi, }: {
|
|
@@ -82,7 +85,7 @@ declare class AIem<Contracts extends Record<string, Abi>, Chains extends Record<
|
|
|
82
85
|
abi: any;
|
|
83
86
|
}): any;
|
|
84
87
|
static init(): AIem<any, any, any>;
|
|
85
|
-
static Get<TAbi extends Abi = any, ReturnType extends GetContractReturnType<TAbi, WalletClient<Transport, Chain, Account>>>(abi: TAbi, chainId: any, address: any, wallet?: WalletClient): ReturnType & {
|
|
88
|
+
static Get<TAbi extends Abi = any, ReturnType extends GetContractReturnType<TAbi, WalletClient<Transport, Chain, Account>>>(abi: TAbi, chainId: any, address: any, wallet?: WalletClient, options?: GetOptions): ReturnType & {
|
|
86
89
|
encode: ReturnType["write"];
|
|
87
90
|
};
|
|
88
91
|
static getPrice({ chainId, address }: {
|
|
@@ -115,4 +118,4 @@ type QueryReturnType<E, S extends QuerySelect<E>> = {
|
|
|
115
118
|
[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];
|
|
116
119
|
};
|
|
117
120
|
|
|
118
|
-
export { AIem, Cache, Fields, Item, QueryReturnType };
|
|
121
|
+
export { AIem, Cache, Fields, type GetOptions, type Item, type QueryReturnType };
|
package/dist/aiem.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './chunk-7MDKCI65.mjs';
|
|
2
2
|
import { helper } from './chunk-UPGWJHSO.mjs';
|
|
3
3
|
import './chunk-K7LFG5BA.mjs';
|
|
4
|
-
import { __spreadProps, __spreadValues, __objRest } from './chunk-
|
|
4
|
+
import { __spreadProps, __spreadValues, __objRest } from './chunk-R4SQKVDQ.mjs';
|
|
5
5
|
import { createPublicClient, http, getContract, encodeFunctionData } from 'viem';
|
|
6
6
|
import { iotexTestnet, mainnet, iotex, bsc, polygon } 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 =
|
|
377
|
+
var hint = "string" ;
|
|
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);
|
|
386
386
|
}
|
|
387
387
|
function OrdinaryToPrimitive(O, hint) {
|
|
388
|
-
|
|
388
|
+
var valueOf, result; {
|
|
389
389
|
var toString_1 = O.toString;
|
|
390
390
|
if (IsCallable(toString_1)) {
|
|
391
391
|
var result = toString_1.call(O);
|
|
@@ -398,19 +398,6 @@ 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
|
-
}
|
|
414
401
|
}
|
|
415
402
|
throw new TypeError();
|
|
416
403
|
}
|
|
@@ -422,10 +409,7 @@ var Reflect2;
|
|
|
422
409
|
}
|
|
423
410
|
function ToPropertyKey(argument) {
|
|
424
411
|
var key = ToPrimitive(
|
|
425
|
-
argument
|
|
426
|
-
3
|
|
427
|
-
/* String */
|
|
428
|
-
);
|
|
412
|
+
argument);
|
|
429
413
|
if (IsSymbol(key))
|
|
430
414
|
return key;
|
|
431
415
|
return ToString(key);
|
|
@@ -955,26 +939,28 @@ var _AIem = class _AIem {
|
|
|
955
939
|
static PubClient(chainId) {
|
|
956
940
|
return this.init().PubClient(chainId);
|
|
957
941
|
}
|
|
958
|
-
PubClient(chainId) {
|
|
959
|
-
return this._cache.wrap(`publicClient-${String(chainId)}`, () => {
|
|
960
|
-
return createPublicClient({
|
|
942
|
+
PubClient(chainId, options = { multicall: true }) {
|
|
943
|
+
return this._cache.wrap(`publicClient-${String(chainId)}-${options == null ? void 0 : options.multicall}`, () => {
|
|
944
|
+
return createPublicClient(__spreadProps(__spreadValues({
|
|
961
945
|
//@ts-ignore
|
|
962
|
-
chain: this.chainMap[chainId]
|
|
946
|
+
chain: this.chainMap[chainId]
|
|
947
|
+
}, (options == null ? void 0 : options.multicall) ? {
|
|
963
948
|
batch: {
|
|
964
949
|
multicall: true
|
|
965
|
-
}
|
|
950
|
+
}
|
|
951
|
+
} : {}), {
|
|
966
952
|
//@ts-ignore
|
|
967
953
|
transport: http()
|
|
968
|
-
});
|
|
954
|
+
}));
|
|
969
955
|
});
|
|
970
956
|
}
|
|
971
957
|
//@ts-ignore
|
|
972
|
-
Get(contractName, chainId, address) {
|
|
958
|
+
Get(contractName, chainId, address, options = { multicall: true }) {
|
|
973
959
|
const wallet = this.getWallet ? this.getWallet() : null;
|
|
974
960
|
const cacheKey = `contract ${chainId}-${address}-${wallet ? wallet.account.address : null}`;
|
|
975
961
|
return this._cache.wrap(cacheKey, () => {
|
|
976
962
|
const contract = this.contractMap[contractName];
|
|
977
|
-
const pubClient = this.PubClient(chainId);
|
|
963
|
+
const pubClient = this.PubClient(chainId, options);
|
|
978
964
|
return this.getContract({
|
|
979
965
|
client: {
|
|
980
966
|
//@ts-ignore
|
|
@@ -1042,11 +1028,11 @@ var _AIem = class _AIem {
|
|
|
1042
1028
|
return globalThis.aiem;
|
|
1043
1029
|
}
|
|
1044
1030
|
//@ts-ignore
|
|
1045
|
-
static Get(abi, chainId, address, wallet) {
|
|
1031
|
+
static Get(abi, chainId, address, wallet, options = { multicall: true }) {
|
|
1046
1032
|
const aiem = this.init();
|
|
1047
1033
|
const cacheKey = `contract ${chainId}-${address}-${wallet ? wallet.account.address : null}`;
|
|
1048
1034
|
return aiem._cache.wrap(cacheKey, () => {
|
|
1049
|
-
const pubClient = aiem.PubClient(chainId);
|
|
1035
|
+
const pubClient = aiem.PubClient(chainId, options);
|
|
1050
1036
|
return aiem.getContract({
|
|
1051
1037
|
client: {
|
|
1052
1038
|
//@ts-ignore
|
|
@@ -1080,94 +1066,105 @@ var _AIem = class _AIem {
|
|
|
1080
1066
|
}
|
|
1081
1067
|
static Query(entity, select) {
|
|
1082
1068
|
return async (entities) => {
|
|
1083
|
-
const results = [];
|
|
1084
1069
|
const isArrayInput = Array.isArray(entities);
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
const
|
|
1093
|
-
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
call
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
break;
|
|
1107
|
-
case "write":
|
|
1108
|
-
obj[key] = encodeFunctionData({
|
|
1109
|
-
//@ts-ignore
|
|
1110
|
-
abi: entity.abi,
|
|
1111
|
-
functionName: key,
|
|
1112
|
-
args: sel[key]
|
|
1113
|
-
});
|
|
1114
|
-
break;
|
|
1115
|
-
case "custom":
|
|
1116
|
-
call = () => obj[key](...Array.isArray(sel[key]) ? sel[key] : []);
|
|
1117
|
-
break;
|
|
1118
|
-
case "contract":
|
|
1119
|
-
const targetMetadata = getFieldMetadata(instance, fieldMetadata.targetKey);
|
|
1120
|
-
if (typeof fieldMetadata.targetKey == "string") {
|
|
1121
|
-
if ((_a = targetMetadata == null ? void 0 : targetMetadata.options) == null ? void 0 : _a.ttl) {
|
|
1122
|
-
const cacheKey = `call ${instance.chainId}-${instance.address}-${fieldMetadata.targetKey}`;
|
|
1123
|
-
call = () => new Promise(async (resolve) => {
|
|
1124
|
-
const address = await this.cache.wrap(cacheKey, async () => this.Get(entity.abi, instance.chainId, instance.address).read[fieldMetadata.targetKey]());
|
|
1125
|
-
resolve(this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId }));
|
|
1126
|
-
});
|
|
1070
|
+
try {
|
|
1071
|
+
const results = [];
|
|
1072
|
+
if (!isArrayInput) {
|
|
1073
|
+
entities = [entities];
|
|
1074
|
+
}
|
|
1075
|
+
for (const entityData of entities) {
|
|
1076
|
+
const instance = Object.assign(new entity(), entityData);
|
|
1077
|
+
const fetchFields = async (obj, sel) => {
|
|
1078
|
+
var _a, _b;
|
|
1079
|
+
const promises = [];
|
|
1080
|
+
for (const key in sel) {
|
|
1081
|
+
const fieldMetadata = getFieldMetadata(obj, key);
|
|
1082
|
+
let call;
|
|
1083
|
+
const enableMulticall = entity.multicall == false ? false : true;
|
|
1084
|
+
if (sel[key] == false) {
|
|
1085
|
+
call = async () => null;
|
|
1086
|
+
} else if (fieldMetadata) {
|
|
1087
|
+
switch (fieldMetadata.type) {
|
|
1088
|
+
case "read":
|
|
1089
|
+
if (Array.isArray(sel[key])) {
|
|
1090
|
+
call = () => this.Get(entity.abi, instance.chainId, instance.address, null, { multicall: enableMulticall }).read[key](sel[key]);
|
|
1127
1091
|
} else {
|
|
1128
|
-
call = () => (
|
|
1129
|
-
//@ts-ignore
|
|
1130
|
-
this.Get(entity.abi, instance.chainId, instance.address).read[fieldMetadata.targetKey]().then((address) => {
|
|
1131
|
-
return this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId });
|
|
1132
|
-
})
|
|
1133
|
-
);
|
|
1092
|
+
call = () => this.Get(entity.abi, instance.chainId, instance.address, null, { multicall: enableMulticall }).read[key]();
|
|
1134
1093
|
}
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1094
|
+
break;
|
|
1095
|
+
case "write":
|
|
1096
|
+
obj[key] = encodeFunctionData({
|
|
1097
|
+
//@ts-ignore
|
|
1098
|
+
abi: entity.abi,
|
|
1099
|
+
functionName: key,
|
|
1100
|
+
args: sel[key]
|
|
1138
1101
|
});
|
|
1139
|
-
|
|
1140
|
-
|
|
1102
|
+
break;
|
|
1103
|
+
case "custom":
|
|
1104
|
+
call = () => obj[key](...Array.isArray(sel[key]) ? sel[key] : []);
|
|
1105
|
+
break;
|
|
1106
|
+
case "contract":
|
|
1107
|
+
const targetMetadata = getFieldMetadata(instance, fieldMetadata.targetKey);
|
|
1108
|
+
if (typeof fieldMetadata.targetKey == "string") {
|
|
1109
|
+
if ((_a = targetMetadata == null ? void 0 : targetMetadata.options) == null ? void 0 : _a.ttl) {
|
|
1110
|
+
const cacheKey = `call ${instance.chainId}-${instance.address}-${fieldMetadata.targetKey}`;
|
|
1111
|
+
call = () => new Promise(async (resolve) => {
|
|
1112
|
+
const address = await this.cache.wrap(cacheKey, async () => this.Get(entity.abi, instance.chainId, instance.address, null, { multicall: enableMulticall }).read[fieldMetadata.targetKey]());
|
|
1113
|
+
resolve(this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId }));
|
|
1114
|
+
});
|
|
1115
|
+
} else {
|
|
1116
|
+
call = () => (
|
|
1117
|
+
//@ts-ignore
|
|
1118
|
+
this.Get(entity.abi, instance.chainId, instance.address, null, { multicall: enableMulticall }).read[fieldMetadata.targetKey]().then((address) => {
|
|
1119
|
+
return this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId });
|
|
1120
|
+
})
|
|
1121
|
+
);
|
|
1122
|
+
}
|
|
1123
|
+
} else {
|
|
1124
|
+
call = () => fieldMetadata.targetKey(instance).then((args) => {
|
|
1125
|
+
return Array.isArray(args) ? this.QueryMany(fieldMetadata.entity(), sel[key])(args) : this.Query(fieldMetadata.entity(), sel[key])(args);
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
break;
|
|
1129
|
+
default:
|
|
1130
|
+
break;
|
|
1131
|
+
}
|
|
1141
1132
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1133
|
+
if (call) {
|
|
1134
|
+
if ((_b = fieldMetadata == null ? void 0 : fieldMetadata.options) == null ? void 0 : _b.ttl) {
|
|
1135
|
+
const cacheKey = `call ${instance.chainId}-${instance.address}-${key}-${JSON.stringify(sel[key])}`;
|
|
1136
|
+
promises.push(
|
|
1137
|
+
new Promise(async (resolve) => {
|
|
1138
|
+
const value = await this.cache.wrap(cacheKey, async () => call(), fieldMetadata.options);
|
|
1139
|
+
obj[key] = value;
|
|
1140
|
+
resolve(value);
|
|
1141
|
+
})
|
|
1142
|
+
);
|
|
1143
|
+
} else {
|
|
1144
|
+
promises.push(
|
|
1145
|
+
call().then((value) => {
|
|
1146
|
+
obj[key] = value;
|
|
1147
|
+
})
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1159
1150
|
}
|
|
1160
1151
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1152
|
+
await Promise.all(promises);
|
|
1153
|
+
};
|
|
1154
|
+
await fetchFields(instance, select);
|
|
1155
|
+
results.push(instance);
|
|
1156
|
+
}
|
|
1157
|
+
if (isArrayInput) {
|
|
1158
|
+
return results;
|
|
1159
|
+
} else {
|
|
1160
|
+
return results[0];
|
|
1161
|
+
}
|
|
1162
|
+
} catch (error) {
|
|
1163
|
+
if (isArrayInput) {
|
|
1164
|
+
return [];
|
|
1165
|
+
} else {
|
|
1166
|
+
return null;
|
|
1167
|
+
}
|
|
1171
1168
|
}
|
|
1172
1169
|
};
|
|
1173
1170
|
}
|