Skip to content

Commit

Permalink
feat: EIP-1559 effectiveGasPrice (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
menduz authored Jan 4, 2024
1 parent b2fa644 commit 6006c46
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-18-bullseye",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"node": {
"version": "lts",
"nodeGypDependencies": true
},
"ghcr.io/devcontainers/features/docker-in-docker": {}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "yarn install --frozen-lockfile"
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
1 change: 1 addition & 0 deletions docs/eth-connect.transactionreceipt.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type TransactionReceipt = {
blockNumber: Quantity;
cumulativeGasUsed: Quantity;
gasUsed: Quantity;
effectiveGasPrice?: Quantity;
contractAddress: Address;
logs: Array<LogObject>;
logsBloom: Data;
Expand Down
1 change: 1 addition & 0 deletions report/eth-connect.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,7 @@ export type TransactionReceipt = {
blockNumber: Quantity;
cumulativeGasUsed: Quantity;
gasUsed: Quantity;
effectiveGasPrice?: Quantity;
contractAddress: Address;
logs: Array<LogObject>;
logsBloom: Data;
Expand Down
2 changes: 2 additions & 0 deletions src/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ export type TransactionReceipt = {
cumulativeGasUsed: Quantity
/** The amount of gas used by this specific transaction alone. */
gasUsed: Quantity
/** The actual value per gas deducted from the sender's account. Before EIP-1559, equal to the gas price. */
effectiveGasPrice?: Quantity
/** The contract address created, if the transaction was a contract creation, otherwise null. */
contractAddress: Address
/** Array of log objects, which this transaction generated. */
Expand Down
3 changes: 3 additions & 0 deletions src/utils/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ export function outputTransactionReceiptFormatter(receipt: TransactionReceipt) {
receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed)
receipt.gasUsed = utils.toDecimal(receipt.gasUsed)

if (receipt.effectiveGasPrice !== undefined && receipt.effectiveGasPrice !== null)
receipt.effectiveGasPrice = utils.toDecimal(receipt.effectiveGasPrice)

if (receipt.logs && utils.isArray(receipt.logs)) {
receipt.logs = receipt.logs.map(function (log) {
return outputLogFormatter(log)
Expand Down
1 change: 1 addition & 0 deletions test/helpers/FakeHttpProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ export class FakeHttpProvider {
blockNumber: '0xb', // 11
blockHash: '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b',
cumulativeGasUsed: '0x33bc', // 13244
effectiveGasPrice: '0xff',
gasUsed: '0x4dc', // 1244
contractAddress: '0x0', // or null, if none was created
logs: [],
Expand Down
4 changes: 3 additions & 1 deletion test/web3.eth.getTransactionReceipt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let txResult = {
transactionIndex: '0x1',
contractAddress: '0x407d73d8a49eeb85d32cf465507dd71d507100c1',
cumulativeGasUsed: '0x7f110',
effectiveGasPrice: '0x123',
status: '0xa',
gasUsed: '0x7f110',
logs: [
Expand Down Expand Up @@ -39,6 +40,7 @@ let formattedTxResult = {
transactionIndex: 1,
contractAddress: '0x407d73d8a49eeb85d32cf465507dd71d507100c1',
cumulativeGasUsed: 520464,
effectiveGasPrice: 0x123,
gasUsed: 520464,
status: 10,
logs: [
Expand All @@ -65,7 +67,7 @@ let formattedTxResult = {

let tests = [
{
args: ['0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'],
args: ['0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'],
formattedArgs: ['0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'],
result: txResult,
formattedResult: formattedTxResult,
Expand Down

0 comments on commit 6006c46

Please sign in to comment.