Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions packages/web3-eth/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ Documentation:

- Ensure provider.supportsSubscriptions exists before watching by subscription (#6440)
- Fixed param sent to `checkRevertBeforeSending` in `sendSignedTransaction`
- Fixed `defaultTransactionBuilder` for value issue

### Added

Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth/src/utils/transaction_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export async function defaultTransactionBuilder<ReturnType = Transaction>(option
}

if (isNullish(populatedTransaction.value)) {
populatedTransaction.value = '0x';
populatedTransaction.value = '0x0';
}

if (!isNullish(populatedTransaction.data)) {
Expand Down
18 changes: 16 additions & 2 deletions packages/web3-eth/test/unit/default_transaction_builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ describe('defaultTransactionBuilder', () => {
});

describe('should populate value', () => {
it('should populate with 0x', async () => {
it('should populate with 0x0 if not provided', async () => {
const input = { ...transaction };
delete input.value;
delete input.maxPriorityFeePerGas;
Expand All @@ -239,7 +239,21 @@ describe('defaultTransactionBuilder', () => {
web3Context,
fillGasPrice: true,
});
expect(result.value).toBe('0x');
expect(result.value).toBe('0x0');
});


it('should not populate with 0x0 if provided', async () => {
const input = { ...transaction };
delete input.maxPriorityFeePerGas;
delete input.maxFeePerGas;

const result = await defaultTransactionBuilder({
transaction: input,
web3Context,
fillGasPrice: true,
});
expect(result.value).not.toBe('0x0');
});
});

Expand Down