diff --git a/examples/sandbox/index.html b/examples/sandbox/index.html index 89b88970d..f70b1a1b5 100644 --- a/examples/sandbox/index.html +++ b/examples/sandbox/index.html @@ -300,12 +300,13 @@
Arkeo

Ethereum

- + + - - - + + +
@@ -437,11 +438,6 @@

Mnemoic Required

- diff --git a/examples/sandbox/index.ts b/examples/sandbox/index.ts index e19c78df9..51a3d2875 100644 --- a/examples/sandbox/index.ts +++ b/examples/sandbox/index.ts @@ -1,5 +1,6 @@ import "regenerator-runtime/runtime"; +import * as sigUtil from "@metamask/eth-sig-util"; import * as coinbase from "@shapeshiftoss/hdwallet-coinbase"; import { CoinbaseProviderConfig } from "@shapeshiftoss/hdwallet-coinbase"; import * as core from "@shapeshiftoss/hdwallet-core"; @@ -19,7 +20,8 @@ import * as walletConnect from "@shapeshiftoss/hdwallet-walletconnect"; import * as walletConnectv2 from "@shapeshiftoss/hdwallet-walletconnectv2"; import * as xdefi from "@shapeshiftoss/hdwallet-xdefi"; import { EthereumProviderOptions } from "@walletconnect/ethereum-provider/dist/types/EthereumProvider"; -import $ from "jquery"; +import { TypedData } from "eip-712"; +import $, { noop } from "jquery"; import Web3 from "web3"; import { @@ -47,7 +49,8 @@ import { } from "./json/cosmos/cosmosAminoTx.json"; import * as dashTxJson from "./json/dashTx.json"; import * as dogeTxJson from "./json/dogeTx.json"; -import { eip712 } from "./json/ethTx.json"; +import { eip712, txs } from "./json/ethereum/ethTx.json"; +import { openSeaListNFTMessage } from "./json/ethereum/OpenSea-ethSignTypedDataV4.json"; import * as ltcTxJson from "./json/ltcTx.json"; import { osmosisDelegateTx, @@ -164,16 +167,6 @@ const $xdefi = $("#xdefi"); const $keplr = $("#keplr"); const $keyring = $("#keyring"); -const $ethAddr = $("#ethAddr"); -const $ethTx = $("#ethTx"); -const $ethSign = $("#ethSign"); -const $ethSend = $("#ethSend"); -const $ethVerify = $("#ethVerify"); -const $ethResults = $("#ethResults"); -const $ethEIP1559 = $("#ethEIP1559"); -const $ethSignTypedData = $("#ethSignTypedData"); -const $ethSignTypedDataPreCalculate = $("#ethSignTypedDataPreCalculate"); - $keepkey.on("click", async (e) => { e.preventDefault(); wallet = await keepkeyAdapter.pairDevice(undefined, /*tryDebugLink=*/ true); @@ -380,7 +373,10 @@ async function deviceConnected(deviceId) { } try { - await ledgerWebUSBAdapter.initialize(); + // skip initialize() on page load b/c: + // Error: WebUSBCouldNotInitialize.... + // "Must be handling a user gesture to show a permission request." + noop(); } catch (e) { console.error("Could not initialize LedgerWebUSBAdapter", e); } @@ -416,7 +412,7 @@ async function deviceConnected(deviceId) { } try { - await keplrAdapter.initialize([]); + await keplrAdapter.initialize(); } catch (e) { console.error("Could not initialize KeplrAdapter", e); } @@ -921,7 +917,7 @@ $rippleAddr.on("click", async (e) => { $rippleTx.on("click", async (e) => { e.preventDefault(); if (!wallet) { - $ethResults.val("No wallet?"); + $rippleResults.val("No wallet?"); return; } if (core.supportsRipple(wallet)) { @@ -954,7 +950,7 @@ const $eosResults = $("#eosResults"); $eosAddr.on("click", async (e) => { e.preventDefault(); if (!wallet) { - $ethResults.val("No wallet?"); + $eosResults.val("No wallet?"); return; } if (core.supportsEos(wallet)) { @@ -978,7 +974,7 @@ $eosAddr.on("click", async (e) => { $eosTx.on("click", async (e) => { e.preventDefault(); if (!wallet) { - $ethResults.val("No wallet?"); + $eosResults.val("No wallet?"); return; } if (core.supportsEos(wallet)) { @@ -1044,21 +1040,18 @@ const $fioResults = $("#fioResults"); $fioAddr.on("click", async (e) => { e.preventDefault(); if (!wallet) { - $ethResults.val("No wallet?"); + $fioResults.val("No wallet?"); return; } if (core.supportsFio(wallet)) { const { addressNList } = wallet.fioGetAccountPaths({ accountIdx: 0 })[0]; - let result = await wallet.fioGetPublicKey({ + let result = await wallet.fioGetAddress({ addressNList, showDisplay: false, - kind: 0, }); - result = await wallet.fioGetPublicKey({ + result = await wallet.fioGetAddress({ addressNList, showDisplay: true, - kind: 0, - address: result, }); $fioResults.val(result); } else { @@ -1070,7 +1063,7 @@ $fioAddr.on("click", async (e) => { $fioTx.on("click", async (e) => { e.preventDefault(); if (!wallet) { - $ethResults.val("No wallet?"); + $fioResults.val("No wallet?"); return; } if (core.supportsFio(wallet)) { @@ -1094,9 +1087,9 @@ $fioTx.on("click", async (e) => { console.info(res); console.info("signature = %d", res.signature); - console.info("serialized = %s", core.toHexString(res.serialized)); + console.info("serialized = %s", res.serialized); - $eosResults.val(res.fioFormSig); + $fioResults.val(JSON.stringify(res)); } else { const label = await wallet.getLabel(); $fioResults.val(label + " does not support Fio"); @@ -1496,7 +1489,7 @@ $thorchainSignSwap.on("click", async (e) => { $thorchainSwapResults.val(JSON.stringify(res)); } else { const label = await wallet.getLabel(); - $ethResults.val(label + " does not support ETH"); + $thorchainSwapResults.val(label + " does not support ETH"); } break; default: @@ -1666,7 +1659,7 @@ $thorchainSignAddLiquidity.on("click", async (e) => { $thorchainAddLiquidityResults.val(JSON.stringify(res)); } else { const label = await wallet.getLabel(); - $ethResults.val(label + " does not support ETH"); + $thorchainAddLiquidityResults.val(label + " does not support ETH"); } break; default: @@ -2480,36 +2473,34 @@ $osmosisSwap.on("click", async (e) => { * Bech32: false */ +interface EthOperationConfig { + handler: (params: any) => Promise; + useEIP1559?: boolean; + typedDataValue?: "OpenSea" | "EIP712DomainIsPrimaryType" | "longPrimaryTypeString"; +} let ethEIP1559Selected = false; -const ethTx = { - addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), - nonce: "0x01", - gasPrice: "0x1dcd65000", - gasLimit: "0x5622", - value: "0x2c68af0bb14000", - to: "0x12eC06288EDD7Ae2CC41A843fE089237fC7354F0", - chainId: 1, - data: "", -}; - -const ethTx1559 = { - addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), - nonce: "0x0", - gasLimit: "0x5ac3", - maxFeePerGas: "0x16854be509", - maxPriorityFeePerGas: "0x540ae480", - value: "0x1550f7dca70000", // 0.006 eth - to: "0xfc0cc6e85dff3d75e3985e0cb83b090cfd498dd1", - chainId: 1, - data: "", -}; +const ethButtons = [ + "ethAddr", + "ethTx", + "ethSign", + "ethSend", + "ethVerify", + "ethResults", + "ethEIP1559", + "ethSignTypedData", + "ethSignTypedDataAlternate1", + "ethSignTypedDataAlternate2", +].reduce((acc, id) => { + acc[id] = $(`#${id}`); + return acc; +}, {} as Record>); -$ethAddr.on("click", async (e) => { +const performEthOperation = async (e: any, config: EthOperationConfig) => { e.preventDefault(); if (!wallet) { - $ethResults.val("No wallet?"); + ethButtons.ethResults.val("No wallet?"); return; } @@ -2518,139 +2509,145 @@ $ethAddr.on("click", async (e) => { coin: "Ethereum", accountIdx: 0, })[0]; - let result = await wallet.ethGetAddress({ - addressNList: hardenedPath.concat(relPath), - showDisplay: false, - }); - result = await wallet.ethGetAddress({ - addressNList: hardenedPath.concat(relPath), - showDisplay: true, - address: result, - }); - $ethResults.val(result); - } else { - const label = await wallet.getLabel(); - $ethResults.val(label + " does not support ETH"); - } -}); - -$ethTx.on("click", async (e) => { - e.preventDefault(); - if (!wallet) { - $ethResults.val("No wallet?"); - return; - } - if (core.supportsETH(wallet)) { - const res = ethEIP1559Selected ? await wallet.ethSignTx(ethTx1559) : await wallet.ethSignTx(ethTx); - $ethResults.val(JSON.stringify(res)); - } else { - const label = await wallet.getLabel(); - $ethResults.val(label + " does not support ETH"); - } -}); -$ethSign.on("click", async (e) => { - e.preventDefault(); - if (!wallet) { - $ethResults.val("No wallet?"); - return; - } - if (core.supportsETH(wallet)) { - const { hardenedPath: hard, relPath: rel } = wallet.ethGetAccountPaths({ - coin: "Ethereum", - accountIdx: 0, - })[0]; - const result = await wallet.ethSignMessage({ - addressNList: hard.concat(rel), - message: "Hello World", - }); - $ethResults.val(result.address + ", " + result.signature); - } else { - const label = await wallet.getLabel(); - $ethResults.val(label + " does not support ETH"); - } -}); + const tx = config.useEIP1559 && ethEIP1559Selected ? txs.ethTx1559 : txs.ethTxLegacy; + let typedData: TypedData | undefined; -$ethSend.on("click", async (e) => { - e.preventDefault(); - if (!wallet) { - $ethResults.val("No wallet?"); - return; - } - if (core.supportsETH(wallet)) { - const result = ethEIP1559Selected - ? await wallet.ethSendTx(ethTx1559 as core.ETHSignTx) - : await wallet.ethSendTx(ethTx as core.ETHSignTx); - console.info("Result: ", result); - $ethResults.val(result.hash); + switch (config.typedDataValue) { + case "OpenSea": + typedData = openSeaListNFTMessage; + break; + case "longPrimaryTypeString": + typedData = eip712["longPrimaryTypeString"]["typedData"]; + break; + case "EIP712DomainIsPrimaryType": + typedData = eip712["EIP712DomainIsPrimaryType"]["typedData"]; + break; + default: + typedData = undefined; + } + const result = await config.handler({ hardenedPath, relPath, tx, typedData }); + ethButtons.ethResults.val(result); } else { const label = await wallet.getLabel(); - $ethResults.val(label + " does not support ETH"); + ethButtons.ethResults.val(`${label} does not support ETH`); } -}); +}; -$ethVerify.on("click", async (e) => { - e.preventDefault(); - if (!wallet) { - $ethResults.val("No wallet?"); - return; - } - if (core.supportsETH(wallet)) { - const result = await wallet.ethVerifyMessage({ - address: "0x2068dD92B6690255553141Dfcf00dF308281f763", - message: "Hello World", - signature: - "61f1dda82e9c3800e960894396c9ce8164fd1526fccb136c71b88442405f7d09721725629915d10bc7cecfca2818fe76bc5816ed96a1b0cebee9b03b052980131b", - }); - $ethResults.val(result ? "✅" : "❌"); - } else { - const label = await wallet.getLabel(); - $ethResults.val(label + " does not support ETH"); - } -}); +ethButtons.ethAddr.on("click", (e) => + performEthOperation(e, { + handler: async ({ hardenedPath, relPath }) => { + let result = await wallet.ethGetAddress({ + addressNList: hardenedPath.concat(relPath), + showDisplay: false, + }); + result = await wallet.ethGetAddress({ + addressNList: hardenedPath.concat(relPath), + showDisplay: true, + address: result, + }); + return result; + }, + }) +); + +ethButtons.ethTx.on("click", (e) => + performEthOperation(e, { + handler: async ({ tx }) => { + const res = await wallet.ethSignTx(tx); + return JSON.stringify(res); + }, + useEIP1559: ethEIP1559Selected, + }) +); + +ethButtons.ethSign.on("click", (e) => + performEthOperation(e, { + handler: async ({ hardenedPath, relPath }) => { + const result = await wallet.ethSignMessage({ + addressNList: hardenedPath.concat(relPath), + message: "0x48656c6c6f20576f726c64", // "Hello World", + }); + return `Address: ${result.address} Signature: ${result.signature}`; + }, + }) +); + +ethButtons.ethSend.on("click", (e) => + performEthOperation(e, { + handler: async ({ tx }) => { + if (wallet?.ethSendTx) { + const result = await wallet.ethSendTx(tx as core.ETHSignTx); + return result.hash; + } else { + const label = await wallet.getVendor(); + return label + " does not support ethSendTx"; + } + }, + useEIP1559: ethEIP1559Selected, + }) +); + +ethButtons.ethVerify.on("click", (e) => + performEthOperation(e, { + handler: async () => { + const signerAddress = "0x2068dD92B6690255553141Dfcf00dF308281f763"; + const result = await wallet.ethVerifyMessage({ + address: signerAddress, + message: "Hello World", + signature: + "0x61f1dda82e9c3800e960894396c9ce8164fd1526fccb136c71b88442405f7d09721725629915d10bc7cecfca2818fe76bc5816ed96a1b0cebee9b03b052980131b", + }); + return result ? `✅ ${signerAddress} is the signer` : `❌ ${signerAddress} is NOT the signer`; + }, + }) +); -$ethEIP1559.on("click", async () => { - if (!ethEIP1559Selected) { - $ethEIP1559.attr("class", "button"); - } else { - $ethEIP1559.attr("class", "button-outline"); - } +ethButtons.ethEIP1559.on("click", () => { ethEIP1559Selected = !ethEIP1559Selected; + ethButtons.ethEIP1559.attr("class", ethEIP1559Selected ? "button" : "button-outline"); }); -$ethSignTypedData.on("click", async (e) => { - e.preventDefault(); - if (!wallet) { - $ethResults.val("No wallet?"); - return; - } - if (core.supportsETH(wallet)) { - const result = await wallet.ethSignTypedData({ - typedData: eip712["calculateHashesOnDevice"]["typedData"], - addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), - }); - $ethResults.val(JSON.stringify(result, null, 2)); - } -}); +const doesRecoveredMatchAddress = (typedData: TypedData, fromAddress: string, signature: string): boolean => { + const recoveredAddress = sigUtil.recoverTypedSignature({ + data: typedData, + signature: signature, + version: sigUtil.SignTypedDataVersion.V4, + }); + return Web3.utils.toChecksumAddress(recoveredAddress) === Web3.utils.toChecksumAddress(fromAddress); +}; -$ethSignTypedDataPreCalculate.on("click", async (e) => { - e.preventDefault(); - if (!wallet) { - $ethResults.val("No wallet?"); - return; - } - if (!keepkey.isKeepKey(wallet)) { - $ethResults.val("Action only supported for KeepKey"); - return; - } - if (core.supportsETH(wallet)) { - const result = await wallet.ethSignTypedData({ - typedData: eip712["precalculateHashes"]["typedData"], - addressNList: core.bip32ToAddressNList("m/44'/60'/0'/0/0"), - }); - $ethResults.val(JSON.stringify(result, null, 2)); - } -}); +const ethSignTypedDataHandler = async ({ hardenedPath, relPath, typedData }) => { + const { address, signature } = await wallet.ethSignTypedData({ + typedData, + addressNList: hardenedPath.concat(relPath), + }); + const success = doesRecoveredMatchAddress(typedData, address, signature); + return ( + (success ? `✅ "${address}" is the signer` : `❌ "${address}" is NOT the signer`) + `; Signature is: "${signature}"` + ); +}; + +ethButtons.ethSignTypedData.on("click", (e) => + performEthOperation(e, { + handler: ethSignTypedDataHandler, + typedDataValue: "OpenSea", + }) +); + +ethButtons.ethSignTypedDataAlternate1.on("click", (e) => + performEthOperation(e, { + handler: ethSignTypedDataHandler, + typedDataValue: "longPrimaryTypeString", + }) +); + +ethButtons.ethSignTypedDataAlternate2.on("click", (e) => + performEthOperation(e, { + handler: ethSignTypedDataHandler, + typedDataValue: "EIP712DomainIsPrimaryType", + }) +); /* ERC-20 diff --git a/examples/sandbox/json/ethTx.json b/examples/sandbox/json/ethTx.json deleted file mode 100644 index 77f3b5d2c..000000000 --- a/examples/sandbox/json/ethTx.json +++ /dev/null @@ -1,150 +0,0 @@ -{ - "eip712": { - "precalculateHashes": { - "typedData": { - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - }, - { - "name": "salt", - "type": "bytes32" - } - ], - "Person": [ - { - "name": "name", - "type": "string" - }, - { - "name": "wallet", - "type": "address" - }, - { - "name": "married", - "type": "bool" - }, - { - "name": "kids", - "type": "uint8" - }, - { - "name": "karma", - "type": "int16" - }, - { - "name": "secret", - "type": "bytes" - }, - { - "name": "small_secret", - "type": "bytes16" - }, - { - "name": "pets", - "type": "string[]" - }, - { - "name": "two_best_friends", - "type": "string[2]" - } - ], - "ThisIsARidiculouslyLongPrimaryTypeToForceHashesToBePrecalculatedByHDWalletKeepKey": [ - { - "name": "from", - "type": "Person" - }, - { - "name": "to", - "type": "Person" - }, - { - "name": "messages", - "type": "string[]" - } - ] - }, - "primaryType": "ThisIsARidiculouslyLongPrimaryTypeToForceHashesToBePrecalculatedByHDWalletKeepKey", - "domain": { - "name": "Ether Mail", - "version": "1", - "chainId": 1, - "verifyingContract": "0x1e0Ae8205e9726E6F296ab8869160A6423E2337E", - "salt": "0xca92da1a6e91d9358328d2f2155af143a7cb74b81a3a4e3e57e2191823dbb56c" - }, - "message": { - "from": { - "name": "Amy", - "wallet": "0xc0004B62C5A39a728e4Af5bee0c6B4a4E54b15ad", - "married": true, - "kids": 2, - "karma": 4, - "secret": "0x62c5a39a728e4af5bee0c6b462c5a39a728e4af5bee0c6b462c5a39a728e4af5bee0c6b462c5a39a728e4af5bee0c6b4", - "small_secret": "0x5ccf0e54367104795a47bc0481645d9e", - "pets": ["parrot"], - "two_best_friends": ["Carl", "Denis"] - }, - "to": { - "name": "Bob", - "wallet": "0x54B0Fa66A065748C40dCA2C7Fe125A2028CF9982", - "married": false, - "kids": 0, - "karma": -4, - "secret": "0x7fe125a2028cf97fe125a2028cf97fe125a2028cf97fe125a2028cf97fe125a2028cf97fe125a2028cf97fe125a2028cf9", - "small_secret": "0xa5e5c47b64775abc476d2962403258de", - "pets": ["dog", "cat"], - "two_best_friends": ["Emil", "Franz"] - }, - "messages": ["Hello, Bob!", "How are you?", "Hope you're fine"] - } - } - }, - "calculateHashesOnDevice": { - "typedData": { - "types": { - "EIP712Domain": [ - { "name": "name", "type": "string" }, - { "name": "version", "type": "string" }, - { "name": "chainId", "type": "uint256" }, - { "name": "verifyingContract", "type": "address" } - ], - "Permit": [ - { "name": "owner", "type": "address" }, - { "name": "spender", "type": "address" }, - { "name": "value", "type": "uint256" }, - { "name": "nonce", "type": "uint256" }, - { "name": "deadline", "type": "uint256" } - ] - }, - "domain": { - "name": "USD Coin", - "version": "2", - "verifyingContract": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - "chainId": 1 - }, - "primaryType": "Permit", - "message": { - "owner": "0x33b35c665496bA8E71B22373843376740401F106", - "spender": "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", - "value": "4023865", - "nonce": 0, - "deadline": 1655431026 - } - } - } - } - } \ No newline at end of file diff --git a/examples/sandbox/json/ethereum/OpenSea-ethSignTypedDataV4.json b/examples/sandbox/json/ethereum/OpenSea-ethSignTypedDataV4.json new file mode 100644 index 000000000..44b3a7400 --- /dev/null +++ b/examples/sandbox/json/ethereum/OpenSea-ethSignTypedDataV4.json @@ -0,0 +1,164 @@ +{ + "openSeaListNFTMessage": { + "types": { + "EIP712Domain": [ + { + "name": "name", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "chainId", + "type": "uint256" + }, + { + "name": "verifyingContract", + "type": "address" + } + ], + "OrderComponents": [ + { + "name": "offerer", + "type": "address" + }, + { + "name": "zone", + "type": "address" + }, + { + "name": "offer", + "type": "OfferItem[]" + }, + { + "name": "consideration", + "type": "ConsiderationItem[]" + }, + { + "name": "orderType", + "type": "uint8" + }, + { + "name": "startTime", + "type": "uint256" + }, + { + "name": "endTime", + "type": "uint256" + }, + { + "name": "zoneHash", + "type": "bytes32" + }, + { + "name": "salt", + "type": "uint256" + }, + { + "name": "conduitKey", + "type": "bytes32" + }, + { + "name": "counter", + "type": "uint256" + } + ], + "OfferItem": [ + { + "name": "itemType", + "type": "uint8" + }, + { + "name": "token", + "type": "address" + }, + { + "name": "identifierOrCriteria", + "type": "uint256" + }, + { + "name": "startAmount", + "type": "uint256" + }, + { + "name": "endAmount", + "type": "uint256" + } + ], + "ConsiderationItem": [ + { + "name": "itemType", + "type": "uint8" + }, + { + "name": "token", + "type": "address" + }, + { + "name": "identifierOrCriteria", + "type": "uint256" + }, + { + "name": "startAmount", + "type": "uint256" + }, + { + "name": "endAmount", + "type": "uint256" + }, + { + "name": "recipient", + "type": "address" + } + ] + }, + "primaryType": "OrderComponents", + "domain": { + "name": "Seaport", + "version": "1.5", + "chainId": 137, + "verifyingContract": "0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC" + }, + "message": { + "offerer": "0x8c9Ed98b7C3961D22Cc871356C7b73d194608817", + "offer": [ + { + "itemType": "2", + "token": "0xa9a6A3626993D487d2Dbda3173cf58cA1a9D9e9f", + "identifierOrCriteria": "64560424590441301826453812164224751707642265079650986418901366599236941237984", + "startAmount": "1", + "endAmount": "1" + } + ], + "consideration": [ + { + "itemType": "1", + "token": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", + "identifierOrCriteria": "0", + "startAmount": "194707500000000000", + "endAmount": "194707500000000000", + "recipient": "0x8c9Ed98b7C3961D22Cc871356C7b73d194608817" + }, + { + "itemType": "1", + "token": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", + "identifierOrCriteria": "0", + "startAmount": "4992500000000000", + "endAmount": "4992500000000000", + "recipient": "0x0000a26b00c1F0DF003000390027140000fAa719" + } + ], + "startTime": "1696393777", + "endTime": "1699072168", + "orderType": 0, + "zone": "0x0000000000000000000000000000000000000000", + "zoneHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "salt": "24446860302761739304752683030156737591518664810215442929815805592127532436551", + "conduitKey": "0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000", + "totalOriginalConsiderationItems": "2", + "counter": "0" + } + } +} diff --git a/examples/sandbox/json/ethereum/ethTx.json b/examples/sandbox/json/ethereum/ethTx.json new file mode 100644 index 000000000..c43243e07 --- /dev/null +++ b/examples/sandbox/json/ethereum/ethTx.json @@ -0,0 +1,198 @@ +{ + "eip712": { + "longPrimaryTypeString": { + "typedData": { + "types": { + "EIP712Domain": [ + { + "name": "name", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "chainId", + "type": "uint256" + }, + { + "name": "verifyingContract", + "type": "address" + }, + { + "name": "salt", + "type": "bytes32" + } + ], + "Person": [ + { + "name": "name", + "type": "string" + }, + { + "name": "wallet", + "type": "address" + }, + { + "name": "married", + "type": "bool" + }, + { + "name": "kids", + "type": "uint8" + }, + { + "name": "karma", + "type": "int16" + }, + { + "name": "secret", + "type": "bytes" + }, + { + "name": "small_secret", + "type": "bytes16" + }, + { + "name": "pets", + "type": "string[]" + }, + { + "name": "two_best_friends", + "type": "string[2]" + } + ], + "ThisIsARidiculouslyLongPrimaryTypeToForceHashesToBePrecalculatedByHDWalletKeepKey": [ + { + "name": "from", + "type": "Person" + }, + { + "name": "to", + "type": "Person" + }, + { + "name": "messages", + "type": "string[]" + } + ] + }, + "primaryType": "ThisIsARidiculouslyLongPrimaryTypeToForceHashesToBePrecalculatedByHDWalletKeepKey", + "domain": { + "name": "Ether Mail", + "version": "1", + "chainId": 1, + "verifyingContract": "0x1e0Ae8205e9726E6F296ab8869160A6423E2337E", + "salt": "0xca92da1a6e91d9358328d2f2155af143a7cb74b81a3a4e3e57e2191823dbb56c" + }, + "message": { + "from": { + "name": "Amy", + "wallet": "0xc0004B62C5A39a728e4Af5bee0c6B4a4E54b15ad", + "married": true, + "kids": 2, + "karma": 4, + "secret": "0x62c5a39a728e4af5bee0c6b462c5a39a728e4af5bee0c6b462c5a39a728e4af5bee0c6b462c5a39a728e4af5bee0c6b4", + "small_secret": "0x5ccf0e54367104795a47bc0481645d9e", + "pets": [ + "parrot" + ], + "two_best_friends": [ + "Carl", + "Denis" + ] + }, + "to": { + "name": "Bob", + "wallet": "0x54B0Fa66A065748C40dCA2C7Fe125A2028CF9982", + "married": false, + "kids": 0, + "karma": -4, + "secret": "0x7fe125a2028cf97fe125a2028cf97fe125a2028cf97fe125a2028cf97fe125a2028cf97fe125a2028cf97fe125a2028cf9", + "small_secret": "0xa5e5c47b64775abc476d2962403258de", + "pets": [ + "dog", + "cat" + ], + "two_best_friends": [ + "Emil", + "Franz" + ] + }, + "messages": [ + "Hello, Bob!", + "How are you?", + "Hope you're fine" + ] + } + } + }, + "EIP712DomainIsPrimaryType": { + "typedData": { + "types": { + "EIP712Domain": [ + { + "name": "name", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "chainId", + "type": "uint256" + }, + { + "name": "verifyingContract", + "type": "address" + } + ] + }, + "domain": { + "name": "USD Coin", + "version": "2", + "verifyingContract": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + "chainId": 1 + }, + "primaryType": "EIP712Domain" + } + } + }, + "txs": { + "ethTxLegacy": { + "addressNList": [ + 2147483692, + 2147483708, + 2147483648, + 0, + 0 + ], + "nonce": "0x01", + "gasPrice": "0x1dcd65000", + "gasLimit": "0x5622", + "value": "0x2c68af0bb14000", + "to": "0x12eC06288EDD7Ae2CC41A843fE089237fC7354F0", + "chainId": 1, + "data": "" + }, + "ethTx1559": { + "addressNList": [ + 2147483692, + 2147483708, + 2147483648, + 0, + 0 + ], + "nonce": "0x0", + "gasLimit": "0x5ac3", + "maxFeePerGas": "0x16854be509", + "maxPriorityFeePerGas": "0x540ae480", + "value": "0x1550f7dca70000", + "to": "0xfc0cc6e85dff3d75e3985e0cb83b090cfd498dd1", + "chainId": 1, + "data": "" + } + } +} diff --git a/examples/sandbox/package.json b/examples/sandbox/package.json index 7c6882739..a2d922812 100644 --- a/examples/sandbox/package.json +++ b/examples/sandbox/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-sandbox", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "private": true, "browserslist": "> 0.5%, last 2 versions, not dead", @@ -10,23 +10,25 @@ "clean": "rm -rf dist node_modules public .parcel-cache" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.52.10", - "@shapeshiftoss/hdwallet-keepkey-tcp": "1.52.10", - "@shapeshiftoss/hdwallet-keepkey-webusb": "1.52.10", - "@shapeshiftoss/hdwallet-keplr": "1.52.10", - "@shapeshiftoss/hdwallet-ledger": "1.52.10", - "@shapeshiftoss/hdwallet-ledger-webhid": "1.52.10", - "@shapeshiftoss/hdwallet-ledger-webusb": "1.52.10", - "@shapeshiftoss/hdwallet-metamask": "1.52.10", - "@shapeshiftoss/hdwallet-native": "1.52.10", - "@shapeshiftoss/hdwallet-portis": "1.52.10", - "@shapeshiftoss/hdwallet-tallyho": "1.52.10", - "@shapeshiftoss/hdwallet-trezor": "1.52.10", - "@shapeshiftoss/hdwallet-trezor-connect": "1.52.10", - "@shapeshiftoss/hdwallet-walletconnect": "1.52.10", - "@shapeshiftoss/hdwallet-xdefi": "1.52.10", + "@metamask/eth-sig-util": "^7.0.0", + "@shapeshiftoss/hdwallet-core": "1.52.11", + "@shapeshiftoss/hdwallet-keepkey-tcp": "1.52.11", + "@shapeshiftoss/hdwallet-keepkey-webusb": "1.52.11", + "@shapeshiftoss/hdwallet-keplr": "1.52.11", + "@shapeshiftoss/hdwallet-ledger": "1.52.11", + "@shapeshiftoss/hdwallet-ledger-webhid": "1.52.11", + "@shapeshiftoss/hdwallet-ledger-webusb": "1.52.11", + "@shapeshiftoss/hdwallet-metamask": "1.52.11", + "@shapeshiftoss/hdwallet-native": "1.52.11", + "@shapeshiftoss/hdwallet-portis": "1.52.11", + "@shapeshiftoss/hdwallet-tallyho": "1.52.11", + "@shapeshiftoss/hdwallet-trezor": "1.52.11", + "@shapeshiftoss/hdwallet-trezor-connect": "1.52.11", + "@shapeshiftoss/hdwallet-walletconnect": "1.52.11", + "@shapeshiftoss/hdwallet-xdefi": "1.52.11", "bip32": "^2.0.4", - "jquery": "^3.4.1", + "eip-712": "^1.0.0", + "jquery": "^3.7.1", "json": "^9.0.6", "p-queue": "^7.4.1", "parcel": "^2.3.2", @@ -34,6 +36,7 @@ "web3": "^1.5.1" }, "devDependencies": { + "@types/jquery": "^3.5.22", "https-browserify": "^1.0.0", "os-browserify": "^0.3.0", "path-browserify": "^1.0.1", diff --git a/examples/sandbox/tsconfig.json b/examples/sandbox/tsconfig.json index 1589f985f..07062f202 100644 --- a/examples/sandbox/tsconfig.json +++ b/examples/sandbox/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { "resolveJsonModule": true, + "esModuleInterop": true } -} \ No newline at end of file +} diff --git a/integration/package.json b/integration/package.json index cdb33798d..b87633a75 100644 --- a/integration/package.json +++ b/integration/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/integration", - "version": "1.52.10", + "version": "1.52.11", "main": "index.js", "license": "MIT", "private": true, @@ -10,15 +10,15 @@ "dev": "lerna run test --scope integration --parallel --include-filtered-dependencies" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.52.10", - "@shapeshiftoss/hdwallet-keepkey": "1.52.10", - "@shapeshiftoss/hdwallet-keepkey-nodewebusb": "1.52.10", - "@shapeshiftoss/hdwallet-keepkey-tcp": "1.52.10", - "@shapeshiftoss/hdwallet-ledger": "1.52.10", - "@shapeshiftoss/hdwallet-native": "1.52.10", - "@shapeshiftoss/hdwallet-portis": "1.52.10", - "@shapeshiftoss/hdwallet-trezor": "1.52.10", - "@shapeshiftoss/hdwallet-xdefi": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", + "@shapeshiftoss/hdwallet-keepkey": "1.52.11", + "@shapeshiftoss/hdwallet-keepkey-nodewebusb": "1.52.11", + "@shapeshiftoss/hdwallet-keepkey-tcp": "1.52.11", + "@shapeshiftoss/hdwallet-ledger": "1.52.11", + "@shapeshiftoss/hdwallet-native": "1.52.11", + "@shapeshiftoss/hdwallet-portis": "1.52.11", + "@shapeshiftoss/hdwallet-trezor": "1.52.11", + "@shapeshiftoss/hdwallet-xdefi": "1.52.11", "fast-json-stable-stringify": "^2.1.0", "msw": "^0.27.1", "whatwg-fetch": "^3.6.2" diff --git a/lerna.json b/lerna.json index cc9e90eab..945a5152d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "lerna": "5.2.0", - "version": "1.52.10", + "version": "1.52.11", "npmClient": "yarn", "useWorkspaces": true, "command": { diff --git a/packages/hdwallet-coinbase/package.json b/packages/hdwallet-coinbase/package.json index c647c3c7d..54460a217 100644 --- a/packages/hdwallet-coinbase/package.json +++ b/packages/hdwallet-coinbase/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-coinbase", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -15,7 +15,7 @@ }, "dependencies": { "@coinbase/wallet-sdk": "^3.6.6", - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "eth-rpc-errors": "^4.0.3", "lodash": "^4.17.21" }, diff --git a/packages/hdwallet-core/package.json b/packages/hdwallet-core/package.json index 5fff9d7b0..ccfd84313 100644 --- a/packages/hdwallet-core/package.json +++ b/packages/hdwallet-core/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-core", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" diff --git a/packages/hdwallet-keepkey-chromeusb/package.json b/packages/hdwallet-keepkey-chromeusb/package.json index 37dd4d4ca..7e920ff54 100644 --- a/packages/hdwallet-keepkey-chromeusb/package.json +++ b/packages/hdwallet-keepkey-chromeusb/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-chromeusb", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.52.10", - "@shapeshiftoss/hdwallet-keepkey": "1.52.10" + "@shapeshiftoss/hdwallet-core": "1.52.11", + "@shapeshiftoss/hdwallet-keepkey": "1.52.11" } } diff --git a/packages/hdwallet-keepkey-electron/package.json b/packages/hdwallet-keepkey-electron/package.json index 47b16a3eb..91ae2b017 100644 --- a/packages/hdwallet-keepkey-electron/package.json +++ b/packages/hdwallet-keepkey-electron/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-electron", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-keepkey": "1.52.10", + "@shapeshiftoss/hdwallet-keepkey": "1.52.11", "uuid": "^8.3.2" }, "peerDependencies": { diff --git a/packages/hdwallet-keepkey-nodehid/package.json b/packages/hdwallet-keepkey-nodehid/package.json index 407a11443..c44c0dbe6 100644 --- a/packages/hdwallet-keepkey-nodehid/package.json +++ b/packages/hdwallet-keepkey-nodehid/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-nodehid", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-keepkey": "1.52.10" + "@shapeshiftoss/hdwallet-keepkey": "1.52.11" }, "peerDependencies": { "node-hid": "^2.1.1" diff --git a/packages/hdwallet-keepkey-nodewebusb/package.json b/packages/hdwallet-keepkey-nodewebusb/package.json index 11711db0d..df52fa24b 100644 --- a/packages/hdwallet-keepkey-nodewebusb/package.json +++ b/packages/hdwallet-keepkey-nodewebusb/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-nodewebusb", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -14,8 +14,8 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.52.10", - "@shapeshiftoss/hdwallet-keepkey": "1.52.10" + "@shapeshiftoss/hdwallet-core": "1.52.11", + "@shapeshiftoss/hdwallet-keepkey": "1.52.11" }, "peerDependencies": { "usb": "^2.3.1" diff --git a/packages/hdwallet-keepkey-tcp/package.json b/packages/hdwallet-keepkey-tcp/package.json index 315685fcf..511ffe376 100644 --- a/packages/hdwallet-keepkey-tcp/package.json +++ b/packages/hdwallet-keepkey-tcp/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-tcp", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -14,8 +14,8 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.52.10", - "@shapeshiftoss/hdwallet-keepkey": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", + "@shapeshiftoss/hdwallet-keepkey": "1.52.11", "axios": "^0.21.1" } } diff --git a/packages/hdwallet-keepkey-webusb/package.json b/packages/hdwallet-keepkey-webusb/package.json index 23e2a6249..62f99d397 100644 --- a/packages/hdwallet-keepkey-webusb/package.json +++ b/packages/hdwallet-keepkey-webusb/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey-webusb", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -14,8 +14,8 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.52.10", - "@shapeshiftoss/hdwallet-keepkey": "1.52.10" + "@shapeshiftoss/hdwallet-core": "1.52.11", + "@shapeshiftoss/hdwallet-keepkey": "1.52.11" }, "devDependencies": { "@types/w3c-web-usb": "^1.0.4" diff --git a/packages/hdwallet-keepkey/package.json b/packages/hdwallet-keepkey/package.json index 7efe4660e..3afe17885 100644 --- a/packages/hdwallet-keepkey/package.json +++ b/packages/hdwallet-keepkey/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keepkey", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -18,13 +18,13 @@ "@ethereumjs/common": "^2.4.0", "@ethereumjs/tx": "^3.3.0", "@keepkey/device-protocol": "^7.12.2", + "@metamask/eth-sig-util": "^7.0.0", "@shapeshiftoss/bitcoinjs-lib": "5.2.0-shapeshift.2", - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "@shapeshiftoss/proto-tx-builder": "^0.8.0", "bignumber.js": "^9.0.1", "bnb-javascript-sdk-nobroadcast": "^2.16.14", "crypto-js": "^4.0.0", - "eip-712": "^1.0.0", "eip55": "^2.1.0", "google-protobuf": "^3.15.8", "icepick": "^2.4.0", diff --git a/packages/hdwallet-keepkey/src/ethereum.ts b/packages/hdwallet-keepkey/src/ethereum.ts index cc374595a..4062cdfe1 100644 --- a/packages/hdwallet-keepkey/src/ethereum.ts +++ b/packages/hdwallet-keepkey/src/ethereum.ts @@ -3,8 +3,8 @@ import { FeeMarketEIP1559Transaction, Transaction } from "@ethereumjs/tx"; import * as Messages from "@keepkey/device-protocol/lib/messages_pb"; import * as Ethereum from "@keepkey/device-protocol/lib/messages-ethereum_pb"; import * as Types from "@keepkey/device-protocol/lib/types_pb"; +import { SignTypedDataVersion, TypedDataUtils } from "@metamask/eth-sig-util"; import * as core from "@shapeshiftoss/hdwallet-core"; -import { getMessage, getTypeHash } from "eip-712"; import * as eip55 from "eip55"; import { arrayify, isBytes, isHexString } from "ethers/lib/utils.js"; @@ -188,80 +188,49 @@ export async function ethSignMessage(transport: Transport, msg: core.ETHSignMess }; } +/** + * Supports EIP-712 eth_signTypedData_v4 + * https://docs.metamask.io/wallet/how-to/sign-data/#use-eth_signtypeddata_v4 + * Due to lack of firmware support, a hashed version of the data is + * displayed to the user on the device when signing + */ export async function ethSignTypedData( transport: Transport, msg: core.ETHSignTypedData ): Promise { - /** - * If the message to be signed is sufficiently small, the KeepKey can calculate the - * domain separator and message hashes. Otherwise, we need to pre-calculate hashes - * here and verify on device. - */ - - const sTypes = JSON.stringify({ types: msg.typedData.types }); - const sPrimaryType = JSON.stringify({ primaryType: msg.typedData.primaryType }); - const sDomain = JSON.stringify({ domain: msg.typedData.domain }); - const sMessage = JSON.stringify({ message: msg.typedData.message }); - try { - if (sTypes.length > 2048 || sPrimaryType.length > 80 || sDomain.length > 2048 || sMessage.length > 2048) { - /* Pre-calculate domain separator and messages hashes and verify on KeepKey */ - - const domainSeparatorHash = getTypeHash(msg.typedData, "EIP712Domain"); - const domainSeparatorHash64 = Buffer.from(domainSeparatorHash).toString("base64"); - const messageHash = getMessage(msg.typedData, true); - const messageHash64 = Buffer.from(messageHash).toString("base64"); - - const t = new Ethereum.EthereumSignTypedHash(); - t.setAddressNList(msg.addressNList); - t.setDomainSeparatorHash(domainSeparatorHash64); - t.setMessageHash(messageHash64); - - const response = await transport.call(Messages.MessageType.MESSAGETYPE_ETHEREUMSIGNTYPEDHASH, t, { - msgTimeout: core.LONG_TIMEOUT, - }); - - const result = response.proto as Ethereum.EthereumTypedDataSignature; - const res: core.ETHSignedTypedData = { - address: result.getAddress() || "", - signature: "0x" + core.toHexString(result.getSignature_asU8()), - }; - - return res; - } else { - /* Let KeepKey calculate domain separator and message hashes */ - const dsh = new Ethereum.Ethereum712TypesValues(); - dsh.setAddressNList(msg.addressNList); - dsh.setEip712types(sTypes); - dsh.setEip712primetype(sPrimaryType); - dsh.setEip712data(sDomain); - dsh.setEip712typevals(1); - - let response = await transport.call(Messages.MessageType.MESSAGETYPE_ETHEREUM712TYPESVALUES, dsh, { - msgTimeout: core.LONG_TIMEOUT, - omitLock: true, - }); - - const mh = new Ethereum.Ethereum712TypesValues(); - mh.setAddressNList(msg.addressNList); - mh.setEip712types(sTypes); - mh.setEip712primetype(sPrimaryType); - mh.setEip712data(sMessage); - mh.setEip712typevals(2); + const version = SignTypedDataVersion.V4; + const EIP_712_DOMAIN = "EIP712Domain"; + const { types, primaryType, domain, message } = msg.typedData; + const domainSeparatorHash: Uint8Array = TypedDataUtils.hashStruct(EIP_712_DOMAIN, domain, types, version); + + const ethereumSignTypedHash = new Ethereum.EthereumSignTypedHash(); + ethereumSignTypedHash.setAddressNList(msg.addressNList); + ethereumSignTypedHash.setDomainSeparatorHash(domainSeparatorHash); + + let messageHash: Uint8Array | undefined = undefined; + // If "EIP712Domain" is the primaryType, messageHash is not required - look at T1 connect impl ;) + // todo: the firmware should define messageHash as an optional Uint8Array field for this case + if (primaryType !== EIP_712_DOMAIN) { + messageHash = TypedDataUtils.hashStruct(primaryType, message, types, version); + ethereumSignTypedHash.setMessageHash(messageHash); + } - response = await transport.call(Messages.MessageType.MESSAGETYPE_ETHEREUM712TYPESVALUES, mh, { + const response = await transport.call( + Messages.MessageType.MESSAGETYPE_ETHEREUMSIGNTYPEDHASH, + ethereumSignTypedHash, + { msgTimeout: core.LONG_TIMEOUT, - omitLock: true, - }); + } + ); - const result = response.proto as Ethereum.EthereumTypedDataSignature; - const res: core.ETHSignedTypedData = { - address: result.getAddress() || "", - signature: "0x" + core.toHexString(result.getSignature_asU8()), - }; + const result = response.proto as Ethereum.EthereumTypedDataSignature; + const res: core.ETHSignedTypedData = { + address: result.getAddress() || "", + signature: "0x" + core.toHexString(result.getSignature_asU8()), + }; - return res; - } + return res; } catch (error) { console.error({ error }); throw new Error("Failed to sign typed ETH message"); diff --git a/packages/hdwallet-keplr/package.json b/packages/hdwallet-keplr/package.json index 719cf0860..4af4968c0 100644 --- a/packages/hdwallet-keplr/package.json +++ b/packages/hdwallet-keplr/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-keplr", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -15,7 +15,7 @@ }, "dependencies": { "@shapeshiftoss/caip": "8.15.0", - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "@shapeshiftoss/proto-tx-builder": "^0.8.0", "@shapeshiftoss/types": "3.1.3", "base64-js": "^1.5.1", diff --git a/packages/hdwallet-ledger-webhid/package.json b/packages/hdwallet-ledger-webhid/package.json index 37e97eb90..c9d3dc7d7 100644 --- a/packages/hdwallet-ledger-webhid/package.json +++ b/packages/hdwallet-ledger-webhid/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-ledger-webhid", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -19,8 +19,8 @@ "@ledgerhq/hw-transport": "^6.7.0", "@ledgerhq/hw-transport-webhid": "^6.7.0", "@ledgerhq/live-common": "^21.8.2", - "@shapeshiftoss/hdwallet-core": "1.52.10", - "@shapeshiftoss/hdwallet-ledger": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", + "@shapeshiftoss/hdwallet-ledger": "1.52.11", "@types/w3c-web-hid": "^1.0.2" }, "devDependencies": { diff --git a/packages/hdwallet-ledger-webusb/package.json b/packages/hdwallet-ledger-webusb/package.json index fe4150ae4..5e4837880 100644 --- a/packages/hdwallet-ledger-webusb/package.json +++ b/packages/hdwallet-ledger-webusb/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-ledger-webusb", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -20,8 +20,8 @@ "@ledgerhq/hw-transport-webusb": "^6.7.0", "@ledgerhq/live-common": "^21.8.2", "@ledgerhq/logs": "^6.10.1", - "@shapeshiftoss/hdwallet-core": "1.52.10", - "@shapeshiftoss/hdwallet-ledger": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", + "@shapeshiftoss/hdwallet-ledger": "1.52.11", "@types/w3c-web-usb": "^1.0.4", "p-queue": "^7.4.1" }, diff --git a/packages/hdwallet-ledger/package.json b/packages/hdwallet-ledger/package.json index 19f3f46ae..17c662282 100644 --- a/packages/hdwallet-ledger/package.json +++ b/packages/hdwallet-ledger/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-ledger", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -18,7 +18,7 @@ "@ethereumjs/common": "^2.4.0", "@ethereumjs/tx": "^3.3.0", "@shapeshiftoss/bitcoinjs-lib": "5.2.0-shapeshift.2", - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "base64-js": "^1.5.1", "bchaddrjs": "^0.4.4", "bitcoinjs-message": "^2.0.0", diff --git a/packages/hdwallet-metamask-shapeshift-multichain/package.json b/packages/hdwallet-metamask-shapeshift-multichain/package.json index 2a4a11086..5ebdc6d04 100644 --- a/packages/hdwallet-metamask-shapeshift-multichain/package.json +++ b/packages/hdwallet-metamask-shapeshift-multichain/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-shapeshift-multichain", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -17,7 +17,7 @@ "@metamask/detect-provider": "^1.2.0", "@metamask/onboarding": "^1.0.1", "@shapeshiftoss/common-api": "^9.3.0", - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "@shapeshiftoss/metamask-snaps-adapter": "^1.0.8", "@shapeshiftoss/metamask-snaps-types": "^1.0.8", "eth-rpc-errors": "^4.0.3", diff --git a/packages/hdwallet-metamask/package.json b/packages/hdwallet-metamask/package.json index f60b26ead..11c1b6211 100644 --- a/packages/hdwallet-metamask/package.json +++ b/packages/hdwallet-metamask/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-metamask", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -16,7 +16,7 @@ "dependencies": { "@metamask/detect-provider": "^1.2.0", "@metamask/onboarding": "^1.0.1", - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "eth-rpc-errors": "^4.0.3", "lodash": "^4.17.21" }, diff --git a/packages/hdwallet-native-vault/package.json b/packages/hdwallet-native-vault/package.json index 3133935d9..27af0b8ec 100644 --- a/packages/hdwallet-native-vault/package.json +++ b/packages/hdwallet-native-vault/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-native-vault", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-native": "1.52.10", + "@shapeshiftoss/hdwallet-native": "1.52.11", "bip39": "^3.0.4", "hash-wasm": "^4.9.0", "idb-keyval": "^6.0.3", diff --git a/packages/hdwallet-native/package.json b/packages/hdwallet-native/package.json index f26d1d17d..6dbdecf79 100644 --- a/packages/hdwallet-native/package.json +++ b/packages/hdwallet-native/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-native", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -16,7 +16,7 @@ "dependencies": { "@shapeshiftoss/bitcoinjs-lib": "5.2.0-shapeshift.2", "@shapeshiftoss/fiosdk": "1.2.1-shapeshift.6", - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "@shapeshiftoss/proto-tx-builder": "^0.8.0", "@zxing/text-encoding": "^0.9.0", "bchaddrjs": "^0.4.9", diff --git a/packages/hdwallet-portis/package.json b/packages/hdwallet-portis/package.json index 781c4353b..bc9f47bba 100644 --- a/packages/hdwallet-portis/package.json +++ b/packages/hdwallet-portis/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-portis", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -15,7 +15,7 @@ }, "dependencies": { "@portis/web3": "3.0.10", - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "base64-js": "^1.5.1", "bip32": "^2.0.4", "bitcoinjs-lib": "^5.1.6", diff --git a/packages/hdwallet-tallyho/package.json b/packages/hdwallet-tallyho/package.json index f0d3bfe45..bce0e8ee4 100644 --- a/packages/hdwallet-tallyho/package.json +++ b/packages/hdwallet-tallyho/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-tallyho", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "lodash": "^4.17.21", "tallyho-onboarding": "^1.0.2" }, diff --git a/packages/hdwallet-tallyho/src/adapter.ts b/packages/hdwallet-tallyho/src/adapter.ts index 530de6cb6..06edd9b5e 100644 --- a/packages/hdwallet-tallyho/src/adapter.ts +++ b/packages/hdwallet-tallyho/src/adapter.ts @@ -23,6 +23,10 @@ export class TallyHoAdapter { return new TallyHoAdapter(keyring); } + public async initialize(): Promise { + return Object.keys(this.keyring.wallets).length; + } + public async pairDevice(): Promise { let provider: TallyHoEthereumProvider | null; // eslint-disable-next-line no-useless-catch diff --git a/packages/hdwallet-trezor-connect/package.json b/packages/hdwallet-trezor-connect/package.json index f8a9427f6..6643ae530 100644 --- a/packages/hdwallet-trezor-connect/package.json +++ b/packages/hdwallet-trezor-connect/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-trezor-connect", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -14,8 +14,8 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.52.10", - "@shapeshiftoss/hdwallet-trezor": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", + "@shapeshiftoss/hdwallet-trezor": "1.52.11", "@trezor/rollout": "^1.2.0", "trezor-connect": "^8.2.1" } diff --git a/packages/hdwallet-trezor/package.json b/packages/hdwallet-trezor/package.json index ded0ed94b..6cac7230c 100644 --- a/packages/hdwallet-trezor/package.json +++ b/packages/hdwallet-trezor/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-trezor", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -17,7 +17,7 @@ "dependencies": { "@ethereumjs/common": "^2.4.0", "@ethereumjs/tx": "^3.3.0", - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "base64-js": "^1.5.1", "lodash": "^4.17.21" }, diff --git a/packages/hdwallet-walletconnect/package.json b/packages/hdwallet-walletconnect/package.json index d554f2cc7..d673e10d4 100644 --- a/packages/hdwallet-walletconnect/package.json +++ b/packages/hdwallet-walletconnect/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-walletconnect", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -15,7 +15,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "@walletconnect/qrcode-modal": "^1.7.8", "@walletconnect/web3-provider": "^1.7.8", "ethers": "^5.6.5" diff --git a/packages/hdwallet-walletconnectV2/package.json b/packages/hdwallet-walletconnectV2/package.json index 4d6fc42fc..22f0a598a 100644 --- a/packages/hdwallet-walletconnectV2/package.json +++ b/packages/hdwallet-walletconnectV2/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-walletconnectv2", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -15,7 +15,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "@walletconnect/ethereum-provider": "^2.10.1", "@walletconnect/modal": "^2.6.2", "ethers": "^5.6.5" diff --git a/packages/hdwallet-xdefi/package.json b/packages/hdwallet-xdefi/package.json index b103921c1..bef82b2bb 100644 --- a/packages/hdwallet-xdefi/package.json +++ b/packages/hdwallet-xdefi/package.json @@ -1,6 +1,6 @@ { "name": "@shapeshiftoss/hdwallet-xdefi", - "version": "1.52.10", + "version": "1.52.11", "license": "MIT", "publishConfig": { "access": "public" @@ -14,7 +14,7 @@ "prepublishOnly": "yarn clean && yarn build" }, "dependencies": { - "@shapeshiftoss/hdwallet-core": "1.52.10", + "@shapeshiftoss/hdwallet-core": "1.52.11", "lodash": "^4.17.21" }, "devDependencies": { diff --git a/tsconfig.json b/tsconfig.json index 176257690..e92968f5c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,6 @@ "sourceMap": true, "composite": true, "isolatedModules": true, - /* Strict Type-Checking Options */ "strict": true, diff --git a/yarn.lock b/yarn.lock index d57ab9c19..62c3ddf77 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1225,7 +1225,7 @@ "@ethereumjs/common" "^2.4.0" ethereumjs-util "^7.1.0" -"@ethereumjs/tx@^4.1.2": +"@ethereumjs/tx@^4.1.2", "@ethereumjs/tx@^4.2.0": version "4.2.0" resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-4.2.0.tgz#5988ae15daf5a3b3c815493bc6b495e76009e853" integrity sha512-1nc6VO4jtFd172BbSnTnDQVr9IYBFl1y4xPzZdtkrkKIncBCkdbgfdRV+MiTkJYAtTxvV12GRZLqBFT1PNK6Yw== @@ -3842,6 +3842,14 @@ dependencies: "@lit-labs/ssr-dom-shim" "^1.0.0" +"@metamask/abi-utils@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@metamask/abi-utils/-/abi-utils-2.0.2.tgz#ad394e9cb8a95ac177cad942daadd88a246c0de8" + integrity sha512-B/A1dY/w4F/t6cDHUscklO6ovb/ztFsrsTXFd8QlqSByk/vyy+QbPE3VVpmmyI/7RX+PA1AJcvBdzCIz+r9dVQ== + dependencies: + "@metamask/utils" "^8.0.0" + superstruct "^1.0.3" + "@metamask/approval-controller@^3.5.1": version "3.5.1" resolved "https://registry.yarnpkg.com/@metamask/approval-controller/-/approval-controller-3.5.1.tgz#8d5099b7f0989d56b815a1423f395a15bf6bf056" @@ -3898,6 +3906,19 @@ json-rpc-random-id "^1.0.0" xtend "^4.0.1" +"@metamask/eth-sig-util@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@metamask/eth-sig-util/-/eth-sig-util-7.0.0.tgz#b035a2b826018578a5d463668bb64828271376d8" + integrity sha512-8KeXZB4SKx3EfNS5ahbjUMegyGvDQYk6Nk3hmM658sXpfAQR5ZlIXBgj+9RF+ZROqsU6EuNVgKt7Fr10re60PQ== + dependencies: + "@ethereumjs/util" "^8.1.0" + "@metamask/abi-utils" "^2.0.2" + "@metamask/utils" "^8.1.0" + ethereum-cryptography "^2.1.2" + ethjs-util "^0.1.6" + tweetnacl "^1.0.3" + tweetnacl-util "^0.15.1" + "@metamask/key-tree@^7.1.1": version "7.1.1" resolved "https://registry.yarnpkg.com/@metamask/key-tree/-/key-tree-7.1.1.tgz#559a76bf8fe0a3495c4a7aa41ed90f5475a7e2a2" @@ -4099,6 +4120,20 @@ semver "^7.5.4" superstruct "^1.0.3" +"@metamask/utils@^8.0.0", "@metamask/utils@^8.1.0": + version "8.2.0" + resolved "https://registry.yarnpkg.com/@metamask/utils/-/utils-8.2.0.tgz#51d608faf1ba7ba021084682160f275bb127d137" + integrity sha512-Zjx6y0PPrf9B4pdZ8JHl0grwJf/qNJ1dzYQh10/QSlj7Ct9Qy+r9PzdgGUHgA4oHohe1Phwy8MFnzB6TWZE11A== + dependencies: + "@ethereumjs/tx" "^4.2.0" + "@noble/hashes" "^1.3.1" + "@scure/base" "^1.1.3" + "@types/debug" "^4.1.7" + debug "^4.3.4" + pony-cause "^2.1.10" + semver "^7.5.4" + superstruct "^1.0.3" + "@motionone/animation@^10.15.1": version "10.15.1" resolved "https://registry.yarnpkg.com/@motionone/animation/-/animation-10.15.1.tgz#4a85596c31cbc5100ae8eb8b34c459fb0ccf6807" @@ -5394,7 +5429,7 @@ resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= -"@scure/base@^1.0.0", "@scure/base@^1.1.1", "@scure/base@~1.1.0": +"@scure/base@^1.0.0", "@scure/base@^1.1.1", "@scure/base@^1.1.3", "@scure/base@~1.1.0": version "1.1.3" resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.3.tgz#8584115565228290a6c6c4961973e0903bb3df2f" integrity sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q== @@ -6198,6 +6233,13 @@ jest-diff "^26.0.0" pretty-format "^26.0.0" +"@types/jquery@^3.5.22": + version "3.5.25" + resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-3.5.25.tgz#c817c71d414855f7d71f46da39f43e6b9579b0b9" + integrity sha512-gykx2c+OZf5nx2tv/5fDQqmvGgTiXshELy5jf9IgXPtVfSBl57IUYByN4osbwMXwJijWGOEYQABzGaFZE79A0Q== + dependencies: + "@types/sizzle" "*" + "@types/js-levenshtein@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@types/js-levenshtein/-/js-levenshtein-1.1.0.tgz#9541eec4ad6e3ec5633270a3a2b55d981edc44a9" @@ -6412,6 +6454,11 @@ dependencies: "@types/node" "*" +"@types/sizzle@*": + version "2.3.5" + resolved "https://registry.yarnpkg.com/@types/sizzle/-/sizzle-2.3.5.tgz#d93dd29cdcd5801d90be968073b09a6b370780e4" + integrity sha512-tAe4Q+OLFOA/AMD+0lq8ovp8t3ysxAOeaScnfNdZpUxaGl51ZMDEITxkvFl1STudQ58mz6gzVGl9VhMKhwRnZQ== + "@types/stack-utils@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" @@ -10930,7 +10977,7 @@ ethereum-cryptography@^0.1.3: secp256k1 "^4.0.1" setimmediate "^1.0.5" -ethereum-cryptography@^2.0.0: +ethereum-cryptography@^2.0.0, ethereum-cryptography@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-2.1.2.tgz#18fa7108622e56481157a5cb7c01c0c6a672eb67" integrity sha512-Z5Ba0T0ImZ8fqXrJbpHcbpAvIswRte2wGNR/KePnu8GbbvgJ47lMxT/ZZPG6i9Jaht4azPDop4HaM00J0J59ug== @@ -11210,7 +11257,7 @@ ethjs-unit@0.1.6, ethjs-unit@^0.1.6: bn.js "4.11.6" number-to-bn "1.7.0" -ethjs-util@0.1.6, ethjs-util@^0.1.3: +ethjs-util@0.1.6, ethjs-util@^0.1.3, ethjs-util@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.6.tgz#f308b62f185f9fe6237132fb2a9818866a5cd536" integrity sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w== @@ -13955,10 +14002,10 @@ jose@^4.3.5: resolved "https://registry.yarnpkg.com/jose/-/jose-4.3.5.tgz#890ec0b3bf26db0b36946ca54087335200deb6f7" integrity sha512-mdTu3En79OYMGBNHw4828hl6ZUOb+gQtNZVRgM+eVL3Rrs4ZYUv/yHPpfDh65GN2HhKBvJsvA0/6tKEcpkyzeg== -jquery@^3.4.1: - version "3.6.0" - resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470" - integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw== +jquery@^3.7.1: + version "3.7.1" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.7.1.tgz#083ef98927c9a6a74d05a6af02806566d16274de" + integrity sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg== js-levenshtein@^1.1.6: version "1.1.6" @@ -16548,6 +16595,11 @@ pocket-js-core@0.0.3: dependencies: axios "^0.18.0" +pony-cause@^2.1.10: + version "2.1.10" + resolved "https://registry.yarnpkg.com/pony-cause/-/pony-cause-2.1.10.tgz#828457ad6f13be401a075dbf14107a9057945174" + integrity sha512-3IKLNXclQgkU++2fSi93sQ6BznFuxSLB11HdvZQ6JW/spahf/P1pAHBQEahr20rs0htZW0UDkM1HmA+nZkXKsw== + posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" @@ -19364,7 +19416,7 @@ tunnel@^0.0.6: resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg== -tweetnacl-util@^0.15.0: +tweetnacl-util@^0.15.0, tweetnacl-util@^0.15.1: version "0.15.1" resolved "https://registry.yarnpkg.com/tweetnacl-util/-/tweetnacl-util-0.15.1.tgz#b80fcdb5c97bcc508be18c44a4be50f022eea00b" integrity sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw==