diff --git a/src/logion/services/polkadot.service.ts b/src/logion/services/polkadot.service.ts index 66c09b0e..1baffd79 100644 --- a/src/logion/services/polkadot.service.ts +++ b/src/logion/services/polkadot.service.ts @@ -1,5 +1,8 @@ import { injectable } from 'inversify'; +import '../lib/polkadot/interfaces/augment-api'; +import '../lib/polkadot/interfaces/augment-types'; import { ApiPromise, WsProvider } from '@polkadot/api'; +import * as definitions from '../lib/polkadot/interfaces/definitions'; import { Log } from "../util/Log"; const { logger } = Log; @@ -20,85 +23,10 @@ export class PolkadotService { const wsProviderUrl = process.env.WS_PROVIDER_URL || 'ws://localhost:9944'; logger.info("Connecting to node %s", wsProviderUrl); const wsProvider = new WsProvider(wsProviderUrl); + const types = Object.values(definitions).reduce((res, { types }): object => ({ ...res, ...types }), {}); return await ApiPromise.create({ provider: wsProvider, - types: { - Address: "MultiAddress", - LookupSource: "MultiAddress", - PeerId: "(Vec)", - AccountInfo: "AccountInfoWithDualRefCount", - TAssetBalance: "u128", - AssetId: "u64", - AssetDetails: { - owner: "AccountId", - issuer: "AccountId", - admin: "AccountId", - freezer: "AccountId", - supply: "Balance", - deposit: "DepositBalance", - max_zombies: "u32", - min_balance: "Balance", - zombies: "u32", - accounts: "u32", - is_frozen: "bool" - }, - AssetMetadata: { - deposit: "DepositBalance", - name: "Vec", - symbol: "Vec", - decimals: "u8" - }, - LocId: "u128", - LegalOfficerCaseOf: { - owner: "AccountId", - requester: "Requester", - metadata: "Vec", - files: "Vec", - closed: "bool", - loc_type: "LocType", - links: "Vec", - void_info: "Option>", - replacer_of: "Option" - }, - MetadataItem: { - name: "Vec", - value: "Vec", - submitter: "AccountId", - }, - LocType: { - _enum: [ - "Transaction", - "Identity" - ] - }, - LocLink: { - id: "LocId", - nature: "Vec", - }, - File: { - hash: "Hash", - nature: "Vec", - submitter: "AccountId", - }, - LocVoidInfo: { - "replacer": "Option" - }, - StorageVersion: { - "_enum": [ - "V1", - "V2MakeLocVoid", - "V3RequesterEnum", - "V4ItemSubmitter", - ] - }, - Requester: { - "_enum": { - "None": null, - "Account": "AccountId", - "Loc": "LocId" - } - } - } + types }); } } diff --git a/tsconfig.json b/tsconfig.json index 110b2557..3f444668 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,12 @@ "compilerOptions": { "emitDecoratorMetadata": true, "experimentalDecorators": true, - "outDir": "dist" + "outDir": "dist", + "baseUrl": ".", + "paths": { + "@polkadot/api/augment": ["src/logion/lib/polkadot/interfaces/augment-api.ts"], + "@polkadot/types/augment": ["src/logion/lib/polkadot/interfaces/augment-types.ts"] + } }, "compileOnSave": false, "exclude": [