Skip to content

Commit c197ede

Browse files
feat: eip-6963 support (#689)
1 parent d20a7d9 commit c197ede

File tree

94 files changed

+299
-3713
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+299
-3713
lines changed

examples/sandbox/index.html

-2
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ <h4>Select</h4>
117117
<button id="native">Pair Native</button>
118118
<button id="metaMask">Pair MetaMask</button>
119119
<button id="phantom">Pair Phantom</button>
120-
<button id="xdefi">Pair XDEFI</button>
121120
<button id="keplr">Pair Keplr</button>
122-
<button id="tallyHo">Pair Tally Ho</button>
123121
<button id="coinbase">Pair Coinbase</button>
124122
<button id="walletConnect">Pair WalletConnect</button>
125123
<button id="walletConnectV2">Pair WalletConnect V2</button>

examples/sandbox/index.ts

+2-40
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ import * as keepkeyWebUSB from "@shapeshiftoss/hdwallet-keepkey-webusb";
99
import * as keplr from "@shapeshiftoss/hdwallet-keplr";
1010
import * as ledgerWebHID from "@shapeshiftoss/hdwallet-ledger-webhid";
1111
import * as ledgerWebUSB from "@shapeshiftoss/hdwallet-ledger-webusb";
12-
import * as metaMask from "@shapeshiftoss/hdwallet-metamask";
12+
import * as metaMask from "@shapeshiftoss/hdwallet-metamask-multichain";
1313
import * as native from "@shapeshiftoss/hdwallet-native";
1414
import * as phantom from "@shapeshiftoss/hdwallet-phantom";
1515
import * as portis from "@shapeshiftoss/hdwallet-portis";
16-
import * as tallyHo from "@shapeshiftoss/hdwallet-tallyho";
1716
import * as trezorConnect from "@shapeshiftoss/hdwallet-trezor-connect";
1817
import { WalletConnectProviderConfig } from "@shapeshiftoss/hdwallet-walletconnect";
1918
import * as walletConnect from "@shapeshiftoss/hdwallet-walletconnect";
2019
import * as walletConnectv2 from "@shapeshiftoss/hdwallet-walletconnectv2";
21-
import * as xdefi from "@shapeshiftoss/hdwallet-xdefi";
2220
import { EthereumProviderOptions } from "@walletconnect/ethereum-provider/dist/types/EthereumProvider";
2321
import { TypedData } from "eip-712";
2422
import $, { noop } from "jquery";
@@ -126,12 +124,10 @@ const keepkeyAdapter = keepkeyWebUSB.WebUSBKeepKeyAdapter.useKeyring(keyring);
126124
const kkbridgeAdapter = keepkeyTcp.TCPKeepKeyAdapter.useKeyring(keyring);
127125
const kkemuAdapter = keepkeyTcp.TCPKeepKeyAdapter.useKeyring(keyring);
128126
const portisAdapter = portis.PortisAdapter.useKeyring(keyring, { portisAppId });
129-
const metaMaskAdapter = metaMask.MetaMaskAdapter.useKeyring(keyring);
127+
const metaMaskAdapter = metaMask.MetaMaskAdapter.useKeyring(keyring, "io.metamask");
130128
const phantomAdapter = phantom.PhantomAdapter.useKeyring(keyring);
131-
const tallyHoAdapter = tallyHo.TallyHoAdapter.useKeyring(keyring);
132129
const walletConnectAdapter = walletConnect.WalletConnectAdapter.useKeyring(keyring, walletConnectOptions);
133130
const walletConnectV2Adapter = walletConnectv2.WalletConnectV2Adapter.useKeyring(keyring, walletConnectV2Options);
134-
const xdefiAdapter = xdefi.XDEFIAdapter.useKeyring(keyring);
135131
const keplrAdapter = keplr.KeplrAdapter.useKeyring(keyring);
136132
const nativeAdapter = native.NativeAdapter.useKeyring(keyring);
137133
const trezorAdapter = trezorConnect.TrezorAdapter.useKeyring(keyring, {
@@ -162,10 +158,8 @@ const $native = $("#native");
162158
const $metaMask = $("#metaMask");
163159
const $phantom = $("#phantom");
164160
const $coinbase = $("#coinbase");
165-
const $tallyHo = $("#tallyHo");
166161
const $walletConnect = $("#walletConnect");
167162
const $walletConnectV2 = $("#walletConnectV2");
168-
const $xdefi = $("#xdefi");
169163
const $keplr = $("#keplr");
170164
const $keyring = $("#keyring");
171165

@@ -284,19 +278,6 @@ $keplr.on("click", async (e) => {
284278
}
285279
});
286280

287-
$tallyHo.on("click", async (e) => {
288-
e.preventDefault();
289-
wallet = await tallyHoAdapter.pairDevice();
290-
window["wallet"] = wallet;
291-
let deviceID = "nothing";
292-
try {
293-
deviceID = await wallet.getDeviceID();
294-
$("#keyring select").val(deviceID);
295-
} catch (error) {
296-
console.error(error);
297-
}
298-
});
299-
300281
$walletConnect.on("click", async (e) => {
301282
e.preventDefault();
302283
try {
@@ -323,19 +304,6 @@ $walletConnectV2.on("click", async (e) => {
323304
}
324305
});
325306

326-
$xdefi.on("click", async (e) => {
327-
e.preventDefault();
328-
wallet = await xdefiAdapter.pairDevice();
329-
window["wallet"] = wallet;
330-
let deviceID = "nothing";
331-
try {
332-
deviceID = await wallet.getDeviceID();
333-
$("#keyring select").val(deviceID);
334-
} catch (error) {
335-
console.error(error);
336-
}
337-
});
338-
339307
async function deviceConnected(deviceId) {
340308
wallet = keyring.get(deviceId);
341309
if (!$keyring.find(`option[value="${deviceId}"]`).length) {
@@ -426,12 +394,6 @@ async function deviceConnected(deviceId) {
426394
console.error("Could not initialize PhantomAdapter", e);
427395
}
428396

429-
try {
430-
await tallyHoAdapter.initialize();
431-
} catch (e) {
432-
console.error("Could not initialize TallyHoAdapter", e);
433-
}
434-
435397
try {
436398
await keplrAdapter.initialize();
437399
} catch (e) {

examples/sandbox/package.json

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shapeshiftoss/hdwallet-sandbox",
3-
"version": "1.55.10",
3+
"version": "1.55.11",
44
"license": "MIT",
55
"private": true,
66
"browserslist": "> 0.5%, last 2 versions, not dead",
@@ -12,25 +12,23 @@
1212
"dependencies": {
1313
"@esm2cjs/p-queue": "^7.3.0",
1414
"@metamask/eth-sig-util": "^7.0.0",
15-
"@shapeshiftoss/hdwallet-coinbase": "1.55.10",
16-
"@shapeshiftoss/hdwallet-core": "1.55.10",
17-
"@shapeshiftoss/hdwallet-keepkey": "1.55.10",
18-
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.55.10",
19-
"@shapeshiftoss/hdwallet-keepkey-webusb": "1.55.10",
20-
"@shapeshiftoss/hdwallet-keplr": "1.55.10",
21-
"@shapeshiftoss/hdwallet-ledger": "1.55.10",
22-
"@shapeshiftoss/hdwallet-ledger-webhid": "1.55.10",
23-
"@shapeshiftoss/hdwallet-ledger-webusb": "1.55.10",
24-
"@shapeshiftoss/hdwallet-metamask": "1.55.10",
25-
"@shapeshiftoss/hdwallet-native": "1.55.10",
26-
"@shapeshiftoss/hdwallet-phantom": "1.55.10",
27-
"@shapeshiftoss/hdwallet-portis": "1.55.10",
28-
"@shapeshiftoss/hdwallet-tallyho": "1.55.10",
29-
"@shapeshiftoss/hdwallet-trezor": "1.55.10",
30-
"@shapeshiftoss/hdwallet-trezor-connect": "1.55.10",
31-
"@shapeshiftoss/hdwallet-walletconnect": "1.55.10",
32-
"@shapeshiftoss/hdwallet-walletconnectv2": "1.55.10",
33-
"@shapeshiftoss/hdwallet-xdefi": "1.55.10",
15+
"@shapeshiftoss/hdwallet-coinbase": "1.55.11",
16+
"@shapeshiftoss/hdwallet-core": "1.55.11",
17+
"@shapeshiftoss/hdwallet-keepkey": "1.55.11",
18+
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.55.11",
19+
"@shapeshiftoss/hdwallet-keepkey-webusb": "1.55.11",
20+
"@shapeshiftoss/hdwallet-keplr": "1.55.11",
21+
"@shapeshiftoss/hdwallet-ledger": "1.55.11",
22+
"@shapeshiftoss/hdwallet-ledger-webhid": "1.55.11",
23+
"@shapeshiftoss/hdwallet-ledger-webusb": "1.55.11",
24+
"@shapeshiftoss/hdwallet-metamask-multichain": "1.55.11",
25+
"@shapeshiftoss/hdwallet-native": "1.55.11",
26+
"@shapeshiftoss/hdwallet-phantom": "1.55.11",
27+
"@shapeshiftoss/hdwallet-portis": "1.55.11",
28+
"@shapeshiftoss/hdwallet-trezor": "1.55.11",
29+
"@shapeshiftoss/hdwallet-trezor-connect": "1.55.11",
30+
"@shapeshiftoss/hdwallet-walletconnect": "1.55.11",
31+
"@shapeshiftoss/hdwallet-walletconnectv2": "1.55.11",
3432
"bip32": "^2.0.4",
3533
"eip-712": "^1.0.0",
3634
"jquery": "^3.7.1",

integration/package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shapeshiftoss/integration",
3-
"version": "1.55.10",
3+
"version": "1.55.11",
44
"main": "index.js",
55
"license": "MIT",
66
"private": true,
@@ -10,15 +10,15 @@
1010
"dev": "lerna run test --scope integration --parallel --include-filtered-dependencies"
1111
},
1212
"dependencies": {
13-
"@shapeshiftoss/hdwallet-core": "1.55.10",
14-
"@shapeshiftoss/hdwallet-keepkey": "1.55.10",
15-
"@shapeshiftoss/hdwallet-keepkey-nodewebusb": "1.55.10",
16-
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.55.10",
17-
"@shapeshiftoss/hdwallet-ledger": "1.55.10",
18-
"@shapeshiftoss/hdwallet-native": "1.55.10",
19-
"@shapeshiftoss/hdwallet-portis": "1.55.10",
20-
"@shapeshiftoss/hdwallet-trezor": "1.55.10",
21-
"@shapeshiftoss/hdwallet-xdefi": "1.55.10",
13+
"@shapeshiftoss/hdwallet-core": "1.55.11",
14+
"@shapeshiftoss/hdwallet-keepkey": "1.55.11",
15+
"@shapeshiftoss/hdwallet-keepkey-nodewebusb": "1.55.11",
16+
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.55.11",
17+
"@shapeshiftoss/hdwallet-ledger": "1.55.11",
18+
"@shapeshiftoss/hdwallet-metamask-multichain": "1.55.11",
19+
"@shapeshiftoss/hdwallet-native": "1.55.11",
20+
"@shapeshiftoss/hdwallet-portis": "1.55.11",
21+
"@shapeshiftoss/hdwallet-trezor": "1.55.11",
2222
"fast-json-stable-stringify": "^2.1.0",
2323
"msw": "^0.27.1",
2424
"whatwg-fetch": "^3.6.2"

integration/src/bitcoin/bitcoin.ts

+25-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as core from "@shapeshiftoss/hdwallet-core";
22
import * as ledger from "@shapeshiftoss/hdwallet-ledger";
3+
import * as metamask from "@shapeshiftoss/hdwallet-metamask-multichain";
34
import * as native from "@shapeshiftoss/hdwallet-native";
45
import * as phantom from "@shapeshiftoss/hdwallet-phantom";
56
import * as portis from "@shapeshiftoss/hdwallet-portis";
@@ -62,6 +63,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
6263
"btcSupportsCoin()",
6364
async () => {
6465
if (!wallet || portis.isPortis(wallet)) return;
66+
// Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
67+
if (metamask.isMetaMask(wallet)) return;
6568
expect(wallet.btcSupportsCoin("Bitcoin")).toBeTruthy();
6669
expect(await info.btcSupportsCoin("Bitcoin")).toBeTruthy();
6770
},
@@ -71,7 +74,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
7174
test(
7275
"btcSupportsCoin() - Testnet",
7376
async () => {
74-
if (!wallet || portis.isPortis(wallet) || phantom.isPhantom(wallet)) return;
77+
if (!wallet || portis.isPortis(wallet) || phantom.isPhantom(wallet) || metamask.isMetaMask(wallet)) return;
7578
expect(wallet.btcSupportsCoin("Testnet")).toBeTruthy();
7679
expect(await info.btcSupportsCoin("Testnet")).toBeTruthy();
7780
},
@@ -88,6 +91,9 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
8891
)
8992
return;
9093

94+
// Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
95+
if (metamask.isMetaMask(wallet)) return;
96+
9197
/* FIXME: Expected failure (trezor does not use scriptType in deriving public keys
9298
and ledger's dependency bitcoinjs-lib/src/crypto.js throws a mysterious TypeError
9399
in between mock transport calls.
@@ -210,10 +216,14 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
210216
const scriptType = args[3] as core.BTCInputScriptType;
211217
const expected = args[4] as string;
212218

219+
// Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
220+
if (metamask.isMetaMask(wallet)) return;
221+
213222
if (!(await wallet.btcSupportsCoin(coin))) return;
214223
expect(await info.btcSupportsCoin(coin)).toBeTruthy();
215224
if (!(await wallet.btcSupportsScriptType(coin, scriptType))) return;
216225
expect(await info.btcSupportsScriptType(coin, scriptType)).toBeTruthy();
226+
217227
const res = await wallet.btcGetAddress({
218228
addressNList: core.bip32ToAddressNList(path),
219229
coin: coin,
@@ -230,7 +240,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
230240
test(
231241
"btcSignTx() - p2pkh",
232242
async () => {
233-
if (!wallet || portis.isPortis(wallet) || phantom.isPhantom(wallet)) return;
243+
if (!wallet || portis.isPortis(wallet) || phantom.isPhantom(wallet) || metamask.isMetaMask(wallet)) return;
234244
if (ledger.isLedger(wallet)) return; // FIXME: Expected failure
235245
const tx: core.BitcoinTx = {
236246
version: 1,
@@ -305,7 +315,7 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
305315
test(
306316
"btcSignTx() - thorchain swap",
307317
async () => {
308-
if (!wallet || portis.isPortis(wallet) || phantom.isPhantom(wallet)) return;
318+
if (!wallet || portis.isPortis(wallet) || phantom.isPhantom(wallet) || metamask.isMetaMask(wallet)) return;
309319
if (ledger.isLedger(wallet)) return; // FIXME: Expected failure
310320
if (trezor.isTrezor(wallet)) return; //TODO: Add trezor support for op return data passed at top level
311321
const tx: core.BitcoinTx = {
@@ -391,6 +401,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
391401
"btcSignMessage()",
392402
async () => {
393403
if (!wallet) return;
404+
// Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
405+
if (metamask.isMetaMask(wallet)) return;
394406

395407
// not implemented for native
396408
if (native.isNative(wallet)) {
@@ -424,6 +436,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
424436
"btcVerifyMessage() - good",
425437
async () => {
426438
if (!wallet) return;
439+
// Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
440+
if (metamask.isMetaMask(wallet)) return;
427441

428442
// not implemented for native
429443
if (native.isNative(wallet)) {
@@ -447,6 +461,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
447461
"btcVerifyMessage() - bad",
448462
async () => {
449463
if (!wallet) return;
464+
// Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
465+
if (metamask.isMetaMask(wallet)) return;
450466

451467
// not implemented for native
452468
if (native.isNative(wallet)) {
@@ -470,6 +486,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
470486
"btcSupportsSecureTransfer()",
471487
async () => {
472488
if (!wallet) return;
489+
// Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
490+
if (metamask.isMetaMask(wallet)) return;
473491
expect(typeof (await wallet.btcSupportsSecureTransfer()) === typeof true).toBeTruthy();
474492
if (await wallet.btcSupportsSecureTransfer()) {
475493
// eslint-disable-next-line jest/no-conditional-expect
@@ -484,6 +502,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
484502
"btcSupportsNativeShapeShift()",
485503
async () => {
486504
if (!wallet) return;
505+
// Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
506+
if (metamask.isMetaMask(wallet)) return;
487507
expect(typeof wallet.btcSupportsNativeShapeShift()).toBe("boolean");
488508
if (wallet.btcSupportsNativeShapeShift()) {
489509
// eslint-disable-next-line jest/no-conditional-expect
@@ -515,6 +535,8 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
515535
const accountIdx = args[1] as number;
516536
const scriptType = args[2] as core.BTCInputScriptType;
517537
if (!wallet) return;
538+
// Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
539+
if (metamask.isMetaMask(wallet)) return;
518540
if (!(await wallet.btcSupportsCoin(coin))) return;
519541
expect(await info.btcSupportsCoin(coin)).toBeTruthy();
520542
if (!(await wallet.btcSupportsScriptType(coin, scriptType))) return;
@@ -537,29 +559,5 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
537559
},
538560
TIMEOUT
539561
);
540-
541-
test(
542-
"btcIsSameAccount()",
543-
async () => {
544-
if (!wallet || phantom.isPhantom(wallet)) return;
545-
[0, 1, 9].forEach((idx) => {
546-
const paths = wallet.btcGetAccountPaths({
547-
coin: "Bitcoin",
548-
accountIdx: idx,
549-
});
550-
expect(typeof wallet.btcIsSameAccount(paths) === typeof true).toBeTruthy();
551-
paths.forEach((path) => {
552-
if (wallet.getVendor() === "Portis") {
553-
// eslint-disable-next-line jest/no-conditional-expect
554-
expect(wallet.btcNextAccountPath(path)).toBeUndefined();
555-
} else {
556-
// eslint-disable-next-line jest/no-conditional-expect
557-
expect(wallet.btcNextAccountPath(path)).not.toBeUndefined();
558-
}
559-
});
560-
});
561-
},
562-
TIMEOUT
563-
);
564562
});
565563
}

integration/src/bitcoin/litecoin.ts

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as core from "@shapeshiftoss/hdwallet-core";
2+
import * as metamask from "@shapeshiftoss/hdwallet-metamask-multichain";
23

34
import { each } from "../utils";
45

@@ -32,6 +33,8 @@ export function litecoinTests(get: () => { wallet: core.HDWallet; info: core.HDW
3233
"btcGetAddress()",
3334
async () => {
3435
if (!wallet) return;
36+
// Non-EVM things are a pain to test with snaps on test env, this wasn't tested before and still isn't
37+
if (metamask.isMetaMask(wallet)) return;
3538
if (!(await wallet.btcSupportsCoin("Litecoin"))) return;
3639
await each(
3740
[
@@ -105,21 +108,5 @@ export function litecoinTests(get: () => { wallet: core.HDWallet; info: core.HDW
105108
},
106109
TIMEOUT
107110
);
108-
109-
test(
110-
"btcIsSameAccount()",
111-
async () => {
112-
if (!wallet) return;
113-
if (!(await wallet.btcSupportsCoin("Litecoin"))) return;
114-
[0, 1, 9].forEach((idx) => {
115-
const paths = wallet.btcGetAccountPaths({
116-
coin: "Litecoin",
117-
accountIdx: idx,
118-
});
119-
expect(typeof wallet.btcIsSameAccount(paths) === typeof true).toBeTruthy();
120-
});
121-
},
122-
TIMEOUT
123-
);
124111
});
125112
}

0 commit comments

Comments
 (0)