From 6254d66aceb4dca160d292993b7cab2cf875ee24 Mon Sep 17 00:00:00 2001 From: JQQQ Date: Tue, 25 Jun 2024 11:13:17 +1200 Subject: [PATCH] Fix avail with ts chainTypes --- Avail/avail-starter/package.json | 3 + Avail/avail-starter/project.ts | 2 +- Avail/avail-starter/src/chaintypes.ts | 183 ++++++++++++++++ Avail/avail-starter/types.json | 211 ------------------- Avail/avail-turing-starter/package.json | 3 + Avail/avail-turing-starter/project.ts | 2 +- Avail/avail-turing-starter/src/chaintypes.ts | 183 ++++++++++++++++ Avail/avail-turing-starter/types.json | 205 ------------------ 8 files changed, 374 insertions(+), 418 deletions(-) create mode 100644 Avail/avail-starter/src/chaintypes.ts delete mode 100644 Avail/avail-starter/types.json create mode 100644 Avail/avail-turing-starter/src/chaintypes.ts delete mode 100644 Avail/avail-turing-starter/types.json diff --git a/Avail/avail-starter/package.json b/Avail/avail-starter/package.json index c8c925c..10923ca 100644 --- a/Avail/avail-starter/package.json +++ b/Avail/avail-starter/package.json @@ -27,5 +27,8 @@ "@subql/cli": "latest", "@subql/testing": "latest", "@subql/node": "latest" + }, + "exports": { + "chaintypes": "src/chaintypes.ts" } } \ No newline at end of file diff --git a/Avail/avail-starter/project.ts b/Avail/avail-starter/project.ts index 7f83423..42c477c 100644 --- a/Avail/avail-starter/project.ts +++ b/Avail/avail-starter/project.ts @@ -38,7 +38,7 @@ const project: SubstrateProject = { */ endpoint: ["wss://rpc-testnet.avail.tools/ws"], chaintypes: { - file: "./types.json", + file: "./dist/chaintypes.js", }, bypassBlocks: ["272000-280500"], }, diff --git a/Avail/avail-starter/src/chaintypes.ts b/Avail/avail-starter/src/chaintypes.ts new file mode 100644 index 0000000..ea1d2a5 --- /dev/null +++ b/Avail/avail-starter/src/chaintypes.ts @@ -0,0 +1,183 @@ +import { OverrideBundleDefinition } from "@polkadot/types/types"; + +const definitions: OverrideBundleDefinition = { + types: [ + { + minmax: [0, undefined], + types: { + "AppId": "Compact", + "DataLookupItem": { + "appId": "AppId", + "start": "Compact" + }, + "CompactDataLookup": { + "size": "Compact", + "index": "Vec" + }, + "KateCommitment": { + "rows": "Compact", + "cols": "Compact", + "commitment": "Vec", + "dataRoot": "H256" + }, + "V3HeaderExtension": { + "appLookup": "CompactDataLookup", + "commitment": "KateCommitment" + }, + "HeaderExtension": { + "_enum": { + "V1": null, + "V2": null, + "V3": "V3HeaderExtension" + } + }, + "DaHeader": { + "parentHash": "Hash", + "number": "Compact", + "stateRoot": "Hash", + "extrinsicsRoot": "Hash", + "digest": "Digest", + "extension": "HeaderExtension" + }, + "Header": "DaHeader", + "CheckAppIdExtra": { + "appId": "AppId" + }, + "CheckAppIdTypes": {}, + "CheckAppId": { + "extra": "CheckAppIdExtra", + "types": "CheckAppIdTypes" + }, + "BlockLengthColumns": "Compact", + "BlockLengthRows": "Compact", + "BlockLength": { + "max": "PerDispatchClass", + "cols": "BlockLengthColumns", + "rows": "BlockLengthRows", + "chunkSize": "Compact" + }, + "PerDispatchClass": { + "normal": "u32", + "operational": "u32", + "mandatory": "u32" + }, + "DataProof": { + "roots": "TxDataRoots", + "proof": "Vec", + "numberOfLeaves": "Compact", + "leafIndex": "Compact", + "leaf": "H256" + }, + "TxDataRoots": { + "dataRoot": "H256", + "blobRoot": "H256", + "bridgeRoot": "H256" + }, + "ProofResponse": { + "dataProof": "DataProof", + "message": "Option" + }, + "AddressedMessage": { + "message": "Message", + "from": "H256", + "to": "H256", + "originDomain": "u32", + "destinationDomain": "u32", + "id": "u64" + }, + "Message": { + "_enum": { + "ArbitraryMessage": "ArbitraryMessage", + "FungibleToken": "FungibleToken" + } + }, + "MessageType": { + "_enum": [ + "ArbitraryMessage", + "FungibleToken" + ] + }, + "FungibleToken": { + "assetId": "H256", + "amount": "String" + }, + "BoundedData": "Vec", + "ArbitraryMessage": "BoundedData", + "Cell": { + "row": "u32", + "col": "u32" + } + }, + }, + ], + rpc: { + "kate": { + "blockLength": { + "description": "Get Block Length", + "params": [ + { + "name": "at", + "type": "Hash", + "isOptional": true + } + ], + "type": "BlockLength" + }, + "queryProof": { + "description": "Generate the kate proof for the given `cells`", + "params": [ + { + "name": "cells", + "type": "Vec" + }, + { + "name": "at", + "type": "Hash", + "isOptional": true + } + ], + "type": "Vec<(U256, [u8; 48])>" + }, + "queryDataProof": { + "description": "Generate the data proof for the given `transaction_index`", + "params": [ + { + "name": "transaction_index", + "type": "u32" + }, + { + "name": "at", + "type": "Hash", + "isOptional": true + } + ], + "type": "ProofResponse" + }, + "queryRows": { + "description": "Query rows based on their indices", + "params": [ + { + "name": "rows", + "type": "Vec" + }, + { + "name": "at", + "type": "Hash", + "isOptional": true + } + ], + "type": "Vec>" + } + } + }, + signedExtensions: { + "CheckAppId": { + "extrinsic": { + "appId": "AppId" + }, + "payload": {} + } + } +}; + +export default { typesBundle: { spec: { "data-avail": definitions } } }; \ No newline at end of file diff --git a/Avail/avail-starter/types.json b/Avail/avail-starter/types.json deleted file mode 100644 index bd8e40a..0000000 --- a/Avail/avail-starter/types.json +++ /dev/null @@ -1,211 +0,0 @@ -{ - "typesBundle":{ - "spec": { - "data-avail": { - "types": { - "AppId": "Compact", - "DataLookupIndexItem": { - "appId": "AppId", - "start": "Compact" - }, - "DataLookup": { - "size": "Compact", - "index": "Vec" - }, - "KateCommitment": { - "rows": "Compact", - "cols": "Compact", - "commitment": "Vec", - "dataRoot": "H256" - }, - "V1HeaderExtension": { - "appLookup": "DataLookup", - "commitment": "KateCommitment" - }, - "V2HeaderExtension": { - "appLookup": "DataLookup", - "commitment": "KateCommitment" - }, - "V3HeaderExtension": { - "appLookup": "DataLookup", - "commitment": "KateCommitment" - }, - "HeaderExtension": { - "_enum": { - "V1": "V1HeaderExtension", - "V2": "V2HeaderExtension", - "V3": "V3HeaderExtension" - } - }, - "DaHeader": { - "parentHash": "Hash", - "number": "Compact", - "stateRoot": "Hash", - "extrinsicsRoot": "Hash", - "digest": "Digest", - "extension": "HeaderExtension" - }, - "Header": "DaHeader", - "CheckAppIdExtra": { - "appId": "AppId" - }, - "CheckAppIdTypes": {}, - "CheckAppId": { - "extra": "CheckAppIdExtra", - "types": "CheckAppIdTypes" - }, - "BlockLengthColumns": "Compact", - "BlockLengthRows": "Compact", - "BlockLength": { - "max": "PerDispatchClass", - "cols": "BlockLengthColumns", - "rows": "BlockLengthRows", - "chunkSize": "Compact" - }, - "PerDispatchClass": { - "normal": "u32", - "operational": "u32", - "mandatory": "u32" - }, - "DataProof": { - "root": "H256", - "proof": "Vec", - "numberOfLeaves": "Compact", - "leaf_index": "Compact", - "leaf": "H256" - }, - "DataProofV2": { - "dataRoot": "H256", - "blobRoot": "H256", - "bridgeRoot": "H256", - "proof": "Vec", - "numberOfLeaves": "Compact", - "leafIndex": "Compact", - "leaf": "H256" - }, - "ProofResponse": { - "dataProof": "DataProofV2", - "message": "Option" - }, - "Message": { - "messageType": "MessageType", - "from": "H256", - "to": "H256", - "originDomain": "u32", - "destinationDomain": "u32", - "data": "Vec", - "id": "u64" - }, - "MessageType": { - "_enum": [ - "ArbitraryMessage", - "FungibleToken" - ] - }, - "Cell": { - "row": "u32", - "col": "u32" - } - }, - "rpc": { - "kate": { - "blockLength": { - "description": "Get Block Length", - "params": [ - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "BlockLength" - }, - "queryProof": { - "description": "Generate the kate proof for the given `cells`", - "params": [ - { - "name": "cells", - "type": "Vec" - }, - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "Vec" - }, - "queryDataProof": { - "description": "Generate the data proof for the given `transaction_index`", - "params": [ - { - "name": "transaction_index", - "type": "u32" - }, - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "DataProof" - }, - "queryDataProofV2": { - "description": "Generate the data proof for the given `transaction_index`", - "params": [ - { - "name": "transaction_index", - "type": "u32" - }, - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "ProofResponse" - }, - "queryAppData": { - "description": "Fetches app data rows for the given app", - "params": [ - { - "name": "app_id", - "type": "AppId" - }, - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "Vec>>" - }, - "queryRows": { - "description": "Query rows based on their indices", - "params": [ - { - "name": "rows", - "type": "Vec" - }, - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "Vec>" - } - } - }, - "signedExtensions": { - "CheckAppId": { - "extrinsic": { - "appId": "AppId" - }, - "payload": {} - } - } - } - } - } -} \ No newline at end of file diff --git a/Avail/avail-turing-starter/package.json b/Avail/avail-turing-starter/package.json index 68b9fce..19f15b0 100644 --- a/Avail/avail-turing-starter/package.json +++ b/Avail/avail-turing-starter/package.json @@ -27,5 +27,8 @@ "@subql/cli": "latest", "@subql/testing": "latest", "@subql/node": "latest" + }, + "exports": { + "chaintypes": "src/chaintypes.ts" } } \ No newline at end of file diff --git a/Avail/avail-turing-starter/project.ts b/Avail/avail-turing-starter/project.ts index 68162f6..d74d57b 100644 --- a/Avail/avail-turing-starter/project.ts +++ b/Avail/avail-turing-starter/project.ts @@ -38,7 +38,7 @@ const project: SubstrateProject = { */ endpoint: ["wss://turing-rpc.avail.so/ws"], chaintypes: { - file: "./types.json", + file: "./dist/chaintypes.js", }, }, dataSources: [ diff --git a/Avail/avail-turing-starter/src/chaintypes.ts b/Avail/avail-turing-starter/src/chaintypes.ts new file mode 100644 index 0000000..19943c8 --- /dev/null +++ b/Avail/avail-turing-starter/src/chaintypes.ts @@ -0,0 +1,183 @@ +import { OverrideBundleDefinition } from "@polkadot/types/types"; + +const definitions: OverrideBundleDefinition = { + types: [ + { + minmax: [0, undefined], + types: { + "AppId": "Compact", + "DataLookupItem": { + "appId": "AppId", + "start": "Compact" + }, + "CompactDataLookup": { + "size": "Compact", + "index": "Vec" + }, + "KateCommitment": { + "rows": "Compact", + "cols": "Compact", + "commitment": "Vec", + "dataRoot": "H256" + }, + "V3HeaderExtension": { + "appLookup": "CompactDataLookup", + "commitment": "KateCommitment" + }, + "HeaderExtension": { + "_enum": { + "V1": null, + "V2": null, + "V3": "V3HeaderExtension" + } + }, + "DaHeader": { + "parentHash": "Hash", + "number": "Compact", + "stateRoot": "Hash", + "extrinsicsRoot": "Hash", + "digest": "Digest", + "extension": "HeaderExtension" + }, + "Header": "DaHeader", + "CheckAppIdExtra": { + "appId": "AppId" + }, + "CheckAppIdTypes": {}, + "CheckAppId": { + "extra": "CheckAppIdExtra", + "types": "CheckAppIdTypes" + }, + "BlockLengthColumns": "Compact", + "BlockLengthRows": "Compact", + "BlockLength": { + "max": "PerDispatchClass", + "cols": "BlockLengthColumns", + "rows": "BlockLengthRows", + "chunkSize": "Compact" + }, + "PerDispatchClass": { + "normal": "u32", + "operational": "u32", + "mandatory": "u32" + }, + "DataProof": { + "roots": "TxDataRoots", + "proof": "Vec", + "numberOfLeaves": "Compact", + "leafIndex": "Compact", + "leaf": "H256" + }, + "TxDataRoots": { + "dataRoot": "H256", + "blobRoot": "H256", + "bridgeRoot": "H256" + }, + "ProofResponse": { + "dataProof": "DataProof", + "message": "Option" + }, + "AddressedMessage": { + "message": "Message", + "from": "H256", + "to": "H256", + "originDomain": "u32", + "destinationDomain": "u32", + "id": "u64" + }, + "Message": { + "_enum": { + "ArbitraryMessage": "ArbitraryMessage", + "FungibleToken": "FungibleToken" + } + }, + "MessageType": { + "_enum": [ + "ArbitraryMessage", + "FungibleToken" + ] + }, + "FungibleToken": { + "assetId": "H256", + "amount": "String" + }, + "BoundedData": "Vec", + "ArbitraryMessage": "BoundedData", + "Cell": { + "row": "u32", + "col": "u32" + } + }, + }, + ], + rpc: { + "kate": { + "blockLength": { + "description": "Get Block Length", + "params": [ + { + "name": "at", + "type": "Hash", + "isOptional": true + } + ], + "type": "BlockLength" + }, + "queryProof": { + "description": "Generate the kate proof for the given `cells`", + "params": [ + { + "name": "cells", + "type": "Vec" + }, + { + "name": "at", + "type": "Hash", + "isOptional": true + } + ], + "type": "Vec<(U256, [u8; 48])>" + }, + "queryDataProof": { + "description": "Generate the data proof for the given `transaction_index`", + "params": [ + { + "name": "transaction_index", + "type": "u32" + }, + { + "name": "at", + "type": "Hash", + "isOptional": true + } + ], + "type": "ProofResponse" + }, + "queryRows": { + "description": "Query rows based on their indices", + "params": [ + { + "name": "rows", + "type": "Vec" + }, + { + "name": "at", + "type": "Hash", + "isOptional": true + } + ], + "type": "Vec>" + } + } + }, + signedExtensions: { + "CheckAppId": { + "extrinsic": { + "appId": "AppId" + }, + "payload": {} + } + } +}; + +export default { typesBundle: { spec: { "avail": definitions } } }; \ No newline at end of file diff --git a/Avail/avail-turing-starter/types.json b/Avail/avail-turing-starter/types.json deleted file mode 100644 index c558302..0000000 --- a/Avail/avail-turing-starter/types.json +++ /dev/null @@ -1,205 +0,0 @@ -{ - "types": { - "AppId": "Compact", - "DataLookupIndexItem": { - "appId": "AppId", - "start": "Compact" - }, - "DataLookup": { - "size": "Compact", - "index": "Vec" - }, - "KateCommitment": { - "rows": "Compact", - "cols": "Compact", - "commitment": "Vec", - "dataRoot": "H256" - }, - "V1HeaderExtension": { - "appLookup": "DataLookup", - "commitment": "KateCommitment" - }, - "V2HeaderExtension": { - "appLookup": "DataLookup", - "commitment": "KateCommitment" - }, - "V3HeaderExtension": { - "appLookup": "DataLookup", - "commitment": "KateCommitment" - }, - "HeaderExtension": { - "_enum": { - "V1": "V1HeaderExtension", - "V2": "V2HeaderExtension", - "V3": "V3HeaderExtension" - } - }, - "DaHeader": { - "parentHash": "Hash", - "number": "Compact", - "stateRoot": "Hash", - "extrinsicsRoot": "Hash", - "digest": "Digest", - "extension": "HeaderExtension" - }, - "Header": "DaHeader", - "CheckAppIdExtra": { - "appId": "AppId" - }, - "CheckAppIdTypes": {}, - "CheckAppId": { - "extra": "CheckAppIdExtra", - "types": "CheckAppIdTypes" - }, - "BlockLengthColumns": "Compact", - "BlockLengthRows": "Compact", - "BlockLength": { - "max": "PerDispatchClass", - "cols": "BlockLengthColumns", - "rows": "BlockLengthRows", - "chunkSize": "Compact" - }, - "PerDispatchClass": { - "normal": "u32", - "operational": "u32", - "mandatory": "u32" - }, - "DataProof": { - "root": "H256", - "proof": "Vec", - "numberOfLeaves": "Compact", - "leaf_index": "Compact", - "leaf": "H256" - }, - "DataProofV2": { - "dataRoot": "H256", - "blobRoot": "H256", - "bridgeRoot": "H256", - "proof": "Vec", - "numberOfLeaves": "Compact", - "leafIndex": "Compact", - "leaf": "H256" - }, - "ProofResponse": { - "dataProof": "DataProofV2", - "message": "Option" - }, - "Message": { - "messageType": "MessageType", - "from": "H256", - "to": "H256", - "originDomain": "u32", - "destinationDomain": "u32", - "data": "Vec", - "id": "u64" - }, - "MessageType": { - "_enum": [ - "ArbitraryMessage", - "FungibleToken" - ] - }, - "Cell": { - "row": "u32", - "col": "u32" - } - }, - "rpc": { - "kate": { - "blockLength": { - "description": "Get Block Length", - "params": [ - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "BlockLength" - }, - "queryProof": { - "description": "Generate the kate proof for the given `cells`", - "params": [ - { - "name": "cells", - "type": "Vec" - }, - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "Vec" - }, - "queryDataProof": { - "description": "Generate the data proof for the given `transaction_index`", - "params": [ - { - "name": "transaction_index", - "type": "u32" - }, - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "DataProof" - }, - "queryDataProofV2": { - "description": "Generate the data proof for the given `transaction_index`", - "params": [ - { - "name": "transaction_index", - "type": "u32" - }, - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "ProofResponse" - }, - "queryAppData": { - "description": "Fetches app data rows for the given app", - "params": [ - { - "name": "app_id", - "type": "AppId" - }, - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "Vec>>" - }, - "queryRows": { - "description": "Query rows based on their indices", - "params": [ - { - "name": "rows", - "type": "Vec" - }, - { - "name": "at", - "type": "Hash", - "isOptional": true - } - ], - "type": "Vec>" - } - } - }, - "signedExtensions": { - "CheckAppId": { - "extrinsic": { - "appId": "AppId" - }, - "payload": {} - } - } -} \ No newline at end of file