Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WalletConnect #544

Merged
merged 19 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/sandbox/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ <h4>Select</h4>
<button id="xdefi">Pair XDEFI</button>
<button id="keplr">Pair Keplr</button>
<button id="tallyHo">Pair Tally Ho</button>
<button id="walletConnect">Pair WalletConnect</button>

<select id="keyring" style="height: 100px" size="4"></select>
</div>
Expand Down
36 changes: 30 additions & 6 deletions examples/sandbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import * as native from "@shapeshiftoss/hdwallet-native";
import * as portis from "@shapeshiftoss/hdwallet-portis";
import * as tallyHo from "@shapeshiftoss/hdwallet-tallyho";
import * as trezorConnect from "@shapeshiftoss/hdwallet-trezor-connect";
import { WalletConnectProviderConfig } from "@shapeshiftoss/hdwallet-walletconnect";
import * as walletConnect from "@shapeshiftoss/hdwallet-walletconnect";
import * as xdefi from "@shapeshiftoss/hdwallet-xdefi";
import $ from "jquery";
import Web3 from "web3";
Expand Down Expand Up @@ -45,6 +47,11 @@ const keyring = new core.Keyring();

const portisAppId = "ff763d3d-9e34-45a1-81d1-caa39b9c64f9";
const mnemonic = "alcohol woman abuse must during monitor noble actual mixed trade anger aisle";
const walletConnectOptions: WalletConnectProviderConfig = {
rpc: {
1: "https://mainnet.infura.io/v3/d734c7eebcdf400185d7eb67322a7e57",
},
};

