@shapeshiftoss/hdwallet-keplr 1.55.4-alpha.1 → 1.55.5
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 +56 -19
- package/dist/adapter.js.map +1 -1
- package/dist/cosmos.js +66 -23
- package/dist/cosmos.js.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/keplr.js +184 -96
- package/dist/keplr.js.map +1 -1
- package/dist/osmosis.js +66 -23
- package/dist/osmosis.js.map +1 -1
- package/package.json +3 -3
- package/tsconfig.tsbuildinfo +1 -1
package/dist/adapter.js
CHANGED
|
@@ -1,29 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
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 __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.KeplrAdapter = void 0;
|
|
36
|
+
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
37
|
+
const keplr_1 = require("./keplr");
|
|
38
|
+
class KeplrAdapter {
|
|
7
39
|
constructor(keyring) {
|
|
8
40
|
this.keyring = keyring;
|
|
9
41
|
}
|
|
10
42
|
static useKeyring(keyring) {
|
|
11
43
|
return new KeplrAdapter(keyring);
|
|
12
44
|
}
|
|
13
|
-
|
|
14
|
-
return
|
|
45
|
+
initialize() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
return Object.keys(this.keyring.wallets).length;
|
|
48
|
+
});
|
|
15
49
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
50
|
+
pairDevice() {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
if (!window.getOfflineSigner || !window.keplr) {
|
|
53
|
+
console.error("Please install Keplr Extension!");
|
|
54
|
+
}
|
|
55
|
+
const wallet = new keplr_1.KeplrHDWallet();
|
|
56
|
+
yield wallet.initialize();
|
|
57
|
+
const deviceID = yield wallet.getDeviceID();
|
|
58
|
+
this.keyring.add(wallet, deviceID);
|
|
59
|
+
this.currentDeviceID = deviceID;
|
|
60
|
+
this.keyring.emit(["Keplr", deviceID, core.Events.CONNECT], deviceID);
|
|
61
|
+
return wallet;
|
|
62
|
+
});
|
|
27
63
|
}
|
|
28
64
|
}
|
|
65
|
+
exports.KeplrAdapter = KeplrAdapter;
|
|
29
66
|
//# 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":"AAAA,
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAqD;AAErD,mCAAwC;AAExC,MAAa,YAAY;IAMvB,YAAoB,OAAqB;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,OAAqB;QAC5C,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;IACnC,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,CAAC,MAAM,CAAC,gBAAgB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBAC9C,OAAO,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;YACnD,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,qBAAa,EAAE,CAAC;YACnC,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,eAAe,GAAG,QAAQ,CAAC;YAChC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;YAEtE,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF;AA/BD,oCA+BC"}
|
package/dist/cosmos.js
CHANGED
|
@@ -1,8 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
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 __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.cosmosDescribePath = cosmosDescribePath;
|
|
36
|
+
exports.cosmosGetAccountPaths = cosmosGetAccountPaths;
|
|
37
|
+
exports.cosmosGetAddress = cosmosGetAddress;
|
|
38
|
+
exports.cosmosSignTx = cosmosSignTx;
|
|
39
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
40
|
+
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
41
|
+
const hdwallet_core_1 = require("@shapeshiftoss/hdwallet-core");
|
|
42
|
+
const proto_tx_builder_1 = require("@shapeshiftoss/proto-tx-builder");
|
|
43
|
+
function cosmosDescribePath(path) {
|
|
6
44
|
const pathStr = core.addressNListToBIP32(path);
|
|
7
45
|
const unknown = {
|
|
8
46
|
verbose: pathStr,
|
|
@@ -15,7 +53,7 @@ export function cosmosDescribePath(path) {
|
|
|
15
53
|
if (path[0] != 0x80000000 + 44) {
|
|
16
54
|
return unknown;
|
|
17
55
|
}
|
|
18
|
-
if (path[1] != 0x80000000 + slip44ByCoin("Atom")) {
|
|
56
|
+
if (path[1] != 0x80000000 + (0, hdwallet_core_1.slip44ByCoin)("Atom")) {
|
|
19
57
|
return unknown;
|
|
20
58
|
}
|
|
21
59
|
if ((path[2] & 0x80000000) >>> 0 !== 0x80000000) {
|
|
@@ -34,29 +72,34 @@ export function cosmosDescribePath(path) {
|
|
|
34
72
|
isPrefork: false,
|
|
35
73
|
};
|
|
36
74
|
}
|
|
37
|
-
|
|
75
|
+
function cosmosGetAccountPaths(msg) {
|
|
38
76
|
return [
|
|
39
77
|
{
|
|
40
|
-
addressNList: [0x80000000 + 44, 0x80000000 + slip44ByCoin("Atom"), 0x80000000 + msg.accountIdx, 0, 0],
|
|
78
|
+
addressNList: [0x80000000 + 44, 0x80000000 + (0, hdwallet_core_1.slip44ByCoin)("Atom"), 0x80000000 + msg.accountIdx, 0, 0],
|
|
41
79
|
},
|
|
42
80
|
];
|
|
43
81
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
82
|
+
function cosmosGetAddress(provider) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
const offlineSigner = provider.getOfflineSigner(caip_1.CHAIN_REFERENCE.CosmosHubMainnet);
|
|
86
|
+
const cosmosAddress = (_b = (_a = (yield (offlineSigner === null || offlineSigner === void 0 ? void 0 : offlineSigner.getAccounts()))) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.address;
|
|
87
|
+
return cosmosAddress;
|
|
88
|
+
});
|
|
48
89
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
90
|
+
function cosmosSignTx(provider, msg) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const offlineSigner = provider.getOfflineSigner(caip_1.CHAIN_REFERENCE.CosmosHubMainnet);
|
|
93
|
+
const address = yield cosmosGetAddress(provider);
|
|
94
|
+
if (!address)
|
|
95
|
+
throw new Error("failed to get address");
|
|
96
|
+
const signerData = {
|
|
97
|
+
sequence: Number(msg.sequence),
|
|
98
|
+
accountNumber: Number(msg.account_number),
|
|
99
|
+
chainId: msg.chain_id,
|
|
100
|
+
};
|
|
101
|
+
return yield (0, proto_tx_builder_1.sign)(address, msg.tx, offlineSigner, signerData);
|
|
102
|
+
});
|
|
60
103
|
}
|
|
61
104
|
/**
|
|
62
105
|
* @todo: Add support for sign/verify message see documentation at:
|
package/dist/cosmos.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmos.js","sourceRoot":"","sources":["../src/cosmos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cosmos.js","sourceRoot":"","sources":["../src/cosmos.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
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("./keplr"), exports);
|
|
3
19
|
//# 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":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,0CAAwB"}
|
package/dist/keplr.js
CHANGED
|
@@ -1,23 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
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 __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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.KeplrHDWallet = exports.KeplrHDWalletInfo = void 0;
|
|
39
|
+
exports.isKeplr = isKeplr;
|
|
40
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
41
|
+
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
42
|
+
const isObject_1 = __importDefault(require("lodash/isObject"));
|
|
43
|
+
const cosmos = __importStar(require("./cosmos"));
|
|
44
|
+
const osmosis = __importStar(require("./osmosis"));
|
|
6
45
|
class KeplrTransport extends core.Transport {
|
|
7
|
-
|
|
8
|
-
return
|
|
46
|
+
getDeviceID() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return "keplr:0";
|
|
49
|
+
});
|
|
9
50
|
}
|
|
10
51
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
52
|
call(...args) {
|
|
12
53
|
return Promise.resolve();
|
|
13
54
|
}
|
|
14
55
|
}
|
|
15
|
-
|
|
16
|
-
return
|
|
56
|
+
function isKeplr(wallet) {
|
|
57
|
+
return (0, isObject_1.default)(wallet) && wallet._isKeplr;
|
|
17
58
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
59
|
+
class KeplrHDWalletInfo {
|
|
60
|
+
constructor() {
|
|
61
|
+
this._supportsCosmosInfo = true;
|
|
62
|
+
this._supportsOsmosisInfo = true;
|
|
63
|
+
}
|
|
21
64
|
getVendor() {
|
|
22
65
|
return "Keplr";
|
|
23
66
|
}
|
|
@@ -56,11 +99,15 @@ export class KeplrHDWalletInfo {
|
|
|
56
99
|
throw new Error("Unsupported path");
|
|
57
100
|
}
|
|
58
101
|
}
|
|
59
|
-
|
|
60
|
-
return chainId
|
|
102
|
+
cosmosSupportsNetwork() {
|
|
103
|
+
return __awaiter(this, arguments, void 0, function* (chainId = 118) {
|
|
104
|
+
return chainId === 118;
|
|
105
|
+
});
|
|
61
106
|
}
|
|
62
|
-
|
|
63
|
-
return
|
|
107
|
+
cosmosSupportsSecureTransfer() {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
return false;
|
|
110
|
+
});
|
|
64
111
|
}
|
|
65
112
|
cosmosSupportsNativeShapeShift() {
|
|
66
113
|
return false;
|
|
@@ -73,11 +120,15 @@ export class KeplrHDWalletInfo {
|
|
|
73
120
|
// TODO: What do we do here?
|
|
74
121
|
return undefined;
|
|
75
122
|
}
|
|
76
|
-
|
|
77
|
-
return chainId
|
|
123
|
+
osmosisSupportsNetwork() {
|
|
124
|
+
return __awaiter(this, arguments, void 0, function* (chainId = 1) {
|
|
125
|
+
return chainId === 1;
|
|
126
|
+
});
|
|
78
127
|
}
|
|
79
|
-
|
|
80
|
-
return
|
|
128
|
+
osmosisSupportsSecureTransfer() {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
return false;
|
|
131
|
+
});
|
|
81
132
|
}
|
|
82
133
|
osmosisSupportsNativeShapeShift() {
|
|
83
134
|
return false;
|
|
@@ -90,25 +141,29 @@ export class KeplrHDWalletInfo {
|
|
|
90
141
|
return undefined;
|
|
91
142
|
}
|
|
92
143
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
_supportsCosmos = true;
|
|
96
|
-
_supportsCosmosInfo = true;
|
|
97
|
-
_supportsOsmosis = true;
|
|
98
|
-
_supportsOsmosisInfo = true;
|
|
99
|
-
transport = new KeplrTransport(new core.Keyring());
|
|
100
|
-
info;
|
|
101
|
-
initialized = false;
|
|
102
|
-
provider = {};
|
|
103
|
-
supportedNetworks = [CHAIN_REFERENCE.CosmosHubMainnet];
|
|
144
|
+
exports.KeplrHDWalletInfo = KeplrHDWalletInfo;
|
|
145
|
+
class KeplrHDWallet {
|
|
104
146
|
constructor() {
|
|
147
|
+
this._isKeplr = true;
|
|
148
|
+
this._supportsCosmos = true;
|
|
149
|
+
this._supportsCosmosInfo = true;
|
|
150
|
+
this._supportsOsmosis = true;
|
|
151
|
+
this._supportsOsmosisInfo = true;
|
|
152
|
+
this.transport = new KeplrTransport(new core.Keyring());
|
|
153
|
+
this.initialized = false;
|
|
154
|
+
this.provider = {};
|
|
155
|
+
this.supportedNetworks = [caip_1.CHAIN_REFERENCE.CosmosHubMainnet];
|
|
105
156
|
this.info = new KeplrHDWalletInfo();
|
|
106
157
|
}
|
|
107
|
-
|
|
108
|
-
return {
|
|
158
|
+
getFeatures() {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
return {};
|
|
161
|
+
});
|
|
109
162
|
}
|
|
110
|
-
|
|
111
|
-
return this
|
|
163
|
+
isLocked() {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
return this.provider.isLocked();
|
|
166
|
+
});
|
|
112
167
|
}
|
|
113
168
|
getVendor() {
|
|
114
169
|
return "Keplr";
|
|
@@ -119,24 +174,26 @@ export class KeplrHDWallet {
|
|
|
119
174
|
getLabel() {
|
|
120
175
|
return Promise.resolve("Keplr");
|
|
121
176
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
177
|
+
initialize() {
|
|
178
|
+
return __awaiter(this, arguments, void 0, function* (networks = []) {
|
|
179
|
+
try {
|
|
180
|
+
if (!window.keplr) {
|
|
181
|
+
throw new Error("Keplr extension not installed.");
|
|
182
|
+
}
|
|
183
|
+
this.provider = window.keplr;
|
|
184
|
+
/** Initialize Keplr Wallet with all supported chains by default
|
|
185
|
+
* or the subset of supported chains passed in the call to initialize() */
|
|
186
|
+
yield this.provider.enable(networks.length ? networks : this.supportedNetworks);
|
|
187
|
+
return Promise.resolve();
|
|
126
188
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
* @todo Use logger instead of console.error()
|
|
136
|
-
*/
|
|
137
|
-
console.error(error);
|
|
138
|
-
throw new Error("Error initializing Keplr");
|
|
139
|
-
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
/**
|
|
191
|
+
* @todo Use logger instead of console.error()
|
|
192
|
+
*/
|
|
193
|
+
console.error(error);
|
|
194
|
+
throw new Error("Error initializing Keplr");
|
|
195
|
+
}
|
|
196
|
+
});
|
|
140
197
|
}
|
|
141
198
|
hasOnDevicePinEntry() {
|
|
142
199
|
return this.info.hasOnDevicePinEntry();
|
|
@@ -162,8 +219,10 @@ export class KeplrHDWallet {
|
|
|
162
219
|
supportsBroadcast() {
|
|
163
220
|
return true;
|
|
164
221
|
}
|
|
165
|
-
|
|
166
|
-
|
|
222
|
+
clearSession() {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
+
// TODO: Can we lock Keplr from here?
|
|
225
|
+
});
|
|
167
226
|
}
|
|
168
227
|
ping(msg) {
|
|
169
228
|
// no ping function for Keplr, so just returning Core.Pong
|
|
@@ -216,27 +275,35 @@ export class KeplrHDWallet {
|
|
|
216
275
|
return this.info.describePath(msg);
|
|
217
276
|
}
|
|
218
277
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
278
|
+
getPublicKeys(msg_1) {
|
|
279
|
+
return __awaiter(this, arguments, void 0, function* (msg, chainId = caip_1.CHAIN_REFERENCE.CosmosHubMainnet) {
|
|
280
|
+
if (!this.supportedNetworks.includes(chainId)) {
|
|
281
|
+
throw new Error(`Unsupported chainId: ${chainId}`);
|
|
282
|
+
}
|
|
283
|
+
const keys = [];
|
|
284
|
+
yield this.provider.enable(chainId);
|
|
285
|
+
const offlineSigner = this.provider.getOfflineSigner(chainId);
|
|
286
|
+
keys.push({ xpub: Buffer.from((yield offlineSigner.getAccounts())[0].pubkey).toString() });
|
|
287
|
+
return keys;
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
isInitialized() {
|
|
291
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
+
return this.initialized;
|
|
293
|
+
});
|
|
231
294
|
}
|
|
232
295
|
disconnect() {
|
|
233
296
|
return Promise.resolve();
|
|
234
297
|
}
|
|
235
|
-
|
|
236
|
-
return chainId
|
|
298
|
+
cosmosSupportsNetwork() {
|
|
299
|
+
return __awaiter(this, arguments, void 0, function* (chainId = 118) {
|
|
300
|
+
return chainId === 118;
|
|
301
|
+
});
|
|
237
302
|
}
|
|
238
|
-
|
|
239
|
-
return
|
|
303
|
+
cosmosSupportsSecureTransfer() {
|
|
304
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
305
|
+
return false;
|
|
306
|
+
});
|
|
240
307
|
}
|
|
241
308
|
cosmosSupportsNativeShapeShift() {
|
|
242
309
|
return false;
|
|
@@ -248,22 +315,32 @@ export class KeplrHDWallet {
|
|
|
248
315
|
return this.info.cosmosNextAccountPath(msg);
|
|
249
316
|
}
|
|
250
317
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
251
|
-
|
|
252
|
-
return (
|
|
318
|
+
cosmosGetAddress() {
|
|
319
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
320
|
+
return (yield cosmos.cosmosGetAddress(this.provider)) || null;
|
|
321
|
+
});
|
|
253
322
|
}
|
|
254
|
-
|
|
255
|
-
return
|
|
323
|
+
cosmosSignTx(msg) {
|
|
324
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
325
|
+
return cosmos.cosmosSignTx(this.provider, msg);
|
|
326
|
+
});
|
|
256
327
|
}
|
|
257
328
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
329
|
+
cosmosSendTx(msg) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
/** Broadcast from Keplr is currently unimplemented */
|
|
332
|
+
return null;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
osmosisSupportsNetwork() {
|
|
336
|
+
return __awaiter(this, arguments, void 0, function* (chainId = 118) {
|
|
337
|
+
return chainId === 118;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
osmosisSupportsSecureTransfer() {
|
|
341
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
342
|
+
return false;
|
|
343
|
+
});
|
|
267
344
|
}
|
|
268
345
|
osmosisSupportsNativeShapeShift() {
|
|
269
346
|
return false;
|
|
@@ -275,22 +352,33 @@ export class KeplrHDWallet {
|
|
|
275
352
|
return this.info.osmosisNextAccountPath(msg);
|
|
276
353
|
}
|
|
277
354
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
278
|
-
|
|
279
|
-
return (
|
|
355
|
+
osmosisGetAddress() {
|
|
356
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
357
|
+
return (yield osmosis.osmosisGetAddress(this.provider)) || null;
|
|
358
|
+
});
|
|
280
359
|
}
|
|
281
|
-
|
|
282
|
-
return
|
|
360
|
+
osmosisSignTx(msg) {
|
|
361
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
362
|
+
return osmosis.osmosisSignTx(this.provider, msg);
|
|
363
|
+
});
|
|
283
364
|
}
|
|
284
365
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
366
|
+
osmosisSendTx(msg) {
|
|
367
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
368
|
+
/** Broadcast from Keplr is currently unimplemented */
|
|
369
|
+
return null;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
getDeviceID() {
|
|
373
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
374
|
+
return "keplr:" + (yield this.cosmosGetAddress());
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
getFirmwareVersion() {
|
|
378
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
379
|
+
return "keplr";
|
|
380
|
+
});
|
|
294
381
|
}
|
|
295
382
|
}
|
|
383
|
+
exports.KeplrHDWallet = KeplrHDWallet;
|
|
296
384
|
//# sourceMappingURL=keplr.js.map
|