Socket
Socket
Sign inDemoInstall

@ethersproject/abstract-signer

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/abstract-signer - npm Package Compare versions

Comparing version 5.3.0 to 5.4.0

2

lib.esm/_version.d.ts

@@ -1,2 +0,2 @@

export declare const version = "abstract-signer/5.3.0";
export declare const version = "abstract-signer/5.4.0";
//# sourceMappingURL=_version.d.ts.map

@@ -1,2 +0,2 @@

export const version = "abstract-signer/5.3.0";
export const version = "abstract-signer/5.4.0";
//# sourceMappingURL=_version.js.map

@@ -1,2 +0,2 @@

import { BlockTag, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
import { BlockTag, FeeData, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";

@@ -38,2 +38,3 @@ import { Bytes, BytesLike } from "@ethersproject/bytes";

getGasPrice(): Promise<BigNumber>;
getFeeData(): Promise<FeeData>;
resolveName(name: string): Promise<string>;

@@ -40,0 +41,0 @@ checkTransaction(transaction: Deferrable<TransactionRequest>): Deferrable<TransactionRequest>;

@@ -16,3 +16,3 @@ "use strict";

const allowedTransactionKeys = [
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "type", "value"
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value"
];

@@ -85,2 +85,8 @@ const forwardErrors = [

}
getFeeData() {
return __awaiter(this, void 0, void 0, function* () {
this._checkProvider("getFeeData");
return yield this.provider.getFeeData();
});
}
resolveName(name) {

@@ -129,2 +135,5 @@ return __awaiter(this, void 0, void 0, function* () {

// - sendTransaction
//
// Notes:
// - We allow gasPrice for EIP-1559 as long as it matches maxFeePerGas
populateTransaction(transaction) {

@@ -145,5 +154,81 @@ return __awaiter(this, void 0, void 0, function* () {

}
if (tx.gasPrice == null) {
tx.gasPrice = this.getGasPrice();
// Do not allow mixing pre-eip-1559 and eip-1559 proerties
const hasEip1559 = (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null);
if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) {
logger.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction);
}
else if ((tx.type === 0 || tx.type === 1) && hasEip1559) {
logger.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction);
}
if ((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null)) {
// Fully-formed EIP-1559 transaction (skip getFeeData)
tx.type = 2;
}
else if (tx.type === 0 || tx.type === 1) {
// Explicit Legacy or EIP-2930 transaction
// Populate missing gasPrice
if (tx.gasPrice == null) {
tx.gasPrice = this.getGasPrice();
}
}
else {
// We need to get fee data to determine things
const feeData = yield this.getFeeData();
if (tx.type == null) {
// We need to auto-detect the intended type of this transaction...
if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) {
// The network supports EIP-1559!
// Upgrade transaction from null to eip-1559
tx.type = 2;
if (tx.gasPrice != null) {
// Using legacy gasPrice property on an eip-1559 network,
// so use gasPrice as both fee properties
const gasPrice = tx.gasPrice;
delete tx.gasPrice;
tx.maxFeePerGas = gasPrice;
tx.maxPriorityFeePerGas = gasPrice;
}
else {
// Populate missing fee data
if (tx.maxFeePerGas == null) {
tx.maxFeePerGas = feeData.maxFeePerGas;
}
if (tx.maxPriorityFeePerGas == null) {
tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
}
}
}
else if (feeData.gasPrice != null) {
// Network doesn't support EIP-1559...
// ...but they are trying to use EIP-1559 properties
if (hasEip1559) {
logger.throwError("network does not support EIP-1559", Logger.errors.UNSUPPORTED_OPERATION, {
operation: "populateTransaction"
});
}
// Populate missing fee data
if (tx.gasPrice == null) {
tx.gasPrice = feeData.gasPrice;
}
// Explicitly set untyped transaction to legacy
tx.type = 0;
}
else {
// getFeeData has failed us.
logger.throwError("failed to get consistent fee data", Logger.errors.UNSUPPORTED_OPERATION, {
operation: "signer.getFeeData"
});
}
}
else if (tx.type === 2) {
// Explicitly using EIP-1559
// Populate missing fee data
if (tx.maxFeePerGas == null) {
tx.maxFeePerGas = feeData.maxFeePerGas;
}
if (tx.maxPriorityFeePerGas == null) {
tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
}
}
}
if (tx.nonce == null) {

@@ -150,0 +235,0 @@ tx.nonce = this.getTransactionCount("pending");

@@ -1,2 +0,2 @@

export declare const version = "abstract-signer/5.3.0";
export declare const version = "abstract-signer/5.4.0";
//# sourceMappingURL=_version.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = "abstract-signer/5.3.0";
exports.version = "abstract-signer/5.4.0";
//# sourceMappingURL=_version.js.map

@@ -1,2 +0,2 @@

import { BlockTag, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
import { BlockTag, FeeData, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";

@@ -38,2 +38,3 @@ import { Bytes, BytesLike } from "@ethersproject/bytes";

getGasPrice(): Promise<BigNumber>;
getFeeData(): Promise<FeeData>;
resolveName(name: string): Promise<string>;

@@ -40,0 +41,0 @@ checkTransaction(transaction: Deferrable<TransactionRequest>): Deferrable<TransactionRequest>;

@@ -60,3 +60,3 @@ "use strict";

var allowedTransactionKeys = [
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "type", "value"
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value"
];

@@ -175,2 +175,14 @@ var forwardErrors = [

};
Signer.prototype.getFeeData = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this._checkProvider("getFeeData");
return [4 /*yield*/, this.provider.getFeeData()];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
Signer.prototype.resolveName = function (name) {

@@ -225,5 +237,8 @@ return __awaiter(this, void 0, void 0, function () {

// - sendTransaction
//
// Notes:
// - We allow gasPrice for EIP-1559 as long as it matches maxFeePerGas
Signer.prototype.populateTransaction = function (transaction) {
return __awaiter(this, void 0, void 0, function () {
var tx;
var tx, hasEip1559, feeData, gasPrice;
var _this = this;

@@ -255,5 +270,80 @@ return __generator(this, function (_a) {

}
hasEip1559 = (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null);
if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) {
logger.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction);
}
else if ((tx.type === 0 || tx.type === 1) && hasEip1559) {
logger.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction);
}
if (!((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null))) return [3 /*break*/, 2];
// Fully-formed EIP-1559 transaction (skip getFeeData)
tx.type = 2;
return [3 /*break*/, 5];
case 2:
if (!(tx.type === 0 || tx.type === 1)) return [3 /*break*/, 3];
// Explicit Legacy or EIP-2930 transaction
// Populate missing gasPrice
if (tx.gasPrice == null) {
tx.gasPrice = this.getGasPrice();
}
return [3 /*break*/, 5];
case 3: return [4 /*yield*/, this.getFeeData()];
case 4:
feeData = _a.sent();
if (tx.type == null) {
// We need to auto-detect the intended type of this transaction...
if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) {
// The network supports EIP-1559!
// Upgrade transaction from null to eip-1559
tx.type = 2;
if (tx.gasPrice != null) {
gasPrice = tx.gasPrice;
delete tx.gasPrice;
tx.maxFeePerGas = gasPrice;
tx.maxPriorityFeePerGas = gasPrice;
}
else {
// Populate missing fee data
if (tx.maxFeePerGas == null) {
tx.maxFeePerGas = feeData.maxFeePerGas;
}
if (tx.maxPriorityFeePerGas == null) {
tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
}
}
}
else if (feeData.gasPrice != null) {
// Network doesn't support EIP-1559...
// ...but they are trying to use EIP-1559 properties
if (hasEip1559) {
logger.throwError("network does not support EIP-1559", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
operation: "populateTransaction"
});
}
// Populate missing fee data
if (tx.gasPrice == null) {
tx.gasPrice = feeData.gasPrice;
}
// Explicitly set untyped transaction to legacy
tx.type = 0;
}
else {
// getFeeData has failed us.
logger.throwError("failed to get consistent fee data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
operation: "signer.getFeeData"
});
}
}
else if (tx.type === 2) {
// Explicitly using EIP-1559
// Populate missing fee data
if (tx.maxFeePerGas == null) {
tx.maxFeePerGas = feeData.maxFeePerGas;
}
if (tx.maxPriorityFeePerGas == null) {
tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
}
}
_a.label = 5;
case 5:
if (tx.nonce == null) {

@@ -288,3 +378,3 @@ tx.nonce = this.getTransactionCount("pending");

return [4 /*yield*/, properties_1.resolveProperties(tx)];
case 2: return [2 /*return*/, _a.sent()];
case 6: return [2 /*return*/, _a.sent()];
}

@@ -291,0 +381,0 @@ });

{
"author": "Richard Moore <me@ricmoo.com>",
"dependencies": {
"@ethersproject/abstract-provider": "^5.3.0",
"@ethersproject/bignumber": "^5.3.0",
"@ethersproject/bytes": "^5.3.0",
"@ethersproject/logger": "^5.3.0",
"@ethersproject/properties": "^5.3.0"
"@ethersproject/abstract-provider": "^5.4.0",
"@ethersproject/bignumber": "^5.4.0",
"@ethersproject/bytes": "^5.4.0",
"@ethersproject/logger": "^5.4.0",
"@ethersproject/properties": "^5.4.0"
},

@@ -22,3 +22,3 @@ "description": "An Abstract Class for desribing an Ethereum Signer for ethers.",

],
"gitHead": "4e6d121fb8aa7327290afab7653364be8ddd8d81",
"gitHead": "c2c0ce75039e7256b287f9a764188d08ed0b7296",
"keywords": [

@@ -44,5 +44,5 @@ "Ethereum",

"sideEffects": false,
"tarballHash": "0x2123b325684a93493b8ba0e346cd2e9c4bc8aa2137c217ab428e6069b86d8885",
"tarballHash": "0x8c090123662370f27356110b775c8ae479d2fbe3e6794b33bdcc9a4ab70ebaed",
"types": "./lib/index.d.ts",
"version": "5.3.0"
"version": "5.4.0"
}

@@ -1,1 +0,1 @@

export const version = "abstract-signer/5.3.0";
export const version = "abstract-signer/5.4.0";
"use strict";
import { BlockTag, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
import { BlockTag, FeeData, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";

@@ -13,3 +13,3 @@ import { Bytes, BytesLike } from "@ethersproject/bytes";

const allowedTransactionKeys: Array<string> = [
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "type", "value"
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value"
];

@@ -143,2 +143,8 @@

async getFeeData(): Promise<FeeData> {
this._checkProvider("getFeeData");
return await this.provider.getFeeData();
}
async resolveName(name: string): Promise<string> {

@@ -151,3 +157,2 @@ this._checkProvider("resolveName");

// Checks a transaction does not contain invalid keys and if

@@ -173,2 +178,3 @@ // no "from" is provided, populates it.

tx.from = this.getAddress();
} else {

@@ -194,2 +200,5 @@ // Make sure any provided address matches this signer

// - sendTransaction
//
// Notes:
// - We allow gasPrice for EIP-1559 as long as it matches maxFeePerGas
async populateTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionRequest> {

@@ -209,3 +218,81 @@

}
if (tx.gasPrice == null) { tx.gasPrice = this.getGasPrice(); }
// Do not allow mixing pre-eip-1559 and eip-1559 proerties
const hasEip1559 = (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null);
if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) {
logger.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction);
} else if ((tx.type === 0 || tx.type === 1) && hasEip1559) {
logger.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction);
}
if ((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null)) {
// Fully-formed EIP-1559 transaction (skip getFeeData)
tx.type = 2;
} else if (tx.type === 0 || tx.type === 1) {
// Explicit Legacy or EIP-2930 transaction
// Populate missing gasPrice
if (tx.gasPrice == null) { tx.gasPrice = this.getGasPrice(); }
} else {
// We need to get fee data to determine things
const feeData = await this.getFeeData();
if (tx.type == null) {
// We need to auto-detect the intended type of this transaction...
if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) {
// The network supports EIP-1559!
// Upgrade transaction from null to eip-1559
tx.type = 2;
if (tx.gasPrice != null) {
// Using legacy gasPrice property on an eip-1559 network,
// so use gasPrice as both fee properties
const gasPrice = tx.gasPrice;
delete tx.gasPrice;
tx.maxFeePerGas = gasPrice;
tx.maxPriorityFeePerGas = gasPrice;
} else {
// Populate missing fee data
if (tx.maxFeePerGas == null) { tx.maxFeePerGas = feeData.maxFeePerGas; }
if (tx.maxPriorityFeePerGas == null) { tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; }
}
} else if (feeData.gasPrice != null) {
// Network doesn't support EIP-1559...
// ...but they are trying to use EIP-1559 properties
if (hasEip1559) {
logger.throwError("network does not support EIP-1559", Logger.errors.UNSUPPORTED_OPERATION, {
operation: "populateTransaction"
});
}
// Populate missing fee data
if (tx.gasPrice == null) { tx.gasPrice = feeData.gasPrice; }
// Explicitly set untyped transaction to legacy
tx.type = 0;
} else {
// getFeeData has failed us.
logger.throwError("failed to get consistent fee data", Logger.errors.UNSUPPORTED_OPERATION, {
operation: "signer.getFeeData"
});
}
} else if (tx.type === 2) {
// Explicitly using EIP-1559
// Populate missing fee data
if (tx.maxFeePerGas == null) { tx.maxFeePerGas = feeData.maxFeePerGas; }
if (tx.maxPriorityFeePerGas == null) { tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; }
}
}
if (tx.nonce == null) { tx.nonce = this.getTransactionCount("pending"); }

@@ -212,0 +299,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc