sdk/js: 0.6.0 version bump and formatting changes
This commit is contained in:
parent
f64703c815
commit
a9b05d8868
|
@ -1,5 +1,17 @@
|
|||
# Changelog
|
||||
|
||||
## 0.6.0
|
||||
|
||||
### Added
|
||||
|
||||
Wormhole chain devnet support
|
||||
|
||||
human-readable part parameter to `humanAddress` function
|
||||
|
||||
### Changed
|
||||
|
||||
`canonicalAddress` and `humanAddress` functions moved from terra to cosmos module
|
||||
|
||||
## 0.5.2
|
||||
|
||||
### Added
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@certusone/wormhole-sdk",
|
||||
"version": "0.5.0",
|
||||
"version": "0.6.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@certusone/wormhole-sdk",
|
||||
"version": "0.5.0",
|
||||
"version": "0.6.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@certusone/wormhole-sdk-proto-web": "^0.0.1",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@certusone/wormhole-sdk",
|
||||
"version": "0.5.1",
|
||||
"version": "0.6.0",
|
||||
"description": "SDK for interacting with Wormhole",
|
||||
"homepage": "https://wormholenetwork.com",
|
||||
"main": "./lib/cjs/index.js",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { bech32 } from "bech32";
|
||||
|
||||
export function canonicalAddress(humanAddress: string) {
|
||||
return new Uint8Array(bech32.fromWords(bech32.decode(humanAddress).words));
|
||||
return new Uint8Array(bech32.fromWords(bech32.decode(humanAddress).words));
|
||||
}
|
||||
export function humanAddress(hrp: string, canonicalAddress: Uint8Array) {
|
||||
return bech32.encode(hrp, bech32.toWords(canonicalAddress));
|
||||
return bech32.encode(hrp, bech32.toWords(canonicalAddress));
|
||||
}
|
||||
|
|
|
@ -20,10 +20,14 @@ test("terra address conversion", () => {
|
|||
});
|
||||
|
||||
test("wormchain address conversion", () => {
|
||||
const human = "wormhole1ap5vgur5zlgys8whugfegnn43emka567dtq0jl";
|
||||
const canonical = "000000000000000000000000e868c4707417d0481dd7e213944e758e776ed35e";
|
||||
const native = tryUint8ArrayToNative(new Uint8Array(Buffer.from(canonical, "hex")), "wormholechain");
|
||||
expect(native).toBe(human);
|
||||
const human = "wormhole1ap5vgur5zlgys8whugfegnn43emka567dtq0jl";
|
||||
const canonical =
|
||||
"000000000000000000000000e868c4707417d0481dd7e213944e758e776ed35e";
|
||||
const native = tryUint8ArrayToNative(
|
||||
new Uint8Array(Buffer.from(canonical, "hex")),
|
||||
"wormholechain"
|
||||
);
|
||||
expect(native).toBe(human);
|
||||
|
||||
expect(tryNativeToHexString(human, "wormholechain")).toBe(canonical)
|
||||
expect(tryNativeToHexString(human, "wormholechain")).toBe(canonical);
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
nativeStringToHexAlgorand,
|
||||
uint8ArrayToNativeStringAlgorand,
|
||||
} from "../algorand";
|
||||
import { canonicalAddress, humanAddress } from "../cosmos"
|
||||
import { canonicalAddress, humanAddress } from "../cosmos";
|
||||
import { buildTokenId } from "../cosmwasm/address";
|
||||
import { isNativeDenom } from "../terra";
|
||||
import {
|
||||
|
@ -91,8 +91,8 @@ export const tryUint8ArrayToNative = (
|
|||
} else if (chainId === CHAIN_ID_ALGORAND) {
|
||||
return uint8ArrayToNativeStringAlgorand(a);
|
||||
} else if (chainId == CHAIN_ID_WORMHOLE_CHAIN) {
|
||||
// wormhole-chain addresses are always 20 bytes.
|
||||
return humanAddress("wormhole", a.slice(-20));
|
||||
// wormhole-chain addresses are always 20 bytes.
|
||||
return humanAddress("wormhole", a.slice(-20));
|
||||
} else if (chainId === CHAIN_ID_NEAR) {
|
||||
throw Error("uint8ArrayToNative: Near not supported yet.");
|
||||
} else if (chainId === CHAIN_ID_INJECTIVE) {
|
||||
|
@ -212,7 +212,7 @@ export const tryNativeToHexString = (
|
|||
} else if (chainId === CHAIN_ID_ALGORAND) {
|
||||
return nativeStringToHexAlgorand(address);
|
||||
} else if (chainId == CHAIN_ID_WORMHOLE_CHAIN) {
|
||||
return uint8ArrayToHex(zeroPad(canonicalAddress(address), 32));
|
||||
return uint8ArrayToHex(zeroPad(canonicalAddress(address), 32));
|
||||
} else if (chainId === CHAIN_ID_NEAR) {
|
||||
throw Error("hexToNativeString: Near not supported yet.");
|
||||
} else if (chainId === CHAIN_ID_INJECTIVE) {
|
||||
|
|
Loading…
Reference in New Issue