@ethersproject/transactions
Advanced tools
Comparing version 5.4.0 to 5.5.0
@@ -1,2 +0,2 @@ | ||
export declare const version = "transactions/5.4.0"; | ||
export declare const version = "transactions/5.5.0"; | ||
//# sourceMappingURL=_version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export const version = "transactions/5.4.0"; | ||
export const version = "transactions/5.5.0"; | ||
//# sourceMappingURL=_version.js.map |
@@ -188,3 +188,3 @@ "use strict"; | ||
} | ||
// Requesting an unsigned transation | ||
// Requesting an unsigned transaction | ||
if (!signature) { | ||
@@ -345,3 +345,3 @@ return RLP.encode(raw); | ||
else { | ||
// Signed Tranasaction | ||
// Signed Transaction | ||
tx.chainId = Math.floor((tx.v - 35) / 2); | ||
@@ -348,0 +348,0 @@ if (tx.chainId < 0) { |
@@ -1,2 +0,2 @@ | ||
export declare const version = "transactions/5.4.0"; | ||
export declare const version = "transactions/5.5.0"; | ||
//# sourceMappingURL=_version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "transactions/5.4.0"; | ||
exports.version = "transactions/5.5.0"; | ||
//# sourceMappingURL=_version.js.map |
@@ -46,3 +46,3 @@ "use strict"; | ||
} | ||
return address_1.getAddress(value); | ||
return (0, address_1.getAddress)(value); | ||
} | ||
@@ -68,12 +68,12 @@ function handleNumber(value) { | ||
function computeAddress(key) { | ||
var publicKey = signing_key_1.computePublicKey(key); | ||
return address_1.getAddress(bytes_1.hexDataSlice(keccak256_1.keccak256(bytes_1.hexDataSlice(publicKey, 1)), 12)); | ||
var publicKey = (0, signing_key_1.computePublicKey)(key); | ||
return (0, address_1.getAddress)((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, bytes_1.hexDataSlice)(publicKey, 1)), 12)); | ||
} | ||
exports.computeAddress = computeAddress; | ||
function recoverAddress(digest, signature) { | ||
return computeAddress(signing_key_1.recoverPublicKey(bytes_1.arrayify(digest), signature)); | ||
return computeAddress((0, signing_key_1.recoverPublicKey)((0, bytes_1.arrayify)(digest), signature)); | ||
} | ||
exports.recoverAddress = recoverAddress; | ||
function formatNumber(value, name) { | ||
var result = bytes_1.stripZeros(bignumber_1.BigNumber.from(value).toHexString()); | ||
var result = (0, bytes_1.stripZeros)(bignumber_1.BigNumber.from(value).toHexString()); | ||
if (result.length > 32) { | ||
@@ -86,5 +86,5 @@ logger.throwArgumentError("invalid length for " + name, ("transaction:" + name), value); | ||
return { | ||
address: address_1.getAddress(addr), | ||
address: (0, address_1.getAddress)(addr), | ||
storageKeys: (storageKeys || []).map(function (storageKey, index) { | ||
if (bytes_1.hexDataLength(storageKey) !== 32) { | ||
if ((0, bytes_1.hexDataLength)(storageKey) !== 32) { | ||
logger.throwArgumentError("invalid access list storageKey", "accessList[" + addr + ":" + index + "]", storageKey); | ||
@@ -131,3 +131,4 @@ } | ||
logger.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas", "tx", { | ||
gasPrice: gasPrice, maxFeePerGas: maxFeePerGas | ||
gasPrice: gasPrice, | ||
maxFeePerGas: maxFeePerGas | ||
}); | ||
@@ -142,3 +143,3 @@ } | ||
formatNumber(transaction.gasLimit || 0, "gasLimit"), | ||
((transaction.to != null) ? address_1.getAddress(transaction.to) : "0x"), | ||
((transaction.to != null) ? (0, address_1.getAddress)(transaction.to) : "0x"), | ||
formatNumber(transaction.value || 0, "value"), | ||
@@ -149,8 +150,8 @@ (transaction.data || "0x"), | ||
if (signature) { | ||
var sig = bytes_1.splitSignature(signature); | ||
var sig = (0, bytes_1.splitSignature)(signature); | ||
fields.push(formatNumber(sig.recoveryParam, "recoveryParam")); | ||
fields.push(bytes_1.stripZeros(sig.r)); | ||
fields.push(bytes_1.stripZeros(sig.s)); | ||
fields.push((0, bytes_1.stripZeros)(sig.r)); | ||
fields.push((0, bytes_1.stripZeros)(sig.s)); | ||
} | ||
return bytes_1.hexConcat(["0x02", RLP.encode(fields)]); | ||
return (0, bytes_1.hexConcat)(["0x02", RLP.encode(fields)]); | ||
} | ||
@@ -163,3 +164,3 @@ function _serializeEip2930(transaction, signature) { | ||
formatNumber(transaction.gasLimit || 0, "gasLimit"), | ||
((transaction.to != null) ? address_1.getAddress(transaction.to) : "0x"), | ||
((transaction.to != null) ? (0, address_1.getAddress)(transaction.to) : "0x"), | ||
formatNumber(transaction.value || 0, "value"), | ||
@@ -170,12 +171,12 @@ (transaction.data || "0x"), | ||
if (signature) { | ||
var sig = bytes_1.splitSignature(signature); | ||
var sig = (0, bytes_1.splitSignature)(signature); | ||
fields.push(formatNumber(sig.recoveryParam, "recoveryParam")); | ||
fields.push(bytes_1.stripZeros(sig.r)); | ||
fields.push(bytes_1.stripZeros(sig.s)); | ||
fields.push((0, bytes_1.stripZeros)(sig.r)); | ||
fields.push((0, bytes_1.stripZeros)(sig.s)); | ||
} | ||
return bytes_1.hexConcat(["0x01", RLP.encode(fields)]); | ||
return (0, bytes_1.hexConcat)(["0x01", RLP.encode(fields)]); | ||
} | ||
// Legacy Transactions and EIP-155 | ||
function _serialize(transaction, signature) { | ||
properties_1.checkProperties(transaction, allowedTransactionKeys); | ||
(0, properties_1.checkProperties)(transaction, allowedTransactionKeys); | ||
var raw = []; | ||
@@ -188,3 +189,3 @@ transactionFields.forEach(function (fieldInfo) { | ||
} | ||
value = bytes_1.arrayify(bytes_1.hexlify(value, options)); | ||
value = (0, bytes_1.arrayify)((0, bytes_1.hexlify)(value, options)); | ||
// Fixed-width field | ||
@@ -196,3 +197,3 @@ if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) { | ||
if (fieldInfo.maxLength) { | ||
value = bytes_1.stripZeros(value); | ||
value = (0, bytes_1.stripZeros)(value); | ||
if (value.length > fieldInfo.maxLength) { | ||
@@ -202,3 +203,3 @@ logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); | ||
} | ||
raw.push(bytes_1.hexlify(value)); | ||
raw.push((0, bytes_1.hexlify)(value)); | ||
}); | ||
@@ -213,3 +214,3 @@ var chainId = 0; | ||
} | ||
else if (signature && !bytes_1.isBytesLike(signature) && signature.v > 28) { | ||
else if (signature && !(0, bytes_1.isBytesLike)(signature) && signature.v > 28) { | ||
// No chainId provided, but the signature is signing with EIP-155; derive chainId | ||
@@ -220,7 +221,7 @@ chainId = Math.floor((signature.v - 35) / 2); | ||
if (chainId !== 0) { | ||
raw.push(bytes_1.hexlify(chainId)); // @TODO: hexValue? | ||
raw.push((0, bytes_1.hexlify)(chainId)); // @TODO: hexValue? | ||
raw.push("0x"); | ||
raw.push("0x"); | ||
} | ||
// Requesting an unsigned transation | ||
// Requesting an unsigned transaction | ||
if (!signature) { | ||
@@ -231,3 +232,3 @@ return RLP.encode(raw); | ||
// case that the signTransaction function only adds a v. | ||
var sig = bytes_1.splitSignature(signature); | ||
var sig = (0, bytes_1.splitSignature)(signature); | ||
// We pushed a chainId and null r, s on for hashing only; remove those | ||
@@ -248,5 +249,5 @@ var v = 27 + sig.recoveryParam; | ||
} | ||
raw.push(bytes_1.hexlify(v)); | ||
raw.push(bytes_1.stripZeros(bytes_1.arrayify(sig.r))); | ||
raw.push(bytes_1.stripZeros(bytes_1.arrayify(sig.s))); | ||
raw.push((0, bytes_1.hexlify)(v)); | ||
raw.push((0, bytes_1.stripZeros)((0, bytes_1.arrayify)(sig.r))); | ||
raw.push((0, bytes_1.stripZeros)((0, bytes_1.arrayify)(sig.s))); | ||
return RLP.encode(raw); | ||
@@ -288,6 +289,6 @@ } | ||
} | ||
tx.r = bytes_1.hexZeroPad(fields[1], 32); | ||
tx.s = bytes_1.hexZeroPad(fields[2], 32); | ||
tx.r = (0, bytes_1.hexZeroPad)(fields[1], 32); | ||
tx.s = (0, bytes_1.hexZeroPad)(fields[2], 32); | ||
try { | ||
var digest = keccak256_1.keccak256(serialize(tx)); | ||
var digest = (0, keccak256_1.keccak256)(serialize(tx)); | ||
tx.from = recoverAddress(digest, { r: tx.r, s: tx.s, recoveryParam: tx.v }); | ||
@@ -302,3 +303,3 @@ } | ||
if (transaction.length !== 9 && transaction.length !== 12) { | ||
logger.throwArgumentError("invalid component count for transaction type: 2", "payload", bytes_1.hexlify(payload)); | ||
logger.throwArgumentError("invalid component count for transaction type: 2", "payload", (0, bytes_1.hexlify)(payload)); | ||
} | ||
@@ -324,3 +325,3 @@ var maxPriorityFeePerGas = handleNumber(transaction[2]); | ||
} | ||
tx.hash = keccak256_1.keccak256(payload); | ||
tx.hash = (0, keccak256_1.keccak256)(payload); | ||
_parseEipSignature(tx, transaction.slice(9), _serializeEip1559); | ||
@@ -332,3 +333,3 @@ return tx; | ||
if (transaction.length !== 8 && transaction.length !== 11) { | ||
logger.throwArgumentError("invalid component count for transaction type: 1", "payload", bytes_1.hexlify(payload)); | ||
logger.throwArgumentError("invalid component count for transaction type: 1", "payload", (0, bytes_1.hexlify)(payload)); | ||
} | ||
@@ -350,3 +351,3 @@ var tx = { | ||
} | ||
tx.hash = keccak256_1.keccak256(payload); | ||
tx.hash = (0, keccak256_1.keccak256)(payload); | ||
_parseEipSignature(tx, transaction.slice(8), _serializeEip2930); | ||
@@ -381,4 +382,4 @@ return tx; | ||
} | ||
tx.r = bytes_1.hexZeroPad(transaction[7], 32); | ||
tx.s = bytes_1.hexZeroPad(transaction[8], 32); | ||
tx.r = (0, bytes_1.hexZeroPad)(transaction[7], 32); | ||
tx.s = (0, bytes_1.hexZeroPad)(transaction[8], 32); | ||
if (bignumber_1.BigNumber.from(tx.r).isZero() && bignumber_1.BigNumber.from(tx.s).isZero()) { | ||
@@ -390,3 +391,3 @@ // EIP-155 unsigned transaction | ||
else { | ||
// Signed Tranasaction | ||
// Signed Transaction | ||
tx.chainId = Math.floor((tx.v - 35) / 2); | ||
@@ -399,3 +400,3 @@ if (tx.chainId < 0) { | ||
if (tx.chainId !== 0) { | ||
raw.push(bytes_1.hexlify(tx.chainId)); | ||
raw.push((0, bytes_1.hexlify)(tx.chainId)); | ||
raw.push("0x"); | ||
@@ -405,5 +406,5 @@ raw.push("0x"); | ||
} | ||
var digest = keccak256_1.keccak256(RLP.encode(raw)); | ||
var digest = (0, keccak256_1.keccak256)(RLP.encode(raw)); | ||
try { | ||
tx.from = recoverAddress(digest, { r: bytes_1.hexlify(tx.r), s: bytes_1.hexlify(tx.s), recoveryParam: recoveryParam }); | ||
tx.from = recoverAddress(digest, { r: (0, bytes_1.hexlify)(tx.r), s: (0, bytes_1.hexlify)(tx.s), recoveryParam: recoveryParam }); | ||
} | ||
@@ -413,3 +414,3 @@ catch (error) { | ||
} | ||
tx.hash = keccak256_1.keccak256(rawTransaction); | ||
tx.hash = (0, keccak256_1.keccak256)(rawTransaction); | ||
} | ||
@@ -420,3 +421,3 @@ tx.type = null; | ||
function parse(rawTransaction) { | ||
var payload = bytes_1.arrayify(rawTransaction); | ||
var payload = (0, bytes_1.arrayify)(rawTransaction); | ||
// Legacy and EIP-155 Transactions | ||
@@ -423,0 +424,0 @@ if (payload[0] > 0x7f) { |
{ | ||
"author": "Richard Moore <me@ricmoo.com>", | ||
"dependencies": { | ||
"@ethersproject/address": "^5.4.0", | ||
"@ethersproject/bignumber": "^5.4.0", | ||
"@ethersproject/bytes": "^5.4.0", | ||
"@ethersproject/constants": "^5.4.0", | ||
"@ethersproject/keccak256": "^5.4.0", | ||
"@ethersproject/logger": "^5.4.0", | ||
"@ethersproject/properties": "^5.4.0", | ||
"@ethersproject/rlp": "^5.4.0", | ||
"@ethersproject/signing-key": "^5.4.0" | ||
"@ethersproject/address": "^5.5.0", | ||
"@ethersproject/bignumber": "^5.5.0", | ||
"@ethersproject/bytes": "^5.5.0", | ||
"@ethersproject/constants": "^5.5.0", | ||
"@ethersproject/keccak256": "^5.5.0", | ||
"@ethersproject/logger": "^5.5.0", | ||
"@ethersproject/properties": "^5.5.0", | ||
"@ethersproject/rlp": "^5.5.0", | ||
"@ethersproject/signing-key": "^5.5.0" | ||
}, | ||
@@ -26,3 +26,3 @@ "description": "Utilities for decoding and encoding Ethereum transaction for ethers.", | ||
], | ||
"gitHead": "71b7547f10229f50d8b701611c5e6041b8ed966b", | ||
"gitHead": "73a46efea32c3f9a4833ed77896a216e3d3752a0", | ||
"keywords": [ | ||
@@ -48,5 +48,5 @@ "Ethereum", | ||
"sideEffects": false, | ||
"tarballHash": "0xc29469b44825e6645ec36d604d33c878d036064a10317e6b29f18e9aec2e0c96", | ||
"tarballHash": "0x2a703ae00409bf0122dd97bf8b4f33f71009dc9df625ff0dd0c391ef25189d65", | ||
"types": "./lib/index.d.ts", | ||
"version": "5.4.0" | ||
"version": "5.5.0" | ||
} |
@@ -1,1 +0,1 @@ | ||
export const version = "transactions/5.4.0"; | ||
export const version = "transactions/5.5.0"; |
@@ -273,3 +273,3 @@ "use strict"; | ||
// Requesting an unsigned transation | ||
// Requesting an unsigned transaction | ||
if (!signature) { | ||
@@ -451,3 +451,3 @@ return RLP.encode(raw); | ||
} else { | ||
// Signed Tranasaction | ||
// Signed Transaction | ||
@@ -454,0 +454,0 @@ tx.chainId = Math.floor((tx.v - 35) / 2); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89975
1312
Updated@ethersproject/bytes@^5.5.0
Updated@ethersproject/logger@^5.5.0
Updated@ethersproject/rlp@^5.5.0