@xyo-network/crypto-contract-function-read-plugin 2.77.18 → 2.77.19
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/browser/CryptoContractDiviner.d.cts +11 -9
- package/dist/browser/CryptoContractDiviner.d.cts.map +1 -1
- package/dist/browser/CryptoContractDiviner.d.mts +11 -9
- package/dist/browser/CryptoContractDiviner.d.mts.map +1 -1
- package/dist/browser/CryptoContractDiviner.d.ts +11 -9
- package/dist/browser/CryptoContractDiviner.d.ts.map +1 -1
- package/dist/browser/Witness.d.cts.map +1 -1
- package/dist/browser/Witness.d.mts.map +1 -1
- package/dist/browser/Witness.d.ts.map +1 -1
- package/dist/browser/index.cjs +14 -41
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +0 -2
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +0 -2
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +0 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +14 -41
- package/dist/browser/index.js.map +1 -1
- package/dist/node/CryptoContractDiviner.d.cts +11 -9
- package/dist/node/CryptoContractDiviner.d.cts.map +1 -1
- package/dist/node/CryptoContractDiviner.d.mts +11 -9
- package/dist/node/CryptoContractDiviner.d.mts.map +1 -1
- package/dist/node/CryptoContractDiviner.d.ts +11 -9
- package/dist/node/CryptoContractDiviner.d.ts.map +1 -1
- package/dist/node/Witness.d.cts.map +1 -1
- package/dist/node/Witness.d.mts.map +1 -1
- package/dist/node/Witness.d.ts.map +1 -1
- package/dist/node/index.d.cts +0 -2
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +0 -2
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +0 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +15 -48
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +14 -41
- package/dist/node/index.mjs.map +1 -1
- package/package.json +14 -14
- package/src/CryptoContractDiviner.ts +26 -28
- package/src/Erc721Sentinel.json +85 -3
- package/src/Witness.ts +4 -1
- package/src/index.ts +0 -2
- package/dist/browser/Erc1155Diviner.d.cts +0 -17
- package/dist/browser/Erc1155Diviner.d.cts.map +0 -1
- package/dist/browser/Erc1155Diviner.d.mts +0 -17
- package/dist/browser/Erc1155Diviner.d.mts.map +0 -1
- package/dist/browser/Erc1155Diviner.d.ts +0 -17
- package/dist/browser/Erc1155Diviner.d.ts.map +0 -1
- package/dist/browser/Erc721Diviner.d.cts +0 -19
- package/dist/browser/Erc721Diviner.d.cts.map +0 -1
- package/dist/browser/Erc721Diviner.d.mts +0 -19
- package/dist/browser/Erc721Diviner.d.mts.map +0 -1
- package/dist/browser/Erc721Diviner.d.ts +0 -19
- package/dist/browser/Erc721Diviner.d.ts.map +0 -1
- package/dist/node/Erc1155Diviner.d.cts +0 -17
- package/dist/node/Erc1155Diviner.d.cts.map +0 -1
- package/dist/node/Erc1155Diviner.d.mts +0 -17
- package/dist/node/Erc1155Diviner.d.mts.map +0 -1
- package/dist/node/Erc1155Diviner.d.ts +0 -17
- package/dist/node/Erc1155Diviner.d.ts.map +0 -1
- package/dist/node/Erc721Diviner.d.cts +0 -19
- package/dist/node/Erc721Diviner.d.cts.map +0 -1
- package/dist/node/Erc721Diviner.d.mts +0 -19
- package/dist/node/Erc721Diviner.d.mts.map +0 -1
- package/dist/node/Erc721Diviner.d.ts +0 -19
- package/dist/node/Erc721Diviner.d.ts.map +0 -1
- package/src/Erc1155Diviner.ts +0 -37
- package/src/Erc721Diviner.ts +0 -43
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { Promisable } from '@xylabs/promise';
|
|
2
2
|
import { AbstractDiviner } from '@xyo-network/abstract-diviner';
|
|
3
|
-
import { CryptoContractFunctionCallResult } from '@xyo-network/crypto-contract-function-read-payload-plugin';
|
|
3
|
+
import { ContractFunctionResult, CryptoContractFunctionCallResult } from '@xyo-network/crypto-contract-function-read-payload-plugin';
|
|
4
4
|
import { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model';
|
|
5
5
|
import { Payload } from '@xyo-network/payload-model';
|
|
6
6
|
export type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined];
|
|
7
7
|
export declare const CryptoContractDivinerConfigSchema = "network.xyo.crypto.contract.diviner.config";
|
|
8
8
|
export type CryptoContractDivinerConfigSchema = typeof CryptoContractDivinerConfigSchema;
|
|
9
|
-
export type CryptoContractDivinerConfig = DivinerConfig
|
|
9
|
+
export type CryptoContractDivinerConfig = DivinerConfig<{
|
|
10
|
+
schema: CryptoContractDivinerConfigSchema;
|
|
11
|
+
}>;
|
|
10
12
|
export type CryptoContractDivinerParams = DivinerParams<CryptoContractDivinerConfig>;
|
|
11
13
|
export declare const ContractInfoSchema = "network.xyo.crypto.contract.info";
|
|
12
14
|
export type ContractInfoSchema = typeof ContractInfoSchema;
|
|
13
|
-
export type
|
|
14
|
-
export type ContractInfo<TFields extends object | null = null, TSchema extends string = ContractInfoSchema> = Payload<TFields extends null ? object : TFields & {
|
|
15
|
+
export type ContractInfo = Payload<{
|
|
15
16
|
address: string;
|
|
16
17
|
chainId: string;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
results?: Record<string, ContractFunctionResult>;
|
|
19
|
+
}, ContractInfoSchema>;
|
|
20
|
+
export declare class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {
|
|
19
21
|
static configSchemas: string[];
|
|
20
22
|
protected static findCallResult<TResult = string>(address: string, functionName: string, params: unknown[], payloads: CryptoContractFunctionCallResult[]): Promise<TResult | undefined>;
|
|
21
23
|
protected static generateCallHash(address: string, functionName: string, params: unknown[]): Promise<string>;
|
|
22
24
|
protected static matchingExistingField<R = string, T extends Payload = Payload>(objs: T[], field: keyof T): R | undefined;
|
|
23
|
-
protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]):
|
|
24
|
-
protected divineHandler(inPayloads?: CryptoContractFunctionCallResult[]): Promise<
|
|
25
|
-
protected
|
|
25
|
+
protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]): ContractInfo;
|
|
26
|
+
protected divineHandler(inPayloads?: CryptoContractFunctionCallResult[]): Promise<ContractInfo[]>;
|
|
27
|
+
protected reduceResults(callResults: CryptoContractFunctionCallResult[]): Promisable<ContractInfo['results']>;
|
|
26
28
|
}
|
|
27
29
|
//# sourceMappingURL=CryptoContractDiviner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoContractDiviner.d.ts","sourceRoot":"","sources":["../../src/CryptoContractDiviner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"CryptoContractDiviner.d.ts","sourceRoot":"","sources":["../../src/CryptoContractDiviner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EACL,sBAAsB,EAEtB,gCAAgC,EAGjC,MAAM,2DAA2D,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAEzE,OAAO,EAAyB,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAE3E,MAAM,MAAM,cAAc,CAAC,OAAO,GAAG,MAAM,EAAE,QAAQ,GAAG,OAAO,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;AAEvI,eAAO,MAAM,iCAAiC,+CAA+C,CAAA;AAC7F,MAAM,MAAM,iCAAiC,GAAG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BpH,SAAS,CAAC,aAAa,CAAC,WAAW,EAAE,gCAAgC,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;CAM9G"}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { Promisable } from '@xylabs/promise';
|
|
2
2
|
import { AbstractDiviner } from '@xyo-network/abstract-diviner';
|
|
3
|
-
import { CryptoContractFunctionCallResult } from '@xyo-network/crypto-contract-function-read-payload-plugin';
|
|
3
|
+
import { ContractFunctionResult, CryptoContractFunctionCallResult } from '@xyo-network/crypto-contract-function-read-payload-plugin';
|
|
4
4
|
import { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model';
|
|
5
5
|
import { Payload } from '@xyo-network/payload-model';
|
|
6
6
|
export type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined];
|
|
7
7
|
export declare const CryptoContractDivinerConfigSchema = "network.xyo.crypto.contract.diviner.config";
|
|
8
8
|
export type CryptoContractDivinerConfigSchema = typeof CryptoContractDivinerConfigSchema;
|
|
9
|
-
export type CryptoContractDivinerConfig = DivinerConfig
|
|
9
|
+
export type CryptoContractDivinerConfig = DivinerConfig<{
|
|
10
|
+
schema: CryptoContractDivinerConfigSchema;
|
|
11
|
+
}>;
|
|
10
12
|
export type CryptoContractDivinerParams = DivinerParams<CryptoContractDivinerConfig>;
|
|
11
13
|
export declare const ContractInfoSchema = "network.xyo.crypto.contract.info";
|
|
12
14
|
export type ContractInfoSchema = typeof ContractInfoSchema;
|
|
13
|
-
export type
|
|
14
|
-
export type ContractInfo<TFields extends object | null = null, TSchema extends string = ContractInfoSchema> = Payload<TFields extends null ? object : TFields & {
|
|
15
|
+
export type ContractInfo = Payload<{
|
|
15
16
|
address: string;
|
|
16
17
|
chainId: string;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
results?: Record<string, ContractFunctionResult>;
|
|
19
|
+
}, ContractInfoSchema>;
|
|
20
|
+
export declare class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {
|
|
19
21
|
static configSchemas: string[];
|
|
20
22
|
protected static findCallResult<TResult = string>(address: string, functionName: string, params: unknown[], payloads: CryptoContractFunctionCallResult[]): Promise<TResult | undefined>;
|
|
21
23
|
protected static generateCallHash(address: string, functionName: string, params: unknown[]): Promise<string>;
|
|
22
24
|
protected static matchingExistingField<R = string, T extends Payload = Payload>(objs: T[], field: keyof T): R | undefined;
|
|
23
|
-
protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]):
|
|
24
|
-
protected divineHandler(inPayloads?: CryptoContractFunctionCallResult[]): Promise<
|
|
25
|
-
protected
|
|
25
|
+
protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]): ContractInfo;
|
|
26
|
+
protected divineHandler(inPayloads?: CryptoContractFunctionCallResult[]): Promise<ContractInfo[]>;
|
|
27
|
+
protected reduceResults(callResults: CryptoContractFunctionCallResult[]): Promisable<ContractInfo['results']>;
|
|
26
28
|
}
|
|
27
29
|
//# sourceMappingURL=CryptoContractDiviner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoContractDiviner.d.ts","sourceRoot":"","sources":["../../src/CryptoContractDiviner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"CryptoContractDiviner.d.ts","sourceRoot":"","sources":["../../src/CryptoContractDiviner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EACL,sBAAsB,EAEtB,gCAAgC,EAGjC,MAAM,2DAA2D,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,M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G,SAAS,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS;IAQzH,SAAS,CAAC,0BAA0B,CAAC,WAAW,EAAE,gCAAgC,EAAE,GAAG,YAAY;cAQ1E,aAAa,CAAC,UAAU,GAAE,gCAAgC,EAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAwBpH,SAAS,CAAC,aAAa,CAAC,WAAW,EAAE,gCAAgC,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;CAM9G"}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { Promisable } from '@xylabs/promise';
|
|
2
2
|
import { AbstractDiviner } from '@xyo-network/abstract-diviner';
|
|
3
|
-
import { CryptoContractFunctionCallResult } from '@xyo-network/crypto-contract-function-read-payload-plugin';
|
|
3
|
+
import { ContractFunctionResult, CryptoContractFunctionCallResult } from '@xyo-network/crypto-contract-function-read-payload-plugin';
|
|
4
4
|
import { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model';
|
|
5
5
|
import { Payload } from '@xyo-network/payload-model';
|
|
6
6
|
export type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined];
|
|
7
7
|
export declare const CryptoContractDivinerConfigSchema = "network.xyo.crypto.contract.diviner.config";
|
|
8
8
|
export type CryptoContractDivinerConfigSchema = typeof CryptoContractDivinerConfigSchema;
|
|
9
|
-
export type CryptoContractDivinerConfig = DivinerConfig
|
|
9
|
+
export type CryptoContractDivinerConfig = DivinerConfig<{
|
|
10
|
+
schema: CryptoContractDivinerConfigSchema;
|
|
11
|
+
}>;
|
|
10
12
|
export type CryptoContractDivinerParams = DivinerParams<CryptoContractDivinerConfig>;
|
|
11
13
|
export declare const ContractInfoSchema = "network.xyo.crypto.contract.info";
|
|
12
14
|
export type ContractInfoSchema = typeof ContractInfoSchema;
|
|
13
|
-
export type
|
|
14
|
-
export type ContractInfo<TFields extends object | null = null, TSchema extends string = ContractInfoSchema> = Payload<TFields extends null ? object : TFields & {
|
|
15
|
+
export type ContractInfo = Payload<{
|
|
15
16
|
address: string;
|
|
16
17
|
chainId: string;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
results?: Record<string, ContractFunctionResult>;
|
|
19
|
+
}, ContractInfoSchema>;
|
|
20
|
+
export declare class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {
|
|
19
21
|
static configSchemas: string[];
|
|
20
22
|
protected static findCallResult<TResult = string>(address: string, functionName: string, params: unknown[], payloads: CryptoContractFunctionCallResult[]): Promise<TResult | undefined>;
|
|
21
23
|
protected static generateCallHash(address: string, functionName: string, params: unknown[]): Promise<string>;
|
|
22
24
|
protected static matchingExistingField<R = string, T extends Payload = Payload>(objs: T[], field: keyof T): R | undefined;
|
|
23
|
-
protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]):
|
|
24
|
-
protected divineHandler(inPayloads?: CryptoContractFunctionCallResult[]): Promise<
|
|
25
|
-
protected
|
|
25
|
+
protected contractInfoRequiredFields(callResults: CryptoContractFunctionCallResult[]): ContractInfo;
|
|
26
|
+
protected divineHandler(inPayloads?: CryptoContractFunctionCallResult[]): Promise<ContractInfo[]>;
|
|
27
|
+
protected reduceResults(callResults: CryptoContractFunctionCallResult[]): Promisable<ContractInfo['results']>;
|
|
26
28
|
}
|
|
27
29
|
//# sourceMappingURL=CryptoContractDiviner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoContractDiviner.d.ts","sourceRoot":"","sources":["../../src/CryptoContractDiviner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,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+
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAGhC,uCAAuC,EAExC,MAAM,2DAA2D,CAAA;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAa,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAE5C,MAAM,MAAM,uCAAuC,CAAC,SAAS,SAAS,QAAQ,IAAI,aAAa,CAC7F,eAAe,CAAC,uCAAuC,CAAC,EACxD;IACE,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,SAAS,CAAA;CACxC,CACF,CAAA;AAED,qBAAa,iCAAiC,CAC5C,SAAS,SAAS,QAAQ,GAAG,QAAQ,EACrC,OAAO,SAAS,uCAAuC,CAAC,SAAS,CAAC,GAAG,uCAAuC,CAAC,SAAS,CAAC,CACvH,SAAQ,eAAe,CAAC,OAAO,EAAE,0BAA0B,CAAC,MAAM,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,gCAAgC,CAAC;IAC7H,OAAgB,aAAa,WAAkD;cAEtD,cAAc,CACrC,UAAU,GAAE,0BAA0B,CAAC,MAAM,SAAS,CAAC,YAAY,CAAC,CAAC,EAAO,GAC3E,OAAO,CAAC,gCAAgC,EAAE,CAAC;CAmC/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Witness.d.ts","sourceRoot":"","sources":["../../src/Witness.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAGhC,uCAAuC,EAExC,MAAM,2DAA2D,CAAA;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;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AAED,qBAAa,iCAAiC,CAC5C,SAAS,SAAS,QAAQ,GAAG,QAAQ,EACrC,OAAO,SAAS,uCAAuC,CAAC,SAAS,CAAC,GAAG,uCAAuC,CAAC,SAAS,CAAC,CACvH,SAAQ,eAAe,CAAC,OAAO,EAAE,0BAA0B,CAAC,MAAM,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,gCAAgC,CAAC;IAC7H,OAAgB,aAAa,WAAkD;cAEtD,cAAc,CACrC,UAAU,GAAE,0BAA0B,CAAC,MAAM,SAAS,CAAC,YAAY,CAAC,CAAC,EAAO,GAC3E,OAAO,CAAC,gCAAgC,EAAE,CAAC;CAmC/C"}
|
package/dist/browser/index.cjs
CHANGED
|
@@ -23,14 +23,8 @@ __export(src_exports, {
|
|
|
23
23
|
ContractInfoSchema: () => ContractInfoSchema,
|
|
24
24
|
CryptoContractDiviner: () => CryptoContractDiviner,
|
|
25
25
|
CryptoContractDivinerConfigSchema: () => CryptoContractDivinerConfigSchema,
|
|
26
|
-
CryptoContractErc1155Diviner: () => CryptoContractErc1155Diviner,
|
|
27
|
-
CryptoContractErc1155DivinerConfigSchema: () => CryptoContractErc1155DivinerConfigSchema,
|
|
28
|
-
CryptoContractErc721Diviner: () => CryptoContractErc721Diviner,
|
|
29
|
-
CryptoContractErc721DivinerConfigSchema: () => CryptoContractErc721DivinerConfigSchema,
|
|
30
26
|
CryptoContractFunctionReadWitness: () => CryptoContractFunctionReadWitness,
|
|
31
27
|
CryptoContractFunctionReadWitnessPlugin: () => CryptoContractFunctionReadWitnessPlugin,
|
|
32
|
-
Erc1155ContractInfoSchema: () => Erc1155ContractInfoSchema,
|
|
33
|
-
Erc721ContractInfoSchema: () => Erc721ContractInfoSchema,
|
|
34
28
|
default: () => src_default
|
|
35
29
|
});
|
|
36
30
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -57,14 +51,17 @@ var CryptoContractFunctionReadWitness = class extends import_abstract_witness.Ab
|
|
|
57
51
|
const fullCallPayload = { ...{ params: [] }, ...this.config.call, ...callPayload };
|
|
58
52
|
const { address, functionName, params } = fullCallPayload;
|
|
59
53
|
const validatedAddress = (0, import_assert.assertEx)(address, "Missing address");
|
|
54
|
+
const validatedFunctionName = (0, import_assert.assertEx)(functionName, "Missing functionName");
|
|
60
55
|
const contract = this.params.factory(validatedAddress);
|
|
61
|
-
const func = (0, import_assert.assertEx)(contract.callStatic[
|
|
56
|
+
const func = (0, import_assert.assertEx)(contract.callStatic[validatedFunctionName], `functionName [${validatedFunctionName}] not found`);
|
|
62
57
|
const rawResult = await func(...params ?? []);
|
|
63
58
|
const result = import_ethers.BigNumber.isBigNumber(rawResult) ? { type: "BigNumber", value: rawResult.toHexString() } : { value: rawResult };
|
|
64
59
|
const observation = {
|
|
65
60
|
address: validatedAddress,
|
|
66
61
|
call: await import_hash.PayloadHasher.hashAsync(fullCallPayload),
|
|
67
62
|
chainId: (await contract.provider.getNetwork()).chainId,
|
|
63
|
+
functionName: validatedFunctionName,
|
|
64
|
+
params,
|
|
68
65
|
result,
|
|
69
66
|
schema: import_crypto_contract_function_read_payload_plugin.CryptoContractFunctionCallResultSchema
|
|
70
67
|
};
|
|
@@ -125,7 +122,8 @@ var CryptoContractDiviner = class _CryptoContractDiviner extends import_abstract
|
|
|
125
122
|
contractInfoRequiredFields(callResults) {
|
|
126
123
|
return {
|
|
127
124
|
address: (0, import_assert2.assertEx)(_CryptoContractDiviner.matchingExistingField(callResults, "address"), "Mismatched address"),
|
|
128
|
-
chainId: (0, import_assert2.assertEx)(_CryptoContractDiviner.matchingExistingField(callResults, "chainId"), "Mismatched chainId")
|
|
125
|
+
chainId: (0, import_assert2.assertEx)(_CryptoContractDiviner.matchingExistingField(callResults, "chainId"), "Mismatched chainId"),
|
|
126
|
+
schema: ContractInfoSchema
|
|
129
127
|
};
|
|
130
128
|
}
|
|
131
129
|
async divineHandler(inPayloads = []) {
|
|
@@ -141,45 +139,20 @@ var CryptoContractDiviner = class _CryptoContractDiviner extends import_abstract
|
|
|
141
139
|
const result = await Promise.all(
|
|
142
140
|
addresses.map(async (address) => {
|
|
143
141
|
const foundCallResults = callResults.filter((callResult) => callResult.address === address);
|
|
144
|
-
|
|
145
|
-
...await this.reduceResults(
|
|
142
|
+
const info = {
|
|
143
|
+
...{ results: await this.reduceResults(foundCallResults) },
|
|
146
144
|
...this.contractInfoRequiredFields(foundCallResults)
|
|
147
145
|
};
|
|
146
|
+
return info;
|
|
148
147
|
})
|
|
149
148
|
);
|
|
150
149
|
return result;
|
|
151
150
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
var CryptoContractErc721Diviner = class _CryptoContractErc721Diviner extends CryptoContractDiviner {
|
|
158
|
-
static configSchemas = [CryptoContractErc721DivinerConfigSchema];
|
|
159
|
-
async reduceResults(address, callResults) {
|
|
160
|
-
const name = await _CryptoContractErc721Diviner.findCallResult(address, "name", [], callResults);
|
|
161
|
-
const symbol = await _CryptoContractErc721Diviner.findCallResult(address, "symbol", [], callResults);
|
|
162
|
-
const totalSupply = await _CryptoContractErc721Diviner.findCallResult(address, "totalSupply", [], callResults);
|
|
163
|
-
return {
|
|
164
|
-
name,
|
|
165
|
-
schema: Erc721ContractInfoSchema,
|
|
166
|
-
symbol,
|
|
167
|
-
totalSupply
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// src/Erc1155Diviner.ts
|
|
173
|
-
var CryptoContractErc1155DivinerConfigSchema = "network.xyo.crypto.contract.erc1155.info.diviner.config";
|
|
174
|
-
var Erc1155ContractInfoSchema = "network.xyo.crypto.contract.erc1155.info";
|
|
175
|
-
var CryptoContractErc1155Diviner = class _CryptoContractErc1155Diviner extends CryptoContractDiviner {
|
|
176
|
-
static configSchemas = [CryptoContractErc1155DivinerConfigSchema];
|
|
177
|
-
async reduceResults(address, callResults) {
|
|
178
|
-
const uri = await _CryptoContractErc1155Diviner.findCallResult(address, "uri", [], callResults);
|
|
179
|
-
return {
|
|
180
|
-
schema: Erc1155ContractInfoSchema,
|
|
181
|
-
uri
|
|
182
|
-
};
|
|
151
|
+
reduceResults(callResults) {
|
|
152
|
+
return callResults.reduce((prev, callResult) => {
|
|
153
|
+
prev[callResult.functionName] = callResult.result;
|
|
154
|
+
return prev;
|
|
155
|
+
}, {});
|
|
183
156
|
}
|
|
184
157
|
};
|
|
185
158
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Witness.ts","../../src/CryptoContractDiviner.ts","../../src/Erc721Diviner.ts","../../src/Erc1155Diviner.ts"],"sourcesContent":["import { CryptoContractFunctionReadWitnessPlugin } from './Plugin'\n\nexport * from './CryptoContractDiviner'\nexport * from './Erc721Diviner'\nexport * from './Erc1155Diviner'\nexport * from './Witness'\n\nexport { CryptoContractFunctionReadWitnessPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default CryptoContractFunctionReadWitnessPlugin\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'\n\nexport const CryptoContractFunctionReadWitnessPlugin = () =>\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 { AbstractWitness } from '@xyo-network/abstract-witness'\nimport {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n CryptoContractFunctionReadWitnessConfig,\n CryptoContractFunctionReadWitnessConfigSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { WitnessParams } from '@xyo-network/witness-model'\nimport { BigNumber, Contract } from 'ethers'\n\nexport type CryptoContractFunctionReadWitnessParams<TContract extends Contract> = WitnessParams<\n AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>,\n {\n factory: (address: string) => TContract\n }\n>\n\nexport class CryptoContractFunctionReadWitness<\n TContract extends Contract = Contract,\n TParams extends CryptoContractFunctionReadWitnessParams<TContract> = CryptoContractFunctionReadWitnessParams<TContract>,\n> extends AbstractWitness<TParams, CryptoContractFunctionCall<keyof TContract['callStatic']>, CryptoContractFunctionCallResult> {\n static override configSchemas = [CryptoContractFunctionReadWitnessConfigSchema]\n\n protected override async observeHandler(\n inPayloads: CryptoContractFunctionCall<keyof TContract['callStatic']>[] = [],\n ): Promise<CryptoContractFunctionCallResult[]> {\n await this.started('throw')\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType(CryptoContractFunctionCallSchema)).map(async (callPayload) => {\n const fullCallPayload = { ...{ params: [] }, ...this.config.call, ...callPayload }\n const { address, functionName, params } = fullCallPayload\n const validatedAddress = assertEx(address, 'Missing address')\n const contract = this.params.factory(validatedAddress)\n const func = assertEx(contract.callStatic[assertEx(functionName, 'missing functionName')], `functionName [${functionName}] not found`)\n const rawResult = await func(...(params ?? []))\n const result: CryptoContractFunctionCallResult['result'] = BigNumber.isBigNumber(rawResult)\n ? { type: 'BigNumber', value: rawResult.toHexString() }\n : { value: rawResult }\n const observation: CryptoContractFunctionCallResult = {\n address: validatedAddress,\n call: await PayloadHasher.hashAsync(fullCallPayload),\n chainId: (await contract.provider.getNetwork()).chainId,\n result,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n }),\n )\n return observations.flat()\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n }\n\n return []\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Promisable } from '@xylabs/promise'\nimport { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nexport type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined]\n\nexport const CryptoContractDivinerConfigSchema = 'network.xyo.crypto.contract.diviner.config'\nexport type CryptoContractDivinerConfigSchema = typeof CryptoContractDivinerConfigSchema\n\nexport type CryptoContractDivinerConfig = DivinerConfig\nexport type CryptoContractDivinerParams = DivinerParams<CryptoContractDivinerConfig>\n\nexport const ContractInfoSchema = 'network.xyo.crypto.contract.info'\nexport type ContractInfoSchema = typeof ContractInfoSchema\n\nexport type OmittedContractInfo<TFields extends object | Payload | null = null, TSchema extends string | null = null> = Omit<\n ContractInfo<TFields, TSchema extends null ? (TFields extends Payload ? TFields['schema'] : never) : TSchema>,\n 'address' | 'chainId'\n>\n\nexport type ContractInfo<TFields extends object | null = null, TSchema extends string = ContractInfoSchema> = Payload<\n TFields extends null\n ? object\n : TFields & {\n address: string\n chainId: string\n },\n TSchema\n>\n\nexport abstract class CryptoContractDiviner<\n TContractInfo extends Payload<Omit<ContractInfo, 'schema'>> = ContractInfo,\n TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override configSchemas = [CryptoContractDivinerConfigSchema]\n\n protected static async findCallResult<TResult = string>(\n address: string,\n functionName: string,\n params: unknown[],\n payloads: CryptoContractFunctionCallResult[],\n ): Promise<TResult | undefined> {\n const callHash = await this.generateCallHash(address, functionName, params)\n const foundPayload = payloads.find((payload) => payload.call === callHash)\n return foundPayload?.result.value as TResult | undefined\n }\n\n protected static async generateCallHash(address: string, functionName: string, params: unknown[]) {\n const callPayload: CryptoContractFunctionCall = {\n address,\n functionName,\n params,\n schema: CryptoContractFunctionCallSchema,\n }\n return await PayloadHasher.hashAsync(callPayload)\n }\n\n protected static matchingExistingField<R = string, T extends Payload = Payload>(objs: T[], field: keyof T) {\n const expectedValue = objs.at(0)?.[field] as R\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[]): Promisable<Omit<ContractInfo, 'schema'>> {\n return {\n address: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'address'), 'Mismatched address'),\n chainId: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'chainId'), 'Mismatched chainId'),\n }\n }\n\n protected override async divineHandler(inPayloads: CryptoContractFunctionCallResult[] = []): Promise<TContractInfo[]> {\n const callResults = inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCallResult>(CryptoContractFunctionCallResultSchema))\n const addresses = Object.keys(\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 return {\n ...(await this.reduceResults(address, foundCallResults)),\n ...this.contractInfoRequiredFields(foundCallResults),\n } as TContractInfo\n }),\n )\n\n return result\n }\n\n protected abstract reduceResults(\n address: string,\n callResults: CryptoContractFunctionCallResult[],\n ): Promisable<Omit<TContractInfo, 'address' | 'chainId'>>\n}\n","import { CryptoContractFunctionCallResult } from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\n\nimport { ContractInfo, CryptoContractDiviner, OmittedContractInfo } from './CryptoContractDiviner'\n\nexport const CryptoContractErc721DivinerConfigSchema = 'network.xyo.crypto.contract.erc721.info.diviner.config'\nexport type CryptoContractErc721DivinerConfigSchema = typeof CryptoContractErc721DivinerConfigSchema\n\nexport type CryptoContractErc721DivinerConfig = DivinerConfig\nexport type CryptoContractErc721DivinerParams = DivinerParams<CryptoContractErc721DivinerConfig>\n\nexport const Erc721ContractInfoSchema = 'network.xyo.crypto.contract.erc721.info'\nexport type Erc721ContractInfoSchema = typeof Erc721ContractInfoSchema\n\nexport type Erc721ContractInfo = ContractInfo<\n {\n name?: string\n symbol?: string\n totalSupply?: string\n },\n Erc721ContractInfoSchema\n>\n\nexport class CryptoContractErc721Diviner<\n TParams extends CryptoContractErc721DivinerParams = CryptoContractErc721DivinerParams,\n> extends CryptoContractDiviner<Erc721ContractInfo, TParams> {\n static override configSchemas = [CryptoContractErc721DivinerConfigSchema]\n\n protected override async reduceResults(\n address: string,\n callResults: CryptoContractFunctionCallResult[],\n ): Promise<OmittedContractInfo<Erc721ContractInfo>> {\n const name = await CryptoContractErc721Diviner.findCallResult(address, 'name', [], callResults)\n const symbol = await CryptoContractErc721Diviner.findCallResult(address, 'symbol', [], callResults)\n const totalSupply = await CryptoContractErc721Diviner.findCallResult(address, 'totalSupply', [], callResults)\n return {\n name,\n schema: Erc721ContractInfoSchema,\n symbol,\n totalSupply,\n }\n }\n}\n","import { CryptoContractFunctionCallResult } from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\n\nimport { ContractInfo, CryptoContractDiviner, OmittedContractInfo } from './CryptoContractDiviner'\n\nexport const CryptoContractErc1155DivinerConfigSchema = 'network.xyo.crypto.contract.erc1155.info.diviner.config'\nexport type CryptoContractErc1155DivinerConfigSchema = typeof CryptoContractErc1155DivinerConfigSchema\n\nexport type CryptoContractErc1155DivinerConfig = DivinerConfig\nexport type CryptoContractErc1155DivinerParams = DivinerParams<CryptoContractErc1155DivinerConfig>\n\nexport const Erc1155ContractInfoSchema = 'network.xyo.crypto.contract.erc1155.info'\nexport type Erc1155ContractInfoSchema = typeof Erc1155ContractInfoSchema\n\nexport type Erc1155ContractInfo = ContractInfo<\n {\n uri?: string\n },\n Erc1155ContractInfoSchema\n>\n\nexport class CryptoContractErc1155Diviner<\n TParams extends CryptoContractErc1155DivinerParams = CryptoContractErc1155DivinerParams,\n> extends CryptoContractDiviner<Erc1155ContractInfo, TParams> {\n static override configSchemas = [CryptoContractErc1155DivinerConfigSchema]\n\n protected override async reduceResults(\n address: string,\n callResults: CryptoContractFunctionCallResult[],\n ): Promise<OmittedContractInfo<Erc1155ContractInfo>> {\n const uri = await CryptoContractErc1155Diviner.findCallResult(address, 'uri', [], callResults)\n return {\n schema: Erc1155ContractInfoSchema,\n uri,\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uCAA0B;AAC1B,IAAAA,wBAAiC;AACjC,+BAA8C;;;ACF9C,oBAAyB;AACzB,8BAAgC;AAChC,0DAOO;AACP,kBAA8B;AAE9B,2BAAsC;AAEtC,oBAAoC;AAS7B,IAAM,oCAAN,cAGG,wCAAsH;AAAA,EAC9H,OAAgB,gBAAgB,CAAC,iGAA6C;AAAA,EAE9E,MAAyB,eACvB,aAA0E,CAAC,GAC9B;AAC7C,UAAM,KAAK,QAAQ,OAAO;AAC1B,QAAI;AACF,YAAM,eAAe,MAAM,QAAQ;AAAA,QACjC,WAAW,WAAO,4CAAsB,oFAAgC,CAAC,EAAE,IAAI,OAAO,gBAAgB;AACpG,gBAAM,kBAAkB,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,KAAK,OAAO,MAAM,GAAG,YAAY;AACjF,gBAAM,EAAE,SAAS,cAAc,OAAO,IAAI;AAC1C,gBAAM,uBAAmB,wBAAS,SAAS,iBAAiB;AAC5D,gBAAM,WAAW,KAAK,OAAO,QAAQ,gBAAgB;AAC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,QACrD;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AAMF;;;ACvGO,IAAM,0CAA0C;AAMhD,IAAM,2BAA2B;AAYjC,IAAM,8BAAN,MAAM,qCAEH,sBAAmD;AAAA,EAC3D,OAAgB,gBAAgB,CAAC,uCAAuC;AAAA,EAExE,MAAyB,cACvB,SACA,aACkD;AAClD,UAAM,OAAO,MAAM,6BAA4B,eAAe,SAAS,QAAQ,CAAC,GAAG,WAAW;AAC9F,UAAM,SAAS,MAAM,6BAA4B,eAAe,SAAS,UAAU,CAAC,GAAG,WAAW;AAClG,UAAM,cAAc,MAAM,6BAA4B,eAAe,SAAS,eAAe,CAAC,GAAG,WAAW;AAC5G,WAAO;AAAA,MACL;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;;;ACrCO,IAAM,2CAA2C;AAMjD,IAAM,4BAA4B;AAUlC,IAAM,+BAAN,MAAM,sCAEH,sBAAoD;AAAA,EAC5D,OAAgB,gBAAgB,CAAC,wCAAwC;AAAA,EAEzE,MAAyB,cACvB,SACA,aACmD;AACnD,UAAM,MAAM,MAAM,8BAA6B,eAAe,SAAS,OAAO,CAAC,GAAG,WAAW;AAC7F,WAAO;AAAA,MACL,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;;;AL1BA,IAAO,cAAQ;","names":["import_payload_model","import_assert","import_crypto_contract_function_read_payload_plugin","import_hash","import_payload_model","result"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Witness.ts","../../src/CryptoContractDiviner.ts"],"sourcesContent":["import { CryptoContractFunctionReadWitnessPlugin } from './Plugin'\n\nexport * from './CryptoContractDiviner'\nexport * from './Witness'\n\nexport { CryptoContractFunctionReadWitnessPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default CryptoContractFunctionReadWitnessPlugin\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'\n\nexport const CryptoContractFunctionReadWitnessPlugin = () =>\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 { AbstractWitness } from '@xyo-network/abstract-witness'\nimport {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n CryptoContractFunctionReadWitnessConfig,\n CryptoContractFunctionReadWitnessConfigSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { WitnessParams } from '@xyo-network/witness-model'\nimport { BigNumber, Contract } from 'ethers'\n\nexport type CryptoContractFunctionReadWitnessParams<TContract extends Contract> = WitnessParams<\n AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>,\n {\n factory: (address: string) => TContract\n }\n>\n\nexport class CryptoContractFunctionReadWitness<\n TContract extends Contract = Contract,\n TParams extends CryptoContractFunctionReadWitnessParams<TContract> = CryptoContractFunctionReadWitnessParams<TContract>,\n> extends AbstractWitness<TParams, CryptoContractFunctionCall<keyof TContract['callStatic']>, CryptoContractFunctionCallResult> {\n static override configSchemas = [CryptoContractFunctionReadWitnessConfigSchema]\n\n protected override async observeHandler(\n inPayloads: CryptoContractFunctionCall<keyof TContract['callStatic']>[] = [],\n ): Promise<CryptoContractFunctionCallResult[]> {\n await this.started('throw')\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType(CryptoContractFunctionCallSchema)).map(async (callPayload) => {\n const fullCallPayload = { ...{ params: [] }, ...this.config.call, ...callPayload }\n const { address, functionName, params } = fullCallPayload\n const validatedAddress = assertEx(address, 'Missing address')\n const validatedFunctionName = assertEx(functionName, 'Missing functionName')\n const contract = this.params.factory(validatedAddress)\n const func = assertEx(contract.callStatic[validatedFunctionName], `functionName [${validatedFunctionName}] not found`)\n const rawResult = await func(...(params ?? []))\n const result: CryptoContractFunctionCallResult['result'] = BigNumber.isBigNumber(rawResult)\n ? { type: 'BigNumber', value: rawResult.toHexString() }\n : { value: rawResult }\n const observation: CryptoContractFunctionCallResult = {\n address: validatedAddress,\n call: await PayloadHasher.hashAsync(fullCallPayload),\n chainId: (await contract.provider.getNetwork()).chainId,\n functionName: validatedFunctionName,\n params,\n result,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n }),\n )\n return observations.flat()\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n }\n\n return []\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Promisable } from '@xylabs/promise'\nimport { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport {\n ContractFunctionResult,\n CryptoContractFunctionCall,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nexport type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined]\n\nexport const CryptoContractDivinerConfigSchema = 'network.xyo.crypto.contract.diviner.config'\nexport type CryptoContractDivinerConfigSchema = typeof CryptoContractDivinerConfigSchema\n\nexport type CryptoContractDivinerConfig = DivinerConfig<{\n schema: CryptoContractDivinerConfigSchema\n}>\nexport type CryptoContractDivinerParams = DivinerParams<CryptoContractDivinerConfig>\n\nexport const ContractInfoSchema = 'network.xyo.crypto.contract.info'\nexport type ContractInfoSchema = typeof ContractInfoSchema\n\nexport type ContractInfo = Payload<\n {\n address: string\n chainId: string\n results?: Record<string, ContractFunctionResult>\n },\n ContractInfoSchema\n>\n\nexport class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {\n static override configSchemas = [CryptoContractDivinerConfigSchema]\n\n protected static async findCallResult<TResult = string>(\n address: string,\n functionName: string,\n params: unknown[],\n payloads: CryptoContractFunctionCallResult[],\n ): Promise<TResult | undefined> {\n const callHash = await this.generateCallHash(address, functionName, params)\n const foundPayload = payloads.find((payload) => payload.call === callHash)\n return foundPayload?.result.value as TResult | undefined\n }\n\n protected static async generateCallHash(address: string, functionName: string, params: unknown[]) {\n const callPayload: CryptoContractFunctionCall = {\n address,\n functionName,\n params,\n schema: CryptoContractFunctionCallSchema,\n }\n return await PayloadHasher.hashAsync(callPayload)\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 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 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 return callResults.reduce<Record<string, ContractFunctionResult>>((prev, callResult) => {\n prev[callResult.functionName] = callResult.result\n return prev\n }, {})\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uCAA0B;AAC1B,IAAAA,wBAAiC;AACjC,+BAA8C;;;ACF9C,oBAAyB;AACzB,8BAAgC;AAChC,0DAOO;AACP,kBAA8B;AAE9B,2BAAsC;AAEtC,oBAAoC;AAS7B,IAAM,oCAAN,cAGG,wCAAsH;AAAA,EAC9H,OAAgB,gBAAgB,CAAC,iGAA6C;AAAA,EAE9E,MAAyB,eACvB,aAA0E,CAAC,GAC9B;AAC7C,UAAM,KAAK,QAAQ,OAAO;AAC1B,QAAI;AACF,YAAM,eAAe,MAAM,QAAQ;AAAA,QACjC,WAAW,WAAO,4CAAsB,oFAAgC,CAAC,EAAE,IAAI,OAAO,gBAAgB;AACpG,gBAAM,kBAAkB,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,KAAK,OAAO,MAAM,GAAG,YAAY;AACjF,gBAAM,EAAE,SAAS,cAAc,OAAO,IAAI;AAC1C,gBAAM,uBAAmB,wBAAS,SAAS,iBAAiB;AAC5D,gBAAM,4BAAwB,wBAAS,cAAc,sBAAsB;AAC3E,gBAAM,WAAW,KAAK,OAAO,QAAQ,gBAAgB;AACrD,gBAAM,WAAO,wBAAS,SAAS,WAAW,qBAAqB,GAAG,iBAAiB,qBAAqB,aAAa;AACrH,gBAAM,YAAY,MAAM,KAAK,GAAI,UAAU,CAAC,CAAE;AAC9C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,aAAsF;AAC5G,WAAO,YAAY,OAA+C,CAAC,MAAM,eAAe;AACtF,WAAK,WAAW,YAAY,IAAI,WAAW;AAC3C,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,EACP;AACF;;;AHlGA,IAAO,cAAQ;","names":["import_payload_model","import_assert","import_crypto_contract_function_read_payload_plugin","import_hash","import_payload_model","result"]}
|
package/dist/browser/index.d.cts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { CryptoContractFunctionReadWitnessPlugin } from './Plugin';
|
|
2
2
|
export * from './CryptoContractDiviner';
|
|
3
|
-
export * from './Erc721Diviner';
|
|
4
|
-
export * from './Erc1155Diviner';
|
|
5
3
|
export * from './Witness';
|
|
6
4
|
export { CryptoContractFunctionReadWitnessPlugin };
|
|
7
5
|
export default CryptoContractFunctionReadWitnessPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uCAAuC,EAAE,MAAM,UAAU,CAAA;AAElE,cAAc,yBAAyB,CAAA;AACvC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uCAAuC,EAAE,MAAM,UAAU,CAAA;AAElE,cAAc,yBAAyB,CAAA;AACvC,cAAc,WAAW,CAAA;AAEzB,OAAO,EAAE,uCAAuC,EAAE,CAAA;AAGlD,eAAe,uCAAuC,CAAA"}
|
package/dist/browser/index.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { CryptoContractFunctionReadWitnessPlugin } from './Plugin';
|
|
2
2
|
export * from './CryptoContractDiviner';
|
|
3
|
-
export * from './Erc721Diviner';
|
|
4
|
-
export * from './Erc1155Diviner';
|
|
5
3
|
export * from './Witness';
|
|
6
4
|
export { CryptoContractFunctionReadWitnessPlugin };
|
|
7
5
|
export default CryptoContractFunctionReadWitnessPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uCAAuC,EAAE,MAAM,UAAU,CAAA;AAElE,cAAc,yBAAyB,CAAA;AACvC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uCAAuC,EAAE,MAAM,UAAU,CAAA;AAElE,cAAc,yBAAyB,CAAA;AACvC,cAAc,WAAW,CAAA;AAEzB,OAAO,EAAE,uCAAuC,EAAE,CAAA;AAGlD,eAAe,uCAAuC,CAAA"}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { CryptoContractFunctionReadWitnessPlugin } from './Plugin';
|
|
2
2
|
export * from './CryptoContractDiviner';
|
|
3
|
-
export * from './Erc721Diviner';
|
|
4
|
-
export * from './Erc1155Diviner';
|
|
5
3
|
export * from './Witness';
|
|
6
4
|
export { CryptoContractFunctionReadWitnessPlugin };
|
|
7
5
|
export default CryptoContractFunctionReadWitnessPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uCAAuC,EAAE,MAAM,UAAU,CAAA;AAElE,cAAc,yBAAyB,CAAA;AACvC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uCAAuC,EAAE,MAAM,UAAU,CAAA;AAElE,cAAc,yBAAyB,CAAA;AACvC,cAAc,WAAW,CAAA;AAEzB,OAAO,EAAE,uCAAuC,EAAE,CAAA;AAGlD,eAAe,uCAAuC,CAAA"}
|
package/dist/browser/index.js
CHANGED
|
@@ -24,14 +24,17 @@ var CryptoContractFunctionReadWitness = class extends AbstractWitness {
|
|
|
24
24
|
const fullCallPayload = { ...{ params: [] }, ...this.config.call, ...callPayload };
|
|
25
25
|
const { address, functionName, params } = fullCallPayload;
|
|
26
26
|
const validatedAddress = assertEx(address, "Missing address");
|
|
27
|
+
const validatedFunctionName = assertEx(functionName, "Missing functionName");
|
|
27
28
|
const contract = this.params.factory(validatedAddress);
|
|
28
|
-
const func = assertEx(contract.callStatic[
|
|
29
|
+
const func = assertEx(contract.callStatic[validatedFunctionName], `functionName [${validatedFunctionName}] not found`);
|
|
29
30
|
const rawResult = await func(...params ?? []);
|
|
30
31
|
const result = BigNumber.isBigNumber(rawResult) ? { type: "BigNumber", value: rawResult.toHexString() } : { value: rawResult };
|
|
31
32
|
const observation = {
|
|
32
33
|
address: validatedAddress,
|
|
33
34
|
call: await PayloadHasher.hashAsync(fullCallPayload),
|
|
34
35
|
chainId: (await contract.provider.getNetwork()).chainId,
|
|
36
|
+
functionName: validatedFunctionName,
|
|
37
|
+
params,
|
|
35
38
|
result,
|
|
36
39
|
schema: CryptoContractFunctionCallResultSchema
|
|
37
40
|
};
|
|
@@ -95,7 +98,8 @@ var CryptoContractDiviner = class _CryptoContractDiviner extends AbstractDiviner
|
|
|
95
98
|
contractInfoRequiredFields(callResults) {
|
|
96
99
|
return {
|
|
97
100
|
address: assertEx2(_CryptoContractDiviner.matchingExistingField(callResults, "address"), "Mismatched address"),
|
|
98
|
-
chainId: assertEx2(_CryptoContractDiviner.matchingExistingField(callResults, "chainId"), "Mismatched chainId")
|
|
101
|
+
chainId: assertEx2(_CryptoContractDiviner.matchingExistingField(callResults, "chainId"), "Mismatched chainId"),
|
|
102
|
+
schema: ContractInfoSchema
|
|
99
103
|
};
|
|
100
104
|
}
|
|
101
105
|
async divineHandler(inPayloads = []) {
|
|
@@ -111,45 +115,20 @@ var CryptoContractDiviner = class _CryptoContractDiviner extends AbstractDiviner
|
|
|
111
115
|
const result = await Promise.all(
|
|
112
116
|
addresses.map(async (address) => {
|
|
113
117
|
const foundCallResults = callResults.filter((callResult) => callResult.address === address);
|
|
114
|
-
|
|
115
|
-
...await this.reduceResults(
|
|
118
|
+
const info = {
|
|
119
|
+
...{ results: await this.reduceResults(foundCallResults) },
|
|
116
120
|
...this.contractInfoRequiredFields(foundCallResults)
|
|
117
121
|
};
|
|
122
|
+
return info;
|
|
118
123
|
})
|
|
119
124
|
);
|
|
120
125
|
return result;
|
|
121
126
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
var CryptoContractErc721Diviner = class _CryptoContractErc721Diviner extends CryptoContractDiviner {
|
|
128
|
-
static configSchemas = [CryptoContractErc721DivinerConfigSchema];
|
|
129
|
-
async reduceResults(address, callResults) {
|
|
130
|
-
const name = await _CryptoContractErc721Diviner.findCallResult(address, "name", [], callResults);
|
|
131
|
-
const symbol = await _CryptoContractErc721Diviner.findCallResult(address, "symbol", [], callResults);
|
|
132
|
-
const totalSupply = await _CryptoContractErc721Diviner.findCallResult(address, "totalSupply", [], callResults);
|
|
133
|
-
return {
|
|
134
|
-
name,
|
|
135
|
-
schema: Erc721ContractInfoSchema,
|
|
136
|
-
symbol,
|
|
137
|
-
totalSupply
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
// src/Erc1155Diviner.ts
|
|
143
|
-
var CryptoContractErc1155DivinerConfigSchema = "network.xyo.crypto.contract.erc1155.info.diviner.config";
|
|
144
|
-
var Erc1155ContractInfoSchema = "network.xyo.crypto.contract.erc1155.info";
|
|
145
|
-
var CryptoContractErc1155Diviner = class _CryptoContractErc1155Diviner extends CryptoContractDiviner {
|
|
146
|
-
static configSchemas = [CryptoContractErc1155DivinerConfigSchema];
|
|
147
|
-
async reduceResults(address, callResults) {
|
|
148
|
-
const uri = await _CryptoContractErc1155Diviner.findCallResult(address, "uri", [], callResults);
|
|
149
|
-
return {
|
|
150
|
-
schema: Erc1155ContractInfoSchema,
|
|
151
|
-
uri
|
|
152
|
-
};
|
|
127
|
+
reduceResults(callResults) {
|
|
128
|
+
return callResults.reduce((prev, callResult) => {
|
|
129
|
+
prev[callResult.functionName] = callResult.result;
|
|
130
|
+
return prev;
|
|
131
|
+
}, {});
|
|
153
132
|
}
|
|
154
133
|
};
|
|
155
134
|
|
|
@@ -159,14 +138,8 @@ export {
|
|
|
159
138
|
ContractInfoSchema,
|
|
160
139
|
CryptoContractDiviner,
|
|
161
140
|
CryptoContractDivinerConfigSchema,
|
|
162
|
-
CryptoContractErc1155Diviner,
|
|
163
|
-
CryptoContractErc1155DivinerConfigSchema,
|
|
164
|
-
CryptoContractErc721Diviner,
|
|
165
|
-
CryptoContractErc721DivinerConfigSchema,
|
|
166
141
|
CryptoContractFunctionReadWitness,
|
|
167
142
|
CryptoContractFunctionReadWitnessPlugin,
|
|
168
|
-
Erc1155ContractInfoSchema,
|
|
169
|
-
Erc721ContractInfoSchema,
|
|
170
143
|
src_default as default
|
|
171
144
|
};
|
|
172
145
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts","../../src/CryptoContractDiviner.ts","../../src/Erc721Diviner.ts","../../src/Erc1155Diviner.ts","../../src/index.ts"],"sourcesContent":["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'\n\nexport const CryptoContractFunctionReadWitnessPlugin = () =>\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 { AbstractWitness } from '@xyo-network/abstract-witness'\nimport {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n CryptoContractFunctionReadWitnessConfig,\n CryptoContractFunctionReadWitnessConfigSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { WitnessParams } from '@xyo-network/witness-model'\nimport { BigNumber, Contract } from 'ethers'\n\nexport type CryptoContractFunctionReadWitnessParams<TContract extends Contract> = WitnessParams<\n AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>,\n {\n factory: (address: string) => TContract\n }\n>\n\nexport class CryptoContractFunctionReadWitness<\n TContract extends Contract = Contract,\n TParams extends CryptoContractFunctionReadWitnessParams<TContract> = CryptoContractFunctionReadWitnessParams<TContract>,\n> extends AbstractWitness<TParams, CryptoContractFunctionCall<keyof TContract['callStatic']>, CryptoContractFunctionCallResult> {\n static override configSchemas = [CryptoContractFunctionReadWitnessConfigSchema]\n\n protected override async observeHandler(\n inPayloads: CryptoContractFunctionCall<keyof TContract['callStatic']>[] = [],\n ): Promise<CryptoContractFunctionCallResult[]> {\n await this.started('throw')\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType(CryptoContractFunctionCallSchema)).map(async (callPayload) => {\n const fullCallPayload = { ...{ params: [] }, ...this.config.call, ...callPayload }\n const { address, functionName, params } = fullCallPayload\n const validatedAddress = assertEx(address, 'Missing address')\n const contract = this.params.factory(validatedAddress)\n const func = assertEx(contract.callStatic[assertEx(functionName, 'missing functionName')], `functionName [${functionName}] not found`)\n const rawResult = await func(...(params ?? []))\n const result: CryptoContractFunctionCallResult['result'] = BigNumber.isBigNumber(rawResult)\n ? { type: 'BigNumber', value: rawResult.toHexString() }\n : { value: rawResult }\n const observation: CryptoContractFunctionCallResult = {\n address: validatedAddress,\n call: await PayloadHasher.hashAsync(fullCallPayload),\n chainId: (await contract.provider.getNetwork()).chainId,\n result,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n }),\n )\n return observations.flat()\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n }\n\n return []\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Promisable } from '@xylabs/promise'\nimport { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nexport type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined]\n\nexport const CryptoContractDivinerConfigSchema = 'network.xyo.crypto.contract.diviner.config'\nexport type CryptoContractDivinerConfigSchema = typeof CryptoContractDivinerConfigSchema\n\nexport type CryptoContractDivinerConfig = DivinerConfig\nexport type CryptoContractDivinerParams = DivinerParams<CryptoContractDivinerConfig>\n\nexport const ContractInfoSchema = 'network.xyo.crypto.contract.info'\nexport type ContractInfoSchema = typeof ContractInfoSchema\n\nexport type OmittedContractInfo<TFields extends object | Payload | null = null, TSchema extends string | null = null> = Omit<\n ContractInfo<TFields, TSchema extends null ? (TFields extends Payload ? TFields['schema'] : never) : TSchema>,\n 'address' | 'chainId'\n>\n\nexport type ContractInfo<TFields extends object | null = null, TSchema extends string = ContractInfoSchema> = Payload<\n TFields extends null\n ? object\n : TFields & {\n address: string\n chainId: string\n },\n TSchema\n>\n\nexport abstract class CryptoContractDiviner<\n TContractInfo extends Payload<Omit<ContractInfo, 'schema'>> = ContractInfo,\n TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override configSchemas = [CryptoContractDivinerConfigSchema]\n\n protected static async findCallResult<TResult = string>(\n address: string,\n functionName: string,\n params: unknown[],\n payloads: CryptoContractFunctionCallResult[],\n ): Promise<TResult | undefined> {\n const callHash = await this.generateCallHash(address, functionName, params)\n const foundPayload = payloads.find((payload) => payload.call === callHash)\n return foundPayload?.result.value as TResult | undefined\n }\n\n protected static async generateCallHash(address: string, functionName: string, params: unknown[]) {\n const callPayload: CryptoContractFunctionCall = {\n address,\n functionName,\n params,\n schema: CryptoContractFunctionCallSchema,\n }\n return await PayloadHasher.hashAsync(callPayload)\n }\n\n protected static matchingExistingField<R = string, T extends Payload = Payload>(objs: T[], field: keyof T) {\n const expectedValue = objs.at(0)?.[field] as R\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[]): Promisable<Omit<ContractInfo, 'schema'>> {\n return {\n address: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'address'), 'Mismatched address'),\n chainId: assertEx(CryptoContractDiviner.matchingExistingField(callResults, 'chainId'), 'Mismatched chainId'),\n }\n }\n\n protected override async divineHandler(inPayloads: CryptoContractFunctionCallResult[] = []): Promise<TContractInfo[]> {\n const callResults = inPayloads.filter(isPayloadOfSchemaType<CryptoContractFunctionCallResult>(CryptoContractFunctionCallResultSchema))\n const addresses = Object.keys(\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 return {\n ...(await this.reduceResults(address, foundCallResults)),\n ...this.contractInfoRequiredFields(foundCallResults),\n } as TContractInfo\n }),\n )\n\n return result\n }\n\n protected abstract reduceResults(\n address: string,\n callResults: CryptoContractFunctionCallResult[],\n ): Promisable<Omit<TContractInfo, 'address' | 'chainId'>>\n}\n","import { CryptoContractFunctionCallResult } from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\n\nimport { ContractInfo, CryptoContractDiviner, OmittedContractInfo } from './CryptoContractDiviner'\n\nexport const CryptoContractErc721DivinerConfigSchema = 'network.xyo.crypto.contract.erc721.info.diviner.config'\nexport type CryptoContractErc721DivinerConfigSchema = typeof CryptoContractErc721DivinerConfigSchema\n\nexport type CryptoContractErc721DivinerConfig = DivinerConfig\nexport type CryptoContractErc721DivinerParams = DivinerParams<CryptoContractErc721DivinerConfig>\n\nexport const Erc721ContractInfoSchema = 'network.xyo.crypto.contract.erc721.info'\nexport type Erc721ContractInfoSchema = typeof Erc721ContractInfoSchema\n\nexport type Erc721ContractInfo = ContractInfo<\n {\n name?: string\n symbol?: string\n totalSupply?: string\n },\n Erc721ContractInfoSchema\n>\n\nexport class CryptoContractErc721Diviner<\n TParams extends CryptoContractErc721DivinerParams = CryptoContractErc721DivinerParams,\n> extends CryptoContractDiviner<Erc721ContractInfo, TParams> {\n static override configSchemas = [CryptoContractErc721DivinerConfigSchema]\n\n protected override async reduceResults(\n address: string,\n callResults: CryptoContractFunctionCallResult[],\n ): Promise<OmittedContractInfo<Erc721ContractInfo>> {\n const name = await CryptoContractErc721Diviner.findCallResult(address, 'name', [], callResults)\n const symbol = await CryptoContractErc721Diviner.findCallResult(address, 'symbol', [], callResults)\n const totalSupply = await CryptoContractErc721Diviner.findCallResult(address, 'totalSupply', [], callResults)\n return {\n name,\n schema: Erc721ContractInfoSchema,\n symbol,\n totalSupply,\n }\n }\n}\n","import { CryptoContractFunctionCallResult } from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\n\nimport { ContractInfo, CryptoContractDiviner, OmittedContractInfo } from './CryptoContractDiviner'\n\nexport const CryptoContractErc1155DivinerConfigSchema = 'network.xyo.crypto.contract.erc1155.info.diviner.config'\nexport type CryptoContractErc1155DivinerConfigSchema = typeof CryptoContractErc1155DivinerConfigSchema\n\nexport type CryptoContractErc1155DivinerConfig = DivinerConfig\nexport type CryptoContractErc1155DivinerParams = DivinerParams<CryptoContractErc1155DivinerConfig>\n\nexport const Erc1155ContractInfoSchema = 'network.xyo.crypto.contract.erc1155.info'\nexport type Erc1155ContractInfoSchema = typeof Erc1155ContractInfoSchema\n\nexport type Erc1155ContractInfo = ContractInfo<\n {\n uri?: string\n },\n Erc1155ContractInfoSchema\n>\n\nexport class CryptoContractErc1155Diviner<\n TParams extends CryptoContractErc1155DivinerParams = CryptoContractErc1155DivinerParams,\n> extends CryptoContractDiviner<Erc1155ContractInfo, TParams> {\n static override configSchemas = [CryptoContractErc1155DivinerConfigSchema]\n\n protected override async reduceResults(\n address: string,\n callResults: CryptoContractFunctionCallResult[],\n ): Promise<OmittedContractInfo<Erc1155ContractInfo>> {\n const uri = await CryptoContractErc1155Diviner.findCallResult(address, 'uri', [], callResults)\n return {\n schema: Erc1155ContractInfoSchema,\n uri,\n }\n }\n}\n","import { CryptoContractFunctionReadWitnessPlugin } from './Plugin'\n\nexport * from './CryptoContractDiviner'\nexport * from './Erc721Diviner'\nexport * from './Erc1155Diviner'\nexport * from './Witness'\n\nexport { CryptoContractFunctionReadWitnessPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default CryptoContractFunctionReadWitnessPlugin\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACF9C,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC;AAAA,EAGE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,qBAAqB;AAE9B,SAAS,6BAA6B;AAEtC,SAAS,iBAA2B;AAS7B,IAAM,oCAAN,cAGG,gBAAsH;AAAA,EAC9H,OAAgB,gBAAgB,CAAC,6CAA6C;AAAA,EAE9E,MAAyB,eACvB,aAA0E,CAAC,GAC9B;AAC7C,UAAM,KAAK,QAAQ,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,IACF;AAAA,EACF;AACF;;;AC1BA,IAAO,cAAQ;","names":["assertEx","CryptoContractFunctionCallResultSchema","CryptoContractFunctionCallSchema","PayloadHasher","isPayloadOfSchemaType","result"]}
|
|
1
|
+
{"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts","../../src/CryptoContractDiviner.ts","../../src/index.ts"],"sourcesContent":["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'\n\nexport const CryptoContractFunctionReadWitnessPlugin = () =>\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 { AbstractWitness } from '@xyo-network/abstract-witness'\nimport {\n CryptoContractFunctionCall,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n CryptoContractFunctionReadWitnessConfig,\n CryptoContractFunctionReadWitnessConfigSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { WitnessParams } from '@xyo-network/witness-model'\nimport { BigNumber, Contract } from 'ethers'\n\nexport type CryptoContractFunctionReadWitnessParams<TContract extends Contract> = WitnessParams<\n AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>,\n {\n factory: (address: string) => TContract\n }\n>\n\nexport class CryptoContractFunctionReadWitness<\n TContract extends Contract = Contract,\n TParams extends CryptoContractFunctionReadWitnessParams<TContract> = CryptoContractFunctionReadWitnessParams<TContract>,\n> extends AbstractWitness<TParams, CryptoContractFunctionCall<keyof TContract['callStatic']>, CryptoContractFunctionCallResult> {\n static override configSchemas = [CryptoContractFunctionReadWitnessConfigSchema]\n\n protected override async observeHandler(\n inPayloads: CryptoContractFunctionCall<keyof TContract['callStatic']>[] = [],\n ): Promise<CryptoContractFunctionCallResult[]> {\n await this.started('throw')\n try {\n const observations = await Promise.all(\n inPayloads.filter(isPayloadOfSchemaType(CryptoContractFunctionCallSchema)).map(async (callPayload) => {\n const fullCallPayload = { ...{ params: [] }, ...this.config.call, ...callPayload }\n const { address, functionName, params } = fullCallPayload\n const validatedAddress = assertEx(address, 'Missing address')\n const validatedFunctionName = assertEx(functionName, 'Missing functionName')\n const contract = this.params.factory(validatedAddress)\n const func = assertEx(contract.callStatic[validatedFunctionName], `functionName [${validatedFunctionName}] not found`)\n const rawResult = await func(...(params ?? []))\n const result: CryptoContractFunctionCallResult['result'] = BigNumber.isBigNumber(rawResult)\n ? { type: 'BigNumber', value: rawResult.toHexString() }\n : { value: rawResult }\n const observation: CryptoContractFunctionCallResult = {\n address: validatedAddress,\n call: await PayloadHasher.hashAsync(fullCallPayload),\n chainId: (await contract.provider.getNetwork()).chainId,\n functionName: validatedFunctionName,\n params,\n result,\n schema: CryptoContractFunctionCallResultSchema,\n }\n return observation\n }),\n )\n return observations.flat()\n } catch (ex) {\n const error = ex as Error\n console.log(`Error [${this.config.name}]: ${error.message}`)\n }\n\n return []\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Promisable } from '@xylabs/promise'\nimport { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport {\n ContractFunctionResult,\n CryptoContractFunctionCall,\n CryptoContractFunctionCallResult,\n CryptoContractFunctionCallResultSchema,\n CryptoContractFunctionCallSchema,\n} from '@xyo-network/crypto-contract-function-read-payload-plugin'\nimport { DivinerConfig, DivinerParams } from '@xyo-network/diviner-model'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nexport type FindCallResult<TResult = string, TPayload = Payload> = [TResult, TPayload] | [undefined, TPayload] | [undefined, undefined]\n\nexport const CryptoContractDivinerConfigSchema = 'network.xyo.crypto.contract.diviner.config'\nexport type CryptoContractDivinerConfigSchema = typeof CryptoContractDivinerConfigSchema\n\nexport type CryptoContractDivinerConfig = DivinerConfig<{\n schema: CryptoContractDivinerConfigSchema\n}>\nexport type CryptoContractDivinerParams = DivinerParams<CryptoContractDivinerConfig>\n\nexport const ContractInfoSchema = 'network.xyo.crypto.contract.info'\nexport type ContractInfoSchema = typeof ContractInfoSchema\n\nexport type ContractInfo = Payload<\n {\n address: string\n chainId: string\n results?: Record<string, ContractFunctionResult>\n },\n ContractInfoSchema\n>\n\nexport class CryptoContractDiviner<TParams extends CryptoContractDivinerParams = CryptoContractDivinerParams> extends AbstractDiviner<TParams> {\n static override configSchemas = [CryptoContractDivinerConfigSchema]\n\n protected static async findCallResult<TResult = string>(\n address: string,\n functionName: string,\n params: unknown[],\n payloads: CryptoContractFunctionCallResult[],\n ): Promise<TResult | undefined> {\n const callHash = await this.generateCallHash(address, functionName, params)\n const foundPayload = payloads.find((payload) => payload.call === callHash)\n return foundPayload?.result.value as TResult | undefined\n }\n\n protected static async generateCallHash(address: string, functionName: string, params: unknown[]) {\n const callPayload: CryptoContractFunctionCall = {\n address,\n functionName,\n params,\n schema: CryptoContractFunctionCallSchema,\n }\n return await PayloadHasher.hashAsync(callPayload)\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 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 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 return callResults.reduce<Record<string, ContractFunctionResult>>((prev, callResult) => {\n prev[callResult.functionName] = callResult.result\n return prev\n }, {})\n }\n}\n","import { CryptoContractFunctionReadWitnessPlugin } from './Plugin'\n\nexport * from './CryptoContractDiviner'\nexport * from './Witness'\n\nexport { CryptoContractFunctionReadWitnessPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default CryptoContractFunctionReadWitnessPlugin\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACF9C,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC;AAAA,EAGE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,qBAAqB;AAE9B,SAAS,6BAA6B;AAEtC,SAAS,iBAA2B;AAS7B,IAAM,oCAAN,cAGG,gBAAsH;AAAA,EAC9H,OAAgB,gBAAgB,CAAC,6CAA6C;AAAA,EAE9E,MAAyB,eACvB,aAA0E,CAAC,GAC9B;AAC7C,UAAM,KAAK,QAAQ,OAAO;AAC1B,QAAI;AACF,YAAM,eAAe,MAAM,QAAQ;AAAA,QACjC,WAAW,OAAO,sBAAsB,gCAAgC,CAAC,EAAE,IAAI,O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gC,CAAC,MAAMI,YAAW;AAC5D,YAAIA,QAAO,SAAS;AAClB,eAAKA,QAAO,OAAO,IAAI;AAAA,QACzB;AACA,eAAO;AAAA,MACT,GAAG,CAAC,CAAC;AAAA,IACP;AACA,UAAM,SAAS,MAAM,QAAQ;AAAA,MAC3B,UAAU,IAAI,OAAO,YAAY;AAC/B,cAAM,mBAAmB,YAAY,OAAO,CAAC,eAAe,WAAW,YAAY,OAAO;AAC1F,cAAM,OAAqB;AAAA,UACzB,GAAG,EAAE,SAAS,MAAM,KAAK,cAAc,gBAAgB,EAAE;AAAA,UACzD,GAAG,KAAK,2BAA2B,gBAAgB;AAAA,QACrD;AACA,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AAAA,EAEU,cAAc,aAAsF;AAC5G,WAAO,YAAY,OAA+C,CAAC,MAAM,eAAe;AACtF,WAAK,WAAW,YAAY,IAAI,WAAW;AAC3C,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,EACP;AACF;;;AClGA,IAAO,cAAQ;","names":["assertEx","CryptoContractFunctionCallResultSchema","CryptoContractFunctionCallSchema","PayloadHasher","isPayloadOfSchemaType","result"]}
|