diff --git a/src/bank/bank.service.ts b/src/bank/bank.service.ts index 2273595..717daef 100644 --- a/src/bank/bank.service.ts +++ b/src/bank/bank.service.ts @@ -15,7 +15,8 @@ export class BankService { public async balance(address: AccAddress, height?: number): Promise { try { - const [balance] = await this.lcdService.bank.balance(address, { height }) + const apikey = process.env.API_KEY + const [balance] = await this.lcdService.bank.balance(address, { height, 'x-apikey': apikey }) return Coin.fromTerraCoins(balance) } catch (err) { @@ -27,7 +28,9 @@ export class BankService { public async total(height?: number): Promise { try { - const [total] = await this.lcdService.bank.total({ height }) + const apikey = process.env.API_KEY + + const [total] = await this.lcdService.bank.total({ height, 'x-apikey': apikey }) return Coin.fromTerraCoins(total) } catch (err) { diff --git a/src/ibc/ibc.service.ts b/src/ibc/ibc.service.ts index 3356cf8..7b4b8df 100644 --- a/src/ibc/ibc.service.ts +++ b/src/ibc/ibc.service.ts @@ -16,7 +16,8 @@ export class IbcService { public async parameters(height?: number): Promise { try { - const result = await this.lcdService.ibcTransfer.parameters({ height }) + const apikey = process.env.API_KEY + const result = await this.lcdService.ibcTransfer.parameters({ height, 'x-apikey': apikey }) return result } catch (err) { this.logger.error({ err }, 'Error getting parameters for %s.', height) diff --git a/src/staking/staking.service.ts b/src/staking/staking.service.ts index 3e5bf6e..b3eb559 100644 --- a/src/staking/staking.service.ts +++ b/src/staking/staking.service.ts @@ -183,7 +183,8 @@ export class StakingService { public async pool(height?: number): Promise { try { - const pool = await this.lcdService.staking.pool({ height }) + const apikey = process.env.API_KEY + const pool = await this.lcdService.staking.pool({ height, 'x-apikey': apikey }) return { bonded_tokens: Coin.fromTerraCoin(pool.bonded_tokens), @@ -198,7 +199,8 @@ export class StakingService { public async parameters(height?: number): Promise { try { - const params = await this.lcdService.staking.parameters({ height }) + const apikey = process.env.API_KEY + const params = await this.lcdService.staking.parameters({ height, 'x-apikey': apikey }) return { unbonding_time: params.unbonding_time.toString(), diff --git a/src/tendermint/tendermint.service.ts b/src/tendermint/tendermint.service.ts index 02d2e53..03cf8a8 100644 --- a/src/tendermint/tendermint.service.ts +++ b/src/tendermint/tendermint.service.ts @@ -17,7 +17,8 @@ export class TendermintService { public async nodeInfo(height?: number): Promise { try { - const data = (await this.lcdService.tendermint.nodeInfo({ height })) as any + const apikey = process.env.API_KEY + const data = (await this.lcdService.tendermint.nodeInfo({ height, 'x-apikey': apikey})) as any return { id: data.default_node_info.default_node_id, @@ -54,7 +55,8 @@ export class TendermintService { public async syncing(height?: number): Promise { try { - return this.lcdService.tendermint.syncing({ height }) + const apikey = process.env.API_KEY + return this.lcdService.tendermint.syncing({ height, 'x-apikey': apikey }) } catch (err) { this.logger.error({ err }, 'Error getting the syncing mode.') @@ -64,7 +66,8 @@ export class TendermintService { public async validatorSet(height?: number): Promise { try { - const [validators] = await this.lcdService.tendermint.validatorSet(height) + const apikey = process.env.API_KEY + const [validators] = await this.lcdService.tendermint.validatorSet(height, {'x-apikey': apikey}) return { validators: validators.map((validator) => ({ @@ -83,7 +86,8 @@ export class TendermintService { public async blockInfo(height?: number): Promise { try { - const info = await this.lcdService.tendermint.blockInfo(height) + const apikey = process.env.API_KEY + const info = await this.lcdService.tendermint.blockInfo(height, {'x-apikey': apikey}) info.block.last_commit.signatures.forEach((s) => { // terra.js should be fixed to return number diff --git a/src/utils/utils.service.ts b/src/utils/utils.service.ts index 6ab06c7..232be14 100644 --- a/src/utils/utils.service.ts +++ b/src/utils/utils.service.ts @@ -18,6 +18,7 @@ export class UtilsService { const { denom, amount } = coin try { + const tax = await this.lcdService.utils.calculateTax(new TerraCoin(denom, amount)) return Coin.fromTerraCoin(tax) diff --git a/src/wasm/wasm.service.ts b/src/wasm/wasm.service.ts index fa56f87..1f4867e 100644 --- a/src/wasm/wasm.service.ts +++ b/src/wasm/wasm.service.ts @@ -16,7 +16,8 @@ export class WasmService { public async codeInfo(codeID: number, height?: number): Promise { try { - const info = await this.lcdService.wasm.codeInfo(codeID, { height }) + const apikey = process.env.API_KEY + const info = await this.lcdService.wasm.codeInfo(codeID, { height, 'x-apikey': apikey }) return { code_hash: info.code_hash, @@ -31,7 +32,8 @@ export class WasmService { public async contractInfo(contractAddress: string, height?: number): Promise { try { - const info = await this.lcdService.wasm.contractInfo(contractAddress, { height }) + const apikey = process.env.API_KEY + const info = await this.lcdService.wasm.contractInfo(contractAddress, { height, 'x-apikey': apikey }) return { code_id: info.code_id, @@ -49,7 +51,8 @@ export class WasmService { public async contractQuery(contractAddress: string, query: Record, height?: number): Promise { try { - const data = await this.lcdService.wasm.contractQuery(contractAddress, query, { height }) + const apikey = process.env.API_KEY + const data = await this.lcdService.wasm.contractQuery(contractAddress, query, { height, 'x-apikey': apikey }) return data } catch (err: any) { @@ -61,7 +64,8 @@ export class WasmService { public async parameters(height?: number): Promise { try { - const parameters = await this.lcdService.wasm.parameters({ height }) + const apikey = process.env.API_KEY + const parameters = await this.lcdService.wasm.parameters({ height, 'x-apikey': apikey }) return parameters } catch (err) {