forked from cerc-io/registry-sdk
Fixes from review
This commit is contained in:
parent
c3066db987
commit
6ca9f4041a
@ -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:
|
||||
|
@ -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:
|
||||
|
22
src/index.ts
22
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 }
|
||||
|
@ -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',
|
||||
|
@ -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': [],
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user