-
Notifications
You must be signed in to change notification settings - Fork 72
feat: Add validation for inputs currency and currencyToken. #683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…llowed function and remove the ticket ID from the unit test descriptions.
yingyangxu2026
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made the changes. Could you please review them again?
| "0x1514000000000000000000000000000000000000" as Address, // WIP | ||
| ], | ||
| 1514: [ | ||
| "0x1514000000000000000000000000000000000000" as Address, // WIP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For WIP, could you use it from "./constants/common"?
And ERC20, could you import from the generated.ts
| * Throws an Error with the same message shape previously used by callers that | ||
| * validated arrays (e.g. group royalties distribution). | ||
| */ | ||
| export const assertCurrenciesAllowed = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rename validateXX?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the logic has some duplication with the caller.
Could you clean it?
And I find the miss the validation, such as the claimAllRevenue method. Could you make sure every currency has been checked in the repo?
| }); | ||
| expect(result.txHash).equal(txHash); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer you put the unit tests into the util file instead of the caller's unit test.
| import { WIP_TOKEN_ADDRESS } from "../../src/constants/common"; | ||
|
|
||
| // Use addresses that are whitelisted for unit tests that exercise currency checks. | ||
| export const mockERC20 = "0xF2104833d386a2734a4eB3B8ad6FC6812F29E38E"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should directly refer to the generated file.
|
|
||
| // Use addresses that are whitelisted for unit tests that exercise currency checks. | ||
| export const mockERC20 = "0xF2104833d386a2734a4eB3B8ad6FC6812F29E38E"; | ||
| export const mockAddress = WIP_TOKEN_ADDRESS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove mockAddress and directly use WIP_TOKEN_ADDRESS.
| * Throws an Error with a consistent message used across the SDK. | ||
| */ | ||
| export const assertCurrencyAllowed = (currency: Address, chainId: SupportedChainIds): void => { | ||
| if (currency === zeroAddress) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lint will not pass when you run pnpm run lint. I think the reusable-build-test-workflow.yml fix step should not be corrected. We should use the pnpm run lint instead of pnpm fix to intercept the unmet rules.
Could you create a ticket to track it?
| const { royaltyPolicy, currency } = normalized; | ||
|
|
||
| // Validate currency whitelist for the resolved chain. | ||
| assertCurrencyAllowed(currency, resolvedChainId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should put the validation into the last step. It makes the entire logic correct.
Description
This pr is adding validation for inputs currency and currencyToken., includes:
Aeneid: Input parameterscurrency/currencyTokenacceptsWIPorMERC20.Mainnet: Input parameterscurrency/currencyTokenacceptsWIP.WIP address:
0x1514000000000000000000000000000000000000MERC20 address:
0xF2104833d386a2734a4eB3B8ad6FC6812F29E38ETest Plan
Add unit tests for the modified APIs.