From a9b05d88682a27ddda1aa0e89ea398ad40aefd45 Mon Sep 17 00:00:00 2001 From: Kevin Peters Date: Fri, 29 Jul 2022 19:33:04 +0000 Subject: [PATCH] sdk/js: 0.6.0 version bump and formatting changes --- sdk/js/CHANGELOG.md | 12 ++++++++++++ sdk/js/package-lock.json | 4 ++-- sdk/js/package.json | 2 +- sdk/js/src/cosmos/address.ts | 4 ++-- sdk/js/src/utils/array.test.ts | 14 +++++++++----- sdk/js/src/utils/array.ts | 8 ++++---- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/sdk/js/CHANGELOG.md b/sdk/js/CHANGELOG.md index 199f84913..c5f8a2a51 100644 --- a/sdk/js/CHANGELOG.md +++ b/sdk/js/CHANGELOG.md @@ -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 diff --git a/sdk/js/package-lock.json b/sdk/js/package-lock.json index b9fb60857..1bb93d447 100644 --- a/sdk/js/package-lock.json +++ b/sdk/js/package-lock.json @@ -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", diff --git a/sdk/js/package.json b/sdk/js/package.json index bea9ac87f..408d0892c 100644 --- a/sdk/js/package.json +++ b/sdk/js/package.json @@ -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", diff --git a/sdk/js/src/cosmos/address.ts b/sdk/js/src/cosmos/address.ts index 340f253a3..978e02005 100644 --- a/sdk/js/src/cosmos/address.ts +++ b/sdk/js/src/cosmos/address.ts @@ -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)); } diff --git a/sdk/js/src/utils/array.test.ts b/sdk/js/src/utils/array.test.ts index 559e463e8..662193fbc 100644 --- a/sdk/js/src/utils/array.test.ts +++ b/sdk/js/src/utils/array.test.ts @@ -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); }); diff --git a/sdk/js/src/utils/array.ts b/sdk/js/src/utils/array.ts index 85eb4583a..a603cb8f0 100644 --- a/sdk/js/src/utils/array.ts +++ b/sdk/js/src/utils/array.ts @@ -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) {