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

feat: do not cache chain id for permit #106

Merged
merged 69 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
fbaded0
renamed folder and changed version
Foivos Jul 6, 2023
8a6d845
npmignore
Foivos Jul 6, 2023
607de5c
npmignore
Foivos Jul 6, 2023
52fc054
Merge remote-tracking branch 'origin/main' into feat/dist
Foivos Jul 6, 2023
f5b5f56
change version
Foivos Jul 6, 2023
4c5738d
using include pattern instead.
Foivos Jul 6, 2023
15e606b
Merge remote-tracking branch 'origin/main' into feat/dist0-1-1
Foivos Jul 6, 2023
d998f1b
Merge branch 'main' into feat/dist0-1-1
Foivos Jul 11, 2023
0548a6e
Fixed most of the things least auhority suggested.
Foivos Jul 11, 2023
8397b07
made lint happy
Foivos Jul 11, 2023
f2e5ea8
Apply suggestions from code review
milapsheth Jul 12, 2023
32ce490
fixed some bugs
Foivos Jul 19, 2023
80616c5
Merge remote-tracking branch 'origin/main' into feat/least-autority-f…
Foivos Jul 19, 2023
dc516fe
added events
Foivos Jul 19, 2023
d6fa384
rename set to transfer for distributor and operator
Foivos Jul 24, 2023
5cc8fbb
changed standardized token to always allow token managers to mint/bur…
Foivos Jul 24, 2023
ea255e0
using immutable storage for remoteAddressValidator address to save gas
Foivos Jul 24, 2023
09bf99a
Merge remote-tracking branch 'origin/main' into feat/gas-optimizations
Foivos Jul 24, 2023
650ca71
Added some recommended changes
Foivos Jul 26, 2023
c69e0a4
added milap's suggested changes
Foivos Jul 26, 2023
63a18e4
Merge remote-tracking branch 'origin/main' into feat/gas-optimizations
Foivos Jul 26, 2023
2993930
Fixed some names and some minor gas optimizations
Foivos Jul 26, 2023
9074ed1
prettier and lint
Foivos Jul 26, 2023
d3cb150
stash
Foivos Jul 27, 2023
53fe6fe
import .env in hardhat.config
Foivos Jul 27, 2023
7eb5207
trying to fix .env.example
Foivos Jul 27, 2023
bf603eb
Added some getters in IRemoteAddressValidator and removed useless che…
Foivos Jul 27, 2023
f1723c3
removed ternary operators
Foivos Jul 27, 2023
bc8ed59
made lint happy
Foivos Jul 27, 2023
7661e1f
Merge branch 'feat/gas-optimizations' into feat/use-create3-lib
Foivos Jul 27, 2023
4bf89db
made lint happy
Foivos Jul 27, 2023
512d126
Added a new token manager to handle fee on transfer and added some te…
Foivos Jul 27, 2023
9e43b1c
fixed the liquidity pool check.
Foivos Jul 28, 2023
ba29a2a
Merge remote-tracking branch 'origin/main' into feat/use-create3-lib
Foivos Jul 28, 2023
1e2aeb3
fix a duplication bug
Foivos Jul 28, 2023
6c62270
lint
Foivos Jul 28, 2023
30c1e53
added some more tests
Foivos Jul 28, 2023
51b70c1
Added more tests
Foivos Jul 28, 2023
6b3f5ed
Merge branch 'feat/use-create3-lib' into feat/fee-on-transfer-separate
Foivos Jul 28, 2023
3e6d85f
Added proper re-entrancy protection for fee on transfer token managers.
Foivos Jul 28, 2023
d4075b8
change to tx.origin for refunds
Foivos Jul 28, 2023
5d9d8ce
Added support for more kinds of addresses.
Foivos Jul 28, 2023
1b35cbf
some minor gas opts
Foivos Jul 28, 2023
412dce9
some more gas optimizations.
Foivos Jul 28, 2023
0a8519f
Added a getter for chain name to the remote address validator.
Foivos Jul 28, 2023
959e495
moved the tokenManager getter functionality to a separate contract wh…
Foivos Jul 28, 2023
0d09703
made lint happy
Foivos Jul 28, 2023
2e44518
Removed tokenManagerGetter and put params into tokenManagers
Foivos Jul 28, 2023
6027ffe
Added separate tokenManager interfaces
Foivos Jul 28, 2023
04041d1
addressed ackeeblockchains's 3.0 report
Foivos Aug 23, 2023
6ee5d06
prettier
Foivos Aug 23, 2023
5acf4a8
added interchain transfer methods to the service and unified receivin…
Foivos Aug 28, 2023
244ff61
made lint happy
Foivos Aug 28, 2023
4e56576
rename sendToken to interchainTransfer
Foivos Aug 29, 2023
a8dc8a4
changed sendToken everywhere
Foivos Aug 29, 2023
b210316
changed from uint256.max to a const
Foivos Aug 30, 2023
2f5adac
change setting to zero to delete for storage slots.
Foivos Sep 4, 2023
af4766a
rearange storage variables to save a bit of gas.
Foivos Sep 4, 2023
634581c
Removed unecesairy casts
Foivos Sep 4, 2023
141648b
made as many event params inexed as possible
Foivos Sep 4, 2023
602d531
Removed unused imports
Foivos Sep 4, 2023
0ec429e
domain separator is calculated each time.
Foivos Sep 4, 2023
f089d50
added some natspec
Foivos Sep 4, 2023
5cf5ea5
Merge branch 'main' into feat/move-views-out-of-serivce
re1ro Sep 27, 2023
ab32389
Merge branch 'feat/move-views-out-of-serivce' into feat/ackee-3.0
re1ro Sep 27, 2023
8a21176
Merge branch 'feat/ackee-3.0' into feat/interchain-transsfer-everywhere
re1ro Sep 27, 2023
ac6e9cf
Merge branch 'feat/interchain-transsfer-everywhere' into feat/code4re…
re1ro Sep 27, 2023
66fc445
Merge branch 'feat/code4rena-gas-opts' into feat/do-not-cache-chain-i…
re1ro Sep 27, 2023
33ff694
Merge branch 'main' into feat/do-not-cache-chain-id-for-permit
milapsheth Oct 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions contracts/token-implementations/ERC20Permit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract contract ERC20Permit is IERC20, IERC20Permit, ERC20 {
* @dev Represents hash of the EIP-712 Domain Separator.
*/
// solhint-disable-next-line var-name-mixedcase
bytes32 public DOMAIN_SEPARATOR;
bytes32 public nameHash;

string private constant EIP191_PREFIX_FOR_EIP712_STRUCTURED_DATA = '\x19\x01';

Expand All @@ -38,13 +38,20 @@ abstract contract ERC20Permit is IERC20, IERC20Permit, ERC20 {
mapping(address => uint256) public nonces;

/**
* @notice Internal function to set the domain type signature hash
* @notice Internal function to set the token name hash
* @param name The token name
*/
function _setDomainTypeSignatureHash(string memory name) internal {
DOMAIN_SEPARATOR = keccak256(
abi.encode(DOMAIN_TYPE_SIGNATURE_HASH, keccak256(bytes(name)), keccak256(bytes('1')), block.chainid, address(this))
);
function _setNameHash(string memory name) internal {
nameHash = keccak256(bytes(name));
}

/**
* @notice Calculates the DOMAIN_SEPARATOR.
* @dev This is not cached because chainid can change on chain forks.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() public view returns (bytes32 domainSeparator) {
domainSeparator = keccak256(abi.encode(DOMAIN_TYPE_SIGNATURE_HASH, nameHash, keccak256(bytes('1')), block.chainid, address(this)));
}

/**
Expand All @@ -69,7 +76,7 @@ abstract contract ERC20Permit is IERC20, IERC20Permit, ERC20 {
bytes32 digest = keccak256(
abi.encodePacked(
EIP191_PREFIX_FOR_EIP712_STRUCTURED_DATA,
DOMAIN_SEPARATOR,
DOMAIN_SEPARATOR(),
keccak256(abi.encode(PERMIT_SIGNATURE_HASH, issuer, spender, value, nonces[issuer]++, deadline))
)
);
Expand Down
2 changes: 1 addition & 1 deletion contracts/token-implementations/StandardizedToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract StandardizedToken is IERC20BurnableMintable, InterchainToken, ERC20Perm
name = tokenName;

_setDistributor(distributor_);
_setDomainTypeSignatureHash(tokenName);
_setNameHash(tokenName);
}
{
uint256 mintAmount;
Expand Down
Loading