-
Notifications
You must be signed in to change notification settings - Fork 972
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add checksum to constants in isValidProtocol (#864) * Increase package version * Add unit tests --------- Co-authored-by: Reagan <[email protected]>
- Loading branch information
1 parent
df72323
commit a24cc4f
Showing
4 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,30 @@ | ||
import { | ||
CROSS_CHAIN_SEAPORT_ADDRESS, | ||
CROSS_CHAIN_SEAPORT_V1_4_ADDRESS, | ||
} from "@opensea/seaport-js/lib/constants"; | ||
import { assert } from "chai"; | ||
import { suite, test } from "mocha"; | ||
import Web3 from "web3"; | ||
import { isValidProtocol } from "../../utils/utils"; | ||
|
||
suite("Utils: utils", () => { | ||
test("isValidProtocol works with all forms of address", async () => { | ||
const seaport_v1_1 = CROSS_CHAIN_SEAPORT_ADDRESS; | ||
const seaport_v_1_4 = CROSS_CHAIN_SEAPORT_V1_4_ADDRESS; | ||
const randomAddress = "0x1F7Cf51573Bf5270323a395F0bb5Fd3c3a4DB867"; | ||
|
||
assert.isTrue(isValidProtocol(seaport_v1_1)); | ||
assert.isTrue(isValidProtocol(seaport_v_1_4)); | ||
assert.isFalse(isValidProtocol(randomAddress)); | ||
|
||
assert.isTrue(isValidProtocol(seaport_v1_1.toLowerCase())); | ||
assert.isTrue(isValidProtocol(seaport_v_1_4.toLowerCase())); | ||
assert.isFalse(isValidProtocol(randomAddress.toLowerCase())); | ||
|
||
assert.isTrue(isValidProtocol(Web3.utils.toChecksumAddress(seaport_v1_1))); | ||
assert.isTrue(isValidProtocol(Web3.utils.toChecksumAddress(seaport_v_1_4))); | ||
assert.isFalse( | ||
isValidProtocol(Web3.utils.toChecksumAddress(randomAddress)) | ||
); | ||
}); | ||
}); |
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