sdk: initial avax support

Change-Id: I54ba771d1ad764379027cddfe500375fa440966f
This commit is contained in:
Chase Moran 2021-12-10 14:07:28 -05:00
parent 57919f6675
commit 0b6b5f3548
4 changed files with 17 additions and 7 deletions

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
## 0.1.4
initial AVAX testnet support
## 0.1.3 ## 0.1.3
### Added ### Added

View File

@ -1,6 +1,6 @@
{ {
"name": "@certusone/wormhole-sdk", "name": "@certusone/wormhole-sdk",
"version": "0.1.3", "version": "0.1.4",
"description": "SDK for interacting with Wormhole", "description": "SDK for interacting with Wormhole",
"homepage": "https://wormholenetwork.com", "homepage": "https://wormholenetwork.com",
"main": "./lib/cjs/index.js", "main": "./lib/cjs/index.js",

View File

@ -6,17 +6,22 @@ import {
CHAIN_ID_TERRA, CHAIN_ID_TERRA,
CHAIN_ID_POLYGON, CHAIN_ID_POLYGON,
CHAIN_ID_ETHEREUM_ROPSTEN, CHAIN_ID_ETHEREUM_ROPSTEN,
CHAIN_ID_AVAX,
} from "./consts"; } from "./consts";
import { humanAddress, canonicalAddress, isNativeDenom } from "../terra"; import { humanAddress, canonicalAddress, isNativeDenom } from "../terra";
import { PublicKey } from "@solana/web3.js"; import { PublicKey } from "@solana/web3.js";
import { hexValue, hexZeroPad, stripZeros } from "ethers/lib/utils"; import { hexValue, hexZeroPad, stripZeros } from "ethers/lib/utils";
import { arrayify, zeroPad } from "@ethersproject/bytes"; import { arrayify, zeroPad } from "@ethersproject/bytes";
export const isEVMChain = (chainId: ChainId) => export const isEVMChain = (chainId: ChainId) => {
return (
chainId === CHAIN_ID_ETH || chainId === CHAIN_ID_ETH ||
chainId === CHAIN_ID_BSC || chainId === CHAIN_ID_BSC ||
chainId === CHAIN_ID_ETHEREUM_ROPSTEN || chainId === CHAIN_ID_ETHEREUM_ROPSTEN ||
chainId === CHAIN_ID_POLYGON; chainId === CHAIN_ID_AVAX ||
chainId === CHAIN_ID_POLYGON
);
};
export const isHexNativeTerra = (h: string) => h.startsWith("01"); export const isHexNativeTerra = (h: string) => h.startsWith("01");
export const nativeTerraHexToDenom = (h: string) => export const nativeTerraHexToDenom = (h: string) =>

View File

@ -1,9 +1,10 @@
export type ChainId = 1 | 2 | 3 | 4 | 5 | 10001; export type ChainId = 1 | 2 | 3 | 4 | 5 | 6 | 10001;
export const CHAIN_ID_SOLANA: ChainId = 1; export const CHAIN_ID_SOLANA: ChainId = 1;
export const CHAIN_ID_ETH: ChainId = 2; export const CHAIN_ID_ETH: ChainId = 2;
export const CHAIN_ID_TERRA: ChainId = 3; export const CHAIN_ID_TERRA: ChainId = 3;
export const CHAIN_ID_BSC: ChainId = 4; export const CHAIN_ID_BSC: ChainId = 4;
export const CHAIN_ID_POLYGON: ChainId = 5; export const CHAIN_ID_POLYGON: ChainId = 5;
export const CHAIN_ID_AVAX: ChainId = 6;
export const CHAIN_ID_ETHEREUM_ROPSTEN: ChainId = 10001; export const CHAIN_ID_ETHEREUM_ROPSTEN: ChainId = 10001;
export const WSOL_ADDRESS = "So11111111111111111111111111111111111111112"; export const WSOL_ADDRESS = "So11111111111111111111111111111111111111112";