@injectivelabs/wallet-ledger 1.20.29 → 1.20.31
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 +21 -3
- package/dist/esm/index.js +21 -3
- package/package.json +5 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -192,6 +192,23 @@ const signTypedDataMethods = new Set([
|
|
|
192
192
|
"eth_signTypedData_v4"
|
|
193
193
|
]);
|
|
194
194
|
const signMessageMethods = new Set(["eth_sign", "personal_sign"]);
|
|
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
|
+
};
|
|
195
212
|
const isEthAddress = (value) => typeof value === "string" && /^0x[a-fA-F0-9]{40}$/.test(value);
|
|
196
213
|
const getTypedDataParam = (method, params) => {
|
|
197
214
|
const typedData = isEthAddress(params[0]) ? params[1] : params[0];
|
|
@@ -251,13 +268,14 @@ var LedgerEip1193Provider = class {
|
|
|
251
268
|
}
|
|
252
269
|
async signTransaction(txData) {
|
|
253
270
|
const ledgerInstance = await this.ledger.getInstance();
|
|
254
|
-
const
|
|
271
|
+
const normalizedTransaction = normalizeTransactionQuantities(txData);
|
|
272
|
+
const serializedTransaction = (0, viem.serializeTransaction)(normalizedTransaction);
|
|
255
273
|
const signature = await ledgerInstance.clearSignTransaction(this.derivationPath, serializedTransaction.substring(2), {
|
|
256
274
|
erc20: true,
|
|
257
275
|
externalPlugins: true,
|
|
258
276
|
nft: true
|
|
259
277
|
});
|
|
260
|
-
return (0, viem.serializeTransaction)(
|
|
278
|
+
return (0, viem.serializeTransaction)(normalizedTransaction, {
|
|
261
279
|
r: signature.r,
|
|
262
280
|
s: signature.s,
|
|
263
281
|
v: BigInt(signature.v)
|
|
@@ -305,7 +323,7 @@ var LedgerEip1193Provider = class {
|
|
|
305
323
|
blockTag: "pending"
|
|
306
324
|
})).toString(16)}`;
|
|
307
325
|
}
|
|
308
|
-
if (args.method
|
|
326
|
+
if (sendTransactionMethods.has(args.method)) {
|
|
309
327
|
const address = await this.getAddress();
|
|
310
328
|
const walletClient = (0, __injectivelabs_wallet_base.getViemWalletClient)({
|
|
311
329
|
chainId: this.chainId,
|
package/dist/esm/index.js
CHANGED
|
@@ -191,6 +191,23 @@ const signTypedDataMethods = new Set([
|
|
|
191
191
|
"eth_signTypedData_v4"
|
|
192
192
|
]);
|
|
193
193
|
const signMessageMethods = new Set(["eth_sign", "personal_sign"]);
|
|
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
|
+
};
|
|
194
211
|
const isEthAddress = (value) => typeof value === "string" && /^0x[a-fA-F0-9]{40}$/.test(value);
|
|
195
212
|
const getTypedDataParam = (method, params) => {
|
|
196
213
|
const typedData = isEthAddress(params[0]) ? params[1] : params[0];
|
|
@@ -250,13 +267,14 @@ var LedgerEip1193Provider = class {
|
|
|
250
267
|
}
|
|
251
268
|
async signTransaction(txData) {
|
|
252
269
|
const ledgerInstance = await this.ledger.getInstance();
|
|
253
|
-
const
|
|
270
|
+
const normalizedTransaction = normalizeTransactionQuantities(txData);
|
|
271
|
+
const serializedTransaction = serializeTransaction(normalizedTransaction);
|
|
254
272
|
const signature = await ledgerInstance.clearSignTransaction(this.derivationPath, serializedTransaction.substring(2), {
|
|
255
273
|
erc20: true,
|
|
256
274
|
externalPlugins: true,
|
|
257
275
|
nft: true
|
|
258
276
|
});
|
|
259
|
-
return serializeTransaction(
|
|
277
|
+
return serializeTransaction(normalizedTransaction, {
|
|
260
278
|
r: signature.r,
|
|
261
279
|
s: signature.s,
|
|
262
280
|
v: BigInt(signature.v)
|
|
@@ -304,7 +322,7 @@ var LedgerEip1193Provider = class {
|
|
|
304
322
|
blockTag: "pending"
|
|
305
323
|
})).toString(16)}`;
|
|
306
324
|
}
|
|
307
|
-
if (args.method
|
|
325
|
+
if (sendTransactionMethods.has(args.method)) {
|
|
308
326
|
const address = await this.getAddress();
|
|
309
327
|
const walletClient = getViemWalletClient({
|
|
310
328
|
chainId: this.chainId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-ledger",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.31",
|
|
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/ts
|
|
54
|
-
"@injectivelabs/
|
|
55
|
-
"@injectivelabs/wallet-base": "1.20.
|
|
56
|
-
"@injectivelabs/
|
|
53
|
+
"@injectivelabs/sdk-ts": "1.20.31",
|
|
54
|
+
"@injectivelabs/exceptions": "1.20.31",
|
|
55
|
+
"@injectivelabs/wallet-base": "1.20.31",
|
|
56
|
+
"@injectivelabs/ts-types": "1.20.31"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@ethersproject/abi": "^5.7.0",
|