-
Notifications
You must be signed in to change notification settings - Fork 55
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
feat: erc20 custody legacy deposit #328
Conversation
WalkthroughWalkthroughThe recent updates to the Changes
Possibly related issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
@@ -22,20 +22,32 @@ | |||
IGatewayEVM public immutable gateway; | |||
/// @notice Mapping of whitelisted tokens => true/false. | |||
mapping(address => bool) public whitelisted; | |||
/// @notice The address of the TSS (Threshold Signature Scheme) contract. | |||
address public tssAddress; |
Check warning
Code scanning / Slither
State variables that could be declared immutable Warning
@@ -53,6 +65,23 @@ | |||
_unpause(); | |||
} | |||
|
|||
/// @notice Unpause contract. | |||
function setSupportsLegacy(bool _supportsLegacy) external onlyRole(DEFAULT_ADMIN_ROLE) { |
Check warning
Code scanning / Slither
Conformance to Solidity naming conventions Warning
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #328 +/- ##
==========================================
+ Coverage 81.81% 82.23% +0.41%
==========================================
Files 7 7
Lines 297 304 +7
Branches 97 99 +2
==========================================
+ Hits 243 250 +7
Misses 54 54 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 4
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files ignored due to path filters (27)
v2/pkg/erc20custody.sol/erc20custody.go
is excluded by!v2/pkg/**
v2/pkg/erc20custody.t.sol/erc20custodytest.go
is excluded by!v2/pkg/**
v2/pkg/erc20custodyechidnatest.sol/erc20custodyechidnatest.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevm.sol/gatewayevm.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevm.t.sol/gatewayevminboundtest.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevm.t.sol/gatewayevmtest.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevmechidnatest.sol/gatewayevmechidnatest.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevmupgrade.t.sol/gatewayevmuupsupgradetest.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevmupgradetest.sol/gatewayevmupgradetest.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevmzevm.t.sol/gatewayevmzevmtest.go
is excluded by!v2/pkg/**
v2/pkg/ierc20custody.sol/ierc20custody.go
is excluded by!v2/pkg/**
v2/pkg/ierc20custody.sol/ierc20custodyerrors.go
is excluded by!v2/pkg/**
v2/pkg/ierc20custody.sol/ierc20custodyevents.go
is excluded by!v2/pkg/**
v2/pkg/zetaconnectornative.t.sol/zetaconnectornativetest.go
is excluded by!v2/pkg/**
v2/pkg/zetaconnectornonnative.t.sol/zetaconnectornonnativetest.go
is excluded by!v2/pkg/**
v2/types/ERC20Custody.ts
is excluded by!v2/types/**
v2/types/ERC20CustodyEchidnaTest.ts
is excluded by!v2/types/**
v2/types/IERC20Custody.sol/IERC20Custody.ts
is excluded by!v2/types/**
v2/types/IERC20Custody.sol/IERC20CustodyEvents.ts
is excluded by!v2/types/**
v2/types/factories/ERC20CustodyEchidnaTest__factory.ts
is excluded by!v2/types/**
v2/types/factories/ERC20Custody__factory.ts
is excluded by!v2/types/**
v2/types/factories/GatewayEVMEchidnaTest__factory.ts
is excluded by!v2/types/**
v2/types/factories/GatewayEVMUpgradeTest__factory.ts
is excluded by!v2/types/**
v2/types/factories/GatewayEVM__factory.ts
is excluded by!v2/types/**
v2/types/factories/IERC20Custody.sol/IERC20CustodyErrors__factory.ts
is excluded by!v2/types/**
v2/types/factories/IERC20Custody.sol/IERC20CustodyEvents__factory.ts
is excluded by!v2/types/**
v2/types/factories/IERC20Custody.sol/IERC20Custody__factory.ts
is excluded by!v2/types/**
Files selected for processing (3)
- v2/src/evm/ERC20Custody.sol (3 hunks)
- v2/src/evm/interfaces/IERC20Custody.sol (3 hunks)
- v2/test/ERC20Custody.t.sol (3 hunks)
Additional context used
GitHub Check: Slither
v2/src/evm/ERC20Custody.sol
[warning] 26-26: State variables that could be declared immutable
ERC20Custody.tssAddress (src/evm/ERC20Custody.sol#26) should be immutable
[warning] 69-69: Conformance to Solidity naming conventions
Parameter ERC20Custody.setSupportsLegacy(bool)._supportsLegacy (src/evm/ERC20Custody.sol#69) is not in mixedCase
[warning] 75-75: Conformance to Solidity naming conventions
Parameter ERC20Custody.setZeta(IERC20)._zeta (src/evm/ERC20Custody.sol#75) is not in mixedCase
[warning] 81-81: Conformance to Solidity naming conventions
Parameter ERC20Custody.setZetaFee(uint256)._zetaFee (src/evm/ERC20Custody.sol#81) is not in mixedCase
Additional comments not posted (10)
v2/src/evm/interfaces/IERC20Custody.sol (2)
41-42
: EventDeposited
is well-defined.The event captures necessary details for legacy deposit tracking. Ensure its usage is consistent across the contract.
52-53
: ErrorLegacyMethodsNotSupported
is appropriately defined.This error enhances clarity in error handling for unsupported legacy methods.
v2/src/evm/ERC20Custody.sol (2)
28-28
: State variablesupportsLegacy
is well-defined.This flag effectively controls the support for legacy methods.
182-204
: Functiondeposit
is well-implemented with legacy support check.The function appropriately handles legacy support and fee management.
v2/test/ERC20Custody.t.sol (6)
41-41
: ErrorLegacyMethodsNotSupported
is appropriately defined for testing.This error facilitates testing of unsupported legacy methods.
477-497
: TesttestDepositLegacy
effectively validates legacy deposit functionality.The test ensures correct balance updates and event emission.
499-519
: TesttestDepositLegacyIfZetaFeeIs0
correctly handles zero fee scenarios.The test ensures the TSS Zeta balance remains unchanged when the fee is zero.
521-540
: TesttestDepositLegacyIfZetaIsZeroAddress
ensures deposits function without a Zeta address.The test confirms deposits proceed correctly when the Zeta address is not set.
542-553
: TesttestDepositLegacyFailsIfNotSupported
correctly verifies failure without legacy support.The test ensures the deposit reverts when legacy support is disabled.
555-567
: TesttestDepositLegacyFailsIfTokenNotWhitelisted
ensures deposits fail for unwhitelisted tokens.The test correctly verifies access control by rejecting deposits for unwhitelisted tokens.
v2/src/evm/ERC20Custody.sol
Outdated
function setZetaFee(uint256 _zetaFee) external onlyRole(DEFAULT_ADMIN_ROLE) { | ||
zetaFee = _zetaFee; | ||
} |
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.
Rename parameter _zetaFee
to follow naming conventions.
The parameter should be in mixedCase to conform with Solidity naming conventions.
- function setZetaFee(uint256 _zetaFee) external onlyRole(DEFAULT_ADMIN_ROLE) {
+ function setZetaFee(uint256 zetaFee) external onlyRole(DEFAULT_ADMIN_ROLE) {
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
function setZetaFee(uint256 _zetaFee) external onlyRole(DEFAULT_ADMIN_ROLE) { | |
zetaFee = _zetaFee; | |
} | |
function setZetaFee(uint256 zetaFee) external onlyRole(DEFAULT_ADMIN_ROLE) { | |
zetaFee = _zetaFee; | |
} |
Tools
GitHub Check: Slither
[warning] 81-81: Conformance to Solidity naming conventions
Parameter ERC20Custody.setZetaFee(uint256)._zetaFee (src/evm/ERC20Custody.sol#81) is not in mixedCase
v2/src/evm/ERC20Custody.sol
Outdated
function setZeta(IERC20 _zeta) external onlyRole(DEFAULT_ADMIN_ROLE) { | ||
zeta = _zeta; | ||
} |
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.
Rename parameter _zeta
to follow naming conventions.
The parameter should be in mixedCase to conform with Solidity naming conventions.
- function setZeta(IERC20 _zeta) external onlyRole(DEFAULT_ADMIN_ROLE) {
+ function setZeta(IERC20 zeta) external onlyRole(DEFAULT_ADMIN_ROLE) {
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
function setZeta(IERC20 _zeta) external onlyRole(DEFAULT_ADMIN_ROLE) { | |
zeta = _zeta; | |
} | |
function setZeta(IERC20 zeta) external onlyRole(DEFAULT_ADMIN_ROLE) { | |
zeta = _zeta; | |
} |
Tools
GitHub Check: Slither
[warning] 75-75: Conformance to Solidity naming conventions
Parameter ERC20Custody.setZeta(IERC20)._zeta (src/evm/ERC20Custody.sol#75) is not in mixedCase
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.
We can remove zeta related logic
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.
Actionable comments posted: 2
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files ignored due to path filters (15)
v2/pkg/erc20custody.sol/erc20custody.go
is excluded by!v2/pkg/**
v2/pkg/erc20custody.t.sol/erc20custodytest.go
is excluded by!v2/pkg/**
v2/pkg/erc20custodyechidnatest.sol/erc20custodyechidnatest.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevm.t.sol/gatewayevminboundtest.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevm.t.sol/gatewayevmtest.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevmechidnatest.sol/gatewayevmechidnatest.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevmupgrade.t.sol/gatewayevmuupsupgradetest.go
is excluded by!v2/pkg/**
v2/pkg/gatewayevmzevm.t.sol/gatewayevmzevmtest.go
is excluded by!v2/pkg/**
v2/pkg/zetaconnectornative.t.sol/zetaconnectornativetest.go
is excluded by!v2/pkg/**
v2/pkg/zetaconnectornonnative.t.sol/zetaconnectornonnativetest.go
is excluded by!v2/pkg/**
v2/types/ERC20Custody.ts
is excluded by!v2/types/**
v2/types/ERC20CustodyEchidnaTest.ts
is excluded by!v2/types/**
v2/types/factories/ERC20CustodyEchidnaTest__factory.ts
is excluded by!v2/types/**
v2/types/factories/ERC20Custody__factory.ts
is excluded by!v2/types/**
v2/types/factories/GatewayEVMEchidnaTest__factory.ts
is excluded by!v2/types/**
Files selected for processing (2)
- v2/src/evm/ERC20Custody.sol (4 hunks)
- v2/test/ERC20Custody.t.sol (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- v2/test/ERC20Custody.t.sol
Additional context used
GitHub Check: Slither
v2/src/evm/ERC20Custody.sol
[warning] 26-26: State variables that could be declared immutable
ERC20Custody.tssAddress (src/evm/ERC20Custody.sol#26) should be immutable
[warning] 62-62: Conformance to Solidity naming conventions
Parameter ERC20Custody.setSupportsLegacy(bool)._supportsLegacy (src/evm/ERC20Custody.sol#62) is not in mixedCase
Additional comments not posted (3)
v2/src/evm/ERC20Custody.sol (3)
27-28
: LGTM: Addition ofsupportsLegacy
.The
supportsLegacy
state variable is a useful addition for managing legacy functionality.
42-43
: LGTM: Constructor changes.The constructor is well-structured and correctly initializes the necessary state variables and roles.
163-182
: LGTM:deposit
function changes.The
deposit
function correctly handles legacy method support and token transfer logic.
@@ -22,6 +22,10 @@ | |||
IGatewayEVM public immutable gateway; | |||
/// @notice Mapping of whitelisted tokens => true/false. | |||
mapping(address => bool) public whitelisted; | |||
/// @notice The address of the TSS (Threshold Signature Scheme) contract. | |||
address public tssAddress; |
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.
Consider making tssAddress
immutable.
The tssAddress
variable is set only once in the constructor and can be declared immutable
for gas optimization.
- address public tssAddress;
+ address public immutable tssAddress;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
address public tssAddress; | |
address public immutable tssAddress; |
Tools
GitHub Check: Slither
[warning] 26-26: State variables that could be declared immutable
ERC20Custody.tssAddress (src/evm/ERC20Custody.sol#26) should be immutable
function setSupportsLegacy(bool _supportsLegacy) external onlyRole(DEFAULT_ADMIN_ROLE) { | ||
supportsLegacy = _supportsLegacy; | ||
} |
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.
Rename parameter _supportsLegacy
to follow naming conventions.
The parameter should be in mixedCase to conform with Solidity naming conventions.
- function setSupportsLegacy(bool _supportsLegacy) external onlyRole(DEFAULT_ADMIN_ROLE) {
+ function setSupportsLegacy(bool supportsLegacy) external onlyRole(DEFAULT_ADMIN_ROLE) {
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
function setSupportsLegacy(bool _supportsLegacy) external onlyRole(DEFAULT_ADMIN_ROLE) { | |
supportsLegacy = _supportsLegacy; | |
} | |
function setSupportsLegacy(bool supportsLegacy) external onlyRole(DEFAULT_ADMIN_ROLE) { | |
supportsLegacy = _supportsLegacy; | |
} |
Tools
GitHub Check: Slither
[warning] 62-62: Conformance to Solidity naming conventions
Parameter ERC20Custody.setSupportsLegacy(bool)._supportsLegacy (src/evm/ERC20Custody.sol#62) is not in mixedCase
Focused to make minimal changes and difference between future version of contract. We need 2 new fields (zeta and zetaFee) which now can only be updated by admin (should this be changed to be called by tss address? or introduce new role for it?), and not added in constructor. I also didn't add maxZetaFee field to keep it minimal, but can be added if needed.
closes: #326
Summary by CodeRabbit
New Features
tssAddress
andsupportsLegacy
for enhanced contract management.Bug Fixes
deposit
function to enforce checks on legacy method support.Tests