Skip to content

Commit 3982f82

Browse files
committed
fix: 1757
1 parent 7aac486 commit 3982f82

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/core/src/transaction/Clause.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ class Clause implements TransactionClause {
136136
amount: VET = VET.of(FixedPointNumber.ZERO),
137137
clauseOptions?: ClauseOptions
138138
): Clause {
139-
if (amount.value.isFinite() && amount.value.isPositive()) {
139+
if (
140+
amount.value.isFinite() &&
141+
amount.value.gte(FixedPointNumber.ZERO)
142+
) {
140143
return new Clause(
141144
contractAddress.toString().toLowerCase(),
142145
Hex.PREFIX + amount.wei.toString(Hex.RADIX),

packages/core/tests/transaction/Clause.unit.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ describe('Clause class tests', () => {
8989
expect(actual.data).toBeDefined();
9090
});
9191

92+
test('Return Clause <- VET value is zero', () => {
93+
const actual = Clause.callFunction(
94+
ClauseFixture.contract.address,
95+
ABIContract.ofAbi(ClauseFixture.contract.abi).getFunction(
96+
'set'
97+
),
98+
[1],
99+
VET.of(0)
100+
);
101+
expect(actual.to).toBe(
102+
ClauseFixture.contract.address.toString().toLowerCase()
103+
);
104+
expect(actual.amount().isZero()).toBe(true);
105+
expect(actual.data).toBeDefined();
106+
});
107+
92108
test('Return Clause <- call function & comment', () => {
93109
const comment = 'Setting x = 1.';
94110
const actual = Clause.callFunction(

0 commit comments

Comments
 (0)