Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFT Metadata Index Manifest & Tests #19

Merged
merged 9 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"--forceExit",
"--runInBand",
"--testTimeout=120000",
"packages/payloadset/packages/evm/src/spec/NftIdToNftMetadataUri/NftIdToNftMetadataUri.spec.ts"
"packages/payloadset/packages/evm/src/spec/NftMetadataUriToNftMetadata/NftMetadataUriToNftMetadata.spec.ts"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
Expand Down
24 changes: 15 additions & 9 deletions packages/payloadset/packages/api/src/Payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export type ApiUriCall = Payload<
},
ApiCallSchema
>
export const isApiUriCall = (value?: unknown): value is ApiUriCall => isApiCall(value) && !!(value as ApiUriCall).uri
export const asApiUriCall = AsObjectFactory.create(isApiUriCall)

export type ApiUriTemplateCall = Payload<
ApiCallFields & {
Expand All @@ -27,12 +29,18 @@ export type ApiUriTemplateCall = Payload<
},
ApiCallSchema
>
export const isApiUriTemplateCall = (value?: unknown): value is ApiUriTemplateCall =>
isApiCall(value) && !!((value as ApiUriTemplateCall).uriTemplate || (value as ApiUriTemplateCall).params)
export const asApiUriTemplateCall = AsObjectFactory.create(isApiUriTemplateCall)

export type ApiCall = ApiUriCall | ApiUriTemplateCall

export const ApiCallResultSchema = 'network.xyo.api.call.result'
export type ApiCallResultSchema = typeof ApiCallResultSchema

export const isApiCall = isPayloadOfSchemaType(ApiCallSchema)
export const asApiCall = AsObjectFactory.create(isApiCall)

