diff --git a/.circleci/config.yml b/.circleci/config.yml
index e8f650031..f8896bff9 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -31,6 +31,9 @@ orbs:
no_output_timeout: 30m
name: Build packages
command: yarn build
+ - run:
+ name: Lint
+ command: yarn lint
- run:
name: Run unit tests
command: yarn test --runInBand --coverage=false
diff --git a/.eslintignore b/.eslintignore
new file mode 120000
index 000000000..3e4e48b0b
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1 @@
+.gitignore
\ No newline at end of file
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 000000000..d81c41066
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,82 @@
+{
+ "parser": "@typescript-eslint/parser",
+ "extends": [
+ "eslint:recommended",
+ "plugin:@typescript-eslint/eslint-recommended",
+ "plugin:@typescript-eslint/recommended",
+ "prettier",
+ "plugin:prettier/recommended",
+ "plugin:jest/recommended"
+ ],
+ "plugins": [
+ "@typescript-eslint",
+ "prettier",
+ "jest",
+ "simple-import-sort"
+ ],
+ "env": {
+ "node": true,
+ "browser": true,
+ "jest/globals": true
+ },
+ "globals": {
+ "process": "readonly"
+ },
+ "rules": {
+ "prettier/prettier": "error",
+ "no-console": [
+ "error",
+ {
+ "allow": [
+ "warn",
+ "error",
+ "info",
+ "debug",
+ "group",
+ "groupEnd",
+ "time",
+ "timeEnd"
+ ]
+ }
+ ],
+ "@typescript-eslint/no-use-before-define": "error",
+ "@typescript-eslint/no-shadow": [
+ "error"
+ ],
+ "jest/no-standalone-expect": [
+ "error",
+ {
+ "additionalTestBlockFunctions": [
+ "beforeAll",
+ "beforeEach",
+ "afterEach",
+ "afterAll"
+ ]
+ }
+ ],
+ // TODO: We need to fix these rules later
+ "@typescript-eslint/no-explicit-any": "off",
+ "simple-import-sort/imports": [
+ "error"
+ ]
+ },
+ "overrides": [
+ {
+ "files": [
+ "**/*.test.{j,t}s"
+ ],
+ "rules": {
+ "@typescript-eslint/no-non-null-assertion": "off",
+ "@typescript-eslint/no-var-requires": "off"
+ }
+ },
+ {
+ "files": [
+ "integration/**"
+ ],
+ "rules": {
+ "jest/no-export": "off"
+ }
+ }
+ ]
+}
diff --git a/.gitignore b/.gitignore
index 5b8d877c8..2bc26d059 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,8 @@
!/.circleci
!/.circleci/**
!/.codeclimate.yml
+!/.eslintignore
+!/.eslintrc
!/.gitbook.yaml
!/.github/
!/.github/**
diff --git a/examples/sandbox/index.ts b/examples/sandbox/index.ts
index 5861a9abb..c6a21fd94 100644
--- a/examples/sandbox/index.ts
+++ b/examples/sandbox/index.ts
@@ -1,35 +1,34 @@
+import "regenerator-runtime/runtime";
+
import * as core from "@shapeshiftoss/hdwallet-core";
import * as keepkey from "@shapeshiftoss/hdwallet-keepkey";
import * as keepkeyTcp from "@shapeshiftoss/hdwallet-keepkey-tcp";
import * as keepkeyWebUSB from "@shapeshiftoss/hdwallet-keepkey-webusb";
-import * as ledgerWebUSB from "@shapeshiftoss/hdwallet-ledger-webusb";
import * as ledgerWebHID from "@shapeshiftoss/hdwallet-ledger-webhid";
+import * as ledgerWebUSB from "@shapeshiftoss/hdwallet-ledger-webusb";
+import * as metaMask from "@shapeshiftoss/hdwallet-metamask";
import * as native from "@shapeshiftoss/hdwallet-native";
import * as portis from "@shapeshiftoss/hdwallet-portis";
-import * as metaMask from "@shapeshiftoss/hdwallet-metamask";
-import * as xdefi from "@shapeshiftoss/hdwallet-xdefi";
import * as trezorConnect from "@shapeshiftoss/hdwallet-trezor-connect";
-
-import * as debug from "debug";
+import * as xdefi from "@shapeshiftoss/hdwallet-xdefi";
import $ from "jquery";
-import "regenerator-runtime/runtime";
import Web3 from "web3";
+import * as bnbTxJson from "./json/bnbTx.json";
import * as btcBech32TxJson from "./json/btcBech32Tx.json";
-import * as btcTxJson from "./json/btcTx.json";
import * as btcSegWitTxJson from "./json/btcSegWitTx.json";
+import * as btcTxJson from "./json/btcTx.json";
import * as dashTxJson from "./json/dashTx.json";
import * as dogeTxJson from "./json/dogeTx.json";
import * as ltcTxJson from "./json/ltcTx.json";
import * as rippleTxJson from "./json/rippleTx.json";
-import * as bnbTxJson from "./json/bnbTx.json";
import {
- thorchainUnsignedTx,
+ thorchainBinanceBaseTx,
thorchainBitcoinBaseTx,
thorchainEthereumBaseTx,
- thorchainBinanceBaseTx,
thorchainNativeRuneBaseTx,
thorchainRouterAbi,
+ thorchainUnsignedTx,
} from "./json/thorchainTx.json";
const keyring = new core.Keyring();
@@ -91,6 +90,14 @@ const $metaMask = $("#metaMask");
const $xdefi = $("#xdefi");
const $keyring = $("#keyring");
+const $ethAddr = $("#ethAddr");
+const $ethTx = $("#ethTx");
+const $ethSign = $("#ethSign");
+const $ethSend = $("#ethSend");
+const $ethVerify = $("#ethVerify");
+const $ethResults = $("#ethResults");
+const $ethEIP1559 = $("#ethEIP1559");
+
$keepkey.on("click", async (e) => {
e.preventDefault();
wallet = await keepkeyAdapter.pairDevice(undefined, /*tryDebugLink=*/ true);
@@ -141,8 +148,8 @@ $portis.on("click", async (e) => {
let deviceId = "nothing";
try {
deviceId = await wallet.getDeviceID();
- } catch (e) {
- console.error(e);
+ } catch (error) {
+ console.error(error);
}
$("#keyring select").val(deviceId);
});
@@ -162,8 +169,8 @@ $metaMask.on("click", async (e) => {
try {
deviceID = await wallet.getDeviceID();
$("#keyring select").val(deviceID);
- } catch (e) {
- console.error(e);
+ } catch (error) {
+ console.error(error);
}
});
$xdefi.on("click", async (e) => {
@@ -174,8 +181,8 @@ $xdefi.on("click", async (e) => {
try {
deviceID = await wallet.getDeviceID();
$("#keyring select").val(deviceID);
- } catch (e) {
- console.error(e);
+ } catch (error) {
+ console.error(error);
}
});
@@ -198,8 +205,8 @@ async function deviceConnected(deviceId) {
keyring.onAny((name: string[], ...values: any[]) => {
const [[deviceId, event]] = values;
const { from_wallet = false, message_type } = event;
- let direction = from_wallet ? "🔑" : "💻";
- debug.default(deviceId)(`${direction} ${message_type}`, event);
+ const direction = from_wallet ? "🔑" : "💻";
+ console.debug(`${deviceId} ${direction} ${message_type}`, event);
const log = document.getElementById("eventLog");
log.innerHTML += `
Event: ${name}
Values: ${JSON.stringify(values)}
`;
@@ -263,17 +270,17 @@ async function deviceConnected(deviceId) {
for (const deviceID of Object.keys(keyring.wallets)) {
await deviceConnected(deviceID);
}
- $keyring.change(async (e) => {
+ $keyring.change(async () => {
if (wallet) {
await wallet.disconnect();
}
- let deviceID = $keyring.find(":selected").val() as string;
+ const deviceID = $keyring.find(":selected").val() as string;
wallet = keyring.get(deviceID);
if (wallet) {
if (wallet.transport) {
await wallet.transport.connect();
if (keepkey.isKeepKey(wallet)) {
- console.log("try connect debuglink");
+ console.info("try connect debuglink");
await wallet.transport.tryConnectDebugLink();
}
}
@@ -287,13 +294,13 @@ async function deviceConnected(deviceId) {
wallet = keyring.get();
window["wallet"] = wallet;
if (wallet) {
- let deviceID = await wallet.getDeviceID();
+ const deviceID = await wallet.getDeviceID();
$keyring.val(deviceID).change();
}
})();
window["handlePinDigit"] = function (digit) {
- let input = document.getElementById("#pinInput") as HTMLInputElement;
+ const input = document.getElementById("#pinInput") as HTMLInputElement;
if (digit === "") {
input.value = input.value.slice(0, -1);
} else {
@@ -306,7 +313,7 @@ window["pinOpen"] = function () {
};
window["pinEntered"] = function () {
- let input = document.getElementById("#pinInput") as HTMLInputElement;
+ const input = document.getElementById("#pinInput") as HTMLInputElement;
wallet.sendPin(input.value);
document.getElementById("#pinModal").className = "modal";
};
@@ -316,7 +323,7 @@ window["passphraseOpen"] = function () {
};
window["passphraseEntered"] = function () {
- let input = document.getElementById("#passphraseInput") as HTMLInputElement;
+ const input = document.getElementById("#passphraseInput") as HTMLInputElement;
wallet.sendPassphrase(input.value);
document.getElementById("#passphraseModal").className = "modal";
};
@@ -326,13 +333,15 @@ window["mnemonicOpen"] = function () {
};
window["mnemonicEntered"] = async function () {
- let input = document.getElementById("#mnemonicInput") as HTMLInputElement;
+ const input = document.getElementById("#mnemonicInput") as HTMLInputElement;
wallet.loadDevice({ mnemonic: input.value });
document.getElementById("#mnemonicModal").className = "modal";
};
window["useTestWallet"] = async function () {
- wallet.loadDevice({ mnemonic: await native.crypto.Isolation.Engines.Dummy.BIP39.Mnemonic.create(testPublicWalletXpubs) });
+ wallet.loadDevice({
+ mnemonic: await native.crypto.Isolation.Engines.Dummy.BIP39.Mnemonic.create(testPublicWalletXpubs),
+ });
document.getElementById("#mnemonicModal").className = "modal";
};
@@ -383,7 +392,7 @@ $getVendor.on("click", async (e) => {
$manageResults.val("No wallet?");
return;
}
- let vendor = await wallet.getVendor();
+ const vendor = await wallet.getVendor();
$manageResults.val(vendor);
});
@@ -393,7 +402,7 @@ $getModel.on("click", async (e) => {
$manageResults.val("No wallet?");
return;
}
- let model = await wallet.getModel();
+ const model = await wallet.getModel();
$manageResults.val(model);
});
@@ -403,7 +412,7 @@ $getDeviceID.on("click", async (e) => {
$manageResults.val("No wallet?");
return;
}
- let deviceID = await wallet.getDeviceID();
+ const deviceID = await wallet.getDeviceID();
$manageResults.val(deviceID);
});
@@ -413,7 +422,7 @@ $getFirmware.on("click", async (e) => {
$manageResults.val("No wallet?");
return;
}
- let firmware = await wallet.getFirmwareVersion();
+ const firmware = await wallet.getFirmwareVersion();
$manageResults.val(firmware);
});
@@ -423,7 +432,7 @@ $getLabel.on("click", async (e) => {
$manageResults.val("No wallet?");
return;
}
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$manageResults.val(label);
});
@@ -594,7 +603,7 @@ $binanceAddr.on("click", async (e) => {
return;
}
if (core.supportsBinance(wallet)) {
- let { addressNList } = wallet.binanceGetAccountPaths({ accountIdx: 0 })[0];
+ const { addressNList } = wallet.binanceGetAccountPaths({ accountIdx: 0 })[0];
let result = await wallet.binanceGetAddress({
addressNList,
showDisplay: false,
@@ -606,7 +615,7 @@ $binanceAddr.on("click", async (e) => {
});
$binanceResults.val(result);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$binanceResults.val(label + " does not support Binance");
}
});
@@ -618,7 +627,7 @@ $binanceTx.on("click", async (e) => {
return;
}
if (core.supportsBinance(wallet)) {
- let res = await wallet.binanceSignTx({
+ const res = await wallet.binanceSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/714'/0'/0/0`),
chain_id: "Binance-Chain-Nile",
account_number: "24250",
@@ -627,7 +636,7 @@ $binanceTx.on("click", async (e) => {
});
$binanceResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$binanceResults.val(label + " does not support Cosmos");
}
});
@@ -646,14 +655,14 @@ $rippleAddr.on("click", async (e) => {
return;
}
if (core.supportsRipple(wallet)) {
- let { addressNList } = wallet.rippleGetAccountPaths({ accountIdx: 0 })[0];
- let result = await wallet.rippleGetAddress({
+ const { addressNList } = wallet.rippleGetAccountPaths({ accountIdx: 0 })[0];
+ const result = await wallet.rippleGetAddress({
addressNList,
showDisplay: true,
});
$rippleResults.val(result);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$rippleResults.val(label + " does not support Ripple");
}
});
@@ -665,7 +674,7 @@ $rippleTx.on("click", async (e) => {
return;
}
if (core.supportsRipple(wallet)) {
- let res = await wallet.rippleSignTx({
+ const res = await wallet.rippleSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/144'/0'/0/0`),
tx: rippleTxJson,
flags: undefined,
@@ -679,7 +688,7 @@ $rippleTx.on("click", async (e) => {
});
$rippleResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$rippleResults.val(label + " does not support Ripple");
}
});
@@ -698,7 +707,7 @@ $eosAddr.on("click", async (e) => {
return;
}
if (core.supportsEos(wallet)) {
- let { addressNList } = wallet.eosGetAccountPaths({ accountIdx: 0 })[0];
+ const { addressNList } = wallet.eosGetAccountPaths({ accountIdx: 0 })[0];
let result = await wallet.eosGetPublicKey({
addressNList,
showDisplay: false,
@@ -710,7 +719,7 @@ $eosAddr.on("click", async (e) => {
});
$eosResults.val(result);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$eosResults.val(label + " does not support Eos");
}
});
@@ -722,7 +731,7 @@ $eosTx.on("click", async (e) => {
return;
}
if (core.supportsEos(wallet)) {
- let unsigned_main = {
+ const unsigned_main = {
expiration: "2020-04-30T22:00:00.000",
ref_block_num: 54661,
ref_block_prefix: 2118672142,
@@ -750,26 +759,26 @@ $eosTx.on("click", async (e) => {
],
};
- let chainid_main = "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906";
- let res = await wallet.eosSignTx({
+ const chainid_main = "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906";
+ const res = await wallet.eosSignTx({
addressNList: core.bip32ToAddressNList("m/44'/194'/0'/0/0"),
chain_id: chainid_main,
tx: unsigned_main,
});
- console.log(res);
- console.log("sigV = %d", res.signatureV);
- console.log("sigR = %s", core.toHexString(res.signatureR));
- console.log("sigS = %s", core.toHexString(res.signatureS));
- console.log("hash = %s", core.toHexString(res.hash));
- console.log("EosFormatSig = %s", res.eosFormSig);
- console.log(
+ console.info(res);
+ console.info("sigV = %d", res.signatureV);
+ console.info("sigR = %s", core.toHexString(res.signatureR));
+ console.info("sigS = %s", core.toHexString(res.signatureS));
+ console.info("hash = %s", core.toHexString(res.hash));
+ console.info("EosFormatSig = %s", res.eosFormSig);
+ console.info(
"EosFormReSig = SIG_K1_Jxa7NRL1hj4Q9wqufaSZa7oAXQQnRxSuAeFSwx6EzHnzPVeB5y6qQge16WCYa3Xod1mDWZv3MnEEPFeK3bEf3iN6es1iVy"
);
$eosResults.val(res.eosFormSig);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$eosResults.val(label + " does not support Eos");
}
});
@@ -788,7 +797,7 @@ $fioAddr.on("click", async (e) => {
return;
}
if (core.supportsFio(wallet)) {
- let { addressNList } = wallet.fioGetAccountPaths({ accountIdx: 0 })[0];
+ const { addressNList } = wallet.fioGetAccountPaths({ accountIdx: 0 })[0];
let result = await wallet.fioGetPublicKey({
addressNList,
showDisplay: false,
@@ -802,7 +811,7 @@ $fioAddr.on("click", async (e) => {
});
$fioResults.val(result);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$fioResults.val(label + " does not support ");
}
});
@@ -814,7 +823,7 @@ $fioTx.on("click", async (e) => {
return;
}
if (core.supportsFio(wallet)) {
- let unsigned_main = {
+ const unsigned_main = {
expiration: "2020-04-30T22:00:00.000",
ref_block_num: 54661,
ref_block_prefix: 2118672142,
@@ -825,20 +834,20 @@ $fioTx.on("click", async (e) => {
actions: [],
};
- let chainid_main = "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906";
- let res = await wallet.fioSignTx({
+ const chainid_main = "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906";
+ const res = await wallet.fioSignTx({
addressNList: core.bip32ToAddressNList("m/44'/194'/0'/0/0"),
chain_id: chainid_main,
tx: unsigned_main,
});
- console.log(res);
- console.log("signature = %d", res.signature);
- console.log("serialized = %s", core.toHexString(res.serialized));
+ console.info(res);
+ console.info("signature = %d", res.signature);
+ console.info("serialized = %s", core.toHexString(res.serialized));
$eosResults.val(res.fioFormSig);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$fioResults.val(label + " does not support Fio");
}
});
@@ -857,8 +866,8 @@ $cosmosAddr.on("click", async (e) => {
return;
}
if (core.supportsCosmos(wallet)) {
- let { addressNList } = wallet.cosmosGetAccountPaths({ accountIdx: 0 })[0];
- let result = await wallet.cosmosGetAddress({
+ const { addressNList } = wallet.cosmosGetAccountPaths({ accountIdx: 0 })[0];
+ const result = await wallet.cosmosGetAddress({
addressNList,
showDisplay: false,
});
@@ -868,7 +877,7 @@ $cosmosAddr.on("click", async (e) => {
});
$cosmosResults.val(result);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$cosmosResults.val(label + " does not support Cosmos");
}
});
@@ -880,7 +889,7 @@ $cosmosTx.on("click", async (e) => {
return;
}
if (core.supportsCosmos(wallet)) {
- let unsigned: core.Cosmos.StdTx = {
+ const unsigned: core.Cosmos.StdTx = {
memo: "KeepKey",
fee: {
amount: [{ amount: "100", denom: "ATOM" }],
@@ -904,7 +913,7 @@ $cosmosTx.on("click", async (e) => {
signatures: null,
};
- let res = await wallet.cosmosSignTx({
+ const res = await wallet.cosmosSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/118'/0'/0/0`),
chain_id: "cosmoshub-2",
account_number: "24250",
@@ -913,7 +922,7 @@ $cosmosTx.on("click", async (e) => {
});
$cosmosResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$cosmosResults.val(label + " does not support Cosmos");
}
});
@@ -944,8 +953,8 @@ $thorchainAddr.on("click", async (e) => {
return;
}
if (core.supportsThorchain(wallet)) {
- let { addressNList } = wallet.thorchainGetAccountPaths({ accountIdx: 0 })[0];
- let result = await wallet.thorchainGetAddress({
+ const { addressNList } = wallet.thorchainGetAccountPaths({ accountIdx: 0 })[0];
+ const result = await wallet.thorchainGetAddress({
addressNList,
showDisplay: false,
});
@@ -955,7 +964,7 @@ $thorchainAddr.on("click", async (e) => {
});
$thorchainNativeResults.val(result);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainNativeResults.val(label + " does not support THORChain");
}
});
@@ -967,7 +976,7 @@ $thorchainTx.on("click", async (e) => {
return;
}
if (core.supportsThorchain(wallet)) {
- let res = await wallet.thorchainSignTx({
+ const res = await wallet.thorchainSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/931'/0'/0/0`),
chain_id: "thorchain",
account_number: "24250",
@@ -976,7 +985,7 @@ $thorchainTx.on("click", async (e) => {
});
$thorchainNativeResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainNativeResults.val(label + " does not support THORChain");
}
});
@@ -988,7 +997,7 @@ $thorchainSignSwap.on("click", async (e) => {
return;
}
if (!$thorchainDestAddress.val().match(/^[a-z0-9]+$/i) && $thorchainDestAddress.val() != "") {
- console.log($thorchainDestAddress.val());
+ console.info($thorchainDestAddress.val());
$thorchainSwapResults.val("Invalid destination address");
return;
}
@@ -999,8 +1008,7 @@ $thorchainSignSwap.on("click", async (e) => {
const routerContractAddress = "0x0000000000000000000000000000000000000000";
const vaultAddress = "0x0000000000000000000000000000000000000000";
let tx = {};
- let res = {};
- let memo = `SWAP:${$thorchainDestChain.val()}:${$thorchainDestAddress.val()}:${$thorchainAmount.val()}`;
+ const memo = `SWAP:${$thorchainDestChain.val()}:${$thorchainDestAddress.val()}:${$thorchainAmount.val()}`;
switch ($thorchainSourceChain.val()) {
case "BTC.BTC":
tx = thorchainBitcoinBaseTx;
@@ -1010,7 +1018,7 @@ $thorchainSignSwap.on("click", async (e) => {
const hex =
"010000000181f605ead676d8182975c16e7191c21d833972dd0ed50583ce4628254d28b6a3010000008a47304402207f3220930276204c83b1740bae1da18e5a3fa2acad34944ecdc3b361b419e3520220598381bdf8273126e11460a8c720afdbb679233123d2d4e94561f75e9b280ce30141045da61d81456b6d787d576dce817a2d61d7f8cb4623ee669cbe711b0bcff327a3797e3da53a2b4e3e210535076c087c8fb98aef60e42dfeea8388435fc99dca43ffffffff0250ec0e00000000001976a914f7b9e0239571434f0ccfdba6f772a6d23f2cfb1388ac10270000000000001976a9149c9d21f47382762df3ad81391ee0964b28dd951788ac00000000";
- let inputs = [
+ const inputs = [
{
addressNList: [0x80000000 + 44, 0x80000000 + 0, 0x80000000 + 0, 0, 0],
scriptType: core.BTCInputScriptType.SpendAddress,
@@ -1022,7 +1030,7 @@ $thorchainSignSwap.on("click", async (e) => {
},
];
- let outputs = [
+ const outputs = [
{
address: "bc1q6m9u2qsu8mh8y7v8rr2ywavtj8g5arzlyhcej7",
addressType: core.BTCOutputAddressType.Spend,
@@ -1032,7 +1040,7 @@ $thorchainSignSwap.on("click", async (e) => {
},
];
- let res = await wallet.btcSignTx({
+ const res = await wallet.btcSignTx({
coin: "Bitcoin",
inputs: inputs,
outputs: outputs,
@@ -1043,24 +1051,24 @@ $thorchainSignSwap.on("click", async (e) => {
$thorchainSwapResults.val(res.serializedTx);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainSwapResults.val(label + " does not support BTC");
}
break;
case "ETH.ETH":
if (core.supportsETH(wallet)) {
const web3 = new Web3();
- console.log(thorchainRouterAbi[0]);
+ console.info(thorchainRouterAbi[0]);
const routerContract = new web3.eth.Contract(thorchainRouterAbi, routerContractAddress);
tx = thorchainEthereumBaseTx;
tx["addressNList"] = core.bip32ToAddressNList("m/44'/60'/0'/0/0");
tx["data"] = routerContract.methods
.deposit(vaultAddress, "0x0000000000000000000000000000000000000000", 0, memo)
.encodeABI();
- res = await wallet.ethSignTx(tx as any);
+ const res = await wallet.ethSignTx(tx as any);
$thorchainSwapResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainSwapResults.val(label + " does not support ETH");
}
break;
@@ -1068,8 +1076,8 @@ $thorchainSignSwap.on("click", async (e) => {
if (core.supportsBinance(wallet)) {
tx = thorchainBinanceBaseTx;
tx["memo"] = memo;
- console.log(tx);
- let res = await wallet.binanceSignTx({
+ console.info(tx);
+ const res = await wallet.binanceSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/714'/0'/0/0`),
chain_id: "Binance-Chain-Nile",
account_number: "24250",
@@ -1078,7 +1086,7 @@ $thorchainSignSwap.on("click", async (e) => {
});
$thorchainSwapResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainSwapResults.val(label + " does not support Cosmos");
}
break;
@@ -1086,8 +1094,8 @@ $thorchainSignSwap.on("click", async (e) => {
if (core.supportsBinance(wallet)) {
tx = thorchainNativeRuneBaseTx;
tx["memo"] = memo;
- console.log(tx);
- let res = await wallet.binanceSignTx({
+ console.info(tx);
+ const res = await wallet.binanceSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/714'/0'/0/0`),
chain_id: "Binance-Chain-Nile",
account_number: "24250",
@@ -1096,7 +1104,7 @@ $thorchainSignSwap.on("click", async (e) => {
});
$thorchainSwapResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainSwapResults.val(label + " does not support Cosmos");
}
break;
@@ -1104,8 +1112,8 @@ $thorchainSignSwap.on("click", async (e) => {
if (core.supportsThorchain(wallet)) {
tx = thorchainUnsignedTx;
tx["memo"] = memo;
- console.log(tx);
- let res = await wallet.thorchainSignTx({
+ console.info(tx);
+ const res = await wallet.thorchainSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/931'/0'/0/0`),
chain_id: "thorchain",
account_number: "24250",
@@ -1114,7 +1122,7 @@ $thorchainSignSwap.on("click", async (e) => {
});
$thorchainSwapResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainSwapResults.val(label + " does not support Cosmos");
}
break;
@@ -1123,16 +1131,16 @@ $thorchainSignSwap.on("click", async (e) => {
tx = thorchainEthereumBaseTx;
tx["addressNList"] = core.bip32ToAddressNList("m/44'/60'/0'/0/0");
tx["data"] = "0x";
- res = await wallet.ethSignTx(tx as any);
+ const res = await wallet.ethSignTx(tx as any);
$thorchainSwapResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$ethResults.val(label + " does not support ETH");
}
break;
default:
- console.log("Base coin is Unknown.");
- console.log("val:", $thorchainSourceChain.val());
+ console.info("Base coin is Unknown.");
+ console.info("val:", $thorchainSourceChain.val());
$thorchainSwapResults.val("Invalid source chain");
return;
}
@@ -1147,7 +1155,7 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
return;
}
if (!$thorchainDestAddress.val().match(/^[a-z0-9]+$/i) && $thorchainDestAddress.val() != "") {
- console.log($thorchainDestAddress.val());
+ console.info($thorchainDestAddress.val());
$thorchainAddLiquidityResults.val("Invalid destination address");
return;
}
@@ -1158,8 +1166,7 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
const routerContractAddress = "0x0000000000000000000000000000000000000000";
const vaultAddress = "0x0000000000000000000000000000000000000000";
let tx = {};
- let res = {};
- let memo = `ADD:${$thorchainLiquidityAsset.val()}:${$thorchainLiquidityPoolAddress.val()}}`;
+ const memo = `ADD:${$thorchainLiquidityAsset.val()}:${$thorchainLiquidityPoolAddress.val()}}`;
switch ($thorchainLiquidityAsset.val()) {
case "BTC.BTC":
tx = thorchainBitcoinBaseTx;
@@ -1169,7 +1176,7 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
const hex =
"010000000181f605ead676d8182975c16e7191c21d833972dd0ed50583ce4628254d28b6a3010000008a47304402207f3220930276204c83b1740bae1da18e5a3fa2acad34944ecdc3b361b419e3520220598381bdf8273126e11460a8c720afdbb679233123d2d4e94561f75e9b280ce30141045da61d81456b6d787d576dce817a2d61d7f8cb4623ee669cbe711b0bcff327a3797e3da53a2b4e3e210535076c087c8fb98aef60e42dfeea8388435fc99dca43ffffffff0250ec0e00000000001976a914f7b9e0239571434f0ccfdba6f772a6d23f2cfb1388ac10270000000000001976a9149c9d21f47382762df3ad81391ee0964b28dd951788ac00000000";
- let inputs = [
+ const inputs = [
{
addressNList: [0x80000000 + 44, 0x80000000 + 0, 0x80000000 + 0, 0, 0],
scriptType: core.BTCInputScriptType.SpendAddress,
@@ -1181,7 +1188,7 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
},
];
- let outputs = [
+ const outputs = [
{
addressType: core.BTCOutputAddressType.Spend,
opReturnData: Buffer.from(memo, "utf-8"),
@@ -1190,7 +1197,7 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
},
];
- let res = await wallet.btcSignTx({
+ const res = await wallet.btcSignTx({
coin: "Bitcoin",
inputs: inputs,
outputs: outputs,
@@ -1200,14 +1207,14 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
$thorchainAddLiquidityResults.val(res.serializedTx);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainAddLiquidityResults.val(label + " does not support BTC");
}
break;
case "ETH.ETH":
if (core.supportsETH(wallet)) {
const web3 = new Web3();
- console.log(thorchainRouterAbi[0]);
+ console.info(thorchainRouterAbi[0]);
const routerContract = new web3.eth.Contract(thorchainRouterAbi, routerContractAddress);
tx = thorchainEthereumBaseTx;
tx["value"] = "0x" + $thorchainLiquidityAmount.val().toString(16);
@@ -1215,11 +1222,11 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
tx["data"] = routerContract.methods
.deposit(vaultAddress, "0x0000000000000000000000000000000000000000", 0, memo)
.encodeABI();
- console.log(tx);
- res = await wallet.ethSignTx(tx as any);
+ console.info(tx);
+ const res = await wallet.ethSignTx(tx as any);
$thorchainAddLiquidityResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainAddLiquidityResults.val(label + " does not support ETH");
}
break;
@@ -1231,7 +1238,7 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
address: $thorchainLiquidityPoolAddress.val(),
coins: [{ amount: $thorchainLiquidityAmount.val(), denom: "BNB" }],
};
- let res = await wallet.binanceSignTx({
+ const res = await wallet.binanceSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/714'/0'/0/0`),
chain_id: "Binance-Chain-Nile",
account_number: "24250",
@@ -1240,7 +1247,7 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
});
$thorchainAddLiquidityResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainAddLiquidityResults.val(label + " does not support Cosmos");
}
break;
@@ -1252,7 +1259,7 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
address: $thorchainLiquidityPoolAddress.val(),
coins: [{ amount: $thorchainLiquidityAmount.val(), denom: "BNB" }],
};
- let res = await wallet.binanceSignTx({
+ const res = await wallet.binanceSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/714'/0'/0/0`),
chain_id: "Binance-Chain-Nile",
account_number: "24250",
@@ -1261,7 +1268,7 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
});
$thorchainAddLiquidityResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainAddLiquidityResults.val(label + " does not support Cosmos");
}
break;
@@ -1273,8 +1280,8 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
address: $thorchainLiquidityPoolAddress.val(),
coins: [{ amount: $thorchainLiquidityAmount.val(), denom: "RUNE" }],
};
- console.log(tx);
- let res = await wallet.thorchainSignTx({
+ console.info(tx);
+ const res = await wallet.thorchainSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/931'/0'/0/0`),
chain_id: "thorchain",
account_number: "24250",
@@ -1283,7 +1290,7 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
});
$thorchainAddLiquidityResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$thorchainAddLiquidityResults.val(label + " does not support Cosmos");
}
break;
@@ -1294,16 +1301,16 @@ $thorchainSignAddLiquidity.on("click", async (e) => {
tx["data"] = "0x";
tx["to"] = $thorchainLiquidityPoolAddress.val();
tx["value"] = $thorchainLiquidityAmount.val();
- res = await wallet.ethSignTx(tx as any);
+ const res = await wallet.ethSignTx(tx as any);
$thorchainAddLiquidityResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$ethResults.val(label + " does not support ETH");
}
break;
default:
- console.log("Base coin is Unknown.");
- console.log("val:", $thorchainSourceChain.val());
+ console.info("Base coin is Unknown.");
+ console.info("val:", $thorchainSourceChain.val());
$thorchainAddLiquidityResults.val("Invalid source chain");
return;
}
@@ -1336,8 +1343,8 @@ $osmosisAddress.on("click", async (e) => {
return;
}
if (core.supportsOsmosis(wallet)) {
- let { addressNList } = wallet.osmosisGetAccountPaths({ accountIdx: 0 })[0];
- let result = await wallet.osmosisGetAddress({
+ const { addressNList } = wallet.osmosisGetAccountPaths({ accountIdx: 0 })[0];
+ const result = await wallet.osmosisGetAddress({
addressNList,
showDisplay: false,
});
@@ -1347,7 +1354,7 @@ $osmosisAddress.on("click", async (e) => {
});
$osmosisAddressResults.val(result);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$osmosisAddressResults.val(label + " does not support Osmosis");
}
});
@@ -1359,7 +1366,7 @@ $osmosisSignTx.on("click", async (e) => {
return;
}
if (core.supportsOsmosis(wallet)) {
- let res = await wallet.osmosisSignTx({
+ const res = await wallet.osmosisSignTx({
tx: {
chain_id: "osmosis",
account_number: "75815",
@@ -1399,7 +1406,7 @@ $osmosisSignTx.on("click", async (e) => {
});
$osmosisSignTxResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$osmosisSignTxResults.val(label + " does not support Osmosis");
}
});
@@ -1411,7 +1418,7 @@ $osmosisDelegate.on("click", async (e) => {
return;
}
if (core.supportsOsmosis(wallet)) {
- let res = await wallet.osmosisSignTx({
+ const res = await wallet.osmosisSignTx({
tx: {
fee: {
amount: [
@@ -1445,7 +1452,7 @@ $osmosisDelegate.on("click", async (e) => {
});
$osmosisDelegateResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$osmosisDelegateResults.val(label + " does not support Osmosis");
}
});
@@ -1457,7 +1464,7 @@ $osmosisUndelegate.on("click", async (e) => {
return;
}
if (core.supportsOsmosis(wallet)) {
- let res = await wallet.osmosisSignTx({
+ const res = await wallet.osmosisSignTx({
tx: {
fee: {
amount: [
@@ -1492,7 +1499,7 @@ $osmosisUndelegate.on("click", async (e) => {
});
$osmosisUndelegateResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$osmosisUndelegateResults.val(label + " does not support Osmosis");
}
});
@@ -1504,13 +1511,6 @@ $osmosisUndelegate.on("click", async (e) => {
* Bech32: false
*/
-const $ethAddr = $("#ethAddr");
-const $ethTx = $("#ethTx");
-const $ethSign = $("#ethSign");
-const $ethSend = $("#ethSend");
-const $ethVerify = $("#ethVerify");
-const $ethResults = $("#ethResults");
-const $ethEIP1559 = $("#ethEIP1559");
let ethEIP1559Selected = false;
@@ -1545,7 +1545,7 @@ $ethAddr.on("click", async (e) => {
}
if (core.supportsETH(wallet)) {
- let { hardenedPath, relPath } = wallet.ethGetAccountPaths({
+ const { hardenedPath, relPath } = wallet.ethGetAccountPaths({
coin: "Ethereum",
accountIdx: 0,
})[0];
@@ -1560,7 +1560,7 @@ $ethAddr.on("click", async (e) => {
});
$ethResults.val(result);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$ethResults.val(label + " does not support ETH");
}
});
@@ -1572,10 +1572,10 @@ $ethTx.on("click", async (e) => {
return;
}
if (core.supportsETH(wallet)) {
- let res = ethEIP1559Selected ? await wallet.ethSignTx(ethTx1559) : await wallet.ethSignTx(ethTx);
+ const res = ethEIP1559Selected ? await wallet.ethSignTx(ethTx1559) : await wallet.ethSignTx(ethTx);
$ethResults.val(JSON.stringify(res));
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$ethResults.val(label + " does not support ETH");
}
});
@@ -1587,17 +1587,17 @@ $ethSign.on("click", async (e) => {
return;
}
if (core.supportsETH(wallet)) {
- let { hardenedPath: hard, relPath: rel } = wallet.ethGetAccountPaths({
+ const { hardenedPath: hard, relPath: rel } = wallet.ethGetAccountPaths({
coin: "Ethereum",
accountIdx: 0,
})[0];
- let result = await wallet.ethSignMessage({
+ const result = await wallet.ethSignMessage({
addressNList: hard.concat(rel),
message: "Hello World",
});
$ethResults.val(result.address + ", " + result.signature);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$ethResults.val(label + " does not support ETH");
}
});
@@ -1609,17 +1609,13 @@ $ethSend.on("click", async (e) => {
return;
}
if (core.supportsETH(wallet)) {
- let { hardenedPath: hard, relPath: rel } = wallet.ethGetAccountPaths({
- coin: "Ethereum",
- accountIdx: 0,
- })[0];
- let result = ethEIP1559Selected
+ const result = ethEIP1559Selected
? await wallet.ethSendTx(ethTx1559 as core.ETHSignTx)
: await wallet.ethSendTx(ethTx as core.ETHSignTx);
- console.log("Result: ", result);
+ console.info("Result: ", result);
$ethResults.val(result.hash);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$ethResults.val(label + " does not support ETH");
}
});
@@ -1631,7 +1627,7 @@ $ethVerify.on("click", async (e) => {
return;
}
if (core.supportsETH(wallet)) {
- let result = await wallet.ethVerifyMessage({
+ const result = await wallet.ethVerifyMessage({
address: "0x2068dD92B6690255553141Dfcf00dF308281f763",
message: "Hello World",
signature:
@@ -1639,12 +1635,12 @@ $ethVerify.on("click", async (e) => {
});
$ethResults.val(result ? "✅" : "❌");
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$ethResults.val(label + " does not support ETH");
}
});
-$ethEIP1559.on("click", async (e) => {
+$ethEIP1559.on("click", async () => {
if (!ethEIP1559Selected) {
$ethEIP1559.attr("class", "button");
} else {
@@ -1783,7 +1779,7 @@ $erc20TransferFrom.on("click", async (e) => {
erc20SetSetSelected($erc20TransferFrom);
});
-$erc20Submit.on("click", async (e) => {
+$erc20Submit.on("click", async () => {
if (!wallet) {
$erc20Results.val("No wallet?");
return;
@@ -1793,7 +1789,7 @@ $erc20Submit.on("click", async (e) => {
let data: any;
if (core.supportsETH(wallet)) {
- let { hardenedPath, relPath } = wallet.ethGetAccountPaths({
+ const { hardenedPath, relPath } = wallet.ethGetAccountPaths({
coin: "Ethereum",
accountIdx: 0,
})[0];
@@ -1851,7 +1847,7 @@ $erc20Submit.on("click", async (e) => {
parseInt($("#erc20Amount").val(), 10).toString(16).padStart(64, "0");
break;
default:
- console.log("oops", erc20Selected);
+ console.info("oops", erc20Selected);
return;
}
if (erc20Selected != $erc20Addr) {
@@ -1871,7 +1867,7 @@ $erc20Submit.on("click", async (e) => {
$erc20Results.val(label + " does not support ETH");
}
- console.log(result);
+ console.info(result);
$erc20Results.val(JSON.stringify(result, null, 4));
});
@@ -1896,7 +1892,7 @@ $btcAddr.on("click", async (e) => {
if (core.supportsBTC(wallet)) {
//coin 0 (mainnet bitcoin)
//path 0
- let res = await wallet.btcGetAddress({
+ const res = await wallet.btcGetAddress({
addressNList: [0x80000000 + 44, 0x80000000 + 0, 0x80000000 + 0, 0, 0],
coin: "Bitcoin",
scriptType: core.BTCInputScriptType.SpendAddress,
@@ -1904,7 +1900,7 @@ $btcAddr.on("click", async (e) => {
});
$btcResults.val(res);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$btcResults.val(label + " does not support BTC");
}
});
@@ -1921,7 +1917,7 @@ $btcTx.on("click", async (e) => {
const hex =
"010000000181f605ead676d8182975c16e7191c21d833972dd0ed50583ce4628254d28b6a3010000008a47304402207f3220930276204c83b1740bae1da18e5a3fa2acad34944ecdc3b361b419e3520220598381bdf8273126e11460a8c720afdbb679233123d2d4e94561f75e9b280ce30141045da61d81456b6d787d576dce817a2d61d7f8cb4623ee669cbe711b0bcff327a3797e3da53a2b4e3e210535076c087c8fb98aef60e42dfeea8388435fc99dca43ffffffff0250ec0e00000000001976a914f7b9e0239571434f0ccfdba6f772a6d23f2cfb1388ac10270000000000001976a9149c9d21f47382762df3ad81391ee0964b28dd951788ac00000000";
- let inputs = [
+ const inputs = [
{
addressNList: [0x80000000 + 44, 0x80000000 + 0, 0x80000000 + 0, 0, 0],
scriptType: core.BTCInputScriptType.SpendAddress,
@@ -1933,7 +1929,7 @@ $btcTx.on("click", async (e) => {
},
];
- let outputs = [
+ const outputs = [
{
address: "1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1",
addressType: core.BTCOutputAddressType.Spend,
@@ -1943,7 +1939,7 @@ $btcTx.on("click", async (e) => {
},
];
- let res = await wallet.btcSignTx({
+ const res = await wallet.btcSignTx({
coin: "Bitcoin",
inputs: inputs,
outputs: outputs,
@@ -1953,7 +1949,7 @@ $btcTx.on("click", async (e) => {
$btcResults.val(res.serializedTx);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$btcResults.val(label + " does not support BTC");
}
});
@@ -1965,7 +1961,7 @@ $btcSign.on("click", async (e) => {
return;
}
if (core.supportsBTC(wallet)) {
- let res = await wallet.btcSignMessage({
+ const res = await wallet.btcSignMessage({
addressNList: core.bip32ToAddressNList("m/44'/0'/0'/0/0"),
coin: "Bitcoin",
scriptType: core.BTCInputScriptType.SpendAddress,
@@ -1973,7 +1969,7 @@ $btcSign.on("click", async (e) => {
});
$btcResults.val(res.address + " " + res.signature);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$btcResults.val(label + " does not support BTC");
}
});
@@ -1985,7 +1981,7 @@ $btcVerify.on("click", async (e) => {
return;
}
if (core.supportsBTC(wallet)) {
- let res = await wallet.btcVerifyMessage({
+ const res = await wallet.btcVerifyMessage({
address: "1FH6ehAd5ZFXCM1cLGzHxK1s4dGdq1JusM",
coin: "Bitcoin",
signature:
@@ -1994,7 +1990,7 @@ $btcVerify.on("click", async (e) => {
});
$btcResults.val(res ? "✅" : "❌");
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$btcResults.val(label + " does not support BTC");
}
});
@@ -2008,7 +2004,6 @@ $btcVerify.on("click", async (e) => {
const $ltcAddr = $("#ltcAddr");
const $ltcTx = $("#ltcTx");
const $ltcSign = $("#ltcSign");
-const $ltcVerify = $("#ltcVerify");
const $ltcResults = $("#ltcResults");
const ltcBip44 = {
@@ -2023,7 +2018,7 @@ $ltcAddr.on("click", async (e) => {
return;
}
if (core.supportsBTC(wallet)) {
- let res = await wallet.btcGetAddress({
+ const res = await wallet.btcGetAddress({
addressNList: ltcBip44.addressNList,
coin: "Litecoin",
scriptType: ltcBip44.scriptType,
@@ -2031,7 +2026,7 @@ $ltcAddr.on("click", async (e) => {
});
$ltcResults.val(res);
} else {
- let label = await wallet.getLabel(); // should be LYXTv5RdsPYKC4qGmb6x6SuKoFMxUdSjLQ
+ const label = await wallet.getLabel(); // should be LYXTv5RdsPYKC4qGmb6x6SuKoFMxUdSjLQ
$ltcResults.val(label + " does not support Litecoin");
}
});
@@ -2079,7 +2074,7 @@ $ltcTx.on("click", async (e) => {
});
$ltcResults.val(res.serializedTx);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$ltcResults.val(label + " does not support Litecoin");
}
});
@@ -2091,7 +2086,7 @@ $ltcSign.on("click", async (e) => {
return;
}
if (core.supportsBTC(wallet)) {
- let res = await wallet.btcSignMessage({
+ const res = await wallet.btcSignMessage({
addressNList: ltcBip44.addressNList,
coin: "Litecoin",
scriptType: core.BTCInputScriptType.SpendAddress,
@@ -2101,7 +2096,7 @@ $ltcSign.on("click", async (e) => {
// Address: LYXTv5RdsPYKC4qGmb6x6SuKoFMxUdSjLQ
// Signature: 1f835c7efaf953e059e7074afa954c5a8535be321f48e393e125e2a839d1721b495b935df1162c2b69f3e698167b75ab8bfd2c9c203f6070ff701ebca49653a056
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$ltcResults.val(label + " does not support Litecoin");
}
});
@@ -2128,7 +2123,7 @@ $dogeAddr.on("click", async (e) => {
return;
}
if (core.supportsBTC(wallet)) {
- let res = await wallet.btcGetAddress({
+ const res = await wallet.btcGetAddress({
addressNList: dogeBip44.addressNList.concat([0, 0]),
coin: "Dogecoin",
scriptType: dogeBip44.scriptType,
@@ -2136,7 +2131,7 @@ $dogeAddr.on("click", async (e) => {
});
$dogeResults.val(res);
} else {
- let label = await wallet.getLabel(); // should be DQTjL9vfXVbMfCGM49KWeYvvvNzRPaoiFp for alcohol abuse
+ const label = await wallet.getLabel(); // should be DQTjL9vfXVbMfCGM49KWeYvvvNzRPaoiFp for alcohol abuse
$dogeResults.val(label + " does not support DOGE");
}
});
@@ -2184,7 +2179,7 @@ $dogeTx.on("click", async (e) => {
});
$dogeResults.val(res.serializedTx); // TODO: Fails for Ledger: "TransportStatusError: Ledger device: Invalid data received (0x6a80)"
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$dogeResults.val(label + " does not support Litecoin");
}
});
@@ -2212,7 +2207,7 @@ $bchAddr.on("click", async (e) => {
return;
}
if (core.supportsBTC(wallet)) {
- let res = await wallet.btcGetAddress({
+ const res = await wallet.btcGetAddress({
addressNList: bchBip44.addressNList.concat([0, 0]),
coin: "BitcoinCash",
scriptType: bchBip44.scriptType,
@@ -2220,7 +2215,7 @@ $bchAddr.on("click", async (e) => {
});
$bchResults.val(res);
} else {
- let label = await wallet.getLabel(); // KK: bitcoincash:qzqxk2q6rhy3j9fnnc00m08g4n5dm827xv2dmtjzzp or Ledger: 1Ci1rvsLpZqvaMLSq7LiFj6mfnV4p3833E
+ const label = await wallet.getLabel(); // KK: bitcoincash:qzqxk2q6rhy3j9fnnc00m08g4n5dm827xv2dmtjzzp or Ledger: 1Ci1rvsLpZqvaMLSq7LiFj6mfnV4p3833E
$bchResults.val(label + " does not support BCH");
}
});
@@ -2269,7 +2264,7 @@ $bchTx.on("click", async (e) => {
});
$bchResults.val(res.serializedTx);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$bchResults.val(label + " does not support Litecoin");
}
});
@@ -2297,7 +2292,7 @@ $dashAddr.on("click", async (e) => {
return;
}
if (core.supportsBTC(wallet)) {
- let res = await wallet.btcGetAddress({
+ const res = await wallet.btcGetAddress({
addressNList: dashBip44.addressNList.concat([0, 0]),
coin: "Dash",
scriptType: dashBip44.scriptType,
@@ -2305,7 +2300,7 @@ $dashAddr.on("click", async (e) => {
});
$dashResults.val(res);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$dashResults.val(label + " does not support Dash");
}
});
@@ -2353,7 +2348,7 @@ $dashTx.on("click", async (e) => {
});
$dashResults.val(res.serializedTx);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$dashResults.val(label + " does not support Dash");
}
});
@@ -2380,7 +2375,7 @@ $dgbAddr.on("click", async (e) => {
return;
}
if (core.supportsBTC(wallet)) {
- let res = await wallet.btcGetAddress({
+ const res = await wallet.btcGetAddress({
addressNList: dgbBip44.addressNList.concat([0, 0]),
coin: "DigiByte",
scriptType: dgbBip44.scriptType,
@@ -2388,7 +2383,7 @@ $dgbAddr.on("click", async (e) => {
});
$dgbResults.val(res);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$dgbResults.val(label + " does not support Dash");
}
});
@@ -2455,7 +2450,7 @@ $dgbTx.on("click", async (e) => {
});
$dgbResults.val(res.serializedTx);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$dgbResults.val(label + " does not support Dash");
}
@@ -2484,7 +2479,7 @@ $btcAddrSegWit.on("click", async (e) => {
if (core.supportsBTC(wallet)) {
//coin 0 (mainnet bitcoin)
//path 0
- let res = await wallet.btcGetAddress({
+ const res = await wallet.btcGetAddress({
addressNList: [0x80000000 + 49, 0x80000000 + 0, 0x80000000 + 0, 0, 0],
coin: "Bitcoin",
scriptType: core.BTCInputScriptType.SpendP2SHWitness,
@@ -2493,7 +2488,7 @@ $btcAddrSegWit.on("click", async (e) => {
$btcResultsSegWit.val(res);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$btcResultsSegWit.val(label + " does not support BTC");
}
});
@@ -2507,7 +2502,7 @@ $btcAddrSegWitNative.on("click", async (e) => {
if (core.supportsBTC(wallet)) {
//coin 0 (mainnet bitcoin)
//path 0
- let res = await wallet.btcGetAddress({
+ const res = await wallet.btcGetAddress({
addressNList: [0x80000000 + 84, 0x80000000 + 0, 0x80000000 + 0, 0, 0],
coin: "Bitcoin",
scriptType: core.BTCInputScriptType.SpendWitness,
@@ -2515,7 +2510,7 @@ $btcAddrSegWitNative.on("click", async (e) => {
});
$btcResultsSegWit.val(res);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$btcResultsSegWit.val(label + " does not support BTC");
}
});
@@ -2531,7 +2526,7 @@ $btcTxSegWit.on("click", async (e) => {
const hex =
"01000000021b09436d8f9fae331e8810ca8ddf5b2bac1c95338a98280ad75efb6773d54a03000000006b48304502210081734b9b58d109997241c85806e6a5c97ba79f4a76ddb98eb227626b21ac1d290220534bee7f3f2a1803b851570b62825a589b5989f69afa44ddee5b591b8f822d3d012103fa044f4e622a9dc7a877155efad20816c6994f95bd1dc21c339a820395a32e01ffffffffe4b64ecf01f1b2e2a8c0ca86662fada7abbb991e9b4974217f5977623d515ea1010000006b4830450221008a2c95c61db777e15ebb7220c9a84565080ed87b97778a0417854fefa87e447202205dafb62309770a98868737d25bc7779caffa4b50993c36c93acf1f07a5d6d69b012102000b4b1051a63e82eeede1f1990ab226685f83ba104a0946edc740e17ce2958bffffffff02a08601000000000017a91463c4b3af0eb54b8b58b07fbde95a4ab3af3b8735874f161100000000001976a91430f7daeb4336f786cb0cf3bb162d83393681ca2d88ac00000000";
- let inputs = [
+ const inputs = [
{
addressNList: [0x80000000 + 49, 0x80000000 + 0, 0x80000000 + 0, 0, 0],
amount: String(100000),
@@ -2543,7 +2538,7 @@ $btcTxSegWit.on("click", async (e) => {
},
];
- let outputs: core.BTCSignTxOutput[] = [
+ const outputs: core.BTCSignTxOutput[] = [
{
address: "3Eq3agTHEhMCC8sZHnJJcCcZFB7BBSJKWr",
addressType: core.BTCOutputAddressType.Spend,
@@ -2552,7 +2547,7 @@ $btcTxSegWit.on("click", async (e) => {
isChange: false,
},
];
- let res = await wallet.btcSignTx({
+ const res = await wallet.btcSignTx({
coin: "Bitcoin",
inputs: inputs,
outputs: outputs,
@@ -2561,7 +2556,7 @@ $btcTxSegWit.on("click", async (e) => {
});
$btcResultsSegWit.val(res.serializedTx);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$btcResultsSegWit.val(label + " does not support BTC");
}
});
@@ -2583,7 +2578,7 @@ $btcTxSegWitNative.on("click", async (e) => {
const hex =
"01000000000101360d7a720e95a6068678eb08e91b3a8a4774222c9f34becf57d0dc4329e0a686000000001716001495f41f5c0e0ec2c7fe27f0ac4bd59a5632a40b5fffffffff02d224000000000000160014ece6935b2a5a5b5ff997c87370b16fa10f16441088ba04000000000017a914dfe58cc93d35fb99e15436f47d3bbfce820328068702483045022100f312e8246e6a00d21fd762f12231c5fb7a20094a32940b9a84e28d712a5ced9b02203b9124d7a94aa7eb1e090ceda32e884511d7068b8d47593aa46537900e3e37d40121037e8bf05c6c7223cfba3ea484ecd61ee910ae38609ea89b4a4839beed2186b3fb00000000";
- let inputs = [
+ const inputs = [
{
addressNList: [0x80000000 + 84, 0x80000000 + 0, 0x80000000 + 0, 0, 0],
amount: String(9426),
@@ -2595,7 +2590,7 @@ $btcTxSegWitNative.on("click", async (e) => {
},
];
- let outputs: core.BTCSignTxOutput[] = [
+ const outputs: core.BTCSignTxOutput[] = [
{
address: "bc1qc5dgazasye0yrzdavnw6wau5up8td8gdqh7t6m",
addressType: core.BTCOutputAddressType.Spend,
@@ -2604,7 +2599,7 @@ $btcTxSegWitNative.on("click", async (e) => {
isChange: false,
},
];
- let res = await wallet.btcSignTx({
+ const res = await wallet.btcSignTx({
coin: "Bitcoin",
inputs: inputs,
outputs: outputs,
@@ -2613,7 +2608,7 @@ $btcTxSegWitNative.on("click", async (e) => {
});
$btcResultsSegWit.val(res.serializedTx);
} else {
- let label = await wallet.getLabel();
+ const label = await wallet.getLabel();
$btcResultsSegWit.val(label + " does not support BTC");
}
diff --git a/examples/sandbox/package.json b/examples/sandbox/package.json
index d5134a6b0..98e231d2b 100644
--- a/examples/sandbox/package.json
+++ b/examples/sandbox/package.json
@@ -23,14 +23,12 @@
"@shapeshiftoss/hdwallet-trezor-connect": "1.19.1",
"@shapeshiftoss/hdwallet-xdefi": "1.19.1",
"bip32": "^2.0.4",
- "debug": "^4.1.1",
"jquery": "^3.4.1",
"json": "^9.0.6",
"parcel": "^2.3.2",
"web3": "^1.5.1"
},
"devDependencies": {
- "@types/debug": "^4.1.2",
"https-browserify": "^1.0.0",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
diff --git a/integration/jest.config.js b/integration/jest.config.js
index 91575d17c..ec6cddacb 100644
--- a/integration/jest.config.js
+++ b/integration/jest.config.js
@@ -10,13 +10,13 @@ module.exports = {
"^@shapeshiftoss/hdwallet-(.*)": "/../../packages/hdwallet-$1/src",
},
globals: {
- 'ts-jest': {
+ "ts-jest": {
diagnostics: {
// TS(7016) "could not find a declaration file for module" occurs when ts-jest is confused about which *.d.ts to pass
// as input to TypeScript's compilation API. When this happens, noImplicitAny will complain. Disabling this error will
// suppress it when run under ts-jest; this is OK, because it will still be reported during the normal build process.
ignoreCodes: [7016],
- }
+ },
},
},
};
diff --git a/integration/package.json b/integration/package.json
index 8f16db4e9..a6157f59f 100644
--- a/integration/package.json
+++ b/integration/package.json
@@ -19,9 +19,7 @@
"@shapeshiftoss/hdwallet-portis": "1.19.1",
"@shapeshiftoss/hdwallet-trezor": "1.19.1",
"@shapeshiftoss/hdwallet-xdefi": "1.19.1",
- "@types/debug": "^4.1.5",
"@types/jest": "^26.0.23",
- "debug": "^4.2.0",
"fast-json-stable-stringify": "^2.1.0",
"jest": "^26.6.3",
"jest-environment-jsdom": "^25.5.0",
diff --git a/integration/src/binance/binance.ts b/integration/src/binance/binance.ts
index c70d89c77..cdef2102e 100644
--- a/integration/src/binance/binance.ts
+++ b/integration/src/binance/binance.ts
@@ -80,6 +80,7 @@ export function binanceTests(get: () => { wallet: core.HDWallet; info: core.HDWa
// Check that the signed transaction matches tx02_signed -- KeepKey doesn't provide this field,
// but the tests will be run with hdwallet-native as well, which will prove this invariant under
// the assumption that both are generating signatures over the same data.
+ // eslint-disable-next-line jest/no-conditional-expect
if (res.serialized) expect(res.serialized).toEqual(tx02_signed.serialized);
const txBytes = Buffer.from(tx02_signed.serialized, "hex");
expect(validateBnbTx(txBytes, input.chain_id)).toEqual(true);
diff --git a/integration/src/bitcoin/bitcoin.ts b/integration/src/bitcoin/bitcoin.ts
index c93a9d171..131614905 100644
--- a/integration/src/bitcoin/bitcoin.ts
+++ b/integration/src/bitcoin/bitcoin.ts
@@ -188,17 +188,17 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
],
],
async (args) => {
- let mode = args[0] as string;
- let coin = args[1] as core.Coin;
- let path = args[2] as string;
- let scriptType = args[3] as core.BTCInputScriptType;
- let expected = args[4] as string;
+ const mode = args[0] as string;
+ const coin = args[1] as core.Coin;
+ const path = args[2] as string;
+ const scriptType = args[3] as core.BTCInputScriptType;
+ const expected = args[4] as string;
if (!(await wallet.btcSupportsCoin(coin))) return;
expect(await info.btcSupportsCoin(coin)).toBeTruthy();
if (!(await wallet.btcSupportsScriptType(coin, scriptType))) return;
expect(await info.btcSupportsScriptType(coin, scriptType)).toBeTruthy();
- let res = await wallet.btcGetAddress({
+ const res = await wallet.btcGetAddress({
addressNList: core.bip32ToAddressNList(path),
coin: coin,
showDisplay: mode === "Show",
@@ -266,7 +266,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
isChange: false,
},
];
- let res = await wallet.btcSignTx(
+ const res = await wallet.btcSignTx(
deepFreeze({
coin: "Bitcoin",
inputs: inputs as core.BTCSignTxInput[],
@@ -333,7 +333,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
hex: "0100000002cfdd9ee3b0ed9d9045f29a252d4c78ecac6c5814b67a29b5f6998fcff1036ac1010000008b483045022072ba61305fe7cb542d142b8f3299a7b10f9ea61f6ffaab5dca8142601869d53c0221009a8027ed79eb3b9bc13577ac2853269323434558528c6b6a7e542be46e7e9a820141047a2d177c0f3626fc68c53610b0270fa6156181f46586c679ba6a88b34c6f4874686390b4d92e5769fbb89c8050b984f4ec0b257a0e5c4ff8bd3b035a51709503ffffffffaf3e45194a9bb60c6108abe8d9d039e0618e8a147911c68f0c67598d2f9ae31a010000008b48304502200fd63adc8f6cb34359dc6cca9e5458d7ea50376cbd0a74514880735e6d1b8a4c0221008b6ead7fe5fbdab7319d6dfede3a0bc8e2a7c5b5a9301636d1de4aa31a3ee9b101410486ad608470d796236b003635718dfc07c0cac0cfc3bfc3079e4f491b0426f0676e6643a39198e8e7bdaffb94f4b49ea21baa107ec2e237368872836073668214ffffffff0170f30500000000001976a91424a56db43cf6f2b02e838ea493f95d8d6047423188ac00000000",
},
];
- let outputs: core.BTCSignTxOutput[] = [
+ const outputs: core.BTCSignTxOutput[] = [
{
address: "bc1qksxqxurvejkndenuv0alqawpr3e4vtqkn246cu",
addressType: core.BTCOutputAddressType.Spend,
@@ -349,7 +349,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
},
];
- let res = await wallet.btcSignTx(
+ const res = await wallet.btcSignTx(
deepFreeze({
coin: "Bitcoin",
inputs: inputs as core.BTCSignTxInput[],
@@ -381,7 +381,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
return;
}
- let res = wallet.btcSignMessage({
+ const res = wallet.btcSignMessage({
addressNList: core.bip32ToAddressNList("m/44'/0'/0'/0/0"),
coin: "Bitcoin",
scriptType: core.BTCInputScriptType.SpendAddress,
@@ -390,6 +390,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
// not implemented on portis
if (portis.isPortis(wallet)) {
+ // eslint-disable-next-line jest/no-conditional-expect
await expect(res).rejects.toThrowError("not supported");
return;
}
@@ -413,7 +414,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
return;
}
- let res = await wallet.btcVerifyMessage({
+ const res = await wallet.btcVerifyMessage({
address: "1FH6ehAd5ZFXCM1cLGzHxK1s4dGdq1JusM",
coin: "Bitcoin",
signature:
@@ -436,7 +437,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
return;
}
- let res = await wallet.btcVerifyMessage({
+ const res = await wallet.btcVerifyMessage({
address: "1FH6ehAd5ZFXCM1cLGzHxK1s4dGdq1JusM",
coin: "Bitcoin",
signature:
@@ -455,6 +456,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
if (!wallet) return;
expect(typeof (await wallet.btcSupportsSecureTransfer()) === typeof true).toBeTruthy();
if (await wallet.btcSupportsSecureTransfer()) {
+ // eslint-disable-next-line jest/no-conditional-expect
expect(await info.btcSupportsSecureTransfer()).toBeTruthy();
}
// TODO: write a testcase that exercise secure transfer, if the wallet claims to support it.
@@ -466,8 +468,9 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
"btcSupportsNativeShapeShift()",
async () => {
if (!wallet) return;
- expect(typeof wallet.btcSupportsNativeShapeShift() === typeof true);
+ expect(typeof wallet.btcSupportsNativeShapeShift()).toBe("boolean");
if (wallet.btcSupportsNativeShapeShift()) {
+ // eslint-disable-next-line jest/no-conditional-expect
expect(info.btcSupportsNativeShapeShift()).toBeTruthy();
}
// TODO: write a testcase that exercises native shapeshift, if the wallet claims to support it.
@@ -492,21 +495,22 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
["BitcoinGold", 0, core.BTCInputScriptType.SpendAddress],
],
async (args) => {
- let coin = args[0] as core.Coin;
- let accountIdx = args[1] as number;
- let scriptType = args[2] as core.BTCInputScriptType;
+ const coin = args[0] as core.Coin;
+ const accountIdx = args[1] as number;
+ const scriptType = args[2] as core.BTCInputScriptType;
if (!wallet) return;
if (!(await wallet.btcSupportsCoin(coin))) return;
expect(await info.btcSupportsCoin(coin)).toBeTruthy();
if (!(await wallet.btcSupportsScriptType(coin, scriptType))) return;
expect(await info.btcSupportsScriptType(coin, scriptType)).toBeTruthy();
- let paths = wallet.btcGetAccountPaths({
+ const paths = wallet.btcGetAccountPaths({
coin: coin,
accountIdx: accountIdx,
scriptType: scriptType,
});
expect(paths.length > 0).toBeTruthy();
if (scriptType !== undefined)
+ // eslint-disable-next-line jest/no-conditional-expect
expect(
paths.filter((path) => {
return path.scriptType !== scriptType;
@@ -523,14 +527,19 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
async () => {
if (!wallet) return;
[0, 1, 9].forEach((idx) => {
- let paths = wallet.btcGetAccountPaths({
+ const paths = wallet.btcGetAccountPaths({
coin: "Bitcoin",
accountIdx: idx,
});
expect(typeof wallet.btcIsSameAccount(paths) === typeof true).toBeTruthy();
paths.forEach((path) => {
- if (wallet.getVendor() === "Portis") expect(wallet.btcNextAccountPath(path)).toBeUndefined();
- else expect(wallet.btcNextAccountPath(path)).not.toBeUndefined();
+ if (wallet.getVendor() === "Portis") {
+ // eslint-disable-next-line jest/no-conditional-expect
+ expect(wallet.btcNextAccountPath(path)).toBeUndefined();
+ } else {
+ // eslint-disable-next-line jest/no-conditional-expect
+ expect(wallet.btcNextAccountPath(path)).not.toBeUndefined();
+ }
});
});
},
diff --git a/integration/src/bitcoin/index.ts b/integration/src/bitcoin/index.ts
index 56f73509b..6bac2768c 100644
--- a/integration/src/bitcoin/index.ts
+++ b/integration/src/bitcoin/index.ts
@@ -1,8 +1,8 @@
import * as core from "@shapeshiftoss/hdwallet-core";
import { bitcoinTests } from "./bitcoin";
-import { testnetTests } from "./testnet";
import { litecoinTests } from "./litecoin";
+import { testnetTests } from "./testnet";
export function btcTests(get: () => { wallet: core.HDWallet; info: core.HDWalletInfo }): void {
bitcoinTests(get);
diff --git a/integration/src/bitcoin/litecoin.ts b/integration/src/bitcoin/litecoin.ts
index e19f323d7..440b3cb0b 100644
--- a/integration/src/bitcoin/litecoin.ts
+++ b/integration/src/bitcoin/litecoin.ts
@@ -58,14 +58,14 @@ export function litecoinTests(get: () => { wallet: core.HDWallet; info: core.HDW
],
],
async (args) => {
- let mode = args[0] as string;
- let coin = args[1] as core.Coin;
- let path = args[2] as string;
- let scriptType = args[3] as core.BTCInputScriptType;
- let expected = args[4] as string;
+ const mode = args[0] as string;
+ const coin = args[1] as core.Coin;
+ const path = args[2] as string;
+ const scriptType = args[3] as core.BTCInputScriptType;
+ const expected = args[4] as string;
if (!(await wallet.btcSupportsScriptType(coin, scriptType))) return;
- let res = await wallet.btcGetAddress({
+ const res = await wallet.btcGetAddress({
addressNList: core.bip32ToAddressNList(path),
coin: coin,
showDisplay: mode === "Show",
@@ -88,18 +88,18 @@ export function litecoinTests(get: () => { wallet: core.HDWallet; info: core.HDW
["Litecoin", 1, core.BTCInputScriptType.SpendWitness],
],
async (args) => {
- let coin = args[0] as core.Coin;
- let accountIdx = args[1] as number;
- let scriptType = args[2] as core.BTCInputScriptType;
+ const coin = args[0] as core.Coin;
+ const accountIdx = args[1] as number;
+ const scriptType = args[2] as core.BTCInputScriptType;
if (!wallet) return;
if (!(await wallet.btcSupportsCoin(coin))) return;
if (!(await wallet.btcSupportsScriptType(coin, scriptType))) return;
- let paths = wallet.btcGetAccountPaths({
+ const paths = wallet.btcGetAccountPaths({
coin: coin,
accountIdx: accountIdx,
scriptType: scriptType,
});
- expect(paths.length > 0);
+ expect(paths.length).toBeGreaterThan(0);
}
);
},
@@ -111,7 +111,7 @@ export function litecoinTests(get: () => { wallet: core.HDWallet; info: core.HDW
async () => {
if (!wallet) return;
[0, 1, 9].forEach((idx) => {
- let paths = wallet.btcGetAccountPaths({
+ const paths = wallet.btcGetAccountPaths({
coin: "Litecoin",
accountIdx: idx,
});
diff --git a/integration/src/bitcoin/testnet.ts b/integration/src/bitcoin/testnet.ts
index ec0cda6da..eb8b5a3c1 100644
--- a/integration/src/bitcoin/testnet.ts
+++ b/integration/src/bitcoin/testnet.ts
@@ -41,8 +41,7 @@ export function testnetTests(get: () => { wallet: core.HDWallet; info: core.HDWa
amount: String(123456789),
vout: 0,
txid: "20912f98ea3ed849042efed0fdac8cb4fc301961c5988cba56902d8ffb61c337",
- hex:
- "01000000013a14418ce8bcac00a0cb56bf8a652110f4897cfcd736e1ab5e943b84f0ab2c80000000006a4730440220548e087d0426b20b8a571b03b9e05829f7558b80c53c12143e342f56ab29e51d02205b68cb7fb223981d4c999725ac1485a982c4259c4f50b8280f137878c232998a012102794a25b254a268e59a5869da57fbae2fadc6727cb3309321dab409b12b2fa17cffffffff0215cd5b070000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca87ccc69633000000001976a914b84bacdcd8f4cc59274a5bfb73f804ca10f7fd1488ac00000000",
+ hex: "01000000013a14418ce8bcac00a0cb56bf8a652110f4897cfcd736e1ab5e943b84f0ab2c80000000006a4730440220548e087d0426b20b8a571b03b9e05829f7558b80c53c12143e342f56ab29e51d02205b68cb7fb223981d4c999725ac1485a982c4259c4f50b8280f137878c232998a012102794a25b254a268e59a5869da57fbae2fadc6727cb3309321dab409b12b2fa17cffffffff0215cd5b070000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca87ccc69633000000001976a914b84bacdcd8f4cc59274a5bfb73f804ca10f7fd1488ac00000000",
},
];
const outputs: core.BTCSignTxOutput[] = [
diff --git a/integration/src/cosmos/cosmos.ts b/integration/src/cosmos/cosmos.ts
index becd06c1f..715170424 100644
--- a/integration/src/cosmos/cosmos.ts
+++ b/integration/src/cosmos/cosmos.ts
@@ -1,25 +1,18 @@
import * as core from "@shapeshiftoss/hdwallet-core";
-import tx_unsigned_transfer from "./tx01.mainnet.cosmos.json";
-import tx_signed_trasnfer from "./tx01.mainnet.cosmos.signed.json";
-
-//delgation
import tx_unsigned_delegation from "./tx01.mainnet.cosmos.delegate.json";
import tx_signed_delegation from "./tx01.mainnet.cosmos.delegate.signed.json";
-
+import tx_unsigned_ibc_cosmos from "./tx01.mainnet.cosmos.ibc.transfer.json";
+import tx_signed_ibc_cosmos from "./tx01.mainnet.cosmos.ibc.transfer.signed.json";
+import tx_unsigned_transfer from "./tx01.mainnet.cosmos.json";
+import tx_unsigned_rewards_cosmos from "./tx01.mainnet.cosmos.rewards.json";
+import tx_signed_rewards_cosmos from "./tx01.mainnet.cosmos.rewards.signed.json";
+import tx_signed_trasnfer from "./tx01.mainnet.cosmos.signed.json";
import tx_unigned_undelegate_cosmos from "./tx01.mainnet.cosmos.undelegate.json";
-import tx_signed_undelegate_cosmos from "./tx01.mainnet.cosmos.undelegate.signed.json";
-
import tx_unsigned_redelegate_cosmos from "./tx01.mainnet.cosmos.undelegate.json";
+import tx_signed_undelegate_cosmos from "./tx01.mainnet.cosmos.undelegate.signed.json";
import tx_signed_redelegate_cosmos from "./tx01.mainnet.cosmos.undelegate.signed.json";
-import tx_unsigned_rewards_cosmos from "./tx01.mainnet.cosmos.rewards.json";
-import tx_signed_rewards_cosmos from "./tx01.mainnet.cosmos.rewards.signed.json";
-
-//IBC
-import tx_unsigned_ibc_cosmos from "./tx01.mainnet.cosmos.ibc.transfer.json";
-import tx_signed_ibc_cosmos from "./tx01.mainnet.cosmos.ibc.transfer.signed.json";
-
const MNEMONIC12_NOPIN_NOPASSPHRASE = "alcohol woman abuse must during monitor noble actual mixed trade anger aisle";
const TIMEOUT = 60 * 1000;
@@ -77,7 +70,7 @@ export function cosmosTests(get: () => { wallet: core.HDWallet; info: core.HDWal
async () => {
if (!wallet) return;
const input: core.CosmosSignTx = {
- tx: (tx_unsigned_transfer as unknown) as core.CosmosTx,
+ tx: tx_unsigned_transfer as unknown as core.CosmosTx,
addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
chain_id: tx_unsigned_transfer.chain_id,
account_number: tx_unsigned_transfer.account_number,
@@ -90,101 +83,99 @@ export function cosmosTests(get: () => { wallet: core.HDWallet; info: core.HDWal
TIMEOUT
);
- //delegate tx
- test(
- "(delegate) cosmosSignTx()",
- async () => {
- if (!wallet) return;
- const input: core.CosmosSignTx = {
- tx: (tx_unsigned_delegation as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unsigned_delegation.chain_id,
- account_number: tx_unsigned_delegation.account_number,
- sequence: tx_unsigned_delegation.sequence,
- };
-
- const res = await wallet.cosmosSignTx(input);
- expect(res?.signatures?.[0]).toEqual(tx_signed_delegation.signatures[0]);
- },
- TIMEOUT
- );
-
- //undelegate
- test(
- "(undelegate) cosmosSignTx()",
- async () => {
- if (!wallet) return;
- const input: core.CosmosSignTx = {
- tx: (tx_unigned_undelegate_cosmos as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unigned_undelegate_cosmos.chain_id,
- account_number: tx_unigned_undelegate_cosmos.account_number,
- sequence: tx_unigned_undelegate_cosmos.sequence,
- };
-
- const res = await wallet.cosmosSignTx(input);
- expect(res?.signatures?.[0]).toEqual(tx_signed_undelegate_cosmos.signatures[0]);
- },
- TIMEOUT
- );
-
- //redelegate
- test(
- "(redelegate) cosmosSignTx()",
- async () => {
- if (!wallet) return;
- const input: core.CosmosSignTx = {
- tx: (tx_unsigned_redelegate_cosmos as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unsigned_redelegate_cosmos.chain_id,
- account_number: tx_unsigned_redelegate_cosmos.account_number,
- sequence: tx_unsigned_redelegate_cosmos.sequence,
- };
-
- const res = await wallet.cosmosSignTx(input);
- expect(res?.signatures?.[0]).toEqual(tx_signed_redelegate_cosmos.signatures[0]);
- },
- TIMEOUT
- );
-
- //claim reward
- test(
- "(claim) cosmosSignTx()",
- async () => {
- if (!wallet) return;
- const input: core.CosmosSignTx = {
- tx: (tx_unsigned_rewards_cosmos as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unsigned_rewards_cosmos.chain_id,
- account_number: tx_unsigned_rewards_cosmos.account_number,
- sequence: tx_unsigned_rewards_cosmos.sequence,
- };
-
- const res = await wallet.cosmosSignTx(input);
- expect(res?.signatures?.[0]).toEqual(tx_signed_rewards_cosmos.signatures[0]);
- },
- TIMEOUT
- );
+ //delegate tx
+ test(
+ "(delegate) cosmosSignTx()",
+ async () => {
+ if (!wallet) return;
+ const input: core.CosmosSignTx = {
+ tx: tx_unsigned_delegation as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unsigned_delegation.chain_id,
+ account_number: tx_unsigned_delegation.account_number,
+ sequence: tx_unsigned_delegation.sequence,
+ };
+ const res = await wallet.cosmosSignTx(input);
+ expect(res?.signatures?.[0]).toEqual(tx_signed_delegation.signatures[0]);
+ },
+ TIMEOUT
+ );
+
+ //undelegate
+ test(
+ "(undelegate) cosmosSignTx()",
+ async () => {
+ if (!wallet) return;
+ const input: core.CosmosSignTx = {
+ tx: tx_unigned_undelegate_cosmos as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unigned_undelegate_cosmos.chain_id,
+ account_number: tx_unigned_undelegate_cosmos.account_number,
+ sequence: tx_unigned_undelegate_cosmos.sequence,
+ };
+
+ const res = await wallet.cosmosSignTx(input);
+ expect(res?.signatures?.[0]).toEqual(tx_signed_undelegate_cosmos.signatures[0]);
+ },
+ TIMEOUT
+ );
+
+ //redelegate
+ test(
+ "(redelegate) cosmosSignTx()",
+ async () => {
+ if (!wallet) return;
+ const input: core.CosmosSignTx = {
+ tx: tx_unsigned_redelegate_cosmos as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unsigned_redelegate_cosmos.chain_id,
+ account_number: tx_unsigned_redelegate_cosmos.account_number,
+ sequence: tx_unsigned_redelegate_cosmos.sequence,
+ };
+
+ const res = await wallet.cosmosSignTx(input);
+ expect(res?.signatures?.[0]).toEqual(tx_signed_redelegate_cosmos.signatures[0]);
+ },
+ TIMEOUT
+ );
+
+ //claim reward
+ test(
+ "(claim) cosmosSignTx()",
+ async () => {
+ if (!wallet) return;
+ const input: core.CosmosSignTx = {
+ tx: tx_unsigned_rewards_cosmos as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unsigned_rewards_cosmos.chain_id,
+ account_number: tx_unsigned_rewards_cosmos.account_number,
+ sequence: tx_unsigned_rewards_cosmos.sequence,
+ };
+
+ const res = await wallet.cosmosSignTx(input);
+ expect(res?.signatures?.[0]).toEqual(tx_signed_rewards_cosmos.signatures[0]);
+ },
+ TIMEOUT
+ );
//IBC
- test(
- "(ibc transfer) cosmosSignTx()",
- async () => {
- if (!wallet) return;
- const input: core.CosmosSignTx = {
- tx: (tx_unsigned_ibc_cosmos as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unsigned_ibc_cosmos.chain_id,
- account_number: tx_unsigned_ibc_cosmos.account_number,
- sequence: tx_unsigned_ibc_cosmos.sequence,
- };
-
- const res = await wallet.cosmosSignTx(input);
- expect(res?.signatures?.[0]).toEqual(tx_signed_ibc_cosmos.signatures[0]);
- },
- TIMEOUT
- );
+ test(
+ "(ibc transfer) cosmosSignTx()",
+ async () => {
+ if (!wallet) return;
+ const input: core.CosmosSignTx = {
+ tx: tx_unsigned_ibc_cosmos as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unsigned_ibc_cosmos.chain_id,
+ account_number: tx_unsigned_ibc_cosmos.account_number,
+ sequence: tx_unsigned_ibc_cosmos.sequence,
+ };
+ const res = await wallet.cosmosSignTx(input);
+ expect(res?.signatures?.[0]).toEqual(tx_signed_ibc_cosmos.signatures[0]);
+ },
+ TIMEOUT
+ );
});
}
diff --git a/integration/src/eos/eos.ts b/integration/src/eos/eos.ts
index 4379868c0..eff3b77e6 100644
--- a/integration/src/eos/eos.ts
+++ b/integration/src/eos/eos.ts
@@ -34,12 +34,12 @@ export function eosTests(get: () => { wallet: core.HDWallet; info: core.HDWallet
"eosGetAccountPaths()",
() => {
if (!wallet) return;
- let paths = wallet.eosGetAccountPaths({ accountIdx: 0 });
+ const paths = wallet.eosGetAccountPaths({ accountIdx: 0 });
expect(paths.length > 0).toBe(true);
expect(paths[0].addressNList[0] > 0x80000000).toBe(true);
paths.forEach((path) => {
- let curAddr = path.addressNList.join();
- let nextAddr = core.mustBeDefined(wallet.eosNextAccountPath(path)).addressNList.join();
+ const curAddr = path.addressNList.join();
+ const nextAddr = core.mustBeDefined(wallet.eosNextAccountPath(path)).addressNList.join();
expect(nextAddr === undefined || nextAddr !== curAddr).toBeTruthy();
});
},
@@ -61,37 +61,51 @@ export function eosTests(get: () => { wallet: core.HDWallet; info: core.HDWallet
TIMEOUT
);
+ // eslint-disable-next-line jest/no-disabled-tests
test.skip(
"kk integration eosSignTx()",
async () => {
if (!wallet) return;
- let txData = tx01_unsigned as any;
- let res = core.mustBeDefined(await wallet.eosSignTx({
- addressNList: core.bip32ToAddressNList("m/44'/194'/0'/0/0"),
- chain_id: txData.chain_id as string,
- tx: txData.transaction as core.EosTx,
- }));
+ const txData = tx01_unsigned as any;
+ const res = core.mustBeDefined(
+ await wallet.eosSignTx({
+ addressNList: core.bip32ToAddressNList("m/44'/194'/0'/0/0"),
+ chain_id: txData.chain_id as string,
+ tx: txData.transaction as core.EosTx,
+ })
+ );
expect(res.signatureV).toEqual(31);
- expect(core.toHexString(res.signatureR)).toEqual("3a58d0889c6e4dde052b76ca092f59f314e2ab4e867164083e108e7a3f40d737");
- expect(core.toHexString(res.signatureS)).toEqual("448f8175217c2fd9bf9dac753adf1baabdfa3132eab7235158fbdf3cbe346805");
+ expect(core.toHexString(res.signatureR)).toEqual(
+ "3a58d0889c6e4dde052b76ca092f59f314e2ab4e867164083e108e7a3f40d737"
+ );
+ expect(core.toHexString(res.signatureS)).toEqual(
+ "448f8175217c2fd9bf9dac753adf1baabdfa3132eab7235158fbdf3cbe346805"
+ );
expect(core.toHexString(res.hash)).toEqual("86a946cd06ddac53c256700ef8bfeed4d1f72512909400df597c8d594d1b0591");
},
TIMEOUT
);
+ // eslint-disable-next-line jest/no-disabled-tests
test.skip(
"confirmed on chain eosSignTx()",
async () => {
if (!wallet) return;
- let txData = tx02_unsigned as any;
- let res = core.mustBeDefined(await wallet.eosSignTx({
- addressNList: core.bip32ToAddressNList("m/44'/194'/0'/0/0"),
- chain_id: txData.chain_id as string,
- tx: txData.transaction as core.EosTx,
- }));
+ const txData = tx02_unsigned as any;
+ const res = core.mustBeDefined(
+ await wallet.eosSignTx({
+ addressNList: core.bip32ToAddressNList("m/44'/194'/0'/0/0"),
+ chain_id: txData.chain_id as string,
+ tx: txData.transaction as core.EosTx,
+ })
+ );
expect(res.signatureV).toEqual(31);
- expect(core.toHexString(res.signatureR)).toEqual("14ce00681a621d1f80a98d5f47a7d703ed515fb9169f0c1f1b54c5199fad7080");
- expect(core.toHexString(res.signatureS)).toEqual("767e9b510b789763fa62aaa8285f48f57ef3d56bb62ce6ebf650ec8a88aca8f0");
+ expect(core.toHexString(res.signatureR)).toEqual(
+ "14ce00681a621d1f80a98d5f47a7d703ed515fb9169f0c1f1b54c5199fad7080"
+ );
+ expect(core.toHexString(res.signatureS)).toEqual(
+ "767e9b510b789763fa62aaa8285f48f57ef3d56bb62ce6ebf650ec8a88aca8f0"
+ );
expect(core.toHexString(res.hash)).toEqual("d34082c1b4c6f578ef46500e30dcdc4987715d088323da8f2fb2b296f9db7b12");
},
TIMEOUT
diff --git a/integration/src/ethereum/ethereum.ts b/integration/src/ethereum/ethereum.ts
index 62972fe36..1122c3a15 100644
--- a/integration/src/ethereum/ethereum.ts
+++ b/integration/src/ethereum/ethereum.ts
@@ -1,7 +1,7 @@
import * as core from "@shapeshiftoss/hdwallet-core";
import * as ledger from "@shapeshiftoss/hdwallet-ledger";
-import * as trezor from "@shapeshiftoss/hdwallet-trezor";
import * as portis from "@shapeshiftoss/hdwallet-portis";
+import * as trezor from "@shapeshiftoss/hdwallet-trezor";
const MNEMONIC12_NOPIN_NOPASSPHRASE = "alcohol woman abuse must during monitor noble actual mixed trade anger aisle";
const MNEMONIC_TEST = "smooth antenna immense oppose august casual fresh meadow happy ugly wave control";
@@ -54,13 +54,13 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
async () => {
if (!wallet) return;
if (await wallet.ethSupportsSecureTransfer()) {
- let account0 = core.bip32ToAddressNList("m/44'/60'/0'/0/0");
- let account1 = core.bip32ToAddressNList("m/44'/60'/1'/0/0");
- let account1Addr = await wallet.ethGetAddress({
+ const account0 = core.bip32ToAddressNList("m/44'/60'/0'/0/0");
+ const account1 = core.bip32ToAddressNList("m/44'/60'/1'/0/0");
+ const account1Addr = await wallet.ethGetAddress({
addressNList: account1,
showDisplay: false,
});
- let res = await wallet.ethSignTx({
+ const res = await wallet.ethSignTx({
addressNList: account0,
nonce: "0x01",
gasPrice: "0x14",
@@ -71,6 +71,7 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
chainId: 1,
data: "",
});
+ // eslint-disable-next-line jest/no-conditional-expect
expect(res).toEqual({
r: "0x2482a45ee0d2851d3ab76a693edd7a393e8bc99422f7857be78a883bc1d60a5b",
s: "0x18d776bcfae586bf08ecc70f714c9bec8959695a20ef73ad0c28233fdaeb1bd2",
@@ -87,7 +88,7 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
"ethGetAccountPaths()",
() => {
if (!wallet) return;
- let paths = wallet.ethGetAccountPaths({
+ const paths = wallet.ethGetAccountPaths({
coin: "Ethereum",
accountIdx: 0,
});
@@ -119,10 +120,6 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
"ethSignTx() - ETH",
async () => {
if (!wallet) return;
- let addr = await wallet.ethGetAddress({
- addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"),
- showDisplay: false,
- });
const txToSign = {
addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"),
@@ -136,7 +133,9 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
};
if (wallet.supportsOfflineSigning()) {
- let res = await wallet.ethSignTx(txToSign);
+ const res = await wallet.ethSignTx(txToSign);
+
+ // eslint-disable-next-line jest/no-conditional-expect
expect(res).toEqual({
r: "0x63db3dd3bf3e1fe7dde1969c0fc8850e34116d0b501c0483a0e08c0f77b8ce0a",
s: "0x28297d012cccf389f6332415e96ee3fc0bbf8474d05f646e029cd281a031464b",
@@ -147,6 +146,7 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
} else if (wallet.supportsBroadcast() && wallet.ethSendTx) {
const res = await wallet.ethSendTx(txToSign);
+ // eslint-disable-next-line jest/no-conditional-expect
expect(res).toMatchInlineSnapshot(`
Object {
"hash": "txHash-0x12eC06288EDD7Ae2CC41A843fE089237fC7354F0",
@@ -164,7 +164,7 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
return;
}
- if (!await wallet.ethSupportsEIP1559()) {
+ if (!(await wallet.ethSupportsEIP1559())) {
return;
}
@@ -176,18 +176,13 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
skipChecksum: true,
});
- let addr = await wallet.ethGetAddress({
- addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"),
- showDisplay: false,
- });
-
- let res = await wallet.ethSignTx({
+ const res = await wallet.ethSignTx({
addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"),
nonce: "0x0",
gasLimit: "0x5ac3",
maxFeePerGas: "0x16854be509",
maxPriorityFeePerGas: "0x540ae480",
- value: "0x1550f7dca70000", // 0.006 eth
+ value: "0x1550f7dca70000", // 0.006 eth
to: "0xfc0cc6e85dff3d75e3985e0cb83b090cfd498dd1",
chainId: 1,
data: "",
@@ -207,12 +202,12 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
"ethSignTx() - ETH EIP-1559 (optional)",
async () => {
if (!wallet) return;
-
- if (!await wallet.ethSupportsEIP1559()) {
- return;
- }
-
- let res = await wallet.ethSignTx({
+
+ if (!(await wallet.ethSupportsEIP1559())) {
+ return;
+ }
+
+ const res = await wallet.ethSignTx({
addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"),
nonce: "0x01",
gasPrice: "0x1dcd65000",
@@ -256,7 +251,9 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
};
if (wallet.supportsOfflineSigning()) {
- let res = await wallet.ethSignTx(txToSign);
+ const res = await wallet.ethSignTx(txToSign);
+
+ // eslint-disable-next-line jest/no-conditional-expect
expect(res).toEqual({
r: "0x1238fd332545415f09a01470350a5a20abc784dbf875cf58f7460560e66c597f",
s: "0x10efa4dd6fdb381c317db8f815252c2ac0d2a883bd364901dee3dec5b7d3660a",
@@ -267,6 +264,7 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
} else if (wallet.supportsBroadcast() && wallet.ethSendTx) {
const res = await wallet.ethSendTx(txToSign);
+ // eslint-disable-next-line jest/no-conditional-expect
expect(res).toMatchInlineSnapshot(`
Object {
"hash": "txHash-0x41e5560054824ea6b0732e656e3ad64e20e94e45",
@@ -346,7 +344,9 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
};
if (wallet.supportsOfflineSigning()) {
- let res = await wallet.ethSignTx(txToSign);
+ const res = await wallet.ethSignTx(txToSign);
+
+ // eslint-disable-next-line jest/no-conditional-expect
expect(res).toEqual({
r: "0x5ea245ddd00fdf3958d6223255e37dcb0c61fa62cfa9cfb25e507da16ec8d96a",
s: "0x6c428730776958b80fd2b2201600420bb49059f9b34ee3b960cdcce45d4a1e09",
@@ -357,6 +357,7 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
} else if (wallet.supportsBroadcast() && wallet.ethSendTx) {
const res = await wallet.ethSendTx(txToSign);
+ // eslint-disable-next-line jest/no-conditional-expect
expect(res).toMatchInlineSnapshot(`
Object {
"hash": "txHash-0xdef1c0ded9bec7f1a1670819833240f027b25eff",
@@ -372,7 +373,7 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
async () => {
if (!wallet) return;
if (ledger.isLedger(wallet)) return; // FIXME: Expected failure
- let res = await wallet.ethSignMessage({
+ const res = await wallet.ethSignMessage({
addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"),
message: "Hello World",
});
@@ -390,16 +391,18 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
if (!wallet) return;
if (wallet.supportsOfflineSigning()) {
- let res = await wallet.ethVerifyMessage({
+ const res = await wallet.ethVerifyMessage({
address: "0x3f2329C9ADFbcCd9A84f52c906E936A42dA18CB8",
message: "Hello World",
signature:
"0x29f7212ecc1c76cea81174af267b67506f754ea8c73f144afa900a0d85b24b21319621aeb062903e856352f38305710190869c3ce5a1425d65ef4fa558d0fc251b",
});
+
+ // eslint-disable-next-line jest/no-conditional-expect
expect(res).toBeTruthy();
}
},
TIMEOUT
);
- });
+ });
}
diff --git a/integration/src/fio/fio.ts b/integration/src/fio/fio.ts
index 49c29efb6..ec8fe46ed 100644
--- a/integration/src/fio/fio.ts
+++ b/integration/src/fio/fio.ts
@@ -1,7 +1,8 @@
import * as core from "@shapeshiftoss/hdwallet-core";
-import * as tx01_unsigned from "./tx01.unsigned.json";
-import * as tx02_signed from "./tx02.signed.json";
+// TODO: Use these test TXs for something?
+// import * as tx01_unsigned from "./tx01.unsigned.json";
+// import * as tx02_signed from "./tx02.signed.json";
const MNEMONIC12_NOPIN_NOPASSPHRASE = "alcohol woman abuse must during monitor noble actual mixed trade anger aisle";
const MNEMONIC12_NOPIN_NOPASSPHRASE2 = "all all all all all all all all all all all all";
diff --git a/integration/src/integration.ts b/integration/src/integration.ts
index b3c7c816b..8535ac086 100644
--- a/integration/src/integration.ts
+++ b/integration/src/integration.ts
@@ -7,21 +7,20 @@ import * as portis from "@shapeshiftoss/hdwallet-portis";
import * as trezor from "@shapeshiftoss/hdwallet-trezor";
import * as xdefi from "@shapeshiftoss/hdwallet-xdefi";
+import { binanceTests } from "./binance";
import { btcTests } from "./bitcoin";
-import { ethTests } from "./ethereum";
import { cosmosTests } from "./cosmos";
-import { osmosisTests } from "./osmosis";
-import { binanceTests } from "./binance";
-import { rippleTests } from "./ripple";
import { eosTests } from "./eos";
+import { ethTests } from "./ethereum";
import { fioTests } from "./fio";
-import { thorchainTests } from "./thorchain";
+import { kavaTests } from "./kava";
+import { osmosisTests } from "./osmosis";
+import { rippleTests } from "./ripple";
import { secretTests } from "./secret";
import { terraTests } from "./terra";
-import { kavaTests } from "./kava";
-import { WalletSuite } from "./wallets/suite";
-
+import { thorchainTests } from "./thorchain";
import { ethereum } from "./wallets/mocks/@metamask/detect-provider";
+import { WalletSuite } from "./wallets/suite";
jest.mock("@metamask/detect-provider", () => async () => Promise.resolve(ethereum));
diff --git a/integration/src/kava/kava.ts b/integration/src/kava/kava.ts
index 9eab7fc66..6c54c8ee2 100644
--- a/integration/src/kava/kava.ts
+++ b/integration/src/kava/kava.ts
@@ -49,7 +49,16 @@ export function kavaTests(get: () => { wallet: core.HDWallet; info: core.HDWalle
path: core.bip32ToAddressNList("m/44'/459'/0'/0/0"),
coin: "Kava",
})
- );
+ ).toMatchInlineSnapshot(`
+ Object {
+ "accountIdx": 0,
+ "coin": "Kava",
+ "isKnown": true,
+ "isPrefork": false,
+ "verbose": "Kava Account #0",
+ "wholeAccount": true,
+ }
+ `);
},
TIMEOUT
);
@@ -88,6 +97,7 @@ export function kavaTests(get: () => { wallet: core.HDWallet; info: core.HDWalle
//expect(res?.signatures?.[0].signature).toEqual(tx_signed.signatures[0].signature_keepkey);
break;
default:
+ // eslint-disable-next-line jest/no-conditional-expect
expect(res?.signatures?.[0].signature).toEqual(tx_signed.signatures[0].signature);
break;
}
diff --git a/integration/src/osmosis/osmosis.ts b/integration/src/osmosis/osmosis.ts
index 9a5117e74..8738475ac 100644
--- a/integration/src/osmosis/osmosis.ts
+++ b/integration/src/osmosis/osmosis.ts
@@ -1,34 +1,23 @@
import * as core from "@shapeshiftoss/hdwallet-core";
-import tx_unsigned_transfer from "./tx01.mainnet.osmosis.transfer.json";
-import tx_signed_transfer from "./tx01.mainnet.osmosis.transfer.signed.json";
-
-//delgation
import tx_unsigned_delegation from "./tx01.mainnet.osmosis.delegate.json";
import tx_signed_delegation from "./tx01.mainnet.osmosis.delegate.signed.json";
-
-import tx_unigned_undelegate_osmosis from "./tx01.mainnet.osmosis.undelegate.json";
-import tx_signed_undelegate_osmosis from "./tx01.mainnet.osmosis.undelegate.signed.json";
-
-import tx_unsigned_redelegate_osmosis from "./tx01.mainnet.osmosis.redelegate.json";
-import tx_signed_redelegate_osmosis from "./tx01.mainnet.osmosis.redelegate.signed.json";
-
-import tx_unsigned_rewards_osmosis from "./tx01.mainnet.osmosis.rewards.json";
-import tx_signed_rewards_osmosis from "./tx01.mainnet.osmosis.rewards.signed.json";
-
-//LP
import tx_unsigned_lp_add_osmosis from "./tx01.mainnet.osmosis.lp-add.json";
import tx_signed_lp_add_osmosis from "./tx01.mainnet.osmosis.lp-add.signed.json";
-
import tx_unsigned_lp_remove_osmosis from "./tx01.mainnet.osmosis.lp-remove.json";
import tx_signed_lp_remove_osmosis from "./tx01.mainnet.osmosis.lp-remove.signed.json";
-
import tx_unsigned_lp_stake_osmosis from "./tx01.mainnet.osmosis.lp-stake.json";
import tx_signed_lp_stake_osmosis from "./tx01.mainnet.osmosis.lp-stake.signed.json";
-
import tx_unsigned_lp_unstake_osmosis from "./tx01.mainnet.osmosis.lp-unstake.json";
import tx_signed_lp_unstake_osmosis from "./tx01.mainnet.osmosis.lp-unstake.signed.json";
-
+import tx_unsigned_redelegate_osmosis from "./tx01.mainnet.osmosis.redelegate.json";
+import tx_signed_redelegate_osmosis from "./tx01.mainnet.osmosis.redelegate.signed.json";
+import tx_unsigned_rewards_osmosis from "./tx01.mainnet.osmosis.rewards.json";
+import tx_signed_rewards_osmosis from "./tx01.mainnet.osmosis.rewards.signed.json";
+import tx_unsigned_transfer from "./tx01.mainnet.osmosis.transfer.json";
+import tx_signed_transfer from "./tx01.mainnet.osmosis.transfer.signed.json";
+import tx_unigned_undelegate_osmosis from "./tx01.mainnet.osmosis.undelegate.json";
+import tx_signed_undelegate_osmosis from "./tx01.mainnet.osmosis.undelegate.signed.json";
const MNEMONIC12_NOPIN_NOPASSPHRASE = "alcohol woman abuse must during monitor noble actual mixed trade anger aisle";
@@ -43,7 +32,7 @@ export function osmosisTests(get: () => { wallet: core.HDWallet; info: core.HDWa
describe("Osmosis", () => {
beforeAll(async () => {
const { wallet: w } = get();
- if (core.supportsOsmosis(w)){
+ if (core.supportsOsmosis(w)) {
wallet = w;
}
});
@@ -88,7 +77,7 @@ export function osmosisTests(get: () => { wallet: core.HDWallet; info: core.HDWa
async () => {
if (!wallet) return;
const input: core.OsmosisSignTx = {
- tx: (tx_unsigned_transfer as unknown) as any,
+ tx: tx_unsigned_transfer as unknown as any,
addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
chain_id: tx_unsigned_transfer.chain_id,
account_number: tx_unsigned_transfer.account_number,
@@ -107,7 +96,7 @@ export function osmosisTests(get: () => { wallet: core.HDWallet; info: core.HDWa
async () => {
if (!wallet) return;
const input: core.OsmosisSignTx = {
- tx: (tx_unsigned_delegation as unknown) as any,
+ tx: tx_unsigned_delegation as unknown as any,
addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
chain_id: tx_unsigned_delegation.chain_id,
account_number: tx_unsigned_delegation.account_number,
@@ -125,13 +114,13 @@ export function osmosisTests(get: () => { wallet: core.HDWallet; info: core.HDWa
"(undelegate) osmosisSignTx()",
async () => {
if (!wallet) return;
- const input: core.OsmosisSignTx = {
- tx: (tx_unigned_undelegate_osmosis as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unigned_undelegate_osmosis.chain_id,
- account_number: tx_unigned_undelegate_osmosis.account_number,
- sequence: tx_unigned_undelegate_osmosis.sequence,
- };
+ const input: core.OsmosisSignTx = {
+ tx: tx_unigned_undelegate_osmosis as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unigned_undelegate_osmosis.chain_id,
+ account_number: tx_unigned_undelegate_osmosis.account_number,
+ sequence: tx_unigned_undelegate_osmosis.sequence,
+ };
const res = await wallet.osmosisSignTx(input);
expect(res?.signatures?.[0]).toEqual(tx_signed_undelegate_osmosis.signatures[0]);
@@ -139,37 +128,37 @@ export function osmosisTests(get: () => { wallet: core.HDWallet; info: core.HDWa
TIMEOUT
);
- //redelegate
- test(
- "(redelegate) osmosisSignTx()",
- async () => {
- if (!wallet) return;
- const input: core.OsmosisSignTx = {
- tx: (tx_unsigned_redelegate_osmosis as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unsigned_redelegate_osmosis.chain_id,
- account_number: tx_unsigned_redelegate_osmosis.account_number,
- sequence: tx_unsigned_redelegate_osmosis.sequence,
- };
-
- const res = await wallet.osmosisSignTx(input);
- expect(res?.signatures?.[0]).toEqual(tx_signed_redelegate_osmosis.signatures[0]);
- },
- TIMEOUT
- );
+ //redelegate
+ test(
+ "(redelegate) osmosisSignTx()",
+ async () => {
+ if (!wallet) return;
+ const input: core.OsmosisSignTx = {
+ tx: tx_unsigned_redelegate_osmosis as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unsigned_redelegate_osmosis.chain_id,
+ account_number: tx_unsigned_redelegate_osmosis.account_number,
+ sequence: tx_unsigned_redelegate_osmosis.sequence,
+ };
+
+ const res = await wallet.osmosisSignTx(input);
+ expect(res?.signatures?.[0]).toEqual(tx_signed_redelegate_osmosis.signatures[0]);
+ },
+ TIMEOUT
+ );
//claim reward
test(
"(claim) osmosisSignTx()",
async () => {
if (!wallet) return;
- const input: core.OsmosisSignTx = {
- tx: (tx_unsigned_rewards_osmosis as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unsigned_rewards_osmosis.chain_id,
- account_number: tx_unsigned_rewards_osmosis.account_number,
- sequence: tx_unsigned_rewards_osmosis.sequence,
- };
+ const input: core.OsmosisSignTx = {
+ tx: tx_unsigned_rewards_osmosis as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unsigned_rewards_osmosis.chain_id,
+ account_number: tx_unsigned_rewards_osmosis.account_number,
+ sequence: tx_unsigned_rewards_osmosis.sequence,
+ };
const res = await wallet.osmosisSignTx(input);
expect(res?.signatures?.[0]).toEqual(tx_signed_rewards_osmosis.signatures[0]);
@@ -178,78 +167,78 @@ export function osmosisTests(get: () => { wallet: core.HDWallet; info: core.HDWa
);
//lp add
- test(
- "(lp add) osmosisSignTx()",
- async () => {
- if (!wallet) return;
- const input: core.OsmosisSignTx = {
- tx: (tx_unsigned_lp_add_osmosis as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unsigned_lp_add_osmosis.chain_id,
- account_number: tx_unsigned_lp_add_osmosis.account_number,
- sequence: tx_unsigned_lp_add_osmosis.sequence,
- };
-
- const res = await wallet.osmosisSignTx(input);
- expect(res?.signatures?.[0]).toEqual(tx_signed_lp_add_osmosis.signatures[0]);
- },
- TIMEOUT
- );
-
- test(
- "(lp remove) osmosisSignTx()",
- async () => {
- if (!wallet) return;
- const input: core.OsmosisSignTx = {
- tx: (tx_unsigned_lp_remove_osmosis as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unsigned_lp_remove_osmosis.chain_id,
- account_number: tx_unsigned_lp_remove_osmosis.account_number,
- sequence: tx_unsigned_lp_remove_osmosis.sequence,
- };
-
- const res = await wallet.osmosisSignTx(input);
- expect(res?.signatures?.[0]).toEqual(tx_signed_lp_remove_osmosis.signatures[0]);
- },
- TIMEOUT
- );
+ test(
+ "(lp add) osmosisSignTx()",
+ async () => {
+ if (!wallet) return;
+ const input: core.OsmosisSignTx = {
+ tx: tx_unsigned_lp_add_osmosis as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unsigned_lp_add_osmosis.chain_id,
+ account_number: tx_unsigned_lp_add_osmosis.account_number,
+ sequence: tx_unsigned_lp_add_osmosis.sequence,
+ };
+
+ const res = await wallet.osmosisSignTx(input);
+ expect(res?.signatures?.[0]).toEqual(tx_signed_lp_add_osmosis.signatures[0]);
+ },
+ TIMEOUT
+ );
+
+ test(
+ "(lp remove) osmosisSignTx()",
+ async () => {
+ if (!wallet) return;
+ const input: core.OsmosisSignTx = {
+ tx: tx_unsigned_lp_remove_osmosis as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unsigned_lp_remove_osmosis.chain_id,
+ account_number: tx_unsigned_lp_remove_osmosis.account_number,
+ sequence: tx_unsigned_lp_remove_osmosis.sequence,
+ };
+
+ const res = await wallet.osmosisSignTx(input);
+ expect(res?.signatures?.[0]).toEqual(tx_signed_lp_remove_osmosis.signatures[0]);
+ },
+ TIMEOUT
+ );
//lp stake
- test(
- "(lp stake) osmosisSignTx()",
- async () => {
- if (!wallet) return;
- const input: core.OsmosisSignTx = {
- tx: (tx_unsigned_lp_stake_osmosis as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unsigned_lp_stake_osmosis.chain_id,
- account_number: tx_unsigned_lp_stake_osmosis.account_number,
- sequence: tx_unsigned_lp_stake_osmosis.sequence,
- };
-
- const res = await wallet.osmosisSignTx(input);
- expect(res?.signatures?.[0]).toEqual(tx_signed_lp_stake_osmosis.signatures[0]);
- },
- TIMEOUT
- );
-
- //lp unstake
- test(
- "(lp unstake) osmosisSignTx()",
- async () => {
- if (!wallet) return;
- const input: core.OsmosisSignTx = {
- tx: (tx_unsigned_lp_unstake_osmosis as unknown) as any,
- addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
- chain_id: tx_unsigned_lp_unstake_osmosis.chain_id,
- account_number: tx_unsigned_lp_unstake_osmosis.account_number,
- sequence: tx_unsigned_lp_unstake_osmosis.sequence,
- };
-
- const res = await wallet.osmosisSignTx(input);
- expect(res?.signatures?.[0]).toEqual(tx_signed_lp_unstake_osmosis.signatures[0]);
- },
- TIMEOUT
- );
+ test(
+ "(lp stake) osmosisSignTx()",
+ async () => {
+ if (!wallet) return;
+ const input: core.OsmosisSignTx = {
+ tx: tx_unsigned_lp_stake_osmosis as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unsigned_lp_stake_osmosis.chain_id,
+ account_number: tx_unsigned_lp_stake_osmosis.account_number,
+ sequence: tx_unsigned_lp_stake_osmosis.sequence,
+ };
+
+ const res = await wallet.osmosisSignTx(input);
+ expect(res?.signatures?.[0]).toEqual(tx_signed_lp_stake_osmosis.signatures[0]);
+ },
+ TIMEOUT
+ );
+
+ //lp unstake
+ test(
+ "(lp unstake) osmosisSignTx()",
+ async () => {
+ if (!wallet) return;
+ const input: core.OsmosisSignTx = {
+ tx: tx_unsigned_lp_unstake_osmosis as unknown as any,
+ addressNList: core.bip32ToAddressNList("m/44'/118'/0'/0/0"),
+ chain_id: tx_unsigned_lp_unstake_osmosis.chain_id,
+ account_number: tx_unsigned_lp_unstake_osmosis.account_number,
+ sequence: tx_unsigned_lp_unstake_osmosis.sequence,
+ };
+
+ const res = await wallet.osmosisSignTx(input);
+ expect(res?.signatures?.[0]).toEqual(tx_signed_lp_unstake_osmosis.signatures[0]);
+ },
+ TIMEOUT
+ );
});
}
diff --git a/integration/src/ripple/ripple.ts b/integration/src/ripple/ripple.ts
index 257a901de..c0bbdc46e 100644
--- a/integration/src/ripple/ripple.ts
+++ b/integration/src/ripple/ripple.ts
@@ -33,12 +33,12 @@ export function rippleTests(get: () => { wallet: core.HDWallet; info: core.HDWal
"rippleGetAccountPaths()",
() => {
if (!wallet) return;
- let paths = wallet.rippleGetAccountPaths({ accountIdx: 0 });
+ const paths = wallet.rippleGetAccountPaths({ accountIdx: 0 });
expect(paths.length > 0).toBe(true);
expect(paths[0].addressNList[0] > 0x80000000).toBe(true);
paths.forEach((path) => {
- let curAddr = path.addressNList.join();
- let nextAddr = core.mustBeDefined(wallet.rippleNextAccountPath(path)).addressNList.join();
+ const curAddr = path.addressNList.join();
+ const nextAddr = core.mustBeDefined(wallet.rippleNextAccountPath(path)).addressNList.join();
expect(nextAddr === undefined || nextAddr !== curAddr).toBeTruthy();
});
},
@@ -64,9 +64,9 @@ export function rippleTests(get: () => { wallet: core.HDWallet; info: core.HDWal
async () => {
if (!wallet) return;
- let res = await wallet.rippleSignTx({
+ const res = await wallet.rippleSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/144'/0'/0/0`),
- tx: (tx01_unsigned as unknown) as core.RippleTx,
+ tx: tx01_unsigned as unknown as core.RippleTx,
flags: undefined,
sequence: "3",
lastLedgerSequence: "0",
@@ -76,7 +76,7 @@ export function rippleTests(get: () => { wallet: core.HDWallet; info: core.HDWal
destinationTag: "1234567890",
},
});
- expect(res).toEqual((tx01_signed as unknown) as core.RippleTx);
+ expect(res).toEqual(tx01_signed as unknown as core.RippleTx);
},
TIMEOUT
);
diff --git a/integration/src/secret/secret.ts b/integration/src/secret/secret.ts
index fd53afca8..afbc6e13f 100644
--- a/integration/src/secret/secret.ts
+++ b/integration/src/secret/secret.ts
@@ -41,6 +41,7 @@ export function secretTests(get: () => { wallet: core.HDWallet; info: core.HDWal
TIMEOUT
);
+ // eslint-disable-next-line jest/no-disabled-tests
test.skip(
"describePath() secret",
async () => {
@@ -50,7 +51,7 @@ export function secretTests(get: () => { wallet: core.HDWallet; info: core.HDWal
path: core.bip32ToAddressNList("m/44'/529'/0'/0/0"),
coin: "Secret",
})
- );
+ ).toMatchInlineSnapshot();
},
TIMEOUT
);
@@ -78,9 +79,7 @@ export function secretTests(get: () => { wallet: core.HDWallet; info: core.HDWal
tx: tx_unsigned as any,
addressNList: core.bip32ToAddressNList("m/44'/529'/0'/0/0"),
chain_id: tx_verbose.accountInfo.chainId,
- // @ts-ignore
account_number: tx_verbose.accountInfo.accountNumber,
- // @ts-ignore
sequence: tx_verbose.accountInfo.sequence,
};
@@ -90,6 +89,7 @@ export function secretTests(get: () => { wallet: core.HDWallet; info: core.HDWal
//expect(res?.signatures?.[0].signature).toEqual(tx_signed.tx.signatures[0].signature_keepkey);
break;
default:
+ // eslint-disable-next-line jest/no-conditional-expect
expect(res?.signatures?.[0].signature).toEqual(tx_signed.signatures[0].signature);
break;
}
diff --git a/integration/src/terra/terra.ts b/integration/src/terra/terra.ts
index 4fea9030f..fad552278 100644
--- a/integration/src/terra/terra.ts
+++ b/integration/src/terra/terra.ts
@@ -49,7 +49,13 @@ export function terraTests(get: () => { wallet: core.HDWallet; info: core.HDWall
path: core.bip32ToAddressNList("m/44'/931'/0'/0/0"),
coin: "Terra",
})
- );
+ ).toMatchInlineSnapshot(`
+ Object {
+ "coin": "Terra",
+ "isKnown": false,
+ "verbose": "m/44'/931'/0'/0/0",
+ }
+ `);
},
TIMEOUT
);
diff --git a/integration/src/thorchain/thorchain.ts b/integration/src/thorchain/thorchain.ts
index db039200f..be1dbbbe9 100644
--- a/integration/src/thorchain/thorchain.ts
+++ b/integration/src/thorchain/thorchain.ts
@@ -2,7 +2,6 @@ import * as core from "@shapeshiftoss/hdwallet-core";
import tx_unsigned from "./tx02.mainnet.thorchain.json";
import tx_signed from "./tx02.mainnet.thorchain.signed.json";
-
import tx_unsigned_swap from "./tx03.mainnet.thorchain.swap.json";
import tx_signed_swap from "./tx03.mainnet.thorchain.swap.signed.json";
@@ -47,12 +46,36 @@ export function thorchainTests(get: () => { wallet: core.HDWallet; info: core.HD
"describePath() thorchain",
async () => {
if (!wallet) return;
- expect(
- wallet.describePath({
- path: core.bip32ToAddressNList("m/44'/931'/0'/0/0"),
- coin: "Thorchain",
- })
- );
+
+ const out = wallet.describePath({
+ path: core.bip32ToAddressNList("m/44'/931'/0'/0/0"),
+ coin: "Thorchain",
+ });
+
+ // This is strange, and probably wrong, behavior... but it's what happens.
+ if (wallet.getVendor() === "KeepKey") {
+ // eslint-disable-next-line jest/no-conditional-expect
+ expect(out).toMatchInlineSnapshot(`
+ Object {
+ "coin": "Thorchain",
+ "isKnown": false,
+ "scriptType": undefined,
+ "verbose": "m/44'/931'/0'/0/0",
+ }
+ `);
+ } else {
+ // eslint-disable-next-line jest/no-conditional-expect
+ expect(out).toMatchInlineSnapshot(`
+ Object {
+ "accountIdx": 0,
+ "coin": "Thorchain",
+ "isKnown": true,
+ "isPrefork": false,
+ "verbose": "Thorchain Account #0",
+ "wholeAccount": true,
+ }
+ `);
+ }
},
TIMEOUT
);
@@ -86,7 +109,6 @@ export function thorchainTests(get: () => { wallet: core.HDWallet; info: core.HD
const res = await wallet.thorchainSignTx(input);
expect(res?.signatures?.[0].signature).toEqual(tx_signed.signatures[0].signature);
-
},
TIMEOUT
);
@@ -104,8 +126,7 @@ export function thorchainTests(get: () => { wallet: core.HDWallet; info: core.HD
};
const res = await wallet.thorchainSignTx(input);
- expect(res?.signatures?.[0].signature).toEqual(tx_signed_swap.signatures[0].signature)
-
+ expect(res?.signatures?.[0].signature).toEqual(tx_signed_swap.signatures[0].signature);
},
TIMEOUT
);
diff --git a/integration/src/wallets/keepkey.ts b/integration/src/wallets/keepkey.ts
index a161e31e1..29d843934 100644
--- a/integration/src/wallets/keepkey.ts
+++ b/integration/src/wallets/keepkey.ts
@@ -2,11 +2,8 @@ import * as core from "@shapeshiftoss/hdwallet-core";
import * as keepkey from "@shapeshiftoss/hdwallet-keepkey";
import * as keepkeyNodeWebUSB from "@shapeshiftoss/hdwallet-keepkey-nodewebusb";
import * as keepkeyTcp from "@shapeshiftoss/hdwallet-keepkey-tcp";
-import * as debug from "debug";
import AxiosHTTPAdapter from "axios/lib/adapters/http";
-const log = debug.default("keepkey");
-
const TIMEOUT = 60 * 1000;
export function name(): string {
@@ -16,37 +13,46 @@ export function name(): string {
async function getBridge(keyring: core.Keyring) {
try {
const tcpAdapter = keepkeyTcp.TCPKeepKeyAdapter.useKeyring(keyring);
- const wallet = await tcpAdapter.pairRawDevice({
- baseURL: "http://localhost:1646",
- adapter: AxiosHTTPAdapter,
- }, true);
- if (wallet) console.log("Using KeepKey Bridge for tests");
+ const wallet = await tcpAdapter.pairRawDevice(
+ {
+ baseURL: "http://localhost:1646",
+ adapter: AxiosHTTPAdapter,
+ },
+ true
+ );
+ if (wallet) console.info("Using KeepKey Bridge for tests");
return wallet;
- } catch (e) {}
- return undefined;
+ } catch {
+ return undefined;
+ }
}
async function getDevice(keyring: core.Keyring) {
try {
const keepkeyAdapter = keepkeyNodeWebUSB.NodeWebUSBKeepKeyAdapter.useKeyring(keyring);
- let wallet = await keepkeyAdapter.pairDevice(undefined, true);
- if (wallet) console.log("Using attached WebUSB KeepKey for tests");
+ const wallet = await keepkeyAdapter.pairDevice(undefined, true);
+ if (wallet) console.info("Using attached WebUSB KeepKey for tests");
return wallet;
- } catch (e) {}
- return undefined;
+ } catch {
+ return undefined;
+ }
}
async function getEmulator(keyring: core.Keyring) {
try {
const tcpAdapter = keepkeyTcp.TCPKeepKeyAdapter.useKeyring(keyring);
- const wallet = await tcpAdapter.pairRawDevice({
- baseURL: "http://localhost:5000",
- adapter: AxiosHTTPAdapter,
- }, true);
- if (wallet) console.log("Using KeepKey Emulator for tests");
+ const wallet = await tcpAdapter.pairRawDevice(
+ {
+ baseURL: "http://localhost:5000",
+ adapter: AxiosHTTPAdapter,
+ },
+ true
+ );
+ if (wallet) console.info("Using KeepKey Emulator for tests");
return wallet;
- } catch (e) {}
- return undefined;
+ } catch {
+ return undefined;
+ }
}
let autoButton = true;
@@ -58,7 +64,7 @@ export function createInfo(): core.HDWalletInfo {
export async function createWallet(): Promise {
const keyring = new core.Keyring();
- const wallet = ((await getBridge(keyring) || await getDevice(keyring))) || (await getEmulator(keyring));
+ const wallet = (await getBridge(keyring)) || (await getDevice(keyring)) || (await getEmulator(keyring));
if (!wallet) throw new Error("No suitable test KeepKey found");
@@ -68,10 +74,6 @@ export async function createWallet(): Promise {
}
});
- wallet.transport?.onAny((event: string | string[], ...values: any[]) => {
- //console.info(event, ...values)
- });
-
return wallet;
}
@@ -79,9 +81,12 @@ export function selfTest(get: () => core.HDWallet): void {
let wallet: keepkey.KeepKeyHDWallet & core.BTCWallet & core.ETHWallet & core.HDWallet;
beforeAll(async () => {
- let w = get();
- if (keepkey.isKeepKey(w) && core.supportsBTC(w) && core.supportsETH(w)) wallet = w;
- else fail("Wallet is not a KeepKey");
+ const w = get();
+ if (keepkey.isKeepKey(w) && core.supportsBTC(w) && core.supportsETH(w)) {
+ wallet = w;
+ } else {
+ throw new Error("Wallet is not a KeepKey");
+ }
await wallet.wipe();
await wallet.loadDevice({
@@ -107,7 +112,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("uses the same BIP32 paths for ETH as the KeepKey Client", () => {
if (!wallet) return;
[0, 1, 3, 27].forEach((account) => {
- let paths = wallet.ethGetAccountPaths({
+ const paths = wallet.ethGetAccountPaths({
coin: "Ethereum",
accountIdx: account,
});
@@ -135,8 +140,8 @@ export function selfTest(get: () => core.HDWallet): void {
async () => {
if (!wallet) return;
- let addrs = [] as string[];
- await new Promise(async (resolve) => {
+ const addrs = [] as string[];
+ await new Promise((resolve) => {
wallet
.btcGetAddress({
coin: "Bitcoin",
@@ -180,6 +185,7 @@ export function selfTest(get: () => core.HDWallet): void {
// TODO: it would appear cancel is not working as expected and resulting in a hanging test.
// revisit and look into how cancel is implemented to fix and make test pass
+ // eslint-disable-next-line jest/no-disabled-tests
test.skip(
"cancel works",
async () => {
@@ -223,7 +229,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("uses correct bip44 paths", () => {
if (!wallet) return;
- let paths = wallet.btcGetAccountPaths({
+ const paths = wallet.btcGetAccountPaths({
coin: "Litecoin",
accountIdx: 3,
});
@@ -250,7 +256,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("supports ethNextAccountPath", () => {
if (!wallet) return;
- let paths = wallet.ethGetAccountPaths({
+ const paths = wallet.ethGetAccountPaths({
coin: "Ethereum",
accountIdx: 5,
});
@@ -280,7 +286,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("supports btcNextAccountPath", () => {
if (!wallet) return;
- let paths = wallet.btcGetAccountPaths({
+ const paths = wallet.btcGetAccountPaths({
coin: "Litecoin",
accountIdx: 3,
});
diff --git a/integration/src/wallets/ledger.ts b/integration/src/wallets/ledger.ts
index 498c490c4..234872274 100644
--- a/integration/src/wallets/ledger.ts
+++ b/integration/src/wallets/ledger.ts
@@ -20,7 +20,7 @@ export class MockTransport extends ledger.LedgerTransport {
method: U,
...args: Parameters>
): Promise> {
- let key = JSON.stringify({ coin: coin, method: method, args: args });
+ const key = JSON.stringify({ coin: coin, method: method, args: args });
if (!this.memoized.has(key)) {
console.error(coin, method, `JSON.parse('${JSON.stringify(args)}')`);
@@ -31,7 +31,7 @@ export class MockTransport extends ledger.LedgerTransport {
}
public memoize(coin: string | null, method: string, args: any, response: any) {
- let key = JSON.stringify({ coin: coin, method: method, args: args });
+ const key = JSON.stringify({ coin: coin, method: method, args: args });
this.memoized.set(key, response);
}
@@ -215,8 +215,8 @@ export function createInfo(): core.HDWalletInfo {
}
export async function createWallet(type: any = "Bitcoin"): Promise {
- let keyring = new core.Keyring();
- let transport = new MockTransport(keyring, type);
+ const keyring = new core.Keyring();
+ const transport = new MockTransport(keyring, type);
return ledger.create(transport as any);
}
@@ -224,9 +224,12 @@ export function selfTest(get: () => core.HDWallet): void {
let wallet: ledger.LedgerHDWallet & core.ETHWallet & core.BTCWallet & core.HDWallet;
beforeAll(async () => {
- let w = get();
- if (ledger.isLedger(w) && core.supportsBTC(w) && core.supportsETH(w)) wallet = w;
- else fail("Wallet is not a Ledger");
+ const w = get();
+ if (ledger.isLedger(w) && core.supportsBTC(w) && core.supportsETH(w)) {
+ wallet = w;
+ } else {
+ throw new Error("Wallet is not a Ledger");
+ }
});
it("supports Ethereum mainnet", async () => {
@@ -248,7 +251,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("validates current app", async () => {
if (!wallet) return;
- expect(await wallet.validateCurrentApp("Bitcoin")).resolves;
+ await expect(wallet.validateCurrentApp("Bitcoin")).resolves.not.toThrow();
await expect(wallet.validateCurrentApp(undefined)).rejects.toThrow(); // no coin
await expect(wallet.validateCurrentApp("FakeCoin")).rejects.toThrow(); // invalid coin
await expect(wallet.validateCurrentApp("Ethereum")).rejects.toThrow(); // wrong coin
@@ -257,7 +260,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("has a non-BIP 44 derivation path for Ethereum", () => {
if (!wallet) return;
[0, 1, 3, 27].forEach((account) => {
- let paths = wallet.ethGetAccountPaths({
+ const paths = wallet.ethGetAccountPaths({
coin: "Ethereum",
accountIdx: account,
});
@@ -289,7 +292,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("uses correct bip44 paths", () => {
if (!wallet) return;
- let paths = wallet.btcGetAccountPaths({
+ const paths = wallet.btcGetAccountPaths({
coin: "Litecoin",
accountIdx: 3,
});
@@ -316,10 +319,12 @@ export function selfTest(get: () => core.HDWallet): void {
it("supports btcNextAccountPath", () => {
if (!wallet) return;
- let paths = core.mustBeDefined(wallet.btcGetAccountPaths({
- coin: "Litecoin",
- accountIdx: 3,
- }));
+ const paths = core.mustBeDefined(
+ wallet.btcGetAccountPaths({
+ coin: "Litecoin",
+ accountIdx: 3,
+ })
+ );
expect(
paths
diff --git a/integration/src/wallets/metamask.ts b/integration/src/wallets/metamask.ts
index f866f5198..560096e5a 100644
--- a/integration/src/wallets/metamask.ts
+++ b/integration/src/wallets/metamask.ts
@@ -19,12 +19,12 @@ export function selfTest(get: () => core.HDWallet): void {
let wallet: metamask.MetaMaskHDWallet;
beforeAll(async () => {
- let w = get() as metamask.MetaMaskHDWallet;
+ const w = get() as metamask.MetaMaskHDWallet;
if (metamask.isMetaMask(w) && !core.supportsBTC(w) && core.supportsETH(w)) {
wallet = w;
} else {
- fail("Wallet is not a MetaMask");
+ throw new Error("Wallet is not a MetaMask");
}
});
@@ -56,7 +56,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("uses correct eth bip44 paths", () => {
if (!wallet) return;
[0, 1, 3, 27].forEach((account) => {
- let paths = wallet.ethGetAccountPaths({
+ const paths = wallet.ethGetAccountPaths({
coin: "Ethereum",
accountIdx: account,
});
@@ -119,7 +119,7 @@ export function selfTest(get: () => core.HDWallet): void {
});
});
- it('should return a valid ETH address', async () => {
+ it("should return a valid ETH address", async () => {
if (!wallet) return;
expect(
await wallet.ethGetAddress({
@@ -127,11 +127,11 @@ export function selfTest(get: () => core.HDWallet): void {
showDisplay: false,
})
).toEqual("0x3f2329C9ADFbcCd9A84f52c906E936A42dA18CB8");
- })
+ });
- it('should sign a message', async () => {
+ it("should sign a message", async () => {
if (!wallet) return;
- let res = await wallet.ethSignMessage({
+ const res = await wallet.ethSignMessage({
addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"),
message: "Hello World",
});
diff --git a/integration/src/wallets/mocks/@metamask/detect-provider.ts b/integration/src/wallets/mocks/@metamask/detect-provider.ts
index 619aef2e5..72b204a75 100644
--- a/integration/src/wallets/mocks/@metamask/detect-provider.ts
+++ b/integration/src/wallets/mocks/@metamask/detect-provider.ts
@@ -3,19 +3,21 @@ export const ethereum = {
switch (method) {
case "eth_accounts":
return ["0x3f2329C9ADFbcCd9A84f52c906E936A42dA18CB8"];
- case "personal_sign":
+ case "personal_sign": {
const [message] = params;
- if (message === '48656c6c6f20576f726c64')
- return '0x29f7212ecc1c76cea81174af267b67506f754ea8c73f144afa900a0d85b24b21319621aeb062903e856352f38305710190869c3ce5a1425d65ef4fa558d0fc251b'
+ if (message === "48656c6c6f20576f726c64")
+ return "0x29f7212ecc1c76cea81174af267b67506f754ea8c73f144afa900a0d85b24b21319621aeb062903e856352f38305710190869c3ce5a1425d65ef4fa558d0fc251b";
- throw new Error('unknown message');
- case "eth_sendTransaction":
+ throw new Error("unknown message");
+ }
+ case "eth_sendTransaction": {
const [{ to }] = params;
return `txHash-${to}`;
+ }
default:
throw new Error(`ethereum: Unkown method ${method}`);
}
- })
-}
\ No newline at end of file
+ }),
+};
diff --git a/integration/src/wallets/native.ts b/integration/src/wallets/native.ts
index 9acb1a8d5..0b24af35b 100644
--- a/integration/src/wallets/native.ts
+++ b/integration/src/wallets/native.ts
@@ -3,6 +3,7 @@ import * as native from "@shapeshiftoss/hdwallet-native";
import * as _ from "lodash";
// TODO: clean this up
+// eslint-disable-next-line jest/no-mocks-import
import mswMock from "../../../packages/hdwallet-native/__mocks__/mswMock";
const mnemonic = "all all all all all all all all all all all all";
@@ -16,13 +17,6 @@ export function createInfo(): core.HDWalletInfo {
return native.info();
}
-export async function createWallet(): Promise {
- const mswMock = await setupMswMocks();
- const wallet = new native.NativeHDWallet({ mnemonic, deviceId });
- await wallet.initialize();
- return wallet;
-}
-
export async function setupMswMocks() {
const binanceMocks = {
get: {
@@ -173,16 +167,23 @@ export async function setupMswMocks() {
return mswMock(_.merge({}, binanceMocks, fioMocks)).startServer();
}
+export async function createWallet(): Promise {
+ await setupMswMocks();
+ const wallet = new native.NativeHDWallet({ mnemonic, deviceId });
+ await wallet.initialize();
+ return wallet;
+}
+
export function selfTest(get: () => core.HDWallet): void {
let wallet: native.NativeHDWallet;
beforeAll(async () => {
- let w = get() as native.NativeHDWallet;
+ const w = get() as native.NativeHDWallet;
if (native.isNative(w) && core.supportsBTC(w) && core.supportsETH(w)) {
wallet = w;
} else {
- fail("Wallet is not native");
+ throw new Error("Wallet is not native");
}
});
@@ -206,7 +207,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("uses correct eth bip44 paths", () => {
if (!wallet) return;
[0, 1, 3, 27].forEach((account) => {
- let paths = core.mustBeDefined(
+ const paths = core.mustBeDefined(
wallet.ethGetAccountPaths({
coin: "Ethereum",
accountIdx: account,
@@ -234,7 +235,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("uses correct btc bip44 paths", () => {
if (!wallet) return;
- let paths = wallet.btcGetAccountPaths({
+ const paths = wallet.btcGetAccountPaths({
coin: "Litecoin",
accountIdx: 3,
});
@@ -258,10 +259,11 @@ export function selfTest(get: () => core.HDWallet): void {
]);
});
+ // eslint-disable-next-line jest/no-disabled-tests
it.skip("supports ethNextAccountPath", () => {
if (!wallet) return;
- let paths = core.mustBeDefined(
+ const paths = core.mustBeDefined(
wallet.ethGetAccountPaths({
coin: "Ethereum",
accountIdx: 5,
@@ -293,7 +295,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("supports btcNextAccountPath", () => {
if (!wallet) return;
- let paths = core.mustBeDefined(
+ const paths = core.mustBeDefined(
wallet.btcGetAccountPaths({
coin: "Litecoin",
accountIdx: 3,
@@ -400,6 +402,7 @@ export function selfTest(get: () => core.HDWallet): void {
});
});
+ // eslint-disable-next-line jest/no-disabled-tests
it.skip("can describe prefork BitcoinCash", () => {
expect(
wallet.describePath({
@@ -420,6 +423,7 @@ export function selfTest(get: () => core.HDWallet): void {
});
});
+ // eslint-disable-next-line jest/no-disabled-tests
it.skip("can describe prefork Segwit Native BTG", () => {
expect(
wallet.describePath({
@@ -440,26 +444,7 @@ export function selfTest(get: () => core.HDWallet): void {
});
});
- it.skip("can describe Bitcoin Change Addresses", () => {
- expect(
- wallet.describePath({
- path: core.bip32ToAddressNList("m/44'/0'/7'/1/5"),
- coin: "Bitcoin",
- scriptType: core.BTCInputScriptType.SpendAddress,
- })
- ).toEqual({
- verbose: "Bitcoin Account #7, Change Address #5 (Legacy)",
- coin: "Bitcoin",
- isKnown: true,
- scriptType: core.BTCInputScriptType.SpendAddress,
- accountIdx: 7,
- addressIdx: 5,
- wholeAccount: false,
- isChange: true,
- isPrefork: false,
- });
- });
-
+ // eslint-disable-next-line jest/no-disabled-tests
it.skip("can describe prefork paths", () => {
expect(
wallet.describePath({
diff --git a/integration/src/wallets/portis.ts b/integration/src/wallets/portis.ts
index 785e2d6d4..86df653c3 100644
--- a/integration/src/wallets/portis.ts
+++ b/integration/src/wallets/portis.ts
@@ -17,8 +17,7 @@ const mockSignEthTxResponse = {
s: "0x28297d012cccf389f6332415e96ee3fc0bbf8474d05f646e029cd281a031464b",
v: 38,
},
- raw:
- "0xf86b018501dcd650008256229412ec06288edd7ae2cc41a843fe089237fc7354f0872c68af0bb140008026a063db3dd3bf3e1fe7dde1969c0fc8850e34116d0b501c0483a0e08c0f77b8ce0aa028297d012cccf389f6332415e96ee3fc0bbf8474d05f646e029cd281a031464b",
+ raw: "0xf86b018501dcd650008256229412ec06288edd7ae2cc41a843fe089237fc7354f0872c68af0bb140008026a063db3dd3bf3e1fe7dde1969c0fc8850e34116d0b501c0483a0e08c0f77b8ce0aa028297d012cccf389f6332415e96ee3fc0bbf8474d05f646e029cd281a031464b",
};
const mockSignERC20TxResponse = {
@@ -27,8 +26,7 @@ const mockSignERC20TxResponse = {
s: "0x10efa4dd6fdb381c317db8f815252c2ac0d2a883bd364901dee3dec5b7d3660a",
v: 37,
},
- raw:
- "0xf8a20114149441e5560054824ea6b0732e656e3ad64e20e94e4580b844a9059cbb0000000000000000000000001d8ce9022f6284c3a5c317f8f34620107214e54500000000000000000000000000000000000000000000000000000002540be40025a01238fd332545415f09a01470350a5a20abc784dbf875cf58f7460560e66c597fa010efa4dd6fdb381c317db8f815252c2ac0d2a883bd364901dee3dec5b7d3660a",
+ raw: "0xf8a20114149441e5560054824ea6b0732e656e3ad64e20e94e4580b844a9059cbb0000000000000000000000001d8ce9022f6284c3a5c317f8f34620107214e54500000000000000000000000000000000000000000000000000000002540be40025a01238fd332545415f09a01470350a5a20abc784dbf875cf58f7460560e66c597fa010efa4dd6fdb381c317db8f815252c2ac0d2a883bd364901dee3dec5b7d3660a",
};
export async function createWallet(): Promise {
@@ -64,9 +62,12 @@ export function selfTest(get: () => core.HDWallet): void {
let wallet: portis.PortisHDWallet & core.ETHWallet & core.HDWallet;
beforeAll(() => {
- let w = get();
- if (portis.isPortis(w) && core.supportsETH(w)) wallet = w;
- else fail("Wallet is not Portis");
+ const w = get();
+ if (portis.isPortis(w) && core.supportsETH(w)) {
+ wallet = w;
+ } else {
+ throw new Error("Wallet is not Portis");
+ }
});
it("supports Ethereum mainnet", async () => {
@@ -81,10 +82,12 @@ export function selfTest(get: () => core.HDWallet): void {
it("does not support more than one account path", async () => {
if (!wallet) return;
- const paths = core.mustBeDefined(await wallet.ethGetAccountPaths({
- coin: "Ethereum",
- accountIdx: 0,
- }));
+ const paths = core.mustBeDefined(
+ await wallet.ethGetAccountPaths({
+ coin: "Ethereum",
+ accountIdx: 0,
+ })
+ );
expect(paths.length).toEqual(1);
const nextPath = await wallet.ethNextAccountPath(paths[0]);
expect(nextPath).toBeUndefined();
diff --git a/integration/src/wallets/trezor.ts b/integration/src/wallets/trezor.ts
index 1c06c8ea4..e8e5b3add 100644
--- a/integration/src/wallets/trezor.ts
+++ b/integration/src/wallets/trezor.ts
@@ -13,8 +13,8 @@ export class MockTransport extends trezor.TrezorTransport {
return "mock#1";
}
- public call(method: string, msg: any, msTimeout?: number): Promise {
- let key = JSON.stringify({ method: method, msg: msg });
+ public call(method: string, msg: any): Promise {
+ const key = JSON.stringify({ method: method, msg: msg });
if (!this.memoized.has(key)) {
console.error(method, `JSON.parse('${JSON.stringify(msg)}')`);
throw new Error("mock not yet recorded for arguments");
@@ -27,7 +27,7 @@ export class MockTransport extends trezor.TrezorTransport {
}
public memoize(method: string, msg: any, response: any) {
- let key = JSON.stringify({ method: method, msg: msg });
+ const key = JSON.stringify({ method: method, msg: msg });
this.memoized.set(key, response);
}
@@ -66,8 +66,7 @@ export class MockTransport extends trezor.TrezorTransport {
transaction: {
to: "0x41e5560054824ea6b0732e656e3ad64e20e94e45",
value: "0x00",
- data:
- "0xa9059cbb0000000000000000000000001d8ce9022f6284c3a5c317f8f34620107214e54500000000000000000000000000000000000000000000000000000002540be400",
+ data: "0xa9059cbb0000000000000000000000001d8ce9022f6284c3a5c317f8f34620107214e54500000000000000000000000000000000000000000000000000000002540be400",
chainId: 1,
nonce: "0x01",
gasLimit: "0x14",
@@ -120,9 +119,7 @@ export class MockTransport extends trezor.TrezorTransport {
try {
this.memoize(
"getAddress",
- JSON.parse(
- '{"path":"m/49\'/0\'/0\'/0/0","showOnTrezor":true,"coin":"btc"}'
- ),
+ JSON.parse('{"path":"m/49\'/0\'/0\'/0/0","showOnTrezor":true,"coin":"btc"}'),
JSON.parse(
'{"payload":{"address":"3AnYTd2FGxJLNKL1AzxfW3FJMntp9D2KKX","path":[2147483697,2147483648,2147483648,0,0],"serializedPath":"m/49\'/0\'/0\'/0/0"},"id":2,"success":true}'
)
@@ -185,9 +182,7 @@ export class MockTransport extends trezor.TrezorTransport {
this.memoize("wipeDevice", {}, { success: true });
this.memoize(
"getAddress",
- JSON.parse(
- '{"path":"m/44\'/0\'/0\'/0/0","showOnTrezor":false,"coin":"btc"}'
- ),
+ JSON.parse('{"path":"m/44\'/0\'/0\'/0/0","showOnTrezor":false,"coin":"btc"}'),
JSON.parse(
'{"payload":{"address":"1FH6ehAd5ZFXCM1cLGzHxK1s4dGdq1JusM","path":[2147483692,2147483648,2147483648,0,0],"serializedPath":"m/44\'/0\'/0\'/0/0"},"id":2,"success":true}'
)
@@ -203,27 +198,21 @@ export class MockTransport extends trezor.TrezorTransport {
);
this.memoize(
"getAddress",
- JSON.parse(
- '{"path":"m/49\'/2\'/0\'/0/0","showOnTrezor":false,"coin":"ltc"}'
- ),
+ JSON.parse('{"path":"m/49\'/2\'/0\'/0/0","showOnTrezor":false,"coin":"ltc"}'),
JSON.parse(
'{"payload":{"address":"MFoQRU1KQq365Sy3cXhix3ygycEU4YWB1V","path":[2147483697,2147483650,2147483648,0,0],"serializedPath":"m/49\'/2\'/0\'/0/0"},"id":2,"success":true}'
)
);
this.memoize(
"getAddress",
- JSON.parse(
- '{"path":"m/44\'/5\'/0\'/0/0","showOnTrezor":false,"coin":"dash"}'
- ),
+ JSON.parse('{"path":"m/44\'/5\'/0\'/0/0","showOnTrezor":false,"coin":"dash"}'),
JSON.parse(
'{"payload":{"address":"XxKhGNv6ECbqVswm9KYcLPQnyWgZ86jJ6Q","path":[2147483692,2147483653,2147483648,0,0],"serializedPath":"m/44\'/5\'/0\'/0/0"},"id":2,"success":true}'
)
);
this.memoize(
"getAddress",
- JSON.parse(
- '{"path":"m/44\'/2\'/0\'/0/0","showOnTrezor":false,"coin":"ltc"}'
- ),
+ JSON.parse('{"path":"m/44\'/2\'/0\'/0/0","showOnTrezor":false,"coin":"ltc"}'),
JSON.parse(
'{"payload":{"address":"LYXTv5RdsPYKC4qGmb6x6SuKoFMxUdSjLQ","path":[2147483692,2147483650,2147483648,0,0],"serializedPath":"m/44\'/2\'/0\'/0/0"},"id":2,"success":true}'
)
@@ -239,18 +228,14 @@ export class MockTransport extends trezor.TrezorTransport {
);
this.memoize(
"getAddress",
- JSON.parse(
- '{"path":"m/84\'/2\'/0\'/0/0","showOnTrezor":false,"coin":"ltc"}'
- ),
+ JSON.parse('{"path":"m/84\'/2\'/0\'/0/0","showOnTrezor":false,"coin":"ltc"}'),
JSON.parse(
'{"payload":{"address":"ltc1qf6pwfkw4wd0fetq2pfrwzlfknskjg6nyvt6ngv","path":[2147483732,2147483650,2147483648,0,0],"serializedPath":"m/84\'/2\'/0\'/0/0"},"id":2,"success":true}'
)
);
this.memoize(
"getAddress",
- JSON.parse(
- '{"path":"m/84\'/2\'/0\'/0/0","showOnTrezor":false,"coin":"ltc"}'
- ),
+ JSON.parse('{"path":"m/84\'/2\'/0\'/0/0","showOnTrezor":false,"coin":"ltc"}'),
JSON.parse(
'{"payload":{"address":"ltc1qf6pwfkw4wd0fetq2pfrwzlfknskjg6nyvt6ngv","path":[2147483732,2147483650,2147483648,0,0],"serializedPath":"m/84\'/2\'/0\'/0/0"},"id":2,"success":true}'
)
@@ -271,18 +256,14 @@ export class MockTransport extends trezor.TrezorTransport {
);
this.memoize(
"getAddress",
- JSON.parse(
- '{"path":"m/49\'/0\'/0\'/0/0","showOnTrezor":false,"coin":"btc"}'
- ),
+ JSON.parse('{"path":"m/49\'/0\'/0\'/0/0","showOnTrezor":false,"coin":"btc"}'),
JSON.parse(
'{"payload":{"address":"3AnYTd2FGxJLNKL1AzxfW3FJMntp9D2KKX","path":[2147483697,2147483648,2147483648,0,0],"serializedPath":"m/49\'/0\'/0\'/0/0"},"id":2,"success":true}'
)
);
this.memoize(
"getAddress",
- JSON.parse(
- '{"path":"m/49\'/0\'/0\'/0/0","showOnTrezor":false,"coin":"btc"}'
- ),
+ JSON.parse('{"path":"m/49\'/0\'/0\'/0/0","showOnTrezor":false,"coin":"btc"}'),
JSON.parse(
'{"payload":{"address":"3AnYTd2FGxJLNKL1AzxfW3FJMntp9D2KKX","path":[2147483697,2147483648,2147483648,0,0],"serializedPath":"m/49\'/0\'/0\'/0/0"},"id":2,"success":true}'
)
@@ -353,8 +334,8 @@ export function name(): string {
}
export async function createWallet(): Promise {
- let keyring = new core.Keyring();
- let transport = new MockTransport(keyring);
+ const keyring = new core.Keyring();
+ const transport = new MockTransport(keyring);
return trezor.create(transport as trezor.TrezorTransport);
}
@@ -366,9 +347,12 @@ export function selfTest(get: () => core.HDWallet): void {
let wallet: trezor.TrezorHDWallet & core.ETHWallet & core.BTCWallet & core.HDWallet;
beforeAll(async () => {
- let w = get();
- if (trezor.isTrezor(w) && core.supportsBTC(w) && core.supportsETH(w)) wallet = w;
- else fail("Wallet is not a Trezor");
+ const w = get();
+ if (trezor.isTrezor(w) && core.supportsBTC(w) && core.supportsETH(w)) {
+ wallet = w;
+ } else {
+ throw new Error("Wallet is not a Trezor");
+ }
});
it("supports Ethereum mainnet", async () => {
@@ -391,7 +375,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("uses the same BIP32 paths for ETH as wallet.trezor.io", () => {
if (!wallet) return;
[0, 1, 3, 27].forEach((account) => {
- let paths = wallet.ethGetAccountPaths({
+ const paths = wallet.ethGetAccountPaths({
coin: "Ethereum",
accountIdx: account,
});
@@ -417,7 +401,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("uses correct bip44 paths", () => {
if (!wallet) return;
- let paths = wallet.btcGetAccountPaths({
+ const paths = wallet.btcGetAccountPaths({
coin: "Litecoin",
accountIdx: 3,
});
@@ -444,7 +428,7 @@ export function selfTest(get: () => core.HDWallet): void {
it("supports btcNextAccountPath", () => {
if (!wallet) return;
- let paths = core.mustBeDefined(
+ const paths = core.mustBeDefined(
wallet.btcGetAccountPaths({
coin: "Litecoin",
accountIdx: 3,
diff --git a/integration/src/wallets/xdefi.ts b/integration/src/wallets/xdefi.ts
index 1e5e0d989..155077d27 100644
--- a/integration/src/wallets/xdefi.ts
+++ b/integration/src/wallets/xdefi.ts
@@ -54,26 +54,28 @@ export async function createWallet(): Promise {
case "eth_accounts":
case "eth_requestAccounts":
return ["0x3f2329C9ADFbcCd9A84f52c906E936A42dA18CB8"];
- case "personal_sign":
+ case "personal_sign": {
const [message] = params;
if (message === "48656c6c6f20576f726c64")
return "0x29f7212ecc1c76cea81174af267b67506f754ea8c73f144afa900a0d85b24b21319621aeb062903e856352f38305710190869c3ce5a1425d65ef4fa558d0fc251b";
throw new Error("unknown message");
- case "eth_sendTransaction":
+ }
+ case "eth_sendTransaction": {
const [{ to }] = params;
return `txHash-${to}`;
+ }
default:
throw new Error(`ethereum: Unknown method ${method}`);
}
- })
- }
+ }),
+ },
};
- const adapter = xdefi.XDeFiAdapter.useKeyring(new core.Keyring())
- const wallet = await adapter.pairDevice()
+ const adapter = xdefi.XDeFiAdapter.useKeyring(new core.Keyring());
+ const wallet = await adapter.pairDevice();
wallet.ethSignTx = jest
.fn()
@@ -107,9 +109,12 @@ export function selfTest(get: () => core.HDWallet): void {
let wallet: xdefi.XDeFiHDWallet & core.ETHWallet & core.HDWallet;
beforeAll(() => {
- let w = get();
- if (xdefi.isXDeFi(w) && core.supportsETH(w)) wallet = w;
- else fail("Wallet is not XDeFi");
+ const w = get();
+ if (xdefi.isXDeFi(w) && core.supportsETH(w)) {
+ wallet = w;
+ } else {
+ throw new Error("Wallet is not XDeFi");
+ }
});
it("supports Ethereum mainnet", async () => {
diff --git a/jest.config.js b/jest.config.js
index 75e9a335c..9ca106c39 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -11,10 +11,10 @@ module.exports = {
"^@shapeshiftoss/hdwallet-(.*)": "/hdwallet-$1/src",
},
globals: {
- 'ts-jest': {
+ "ts-jest": {
diagnostics: {
ignoreCodes: [7016],
- }
+ },
},
},
setupFiles: ["fake-indexeddb/auto"],
diff --git a/package.json b/package.json
index 164073348..820f7a126 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,8 @@
},
"scripts": {
"clean": "lerna run clean --scope @shapeshiftoss/* && rm -rf coverage test-report node_modules && yarn cache clean",
+ "lint": "eslint --cache --max-warnings=0 .",
+ "lint:fix": "yarn lint --fix",
"lint:ts": "tsc --noEmit",
"format": "prettier .",
"build": "yarn tsc --build",
@@ -35,6 +37,13 @@
"postinstall": "patch-package"
},
"devDependencies": {
+ "@typescript-eslint/eslint-plugin": "^5.14.0",
+ "@typescript-eslint/parser": "^5.14.0",
+ "eslint": "^8.10.0",
+ "eslint-config-prettier": "8.5.0",
+ "eslint-plugin-jest": "26.1.1",
+ "eslint-plugin-prettier": "4.0.0",
+ "eslint-plugin-simple-import-sort": "^7.0.0",
"fake-indexeddb": "^3.1.7",
"jest": "^26.6.3",
"jest-environment-jsdom": "^25.5.0",
diff --git a/packages/hdwallet-core/src/binance.ts b/packages/hdwallet-core/src/binance.ts
index cba8e74b2..f9542bb9d 100644
--- a/packages/hdwallet-core/src/binance.ts
+++ b/packages/hdwallet-core/src/binance.ts
@@ -6,7 +6,9 @@ export interface BinanceGetAddress {
showDisplay?: boolean;
}
+// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Binance {
+ // eslint-disable-next-line @typescript-eslint/no-namespace
namespace sdk {
export type Coins = Coin[];
@@ -100,8 +102,8 @@ export interface BinanceWallet extends BinanceWalletInfo, HDWallet {
}
export function binanceDescribePath(path: BIP32Path): PathDescription {
- let pathStr = addressNListToBIP32(path);
- let unknown: PathDescription = {
+ const pathStr = addressNListToBIP32(path);
+ const unknown: PathDescription = {
verbose: pathStr,
coin: "Binance",
isKnown: false,
@@ -127,7 +129,7 @@ export function binanceDescribePath(path: BIP32Path): PathDescription {
return unknown;
}
- let index = path[2] & 0x7fffffff;
+ const index = path[2] & 0x7fffffff;
return {
verbose: `Binance Account #${index}`,
accountIdx: index,
diff --git a/packages/hdwallet-core/src/bitcoin.ts b/packages/hdwallet-core/src/bitcoin.ts
index 1ab52165e..1676c413a 100644
--- a/packages/hdwallet-core/src/bitcoin.ts
+++ b/packages/hdwallet-core/src/bitcoin.ts
@@ -388,7 +388,7 @@ export function describeUTXOPath(path: BIP32Path, coin: Coin, scriptType: BTCInp
if ((path[0] & 0x80000000) >>> 0 !== 0x80000000) return unknown;
- let purpose = path[0] & 0x7fffffff;
+ const purpose = path[0] & 0x7fffffff;
if (![44, 49, 84].includes(purpose)) return unknown;
@@ -396,9 +396,9 @@ export function describeUTXOPath(path: BIP32Path, coin: Coin, scriptType: BTCInp
if (purpose === 49 && scriptType !== BTCInputScriptType.SpendP2SHWitness) return unknown;
- let wholeAccount = path.length === 3;
+ const wholeAccount = path.length === 3;
- let script = (
+ const script = (
{
[BTCInputScriptType.SpendAddress]: ["Legacy"],
[BTCInputScriptType.SpendP2SHWitness]: [],
@@ -445,9 +445,9 @@ export function describeUTXOPath(path: BIP32Path, coin: Coin, scriptType: BTCInp
break;
}
- let attr = attributes.length ? ` (${attributes.join(", ")})` : "";
+ const attr = attributes.length ? ` (${attributes.join(", ")})` : "";
- let accountIdx = path[2] & 0x7fffffff;
+ const accountIdx = path[2] & 0x7fffffff;
if (wholeAccount) {
return {
@@ -460,8 +460,8 @@ export function describeUTXOPath(path: BIP32Path, coin: Coin, scriptType: BTCInp
isPrefork,
};
} else {
- let change = path[3] === 1 ? "Change " : "";
- let addressIdx = path[4];
+ const change = path[3] === 1 ? "Change " : "";
+ const addressIdx = path[4];
return {
coin,
verbose: `${coin} Account #${accountIdx}, ${change}Address #${addressIdx}${attr}`,
diff --git a/packages/hdwallet-core/src/cosmos.ts b/packages/hdwallet-core/src/cosmos.ts
index 1eedd664d..d2393abc9 100644
--- a/packages/hdwallet-core/src/cosmos.ts
+++ b/packages/hdwallet-core/src/cosmos.ts
@@ -6,6 +6,7 @@ export interface CosmosGetAddress {
showDisplay?: boolean;
}
+// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Cosmos {
export interface Msg {
type: string;
@@ -24,6 +25,7 @@ export namespace Cosmos {
gas: string;
}
+ // eslint-disable-next-line @typescript-eslint/no-namespace
namespace crypto {
export interface PubKey {
type: string;
@@ -61,10 +63,10 @@ export interface CosmosSignTx {
}
export interface CosmosSignedTx {
- serialized: string
- body: string
- authInfoBytes: string
- signatures: string[]
+ serialized: string;
+ body: string;
+ authInfoBytes: string;
+ signatures: string[];
}
export interface CosmosGetAccountPaths {
@@ -98,8 +100,8 @@ export interface CosmosWallet extends CosmosWalletInfo, HDWallet {
}
export function cosmosDescribePath(path: BIP32Path): PathDescription {
- let pathStr = addressNListToBIP32(path);
- let unknown: PathDescription = {
+ const pathStr = addressNListToBIP32(path);
+ const unknown: PathDescription = {
verbose: pathStr,
coin: "Atom",
isKnown: false,
@@ -125,7 +127,7 @@ export function cosmosDescribePath(path: BIP32Path): PathDescription {
return unknown;
}
- let index = path[2] & 0x7fffffff;
+ const index = path[2] & 0x7fffffff;
return {
verbose: `Cosmos Account #${index}`,
accountIdx: index,
diff --git a/packages/hdwallet-core/src/eos.ts b/packages/hdwallet-core/src/eos.ts
index 73201f418..42548568d 100644
--- a/packages/hdwallet-core/src/eos.ts
+++ b/packages/hdwallet-core/src/eos.ts
@@ -18,6 +18,7 @@ export interface eosNextAccountPath {
accountIdx: number;
}
+// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Eos {
export interface EosPermissionLevel {
actor: string;
@@ -50,6 +51,7 @@ export interface EosToSignTx {
}
/* device response asking for next action */
+// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface EosTxActionRequest {}
/*
diff --git a/packages/hdwallet-core/src/ethereum.ts b/packages/hdwallet-core/src/ethereum.ts
index db1a6ec03..25d4908b7 100644
--- a/packages/hdwallet-core/src/ethereum.ts
+++ b/packages/hdwallet-core/src/ethereum.ts
@@ -1,5 +1,5 @@
import { addressNListToBIP32, slip44ByCoin } from "./utils";
-import { ExchangeType, BIP32Path, HDWallet, HDWalletInfo, PathDescription } from "./wallet";
+import { BIP32Path, ExchangeType, HDWallet, HDWalletInfo, PathDescription } from "./wallet";
export enum ETHTransactionType {
ETH_TX_TYPE_LEGACY = 0,
@@ -142,8 +142,8 @@ export interface ETHWallet extends ETHWalletInfo, HDWallet {
}
export function describeETHPath(path: BIP32Path): PathDescription {
- let pathStr = addressNListToBIP32(path);
- let unknown: PathDescription = {
+ const pathStr = addressNListToBIP32(path);
+ const unknown: PathDescription = {
verbose: pathStr,
coin: "Ethereum",
isKnown: false,
@@ -161,7 +161,7 @@ export function describeETHPath(path: BIP32Path): PathDescription {
if (path[4] !== 0) return unknown;
- let index = path[2] & 0x7fffffff;
+ const index = path[2] & 0x7fffffff;
return {
verbose: `Ethereum Account #${index}`,
accountIdx: index,
diff --git a/packages/hdwallet-core/src/fio.ts b/packages/hdwallet-core/src/fio.ts
index f8da72547..be8e411fd 100644
--- a/packages/hdwallet-core/src/fio.ts
+++ b/packages/hdwallet-core/src/fio.ts
@@ -18,6 +18,7 @@ export interface FioNextAccountPath {
accountIdx: number;
}
+// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Fio {
export interface PermissionLevel {
actor?: string;
@@ -229,8 +230,8 @@ export interface FioWallet extends FioWalletInfo, HDWallet {
}
export function fioDescribePath(path: BIP32Path): PathDescription {
- let pathStr = addressNListToBIP32(path);
- let unknown: PathDescription = {
+ const pathStr = addressNListToBIP32(path);
+ const unknown: PathDescription = {
verbose: pathStr,
coin: "Fio",
isKnown: false,
@@ -256,7 +257,7 @@ export function fioDescribePath(path: BIP32Path): PathDescription {
return unknown;
}
- let index = path[2] & 0x7fffffff;
+ const index = path[2] & 0x7fffffff;
return {
verbose: `Fio Account #${index}`,
accountIdx: index,
diff --git a/packages/hdwallet-core/src/kava.ts b/packages/hdwallet-core/src/kava.ts
index 17d33d685..dae27f3bf 100644
--- a/packages/hdwallet-core/src/kava.ts
+++ b/packages/hdwallet-core/src/kava.ts
@@ -7,6 +7,7 @@ export interface KavaGetAddress {
testnet?: boolean;
}
+// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Kava {
export interface Msg {
type: string;
@@ -25,6 +26,7 @@ export namespace Kava {
gas: string;
}
+ // eslint-disable-next-line @typescript-eslint/no-namespace
namespace crypto {
export interface PubKey {
type: string;
@@ -95,8 +97,8 @@ export interface KavaWallet extends KavaWalletInfo, HDWallet {
}
export function kavaDescribePath(path: BIP32Path): PathDescription {
- let pathStr = addressNListToBIP32(path);
- let unknown: PathDescription = {
+ const pathStr = addressNListToBIP32(path);
+ const unknown: PathDescription = {
verbose: pathStr,
coin: "Kava",
isKnown: false,
@@ -122,7 +124,7 @@ export function kavaDescribePath(path: BIP32Path): PathDescription {
return unknown;
}
- let index = path[2] & 0x7fffffff;
+ const index = path[2] & 0x7fffffff;
return {
verbose: `Kava Account #${index}`,
accountIdx: index,
diff --git a/packages/hdwallet-core/src/keyring.ts b/packages/hdwallet-core/src/keyring.ts
index ca9de78fb..4701eb654 100644
--- a/packages/hdwallet-core/src/keyring.ts
+++ b/packages/hdwallet-core/src/keyring.ts
@@ -33,11 +33,13 @@ export class Keyring extends eventemitter2.EventEmitter2 {
}
public async exec(method: string, ...args: any[]): Promise<{ [deviceID: string]: any }> {
- return Promise.all(Object.values(this.wallets).map((w) => {
- const fn: unknown = (w as any)[method];
- if (typeof fn !== "function") throw new Error(`can't exec non-existent method ${method}`);
- return fn.call(w, ...args);
- })).then((values) =>
+ return Promise.all(
+ Object.values(this.wallets).map((w) => {
+ const fn: unknown = (w as any)[method];
+ if (typeof fn !== "function") throw new Error(`can't exec non-existent method ${method}`);
+ return fn.call(w, ...args);
+ })
+ ).then((values) =>
values.reduce((final, response, i) => {
final[Object.keys(this.wallets)[i]] = response;
return final;
@@ -62,7 +64,7 @@ export class Keyring extends eventemitter2.EventEmitter2 {
} catch (e) {
console.error(e);
} finally {
- let aliasee = this.aliases[deviceID];
+ const aliasee = this.aliases[deviceID];
if (aliasee) {
delete this.aliases[deviceID];
delete this.wallets[aliasee];
@@ -88,6 +90,8 @@ export class Keyring extends eventemitter2.EventEmitter2 {
const wallet: HDWallet | null = this.get(deviceID);
if (!wallet) return;
const vendor: string = wallet.getVendor();
- events.onAny((e: string | string[], ...values: any[]) => this.emit([vendor, deviceID, (typeof e === "string" ? e : e.join(";"))], [deviceID, ...values]));
+ events.onAny((e: string | string[], ...values: any[]) =>
+ this.emit([vendor, deviceID, typeof e === "string" ? e : e.join(";")], [deviceID, ...values])
+ );
}
}
diff --git a/packages/hdwallet-core/src/osmosis.ts b/packages/hdwallet-core/src/osmosis.ts
index e239a65fc..9b616101d 100644
--- a/packages/hdwallet-core/src/osmosis.ts
+++ b/packages/hdwallet-core/src/osmosis.ts
@@ -6,6 +6,7 @@ export interface OsmosisGetAddress {
showDisplay?: boolean;
}
+// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Osmosis {
export interface Msg {
type: string;
@@ -24,6 +25,7 @@ export namespace Osmosis {
gas: string;
}
+ // eslint-disable-next-line @typescript-eslint/no-namespace
namespace crypto {
export interface PubKey {
type: string;
@@ -61,10 +63,10 @@ export interface OsmosisSignTx {
}
export interface OsmosisSignedTx {
- serialized: string
- body: string
- authInfoBytes: string
- signatures: string[]
+ serialized: string;
+ body: string;
+ authInfoBytes: string;
+ signatures: string[];
}
export interface OsmosisGetAccountPaths {
@@ -98,8 +100,8 @@ export interface OsmosisWallet extends OsmosisWalletInfo, HDWallet {
}
export function osmosisDescribePath(path: BIP32Path): PathDescription {
- let pathStr = addressNListToBIP32(path);
- let unknown: PathDescription = {
+ const pathStr = addressNListToBIP32(path);
+ const unknown: PathDescription = {
verbose: pathStr,
coin: "Atom",
isKnown: false,
@@ -125,7 +127,7 @@ export function osmosisDescribePath(path: BIP32Path): PathDescription {
return unknown;
}
- let index = path[2] & 0x7fffffff;
+ const index = path[2] & 0x7fffffff;
return {
verbose: `Osmosis Account #${index}`,
accountIdx: index,
diff --git a/packages/hdwallet-core/src/ripple.ts b/packages/hdwallet-core/src/ripple.ts
index 5747a4a61..41d437f6c 100644
--- a/packages/hdwallet-core/src/ripple.ts
+++ b/packages/hdwallet-core/src/ripple.ts
@@ -4,7 +4,10 @@ export interface RippleGetAddress {
addressNList: BIP32Path;
showDisplay?: boolean;
}
+
+// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Ripple {
+ // eslint-disable-next-line @typescript-eslint/no-namespace
namespace sdk {
interface Msg {
type: string;
@@ -21,6 +24,8 @@ declare namespace Ripple {
amount: sdk.Coins;
gas: string;
}
+
+ // eslint-disable-next-line @typescript-eslint/no-namespace
namespace crypto {
interface PubKey {
type: string;
diff --git a/packages/hdwallet-core/src/secret.ts b/packages/hdwallet-core/src/secret.ts
index 27eb28604..1d6ab5009 100644
--- a/packages/hdwallet-core/src/secret.ts
+++ b/packages/hdwallet-core/src/secret.ts
@@ -7,6 +7,7 @@ export interface SecretGetAddress {
testnet?: boolean;
}
+// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Secret {
export interface Msg {
type: string;
@@ -25,6 +26,7 @@ export namespace Secret {
gas: string;
}
+ // eslint-disable-next-line @typescript-eslint/no-namespace
namespace crypto {
export interface PubKey {
type: string;
@@ -96,8 +98,8 @@ export interface SecretWallet extends SecretWalletInfo, HDWallet {
}
export function secretDescribePath(path: BIP32Path): PathDescription {
- let pathStr = addressNListToBIP32(path);
- let unknown: PathDescription = {
+ const pathStr = addressNListToBIP32(path);
+ const unknown: PathDescription = {
verbose: pathStr,
coin: "Secret",
isKnown: false,
@@ -123,7 +125,7 @@ export function secretDescribePath(path: BIP32Path): PathDescription {
return unknown;
}
- let index = path[2] & 0x7fffffff;
+ const index = path[2] & 0x7fffffff;
return {
verbose: `Secret Account #${index}`,
accountIdx: index,
diff --git a/packages/hdwallet-core/src/terra.ts b/packages/hdwallet-core/src/terra.ts
index 270fdd6dc..8313c07dc 100644
--- a/packages/hdwallet-core/src/terra.ts
+++ b/packages/hdwallet-core/src/terra.ts
@@ -7,6 +7,7 @@ export interface TerraGetAddress {
testnet?: boolean;
}
+// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Terra {
export interface Msg {
type: string;
@@ -25,6 +26,7 @@ export namespace Terra {
gas: string;
}
+ // eslint-disable-next-line @typescript-eslint/no-namespace
namespace crypto {
export interface PubKey {
type: string;
@@ -95,8 +97,8 @@ export interface TerraWallet extends TerraWalletInfo, HDWallet {
}
export function terraDescribePath(path: BIP32Path): PathDescription {
- let pathStr = addressNListToBIP32(path);
- let unknown: PathDescription = {
+ const pathStr = addressNListToBIP32(path);
+ const unknown: PathDescription = {
verbose: pathStr,
coin: "Terra",
isKnown: false,
@@ -122,7 +124,7 @@ export function terraDescribePath(path: BIP32Path): PathDescription {
return unknown;
}
- let index = path[2] & 0x7fffffff;
+ const index = path[2] & 0x7fffffff;
return {
verbose: `Terra Account #${index}`,
accountIdx: index,
diff --git a/packages/hdwallet-core/src/thorchain.ts b/packages/hdwallet-core/src/thorchain.ts
index 04d84d4ad..66a4bcd87 100644
--- a/packages/hdwallet-core/src/thorchain.ts
+++ b/packages/hdwallet-core/src/thorchain.ts
@@ -7,6 +7,7 @@ export interface ThorchainGetAddress {
testnet?: boolean;
}
+// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Thorchain {
export interface Msg {
type: string;
@@ -25,6 +26,7 @@ export namespace Thorchain {
gas: string;
}
+ // eslint-disable-next-line @typescript-eslint/no-namespace
namespace crypto {
export interface PubKey {
type: string;
@@ -95,8 +97,8 @@ export interface ThorchainWallet extends ThorchainWalletInfo, HDWallet {
}
export function thorchainDescribePath(path: BIP32Path): PathDescription {
- let pathStr = addressNListToBIP32(path);
- let unknown: PathDescription = {
+ const pathStr = addressNListToBIP32(path);
+ const unknown: PathDescription = {
verbose: pathStr,
coin: "Rune",
isKnown: false,
@@ -122,7 +124,7 @@ export function thorchainDescribePath(path: BIP32Path): PathDescription {
return unknown;
}
- let index = path[2] & 0x7fffffff;
+ const index = path[2] & 0x7fffffff;
return {
verbose: `Thorchain Account #${index}`,
accountIdx: index,
diff --git a/packages/hdwallet-core/src/transport.ts b/packages/hdwallet-core/src/transport.ts
index dcda503ac..a50296d91 100644
--- a/packages/hdwallet-core/src/transport.ts
+++ b/packages/hdwallet-core/src/transport.ts
@@ -20,10 +20,12 @@ export abstract class Transport extends eventemitter2.EventEmitter2 {
/**
* Optional method to bootstrap connection to device
*/
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
public async connect(): Promise {}
/**
* Optional function that gets called to clean up connection to device
*/
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
public async disconnect(): Promise {}
}
diff --git a/packages/hdwallet-core/src/utils.test.ts b/packages/hdwallet-core/src/utils.test.ts
index 1fdf26d6f..773791077 100644
--- a/packages/hdwallet-core/src/utils.test.ts
+++ b/packages/hdwallet-core/src/utils.test.ts
@@ -1,12 +1,12 @@
import {
- isArray,
- fromHexString,
- toHexString,
+ bip32Like,
bip32ToAddressNList,
- slip44ByCoin,
+ fromHexString,
+ isArray,
satsFromStr,
+ slip44ByCoin,
stripHexPrefix,
- bip32Like,
+ toHexString,
} from "./utils";
describe("isArray", () => {
diff --git a/packages/hdwallet-core/src/utils.ts b/packages/hdwallet-core/src/utils.ts
index 900239ac7..3ff977e4f 100644
--- a/packages/hdwallet-core/src/utils.ts
+++ b/packages/hdwallet-core/src/utils.ts
@@ -4,7 +4,7 @@ import * as RxOp from "rxjs/operators";
import { BIP32Path, Coin } from "./wallet";
-export type Constructor = new (...args: any[]) => T;
+export type Constructor = new (...args: any[]) => T;
export const DEFAULT_TIMEOUT = 5000; // 5 seconds
export const LONG_TIMEOUT = 5 * 60 * 1000; // 5 minutes
@@ -35,7 +35,7 @@ export function arrayify(value: string): Uint8Array {
throw new Error("can only convert hex strings");
}
- let match = value.match(/^(0x)?[0-9a-fA-F]*$/);
+ const match = value.match(/^(0x)?[0-9a-fA-F]*$/);
if (!match) {
throw new Error("invalid hexadecimal string");
@@ -59,6 +59,12 @@ export function arrayify(value: string): Uint8Array {
}
const HARDENED = 0x80000000;
+
+export function bip32Like(path: string): boolean {
+ if (path == "m/") return true;
+ return /^m(((\/[0-9]+h)+|(\/[0-9]+H)+|(\/[0-9]+')*)((\/[0-9]+)*))$/.test(path);
+}
+
export function bip32ToAddressNList(path: string): number[] {
if (!bip32Like(path)) {
throw new Error(`Not a bip32 path: '${path}'`);
@@ -70,7 +76,7 @@ export function bip32ToAddressNList(path: string): number[] {
if (segments.length === 1 && segments[0] === "") return [];
const ret = new Array(segments.length);
for (let i = 0; i < segments.length; i++) {
- const tmp = /(\d+)([hH\']?)/.exec(segments[i]);
+ const tmp = /(\d+)([hH']?)/.exec(segments[i]);
if (tmp === null) {
throw new Error("Invalid input");
}
@@ -91,12 +97,10 @@ export function addressNListToBIP32(address: number[]): string {
return `m/${address.map((num) => (num >= HARDENED ? `${num - HARDENED}'` : num)).join("/")}`;
}
-export function bip32Like(path: string): boolean {
- if (path == "m/") return true;
- return /^m(((\/[0-9]+h)+|(\/[0-9]+H)+|(\/[0-9]+')*)((\/[0-9]+)*))$/.test(path);
-}
-
-export function takeFirstOfManyEvents(eventEmitter: eventemitter2.EventEmitter2, events: string[]): Rx.Observable<{}> {
+export function takeFirstOfManyEvents(
+ eventEmitter: eventemitter2.EventEmitter2,
+ events: string[]
+): Rx.Observable