Skip to content
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

refactor: port ZRC20 contract to v2 #281

Merged
merged 54 commits into from
Aug 5, 2024
Merged

refactor: port ZRC20 contract to v2 #281

merged 54 commits into from
Aug 5, 2024

Conversation

skosito
Copy link
Contributor

@skosito skosito commented Aug 1, 2024

closes: #279
#275 (this was already here because it is same for v1)

also adds unit tests for zrc20 in v2

Questions:

  • zrc20 v2 is the same as v1, except there is one more sender allowed in deposit - gatewayZEVM - should we remove remaining allowed senders on deposit methods?

  • zrc20 still uses system contract, but system contract has other functionalities, should we write another simpler version for system contract with only functionality thats needed by zrc20?

Summary by CodeRabbit

  • New Features

    • Introduced new functions, depositAndRevert and updated execute functions, enhancing contract capabilities.
    • Added the UpdatedGateway event for tracking changes to gateway addresses.
  • Improvements

    • Enhanced ABI structure for better clarity and usability, including renaming parameters for consistency.
    • Improved error handling capabilities within contracts.
  • Bug Fixes

    • Resolved ambiguities in function signatures to ensure clearer interactions.
  • Tests

    • Added a comprehensive test suite for the ZRC20 smart contract to validate functionality and error handling.

Copy link
Contributor

coderabbitai bot commented Aug 1, 2024

Walkthrough

The recent updates to the ZRC20 contract enhance its functionality by introducing a gateway address feature, enabling more effective deposit management. Key changes include adding the gatewayAddress field, renaming existing parameters for clarity, and introducing new functions for managing the gateway address. These modifications improve contract maintainability and align with future interoperability and security goals.

Changes

Files Change Summary
v2/pkg/gatewayzevm.sol/... Significant revisions to the GatewayZEVM contract, introducing new functions and modifying parameters, especially for deposit and execution functions.
v2/pkg/izrc20.sol/... Modifications to the IZRC20 ABI, changing PROTOCOL_FLAT_FEE to protocolFlatFee for consistency, along with updates to the metadata and event handling.
v2/pkg/zrc20.sol/... Updates to the ZRC20 contract with new gateway address management features, renaming parameters for clarity, and introducing the updateGatewayAddress function.
v2/test/... Tests updated to accommodate new event emissions and function calls following the ABI changes, ensuring comprehensive coverage of the new features.
v2/typechain-types/... TypeScript interfaces updated to reflect changes in the contract ABI, particularly for the protocolFlatFee function.

Assessment against linked issues

Objective Addressed Explanation
Add gatewayAddress as part of the ZRC20 contract
Introduce updateGatewayAddress callable by fungible address
Add gatewayAddress checks in deposit function Scope of checks isn't clearly defined.
Maintain existing field integrity during updates
Ensure clarity in naming conventions

Poem

In the meadow, a rabbit did play,
With gateway changes brightening the way.
"Hop, hop," said he, with a gleeful dance,
"New features abound, let's give them a chance!"
With binkies and hops, he celebrated the code,
In the world of smart contracts, the garden has glowed! 🐇✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 61.64%. Comparing base (9157fd7) to head (364c3ef).
Report is 1 commits behind head on main.

Files Patch % Lines
v2/src/zevm/ZRC20.sol 76.92% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #281      +/-   ##
==========================================
+ Coverage   58.10%   61.64%   +3.54%     
==========================================
  Files          16       16              
  Lines         401      425      +24     
  Branches       28       22       -6     
==========================================
+ Hits          233      262      +29     
+ Misses        165      160       -5     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

v2/test/ZRC20.t.sol Show resolved Hide resolved
Comment on lines 108 to 109
uint256 balanceStart = zrc20.balanceOf(addr1);
assertEq(0, balanceStart);
Copy link
Contributor

Choose a reason for hiding this comment

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

We can delete this two lines, addr1 is not sending/receiving tokens here.

v2/test/ZRC20.t.sol Show resolved Hide resolved
zrc20.withdraw(abi.encodePacked(addr1), 50_000);

uint256 fungibleModuleBalanceAfter = zrc20.balanceOf(fungibleModule);
assertEq(fungibleModuleBalanceStart + 20, fungibleModuleBalanceAfter);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: why this + 20? Shouldn't the protocol receive only 10?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uint256 gasFee = gasPrice * gasLimit + protocolFlatFee;

and i set gasLimit and protocolFlatFee to be 10 in test, and gasPrice is 1

Base automatically changed from v1-v2-split to main August 2, 2024 11:42
Copy link

gitguardian bot commented Aug 2, 2024

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
13159201 Triggered Alchemy API Key 72e1200 v2/lib/forge-std/src/StdChains.sol View secret
13159201 Triggered Alchemy API Key 8fafcbd v2/lib/forge-std/src/StdChains.sol View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (11)
v2/typechain-types/factories/IZRC20.sol/IZRC20Metadata__factory.ts (1)

148-160: Inconsistency detected in function name renaming.

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee has not been consistently applied across the codebase. Both the old and new function names are present in multiple files. Please ensure that the renaming is applied consistently throughout the codebase to avoid any potential issues.

  • Files with PROTOCOL_FLAT_FEE:

    • v1/pkg/contracts/zevm/zrc20.sol/zrc20.go
    • v1/typechain-types/contracts/zevm/interfaces/IZRC20.ts
    • v1/typechain-types/contracts/zevm/interfaces/IZRC20.sol/IZRC20.ts
    • v1/typechain-types/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata.ts
    • v1/typechain-types/contracts/zevm/ZRC20.sol/ZRC20.ts
    • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20__factory.ts
    • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata__factory.ts
    • v1/typechain-types/factories/contracts/zevm/ZRC20.sol/ZRC20__factory.ts
    • v1/typechain-types/factories/contracts/zevm/ZRC20New.sol/ZRC20New__factory.ts
    • v1/contracts/zevm/interfaces/IZRC20.sol
    • v1/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md
    • v1/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md
    • v1/contracts/zevm/ZRC20.sol
    • v2/typechain-types/factories/IZRC20.sol/IZRC20Metadata__factory.ts
  • Files with protocolFlatFee:

    • v2/typechain-types/factories/GatewayZEVM__factory.ts
    • v2/typechain-types/factories/ZRC20.sol/ZRC20__factory.ts
    • v2/typechain-types/factories/IZRC20.sol/ZRC20Events__factory.ts
    • v2/typechain-types/factories/IZRC20.sol/IZRC20__factory.ts
    • v2/typechain-types/factories/IZRC20.sol/IZRC20Metadata__factory.ts
    • v2/typechain-types/factories/IGatewayZEVM.sol/IGatewayZEVMEvents__factory.ts
    • v2/typechain-types/ZRC20.sol/ZRC20.ts
    • v2/typechain-types/IZRC20.sol/IZRC20Metadata.ts
    • v2/typechain-types/IGatewayZEVM.sol/IGatewayZEVMEvents.ts
    • v2/typechain-types/GatewayZEVM.ts
    • v2/typechain-types/IZRC20.sol/IZRC20.ts
    • v2/src/zevm/ZRC20.sol
    • v2/test/ZRC20.t.sol
    • v2/test/GatewayZEVM.t.sol
    • v2/test/GatewayEVMZEVM.t.sol
    • v2/scripts/localnet/worker.ts
    • v2/pkg/zrc20.sol/zrc20.go
    • v2/pkg/izrc20.sol/zrc20events.go
    • v2/pkg/izrc20.sol/izrc20.go
    • v2/pkg/izrc20.sol/izrc20metadata.go
    • v2/pkg/igatewayzevm.sol/igatewayzevmevents.go
    • v2/pkg/gatewayevmzevm.t.sol/gatewayevmzevmtest.go
    • v2/pkg/gatewayzevm.sol/gatewayzevm.go
    • v2/pkg/gatewayzevm.t.sol/gatewayzevminboundtest.go
    • v2/pkg/gatewayzevm.t.sol/gatewayzevmoutboundtest.go
    • v2/src/zevm/GatewayZEVM.sol
    • v2/src/zevm/interfaces/IGatewayZEVM.sol
    • v2/src/zevm/interfaces/IZRC20.sol
Analysis chain

Approve renaming for clarity. Verify consistency.

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee improves clarity and consistency. Ensure that this change is consistently applied across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg --type text 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg --type text 'protocolFlatFee'

Length of output: 125


Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg 'protocolFlatFee'

Length of output: 128069

v2/typechain-types/IZRC20.sol/IZRC20.ts (5)

32-34: Inconsistency Detected: Rename PROTOCOL_FLAT_FEE to protocolFlatFee Across Codebase

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee has not been consistently applied throughout the codebase. This inconsistency can lead to potential issues.

Please ensure the following files are updated:

  • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20__factory.ts
  • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20.sol/IZRC20__factory.ts
  • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata__factory.ts
  • v1/typechain-types/contracts/zevm/interfaces/IZRC20.ts
  • v1/typechain-types/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata.ts
  • v1/typechain-types/contracts/zevm/ZRC20.sol/ZRC20.ts
  • v1/contracts/zevm/ZRC20.sol
  • v1/contracts/zevm/interfaces/IZRC20.sol
  • v1/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md
  • v1/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md
  • v1/docs/src/contracts/zevm/Interfaces.sol/interface.IZRC20.md

Please review and apply the changes consistently.

Analysis chain

Approve renaming for clarity. Verify consistency.

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee in the getFunction method improves clarity and consistency. Ensure that this change is consistently applied across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg --type text 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg --type text 'protocolFlatFee'

Length of output: 125


Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg 'protocolFlatFee'

Length of output: 128069


57-60: Inconsistent renaming of PROTOCOL_FLAT_FEE to protocolFlatFee

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee is not consistently applied across the codebase. The old name PROTOCOL_FLAT_FEE is still present in several files. Please ensure that the renaming is uniformly applied throughout the codebase.

Locations with PROTOCOL_FLAT_FEE:

  • v1/typechain-types/contracts/zevm/interfaces/IZRC20.ts
  • v1/typechain-types/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata.ts
  • v1/typechain-types/contracts/zevm/ZRC20.sol/ZRC20.ts
  • v1/typechain-types/contracts/zevm/interfaces/IZRC20.sol/IZRC20.ts
  • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20__factory.ts
  • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata__factory.ts
  • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20.sol/IZRC20__factory.ts
  • v1/typechain-types/factories/contracts/zevm/ZRC20New.sol/ZRC20New__factory.ts
  • v1/typechain-types/factories/contracts/zevm/ZRC20.sol/ZRC20__factory.ts
  • v1/pkg/contracts/zevm/zrc20.sol/zrc20.go
  • v1/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md
  • v1/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md
  • v1/contracts/zevm/ZRC20.sol
  • v1/pkg/contracts/zevm/interfaces/izrc20.sol/izrc20metadata.go
  • v1/pkg/contracts/zevm/interfaces/izrc20.sol/izrc20.go
  • v1/contracts/zevm/interfaces/IZRC20.sol
  • v1/docs/src/contracts/zevm/Interfaces.sol/interface.IZRC20.md

