@xyo-network/diviner-evm-call-result-to-token-uri 4.1.1 → 5.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.
- package/dist/neutral/index.d.ts +6 -53
- package/package.json +15 -12
- package/src/spec/Diviner.spec.ts +72 -0
- package/typedoc.json +0 -5
- package/xy.config.ts +0 -10
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,53 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The config schema for the EVM call result to NFT token URI diviner
|
|
10
|
-
*/
|
|
11
|
-
declare const EvmCallResultToNftTokenUriDivinerConfigSchema = "network.xyo.evm.call.results.metadata.uri.diviner.config";
|
|
12
|
-
/**
|
|
13
|
-
* The config schema for the EVM call result to NFT token URI diviner
|
|
14
|
-
*/
|
|
15
|
-
type EvmCallResultToNftTokenUriDivinerConfigSchema = typeof EvmCallResultToNftTokenUriDivinerConfigSchema;
|
|
16
|
-
/**
|
|
17
|
-
* The config for the EVM call result to NFT token URI diviner
|
|
18
|
-
*/
|
|
19
|
-
type EvmCallResultToNftTokenUriDivinerConfig = DivinerConfig<{
|
|
20
|
-
schema: EvmCallResultToNftTokenUriDivinerConfigSchema;
|
|
21
|
-
}>;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The params for the EVM call result to NFT token URI diviner
|
|
25
|
-
*/
|
|
26
|
-
type EvmCallResultToNftTokenUriDivinerParams = DivinerParams<AnyConfigSchema<EvmCallResultToNftTokenUriDivinerConfig>>;
|
|
27
|
-
|
|
28
|
-
declare class EvmCallResultToNftTokenUriDiviner<TParams extends EvmCallResultToNftTokenUriDivinerParams = EvmCallResultToNftTokenUriDivinerParams> extends AbstractDiviner<TParams, Payload, NftMetadataUri> {
|
|
29
|
-
static readonly configSchemas: Schema[];
|
|
30
|
-
static readonly defaultConfigSchema: Schema;
|
|
31
|
-
protected divineHandler(payloads?: Payload[]): NftMetadataUri[];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type EvmTokenUriCallResults = EvmCallResults & {
|
|
35
|
-
results: {
|
|
36
|
-
tokenURI: {
|
|
37
|
-
args: [string];
|
|
38
|
-
result?: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The schema for the EVM call result to NFT token URI diviner.
|
|
45
|
-
*/
|
|
46
|
-
declare const EvmCallResultToNftTokenUriDivinerSchema = "network.xyo.evm.call.results.metadata.uri.diviner";
|
|
47
|
-
/**
|
|
48
|
-
* The schema for the EVM call result to NFT token URI diviner.
|
|
49
|
-
*/
|
|
50
|
-
type EvmCallResultToNftTokenUriDivinerSchema = typeof EvmCallResultToNftTokenUriDivinerSchema;
|
|
51
|
-
|
|
52
|
-
export { EvmCallResultToNftTokenUriDiviner, EvmCallResultToNftTokenUriDivinerConfigSchema, EvmCallResultToNftTokenUriDivinerSchema };
|
|
53
|
-
export type { EvmCallResultToNftTokenUriDivinerConfig, EvmCallResultToNftTokenUriDivinerParams, EvmTokenUriCallResults };
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export * from './Diviner.ts';
|
|
3
|
+
export * from './Params.ts';
|
|
4
|
+
export * from './Payload.ts';
|
|
5
|
+
export * from './Schema.ts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/diviner-evm-call-result-to-token-uri",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -28,20 +28,23 @@
|
|
|
28
28
|
},
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
31
35
|
"dependencies": {
|
|
32
|
-
"@xyo-network/diviner-abstract": "^
|
|
33
|
-
"@xyo-network/diviner-model": "^
|
|
34
|
-
"@xyo-network/evm-call-witness": "^
|
|
35
|
-
"@xyo-network/evm-nft-id-payload-plugin": "^
|
|
36
|
-
"@xyo-network/module-model": "^
|
|
37
|
-
"@xyo-network/payload-model": "^
|
|
36
|
+
"@xyo-network/diviner-abstract": "^5.0.0",
|
|
37
|
+
"@xyo-network/diviner-model": "^5.0.0",
|
|
38
|
+
"@xyo-network/evm-call-witness": "^5.0.0",
|
|
39
|
+
"@xyo-network/evm-nft-id-payload-plugin": "^5.0.0",
|
|
40
|
+
"@xyo-network/module-model": "^5.0.0",
|
|
41
|
+
"@xyo-network/payload-model": "^5.0.0"
|
|
38
42
|
},
|
|
39
43
|
"devDependencies": {
|
|
40
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
41
|
-
"@xylabs/tsconfig": "^7.0.
|
|
42
|
-
"@xylabs/vitest-extended": "^
|
|
43
|
-
"@xyo-network/evm-nft-id-payload-plugin": "^
|
|
44
|
-
"knip": "^5.62.0",
|
|
44
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.2",
|
|
45
|
+
"@xylabs/tsconfig": "^7.0.2",
|
|
46
|
+
"@xylabs/vitest-extended": "^5.0.0",
|
|
47
|
+
"@xyo-network/evm-nft-id-payload-plugin": "^5.0.0",
|
|
45
48
|
"typescript": "^5.8.3",
|
|
46
49
|
"vitest": "^3.2.4"
|
|
47
50
|
},
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import { isNftMetadataUri, NftMetadataUriSchema } from '@xyo-network/evm-nft-id-payload-plugin'
|
|
4
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
5
|
+
import {
|
|
6
|
+
beforeAll,
|
|
7
|
+
describe, expect, it,
|
|
8
|
+
} from 'vitest'
|
|
9
|
+
|
|
10
|
+
import { EvmCallResultToNftTokenUriDivinerConfigSchema } from '../Config.ts'
|
|
11
|
+
import { EvmCallResultToNftTokenUriDiviner } from '../Diviner.ts'
|
|
12
|
+
import type { EvmTokenUriCallResults } from '../Payload.ts'
|
|
13
|
+
|
|
14
|
+
const validateResult = (evmCallResults: EvmTokenUriCallResults, actual: Payload[]) => {
|
|
15
|
+
const results = actual.filter(isNftMetadataUri)
|
|
16
|
+
expect(results.length).toBe(1)
|
|
17
|
+
const {
|
|
18
|
+
address,
|
|
19
|
+
chainId,
|
|
20
|
+
results: { tokenURI: { args: [tokenId] } },
|
|
21
|
+
} = evmCallResults
|
|
22
|
+
expect(results[0].address).toBe(address)
|
|
23
|
+
expect(results[0].chainId).toBe(chainId)
|
|
24
|
+
expect(results[0].tokenId).toBe(tokenId)
|
|
25
|
+
expect(results[0].schema).toBe(NftMetadataUriSchema)
|
|
26
|
+
expect(results[0].metadataUri).toBeString()
|
|
27
|
+
const num = Number(BigInt(tokenId)).toString()
|
|
28
|
+
// It is not always true that the metadata URI contains the token ID, but
|
|
29
|
+
// it is true for the cases we are testing
|
|
30
|
+
expect(results[0].metadataUri).toContain(num)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe('CryptoWalletNftDiviner', () => {
|
|
34
|
+
const cases = [
|
|
35
|
+
{
|
|
36
|
+
address: '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D',
|
|
37
|
+
chainId: 1,
|
|
38
|
+
results: { tokenURI: { args: ['0x0f'], result: 'ipfs://QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/15' } },
|
|
39
|
+
schema: 'network.xyo.evm.call.results',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
address: '0xEdB61f74B0d09B2558F1eeb79B247c1F363Ae452',
|
|
43
|
+
chainId: 1,
|
|
44
|
+
results: { tokenURI: { args: ['0x543'], result: 'https://gutter-cats-metadata.s3.us-east-2.amazonaws.com/metadata/1347' } },
|
|
45
|
+
schema: 'network.xyo.evm.call.results',
|
|
46
|
+
},
|
|
47
|
+
] as EvmTokenUriCallResults[]
|
|
48
|
+
let diviner: EvmCallResultToNftTokenUriDiviner
|
|
49
|
+
beforeAll(async () => {
|
|
50
|
+
diviner = await EvmCallResultToNftTokenUriDiviner.create({
|
|
51
|
+
account: 'random',
|
|
52
|
+
config: { schema: EvmCallResultToNftTokenUriDivinerConfigSchema },
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
describe('divine', () => {
|
|
56
|
+
it.each(cases)('transforms the input to the result', async (evmCallResult) => {
|
|
57
|
+
const result = await diviner.divine([evmCallResult])
|
|
58
|
+
validateResult(evmCallResult, result)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('replaced values in templatized results', async () => {
|
|
62
|
+
const evmCallResult = {
|
|
63
|
+
address: '0xEdB61f74B0d09B2558F1eeb79B247c1F363Ae452',
|
|
64
|
+
chainId: 1,
|
|
65
|
+
results: { tokenURI: { args: ['0x543'], result: 'https://gutter-cats-metadata.s3.us-east-2.amazonaws.com/metadata/{id}' } },
|
|
66
|
+
schema: 'network.xyo.evm.call.results',
|
|
67
|
+
} as EvmTokenUriCallResults
|
|
68
|
+
const result = await diviner.divine([evmCallResult])
|
|
69
|
+
validateResult(evmCallResult, result)
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
})
|
package/typedoc.json
DELETED