From bf6950fc5eebebe3f7500284f6f3612dae864a2e Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 24 Jun 2025 07:24:41 +0000 Subject: [PATCH] Add support for token denom $Z (#2) Part of https://www.notion.so/zenithd-milestone-4-1d6a6b22d4728043b7e4dbf70c50aa56 Reviewed-on: https://git.vdb.to/LaconicNetwork/zenith-faucet/pulls/2 Co-authored-by: Prathamesh Musale Co-committed-by: Prathamesh Musale --- .dockerignore | 3 +++ .npmrc | 1 + package.json | 1 + src/index.ts | 6 ++++-- yarn.lock | 8 ++++++++ 5 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 .npmrc diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7cb9afe --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +dist +db diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..2bc2a82 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +@laconic-network:registry=https://git.vdb.to/api/packages/LaconicNetwork/npm/ diff --git a/package.json b/package.json index b9f783f..7c6b9b9 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@cosmjs/encoding": "^0.33.1", "@cosmjs/proto-signing": "^0.33.1", "@cosmjs/stargate": "^0.33.1", + "@laconic-network/cosmjs-util": "^0.1.0", "@keyv/sqlite": "^3.6.7", "cors": "^2.8.5", "express": "^4.19.2", diff --git a/src/index.ts b/src/index.ts index 5814e27..1a46674 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,11 +6,13 @@ import toml from 'toml'; import cors from 'cors'; import { DirectSecp256k1Wallet } from '@cosmjs/proto-signing'; -import { GasPrice, SigningStargateClient } from '@cosmjs/stargate'; +import { SigningStargateClient } from '@cosmjs/stargate'; import { Comet38Client } from '@cosmjs/tendermint-rpc'; import { fromBech32 } from '@cosmjs/encoding'; import KeyvSqlite from '@keyv/sqlite'; +import { parseCustomGasPrice } from '@laconic-network/cosmjs-util'; + const CONFIG_PATH = 'environments/local.toml'; const FAUCET_DATA_FILE = 'faucet_data.sqlite'; const FAUCET_DATA_TTL = 86400000; // 24 hrs @@ -123,7 +125,7 @@ async function sendTokens (config: Config, recipientAddress: string, amount: str const client = await SigningStargateClient.createWithSigner( cometClient, wallet, - { gasPrice: GasPrice.fromString(`${config.upstream.gasPrice}${config.upstream.denom}`) } + { gasPrice: parseCustomGasPrice(`${config.upstream.gasPrice}${config.upstream.denom}`) } ); const result = await client.sendTokens( diff --git a/yarn.lock b/yarn.lock index 83dc5a7..17b439c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -201,6 +201,14 @@ dependencies: sqlite3 "^5.1.7" +"@laconic-network/cosmjs-util@^0.1.0": + version "0.1.0" + resolved "https://git.vdb.to/api/packages/LaconicNetwork/npm/%40laconic-network%2Fcosmjs-util/-/0.1.0/cosmjs-util-0.1.0.tgz#899af1de6101834e42c68aa684a00f51f7b913ed" + integrity sha512-18Gez/2FwDkLf/de1x6httgtwrj+9jldc7V6Or0KGGtboQgKPUC6G5RebowpeWR/d9GVORV3ha8H2PpCtH4XMQ== + dependencies: + "@cosmjs/math" "^0.33.1" + "@cosmjs/stargate" "^0.33.1" + "@noble/hashes@^1": version "1.4.0" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426"