@injectivelabs/wallet-ledger 1.20.30 → 1.20.32
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 +19 -2
- package/dist/esm/index.js +19 -2
- package/package.json +5 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -193,6 +193,22 @@ const signTypedDataMethods = new Set([
|
|
|
193
193
|
]);
|
|
194
194
|
const signMessageMethods = new Set(["eth_sign", "personal_sign"]);
|
|
195
195
|
const sendTransactionMethods = new Set(["eth_sendTransaction", "wallet_sendTransaction"]);
|
|
196
|
+
const bigintTransactionQuantityFields = [
|
|
197
|
+
"value",
|
|
198
|
+
"gas",
|
|
199
|
+
"gasLimit",
|
|
200
|
+
"gasPrice",
|
|
201
|
+
"maxFeePerGas",
|
|
202
|
+
"maxPriorityFeePerGas",
|
|
203
|
+
"maxFeePerBlobGas"
|
|
204
|
+
];
|
|
205
|
+
const numberTransactionQuantityFields = ["chainId", "nonce"];
|
|
206
|
+
const normalizeTransactionQuantities = (transaction) => {
|
|
207
|
+
const normalizedTransaction = { ...transaction };
|
|
208
|
+
for (const field of bigintTransactionQuantityFields) if (normalizedTransaction[field] !== void 0) normalizedTransaction[field] = BigInt(normalizedTransaction[field]);
|
|
209
|
+
for (const field of numberTransactionQuantityFields) if (normalizedTransaction[field] !== void 0) normalizedTransaction[field] = Number(BigInt(normalizedTransaction[field]));
|
|
210
|
+
return normalizedTransaction;
|
|
211
|
+
};
|
|
196
212
|
const isEthAddress = (value) => typeof value === "string" && /^0x[a-fA-F0-9]{40}$/.test(value);
|
|
197
213
|
const getTypedDataParam = (method, params) => {
|
|
198
214
|
const typedData = isEthAddress(params[0]) ? params[1] : params[0];
|
|
@@ -252,13 +268,14 @@ var LedgerEip1193Provider = class {
|
|
|
252
268
|
}
|
|
253
269
|
async signTransaction(txData) {
|
|
254
270
|
const ledgerInstance = await this.ledger.getInstance();
|
|
255
|
-
const
|
|
271
|
+
const normalizedTransaction = normalizeTransactionQuantities(txData);
|
|
272
|
+
const serializedTransaction = (0, viem.serializeTransaction)(normalizedTransaction);
|
|
256
273
|
const signature = await ledgerInstance.clearSignTransaction(this.derivationPath, serializedTransaction.substring(2), {
|
|
257
274
|
erc20: true,
|
|
258
275
|
externalPlugins: true,
|
|
259
276
|
nft: true
|
|
260
277
|
});
|
|
261
|
-
return (0, viem.serializeTransaction)(
|
|
278
|
+
return (0, viem.serializeTransaction)(normalizedTransaction, {
|
|
262
279
|
r: signature.r,
|
|
263
280
|
s: signature.s,
|
|
264
281
|
v: BigInt(signature.v)
|
package/dist/esm/index.js
CHANGED
|
@@ -192,6 +192,22 @@ const signTypedDataMethods = new Set([
|
|
|
192
192
|
]);
|
|
193
193
|
const signMessageMethods = new Set(["eth_sign", "personal_sign"]);
|
|
194
194
|
const sendTransactionMethods = new Set(["eth_sendTransaction", "wallet_sendTransaction"]);
|
|
195
|
+
const bigintTransactionQuantityFields = [
|
|
196
|
+
"value",
|
|
197
|
+
"gas",
|
|
198
|
+
"gasLimit",
|
|
199
|
+
"gasPrice",
|
|
200
|
+
"maxFeePerGas",
|
|
201
|
+
"maxPriorityFeePerGas",
|
|
202
|
+
"maxFeePerBlobGas"
|
|
203
|
+
];
|
|
204
|
+
const numberTransactionQuantityFields = ["chainId", "nonce"];
|
|
205
|
+
const normalizeTransactionQuantities = (transaction) => {
|
|
206
|
+
const normalizedTransaction = { ...transaction };
|
|
207
|
+
for (const field of bigintTransactionQuantityFields) if (normalizedTransaction[field] !== void 0) normalizedTransaction[field] = BigInt(normalizedTransaction[field]);
|
|
208
|
+
for (const field of numberTransactionQuantityFields) if (normalizedTransaction[field] !== void 0) normalizedTransaction[field] = Number(BigInt(normalizedTransaction[field]));
|
|
209
|
+
return normalizedTransaction;
|
|
210
|
+
};
|
|
195
211
|
const isEthAddress = (value) => typeof value === "string" && /^0x[a-fA-F0-9]{40}$/.test(value);
|
|
196
212
|
const getTypedDataParam = (method, params) => {
|
|
197
213
|
const typedData = isEthAddress(params[0]) ? params[1] : params[0];
|
|
@@ -251,13 +267,14 @@ var LedgerEip1193Provider = class {
|
|
|
251
267
|
}
|
|
252
268
|
async signTransaction(txData) {
|
|
253
269
|
const ledgerInstance = await this.ledger.getInstance();
|
|
254
|
-
const
|
|
270
|
+
const normalizedTransaction = normalizeTransactionQuantities(txData);
|
|
271
|
+
const serializedTransaction = serializeTransaction(normalizedTransaction);
|
|
255
272
|
const signature = await ledgerInstance.clearSignTransaction(this.derivationPath, serializedTransaction.substring(2), {
|
|
256
273
|
erc20: true,
|
|
257
274
|
externalPlugins: true,
|
|
258
275
|
nft: true
|
|
259
276
|
});
|
|
260
|
-
return serializeTransaction(
|
|
277
|
+
return serializeTransaction(normalizedTransaction, {
|
|
261
278
|
r: signature.r,
|
|
262
279
|
s: signature.s,
|
|
263
280
|
v: BigInt(signature.v)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-ledger",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.32",
|
|
4
4
|
"description": "Ledger wallet strategy for use with @injectivelabs/wallet-core.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"@ledgerhq/hw-transport-webusb": "^6.34.4",
|
|
51
51
|
"buffer": "^6.0.3",
|
|
52
52
|
"viem": "^2.54.6",
|
|
53
|
-
"@injectivelabs/exceptions": "1.20.
|
|
54
|
-
"@injectivelabs/sdk-ts": "1.20.
|
|
55
|
-
"@injectivelabs/
|
|
56
|
-
"@injectivelabs/
|
|
53
|
+
"@injectivelabs/exceptions": "1.20.32",
|
|
54
|
+
"@injectivelabs/sdk-ts": "1.20.32",
|
|
55
|
+
"@injectivelabs/ts-types": "1.20.32",
|
|
56
|
+
"@injectivelabs/wallet-base": "1.20.32"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@ethersproject/abi": "^5.7.0",
|