const testPublicWalletXpubs = [
"xpub661MyMwAqRbcFLgDU7wpcEVubSF7NkswwmXBUkDiGUW6uopeUMys4AqKXNgpfZKRTLnpKQgffd6a2c3J8JxLkF1AQN17Pm9QYHEqEfo1Rsx", // all seed root key
Expand All @@ -67,12 +74,10 @@ const kkemuAdapter = keepkeyTcp.TCPKeepKeyAdapter.useKeyring(keyring);
const portisAdapter = portis.PortisAdapter.useKeyring(keyring, { portisAppId });
const metaMaskAdapter = metaMask.MetaMaskAdapter.useKeyring(keyring);
const tallyHoAdapter = tallyHo.TallyHoAdapter.useKeyring(keyring);
const walletConnectAdapter = walletConnect.WalletConnectAdapter.useKeyring(keyring, walletConnectOptions);
const xdefiAdapter = xdefi.XDEFIAdapter.useKeyring(keyring);
const keplrAdapter = keplr.KeplrAdapter.useKeyring(keyring);
const nativeAdapter = native.NativeAdapter.useKeyring(keyring, {
mnemonic,
deviceId: "native-wallet-test",
});
const nativeAdapter = native.NativeAdapter.useKeyring(keyring);
const trezorAdapter = trezorConnect.TrezorAdapter.useKeyring(keyring, {
debug: false,
manifest: {
Expand Down Expand Up @@ -100,6 +105,7 @@ const $portis = $("#portis");
const $native = $("#native");
const $metaMask = $("#metaMask");
const $tallyHo = $("#tallyHo");
const $walletConnect = $("#walletConnect");
const $xdefi = $("#xdefi");
const $keplr = $("#keplr");
const $keyring = $("#keyring");
Expand Down Expand Up @@ -214,9 +220,22 @@ $tallyHo.on("click", async (e) => {
}
});

$walletConnect.on("click", async (e) => {
e.preventDefault();
try {
wallet = await walletConnectAdapter.pairDevice();
window["wallet"] = wallet;
let deviceID = "nothing";
deviceID = await wallet.getDeviceID();
$("#keyring select").val(deviceID);
} catch (error) {
console.error(error);
}
});

$xdefi.on("click", async (e) => {
e.preventDefault();
wallet = await xdefiAdapter.pairDevice("testid");
wallet = await xdefiAdapter.pairDevice();
window["wallet"] = wallet;
let deviceID = "nothing";
try {
Expand Down Expand Up @@ -314,6 +333,12 @@ async function deviceConnected(deviceId) {
console.error("Could not initialize TallyHoAdapter", e);
}

try {
await walletConnectAdapter.initialize();
} catch (e) {
console.error("Could not initialize WalletConnectAdapter", e);
}

for (const deviceID of Object.keys(keyring.wallets)) {
await deviceConnected(deviceID);
}
Expand Down Expand Up @@ -676,7 +701,6 @@ $binanceTx.on("click", async (e) => {
if (core.supportsBinance(wallet)) {
const res = await wallet.binanceSignTx({
addressNList: core.bip32ToAddressNList(`m/44'/714'/0'/0/0`),
chain_id: "Binance-Chain-Nile",
account_number: "24250",
sequence: 31,
tx: bnbTxJson,
Expand Down
26 changes: 13 additions & 13 deletions examples/sandbox/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hdwallet-sandbox",
"version": "1.25.0",
"version": "1.26.0",
"license": "MIT",
"private": true,
"browserslist": "> 0.5%, last 2 versions, not dead",
Expand All @@ -10,18 +10,18 @@
"clean": "rm -rf public .parcel-cache"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "1.25.0",
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.25.0",
"@shapeshiftoss/hdwallet-keepkey-webusb": "1.25.0",
"@shapeshiftoss/hdwallet-ledger": "1.25.0",
"@shapeshiftoss/hdwallet-ledger-webhid": "1.25.0",
"@shapeshiftoss/hdwallet-ledger-webusb": "1.25.0",
"@shapeshiftoss/hdwallet-metamask": "1.25.0",
"@shapeshiftoss/hdwallet-native": "1.25.0",
"@shapeshiftoss/hdwallet-portis": "1.25.0",
"@shapeshiftoss/hdwallet-trezor": "1.25.0",
"@shapeshiftoss/hdwallet-trezor-connect": "1.25.0",
"@shapeshiftoss/hdwallet-xdefi": "1.25.0",
"@shapeshiftoss/hdwallet-core": "1.26.0",
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.26.0",
"@shapeshiftoss/hdwallet-keepkey-webusb": "1.26.0",
"@shapeshiftoss/hdwallet-ledger": "1.26.0",
"@shapeshiftoss/hdwallet-ledger-webhid": "1.26.0",
"@shapeshiftoss/hdwallet-ledger-webusb": "1.26.0",
"@shapeshiftoss/hdwallet-metamask": "1.26.0",
"@shapeshiftoss/hdwallet-native": "1.26.0",
"@shapeshiftoss/hdwallet-portis": "1.26.0",
"@shapeshiftoss/hdwallet-trezor": "1.26.0",
"@shapeshiftoss/hdwallet-trezor-connect": "1.26.0",
"@shapeshiftoss/hdwallet-xdefi": "1.26.0",
"bip32": "^2.0.4",
"jquery": "^3.4.1",
"json": "^9.0.6",
Expand Down
20 changes: 10 additions & 10 deletions integration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/integration",
"version": "1.25.0",
"version": "1.26.0",
"main": "index.js",
"license": "MIT",
"private": true,
Expand All @@ -10,15 +10,15 @@
"dev": "lerna run test --scope integration --parallel --include-filtered-dependencies"
},
"dependencies": {
"@shapeshiftoss/hdwallet-core": "1.25.0",
"@shapeshiftoss/hdwallet-keepkey": "1.25.0",
"@shapeshiftoss/hdwallet-keepkey-nodewebusb": "1.25.0",
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.25.0",
"@shapeshiftoss/hdwallet-ledger": "1.25.0",
"@shapeshiftoss/hdwallet-native": "1.25.0",
"@shapeshiftoss/hdwallet-portis": "1.25.0",
"@shapeshiftoss/hdwallet-trezor": "1.25.0",
"@shapeshiftoss/hdwallet-xdefi": "1.25.0",
"@shapeshiftoss/hdwallet-core": "1.26.0",
"@shapeshiftoss/hdwallet-keepkey": "1.26.0",
"@shapeshiftoss/hdwallet-keepkey-nodewebusb": "1.26.0",
"@shapeshiftoss/hdwallet-keepkey-tcp": "1.26.0",
"@shapeshiftoss/hdwallet-ledger": "1.26.0",
"@shapeshiftoss/hdwallet-native": "1.26.0",
"@shapeshiftoss/hdwallet-portis": "1.26.0",
"@shapeshiftoss/hdwallet-trezor": "1.26.0",
"@shapeshiftoss/hdwallet-xdefi": "1.26.0",
"@types/jest": "^26.0.23",
"fast-json-stable-stringify": "^2.1.0",
"jest": "^26.6.3",
Expand Down
2 changes: 2 additions & 0 deletions integration/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as native from "@shapeshiftoss/hdwallet-native";
import * as portis from "@shapeshiftoss/hdwallet-portis";
import * as tallyHo from "@shapeshiftoss/hdwallet-tallyho";
import * as trezor from "@shapeshiftoss/hdwallet-trezor";
import * as walletconnect from "@shapeshiftoss/hdwallet-walletconnect";
import * as xdefi from "@shapeshiftoss/hdwallet-xdefi";

import { binanceTests } from "./binance";
Expand Down Expand Up @@ -56,6 +57,7 @@ export function integration(suite: WalletSuite): void {
(native.isNative(wallet) ? 1 : 0) +
(metamask.isMetaMask(wallet) ? 1 : 0) +
(tallyHo.isTallyHo(wallet) ? 1 : 0) +
(walletconnect.isWalletConnect(wallet) ? 1 : 0) +
(xdefi.isXDEFI(wallet) ? 1 : 0)
).toEqual(1);
});
Expand Down
Loading