@injectivelabs/wallet-trezor 1.16.25-alpha.0 → 1.16.25-alpha.2
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/cjs/index.cjs +31 -21
- package/dist/esm/index.js +31 -21
- package/package.json +8 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -15,13 +15,11 @@ const TrezorDerivationPathType = {
|
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/strategy/lib.ts
|
|
18
|
-
let TrezorConnect;
|
|
19
18
|
async function loadTrezorConnect() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return TrezorConnect;
|
|
19
|
+
console.log("🪵Loading TrezorConnect...");
|
|
20
|
+
const module$1 = await import("@trezor/connect-web");
|
|
21
|
+
console.log("🪵Module:", module$1);
|
|
22
|
+
return module$1.default;
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
//#endregion
|
|
@@ -128,7 +126,7 @@ var AccountManager = class {
|
|
|
128
126
|
return this.wallets.slice(start, end);
|
|
129
127
|
}
|
|
130
128
|
async getWalletsBasedOnIndex({ start, end, baseDerivationPath, derivationPathType }) {
|
|
131
|
-
const TrezorConnect
|
|
129
|
+
const TrezorConnect = await loadTrezorConnect();
|
|
132
130
|
const pathsToFetch = [];
|
|
133
131
|
for (let index = start; index < end; index += 1) {
|
|
134
132
|
const path = this.getTrezorDerivationPathBasedOnType({
|
|
@@ -141,7 +139,7 @@ var AccountManager = class {
|
|
|
141
139
|
showOnTrezor: false
|
|
142
140
|
});
|
|
143
141
|
}
|
|
144
|
-
const result = await TrezorConnect
|
|
142
|
+
const result = await TrezorConnect.ethereumGetPublicKey({ bundle: pathsToFetch });
|
|
145
143
|
if (!result.success) throw new __injectivelabs_exceptions.TrezorException(new Error(result.payload && result.payload.error || "Please make sure your Trezor is connected and unlocked"));
|
|
146
144
|
for (const item of result.payload) {
|
|
147
145
|
const hdKey = {
|
|
@@ -184,18 +182,24 @@ var AccountManager = class {
|
|
|
184
182
|
//#region src/strategy/hw/transport/base.ts
|
|
185
183
|
const TREZOR_CONNECT_MANIFEST = {
|
|
186
184
|
email: "contact@injectivelabs.org",
|
|
187
|
-
appUrl: "https://injectivelabs.org"
|
|
185
|
+
appUrl: "https://injectivelabs.org",
|
|
186
|
+
appName: "Injective Labs"
|
|
188
187
|
};
|
|
189
188
|
var BaseTrezorTransport = class {
|
|
190
189
|
constructor() {
|
|
191
190
|
_defineProperty(this, "accountManager", null);
|
|
192
191
|
}
|
|
193
192
|
async connect() {
|
|
194
|
-
const TrezorConnect
|
|
195
|
-
if (!(await TrezorConnect
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
193
|
+
const TrezorConnect = await loadTrezorConnect();
|
|
194
|
+
if (!(await TrezorConnect.getSettings()).success) {
|
|
195
|
+
console.log("🪵Initializing TrezorConnect...");
|
|
196
|
+
await TrezorConnect.init({
|
|
197
|
+
lazyLoad: true,
|
|
198
|
+
manifest: TREZOR_CONNECT_MANIFEST,
|
|
199
|
+
debug: true,
|
|
200
|
+
coreMode: "popup"
|
|
201
|
+
});
|
|
202
|
+
}
|
|
199
203
|
return Promise.resolve();
|
|
200
204
|
}
|
|
201
205
|
async getAccountManager() {
|
|
@@ -268,7 +272,8 @@ var TrezorBase = class extends __injectivelabs_wallet_base.BaseConcreteStrategy
|
|
|
268
272
|
return response;
|
|
269
273
|
}
|
|
270
274
|
async signEip712TypedData(eip712json, address) {
|
|
271
|
-
const TrezorConnect
|
|
275
|
+
const TrezorConnect = await loadTrezorConnect();
|
|
276
|
+
console.log("🪵Address:", address);
|
|
272
277
|
const object = JSON.parse(eip712json);
|
|
273
278
|
const { types: { EIP712Domain = [],...otherTypes } = {}, message = {}, domain = {}, primaryType, domain_separator_hash, message_hash } = transformTypedData({
|
|
274
279
|
...object,
|
|
@@ -279,9 +284,13 @@ var TrezorBase = class extends __injectivelabs_wallet_base.BaseConcreteStrategy
|
|
|
279
284
|
}
|
|
280
285
|
});
|
|
281
286
|
try {
|
|
287
|
+
console.log("🪵Signing EIP-712 typed data with Trezor...");
|
|
282
288
|
await this.trezor.connect();
|
|
283
|
-
|
|
284
|
-
const
|
|
289
|
+
console.log("🪵Connected to Trezor...");
|
|
290
|
+
const derivationPath = "m/44'/60'/0'/0/0";
|
|
291
|
+
console.log("🪵Derivation path:", derivationPath);
|
|
292
|
+
console.log("Signing EIP-712 typed data with Trezor...");
|
|
293
|
+
const response = await TrezorConnect.ethereumSignTypedData({
|
|
285
294
|
path: derivationPath,
|
|
286
295
|
data: {
|
|
287
296
|
types: {
|
|
@@ -296,6 +305,7 @@ var TrezorBase = class extends __injectivelabs_wallet_base.BaseConcreteStrategy
|
|
|
296
305
|
domain_separator_hash,
|
|
297
306
|
metamask_v4_compat: true
|
|
298
307
|
});
|
|
308
|
+
console.log("🪵response", response);
|
|
299
309
|
if (!response.success) throw new Error(response.payload && response.payload.error || "Unknown error");
|
|
300
310
|
return response.payload.signature;
|
|
301
311
|
} catch (e) {
|
|
@@ -321,11 +331,11 @@ var TrezorBase = class extends __injectivelabs_wallet_base.BaseConcreteStrategy
|
|
|
321
331
|
});
|
|
322
332
|
}
|
|
323
333
|
async signArbitrary(signer, data) {
|
|
324
|
-
const TrezorConnect
|
|
334
|
+
const TrezorConnect = await loadTrezorConnect();
|
|
325
335
|
try {
|
|
326
336
|
await this.trezor.connect();
|
|
327
337
|
const { derivationPath } = await this.getWalletForAddress(signer);
|
|
328
|
-
const response = await TrezorConnect
|
|
338
|
+
const response = await TrezorConnect.ethereumSignMessage({
|
|
329
339
|
path: derivationPath,
|
|
330
340
|
message: (0, __injectivelabs_sdk_ts.toUtf8)(data)
|
|
331
341
|
});
|
|
@@ -360,7 +370,7 @@ var TrezorBase = class extends __injectivelabs_wallet_base.BaseConcreteStrategy
|
|
|
360
370
|
throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("You can only fetch PubKey from Cosmos native wallets"));
|
|
361
371
|
}
|
|
362
372
|
async signEvmTransaction(txData, args) {
|
|
363
|
-
const TrezorConnect
|
|
373
|
+
const TrezorConnect = await loadTrezorConnect();
|
|
364
374
|
const chainId = parseInt(args.evmChainId.toString(), 10);
|
|
365
375
|
const nonce = await (await this.getAlchemy(args.evmChainId)).core.getTransactionCount(args.address);
|
|
366
376
|
const parseHexValue = (value) => {
|
|
@@ -387,7 +397,7 @@ var TrezorBase = class extends __injectivelabs_wallet_base.BaseConcreteStrategy
|
|
|
387
397
|
try {
|
|
388
398
|
await this.trezor.connect();
|
|
389
399
|
const { derivationPath } = await this.getWalletForAddress(args.address);
|
|
390
|
-
const response = await TrezorConnect
|
|
400
|
+
const response = await TrezorConnect.ethereumSignTransaction({
|
|
391
401
|
path: derivationPath,
|
|
392
402
|
transaction: trezorTxData
|
|
393
403
|
});
|
package/dist/esm/index.js
CHANGED
|
@@ -15,13 +15,11 @@ const TrezorDerivationPathType = {
|
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/strategy/lib.ts
|
|
18
|
-
let TrezorConnect;
|
|
19
18
|
async function loadTrezorConnect() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return TrezorConnect;
|
|
19
|
+
console.log("🪵Loading TrezorConnect...");
|
|
20
|
+
const module = await import("@trezor/connect-web");
|
|
21
|
+
console.log("🪵Module:", module);
|
|
22
|
+
return module.default;
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
//#endregion
|
|
@@ -128,7 +126,7 @@ var AccountManager = class {
|
|
|
128
126
|
return this.wallets.slice(start, end);
|
|
129
127
|
}
|
|
130
128
|
async getWalletsBasedOnIndex({ start, end, baseDerivationPath, derivationPathType }) {
|
|
131
|
-
const TrezorConnect
|
|
129
|
+
const TrezorConnect = await loadTrezorConnect();
|
|
132
130
|
const pathsToFetch = [];
|
|
133
131
|
for (let index = start; index < end; index += 1) {
|
|
134
132
|
const path = this.getTrezorDerivationPathBasedOnType({
|
|
@@ -141,7 +139,7 @@ var AccountManager = class {
|
|
|
141
139
|
showOnTrezor: false
|
|
142
140
|
});
|
|
143
141
|
}
|
|
144
|
-
const result = await TrezorConnect
|
|
142
|
+
const result = await TrezorConnect.ethereumGetPublicKey({ bundle: pathsToFetch });
|
|
145
143
|
if (!result.success) throw new TrezorException(new Error(result.payload && result.payload.error || "Please make sure your Trezor is connected and unlocked"));
|
|
146
144
|
for (const item of result.payload) {
|
|
147
145
|
const hdKey = {
|
|
@@ -184,18 +182,24 @@ var AccountManager = class {
|
|
|
184
182
|
//#region src/strategy/hw/transport/base.ts
|
|
185
183
|
const TREZOR_CONNECT_MANIFEST = {
|
|
186
184
|
email: "contact@injectivelabs.org",
|
|
187
|
-
appUrl: "https://injectivelabs.org"
|
|
185
|
+
appUrl: "https://injectivelabs.org",
|
|
186
|
+
appName: "Injective Labs"
|
|
188
187
|
};
|
|
189
188
|
var BaseTrezorTransport = class {
|
|
190
189
|
constructor() {
|
|
191
190
|
_defineProperty(this, "accountManager", null);
|
|
192
191
|
}
|
|
193
192
|
async connect() {
|
|
194
|
-
const TrezorConnect
|
|
195
|
-
if (!(await TrezorConnect
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
193
|
+
const TrezorConnect = await loadTrezorConnect();
|
|
194
|
+
if (!(await TrezorConnect.getSettings()).success) {
|
|
195
|
+
console.log("🪵Initializing TrezorConnect...");
|
|
196
|
+
await TrezorConnect.init({
|
|
197
|
+
lazyLoad: true,
|
|
198
|
+
manifest: TREZOR_CONNECT_MANIFEST,
|
|
199
|
+
debug: true,
|
|
200
|
+
coreMode: "popup"
|
|
201
|
+
});
|
|
202
|
+
}
|
|
199
203
|
return Promise.resolve();
|
|
200
204
|
}
|
|
201
205
|
async getAccountManager() {
|
|
@@ -268,7 +272,8 @@ var TrezorBase = class extends BaseConcreteStrategy {
|
|
|
268
272
|
return response;
|
|
269
273
|
}
|
|
270
274
|
async signEip712TypedData(eip712json, address) {
|
|
271
|
-
const TrezorConnect
|
|
275
|
+
const TrezorConnect = await loadTrezorConnect();
|
|
276
|
+
console.log("🪵Address:", address);
|
|
272
277
|
const object = JSON.parse(eip712json);
|
|
273
278
|
const { types: { EIP712Domain = [],...otherTypes } = {}, message = {}, domain = {}, primaryType, domain_separator_hash, message_hash } = transformTypedData({
|
|
274
279
|
...object,
|
|
@@ -279,9 +284,13 @@ var TrezorBase = class extends BaseConcreteStrategy {
|
|
|
279
284
|
}
|
|
280
285
|
});
|
|
281
286
|
try {
|
|
287
|
+
console.log("🪵Signing EIP-712 typed data with Trezor...");
|
|
282
288
|
await this.trezor.connect();
|
|
283
|
-
|
|
284
|
-
const
|
|
289
|
+
console.log("🪵Connected to Trezor...");
|
|
290
|
+
const derivationPath = "m/44'/60'/0'/0/0";
|
|
291
|
+
console.log("🪵Derivation path:", derivationPath);
|
|
292
|
+
console.log("Signing EIP-712 typed data with Trezor...");
|
|
293
|
+
const response = await TrezorConnect.ethereumSignTypedData({
|
|
285
294
|
path: derivationPath,
|
|
286
295
|
data: {
|
|
287
296
|
types: {
|
|
@@ -296,6 +305,7 @@ var TrezorBase = class extends BaseConcreteStrategy {
|
|
|
296
305
|
domain_separator_hash,
|
|
297
306
|
metamask_v4_compat: true
|
|
298
307
|
});
|
|
308
|
+
console.log("🪵response", response);
|
|
299
309
|
if (!response.success) throw new Error(response.payload && response.payload.error || "Unknown error");
|
|
300
310
|
return response.payload.signature;
|
|
301
311
|
} catch (e) {
|
|
@@ -321,11 +331,11 @@ var TrezorBase = class extends BaseConcreteStrategy {
|
|
|
321
331
|
});
|
|
322
332
|
}
|
|
323
333
|
async signArbitrary(signer, data) {
|
|
324
|
-
const TrezorConnect
|
|
334
|
+
const TrezorConnect = await loadTrezorConnect();
|
|
325
335
|
try {
|
|
326
336
|
await this.trezor.connect();
|
|
327
337
|
const { derivationPath } = await this.getWalletForAddress(signer);
|
|
328
|
-
const response = await TrezorConnect
|
|
338
|
+
const response = await TrezorConnect.ethereumSignMessage({
|
|
329
339
|
path: derivationPath,
|
|
330
340
|
message: toUtf8(data)
|
|
331
341
|
});
|
|
@@ -360,7 +370,7 @@ var TrezorBase = class extends BaseConcreteStrategy {
|
|
|
360
370
|
throw new WalletException(/* @__PURE__ */ new Error("You can only fetch PubKey from Cosmos native wallets"));
|
|
361
371
|
}
|
|
362
372
|
async signEvmTransaction(txData, args) {
|
|
363
|
-
const TrezorConnect
|
|
373
|
+
const TrezorConnect = await loadTrezorConnect();
|
|
364
374
|
const chainId = parseInt(args.evmChainId.toString(), 10);
|
|
365
375
|
const nonce = await (await this.getAlchemy(args.evmChainId)).core.getTransactionCount(args.address);
|
|
366
376
|
const parseHexValue = (value) => {
|
|
@@ -387,7 +397,7 @@ var TrezorBase = class extends BaseConcreteStrategy {
|
|
|
387
397
|
try {
|
|
388
398
|
await this.trezor.connect();
|
|
389
399
|
const { derivationPath } = await this.getWalletForAddress(args.address);
|
|
390
|
-
const response = await TrezorConnect
|
|
400
|
+
const response = await TrezorConnect.ethereumSignTransaction({
|
|
391
401
|
path: derivationPath,
|
|
392
402
|
transaction: trezorTxData
|
|
393
403
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-trezor",
|
|
3
3
|
"description": "Trezor wallet strategy for use with @injectivelabs/wallet-core.",
|
|
4
|
-
"version": "1.16.25-alpha.
|
|
4
|
+
"version": "1.16.25-alpha.2",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": {
|
|
@@ -56,16 +56,17 @@
|
|
|
56
56
|
"lint": "eslint . --ext .ts,.js"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@
|
|
60
|
-
"@injectivelabs/
|
|
61
|
-
"@injectivelabs/
|
|
62
|
-
"@injectivelabs/
|
|
63
|
-
"@
|
|
59
|
+
"@injectivelabs/exceptions": "1.16.25-alpha.2",
|
|
60
|
+
"@injectivelabs/sdk-ts": "1.16.25-alpha.2",
|
|
61
|
+
"@injectivelabs/ts-types": "1.16.25-alpha.2",
|
|
62
|
+
"@injectivelabs/wallet-base": "1.16.25-alpha.2",
|
|
63
|
+
"@trezor/connect": "^9.6.4",
|
|
64
|
+
"@trezor/connect-web": "^9.6.4",
|
|
64
65
|
"alchemy-sdk": "^3.4.7",
|
|
65
66
|
"viem": "^2.33.2"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"shx": "^0.3.3"
|
|
69
70
|
},
|
|
70
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "bfa4ecff376de6cb71007524bde7de4f5a8e9de0"
|
|
71
72
|
}
|