Skip to content

Conversation

@yingyangxu2026
Copy link
Collaborator

Description

This pr is adding validation for inputs currency and currencyToken., includes:

  • On Aeneid : Input parameters currency / currencyToken accepts WIP or MERC20.
  • On Mainnet: Input parameters currency / currencyToken accepts WIP.

WIP address: 0x1514000000000000000000000000000000000000
MERC20 address: 0xF2104833d386a2734a4eB3B8ad6FC6812F29E38E

Test Plan

Add unit tests for the modified APIs.

@yingyangxu2026 yingyangxu2026 changed the title Tssdk 135 feat: Add validation for inputs currency and currencyToken. Jan 16, 2026
…llowed function and remove the ticket ID from the unit test descriptions.
Copy link
Collaborator Author

@yingyangxu2026 yingyangxu2026 left a 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
Copy link
Collaborator

@bonnie57 bonnie57 Jan 20, 2026

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 = (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename validateXX?

Copy link
Collaborator

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);
});

Copy link
Collaborator

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";
Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

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);
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants