-
Notifications
You must be signed in to change notification settings - Fork 0
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
[wip]: add contract package #108
base: master
Are you sure you want to change the base?
Conversation
❌ Deploy Preview for qubic-js-sdk-example failed.
|
df857b0
to
a8c4cc7
Compare
a8c4cc7
to
2e0478f
Compare
2e0478f
to
cbfcb2b
Compare
import '@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol'; | ||
import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; | ||
|
||
contract ForwarderUpgradeable is Initializable, OwnableUpgradeable, EIP712Upgradeable { |
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.
要繼承UUPSUpgradeable還有function要有_authorizeUpgrade才能做升級
* variables without shifting down storage in the inheritance chain. | ||
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps | ||
*/ | ||
uint256[48] private __gap; |
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.
如果是想要保持都是50個變數的話應該是uint256[49]?
|
||
bytes memory data = abi.encode(META_TRANSACTION_TYPEHASH, authorizer, nonces[authorizer], keccak256(callData)); | ||
|
||
require(EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == authorizer, 'NativeMetaTransaction: invalid signature'); |
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.
我覺得這裡要擋掉recover回來的address是0x0000000000000000000000000000000000000000, 因為authorizer如果是0x0000000000000000000000000000000000000000, 不合法的signature是也會過的
|
||
bytes memory data = abi.encode(CANCEL_META_TRANSACTION_TYPEHASH, authorizer, nonce); | ||
|
||
require(EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == authorizer, 'NativeMetaTransaction: invalid signature'); |
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.
ditto
validBefore | ||
); | ||
|
||
require(EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == authorizer, 'NativeMetaTransaction: invalid signature'); |
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.
ditto
) internal view { | ||
_requireValidFuntionCall(callData); | ||
|
||
if (relayer != address(0)) { |
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.
問一下為什麼要有這個判斷啊?
deadline | ||
); | ||
|
||
require(EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == authorizer, 'NativeMetaTransaction: invalid signature'); |
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.
ditto
nonces[authorizer] = nonces[authorizer].add(1); | ||
|
||
// Append authorizer at the end to extract it from calling context | ||
(bool success, bytes memory returnData) = address(this).call(abi.encodePacked(callData, authorizer)); |
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.
value應該要帶進去
(bool success, bytes memory returnData) = address(this).call{value: msg.value}(abi.encodePacked(callData, authorizer));
_requireValidAuthorization(relayer, authorizer, nonce, callData, deadline, v, r, s); | ||
|
||
// Append userAddress at the end to extract it from calling context | ||
(bool success, bytes memory returnData) = address(this).call(abi.encodePacked(callData, authorizer)); |
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.
value要帶進去
_requireValidAuthorization(relayer, authorizer, nonce, callData, validAfter, validBefore, v, r, s); | ||
|
||
// Append userAddress at the end to extract it from calling context | ||
(bool success, bytes memory returnData) = address(this).call(abi.encodePacked(callData, authorizer)); |
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.
ditto
No description provided.