-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add evm function call #270
Merged
Merged
Changes from 63 commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
ba687de
Refactor to match new multichain tools interface
Pessina 682c50a
Fix typescript errors
Pessina b288cea
Improve fast-auth-wallet types
Pessina 2188e43
Roll back yarn lock
Pessina 4a94035
Fix imports
Pessina 6a29c94
Fix validation
Pessina c107a34
Fix BNB fee and simplify logic to get Asset Metadata
Pessina b344e63
Use SendMultiChainMessage instead of ChainDetails on get asset metada…
Pessina 6b32fb7
Add sync comment on SignMultichainMessage type
Pessina f2cf1a9
Remove unused packages
Pessina 39751d7
Add wallet on beta version and fix types
Pessina 5ad56a0
Fix multichain tests
Pessina 3f7e44a
Update sign transaction with new wallet interface
Pessina 18c41e3
Add test for FunctionCall
Pessina c085798
Remove unused variable
Pessina a68dfa2
Remove only from MultiChain test
Pessina 72fdd84
Add new packages
Pessina 9c7261b
Add EVM FunctionCall to iFrame interface
Pessina a9c2529
Remove unused methods and make callContractWithDataField more flexible
Pessina 6296b72
Include all derived addresses for johndoe12.testnet
Pessina 09870c7
Add tests for EVM FunctionCall
Pessina f17be10
Re-use constant derive address on faucets
Pessina 0a0ed58
Clean up code
Pessina 459a495
Skip EVM function call tests as it will hit the Infura limit
Pessina 07c99b7
Remove unused code
Pessina 322e667
Fix overflow and rename constant
Pessina 0acdc02
Include from on EVM fee estimation transaction
Pessina 93445c8
Deployment with ethers on local hardhat network working
Pessina f36d717
Add hardhat to e2e workspace and deploy contract from testset
Pessina 8cdafa2
Add CHAIN_CONFIG to getMultichainAssetInfo
Pessina d515701
Include new field to choose using local rpc
Pessina 32db86d
Fix nonce issue by creating one account per test
Pessina 8e05009
Include command to run hardhat server
Pessina 41b6262
Fix BTC wrong chainConfig
Pessina 4ab3919
Display error on iFrame instead of closing it and returning
Pessina a4b8c3c
Allow to use local/real RPC
Pessina 5768130
Fix closeModal function
Pessina a498c95
Fix invalid forms submission on safari
Pessina 63c7be1
Revert to production config
Pessina c239818
Remove hardcoded rpc urls
Pessina 18d4fbe
Update the tests to run most common failing tests separated
Pessina dcce727
DRY playwright.yml
Pessina bff18f3
Fix servers initialization
Pessina 577d6da
Matrix run in sequence
Pessina 85ad47d
Fix command
Pessina f911888
Fix alignment
Pessina 66e9b5a
Remove useless server start
Pessina 460e3e2
Rename and reorder the tests
Pessina 2d95a94
Fix hardhat start url
Pessina 661bd34
update yarn.lock
Pessina d3b1029
Update to new multichain-tools package with nonce error handling and …
Pessina 99ca26e
Update comment
Pessina 160875f
Remove test.only
Pessina 3f6f58c
Update multichain-tools version and fix but on amount validation
Pessina 62d392b
Remove nonce retry for evm
Pessina eedf696
Add key rotation on multichain signature to avoid nonce issues
Pessina 01e2e94
Update playwright variables
Pessina 7ebf669
Re-add testAccounts.json
Pessina c75ff41
Update to use contract v5
Pessina 787f615
Update Unknown key address
Pessina 40b302a
Add correct EVM_DOMAIN key
Pessina f8416eb
Merge remote-tracking branch 'origin/main' into add-evm-function-call
Pessina db52750
Update playwright file
Pessina 972d21e
Upgrade versions and fix types
Pessina eafbd0d
Merge remote-tracking branch 'origin/main' into add-evm-function-call
Pessina e515578
Upgrade packages and contract
Pessina 30c7380
Reduce project to avoid concurrency issues
Pessina 0e0f5f8
PR comments
Pessina 39ea0a5
Add chainId validation
Pessina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Origal repo: https://github.com/Consensys/Tokens/blob/master/contracts/eip20/EIP20.sol | ||
|
||
pragma solidity ^0.8.24; | ||
|
||
interface EIP20Interface { | ||
function totalSupply() external view returns (uint256); | ||
function balanceOf(address _owner) external view returns (uint256 balance); | ||
function transfer(address _to, uint256 _value) external returns (bool success); | ||
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); | ||
function approve(address _spender, uint256 _value) external returns (bool success); | ||
function allowance(address _owner, address _spender) external view returns (uint256 remaining); | ||
function mint(address _to, uint256 _amount) external returns (bool success); | ||
|
||
event Transfer(address indexed _from, address indexed _to, uint256 _value); | ||
event Approval(address indexed _owner, address indexed _spender, uint256 _value); | ||
} | ||
|
||
contract EIP20 is EIP20Interface { | ||
|
||
uint256 constant private MAX_UINT256 = type(uint256).max; | ||
mapping (address => uint256) public balances; | ||
mapping (address => mapping (address => uint256)) public allowed; | ||
string public name; | ||
uint8 public decimals; | ||
string public symbol; | ||
uint256 private _totalSupply; | ||
|
||
constructor( | ||
uint256 _initialAmount, | ||
string memory _tokenName, | ||
uint8 _decimalUnits, | ||
string memory _tokenSymbol | ||
) { | ||
balances[msg.sender] = _initialAmount; | ||
_totalSupply = _initialAmount; | ||
name = _tokenName; | ||
decimals = _decimalUnits; | ||
symbol = _tokenSymbol; | ||
} | ||
|
||
function totalSupply() external view override returns (uint256) { | ||
return _totalSupply; | ||
} | ||
|
||
function balanceOf(address _owner) public view override returns (uint256 balance) { | ||
return balances[_owner]; | ||
} | ||
|
||
function transfer(address _to, uint256 _value) public override returns (bool success) { | ||
require(balances[msg.sender] >= _value, "Insufficient balance"); | ||
unchecked { | ||
balances[msg.sender] -= _value; | ||
balances[_to] += _value; | ||
} | ||
emit Transfer(msg.sender, _to, _value); | ||
return true; | ||
} | ||
|
||
function transferFrom(address _from, address _to, uint256 _value) public override returns (bool success) { | ||
uint256 currentAllowance = allowed[_from][msg.sender]; | ||
require(balances[_from] >= _value && currentAllowance >= _value, "Insufficient balance or allowance"); | ||
unchecked { | ||
balances[_to] += _value; | ||
balances[_from] -= _value; | ||
if (currentAllowance < MAX_UINT256) { | ||
allowed[_from][msg.sender] -= _value; | ||
} | ||
} | ||
emit Transfer(_from, _to, _value); | ||
return true; | ||
} | ||
|
||
function approve(address _spender, uint256 _value) public override returns (bool success) { | ||
allowed[msg.sender][_spender] = _value; | ||
emit Approval(msg.sender, _spender, _value); | ||
return true; | ||
} | ||
|
||
function allowance(address _owner, address _spender) public view override returns (uint256 remaining) { | ||
return allowed[_owner][_spender]; | ||
} | ||
|
||
function mint(address _to, uint256 _amount) external override returns (bool success) { | ||
require(_to != address(0), "ERC20: mint to the zero address"); | ||
_totalSupply += _amount; | ||
unchecked { | ||
balances[_to] += _amount; | ||
} | ||
emit Transfer(address(0), _to, _amount); | ||
return true; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/near-fast-auth-signer-e2e-tests/hardhat.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require('@nomicfoundation/hardhat-toolbox'); | ||
|
||
const config = { | ||
solidity: '0.8.24', | ||
networks: { | ||
hardhat: { | ||
port: 8545 | ||
} | ||
} | ||
}; | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
so this file is extended version of file from above link? could you add a bit more detail about what has modified/extended and why? (eg. I notice that
mint
doesn't exist on above, but added below)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 didn't added any explanation because we will never change this file again. It's just a contract implementing the ERC20 interface for testing.
The code here was copy pasted from the URL linked, and the mint function was added so we can distribute the tokens as we want for testing.
I was checking other options to implement this contracts, looks like Open Zeppelin haves a npm package with the implementations for all we need ERC20, ERC721, ERC1155.
But if it's ok I would like to tackle this in another PR, there is too much work here already.
That's the package I'm looking to use: https://www.npmjs.com/package/@openzeppelin/contracts