diff --git a/src/client/lcd/LCDClient.ts b/src/client/lcd/LCDClient.ts index 3f61a51..4539f0a 100644 --- a/src/client/lcd/LCDClient.ts +++ b/src/client/lcd/LCDClient.ts @@ -148,11 +148,11 @@ export class LCDClient { * */ constructor(chains: Record) { - // check for duplicate prefixes - const prefixes = Object.values(chains).map(c => c.prefix); - if (new Set(prefixes).size !== prefixes.length) { - throw new Error('Every chain must have an unique bech32 prefix'); - } + // // check for duplicate prefixes + // const prefixes = Object.values(chains).map(c => c.prefix); + // if (new Set(prefixes).size !== prefixes.length) { + // throw new Error('Every chain must have an unique bech32 prefix'); + // } this.config = chains; diff --git a/src/client/lcd/Wallet.ts b/src/client/lcd/Wallet.ts index f273919..601cc73 100644 --- a/src/client/lcd/Wallet.ts +++ b/src/client/lcd/Wallet.ts @@ -14,7 +14,10 @@ export class Wallet { sequence: number; }> { return this.lcd.auth - .accountInfo(this.key.accAddress(this.lcd.config[chainID].prefix)) + .accountInfo( + this.key.accAddress(this.lcd.config[chainID].prefix), + chainID + ) .then(d => { return { account_number: d.getAccountNumber(), @@ -25,7 +28,10 @@ export class Wallet { public accountNumber(chainID: string): Promise { return this.lcd.auth - .accountInfo(this.key.accAddress(this.lcd.config[chainID].prefix)) + .accountInfo( + this.key.accAddress(this.lcd.config[chainID].prefix), + chainID + ) .then(d => { return d.getAccountNumber(); }); @@ -33,7 +39,10 @@ export class Wallet { public sequence(chainID: string): Promise { return this.lcd.auth - .accountInfo(this.key.accAddress(this.lcd.config[chainID].prefix)) + .accountInfo( + this.key.accAddress(this.lcd.config[chainID].prefix), + chainID + ) .then(d => { return d.getSequenceNumber(); }); diff --git a/src/client/lcd/api/AuthAPI.ts b/src/client/lcd/api/AuthAPI.ts index 3c2f12d..1a41c6e 100644 --- a/src/client/lcd/api/AuthAPI.ts +++ b/src/client/lcd/api/AuthAPI.ts @@ -73,9 +73,10 @@ export class AuthAPI extends BaseAPI { */ public async accountInfo( address: AccAddress, + chainID: string, params: APIParams = {} ): Promise { - const { account } = await this.getReqFromAddress(address).get<{ + const { account } = await this.getReqFromChainID(chainID).get<{ account: | BaseAccount.Data | LazyGradedVestingAccount.Data diff --git a/src/client/lcd/api/BankAPI.ts b/src/client/lcd/api/BankAPI.ts index 4c8e7eb..e0f391c 100644 --- a/src/client/lcd/api/BankAPI.ts +++ b/src/client/lcd/api/BankAPI.ts @@ -54,9 +54,10 @@ export class BankAPI extends BaseAPI { */ public async balance( address: AccAddress, + chainID: string, params: Partial = {} ): Promise<[Coins, Pagination]> { - return this.getReqFromAddress(address) + return this.getReqFromChainID(chainID) .get<{ balances: Coins.Data; pagination: Pagination; @@ -70,9 +71,10 @@ export class BankAPI extends BaseAPI { */ public async spendableBalances( address: AccAddress, + chainID: string, params: Partial = {} ): Promise<[Coins, Pagination]> { - return this.getReqFromAddress(address) + return this.getReqFromChainID(chainID) .get<{ balances: Coins.Data; pagination: Pagination; diff --git a/src/client/lcd/api/DistributionAPI.ts b/src/client/lcd/api/DistributionAPI.ts index a4dace9..2185402 100644 --- a/src/client/lcd/api/DistributionAPI.ts +++ b/src/client/lcd/api/DistributionAPI.ts @@ -72,9 +72,10 @@ export class DistributionAPI extends BaseAPI { */ public async rewards( delegator: AccAddress, + chainID: string, params: APIParams = {} ): Promise { - const rewardsData = await this.getReqFromAddress(delegator) + const rewardsData = await this.getReqFromChainID(chainID) .get( `/cosmos/distribution/v1beta1/delegators/${delegator}/rewards`, params @@ -97,9 +98,10 @@ export class DistributionAPI extends BaseAPI { */ public async validatorCommission( validator: ValAddress, + chainID: string, params: APIParams = {} ): Promise { - return this.getReqFromAddress(validator) + return this.getReqFromChainID(chainID) .get<{ commission: { commission: Coins.Data; @@ -118,10 +120,11 @@ export class DistributionAPI extends BaseAPI { */ public async validatorSlashingEvents( validator: ValAddress, + chainID: string, params: APIParams = {} // TODO: slashes type ): Promise<[any[], Pagination]> { - return this.getReqFromAddress(validator) + return this.getReqFromChainID(chainID) .get<{ slashes: []; pagination: Pagination; @@ -135,9 +138,10 @@ export class DistributionAPI extends BaseAPI { */ public async withdrawAddress( delegator: AccAddress, + chainID: string, params: APIParams = {} ): Promise { - return this.getReqFromAddress(delegator) + return this.getReqFromChainID(chainID) .get<{ withdraw_address: AccAddress }>( `/cosmos/distribution/v1beta1/delegators/${delegator}/withdraw_address`, params diff --git a/src/client/lcd/api/TxAPI.ts b/src/client/lcd/api/TxAPI.ts index 263cfa3..3b8e51b 100644 --- a/src/client/lcd/api/TxAPI.ts +++ b/src/client/lcd/api/TxAPI.ts @@ -237,7 +237,10 @@ export class TxAPI extends BaseAPI { let publicKey = signer.publicKey; if (sequenceNumber === undefined || !publicKey) { - const account = await this.lcd.auth.accountInfo(signer.address); + const account = await this.lcd.auth.accountInfo( + signer.address, + options?.chainID + ); if (sequenceNumber === undefined) { sequenceNumber = account.getSequenceNumber(); } diff --git a/src/client/lcd/api/WasmAPI.ts b/src/client/lcd/api/WasmAPI.ts index 9ac138c..5cd9e55 100644 --- a/src/client/lcd/api/WasmAPI.ts +++ b/src/client/lcd/api/WasmAPI.ts @@ -114,13 +114,14 @@ export class WasmAPI extends BaseAPI { public async contractInfo( contractAddress: AccAddress, + chainID: string, params: APIParams = {} ): Promise { // new endpoint doesn't return init_msg so have to retrieve it from history const [historyEntry] = await this.contractHistory(contractAddress); const endpoint = `/cosmwasm/wasm/v1/contract/${contractAddress}`; - return this.getReqFromAddress(contractAddress) + return this.getReqFromChainID(chainID) .get<{ contract_info: ContractInfo.DataV2 }>(endpoint, params) .then(({ contract_info: d }) => ({ code_id: Number.parseInt(d.code_id),