Please update these occurrences to maintain consistency.

Analysis chain

Approve renaming for clarity. Verify consistency.

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee in the encodeFunctionData method improves clarity and consistency. Ensure that this change is consistently applied across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg --type text 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg --type text 'protocolFlatFee'

Length of output: 125


Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg 'protocolFlatFee'

Length of output: 128069


87-90: Inconsistency found in function name change.

The function name PROTOCOL_FLAT_FEE has not been consistently renamed to protocolFlatFee across the codebase. Please update all occurrences of PROTOCOL_FLAT_FEE to protocolFlatFee to ensure consistency.

  • Files with old function name PROTOCOL_FLAT_FEE:

    • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20__factory.ts
    • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20.sol/IZRC20__factory.ts
    • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata__factory.ts
    • v1/typechain-types/factories/contracts/zevm/ZRC20New.sol/ZRC20New__factory.ts
    • v1/typechain-types/factories/contracts/zevm/ZRC20.sol/ZRC20__factory.ts
    • v1/typechain-types/contracts/zevm/interfaces/IZRC20.ts
    • v1/typechain-types/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata.ts
    • v1/typechain-types/contracts/zevm/ZRC20.sol/ZRC20.ts
    • v1/typechain-types/contracts/zevm/interfaces/IZRC20.sol/IZRC20.ts
    • v1/pkg/contracts/zevm/zrc20.sol/zrc20.go
    • v1/pkg/contracts/zevm/interfaces/izrc20.sol/izrc20.go
    • v1/pkg/contracts/zevm/interfaces/izrc20.sol/izrc20metadata.go
    • v1/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md
    • v1/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md
  • Files with new function name protocolFlatFee:

    • v2/typechain-types/factories/GatewayZEVM__factory.ts
    • v2/typechain-types/factories/ZRC20.sol/ZRC20__factory.ts
    • v2/typechain-types/factories/IZRC20.sol/ZRC20Events__factory.ts
    • v2/typechain-types/factories/IZRC20.sol/IZRC20__factory.ts
    • v2/typechain-types/factories/IZRC20.sol/IZRC20Metadata__factory.ts
    • v2/typechain-types/factories/IGatewayZEVM.sol/IGatewayZEVMEvents__factory.ts
    • v2/typechain-types/ZRC20.sol/ZRC20.ts
    • v2/typechain-types/IZRC20.sol/ZRC20Events.ts
    • v2/typechain-types/IZRC20.sol/IZRC20Metadata.ts
    • v2/typechain-types/IZRC20.sol/IZRC20.ts
    • v2/typechain-types/IGatewayZEVM.sol/IGatewayZEVMEvents.ts
    • v2/typechain-types/GatewayZEVM.ts
    • v2/scripts/localnet/worker.ts
    • v2/src/zevm/GatewayZEVM.sol
    • v2/src/zevm/ZRC20.sol
    • v2/src/zevm/interfaces/IZRC20.sol
    • v2/src/zevm/interfaces/IGatewayZEVM.sol
    • v2/test/ZRC20.t.sol
    • v2/test/GatewayZEVM.t.sol
    • v2/pkg/zrc20.sol/zrc20.go
    • v2/pkg/izrc20.sol/izrc20metadata.go
    • v2/pkg/izrc20.sol/zrc20events.go
    • v2/pkg/izrc20.sol/izrc20.go
    • v2/pkg/igatewayzevm.sol/igatewayzevmevents.go
    • v2/pkg/gatewayzevm.sol/gatewayzevm.go
    • v2/pkg/gatewayevmzevm.t.sol/gatewayevmzevmtest.go
    • v2/test/GatewayEVMZEVM.t.sol
Analysis chain

Approve renaming for clarity. Verify consistency.

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee in the decodeFunctionResult method improves clarity and consistency. Ensure that this change is consistently applied across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg --type text 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg --type text 'protocolFlatFee'

Length of output: 125


Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg 'protocolFlatFee'

Length of output: 128069


227-229: Update all occurrences of PROTOCOL_FLAT_FEE to protocolFlatFee for consistency.

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee has not been consistently applied across the codebase. Please ensure that all instances of PROTOCOL_FLAT_FEE are updated to protocolFlatFee in the following files:

  • v1/typechain-types/contracts/zevm/ZRC20.sol/ZRC20.ts
  • v1/typechain-types/contracts/zevm/interfaces/IZRC20.ts
  • v1/typechain-types/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata.ts
  • v1/typechain-types/factories/contracts/zevm/ZRC20New.sol/ZRC20New__factory.ts
  • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20__factory.ts
  • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata__factory.ts
  • v1/pkg/contracts/zevm/zrc20.sol/zrc20.go
  • v1/pkg/contracts/zevm/interfaces/izrc20.sol/izrc20.go
  • v1/pkg/contracts/zevm/interfaces/izrc20.sol/izrc20metadata.go
  • v1/contracts/zevm/interfaces/IZRC20.sol
  • v1/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md
  • v1/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md
  • v1/contracts/zevm/ZRC20.sol
  • v2/typechain-types/ZRC20.sol/ZRC20.ts
  • v2/typechain-types/factories/GatewayZEVM__factory.ts
  • v2/typechain-types/factories/ZRC20.sol/ZRC20__factory.ts
  • v2/typechain-types/factories/IZRC20.sol/ZRC20Events__factory.ts
  • v2/typechain-types/factories/IZRC20.sol/IZRC20__factory.ts
  • v2/typechain-types/factories/IZRC20.sol/IZRC20Metadata__factory.ts
  • v2/typechain-types/factories/IGatewayZEVM.sol/IGatewayZEVMEvents__factory.ts
  • v2/typechain-types/IZRC20.sol/IZRC20Metadata.ts
  • v2/typechain-types/IZRC20.sol/ZRC20Events.ts
  • v2/typechain-types/IZRC20.sol/IZRC20.ts
  • v2/typechain-types/IGatewayZEVM.sol/IGatewayZEVMEvents.ts
  • v2/typechain-types/GatewayZEVM.ts
  • v2/src/zevm/ZRC20.sol
  • v2/src/zevm/GatewayZEVM.sol
  • v2/src/zevm/interfaces/IZRC20.sol
  • v2/src/zevm/interfaces/IGatewayZEVM.sol
  • v2/scripts/localnet/worker.ts
  • v2/test/ZRC20.t.sol
  • v2/test/GatewayEVMZEVM.t.sol
  • v2/test/GatewayZEVM.t.sol
  • v2/pkg/zrc20.sol/zrc20.go
  • v2/pkg/izrc20.sol/izrc20metadata.go
  • v2/pkg/izrc20.sol/izrc20.go
  • v2/pkg/igatewayzevm.sol/igatewayzevmevents.go
  • v2/pkg/izrc20.sol/zrc20events.go
  • v2/pkg/gatewayzevm.t.sol/gatewayzevmoutboundtest.go
  • v2/pkg/gatewayzevm.t.sol/gatewayzevminboundtest.go
  • v2/pkg/gatewayevmzevm.t.sol/gatewayevmzevmtest.go
  • v2/pkg/gatewayzevm.sol/gatewayzevm.go
Analysis chain

Approve renaming for clarity. Verify consistency.

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee in the getFunction method improves clarity and consistency. Ensure that this change is consistently applied across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg --type text 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg --type text 'protocolFlatFee'

Length of output: 125


Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg 'protocolFlatFee'

Length of output: 128069


172-173: Inconsistency Detected: Rename PROTOCOL_FLAT_FEE to protocolFlatFee Across the Codebase

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee has not been consistently applied. Multiple instances of the old function name still exist. Please ensure that all occurrences of PROTOCOL_FLAT_FEE are updated to protocolFlatFee to maintain consistency.

  • Files with PROTOCOL_FLAT_FEE:

    • v1/typechain-types/factories/contracts/zevm/ZRC20.sol/ZRC20__factory.ts
    • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata__factory.ts
    • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20.sol/IZRC20__factory.ts
    • v1/typechain-types/factories/contracts/zevm/interfaces/IZRC20__factory.ts
    • v1/typechain-types/contracts/zevm/interfaces/IZRC20.ts
    • v1/typechain-types/contracts/zevm/interfaces/IZRC20.sol/IZRC20.ts
    • v1/typechain-types/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata.ts
    • v1/typechain-types/contracts/zevm/ZRC20.sol/ZRC20.ts
    • v1/pkg/contracts/zevm/zrc20.sol/zrc20.go
    • v1/pkg/contracts/zevm/interfaces/izrc20.sol/izrc20metadata.go
    • v1/pkg/contracts/zevm/interfaces/izrc20.sol/izrc20.go
    • v1/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md
    • v1/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md
    • v1/contracts/zevm/ZRC20.sol
    • v1/contracts/zevm/interfaces/IZRC20.sol
  • Files with protocolFlatFee:

    • v2/typechain-types/ZRC20.sol/ZRC20.ts
    • v2/typechain-types/factories/GatewayZEVM__factory.ts
    • v2/typechain-types/factories/ZRC20.sol/ZRC20__factory.ts
    • v2/typechain-types/factories/IZRC20.sol/ZRC20Events__factory.ts
    • v2/typechain-types/factories/IZRC20.sol/IZRC20Metadata__factory.ts
    • v2/typechain-types/factories/IZRC20.sol/IZRC20__factory.ts
    • v2/typechain-types/factories/IGatewayZEVM.sol/IGatewayZEVMEvents__factory.ts
    • v2/typechain-types/IZRC20.sol/IZRC20Metadata.ts
    • v2/typechain-types/IZRC20.sol/IZRC20.ts
    • v2/typechain-types/IGatewayZEVM.sol/IGatewayZEVMEvents.ts
    • v2/typechain-types/GatewayZEVM.ts
    • v2/test/ZRC20.t.sol
    • v2/test/GatewayZEVM.t.sol
    • v2/test/GatewayEVMZEVM.t.sol
    • v2/typechain-types/IZRC20.sol/ZRC20Events.ts
    • v2/pkg/zrc20.sol/zrc20.go
    • v2/pkg/izrc20.sol/izrc20metadata.go
    • v2/pkg/izrc20.sol/izrc20.go
    • v2/pkg/izrc20.sol/zrc20events.go
    • v2/pkg/igatewayzevm.sol/igatewayzevmevents.go
    • v2/pkg/gatewayzevm.t.sol/gatewayzevminboundtest.go
    • v2/pkg/gatewayzevm.t.sol/gatewayzevmoutboundtest.go
    • v2/scripts/localnet/worker.ts
    • v2/src/zevm/ZRC20.sol
    • v2/src/zevm/GatewayZEVM.sol
    • v2/src/zevm/interfaces/IZRC20.sol
    • v2/src/zevm/interfaces/IGatewayZEVM.sol
Analysis chain

Approve renaming for clarity. Verify consistency.

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee in the IZRC20 interface improves clarity and consistency. Ensure that this change is consistently applied across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg --type text 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg --type text 'protocolFlatFee'

