Skip to content

Commit

Permalink
Fix supply by denom call
Browse files Browse the repository at this point in the history
  • Loading branch information
froch committed May 29, 2024
1 parent a3e9329 commit 2864ba5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/libs/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const DEFAULT: RequestRegistry = {
adapter,
},
bank_supply: { url: '/cosmos/bank/v1beta1/supply', adapter },
bank_supply_by_denom: { url: '/cosmos/bank/v1beta1/supply/{denom}', adapter },
bank_supply_by_denom: { url: '/cosmos/bank/v1beta1/supply/by_denom?denom={denom}', adapter },
distribution_params: { url: '/cosmos/distribution/v1beta1/params', adapter },
distribution_community_pool: {
url: '/cosmos/distribution/v1beta1/community_pool',
Expand Down
19 changes: 7 additions & 12 deletions src/libs/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function registeCustomRequest() {
}
});
}

registeCustomRequest()

export class CosmosRestClient extends BaseRestClient<RequestRegistry> {
Expand All @@ -49,7 +49,7 @@ export class CosmosRestClient extends BaseRestClient<RequestRegistry> {
}

static newStrategy(endpoint: string, chain: any) {

let req
if(chain) {
// find by name first
Expand Down Expand Up @@ -81,19 +81,14 @@ export class CosmosRestClient extends BaseRestClient<RequestRegistry> {
async getBankDenomMetadata() {
return this.request(this.registry.bank_denoms_metadata, {});
}
async getBankSupply(page?: PageRequest) {
async getBankSupply(page?: PageRequest) {
if(!page) page = new PageRequest()
const query =`?${page.toQueryString()}`;
return this.request(this.registry.bank_supply, {}, query);
}
async getBankSupplyByDenom(denom: string) {
let supply;
try{
supply = await this.request(this.registry.bank_supply_by_denom, { denom });
} catch(err) {
// will move this to sdk version profile later
supply = await this.request({url: "/cosmos/bank/v1beta1/supply/by_denom?denom={denom}", adapter } as Request<{ amount: Coin }>, { denom });
}
let supply = await this.request(this.registry.bank_supply_by_denom, { denom });
console.log(supply)
return supply
}
// Distribution Module
Expand Down Expand Up @@ -223,7 +218,7 @@ export class CosmosRestClient extends BaseRestClient<RequestRegistry> {
// page.reverse = true
page.count_total = true
page.offset = 0
}
}
const query =`?${page.toQueryString()}`;
return this.request(this.registry.staking_validators_delegations, {
validator_addr,
Expand Down Expand Up @@ -282,7 +277,7 @@ export class CosmosRestClient extends BaseRestClient<RequestRegistry> {
// query ibc receiving msgs
// ?&pagination.reverse=true&events=recv_packet.packet_dst_channel='${channel}'&events=recv_packet.packet_dst_port='${port}'
async getTxs(query: string, params: any, page?: PageRequest) {
if(!page) page = new PageRequest()
if(!page) page = new PageRequest()
return this.request(this.registry.tx_txs, params, `${query}&${page.toQueryString()}`);
}
async getTxsAt(height: string | number) {
Expand Down

0 comments on commit 2864ba5

Please sign in to comment.