|
@ -190,6 +190,7 @@ type RollupInterface interface { |
|
|
// RollupClient is the implementation of the interface to the Rollup Smart Contract in ethereum.
|
|
|
// RollupClient is the implementation of the interface to the Rollup Smart Contract in ethereum.
|
|
|
type RollupClient struct { |
|
|
type RollupClient struct { |
|
|
client *EthereumClient |
|
|
client *EthereumClient |
|
|
|
|
|
chainID *big.Int |
|
|
address ethCommon.Address |
|
|
address ethCommon.Address |
|
|
tokenHEZCfg TokenConfig |
|
|
tokenHEZCfg TokenConfig |
|
|
hermez *Hermez.Hermez |
|
|
hermez *Hermez.Hermez |
|
@ -211,8 +212,13 @@ func NewRollupClient(client *EthereumClient, address ethCommon.Address, tokenHEZ |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
|
|
|
chainID, err := client.client.ChainID(context.Background()) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
return &RollupClient{ |
|
|
return &RollupClient{ |
|
|
client: client, |
|
|
client: client, |
|
|
|
|
|
chainID: chainID, |
|
|
address: address, |
|
|
address: address, |
|
|
tokenHEZCfg: tokenHEZCfg, |
|
|
tokenHEZCfg: tokenHEZCfg, |
|
|
hermez: hermez, |
|
|
hermez: hermez, |
|
@ -290,8 +296,7 @@ func (c *RollupClient) RollupAddToken(tokenAddress ethCommon.Address, feeAddToke |
|
|
} |
|
|
} |
|
|
tokenName := c.tokenHEZCfg.Name |
|
|
tokenName := c.tokenHEZCfg.Name |
|
|
tokenAddr := c.tokenHEZCfg.Address |
|
|
tokenAddr := c.tokenHEZCfg.Address |
|
|
chainid, _ := c.client.Client().ChainID(context.Background()) |
|
|
|
|
|
digest, _ := createPermitDigest(tokenAddr, owner, spender, chainid, feeAddToken, nonce, deadline, tokenName) |
|
|
|
|
|
|
|
|
digest, _ := createPermitDigest(tokenAddr, owner, spender, c.chainID, feeAddToken, nonce, deadline, tokenName) |
|
|
signature, _ := c.client.ks.SignHash(*c.client.account, digest) |
|
|
signature, _ := c.client.ks.SignHash(*c.client.account, digest) |
|
|
permit := createPermit(owner, spender, feeAddToken, deadline, digest, signature) |
|
|
permit := createPermit(owner, spender, feeAddToken, deadline, digest, signature) |
|
|
|
|
|
|
|
@ -387,8 +392,7 @@ func (c *RollupClient) RollupL1UserTxERC20Permit(fromBJJ *babyjub.PublicKey, fro |
|
|
} |
|
|
} |
|
|
tokenName := c.tokenHEZCfg.Name |
|
|
tokenName := c.tokenHEZCfg.Name |
|
|
tokenAddr := c.tokenHEZCfg.Address |
|
|
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, c.chainID, amount, nonce, deadline, tokenName) |
|
|
signature, _ := c.client.ks.SignHash(*c.client.account, digest) |
|
|
signature, _ := c.client.ks.SignHash(*c.client.account, digest) |
|
|
permit := createPermit(owner, spender, amount, deadline, digest, signature) |
|
|
permit := createPermit(owner, spender, amount, deadline, digest, signature) |
|
|
return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, uint16(loadAmountF), |
|
|
return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, uint16(loadAmountF), |
|
@ -601,6 +605,7 @@ func (c *RollupClient) RollupForgeBatchArgs(ethTxHash ethCommon.Hash) (*RollupFo |
|
|
return nil, nil, err |
|
|
return nil, nil, err |
|
|
} |
|
|
} |
|
|
txData := tx.Data() |
|
|
txData := tx.Data() |
|
|
|
|
|
|
|
|
method, err := c.contractAbi.MethodById(txData[:4]) |
|
|
method, err := c.contractAbi.MethodById(txData[:4]) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, nil, err |
|
|
return nil, nil, err |
|
@ -641,7 +646,7 @@ func (c *RollupClient) RollupForgeBatchArgs(ethTxHash ethCommon.Hash) (*RollupFo |
|
|
signature = append(signature, r[:]...) |
|
|
signature = append(signature, r[:]...) |
|
|
signature = append(signature, s[:]...) |
|
|
signature = append(signature, s[:]...) |
|
|
signature = append(signature, v) |
|
|
signature = append(signature, v) |
|
|
l1Tx, err := common.L1CoordinatorTxFromBytes(bytesL1Coordinator) |
|
|
|
|
|
|
|
|
l1Tx, err := common.L1CoordinatorTxFromBytes(bytesL1Coordinator, c.chainID, c.address) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, nil, err |
|
|
return nil, nil, err |
|
|
} |
|
|
} |
|
|