Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvements #369

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Enforce standard set of fields for tx when calling estimateGas and cr…
…eateAccesslist
rileystephens28 committed Nov 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 3a82e85db80e4c71e4ce44c038a430ab83868a9e
36 changes: 24 additions & 12 deletions src/signers/abstract-signer.ts
Original file line number Diff line number Diff line change
@@ -114,17 +114,6 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
pop.nonce = await this.getNonce('pending');
}

if (pop.gasLimit == null || pop.gasLimit === 0n) {
if (pop.type == 0) pop.gasLimit = await this.estimateGas(pop);
else {
//Special cases for type 2 tx to bypass address out of scope in the node
const temp = pop.to;
pop.to = '0x0000000000000000000000000000000000000000';
pop.gasLimit = getBigInt(2 * Number(await this.estimateGas(pop)));
pop.to = temp;
}
}

// Populate the chain ID
const network = await (<Provider>this.provider).getNetwork();

@@ -134,6 +123,29 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
} else {
pop.chainId = network.chainId;
}

// Create a base transaction object to be used for gas estimation and access list creation
const baseTx: QuaiTransactionLike = {
chainId: pop.chainId,
type: pop.type,
from: pop.from,
nonce: pop.nonce,
};
if (pop.to) baseTx.to = pop.to;
if (pop.data) baseTx.data = pop.data;
if (pop.value) baseTx.value = pop.value;

if (pop.gasLimit == null || pop.gasLimit === 0n) {
if (pop.type == 0) {
pop.gasLimit = await this.estimateGas(baseTx);
} else {
//Special cases for type 2 tx to bypass address out of scope in the node
baseTx.to = '0x0000000000000000000000000000000000000000';
pop.gasLimit = getBigInt(2 * Number(await this.estimateGas(baseTx)));
baseTx.to = pop.to;
}
}

if (pop.gasPrice == null || pop.minerTip == null) {
const feeData = await provider.getFeeData(zone, true);

@@ -148,7 +160,7 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
if (tx.accessList) {
pop.accessList = tx.accessList;
} else {
pop.accessList = await this.createAccessList(pop as QuaiTransactionRequest);
pop.accessList = await this.createAccessList(baseTx as QuaiTransactionRequest);
}
}
//@TOOD: Don't await all over the place; save them up for