Skip to content

Commit

Permalink
update fee fetch the thorchain client (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorian1te authored Dec 7, 2023
1 parent 617f662 commit 901ded3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 20 deletions.
6 changes: 6 additions & 0 deletions packages/xchain-thorchain-amm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.8.7 (2023-12-07)

## Update

- dependency xchain-thorchain

# v0.8.6 (2023-12-06)

## Update
Expand Down
6 changes: 3 additions & 3 deletions packages/xchain-thorchain-amm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xchainjs/xchain-thorchain-amm",
"version": "0.8.6",
"version": "0.8.7",
"description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
"keywords": [
"THORChain",
Expand Down Expand Up @@ -55,7 +55,7 @@
"@xchainjs/xchain-litecoin": "^0.13.6",
"@xchainjs/xchain-mayachain": "^0.2.10",
"@xchainjs/xchain-midgard": "^0.5.2",
"@xchainjs/xchain-thorchain": "^0.28.13",
"@xchainjs/xchain-thorchain": "^0.28.14",
"@xchainjs/xchain-util": "^0.13.1",
"@xchainjs/xchain-utxo-providers": "^0.2.8",
"axios": "^1.3.6",
Expand Down Expand Up @@ -91,7 +91,7 @@
"@xchainjs/xchain-litecoin": "^0.13.6",
"@xchainjs/xchain-mayachain": "^0.2.10",
"@xchainjs/xchain-midgard": "^0.5.2",
"@xchainjs/xchain-thorchain": "^0.28.13",
"@xchainjs/xchain-thorchain": "^0.28.14",
"@xchainjs/xchain-util": "^0.13.1",
"@xchainjs/xchain-utxo-providers": "^0.2.8",
"axios": "^1.3.6",
Expand Down
6 changes: 6 additions & 0 deletions packages/xchain-thorchain/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.28.14 (2023-12-07)

## Update

- Change thorchain getFees() to fetch to /thorchain/network

# v0.28.13 (2023-11-16)

## Update
Expand Down
5 changes: 5 additions & 0 deletions packages/xchain-thorchain/__e2e__/thorchain-client.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ describe('thorchain Integration Tests', () => {
expect(tx.type).toBe('transfer')
expect(tx.from[1].amount.amount().toNumber()).toBe(13744300000000)
})

it('should fetch thorchain native Tx fee', async () => {
const fees = await thorClient.getFees()
expect(fees.average.amount().toNumber()).toEqual(2000000)
})
it('should prepare transaction', async () => {
try {
const sender = await thorClient.getAddressAsync(3)
Expand Down
4 changes: 2 additions & 2 deletions packages/xchain-thorchain/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xchainjs/xchain-thorchain",
"version": "0.28.13",
"version": "0.28.14",
"description": "Custom Thorchain client and utilities used by XChainJS clients",
"keywords": [
"THORChain",
Expand Down Expand Up @@ -56,4 +56,4 @@
"axios": "^1.3.6",
"bech32-buffer": "^0.2.0"
}
}
}
8 changes: 3 additions & 5 deletions packages/xchain-thorchain/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import {
ExplorerUrls,
NodeUrl,
ThorchainClientParams,
ThorchainConstantsResponse,
ThorchainNetworkResponse,
TxData,
TxOfflineParams,
} from './types'
Expand Down Expand Up @@ -884,10 +884,8 @@ class Client extends BaseXChainClient implements ThorchainClient, XChainClient {
async getFees(): Promise<Fees> {
try {
const {
data: {
int_64_values: { NativeTransactionFee: fee },
},
} = await axios.get<ThorchainConstantsResponse>(`${this.getClientUrl().node}/thorchain/constants`)
data: { native_tx_fee_rune: fee },
} = await axios.get<ThorchainNetworkResponse>(`${this.getClientUrl().node}/thorchain/network`)

// validate data
if (!fee || isNaN(fee) || fee < 0) throw Error(`Invalid fee: ${fee.toString()}`)
Expand Down
8 changes: 3 additions & 5 deletions packages/xchain-thorchain/src/types/client-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ export type TxOfflineParams = TxParams & {
/**
* Response from `thorchain/constants` endpoint
*/
export type ThorchainConstantsResponse = {
int_64_values: {
// We are in fee interested only - ignore all other values
NativeTransactionFee: number
}
export type ThorchainNetworkResponse = {
// We are in fee interested only - ignore all other values
native_tx_fee_rune: number
}

/**
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2600,11 +2600,6 @@
"@typescript-eslint/types" "5.59.1"
eslint-visitor-keys "^3.3.0"

"@xchainjs/xchain-client@^0.14.1":
version "0.14.2"
resolved "https://registry.yarnpkg.com/@xchainjs/xchain-client/-/xchain-client-0.14.2.tgz#9047bcb83a940fdceff52cd53baeb2fdc8362237"
integrity sha512-uYnKLU5qcDixNizIGtyt7K4FYHkWCEq2PNKSv/8mApjIVjsYvt2TnzFCazj0kK0tOxhlFZUzELCHbvQpF+ugDg==

"@yarnpkg/lockfile@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
Expand Down

0 comments on commit 901ded3

Please sign in to comment.