zeta-chain / toolkit

A library of ZetaChain helper utilities, contracts, and Hardhat tasks for smart-contract development
MIT License
43 stars 22 forks source link

feat: Gateway methods and Solana deposit #179

Closed fadeev closed 2 months ago

fadeev commented 2 months ago
npx hardhat solana-deposit --amount 0.1 --recipient 0x1b02C3079c039DF9E20DC68427cb87bf821BffeF --types '["address", "bytes", "bool"]' 0x05ba149a7bd6dc1f937fa9046a9e05c05f3b18b0 0x4955a3F38ff86ae92A914445099caa8eA2B9bA32 true

Transaction signature: 5PzGKxPSsK7pzQHvEFBxCmvifdfsG96mnaM4T9ZSAwHS3UfDCHjGZT57FtM14AwTJqkXH7Do9DGVEo6QBmdRfBWV

Start localnet:

npx hardhat localnet

Deploy some contracts from example-contracts/universal/hello:

yarn deploy

🔑 Using account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

🚀 Successfully deployed contract on localhost.
📜 Contract address: 0xc5a5C42992dECbae36851359345FE25997F5C42d

🔑 Using account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

🚀 Successfully deployed contract on localhost.
📜 Contract address: 0x67d269191c92Caf3cD7723F116c85e6E9bf55933
npx hardhat evm-call --network localhost --receiver 0x67d269191c92Caf3cD7723F116c85e6E9bf55933 --types '["string"]' foo
npx hardhat evm-deposit --amount 1 --network localhost --receiver 0x4955a3F38ff86ae92A914445099caa8eA2B9bA32 
npx hardhat evm-deposit-and-call --amount 1 --network localhost --receiver 0xc5a5C42992dECbae36851359345FE25997F5C42d --erc20 0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82 --types '["string"]' foo
npx hardhat zetachain-call --network localhost --receiver 0x67d269191c92Caf3cD7723F116c85e6E9bf55933 --zrc20 0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf --function "hello(string)" --types '["string"]' foo
npx hardhat zetachain-withdraw --network localhost --receiver 0x4955a3F38ff86ae92A914445099caa8eA2B9bA32 --zrc20 0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf --amount 1 
npx hardhat zetachain-withdraw-and-call --network localhost --receiver 0x67d269191c92Caf3cD7723F116c85e6E9bf55933 --zrc20 0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf --amount 1 --function "hello(string)" --types '["string"]' foo

Depends on https://github.com/zeta-chain/localnet/pull/32

Summary by CodeRabbit

coderabbitai[bot] commented 2 months ago
Walkthrough ## Walkthrough The recent changes encompass updates to various smart contracts, libraries, and configuration files within the ZetaChain protocol. Key modifications include the introduction of new functionalities for handling deposits and withdrawals across Solana and Ethereum blockchains, enhancements to contract interfaces, and updates to bytecode across multiple factories. Additionally, new dependencies were added to the project, and the TypeScript configuration was adjusted for improved type management. ## Changes | File Path | Change Summary | |---------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `contracts/SwapHelperLib.sol` | Formatting adjustments for readability; no functional changes. | | `package.json` | Added dependencies: `@coral-xyz/anchor` and `@solana/web3.js`. | | `packages/client/src/client.ts` | Introduced new methods for handling deposits and calls across Solana and Ethereum in the `ZetaChainClient` class. | | `packages/client/src/index.ts` | Added exports for new modules related to Solana and Ethereum deposits. | | `packages/client/src/evmCall.ts`, `packages/client/src/evmDeposit.ts`, `packages/client/src/evmDepositAndCall.ts`, `packages/client/src/solanaDeposit.ts`, `packages/client/src/zetachainCall.ts`, `packages/client/src/zetachainWithdraw.ts`, `packages/client/src/zetachainWithdrawAndCall.ts` | Implemented various functions for deposits, withdrawals, and contract calls on both EVM and Solana networks. | | `packages/tasks/src/evmCall.ts`, `packages/tasks/src/evmDeposit.ts`, `packages/tasks/src/evmDepositAndCall.ts`, `packages/tasks/src/solanaDeposit.ts`, `packages/tasks/src/zetachainCall.ts`, `packages/tasks/src/zetachainWithdraw.ts`, `packages/tasks/src/zetachainWithdrawAndCall.ts` | Created Hardhat tasks for interacting with EVM and Solana networks, facilitating deposits, withdrawals, and contract calls. | | `tsconfig.json` | Removed `typeRoots` array to simplify TypeScript configuration. | | `typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/IZRC20.sol/IZRC20.ts` | Modified function signatures, removed events, and simplified the `burn` function parameters. | | `typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/IZRC20.sol/IZRC20Metadata.ts` | Introduced interface for ZRC20 token metadata, detailing standard ERC20 operations. | | `typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/IZRC20.sol/ZRC20Events.ts` | Defined interface for ZRC20 token events, facilitating event management in smart contracts. | | `typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/index.ts` | Autogenerated index for ZRC20 interfaces, enhancing modularity. | | `typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/SystemContract.sol/SystemContract__factory.ts` | Updated bytecode and constructor parameters for `SystemContract`. | | `typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IZRC20.sol/IZRC20__factory.ts` | Removed events and functions from ABI, reflecting a refactor of the contract interface. | | `typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IZRC20.sol/ZRC20Events__factory.ts` | Autogenerated factory for ZRC20Events contract interface, encapsulating event definitions. | | `typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/index.ts` | Autogenerated index for ZRC20 interface factories, consolidating access to multiple factory classes. | | `typechain-types/factories/contracts/OnlySystem__factory.ts` | Updated bytecode string for `OnlySystem` contract. | | `typechain-types/factories/contracts/SwapHelperLib__factory.ts` | Updated bytecode string for `SwapHelperLib` contract. | ## Sequence Diagram(s) ```mermaid sequenceDiagram participant User participant ZetaChainClient participant SolanaNetwork participant EVMNetwork User->>ZetaChainClient: Call solanaDeposit(amount, recipient) ZetaChainClient->>SolanaNetwork: Initiate deposit transaction SolanaNetwork-->>ZetaChainClient: Transaction success ZetaChainClient-->>User: Confirm deposit ``` ```mermaid sequenceDiagram participant User participant EVMNetwork participant GatewayContract User->>EVMNetwork: Call evmDeposit(amount, recipient) EVMNetwork->>GatewayContract: Initiate deposit transaction GatewayContract-->>EVMNetwork: Transaction success EVMNetwork-->>User: Confirm deposit ```

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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `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 using 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. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
fadeev commented 2 months ago

@andresaiello @zeta-chain/fullstack please, review.