Length of output: 125


Script:

#!/bin/bash
# Description: Verify consistency of the function name change across the codebase.

# Test: Search for the old function name. Expect: No occurrences.
rg 'PROTOCOL_FLAT_FEE'

# Test: Search for the new function name. Expect: Multiple occurrences.
rg 'protocolFlatFee'

Length of output: 128069

v2/pkg/izrc20.sol/izrc20metadata.go (1)

310-322: Incomplete renaming of function PROTOCOLFLATFEE to ProtocolFlatFee.

The function PROTOCOLFLATFEE has been renamed to ProtocolFlatFee in some instances, but the old name still exists in multiple files. Please update all references to PROTOCOLFLATFEE to ProtocolFlatFee in the following files:

  • v1/pkg/contracts/zevm/zrc20.sol/zrc20.go
  • v1/pkg/contracts/zevm/interfaces/izrc20.sol/izrc20metadata.go
  • v1/pkg/contracts/zevm/interfaces/izrc20.sol/izrc20.go
Analysis chain

Verify the function name change across the codebase.

The function PROTOCOLFLATFEE has been renamed to ProtocolFlatFee. Ensure that all references to this function are updated accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to the renamed function `ProtocolFlatFee`.

# Test: Search for the old function name. Expect: No occurrences of the old name.
rg --type go 'PROTOCOLFLATFEE'

# Test: Search for the new function name. Expect: Only occurrences of the new name.
rg --type go 'ProtocolFlatFee'

Length of output: 59986

v2/pkg/systemcontractmock.sol/systemcontractmock.go (1)

Inconsistency with ABI changes detected

The SystemContractMockTransactor struct is missing the TransactOpts field, which is crucial for ABI consistency.

  • File: v2/pkg/systemcontractmock.sol/systemcontractmock.go
  • Lines: 76-78
  • Current Definition:
    type SystemContractMockTransactor struct {
      contract *bind.BoundContract // Generic contract wrapper for the low level calls
    }

Please update the struct to include the TransactOpts field to ensure consistency with the ABI changes.

Analysis chain

Line range hint 88-90:
Ensure consistency with ABI changes.

The SystemContractMockTransactor struct is correctly defined. Verify that it is consistent with the ABI changes.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `SystemContractMockTransactor` struct is consistent with the ABI changes.

# Test: Check for consistency between the struct definition and the ABI.
ast-grep --lang go --pattern $'type SystemContractMockTransactor struct {
  contract *bind.BoundContract
}' | grep -E 'contract|Transact'

Length of output: 138


Script:

#!/bin/bash
# Description: Verify that the `SystemContractMockTransactor` struct is consistent with the ABI changes.

# Test: Check for the definition of the `SystemContractMockTransactor` struct and display its content.
ast-grep --lang go --pattern $'type SystemContractMockTransactor struct {
  contract *bind.BoundContract
  TransactOpts bind.TransactOpts
}'

Length of output: 141


Script:

#!/bin/bash
# Description: Search for all struct definitions in the `v2/pkg/systemcontractmock.sol/systemcontractmock.go` file and display their content.

# Test: List all struct definitions in the specified file.
ast-grep --lang go --pattern $'type $_ struct {
  $$$
}' v2/pkg/systemcontractmock.sol/systemcontractmock.go

Length of output: 11991

v2/pkg/zrc20.sol/zrc20.go (2)

391-399: The renaming from GASLIMIT to GasLimit is not consistent.

The following instances of GASLIMIT still exist in the codebase and need to be updated:

  • v1/pkg/contracts/zevm/zrc20.sol/zrc20.go:func (_ZRC20 *ZRC20Caller) GASLIMIT(opts *bind.CallOpts) (*big.Int, error)
  • v1/pkg/contracts/zevm/zrc20.sol/zrc20.go:func (_ZRC20 *ZRC20Session) GASLIMIT() (*big.Int, error)
  • v1/pkg/contracts/zevm/zrc20.sol/zrc20.go:func (_ZRC20 *ZRC20CallerSession) GASLIMIT() (*big.Int, error)

Please ensure that all instances of GASLIMIT are renamed to GasLimit for consistency.

Analysis chain

Verify the consistency of the renaming from GASLIMIT to GasLimit.

Ensure that all instances where GASLIMIT was used have been updated to GasLimit.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all instances of `GASLIMIT` have been renamed to `GasLimit`.

# Test: Search for the old function name. Expect: No occurrences of `GASLIMIT`.
rg --type go $'GASLIMIT'

Length of output: 900


Script:

#!/bin/bash
# Description: Verify if the function `GasLimit` exists in the same file where `GASLIMIT` was found.

# Test: Search for the new function name. Expect: Occurrences of `GasLimit`.
rg --type go $'GasLimit' v1/pkg/contracts/zevm/zrc20.sol/zrc20.go

Length of output: 11393


747-749: Incomplete renaming of UpdateGasLimit to UpdateGasLimit.

The function name UpdateGasLimit is still present in the codebase. Please ensure all occurrences are updated to UpdateGasLimit.

  • v2/pkg/zrc20.sol/zrc20.go

    • Line 747: func (_ZRC20 *ZRC20Transactor) UpdateGasLimit(opts *bind.TransactOpts, gasLimit_ *big.Int) (*types.Transaction, error)
    • Line 749: return _ZRC20.contract.Transact(opts, "updateGasLimit", gasLimit_)
    • Line 751: func (_ZRC20 *ZRC20Session) UpdateGasLimit(gasLimit_ *big.Int) (*types.Transaction, error)
    • Line 753: return _ZRC20.Contract.UpdateGasLimit(&_ZRC20.TransactOpts, gasLimit_)
    • Line 755: func (_ZRC20 *ZRC20TransactorSession) UpdateGasLimit(gasLimit_ *big.Int) (*types.Transaction, error)
    • Line 757: return _ZRC20.Contract.UpdateGasLimit(&_ZRC20.TransactOpts, gasLimit_)
  • v2/pkg/zrc20.t.sol/zrc20test.go

    • Line 759: func (_ZRC20Test *ZRC20TestTransactor) TestUpdateGasLimit(opts *bind.TransactOpts) (*types.Transaction, error)
    • Line 761: return _ZRC20Test.contract.Transact(opts, "testUpdateGasLimit")
    • Line 763: func (_ZRC20Test *ZRC20TestSession) TestUpdateGasLimit() (*types.Transaction, error)
    • Line 765: return _ZRC20Test.Contract.TestUpdateGasLimit(&_ZRC20Test.TransactOpts)
    • Line 767: func (_ZRC20Test *ZRC20TestTransactorSession) TestUpdateGasLimit() (*types.Transaction, error)
    • Line 769: return _ZRC20Test.Contract.TestUpdateGasLimit(&_ZRC20Test.TransactOpts)
  • v1/pkg/contracts/zevm/zrc20.sol/zrc20.go

    • Line 771: func (_ZRC20 *ZRC20Transactor) UpdateGasLimit(opts *bind.TransactOpts, gasLimit *big.Int) (*types.Transaction, error)
    • Line 773: return _ZRC20.Contract.UpdateGasLimit(&_ZRC20.TransactOpts, gasLimit)
    • Line 775: func (_ZRC20 *ZRC20Session) UpdateGasLimit(gasLimit *big.Int) (*types.Transaction, error)
    • Line 777: return _ZRC20.Contract.UpdateGasLimit(&_ZRC20.TransactOpts, gasLimit)
    • Line 779: func (_ZRC20 *ZRC20TransactorSession) UpdateGasLimit(gasLimit *big.Int) (*types.Transaction, error)
    • Line 781: return _ZRC20.Contract.UpdateGasLimit(&_ZRC20.TransactOpts, gasLimit)
Analysis chain

Verify the consistency of the renaming from UpdateGasLimit to UpdateGasLimit.

Ensure that all instances where UpdateGasLimit was used have been updated to UpdateGasLimit.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all instances of `UpdateGasLimit` have been renamed to `UpdateGasLimit`.

# Test: Search for the old function name. Expect: No occurrences of `UpdateGasLimit`.
rg --type go $'UpdateGasLimit'

Length of output: 16408

v2/pkg/gatewayzevm.sol/gatewayzevm.go (1)

Line range hint 15-18:
Avoid function signature ambiguity.

The depositAndCall function is defined twice with different parameter orders. This can lead to ambiguity in function calls and potential issues.

Consider renaming one of the functions to clearly differentiate their purposes and avoid ambiguity.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8c5c55c and ca92f50.

Files selected for processing (26)
  • v2/pkg/gatewayzevm.sol/gatewayzevm.go (1 hunks)
  • v2/pkg/izrc20.sol/izrc20.go (3 hunks)
  • v2/pkg/izrc20.sol/izrc20metadata.go (3 hunks)
  • v2/pkg/izrc20.sol/zrc20events.go (2 hunks)
  • v2/pkg/senderzevm.sol/senderzevm.go (1 hunks)
  • v2/pkg/systemcontract.sol/systemcontract.go (1 hunks)
  • v2/pkg/systemcontractmock.sol/systemcontractmock.go (1 hunks)
  • v2/pkg/zrc20.sol/zrc20.go (8 hunks)
  • v2/src/zevm/GatewayZEVM.sol (2 hunks)
  • v2/src/zevm/ZRC20.sol (6 hunks)
  • v2/src/zevm/interfaces/IZRC20.sol (2 hunks)
  • v2/test/GatewayEVMZEVM.t.sol (2 hunks)
  • v2/test/GatewayZEVM.t.sol (3 hunks)
  • v2/test/ZRC20.t.sol (1 hunks)
  • v2/typechain-types/IZRC20.sol/IZRC20.ts (7 hunks)
  • v2/typechain-types/IZRC20.sol/IZRC20Metadata.ts (8 hunks)
  • v2/typechain-types/IZRC20.sol/ZRC20Events.ts (4 hunks)
  • v2/typechain-types/ZRC20.sol/ZRC20.ts (16 hunks)
  • v2/typechain-types/factories/GatewayZEVM__factory.ts (1 hunks)
  • v2/typechain-types/factories/IZRC20.sol/IZRC20Metadata__factory.ts (2 hunks)
  • v2/typechain-types/factories/IZRC20.sol/IZRC20__factory.ts (2 hunks)
  • v2/typechain-types/factories/IZRC20.sol/ZRC20Events__factory.ts (1 hunks)
  • v2/typechain-types/factories/SenderZEVM__factory.ts (1 hunks)
  • v2/typechain-types/factories/SystemContract.sol/SystemContract__factory.ts (1 hunks)
  • v2/typechain-types/factories/SystemContractMock.sol/SystemContractMock__factory.ts (1 hunks)
  • v2/typechain-types/factories/ZRC20.sol/ZRC20__factory.ts (12 hunks)
Additional context used
Biome
v2/typechain-types/ZRC20.sol/ZRC20.ts

[error] 433-433: void is confusing outside a return type or a type parameter.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)


[error] 439-439: void is confusing outside a return type or a type parameter.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)


[error] 543-543: void is confusing outside a return type or a type parameter.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)


