From 6ca9f4041a8eb263657b38a498be4082e525502b Mon Sep 17 00:00:00 2001 From: nabarun Date: Mon, 18 Apr 2022 16:57:37 +0530 Subject: [PATCH] Fixes from review --- README.md | 2 +- src/auction.test.ts | 2 +- src/index.ts | 22 +++++++++++++++------- src/testing/helper.ts | 2 +- src/types.ts | 4 +--- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 10320d8..7e2c8ec 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Follow these steps to run the tests: - In chiba-clonk repo run: ```bash - AUCTION_ENABLED=true ./init.sh + TEST_AUCTION_ENABLED=true ./init.sh ``` - Export the private key and change it in `.env` file again using: diff --git a/src/auction.test.ts b/src/auction.test.ts index c911833..32b6ca4 100644 --- a/src/auction.test.ts +++ b/src/auction.test.ts @@ -117,7 +117,7 @@ if (!process.env.AUCTIONS_ENABLED) { /** Running these tests requires name auctions enabled. In chiba-clonk repo run: - AUCTION_ENABLED=true ./init.sh + TEST_AUCTION_ENABLED=true ./init.sh Run tests: diff --git a/src/index.ts b/src/index.ts index 3ac7e09..2687842 100644 --- a/src/index.ts +++ b/src/index.ts @@ -46,8 +46,6 @@ import { const DEFAULT_WRITE_ERROR = 'Unable to write to chiba-clonk.'; -export const DEFAULT_CHAIN_ID = 'chibaclonk_9000-1'; - // Parse Tx response from cosmos-sdk. export const parseTxResponse = (result: any) => { const { txhash: hash, height, ...txResponse } = result; @@ -97,6 +95,7 @@ export class Registry { _client: RegistryClient static processWriteError(error: string) { + console.log("error", error) // error string a stacktrace containing the message. // https://gist.github.com/nikugogoi/de55d390574ded3466abad8bffd81952#file-txresponse-js-L7 const errorMessage = NAMESERVICE_ERRORS.find(message => error.includes(message)) @@ -104,7 +103,7 @@ export class Registry { return errorMessage || DEFAULT_WRITE_ERROR; } - constructor(restUrl: string, gqlUrl: string, cosmosChainId = DEFAULT_CHAIN_ID) { + constructor(restUrl: string, gqlUrl: string, chainId: string) { if (!isUrl(restUrl)) { throw new Error('Path to a REST endpoint should be provided.'); } @@ -117,9 +116,9 @@ export class Registry { this._client = new RegistryClient(restUrl, gqlUrl); this._chain = { - chainId: 9000, - cosmosChainId - } + cosmosChainId: chainId, + chainId: this._parseEthChainId(chainId) + }; } /** @@ -308,7 +307,6 @@ export class Registry { const msgParams = { name: params.name, - // TODO: Pass empty string as owner. owner: params.owner || sender.accountAddress } @@ -523,6 +521,16 @@ export class Registry { return response; } + + /** + * https://evmos.dev/basics/chain_id.html + */ + _parseEthChainId (chainId: string) { + const [ idWithChainNumber ] = chainId.split('-') + const [ _, ethChainId ] = idWithChainNumber.split('_') + + return Number(ethChainId) + } } export { Account } diff --git a/src/testing/helper.ts b/src/testing/helper.ts index 4fe2ffb..75e3854 100644 --- a/src/testing/helper.ts +++ b/src/testing/helper.ts @@ -21,7 +21,7 @@ export const getConfig = () => { assert(process.env.PRIVATE_KEY); return { - chainId: process.env.CHIBA_CLONK_CHAIN_ID || 'chibaclonk_9000-1', + chainId: process.env.COSMOS_CHAIN_ID || 'chibaclonk_9000-1', privateKey: process.env.PRIVATE_KEY, restEndpoint: process.env.CHIBA_CLONK_REST_ENDPOINT || 'http://localhost:1317', gqlEndpoint: process.env.CHIBA_CLONK_GQL_ENDPOINT || 'http://localhost:9473/api', diff --git a/src/types.ts b/src/types.ts index 8de16b4..0a506e5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -34,16 +34,14 @@ export class Record { * Serialize record. */ serialize() { - // return Util.sortJSON({ - // }); return { 'id': '_', 'bond_id': '_', 'create_time': '_', 'expiry_time': '_', + // Setting deleted as false (zero value) throws error in EIP712 signature verification. 'deleted': true, 'attributes': this.attributes, - // 'owners': [], } }