@keplr-wallet/background 0.11.33 → 0.11.35-rc.1
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/build/keyring/crypto.js.map +1 -1
- package/build/keyring/handler.js +2 -2
- package/build/keyring/handler.js.map +1 -1
- package/build/keyring/keyring.d.ts +2 -2
- package/build/keyring/keyring.js +14 -5
- package/build/keyring/keyring.js.map +1 -1
- package/build/keyring/messages.d.ts +4 -2
- package/build/keyring/messages.js +4 -2
- package/build/keyring/messages.js.map +1 -1
- package/build/keyring/service.d.ts +2 -2
- package/build/keyring/service.js +4 -4
- package/build/keyring/service.js.map +1 -1
- package/build/ledger/ledger.d.ts +5 -4
- package/build/ledger/ledger.js +20 -9
- package/build/ledger/ledger.js.map +1 -1
- package/build/ledger/service.d.ts +4 -4
- package/build/ledger/service.js +9 -8
- package/build/ledger/service.js.map +1 -1
- package/package.json +12 -12
- package/src/keyring/crypto.ts +2 -0
- package/src/keyring/handler.ts +9 -2
- package/src/keyring/keyring.ts +29 -5
- package/src/keyring/messages.ts +4 -2
- package/src/keyring/service.ts +13 -4
- package/src/ledger/ledger.ts +26 -12
- package/src/ledger/service.ts +36 -20
package/build/ledger/ledger.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import Eth from "@ledgerhq/hw-app-eth";
|
|
|
3
3
|
import { EthSignType } from "@keplr-wallet/types";
|
|
4
4
|
import { BIP44HDPath } from "../keyring";
|
|
5
5
|
import { Buffer } from "buffer/";
|
|
6
|
+
import { CosmosApp } from "@keplr-wallet/ledger-cosmos";
|
|
6
7
|
export declare enum LedgerApp {
|
|
7
8
|
Cosmos = "cosmos",
|
|
8
9
|
Ethereum = "ethereum"
|
|
@@ -19,10 +20,10 @@ export declare class LedgerInitError extends Error {
|
|
|
19
20
|
constructor(errorOn: LedgerInitErrorOn, message?: string);
|
|
20
21
|
}
|
|
21
22
|
export declare class Ledger {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
constructor(cosmosApp
|
|
25
|
-
static init(transportIniter: TransportIniter, initArgs: any[] | undefined, app: LedgerApp): Promise<Ledger>;
|
|
23
|
+
readonly cosmosApp: CosmosApp | undefined;
|
|
24
|
+
readonly ethereumApp: Eth | undefined;
|
|
25
|
+
constructor(cosmosApp?: CosmosApp | undefined, ethereumApp?: Eth | undefined);
|
|
26
|
+
static init(transportIniter: TransportIniter, initArgs: any[] | undefined, app: LedgerApp, cosmosLikeApp: string): Promise<Ledger>;
|
|
26
27
|
getVersion(): Promise<{
|
|
27
28
|
deviceLocked: boolean;
|
|
28
29
|
major: number;
|
package/build/ledger/ledger.js
CHANGED
|
@@ -23,8 +23,7 @@ const keyring_1 = require("../keyring");
|
|
|
23
23
|
const transactions_1 = require("@ethersproject/transactions");
|
|
24
24
|
const buffer_1 = require("buffer/");
|
|
25
25
|
const utils_1 = require("../keyring/utils");
|
|
26
|
-
|
|
27
|
-
const CosmosApp = require("ledger-cosmos-js").default;
|
|
26
|
+
const ledger_cosmos_1 = require("@keplr-wallet/ledger-cosmos");
|
|
28
27
|
var LedgerApp;
|
|
29
28
|
(function (LedgerApp) {
|
|
30
29
|
LedgerApp["Cosmos"] = "cosmos";
|
|
@@ -54,11 +53,11 @@ class LedgerInitError extends Error {
|
|
|
54
53
|
}
|
|
55
54
|
exports.LedgerInitError = LedgerInitError;
|
|
56
55
|
class Ledger {
|
|
57
|
-
constructor(cosmosApp, ethereumApp = undefined) {
|
|
56
|
+
constructor(cosmosApp = undefined, ethereumApp = undefined) {
|
|
58
57
|
this.cosmosApp = cosmosApp;
|
|
59
58
|
this.ethereumApp = ethereumApp;
|
|
60
59
|
}
|
|
61
|
-
static init(transportIniter, initArgs = [], app) {
|
|
60
|
+
static init(transportIniter, initArgs = [], app, cosmosLikeApp) {
|
|
62
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
62
|
const transport = yield transportIniter(...initArgs);
|
|
64
63
|
try {
|
|
@@ -68,9 +67,9 @@ class Ledger {
|
|
|
68
67
|
// getAppConfiguration() works even if the ledger is on screen saver mode.
|
|
69
68
|
// To detect the screen saver mode, we should request the address before using.
|
|
70
69
|
yield ethereumApp.getAddress("m/44'/60'/0'/0/0");
|
|
71
|
-
return new Ledger(
|
|
70
|
+
return new Ledger(undefined, ethereumApp);
|
|
72
71
|
}
|
|
73
|
-
const cosmosApp = new CosmosApp(transport);
|
|
72
|
+
const cosmosApp = new ledger_cosmos_1.CosmosApp(cosmosLikeApp, transport);
|
|
74
73
|
const ledger = new Ledger(cosmosApp, undefined);
|
|
75
74
|
const versionResponse = yield ledger.getVersion();
|
|
76
75
|
// In this case, device is on screen saver.
|
|
@@ -79,6 +78,17 @@ class Ledger {
|
|
|
79
78
|
if (versionResponse.deviceLocked) {
|
|
80
79
|
throw new router_1.KeplrError("ledger", 102, "Device is on screen saver");
|
|
81
80
|
}
|
|
81
|
+
let appName = "";
|
|
82
|
+
try {
|
|
83
|
+
const appInfo = yield cosmosApp.getAppInfo();
|
|
84
|
+
appName = appInfo.app_name;
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
console.log(e);
|
|
88
|
+
}
|
|
89
|
+
if (appName && appName !== cosmosLikeApp) {
|
|
90
|
+
throw new router_1.KeplrError("ledger", 122, "Invalid cosmos app selected");
|
|
91
|
+
}
|
|
82
92
|
return ledger;
|
|
83
93
|
}
|
|
84
94
|
catch (e) {
|
|
@@ -93,6 +103,7 @@ class Ledger {
|
|
|
93
103
|
});
|
|
94
104
|
}
|
|
95
105
|
getVersion() {
|
|
106
|
+
var _a;
|
|
96
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
108
|
if (!this.cosmosApp) {
|
|
98
109
|
throw new router_1.KeplrError("ledger", 100, "Cosmos App not initialized");
|
|
@@ -102,7 +113,7 @@ class Ledger {
|
|
|
102
113
|
throw new Error(result.error_message);
|
|
103
114
|
}
|
|
104
115
|
return {
|
|
105
|
-
deviceLocked: result.device_locked,
|
|
116
|
+
deviceLocked: (_a = result.device_locked) !== null && _a !== void 0 ? _a : false,
|
|
106
117
|
major: result.major,
|
|
107
118
|
minor: result.minor,
|
|
108
119
|
patch: result.patch,
|
|
@@ -131,7 +142,7 @@ class Ledger {
|
|
|
131
142
|
if (!this.cosmosApp) {
|
|
132
143
|
throw new router_1.KeplrError("ledger", 100, "Cosmos App not initialized");
|
|
133
144
|
}
|
|
134
|
-
const result = yield this.cosmosApp.
|
|
145
|
+
const result = yield this.cosmosApp.getPublicKey(fields.account, fields.change, fields.addressIndex);
|
|
135
146
|
if (result.error_message !== "No errors") {
|
|
136
147
|
throw new Error(result.error_message);
|
|
137
148
|
}
|
|
@@ -144,7 +155,7 @@ class Ledger {
|
|
|
144
155
|
if (!this.cosmosApp) {
|
|
145
156
|
throw new router_1.KeplrError("ledger", 100, "Cosmos App not initialized");
|
|
146
157
|
}
|
|
147
|
-
const result = yield this.cosmosApp.sign(
|
|
158
|
+
const result = yield this.cosmosApp.sign(fields.account, fields.change, fields.addressIndex, message);
|
|
148
159
|
if (result.error_message !== "No errors") {
|
|
149
160
|
throw new Error(result.error_message);
|
|
150
161
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../src/ledger/ledger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,wFAA4D;AAC5D,wFAA4D;AAC5D,yCAA8D;AAC9D,iDAAkD;AAClD,sEAAuC;AACvC,+CAAkD;AAClD,wCAAiE;AACjE,8DAAwD;AACxD,oCAAiC;AACjC,4CAA2D;
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../src/ledger/ledger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,wFAA4D;AAC5D,wFAA4D;AAC5D,yCAA8D;AAC9D,iDAAkD;AAClD,sEAAuC;AACvC,+CAAkD;AAClD,wCAAiE;AACjE,8DAAwD;AACxD,oCAAiC;AACjC,4CAA2D;AAC3D,+DAAwD;AAExD,IAAY,SAGX;A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,CAAC,CAAC,EAAE,EAAE,EAAE;YAClB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC3B,2CAA2C;YAC3C,IAAI,CAAC,GAAG,CAAC,EAAE;gBACT,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aACvB;YACD,CAAC,EAAE,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC;IAED,gEAAgE;IAChE,MAAM,CAAC,mBAAmB,CAAC,SAI1B;QACC,sCAAsC;QACtC,MAAM,CAAC,GAAG,eAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAC1C,sCAAsC;QACtC,MAAM,CAAC,GAAG,eAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAE1C,mBAAmB;QACnB,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;SAClE;QAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;SAClE;QAED,OAAO,eAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,eAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAlQD,wBAkQC"}
|
|
@@ -12,11 +12,11 @@ export declare class LedgerService {
|
|
|
12
12
|
protected interactionService: InteractionService;
|
|
13
13
|
constructor(kvStore: KVStore, options: Partial<LedgerOptions>);
|
|
14
14
|
init(interactionService: InteractionService): void;
|
|
15
|
-
getPublicKey(env: Env, ledgerApp: LedgerApp, bip44HDPath: BIP44HDPath): Promise<Uint8Array>;
|
|
16
|
-
sign(env: Env, bip44HDPath: BIP44HDPath, expectedPubKey: Uint8Array, message: Uint8Array): Promise<Uint8Array>;
|
|
15
|
+
getPublicKey(env: Env, ledgerApp: LedgerApp, bip44HDPath: BIP44HDPath, cosmosLikeApp?: string): Promise<Uint8Array>;
|
|
16
|
+
sign(env: Env, bip44HDPath: BIP44HDPath, expectedPubKey: Uint8Array, message: Uint8Array, cosmosLikeApp?: string): Promise<Uint8Array>;
|
|
17
17
|
signEthereum(env: Env, type: EthSignType, bip44HDPath: BIP44HDPath, expectedPubKey: Uint8Array, message: Uint8Array): Promise<Uint8Array>;
|
|
18
|
-
useLedger<T>(env: Env, ledgerApp: LedgerApp, fn: (ledger: Ledger, retryCount: number) => Promise<T
|
|
19
|
-
initLedger(env: Env, ledgerApp: LedgerApp): Promise<{
|
|
18
|
+
useLedger<T>(env: Env, ledgerApp: LedgerApp, fn: (ledger: Ledger, retryCount: number) => Promise<T>, cosmosLikeApp?: string): Promise<T>;
|
|
19
|
+
initLedger(env: Env, ledgerApp: LedgerApp, cosmosLikeApp?: string): Promise<{
|
|
20
20
|
ledger: Ledger;
|
|
21
21
|
retryCount: number;
|
|
22
22
|
}>;
|
package/build/ledger/service.js
CHANGED
|
@@ -35,7 +35,7 @@ class LedgerService {
|
|
|
35
35
|
init(interactionService) {
|
|
36
36
|
this.interactionService = interactionService;
|
|
37
37
|
}
|
|
38
|
-
getPublicKey(env, ledgerApp, bip44HDPath) {
|
|
38
|
+
getPublicKey(env, ledgerApp, bip44HDPath, cosmosLikeApp = "Cosmos") {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
return yield this.useLedger(env, ledgerApp, (ledger, retryCount) => __awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
try {
|
|
@@ -51,10 +51,10 @@ class LedgerService {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
}));
|
|
54
|
+
}), cosmosLikeApp);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
sign(env, bip44HDPath, expectedPubKey, message) {
|
|
57
|
+
sign(env, bip44HDPath, expectedPubKey, message, cosmosLikeApp = "Cosmos") {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
59
|
const ledgerApp = ledger_1.LedgerApp.Cosmos;
|
|
60
60
|
return yield this.useLedger(env, ledgerApp, (ledger, retryCount) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -85,7 +85,7 @@ class LedgerService {
|
|
|
85
85
|
}
|
|
86
86
|
throw e;
|
|
87
87
|
}
|
|
88
|
-
}));
|
|
88
|
+
}), cosmosLikeApp);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
signEthereum(env, type, bip44HDPath, expectedPubKey, message) {
|
|
@@ -121,11 +121,11 @@ class LedgerService {
|
|
|
121
121
|
}));
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
-
useLedger(env, ledgerApp, fn) {
|
|
124
|
+
useLedger(env, ledgerApp, fn, cosmosLikeApp = "Cosmos") {
|
|
125
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
126
|
let ledger;
|
|
127
127
|
try {
|
|
128
|
-
ledger = yield this.initLedger(env, ledgerApp);
|
|
128
|
+
ledger = yield this.initLedger(env, ledgerApp, cosmosLikeApp);
|
|
129
129
|
return yield fn(ledger.ledger, ledger.retryCount);
|
|
130
130
|
}
|
|
131
131
|
finally {
|
|
@@ -135,7 +135,7 @@ class LedgerService {
|
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
initLedger(env, ledgerApp) {
|
|
138
|
+
initLedger(env, ledgerApp, cosmosLikeApp = "Cosmos") {
|
|
139
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
140
|
if (this.previousInitAborter) {
|
|
141
141
|
this.previousInitAborter(new Error("New ledger request occurred before the ledger was initialized"));
|
|
@@ -167,7 +167,7 @@ class LedgerService {
|
|
|
167
167
|
if (!transportIniter) {
|
|
168
168
|
throw new router_1.KeplrError("ledger", 112, `Unknown mode: ${mode}`);
|
|
169
169
|
}
|
|
170
|
-
const ledger = yield ledger_1.Ledger.init(transportIniter, initArgs, ledgerApp);
|
|
170
|
+
const ledger = yield ledger_1.Ledger.init(transportIniter, initArgs, ledgerApp, cosmosLikeApp);
|
|
171
171
|
this.previousInitAborter = undefined;
|
|
172
172
|
return {
|
|
173
173
|
ledger,
|
|
@@ -184,6 +184,7 @@ class LedgerService {
|
|
|
184
184
|
event: "init-failed",
|
|
185
185
|
ledgerApp,
|
|
186
186
|
mode,
|
|
187
|
+
cosmosLikeApp,
|
|
187
188
|
}, {
|
|
188
189
|
forceOpenWindow: true,
|
|
189
190
|
channel: "ledger",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/ledger/service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qCAKkB;AAElB,kDAA0B;AAE1B,iDAAiE;AAKjE,oCAAiC;AAGjC,MAAa,aAAa;IAOxB,YACqB,OAAgB,EACnC,OAA+B;;QADZ,YAAO,GAAP,OAAO,CAAS;QAGnC,IAAI,CAAC,OAAO,GAAG;YACb,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,QAAQ;YAC5C,gBAAgB,QAAE,OAAO,CAAC,gBAAgB,mCAAI,EAAE;SACjD,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE;YAC5C,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,2BAAkB,CAAC;SAC9D;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE;YAC5C,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,2BAAkB,CAAC;SAC9D;IACH,CAAC;IAED,IAAI,CAAC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
3
|
+
"version": "0.11.35-rc.1",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"author": "chainapsis",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,15 +31,16 @@
|
|
|
31
31
|
"@ethersproject/hash": "^5.7.0",
|
|
32
32
|
"@ethersproject/transactions": "^5.7.0",
|
|
33
33
|
"@ethersproject/wallet": "^5.7.0",
|
|
34
|
-
"@keplr-wallet/chain-validator": "0.11.
|
|
35
|
-
"@keplr-wallet/common": "0.11.
|
|
36
|
-
"@keplr-wallet/cosmos": "0.11.
|
|
37
|
-
"@keplr-wallet/crypto": "0.11.
|
|
38
|
-
"@keplr-wallet/
|
|
39
|
-
"@keplr-wallet/
|
|
40
|
-
"@keplr-wallet/
|
|
41
|
-
"@keplr-wallet/
|
|
42
|
-
"@keplr-wallet/
|
|
34
|
+
"@keplr-wallet/chain-validator": "0.11.35-rc.1",
|
|
35
|
+
"@keplr-wallet/common": "0.11.35-rc.1",
|
|
36
|
+
"@keplr-wallet/cosmos": "0.11.35-rc.1",
|
|
37
|
+
"@keplr-wallet/crypto": "0.11.35-rc.1",
|
|
38
|
+
"@keplr-wallet/ledger-cosmos": "0.11.35-rc.1",
|
|
39
|
+
"@keplr-wallet/popup": "0.11.35-rc.1",
|
|
40
|
+
"@keplr-wallet/proto-types": "0.11.35-rc.1",
|
|
41
|
+
"@keplr-wallet/router": "0.11.35-rc.1",
|
|
42
|
+
"@keplr-wallet/types": "0.11.35-rc.1",
|
|
43
|
+
"@keplr-wallet/unit": "0.11.35-rc.1",
|
|
43
44
|
"@keystonehq/base-eth-keyring": "^0.6.4",
|
|
44
45
|
"@keystonehq/bc-ur-registry": "^0.5.1",
|
|
45
46
|
"@keystonehq/bc-ur-registry-cosmos": "^0.1.1",
|
|
@@ -56,12 +57,11 @@
|
|
|
56
57
|
"buffer": "^6.0.3",
|
|
57
58
|
"delay": "^4.4.0",
|
|
58
59
|
"joi": "^17.5.0",
|
|
59
|
-
"ledger-cosmos-js": "^2.1.8",
|
|
60
60
|
"long": "^4.0.0",
|
|
61
61
|
"pbkdf2": "^3.1.2",
|
|
62
62
|
"secp256k1": "^4.0.2",
|
|
63
63
|
"secretjs": "0.17.7",
|
|
64
64
|
"utility-types": "^3.10.0"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "7e69e85cd076bd1a1b497b939b41ab80dd9f6dfd"
|
|
67
67
|
}
|
package/src/keyring/crypto.ts
CHANGED
|
@@ -25,6 +25,8 @@ export interface KeyStore {
|
|
|
25
25
|
coinTypeForChain: CoinTypeForChain;
|
|
26
26
|
bip44HDPath?: BIP44HDPath;
|
|
27
27
|
meta?: {
|
|
28
|
+
// "__ledger__cosmos_app_like__" is used for allowing other cosmos-like app such as "Terra"
|
|
29
|
+
// If "__ledger__cosmos_app_like__" is empty, handle it as "Cosmos" for backward compatibility.
|
|
28
30
|
[key: string]: string;
|
|
29
31
|
};
|
|
30
32
|
crypto: {
|
package/src/keyring/handler.ts
CHANGED
|
@@ -257,7 +257,8 @@ const handleCreateLedgerKeyMsg: (
|
|
|
257
257
|
msg.kdf,
|
|
258
258
|
msg.password,
|
|
259
259
|
msg.meta,
|
|
260
|
-
msg.bip44HDPath
|
|
260
|
+
msg.bip44HDPath,
|
|
261
|
+
msg.cosmosLikeApp
|
|
261
262
|
);
|
|
262
263
|
};
|
|
263
264
|
};
|
|
@@ -279,7 +280,13 @@ const handleAddLedgerKeyMsg: (
|
|
|
279
280
|
service: KeyRingService
|
|
280
281
|
) => InternalHandler<AddLedgerKeyMsg> = (service) => {
|
|
281
282
|
return async (env, msg) => {
|
|
282
|
-
return await service.addLedgerKey(
|
|
283
|
+
return await service.addLedgerKey(
|
|
284
|
+
env,
|
|
285
|
+
msg.kdf,
|
|
286
|
+
msg.meta,
|
|
287
|
+
msg.bip44HDPath,
|
|
288
|
+
msg.cosmosLikeApp
|
|
289
|
+
);
|
|
283
290
|
};
|
|
284
291
|
};
|
|
285
292
|
|
package/src/keyring/keyring.ts
CHANGED
|
@@ -383,7 +383,8 @@ export class KeyRing {
|
|
|
383
383
|
kdf: "scrypt" | "sha256" | "pbkdf2",
|
|
384
384
|
password: string,
|
|
385
385
|
meta: Record<string, string>,
|
|
386
|
-
bip44HDPath: BIP44HDPath
|
|
386
|
+
bip44HDPath: BIP44HDPath,
|
|
387
|
+
cosmosLikeApp?: string
|
|
387
388
|
): Promise<{
|
|
388
389
|
status: KeyRingStatus;
|
|
389
390
|
multiKeyStoreInfo: MultiKeyStoreInfoWithSelected;
|
|
@@ -396,11 +397,19 @@ export class KeyRing {
|
|
|
396
397
|
);
|
|
397
398
|
}
|
|
398
399
|
|
|
400
|
+
if (cosmosLikeApp) {
|
|
401
|
+
meta = {
|
|
402
|
+
...meta,
|
|
403
|
+
__ledger__cosmos_app_like__: cosmosLikeApp,
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
|
|
399
407
|
// Get public key first
|
|
400
408
|
const publicKey = await this.ledgerKeeper.getPublicKey(
|
|
401
409
|
env,
|
|
402
410
|
LedgerApp.Cosmos,
|
|
403
|
-
bip44HDPath
|
|
411
|
+
bip44HDPath,
|
|
412
|
+
cosmosLikeApp
|
|
404
413
|
);
|
|
405
414
|
|
|
406
415
|
const pubKeys = {
|
|
@@ -918,11 +927,17 @@ export class KeyRing {
|
|
|
918
927
|
throw new Error("Can't sign cosmos sign doc by ethereum app on ledger");
|
|
919
928
|
}
|
|
920
929
|
|
|
930
|
+
const cosmosLikeApp =
|
|
931
|
+
(this.keyStore.meta
|
|
932
|
+
? this.keyStore.meta["__ledger__cosmos_app_like__"]
|
|
933
|
+
: undefined) || "Cosmos";
|
|
934
|
+
|
|
921
935
|
return await this.ledgerKeeper.sign(
|
|
922
936
|
env,
|
|
923
937
|
KeyRing.getKeyStoreBIP44Path(this.keyStore),
|
|
924
938
|
await this.ensureLedgerPublicKey(LedgerApp.Cosmos),
|
|
925
|
-
message
|
|
939
|
+
message,
|
|
940
|
+
cosmosLikeApp
|
|
926
941
|
);
|
|
927
942
|
} else if (this.keyStore.type === "keystone") {
|
|
928
943
|
const coinType = this.computeKeyStoreCoinType(chainId, defaultCoinType);
|
|
@@ -1198,7 +1213,8 @@ export class KeyRing {
|
|
|
1198
1213
|
env: Env,
|
|
1199
1214
|
kdf: "scrypt" | "sha256" | "pbkdf2",
|
|
1200
1215
|
meta: Record<string, string>,
|
|
1201
|
-
bip44HDPath: BIP44HDPath
|
|
1216
|
+
bip44HDPath: BIP44HDPath,
|
|
1217
|
+
cosmosLikeApp?: string
|
|
1202
1218
|
): Promise<{
|
|
1203
1219
|
multiKeyStoreInfo: MultiKeyStoreInfoWithSelected;
|
|
1204
1220
|
}> {
|
|
@@ -1210,11 +1226,19 @@ export class KeyRing {
|
|
|
1210
1226
|
);
|
|
1211
1227
|
}
|
|
1212
1228
|
|
|
1229
|
+
if (cosmosLikeApp) {
|
|
1230
|
+
meta = {
|
|
1231
|
+
...meta,
|
|
1232
|
+
__ledger__cosmos_app_like__: cosmosLikeApp,
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1213
1236
|
// Get public key first
|
|
1214
1237
|
const publicKey = await this.ledgerKeeper.getPublicKey(
|
|
1215
1238
|
env,
|
|
1216
1239
|
LedgerApp.Cosmos,
|
|
1217
|
-
bip44HDPath
|
|
1240
|
+
bip44HDPath,
|
|
1241
|
+
cosmosLikeApp
|
|
1218
1242
|
);
|
|
1219
1243
|
|
|
1220
1244
|
const pubKeys = {
|
package/src/keyring/messages.ts
CHANGED
|
@@ -354,7 +354,8 @@ export class CreateLedgerKeyMsg extends Message<{
|
|
|
354
354
|
public readonly kdf: "scrypt" | "sha256" | "pbkdf2",
|
|
355
355
|
public readonly password: string,
|
|
356
356
|
public readonly meta: Record<string, string>,
|
|
357
|
-
public readonly bip44HDPath: BIP44HDPath
|
|
357
|
+
public readonly bip44HDPath: BIP44HDPath,
|
|
358
|
+
public readonly cosmosLikeApp?: string
|
|
358
359
|
) {
|
|
359
360
|
super();
|
|
360
361
|
}
|
|
@@ -472,7 +473,8 @@ export class AddLedgerKeyMsg extends Message<{
|
|
|
472
473
|
constructor(
|
|
473
474
|
public readonly kdf: "scrypt" | "sha256" | "pbkdf2",
|
|
474
475
|
public readonly meta: Record<string, string>,
|
|
475
|
-
public readonly bip44HDPath: BIP44HDPath
|
|
476
|
+
public readonly bip44HDPath: BIP44HDPath,
|
|
477
|
+
public readonly cosmosLikeApp?: string
|
|
476
478
|
) {
|
|
477
479
|
super();
|
|
478
480
|
}
|
package/src/keyring/service.ts
CHANGED
|
@@ -218,7 +218,8 @@ export class KeyRingService {
|
|
|
218
218
|
kdf: "scrypt" | "sha256" | "pbkdf2",
|
|
219
219
|
password: string,
|
|
220
220
|
meta: Record<string, string>,
|
|
221
|
-
bip44HDPath: BIP44HDPath
|
|
221
|
+
bip44HDPath: BIP44HDPath,
|
|
222
|
+
cosmosLikeApp?: string
|
|
222
223
|
): Promise<{
|
|
223
224
|
status: KeyRingStatus;
|
|
224
225
|
multiKeyStoreInfo: MultiKeyStoreInfoWithSelected;
|
|
@@ -228,7 +229,8 @@ export class KeyRingService {
|
|
|
228
229
|
kdf,
|
|
229
230
|
password,
|
|
230
231
|
meta,
|
|
231
|
-
bip44HDPath
|
|
232
|
+
bip44HDPath,
|
|
233
|
+
cosmosLikeApp
|
|
232
234
|
);
|
|
233
235
|
}
|
|
234
236
|
|
|
@@ -843,11 +845,18 @@ Salt: ${salt}`;
|
|
|
843
845
|
env: Env,
|
|
844
846
|
kdf: "scrypt" | "sha256" | "pbkdf2",
|
|
845
847
|
meta: Record<string, string>,
|
|
846
|
-
bip44HDPath: BIP44HDPath
|
|
848
|
+
bip44HDPath: BIP44HDPath,
|
|
849
|
+
cosmosLikeApp?: string
|
|
847
850
|
): Promise<{
|
|
848
851
|
multiKeyStoreInfo: MultiKeyStoreInfoWithSelected;
|
|
849
852
|
}> {
|
|
850
|
-
return this.keyRing.addLedgerKey(
|
|
853
|
+
return this.keyRing.addLedgerKey(
|
|
854
|
+
env,
|
|
855
|
+
kdf,
|
|
856
|
+
meta,
|
|
857
|
+
bip44HDPath,
|
|
858
|
+
cosmosLikeApp
|
|
859
|
+
);
|
|
851
860
|
}
|
|
852
861
|
|
|
853
862
|
public async changeKeyStoreFromMultiKeyStore(
|
package/src/ledger/ledger.ts
CHANGED
|
@@ -9,9 +9,7 @@ import { BIP44HDPath, EIP712MessageValidator } from "../keyring";
|
|
|
9
9
|
import { serialize } from "@ethersproject/transactions";
|
|
10
10
|
import { Buffer } from "buffer/";
|
|
11
11
|
import { domainHash, messageHash } from "../keyring/utils";
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
14
|
-
const CosmosApp: any = require("ledger-cosmos-js").default;
|
|
12
|
+
import { CosmosApp } from "@keplr-wallet/ledger-cosmos";
|
|
15
13
|
|
|
16
14
|
export enum LedgerApp {
|
|
17
15
|
Cosmos = "cosmos",
|
|
@@ -43,14 +41,15 @@ export class LedgerInitError extends Error {
|
|
|
43
41
|
|
|
44
42
|
export class Ledger {
|
|
45
43
|
constructor(
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
public readonly cosmosApp: CosmosApp | undefined = undefined,
|
|
45
|
+
public readonly ethereumApp: Eth | undefined = undefined
|
|
48
46
|
) {}
|
|
49
47
|
|
|
50
48
|
static async init(
|
|
51
49
|
transportIniter: TransportIniter,
|
|
52
50
|
initArgs: any[] = [],
|
|
53
|
-
app: LedgerApp
|
|
51
|
+
app: LedgerApp,
|
|
52
|
+
cosmosLikeApp: string
|
|
54
53
|
): Promise<Ledger> {
|
|
55
54
|
const transport = await transportIniter(...initArgs);
|
|
56
55
|
try {
|
|
@@ -62,10 +61,10 @@ export class Ledger {
|
|
|
62
61
|
// To detect the screen saver mode, we should request the address before using.
|
|
63
62
|
await ethereumApp.getAddress("m/44'/60'/0'/0/0");
|
|
64
63
|
|
|
65
|
-
return new Ledger(
|
|
64
|
+
return new Ledger(undefined, ethereumApp);
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
const cosmosApp = new CosmosApp(transport);
|
|
67
|
+
const cosmosApp = new CosmosApp(cosmosLikeApp, transport);
|
|
69
68
|
|
|
70
69
|
const ledger = new Ledger(cosmosApp, undefined);
|
|
71
70
|
const versionResponse = await ledger.getVersion();
|
|
@@ -77,6 +76,17 @@ export class Ledger {
|
|
|
77
76
|
throw new KeplrError("ledger", 102, "Device is on screen saver");
|
|
78
77
|
}
|
|
79
78
|
|
|
79
|
+
let appName = "";
|
|
80
|
+
try {
|
|
81
|
+
const appInfo = await cosmosApp.getAppInfo();
|
|
82
|
+
appName = appInfo.app_name;
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.log(e);
|
|
85
|
+
}
|
|
86
|
+
if (appName && appName !== cosmosLikeApp) {
|
|
87
|
+
throw new KeplrError("ledger", 122, "Invalid cosmos app selected");
|
|
88
|
+
}
|
|
89
|
+
|
|
80
90
|
return ledger;
|
|
81
91
|
} catch (e) {
|
|
82
92
|
if (transport) {
|
|
@@ -109,7 +119,7 @@ export class Ledger {
|
|
|
109
119
|
}
|
|
110
120
|
|
|
111
121
|
return {
|
|
112
|
-
deviceLocked: result.device_locked,
|
|
122
|
+
deviceLocked: result.device_locked ?? false,
|
|
113
123
|
major: result.major,
|
|
114
124
|
minor: result.minor,
|
|
115
125
|
patch: result.patch,
|
|
@@ -140,8 +150,10 @@ export class Ledger {
|
|
|
140
150
|
throw new KeplrError("ledger", 100, "Cosmos App not initialized");
|
|
141
151
|
}
|
|
142
152
|
|
|
143
|
-
const result = await this.cosmosApp.
|
|
144
|
-
|
|
153
|
+
const result = await this.cosmosApp.getPublicKey(
|
|
154
|
+
fields.account,
|
|
155
|
+
fields.change,
|
|
156
|
+
fields.addressIndex
|
|
145
157
|
);
|
|
146
158
|
if (result.error_message !== "No errors") {
|
|
147
159
|
throw new Error(result.error_message);
|
|
@@ -157,7 +169,9 @@ export class Ledger {
|
|
|
157
169
|
}
|
|
158
170
|
|
|
159
171
|
const result = await this.cosmosApp.sign(
|
|
160
|
-
|
|
172
|
+
fields.account,
|
|
173
|
+
fields.change,
|
|
174
|
+
fields.addressIndex,
|
|
161
175
|
message
|
|
162
176
|
);
|
|
163
177
|
if (result.error_message !== "No errors") {
|