Skip to content

Commit

Permalink
V0.13.6 (#282)
Browse files Browse the repository at this point in the history
* chore: add missing chains

* chore: fix manualRelayToDestChain (#281)

* chore: fix evm event retrieval should not require useWindowEthereum

* chore: fix tests

* chore: update version to 0.13.6-alpha.1

* chore: add registry-url for release-alpha action

* chore: set default to useWindowEthereum in execute function

* chore: update filecoin calibration testnet chain id

* chore: update filecoin rpc

* chore: add retry for fetchBatchData

* 0.13.6-alpha.2

* chore: addressing bignumber issue with estimateGasFee (#283)

* chore: addressing bignumber issue with estimateGasFee

* chore: change gasLimit type to BigNumberish

* 0.13.6-alpha.3

* chore: adding polygon evm

* 0.13.6-alpha.4

* Chore/fix manual relay to dest chain (#284)

* chore: fix evm event retrieval should not require useWindowEthereum

* chore: fix tests

* chore: update version to 0.13.6-alpha.1

* chore: add registry-url for release-alpha action

* chore: set default to useWindowEthereum in execute function

* chore: update filecoin calibration testnet chain id

* chore: update filecoin rpc

* chore: add retry for fetchBatchData

* chore: add fallback for getEventIndex

* chore: adding updated chains

---------

Co-authored-by: npty <[email protected]>

* chore: adding updated chains (#288)

* chore: support specify dest chain log index (#285)

* chore: allow user to pass destChain and eventIndex

* chore: same thing for addGas

* chore: adding optional parameter for log index to recovery methods (#287)

* chore: adding optional parameter for log index to recovery methods

* chore: code cleanup

* chore: fix test

---------

Co-authored-by: Canh Trinh <[email protected]>
Co-authored-by: Canh Trinh <[email protected]>

* chore: update v0.13.6 changelog

* chore: fix for fractional component exceeds decimals

* 0.13.6-alpha.5

* chore: add mantle testnet/mainnet configs

* 0.13.6-alpha.6

* chore: remove unused parameter

* chore: fix test

* feat(AXE-1171): add srcTxLogIndex and srcTxIndex to execute method params

* 0.13.6-alpha.7

* chore(AXE-1171): fix test

* chore: update changelog

* 0.13.6

---------

Co-authored-by: npty <[email protected]>
Co-authored-by: npty <[email protected]>
  • Loading branch information
3 people authored Sep 1, 2023
1 parent 3d30bc5 commit c763d1c
Show file tree
Hide file tree
Showing 17 changed files with 247 additions and 73 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release-alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"

- name: Install pnpm
uses: pnpm/action-setup@v2
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.13.6] - 2023-SEPTEMBER-1

- Fix the issue with `manualRelayToDestChain` where the web client incorrectly utilizes the provider from the injected browser wallet instead of the rpcUrl embedded in the SDK. This error arises when the injected wallet's network differs from the source chain.
- update `manualRelayToDestChain` method to accept `txLogIndex` optional parameter
- update `addGas`, `addNativeGas`
- Add `Linea`, `Base`, `Mantle` evm mainnet configs; `Archway`, `Aura`, `IXO`, `Neutron`, `Provenance`, `Sei` to cosmos mainnet configs; Polygon-zkEvm to evm configs
- Update the `estimateGasFee` method on `AxelarQueryAPI` to accept `BigNumberish` type for `gasLimit` parameter
- fix `doesTxMeetConfirmHt` and `getEventIndex` methods to search for EVM transaction receipt from Axelarscan API if not found from the source blockchain
- fix `BigNumberUtils` to address `fractional component exceeds decimals` error, a valid edge case where floating point numbers can exceed specified atomic units

## [0.13.5] - 2023-JULY-10

- Fix constant declaration for Optimism testnet
Expand Down
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.13.5",
"version": "0.13.6",
"description": "The JavaScript SDK for Axelar Network",
"repository": {
"type": "git",
Expand Down
18 changes: 16 additions & 2 deletions src/chains/supported-chains-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,45 @@ export const CHAINS = {
BASE: "base",
BINANCE: "binance",
BNBCHAIN: "binance",
BURNT: "burnt",
BURNT: "burnt-2",
CELO: "celo",
COMDEX: "comdex-2",
ETHEREUM: "ethereum-2",
EVMOS: "evmos",
FANTOM: "Fantom",
FETCH: "fetch",
FILECOIN: "filecoin",
FILECOIN: "filecoin-2",
HERO: "hero",
HIGHRISE: "highrise",
IMPACTHUB: "impacthub",
KAVA: "kava",
KUJIRA: "kujira",
LINEA: "linea",
MANTLE: "mantle",
MOONBEAM: "Moonbeam",
NEUTRON: "neutron",
ODIN: "odin",
OPTIMISM: "optimism",
OSMOSIS: "osmosis-6",
PERSISTENCE: "persistence",
POLYGON: "Polygon",
POLYGONZKEVM: "polygon-zkevm",
SECRETSNIP: "secret-snip-2",
SEI: "sei-2",
TERITORI: "teritori",
TERRA: "terra-3",
XPLA: "xpla",
},
MAINNET: {
ACRE: "acre",
AGORIC: "agoric",
ARBITRUM: "arbitrum",
ARCHWAY: "archway",
ASSETMANTLE: "assetmantle",
AURA: "aura",
AVALANCHE: "Avalanche",
AXELAR: "Axelarnet",
BASE: "base",
BINANCE: "binance",
BNBCHAIN: "binance",
CARBON: "carbon",
Expand All @@ -55,19 +62,26 @@ export const CHAINS = {
FETCH: "fetch",
FILECOIN: "filecoin",
INJECTIVE: "injective",
IXO: "ixo",
JUNO: "juno",
KAVA: "kava",
KI: "ki",
KUJIRA: "kujira",
LINEA: "linea",
MANTLE: "mantle",
MOONBEAM: "Moonbeam",
NEUTRON: "neutron",
OPTIMISM: "optimism",
OSMOSIS: "osmosis",
PERSISTENCE: "persistence",
POLYGON: "Polygon",
POLYGONZKEVM: "polygon-zkevm",
PROVENANCE: "provenance",
REBUS: "rebus",
REGEN: "regen",
SECRET: "secret",
SECRETSNIP: "secret-snip",
SEI: "sei",
SOMMELIER: "sommelier",
STARGAZE: "stargaze",
STRIDE: "stride",
Expand Down
11 changes: 10 additions & 1 deletion src/libs/AxelarGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,36 @@ export const AXELAR_GATEWAY: Record<Environment, Partial<Record<EvmChain, string
[Environment.MAINNET]: {
[EvmChain.ETHEREUM]: "0x4F4495243837681061C4743b74B3eEdf548D56A5",
[EvmChain.AVALANCHE]: "0x5029C0EFf6C34351a0CEc334542cDb22c7928f78",
[EvmChain.BNBCHAIN]: "0x304acf330bbE08d1e512eefaa92F6a57871fD895",
[EvmChain.FANTOM]: "0x304acf330bbE08d1e512eefaa92F6a57871fD895",
[EvmChain.POLYGON]: "0x6f015F16De9fC8791b234eF68D486d2bF203FBA8",
[EvmChain.MOONBEAM]: "0x4F4495243837681061C4743b74B3eEdf548D56A5",
[EvmChain.ARBITRUM]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.AURORA]: "0x304acf330bbE08d1e512eefaa92F6a57871fD895",
[EvmChain.BASE]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.CELO]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.KAVA]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.OPTIMISM]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.FILECOIN]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.MANTLE]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
},
[Environment.TESTNET]: {
[EvmChain.ETHEREUM]: "0xBC6fcce7c5487d43830a219CA6E7B83238B41e71",
[EvmChain.ETHEREUM]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.AVALANCHE]: "0xC249632c2D40b9001FE907806902f63038B737Ab",
[EvmChain.BASE]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.BNBCHAIN]: "0x4D147dCb984e6affEEC47e44293DA442580A3Ec0",
[EvmChain.FANTOM]: "0x97837985Ec0494E7b9C71f5D3f9250188477ae14",
[EvmChain.POLYGON]: "0xBF62ef1486468a6bd26Dd669C06db43dEd5B849B",
[EvmChain.POLYGON_ZKEVM]: "0x999117D44220F33e0441fbAb2A5aDB8FF485c54D",
[EvmChain.MOONBEAM]: "0x5769D84DD62a6fD969856c75c7D321b84d455929",
[EvmChain.ARBITRUM]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.AURORA]: "0x304acf330bbE08d1e512eefaa92F6a57871fD895",
[EvmChain.CELO]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.KAVA]: "0xC8D18F85cB0Cee5C95eC29c69DeaF6cea972349c",
[EvmChain.OPTIMISM]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.LINEA]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.FILECOIN]: "0x999117D44220F33e0441fbAb2A5aDB8FF485c54D",
[EvmChain.MANTLE]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
},
[Environment.DEVNET]: {
[EvmChain.ETHEREUM]: "0x7358799e0c8250f0B7D1164824F6Dd5bA31C9Cd6",
Expand Down
29 changes: 17 additions & 12 deletions src/libs/AxelarQueryAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import {
import { throwIfInvalidChainIds } from "../utils";
import { loadChains } from "../chains";
import s3 from "./TransactionRecoveryApi/constants/s3";
import { BigNumber } from "ethers";
import { BigNumber, BigNumberish } from "ethers";
import { ChainInfo } from "src/chains/types";
import { BigNumberUtils } from "./BigNumberUtils";

interface TranslatedTransferRateLimitResponse {
incoming: string;
Expand All @@ -37,7 +38,7 @@ export interface AxelarQueryAPIFeeResponse {
executionFee: string;
executionFeeWithMultiplier: string;
gasMultiplier: number;
gasLimit: number;
gasLimit: BigNumberish;
minGasPrice: string;
apiResponse: any;
isExpressSupported: boolean;
Expand Down Expand Up @@ -98,10 +99,12 @@ export class AxelarQueryAPI {
public async getEVMEvent(sourceChainId: string, srcTxHash: string, srcEventId: number) {
await throwIfInvalidChainIds([sourceChainId], this.environment);
await this.initQueryClientIfNeeded();
return this.axelarQueryClient.evm.Event({
chain: sourceChainId,
eventId: `${srcTxHash}-${srcEventId}`,
});
return this.axelarQueryClient.evm
.Event({
chain: sourceChainId,
eventId: `${srcTxHash}-${srcEventId}`,
})
.catch(() => undefined);
}

public async getConfirmationHeight(chain: string) {
Expand Down Expand Up @@ -251,7 +254,7 @@ export class AxelarQueryAPI {
sourceChainId: EvmChain | string,
destinationChainId: EvmChain | string,
sourceChainTokenSymbol: GasToken | string,
gasLimit: number = DEFAULT_ESTIMATED_GAS,
gasLimit: BigNumberish = DEFAULT_ESTIMATED_GAS,
gasMultiplier = 1.1,
minGasPrice = "0",
gmpParams?: GMPParams
Expand All @@ -276,14 +279,16 @@ export class AxelarQueryAPI {
throw new Error("Failed to estimate gas fee");
}

const destGasFeeWei = parseUnits(
(gasLimit * Number(destToken.gas_price)).toFixed(destToken.decimals),
const destGasFeeWei = BigNumberUtils.multiplyToGetWei(
BigNumber.from(gasLimit),
destToken.gas_price,
destToken.decimals
);

const minDestGasFeeWei = BigNumber.from(gasLimit).mul(minGasPrice); //minGasPrice already provided by the user in wei
const srcGasFeeWei = parseUnits(
(gasLimit * Number(sourceToken.gas_price)).toFixed(sourceToken.decimals),

const srcGasFeeWei = BigNumberUtils.multiplyToGetWei(
BigNumber.from(gasLimit),
sourceToken.gas_price,
sourceToken.decimals
);

Expand Down
19 changes: 19 additions & 0 deletions src/libs/BigNumberUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { BigNumber } from "ethers";
import { parseUnits } from "ethers/lib/utils";

export class BigNumberUtils {
public static multiplyToGetWei(bn: BigNumber | string, number: string, units: number): BigNumber {
if (number.toString().split(".")[1].length <= units) {
return BigNumber.from(bn).mul(parseUnits(number, units));
} else {
const multiplier = Math.pow(10, units);
return BigNumber.from(bn)
.mul(parseUnits((Number(number) * multiplier).toString(), units))
.div(multiplier);
}
}

public static divideToGetWei(bn: BigNumber | string, number: string, units: number): BigNumber {
return BigNumber.from(bn).div(parseUnits(number, units));
}
}
Loading

0 comments on commit c763d1c

Please sign in to comment.