Skip to content

Commit

Permalink
6508 fix (#6509)
Browse files Browse the repository at this point in the history
* fixed issue, unit test and changelog

* changelog
  • Loading branch information
jdevcs authored Oct 17, 2023
1 parent 70d1957 commit 226b3ba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
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 (#6509)

### 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

0 comments on commit 226b3ba

Please sign in to comment.