[error] 546-546: void is confusing outside a return type or a type parameter.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)


[error] 551-551: void is confusing outside a return type or a type parameter.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)

Additional comments not posted (105)
v2/src/zevm/interfaces/IZRC20.sol (2)

27-27: Renamed function aligns with naming conventions.

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee improves code readability and consistency with Solidity naming conventions.


48-48: New event enhances event-driven architecture.

The addition of the UpdatedGateway event improves the contract's ability to notify interested parties about changes in the gateway address.

v2/typechain-types/factories/IZRC20.sol/ZRC20Events__factory.ts (1)

100-112: New event added to ABI.

The addition of the UpdatedGateway event to the ABI enhances the contract's event handling capabilities and aligns with the changes in the ZRC20Events interface.

v2/typechain-types/factories/IZRC20.sol/IZRC20__factory.ts (1)

119-131: Renamed function aligns with naming conventions.

The renaming of PROTOCOL_FLAT_FEE to protocolFlatFee improves code readability and consistency with Solidity naming conventions.

v2/typechain-types/factories/SenderZEVM__factory.ts (1)

123-123: Approve bytecode update. Verify correctness.

The update to the _bytecode constant likely reflects an update to the underlying bytecode representation. Ensure that this update is correct and does not introduce any issues.

Verification successful

Bytecode update verified and approved.

The update to the _bytecode constant in SenderZEVM__factory.ts has been verified and matches the expected bytecode. No issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the new bytecode.

# Test: Compare the new bytecode with the expected bytecode. Expect: Match.
expected_bytecode="0x6080604052348015600f57600080fd5b5060405161080c38038061080c833981016040819052602c916050565b600080546001600160a01b0319166001600160a01b0392909216919091179055607e565b600060208284031215606157600080fd5b81516001600160a01b0381168114607757600080fd5b9392505050565b61077f8061008d6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80630abd890514610046578063116191b61461005b578063865b36f6146100a4575b600080fd5b6100596100543660046104c4565b6100b7565b005b60005461007b9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6100596100b236600461057f565b6102af565b60008383836040516024016100ce93929190610674565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fe04d4f970000000000000000000000000000000000000000000000000000000017905260005490517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526024810189905291925086169063095ea7b3906044016020604051808303816000875af11580156101be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101e2919061069e565b610218576040517f8164f84200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000546040517f7993c1e000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690637993c1e090610274908a908a908a9087906004016106c2565b600060405180830381600087803b15801561028e57600080fd5b505af11580156102a2573d6000803e3d6000fd5b5050505050505050505050565b60008383836040516024016102c693929190610674565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fe04d4f970000000000000000000000000000000000000000000000000000000017905260005490517f5d40e17800000000000000000000000000000000000000000000000000000000815291925073ffffffffffffffffffffffffffffffffffffffff1690635d40e1789061039690899089908690600401610714565b600060405180830381600087803b1580156103b057600080fd5b505af11580156103c4573d6000803e3d6000fd5b50505050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261041057600080fd5b81356020830160008067ffffffffffffffff841115610431576104316103d0565b506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f85018116603f0116810181811067ffffffffffffffff8211171561047e5761047e6103d0565b60405283815290508082840187101561049657600080fd5b838360208301376000602085830101528094505050505092915050565b80151581146104c157600080fd5b50565b60008060008060008060c087890312156104dd57600080fd5b863567ffffffffffffffff8111156104f457600080fd5b61050089828a016103ff565b96505060208701359450604087013573ffffffffffffffffffffffffffffffffffffffff8116811461053157600080fd5b9350606087013567ffffffffffffffff81111561054d57600080fd5b61055989828a016103ff565b9350506080870135915060a0870135610571816104b3565b809150509295509295509295565b600080600080600060a0868803121561059757600080fd5b853567ffffffffffffffff8111156105ae57600080fd5b6105ba888289016103ff565b95505060208601359350604086013567ffffffffffffffff8111156105de57600080fd5b6105ea888289016103ff565b935050606086013591506080860135610602816104b3565b809150509295509295909350565b6000815180845260005b818110156106365760208185018101518683018201520161061a565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6060815260006106876060830186610610565b602083019490945250901515604090910152919050565b6000602082840312156106b057600080fd5b81516106bb816104b3565b9392505050565b6080815260006106d56080830187610610565b85602084015273ffffffffffffffffffffffffffffffffffffffff8516604084015282810360608401526107098185610610565b979650505050505050565b6060815260006107276060830186610610565b846020840152828103604084015261073f8185610610565b969550505050505056fea264697066735822122011f5a132ec30e33aab727a8c0099e5989394033720d9fda5b9669b838309363564736f6c634300081a0033"

echo "$expected_bytecode"

Length of output: 12395

v2/typechain-types/IZRC20.sol/IZRC20Metadata.ts (5)

34-34: Ensure consistency in naming conventions.

The function name protocolFlatFee has been updated from PROTOCOL_FLAT_FEE. This change promotes consistency and clarity in the API.


62-65: Update function encoding for protocolFlatFee.

The encodeFunctionData method now references protocolFlatFee. This ensures that the function encoding aligns with the new naming convention.


95-98: Update function decoding for protocolFlatFee.

The decodeFunctionResult method now references protocolFlatFee. This ensures that the function decoding aligns with the new naming convention.


185-185: Update TypedContractMethod for protocolFlatFee.

The TypedContractMethod for protocolFlatFee has been updated to reflect the new naming convention. This change ensures that the method is correctly typed and accessible.


248-250: Update getFunction method for protocolFlatFee.

The getFunction method now references protocolFlatFee. This ensures that the function retrieval aligns with the new naming convention.

v2/test/GatewayEVMZEVM.t.sol (2)

170-170: Update function call for protocolFlatFee.

The emit Withdrawal function call now references protocolFlatFee instead of PROTOCOL_FLAT_FEE. This change ensures that the function call aligns with the new naming convention.


17-19: Update import statements for ZRC20.sol.

The import statement for ZRC20.sol has been updated to a source path. Ensure that this change aligns with the project's directory structure and dependency management.

Verification successful

The import statement for ZRC20.sol is correct.

The import path src/zevm/ZRC20.sol in the v2/test/GatewayEVMZEVM.t.sol file aligns with the directory structure of the project.

  • import "src/zevm/ZRC20.sol";
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the new import path for `ZRC20.sol`.

# Test: Search for the `ZRC20.sol` file in the new path. Expect: The file should exist in the specified path.
fd --type f 'ZRC20.sol' --exec echo "File found at: {}"

Length of output: 247


Script:

#!/bin/bash
# Description: Verify the import statements in the `v2/test/GatewayEVMZEVM.t.sol` file.

# Search for import statements in the specified file.
rg 'import' v2/test/GatewayEVMZEVM.t.sol -A 1

Length of output: 747

v2/test/ZRC20.t.sol (23)

1-50: Setup function looks good.

The setup function initializes the necessary contracts and addresses for the tests. Ensure that all initializations are correct and complete.


52-64: Basic info test looks good.

The testZRC20BasicInfo function verifies the basic information of the ZRC20 contract. The assertions are correct and complete.


66-76: Transfer from test looks good.

The testTransferFrom function verifies the transfer functionality of the ZRC20 contract. The assertions are correct and complete.


78-85: Transfer from fails if no allowance test looks good.

The testTransferFromFailsIfNoAllowance function verifies that the transfer fails if there is no allowance. The assertions are correct and complete.


87-95: Transfer from fails if no balance test looks good.

The testTransferFromFailsIfNoBalance function verifies that the transfer fails if there is no balance. The assertions are correct and complete.


97-105: Transfer from fails if sender is zero address test looks good.

The testTransferFromFailsIfSenderIsZeroAddress function verifies that the transfer fails if the sender address is zero. The assertions are correct and complete.


107-112: Transfer from fails if recipient is zero address test looks good.

The testTransferFromFailsIfRecipientIsZeroAddress function verifies that the transfer fails if the recipient address is zero. The assertions are correct and complete.


114-125: Burn test looks good.

The testBurn function verifies the burn functionality of the ZRC20 contract. The assertions are correct and complete.


127-130: Burn fails if no balance test looks good.

The testBurnFailsIfNoBalance function verifies that the burn fails if there is no balance. The assertions are correct and complete.


132-141: Deposit test looks good.

The testDeposit function verifies the deposit functionality of the ZRC20 contract. The assertions are correct and complete.


143-153: Withdraw gas fee test looks good.

The testWithdrawGasFee function verifies the gas fee withdrawal functionality of the ZRC20 contract. The assertions are correct and complete.


155-161: Withdraw gas fee fails if gas coin not set test looks good.

The testWithdrawGasFeeFailsIfGasCoinNotSetForChainId function verifies that the gas fee withdrawal fails if the gas coin is not set. The assertions are correct and complete.


163-169: Withdraw gas fee fails if gas price not set test looks good.

The testWithdrawGasFeeFailsIfGasPriceNotSetForChainId function verifies that the gas fee withdrawal fails if the gas price is not set. The assertions are correct and complete.


171-195: Withdraw test looks good.

The testWithdraw function verifies the withdrawal functionality of the ZRC20 contract. The assertions are correct and complete.


197-200: Deposit fails if sender is not gateway test looks good.

The testDepositFailsIfSenderIsNotGateway function verifies that the deposit fails if the sender is not the gateway. The assertions are correct and complete.


202-206: Update system contract address test looks good.

The testUpdateSystemContractAddress function verifies the update of the system contract address. The assertions are correct and complete.


208-211: Update system contract address fails if sender is not fungible test looks good.

The testUpdateSystemContractAddressFailsIfSenderIsNotFungible function verifies that the update fails if the sender is not fungible. The assertions are correct and complete.


213-217: Update gateway address test looks good.

The testUpdateGatewayAddress function verifies the update of the gateway address. The assertions are correct and complete.


219-222: Update gateway address fails if sender is not fungible test looks good.

The testUpdateGatewayAddressFailsIfSenderIsNotFungible function verifies that the update fails if the sender is not fungible. The assertions are correct and complete.


224-228: Update gas limit test looks good.

The testUpdateGasLimit function verifies the update of the gas limit. The assertions are correct and complete.


230-233: Update gas limit fails if sender is not fungible test looks good.

The testUpdateGasLimitFailsIfSenderIsNotFungible function verifies that the update fails if the sender is not fungible. The assertions are correct and complete.


235-239: Update protocol flat fee test looks good.

The testUpdateProtocolFlatFee function verifies the update of the protocol flat fee. The assertions are correct and complete.


241-244: Update protocol flat fee fails if sender is not fungible test looks good.

The testUpdateProtocolFlatFeeFailsIfSenderIsNotFungible function verifies that the update fails if the sender is not fungible. The assertions are correct and complete.

v2/src/zevm/ZRC20.sol (9)

32-38: Approved: Renaming public state variables for readability.

The renaming of public state variables to follow camelCase convention improves readability and adheres to best practices.


74-84: Approved: Constructor updates for renamed variables.