export interface HttpMeta {
code?: string
status?: number
Expand All @@ -49,6 +57,11 @@ export type ApiCallJsonResult<T extends ApiCallJsonResultType = ApiCallJsonResul
ApiCallResultSchema
>

export const isApiCallJsonResult = <T extends ApiCallJsonResultType = ApiCallJsonResultType>(x?: unknown | null): x is ApiCallJsonResult<T> => {
return isPayloadOfSchemaType(ApiCallResultSchema)(x) && (x as ApiCallJsonResult)?.contentType === 'application/json'
}
export const asApiCallJsonResult = AsObjectFactory.create(isApiCallJsonResult)

export type ApiCallBase64Result = Payload<
{
call: Hash
Expand All @@ -71,12 +84,5 @@ export type ApiCallResult<TJson extends JsonArray | JsonObject = JsonArray | Jso
| ApiCallJsonResult<TJson>
| ApiCallErrorResult

export const isApiCall = isPayloadOfSchemaType(ApiCallSchema)
export const asApiCall = AsObjectFactory.create(isApiCall)

export const isApiUriCall = (value?: unknown): value is ApiUriCall => isApiCall(value) && !!(value as ApiUriCall).uri
export const asApiUriCall = AsObjectFactory.create(isApiUriCall)

export const isApiUriTemplateCall = (value?: unknown): value is ApiUriTemplateCall =>
isApiCall(value) && !!((value as ApiUriTemplateCall).uriTemplate || (value as ApiUriTemplateCall).params)
export const asApiUriTemplateCall = AsObjectFactory.create(isApiUriTemplateCall)
export const isApiCallResult = isPayloadOfSchemaType(ApiCallResultSchema)
export const asApiCallResult = AsObjectFactory.create(isApiCallResult)
1 change: 1 addition & 0 deletions packages/payloadset/packages/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@xylabs/ts-scripts-yarn3": "^3.2.28",
"@xylabs/tsconfig": "^3.2.28",
"@xyo-network/account": "^2.86.1",
"@xyo-network/api-call-witness": "workspace:~",
"@xyo-network/diviner-boundwitness-memory": "^2.86.1",
"@xyo-network/diviner-evm-call-result-to-token-uri": "workspace:~",
"@xyo-network/diviner-model": "^2.86.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ describeIf(providers.length)('NftIdToNftMetadataUri', () => {
})
})
describe('Index', () => {
it.each(cases)('returns indexed NftIndex results', async (address, tokenId) => {
beforeAll(async () => {
await delay(100)
})
it.each(cases)('returns indexed NftIndex results', async (address, tokenId) => {
const diviner = asDivinerInstance(await node.resolve('IndexDiviner'))
expect(diviner).toBeDefined()
const query = { address, chainId, length: 1, schema: PayloadDivinerQuerySchema, tokenId }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
{
"$schema": "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
"nodes": [
{
"config": {
"name": "NftTokenUriNode",
"schema": "network.xyo.node.config"
},
"modules": {
"private": [
{
"config": {
"name": "AddressStateArchivist",
"schema": "network.xyo.archivist.config",
"storeQueries": false
}
},
{
"config": {
"archivist": "AddressStateArchivist",
"name": "AddressStateBoundWitnessDiviner",
"schema": "network.xyo.diviner.boundwitness.config"
}
},
{
"config": {
"archivist": "AddressStateArchivist",
"name": "AddressStatePayloadDiviner",
"schema": "network.xyo.diviner.payload.config"
}
},
{
"config": {
"name": "IndexArchivist",
"schema": "network.xyo.archivist.config"
}
},
{
"config": {
"archivist": "IndexArchivist",
"name": "IndexBoundWitnessDiviner",
"schema": "network.xyo.diviner.boundwitness.config"
}
},
{
"config": {
"archivist": "IndexArchivist",
"name": "IndexPayloadDiviner",
"schema": "network.xyo.diviner.payload.config"
}
},
{
"config": {
"filter": {
"payload_schemas": ["network.xyo.api.call.result"]
},
"labels": {
"network.xyo.diviner.stage": "stateToIndexCandidateDiviner"
},
"name": "StateToIndexCandidateDiviner",
"payloadStore": {
"archivist": "Archivist",
"boundWitnessDiviner": "BoundWitnessDiviner",
"payloadDiviner": "PayloadDiviner"
},
"schema": "network.xyo.diviner.indexing.temporal.stage.stateToIndexCandidateDiviner.config"
}
},
{
"config": {
"labels": {
"network.xyo.diviner.stage": "indexCandidateToIndexDiviner"
},
"name": "IndexCandidateToIndexDiviner",
"schema": "network.xyo.diviner.indexing.temporal.stage.indexCandidateToIndexDiviner.config",
"schemaTransforms": {
"network.xyo.api.call.result": [
{
"destinationField": "uri",
"sourcePathExpression": "$.call"
}
],
"network.xyo.timestamp": [
{
"destinationField": "timestamp",
"sourcePathExpression": "$.timestamp"
}
]
}
}
},
{
"config": {
"divinerQuerySchema": "network.xyo.diviner.payload.query",
"indexQuerySchema": "network.xyo.diviner.payload.query",
"indexSchema": "network.xyo.diviner.indexing.temporal.result.index",
"labels": {
"network.xyo.diviner.stage": "divinerQueryToIndexQueryDiviner"
},
"name": "QueryToIndexQueryDiviner",
"schema": "network.xyo.diviner.indexing.temporal.stage.divinerQueryToIndexQueryDiviner.config",
"schemaTransforms": {
"network.xyo.diviner.payload.query": [
{
"destinationField": "uri",
"sourcePathExpression": "$.uri"
},
{
"defaultValue": 1,
"destinationField": "limit",
"sourcePathExpression": "$.limit"
},
{
"defaultValue": 0,
"destinationField": "offset",
"sourcePathExpression": "$.offset"
},
{
"defaultValue": "desc",
"destinationField": "order",
"sourcePathExpression": "$.order"
}
]
}
}
},
{
"config": {
"labels": {
"network.xyo.diviner.stage": "indexQueryResponseToDivinerQueryResponseDiviner"
},
"name": "IndexQueryResponseToQueryResponseDiviner",
"schema": "network.xyo.diviner.indexing.temporal.stage.indexQueryResponseToDivinerQueryResponseDiviner.config"
}
},
{
"config": {
"name": "TimestampWitness",
"schema": "network.xyo.witness.timestamp.config"
}
},
{
"config": {
"name": "ApiCallWitness",
"schema": "network.xyo.api.call.witness.config"
}
}
],
"public": [
{
"config": {
"name": "Archivist",
"schema": "network.xyo.archivist.config",
"storeQueries": false
}
},
{
"config": {
"archivist": "Archivist",
"name": "BoundWitnessDiviner",
"schema": "network.xyo.diviner.boundwitness.config"
}
},
{
"config": {
"archivist": "Archivist",
"name": "PayloadDiviner",
"schema": "network.xyo.diviner.payload.config"
}
},
{
"config": {
"indexStore": {
"archivist": "IndexArchivist",
"boundWitnessDiviner": "IndexBoundWitnessDiviner",
"payloadDiviner": "IndexPayloadDiviner"
},
"indexingDivinerStages": {
"divinerQueryToIndexQueryDiviner": "QueryToIndexQueryDiviner",
"indexCandidateToIndexDiviner": "IndexCandidateToIndexDiviner",
"indexQueryResponseToDivinerQueryResponseDiviner": "IndexQueryResponseToQueryResponseDiviner",
"stateToIndexCandidateDiviner": "StateToIndexCandidateDiviner"
},
"name": "IndexDiviner",
"pollFrequency": 1,
"schema": "network.xyo.diviner.indexing.temporal.config",
"stateStore": {
"archivist": "AddressStateArchivist",
"boundWitnessDiviner": "AddressStateBoundWitnessDiviner",
"payloadDiviner": "AddressStatePayloadDiviner"
}
}
},
{
"config": {
"archiving": {
"archivists": ["Archivist"]
},
"name": "NftMetadataSentinel",
"schema": "network.xyo.sentinel.config",
"synchronous": "true",
"tasks": [
{
"input": true,
"module": "ApiCallWitness"
},
{
"input": true,
"module": "TimestampWitness"
}
]
}
}
]
}
}
],
"schema": "network.xyo.manifest"
}
Loading