From 553b3df0b2490b102a76d637258efa4920acb2cb Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sun, 23 Feb 2020 12:48:01 +0100 Subject: [PATCH] Augment naming --- packages/api/src/types/index.ts | 2 +- packages/typegen/src/fromChain.ts | 12 +++++------- packages/types/src/types/helpers.ts | 2 -- packages/types/src/types/index.ts | 3 +++ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/api/src/types/index.ts b/packages/api/src/types/index.ts index c52d8c1565..d268cad446 100644 --- a/packages/api/src/types/index.ts +++ b/packages/api/src/types/index.ts @@ -2,7 +2,7 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -// Module augmentation so that `api.{consts,query,rpc,tx}.*.*` work +// Augment the modules import '@polkadot/api/augment'; import BN from 'bn.js'; diff --git a/packages/typegen/src/fromChain.ts b/packages/typegen/src/fromChain.ts index 0b45d89d60..19db88d55d 100644 --- a/packages/typegen/src/fromChain.ts +++ b/packages/typegen/src/fromChain.ts @@ -2,7 +2,6 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import fs from 'fs'; import path from 'path'; import yargs from 'yargs'; import getWSClass from '@polkadot/rpc-provider/ws/getWSClass'; @@ -21,18 +20,17 @@ function generate (metaHex: string, pkg: string | undefined, output: string, isS const extraTypes = pkg ? { [pkg]: require(path.join(process.cwd(), output, 'definitions')) } : {}; - const hasRegistry = fs.existsSync(path.join(process.cwd(), output, 'augment-types.ts')); - generateConst(path.join(process.cwd(), output, 'augment-consts.ts'), metaHex, extraTypes, isStrict); - generateQuery(path.join(process.cwd(), output, 'augment-query.ts'), metaHex, extraTypes, isStrict); - generateTx(path.join(process.cwd(), output, 'augment-tx.ts'), metaHex, extraTypes, isStrict); + generateConst(path.join(process.cwd(), output, 'augment-api-consts.ts'), metaHex, extraTypes, isStrict); + generateQuery(path.join(process.cwd(), output, 'augment-api-query.ts'), metaHex, extraTypes, isStrict); + generateTx(path.join(process.cwd(), output, 'augment-api-tx.ts'), metaHex, extraTypes, isStrict); - writeFile(path.join(process.cwd(), output, 'augment.ts'), (): string => + writeFile(path.join(process.cwd(), output, 'augment-api.ts'), (): string => [ HEADER, ...[ '@polkadot/api/augment/rpc', - ...['consts', 'query', hasRegistry ? 'types' : '', 'tx'].filter((key) => !!key).map((key) => `./augment-${key}`) + ...['consts', 'query', 'tx'].filter((key) => !!key).map((key) => `./augment-api-${key}`) ].map((path) => `import '${path}';\n`) ].join('') ); diff --git a/packages/types/src/types/helpers.ts b/packages/types/src/types/helpers.ts index b169704db7..fe3ddb7442 100644 --- a/packages/types/src/types/helpers.ts +++ b/packages/types/src/types/helpers.ts @@ -2,8 +2,6 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -// augment the registry -import '@polkadot/types/augment'; import { InterfaceRegistry } from '@polkadot/types/interfaceRegistry'; import BN from 'bn.js'; diff --git a/packages/types/src/types/index.ts b/packages/types/src/types/index.ts index 12e3098283..815c9e5a18 100644 --- a/packages/types/src/types/index.ts +++ b/packages/types/src/types/index.ts @@ -2,6 +2,9 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +// augment the registry +import '@polkadot/types/augment'; + export * from '../create/types'; export * from './calls'; export * from './codec';