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

[wip]: add contract package #108

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

alanchchen
Copy link
Contributor

No description provided.

@netlify
Copy link

netlify bot commented Apr 28, 2022

Deploy Preview for qubic-js-sdk-example failed.

Name Link
🔨 Latest commit cbfcb2b
🔍 Latest deploy log https://app.netlify.com/sites/qubic-js-sdk-example/deploys/6274fcb18ccb710008e681e1

@alanchchen alanchchen force-pushed the feature/add-contracts branch from df857b0 to a8c4cc7 Compare April 28, 2022 09:26
@alanchchen alanchchen force-pushed the feature/add-contracts branch from a8c4cc7 to 2e0478f Compare April 29, 2022 08:02
@alanchchen alanchchen force-pushed the feature/add-contracts branch from 2e0478f to cbfcb2b Compare May 6, 2022 10:47
import '@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';

contract ForwarderUpgradeable is Initializable, OwnableUpgradeable, EIP712Upgradeable {

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;

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');

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');

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');

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)) {

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');

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));

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));

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));

Choose a reason for hiding this comment

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

ditto

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.

2 participants