Skip to content

Commit

Permalink
add api-key to lcd requests
Browse files Browse the repository at this point in the history
  • Loading branch information
markonmars committed Jun 26, 2024
1 parent eae0493 commit ab252b6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM node:lts-alpine
FROM node:19.4-alpine
RUN apk add g++ make py3-pip

# Create app directory
WORKDIR /usr/src/app
Expand All @@ -12,4 +13,4 @@ RUN npm ci
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

CMD [ "npm", "run", "start:dev" ]
CMD [ "npm", "run", "start:dev" ]
26 changes: 26 additions & 0 deletions scripts/ecr_upload_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e
set -o pipefail

aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ECR_REGISTRY_URI

# AWS_ECR_REPOSITORY_NAME

latest_commit=$(git rev-parse HEAD)

# Get the current branch name (optional)
current_branch=$(git rev-parse --abbrev-ref HEAD)

# Generate the Docker image tag by combining the version and the latest commit hash
image_tag="${AWS_ECR_REPOSITORY_NAME}:${current_branch}-${latest_commit}"

sudo docker build --no-cache -t $image_tag .

image_uri="${AWS_ECR_REGISTRY_URI}/${image_tag}"

sudo docker tag $image_tag $image_uri

sudo docker push $image_uri

echo $image_uri
2 changes: 0 additions & 2 deletions src/bank/bank.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ export class BankService {
public async total(height?: number): Promise<Coin[]> {
try {
const apikey = process.env.API_KEY

const [total] = await this.lcdService.bank.total({ height, 'x-apikey': apikey })

return Coin.fromTerraCoins(total)
} catch (err) {
this.logger.error({ err }, 'Error getting the total supply of tokens in circulation for all denominations.')
Expand Down
2 changes: 1 addition & 1 deletion src/gov/gov.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class GovResolver {

@ResolveField(() => String)
public async proposer(@Args() args: GetGovArgs): Promise<string> {
return this.govService.proposer(args.proposalId, args.height)
return this.govService.proposer(args.proposalId)
}

@ResolveField(() => [MsgDeposit])
Expand Down
2 changes: 1 addition & 1 deletion src/gov/gov.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class GovService {
}
}

public async proposer(proposalId: number, height?: number): Promise<string> {
public async proposer(proposalId: number): Promise<string> {
try {
return this.lcdService.gov.proposer(proposalId)
} catch (err) {
Expand Down
6 changes: 3 additions & 3 deletions src/tendermint/tendermint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class TendermintService {
public async nodeInfo(height?: number): Promise<NodeInfo> {
try {
const apikey = process.env.API_KEY
const data = (await this.lcdService.tendermint.nodeInfo({ height, 'x-apikey': apikey})) as any
const data = (await this.lcdService.tendermint.nodeInfo({ height, 'x-apikey': apikey })) as any

return {
id: data.default_node_info.default_node_id,
Expand Down Expand Up @@ -67,7 +67,7 @@ export class TendermintService {
public async validatorSet(height?: number): Promise<ValidatorSet> {
try {
const apikey = process.env.API_KEY
const [validators] = await this.lcdService.tendermint.validatorSet(height, {'x-apikey': apikey})
const [validators] = await this.lcdService.tendermint.validatorSet(height, { 'x-apikey': apikey })

return {
validators: validators.map<DelegateValidator>((validator) => ({
Expand All @@ -87,7 +87,7 @@ export class TendermintService {
public async blockInfo(height?: number): Promise<BlockInfo> {
try {
const apikey = process.env.API_KEY
const info = await this.lcdService.tendermint.blockInfo(height, {'x-apikey': apikey})
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
Expand Down
1 change: 0 additions & 1 deletion src/utils/utils.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class UtilsService {
const { denom, amount } = coin

try {

const tax = await this.lcdService.utils.calculateTax(new TerraCoin(denom, amount))

return Coin.fromTerraCoin(tax)
Expand Down

0 comments on commit ab252b6

Please sign in to comment.