Browse Source

sdk/js: 0.6.0 version bump and formatting changes

Kevin Peters 3 years ago
parent
commit
a9b05d8868

+ 12 - 0
sdk/js/CHANGELOG.md

@@ -1,5 +1,17 @@
 # Changelog
 # 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
 ## 0.5.2
 
 
 ### Added
 ### Added

+ 2 - 2
sdk/js/package-lock.json

@@ -1,12 +1,12 @@
 {
 {
   "name": "@certusone/wormhole-sdk",
   "name": "@certusone/wormhole-sdk",
-  "version": "0.5.0",
+  "version": "0.6.0",
   "lockfileVersion": 2,
   "lockfileVersion": 2,
   "requires": true,
   "requires": true,
   "packages": {
   "packages": {
     "": {
     "": {
       "name": "@certusone/wormhole-sdk",
       "name": "@certusone/wormhole-sdk",
-      "version": "0.5.0",
+      "version": "0.6.0",
       "license": "Apache-2.0",
       "license": "Apache-2.0",
       "dependencies": {
       "dependencies": {
         "@certusone/wormhole-sdk-proto-web": "^0.0.1",
         "@certusone/wormhole-sdk-proto-web": "^0.0.1",

+ 1 - 1
sdk/js/package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "@certusone/wormhole-sdk",
   "name": "@certusone/wormhole-sdk",
-  "version": "0.5.1",
+  "version": "0.6.0",
   "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",

+ 2 - 2
sdk/js/src/cosmos/address.ts

@@ -1,8 +1,8 @@
 import { bech32 } from "bech32";
 import { bech32 } from "bech32";
 
 
 export function canonicalAddress(humanAddress: string) {
 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) {
 export function humanAddress(hrp: string, canonicalAddress: Uint8Array) {
-    return bech32.encode(hrp, bech32.toWords(canonicalAddress));
+  return bech32.encode(hrp, bech32.toWords(canonicalAddress));
 }
 }

+ 9 - 5
sdk/js/src/utils/array.test.ts

@@ -20,10 +20,14 @@ test("terra address conversion", () => {
 });
 });
 
 
 test("wormchain 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);
 });
 });

+ 4 - 4
sdk/js/src/utils/array.ts

@@ -6,7 +6,7 @@ import {
   nativeStringToHexAlgorand,
   nativeStringToHexAlgorand,
   uint8ArrayToNativeStringAlgorand,
   uint8ArrayToNativeStringAlgorand,
 } from "../algorand";
 } from "../algorand";
-import { canonicalAddress, humanAddress } from "../cosmos"
+import { canonicalAddress, humanAddress } from "../cosmos";
 import { buildTokenId } from "../cosmwasm/address";
 import { buildTokenId } from "../cosmwasm/address";
 import { isNativeDenom } from "../terra";
 import { isNativeDenom } from "../terra";
 import {
 import {
@@ -91,8 +91,8 @@ export const tryUint8ArrayToNative = (
   } else if (chainId === CHAIN_ID_ALGORAND) {
   } else if (chainId === CHAIN_ID_ALGORAND) {
     return uint8ArrayToNativeStringAlgorand(a);
     return uint8ArrayToNativeStringAlgorand(a);
   } else if (chainId == CHAIN_ID_WORMHOLE_CHAIN) {
   } 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) {
   } else if (chainId === CHAIN_ID_NEAR) {
     throw Error("uint8ArrayToNative: Near not supported yet.");
     throw Error("uint8ArrayToNative: Near not supported yet.");
   } else if (chainId === CHAIN_ID_INJECTIVE) {
   } else if (chainId === CHAIN_ID_INJECTIVE) {
@@ -212,7 +212,7 @@ export const tryNativeToHexString = (
   } else if (chainId === CHAIN_ID_ALGORAND) {
   } else if (chainId === CHAIN_ID_ALGORAND) {
     return nativeStringToHexAlgorand(address);
     return nativeStringToHexAlgorand(address);
   } else if (chainId == CHAIN_ID_WORMHOLE_CHAIN) {
   } 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) {
   } else if (chainId === CHAIN_ID_NEAR) {
     throw Error("hexToNativeString: Near not supported yet.");
     throw Error("hexToNativeString: Near not supported yet.");
   } else if (chainId === CHAIN_ID_INJECTIVE) {
   } else if (chainId === CHAIN_ID_INJECTIVE) {