mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-06 19:06:42 +01:00
Update importers of eth, review eth/README.md
This commit is contained in:
@@ -12,23 +12,28 @@ While the prepared deployment is not found to master, branch in repository must
|
||||
|
||||
Now, install the dependencies:
|
||||
|
||||
`npm i`
|
||||
```
|
||||
cd contracts/
|
||||
yarn install
|
||||
```
|
||||
|
||||
Go to where the deployment scripts for the test are found:
|
||||
|
||||
`cd scripts/ethclient-test-deployment`
|
||||
`cd scripts/ethclient-deployment/`
|
||||
|
||||
Now, a bash script has to be run to do the deployment:
|
||||
`./test-deployment`
|
||||
Now, a bash script (which uses gnome-terminal) has to be run to do the deployment:
|
||||
`./test-deploy.sh`
|
||||
|
||||
This bash file follows these steps:
|
||||
- `npx builder node`: a local blockchain to do our tests
|
||||
- `npx buidler run --network localhost test-deployment.js`: run the deployment on the local blockchain
|
||||
|
||||
Alternatively you can run the two previous commands manually in different terminals.
|
||||
|
||||
An output file necessary for the next step is obtained: `deploy-output`.
|
||||
|
||||
> The files that find in `/eth/contracts` must be obtained from the same contract that we deploy in this step
|
||||
> The files that appear in `hermez-node/eth/contracts` must be generated from the same contract that we deploy in this step
|
||||
|
||||
## Ethclient Test
|
||||
|
||||
Different environment variables are necessary to run this test.
|
||||
@@ -46,9 +51,9 @@ WDELAYER="0x500D1d6A4c7D8Ae28240b47c8FCde034D827fD5e"
|
||||
WDELAYER_TEST="0x1d80315fac6aBd3EfeEbE97dEc44461ba7556160"
|
||||
```
|
||||
|
||||
> An example is found in `/etc/.env.example`
|
||||
> An example is found in `hermez-node/eth/.env.example`
|
||||
|
||||
And then run test:
|
||||
And then run test from `hermez-node/eth/`:
|
||||
|
||||
`INTEGRATION=1 go test`
|
||||
|
||||
|
||||
@@ -263,13 +263,14 @@ type AuctionInterface interface {
|
||||
type AuctionClient struct {
|
||||
client *EthereumClient
|
||||
address ethCommon.Address
|
||||
tokenHEZ TokenConfig
|
||||
tokenHEZCfg TokenConfig
|
||||
auction *HermezAuctionProtocol.HermezAuctionProtocol
|
||||
tokenHEZ *HEZ.HEZ
|
||||
contractAbi abi.ABI
|
||||
}
|
||||
|
||||
// NewAuctionClient creates a new AuctionClient. `tokenAddress` is the address of the HEZ tokens.
|
||||
func NewAuctionClient(client *EthereumClient, address ethCommon.Address, tokenHEZ TokenConfig) (*AuctionClient, error) {
|
||||
func NewAuctionClient(client *EthereumClient, address ethCommon.Address, tokenHEZCfg TokenConfig) (*AuctionClient, error) {
|
||||
contractAbi, err := abi.JSON(strings.NewReader(string(HermezAuctionProtocol.HermezAuctionProtocolABI)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -278,11 +279,16 @@ func NewAuctionClient(client *EthereumClient, address ethCommon.Address, tokenHE
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tokenHEZ, err := HEZ.NewHEZ(tokenHEZCfg.Address, client.Client())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &AuctionClient{
|
||||
client: client,
|
||||
address: address,
|
||||
tokenHEZ: tokenHEZ,
|
||||
tokenHEZCfg: tokenHEZCfg,
|
||||
auction: auction,
|
||||
tokenHEZ: tokenHEZ,
|
||||
contractAbi: contractAbi,
|
||||
}, nil
|
||||
}
|
||||
@@ -561,17 +567,16 @@ func (c *AuctionClient) AuctionBid(amount *big.Int, slot int64, bidAmount *big.I
|
||||
if tx, err = c.client.CallAuth(
|
||||
0,
|
||||
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||
tokenHEZcontract, err := HEZ.NewHEZ(c.tokenHEZ.Address, ec)
|
||||
owner := c.client.account.Address
|
||||
spender := c.address
|
||||
nonce, err := c.tokenHEZ.Nonces(nil, owner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
owner := c.client.account.Address
|
||||
spender := c.address
|
||||
nonce, err := tokenHEZcontract.Nonces(nil, owner)
|
||||
tokenname := c.tokenHEZ.Name
|
||||
tokenAddr := c.tokenHEZ.Address
|
||||
chainid, _ := c.client.client.ChainID(context.Background())
|
||||
digest, _ := createPermitDigest(tokenAddr, owner, spender, chainid, amount, nonce, deadline, tokenname)
|
||||
tokenName := c.tokenHEZCfg.Name
|
||||
tokenAddr := c.tokenHEZCfg.Address
|
||||
chainid, _ := c.client.Client().ChainID(context.Background())
|
||||
digest, _ := createPermitDigest(tokenAddr, owner, spender, chainid, amount, nonce, deadline, tokenName)
|
||||
signature, _ := c.client.ks.SignHash(*c.client.account, digest)
|
||||
permit := createPermit(owner, spender, amount, deadline, digest, signature)
|
||||
_slot := big.NewInt(slot)
|
||||
@@ -581,7 +586,6 @@ func (c *AuctionClient) AuctionBid(amount *big.Int, slot int64, bidAmount *big.I
|
||||
return nil, fmt.Errorf("Failed bid: %w", err)
|
||||
}
|
||||
return tx, nil
|
||||
|
||||
}
|
||||
|
||||
// AuctionMultiBid is the interface to call the smart contract function
|
||||
@@ -590,18 +594,17 @@ func (c *AuctionClient) AuctionMultiBid(amount *big.Int, startingSlot, endingSlo
|
||||
if tx, err = c.client.CallAuth(
|
||||
1000000, //nolint:gomnd
|
||||
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||
tokenHEZcontract, err := HEZ.NewHEZ(c.tokenHEZ.Address, ec)
|
||||
owner := c.client.account.Address
|
||||
spender := c.address
|
||||
nonce, err := c.tokenHEZ.Nonces(nil, owner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
owner := c.client.account.Address
|
||||
spender := c.address
|
||||
nonce, err := tokenHEZcontract.Nonces(nil, owner)
|
||||
tokenname := c.tokenHEZ.Name
|
||||
tokenAddr := c.tokenHEZ.Address
|
||||
chainid, _ := c.client.client.ChainID(context.Background())
|
||||
tokenName := c.tokenHEZCfg.Name
|
||||
tokenAddr := c.tokenHEZCfg.Address
|
||||
chainid, _ := c.client.Client().ChainID(context.Background())
|
||||
|
||||
digest, _ := createPermitDigest(tokenAddr, owner, spender, chainid, amount, nonce, deadline, tokenname)
|
||||
digest, _ := createPermitDigest(tokenAddr, owner, spender, chainid, amount, nonce, deadline, tokenName)
|
||||
signature, _ := c.client.ks.SignHash(*c.client.account, digest)
|
||||
permit := createPermit(owner, spender, amount, deadline, digest, signature)
|
||||
_startingSlot := big.NewInt(startingSlot)
|
||||
|
||||
@@ -13,7 +13,7 @@ const openAuctionSlotsConst = uint16(4320)
|
||||
const closedAuctionSlotsConst = uint16(2)
|
||||
const outbiddingConst = uint16(1000)
|
||||
const currentSlotConst = 0
|
||||
const BLOCKSPERSLOT = uint8(40)
|
||||
const blocksPerSlot = uint8(40)
|
||||
const minBidStr = "10000000000000000000"
|
||||
const URL = "http://localhost:3000"
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestAuctionConstants(t *testing.T) {
|
||||
|
||||
auctionConstants, err := auctionClientTest.AuctionConstants()
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, auctionConstants.BlocksPerSlot, BLOCKSPERSLOT)
|
||||
assert.Equal(t, auctionConstants.BlocksPerSlot, blocksPerSlot)
|
||||
assert.Equal(t, auctionConstants.GenesisBlockNum, genesisBlock)
|
||||
assert.Equal(t, auctionConstants.HermezRollup, hermezRollupAddressTestConst)
|
||||
assert.Equal(t, auctionConstants.InitialMinimalBidding, INITMINBID)
|
||||
@@ -277,7 +277,7 @@ func TestAuctionBid(t *testing.T) {
|
||||
|
||||
func TestAuctionGetSlotNumber(t *testing.T) {
|
||||
slotConst := 4
|
||||
blockNum := int(BLOCKSPERSLOT)*slotConst + int(genesisBlock)
|
||||
blockNum := int(blocksPerSlot)*slotConst + int(genesisBlock)
|
||||
|
||||
slot, err := auctionClientTest.AuctionGetSlotNumber(int64(blockNum))
|
||||
require.Nil(t, err)
|
||||
@@ -286,7 +286,7 @@ func TestAuctionGetSlotNumber(t *testing.T) {
|
||||
|
||||
func TestAuctionCanForge(t *testing.T) {
|
||||
slotConst := 4
|
||||
blockNum := int(BLOCKSPERSLOT)*slotConst + int(genesisBlock)
|
||||
blockNum := int(blocksPerSlot)*slotConst + int(genesisBlock)
|
||||
|
||||
canForge, err := auctionClientTest.AuctionCanForge(governanceAddressConst, int64(blockNum))
|
||||
require.Nil(t, err)
|
||||
@@ -344,7 +344,7 @@ func TestAuctionForge(t *testing.T) {
|
||||
auctionClientTestHermez, err := NewAuctionClient(ethereumClientHermez, auctionTestAddressConst, tokenHEZ)
|
||||
require.Nil(t, err)
|
||||
slotConst := 4
|
||||
blockNum := int64(int(BLOCKSPERSLOT)*slotConst + int(genesisBlock))
|
||||
blockNum := int64(int(blocksPerSlot)*slotConst + int(genesisBlock))
|
||||
currentBlockNum, _ := auctionClientTestHermez.client.EthCurrentBlock()
|
||||
blocksToAdd := blockNum - currentBlockNum
|
||||
addBlocks(blocksToAdd, ethClientDialURL)
|
||||
|
||||
@@ -11,7 +11,7 @@ abigen --abi=HEZ.abi --bin=HEZ.bin --pkg=HEZ --out=HEZ.go
|
||||
You must compile the contracts to get the `.bin` and `.abi` files. The contracts used are in the repo: https://github.com/hermeznetwork/contracts
|
||||
|
||||
Branch: `RemoveERC777`
|
||||
Specifically they have been processed in the commit with hash: `7574ba47fd3d7dab2653a22f57b15c69280350dc`
|
||||
Specifically they have been processed in the commit with hash: `2a1cfccfba6770c1077ecea983d2c743dc4a1e93`
|
||||
|
||||
Versions:
|
||||
```
|
||||
|
||||
@@ -277,6 +277,8 @@ func (c *EthereumClient) EthBlockByNumber(ctx context.Context, number int64) (*c
|
||||
|
||||
// EthERC20Consts returns the constants defined for a particular ERC20 Token instance.
|
||||
func (c *EthereumClient) EthERC20Consts(tokenAddress ethCommon.Address) (*ERC20Consts, error) {
|
||||
// We use the HEZ token smart contract interfacehere because it's an
|
||||
// ERC20, which allows us to access the standard ERC20 constants.
|
||||
instance, err := HEZ.NewHEZ(tokenAddress, c.client)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package eth
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"net/http"
|
||||
@@ -68,19 +67,21 @@ func addTime(seconds float64, url string) {
|
||||
}
|
||||
|
||||
func createPermitDigest(tokenAddr, owner, spender ethCommon.Address, chainID, value, nonce, deadline *big.Int, tokenName string) ([]byte, error) {
|
||||
// NOTE: We ignore hash.Write errors because we are writing to a memory
|
||||
// buffer and don't expect any errors to occur.
|
||||
abiPermit := []byte("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")
|
||||
hashPermit := sha3.NewLegacyKeccak256()
|
||||
hashPermit.Write(abiPermit)
|
||||
hashPermit.Write(abiPermit) //nolint:errcheck,gosec
|
||||
abiEIP712Domain := []byte("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
|
||||
hashEIP712Domain := sha3.NewLegacyKeccak256()
|
||||
hashEIP712Domain.Write(abiEIP712Domain)
|
||||
hashEIP712Domain.Write(abiEIP712Domain) //nolint:errcheck,gosec
|
||||
var encodeBytes []byte
|
||||
paddedHash := ethCommon.LeftPadBytes(hashEIP712Domain.Sum(nil), 32)
|
||||
hashName := sha3.NewLegacyKeccak256()
|
||||
hashName.Write([]byte(tokenName))
|
||||
hashName.Write([]byte(tokenName)) //nolint:errcheck,gosec
|
||||
paddedName := ethCommon.LeftPadBytes(hashName.Sum(nil), 32)
|
||||
hashVersion := sha3.NewLegacyKeccak256()
|
||||
hashVersion.Write([]byte("1"))
|
||||
hashVersion.Write([]byte("1")) //nolint:errcheck,gosec
|
||||
paddedX := ethCommon.LeftPadBytes(hashVersion.Sum(nil), 32)
|
||||
paddedChainID := ethCommon.LeftPadBytes(chainID.Bytes(), 32)
|
||||
paddedAddr := ethCommon.LeftPadBytes(tokenAddr.Bytes(), 32)
|
||||
@@ -90,7 +91,7 @@ func createPermitDigest(tokenAddr, owner, spender ethCommon.Address, chainID, va
|
||||
encodeBytes = append(encodeBytes, paddedChainID...)
|
||||
encodeBytes = append(encodeBytes, paddedAddr...)
|
||||
_domainSeparator := sha3.NewLegacyKeccak256()
|
||||
_domainSeparator.Write(encodeBytes)
|
||||
_domainSeparator.Write(encodeBytes) //nolint:errcheck,gosec
|
||||
|
||||
var bytes1 []byte
|
||||
paddedHashPermit := ethCommon.LeftPadBytes(hashPermit.Sum(nil), 32)
|
||||
@@ -106,19 +107,11 @@ func createPermitDigest(tokenAddr, owner, spender ethCommon.Address, chainID, va
|
||||
bytes1 = append(bytes1, paddedNonce...)
|
||||
bytes1 = append(bytes1, paddedDeadline...)
|
||||
hashBytes1 := sha3.NewLegacyKeccak256()
|
||||
hashBytes1.Write(bytes1)
|
||||
hashBytes1.Write(bytes1) //nolint:errcheck,gosec
|
||||
|
||||
var bytes2 []byte
|
||||
byte19, err := hex.DecodeString("19")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
byte01, err := hex.DecodeString("01")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
paddedY := ethCommon.LeftPadBytes(byte19, 1)
|
||||
paddedZ := ethCommon.LeftPadBytes(byte01, 1)
|
||||
paddedY := ethCommon.LeftPadBytes([]byte{0x19}, 1)
|
||||
paddedZ := ethCommon.LeftPadBytes([]byte{0x01}, 1)
|
||||
paddedDomainSeparator := ethCommon.LeftPadBytes(_domainSeparator.Sum(nil), 32)
|
||||
paddedHashBytes1 := ethCommon.LeftPadBytes(hashBytes1.Sum(nil), 32)
|
||||
bytes2 = append(bytes2, paddedY...)
|
||||
@@ -126,7 +119,7 @@ func createPermitDigest(tokenAddr, owner, spender ethCommon.Address, chainID, va
|
||||
bytes2 = append(bytes2, paddedDomainSeparator...)
|
||||
bytes2 = append(bytes2, paddedHashBytes1...)
|
||||
hashBytes2 := sha3.NewLegacyKeccak256()
|
||||
hashBytes2.Write(bytes2)
|
||||
hashBytes2.Write(bytes2) //nolint:errcheck,gosec
|
||||
|
||||
return hashBytes2.Sum(nil), nil
|
||||
}
|
||||
@@ -134,11 +127,11 @@ func createPermitDigest(tokenAddr, owner, spender ethCommon.Address, chainID, va
|
||||
func createPermit(owner, spender ethCommon.Address, amount, deadline *big.Int, digest, signature []byte) []byte {
|
||||
r := signature[0:32]
|
||||
s := signature[32:64]
|
||||
v := signature[64] + byte(27)
|
||||
v := signature[64] + byte(27) //nolint:gomnd
|
||||
|
||||
ABIpermit := []byte("permit(address,address,uint256,uint256,uint8,bytes32,bytes32)")
|
||||
hash := sha3.NewLegacyKeccak256()
|
||||
hash.Write(ABIpermit)
|
||||
hash.Write(ABIpermit) //nolint:errcheck,gosec
|
||||
methodID := hash.Sum(nil)[:4]
|
||||
|
||||
var permit []byte
|
||||
|
||||
@@ -16,25 +16,25 @@ import (
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
var ethClientDialURLConst = "http://localhost:8545"
|
||||
var passwordConst = "pass"
|
||||
var deadlineConst, _ = new(big.Int).SetString("ffffffffffffffffffffffffffffffff", 16)
|
||||
|
||||
var errEnvVar = fmt.Errorf("Some environment variable is missing")
|
||||
|
||||
var (
|
||||
ethClientDialURL = "http://localhost:8545"
|
||||
password = "pass"
|
||||
deadline, _ = new(big.Int).SetString("ffffffffffffffffffffffffffffffff", 16)
|
||||
)
|
||||
|
||||
// Smart Contract Addresses
|
||||
var (
|
||||
password string
|
||||
ethClientDialURL string
|
||||
deadline *big.Int
|
||||
genesisBlock int64
|
||||
auctionAddressConst ethCommon.Address
|
||||
auctionTestAddressConst ethCommon.Address
|
||||
tokenHEZAddressConst ethCommon.Address
|
||||
hermezRollupAddressConst ethCommon.Address
|
||||
wdelayerAddressConst ethCommon.Address
|
||||
wdelayerTestAddressConst ethCommon.Address
|
||||
tokenHEZ TokenConfig
|
||||
genesisBlock int64
|
||||
auctionAddressConst ethCommon.Address
|
||||
auctionTestAddressConst ethCommon.Address
|
||||
tokenHEZAddressConst ethCommon.Address
|
||||
hermezRollupAddressConst ethCommon.Address
|
||||
wdelayerAddressConst ethCommon.Address
|
||||
wdelayerTestAddressConst ethCommon.Address
|
||||
tokenHEZ TokenConfig
|
||||
|
||||
donationAddressStr = "0x6c365935CA8710200C7595F0a72EB6023A7706Cd"
|
||||
donationAddressConst = ethCommon.HexToAddress(donationAddressStr)
|
||||
bootCoordinatorAddressStr = "0xc783df8a850f42e7f7e57013759c285caa701eb6"
|
||||
@@ -65,9 +65,9 @@ var (
|
||||
auxAddressStr = "0x3d91185a02774C70287F6c74Dd26d13DFB58ff16"
|
||||
auxAddressConst = ethCommon.HexToAddress(auxAddressStr)
|
||||
|
||||
aux2AddressSK = "28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29087"
|
||||
aux2AddressStr = "0x532792b73c0c6e7565912e7039c59986f7e1dd1f"
|
||||
aux2AddressConst = ethCommon.HexToAddress(aux2AddressStr)
|
||||
aux2AddressSK = "28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29087"
|
||||
// aux2AddressStr = "0x532792b73c0c6e7565912e7039c59986f7e1dd1f"
|
||||
// aux2AddressConst = ethCommon.HexToAddress(aux2AddressStr)
|
||||
|
||||
hermezRollupTestSK = "28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29088"
|
||||
hermezRollupTestAddressStr = "0xEa960515F8b4C237730F028cBAcF0a28E7F45dE0"
|
||||
@@ -111,7 +111,7 @@ func addKey(ks *keystore.KeyStore, skHex string) *accounts.Account {
|
||||
func getEnvVariables() {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
fmt.Println("Variables loaded from command")
|
||||
fmt.Println("Variables loaded from environment")
|
||||
} else {
|
||||
fmt.Println("Variables loaded from .env file")
|
||||
}
|
||||
@@ -130,9 +130,6 @@ func getEnvVariables() {
|
||||
panic(errEnvVar)
|
||||
}
|
||||
|
||||
ethClientDialURL = ethClientDialURLConst
|
||||
password = passwordConst
|
||||
deadline = deadlineConst
|
||||
auctionAddressConst = ethCommon.HexToAddress(auctionAddressStr)
|
||||
auctionTestAddressConst = ethCommon.HexToAddress(auctionTestAddressStr)
|
||||
tokenHEZAddressConst = ethCommon.HexToAddress(tokenHEZAddressStr)
|
||||
|
||||
@@ -290,13 +290,14 @@ type RollupInterface interface {
|
||||
type RollupClient struct {
|
||||
client *EthereumClient
|
||||
address ethCommon.Address
|
||||
tokenHEZ TokenConfig
|
||||
tokenHEZCfg TokenConfig
|
||||
hermez *Hermez.Hermez
|
||||
tokenHEZ *HEZ.HEZ
|
||||
contractAbi abi.ABI
|
||||
}
|
||||
|
||||
// NewRollupClient creates a new RollupClient
|
||||
func NewRollupClient(client *EthereumClient, address ethCommon.Address, tokenHEZ TokenConfig) (*RollupClient, error) {
|
||||
func NewRollupClient(client *EthereumClient, address ethCommon.Address, tokenHEZCfg TokenConfig) (*RollupClient, error) {
|
||||
contractAbi, err := abi.JSON(strings.NewReader(string(Hermez.HermezABI)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -305,11 +306,16 @@ func NewRollupClient(client *EthereumClient, address ethCommon.Address, tokenHEZ
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tokenHEZ, err := HEZ.NewHEZ(tokenHEZCfg.Address, client.Client())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &RollupClient{
|
||||
client: client,
|
||||
address: address,
|
||||
tokenHEZ: tokenHEZ,
|
||||
tokenHEZCfg: tokenHEZCfg,
|
||||
hermez: hermez,
|
||||
tokenHEZ: tokenHEZ,
|
||||
contractAbi: contractAbi,
|
||||
}, nil
|
||||
}
|
||||
@@ -375,17 +381,16 @@ func (c *RollupClient) RollupAddToken(tokenAddress ethCommon.Address, feeAddToke
|
||||
if tx, err = c.client.CallAuth(
|
||||
0,
|
||||
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||
tokenHEZcontract, err := HEZ.NewHEZ(c.tokenHEZ.Address, ec)
|
||||
owner := c.client.account.Address
|
||||
spender := c.address
|
||||
nonce, err := c.tokenHEZ.Nonces(nil, owner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
owner := c.client.account.Address
|
||||
spender := c.address
|
||||
nonce, err := tokenHEZcontract.Nonces(nil, owner)
|
||||
tokenname := c.tokenHEZ.Name
|
||||
tokenAddr := c.tokenHEZ.Address
|
||||
chainid, _ := c.client.client.ChainID(context.Background())
|
||||
digest, _ := createPermitDigest(tokenAddr, owner, spender, chainid, feeAddToken, nonce, deadline, tokenname)
|
||||
tokenName := c.tokenHEZCfg.Name
|
||||
tokenAddr := c.tokenHEZCfg.Address
|
||||
chainid, _ := c.client.Client().ChainID(context.Background())
|
||||
digest, _ := createPermitDigest(tokenAddr, owner, spender, chainid, feeAddToken, nonce, deadline, tokenName)
|
||||
signature, _ := c.client.ks.SignHash(*c.client.account, digest)
|
||||
permit := createPermit(owner, spender, feeAddToken, deadline, digest, signature)
|
||||
|
||||
@@ -431,7 +436,6 @@ func (c *RollupClient) RollupL1UserTxERC20ETH(fromBJJ *babyjub.PublicKey, fromId
|
||||
babyPubKey := new(big.Int).SetBytes(pkCompB)
|
||||
fromIdxBig := big.NewInt(fromIdx)
|
||||
toIdxBig := big.NewInt(toIdx)
|
||||
tokenIDBig := uint32(tokenID)
|
||||
loadAmountF, err := common.NewFloat16(loadAmount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -444,7 +448,8 @@ func (c *RollupClient) RollupL1UserTxERC20ETH(fromBJJ *babyjub.PublicKey, fromId
|
||||
auth.Value = loadAmount
|
||||
}
|
||||
var permit []byte
|
||||
return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, uint16(loadAmountF), uint16(amountF), tokenIDBig, toIdxBig, permit)
|
||||
return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, uint16(loadAmountF),
|
||||
uint16(amountF), tokenID, toIdxBig, permit)
|
||||
},
|
||||
); err != nil {
|
||||
return nil, fmt.Errorf("Failed add L1 Tx ERC20/ETH: %w", err)
|
||||
@@ -462,7 +467,6 @@ func (c *RollupClient) RollupL1UserTxERC20Permit(fromBJJ *babyjub.PublicKey, fro
|
||||
babyPubKey := new(big.Int).SetBytes(pkCompB)
|
||||
fromIdxBig := big.NewInt(fromIdx)
|
||||
toIdxBig := big.NewInt(toIdx)
|
||||
tokenIDBig := uint32(tokenID)
|
||||
loadAmountF, err := common.NewFloat16(loadAmount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -474,20 +478,20 @@ func (c *RollupClient) RollupL1UserTxERC20Permit(fromBJJ *babyjub.PublicKey, fro
|
||||
if tokenID == 0 {
|
||||
auth.Value = loadAmount
|
||||
}
|
||||
tokenHEZcontract, err := HEZ.NewHEZ(c.tokenHEZ.Address, ec)
|
||||
owner := c.client.account.Address
|
||||
spender := c.address
|
||||
nonce, err := c.tokenHEZ.Nonces(nil, owner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
owner := c.client.account.Address
|
||||
spender := c.address
|
||||
nonce, err := tokenHEZcontract.Nonces(nil, owner)
|
||||
tokenname := c.tokenHEZ.Name
|
||||
tokenAddr := c.tokenHEZ.Address
|
||||
chainid, _ := c.client.client.ChainID(context.Background())
|
||||
digest, _ := createPermitDigest(tokenAddr, owner, spender, chainid, amount, nonce, deadline, tokenname)
|
||||
tokenName := c.tokenHEZCfg.Name
|
||||
tokenAddr := c.tokenHEZCfg.Address
|
||||
chainid, _ := c.client.Client().ChainID(context.Background())
|
||||
digest, _ := createPermitDigest(tokenAddr, owner, spender, chainid, amount, nonce, deadline, tokenName)
|
||||
signature, _ := c.client.ks.SignHash(*c.client.account, digest)
|
||||
permit := createPermit(owner, spender, amount, deadline, digest, signature)
|
||||
return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, uint16(loadAmountF), uint16(amountF), tokenIDBig, toIdxBig, permit)
|
||||
return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, uint16(loadAmountF),
|
||||
uint16(amountF), tokenID, toIdxBig, permit)
|
||||
},
|
||||
); err != nil {
|
||||
return nil, fmt.Errorf("Failed add L1 Tx ERC20Permit: %w", err)
|
||||
|
||||
@@ -105,7 +105,7 @@ func TestRollupForgeBatch(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
// Add Blocks
|
||||
blockNum := int64(int(BLOCKSPERSLOT)*int(currentSlot+4) + int(genesisBlock))
|
||||
blockNum := int64(int(blocksPerSlot)*int(currentSlot+4) + int(genesisBlock))
|
||||
currentBlockNum, _ := auctionClient.client.EthCurrentBlock()
|
||||
blocksToAdd := blockNum - currentBlockNum
|
||||
addBlocks(blocksToAdd, ethClientDialURL)
|
||||
|
||||
@@ -138,7 +138,7 @@ func TestWDelayerWithdrawal(t *testing.T) {
|
||||
amount := new(big.Int)
|
||||
amount.SetString("1100000000000000000", 10)
|
||||
_, err := wdelayerClientTest.WDelayerWithdrawal(auxAddressConst, tokenHEZAddressConst)
|
||||
require.Contains(t, err.Error(), "Withdrawal not allowed yet")
|
||||
require.Contains(t, err.Error(), "WITHDRAWAL_NOT_ALLOWED")
|
||||
addBlocks(newWithdrawalDelay.Int64(), ethClientDialURL)
|
||||
_, err = wdelayerClientTest.WDelayerWithdrawal(auxAddressConst, tokenHEZAddressConst)
|
||||
require.Nil(t, err)
|
||||
@@ -193,7 +193,7 @@ func TestWDelayerEscapeHatchWithdrawal(t *testing.T) {
|
||||
wdelayerClientWhite, err := NewWDelayerClient(ethereumClientWhite, wdelayerTestAddressConst)
|
||||
require.Nil(t, err)
|
||||
_, err = wdelayerClientWhite.WDelayerEscapeHatchWithdrawal(governanceAddressConst, tokenHEZAddressConst, amount)
|
||||
require.Contains(t, err.Error(), "NO MAX_EMERGENCY_MODE_TIME")
|
||||
require.Contains(t, err.Error(), "NO_MAX_EMERGENCY_MODE_TIME")
|
||||
seconds := maxEmergencyModeTime.Seconds()
|
||||
addTime(seconds, ethClientDialURL)
|
||||
_, err = wdelayerClientWhite.WDelayerEscapeHatchWithdrawal(governanceAddressConst, tokenHEZAddressConst, amount)
|
||||
|
||||
Reference in New Issue
Block a user