@dappworks/kit 0.4.118 → 0.4.119

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/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?: undefined;
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 QueryResult<E, S extends QuerySelect<E>> = E extends Array<any> ? Promise<Array<QueryReturnType<E[number], S>>> : E extends object ? Promise<QueryReturnType<E, S>> : never;
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]> | true : true;
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, type QueryResult, type QueryReturnType, type QuerySelect };
116
+ export { AIem, Cache, Fields, type Item, type QueryReturnType };
package/dist/aiem.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import './chunk-7MDKCI65.mjs';
2
- import { helper } from './chunk-46XF5IRX.mjs';
2
+ import { helper } from './chunk-Q3AD5RHQ.mjs';
3
3
  import './chunk-MGU3KYGC.mjs';
4
4
  import { __spreadProps, __spreadValues, __objRest } from './chunk-R4SQKVDQ.mjs';
5
5
  import { createPublicClient, http, getContract, encodeFunctionData } from 'viem';
@@ -856,29 +856,35 @@ var _AIem = class _AIem {
856
856
  };
857
857
  this.funcMap = {};
858
858
  this.Set(args);
859
- this.contracts = new Proxy({}, {
860
- //@ts-ignore
861
- get: (target, contractName) => {
862
- if (target[contractName])
859
+ this.contracts = new Proxy(
860
+ {},
861
+ {
862
+ //@ts-ignore
863
+ get: (target, contractName) => {
864
+ if (target[contractName])
865
+ return target[contractName];
866
+ if (!this.nameMap[contractName]) {
867
+ throw new Error(`Contract ${String(contractName)} not found`);
868
+ }
869
+ target[contractName] = new Proxy(
870
+ {},
871
+ {
872
+ //@ts-ignore
873
+ get: (innerTarget, contractAlias) => {
874
+ var _a;
875
+ const addressStr = (_a = this.nameMap[contractName]) == null ? void 0 : _a[contractAlias];
876
+ if (!addressStr) {
877
+ throw new Error(`Alias ${String(contractAlias)} for contract ${String(contractName)} not found`);
878
+ }
879
+ const [chainId, address] = addressStr.split("-");
880
+ return this.Get(contractName, String(chainId), address);
881
+ }
882
+ }
883
+ );
863
884
  return target[contractName];
864
- if (!this.nameMap[contractName]) {
865
- throw new Error(`Contract ${String(contractName)} not found`);
866
885
  }
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
886
  }
881
- });
887
+ );
882
888
  }
883
889
  get _cache() {
884
890
  return _AIem.cache;
@@ -948,9 +954,13 @@ var _AIem = class _AIem {
948
954
  const methodConfig = (_a = this.funcMap) == null ? void 0 : _a[funcName];
949
955
  const cacheKey = `call ${client.public.chain.id}-${address}-${funcName}-${JSON.stringify(args)}`;
950
956
  if (methodConfig) {
951
- return this.cache.wrap(cacheKey, () => {
952
- return target[funcName](...args);
953
- }, methodConfig);
957
+ return this.cache.wrap(
958
+ cacheKey,
959
+ () => {
960
+ return target[funcName](...args);
961
+ },
962
+ methodConfig
963
+ );
954
964
  }
955
965
  return target[funcName](...args);
956
966
  };
@@ -991,101 +1001,121 @@ var _AIem = class _AIem {
991
1001
  });
992
1002
  }
993
1003
  static async getPrice({ chainId = "4689", address }) {
994
- const priceMap = await this.cache.wrap(`token-price`, async () => {
995
- const res = await (await fetch("https://api.iopay.me/api/rest/price")).json();
996
- return Object.values(res).flat().reduce((p, c) => {
997
- p[`${4689}-${c.platforms.toLowerCase()}`] = c.current_price;
998
- return p;
999
- }, {});
1000
- }, { ttl: 1e3 * 60 });
1004
+ const priceMap = await this.cache.wrap(
1005
+ `token-price`,
1006
+ async () => {
1007
+ const res = await (await fetch("https://api.iopay.me/api/rest/price")).json();
1008
+ return Object.values(res).flat().reduce((p, c) => {
1009
+ p[`${4689}-${c.platforms.toLowerCase()}`] = c.current_price;
1010
+ return p;
1011
+ }, {});
1012
+ },
1013
+ { ttl: 1e3 * 60 }
1014
+ );
1001
1015
  return priceMap[`${chainId}-${address}`];
1002
1016
  }
1003
- };
1004
- _AIem.cache = new Cache();
1005
- _AIem.defaultFuncMap = {
1006
- "totalSupply": { ttl: 15 * 1e3 },
1007
- "symbol": { ttl: 60 * 1e3 },
1008
- "name": { ttl: 60 * 1e3 },
1009
- "decimals": { ttl: 60 * 1e3 },
1010
- "balanceOf": { ttl: 5 * 1e3 }
1011
- };
1012
- _AIem.Query = (entity, select) => {
1013
- return async (entities) => {
1014
- const results = [];
1015
- const isArrayInput = Array.isArray(entities);
1016
- if (!isArrayInput) {
1017
- entities = [entities];
1018
- }
1019
- for (const entityData of entities) {
1020
- const instance = Object.assign(new entity(), entityData);
1021
- const fetchFields = async (obj, sel) => {
1022
- var _a, _b;
1023
- const promises = [];
1024
- for (const key in sel) {
1025
- const fieldMetadata = getFieldMetadata(obj, key);
1026
- let call;
1027
- if (fieldMetadata) {
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
- });
1017
+ static QueryMany(entity, select) {
1018
+ return async (_entities) => {
1019
+ return this.Query(entity, select)(_entities);
1020
+ };
1021
+ }
1022
+ static Query(entity, select) {
1023
+ return async (entities) => {
1024
+ const results = [];
1025
+ const isArrayInput = Array.isArray(entities);
1026
+ if (!isArrayInput) {
1027
+ entities = [entities];
1028
+ }
1029
+ for (const entityData of entities) {
1030
+ const instance = Object.assign(new entity(), entityData);
1031
+ const fetchFields = async (obj, sel) => {
1032
+ var _a, _b;
1033
+ const promises = [];
1034
+ for (const key in sel) {
1035
+ const fieldMetadata = getFieldMetadata(obj, key);
1036
+ let call;
1037
+ if (fieldMetadata) {
1038
+ switch (fieldMetadata.type) {
1039
+ case "read":
1040
+ if (Array.isArray(sel[key])) {
1041
+ call = () => this.Get(entity.abi, instance.chainId, instance.address).read[key](sel[key]);
1056
1042
  } else {
1057
- call = () => _AIem.Get(entity.abi, instance.chainId, instance.address).read[fieldMetadata.targetKey]().then((address) => {
1058
- return _AIem.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId });
1059
- });
1043
+ call = () => this.Get(entity.abi, instance.chainId, instance.address).read[key]();
1060
1044
  }
1061
- }
1062
- break;
1045
+ break;
1046
+ case "write":
1047
+ obj[key] = encodeFunctionData({
1048
+ //@ts-ignore
1049
+ abi: entity.abi,
1050
+ functionName: key,
1051
+ args: sel[key]
1052
+ });
1053
+ break;
1054
+ case "custom":
1055
+ call = () => obj[key](...Array.isArray(sel[key]) ? sel[key] : []);
1056
+ break;
1057
+ case "contract":
1058
+ if (fieldMetadata.targetKey) {
1059
+ const targetMetadata = getFieldMetadata(instance, fieldMetadata.targetKey);
1060
+ if ((_a = targetMetadata == null ? void 0 : targetMetadata.options) == null ? void 0 : _a.ttl) {
1061
+ const cacheKey = `call ${instance.chainId}-${instance.address}-${fieldMetadata.targetKey}`;
1062
+ call = () => new Promise(async (resolve) => {
1063
+ const address = await this.cache.wrap(cacheKey, async () => this.Get(entity.abi, instance.chainId, instance.address).read[fieldMetadata.targetKey]());
1064
+ resolve(this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId }));
1065
+ });
1066
+ } else {
1067
+ call = () => (
1068
+ //@ts-ignore
1069
+ this.Get(entity.abi, instance.chainId, instance.address).read[fieldMetadata.targetKey]().then((address) => {
1070
+ return this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId });
1071
+ })
1072
+ );
1073
+ }
1074
+ }
1075
+ break;
1076
+ }
1077
+ } else if (sel[key] === true) {
1078
+ obj[key] = obj[key];
1063
1079
  }
1064
- } else if (sel[key] === true) {
1065
- obj[key] = obj[key];
1066
- }
1067
- if (call) {
1068
- if ((_b = fieldMetadata == null ? void 0 : fieldMetadata.options) == null ? void 0 : _b.ttl) {
1069
- const cacheKey = `call ${instance.chainId}-${instance.address}-${key}-${JSON.stringify(sel[key])}`;
1070
- promises.push(new Promise(async (resolve) => {
1071
- const value = await _AIem.cache.wrap(cacheKey, async () => call(), fieldMetadata.options);
1072
- obj[key] = value;
1073
- resolve(value);
1074
- }));
1075
- } else {
1076
- promises.push(call().then((value) => {
1077
- obj[key] = value;
1078
- }));
1080
+ if (call) {
1081
+ if ((_b = fieldMetadata == null ? void 0 : fieldMetadata.options) == null ? void 0 : _b.ttl) {
1082
+ const cacheKey = `call ${instance.chainId}-${instance.address}-${key}-${JSON.stringify(sel[key])}`;
1083
+ promises.push(
1084
+ new Promise(async (resolve) => {
1085
+ const value = await this.cache.wrap(cacheKey, async () => call(), fieldMetadata.options);
1086
+ obj[key] = value;
1087
+ resolve(value);
1088
+ })
1089
+ );
1090
+ } else {
1091
+ promises.push(
1092
+ call().then((value) => {
1093
+ obj[key] = value;
1094
+ })
1095
+ );
1096
+ }
1079
1097
  }
1080
1098
  }
1081
- }
1082
- await Promise.all(promises);
1083
- };
1084
- await fetchFields(instance, select);
1085
- results.push(instance);
1086
- }
1087
- return isArrayInput ? results : results[0];
1088
- };
1099
+ await Promise.all(promises);
1100
+ };
1101
+ await fetchFields(instance, select);
1102
+ results.push(instance);
1103
+ }
1104
+ if (isArrayInput) {
1105
+ return results;
1106
+ } else {
1107
+ return results[0];
1108
+ }
1109
+ };
1110
+ }
1111
+ };
1112
+ _AIem.cache = new Cache();
1113
+ _AIem.defaultFuncMap = {
1114
+ totalSupply: { ttl: 15 * 1e3 },
1115
+ symbol: { ttl: 60 * 1e3 },
1116
+ name: { ttl: 60 * 1e3 },
1117
+ decimals: { ttl: 60 * 1e3 },
1118
+ balanceOf: { ttl: 5 * 1e3 }
1089
1119
  };
1090
1120
  _AIem.utils = {
1091
1121
  autoFormat: async ({ value, decimals, chainId, address }) => {
package/dist/aiem.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../aiem.ts","../../../node_modules/reflect-metadata/Reflect.js","../lib/decorators.ts"],"names":["Reflect","hasOwn","MapIterator","Map","Set","WeakMap"],"mappings":";;;;;;;;;;;;AAAA,SAAiD,oBAAoB,aAAa,MAAwE,0BAA0B;AAEpL,SAAS,OAAO,SAAS,KAAK,SAAS,oBAAqB;AAC5D,OAAO,cAAc;;;ACWrB,IAAIA;AAAA,CACH,SAAUA,UAAS;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S,SAAS,QAAQ,YAAY,EAAE,CAAC;AAC7E,UAAM,MAAM,IAAI,UAAU,KAAK,YAAY,EAAE,aAAa,SAAS,CAAC,EAAE,QAAQ,CAAC;AAC/E,WAAO,iCAAK,OAAL,EAAW,IAAI;AAAA,EACxB;AACF;AA7VK,IAAM,OAAN","sourcesContent":["import { type Chain, type GetContractReturnType, createPublicClient, getContract, http, type Abi, PublicClient, HttpTransport, WalletClient, AbiFunction, encodeFunctionData } from 'viem'\nimport md5 from \"md5\"\nimport { iotex, mainnet, bsc, polygon, iotexTestnet, } from 'viem/chains'\nimport TTLCache from '@isaacs/ttlcache'\nimport { ClassType } from \"./lib/interface\"\nimport { Fields, getFieldMetadata } from \"./lib/decorators\"\nimport { helper } from './utils'\nimport BigNumber from 'bignumber.js'\n\n//@ts-ignore\nmainnet.rpcUrls.default.http = ['https://rpc.ankr.com/eth']\n//@ts-ignore\nmainnet.rpcUrls.default.webSocket = [\"wss://ethereum-rpc.publicnode.com\"]\n\n\n\n\nexport { Fields } from \"./lib/decorators\"\n\nexport class Cache {\n kv = new TTLCache<string, any>({ max: 10000, ttl: 1000 * 60, });\n\n wrap<T>(key: string, fn: () => T | Promise<T>, config: TTLCache.Options<any, any> = {}): T | Promise<T> {\n if (this.kv.has(key)) {\n // console.log(`load ${key} from cache`)\n return this.kv.get(key);\n }\n\n const result = fn();\n if (result instanceof Promise) {\n const promiseResult = result.then(res => {\n this.kv.set(key, res, config);\n return res;\n });\n this.kv.set(key, promiseResult, config);\n return promiseResult;\n } else {\n this.kv.set(key, result, config);\n return result;\n }\n }\n}\n\n\nexport class AIem<Contracts extends Record<string, Abi>, Chains extends Record<string, Chain>, Addrs extends { [K in keyof Contracts]?: { [key: string]: `${string}-0x${string}` } }> {\n static cache?: Cache = new Cache()\n cache?: Cache = new Cache()\n contractMap?: Contracts\n //@ts-ignore\n chainMap?: Chains = {\n [iotex.id]: iotex,\n [mainnet.id]: mainnet,\n [bsc.id]: bsc,\n [polygon.id]: polygon,\n [iotexTestnet.id]: iotexTestnet,\n }\n nameMap?: Addrs\n contracts: {\n [K in keyof Addrs & keyof Contracts]: {\n //@ts-ignore\n [KK in keyof Addrs[K]]: GetContractReturnType<Contracts[K], PublicClient<HttpTransport, Chain, any, any>, any, any>\n }\n }\n static defaultFuncMap = {\n \"totalSupply\": { ttl: 15 * 1000 },\n \"symbol\": { ttl: 60 * 1000 },\n \"name\": { ttl: 60 * 1000 },\n \"decimals\": { ttl: 60 * 1000 },\n \"balanceOf\": { ttl: 5 * 1000 }\n }\n funcMap?: { [key: string]: { ttl?: number } } = {}\n\n\n get _cache() {\n return AIem.cache\n }\n\n\n //@ts-ignore\n getWallet?: () => WalletClient\n\n static Set<Contracts extends Record<string, Abi>, Chains extends Record<string, Chain>, Addrs extends { [K in keyof Contracts]?: { [key: string]: `${string}-0x${string}` } }>(args: Pick<AIem<Contracts, Chains, Addrs>, \"contractMap\" | \"chainMap\" | \"nameMap\" | \"getWallet\" | \"cache\" | \"funcMap\">) {\n return this.init().Set(args)\n }\n\n Set<Contracts extends Record<string, Abi>, Chains extends Record<string, Chain>, Addrs extends { [K in keyof Contracts]?: { [key: string]: `${string}-0x${string}` } }>(args: Pick<AIem<Contracts, Chains, Addrs>, \"contractMap\" | \"chainMap\" | \"nameMap\" | \"getWallet\" | \"cache\" | \"funcMap\">): AIem<Contracts, Chains, Addrs> {\n const { chainMap = {}, contractMap = {}, funcMap, ...rest } = args || {}\n //@ts-ignore\n this.chainMap = Object.assign({}, this.chainMap || {}, chainMap)\n //@ts-ignore\n this.contractMap = Object.assign({}, this.contractMap || {}, contractMap)\n //@ts-ignore\n this.funcMap = Object.assign({}, this.funcMap || {}, funcMap)\n\n Object.assign(this, rest)\n return this as any\n }\n\n\n constructor(args: Pick<AIem<Contracts, Chains, Addrs>, \"contractMap\" | \"chainMap\" | \"nameMap\" | \"getWallet\" | \"cache\" | \"funcMap\"> = {}) {\n\n\n this.Set(args)\n\n this.contracts = new Proxy({}, {\n //@ts-ignore\n get: (target: any, contractName: keyof Addrs & keyof Contracts) => {\n if (target[contractName]) return target[contractName]\n\n if (!this.nameMap[contractName]) {\n throw new Error(`Contract ${String(contractName)} not found`);\n }\n\n target[contractName] = new Proxy({}, {\n //@ts-ignore\n get: (innerTarget: any, contractAlias: keyof Addrs[keyof Addrs]) => {\n const addressStr = this.nameMap[contractName]?.[contractAlias];\n if (!addressStr) {\n throw new Error(`Alias ${String(contractAlias)} for contract ${String(contractName)} not found`);\n }\n const [chainId, address] = addressStr.split('-');\n\n\n // Assuming getContractInstance is a function that retrieves a contract instance\n return this.Get(contractName, String(chainId), address as `0x${string}`);\n }\n });\n return target[contractName];\n }\n }) as any;\n\n }\n\n // WsClient<C extends keyof Chains>(chainId: C): PublicClient<WebSocketTransport, Chain, any, any> {\n // //@ts-ignore\n // return this.cache.wrap(`wsClient-${String(chainId)}`, () => {\n // // const wsUrl = this.chainMap[chainId]?.rpcUrls?.default?.webSocket?.[0]\n // // if (!wsUrl) throw new Error(`rpcUrls.default.webSocket[0] is not defined for chainId ${String(chainId)}`)\n // // //@ts-ignore\n // return createPublicClient({\n // //@ts-ignore\n // chain: this.chainMap[chainId],\n // transport: webSocket()\n // }) as PublicClient<WebSocketTransport, Chain, any, any>\n // })\n // }\n\n\n PubClient<C extends keyof Chains>(chainId: C): PublicClient<HttpTransport, Chain, any, any> {\n //@ts-ignore\n return this._cache.wrap(`publicClient-${String(chainId)}`, () => {\n //@ts-ignore\n return createPublicClient({\n //@ts-ignore\n chain: this.chainMap[chainId],\n transport: http()\n }) as PublicClient<HttpTransport, Chain, any, any>\n })\n }\n\n\n //@ts-ignore\n 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>> {\n const wallet = this.getWallet ? this.getWallet() : null\n //@ts-ignore\n const cacheKey = `contract ${chainId}-${address}-${wallet ? wallet.account.address : null}`\n return this._cache.wrap(cacheKey, () => {\n //@ts-ignore\n const contract = this.contractMap[contractName];\n //@ts-ignore\n const pubClient = this.PubClient(chainId)\n\n //@ts-ignore\n return this.getContract({\n client: {\n //@ts-ignore\n public: pubClient,\n //@ts-ignore\n wallet\n },\n address,\n abi: contract\n })\n }) as any\n }\n\n getContract({\n client,\n address,\n abi\n }: {\n client: {\n public: PublicClient<HttpTransport, Chain, any, any>\n wallet?: WalletClient\n }\n address: `0x${string}`\n abi: any,\n }) {\n const handler = {\n get: (target: any, funcName: any) => {\n if (typeof target[funcName] === 'function') {\n return async (...args: any[]) => {\n const methodConfig = this.funcMap?.[funcName as string];\n // const cacheKey = `method:${client.public.chain.id}-${address}-${String(funcName)}-${JSON.stringify(args)}`;\n const cacheKey = `call ${client.public.chain.id}-${address}-${funcName}-${JSON.stringify(args)}`\n\n\n if (methodConfig) {\n return this.cache.wrap(cacheKey, () => {\n return target[funcName](...args);\n }, methodConfig);\n }\n\n return target[funcName](...args);\n };\n }\n return new Proxy(target[funcName], handler)\n }\n }\n\n //@ts-ignore\n const contract = getContract({\n //@ts-ignore\n client,\n address,\n abi\n })\n return new Proxy(contract, handler) as any\n }\n\n\n static init(): AIem<any, any, any> {\n if (!globalThis.aiem) {\n //@ts-ignore\n globalThis.aiem = new AIem();\n }\n\n return globalThis.aiem;\n }\n\n //@ts-ignore\n static Get<TAbi extends Abi = any>(abi: TAbi, chainId: any, address: any, wallet?: WalletClient): GetContractReturnType<TAbi, PublicClient<HttpTransport, Chain, any, any>> {\n const aiem = this.init()\n\n const cacheKey = `contract ${chainId}-${address}-${wallet ? wallet.account.address : null}`\n return aiem._cache.wrap(cacheKey, () => {\n //@ts-ignore\n const pubClient = aiem.PubClient(chainId)\n\n //@ts-ignore\n return aiem.getContract({\n client: {\n //@ts-ignore\n public: pubClient,\n //@ts-ignore\n wallet\n },\n address,\n abi\n })\n }) as any\n }\n\n static Query = <E, S extends QuerySelect<E>>(\n entity: ClassType<E>,\n select: S\n ): ((entities: Partial<E> | Partial<E>[]) => Promise<QueryResult<E, S>>) => {\n return async (entities: Partial<E> | Partial<E>[]): Promise<QueryResult<E, S>> => {\n const results: Array<QueryReturnType<E, S>> = [];\n const isArrayInput = Array.isArray(entities);\n\n if (!isArrayInput) {\n //@ts-ignore\n entities = [entities];\n }\n //@ts-ignore\n for (const entityData of entities) {\n const instance = Object.assign(new entity(), entityData);\n // const result: any = {};\n\n const fetchFields = async (obj: any, sel: any) => {\n const promises = [];\n for (const key in sel) {\n // return console.log(key, getFieldMetadata(obj, key))\n // Check if the property is annotated with @Fields.read(), @Fields.custom(), or @Fields.contract()\n const fieldMetadata = getFieldMetadata(obj, key);\n\n let call: any\n // console.log(key, fieldMetadata, instance)\n if (fieldMetadata) {\n switch (fieldMetadata.type) {\n case 'read':\n if (Array.isArray(sel[key])) {\n //@ts-ignore\n call = () => this.Get(entity.abi, instance.chainId, instance.address).read[key](sel[key])\n } else {\n //@ts-ignore\n call = () => this.Get(entity.abi, instance.chainId, instance.address).read[key]()\n }\n break\n case 'write':\n obj[key] = encodeFunctionData({\n //@ts-ignore\n abi: entity.abi,\n functionName: key,\n args: sel[key],\n })\n break\n case 'custom':\n call = () => obj[key](...(Array.isArray(sel[key]) ? sel[key] : []))\n break;\n case 'contract':\n // console.log(fieldMetadata)\n if (fieldMetadata.targetKey) {\n const targetMetadata = getFieldMetadata(instance, fieldMetadata.targetKey);\n\n if (targetMetadata?.options?.ttl) {\n //@ts-ignore\n const cacheKey = `call ${instance.chainId}-${instance.address}-${fieldMetadata.targetKey}`\n //@ts-ignore\n call = () => new Promise(async resolve => {\n //@ts-ignore\n const address = await this.cache.wrap(cacheKey, async () => this.Get(entity.abi, instance.chainId, instance.address).read[fieldMetadata.targetKey]())\n //@ts-ignore\n resolve(this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId }))\n })\n\n\n } else {\n //@ts-ignore\n call = () => this.Get(entity.abi, instance.chainId, instance.address).read[fieldMetadata.targetKey]().then((address: any) => {\n // console.log({ address, sel: sel[key] })\n //@ts-ignore\n return this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId })\n })\n }\n }\n break;\n default:\n break;\n }\n } else if (sel[key] === true) {\n obj[key] = obj[key];\n }\n\n if (call) {\n if (fieldMetadata?.options?.ttl) {\n //@ts-ignore\n const cacheKey = `call ${instance.chainId}-${instance.address}-${key}-${JSON.stringify(sel[key])}`\n promises.push(new Promise(async (resolve) => {\n const value = await this.cache.wrap(cacheKey, async () => call(), fieldMetadata.options)\n obj[key] = value\n resolve(value)\n }))\n } else {\n promises.push(call().then(value => {\n obj[key] = value\n }))\n }\n }\n }\n\n await Promise.all(promises);\n };\n\n await fetchFields(instance, select);\n //@ts-ignore\n results.push(instance);\n }\n\n return isArrayInput ? results as any : results[0] as any;\n\n };\n };\n\n static async getPrice({ chainId = \"4689\", address }: { chainId?: string, address: string }) {\n const priceMap = await this.cache.wrap(`token-price`, async () => {\n const res = await (await fetch(\"https://api.iopay.me/api/rest/price\")).json()\n return Object.values(res).flat().reduce((p, c: { platforms: string, current_price: number }) => {\n p[`${4689}-${c.platforms.toLowerCase()}`] = c.current_price\n return p\n }, {})\n }, { ttl: 1000 * 60 })\n return priceMap[`${chainId}-${address}`]\n }\n\n static utils = {\n autoFormat: async ({ value, decimals, chainId, address }: { value: string, decimals: number, chainId: string, address: string }) => {\n const wrap = helper.number.warpBigNumber(value, decimals, { format: '0,0.000000', fallback: '' })\n const price = await this.getPrice({ chainId, address: address.toLowerCase() })\n const usd = new BigNumber(wrap.originFormat).multipliedBy(price || 1).toFixed(2)\n return { ...wrap, usd }\n }\n }\n}\n\nexport type QueryResult<E, S extends QuerySelect<E>> =\n E extends Array<any> ? Promise<Array<QueryReturnType<E[number], S>>> :\n E extends object ? Promise<QueryReturnType<E, S>> :\n never;\n\nexport type QuerySelect<E> = {\n [K in keyof E]?:\n E[K] extends (...args: any[]) => any ? Parameters<E[K]> | true :\n E[K] extends object ? QuerySelect<E[K]> | true\n : true;\n};\n\n\nexport type QueryReturnType<E, S extends QuerySelect<E>> = {\n [K in keyof E]:\n K extends keyof S ?\n E[K] extends (...args: any[]) => any ? Awaited<ReturnType<E[K]>> :\n E[K] extends object ? S[K] extends object ? QueryReturnType<E[K], S[K]> :\n E[K] : E[K]\n : E[K]\n};\n// export type QueryReturnType<E, S extends QuerySelect<E>> = {\n// [K in keyof S]:\n// K extends keyof E ?\n// E[K] extends (...args: any[]) => any ? Awaited<ReturnType<E[K]>> :\n// E[K] extends object ? S[K] extends object ? K extends keyof E ? QueryReturnType<E[K], S[K]> :\n// E[K] : E[K] : E[K]\n// // S[K] extends true ? K extends keyof E ? E[K] : never :\n// // S[K] extends any[] ? K extends keyof E ? E[K] extends (...args: any[]) => any ? Awaited<ReturnType<E[K]>> : never : never :\n// // S[K] extends object ? K extends keyof E ? QueryReturnType<E[K], S[K]> : never\n// : never\n// };","/*! *****************************************************************************\nCopyright (C) Microsoft. All rights reserved.\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0\n\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\nMERCHANTABLITY OR NON-INFRINGEMENT.\n\nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */\nvar Reflect;\n(function (Reflect) {\n // Metadata Proposal\n // https://rbuckton.github.io/reflect-metadata/\n (function (factory) {\n var root = typeof global === \"object\" ? global :\n typeof self === \"object\" ? self :\n typeof this === \"object\" ? this :\n Function(\"return this;\")();\n var exporter = makeExporter(Reflect);\n if (typeof root.Reflect === \"undefined\") {\n root.Reflect = Reflect;\n }\n else {\n exporter = makeExporter(root.Reflect, exporter);\n }\n factory(exporter);\n function makeExporter(target, previous) {\n return function (key, value) {\n if (typeof target[key] !== \"function\") {\n Object.defineProperty(target, key, { configurable: true, writable: true, value: value });\n }\n if (previous)\n previous(key, value);\n };\n }\n })(function (exporter) {\n var hasOwn = Object.prototype.hasOwnProperty;\n // feature test for Symbol support\n var supportsSymbol = typeof Symbol === \"function\";\n var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== \"undefined\" ? Symbol.toPrimitive : \"@@toPrimitive\";\n var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== \"undefined\" ? Symbol.iterator : \"@@iterator\";\n var supportsCreate = typeof Object.create === \"function\"; // feature test for Object.create support\n var supportsProto = { __proto__: [] } instanceof Array; // feature test for __proto__ support\n var downLevel = !supportsCreate && !supportsProto;\n var HashMap = {\n // create an object in dictionary mode (a.k.a. \"slow\" mode in v8)\n create: supportsCreate\n ? function () { return MakeDictionary(Object.create(null)); }\n : supportsProto\n ? function () { return MakeDictionary({ __proto__: null }); }\n : function () { return MakeDictionary({}); },\n has: downLevel\n ? function (map, key) { return hasOwn.call(map, key); }\n : function (map, key) { return key in map; },\n get: downLevel\n ? function (map, key) { return hasOwn.call(map, key) ? map[key] : undefined; }\n : function (map, key) { return map[key]; },\n };\n // Load global or shim versions of Map, Set, and WeakMap\n var functionPrototype = Object.getPrototypeOf(Function);\n var usePolyfill = typeof process === \"object\" && process.env && process.env[\"REFLECT_METADATA_USE_MAP_POLYFILL\"] === \"true\";\n var _Map = !usePolyfill && typeof Map === \"function\" && typeof Map.prototype.entries === \"function\" ? Map : CreateMapPolyfill();\n var _Set = !usePolyfill && typeof Set === \"function\" && typeof Set.prototype.entries === \"function\" ? Set : CreateSetPolyfill();\n var _WeakMap = !usePolyfill && typeof WeakMap === \"function\" ? WeakMap : CreateWeakMapPolyfill();\n // [[Metadata]] internal slot\n // https://rbuckton.github.io/reflect-metadata/#ordinary-object-internal-methods-and-internal-slots\n var Metadata = new _WeakMap();\n /**\n * Applies a set of decorators to a property of a target object.\n * @param decorators An array of decorators.\n * @param target The target object.\n * @param propertyKey (Optional) The property key to decorate.\n * @param attributes (Optional) The property descriptor for the target key.\n * @remarks Decorators are applied in reverse order.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Example = Reflect.decorate(decoratorsArray, Example);\n *\n * // property (on constructor)\n * Reflect.decorate(decoratorsArray, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.decorate(decoratorsArray, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Object.defineProperty(Example, \"staticMethod\",\n * Reflect.decorate(decoratorsArray, Example, \"staticMethod\",\n * Object.getOwnPropertyDescriptor(Example, \"staticMethod\")));\n *\n * // method (on prototype)\n * Object.defineProperty(Example.prototype, \"method\",\n * Reflect.decorate(decoratorsArray, Example.prototype, \"method\",\n * Object.getOwnPropertyDescriptor(Example.prototype, \"method\")));\n *\n */\n function decorate(decorators, target, propertyKey, attributes) {\n if (!IsUndefined(propertyKey)) {\n if (!IsArray(decorators))\n throw new TypeError();\n if (!IsObject(target))\n throw new TypeError();\n if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))\n throw new TypeError();\n if (IsNull(attributes))\n attributes = undefined;\n propertyKey = ToPropertyKey(propertyKey);\n return DecorateProperty(decorators, target, propertyKey, attributes);\n }\n else {\n if (!IsArray(decorators))\n throw new TypeError();\n if (!IsConstructor(target))\n throw new TypeError();\n return DecorateConstructor(decorators, target);\n }\n }\n exporter(\"decorate\", decorate);\n // 4.1.2 Reflect.metadata(metadataKey, metadataValue)\n // https://rbuckton.github.io/reflect-metadata/#reflect.metadata\n /**\n * A default metadata decorator factory that can be used on a class, class member, or parameter.\n * @param metadataKey The key for the metadata entry.\n * @param metadataValue The value for the metadata entry.\n * @returns A decorator function.\n * @remarks\n * If `metadataKey` is already defined for the target and target key, the\n * metadataValue for that key will be overwritten.\n * @example\n *\n * // constructor\n * @Reflect.metadata(key, value)\n * class Example {\n * }\n *\n * // property (on constructor, TypeScript only)\n * class Example {\n * @Reflect.metadata(key, value)\n * static staticProperty;\n * }\n *\n * // property (on prototype, TypeScript only)\n * class Example {\n * @Reflect.metadata(key, value)\n * property;\n * }\n *\n * // method (on constructor)\n * class Example {\n * @Reflect.metadata(key, value)\n * static staticMethod() { }\n * }\n *\n * // method (on prototype)\n * class Example {\n * @Reflect.metadata(key, value)\n * method() { }\n * }\n *\n */\n function metadata(metadataKey, metadataValue) {\n function decorator(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))\n throw new TypeError();\n OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n }\n return decorator;\n }\n exporter(\"metadata\", metadata);\n /**\n * Define a unique metadata entry on the target.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param metadataValue A value that contains attached metadata.\n * @param target The target object on which to define metadata.\n * @param propertyKey (Optional) The property key for the target.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Reflect.defineMetadata(\"custom:annotation\", options, Example);\n *\n * // property (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example, \"staticMethod\");\n *\n * // method (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example.prototype, \"method\");\n *\n * // decorator factory as metadata-producing annotation.\n * function MyAnnotation(options): Decorator {\n * return (target, key?) => Reflect.defineMetadata(\"custom:annotation\", options, target, key);\n * }\n *\n */\n function defineMetadata(metadataKey, metadataValue, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n }\n exporter(\"defineMetadata\", defineMetadata);\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.hasMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function hasMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryHasMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"hasMetadata\", hasMetadata);\n /**\n * Gets a value indicating whether the target object has the provided metadata key defined.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata key was defined on the target object; otherwise, `false`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function hasOwnMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"hasOwnMetadata\", hasOwnMetadata);\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.getMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function getMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryGetMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"getMetadata\", getMetadata);\n /**\n * Gets the metadata value for the provided metadata key on the target object.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function getOwnMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"getOwnMetadata\", getOwnMetadata);\n /**\n * Gets the metadata keys defined on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns An array of unique metadata keys.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getMetadataKeys(Example);\n *\n * // property (on constructor)\n * result = Reflect.getMetadataKeys(Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getMetadataKeys(Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getMetadataKeys(Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getMetadataKeys(Example.prototype, \"method\");\n *\n */\n function getMetadataKeys(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryMetadataKeys(target, propertyKey);\n }\n exporter(\"getMetadataKeys\", getMetadataKeys);\n /**\n * Gets the unique metadata keys defined on the target object.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns An array of unique metadata keys.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getOwnMetadataKeys(Example);\n *\n * // property (on constructor)\n * result = Reflect.getOwnMetadataKeys(Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getOwnMetadataKeys(Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getOwnMetadataKeys(Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getOwnMetadataKeys(Example.prototype, \"method\");\n *\n */\n function getOwnMetadataKeys(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryOwnMetadataKeys(target, propertyKey);\n }\n exporter(\"getOwnMetadataKeys\", getOwnMetadataKeys);\n /**\n * Deletes the metadata entry from the target object with the provided key.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata entry was found and deleted; otherwise, false.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function deleteMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n var metadataMap = GetOrCreateMetadataMap(target, propertyKey, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return false;\n if (!metadataMap.delete(metadataKey))\n return false;\n if (metadataMap.size > 0)\n return true;\n var targetMetadata = Metadata.get(target);\n targetMetadata.delete(propertyKey);\n if (targetMetadata.size > 0)\n return true;\n Metadata.delete(target);\n return true;\n }\n exporter(\"deleteMetadata\", deleteMetadata);\n function DecorateConstructor(decorators, target) {\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n var decorated = decorator(target);\n if (!IsUndefined(decorated) && !IsNull(decorated)) {\n if (!IsConstructor(decorated))\n throw new TypeError();\n target = decorated;\n }\n }\n return target;\n }\n function DecorateProperty(decorators, target, propertyKey, descriptor) {\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n var decorated = decorator(target, propertyKey, descriptor);\n if (!IsUndefined(decorated) && !IsNull(decorated)) {\n if (!IsObject(decorated))\n throw new TypeError();\n descriptor = decorated;\n }\n }\n return descriptor;\n }\n function GetOrCreateMetadataMap(O, P, Create) {\n var targetMetadata = Metadata.get(O);\n if (IsUndefined(targetMetadata)) {\n if (!Create)\n return undefined;\n targetMetadata = new _Map();\n Metadata.set(O, targetMetadata);\n }\n var metadataMap = targetMetadata.get(P);\n if (IsUndefined(metadataMap)) {\n if (!Create)\n return undefined;\n metadataMap = new _Map();\n targetMetadata.set(P, metadataMap);\n }\n return metadataMap;\n }\n // 3.1.1.1 OrdinaryHasMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasmetadata\n function OrdinaryHasMetadata(MetadataKey, O, P) {\n var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn)\n return true;\n var parent = OrdinaryGetPrototypeOf(O);\n if (!IsNull(parent))\n return OrdinaryHasMetadata(MetadataKey, parent, P);\n return false;\n }\n // 3.1.2.1 OrdinaryHasOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasownmetadata\n function OrdinaryHasOwnMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return false;\n return ToBoolean(metadataMap.has(MetadataKey));\n }\n // 3.1.3.1 OrdinaryGetMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetmetadata\n function OrdinaryGetMetadata(MetadataKey, O, P) {\n var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn)\n return OrdinaryGetOwnMetadata(MetadataKey, O, P);\n var parent = OrdinaryGetPrototypeOf(O);\n if (!IsNull(parent))\n return OrdinaryGetMetadata(MetadataKey, parent, P);\n return undefined;\n }\n // 3.1.4.1 OrdinaryGetOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetownmetadata\n function OrdinaryGetOwnMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return undefined;\n return metadataMap.get(MetadataKey);\n }\n // 3.1.5.1 OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarydefineownmetadata\n function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ true);\n metadataMap.set(MetadataKey, MetadataValue);\n }\n // 3.1.6.1 OrdinaryMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarymetadatakeys\n function OrdinaryMetadataKeys(O, P) {\n var ownKeys = OrdinaryOwnMetadataKeys(O, P);\n var parent = OrdinaryGetPrototypeOf(O);\n if (parent === null)\n return ownKeys;\n var parentKeys = OrdinaryMetadataKeys(parent, P);\n if (parentKeys.length <= 0)\n return ownKeys;\n if (ownKeys.length <= 0)\n return parentKeys;\n var set = new _Set();\n var keys = [];\n for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {\n var key = ownKeys_1[_i];\n var hasKey = set.has(key);\n if (!hasKey) {\n set.add(key);\n keys.push(key);\n }\n }\n for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {\n var key = parentKeys_1[_a];\n var hasKey = set.has(key);\n if (!hasKey) {\n set.add(key);\n keys.push(key);\n }\n }\n return keys;\n }\n // 3.1.7.1 OrdinaryOwnMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryownmetadatakeys\n function OrdinaryOwnMetadataKeys(O, P) {\n var keys = [];\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return keys;\n var keysObj = metadataMap.keys();\n var iterator = GetIterator(keysObj);\n var k = 0;\n while (true) {\n var next = IteratorStep(iterator);\n if (!next) {\n keys.length = k;\n return keys;\n }\n var nextValue = IteratorValue(next);\n try {\n keys[k] = nextValue;\n }\n catch (e) {\n try {\n IteratorClose(iterator);\n }\n finally {\n throw e;\n }\n }\n k++;\n }\n }\n // 6 ECMAScript Data Typ0es and Values\n // https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values\n function Type(x) {\n if (x === null)\n return 1 /* Null */;\n switch (typeof x) {\n case \"undefined\": return 0 /* Undefined */;\n case \"boolean\": return 2 /* Boolean */;\n case \"string\": return 3 /* String */;\n case \"symbol\": return 4 /* Symbol */;\n case \"number\": return 5 /* Number */;\n case \"object\": return x === null ? 1 /* Null */ : 6 /* Object */;\n default: return 6 /* Object */;\n }\n }\n // 6.1.1 The Undefined Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-undefined-type\n function IsUndefined(x) {\n return x === undefined;\n }\n // 6.1.2 The Null Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-null-type\n function IsNull(x) {\n return x === null;\n }\n // 6.1.5 The Symbol Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-symbol-type\n function IsSymbol(x) {\n return typeof x === \"symbol\";\n }\n // 6.1.7 The Object Type\n // https://tc39.github.io/ecma262/#sec-object-type\n function IsObject(x) {\n return typeof x === \"object\" ? x !== null : typeof x === \"function\";\n }\n // 7.1 Type Conversion\n // https://tc39.github.io/ecma262/#sec-type-conversion\n // 7.1.1 ToPrimitive(input [, PreferredType])\n // https://tc39.github.io/ecma262/#sec-toprimitive\n function ToPrimitive(input, PreferredType) {\n switch (Type(input)) {\n case 0 /* Undefined */: return input;\n case 1 /* Null */: return input;\n case 2 /* Boolean */: return input;\n case 3 /* String */: return input;\n case 4 /* Symbol */: return input;\n case 5 /* Number */: return input;\n }\n var hint = PreferredType === 3 /* String */ ? \"string\" : PreferredType === 5 /* Number */ ? \"number\" : \"default\";\n var exoticToPrim = GetMethod(input, toPrimitiveSymbol);\n if (exoticToPrim !== undefined) {\n var result = exoticToPrim.call(input, hint);\n if (IsObject(result))\n throw new TypeError();\n return result;\n }\n return OrdinaryToPrimitive(input, hint === \"default\" ? \"number\" : hint);\n }\n // 7.1.1.1 OrdinaryToPrimitive(O, hint)\n // https://tc39.github.io/ecma262/#sec-ordinarytoprimitive\n function OrdinaryToPrimitive(O, hint) {\n if (hint === \"string\") {\n var toString_1 = O.toString;\n if (IsCallable(toString_1)) {\n var result = toString_1.call(O);\n if (!IsObject(result))\n return result;\n }\n var valueOf = O.valueOf;\n if (IsCallable(valueOf)) {\n var result = valueOf.call(O);\n if (!IsObject(result))\n return result;\n }\n }\n else {\n var valueOf = O.valueOf;\n if (IsCallable(valueOf)) {\n var result = valueOf.call(O);\n if (!IsObject(result))\n return result;\n }\n var toString_2 = O.toString;\n if (IsCallable(toString_2)) {\n var result = toString_2.call(O);\n if (!IsObject(result))\n return result;\n }\n }\n throw new TypeError();\n }\n // 7.1.2 ToBoolean(argument)\n // https://tc39.github.io/ecma262/2016/#sec-toboolean\n function ToBoolean(argument) {\n return !!argument;\n }\n // 7.1.12 ToString(argument)\n // https://tc39.github.io/ecma262/#sec-tostring\n function ToString(argument) {\n return \"\" + argument;\n }\n // 7.1.14 ToPropertyKey(argument)\n // https://tc39.github.io/ecma262/#sec-topropertykey\n function ToPropertyKey(argument) {\n var key = ToPrimitive(argument, 3 /* String */);\n if (IsSymbol(key))\n return key;\n return ToString(key);\n }\n // 7.2 Testing and Comparison Operations\n // https://tc39.github.io/ecma262/#sec-testing-and-comparison-operations\n // 7.2.2 IsArray(argument)\n // https://tc39.github.io/ecma262/#sec-isarray\n function IsArray(argument) {\n return Array.isArray\n ? Array.isArray(argument)\n : argument instanceof Object\n ? argument instanceof Array\n : Object.prototype.toString.call(argument) === \"[object Array]\";\n }\n // 7.2.3 IsCallable(argument)\n // https://tc39.github.io/ecma262/#sec-iscallable\n function IsCallable(argument) {\n // NOTE: This is an approximation as we cannot check for [[Call]] internal method.\n return typeof argument === \"function\";\n }\n // 7.2.4 IsConstructor(argument)\n // https://tc39.github.io/ecma262/#sec-isconstructor\n function IsConstructor(argument) {\n // NOTE: This is an approximation as we cannot check for [[Construct]] internal method.\n return typeof argument === \"function\";\n }\n // 7.2.7 IsPropertyKey(argument)\n // https://tc39.github.io/ecma262/#sec-ispropertykey\n function IsPropertyKey(argument) {\n switch (Type(argument)) {\n case 3 /* String */: return true;\n case 4 /* Symbol */: return true;\n default: return false;\n }\n }\n // 7.3 Operations on Objects\n // https://tc39.github.io/ecma262/#sec-operations-on-objects\n // 7.3.9 GetMethod(V, P)\n // https://tc39.github.io/ecma262/#sec-getmethod\n function GetMethod(V, P) {\n var func = V[P];\n if (func === undefined || func === null)\n return undefined;\n if (!IsCallable(func))\n throw new TypeError();\n return func;\n }\n // 7.4 Operations on Iterator Objects\n // https://tc39.github.io/ecma262/#sec-operations-on-iterator-objects\n function GetIterator(obj) {\n var method = GetMethod(obj, iteratorSymbol);\n if (!IsCallable(method))\n throw new TypeError(); // from Call\n var iterator = method.call(obj);\n if (!IsObject(iterator))\n throw new TypeError();\n return iterator;\n }\n // 7.4.4 IteratorValue(iterResult)\n // https://tc39.github.io/ecma262/2016/#sec-iteratorvalue\n function IteratorValue(iterResult) {\n return iterResult.value;\n }\n // 7.4.5 IteratorStep(iterator)\n // https://tc39.github.io/ecma262/#sec-iteratorstep\n function IteratorStep(iterator) {\n var result = iterator.next();\n return result.done ? false : result;\n }\n // 7.4.6 IteratorClose(iterator, completion)\n // https://tc39.github.io/ecma262/#sec-iteratorclose\n function IteratorClose(iterator) {\n var f = iterator[\"return\"];\n if (f)\n f.call(iterator);\n }\n // 9.1 Ordinary Object Internal Methods and Internal Slots\n // https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots\n // 9.1.1.1 OrdinaryGetPrototypeOf(O)\n // https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof\n function OrdinaryGetPrototypeOf(O) {\n var proto = Object.getPrototypeOf(O);\n if (typeof O !== \"function\" || O === functionPrototype)\n return proto;\n // TypeScript doesn't set __proto__ in ES5, as it's non-standard.\n // Try to determine the superclass constructor. Compatible implementations\n // must either set __proto__ on a subclass constructor to the superclass constructor,\n // or ensure each class has a valid `constructor` property on its prototype that\n // points back to the constructor.\n // If this is not the same as Function.[[Prototype]], then this is definately inherited.\n // This is the case when in ES6 or when using __proto__ in a compatible browser.\n if (proto !== functionPrototype)\n return proto;\n // If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.\n var prototype = O.prototype;\n var prototypeProto = prototype && Object.getPrototypeOf(prototype);\n if (prototypeProto == null || prototypeProto === Object.prototype)\n return proto;\n // If the constructor was not a function, then we cannot determine the heritage.\n var constructor = prototypeProto.constructor;\n if (typeof constructor !== \"function\")\n return proto;\n // If we have some kind of self-reference, then we cannot determine the heritage.\n if (constructor === O)\n return proto;\n // we have a pretty good guess at the heritage.\n return constructor;\n }\n // naive Map shim\n function CreateMapPolyfill() {\n var cacheSentinel = {};\n var arraySentinel = [];\n var MapIterator = /** @class */ (function () {\n function MapIterator(keys, values, selector) {\n this._index = 0;\n this._keys = keys;\n this._values = values;\n this._selector = selector;\n }\n MapIterator.prototype[\"@@iterator\"] = function () { return this; };\n MapIterator.prototype[iteratorSymbol] = function () { return this; };\n MapIterator.prototype.next = function () {\n var index = this._index;\n if (index >= 0 && index < this._keys.length) {\n var result = this._selector(this._keys[index], this._values[index]);\n if (index + 1 >= this._keys.length) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n else {\n this._index++;\n }\n return { value: result, done: false };\n }\n return { value: undefined, done: true };\n };\n MapIterator.prototype.throw = function (error) {\n if (this._index >= 0) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n throw error;\n };\n MapIterator.prototype.return = function (value) {\n if (this._index >= 0) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n return { value: value, done: true };\n };\n return MapIterator;\n }());\n return /** @class */ (function () {\n function Map() {\n this._keys = [];\n this._values = [];\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n }\n Object.defineProperty(Map.prototype, \"size\", {\n get: function () { return this._keys.length; },\n enumerable: true,\n configurable: true\n });\n Map.prototype.has = function (key) { return this._find(key, /*insert*/ false) >= 0; };\n Map.prototype.get = function (key) {\n var index = this._find(key, /*insert*/ false);\n return index >= 0 ? this._values[index] : undefined;\n };\n Map.prototype.set = function (key, value) {\n var index = this._find(key, /*insert*/ true);\n this._values[index] = value;\n return this;\n };\n Map.prototype.delete = function (key) {\n var index = this._find(key, /*insert*/ false);\n if (index >= 0) {\n var size = this._keys.length;\n for (var i = index + 1; i < size; i++) {\n this._keys[i - 1] = this._keys[i];\n this._values[i - 1] = this._values[i];\n }\n this._keys.length--;\n this._values.length--;\n if (key === this._cacheKey) {\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n }\n return true;\n }\n return false;\n };\n Map.prototype.clear = function () {\n this._keys.length = 0;\n this._values.length = 0;\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n };\n Map.prototype.keys = function () { return new MapIterator(this._keys, this._values, getKey); };\n Map.prototype.values = function () { return new MapIterator(this._keys, this._values, getValue); };\n Map.prototype.entries = function () { return new MapIterator(this._keys, this._values, getEntry); };\n Map.prototype[\"@@iterator\"] = function () { return this.entries(); };\n Map.prototype[iteratorSymbol] = function () { return this.entries(); };\n Map.prototype._find = function (key, insert) {\n if (this._cacheKey !== key) {\n this._cacheIndex = this._keys.indexOf(this._cacheKey = key);\n }\n if (this._cacheIndex < 0 && insert) {\n this._cacheIndex = this._keys.length;\n this._keys.push(key);\n this._values.push(undefined);\n }\n return this._cacheIndex;\n };\n return Map;\n }());\n function getKey(key, _) {\n return key;\n }\n function getValue(_, value) {\n return value;\n }\n function getEntry(key, value) {\n return [key, value];\n }\n }\n // naive Set shim\n function CreateSetPolyfill() {\n return /** @class */ (function () {\n function Set() {\n this._map = new _Map();\n }\n Object.defineProperty(Set.prototype, \"size\", {\n get: function () { return this._map.size; },\n enumerable: true,\n configurable: true\n });\n Set.prototype.has = function (value) { return this._map.has(value); };\n Set.prototype.add = function (value) { return this._map.set(value, value), this; };\n Set.prototype.delete = function (value) { return this._map.delete(value); };\n Set.prototype.clear = function () { this._map.clear(); };\n Set.prototype.keys = function () { return this._map.keys(); };\n Set.prototype.values = function () { return this._map.values(); };\n Set.prototype.entries = function () { return this._map.entries(); };\n Set.prototype[\"@@iterator\"] = function () { return this.keys(); };\n Set.prototype[iteratorSymbol] = function () { return this.keys(); };\n return Set;\n }());\n }\n // naive WeakMap shim\n function CreateWeakMapPolyfill() {\n var UUID_SIZE = 16;\n var keys = HashMap.create();\n var rootKey = CreateUniqueKey();\n return /** @class */ (function () {\n function WeakMap() {\n this._key = CreateUniqueKey();\n }\n WeakMap.prototype.has = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? HashMap.has(table, this._key) : false;\n };\n WeakMap.prototype.get = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? HashMap.get(table, this._key) : undefined;\n };\n WeakMap.prototype.set = function (target, value) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ true);\n table[this._key] = value;\n return this;\n };\n WeakMap.prototype.delete = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? delete table[this._key] : false;\n };\n WeakMap.prototype.clear = function () {\n // NOTE: not a real clear, just makes the previous data unreachable\n this._key = CreateUniqueKey();\n };\n return WeakMap;\n }());\n function CreateUniqueKey() {\n var key;\n do\n key = \"@@WeakMap@@\" + CreateUUID();\n while (HashMap.has(keys, key));\n keys[key] = true;\n return key;\n }\n function GetOrCreateWeakMapTable(target, create) {\n if (!hasOwn.call(target, rootKey)) {\n if (!create)\n return undefined;\n Object.defineProperty(target, rootKey, { value: HashMap.create() });\n }\n return target[rootKey];\n }\n function FillRandomBytes(buffer, size) {\n for (var i = 0; i < size; ++i)\n buffer[i] = Math.random() * 0xff | 0;\n return buffer;\n }\n function GenRandomBytes(size) {\n if (typeof Uint8Array === \"function\") {\n if (typeof crypto !== \"undefined\")\n return crypto.getRandomValues(new Uint8Array(size));\n if (typeof msCrypto !== \"undefined\")\n return msCrypto.getRandomValues(new Uint8Array(size));\n return FillRandomBytes(new Uint8Array(size), size);\n }\n return FillRandomBytes(new Array(size), size);\n }\n function CreateUUID() {\n var data = GenRandomBytes(UUID_SIZE);\n // mark as random - RFC 4122 § 4.4\n data[6] = data[6] & 0x4f | 0x40;\n data[8] = data[8] & 0xbf | 0x80;\n var result = \"\";\n for (var offset = 0; offset < UUID_SIZE; ++offset) {\n var byte = data[offset];\n if (offset === 4 || offset === 6 || offset === 8)\n result += \"-\";\n if (byte < 16)\n result += \"0\";\n result += byte.toString(16).toLowerCase();\n }\n return result;\n }\n }\n // uses a heuristic used by v8 and chakra to force an object into dictionary mode.\n function MakeDictionary(obj) {\n obj.__ = undefined;\n delete obj.__;\n return obj;\n }\n });\n})(Reflect || (Reflect = {}));\n","import 'reflect-metadata';\nimport { ClassType } from './interface';\n\nexport const FIELD_KEY = Symbol('aiem_field');\n\n\n\nexport interface FieldParams {\n ttl?: number\n}\n\n\nexport type ContractParams<T extends any = any, K extends keyof T = keyof T> = K\n\n\n\nexport class Fields {\n static hide(options: FieldParams = {}) {\n return function (target: any, propertyKey: any, descriptor?: PropertyDescriptor) {\n Reflect.defineMetadata(FIELD_KEY, { type: 'hide', options }, target, propertyKey);\n };\n }\n static read(options: FieldParams = {}) {\n return function (target: any, propertyKey: any, descriptor?: PropertyDescriptor) {\n Reflect.defineMetadata(FIELD_KEY, { type: 'read', options }, target, propertyKey);\n };\n }\n static write(options: FieldParams = {}) {\n return function (target: any, propertyKey: any, descriptor?: PropertyDescriptor) {\n Reflect.defineMetadata(FIELD_KEY, { type: 'write', options }, target, propertyKey);\n };\n }\n\n static custom(options: FieldParams = {}) {\n return function (target: (...args: any[]) => Promise<any>, propertyKey: any, descriptor?: PropertyDescriptor) {\n Reflect.defineMetadata(FIELD_KEY, { type: 'custom', options }, target, propertyKey);\n };\n }\n\n static contract<T = any, R = any>(entity: () => ClassType<R>, options: ContractParams<T>) {\n return function (target: any, propertyKey: any, descriptor?: PropertyDescriptor) {\n Reflect.defineMetadata(FIELD_KEY, { type: 'contract', entity, targetKey: options }, target, propertyKey);\n };\n }\n}\n\nexport class Format { }\n\nexport function getFieldMetadata(target: any, propertyKey: string) {\n return Reflect.getMetadata(FIELD_KEY, target, propertyKey);\n}"]}
1
+ {"version":3,"sources":["../aiem.ts","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ACT,OAAO;AACL,eAAO,QAAQ,CAAC;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACF;AA1Xa,MACJ,QAAgB,IAAI,MAAM;AADtB,MAmBJ,iBAAiB;AAAA,EACtB,aAAa,EAAE,KAAK,KAAK,IAAK;AAAA,EAC9B,QAAQ,EAAE,KAAK,KAAK,IAAK;AAAA,EACzB,MAAM,EAAE,KAAK,KAAK,IAAK;AAAA,EACvB,UAAU,EAAE,KAAK,KAAK,IAAK;AAAA,EAC3B,WAAW,EAAE,KAAK,IAAI,IAAK;AAC7B;AAzBW,MAoPJ,QAAQ;AAAA,EACb,YAAY,OAAO,EAAE,OAAO,UAAU,SAAS,QAAQ,MAA6E;AAClI,UAAM,OAAO,OAAO,OAAO,cAAc,OAAO,UAAU,EAAE,QAAQ,cAAc,UAAU,GAAG,CAAC;AAChG,UAAM,QAAQ,MAAM,MAAK,SAAS,EAAE,SAAS,SAAS,QAAQ,YAAY,EAAE,CAAC;AAC7E,UAAM,MAAM,IAAI,UAAU,KAAK,YAAY,EAAE,aAAa,SAAS,CAAC,EAAE,QAAQ,CAAC;AAC/E,WAAO,iCAAK,OAAL,EAAW,IAAI;AAAA,EACxB;AACF;AA3PK,IAAM,OAAN","sourcesContent":["import { type Chain, type GetContractReturnType, createPublicClient, getContract, http, type Abi, PublicClient, HttpTransport, WalletClient, AbiFunction, encodeFunctionData } from \"viem\";\nimport md5 from \"md5\";\nimport { iotex, mainnet, bsc, polygon, iotexTestnet } from \"viem/chains\";\nimport TTLCache from \"@isaacs/ttlcache\";\nimport { ClassType } from \"./lib/interface\";\nimport { Fields, getFieldMetadata } from \"./lib/decorators\";\nimport { helper } from \"./utils\";\nimport BigNumber from \"bignumber.js\";\n\n//@ts-ignore\nmainnet.rpcUrls.default.http = [\"https://rpc.ankr.com/eth\"];\n//@ts-ignore\nmainnet.rpcUrls.default.webSocket = [\"wss://ethereum-rpc.publicnode.com\"];\n\nexport { Fields } from \"./lib/decorators\";\n\nexport class Cache {\n kv = new TTLCache<string, any>({ max: 10000, ttl: 1000 * 60 });\n\n wrap<T>(key: string, fn: () => T | Promise<T>, config: TTLCache.Options<any, any> = {}): T | Promise<T> {\n if (this.kv.has(key)) {\n // console.log(`load ${key} from cache`)\n return this.kv.get(key);\n }\n\n const result = fn();\n if (result instanceof Promise) {\n const promiseResult = result.then((res) => {\n this.kv.set(key, res, config);\n return res;\n });\n this.kv.set(key, promiseResult, config);\n return promiseResult;\n } else {\n this.kv.set(key, result, config);\n return result;\n }\n }\n}\n\nexport class AIem<Contracts extends Record<string, Abi>, Chains extends Record<string, Chain>, Addrs extends { [K in keyof Contracts]?: { [key: string]: `${string}-0x${string}` } }> {\n static cache?: Cache = new Cache();\n cache?: Cache = new Cache();\n contractMap?: Contracts;\n //@ts-ignore\n chainMap?: Chains = {\n [iotex.id]: iotex,\n [mainnet.id]: mainnet,\n [bsc.id]: bsc,\n [polygon.id]: polygon,\n [iotexTestnet.id]: iotexTestnet,\n };\n nameMap?: Addrs;\n contracts: {\n [K in keyof Addrs & keyof Contracts]: {\n //@ts-ignore\n [KK in keyof Addrs[K]]: GetContractReturnType<Contracts[K], PublicClient<HttpTransport, Chain, any, any>, any, any>;\n };\n };\n static defaultFuncMap = {\n totalSupply: { ttl: 15 * 1000 },\n symbol: { ttl: 60 * 1000 },\n name: { ttl: 60 * 1000 },\n decimals: { ttl: 60 * 1000 },\n balanceOf: { ttl: 5 * 1000 },\n };\n funcMap?: { [key: string]: { ttl?: number } } = {};\n\n get _cache() {\n return AIem.cache;\n }\n\n //@ts-ignore\n getWallet?: () => WalletClient;\n\n static Set<Contracts extends Record<string, Abi>, Chains extends Record<string, Chain>, Addrs extends { [K in keyof Contracts]?: { [key: string]: `${string}-0x${string}` } }>(\n args: Pick<AIem<Contracts, Chains, Addrs>, \"contractMap\" | \"chainMap\" | \"nameMap\" | \"getWallet\" | \"cache\" | \"funcMap\">,\n ) {\n return this.init().Set(args);\n }\n\n Set<Contracts extends Record<string, Abi>, Chains extends Record<string, Chain>, Addrs extends { [K in keyof Contracts]?: { [key: string]: `${string}-0x${string}` } }>(\n args: Pick<AIem<Contracts, Chains, Addrs>, \"contractMap\" | \"chainMap\" | \"nameMap\" | \"getWallet\" | \"cache\" | \"funcMap\">,\n ): AIem<Contracts, Chains, Addrs> {\n const { chainMap = {}, contractMap = {}, funcMap, ...rest } = args || {};\n //@ts-ignore\n this.chainMap = Object.assign({}, this.chainMap || {}, chainMap);\n //@ts-ignore\n this.contractMap = Object.assign({}, this.contractMap || {}, contractMap);\n //@ts-ignore\n this.funcMap = Object.assign({}, this.funcMap || {}, funcMap);\n\n Object.assign(this, rest);\n return this as any;\n }\n\n constructor(args: Pick<AIem<Contracts, Chains, Addrs>, \"contractMap\" | \"chainMap\" | \"nameMap\" | \"getWallet\" | \"cache\" | \"funcMap\"> = {}) {\n this.Set(args);\n\n this.contracts = new Proxy(\n {},\n {\n //@ts-ignore\n get: (target: any, contractName: keyof Addrs & keyof Contracts) => {\n if (target[contractName]) return target[contractName];\n\n if (!this.nameMap[contractName]) {\n throw new Error(`Contract ${String(contractName)} not found`);\n }\n\n target[contractName] = new Proxy(\n {},\n {\n //@ts-ignore\n get: (innerTarget: any, contractAlias: keyof Addrs[keyof Addrs]) => {\n const addressStr = this.nameMap[contractName]?.[contractAlias];\n if (!addressStr) {\n throw new Error(`Alias ${String(contractAlias)} for contract ${String(contractName)} not found`);\n }\n const [chainId, address] = addressStr.split(\"-\");\n\n // Assuming getContractInstance is a function that retrieves a contract instance\n return this.Get(contractName, String(chainId), address as `0x${string}`);\n },\n },\n );\n return target[contractName];\n },\n },\n ) as any;\n }\n\n // WsClient<C extends keyof Chains>(chainId: C): PublicClient<WebSocketTransport, Chain, any, any> {\n // //@ts-ignore\n // return this.cache.wrap(`wsClient-${String(chainId)}`, () => {\n // // const wsUrl = this.chainMap[chainId]?.rpcUrls?.default?.webSocket?.[0]\n // // if (!wsUrl) throw new Error(`rpcUrls.default.webSocket[0] is not defined for chainId ${String(chainId)}`)\n // // //@ts-ignore\n // return createPublicClient({\n // //@ts-ignore\n // chain: this.chainMap[chainId],\n // transport: webSocket()\n // }) as PublicClient<WebSocketTransport, Chain, any, any>\n // })\n // }\n\n PubClient<C extends keyof Chains>(chainId: C): PublicClient<HttpTransport, Chain, any, any> {\n //@ts-ignore\n return this._cache.wrap(`publicClient-${String(chainId)}`, () => {\n //@ts-ignore\n return createPublicClient({\n //@ts-ignore\n chain: this.chainMap[chainId],\n transport: http(),\n }) as PublicClient<HttpTransport, Chain, any, any>;\n });\n }\n\n //@ts-ignore\n Get<K extends keyof Contracts, C extends keyof Chains, Addr extends `0x${string}`>(\n contractName: K,\n chainId: C,\n address: Addr,\n //@ts-ignore\n ): GetContractReturnType<Contracts[K], PublicClient<HttpTransport, Chain, any, any>> {\n const wallet = this.getWallet ? this.getWallet() : null;\n //@ts-ignore\n const cacheKey = `contract ${chainId}-${address}-${wallet ? wallet.account.address : null}`;\n return this._cache.wrap(cacheKey, () => {\n //@ts-ignore\n const contract = this.contractMap[contractName];\n //@ts-ignore\n const pubClient = this.PubClient(chainId);\n\n //@ts-ignore\n return this.getContract({\n client: {\n //@ts-ignore\n public: pubClient,\n //@ts-ignore\n wallet,\n },\n address,\n abi: contract,\n });\n }) as any;\n }\n\n getContract({\n client,\n address,\n abi,\n }: {\n client: {\n public: PublicClient<HttpTransport, Chain, any, any>;\n wallet?: WalletClient;\n };\n address: `0x${string}`;\n abi: any;\n }) {\n const handler = {\n get: (target: any, funcName: any) => {\n if (typeof target[funcName] === \"function\") {\n return async (...args: any[]) => {\n const methodConfig = this.funcMap?.[funcName as string];\n // const cacheKey = `method:${client.public.chain.id}-${address}-${String(funcName)}-${JSON.stringify(args)}`;\n const cacheKey = `call ${client.public.chain.id}-${address}-${funcName}-${JSON.stringify(args)}`;\n\n if (methodConfig) {\n return this.cache.wrap(\n cacheKey,\n () => {\n return target[funcName](...args);\n },\n methodConfig,\n );\n }\n\n return target[funcName](...args);\n };\n }\n return new Proxy(target[funcName], handler);\n },\n };\n\n //@ts-ignore\n const contract = getContract({\n //@ts-ignore\n client,\n address,\n abi,\n });\n return new Proxy(contract, handler) as any;\n }\n\n static init(): AIem<any, any, any> {\n if (!globalThis.aiem) {\n //@ts-ignore\n globalThis.aiem = new AIem();\n }\n\n return globalThis.aiem;\n }\n\n //@ts-ignore\n static Get<TAbi extends Abi = any>(abi: TAbi, chainId: any, address: any, wallet?: WalletClient): GetContractReturnType<TAbi, PublicClient<HttpTransport, Chain, any, any>> {\n const aiem = this.init();\n\n const cacheKey = `contract ${chainId}-${address}-${wallet ? wallet.account.address : null}`;\n return aiem._cache.wrap(cacheKey, () => {\n //@ts-ignore\n const pubClient = aiem.PubClient(chainId);\n\n //@ts-ignore\n return aiem.getContract({\n client: {\n //@ts-ignore\n public: pubClient,\n //@ts-ignore\n wallet,\n },\n address,\n abi,\n });\n }) as any;\n }\n\n static async getPrice({ chainId = \"4689\", address }: { chainId?: string; address: string }) {\n const priceMap = await this.cache.wrap(\n `token-price`,\n async () => {\n const res = await (await fetch(\"https://api.iopay.me/api/rest/price\")).json();\n return Object.values(res)\n .flat()\n .reduce((p, c: { platforms: string; current_price: number }) => {\n p[`${4689}-${c.platforms.toLowerCase()}`] = c.current_price;\n return p;\n }, {});\n },\n { ttl: 1000 * 60 },\n );\n return priceMap[`${chainId}-${address}`];\n }\n\n static utils = {\n autoFormat: async ({ value, decimals, chainId, address }: { value: string; decimals: number; chainId: string; address: string }) => {\n const wrap = helper.number.warpBigNumber(value, decimals, { format: \"0,0.000000\", fallback: \"\" });\n const price = await this.getPrice({ chainId, address: address.toLowerCase() });\n const usd = new BigNumber(wrap.originFormat).multipliedBy(price || 1).toFixed(2);\n return { ...wrap, usd };\n },\n };\n\n static QueryMany<E, S extends QuerySelect<E>>(entity: ClassType<E>, select: S) {\n return async (_entities: Partial<E>[]): Promise<QueryReturnType<E, S>[]> => {\n //@ts-ignore\n return this.Query(entity, select)(_entities) as any;\n };\n }\n\n static Query<E, S extends QuerySelect<E>>(entity: ClassType<E>, select: S) {\n return async (entities: Partial<E>): Promise<QueryReturnType<E, S>> => {\n const results: Array<QueryReturnType<E, S>> = [];\n const isArrayInput = Array.isArray(entities);\n\n if (!isArrayInput) {\n //@ts-ignore\n entities = [entities];\n }\n //@ts-ignore\n for (const entityData of entities) {\n const instance = Object.assign(new entity(), entityData);\n // const result: any = {};\n\n const fetchFields = async (obj: any, sel: any) => {\n const promises = [];\n for (const key in sel) {\n // return console.log(key, getFieldMetadata(obj, key))\n // Check if the property is annotated with @Fields.read(), @Fields.custom(), or @Fields.contract()\n const fieldMetadata = getFieldMetadata(obj, key);\n\n let call: any;\n // console.log(key, fieldMetadata, instance)\n if (fieldMetadata) {\n switch (fieldMetadata.type) {\n case \"read\":\n if (Array.isArray(sel[key])) {\n //@ts-ignore\n call = () => this.Get(entity.abi, instance.chainId, instance.address).read[key](sel[key]);\n } else {\n //@ts-ignore\n call = () => this.Get(entity.abi, instance.chainId, instance.address).read[key]();\n }\n break;\n case \"write\":\n obj[key] = encodeFunctionData({\n //@ts-ignore\n abi: entity.abi,\n functionName: key,\n args: sel[key],\n });\n break;\n case \"custom\":\n call = () => obj[key](...(Array.isArray(sel[key]) ? sel[key] : []));\n break;\n case \"contract\":\n // console.log(fieldMetadata)\n if (fieldMetadata.targetKey) {\n const targetMetadata = getFieldMetadata(instance, fieldMetadata.targetKey);\n\n if (targetMetadata?.options?.ttl) {\n //@ts-ignore\n const cacheKey = `call ${instance.chainId}-${instance.address}-${fieldMetadata.targetKey}`;\n //@ts-ignore\n call = () =>\n new Promise(async (resolve) => {\n //@ts-ignore\n const address = await this.cache.wrap(cacheKey, async () => this.Get(entity.abi, instance.chainId, instance.address).read[fieldMetadata.targetKey]());\n //@ts-ignore\n resolve(this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId }));\n });\n } else {\n call = () =>\n //@ts-ignore\n this.Get(entity.abi, instance.chainId, instance.address)\n //@ts-ignore\n .read[fieldMetadata.targetKey]()\n .then((address: any) => {\n // console.log({ address, sel: sel[key] })\n //@ts-ignore\n return this.Query(fieldMetadata.entity(), sel[key])({ address, chainId: instance.chainId });\n });\n }\n }\n break;\n default:\n break;\n }\n } else if (sel[key] === true) {\n obj[key] = obj[key];\n }\n\n if (call) {\n if (fieldMetadata?.options?.ttl) {\n //@ts-ignore\n const cacheKey = `call ${instance.chainId}-${instance.address}-${key}-${JSON.stringify(sel[key])}`;\n promises.push(\n new Promise(async (resolve) => {\n const value = await this.cache.wrap(cacheKey, async () => call(), fieldMetadata.options);\n obj[key] = value;\n resolve(value);\n }),\n );\n } else {\n promises.push(\n call().then((value) => {\n obj[key] = value;\n }),\n );\n }\n }\n }\n\n await Promise.all(promises);\n };\n\n await fetchFields(instance, select);\n //@ts-ignore\n results.push(instance);\n }\n\n if (isArrayInput) {\n return results as any\n } else {\n return results[0] as any\n }\n };\n }\n}\nexport type Item<T> = T extends (infer U)[] ? U : T;\n\n// export type QueryResult<E, S extends QuerySelect<E>> =\n// E extends Array<any> ? Promise<Array<QueryReturnType<E[number], S>>> :\n// E extends object ? Promise<QueryReturnType<E, S>> :\n// never;\n\ntype QuerySelect<E> = {\n [K in keyof E]?: E[K] extends (...args: any[]) => any ? Parameters<E[K]> | true : E[K] extends object ? QuerySelect<E[K]> : true;\n};\n\n// type FunctionReturn<T> = T extends (...args: any[]) => any ? Awaited<ReturnType<T>> : T;\n// type NestedReturn<E, S> = E extends object ? S extends object ? QueryReturnType<E, S> : E : E;\n\nexport type QueryReturnType<E, S extends QuerySelect<E>> = {\n [K in keyof E]: K extends keyof S\n ? E[K] extends (...args: any[]) => any\n ? Awaited<ReturnType<E[K]>>\n : E[K] extends object\n ? S[K] extends object\n ? QueryReturnType<E[K], S[K]>\n : E[K]\n : E[K]\n : E[K];\n};\n","/*! *****************************************************************************\nCopyright (C) Microsoft. All rights reserved.\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0\n\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\nMERCHANTABLITY OR NON-INFRINGEMENT.\n\nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */\nvar Reflect;\n(function (Reflect) {\n // Metadata Proposal\n // https://rbuckton.github.io/reflect-metadata/\n (function (factory) {\n var root = typeof global === \"object\" ? global :\n typeof self === \"object\" ? self :\n typeof this === \"object\" ? this :\n Function(\"return this;\")();\n var exporter = makeExporter(Reflect);\n if (typeof root.Reflect === \"undefined\") {\n root.Reflect = Reflect;\n }\n else {\n exporter = makeExporter(root.Reflect, exporter);\n }\n factory(exporter);\n function makeExporter(target, previous) {\n return function (key, value) {\n if (typeof target[key] !== \"function\") {\n Object.defineProperty(target, key, { configurable: true, writable: true, value: value });\n }\n if (previous)\n previous(key, value);\n };\n }\n })(function (exporter) {\n var hasOwn = Object.prototype.hasOwnProperty;\n // feature test for Symbol support\n var supportsSymbol = typeof Symbol === \"function\";\n var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== \"undefined\" ? Symbol.toPrimitive : \"@@toPrimitive\";\n var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== \"undefined\" ? Symbol.iterator : \"@@iterator\";\n var supportsCreate = typeof Object.create === \"function\"; // feature test for Object.create support\n var supportsProto = { __proto__: [] } instanceof Array; // feature test for __proto__ support\n var downLevel = !supportsCreate && !supportsProto;\n var HashMap = {\n // create an object in dictionary mode (a.k.a. \"slow\" mode in v8)\n create: supportsCreate\n ? function () { return MakeDictionary(Object.create(null)); }\n : supportsProto\n ? function () { return MakeDictionary({ __proto__: null }); }\n : function () { return MakeDictionary({}); },\n has: downLevel\n ? function (map, key) { return hasOwn.call(map, key); }\n : function (map, key) { return key in map; },\n get: downLevel\n ? function (map, key) { return hasOwn.call(map, key) ? map[key] : undefined; }\n : function (map, key) { return map[key]; },\n };\n // Load global or shim versions of Map, Set, and WeakMap\n var functionPrototype = Object.getPrototypeOf(Function);\n var usePolyfill = typeof process === \"object\" && process.env && process.env[\"REFLECT_METADATA_USE_MAP_POLYFILL\"] === \"true\";\n var _Map = !usePolyfill && typeof Map === \"function\" && typeof Map.prototype.entries === \"function\" ? Map : CreateMapPolyfill();\n var _Set = !usePolyfill && typeof Set === \"function\" && typeof Set.prototype.entries === \"function\" ? Set : CreateSetPolyfill();\n var _WeakMap = !usePolyfill && typeof WeakMap === \"function\" ? WeakMap : CreateWeakMapPolyfill();\n // [[Metadata]] internal slot\n // https://rbuckton.github.io/reflect-metadata/#ordinary-object-internal-methods-and-internal-slots\n var Metadata = new _WeakMap();\n /**\n * Applies a set of decorators to a property of a target object.\n * @param decorators An array of decorators.\n * @param target The target object.\n * @param propertyKey (Optional) The property key to decorate.\n * @param attributes (Optional) The property descriptor for the target key.\n * @remarks Decorators are applied in reverse order.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Example = Reflect.decorate(decoratorsArray, Example);\n *\n * // property (on constructor)\n * Reflect.decorate(decoratorsArray, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.decorate(decoratorsArray, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Object.defineProperty(Example, \"staticMethod\",\n * Reflect.decorate(decoratorsArray, Example, \"staticMethod\",\n * Object.getOwnPropertyDescriptor(Example, \"staticMethod\")));\n *\n * // method (on prototype)\n * Object.defineProperty(Example.prototype, \"method\",\n * Reflect.decorate(decoratorsArray, Example.prototype, \"method\",\n * Object.getOwnPropertyDescriptor(Example.prototype, \"method\")));\n *\n */\n function decorate(decorators, target, propertyKey, attributes) {\n if (!IsUndefined(propertyKey)) {\n if (!IsArray(decorators))\n throw new TypeError();\n if (!IsObject(target))\n throw new TypeError();\n if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))\n throw new TypeError();\n if (IsNull(attributes))\n attributes = undefined;\n propertyKey = ToPropertyKey(propertyKey);\n return DecorateProperty(decorators, target, propertyKey, attributes);\n }\n else {\n if (!IsArray(decorators))\n throw new TypeError();\n if (!IsConstructor(target))\n throw new TypeError();\n return DecorateConstructor(decorators, target);\n }\n }\n exporter(\"decorate\", decorate);\n // 4.1.2 Reflect.metadata(metadataKey, metadataValue)\n // https://rbuckton.github.io/reflect-metadata/#reflect.metadata\n /**\n * A default metadata decorator factory that can be used on a class, class member, or parameter.\n * @param metadataKey The key for the metadata entry.\n * @param metadataValue The value for the metadata entry.\n * @returns A decorator function.\n * @remarks\n * If `metadataKey` is already defined for the target and target key, the\n * metadataValue for that key will be overwritten.\n * @example\n *\n * // constructor\n * @Reflect.metadata(key, value)\n * class Example {\n * }\n *\n * // property (on constructor, TypeScript only)\n * class Example {\n * @Reflect.metadata(key, value)\n * static staticProperty;\n * }\n *\n * // property (on prototype, TypeScript only)\n * class Example {\n * @Reflect.metadata(key, value)\n * property;\n * }\n *\n * // method (on constructor)\n * class Example {\n * @Reflect.metadata(key, value)\n * static staticMethod() { }\n * }\n *\n * // method (on prototype)\n * class Example {\n * @Reflect.metadata(key, value)\n * method() { }\n * }\n *\n */\n function metadata(metadataKey, metadataValue) {\n function decorator(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))\n throw new TypeError();\n OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n }\n return decorator;\n }\n exporter(\"metadata\", metadata);\n /**\n * Define a unique metadata entry on the target.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param metadataValue A value that contains attached metadata.\n * @param target The target object on which to define metadata.\n * @param propertyKey (Optional) The property key for the target.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Reflect.defineMetadata(\"custom:annotation\", options, Example);\n *\n * // property (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example, \"staticMethod\");\n *\n * // method (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example.prototype, \"method\");\n *\n * // decorator factory as metadata-producing annotation.\n * function MyAnnotation(options): Decorator {\n * return (target, key?) => Reflect.defineMetadata(\"custom:annotation\", options, target, key);\n * }\n *\n */\n function defineMetadata(metadataKey, metadataValue, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n }\n exporter(\"defineMetadata\", defineMetadata);\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.hasMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function hasMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryHasMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"hasMetadata\", hasMetadata);\n /**\n * Gets a value indicating whether the target object has the provided metadata key defined.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata key was defined on the target object; otherwise, `false`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function hasOwnMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"hasOwnMetadata\", hasOwnMetadata);\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.getMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function getMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryGetMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"getMetadata\", getMetadata);\n /**\n * Gets the metadata value for the provided metadata key on the target object.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function getOwnMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"getOwnMetadata\", getOwnMetadata);\n /**\n * Gets the metadata keys defined on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns An array of unique metadata keys.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getMetadataKeys(Example);\n *\n * // property (on constructor)\n * result = Reflect.getMetadataKeys(Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getMetadataKeys(Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getMetadataKeys(Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getMetadataKeys(Example.prototype, \"method\");\n *\n */\n function getMetadataKeys(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryMetadataKeys(target, propertyKey);\n }\n exporter(\"getMetadataKeys\", getMetadataKeys);\n /**\n * Gets the unique metadata keys defined on the target object.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns An array of unique metadata keys.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getOwnMetadataKeys(Example);\n *\n * // property (on constructor)\n * result = Reflect.getOwnMetadataKeys(Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getOwnMetadataKeys(Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getOwnMetadataKeys(Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getOwnMetadataKeys(Example.prototype, \"method\");\n *\n */\n function getOwnMetadataKeys(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryOwnMetadataKeys(target, propertyKey);\n }\n exporter(\"getOwnMetadataKeys\", getOwnMetadataKeys);\n /**\n * Deletes the metadata entry from the target object with the provided key.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata entry was found and deleted; otherwise, false.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function deleteMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n var metadataMap = GetOrCreateMetadataMap(target, propertyKey, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return false;\n if (!metadataMap.delete(metadataKey))\n return false;\n if (metadataMap.size > 0)\n return true;\n var targetMetadata = Metadata.get(target);\n targetMetadata.delete(propertyKey);\n if (targetMetadata.size > 0)\n return true;\n Metadata.delete(target);\n return true;\n }\n exporter(\"deleteMetadata\", deleteMetadata);\n function DecorateConstructor(decorators, target) {\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n var decorated = decorator(target);\n if (!IsUndefined(decorated) && !IsNull(decorated)) {\n if (!IsConstructor(decorated))\n throw new TypeError();\n target = decorated;\n }\n }\n return target;\n }\n function DecorateProperty(decorators, target, propertyKey, descriptor) {\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n var decorated = decorator(target, propertyKey, descriptor);\n if (!IsUndefined(decorated) && !IsNull(decorated)) {\n if (!IsObject(decorated))\n throw new TypeError();\n descriptor = decorated;\n }\n }\n return descriptor;\n }\n function GetOrCreateMetadataMap(O, P, Create) {\n var targetMetadata = Metadata.get(O);\n if (IsUndefined(targetMetadata)) {\n if (!Create)\n return undefined;\n targetMetadata = new _Map();\n Metadata.set(O, targetMetadata);\n }\n var metadataMap = targetMetadata.get(P);\n if (IsUndefined(metadataMap)) {\n if (!Create)\n return undefined;\n metadataMap = new _Map();\n targetMetadata.set(P, metadataMap);\n }\n return metadataMap;\n }\n // 3.1.1.1 OrdinaryHasMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasmetadata\n function OrdinaryHasMetadata(MetadataKey, O, P) {\n var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn)\n return true;\n var parent = OrdinaryGetPrototypeOf(O);\n if (!IsNull(parent))\n return OrdinaryHasMetadata(MetadataKey, parent, P);\n return false;\n }\n // 3.1.2.1 OrdinaryHasOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasownmetadata\n function OrdinaryHasOwnMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return false;\n return ToBoolean(metadataMap.has(MetadataKey));\n }\n // 3.1.3.1 OrdinaryGetMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetmetadata\n function OrdinaryGetMetadata(MetadataKey, O, P) {\n var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn)\n return OrdinaryGetOwnMetadata(MetadataKey, O, P);\n var parent = OrdinaryGetPrototypeOf(O);\n if (!IsNull(parent))\n return OrdinaryGetMetadata(MetadataKey, parent, P);\n return undefined;\n }\n // 3.1.4.1 OrdinaryGetOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetownmetadata\n function OrdinaryGetOwnMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return undefined;\n return metadataMap.get(MetadataKey);\n }\n // 3.1.5.1 OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarydefineownmetadata\n function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ true);\n metadataMap.set(MetadataKey, MetadataValue);\n }\n // 3.1.6.1 OrdinaryMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarymetadatakeys\n function OrdinaryMetadataKeys(O, P) {\n var ownKeys = OrdinaryOwnMetadataKeys(O, P);\n var parent = OrdinaryGetPrototypeOf(O);\n if (parent === null)\n return ownKeys;\n var parentKeys = OrdinaryMetadataKeys(parent, P);\n if (parentKeys.length <= 0)\n return ownKeys;\n if (ownKeys.length <= 0)\n return parentKeys;\n var set = new _Set();\n var keys = [];\n for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {\n var key = ownKeys_1[_i];\n var hasKey = set.has(key);\n if (!hasKey) {\n set.add(key);\n keys.push(key);\n }\n }\n for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {\n var key = parentKeys_1[_a];\n var hasKey = set.has(key);\n if (!hasKey) {\n set.add(key);\n keys.push(key);\n }\n }\n return keys;\n }\n // 3.1.7.1 OrdinaryOwnMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryownmetadatakeys\n function OrdinaryOwnMetadataKeys(O, P) {\n var keys = [];\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return keys;\n var keysObj = metadataMap.keys();\n var iterator = GetIterator(keysObj);\n var k = 0;\n while (true) {\n var next = IteratorStep(iterator);\n if (!next) {\n keys.length = k;\n return keys;\n }\n var nextValue = IteratorValue(next);\n try {\n keys[k] = nextValue;\n }\n catch (e) {\n try {\n IteratorClose(iterator);\n }\n finally {\n throw e;\n }\n }\n k++;\n }\n }\n // 6 ECMAScript Data Typ0es and Values\n // https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values\n function Type(x) {\n if (x === null)\n return 1 /* Null */;\n switch (typeof x) {\n case \"undefined\": return 0 /* Undefined */;\n case \"boolean\": return 2 /* Boolean */;\n case \"string\": return 3 /* String */;\n case \"symbol\": return 4 /* Symbol */;\n case \"number\": return 5 /* Number */;\n case \"object\": return x === null ? 1 /* Null */ : 6 /* Object */;\n default: return 6 /* Object */;\n }\n }\n // 6.1.1 The Undefined Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-undefined-type\n function IsUndefined(x) {\n return x === undefined;\n }\n // 6.1.2 The Null Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-null-type\n function IsNull(x) {\n return x === null;\n }\n // 6.1.5 The Symbol Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-symbol-type\n function IsSymbol(x) {\n return typeof x === \"symbol\";\n }\n // 6.1.7 The Object Type\n // https://tc39.github.io/ecma262/#sec-object-type\n function IsObject(x) {\n return typeof x === \"object\" ? x !== null : typeof x === \"function\";\n }\n // 7.1 Type Conversion\n // https://tc39.github.io/ecma262/#sec-type-conversion\n // 7.1.1 ToPrimitive(input [, PreferredType])\n // https://tc39.github.io/ecma262/#sec-toprimitive\n function ToPrimitive(input, PreferredType) {\n switch (Type(input)) {\n case 0 /* Undefined */: return input;\n case 1 /* Null */: return input;\n case 2 /* Boolean */: return input;\n case 3 /* String */: return input;\n case 4 /* Symbol */: return input;\n case 5 /* Number */: return input;\n }\n var hint = PreferredType === 3 /* String */ ? \"string\" : PreferredType === 5 /* Number */ ? \"number\" : \"default\";\n var exoticToPrim = GetMethod(input, toPrimitiveSymbol);\n if (exoticToPrim !== undefined) {\n var result = exoticToPrim.call(input, hint);\n if (IsObject(result))\n throw new TypeError();\n return result;\n }\n return OrdinaryToPrimitive(input, hint === \"default\" ? \"number\" : hint);\n }\n // 7.1.1.1 OrdinaryToPrimitive(O, hint)\n // https://tc39.github.io/ecma262/#sec-ordinarytoprimitive\n function OrdinaryToPrimitive(O, hint) {\n if (hint === \"string\") {\n var toString_1 = O.toString;\n if (IsCallable(toString_1)) {\n var result = toString_1.call(O);\n if (!IsObject(result))\n return result;\n }\n var valueOf = O.valueOf;\n if (IsCallable(valueOf)) {\n var result = valueOf.call(O);\n if (!IsObject(result))\n return result;\n }\n }\n else {\n var valueOf = O.valueOf;\n if (IsCallable(valueOf)) {\n var result = valueOf.call(O);\n if (!IsObject(result))\n return result;\n }\n var toString_2 = O.toString;\n if (IsCallable(toString_2)) {\n var result = toString_2.call(O);\n if (!IsObject(result))\n return result;\n }\n }\n throw new TypeError();\n }\n // 7.1.2 ToBoolean(argument)\n // https://tc39.github.io/ecma262/2016/#sec-toboolean\n function ToBoolean(argument) {\n return !!argument;\n }\n // 7.1.12 ToString(argument)\n // https://tc39.github.io/ecma262/#sec-tostring\n function ToString(argument) {\n return \"\" + argument;\n }\n // 7.1.14 ToPropertyKey(argument)\n // https://tc39.github.io/ecma262/#sec-topropertykey\n function ToPropertyKey(argument) {\n var key = ToPrimitive(argument, 3 /* String */);\n if (IsSymbol(key))\n return key;\n return ToString(key);\n }\n // 7.2 Testing and Comparison Operations\n // https://tc39.github.io/ecma262/#sec-testing-and-comparison-operations\n // 7.2.2 IsArray(argument)\n // https://tc39.github.io/ecma262/#sec-isarray\n function IsArray(argument) {\n return Array.isArray\n ? Array.isArray(argument)\n : argument instanceof Object\n ? argument instanceof Array\n : Object.prototype.toString.call(argument) === \"[object Array]\";\n }\n // 7.2.3 IsCallable(argument)\n // https://tc39.github.io/ecma262/#sec-iscallable\n function IsCallable(argument) {\n // NOTE: This is an approximation as we cannot check for [[Call]] internal method.\n return typeof argument === \"function\";\n }\n // 7.2.4 IsConstructor(argument)\n // https://tc39.github.io/ecma262/#sec-isconstructor\n function IsConstructor(argument) {\n // NOTE: This is an approximation as we cannot check for [[Construct]] internal method.\n return typeof argument === \"function\";\n }\n // 7.2.7 IsPropertyKey(argument)\n // https://tc39.github.io/ecma262/#sec-ispropertykey\n function IsPropertyKey(argument) {\n switch (Type(argument)) {\n case 3 /* String */: return true;\n case 4 /* Symbol */: return true;\n default: return false;\n }\n }\n // 7.3 Operations on Objects\n // https://tc39.github.io/ecma262/#sec-operations-on-objects\n // 7.3.9 GetMethod(V, P)\n // https://tc39.github.io/ecma262/#sec-getmethod\n function GetMethod(V, P) {\n var func = V[P];\n if (func === undefined || func === null)\n return undefined;\n if (!IsCallable(func))\n throw new TypeError();\n return func;\n }\n // 7.4 Operations on Iterator Objects\n // https://tc39.github.io/ecma262/#sec-operations-on-iterator-objects\n function GetIterator(obj) {\n var method = GetMethod(obj, iteratorSymbol);\n if (!IsCallable(method))\n throw new TypeError(); // from Call\n var iterator = method.call(obj);\n if (!IsObject(iterator))\n throw new TypeError();\n return iterator;\n }\n // 7.4.4 IteratorValue(iterResult)\n // https://tc39.github.io/ecma262/2016/#sec-iteratorvalue\n function IteratorValue(iterResult) {\n return iterResult.value;\n }\n // 7.4.5 IteratorStep(iterator)\n // https://tc39.github.io/ecma262/#sec-iteratorstep\n function IteratorStep(iterator) {\n var result = iterator.next();\n return result.done ? false : result;\n }\n // 7.4.6 IteratorClose(iterator, completion)\n // https://tc39.github.io/ecma262/#sec-iteratorclose\n function IteratorClose(iterator) {\n var f = iterator[\"return\"];\n if (f)\n f.call(iterator);\n }\n // 9.1 Ordinary Object Internal Methods and Internal Slots\n // https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots\n // 9.1.1.1 OrdinaryGetPrototypeOf(O)\n // https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof\n function OrdinaryGetPrototypeOf(O) {\n var proto = Object.getPrototypeOf(O);\n if (typeof O !== \"function\" || O === functionPrototype)\n return proto;\n // TypeScript doesn't set __proto__ in ES5, as it's non-standard.\n // Try to determine the superclass constructor. Compatible implementations\n // must either set __proto__ on a subclass constructor to the superclass constructor,\n // or ensure each class has a valid `constructor` property on its prototype that\n // points back to the constructor.\n // If this is not the same as Function.[[Prototype]], then this is definately inherited.\n // This is the case when in ES6 or when using __proto__ in a compatible browser.\n if (proto !== functionPrototype)\n return proto;\n // If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.\n var prototype = O.prototype;\n var prototypeProto = prototype && Object.getPrototypeOf(prototype);\n if (prototypeProto == null || prototypeProto === Object.prototype)\n return proto;\n // If the constructor was not a function, then we cannot determine the heritage.\n var constructor = prototypeProto.constructor;\n if (typeof constructor !== \"function\")\n return proto;\n // If we have some kind of self-reference, then we cannot determine the heritage.\n if (constructor === O)\n return proto;\n // we have a pretty good guess at the heritage.\n return constructor;\n }\n // naive Map shim\n function CreateMapPolyfill() {\n var cacheSentinel = {};\n var arraySentinel = [];\n var MapIterator = /** @class */ (function () {\n function MapIterator(keys, values, selector) {\n this._index = 0;\n this._keys = keys;\n this._values = values;\n this._selector = selector;\n }\n MapIterator.prototype[\"@@iterator\"] = function () { return this; };\n MapIterator.prototype[iteratorSymbol] = function () { return this; };\n MapIterator.prototype.next = function () {\n var index = this._index;\n if (index >= 0 && index < this._keys.length) {\n var result = this._selector(this._keys[index], this._values[index]);\n if (index + 1 >= this._keys.length) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n else {\n this._index++;\n }\n return { value: result, done: false };\n }\n return { value: undefined, done: true };\n };\n MapIterator.prototype.throw = function (error) {\n if (this._index >= 0) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n throw error;\n };\n MapIterator.prototype.return = function (value) {\n if (this._index >= 0) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n return { value: value, done: true };\n };\n return MapIterator;\n }());\n return /** @class */ (function () {\n function Map() {\n this._keys = [];\n this._values = [];\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n }\n Object.defineProperty(Map.prototype, \"size\", {\n get: function () { return this._keys.length; },\n enumerable: true,\n configurable: true\n });\n Map.prototype.has = function (key) { return this._find(key, /*insert*/ false) >= 0; };\n Map.prototype.get = function (key) {\n var index = this._find(key, /*insert*/ false);\n return index >= 0 ? this._values[index] : undefined;\n };\n Map.prototype.set = function (key, value) {\n var index = this._find(key, /*insert*/ true);\n this._values[index] = value;\n return this;\n };\n Map.prototype.delete = function (key) {\n var index = this._find(key, /*insert*/ false);\n if (index >= 0) {\n var size = this._keys.length;\n for (var i = index + 1; i < size; i++) {\n this._keys[i - 1] = this._keys[i];\n this._values[i - 1] = this._values[i];\n }\n this._keys.length--;\n this._values.length--;\n if (key === this._cacheKey) {\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n }\n return true;\n }\n return false;\n };\n Map.prototype.clear = function () {\n this._keys.length = 0;\n this._values.length = 0;\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n };\n Map.prototype.keys = function () { return new MapIterator(this._keys, this._values, getKey); };\n Map.prototype.values = function () { return new MapIterator(this._keys, this._values, getValue); };\n Map.prototype.entries = function () { return new MapIterator(this._keys, this._values, getEntry); };\n Map.prototype[\"@@iterator\"] = function () { return this.entries(); };\n Map.prototype[iteratorSymbol] = function () { return this.entries(); };\n Map.prototype._find = function (key, insert) {\n if (this._cacheKey !== key) {\n this._cacheIndex = this._keys.indexOf(this._cacheKey = key);\n }\n if (this._cacheIndex < 0 && insert) {\n this._cacheIndex = this._keys.length;\n this._keys.push(key);\n this._values.push(undefined);\n }\n return this._cacheIndex;\n };\n return Map;\n }());\n function getKey(key, _) {\n return key;\n }\n function getValue(_, value) {\n return value;\n }\n function getEntry(key, value) {\n return [key, value];\n }\n }\n // naive Set shim\n function CreateSetPolyfill() {\n return /** @class */ (function () {\n function Set() {\n this._map = new _Map();\n }\n Object.defineProperty(Set.prototype, \"size\", {\n get: function () { return this._map.size; },\n enumerable: true,\n configurable: true\n });\n Set.prototype.has = function (value) { return this._map.has(value); };\n Set.prototype.add = function (value) { return this._map.set(value, value), this; };\n Set.prototype.delete = function (value) { return this._map.delete(value); };\n Set.prototype.clear = function () { this._map.clear(); };\n Set.prototype.keys = function () { return this._map.keys(); };\n Set.prototype.values = function () { return this._map.values(); };\n Set.prototype.entries = function () { return this._map.entries(); };\n Set.prototype[\"@@iterator\"] = function () { return this.keys(); };\n Set.prototype[iteratorSymbol] = function () { return this.keys(); };\n return Set;\n }());\n }\n // naive WeakMap shim\n function CreateWeakMapPolyfill() {\n var UUID_SIZE = 16;\n var keys = HashMap.create();\n var rootKey = CreateUniqueKey();\n return /** @class */ (function () {\n function WeakMap() {\n this._key = CreateUniqueKey();\n }\n WeakMap.prototype.has = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? HashMap.has(table, this._key) : false;\n };\n WeakMap.prototype.get = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? HashMap.get(table, this._key) : undefined;\n };\n WeakMap.prototype.set = function (target, value) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ true);\n table[this._key] = value;\n return this;\n };\n WeakMap.prototype.delete = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? delete table[this._key] : false;\n };\n WeakMap.prototype.clear = function () {\n // NOTE: not a real clear, just makes the previous data unreachable\n this._key = CreateUniqueKey();\n };\n return WeakMap;\n }());\n function CreateUniqueKey() {\n var key;\n do\n key = \"@@WeakMap@@\" + CreateUUID();\n while (HashMap.has(keys, key));\n keys[key] = true;\n return key;\n }\n function GetOrCreateWeakMapTable(target, create) {\n if (!hasOwn.call(target, rootKey)) {\n if (!create)\n return undefined;\n Object.defineProperty(target, rootKey, { value: HashMap.create() });\n }\n return target[rootKey];\n }\n function FillRandomBytes(buffer, size) {\n for (var i = 0; i < size; ++i)\n buffer[i] = Math.random() * 0xff | 0;\n return buffer;\n }\n function GenRandomBytes(size) {\n if (typeof Uint8Array === \"function\") {\n if (typeof crypto !== \"undefined\")\n return crypto.getRandomValues(new Uint8Array(size));\n if (typeof msCrypto !== \"undefined\")\n return msCrypto.getRandomValues(new Uint8Array(size));\n return FillRandomBytes(new Uint8Array(size), size);\n }\n return FillRandomBytes(new Array(size), size);\n }\n function CreateUUID() {\n var data = GenRandomBytes(UUID_SIZE);\n // mark as random - RFC 4122 § 4.4\n data[6] = data[6] & 0x4f | 0x40;\n data[8] = data[8] & 0xbf | 0x80;\n var result = \"\";\n for (var offset = 0; offset < UUID_SIZE; ++offset) {\n var byte = data[offset];\n if (offset === 4 || offset === 6 || offset === 8)\n result += \"-\";\n if (byte < 16)\n result += \"0\";\n result += byte.toString(16).toLowerCase();\n }\n return result;\n }\n }\n // uses a heuristic used by v8 and chakra to force an object into dictionary mode.\n function MakeDictionary(obj) {\n obj.__ = undefined;\n delete obj.__;\n return obj;\n }\n });\n})(Reflect || (Reflect = {}));\n","import 'reflect-metadata';\nimport { ClassType } from './interface';\n\nexport const FIELD_KEY = Symbol('aiem_field');\n\n\n\nexport interface FieldParams {\n ttl?: number\n}\n\n\nexport type ContractParams<T extends any = any, K extends keyof T = keyof T> = K\n\n\n\nexport class Fields {\n static hide(options: FieldParams = {}) {\n return function (target: any, propertyKey: any, descriptor?: PropertyDescriptor) {\n Reflect.defineMetadata(FIELD_KEY, { type: 'hide', options }, target, propertyKey);\n };\n }\n static read(options: FieldParams = {}) {\n return function (target: any, propertyKey: any, descriptor?: PropertyDescriptor) {\n Reflect.defineMetadata(FIELD_KEY, { type: 'read', options }, target, propertyKey);\n };\n }\n static write(options: FieldParams = {}) {\n return function (target: any, propertyKey: any, descriptor?: PropertyDescriptor) {\n Reflect.defineMetadata(FIELD_KEY, { type: 'write', options }, target, propertyKey);\n };\n }\n\n static custom(options: FieldParams = {}) {\n return function (target: (...args: any[]) => Promise<any>, propertyKey: any, descriptor?: PropertyDescriptor) {\n Reflect.defineMetadata(FIELD_KEY, { type: 'custom', options }, target, propertyKey);\n };\n }\n\n static contract<T = any, R = any>(entity: () => ClassType<R>, options: ContractParams<T>) {\n return function (target: any, propertyKey: any, descriptor?: PropertyDescriptor) {\n Reflect.defineMetadata(FIELD_KEY, { type: 'contract', entity, targetKey: options }, target, propertyKey);\n };\n }\n}\n\nexport class Format { }\n\nexport function getFieldMetadata(target: any, propertyKey: string) {\n return Reflect.getMetadata(FIELD_KEY, target, propertyKey);\n}"]}
@@ -238,6 +238,7 @@ var helper = {
238
238
  return {
239
239
  value: "...",
240
240
  format: "...",
241
+ originFormat: "...",
241
242
  decimals: "0",
242
243
  isZero: true
243
244
  };
@@ -247,8 +248,8 @@ var helper = {
247
248
  value: BigNumberResponse.value.toFixed(0),
248
249
  originFormat: BigNumberResponse.value.div(10 ** decimals).toFixed(),
249
250
  format: helper.number.numberFormat(BigNumberResponse.value.div(10 ** decimals).toFixed(), format, { fallback, min }),
250
- decimals: String(BigNumberResponse.decimals)
251
- // isZero: BigNumberResponse.value.isZero(),
251
+ decimals: String(BigNumberResponse.decimals),
252
+ isZero: BigNumberResponse.value.isZero()
252
253
  };
253
254
  },
254
255
  //http://numeraljs.com/ format params does not need to deal with decimal places
@@ -316,4 +317,4 @@ var helper = {
316
317
 
317
318
  export { helper };
318
319
  //# sourceMappingURL=out.js.map
319
- //# sourceMappingURL=chunk-46XF5IRX.mjs.map
320
+ //# sourceMappingURL=chunk-Q3AD5RHQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../lib/helper.ts"],"names":[],"mappings":";;;;;AAAA,O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e;AAC1E,UAAI;AACF,YAAI,eAAe,QAAQ,OAAO,QAAQ,kBAAkB,OAAO,GAAG;AACpE,iBAAO,KAAK,OAAO,EAAE,UAAU;AAAA,QACjC;AACA,YAAI,eAAe,QAAQ,OAAO,QAAQ,mBAAmB,OAAO,GAAG;AACrE,iBAAO,KAAK,OAAO,EAAE,OAAO;AAAA,QAC9B;AAAA,MACF,SAAS,OAAO;AAAA,MAAE;AAClB,aAAO;AAAA,IACT;AAAA,IACA,oBAAoB,CAAC,YAAoB,sBAAsB,KAAK,OAAO;AAAA,IAC3E,mBAAmB,CAAC,YAAoB,sBAAsB,KAAK,OAAO;AAAA,IAC1E,iBAAiB,CAAC,YAAoB,OAAO,QAAQ,mBAAmB,OAAO,KAAK,OAAO,QAAQ,kBAAkB,OAAO;AAAA,EAC9H;AACF","sourcesContent":["import BN, { BigNumber } from \"bignumber.js\";\nimport JSONFormat from \"json-format\";\nimport { _ } from \"./lodash\";\nimport copy from \"copy-to-clipboard\";\nimport numeral from \"numeral\";\nimport { from } from \"@iotexproject/iotex-address-ts\";\n\nconst valMap = {\n undefined: \"\",\n null: \"\",\n false: false,\n};\n\nexport const helper = {\n env: {\n isIopayMobile: () => navigator.userAgent && (navigator.userAgent.includes(\"IoPayAndroid\") || navigator.userAgent.includes(\"IoPayiOs\")),\n isBrowser: () => typeof window === \"object\",\n onBrowser(func) {\n if (this.isBrowser()) {\n func();\n }\n },\n },\n promise: {\n async sleep(ms) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n },\n async runAsync<T, U = Error>(promise: Promise<T>): Promise<[U | null, T | null]> {\n return promise.then<[null, T]>((data: T) => [null, data]).catch<[U, null]>((err) => [err, null]);\n },\n },\n object: {\n crawlObject(object, options) {\n const newObj = JSON.parse(JSON.stringify(object));\n return helper.object.crawl(newObj, options);\n },\n crawl(object, options) {\n Object.keys(object).forEach((i) => {\n if (typeof object[i] === \"object\") {\n helper.object.crawl(object[i], options);\n } else {\n const handler = options[typeof object[i]];\n if (handler) {\n object[i] = handler(object[i]);\n }\n }\n });\n return object;\n },\n },\n json: {\n isJsonString(str: string) {\n if (!str || typeof str !== \"string\") return false;\n if (!str?.includes(\"{\")) return false;\n try {\n JSON.parse(str);\n } catch (e) {\n return false;\n }\n return true;\n },\n safeParse(val: any) {\n try {\n return JSON.parse(val);\n } catch (error) {\n return val;\n }\n },\n },\n deepAssign(target, ...sources) {\n sources.forEach((source) => {\n Object.keys(source).forEach((key) => {\n let descriptor = Object.getOwnPropertyDescriptor(source, key);\n if (descriptor && descriptor?.get) {\n return Object.defineProperty(target, key, descriptor);\n }\n const targetValue = target[key];\n let sourceValue = source[key];\n if (helper.isObject(targetValue) && helper.isObject(sourceValue)) {\n try {\n target[key] = helper.deepAssign(targetValue, sourceValue);\n } catch (e) {\n target[key] = Object.assign(targetValue, sourceValue);\n }\n } else {\n target[key] = sourceValue;\n }\n });\n });\n return target;\n },\n isObject(value) {\n return value != null && typeof value === \"object\";\n },\n deepMerge(obj, newObj) {\n const newVal = _.mergeWith(obj, newObj, (...args) => {\n const [objValue, srcValue] = args;\n if (typeof srcValue === \"object\") {\n return helper.deepMerge(objValue, srcValue);\n }\n return srcValue || valMap[srcValue];\n });\n return newVal;\n },\n img: {\n parse(src: string | undefined) {\n if (!src) return \"/img-404.svg\";\n if (src?.startsWith(\"ipfs\")) {\n return \"https://ipfs.io/ipfs/\" + src.split(\"://\")[1];\n }\n return src;\n },\n },\n string: {\n copy(str: string) {\n copy(str);\n },\n fristUpper(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n },\n firstUpperCase(str: string) {\n return str.replace(/^\\S/, (s) => s.toUpperCase());\n },\n toFixString(str, length) {\n if (str && str.length > length) {\n return str.substr(0, length) + \"...\";\n } else {\n return str;\n }\n },\n truncate(fullStr = \"\", strLen, separator) {\n if (fullStr.length <= strLen) return fullStr;\n\n separator = separator || \"...\";\n\n var sepLen = separator.length,\n charsToShow = strLen - sepLen,\n frontChars = Math.ceil(charsToShow / 2),\n backChars = Math.floor(charsToShow / 2);\n\n return fullStr.substr(0, frontChars) + separator + fullStr.substr(fullStr.length - backChars);\n },\n validAbi(abi: string): { abi: any[]; address: string } {\n try {\n JSON.parse(abi);\n const _abi = helper.json.safeParse(abi);\n if (!_abi) {\n return { abi: [], address: \"\" };\n }\n if (Array.isArray(_abi)) {\n return { abi: _abi, address: \"\" };\n } else if (_abi.abi && _abi.address) {\n return { abi: _abi.abi, address: _abi.address };\n } else if (_abi.abi && !_abi.addresses) {\n return { abi: _abi.abi, address: \"\" };\n }\n return { abi: [], address: \"\" };\n } catch (error) {\n return { abi: [], address: \"\" };\n }\n },\n random(count: number) {\n const chars = \"abcdefghijklmnopqrstuvwxyz\";\n let result = \"\";\n for (let i = 0; i < count; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return result;\n },\n },\n download: {\n downloadByBlob(name: string, blob: Blob) {\n const a = document.createElement(\"a\");\n const href = window.URL.createObjectURL(blob);\n a.href = href;\n a.download = name;\n a.click();\n },\n downloadJSON(name: string, jsonObj: object) {\n try {\n const jsonStr: string = JSONFormat(jsonObj);\n const blob = new Blob([jsonStr], { type: \"application/json\" });\n this.downloadByBlob(name + \".json\", blob);\n } catch (error) {\n console.error(error);\n }\n },\n },\n number: {\n countNonZeroNumbers: (str: string) => {\n let index = 0;\n const length = str.length;\n for (; index < length && (str[index] === \"0\" || str[index] === \".\"); index += 1);\n return length - index - Number(str.includes(\".\"));\n },\n numberWithCommas(num: number) {\n return num.toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n },\n getBN: (value: number | string | BN) => {\n return value instanceof BN ? value : typeof value === \"string\" ? new BN(Number(value)) : new BN(value);\n },\n toPrecisionFloor: (str: number | string, options?: { decimals?: number; format?: string; toLocalString?: boolean }) => {\n const { decimals = 6, format = \"\", toLocalString = false } = options || {};\n if (!str || isNaN(Number(str))) return \"\";\n\n if (helper.number.countNonZeroNumbers(String(str)) <= decimals) return String(str);\n const numStr = new BN(str).toFixed();\n let result = \"\";\n let index = 0;\n const numLength = numStr.length;\n\n for (; numStr[index] === \"0\" && index < numLength; index += 1);\n\n if (index === numLength) return \"0\";\n\n if (numStr[index] === \".\") {\n // number < 0\n result = \"0\";\n for (; (numStr[index] === \"0\" || numStr[index] === \".\") && index < numLength; index += 1) {\n result = result + numStr[index];\n }\n }\n let resultNumLength = 0;\n for (; index < numLength && (resultNumLength < decimals || !result.includes(\".\")); index += 1) {\n result = result + numStr[index];\n\n if (numStr[index] !== \".\") resultNumLength += 1;\n }\n if (format) {\n return numeral(Number(result)).format(format);\n }\n\n if (toLocalString) {\n return helper.number.numberWithCommas(Number(new BN(result).toFixed()));\n }\n\n return new BN(result).toFixed();\n },\n\n //format: '0,0'\n warpBigNumber(value: string, decimals = 18, options?: { format?: string; fallback?: string; min?: number }) {\n const { format = \"0.0\", fallback = \"0.000\", min } = options || {};\n if (!value) {\n return {\n value: \"...\",\n format: \"...\",\n originFormat: \"...\",\n decimals: \"0\",\n isZero: true,\n };\n }\n const BigNumberResponse = { value: new BigNumber(value), decimals }\n return {\n value: BigNumberResponse.value.toFixed(0),\n originFormat: BigNumberResponse.value.div(10 ** decimals).toFixed(),\n format: helper.number.numberFormat(BigNumberResponse.value.div(10 ** decimals).toFixed(), format, { fallback, min }),\n decimals: String(BigNumberResponse.decimals),\n isZero: BigNumberResponse.value.isZero(),\n };\n },\n //http://numeraljs.com/ format params does not need to deal with decimal places\n //format: '$0,0' '0a' '0,0' '0,0$'\n numberFormat(str: string | number, format: string = \"0,0\", options: { min?: number; fallback?: string } = {}): string {\n const { fallback = \"0.00\" } = options || {};\n\n if (!str || isNaN(Number(str))) return fallback;\n const numStr = new BigNumber(str).toFixed();\n const countNonZeroNumbers = (_str: string) => {\n const decimalPointIndex = _str.indexOf(\".\");\n if (decimalPointIndex === -1) {\n return 0;\n }\n const decimalPart = _str.substring(decimalPointIndex + 1);\n let trailingZerosCount = 0;\n for (let i = 0; i < decimalPart.length; i++) {\n if (decimalPart[i] === \"0\") {\n trailingZerosCount++;\n } else {\n break;\n }\n }\n return trailingZerosCount;\n };\n\n const fractionDigits = countNonZeroNumbers(format);\n const numberFractionDigits = countNonZeroNumbers(numStr);\n if (options?.min) {\n if (new BigNumber(numStr).isLessThan(new BigNumber(options?.min || 0))) {\n return `< ${numeral(options?.min).format(format)}`;\n }\n }\n const fullStr = new BigNumber(numStr).toFixed();\n let preStr = numeral(fullStr.split(\".\")[0]).format(format.split(\".\")[0]);\n const fractionStr = fullStr.split(\".\")?.[1]?.slice(0, fractionDigits + numberFractionDigits);\n\n if (numberFractionDigits >= fractionDigits) {\n return (preStr + \".\" + fractionStr).replace(/\\.?0+$/, \"\");\n }\n\n if (fractionStr?.[fractionDigits - 1] == \"9\") {\n return (preStr + \".\" + fractionStr.slice(0, fractionDigits - 1) + \"9\").replace(/\\.?0+$/, \"\");\n }\n\n const resultStr = numeral(new BigNumber(numStr).toString()).format(format);\n return resultStr.replace(/\\.?0+$/, \"\");\n },\n },\n address: {\n convertAddress: (addressMode: \"io\" | \"0x\", address: string = \"\"): string => {\n try {\n if (addressMode == \"0x\" && helper.address.validateIoAddress(address)) {\n return from(address).stringEth();\n }\n if (addressMode == \"io\" && helper.address.validateEthAddress(address)) {\n return from(address).string();\n }\n } catch (error) { }\n return address;\n },\n validateEthAddress: (address: string) => /^0x[a-fA-F0-9]{40}$/.test(address),\n validateIoAddress: (address: string) => /^io[a-zA-Z0-9]{39}$/.test(address),\n validateAddress: (address: string) => helper.address.validateEthAddress(address) || helper.address.validateIoAddress(address),\n },\n};\n"]}
package/dist/dev.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { helper } from './chunk-46XF5IRX.mjs';
1
+ import { helper } from './chunk-Q3AD5RHQ.mjs';
2
2
  import { _ } from './chunk-MGU3KYGC.mjs';
3
3
  import { cn } from './chunk-AIZ7XDNV.mjs';
4
4
  import { __objRest, __spreadProps, __spreadValues } from './chunk-R4SQKVDQ.mjs';
package/dist/form.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { useStore } from './chunk-WS43BV7Y.mjs';
2
2
  import { RootStore } from './chunk-XJMRAPHI.mjs';
3
- import { helper } from './chunk-46XF5IRX.mjs';
3
+ import { helper } from './chunk-Q3AD5RHQ.mjs';
4
4
  import { _ } from './chunk-MGU3KYGC.mjs';
5
5
  import { cn } from './chunk-AIZ7XDNV.mjs';
6
6
  import { __objRest, __spreadValues, __spreadProps } from './chunk-R4SQKVDQ.mjs';
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import './chunk-4YCP5CJ4.mjs';
3
3
  export { rootStore, useStore } from './chunk-WS43BV7Y.mjs';
4
4
  import { RootStore } from './chunk-XJMRAPHI.mjs';
5
5
  export { RootStore } from './chunk-XJMRAPHI.mjs';
6
- import { helper } from './chunk-46XF5IRX.mjs';
6
+ import { helper } from './chunk-Q3AD5RHQ.mjs';
7
7
  export { PaginationState } from './chunk-ONVPCAMQ.mjs';
8
8
  import './chunk-MGU3KYGC.mjs';
9
9
  import './chunk-R4SQKVDQ.mjs';
package/dist/utils.d.mts CHANGED
@@ -107,15 +107,9 @@ declare const helper: {
107
107
  }): {
108
108
  value: string;
109
109
  format: string;
110
- decimals: string;
111
- isZero: boolean;
112
- originFormat?: undefined;
113
- } | {
114
- value: string;
115
110
  originFormat: string;
116
- format: string;
117
111
  decimals: string;
118
- isZero?: undefined;
112
+ isZero: boolean;
119
113
  };
120
114
  numberFormat(str: string | number, format?: string, options?: {
121
115
  min?: number;
package/dist/utils.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  export { cache } from './chunk-7MDKCI65.mjs';
2
- export { helper } from './chunk-46XF5IRX.mjs';
2
+ export { helper } from './chunk-Q3AD5RHQ.mjs';
3
3
  import './chunk-MGU3KYGC.mjs';
4
4
  import './chunk-R4SQKVDQ.mjs';
5
5
  //# sourceMappingURL=out.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dappworks/kit",
3
- "version": "0.4.118",
3
+ "version": "0.4.119",
4
4
  "description": "",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../lib/helper.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,MAAM,iBAAiB;AAC9B,OAAO,gBAAgB;AAEvB,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB,SAAS,YAAY;AAErB,IAAM,SAAS;AAAA,EACb,WAAW;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AACT;AAEO,IAAM,SAAS;AAAA,EACpB,KAAK;AAAA,IACH,eAAe,MAAM,UAAU,cAAc,UAAU,UAAU,SAAS,cAAc,KAAK,UAAU,UAAU,SAAS,UAAU;AAAA,IACpI,WAAW,MAAM,OAAO,WAAW;AAAA,IACnC,UAAU,MAAM;AACd,UAAI,KAAK,UAAU,GAAG;AACpB,aAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP,MAAM,MAAM,IAAI;AACd,aAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA,IACzD;AAAA,IACA,MAAM,SAAuB,SAAoD;AAC/E,aAAO,QAAQ,KAAgB,CAAC,SAAY,CAAC,MAAM,IAAI,CAAC,EAAE,MAAiB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;AAAA,IACjG;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,YAAY,QAAQ,SAAS;AAC3B,YAAM,SAAS,KAAK,MAAM,KAAK,UAAU,MAAM,CAAC;AAChD,aAAO,OAAO,OAAO,MAAM,QAAQ,OAAO;AAAA,IAC5C;AAAA,IACA,MAAM,QAAQ,SAAS;AACrB,aAAO,KAAK,MAAM,EAAE,QAAQ,CAAC,MAAM;AACjC,YAAI,OAAO,OAAO,CAAC,MAAM,UAAU;AACjC,iBAAO,OAAO,MAAM,OAAO,CAAC,GAAG,OAAO;AAAA,QACxC,OAAO;AACL,gBAAM,UA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QAAQ,UAAU,EAAE;AAAA,IACvC;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP,gBAAgB,CAAC,aAA0B,UAAkB,OAAe;AAC1E,UAAI;AACF,YAAI,eAAe,QAAQ,OAAO,QAAQ,kBAAkB,OAAO,GAAG;AACpE,iBAAO,KAAK,OAAO,EAAE,UAAU;AAAA,QACjC;AACA,YAAI,eAAe,QAAQ,OAAO,QAAQ,mBAAmB,OAAO,GAAG;AACrE,iBAAO,KAAK,OAAO,EAAE,OAAO;AAAA,QAC9B;AAAA,MACF,SAAS,OAAO;AAAA,MAAE;AAClB,aAAO;AAAA,IACT;AAAA,IACA,oBAAoB,CAAC,YAAoB,sBAAsB,KAAK,OAAO;AAAA,IAC3E,mBAAmB,CAAC,YAAoB,sBAAsB,KAAK,OAAO;AAAA,IAC1E,iBAAiB,CAAC,YAAoB,OAAO,QAAQ,mBAAmB,OAAO,KAAK,OAAO,QAAQ,kBAAkB,OAAO;AAAA,EAC9H;AACF","sourcesContent":["import BN, { BigNumber } from \"bignumber.js\";\nimport JSONFormat from \"json-format\";\nimport { _ } from \"./lodash\";\nimport copy from \"copy-to-clipboard\";\nimport numeral from \"numeral\";\nimport { from } from \"@iotexproject/iotex-address-ts\";\n\nconst valMap = {\n undefined: \"\",\n null: \"\",\n false: false,\n};\n\nexport const helper = {\n env: {\n isIopayMobile: () => navigator.userAgent && (navigator.userAgent.includes(\"IoPayAndroid\") || navigator.userAgent.includes(\"IoPayiOs\")),\n isBrowser: () => typeof window === \"object\",\n onBrowser(func) {\n if (this.isBrowser()) {\n func();\n }\n },\n },\n promise: {\n async sleep(ms) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n },\n async runAsync<T, U = Error>(promise: Promise<T>): Promise<[U | null, T | null]> {\n return promise.then<[null, T]>((data: T) => [null, data]).catch<[U, null]>((err) => [err, null]);\n },\n },\n object: {\n crawlObject(object, options) {\n const newObj = JSON.parse(JSON.stringify(object));\n return helper.object.crawl(newObj, options);\n },\n crawl(object, options) {\n Object.keys(object).forEach((i) => {\n if (typeof object[i] === \"object\") {\n helper.object.crawl(object[i], options);\n } else {\n const handler = options[typeof object[i]];\n if (handler) {\n object[i] = handler(object[i]);\n }\n }\n });\n return object;\n },\n },\n json: {\n isJsonString(str: string) {\n if (!str || typeof str !== \"string\") return false;\n if (!str?.includes(\"{\")) return false;\n try {\n JSON.parse(str);\n } catch (e) {\n return false;\n }\n return true;\n },\n safeParse(val: any) {\n try {\n return JSON.parse(val);\n } catch (error) {\n return val;\n }\n },\n },\n deepAssign(target, ...sources) {\n sources.forEach((source) => {\n Object.keys(source).forEach((key) => {\n let descriptor = Object.getOwnPropertyDescriptor(source, key);\n if (descriptor && descriptor?.get) {\n return Object.defineProperty(target, key, descriptor);\n }\n const targetValue = target[key];\n let sourceValue = source[key];\n if (helper.isObject(targetValue) && helper.isObject(sourceValue)) {\n try {\n target[key] = helper.deepAssign(targetValue, sourceValue);\n } catch (e) {\n target[key] = Object.assign(targetValue, sourceValue);\n }\n } else {\n target[key] = sourceValue;\n }\n });\n });\n return target;\n },\n isObject(value) {\n return value != null && typeof value === \"object\";\n },\n deepMerge(obj, newObj) {\n const newVal = _.mergeWith(obj, newObj, (...args) => {\n const [objValue, srcValue] = args;\n if (typeof srcValue === \"object\") {\n return helper.deepMerge(objValue, srcValue);\n }\n return srcValue || valMap[srcValue];\n });\n return newVal;\n },\n img: {\n parse(src: string | undefined) {\n if (!src) return \"/img-404.svg\";\n if (src?.startsWith(\"ipfs\")) {\n return \"https://ipfs.io/ipfs/\" + src.split(\"://\")[1];\n }\n return src;\n },\n },\n string: {\n copy(str: string) {\n copy(str);\n },\n fristUpper(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n },\n firstUpperCase(str: string) {\n return str.replace(/^\\S/, (s) => s.toUpperCase());\n },\n toFixString(str, length) {\n if (str && str.length > length) {\n return str.substr(0, length) + \"...\";\n } else {\n return str;\n }\n },\n truncate(fullStr = \"\", strLen, separator) {\n if (fullStr.length <= strLen) return fullStr;\n\n separator = separator || \"...\";\n\n var sepLen = separator.length,\n charsToShow = strLen - sepLen,\n frontChars = Math.ceil(charsToShow / 2),\n backChars = Math.floor(charsToShow / 2);\n\n return fullStr.substr(0, frontChars) + separator + fullStr.substr(fullStr.length - backChars);\n },\n validAbi(abi: string): { abi: any[]; address: string } {\n try {\n JSON.parse(abi);\n const _abi = helper.json.safeParse(abi);\n if (!_abi) {\n return { abi: [], address: \"\" };\n }\n if (Array.isArray(_abi)) {\n return { abi: _abi, address: \"\" };\n } else if (_abi.abi && _abi.address) {\n return { abi: _abi.abi, address: _abi.address };\n } else if (_abi.abi && !_abi.addresses) {\n return { abi: _abi.abi, address: \"\" };\n }\n return { abi: [], address: \"\" };\n } catch (error) {\n return { abi: [], address: \"\" };\n }\n },\n random(count: number) {\n const chars = \"abcdefghijklmnopqrstuvwxyz\";\n let result = \"\";\n for (let i = 0; i < count; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return result;\n },\n },\n download: {\n downloadByBlob(name: string, blob: Blob) {\n const a = document.createElement(\"a\");\n const href = window.URL.createObjectURL(blob);\n a.href = href;\n a.download = name;\n a.click();\n },\n downloadJSON(name: string, jsonObj: object) {\n try {\n const jsonStr: string = JSONFormat(jsonObj);\n const blob = new Blob([jsonStr], { type: \"application/json\" });\n this.downloadByBlob(name + \".json\", blob);\n } catch (error) {\n console.error(error);\n }\n },\n },\n number: {\n countNonZeroNumbers: (str: string) => {\n let index = 0;\n const length = str.length;\n for (; index < length && (str[index] === \"0\" || str[index] === \".\"); index += 1);\n return length - index - Number(str.includes(\".\"));\n },\n numberWithCommas(num: number) {\n return num.toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n },\n getBN: (value: number | string | BN) => {\n return value instanceof BN ? value : typeof value === \"string\" ? new BN(Number(value)) : new BN(value);\n },\n toPrecisionFloor: (str: number | string, options?: { decimals?: number; format?: string; toLocalString?: boolean }) => {\n const { decimals = 6, format = \"\", toLocalString = false } = options || {};\n if (!str || isNaN(Number(str))) return \"\";\n\n if (helper.number.countNonZeroNumbers(String(str)) <= decimals) return String(str);\n const numStr = new BN(str).toFixed();\n let result = \"\";\n let index = 0;\n const numLength = numStr.length;\n\n for (; numStr[index] === \"0\" && index < numLength; index += 1);\n\n if (index === numLength) return \"0\";\n\n if (numStr[index] === \".\") {\n // number < 0\n result = \"0\";\n for (; (numStr[index] === \"0\" || numStr[index] === \".\") && index < numLength; index += 1) {\n result = result + numStr[index];\n }\n }\n let resultNumLength = 0;\n for (; index < numLength && (resultNumLength < decimals || !result.includes(\".\")); index += 1) {\n result = result + numStr[index];\n\n if (numStr[index] !== \".\") resultNumLength += 1;\n }\n if (format) {\n return numeral(Number(result)).format(format);\n }\n\n if (toLocalString) {\n return helper.number.numberWithCommas(Number(new BN(result).toFixed()));\n }\n\n return new BN(result).toFixed();\n },\n\n //format: '0,0'\n warpBigNumber(value: string, decimals = 18, options?: { format?: string; fallback?: string; min?: number }) {\n const { format = \"0.0\", fallback = \"0.000\", min } = options || {};\n if (!value) {\n return {\n value: \"...\",\n format: \"...\",\n decimals: \"0\",\n isZero: true,\n };\n }\n const BigNumberResponse = { value: new BigNumber(value), decimals }\n return {\n value: BigNumberResponse.value.toFixed(0),\n originFormat: BigNumberResponse.value.div(10 ** decimals).toFixed(),\n format: helper.number.numberFormat(BigNumberResponse.value.div(10 ** decimals).toFixed(), format, { fallback, min }),\n decimals: String(BigNumberResponse.decimals),\n // isZero: BigNumberResponse.value.isZero(),\n };\n },\n //http://numeraljs.com/ format params does not need to deal with decimal places\n //format: '$0,0' '0a' '0,0' '0,0$'\n numberFormat(str: string | number, format: string = \"0,0\", options: { min?: number; fallback?: string } = {}): string {\n const { fallback = \"0.00\" } = options || {};\n\n if (!str || isNaN(Number(str))) return fallback;\n const numStr = new BigNumber(str).toFixed();\n const countNonZeroNumbers = (_str: string) => {\n const decimalPointIndex = _str.indexOf(\".\");\n if (decimalPointIndex === -1) {\n return 0;\n }\n const decimalPart = _str.substring(decimalPointIndex + 1);\n let trailingZerosCount = 0;\n for (let i = 0; i < decimalPart.length; i++) {\n if (decimalPart[i] === \"0\") {\n trailingZerosCount++;\n } else {\n break;\n }\n }\n return trailingZerosCount;\n };\n\n const fractionDigits = countNonZeroNumbers(format);\n const numberFractionDigits = countNonZeroNumbers(numStr);\n if (options?.min) {\n if (new BigNumber(numStr).isLessThan(new BigNumber(options?.min || 0))) {\n return `< ${numeral(options?.min).format(format)}`;\n }\n }\n const fullStr = new BigNumber(numStr).toFixed();\n let preStr = numeral(fullStr.split(\".\")[0]).format(format.split(\".\")[0]);\n const fractionStr = fullStr.split(\".\")?.[1]?.slice(0, fractionDigits + numberFractionDigits);\n\n if (numberFractionDigits >= fractionDigits) {\n return (preStr + \".\" + fractionStr).replace(/\\.?0+$/, \"\");\n }\n\n if (fractionStr?.[fractionDigits - 1] == \"9\") {\n return (preStr + \".\" + fractionStr.slice(0, fractionDigits - 1) + \"9\").replace(/\\.?0+$/, \"\");\n }\n\n const resultStr = numeral(new BigNumber(numStr).toString()).format(format);\n return resultStr.replace(/\\.?0+$/, \"\");\n },\n },\n address: {\n convertAddress: (addressMode: \"io\" | \"0x\", address: string = \"\"): string => {\n try {\n if (addressMode == \"0x\" && helper.address.validateIoAddress(address)) {\n return from(address).stringEth();\n }\n if (addressMode == \"io\" && helper.address.validateEthAddress(address)) {\n return from(address).string();\n }\n } catch (error) { }\n return address;\n },\n validateEthAddress: (address: string) => /^0x[a-fA-F0-9]{40}$/.test(address),\n validateIoAddress: (address: string) => /^io[a-zA-Z0-9]{39}$/.test(address),\n validateAddress: (address: string) => helper.address.validateEthAddress(address) || helper.address.validateIoAddress(address),\n },\n};\n"]}