The constructor has been updated to use the new variable names, ensuring correct assignment of values.


235-237: Approved: Update to deposit function for gateway address check.

The deposit function now correctly checks the gatewayAddress variable, ensuring proper authorization.


248-255: Approved: Update to withdrawGasFee function for renamed variables.

The withdrawGasFee function now correctly uses the renamed systemContractAddress, gasLimit, and protocolFlatFee variables.


273-273: Approved: Update to withdraw function for renamed variable.

The withdraw function now correctly uses the renamed protocolFlatFee variable.


282-282: Approved: Update to updateSystemContractAddress function for renamed variable.

The updateSystemContractAddress function now correctly uses the renamed systemContractAddress variable.


286-293: Approved: New updateGatewayAddress function.

The new updateGatewayAddress function allows updating the gatewayAddress variable, following the pattern of other update functions.


299-300: Approved: Update to updateGasLimit function for renamed variable.

The updateGasLimit function now correctly uses the renamed gasLimit variable.


308-309: Approved: Update to updateProtocolFlatFee function for renamed variable.

The updateProtocolFlatFee function now correctly uses the renamed protocolFlatFee variable.

v2/typechain-types/IZRC20.sol/ZRC20Events.ts (5)

31-31: Approved: Inclusion of UpdatedGateway event in ZRC20EventsInterface.

The ZRC20EventsInterface now includes the UpdatedGateway event, ensuring it is part of the interface.


104-114: Approved: Addition of UpdatedGatewayEvent namespace.

The UpdatedGatewayEvent namespace defines types for the new event, ensuring it is well-defined and type-safe.


243-249: Approved: Update to getEvent method for UpdatedGateway event.

The getEvent method now includes a case for retrieving the UpdatedGateway event, ensuring it can be accessed similarly to existing events.


317-326: Approved: Addition of UpdatedGateway event signature.

The event signature for UpdatedGateway has been added, ensuring it is included in the list of event signatures.


327-327: Approved: Addition of UpdatedGateway event filter.

The event filter for UpdatedGateway has been added, ensuring it can be filtered and listened for.

v2/src/zevm/GatewayZEVM.sol (2)

121-121: Approved: Update to withdraw function to use protocolFlatFee function.

The withdraw function now uses the protocolFlatFee function instead of a constant, allowing for dynamic access to the fee.


140-140: Approved: Update to withdrawAndCall function to use protocolFlatFee function.

The withdrawAndCall function now uses the protocolFlatFee function instead of a constant, allowing for dynamic access to the fee.

v2/typechain-types/factories/SystemContractMock.sol/SystemContractMock__factory.ts (1)

345-345: Verify the correctness of the new bytecode.

The bytecode has been completely replaced. Ensure that the new bytecode functions as intended and does not introduce any unintended consequences.

v2/typechain-types/ZRC20.sol/ZRC20.ts (9)

38-43: Confirm the addition of new function fragments.

The new function fragments gasLimit, gatewayAddress, protocolFlatFee, and systemContractAddress are correctly added and follow the naming conventions.


48-48: Confirm the addition of updateGatewayAddress function fragment.

The new function fragment updateGatewayAddress is correctly added and follows the naming conventions.


61-61: Confirm the addition of UpdatedGateway event fragment.

The new event fragment UpdatedGateway is correctly added and follows the naming conventions.


91-105: Confirm the addition of new function fragments to encodeFunctionData.

The new function fragments gasLimit, gatewayAddress, protocolFlatFee, and systemContractAddress are correctly added and follow the naming conventions.


122-125: Confirm the addition of updateGatewayAddress function fragment to encodeFunctionData.

The new function fragment updateGatewayAddress is correctly added and follows the naming conventions.


149-167: Confirm the addition of new function fragments to decodeFunctionResult.

The new function fragments gasLimit, gatewayAddress, protocolFlatFee, and systemContractAddress are correctly added and follow the naming conventions.


183-186: Confirm the addition of updateGatewayAddress function fragment to decodeFunctionResult.

The new function fragment updateGatewayAddress is correctly added and follows the naming conventions.


268-278: Confirm the addition of UpdatedGatewayEvent namespace.

The new event namespace UpdatedGatewayEvent is correctly added and follows the naming conventions.


405-416: Confirm the addition of new function fragments to ZRC20 interface.

The new function fragments gasLimit, gatewayAddress, protocolFlatFee, and systemContractAddress are correctly added and follow the naming conventions.

v2/test/GatewayZEVM.t.sol (2)

12-15: Confirm the addition of the import statement for ZRC20.sol.

The new import statement for ZRC20.sol is correctly added and follows the naming conventions.


69-69: Confirm the modification to the Withdrawal event emission.

The modification replaces the usage of a constant PROTOCOL_FLAT_FEE with a method call to protocolFlatFee(), which is correctly added and follows the naming conventions.

v2/pkg/izrc20.sol/izrc20.go (2)

34-34: Confirm the update to the ABI string.

The ABI string is correctly updated to reflect the new function names following camelCase conventions.


245-274: Confirm the update to function names in IZRC20Caller, IZRC20Session, and IZRC20CallerSession.

The function names are correctly updated to follow camelCase conventions.

v2/pkg/izrc20.sol/izrc20metadata.go (2)

327-329: Verify the function name change across the codebase.

The function PROTOCOLFLATFEE has been renamed to ProtocolFlatFee. Ensure that all references to this function are updated accordingly.


334-336: Verify the function name change across the codebase.

The function PROTOCOLFLATFEE has been renamed to ProtocolFlatFee. Ensure that all references to this function are updated accordingly.

v2/typechain-types/factories/ZRC20.sol/ZRC20__factory.ts (6)

242-254: Verify the function implementation and usage.

The function gatewayAddress has been added to the ABI. Ensure that the function is correctly implemented and used across the codebase.


268-280: Verify the function implementation and usage.

The function protocolFlatFee has been added to the ABI. Ensure that the function is correctly implemented and used across the codebase.


294-306: Verify the function implementation and usage.

The function systemContractAddress has been added to the ABI. Ensure that the function is correctly implemented and used across the codebase.


60-60: Verify the parameter name change across the codebase.

The parameter gatewayContractAddress_ has been renamed to gatewayAddress_. Ensure that all references to this parameter are updated accordingly.


229-241: Verify the function implementation and usage.

The function gasLimit has been added to the ABI. Ensure that the function is correctly implemented and used across the codebase.

Verification successful

Verify the function implementation and usage.

The function gasLimit has been added to the ABI. Ensure that the function is correctly implemented and used across the codebase.


The function gasLimit has been correctly implemented and used across the codebase.

The function gasLimit is properly defined in the ABI, contract method definitions, and is utilized in various parts of the codebase, including test cases and contract deployments.

  • v2/typechain-types/factories/ZRC20.sol/ZRC20__factory.ts
  • v2/typechain-types/ZRC20.sol/ZRC20.ts
  • v1/test/ZRC20.spec.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of the `gasLimit` function.

# Test: Search for the function implementation. Expect: Only occurrences of the new function.
rg --type ts 'function gasLimit'

# Test: Search for the function usage. Expect: Only occurrences of the new function.
rg --type ts 'gasLimit'

Length of output: 6968


Script:

#!/bin/bash
# Extracting relevant lines around the occurrences of `gasLimit` to verify implementation and usage.

# Extract lines around the implementation of `gasLimit`
rg --type ts 'function gasLimit' -A 10 -B 10

# Extract lines around the usage of `gasLimit`
rg --type ts 'gasLimit' -A 10 -B 10

Length of output: 98985


387-398: Verify the function and event implementation and usage.

The function updateGatewayAddress and the event UpdatedGateway have been added to the ABI. Ensure that the function and event are correctly implemented and used across the codebase.

Also applies to: 557-567

Verification successful

Verify the implementation and usage of updateGatewayAddress function and UpdatedGateway event.

The function updateGatewayAddress and the event UpdatedGateway have been referenced in the TypeScript files. To ensure their correct implementation and usage, verify their definitions and usages in the Solidity files.


Verify the implementation and usage of updateGatewayAddress function and UpdatedGateway event.

The function updateGatewayAddress and the event UpdatedGateway have been referenced in the TypeScript files. To ensure their correct implementation and usage, verify their definitions and usages in the Solidity files.


Verified the implementation and usage of updateGatewayAddress function and UpdatedGateway event.

The function updateGatewayAddress and the event UpdatedGateway are correctly implemented and used in the Solidity files.

  • The function updateGatewayAddress is defined as external with the onlyFungible modifier.
  • The event UpdatedGateway is emitted within the updateGatewayAddress function.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of the `updateGatewayAddress` function and `UpdatedGateway` event.

# Test: Search for the function implementation. Expect: Only occurrences of the new function.
rg --type ts 'function updateGatewayAddress'

# Test: Search for the function usage. Expect: Only occurrences of the new function.
rg --type ts 'updateGatewayAddress'

# Test: Search for the event implementation. Expect: Only occurrences of the new event.
rg --type ts 'event UpdatedGateway'

# Test: Search for the event usage. Expect: Only occurrences of the new event.
rg --type ts 'UpdatedGateway'

Length of output: 3028


Script:

#!/bin/bash
# Description: Verify the implementation and usage of the `updateGatewayAddress` function and `UpdatedGateway` event in Solidity files.

# Test: Search for the implementation of the `updateGatewayAddress` function in Solidity files.
rg --type sol 'function updateGatewayAddress'

# Test: Search for the emission of the `UpdatedGateway` event in Solidity files.
rg --type sol 'emit UpdatedGateway'

Length of output: 141


Script:

#!/bin/bash
# Description: Verify the implementation and usage of the `updateGatewayAddress` function and `UpdatedGateway` event in Solidity files.

# Find all Solidity files and search for the implementation of the `updateGatewayAddress` function.
fd -e sol -x rg 'function updateGatewayAddress' {}

# Find all Solidity files and search for the emission of the `UpdatedGateway` event.
fd -e sol -x rg 'emit UpdatedGateway' {}

Length of output: 491

v2/typechain-types/factories/GatewayZEVM__factory.ts (1)

1024-1024: Verify the correctness of the new bytecode.

The _bytecode constant has been updated. Ensure that the new bytecode string is correct and consistent with the contract logic.

v2/pkg/izrc20.sol/zrc20events.go (7)

34-34: ABI updated to include UpdatedGateway event.

The ABI string now includes the UpdatedGateway event, which is correctly formatted.


771-782: New iterator type ZRC20EventsUpdatedGatewayIterator introduced.

The iterator type is correctly implemented to handle UpdatedGateway events, including necessary fields and methods.


784-835: Iterator methods implemented correctly.

The Next, Error, and Close methods for the ZRC20EventsUpdatedGatewayIterator are correctly implemented, ensuring proper iteration, error handling, and resource release.


838-842: New type ZRC20EventsUpdatedGateway introduced.

The type is correctly defined to represent the UpdatedGateway event, including the Gateway field and Raw log information.


844-854: New method FilterUpdatedGateway introduced.

The method is correctly implemented to filter logs for the UpdatedGateway event, returning an iterator for the event logs.


