Fixes from review

This commit is contained in:
nabarun 2022-04-18 16:57:37 +05:30 committed by Ashwin Phatak
parent c3066db987
commit 6ca9f4041a
5 changed files with 19 additions and 13 deletions

View File

@ -35,7 +35,7 @@ Follow these steps to run the tests:
- In chiba-clonk repo run: - In chiba-clonk repo run:
```bash ```bash
AUCTION_ENABLED=true ./init.sh TEST_AUCTION_ENABLED=true ./init.sh
``` ```
- Export the private key and change it in `.env` file again using: - Export the private key and change it in `.env` file again using:

View File

@ -117,7 +117,7 @@ if (!process.env.AUCTIONS_ENABLED) {
/** /**
Running these tests requires name auctions enabled. In chiba-clonk repo run: 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: Run tests:

View File

@ -46,8 +46,6 @@ import {
const DEFAULT_WRITE_ERROR = 'Unable to write to chiba-clonk.'; const DEFAULT_WRITE_ERROR = 'Unable to write to chiba-clonk.';
export const DEFAULT_CHAIN_ID = 'chibaclonk_9000-1';
// Parse Tx response from cosmos-sdk. // Parse Tx response from cosmos-sdk.
export const parseTxResponse = (result: any) => { export const parseTxResponse = (result: any) => {
const { txhash: hash, height, ...txResponse } = result; const { txhash: hash, height, ...txResponse } = result;
@ -97,6 +95,7 @@ export class Registry {
_client: RegistryClient _client: RegistryClient
static processWriteError(error: string) { static processWriteError(error: string) {
console.log("error", error)
// error string a stacktrace containing the message. // error string a stacktrace containing the message.
// https://gist.github.com/nikugogoi/de55d390574ded3466abad8bffd81952#file-txresponse-js-L7 // https://gist.github.com/nikugogoi/de55d390574ded3466abad8bffd81952#file-txresponse-js-L7
const errorMessage = NAMESERVICE_ERRORS.find(message => error.includes(message)) const errorMessage = NAMESERVICE_ERRORS.find(message => error.includes(message))
@ -104,7 +103,7 @@ export class Registry {
return errorMessage || DEFAULT_WRITE_ERROR; return errorMessage || DEFAULT_WRITE_ERROR;
} }
constructor(restUrl: string, gqlUrl: string, cosmosChainId = DEFAULT_CHAIN_ID) { constructor(restUrl: string, gqlUrl: string, chainId: string) {
if (!isUrl(restUrl)) { if (!isUrl(restUrl)) {
throw new Error('Path to a REST endpoint should be provided.'); 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._client = new RegistryClient(restUrl, gqlUrl);
this._chain = { this._chain = {
chainId: 9000, cosmosChainId: chainId,
cosmosChainId chainId: this._parseEthChainId(chainId)
} };
} }
/** /**
@ -308,7 +307,6 @@ export class Registry {
const msgParams = { const msgParams = {
name: params.name, name: params.name,
// TODO: Pass empty string as owner.
owner: params.owner || sender.accountAddress owner: params.owner || sender.accountAddress
} }
@ -523,6 +521,16 @@ export class Registry {
return response; 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 } export { Account }

View File

@ -21,7 +21,7 @@ export const getConfig = () => {
assert(process.env.PRIVATE_KEY); assert(process.env.PRIVATE_KEY);
return { 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, privateKey: process.env.PRIVATE_KEY,
restEndpoint: process.env.CHIBA_CLONK_REST_ENDPOINT || 'http://localhost:1317', restEndpoint: process.env.CHIBA_CLONK_REST_ENDPOINT || 'http://localhost:1317',
gqlEndpoint: process.env.CHIBA_CLONK_GQL_ENDPOINT || 'http://localhost:9473/api', gqlEndpoint: process.env.CHIBA_CLONK_GQL_ENDPOINT || 'http://localhost:9473/api',

View File

@ -34,16 +34,14 @@ export class Record {
* Serialize record. * Serialize record.
*/ */
serialize() { serialize() {
// return Util.sortJSON({
// });
return { return {
'id': '_', 'id': '_',
'bond_id': '_', 'bond_id': '_',
'create_time': '_', 'create_time': '_',
'expiry_time': '_', 'expiry_time': '_',
// Setting deleted as false (zero value) throws error in EIP712 signature verification.
'deleted': true, 'deleted': true,
'attributes': this.attributes, 'attributes': this.attributes,
// 'owners': [],
} }
} }