@shapeshiftoss/hdwallet-walletconnectv2 1.50.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 ShapeShift
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ import { Keyring } from "@shapeshiftoss/hdwallet-core";
2
+ import { EthereumProviderOptions } from "@walletconnect/ethereum-provider/dist/types/EthereumProvider";
3
+ import { WalletConnectV2HDWallet } from "./walletconnectV2";
4
+ export declare class WalletConnectV2Adapter {
5
+ keyring: Keyring;
6
+ private readonly providerConfig;
7
+ private constructor();
8
+ static useKeyring(keyring: Keyring, config: EthereumProviderOptions): WalletConnectV2Adapter;
9
+ initialize(): Promise<number>;
10
+ pairDevice(): Promise<WalletConnectV2HDWallet>;
11
+ }
12
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8DAA8D,CAAC;AAEvG,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,qBAAa,sBAAsB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA0B;IAEzD,OAAO;WAKO,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,uBAAuB;IAI7D,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B,UAAU,IAAI,OAAO,CAAC,uBAAuB,CAAC;CAoB5D"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.WalletConnectV2Adapter = void 0;
13
+ const hdwallet_core_1 = require("@shapeshiftoss/hdwallet-core");
14
+ const ethereum_provider_1 = require("@walletconnect/ethereum-provider");
15
+ const walletconnectV2_1 = require("./walletconnectV2");
16
+ class WalletConnectV2Adapter {
17
+ constructor(keyring, config) {
18
+ this.keyring = keyring;
19
+ this.providerConfig = config;
20
+ }
21
+ static useKeyring(keyring, config) {
22
+ return new WalletConnectV2Adapter(keyring, config);
23
+ }
24
+ initialize() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return Object.keys(this.keyring.wallets).length;
27
+ });
28
+ }
29
+ pairDevice() {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ try {
32
+ if (!this.providerConfig) {
33
+ throw new Error("WalletConnectV2 provider configuration not set.");
34
+ }
35
+ const provider = yield ethereum_provider_1.EthereumProvider.init(this.providerConfig);
36
+ const wallet = new walletconnectV2_1.WalletConnectV2HDWallet(provider);
37
+ // Enable session (triggers QR Code modal)
38
+ yield wallet.initialize();
39
+ const deviceID = yield wallet.getDeviceID();
40
+ this.keyring.add(wallet, deviceID);
41
+ this.keyring.emit(["WalletConnectV2", deviceID, hdwallet_core_1.Events.CONNECT], deviceID);
42
+ return wallet;
43
+ }
44
+ catch (error) {
45
+ console.error("Could not pair WalletConnectV2");
46
+ throw error;
47
+ }
48
+ });
49
+ }
50
+ }
51
+ exports.WalletConnectV2Adapter = WalletConnectV2Adapter;
52
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gEAA+D;AAC/D,wEAAoE;AAGpE,uDAA4D;AAE5D,MAAa,sBAAsB;IAIjC,YAAoB,OAAgB,EAAE,MAA+B;QACnE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,OAAgB,EAAE,MAA+B;QACxE,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;IAEY,UAAU;;YACrB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;QAClD,CAAC;KAAA;IAEY,UAAU;;YACrB,IAAI;gBACF,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;oBACxB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;iBACpE;gBAED,MAAM,QAAQ,GAAG,MAAM,oCAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAClE,MAAM,MAAM,GAAG,IAAI,yCAAuB,CAAC,QAAQ,CAAC,CAAC;gBAErD,2CAA2C;gBAC3C,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC1B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;gBAC5C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,QAAQ,EAAE,sBAAM,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;gBAC3E,OAAO,MAAM,CAAC;aACf;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;gBAChD,MAAM,KAAK,CAAC;aACb;QACH,CAAC;KAAA;CACF;AArCD,wDAqCC"}
@@ -0,0 +1,17 @@
1
+ import type { BIP32Path, ETHSignedMessage, ETHSignedTx, ETHSignTx, ETHTxHash, ETHVerifyMessage, PathDescription } from "@shapeshiftoss/hdwallet-core";
2
+ import EthereumProvider from "@walletconnect/ethereum-provider";
3
+ import type { Bytes } from "ethers";
4
+ export declare function describeETHPath(path: BIP32Path): PathDescription;
5
+ export declare function ethSignTx(args: ETHSignTx & {
6
+ from: string;
7
+ }, provider: EthereumProvider): Promise<ETHSignedTx | null>;
8
+ export declare function ethSendTx(msg: ETHSignTx & {
9
+ from: string;
10
+ }, provider: EthereumProvider): Promise<ETHTxHash | null>;
11
+ export declare function ethSignMessage(args: {
12
+ data: string | Bytes;
13
+ fromAddress: string;
14
+ }, provider: EthereumProvider): Promise<ETHSignedMessage | null>;
15
+ export declare function ethGetAddress(provider: EthereumProvider): Promise<string | null>;
16
+ export declare function ethVerifyMessage(provider: EthereumProvider, args: ETHVerifyMessage): Promise<boolean>;
17
+ //# sourceMappingURL=ethereum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../src/ethereum.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAuBpC,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe,CA4BhE;AAED,wBAAsB,SAAS,CAC7B,IAAI,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAClC,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAG7B;AAED,wBAAsB,SAAS,CAC7B,GAAG,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACjC,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAQ3B;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EACnD,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAOlC;AAED,wBAAsB,aAAa,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAatF;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAE3G"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ethVerifyMessage = exports.ethGetAddress = exports.ethSignMessage = exports.ethSendTx = exports.ethSignTx = exports.describeETHPath = void 0;
13
+ const hdwallet_core_1 = require("@shapeshiftoss/hdwallet-core");
14
+ const utils_1 = require("ethers/lib/utils");
15
+ const getUnsignedTxFromMessage = (msg) => {
16
+ const utxBase = {
17
+ from: msg.from,
18
+ to: msg.to,
19
+ value: msg.value,
20
+ data: msg.data,
21
+ chainId: msg.chainId,
22
+ nonce: msg.nonce,
23
+ gasLimit: msg.gasLimit,
24
+ };
25
+ return msg.maxFeePerGas
26
+ ? Object.assign(Object.assign({}, utxBase), { maxFeePerGas: msg.maxFeePerGas, maxPriorityFeePerGas: msg.maxPriorityFeePerGas }) : Object.assign(Object.assign({}, utxBase), { gasPrice: msg.gasPrice });
27
+ };
28
+ function describeETHPath(path) {
29
+ const pathStr = hdwallet_core_1.addressNListToBIP32(path);
30
+ const unknown = {
31
+ verbose: pathStr,
32
+ coin: "Ethereum",
33
+ isKnown: false,
34
+ };
35
+ if (path.length !== 5)
36
+ return unknown;
37
+ if (path[0] !== 0x80000000 + 44)
38
+ return unknown;
39
+ if (path[1] !== 0x80000000 + hdwallet_core_1.slip44ByCoin("Ethereum"))
40
+ return unknown;
41
+ if ((path[2] & 0x80000000) >>> 0 !== 0x80000000)
42
+ return unknown;
43
+ if (path[3] !== 0)
44
+ return unknown;
45
+ if (path[4] !== 0)
46
+ return unknown;
47
+ const index = path[2] & 0x7fffffff;
48
+ return {
49
+ verbose: `Ethereum Account #${index}`,
50
+ accountIdx: index,
51
+ wholeAccount: true,
52
+ coin: "Ethereum",
53
+ isKnown: true,
54
+ };
55
+ }
56
+ exports.describeETHPath = describeETHPath;
57
+ function ethSignTx(args, provider) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const utx = getUnsignedTxFromMessage(args);
60
+ return yield provider.request({ method: "eth_signTransaction", params: [utx] });
61
+ });
62
+ }
63
+ exports.ethSignTx = ethSignTx;
64
+ function ethSendTx(msg, provider) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ const utx = getUnsignedTxFromMessage(msg);
67
+ const txHash = yield provider.request({ method: "eth_sendTransaction", params: [utx] });
68
+ return txHash
69
+ ? {
70
+ hash: txHash,
71
+ }
72
+ : null;
73
+ });
74
+ }
75
+ exports.ethSendTx = ethSendTx;
76
+ function ethSignMessage(args, provider) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const buffer = utils_1.isBytes(args.data) ? Buffer.from(utils_1.arrayify(args.data)) : Buffer.from(args.data);
79
+ return yield provider.request({
80
+ method: "eth_sign",
81
+ params: [args.fromAddress, buffer],
82
+ });
83
+ });
84
+ }
85
+ exports.ethSignMessage = ethSignMessage;
86
+ function ethGetAddress(provider) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ try {
89
+ if (!(provider && provider.connected)) {
90
+ throw new Error("No WalletConnectV2 provider available.");
91
+ }
92
+ const ethAccounts = yield provider.request({
93
+ method: "eth_accounts",
94
+ });
95
+ return ethAccounts[0];
96
+ }
97
+ catch (error) {
98
+ console.error(error);
99
+ return null;
100
+ }
101
+ });
102
+ }
103
+ exports.ethGetAddress = ethGetAddress;
104
+ function ethVerifyMessage(provider, args) {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ return yield provider.request({ method: "ethVerifyMessage", params: [args.message, args.signature] });
107
+ });
108
+ }
109
+ exports.ethVerifyMessage = ethVerifyMessage;
110
+ //# sourceMappingURL=ethereum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../src/ethereum.ts"],"names":[],"mappings":";;;;;;;;;;;;AASA,gEAAiF;AAGjF,4CAAqD;AAErD,MAAM,wBAAwB,GAAG,CAAC,GAAiC,EAAE,EAAE;IACrE,MAAM,OAAO,GAAG;QACd,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,QAAQ,EAAE,GAAG,CAAC,QAAQ;KACvB,CAAC;IAEF,OAAO,GAAG,CAAC,YAAY;QACrB,CAAC,iCACM,OAAO,KACV,YAAY,EAAE,GAAG,CAAC,YAAY,EAC9B,oBAAoB,EAAE,GAAG,CAAC,oBAAoB,IAElD,CAAC,iCAAM,OAAO,KAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,GAAE,CAAC;AAC7C,CAAC,CAAC;AAEF,SAAgB,eAAe,CAAC,IAAe;IAC7C,MAAM,OAAO,GAAG,mCAAmB,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAoB;QAC/B,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,KAAK;KACf,CAAC;IAEF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAEtC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,GAAG,EAAE;QAAE,OAAO,OAAO,CAAC;IAEhD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,GAAG,4BAAY,CAAC,UAAU,CAAC;QAAE,OAAO,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AAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9F,OAAO,MAAM,QAAQ,CAAC,OAAO,CAAC;YAC5B,MAAM,EAAE,UAAU;YAClB,MAAM,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;SACnC,CAAC,CAAC;IACL,CAAC;CAAA;AAVD,wCAUC;AAED,SAAsB,aAAa,CAAC,QAA0B;;QAC5D,IAAI;YACF,IAAI,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE;gBACrC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;aAC3D;YACD,MAAM,WAAW,GAAa,MAAM,QAAQ,CAAC,OAAO,CAAC;gBACnD,MAAM,EAAE,cAAc;aACvB,CAAC,CAAC;YACH,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;SACvB;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CAAA;AAbD,sCAaC;AAED,SAAsB,gBAAgB,CAAC,QAA0B,EAAE,IAAsB;;QACvF,OAAO,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IACxG,CAAC;CAAA;AAFD,4CAEC"}
@@ -0,0 +1,3 @@
1
+ export * from "./adapter";
2
+ export * from "./walletconnectV2";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./adapter"), exports);
14
+ __exportStar(require("./walletconnectV2"), exports);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,oDAAkC"}
@@ -0,0 +1,121 @@
1
+ import type { Coin, DescribePath, ETHAccountPath, ETHGetAccountPath, ETHSignedMessage, ETHSignedTx, ETHSignMessage, ETHSignTx, ETHTxHash, ETHVerifyMessage, ETHWallet, ETHWalletInfo, HDWallet, HDWalletInfo, PathDescription, Ping, Pong, PublicKey } from "@shapeshiftoss/hdwallet-core";
2
+ import EthereumProvider from "@walletconnect/ethereum-provider";
3
+ export declare function isWalletConnectV2(wallet: HDWallet): wallet is WalletConnectV2HDWallet;
4
+ /**
5
+ * WalletConnect Wallet Info
6
+ *
7
+ * Supported JSON-RPC API Methods:
8
+ * - personal_sign
9
+ * - eth_sign
10
+ * - eth_signTypedData
11
+ * - eth_sendTransaction
12
+ * - eth_signTransaction
13
+ * - eth_sendRawTransaction
14
+ * @see https://specs.walletconnect.com/2.0/blockchain-rpc/ethereum-rpc
15
+ */
16
+ export declare class WalletConnectV2WalletInfo implements HDWalletInfo, ETHWalletInfo {
17
+ readonly _supportsETHInfo = true;
18
+ readonly _supportsBTCInfo = false;
19
+ getVendor(): string;
20
+ hasOnDevicePinEntry(): boolean;
21
+ hasOnDevicePassphrase(): boolean;
22
+ hasOnDeviceDisplay(): boolean;
23
+ hasOnDeviceRecovery(): boolean;
24
+ hasNativeShapeShift(): boolean;
25
+ supportsBip44Accounts(): boolean;
26
+ supportsOfflineSigning(): boolean;
27
+ supportsBroadcast(): boolean;
28
+ describePath(msg: DescribePath): PathDescription;
29
+ ethNextAccountPath(): ETHAccountPath | undefined;
30
+ ethSupportsNetwork(chainId: number): Promise<boolean>;
31
+ ethSupportsSecureTransfer(): Promise<boolean>;
32
+ ethSupportsNativeShapeShift(): boolean;
33
+ ethSupportsEIP1559(): Promise<boolean>;
34
+ ethGetAccountPaths(msg: ETHGetAccountPath): Array<ETHAccountPath>;
35
+ }
36
+ export declare class WalletConnectV2HDWallet implements HDWallet, ETHWallet {
37
+ readonly _supportsETH = true;
38
+ readonly _supportsETHInfo = true;
39
+ readonly _supportsBTCInfo = false;
40
+ readonly _supportsBTC = false;
41
+ readonly _isWalletConnectV2 = true;
42
+ readonly _supportsEthSwitchChain = true;
43
+ readonly _supportsAvalanche = true;
44
+ readonly _supportsOptimism = true;
45
+ readonly _supportsBSC = true;
46
+ readonly _supportsPolygon = true;
47
+ readonly _supportsGnosis = true;
48
+ readonly _supportsArbitrum = true;
49
+ info: WalletConnectV2WalletInfo & HDWalletInfo;
50
+ provider: EthereumProvider;
51
+ connected: boolean;
52
+ chainId: number | undefined;
53
+ accounts: string[];
54
+ ethAddress: string | undefined;
55
+ constructor(provider: EthereumProvider);
56
+ getFeatures(): Promise<Record<string, any>>;
57
+ isLocked(): Promise<boolean>;
58
+ getVendor(): string;
59
+ getModel(): Promise<string>;
60
+ getLabel(): Promise<string>;
61
+ initialize(): Promise<void>;
62
+ hasOnDevicePinEntry(): boolean;
63
+ hasOnDevicePassphrase(): boolean;
64
+ hasOnDeviceDisplay(): boolean;
65
+ hasOnDeviceRecovery(): boolean;
66
+ hasNativeShapeShift(srcCoin: Coin, dstCoin: Coin): boolean;
67
+ supportsBip44Accounts(): boolean;
68
+ /**
69
+ * Supports Offline Signing
70
+ *
71
+ * Offline signing is supported when `signTransaction` does not broadcast
72
+ * the tx message. WalletConnect's core Connector implementation always
73
+ * makes a request, so offline signing is not supported.
74
+ */
75
+ supportsOfflineSigning(): boolean;
76
+ supportsBroadcast(): boolean;
77
+ clearSession(): Promise<void>;
78
+ ping(msg: Ping): Promise<Pong>;
79
+ sendPin(): Promise<void>;
80
+ sendPassphrase(): Promise<void>;
81
+ sendCharacter(): Promise<void>;
82
+ sendWord(): Promise<void>;
83
+ cancel(): Promise<void>;
84
+ wipe(): Promise<void>;
85
+ reset(): Promise<void>;
86
+ recover(): Promise<void>;
87
+ loadDevice(): Promise<void>;
88
+ describePath(msg: DescribePath): PathDescription;
89
+ getPublicKeys(): Promise<Array<PublicKey | null>>;
90
+ isInitialized(): Promise<boolean>;
91
+ disconnect(): Promise<void>;
92
+ ethSupportsNetwork(chainId?: number): Promise<boolean>;
93
+ ethSupportsSecureTransfer(): Promise<boolean>;
94
+ ethSupportsNativeShapeShift(): boolean;
95
+ ethSupportsEIP1559(): Promise<boolean>;
96
+ ethGetAccountPaths(msg: ETHGetAccountPath): Array<ETHAccountPath>;
97
+ ethNextAccountPath(): ETHAccountPath | undefined;
98
+ ethGetAddress(): Promise<string | null>;
99
+ /**
100
+ * Ethereum Signed Transaction
101
+ *
102
+ * @see https://docs.walletconnect.com/client-api#sign-transaction-eth_signtransaction
103
+ */
104
+ ethSignTx(msg: ETHSignTx): Promise<ETHSignedTx | null>;
105
+ /**
106
+ * Ethereum Send Transaction
107
+ *
108
+ * @see https://docs.walletconnect.com/client-api#send-transaction-eth_sendtransaction
109
+ */
110
+ ethSendTx(msg: ETHSignTx): Promise<ETHTxHash | null>;
111
+ /**
112
+ * Ethereum Sign Message
113
+ *
114
+ * @see https://docs.walletconnect.com/client-api#sign-message-eth_sign
115
+ */
116
+ ethSignMessage(msg: ETHSignMessage): Promise<ETHSignedMessage | null>;
117
+ ethVerifyMessage(msg: ETHVerifyMessage): Promise<boolean | null>;
118
+ getDeviceID(): Promise<string>;
119
+ getFirmwareVersion(): Promise<string>;
120
+ }
121
+ //# sourceMappingURL=walletconnectV2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletconnectV2.d.ts","sourceRoot":"","sources":["../src/walletconnectV2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,IAAI,EACJ,SAAS,EACV,MAAM,8BAA8B,CAAC;AAEtC,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAKhE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,IAAI,uBAAuB,CAErF;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,yBAA0B,YAAW,YAAY,EAAE,aAAa;IAC3E,QAAQ,CAAC,gBAAgB,QAAQ;IACjC,QAAQ,CAAC,gBAAgB,SAAS;IAC3B,SAAS,IAAI,MAAM;IAInB,mBAAmB,IAAI,OAAO;IAI9B,qBAAqB,IAAI,OAAO;IAIhC,kBAAkB,IAAI,OAAO;IAI7B,mBAAmB,IAAI,OAAO;IAI9B,mBAAmB,IAAI,OAAO;IAI9B,qBAAqB,IAAI,OAAO;IAIhC,sBAAsB,IAAI,OAAO;IAIjC,iBAAiB,IAAI,OAAO;IAI5B,YAAY,CAAC,GAAG,EAAE,YAAY,GAAG,eAAe;IAShD,kBAAkB,IAAI,cAAc,GAAG,SAAS;IAI1C,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIrD,yBAAyB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