@injectivelabs/wallet-ledger 1.15.2 → 1.15.4
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.
|
@@ -103,16 +103,36 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
|
|
|
103
103
|
const object = JSON.parse(eip712json);
|
|
104
104
|
try {
|
|
105
105
|
const ledger = await this.ledger.getInstance();
|
|
106
|
-
const result = await ledger.
|
|
106
|
+
const result = await ledger.signEIP712Message(derivationPath, object);
|
|
107
107
|
const combined = `${result.r}${result.s}${result.v.toString(16)}`;
|
|
108
108
|
return combined.startsWith('0x') ? combined : `0x${combined}`;
|
|
109
109
|
}
|
|
110
110
|
catch (e) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
const errorMessage = e.message;
|
|
112
|
+
const isKnownNanoSError = errorMessage.includes('instruction not supported') ||
|
|
113
|
+
errorMessage.includes('invalid status') ||
|
|
114
|
+
errorMessage.includes('not supported') ||
|
|
115
|
+
errorMessage.includes('INS_NOT_SUPPORTED');
|
|
116
|
+
if (!isKnownNanoSError) {
|
|
117
|
+
throw new exceptions_1.LedgerException(new Error(errorMessage), {
|
|
118
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
119
|
+
type: exceptions_1.ErrorType.WalletError,
|
|
120
|
+
contextModule: wallet_base_1.WalletAction.SignTransaction,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
const ledger = await this.ledger.getInstance();
|
|
125
|
+
const result = await ledger.signEIP712HashedMessage(derivationPath, (0, ethereumjs_util_1.bufferToHex)((0, utils_js_1.domainHash)(object)), (0, ethereumjs_util_1.bufferToHex)((0, utils_js_1.messageHash)(object)));
|
|
126
|
+
const combined = `${result.r}${result.s}${result.v.toString(16)}`;
|
|
127
|
+
return combined.startsWith('0x') ? combined : `0x${combined}`;
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
throw new exceptions_1.LedgerException(new Error(e.message), {
|
|
131
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
132
|
+
type: exceptions_1.ErrorType.WalletError,
|
|
133
|
+
contextModule: wallet_base_1.WalletAction.SignTransaction,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
116
136
|
}
|
|
117
137
|
}
|
|
118
138
|
async signAminoCosmosTransaction(_transaction) {
|
|
@@ -98,16 +98,36 @@ export default class LedgerBase extends BaseConcreteStrategy {
|
|
|
98
98
|
const object = JSON.parse(eip712json);
|
|
99
99
|
try {
|
|
100
100
|
const ledger = await this.ledger.getInstance();
|
|
101
|
-
const result = await ledger.
|
|
101
|
+
const result = await ledger.signEIP712Message(derivationPath, object);
|
|
102
102
|
const combined = `${result.r}${result.s}${result.v.toString(16)}`;
|
|
103
103
|
return combined.startsWith('0x') ? combined : `0x${combined}`;
|
|
104
104
|
}
|
|
105
105
|
catch (e) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
const errorMessage = e.message;
|
|
107
|
+
const isKnownNanoSError = errorMessage.includes('instruction not supported') ||
|
|
108
|
+
errorMessage.includes('invalid status') ||
|
|
109
|
+
errorMessage.includes('not supported') ||
|
|
110
|
+
errorMessage.includes('INS_NOT_SUPPORTED');
|
|
111
|
+
if (!isKnownNanoSError) {
|
|
112
|
+
throw new LedgerException(new Error(errorMessage), {
|
|
113
|
+
code: UnspecifiedErrorCode,
|
|
114
|
+
type: ErrorType.WalletError,
|
|
115
|
+
contextModule: WalletAction.SignTransaction,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const ledger = await this.ledger.getInstance();
|
|
120
|
+
const result = await ledger.signEIP712HashedMessage(derivationPath, bufferToHex(domainHash(object)), bufferToHex(messageHash(object)));
|
|
121
|
+
const combined = `${result.r}${result.s}${result.v.toString(16)}`;
|
|
122
|
+
return combined.startsWith('0x') ? combined : `0x${combined}`;
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
throw new LedgerException(new Error(e.message), {
|
|
126
|
+
code: UnspecifiedErrorCode,
|
|
127
|
+
type: ErrorType.WalletError,
|
|
128
|
+
contextModule: WalletAction.SignTransaction,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
111
131
|
}
|
|
112
132
|
}
|
|
113
133
|
async signAminoCosmosTransaction(_transaction) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-ledger",
|
|
3
3
|
"description": "Ledger wallet strategy for use with @injectivelabs/wallet-core.",
|
|
4
|
-
"version": "1.15.
|
|
4
|
+
"version": "1.15.4",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": {
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"@ethereumjs/common": "^3.1.1",
|
|
65
65
|
"@ethereumjs/tx": "^4.1.1",
|
|
66
66
|
"@injectivelabs/exceptions": "^1.15.1",
|
|
67
|
-
"@injectivelabs/sdk-ts": "^1.15.
|
|
67
|
+
"@injectivelabs/sdk-ts": "^1.15.4",
|
|
68
68
|
"@injectivelabs/ts-types": "^1.15.2",
|
|
69
|
-
"@injectivelabs/wallet-base": "^1.15.
|
|
69
|
+
"@injectivelabs/wallet-base": "^1.15.4",
|
|
70
70
|
"alchemy-sdk": "^3.4.7",
|
|
71
71
|
"eth-sig-util": "^3.0.1",
|
|
72
72
|
"ethereumjs-util": "^7.1.0",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"@types/hdkey": "^2.0.1",
|
|
79
79
|
"@types/ledgerhq__hw-transport-webusb": "^4.70.1"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "b3c1eea83eec540cbd39b923a430c132014b59b6"
|
|
82
82
|
}
|