@shapeshiftoss/hdwallet-walletconnect 1.55.2-alpha.0 → 1.55.3
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/dist/adapter.js +25 -43
- package/dist/adapter.js.map +1 -1
- package/dist/ethereum.js +29 -77
- package/dist/ethereum.js.map +1 -1
- package/dist/index.js +2 -18
- package/dist/index.js.map +1 -1
- package/dist/walletconnect.js +129 -234
- package/dist/walletconnect.js.map +1 -1
- package/package.json +3 -3
- package/tsconfig.tsbuildinfo +1 -1
package/dist/adapter.js
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.WalletConnectAdapter = void 0;
|
|
16
|
-
const hdwallet_core_1 = require("@shapeshiftoss/hdwallet-core");
|
|
17
|
-
const web3_provider_1 = __importDefault(require("@walletconnect/web3-provider"));
|
|
18
|
-
const walletconnect_1 = require("./walletconnect");
|
|
19
|
-
class WalletConnectAdapter {
|
|
1
|
+
import { Events } from "@shapeshiftoss/hdwallet-core";
|
|
2
|
+
import WalletConnectProvider from "@walletconnect/web3-provider";
|
|
3
|
+
import { WalletConnectHDWallet } from "./walletconnect";
|
|
4
|
+
export class WalletConnectAdapter {
|
|
5
|
+
keyring;
|
|
6
|
+
providerConfig;
|
|
20
7
|
constructor(keyring, config) {
|
|
21
8
|
this.keyring = keyring;
|
|
22
9
|
this.providerConfig = config;
|
|
@@ -24,32 +11,27 @@ class WalletConnectAdapter {
|
|
|
24
11
|
static useKeyring(keyring, config) {
|
|
25
12
|
return new WalletConnectAdapter(keyring, config);
|
|
26
13
|
}
|
|
27
|
-
initialize() {
|
|
28
|
-
return
|
|
29
|
-
return Object.keys(this.keyring.wallets).length;
|
|
30
|
-
});
|
|
14
|
+
async initialize() {
|
|
15
|
+
return Object.keys(this.keyring.wallets).length;
|
|
31
16
|
}
|
|
32
|
-
pairDevice() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
throw new Error("WalletConnect provider configuration not set.");
|
|
37
|
-
}
|
|
38
|
-
const provider = new web3_provider_1.default(this.providerConfig);
|
|
39
|
-
const wallet = new walletconnect_1.WalletConnectHDWallet(provider);
|
|
40
|
-
// Enable session (triggers QR Code modal)
|
|
41
|
-
yield wallet.initialize();
|
|
42
|
-
const deviceID = yield wallet.getDeviceID();
|
|
43
|
-
this.keyring.add(wallet, deviceID);
|
|
44
|
-
this.keyring.emit(["WalletConnect", deviceID, hdwallet_core_1.Events.CONNECT], deviceID);
|
|
45
|
-
return wallet;
|
|
17
|
+
async pairDevice() {
|
|
18
|
+
try {
|
|
19
|
+
if (!this.providerConfig) {
|
|
20
|
+
throw new Error("WalletConnect provider configuration not set.");
|
|
46
21
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
22
|
+
const provider = new WalletConnectProvider(this.providerConfig);
|
|
23
|
+
const wallet = new WalletConnectHDWallet(provider);
|
|
24
|
+
// Enable session (triggers QR Code modal)
|
|
25
|
+
await wallet.initialize();
|
|
26
|
+
const deviceID = await wallet.getDeviceID();
|
|
27
|
+
this.keyring.add(wallet, deviceID);
|
|
28
|
+
this.keyring.emit(["WalletConnect", deviceID, Events.CONNECT], deviceID);
|
|
29
|
+
return wallet;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error("Could not pair WalletConnect");
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
52
35
|
}
|
|
53
36
|
}
|
|
54
|
-
exports.WalletConnectAdapter = WalletConnectAdapter;
|
|
55
37
|
//# sourceMappingURL=adapter.js.map
|
package/dist/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,8BAA8B,CAAC;AAC/D,OAAO,qBAAqB,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAQxD,MAAM,OAAO,oBAAoB;IAC/B,OAAO,CAAU;IACT,cAAc,CAA8B;IAEpD,YAAoB,OAAgB,EAAE,MAAmC;QACvE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,OAAgB,EAAE,MAAmC;QAC5E,OAAO,IAAI,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;YACnE,CAAC;YACD,MAAM,QAAQ,GAAG,IAAI,qBAAqB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAChE,MAAM,MAAM,GAAG,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAAC;YAEnD,2CAA2C;YAC3C,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;YAC5C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;YACzE,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAC9C,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
package/dist/ethereum.js
CHANGED
|
@@ -1,41 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.ethGetAddress = exports.ethSignMessage = exports.ethSendTx = exports.ethSignTx = exports.describeETHPath = void 0;
|
|
36
|
-
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
37
|
-
const utils_1 = require("ethers/lib/utils");
|
|
38
|
-
function describeETHPath(path) {
|
|
1
|
+
import * as core from "@shapeshiftoss/hdwallet-core";
|
|
2
|
+
import { isHexString } from "ethers/lib/utils";
|
|
3
|
+
export function describeETHPath(path) {
|
|
39
4
|
const pathStr = core.addressNListToBIP32(path);
|
|
40
5
|
const unknown = {
|
|
41
6
|
verbose: pathStr,
|
|
@@ -63,48 +28,35 @@ function describeETHPath(path) {
|
|
|
63
28
|
isKnown: true,
|
|
64
29
|
};
|
|
65
30
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
return yield provider.wc.signTransaction(args);
|
|
70
|
-
});
|
|
31
|
+
export async function ethSignTx(args, provider) {
|
|
32
|
+
return await provider.wc.signTransaction(args);
|
|
71
33
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
: null;
|
|
81
|
-
});
|
|
34
|
+
export async function ethSendTx(args, provider) {
|
|
35
|
+
const txHash = await provider.wc.sendTransaction(args);
|
|
36
|
+
return txHash
|
|
37
|
+
? {
|
|
38
|
+
hash: txHash,
|
|
39
|
+
}
|
|
40
|
+
: null;
|
|
82
41
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
throw new Error("data is not an hex string");
|
|
88
|
-
return yield provider.wc.signMessage([args.data, args.fromAddress]);
|
|
89
|
-
});
|
|
42
|
+
export async function ethSignMessage(args, provider) {
|
|
43
|
+
if (!isHexString(args.data))
|
|
44
|
+
throw new Error("data is not an hex string");
|
|
45
|
+
return await provider.wc.signMessage([args.data, args.fromAddress]);
|
|
90
46
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (!(provider && provider.request && provider.connected)) {
|
|
96
|
-
throw new Error("No WalletConnect provider available.");
|
|
97
|
-
}
|
|
98
|
-
const ethAccounts = yield provider.request({
|
|
99
|
-
method: "eth_accounts",
|
|
100
|
-
});
|
|
101
|
-
return ethAccounts[0];
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
console.error(error);
|
|
105
|
-
return null;
|
|
47
|
+
export async function ethGetAddress(provider) {
|
|
48
|
+
try {
|
|
49
|
+
if (!(provider && provider.request && provider.connected)) {
|
|
50
|
+
throw new Error("No WalletConnect provider available.");
|
|
106
51
|
}
|
|
107
|
-
|
|
52
|
+
const ethAccounts = await provider.request({
|
|
53
|
+
method: "eth_accounts",
|
|
54
|
+
});
|
|
55
|
+
return ethAccounts[0];
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error(error);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
108
61
|
}
|
|
109
|
-
exports.ethGetAddress = ethGetAddress;
|
|
110
62
|
//# sourceMappingURL=ethereum.js.map
|
package/dist/ethereum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../src/ethereum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../src/ethereum.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,UAAU,eAAe,CAAC,IAAoB;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAyB;QACpC,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,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QAAE,OAAO,OAAO,CAAC;IAE3E,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,UAAU;QAAE,OAAO,OAAO,CAAC;IAEhE,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAElC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAElC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;IACnC,OAAO;QACL,OAAO,EAAE,qBAAqB,KAAK,EAAE;QACrC,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,IAAI;QAClB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAA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,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./adapter"), exports);
|
|
18
|
-
__exportStar(require("./walletconnect"), exports);
|
|
1
|
+
export * from "./adapter";
|
|
2
|
+
export * from "./walletconnect";
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC"}
|