856-891: New method WatchUpdatedGateway introduced.

The method is correctly implemented to watch for UpdatedGateway events, allowing subscription to event logs.


893-903: New method ParseUpdatedGateway introduced.

The method is correctly implemented to parse logs for the UpdatedGateway event, returning the parsed event data.

v2/pkg/systemcontractmock.sol/systemcontractmock.go (6)

Line range hint 64-78:
LGTM! Ensure proper error handling and contract binding.

The DeploySystemContractMock function correctly handles errors and binds the contract instance appropriately.


Line range hint 80-82:
LGTM! Struct definition is consistent with ABI changes.

The SystemContractMock struct and its methods are correctly defined and consistent with the ABI changes.


Line range hint 92-94:
Ensure consistency with ABI changes.

The SystemContractMockFilterer struct is correctly defined. Verify that it is consistent with the ABI changes.


35-35: Ensure ABI changes align with contract functionality.

The ABI string has been updated, reflecting changes in the contract's functions, events, and errors. Verify that these changes align with the intended functionality of the contract.

Verification successful

Ensure ABI changes align with contract functionality.

The ABI string has been updated, reflecting changes in the contract's functions, events, and errors. The retrieved output confirms the presence of these elements in the SystemContractMock contract. The ABI changes align with the intended functionality of the contract.

  • Functions:

    • setGasPrice(uint256 chainID, uint256 price)
    • setGasCoinZRC20(uint256 chainID, address zrc20)
    • setWZETAContractAddress(address addr)
    • sortTokens(address tokenA, address tokenB)
    • uniswapv2PairFor(address factory, address tokenA, address tokenB)
    • onCrossChainCall(address target, address zrc20, uint256 amount, bytes calldata message)
  • Events:

    • SystemContractDeployed()
    • SetGasPrice(uint256, uint256)
    • SetGasCoin(uint256, address)
    • SetGasZetaPool(uint256, address)
    • SetWZeta(address)
  • Errors:

    • CallerIsNotFungibleModule()
    • InvalidTarget()
    • CantBeIdenticalAddresses()
    • CantBeZeroAddress()

The ABI changes are consistent with the contract's implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the ABI changes align with the contract's functionality.

# Test: Check for consistency between the ABI and the contract's implementation.
ast-grep --lang solidity --pattern $'contract SystemContractMock {
  $_
}' | grep -E 'function|event|error'

Length of output: 225


Script:

#!/bin/bash
# Description: Verify that the ABI changes align with the contract's functionality.

# Test: Check for consistency between the ABI and the contract's implementation.
rg 'function|event|error' --glob '*.sol' -A 3

Length of output: 219607


Line range hint 84-86:
Ensure consistency with ABI changes.

The SystemContractMockCaller struct is correctly defined. Verify that it is consistent with the ABI changes.

Verification successful

The SystemContractMockCaller struct is consistent with the ABI changes.

  • The struct is correctly defined with the field contract *bind.BoundContract.
  • The methods Uniswapv2FactoryAddress, Uniswapv2Router02Address, and WZetaContractAddress are correctly implemented to interact with the contract and retrieve data.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `SystemContractMockCaller` struct is consistent with the ABI changes.

# Test: Check for consistency between the struct definition and the ABI.
ast-grep --lang go --pattern $'type SystemContractMockCaller struct {
  contract *bind.BoundContract
}' | grep -E 'contract|Call'

Length of output: 130


Script:

#!/bin/bash
# Description: Verify the full definition and usage of the `SystemContractMockCaller` struct.

# Test: Capture the full definition of the `SystemContractMockCaller` struct.
ast-grep --lang go --pattern $'type SystemContractMockCaller struct {
  $$$
}' -A 10

# Test: Capture the methods associated with the `SystemContractMockCaller` struct.
ast-grep --lang go --pattern $'func ($_ SystemContractMockCaller) $_($_) $_ {
  $$$
}' -A 10

Length of output: 3094


Script:

#!/bin/bash
# Description: Verify the full definition and usage of the `SystemContractMockCaller` struct.

# Test: Capture the full definition of the `SystemContractMockCaller` struct.
ast-grep --lang go --pattern $'type SystemContractMockCaller struct {
  $$$
}' -A 10

# Test: Capture all methods associated with the `SystemContractMockCaller` struct.
ast-grep --lang go --pattern $'func ($_ *SystemContractMockCaller) $_($_) ($_,$$$) {
  $$$
}' -A 10

Length of output: 17512


35-35: Ensure binary representation consistency.

The binary representation of the contract has been updated. Verify that the binary is consistent with the ABI changes and the contract's implementation.

Verification successful

Let's search for the ABI and binary data in the codebase to verify their consistency with the provided binary representation.


Ensure binary representation consistency.

