Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 226b3ba

Browse files
authored
6508 fix (#6509)
* fixed issue, unit test and changelog * changelog
1 parent 70d1957 commit 226b3ba

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

packages/web3-eth/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ Documentation:
201201

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

205206
### Added
206207

packages/web3-eth/src/utils/transaction_builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export async function defaultTransactionBuilder<ReturnType = Transaction>(option
155155
}
156156

157157
if (isNullish(populatedTransaction.value)) {
158-
populatedTransaction.value = '0x';
158+
populatedTransaction.value = '0x0';
159159
}
160160

161161
if (!isNullish(populatedTransaction.data)) {

packages/web3-eth/test/unit/default_transaction_builder.test.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ describe('defaultTransactionBuilder', () => {
228228
});
229229

230230
describe('should populate value', () => {
231-
it('should populate with 0x', async () => {
231+
it('should populate with 0x0 if not provided', async () => {
232232
const input = { ...transaction };
233233
delete input.value;
234234
delete input.maxPriorityFeePerGas;
@@ -239,7 +239,21 @@ describe('defaultTransactionBuilder', () => {
239239
web3Context,
240240
fillGasPrice: true,
241241
});
242-
expect(result.value).toBe('0x');
242+
expect(result.value).toBe('0x0');
243+
});
244+
245+
246+
it('should not populate with 0x0 if provided', async () => {
247+
const input = { ...transaction };
248+
delete input.maxPriorityFeePerGas;
249+
delete input.maxFeePerGas;
250+
251+
const result = await defaultTransactionBuilder({
252+
transaction: input,
253+
web3Context,
254+
fillGasPrice: true,
255+
});
256+
expect(result.value).not.toBe('0x0');
243257
});
244258
});
245259

0 commit comments

Comments
 (0)