Skip to content

Commit

Permalink
Merge pull request #250 from reidrankin/improved-tests-housekeeping
Browse files Browse the repository at this point in the history
Improved Tests Phase 1: Housekeeping
  • Loading branch information
elmutt authored Apr 2, 2021
2 parents b52440a + 0d08f15 commit bab11e1
Show file tree
Hide file tree
Showing 27 changed files with 120 additions and 85 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
20 changes: 10 additions & 10 deletions examples/sandbox/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hdwallet-sandbox",
"version": "1.13.2",
"version": "1.13.3",
"main": "index.js",
"license": "MIT",
"private": true,
Expand All @@ -10,15 +10,15 @@
"clean": "rm -rf dist .cache"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-keepkey-tcp": "^1.13.2",
"@shapeshiftoss/hdwallet-keepkey-webusb": "^1.13.2",
"@shapeshiftoss/hdwallet-ledger": "^1.13.2",
"@shapeshiftoss/hdwallet-ledger-webusb": "^1.13.2",
"@shapeshiftoss/hdwallet-native": "^1.13.2",
"@shapeshiftoss/hdwallet-portis": "^1.13.2",
"@shapeshiftoss/hdwallet-trezor": "^1.13.2",
"@shapeshiftoss/hdwallet-trezor-connect": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"@shapeshiftoss/hdwallet-keepkey-tcp": "^1.13.3",
"@shapeshiftoss/hdwallet-keepkey-webusb": "^1.13.3",
"@shapeshiftoss/hdwallet-ledger": "^1.13.3",
"@shapeshiftoss/hdwallet-ledger-webusb": "^1.13.3",
"@shapeshiftoss/hdwallet-native": "^1.13.3",
"@shapeshiftoss/hdwallet-portis": "^1.13.3",
"@shapeshiftoss/hdwallet-trezor": "^1.13.3",
"@shapeshiftoss/hdwallet-trezor-connect": "^1.13.3",
"bip32": "^2.0.4",
"debug": "^4.1.1",
"jquery": "^3.4.1",
Expand Down
12 changes: 6 additions & 6 deletions integration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/integration",
"version": "1.13.2",
"version": "1.13.3",
"main": "index.js",
"license": "MIT",
"private": true,
Expand All @@ -10,11 +10,11 @@
"dev": "lerna run test --scope integration --parallel --include-filtered-dependencies"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.2",
"@shapeshiftoss/hdwallet-keepkey-nodewebusb": "^1.13.2",
"@shapeshiftoss/hdwallet-keepkey-tcp": "^1.13.2",
"@shapeshiftoss/hdwallet-trezor": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.3",
"@shapeshiftoss/hdwallet-keepkey-nodewebusb": "^1.13.3",
"@shapeshiftoss/hdwallet-keepkey-tcp": "^1.13.3",
"@shapeshiftoss/hdwallet-trezor": "^1.13.3",
"debug": "^4.1.1",
"fast-json-stable-stringify": "^2.1.0",
"parcel-bundler": "^1.12.4",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "3.22.1",
"version": "1.13.2",
"version": "1.13.3",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
Expand Down
2 changes: 1 addition & 1 deletion packages/hdwallet-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-core",
"version": "1.13.2",
"version": "1.13.3",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-keepkey-chromeusb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey-chromeusb",
"version": "1.13.2",
"version": "1.13.3",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -14,8 +14,8 @@
"prepublishOnly": "yarn clean && yarn build"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.3",
"bytebuffer": "^5.0.1",
"eventemitter2": "^5.0.1"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-keepkey-nodehid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey-nodehid",
"version": "1.13.2",
"version": "1.13.3",
"license": "MIT",
"private": true,
"main": "dist/index.js",
Expand All @@ -12,8 +12,8 @@
"prepublishOnly": "yarn clean && yarn build"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.3",
"bytebuffer": "^5.0.1",
"crypto": "^1.0.1",
"eventemitter2": "^5.0.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-keepkey-nodewebusb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey-nodewebusb",
"version": "1.13.2",
"version": "1.13.3",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -15,8 +15,8 @@
},
"dependencies": {
"@babel/polyfill": "^7.4.3",
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.3",
"bytebuffer": "^5.0.1",
"crypto": "^1.0.1",
"eventemitter2": "^5.0.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-keepkey-tcp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey-tcp",
"version": "1.13.2",
"version": "1.13.3",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -14,8 +14,8 @@
"prepublishOnly": "yarn clean && yarn build"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.3",
"axios": "^0.18.0",
"bytebuffer": "^5.0.1",
"eventemitter2": "^5.0.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-keepkey-webusb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey-webusb",
"version": "1.13.2",
"version": "1.13.3",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -14,8 +14,8 @@
"prepublishOnly": "yarn clean && yarn build"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"@shapeshiftoss/hdwallet-keepkey": "^1.13.3",
"bytebuffer": "^5.0.1",
"eventemitter2": "^5.0.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/hdwallet-keepkey/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey",
"version": "1.13.2",
"version": "1.13.3",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -16,7 +16,7 @@
},
"dependencies": {
"@keepkey/device-protocol": "^7.0.2",
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"bignumber.js": "^9.0.1",
"eip55": "^1.0.3",
"ethereumjs-tx": "^1.3.7",
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-ledger-u2f/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-ledger-u2f",
"version": "1.13.2",
"version": "1.13.3",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -18,8 +18,8 @@
"@ledgerhq/hw-app-eth": "^4.48.0",
"@ledgerhq/hw-transport": "^4.48.0",
"@ledgerhq/hw-transport-u2f": "^4.48.0",
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-ledger": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"@shapeshiftoss/hdwallet-ledger": "^1.13.3",
"bytebuffer": "^5.0.1",
"eventemitter2": "^5.0.1"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/hdwallet-ledger-webusb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-ledger-webusb",
"version": "1.13.2",
"version": "1.13.3",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -19,8 +19,8 @@
"@ledgerhq/hw-transport": "^4.73.4",
"@ledgerhq/hw-transport-webusb": "^4.73.4",
"@ledgerhq/live-common": "^8.4.1",
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-ledger": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"@shapeshiftoss/hdwallet-ledger": "^1.13.3",
"bytebuffer": "^5.0.1",
"eventemitter2": "^5.0.1"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/hdwallet-ledger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-ledger",
"version": "1.13.2",
"version": "1.13.3",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -17,7 +17,7 @@
"dependencies": {
"@babel/polyfill": "^7.4.0",
"@ledgerhq/live-common": "^8.4.1",
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"base64-js": "^1.3.0",
"bchaddrjs": "^0.4.4",
"bip32-path": "^0.4.2",
Expand Down
9 changes: 9 additions & 0 deletions packages/hdwallet-native/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
preset: "ts-jest",
// testEnvironment: "node",
testPathIgnorePatterns: ["dist"],
globals: {
Uint8Array: Uint8Array,
ArrayBuffer: ArrayBuffer,
},
};
7 changes: 4 additions & 3 deletions packages/hdwallet-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-native",
"version": "1.13.2",
"version": "1.13.3",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -15,8 +15,9 @@
},
"dependencies": {
"@cosmostation/cosmosjs": "^0.9.5",
"@shapeshiftoss/hdwallet-core": "^1.13.2",
"@shapeshiftoss/hdwallet-core": "^1.13.3",
"@terra-money/terra.js": "^1.6.0",
"@zxing/text-encoding": "^0.9.0",
"bchaddrjs": "^0.4.9",
"bignumber.js": "^9.0.1",
"bip32": "^2.0.5",
Expand All @@ -30,7 +31,7 @@
"fiosdk-offline": "^1.2.21",
"lodash": "^4.17.15",
"secretjs-offline": "^0.11.2",
"text-encoding": "^0.7.0"
"web-encoding": "^1.1.0"
},
"devDependencies": {
"@peculiar/webcrypto": "^1.1.3",
Expand Down
17 changes: 12 additions & 5 deletions packages/hdwallet-native/src/binance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function MixinNativeBinanceWalletInfo<TBase extends core.Constructor>(Bas
}

binanceGetAccountPaths(msg: core.BinanceGetAccountPaths): Array<core.BinanceAccountPath> {
const slip44 = core.slip44ByCoin("Binance")
const slip44 = core.slip44ByCoin("Binance");
return [
{
addressNList: [0x80000000 + 44, 0x80000000 + slip44, 0x80000000 + msg.accountIdx, 0, 0],
Expand All @@ -48,7 +48,7 @@ export function MixinNativeBinanceWallet<TBase extends core.Constructor<NativeHD
#wallet: BIP32Interface;

async binanceInitializeWallet(seed: Buffer): Promise<void> {
const network = getNetwork("cosmos");
const network = getNetwork("binance");
this.#wallet = bitcoin.bip32.fromSeed(seed, network);
}

Expand Down Expand Up @@ -86,9 +86,9 @@ export function MixinNativeBinanceWallet<TBase extends core.Constructor<NativeHD
await client.initChain();

const addressFrom = msg.tx?.msgs?.[0]?.inputs?.[0]?.address;
const addressFromVerify = client.getClientKeyAddress()
const addressFromVerify = client.getClientKeyAddress();
if (addressFrom !== addressFromVerify) {
throw Error("Invalid permissions to sign for address")
throw Error("Invalid permissions to sign for address");
}
const addressTo = msg.tx.msgs[0].outputs[0].address;
// The Binance SDK takes amounts as decimal strings.
Expand All @@ -97,7 +97,14 @@ export function MixinNativeBinanceWallet<TBase extends core.Constructor<NativeHD
const asset = "BNB";
const memo = msg.tx.memo;

const result: any = await client.transfer(addressFrom, addressTo, amount.shiftedBy(-8).toString(), asset, memo, msg.sequence ?? null);
const result: any = await client.transfer(
addressFrom,
addressTo,
amount.shiftedBy(-8).toString(),
asset,
memo,
msg.sequence ?? null
);
const aminoPubKey: Buffer = result.signatures[0].pub_key;
const signature = Buffer.from(result.signatures[0].signature, "base64").toString("base64");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("CryptoHelpers", () => {
expect(fromBufferToUtf8(decrypted)).toEqual("totally random secret data");
});

it("should should fail if the mac is incorrect", async () => {
it("should fail if the mac is incorrect", async () => {
const key = await helper.makeKey("password", "email");
const encrypted = await helper.aesEncrypt(toArrayBuffer("totally random secret data"), key);
const mac = new Uint8Array(encrypted.mac.byteLength).fill(128);
Expand Down
12 changes: 11 additions & 1 deletion packages/hdwallet-native/src/crypto/classes/cipherString.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*
Copied from portis: packages/portis-crypto/src/models/cipherString.ts
*/
import { fromBufferToB64 } from "../utils";
import { fromBufferToB64, fromB64ToArray } from "../utils";
import { EncryptedObject } from "./encryptedObject";
import { EncryptionType } from "./encryptionType";
import { SymmetricCryptoKey } from "./symmetricCryptoKey";

export class CipherString {
readonly encryptionType: EncryptionType = EncryptionType.AesCbc256_HmacSha256_B64;
Expand Down Expand Up @@ -44,4 +45,13 @@ export class CipherString {
get encryptedString() {
return `${this.encryptionType}.${[this.data, this.iv, this.mac || ""].join("|")}`;
}

toEncryptedObject(key: SymmetricCryptoKey): EncryptedObject {
return Object.assign(new EncryptedObject(), {
data: fromB64ToArray(this.data),
iv: fromB64ToArray(this.iv),
mac: fromB64ToArray(this.mac),
key,
})
}
}
Loading

1 comment on commit bab11e1

@vercel
Copy link

@vercel vercel bot commented on bab11e1 Apr 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.