forked from subquery/subql
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ethereum address validation to include Zilliqa address (#231)
* Update ethereum address validation to include Zilliqa address * Update changelog
- Loading branch information
Showing
6 changed files
with
129 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
import {isEthereumOrZilliqaAddress} from './utils'; | ||
|
||
describe('Project Utils', () => { | ||
it('can validate Ethereum and Zilliqa addresses', () => { | ||
// Ethereum addresses | ||
expect(isEthereumOrZilliqaAddress('0x0000000000000000000000000000000000000000')).toBeTruthy(); | ||
expect(isEthereumOrZilliqaAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')).toBeTruthy(); | ||
|
||
// Zilliqa addresses | ||
expect(isEthereumOrZilliqaAddress('0x7Aa7eA9f4534d8D70224b9c2FB165242F321F12b')).toBeTruthy(); | ||
expect(isEthereumOrZilliqaAddress('zil102n74869xnvdwq3yh8p0k9jjgtejruft268tg8')).toBeTruthy(); | ||
|
||
// Invalid addresses | ||
expect(isEthereumOrZilliqaAddress('')).toBeFalsy(); | ||
expect(isEthereumOrZilliqaAddress('hello world')).toBeFalsy(); | ||
expect(isEthereumOrZilliqaAddress('zil1')).toBeFalsy(); | ||
expect(isEthereumOrZilliqaAddress('0x0')).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters