Skip to content

Commit

Permalink
add address isZero check
Browse files Browse the repository at this point in the history
  • Loading branch information
michavie committed Jul 6, 2022
1 parent f33a25d commit a2dcefb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Domain/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,9 @@ public function isContractAddress(): bool
{
return str_starts_with($this->valueHex, self::SMART_CONTRACT_HEX_PUBKEY_PREFIX);
}

public function isZero(): bool
{
return $this->valueHex === Address::zero()->valueHex;
}
}
2 changes: 2 additions & 0 deletions tests/Domain/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
]);

it('zero - returns a zero address', fn () => expect(Address::zero()->bech32())->toBe('erd1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6gq4hu'));

it('isZero - returns true for a zero address', fn () => expect(Address::zero()->isZero())->toBeTrue());

0 comments on commit a2dcefb

Please sign in to comment.