@xyo-network/crypto-contract-function-read-plugin 3.6.0 → 4.0.0

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Diviner/Diviner.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { Promisable } from '@xylabs/promise'\nimport type {\n ContractInfo,\n CryptoContractDivinerParams,\n CryptoContractFunctionCallResult,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n asCryptoContractFunctionCallSuccess,\n ContractInfoSchema,\n CryptoContractDivinerConfigSchema,\n CryptoContractDivinerLabels,\n CryptoContractFunctionCallResultSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\n/** @deprecated use EvmCallDiviner instead */\nexport type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined]\n\n/** @deprecated use EvmCallDiviner instead */\nexport class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractDivinerConfigSchema\n static override readonly labels: CryptoContractDivinerLabels = { ...super.labels, ...CryptoContractDivinerLabels }\n\n protected static findCallResult<TResult = string>(\n address: string,\n functionName: string,\n payloads: CryptoContractFunctionCallResult[],\n ): TResult | undefined {\n const foundPayload = payloads.find(payload => payload.functionName === functionName && payload.address === address)\n return asCryptoContractFunctionCallSuccess(foundPayload)?.result as TResult | undefined\n }\n\n protected static matchingExistingField<R = string, T extends Payload = Payload>(objs: T[], field: keyof T): R | undefined {\n const expectedValue = objs.at(0)?.[field] as R\n // eslint-disable-next-line unicorn/no-array-reduce\n const didNotMatch = objs.reduce((prev, obj) => {\n return prev || obj[field] !== expectedValue\n }, false)\n return didNotMatch ? undefined : expectedValue\n }\n\n protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]): ContractInfo {\n return {\n address: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'address'), () => 'Mismatched address'),\n chainId: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'chainId'), () => 'Mismatched chainId'),\n schema: ContractInfoSchema,\n }\n }\n\n protected override async divineHandler(inPayloads: CryptoContractFunctionCallResult[] = []): Promise<ContractInfo[]> {\n const callResults = inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCallResult>(CryptoContractFunctionCallResultSchema))\n const addresses = Object.keys(\n // eslint-disable-next-line unicorn/no-array-reduce\n callResults.reduce<Record<string, boolean>>((prev, result) => {\n if (result.address) {\n prev[result.address] = true\n }\n return prev\n }, {}),\n )\n const result = await Promise.all(\n addresses.map(async (address) => {\n const foundCallResults = callResults.filter(callResult => callResult.address === address)\n const info: ContractInfo = {\n results: await this.reduceResults(foundCallResults),\n ...this.contractInfoRequiredFields(foundCallResults),\n }\n return info\n }),\n )\n\n return result\n }\n\n protected reduceResults(callResults: CryptoContractFunctionCallResult[]): Promisable<ContractInfo['results']> {\n // eslint-disable-next-line unicorn/no-array-reduce\n return callResults.reduce<Record<string, unknown>>((prev, callResult) => {\n prev[callResult.functionName] = asCryptoContractFunctionCallSuccess(callResult)?.result\n return prev\n }, {})\n }\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CryptoContractFunctionReadWitness } from './Witness.ts'\n\n/** @deprecated use EvmCallWitness instead */\nexport const CryptoContractFunctionReadWitnessPlugin = () =>\n\n createPayloadSetWitnessPlugin<CryptoContractFunctionReadWitness>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await CryptoContractFunctionReadWitness.create(params)\n return result\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport type { JsonObject } from '@xylabs/object'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallFailure,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallSuccess,\n CryptoContractFunctionReadWitnessConfig,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n CryptoContractFunctionReadWitnessConfigSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type { WitnessParams } from '@xyo-network/witness-model'\nimport type { InterfaceAbi, Provider } from 'ethers'\nimport { Contract } from 'ethers'\n\n/** @deprecated use EvmCallWitness instead */\nexport type CryptoContractFunctionReadWitnessParams = WitnessParams<\n AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>,\n {\n providers: Provider[]\n }\n>\n\n/** @deprecated use EvmCallWitness instead */\nexport class CryptoContractFunctionReadWitness<\n TParams extends CryptoContractFunctionReadWitnessParams = CryptoContractFunctionReadWitnessParams,\n> extends AbstractWitness<TParams, CryptoContractFunctionCall, CryptoContractFunctionCallResult> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractFunctionReadWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractFunctionReadWitnessConfigSchema\n\n get abi() {\n return assertEx(this.config.abi, () => 'Missing abi') as InterfaceAbi\n }\n\n protected override async observeHandler(inPayloads: CryptoContractFunctionCall[] = []): Promise<CryptoContractFunctionCallResult[]> {\n await this.started('throw')\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCall>(CryptoContractFunctionCallSchema)).map(async ({\n functionName, args, address,\n }) => {\n const { providers } = this.params\n const provider = providers[Date.now() % providers.length] // pick a random provider\n const validatedAddress = assertEx(address ?? this.config.address, () => 'Missing address')\n const validatedFunctionName = assertEx(functionName ?? this.config.functionName, () => 'Missing address')\n const mergedArgs = [...(args ?? this.config.args ?? [])] as JsonObject[]\n\n const contract = new Contract(validatedAddress, this.abi, provider)\n try {\n const result = await contract[validatedFunctionName](...mergedArgs)\n const transformedResult = typeof result === 'bigint' ? result.toString(16) : result\n const observation: CryptoContractFunctionCallSuccess = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n functionName: validatedFunctionName,\n result: transformedResult,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n } catch (ex) {\n const error = ex as Error & { code: string }\n console.log(`Error [${this.config.name}]: ${error.code}`)\n const observation: CryptoContractFunctionCallFailure = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n error: error.code,\n functionName: validatedFunctionName,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n }\n }),\n )\n return observations\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n throw error\n }\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAOzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AAM/B,IAAM,wBAAN,MAAM,+BAAyG,gBAAyB;AAAA,EAC7I,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,iCAAiC;AAAA,EAC7G,OAAyB,sBAA8B;AAAA,EACvD,OAAyB,SAAsC,EAAE,GAAG,MAAM,QAAQ,GAAG,4BAA4B;AAAA,EAEjH,OAAiB,eACf,SACA,cACA,UACqB;AACrB,UAAM,eAAe,SAAS,KAAK,aAAW,QAAQ,iB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AW,OAAO,SAAS,EAAE,IAAI;AAC7E,kBAAM,cAAiD;AAAA,cACrD,SAAS;AAAA,cACT,MAAM;AAAA,cACN,SAAS,QAAQ,MAAM,SAAS,WAAW,GAAG,OAAO;AAAA,cACrD,cAAc;AAAA,cACd,QAAQ;AAAA,cACR,QAAQC;AAAA,YACV;AACA,mBAAO;AAAA,UACT,SAAS,IAAI;AACX,kBAAM,QAAQ;AACd,oBAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,IAAI,EAAE;AACxD,kBAAM,cAAiD;AAAA,cACrD,SAAS;AAAA,cACT,MAAM;AAAA,cACN,SAAS,QAAQ,MAAM,SAAS,WAAW,GAAG,OAAO;AAAA,cACrD,OAAO,MAAM;AAAA,cACb,cAAc;AAAA,cACd,QAAQA;AAAA,YACV;AACA,mBAAO;AAAA,UACT;AAAA,QACF,CAAC;AAAA,MACH;AACA,aAAO;AAAA,IACT,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,OAAO,EAAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;;;ADlFO,IAAM,0CAA0C,MAErD;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,kCAAkC,OAAO,MAAM;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["result","assertEx","CryptoContractFunctionCallResultSchema","isPayloadOfSchemaType"]}
1
+ {"version":3,"sources":["../../src/Diviner/Diviner.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { Promisable } from '@xylabs/promise'\nimport type {\n ContractInfo,\n CryptoContractDivinerParams,\n CryptoContractFunctionCallResult,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n asCryptoContractFunctionCallSuccess,\n ContractInfoSchema,\n CryptoContractDivinerConfigSchema,\n CryptoContractDivinerLabels,\n CryptoContractFunctionCallResultSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\n/** @deprecated use EvmCallDiviner instead */\nexport type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined]\n\n/** @deprecated use EvmCallDiviner instead */\nexport class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractDivinerConfigSchema\n static override readonly labels: CryptoContractDivinerLabels = { ...super.labels, ...CryptoContractDivinerLabels }\n\n protected static findCallResult<TResult = string>(\n address: string,\n functionName: string,\n payloads: CryptoContractFunctionCallResult[],\n ): TResult | undefined {\n const foundPayload = payloads.find(payload => payload.functionName === functionName && payload.address === address)\n return asCryptoContractFunctionCallSuccess(foundPayload)?.result as TResult | undefined\n }\n\n protected static matchingExistingField<R = string, T extends Payload = Payload>(objs: T[], field: keyof T): R | undefined {\n const expectedValue = objs.at(0)?.[field] as R\n // eslint-disable-next-line unicorn/no-array-reduce\n const didNotMatch = objs.reduce((prev, obj) => {\n return prev || obj[field] !== expectedValue\n }, false)\n return didNotMatch ? undefined : expectedValue\n }\n\n protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]): ContractInfo {\n return {\n address: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'address'), () => 'Mismatched address'),\n chainId: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'chainId'), () => 'Mismatched chainId'),\n schema: ContractInfoSchema,\n }\n }\n\n protected override async divineHandler(inPayloads: CryptoContractFunctionCallResult[] = []): Promise<ContractInfo[]> {\n const callResults = inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCallResult>(CryptoContractFunctionCallResultSchema))\n const addresses = Object.keys(\n // eslint-disable-next-line unicorn/no-array-reduce\n callResults.reduce<Record<string, boolean>>((prev, result) => {\n if (result.address) {\n prev[result.address] = true\n }\n return prev\n }, {}),\n )\n const result = await Promise.all(\n addresses.map(async (address) => {\n const foundCallResults = callResults.filter(callResult => callResult.address === address)\n const info: ContractInfo = {\n results: await this.reduceResults(foundCallResults),\n ...this.contractInfoRequiredFields(foundCallResults),\n }\n return info\n }),\n )\n\n return result\n }\n\n protected reduceResults(callResults: CryptoContractFunctionCallResult[]): Promisable<ContractInfo['results']> {\n // eslint-disable-next-line unicorn/no-array-reduce\n return callResults.reduce<Record<string, unknown>>((prev, callResult) => {\n prev[callResult.functionName] = asCryptoContractFunctionCallSuccess(callResult)?.result\n return prev\n }, {})\n }\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CryptoContractFunctionReadWitness } from './Witness.ts'\n\n/** @deprecated use EvmCallWitness instead */\nexport const CryptoContractFunctionReadWitnessPlugin = () =>\n\n createPayloadSetWitnessPlugin<CryptoContractFunctionReadWitness>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await CryptoContractFunctionReadWitness.create(params)\n return result\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport type { JsonObject } from '@xylabs/object'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallFailure,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallSuccess,\n CryptoContractFunctionReadWitnessConfig,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n CryptoContractFunctionReadWitnessConfigSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type { WitnessParams } from '@xyo-network/witness-model'\nimport type { InterfaceAbi, Provider } from 'ethers'\nimport { Contract } from 'ethers'\n\n/** @deprecated use EvmCallWitness instead */\nexport interface CryptoContractFunctionReadWitnessParams extends WitnessParams<\n AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>>\n{\n providers: Provider[]\n}\n\n/** @deprecated use EvmCallWitness instead */\nexport class CryptoContractFunctionReadWitness<\n TParams extends CryptoContractFunctionReadWitnessParams = CryptoContractFunctionReadWitnessParams,\n> extends AbstractWitness<TParams, CryptoContractFunctionCall, CryptoContractFunctionCallResult> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractFunctionReadWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractFunctionReadWitnessConfigSchema\n\n get abi() {\n return assertEx(this.config.abi, () => 'Missing abi') as InterfaceAbi\n }\n\n protected override async observeHandler(inPayloads: CryptoContractFunctionCall[] = []): Promise<CryptoContractFunctionCallResult[]> {\n await this.started('throw')\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCall>(CryptoContractFunctionCallSchema)).map(async ({\n functionName, args, address,\n }) => {\n const { providers } = this.params\n const provider = providers[Date.now() % providers.length] // pick a random provider\n const validatedAddress = assertEx(address ?? this.config.address, () => 'Missing address')\n const validatedFunctionName = assertEx(functionName ?? this.config.functionName, () => 'Missing address')\n const mergedArgs = [...(args ?? this.config.args ?? [])] as JsonObject[]\n\n const contract = new Contract(validatedAddress, this.abi, provider)\n try {\n const result = await contract[validatedFunctionName](...mergedArgs)\n const transformedResult = typeof result === 'bigint' ? result.toString(16) : result\n const observation: CryptoContractFunctionCallSuccess = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n functionName: validatedFunctionName,\n result: transformedResult,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n } catch (ex) {\n const error = ex as Error & { code: string }\n console.log(`Error [${this.config.name}]: ${error.code}`)\n const observation: CryptoContractFunctionCallFailure = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n error: error.code,\n functionName: validatedFunctionName,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n }\n }),\n )\n return observations\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n throw error\n }\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAOzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AAM/B,IAAM,wBAAN,MAAM,+BAAyG,gBAAyB;AAAA,EAC7I,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,iCAAiC;AAAA,EAC7G,OAAyB,sBAA8B;AAAA,EACvD,OAAyB,SAAsC,EAAE,GAAG,MAAM,QAAQ,GAAG,4BAA4B;AAAA,EAEjH,OAAiB,eACf,SACA,cACA,UACqB;AACrB,UAAM,eAAe,SAAS,KAAK,aAAW,QAAQ,iBAAiB,gBAAgB,QAAQ,YAAY,OAAO;AAClH,WAAO,oCAAoC,YAAY,GAAG;AAAA,EAC5D;AAAA,EAEA,OAAiB,sBAA+D,MAAW,OAA+B;AACxH,UAAM,gBAAgB,KAAK,GAAG,CAAC,IAAI,KAAK;AAExC,UAAM,cAAc,KAAK,OAAO,CAAC,MAAM,QAAQ;AAC7C,aAAO,QAAQ,IAAI,KAAK,MAAM;AAAA,IAChC,GAAG,KAAK;AACR,WAAO,cAAc,SAAY;AAAA,EACnC;AAAA,EAEU,2BAA2B,aAA+D;AAClG,WAAO;AAAA,MACL,SAAS,SAA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M;AAAA,cACN,SAAS,QAAQ,MAAM,SAAS,WAAW,GAAG,OAAO;AAAA,cACrD,OAAO,MAAM;AAAA,cACb,cAAc;AAAA,cACd,QAAQA;AAAA,YACV;AACA,mBAAO;AAAA,UACT;AAAA,QACF,CAAC;AAAA,MACH;AACA,aAAO;AAAA,IACT,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,OAAO,EAAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;;;ADjFO,IAAM,0CAA0C,MAErD;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,kCAAkC,OAAO,MAAM;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["result","assertEx","CryptoContractFunctionCallResultSchema","isPayloadOfSchemaType"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Diviner/Diviner.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { Promisable } from '@xylabs/promise'\nimport type {\n ContractInfo,\n CryptoContractDivinerParams,\n CryptoContractFunctionCallResult,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n asCryptoContractFunctionCallSuccess,\n ContractInfoSchema,\n CryptoContractDivinerConfigSchema,\n CryptoContractDivinerLabels,\n CryptoContractFunctionCallResultSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\n/** @deprecated use EvmCallDiviner instead */\nexport type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined]\n\n/** @deprecated use EvmCallDiviner instead */\nexport class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractDivinerConfigSchema\n static override readonly labels: CryptoContractDivinerLabels = { ...super.labels, ...CryptoContractDivinerLabels }\n\n protected static findCallResult<TResult = string>(\n address: string,\n functionName: string,\n payloads: CryptoContractFunctionCallResult[],\n ): TResult | undefined {\n const foundPayload = payloads.find(payload => payload.functionName === functionName && payload.address === address)\n return asCryptoContractFunctionCallSuccess(foundPayload)?.result as TResult | undefined\n }\n\n protected static matchingExistingField<R = string, T extends Payload = Payload>(objs: T[], field: keyof T): R | undefined {\n const expectedValue = objs.at(0)?.[field] as R\n // eslint-disable-next-line unicorn/no-array-reduce\n const didNotMatch = objs.reduce((prev, obj) => {\n return prev || obj[field] !== expectedValue\n }, false)\n return didNotMatch ? undefined : expectedValue\n }\n\n protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]): ContractInfo {\n return {\n address: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'address'), () => 'Mismatched address'),\n chainId: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'chainId'), () => 'Mismatched chainId'),\n schema: ContractInfoSchema,\n }\n }\n\n protected override async divineHandler(inPayloads: CryptoContractFunctionCallResult[] = []): Promise<ContractInfo[]> {\n const callResults = inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCallResult>(CryptoContractFunctionCallResultSchema))\n const addresses = Object.keys(\n // eslint-disable-next-line unicorn/no-array-reduce\n callResults.reduce<Record<string, boolean>>((prev, result) => {\n if (result.address) {\n prev[result.address] = true\n }\n return prev\n }, {}),\n )\n const result = await Promise.all(\n addresses.map(async (address) => {\n const foundCallResults = callResults.filter(callResult => callResult.address === address)\n const info: ContractInfo = {\n results: await this.reduceResults(foundCallResults),\n ...this.contractInfoRequiredFields(foundCallResults),\n }\n return info\n }),\n )\n\n return result\n }\n\n protected reduceResults(callResults: CryptoContractFunctionCallResult[]): Promisable<ContractInfo['results']> {\n // eslint-disable-next-line unicorn/no-array-reduce\n return callResults.reduce<Record<string, unknown>>((prev, callResult) => {\n prev[callResult.functionName] = asCryptoContractFunctionCallSuccess(callResult)?.result\n return prev\n }, {})\n }\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CryptoContractFunctionReadWitness } from './Witness.ts'\n\n/** @deprecated use EvmCallWitness instead */\nexport const CryptoContractFunctionReadWitnessPlugin = () =>\n\n createPayloadSetWitnessPlugin<CryptoContractFunctionReadWitness>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await CryptoContractFunctionReadWitness.create(params)\n return result\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport type { JsonObject } from '@xylabs/object'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallFailure,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallSuccess,\n CryptoContractFunctionReadWitnessConfig,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n CryptoContractFunctionReadWitnessConfigSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type { WitnessParams } from '@xyo-network/witness-model'\nimport type { InterfaceAbi, Provider } from 'ethers'\nimport { Contract } from 'ethers'\n\n/** @deprecated use EvmCallWitness instead */\nexport type CryptoContractFunctionReadWitnessParams = WitnessParams<\n AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>,\n {\n providers: Provider[]\n }\n>\n\n/** @deprecated use EvmCallWitness instead */\nexport class CryptoContractFunctionReadWitness<\n TParams extends CryptoContractFunctionReadWitnessParams = CryptoContractFunctionReadWitnessParams,\n> extends AbstractWitness<TParams, CryptoContractFunctionCall, CryptoContractFunctionCallResult> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractFunctionReadWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractFunctionReadWitnessConfigSchema\n\n get abi() {\n return assertEx(this.config.abi, () => 'Missing abi') as InterfaceAbi\n }\n\n protected override async observeHandler(inPayloads: CryptoContractFunctionCall[] = []): Promise<CryptoContractFunctionCallResult[]> {\n await this.started('throw')\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCall>(CryptoContractFunctionCallSchema)).map(async ({\n functionName, args, address,\n }) => {\n const { providers } = this.params\n const provider = providers[Date.now() % providers.length] // pick a random provider\n const validatedAddress = assertEx(address ?? this.config.address, () => 'Missing address')\n const validatedFunctionName = assertEx(functionName ?? this.config.functionName, () => 'Missing address')\n const mergedArgs = [...(args ?? this.config.args ?? [])] as JsonObject[]\n\n const contract = new Contract(validatedAddress, this.abi, provider)\n try {\n const result = await contract[validatedFunctionName](...mergedArgs)\n const transformedResult = typeof result === 'bigint' ? result.toString(16) : result\n const observation: CryptoContractFunctionCallSuccess = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n functionName: validatedFunctionName,\n result: transformedResult,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n } catch (ex) {\n const error = ex as Error & { code: string }\n console.log(`Error [${this.config.name}]: ${error.code}`)\n const observation: CryptoContractFunctionCallFailure = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n error: error.code,\n functionName: validatedFunctionName,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n }\n }),\n )\n return observations\n } catch (ex) {\n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;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,kCAAkC,OAAO,MAAM;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["result","assertEx","CryptoContractFunctionCallResultSchema","isPayloadOfSchemaType"]}
1
+ {"version":3,"sources":["../../src/Diviner/Diviner.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { Promisable } from '@xylabs/promise'\nimport type {\n ContractInfo,\n CryptoContractDivinerParams,\n CryptoContractFunctionCallResult,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n asCryptoContractFunctionCallSuccess,\n ContractInfoSchema,\n CryptoContractDivinerConfigSchema,\n CryptoContractDivinerLabels,\n CryptoContractFunctionCallResultSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\n/** @deprecated use EvmCallDiviner instead */\nexport type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined]\n\n/** @deprecated use EvmCallDiviner instead */\nexport class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractDivinerConfigSchema\n static override readonly labels: CryptoContractDivinerLabels = { ...super.labels, ...CryptoContractDivinerLabels }\n\n protected static findCallResult<TResult = string>(\n address: string,\n functionName: string,\n payloads: CryptoContractFunctionCallResult[],\n ): TResult | undefined {\n const foundPayload = payloads.find(payload => payload.functionName === functionName && payload.address === address)\n return asCryptoContractFunctionCallSuccess(foundPayload)?.result as TResult | undefined\n }\n\n protected static matchingExistingField<R = string, T extends Payload = Payload>(objs: T[], field: keyof T): R | undefined {\n const expectedValue = objs.at(0)?.[field] as R\n // eslint-disable-next-line unicorn/no-array-reduce\n const didNotMatch = objs.reduce((prev, obj) => {\n return prev || obj[field] !== expectedValue\n }, false)\n return didNotMatch ? undefined : expectedValue\n }\n\n protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]): ContractInfo {\n return {\n address: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'address'), () => 'Mismatched address'),\n chainId: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'chainId'), () => 'Mismatched chainId'),\n schema: ContractInfoSchema,\n }\n }\n\n protected override async divineHandler(inPayloads: CryptoContractFunctionCallResult[] = []): Promise<ContractInfo[]> {\n const callResults = inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCallResult>(CryptoContractFunctionCallResultSchema))\n const addresses = Object.keys(\n // eslint-disable-next-line unicorn/no-array-reduce\n callResults.reduce<Record<string, boolean>>((prev, result) => {\n if (result.address) {\n prev[result.address] = true\n }\n return prev\n }, {}),\n )\n const result = await Promise.all(\n addresses.map(async (address) => {\n const foundCallResults = callResults.filter(callResult => callResult.address === address)\n const info: ContractInfo = {\n results: await this.reduceResults(foundCallResults),\n ...this.contractInfoRequiredFields(foundCallResults),\n }\n return info\n }),\n )\n\n return result\n }\n\n protected reduceResults(callResults: CryptoContractFunctionCallResult[]): Promisable<ContractInfo['results']> {\n // eslint-disable-next-line unicorn/no-array-reduce\n return callResults.reduce<Record<string, unknown>>((prev, callResult) => {\n prev[callResult.functionName] = asCryptoContractFunctionCallSuccess(callResult)?.result\n return prev\n }, {})\n }\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CryptoContractFunctionReadWitness } from './Witness.ts'\n\n/** @deprecated use EvmCallWitness instead */\nexport const CryptoContractFunctionReadWitnessPlugin = () =>\n\n createPayloadSetWitnessPlugin<CryptoContractFunctionReadWitness>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await CryptoContractFunctionReadWitness.create(params)\n return result\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport type { JsonObject } from '@xylabs/object'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallFailure,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallSuccess,\n CryptoContractFunctionReadWitnessConfig,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n CryptoContractFunctionReadWitnessConfigSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type { WitnessParams } from '@xyo-network/witness-model'\nimport type { InterfaceAbi, Provider } from 'ethers'\nimport { Contract } from 'ethers'\n\n/** @deprecated use EvmCallWitness instead */\nexport interface CryptoContractFunctionReadWitnessParams extends WitnessParams<\n AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>>\n{\n providers: Provider[]\n}\n\n/** @deprecated use EvmCallWitness instead */\nexport class CryptoContractFunctionReadWitness<\n TParams extends CryptoContractFunctionReadWitnessParams = CryptoContractFunctionReadWitnessParams,\n> extends AbstractWitness<TParams, CryptoContractFunctionCall, CryptoContractFunctionCallResult> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractFunctionReadWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractFunctionReadWitnessConfigSchema\n\n get abi() {\n return assertEx(this.config.abi, () => 'Missing abi') as InterfaceAbi\n }\n\n protected override async observeHandler(inPayloads: CryptoContractFunctionCall[] = []): Promise<CryptoContractFunctionCallResult[]> {\n await this.started('throw')\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCall>(CryptoContractFunctionCallSchema)).map(async ({\n functionName, args, address,\n }) => {\n const { providers } = this.params\n const provider = providers[Date.now() % providers.length] // pick a random provider\n const validatedAddress = assertEx(address ?? this.config.address, () => 'Missing address')\n const validatedFunctionName = assertEx(functionName ?? this.config.functionName, () => 'Missing address')\n const mergedArgs = [...(args ?? this.config.args ?? [])] as JsonObject[]\n\n const contract = new Contract(validatedAddress, this.abi, provider)\n try {\n const result = await contract[validatedFunctionName](...mergedArgs)\n const transformedResult = typeof result === 'bigint' ? result.toString(16) : result\n const observation: CryptoContractFunctionCallSuccess = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n functionName: validatedFunctionName,\n result: transformedResult,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n } catch (ex) {\n const error = ex as Error & { code: string }\n console.log(`Error [${this.config.name}]: ${error.code}`)\n const observation: CryptoContractFunctionCallFailure = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n error: error.code,\n functionName: validatedFunctionName,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n }\n }),\n )\n return observations\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n throw error\n }\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAOzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AAM/B,IAAM,wBAAN,MAAM,+BAAyG,gBAAyB;AAAA,EAC7I,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,iCAAiC;AAAA,EAC7G,OAAyB,sBAA8B;AAAA,EACvD,OAAyB,SAAsC,EAAE,GAAG,M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,QAAQ;AAClE,cAAI;AACF,kBAAM,SAAS,MAAM,SAAS,qBAAqB,EAAE,GAAG,UAAU;AAClE,kBAAM,oBAAoB,OAAO,WAAW,WAAW,OAAO,SAAS,EAAE,IAAI;AAC7E,kBAAM,cAAiD;AAAA,cACrD,SAAS;AAAA,cACT,MAAM;AAAA,cACN,SAAS,QAAQ,MAAM,SAAS,WAAW,GAAG,OAAO;AAAA,cACrD,cAAc;AAAA,cACd,QAAQ;AAAA,cACR,QAAQC;AAAA,YACV;AACA,mBAAO;AAAA,UACT,SAAS,IAAI;AACX,kBAAM,QAAQ;AACd,oBAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,IAAI,EAAE;AACxD,kBAAM,cAAiD;AAAA,cACrD,SAAS;AAAA,cACT,MAAM;AAAA,cACN,SAAS,QAAQ,MAAM,SAAS,WAAW,GAAG,OAAO;AAAA,cACrD,OAAO,MAAM;AAAA,cACb,cAAc;AAAA,cACd,QAAQA;AAAA,YACV;AACA,mBAAO;AAAA,UACT;AAAA,QACF,CAAC;AAAA,MACH;AACA,aAAO;AAAA,IACT,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,OAAO,EAAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;;;ADjFO,IAAM,0CAA0C,MAErD;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,kCAAkC,OAAO,MAAM;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["result","assertEx","CryptoContractFunctionCallResultSchema","isPayloadOfSchemaType"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Diviner/Diviner.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { Promisable } from '@xylabs/promise'\nimport type {\n ContractInfo,\n CryptoContractDivinerParams,\n CryptoContractFunctionCallResult,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n asCryptoContractFunctionCallSuccess,\n ContractInfoSchema,\n CryptoContractDivinerConfigSchema,\n CryptoContractDivinerLabels,\n CryptoContractFunctionCallResultSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\n/** @deprecated use EvmCallDiviner instead */\nexport type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined]\n\n/** @deprecated use EvmCallDiviner instead */\nexport class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractDivinerConfigSchema\n static override readonly labels: CryptoContractDivinerLabels = { ...super.labels, ...CryptoContractDivinerLabels }\n\n protected static findCallResult<TResult = string>(\n address: string,\n functionName: string,\n payloads: CryptoContractFunctionCallResult[],\n ): TResult | undefined {\n const foundPayload = payloads.find(payload => payload.functionName === functionName && payload.address === address)\n return asCryptoContractFunctionCallSuccess(foundPayload)?.result as TResult | undefined\n }\n\n protected static matchingExistingField<R = string, T extends Payload = Payload>(objs: T[], field: keyof T): R | undefined {\n const expectedValue = objs.at(0)?.[field] as R\n // eslint-disable-next-line unicorn/no-array-reduce\n const didNotMatch = objs.reduce((prev, obj) => {\n return prev || obj[field] !== expectedValue\n }, false)\n return didNotMatch ? undefined : expectedValue\n }\n\n protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]): ContractInfo {\n return {\n address: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'address'), () => 'Mismatched address'),\n chainId: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'chainId'), () => 'Mismatched chainId'),\n schema: ContractInfoSchema,\n }\n }\n\n protected override async divineHandler(inPayloads: CryptoContractFunctionCallResult[] = []): Promise<ContractInfo[]> {\n const callResults = inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCallResult>(CryptoContractFunctionCallResultSchema))\n const addresses = Object.keys(\n // eslint-disable-next-line unicorn/no-array-reduce\n callResults.reduce<Record<string, boolean>>((prev, result) => {\n if (result.address) {\n prev[result.address] = true\n }\n return prev\n }, {}),\n )\n const result = await Promise.all(\n addresses.map(async (address) => {\n const foundCallResults = callResults.filter(callResult => callResult.address === address)\n const info: ContractInfo = {\n results: await this.reduceResults(foundCallResults),\n ...this.contractInfoRequiredFields(foundCallResults),\n }\n return info\n }),\n )\n\n return result\n }\n\n protected reduceResults(callResults: CryptoContractFunctionCallResult[]): Promisable<ContractInfo['results']> {\n // eslint-disable-next-line unicorn/no-array-reduce\n return callResults.reduce<Record<string, unknown>>((prev, callResult) => {\n prev[callResult.functionName] = asCryptoContractFunctionCallSuccess(callResult)?.result\n return prev\n }, {})\n }\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CryptoContractFunctionReadWitness } from './Witness.ts'\n\n/** @deprecated use EvmCallWitness instead */\nexport const CryptoContractFunctionReadWitnessPlugin = () =>\n\n createPayloadSetWitnessPlugin<CryptoContractFunctionReadWitness>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await CryptoContractFunctionReadWitness.create(params)\n return result\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport type { JsonObject } from '@xylabs/object'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallFailure,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallSuccess,\n CryptoContractFunctionReadWitnessConfig,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n CryptoContractFunctionReadWitnessConfigSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type { WitnessParams } from '@xyo-network/witness-model'\nimport type { InterfaceAbi, Provider } from 'ethers'\nimport { Contract } from 'ethers'\n\n/** @deprecated use EvmCallWitness instead */\nexport type CryptoContractFunctionReadWitnessParams = WitnessParams<\n AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>,\n {\n providers: Provider[]\n }\n>\n\n/** @deprecated use EvmCallWitness instead */\nexport class CryptoContractFunctionReadWitness<\n TParams extends CryptoContractFunctionReadWitnessParams = CryptoContractFunctionReadWitnessParams,\n> extends AbstractWitness<TParams, CryptoContractFunctionCall, CryptoContractFunctionCallResult> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractFunctionReadWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractFunctionReadWitnessConfigSchema\n\n get abi() {\n return assertEx(this.config.abi, () => 'Missing abi') as InterfaceAbi\n }\n\n protected override async observeHandler(inPayloads: CryptoContractFunctionCall[] = []): Promise<CryptoContractFunctionCallResult[]> {\n await this.started('throw')\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCall>(CryptoContractFunctionCallSchema)).map(async ({\n functionName, args, address,\n }) => {\n const { providers } = this.params\n const provider = providers[Date.now() % providers.length] // pick a random provider\n const validatedAddress = assertEx(address ?? this.config.address, () => 'Missing address')\n const validatedFunctionName = assertEx(functionName ?? this.config.functionName, () => 'Missing address')\n const mergedArgs = [...(args ?? this.config.args ?? [])] as JsonObject[]\n\n const contract = new Contract(validatedAddress, this.abi, provider)\n try {\n const result = await contract[validatedFunctionName](...mergedArgs)\n const transformedResult = typeof result === 'bigint' ? result.toString(16) : result\n const observation: CryptoContractFunctionCallSuccess = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n functionName: validatedFunctionName,\n result: transformedResult,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n } catch (ex) {\n const error = ex as Error & { code: string }\n console.log(`Error [${this.config.name}]: ${error.code}`)\n const observation: CryptoContractFunctionCallFailure = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n error: error.code,\n functionName: validatedFunctionName,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n }\n }),\n )\n return observations\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n throw error\n }\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAOzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AAM/B,IAAM,wBAAN,MAAM,+BAAyG,gBAAyB;AAAA,EAC7I,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,iCAAiC;AAAA,EAC7G,OAAyB,sBAA8B;AAAA,EACvD,OAAyB,SAAsC,EAAE,GAAG,MAAM,QAAQ,GAAG,4BAA4B;AAAA,EAEjH,OAAiB,eACf,SACA,cACA,UACqB;AACrB,UAAM,eAAe,SAAS,KAAK,aAAW,QAAQ,iBAAiB,gBAAgB,QAAQ,YAAY,OAAO;AAClH,WAAO,oCAAoC,YAAY,GAAG;AAAA,EAC5D;AAAA,EAEA,OAAiB,sBAA+D,MAAW,OAA+B;AACxH,UAAM,gBAAgB,KAAK,GAAG,CAAC,IAAI,KAAK;AAExC,UAAM,cAAc,KAAK,OAAO,CAAC,MAAM,QAAQ;AAC7C,aAAO,QAAQ,IAAI,KAA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QAAQ;AACd,oBAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,IAAI,EAAE;AACxD,kBAAM,cAAiD;AAAA,cACrD,SAAS;AAAA,cACT,MAAM;AAAA,cACN,SAAS,QAAQ,MAAM,SAAS,WAAW,GAAG,OAAO;AAAA,cACrD,OAAO,MAAM;AAAA,cACb,cAAc;AAAA,cACd,QAAQA;AAAA,YACV;AACA,mBAAO;AAAA,UACT;AAAA,QACF,CAAC;AAAA,MACH;AACA,aAAO;AAAA,IACT,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,IAAI,UAAU,KAAK,OAAO,IAAI,MAAM,MAAM,OAAO,EAAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;;;ADlFO,IAAM,0CAA0C,MAErD;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,kCAAkC,OAAO,MAAM;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["result","assertEx","CryptoContractFunctionCallResultSchema","isPayloadOfSchemaType"]}
1
+ {"version":3,"sources":["../../src/Diviner/Diviner.ts","../../src/Plugin.ts","../../src/Witness.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { Promisable } from '@xylabs/promise'\nimport type {\n ContractInfo,\n CryptoContractDivinerParams,\n CryptoContractFunctionCallResult,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n asCryptoContractFunctionCallSuccess,\n ContractInfoSchema,\n CryptoContractDivinerConfigSchema,\n CryptoContractDivinerLabels,\n CryptoContractFunctionCallResultSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\n\n/** @deprecated use EvmCallDiviner instead */\nexport type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined]\n\n/** @deprecated use EvmCallDiviner instead */\nexport class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractDivinerConfigSchema\n static override readonly labels: CryptoContractDivinerLabels = { ...super.labels, ...CryptoContractDivinerLabels }\n\n protected static findCallResult<TResult = string>(\n address: string,\n functionName: string,\n payloads: CryptoContractFunctionCallResult[],\n ): TResult | undefined {\n const foundPayload = payloads.find(payload => payload.functionName === functionName && payload.address === address)\n return asCryptoContractFunctionCallSuccess(foundPayload)?.result as TResult | undefined\n }\n\n protected static matchingExistingField<R = string, T extends Payload = Payload>(objs: T[], field: keyof T): R | undefined {\n const expectedValue = objs.at(0)?.[field] as R\n // eslint-disable-next-line unicorn/no-array-reduce\n const didNotMatch = objs.reduce((prev, obj) => {\n return prev || obj[field] !== expectedValue\n }, false)\n return didNotMatch ? undefined : expectedValue\n }\n\n protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]): ContractInfo {\n return {\n address: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'address'), () => 'Mismatched address'),\n chainId: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'chainId'), () => 'Mismatched chainId'),\n schema: ContractInfoSchema,\n }\n }\n\n protected override async divineHandler(inPayloads: CryptoContractFunctionCallResult[] = []): Promise<ContractInfo[]> {\n const callResults = inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCallResult>(CryptoContractFunctionCallResultSchema))\n const addresses = Object.keys(\n // eslint-disable-next-line unicorn/no-array-reduce\n callResults.reduce<Record<string, boolean>>((prev, result) => {\n if (result.address) {\n prev[result.address] = true\n }\n return prev\n }, {}),\n )\n const result = await Promise.all(\n addresses.map(async (address) => {\n const foundCallResults = callResults.filter(callResult => callResult.address === address)\n const info: ContractInfo = {\n results: await this.reduceResults(foundCallResults),\n ...this.contractInfoRequiredFields(foundCallResults),\n }\n return info\n }),\n )\n\n return result\n }\n\n protected reduceResults(callResults: CryptoContractFunctionCallResult[]): Promisable<ContractInfo['results']> {\n // eslint-disable-next-line unicorn/no-array-reduce\n return callResults.reduce<Record<string, unknown>>((prev, callResult) => {\n prev[callResult.functionName] = asCryptoContractFunctionCallSuccess(callResult)?.result\n return prev\n }, {})\n }\n}\n","import { NftSchema } from '@xyo-network/crypto-nft-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CryptoContractFunctionReadWitness } from './Witness.ts'\n\n/** @deprecated use EvmCallWitness instead */\nexport const CryptoContractFunctionReadWitnessPlugin = () =>\n\n createPayloadSetWitnessPlugin<CryptoContractFunctionReadWitness>(\n { required: { [NftSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await CryptoContractFunctionReadWitness.create(params)\n return result\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport type { JsonObject } from '@xylabs/object'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallFailure,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallSuccess,\n CryptoContractFunctionReadWitnessConfig,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport {\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n CryptoContractFunctionReadWitnessConfigSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type { WitnessParams } from '@xyo-network/witness-model'\nimport type { InterfaceAbi, Provider } from 'ethers'\nimport { Contract } from 'ethers'\n\n/** @deprecated use EvmCallWitness instead */\nexport interface CryptoContractFunctionReadWitnessParams extends WitnessParams<\n AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>>\n{\n providers: Provider[]\n}\n\n/** @deprecated use EvmCallWitness instead */\nexport class CryptoContractFunctionReadWitness<\n TParams extends CryptoContractFunctionReadWitnessParams = CryptoContractFunctionReadWitnessParams,\n> extends AbstractWitness<TParams, CryptoContractFunctionCall, CryptoContractFunctionCallResult> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CryptoContractFunctionReadWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = CryptoContractFunctionReadWitnessConfigSchema\n\n get abi() {\n return assertEx(this.config.abi, () => 'Missing abi') as InterfaceAbi\n }\n\n protected override async observeHandler(inPayloads: CryptoContractFunctionCall[] = []): Promise<CryptoContractFunctionCallResult[]> {\n await this.started('throw')\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCall>(CryptoContractFunctionCallSchema)).map(async ({\n functionName, args, address,\n }) => {\n const { providers } = this.params\n const provider = providers[Date.now() % providers.length] // pick a random provider\n const validatedAddress = assertEx(address ?? this.config.address, () => 'Missing address')\n const validatedFunctionName = assertEx(functionName ?? this.config.functionName, () => 'Missing address')\n const mergedArgs = [...(args ?? this.config.args ?? [])] as JsonObject[]\n\n const contract = new Contract(validatedAddress, this.abi, provider)\n try {\n const result = await contract[validatedFunctionName](...mergedArgs)\n const transformedResult = typeof result === 'bigint' ? result.toString(16) : result\n const observation: CryptoContractFunctionCallSuccess = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n functionName: validatedFunctionName,\n result: transformedResult,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n } catch (ex) {\n const error = ex as Error & { code: string }\n console.log(`Error [${this.config.name}]: ${error.code}`)\n const observation: CryptoContractFunctionCallFailure = {\n address: validatedAddress,\n args: mergedArgs,\n chainId: Number((await provider.getNetwork()).chainId),\n error: error.code,\n functionName: validatedFunctionName,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n }\n }),\n )\n return observations\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n throw error\n }\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAOzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAEhC,SAAS,6BAA6B;AAM/B,IAAM,wBAAN,MAAM,+BAAyG,gBAAyB;AAAA,EAC7I,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,iCAAiC;AAAA,EAC7G,OAAyB,sBAA8B;AAAA,EACvD,OAAyB,SAAsC,EAAE,GAAG,MAAM,QAAQ,GAAG,4BAA4B;AAAA,EAEjH,OAAiB,eACf,SACA,cACA,UACqB;AACrB,UAAM,eAAe,SAAS,KAAK,aAAW,QAAQ,iBAAiB,gBAAgB,QAAQ,YAAY,OAAO;AAClH,WAAO,oCAAoC,YAAY,GAAG;AAAA,EAC5D;AAAA,EAEA,OAAiB,sBAA+D,MAAW,OAA+B;AACxH,UAAM,gBAAgB,KAAK,GAAG,CAAC,IAAI,KAAK;AAExC,UAAM,cAAc,KAAK,OAAO,CAAC,MAAM,QAAQ;AAC7C,aAAO,QAAQ,IAAI,KAAK,MAAM;AAAA,IAChC,GAAG,KAAK;AACR,WAAO,cAAc,SAAY;AAAA,EACnC;AAAA,EAEU,2BAA2B,aAA+D;AAClG,WAAO;AAAA,MACL,SAAS,SAAS,uBAAsB,sBAAsB,aAAa,SAAS,GAAG,MAAM,oBAAoB;AAAA,MACjH,SAAS,SAAS,uBAAsB,sBAAsB,aAAa,SAAS,GAAG,MAAM,oBAAoB;AAAA,MACjH,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EAEA,MAAyB,cAAc,aAAiD,CAAC,GAA4B;AACnH,UAAM,cAAc,WAAW,OAAO,sBAAwD,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U,KAAK,OAAO,IAAI,MAAM,MAAM,OAAO,EAAE;AAC3D,YAAM;AAAA,IACR;AAAA,EACF;AACF;;;ADjFO,IAAM,0CAA0C,MAErD;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACzD;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,kCAAkC,OAAO,MAAM;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["result","assertEx","CryptoContractFunctionCallResultSchema","isPayloadOfSchemaType"]}
@@ -1,14 +1,4 @@
1
1
  import { CryptoContractFunctionReadWitness } from './Witness.ts';
2
2
  /** @deprecated use EvmCallWitness instead */
3
- export declare const CryptoContractFunctionReadWitnessPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<CryptoContractFunctionReadWitness<import(".store/@xylabs-base-npm-4.10.0-083847c57a/package").BaseParamsFields & {
4
- account?: import(".store/@xyo-network-account-model-npm-3.17.0-f4dfdc79cc/package").AccountInstance | "random";
5
- addToResolvers?: boolean;
6
- additionalSigners?: import(".store/@xyo-network-account-model-npm-3.17.0-f4dfdc79cc/package").AccountInstance[];
7
- allowNameResolution?: boolean;
8
- config: import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/crypto-contract-function-read-payload-plugin").CryptoContractFunctionReadWitnessConfig>;
9
- ephemeralQueryAccountEnabled?: boolean;
10
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
11
- } & import("@xyo-network/module-model").ModuleChildrenParams & {
12
- providers: import("ethers").Provider[];
13
- }>>;
3
+ export declare const CryptoContractFunctionReadWitnessPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<CryptoContractFunctionReadWitness<import("./Witness.ts").CryptoContractFunctionReadWitnessParams>>;
14
4
  //# sourceMappingURL=Plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAA;AAEhE,6CAA6C;AAC7C,eAAO,MAAM,uCAAuC;;;;;;;;;;GAUjD,CAAA"}
1
+ {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAA;AAEhE,6CAA6C;AAC7C,eAAO,MAAM,uCAAuC,2KAUjD,CAAA"}
@@ -5,9 +5,9 @@ import type { Schema } from '@xyo-network/payload-model';
5
5
  import type { WitnessParams } from '@xyo-network/witness-model';
6
6
  import type { InterfaceAbi, Provider } from 'ethers';
7
7
  /** @deprecated use EvmCallWitness instead */
8
- export type CryptoContractFunctionReadWitnessParams = WitnessParams<AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>, {
8
+ export interface CryptoContractFunctionReadWitnessParams extends WitnessParams<AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>> {
9
9
  providers: Provider[];
10
- }>;
10
+ }
11
11
  /** @deprecated use EvmCallWitness instead */
12
12
  export declare class CryptoContractFunctionReadWitness<TParams extends CryptoContractFunctionReadWitnessParams = CryptoContractFunctionReadWitnessParams> extends AbstractWitness<TParams, CryptoContractFunctionCall, CryptoContractFunctionCallResult> {
13
13
  static readonly configSchemas: Schema[];
@@ -1 +1 @@
1
- {"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EACV,0BAA0B,EAE1B,gCAAgC,EAEhC,uCAAuC,EACxC,MAAM,2DAA2D,CAAA;AAMlE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,KAAK,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7C,qBAAa,iCAAiC,CAC5C,OAAO,SAAS,uCAAuC,GAAG,uCAAuC,CACjG,SAAQ,eAAe,CAAC,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,CAAC;IAC9F,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA0E;IAC1H,gBAAyB,mBAAmB,EAAE,MAAM,CAAgD;IAEpG,IAAI,GAAG,IACoD,YAAY,CACtE;cAEwB,cAAc,CAAC,UAAU,GAAE,0BAA0B,EAAO,GAAG,OAAO,CAAC,gCAAgC,EAAE,CAAC;CAgDpI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/crypto-contract-function-read-plugin",
3
- "version": "3.6.0",
3
+ "version": "4.0.0",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -29,48 +29,48 @@
29
29
  "module": "dist/neutral/index.mjs",
30
30
  "types": "dist/types/index.d.ts",
31
31
  "dependencies": {
32
- "@xylabs/assert": "^4.10.0",
33
- "@xylabs/promise": "^4.10.0",
34
- "@xyo-network/abstract-witness": "^3.17.0",
35
- "@xyo-network/crypto-contract-function-read-payload-plugin": "^3.6.0",
36
- "@xyo-network/crypto-nft-payload-plugin": "^3.6.0",
37
- "@xyo-network/diviner-abstract": "^3.17.0",
38
- "@xyo-network/module-model": "^3.17.0",
39
- "@xyo-network/payload-model": "^3.17.0",
40
- "@xyo-network/payloadset-plugin": "^3.17.0",
41
- "@xyo-network/witness-model": "^3.17.0",
42
- "ethers": "^6.14.1"
32
+ "@xylabs/assert": "^4.12.31",
33
+ "@xylabs/promise": "^4.12.31",
34
+ "@xyo-network/abstract-witness": "^4.0.1",
35
+ "@xyo-network/crypto-contract-function-read-payload-plugin": "^4.0.0",
36
+ "@xyo-network/crypto-nft-payload-plugin": "^4.0.0",
37
+ "@xyo-network/diviner-abstract": "^4.0.1",
38
+ "@xyo-network/module-model": "^4.0.1",
39
+ "@xyo-network/payload-model": "^4.0.1",
40
+ "@xyo-network/payloadset-plugin": "^4.0.1",
41
+ "@xyo-network/witness-model": "^4.0.1",
42
+ "ethers": "^6.15.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@xylabs/delay": "^4.10.0",
46
- "@xylabs/hex": "^4.10.0",
47
- "@xylabs/object": "^4.10.0",
48
- "@xylabs/ts-scripts-yarn3": "^6.5.7",
49
- "@xylabs/tsconfig": "^6.5.7",
50
- "@xylabs/vitest-extended": "^4.10.0",
51
- "@xyo-network/archivist-memory": "^3.17.0",
52
- "@xyo-network/diviner-boundwitness-memory": "^3.17.0",
53
- "@xyo-network/diviner-jsonpatch": "^3.17.0",
54
- "@xyo-network/diviner-jsonpath-aggregate-memory": "^3.17.0",
55
- "@xyo-network/diviner-model": "^3.17.0",
56
- "@xyo-network/diviner-payload-memory": "^3.17.0",
57
- "@xyo-network/diviner-payload-model": "^3.17.0",
58
- "@xyo-network/diviner-range": "^3.17.0",
59
- "@xyo-network/diviner-temporal-indexing": "^3.17.0",
60
- "@xyo-network/evm-nft-id-payload-plugin": "^3.6.0",
61
- "@xyo-network/manifest": "^3.17.0",
62
- "@xyo-network/module-factory-locator": "^3.17.0",
63
- "@xyo-network/node-memory": "^3.17.0",
64
- "@xyo-network/open-zeppelin-typechain": "^3.5.2",
65
- "@xyo-network/sentinel-model": "^3.17.0",
66
- "@xyo-network/wallet": "^3.17.0",
67
- "@xyo-network/wallet-model": "^3.17.0",
68
- "@xyo-network/witness-blockchain-abstract": "^3.17.0",
69
- "@xyo-network/witness-timestamp": "^3.17.0",
45
+ "@xylabs/delay": "^4.12.31",
46
+ "@xylabs/hex": "^4.12.31",
47
+ "@xylabs/object": "^4.12.31",
48
+ "@xylabs/ts-scripts-yarn3": "^6.5.12",
49
+ "@xylabs/tsconfig": "^6.5.12",
50
+ "@xylabs/vitest-extended": "^4.12.31",
51
+ "@xyo-network/archivist-memory": "^4.0.1",
52
+ "@xyo-network/diviner-boundwitness-memory": "^4.0.1",
53
+ "@xyo-network/diviner-jsonpatch": "^4.0.1",
54
+ "@xyo-network/diviner-jsonpath-aggregate-memory": "^4.0.1",
55
+ "@xyo-network/diviner-model": "^4.0.1",
56
+ "@xyo-network/diviner-payload-generic": "^4.0.1",
57
+ "@xyo-network/diviner-payload-model": "^4.0.1",
58
+ "@xyo-network/diviner-range": "^4.0.1",
59
+ "@xyo-network/diviner-temporal-indexing": "^4.0.1",
60
+ "@xyo-network/evm-nft-id-payload-plugin": "^4.0.0",
61
+ "@xyo-network/manifest": "^4.0.1",
62
+ "@xyo-network/module-factory-locator": "^4.0.1",
63
+ "@xyo-network/node-memory": "^4.0.1",
64
+ "@xyo-network/open-zeppelin-typechain": "^3.5.4",
65
+ "@xyo-network/sentinel-model": "^4.0.1",
66
+ "@xyo-network/wallet": "^4.0.1",
67
+ "@xyo-network/wallet-model": "^4.0.1",
68
+ "@xyo-network/witness-blockchain-abstract": "^4.0.1",
69
+ "@xyo-network/witness-timestamp": "^4.0.1",
70
70
  "async-mutex": "^0.5.0",
71
- "knip": "^5.57.0",
71
+ "knip": "^5.61.3",
72
72
  "typescript": "^5.8.3",
73
- "vitest": "^3.1.4"
73
+ "vitest": "^3.2.4"
74
74
  },
75
75
  "publishConfig": {
76
76
  "access": "public"
package/src/Witness.ts CHANGED
@@ -21,12 +21,11 @@ import type { InterfaceAbi, Provider } from 'ethers'
21
21
  import { Contract } from 'ethers'
22
22
 
23
23
  /** @deprecated use EvmCallWitness instead */
24
- export type CryptoContractFunctionReadWitnessParams = WitnessParams<
25
- AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>,
26
- {
27
- providers: Provider[]
28
- }
29
- >
24
+ export interface CryptoContractFunctionReadWitnessParams extends WitnessParams<
25
+ AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>>
26
+ {
27
+ providers: Provider[]
28
+ }
30
29
 
31
30
  /** @deprecated use EvmCallWitness instead */
32
31
  export class CryptoContractFunctionReadWitness<