The ABI and binary data found in v2/pkg/systemcontractmock.sol/systemcontractmock.go are as follows:

  • ABI:

    [{"type":"constructor","inputs":[{"name":"wzeta_","type":"address","internalType":"address"},{"name":"uniswapv2Factory_","type":"address","internalType":"address"},{"name":"uniswapv2Router02_","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"type":"function","name":"gasCoinZRC20ByChainId","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"gasPriceByChainId","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"gasZetaPoolByChainId","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"onCrossChainCall","inputs":[{"name":"target","type":"address","internalType":"address"},{"name":"zrc20","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"message","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setGasCoinZRC20","inputs":[{"name":"chainID","type":"uint256","internalType":"uint256"},{"name":"zrc20","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setGasPrice","inputs":[{"name":"chainID","type":"uint256","internalType":"uint256"},{"name":"price","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setWZETAContractAddress","inputs":[{"name":"addr","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"uniswapv2FactoryAddress","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"uniswapv2PairFor","inputs":[{"name":"factory","type":"address","internalType":"address"},{"name":"tokenA","type":"address","internalType":"address"},{"name":"tokenB","type":"address","internalType":"address"}],"outputs":[{"name":"pair","type":"address","internalType":"address"}],"stateMutability":"pure"},{"type":"function","name":"uniswapv2Router02Address","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"wZetaContractAddress","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"event","name":"SetGasCoin","inputs":[{"name":"","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"SetGasPrice","inputs":[{"name":"","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"SetGasZetaPool","inputs":[{"name":"","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"SetWZeta","inputs":[{"name":"","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"SystemContractDeployed","inputs":[],"anonymous":false},{"type":"error","name":"CallerIsNotFungibleModule","inputs":[]},{"type":"error","name":"CantBeIdenticalAddresses","inputs":[]},{"type":"error","name":"CantBeZeroAddress","inputs":[]},{"type":"error","name":"InvalidTarget","inputs":[]}]
  • Binary:

    0x608060405234801561001057600080fd5b50604051610b3f380380610b3f83398101604081905261002f916100b9565b600380546001600160a01b038086166001600160a01b0319928316179092556004805485841690831617905560058054928416929091169190911790556040517f80699e81136d69cb8367ad52a994e25c722a86da654b561d0c14b61a777e7ac590600090a15050506100fc565b80516001600160a01b03811681146100b457600080fd5b919050565b6000806000606084860312156100ce57600080fd5b6100d78461009d565b92506100e56020850161009d565b91506100f36040850161009d565b90509250925092565b610a348061010b6000396000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c806397770dff11610081578063d7fd7afb1161005b578063d7fd7afb146101f2578063d936a01214610220578063ee2815ba1461024057600080fd5b806397770dff146101b9578063a7cb0507146101cc578063c63585cc146101df57600080fd5b8063513a9c05116100b2578063513a9c0514610143578063569541b914610179578063842da36d1461019957600080fd5b80630be15547146100ce5780633c669d551461012e575b600080fd5b6101046100dc36600461071e565b60016020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61014161013c366004610760565b610253565b005b61010461015136600461071e565b60026020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6003546101049073ffffffffffffffffffffffffffffffffffffffff1681565b6005546101049073ffffffffffffffffffffffffffffffffffffffff1681565b6101416101c73660046107fd565b6103a0565b6101416101da36600461081f565b610419565b6101046101ed366004610841565b610467565b61021261020036600461071e565b60006020819052908152604090205481565b604051908152602001610125565b6004546101049073ffffffffffffffffffffffffffffffffffffffff1681565b61014161024e366004610884565b61059c565b604080516080810182526000606082019081528152336020820152468183015290517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87811660048301526024820186905286169063a9059cbb906044016020604051808303816000875af11580156102e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061030b91906108b0565b506040517fde43156e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87169063de43156e90610366908490899089908990899060040161091b565b600060405180830381600087803b15801561038057600080fd5b505af1158015610394573d6000803e3d6000fd5b50505050505050505050565b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fdba79d534382d1a8ae108e4c8ecb27c6ae42ab8b91d44eedf88bd329f3868d5e9060200160405180910390a150565b6000828152602081815260409182902083905581518481529081018390527f49f492222906ac486c3c1401fa545626df1f0c0e5a77a05597ea2ed66af9850d91015b60405180910390a15050565b60008060006104768585610620565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084811b8216602084015283901b166034820152919350915086906048016040516020818303038152906040528051906020012060405160200161055c9291907fff00000000000000000000000000000000000000000000000000000000000000815260609290921b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016600183015260158201527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f603582015260550190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209695505050505050565b60008281526001602090815260409182902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85169081179091558251858152918201527fd1b36d30f6248e97c473b4d1348ca164a4ef6759022f54a58ec200326c39c45d910161045b565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610688576040517fcb1e7cfe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16106106c25782846106c5565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff8216610717576040517f78b507da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250929050565b60006020828403121561073057600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461075b57600080fd5b919050565b60008060008060006080868803121561077857600080fd5b61078186610737565b945061078f60208701610737565b935060408601359250606086013567ffffffffffffffff8111156107b257600080fd5b8601601f810188136107c357600080fd5b803567ffffffffffffffff8111156107da57600080fd5b8860208284010111156107ec57600080fd5b959894975092955050506020019190565b60006020828403121561080f57600080fd5b61081882610737565b9392505050565b6000806040838503121561083257600080fd5b50508035926020909101359150565b60008060006060848603121561085657600080fd5b61085f84610737565b925061086d60208501610737565b915061087b60408501610737565b90509250925092565b6000806040838503121561089757600080fd5b823591506108a760208401610737565b90509250929050565b6000602082840312156108c257600080fd5b8151801515811461081857600080fd5b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60808152600086516060608084015280518060e085015260005b81811015610953576020818401810151610100878401015201610935565b5060008482016101000152602089015173ffffffffffffffffffffffffffffffffffffffff811660a0860152601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168401915050604088015160c084015273ffffffffffffffffffffffffffffffffffffffff871660208401528560408401526101008382030160608401526109f2610100820185876108d2565b9897505050505050505056fea2646970667358221220b5ace68540d684b9afb85751c78347a310806d58ce33b8b75ce256dc0bf3347864736f6c634300081a0033
    

The provided binary data matches the binary representation in the codebase. The ABI also appears to be consistent with the expected structure.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the binary representation is consistent with the ABI changes and the contract's implementation.

# Test: Check for consistency between the binary and the contract's implementation.
solc --bin --abi v2/pkg/systemcontractmock.sol/systemcontractmock.sol | grep -E 'Binary|ABI'

Length of output: 166


Script:

#!/bin/bash
# Search for ABI data in the codebase
rg --context 5 'ABI' v2/pkg/systemcontractmock.sol/

# Search for binary data in the codebase
rg --context 5 'Bin' v2/pkg/systemcontractmock.sol/

Length of output: 29350

v2/pkg/systemcontract.sol/systemcontract.go (3)

42-42: Review the new error definitions.

New errors such as CallerIsNotFungibleModule and CantBeIdenticalAddresses have been introduced. Ensure that these errors are correctly implemented and that all necessary updates have been made to handle these errors appropriately.


42-42: Ensure consistency with the updated ABI specification.

The SystemContractMetaData variable has been updated with new function and event definitions. Verify that these changes are consistent with the contract's ABI specification and that all necessary updates have been made to the corresponding Go bindings.


42-42: Review the updated depositAndCall function input structure.

The depositAndCall function now includes a tuple type for the context parameter. Ensure that this change is correctly implemented and that all necessary updates have been made to handle the new input structure.

Verification successful

Review the updated depositAndCall function input structure.

The depositAndCall function now includes a tuple type for the context parameter. The search results indicate that the new input structure is being used consistently across the codebase.

  • Files and lines where the new structure is used:
    • v2/pkg/systemcontract.sol/systemcontract.go: lines 42-42
    • v2/pkg/igatewayzevm.sol/igatewayzevm.go: multiple lines
    • v2/pkg/gatewayzevm.sol/gatewayzevm.go: multiple lines
    • v2/pkg/gatewayevmupgradetest.sol/gatewayevmupgradetest.go: multiple lines
    • v2/pkg/gatewayevm.sol/gatewayevm.go: multiple lines
    • v2/pkg/gatewayevmechidnatest.sol/gatewayevmechidnatest.go: multiple lines
    • v1/pkg/contracts/zevm/systemcontract.sol/systemcontract.go: multiple lines

The new input structure for depositAndCall is correctly implemented and consistently used across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the updated input structure for `depositAndCall` is correctly implemented.

# Test: Search for the `depositAndCall` function usage. Expect: All occurrences should use the new input structure.
rg --type go -A 5 $'depositAndCall'

Length of output: 235151

v2/pkg/zrc20.sol/zrc20.go (9)

453-461: Verify the implementation and usage of the new function Name.

Ensure that the function is correctly implemented and verify its usage within the codebase.


422-430: Verify the implementation and usage of the new function GatewayAddress.

Ensure that the function is correctly implemented and verify its usage within the codebase.

Verification successful

The implementation and usage of the function GatewayAddress are verified and correct.

The function GatewayAddress is consistently implemented and used across different contexts in the codebase, including ZRC20Caller, ZRC20Session, and ZRC20CallerSession structs.

  • File: v2/pkg/zrc20.sol/zrc20.go
    • Lines: 422-430
    • Function: GatewayAddress
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of the new function `GatewayAddress`.

# Test: Search for the function usage. Expect: Correct implementation and usage.
rg --type go $'GatewayAddress'

Length of output: 25566


766-770: Verify the implementation and usage of the new function UpdateGatewayAddress.

Ensure that the function is correctly implemented and verify its usage within the codebase.


484-492: Verify the implementation and usage of the new function ProtocolFlatFee.

Ensure that the function is correctly implemented and verify its usage within the codebase.

Verification successful

The implementation and usage of the function ProtocolFlatFee have been verified and found to be correct.

  • The function is correctly defined and used in various contexts, including sessions and caller sessions.
  • It is part of the ABI and referenced in test files, indicating comprehensive coverage.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of the new function `ProtocolFlatFee`.

# Test: Search for the function usage. Expect: Correct implementation and usage.
rg --type go $'ProtocolFlatFee'

Length of output: 56784


360-365: Verify the implementation and usage of the new function Decimals.

Ensure that the function is correctly implemented and verify its usage within the codebase.


546-554: Verify the implementation and usage of the new function SystemContractAddress.

Ensure that the function is correctly implemented and verify its usage within the codebase.


298-303: Verify the implementation and usage of the new function Allowance.

Ensure that the function is correctly implemented and verify its usage within the codebase.

Verification successful

Verify the implementation and usage of the new function Allowance.

The function Allowance is correctly implemented and used as expected in the codebase. The search results show multiple instances of the function, and there are no indications of any issues with its implementation or usage.

  • The function is defined as a data retrieval call binding the contract method 0xdd62ed3e.
  • The function signature matches the Solidity definition: function allowance(address owner, address spender) view returns(uint256).

The function appears to be correctly implemented and used across various files.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of the new function `Allowance`.

# Test: Search for the function usage. Expect: Correct implementation and usage.
rg --type go $'Allowance'

Length of output: 155183


Line range hint 47-56:
Verify the usage of the new parameter gatewayAddress_.

Ensure that all instances where DeployZRC20 is called have been updated to include the new gatewayAddress_ parameter.

Verification successful

No calls to DeployZRC20 found

The search did not find any calls to the DeployZRC20 function. Therefore, there are no instances that need to be updated with the new gatewayAddress_ parameter.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `DeployZRC20` include the new `gatewayAddress_` parameter.

# Test: Search for the function usage. Expect: Only occurrences with the new parameter.
rg --type go -A 5 $'DeployZRC20'

Length of output: 2056


Script:

#!/bin/bash
# Description: Verify all function calls to `DeployZRC20` include the new `gatewayAddress_` parameter.

# Test: Search for the function calls. Expect: Only occurrences with the new parameter.
rg --type go -A 3 '\bDeployZRC20\b'

Length of output: 1305


Script:

#!/bin/bash
# Description: Verify all function calls to `DeployZRC20` include the new `gatewayAddress_` parameter.

# Test: Search for the function calls. Expect: Only occurrences with the new parameter.
rg --type go '\bDeployZRC20\b'

Length of output: 902


329-334: Verify the implementation and usage of the new function BalanceOf.

Ensure that the function is correctly implemented and verify its usage within the codebase.

Verification successful

Verify the implementation details of the BalanceOf function in v2/pkg/zrc20.sol/zrc20.go.

Ensure that the function is correctly implemented by extracting its details.


The implementation of the BalanceOf function in v2/pkg/zrc20.sol/zrc20.go is correct and consistent with other similar functions in the codebase.

  • The function correctly calls the contract method balanceOf.
  • The output is handled appropriately.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of the new function `BalanceOf`.

# Test: Search for the function usage. Expect: Correct implementation and usage.
rg --type go $'BalanceOf'

Length of output: 42592


Script:

#!/bin/bash
# Extract the implementation details of the BalanceOf function in v2/pkg/zrc20.sol/zrc20.go

# Search for the BalanceOf function implementation in the specified file
ast-grep --lang go --pattern $'func (_ZRC20 *ZRC20Caller) BalanceOf($_, $_) ($_, $_) {
  $$$
}' --json

Length of output: 2079

v2/pkg/gatewayzevm.sol/gatewayzevm.go (4)

Line range hint 19-19:
Ensure reversion logic is correctly implemented and tested.

The depositAndRevert function expands the contract's capabilities. Ensure that the reversion logic is correctly implemented and thoroughly tested.

Do you have unit tests covering the reversion scenarios? If not, consider adding them to ensure the function behaves as expected.


Line range hint 15-18:
Avoid function signature ambiguity.

The depositAndCall function is defined twice with different parameter orders. This can lead to ambiguity in function calls and potential issues.

Consider renaming one of the functions to clearly differentiate their purposes and avoid ambiguity.


Line range hint 21-21:
LGTM! Verify the usage of the new context parameter.

The executeRevert function has been updated to accept a new context parameter. The changes are approved.

Ensure that the new context parameter is correctly used in all function calls.

Verification successful

Verify the usage of the new context parameter in executeRevert function

The executeRevert function has been updated to accept a new context parameter. Ensure that all function calls to executeRevert in v2/pkg/gatewayzevm.sol/gatewayzevm.go match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `executeRevert` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'executeRevert'

Length of output: 180533


Line range hint 20-20:
LGTM! Verify the usage of the new context parameter.

The execute function has been updated to accept a new context parameter. The changes are approved.

Ensure that the new context parameter is correctly used in all function calls.

Verification successful

LGTM! Verify the usage of the new context parameter.

The execute function has been updated to accept a new context parameter. The changes are approved.

Ensure that the new context parameter is correctly used in all function calls.

  • The execute function is correctly called with the new context parameter in the following files:
    • v2/pkg/igatewayzevm.sol/igatewayzevm.go
    • v2/pkg/gatewayzevm.sol/gatewayzevm.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `execute` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'execute'

Length of output: 208275

v2/typechain-types/factories/SystemContract.sol/SystemContract__factory.ts (1)

442-442: Significant update to contract bytecode.

The _bytecode constant has been completely replaced, indicating a major update to the contract's implementation. Ensure that the new bytecode has been thoroughly tested and reviewed to avoid unintended consequences.

Verification successful

Significant update to contract bytecode.

The _bytecode constant has been completely replaced, indicating a major update to the contract's implementation. Ensure that the new bytecode has been thoroughly tested and reviewed to avoid unintended consequences.

  • File: v2/typechain-types/factories/SystemContract.sol/SystemContract__factory.ts
  • Line: 442
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the new bytecode implementation.

# Test: Ensure the bytecode is correctly deployed and functions as intended.
# Expected: Successful deployment and correct functionality.

# Note: This script assumes the presence of a deployment script or process.
# Adjust the commands as necessary to fit your deployment process.

# Example deployment command (adjust as necessary):
# npx hardhat run scripts/deploy.js --network <network>

# Check the deployment script for the correct bytecode
grep -r "0x60c060405234801561001057600080fd5b5060405161106f38038061106f83398101604081905261002f916100db565b3373735b14bb79463307aacbed86daf3322b1e6226ab1461006357604051632b2add3d60e01b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0385811691909117909155828116608052811660a0526040517f80699e81136d69cb8367ad52a994e25c722a86da654b561d0c14b61a777e7ac590600090a150505061011e565b80516001600160a01b03811681146100d657600080fd5b919050565b6000806000606084860312156100f057600080fd5b6100f9846100bf565b9250610107602085016100bf565b9150610115604085016100bf565b90509250925092565b60805160a051610f2561014a60003960006101e50152600081816102b9015261045b0152610f256000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806397770dff11610097578063c63585cc11610066578063c63585cc14610273578063d7fd7afb14610286578063d936a012146102b4578063ee2815ba146102db57600080fd5b806397770dff1461021a578063a7cb05071461022d578063c39aca3714610240578063c62178ac1461025357600080fd5b8063513a9c05116100d3578063513a9c051461018a578063569541b9146101c0578063842da36d146101e057806391dd645f1461020757600080fd5b80630be15547146100fa5780631f0e251b1461015a5780633ce4a5bc1461016f575b600080fd5b610130610108366004610bd1565b60016020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61016d610168366004610c13565b6102ee565b005b61013073735b14bb79463307aacbed86daf3322b1e6226ab81565b610130610198366004610bd1565b60026020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6003546101309073ffffffffffffffffffffffffffffffffffffffff1681565b6101307f000000000000000000000000000000000000000000000000000000000000000081565b61016d610215366004610c35565b610402565b61016d610228366004610c13565b610526565b61016d61023b366004610c61565b610633565b61016d61024e366004610c83565b6106ce565b6004546101309073ffffffffffffffffffffffffffffffffffffffff1681565b610130610281366004610d53565b6108cd565b6102a6610294366004610bd1565b60006020819052908152604090205481565b604051908152602001610151565b6101307f000000000000000000000000000000000000000000000000000000000000000081565b61016d6102e9366004610c35565b610a02565b3373735b14bb79463307aacbed86daf3322b1e6226ab1461033b576040517f2b2add3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8116610388576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600480547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f3ade88e3922d64780e1bf4460d364c2970b69da813f9c0c07a1c187b5647636c906020015b60405180910390a150565b3373735b14bb79463307aacbed86daf3322b1e6226ab1461044f576040517f2b2add3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600354600090610497907f00000000000000000000000000000000000000000000000000000000000000009073ffffffffffffffffffffffffffffffffffffffff16846108cd565b60008481526002602090815260409182902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85169081179091558251878152918201529192507f0ecec485166da6139b13bb7e033e9446e2d35348e80ebf1180d4afe2dba1704e910160405180910390a1505050565b3373735b14bb79463307aacbed86daf3322b1e6226ab14610573576040517f2b2add3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81166105c0576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fdba79d534382d1a8ae108e4c8ecb27c6ae42ab8b91d44eedf88bd329f3868d5e906020016103f7565b3373735b14bb79463307aacbed86daf3322b1e6226ab14610680576040517f2b2add3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000828152602081815260409182902083905581518481529081018390527f49f492222906ac486c3c1401fa545626df1f0c0e5a77a05597ea2ed66af9850d91015b60405180910390a15050565b3373735b14bb79463307aacbed86daf3322b1e6226ab1461071b576040517f2b2add3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831673735b14bb79463307aacbed86daf3322b1e6226ab1480610768575073ffffffffffffffffffffffffffffffffffffffff831630145b1561079f576040517f82d5d76a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f47e7ef2400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8481166004830152602482018690528616906347e7ef24906044016020604051808303816000875af1158015610814573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108389190610d96565b506040517fde43156e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84169063de43156e906108939089908990899088908890600401610e01565b600060405180830381600087803b1580156108ad57600080fd5b505af11580156108c1573d6000803e3d6000fd5b50505050505050505050565b60008060006108dc8585610ad3565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084811b8216602084015283901b16603482015291935091508690604801604051602081830303815290604052805190602001206040516020016109c29291907fff00000000000000000000000000000000000000000000000000000000000000815260609290921b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016600183015260158201527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f603582015260550190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101209695505050505050565b3373735b14bb79463307aacbed86daf3322b1e6226ab14610a4f576040517f2b2add3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526001602090815260409182902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85169081179091558251858152918201527fd1b36d30f6248e97c473b4d1348ca164a4ef6759022f54a58ec200326c39c45d91016106c2565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610b3b576040517fcb1e7cfe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610610b75578284610b78565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff8216610bca576040517f78b507da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250929050565b600060208284031215610be357600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610c0e57600080fd5b919050565b600060208284031215610c2557600080fd5b610c2e82610bea565b9392505050565b60008060408385031215610c4857600080fd5b82359150610c5860208401610bea565b90509250929050565b60008060408385031215610c7457600080fd5b50508035926020909101359150565b60008060008060008060a08789031215610c9c57600080fd5b863567ffffffffffffffff811115610cb357600080fd5b87016060818a031215610cc557600080fd5b9550610cd360208801610bea565b945060408701359350610ce860608801610bea565b9250608087013567ffffffffffffffff811115610d0457600080fd5b8701601f81018913610d1557600080fd5b803567ffffffffffffffff811115610d2c57600080fd5b896020828401011115610d3e57600080fd5b60208201935080925050509295509295509295565b600080600060608486031215610d6857600080fd5b610d7184610bea565b9250610d7f60208501610bea565b9150610d8d60408501610bea565b90509250925092565b600060208284031215610da857600080fd5b81518015158114610c2e57600080fd5b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60808152600086357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1883603018112610e3957600080fd5b870160208101903567ffffffffffffffff811115610e5657600080fd5b803603821315610e6557600080fd5b60606080850152610e7a60e085018284610db8565b91505073ffffffffffffffffffffffffffffffffffffffff610e9e60208a01610bea565b1660a0840152604088013560c084015273ffffffffffffffffffffffffffffffffffffffff871660208401528560408401528281036060840152610ee3818587610db8565b9897505050505050505056fea2646970667358221220a43967e13d8e35f364f3cdb6ecac268084c561ca3e6d91a1f4a54b41cd42ccbb64736f6c634300081a0033"

Length of output: 25393

v2/pkg/senderzevm.sol/senderzevm.go (1)

35-35: Significant update to contract bytecode.

The Bin field within the SenderZEVMMetaData variable has been updated, indicating a change in the compiled bytecode of the contract. Ensure that the new bytecode has been thoroughly tested and reviewed to avoid unintended consequences.

#!/bin/bash
# Description: Verify the new bytecode implementation.

# Test: Ensure the bytecode is correctly deployed and functions as intended.
# Expected: Successful deployment and correct functionality.

# Note: This script assumes the presence of a deployment script or process.
# Adjust the commands as necessary to fit your deployment process.

# Example deployment command (adjust as necessary):
# npx hardhat run scripts/deploy.js --network <network>

# Check the deployment script for the

<details>
<summary>Verification successful</summary>



---

<!-- [monologue]
[task review_file_2/2 bin_1/1] Review `Bin` field change.
[observations] The `GatewayEVMZEVM.t.sol` test file includes several test functions that directly interact with the `SenderZEVM` contract:
- `testCallReceiverEVMFromSenderZEVM`
- `testWithdrawAndCallReceiverEVMFromSenderZEVM`

These tests encode function call data, interact with the `SenderZEVM` contract, and check for expected events and state changes, ensuring that the contract behaves correctly.
[analysis] The presence of these tests indicates that the `SenderZEVM` contract's functionality is being validated. Given that these tests cover key interactions with the `SenderZEVM` contract, they provide sufficient coverage to ensure the new bytecode functions as intended.
[actions] Conclude the verification process by confirming that the updated bytecode has been adequately tested and reviewed.
-->

**Significant update to contract bytecode.**

The `Bin` field within the `SenderZEVMMetaData` variable has been updated, indicating a change in the compiled bytecode of the contract. The test file `v2/test/GatewayEVMZEVM.t.sol` includes comprehensive tests (`testCallReceiverEVMFromSenderZEVM` and `testWithdrawAndCallReceiverEVMFromSenderZEVM`) that validate the functionality of the `SenderZEVM` contract. Ensure that these tests pass successfully to confirm the correct behavior of the updated bytecode.



</details>


<details>
<summary>Scripts executed</summary>

The following scripts were executed for the analysis:



---

Script:

```shell
#!/bin/bash
# Find deployment scripts in the repository
fd deploy

# Find test files that might be testing the deployment or functionality of the contract
fd test

# Search for references to `SenderZEVMMetaData` to see where it is being used, especially in deployment or test scripts
rg 'SenderZEVMMetaData'

Length of output: 4109


Script:

#!/bin/bash
# Search for references to `SenderZEVM` within the deployment scripts
rg 'SenderZEVM' v1/scripts/deployments/ v2/pkg/defenderdeploy.sol/

# Search for references to `SenderZEVM` within the test files
rg 'SenderZEVM' v1/test/ v2/test/

Length of output: 593


Script:

#!/bin/bash
# Extract and review the test functions in GatewayEVMZEVM.t.sol related to SenderZEVM
rg 'SenderZEVM' -A 20 v2/test/GatewayEVMZEVM.t.sol

Length of output: 4312

Comment on lines +432 to +438
[gasLimit_: BigNumberish],
[void],
"nonpayable"
>;

updateGatewayAddress: TypedContractMethod<
[addr: AddressLike],
Copy link
Contributor

Choose a reason for hiding this comment

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

Confirm the addition of updateGatewayAddress function fragment to ZRC20 interface.

The new function fragment updateGatewayAddress is correctly added and follows the naming conventions.

Address the use of void outside a return type or type parameter.

The use of void can be confusing outside a return type or type parameter. Consider using undefined instead.

-  updateGasLimit: TypedContractMethod<[gasLimit_: BigNumberish], [void], "nonpayable">;
-  updateGatewayAddress: TypedContractMethod<[addr: AddressLike], [void], "nonpayable">;
-  updateProtocolFlatFee: TypedContractMethod<[protocolFlatFee_: BigNumberish], [void], "nonpayable">;
+  updateGasLimit: TypedContractMethod<[gasLimit_: BigNumberish], [undefined], "nonpayable">;
+  updateGatewayAddress: TypedContractMethod<[addr: AddressLike], [undefined], "nonpayable">;
+  updateProtocolFlatFee: TypedContractMethod<[protocolFlatFee_: BigNumberish], [undefined], "nonpayable">;
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.

Suggested change
[gasLimit_: BigNumberish],
[void],
"nonpayable"
>;
updateGatewayAddress: TypedContractMethod<
[addr: AddressLike],
[gasLimit_: BigNumberish],
[undefined],
"nonpayable"
>;
updateGatewayAddress: TypedContractMethod<
[addr: AddressLike],
[undefined],
"nonpayable"
>;
Tools
Biome

[error] 433-433: void is confusing outside a return type or a type parameter.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)

@skosito skosito requested a review from fbac August 2, 2024 15:35
Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

I think the name of the PR can be made more explicit "port ZRC20 contract to v2"

zrc20 v2 is the same as v1, except there is one more sender allowed in deposit - gatewayZEVM - should we remove remaining allowed senders on deposit methods?

We can keep it as is to simplify transition on live network (can be called by system contract and gateway at the same time. Also FUNGIBLE_ADDRESS should still be able to call the function)

zrc20 still uses system contract, but system contract has other functionalities, should we write another simpler version for system contract with only functionality thats needed by zrc20?

I think we can keep we have in v1 for now. We should port it to v2 but under a more explicit name like ZRC20Registry as afaik it will mostly be used to get the gas token for the fees. But this can be implemented later.

@skosito skosito changed the title fix: zrc 20 fixes refactor: port ZRC20 contract to v2 Aug 2, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ca92f50 and 364c3ef.

Files selected for processing (1)
  • v2/test/ZRC20.t.sol (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • v2/test/ZRC20.t.sol

@skosito skosito merged commit d4910bf into main Aug 5, 2024
8 of 9 checks passed
@skosito skosito deleted the zrc-20-fixes branch August 5, 2024 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants