@xyo-network/crypto-contract-function-read-plugin 2.78.0 → 2.78.1
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 +3 -4
- package/dist/browser/CryptoContractDiviner.d.cts.map +1 -1
- package/dist/browser/CryptoContractDiviner.d.mts +3 -4
- package/dist/browser/CryptoContractDiviner.d.mts.map +1 -1
- package/dist/browser/CryptoContractDiviner.d.ts +3 -4
- package/dist/browser/CryptoContractDiviner.d.ts.map +1 -1
- package/dist/browser/Plugin.d.cts +33 -3
- package/dist/browser/Plugin.d.cts.map +1 -1
- package/dist/browser/Plugin.d.mts +33 -3
- package/dist/browser/Plugin.d.mts.map +1 -1
- package/dist/browser/Plugin.d.ts +33 -3
- package/dist/browser/Plugin.d.ts.map +1 -1
- package/dist/browser/Witness.d.cts +5 -5
- package/dist/browser/Witness.d.cts.map +1 -1
- package/dist/browser/Witness.d.mts +5 -5
- package/dist/browser/Witness.d.mts.map +1 -1
- package/dist/browser/Witness.d.ts +5 -5
- package/dist/browser/Witness.d.ts.map +1 -1
- package/dist/browser/index.cjs +40 -42
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +42 -44
- package/dist/browser/index.js.map +1 -1
- package/dist/node/CryptoContractDiviner.d.cts +3 -4
- package/dist/node/CryptoContractDiviner.d.cts.map +1 -1
- package/dist/node/CryptoContractDiviner.d.mts +3 -4
- package/dist/node/CryptoContractDiviner.d.mts.map +1 -1
- package/dist/node/CryptoContractDiviner.d.ts +3 -4
- package/dist/node/CryptoContractDiviner.d.ts.map +1 -1
- package/dist/node/Plugin.d.cts +33 -3
- package/dist/node/Plugin.d.cts.map +1 -1
- package/dist/node/Plugin.d.mts +33 -3
- package/dist/node/Plugin.d.mts.map +1 -1
- package/dist/node/Plugin.d.ts +33 -3
- package/dist/node/Plugin.d.ts.map +1 -1
- package/dist/node/Witness.d.cts +5 -5
- package/dist/node/Witness.d.cts.map +1 -1
- package/dist/node/Witness.d.mts +5 -5
- package/dist/node/Witness.d.mts.map +1 -1
- package/dist/node/Witness.d.ts +5 -5
- package/dist/node/Witness.d.ts.map +1 -1
- package/dist/node/index.js +42 -42
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +44 -44
- package/dist/node/index.mjs.map +1 -1
- package/package.json +14 -14
- package/src/CryptoContractDiviner.ts +5 -19
- package/src/Erc721Sentinel.json +11 -37
- package/src/Witness.ts +44 -40
- package/src/Erc721SentinelFull.json +0 -212
package/src/Witness.ts
CHANGED
|
@@ -1,74 +1,78 @@
|
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber'
|
|
2
|
+
import { Contract } from '@ethersproject/contracts'
|
|
3
|
+
import { JsonRpcProvider } from '@ethersproject/providers'
|
|
1
4
|
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import { fulfilled } from '@xylabs/promise'
|
|
3
5
|
import { AbstractWitness } from '@xyo-network/abstract-witness'
|
|
4
6
|
import {
|
|
5
7
|
CryptoContractFunctionCall,
|
|
8
|
+
CryptoContractFunctionCallFailure,
|
|
6
9
|
CryptoContractFunctionCallResult,
|
|
7
10
|
CryptoContractFunctionCallResultSchema,
|
|
8
11
|
CryptoContractFunctionCallSchema,
|
|
12
|
+
CryptoContractFunctionCallSuccess,
|
|
9
13
|
CryptoContractFunctionReadWitnessConfig,
|
|
10
14
|
CryptoContractFunctionReadWitnessConfigSchema,
|
|
11
15
|
} from '@xyo-network/crypto-contract-function-read-payload-plugin'
|
|
12
16
|
import { AnyConfigSchema } from '@xyo-network/module-model'
|
|
13
17
|
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
14
18
|
import { WitnessParams } from '@xyo-network/witness-model'
|
|
15
|
-
import { BigNumber, Contract } from 'ethers'
|
|
16
19
|
|
|
17
|
-
export type CryptoContractFunctionReadWitnessParams
|
|
20
|
+
export type CryptoContractFunctionReadWitnessParams = WitnessParams<
|
|
18
21
|
AnyConfigSchema<CryptoContractFunctionReadWitnessConfig>,
|
|
19
22
|
{
|
|
20
|
-
|
|
23
|
+
providers: JsonRpcProvider[]
|
|
21
24
|
}
|
|
22
25
|
>
|
|
23
26
|
|
|
24
27
|
export class CryptoContractFunctionReadWitness<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
> extends AbstractWitness<TParams, CryptoContractFunctionCall<keyof TContract['callStatic']>, CryptoContractFunctionCallResult> {
|
|
28
|
+
TParams extends CryptoContractFunctionReadWitnessParams = CryptoContractFunctionReadWitnessParams,
|
|
29
|
+
> extends AbstractWitness<TParams, CryptoContractFunctionCall, CryptoContractFunctionCallResult> {
|
|
28
30
|
static override configSchemas = [CryptoContractFunctionReadWitnessConfigSchema]
|
|
29
31
|
|
|
30
|
-
protected override async observeHandler(
|
|
31
|
-
inPayloads: CryptoContractFunctionCall<keyof TContract['callStatic']>[] = [],
|
|
32
|
-
): Promise<CryptoContractFunctionCallResult[]> {
|
|
32
|
+
protected override async observeHandler(inPayloads: CryptoContractFunctionCall[] = []): Promise<CryptoContractFunctionCallResult[]> {
|
|
33
33
|
await this.started('throw')
|
|
34
34
|
try {
|
|
35
|
-
const observations = await Promise.
|
|
36
|
-
inPayloads.filter(isPayloadOfSchemaType(CryptoContractFunctionCallSchema)).map(async (
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const validatedAddress = assertEx(address, 'Missing address')
|
|
40
|
-
const validatedFunctionName = assertEx(functionName, 'Missing
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
const observations = await Promise.all(
|
|
36
|
+
inPayloads.filter(isPayloadOfSchemaType(CryptoContractFunctionCallSchema)).map(async ({ functionName, args, address }) => {
|
|
37
|
+
const { providers } = this.params
|
|
38
|
+
const provider = providers[Date.now() % providers.length] //pick a random provider
|
|
39
|
+
const validatedAddress = assertEx(address ?? this.config.address, 'Missing address')
|
|
40
|
+
const validatedFunctionName = assertEx(functionName ?? this.config.functionName, 'Missing address')
|
|
41
|
+
const mergedArgs = [...(args ?? this.config.args ?? [])]
|
|
42
|
+
|
|
43
|
+
const contract = new Contract(validatedAddress, this.config.contract, provider)
|
|
44
|
+
try {
|
|
45
|
+
const result = await contract.callStatic[validatedFunctionName](...mergedArgs)
|
|
46
|
+
const transformedResult = BigNumber.isBigNumber(result) ? result.toHexString() : result
|
|
47
|
+
const observation: CryptoContractFunctionCallSuccess = {
|
|
48
|
+
address: validatedAddress,
|
|
49
|
+
args: mergedArgs,
|
|
50
|
+
chainId: provider.network.chainId,
|
|
51
|
+
functionName: validatedFunctionName,
|
|
52
|
+
result: transformedResult,
|
|
53
|
+
schema: CryptoContractFunctionCallResultSchema,
|
|
54
|
+
}
|
|
55
|
+
return observation
|
|
56
|
+
} catch (ex) {
|
|
57
|
+
const error = ex as Error & { code: string }
|
|
58
|
+
console.log(`Error [${this.config.name}]: ${error.code}`)
|
|
59
|
+
const observation: CryptoContractFunctionCallFailure = {
|
|
60
|
+
address: validatedAddress,
|
|
61
|
+
args: mergedArgs,
|
|
62
|
+
chainId: provider.network.chainId,
|
|
63
|
+
error: error.code,
|
|
64
|
+
functionName: validatedFunctionName,
|
|
65
|
+
schema: CryptoContractFunctionCallResultSchema,
|
|
50
66
|
}
|
|
51
|
-
|
|
52
|
-
const result: CryptoContractFunctionCallResult['result'] = BigNumber.isBigNumber(rawResult)
|
|
53
|
-
? { type: 'BigNumber', value: rawResult.toHexString() }
|
|
54
|
-
: { value: rawResult }
|
|
55
|
-
const observation: CryptoContractFunctionCallResult = {
|
|
56
|
-
address: validatedAddress,
|
|
57
|
-
chainId: (await contract.provider.getNetwork()).chainId,
|
|
58
|
-
functionName: validatedFunctionName,
|
|
59
|
-
params,
|
|
60
|
-
result,
|
|
61
|
-
schema: CryptoContractFunctionCallResultSchema,
|
|
67
|
+
return observation
|
|
62
68
|
}
|
|
63
|
-
return observation
|
|
64
69
|
}),
|
|
65
70
|
)
|
|
66
|
-
return observations
|
|
71
|
+
return observations
|
|
67
72
|
} catch (ex) {
|
|
68
73
|
const error = ex as Error
|
|
69
74
|
console.log(`Error [${this.config.name}]: ${error.message}`)
|
|
75
|
+
throw error
|
|
70
76
|
}
|
|
71
|
-
|
|
72
|
-
return []
|
|
73
77
|
}
|
|
74
78
|
}
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/a5a229a767e3998e13cce8160fd1c2b027317424/packages/manifest/src/schema.json",
|
|
3
|
-
"nodes": [
|
|
4
|
-
{
|
|
5
|
-
"config": {
|
|
6
|
-
"accountPath": "m/44'/60'/1'/0'/0'",
|
|
7
|
-
"name": "NftInfo",
|
|
8
|
-
"schema": "network.xyo.node.config"
|
|
9
|
-
},
|
|
10
|
-
"modules": {
|
|
11
|
-
"public": [
|
|
12
|
-
{
|
|
13
|
-
"config": {
|
|
14
|
-
"accountPath": "m/44'/60'/1'/1'/0'",
|
|
15
|
-
"call": {
|
|
16
|
-
"functionName": "name",
|
|
17
|
-
"params": []
|
|
18
|
-
},
|
|
19
|
-
"labels": {
|
|
20
|
-
"network.xyo.crypto.contract.interface": "Erc721"
|
|
21
|
-
},
|
|
22
|
-
"language": "javascript",
|
|
23
|
-
"name": "Erc721NameWitness",
|
|
24
|
-
"schema": "network.xyo.crypto.contract.function.read.config"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"config": {
|
|
29
|
-
"accountPath": "m/44'/60'/1'/1'/1'",
|
|
30
|
-
"call": {
|
|
31
|
-
"functionName": "symbol",
|
|
32
|
-
"params": []
|
|
33
|
-
},
|
|
34
|
-
"labels": {
|
|
35
|
-
"network.xyo.crypto.contract.interface": "Erc721"
|
|
36
|
-
},
|
|
37
|
-
"language": "javascript",
|
|
38
|
-
"name": "Erc721SymbolWitness",
|
|
39
|
-
"schema": "network.xyo.crypto.contract.function.read.config"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"config": {
|
|
44
|
-
"accountPath": "m/44'/60'/1'/1'/2'",
|
|
45
|
-
"call": {
|
|
46
|
-
"functionName": "tokenURI"
|
|
47
|
-
},
|
|
48
|
-
"labels": {
|
|
49
|
-
"network.xyo.crypto.contract.interface": "Erc721"
|
|
50
|
-
},
|
|
51
|
-
"language": "javascript",
|
|
52
|
-
"name": "Erc721TokenURIWitness",
|
|
53
|
-
"schema": "network.xyo.crypto.contract.function.read.config"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"config": {
|
|
58
|
-
"accountPath": "m/44'/60'/1'/1'/3'",
|
|
59
|
-
"call": {
|
|
60
|
-
"functionName": "ownerOf"
|
|
61
|
-
},
|
|
62
|
-
"labels": {
|
|
63
|
-
"network.xyo.crypto.contract.interface": "Erc721"
|
|
64
|
-
},
|
|
65
|
-
"language": "javascript",
|
|
66
|
-
"name": "Erc721OwnerOfWitness",
|
|
67
|
-
"schema": "network.xyo.crypto.contract.function.read.config"
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"config": {
|
|
72
|
-
"accountPath": "m/44'/60'/1'/1'/4'",
|
|
73
|
-
"call": {
|
|
74
|
-
"functionName": "totalSupply",
|
|
75
|
-
"params": []
|
|
76
|
-
},
|
|
77
|
-
"labels": {
|
|
78
|
-
"network.xyo.crypto.contract.interface": "Erc721Enumerable"
|
|
79
|
-
},
|
|
80
|
-
"language": "javascript",
|
|
81
|
-
"name": "Erc721TotalSupplyWitness",
|
|
82
|
-
"schema": "network.xyo.crypto.contract.function.read.config"
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
"config": {
|
|
87
|
-
"accountPath": "m/44'/60'/1'/1'/5'",
|
|
88
|
-
"call": {
|
|
89
|
-
"functionName": "tokenByIndex"
|
|
90
|
-
},
|
|
91
|
-
"labels": {
|
|
92
|
-
"network.xyo.crypto.contract.interface": "Erc721Enumerable"
|
|
93
|
-
},
|
|
94
|
-
"language": "javascript",
|
|
95
|
-
"name": "Erc721TokenByIndexWitness",
|
|
96
|
-
"schema": "network.xyo.crypto.contract.function.read.config"
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"config": {
|
|
101
|
-
"accountPath": "m/44'/60'/1'/1'/8'",
|
|
102
|
-
"call": {
|
|
103
|
-
"functionName": "uri",
|
|
104
|
-
"params": []
|
|
105
|
-
},
|
|
106
|
-
"labels": {
|
|
107
|
-
"network.xyo.crypto.contract.interface": "Erc1155"
|
|
108
|
-
},
|
|
109
|
-
"language": "javascript",
|
|
110
|
-
"name": "Erc1155UriWitness",
|
|
111
|
-
"schema": "network.xyo.crypto.contract.function.read.config"
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
"config": {
|
|
116
|
-
"accountPath": "m/44'/60'/1'/2'/0'",
|
|
117
|
-
"language": "javascript",
|
|
118
|
-
"name": "Erc721ContractInfoDiviner",
|
|
119
|
-
"schema": "network.xyo.crypto.contract.diviner.config"
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
"config": {
|
|
124
|
-
"accountPath": "m/44'/60'/1'/2'/1'",
|
|
125
|
-
"language": "javascript",
|
|
126
|
-
"name": "Erc1155ContractInfoDiviner",
|
|
127
|
-
"schema": "network.xyo.crypto.contract.diviner.config"
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
"config": {
|
|
132
|
-
"accountPath": "m/44'/60'/1'/3'/0'",
|
|
133
|
-
"language": "javascript",
|
|
134
|
-
"name": "NftInfoSentinel",
|
|
135
|
-
"schema": "network.xyo.sentinel.config",
|
|
136
|
-
"synchronous": "true",
|
|
137
|
-
"tasks": [
|
|
138
|
-
{
|
|
139
|
-
"input": true,
|
|
140
|
-
"module": "Erc721NameWitness"
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
"input": true,
|
|
144
|
-
"module": "Erc721SymbolWitness"
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
"input": true,
|
|
148
|
-
"module": "Erc721TotalSupplyWitness"
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
"input": true,
|
|
152
|
-
"module": "Erc1155UriWitness"
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
"input": [
|
|
156
|
-
"Erc721NameWitness",
|
|
157
|
-
"Erc721SymbolWitness",
|
|
158
|
-
"Erc721TotalSupplyWitness"
|
|
159
|
-
],
|
|
160
|
-
"module": "Erc721ContractInfoDiviner"
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
"input": [
|
|
164
|
-
"Erc1155UriWitness"
|
|
165
|
-
],
|
|
166
|
-
"module": "Erc1155ContractInfoDiviner"
|
|
167
|
-
}
|
|
168
|
-
]
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"config": {
|
|
173
|
-
"accountPath": "m/44'/60'/1'/3'/1'",
|
|
174
|
-
"language": "javascript",
|
|
175
|
-
"name": "NftTokenInfoSentinel",
|
|
176
|
-
"schema": "network.xyo.sentinel.config",
|
|
177
|
-
"synchronous": "true",
|
|
178
|
-
"tasks": [
|
|
179
|
-
{
|
|
180
|
-
"input": true,
|
|
181
|
-
"module": "Erc721TokenURIWitness"
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
"input": true,
|
|
185
|
-
"module": "Erc721OwnerOfWitness"
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
"input": true,
|
|
189
|
-
"module": "Erc1155UriWitness"
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
"input": [
|
|
193
|
-
"Erc721TokenByIndexWitness",
|
|
194
|
-
"Erc721OwnerOfWitness"
|
|
195
|
-
],
|
|
196
|
-
"module": "Erc721ContractInfoDiviner"
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
"input": [
|
|
200
|
-
"Erc1155UriWitness"
|
|
201
|
-
],
|
|
202
|
-
"module": "Erc1155ContractInfoDiviner"
|
|
203
|
-
}
|
|
204
|
-
]
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
]
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
],
|
|
211
|
-
"schema": "network.xyo.manifest"
|
|
212
|
-
}
|