diff --git a/configs/mangata.yml b/configs/mangata.yml new file mode 100644 index 00000000..bbfe4819 --- /dev/null +++ b/configs/mangata.yml @@ -0,0 +1,30 @@ +endpoint: wss://mangata-x.api.onfinality.io/public-ws +mock-signature-host: true +db: ./mangata.db.sqlite + +registered-types: + types: + ShufflingSeed: + seed: 'H256' + proof: 'H512' + Header: + parentHash: 'Hash' + number: 'Compact' + stateRoot: 'Hash' + extrinsicsRoot: 'Hash' + digest: 'Digest' + seed: 'ShufflingSeed' + count: 'BlockNumber' + +import-storage: + Sudo: + Key: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice + Tokens: + Accounts: + - + - + - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY + - token: 0 + - free: '1000000000000000000000000' # 1M MG + Council: + Members: [5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY] diff --git a/e2e/helper.ts b/e2e/helper.ts index 76d84e48..06c7eeb6 100644 --- a/e2e/helper.ts +++ b/e2e/helper.ts @@ -76,6 +76,7 @@ export const setupAll = async ({ }, mockSignatureHost, allowUnresolvedImports, + registeredTypes: {}, }) const { port, close } = await createServer(handler({ chain })) diff --git a/src/blockchain/block.ts b/src/blockchain/block.ts index 43d4a8ca..33259a43 100644 --- a/src/blockchain/block.ts +++ b/src/blockchain/block.ts @@ -175,6 +175,7 @@ export class Block { this.runtimeVersion, ]).then(([data, properties, chain, version]) => { const registry = new TypeRegistry(this.hash) + registry.setKnownTypes(this.chain.registeredTypes) registry.setChainProperties(registry.createType('ChainProperties', properties) as ChainProperties) registry.register(getSpecTypes(registry, chain, version.specName, version.specVersion)) registry.setHasher(getSpecHasher(registry, chain, version.specName)) diff --git a/src/blockchain/index.ts b/src/blockchain/index.ts index 4f1096f9..d248583b 100644 --- a/src/blockchain/index.ts +++ b/src/blockchain/index.ts @@ -1,6 +1,7 @@ import { ApplyExtrinsicResult } from '@polkadot/types/interfaces' import { DataSource } from 'typeorm' import { HexString } from '@polkadot/util/types' +import { RegisteredTypes } from '@polkadot/types/types' import { blake2AsHex } from '@polkadot/util-crypto' import { u8aConcat, u8aToHex } from '@polkadot/util' import type { TransactionValidity } from '@polkadot/types/interfaces/txqueue' @@ -23,6 +24,7 @@ export interface Options { header: { number: number; hash: HexString } mockSignatureHost?: boolean allowUnresolvedImports?: boolean + registeredTypes: RegisteredTypes } export class Blockchain { @@ -31,6 +33,7 @@ export class Blockchain { readonly db: DataSource | undefined readonly mockSignatureHost: boolean readonly allowUnresolvedImports: boolean + readonly registeredTypes: RegisteredTypes readonly #txpool: TxPool readonly #inherentProvider: InherentProvider @@ -50,11 +53,13 @@ export class Blockchain { header, mockSignatureHost = false, allowUnresolvedImports = false, + registeredTypes = {}, }: Options) { this.api = api this.db = db this.mockSignatureHost = mockSignatureHost this.allowUnresolvedImports = allowUnresolvedImports + this.registeredTypes = registeredTypes this.#head = new Block(this, header.number, header.hash) this.#registerBlock(this.#head) diff --git a/src/schema/index.ts b/src/schema/index.ts index 7e7a7c51..f774d74c 100644 --- a/src/schema/index.ts +++ b/src/schema/index.ts @@ -26,6 +26,7 @@ export const configSchema = z 'wasm-override': z.string().optional(), genesis: z.union([z.string(), genesisSchema]).optional(), timestamp: z.number().optional(), + 'registered-types': z.any().optional(), }) .strict() diff --git a/src/setup.ts b/src/setup.ts index f7570970..e66ac2b0 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -71,6 +71,7 @@ export const setup = async (argv: Config) => { }, mockSignatureHost: argv['mock-signature-host'], allowUnresolvedImports: argv['allow-unresolved-imports'], + registeredTypes: argv['registered-types'], }) if (argv.timestamp) await timeTravel(chain, argv.timestamp)