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

contract: add erc20 functions #100

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

contract: add erc20 functions #100

wants to merge 14 commits into from

Conversation

kroist
Copy link
Collaborator

@kroist kroist commented Jan 30, 2025

No description provided.

Copy link

github-actions bot commented Jan 31, 2025

Transaction NameMainCurrentDifference (%)
NewAccount200114720011470.00000%
Deposit182866418286640.00000%
Withdraw189868318986830.00000%

Copy link

github-actions bot commented Jan 31, 2025

📊 Coverage Report

📈 Total Coverage Summary

Type Covered Total Coverage
📝 Lines 2008 3151 🟠 63.72%
📄 Statements 2008 3151 🟠 63.72%
⚡ Functions 69 77 🟡 89.61%
🔀 Branches 197 200 🟡 98.5%

Coverage Legend

  • ✅ 100% Coverage
  • 🟡 80-99% Coverage
  • 🟠 50-79% Coverage
  • ❌ 0-49% Coverage

📁 File Coverage

📋 Detailed Coverage Report
File Lines Statements Functions Branches
zkOS-monorepo/ts/shielder-sdk/src/_generated/abi_v0_0_1.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/_generated/abi.ts 0% 0% 0% 0%
zkOS-monorepo/ts/shielder-sdk/src/actions/deposit.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/actions/index.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/actions/newAccount.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/actions/utils.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/actions/withdraw.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/chain/contract.ts 9.09% 9.09% 25% 100%
zkOS-monorepo/ts/shielder-sdk/src/chain/relayer.ts 20.75% 20.75% 33.33% 50%
zkOS-monorepo/ts/shielder-sdk/src/client.ts 100% 100% 93.75% 100%
zkOS-monorepo/ts/shielder-sdk/src/constants.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/index.ts 0% 0% 0% 0%
zkOS-monorepo/ts/shielder-sdk/src/state/events.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/state/index.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/state/manager.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/state/storageSchema.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/state/sync.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/state/types.ts 100% 100% 100% 100%
zkOS-monorepo/ts/shielder-sdk/src/utils.ts 100% 100% 100% 100%

@kroist kroist marked this pull request as ready for review February 3, 2025 09:07
@kroist kroist changed the title add erc20 functions contract: add erc20 functions Feb 3, 2025
Copy link
Member

Choose a reason for hiding this comment

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

a lot of commented jobs - I guess this is something to be restored

Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming it's doable in this PR, not sure what breaks if we restore it now. We might prefer leaving a TODO and/or JIRA (sub)task.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I commented it cause the new binary for gas measurement is not compatible with main branch contracts
https://github.com/Cardinal-Cryptography/zkOS-monorepo/actions/runs/13071400613/job/36473677457

This can be fixed with compiling the additional binary on the main branch. Not sure if it's worth doing, what do you suggest?

Copy link
Contributor

Choose a reason for hiding this comment

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

Any decision that ensures we don't forget about restoring the commented-out part is fine by me. Leaving this for @pmikolajczyk41 to weigh in.

Copy link
Member

Choose a reason for hiding this comment

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

this PR is already huge; I'd suggest adding Jira ticket and solving this in a follow-up

Copy link
Contributor

Choose a reason for hiding this comment

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

contracts/DepositLimit.sol Outdated Show resolved Hide resolved
contracts/Shielder.sol Outdated Show resolved Hide resolved
contracts/Shielder.sol Outdated Show resolved Hide resolved
contracts/Shielder.sol Outdated Show resolved Hide resolved
contracts/Shielder.sol Outdated Show resolved Hide resolved
contracts/Shielder.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@guspiel guspiel left a comment

Choose a reason for hiding this comment

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

Awesome!

Haven't read everything, but posting some initial comments. Will finish reviewing today.

crates/shielder-cli/src/recovery.rs Outdated Show resolved Hide resolved
contracts/Shielder.sol Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming it's doable in this PR, not sure what breaks if we restore it now. We might prefer leaving a TODO and/or JIRA (sub)task.

contracts/Shielder.sol Show resolved Hide resolved
crates/shielder-contract/src/types.rs Show resolved Hide resolved
contracts/DepositLimit.sol Outdated Show resolved Hide resolved
contracts/DepositLimit.sol Outdated Show resolved Hide resolved
contracts/Shielder.sol Outdated Show resolved Hide resolved
contracts/Shielder.sol Show resolved Hide resolved
contracts/Shielder.sol Outdated Show resolved Hide resolved
Copy link
Member

@pmikolajczyk41 pmikolajczyk41 left a comment

Choose a reason for hiding this comment

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

nice work, kudos!

for future, I'd suggest doing preliminary, no-brainer PR for simply renaming contract functions and applying this to >20 files, and then, proper PR with semantic changes

Comment on lines -33 to +34
bytes3 public constant CONTRACT_VERSION = 0x000001;
bytes3 public constant CONTRACT_VERSION = 0x000100;
Copy link
Member

Choose a reason for hiding this comment

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

just out of curiosity - have we already decided that the new version is 0.1.0, not 0.0.2? (apart from this PR ofc :P)

Copy link
Contributor

Choose a reason for hiding this comment

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

The agreement was that if circuits get updated, the middle (or the first) number gets bumped.

@@ -313,4 +323,40 @@ contract Shielder is
function setDepositLimit(uint256 _depositLimit) external onlyOwner {
_setDepositLimit(_depositLimit);
}

function handleTokenTransferIn(
Copy link
Member

Choose a reason for hiding this comment

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

+1 for these handlers

} else {
IERC20 token = IERC20(tokenAddress);
bool transferSuccess = token.transfer(to, amount);
if (!transferSuccess) revert NativeTransferFailed();
Copy link
Member

Choose a reason for hiding this comment

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

new error is needed here (not native transfer)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added ERC20TransferFailed

Copy link
Contributor

@guspiel guspiel left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants