Skip to content

Commit

Permalink
chore: adding fee query (#65)
Browse files Browse the repository at this point in the history
* chore: adding fee query

* chore: linting cleanup

* chore: changing name of method from getTransactionFee to getTransferFee
  • Loading branch information
canhtrinh authored Mar 18, 2022
1 parent 9f92b2d commit fd03a50
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 540 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axelar-network/axelarjs-sdk",
"version": "0.4.25",
"version": "0.4.26",
"description": "The JavaScript SDK for Axelar Network",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
26 changes: 25 additions & 1 deletion src/TransferAssetBridge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export class TransferAssetBridge {
}

public async getFeeForChainAndAsset(
chain: string, asset: string
chain: string,
asset: string
): Promise<any> {
try {
return (await this.restServices.get(
Expand All @@ -118,6 +119,29 @@ export class TransferAssetBridge {
}
}

public async getTransferFee(
sourceChain: string,
destinationChain: string,
asset: string
): Promise<number> {
try {
const sourceChainFeeInfo = await this.getFeeForChainAndAsset(
sourceChain,
asset
);
const destinationChainFeeInfo = await this.getFeeForChainAndAsset(
destinationChain,
asset
);
return (
+sourceChainFeeInfo?.fee_info?.min_fee +
+destinationChainFeeInfo?.fee_info?.min_fee
);
} catch (e: any) {
throw e;
}
}

public async getDepositAddress(
message: AssetTransferObject,
showAlerts: boolean
Expand Down
Loading

0 comments on commit fd03a50

Please sign in to comment.