-
Notifications
You must be signed in to change notification settings - Fork 23
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
Modify l2deposit using spender from user with permit #115
Modify l2deposit using spender from user with permit #115
Conversation
_deposit.l1TokenAddr, // tokenAddr | ||
address(l2Deposit), // requester | ||
_deposit.sender, // user | ||
address(l2Deposit), // recipient | ||
_deposit.amount, // amount | ||
getEIP712Hash(l2Deposit.EIP712_DOMAIN_SEPARATOR(), L2DepositLibEIP712._getDepositHash(DEFAULT_DEPOSIT)), // actionHash | ||
uint64(_deposit.expiry) // expiry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the case where I think named parameter can help. What do you think? @pilagod @charlesjhongc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot this is a struct
initialization. @108356037 Can you test if we could use named parameter to initialize a struct (e.g., the SpendWithPermit
struct)?
SpenderLibEIP712.SpendWithPermit({
tokenAddr: _deposit.l1TokenAddr,
requester: address(l2Deposit),
...
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like this ?:
function _createSpenderPermitFromL2Deposit(L2DepositLibEIP712.Deposit memory _deposit) internal view returns (SpenderLibEIP712.SpendWithPermit memory) {
return
SpenderLibEIP712.SpendWithPermit({
tokenAddr: _deposit.l1TokenAddr,
requester: address(l2Deposit),
user: _deposit.sender,
recipient: address(l2Deposit),
amount: _deposit.amount,
actionHash: getEIP712Hash(l2Deposit.EIP712_DOMAIN_SEPARATOR(), L2DepositLibEIP712._getDepositHash(DEFAULT_DEPOSIT)),
expiry: uint64(_deposit.expiry)
});
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the code with _createSpenderPermitFromL2Deposit
rewritten as above, all test case passed. 🫡
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yap! This is awesome. I would like to proceed with named parameter. Let's wait for the comment from @pilagod and @charlesjhongc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think named params should be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modify to named parameters in several places:
7b4392e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR is mature enough and only some minors are left. But should be waiting for #114 get merged and rebase on it.
_deposit.l1TokenAddr, // tokenAddr | ||
address(l2Deposit), // requester | ||
_deposit.sender, // user | ||
address(l2Deposit), // recipient | ||
_deposit.amount, // amount | ||
getEIP712Hash(l2Deposit.EIP712_DOMAIN_SEPARATOR(), L2DepositLibEIP712._getDepositHash(DEFAULT_DEPOSIT)), // actionHash | ||
uint64(_deposit.expiry) // expiry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think named params should be better.
The #114 had been merged. We could start to do the sign permit refinement 💪 |
…nderFromUserWithPermit This merge if for update on PR#114 that merged into branch 'spender_permit_feature'
Modified the test cases using |
This PR modifies
L2Deposit.sol
&IL2Deposit.sol
usingspendFromUserToWithPermit
.Related test case files are also modified, run test case with the following command at project root: