Browse Source

Merge pull request #143 from hermeznetwork/feature/ethclient5-sc

Update ethclient auction & add wdelayer
feature/sql-semaphore1
Eduard S 4 years ago
committed by GitHub
parent
commit
dd85322e13
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 2104 additions and 30 deletions
  1. +127
    -15
      eth/auction.go
  2. +66
    -15
      eth/auction_test.go
  3. +1696
    -0
      eth/contracts/erc777/ERC777.go
  4. +214
    -0
      eth/wdelayer.go
  5. +1
    -0
      go.mod

+ 127
- 15
eth/auction.go

@ -1,6 +1,7 @@
package eth package eth
import ( import (
"encoding/binary"
"fmt" "fmt"
"math/big" "math/big"
@ -9,7 +10,9 @@ import (
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
HermezAuctionProtocol "github.com/hermeznetwork/hermez-node/eth/contracts/auction" HermezAuctionProtocol "github.com/hermeznetwork/hermez-node/eth/contracts/auction"
ERC777 "github.com/hermeznetwork/hermez-node/eth/contracts/erc777"
"github.com/hermeznetwork/hermez-node/log" "github.com/hermeznetwork/hermez-node/log"
"golang.org/x/crypto/sha3"
) )
// AuctionConstants are the constants of the Rollup Smart Contract // AuctionConstants are the constants of the Rollup Smart Contract
@ -241,8 +244,7 @@ type AuctionInterface interface {
// AuctionTokensReceived(operator, from, to ethCommon.Address, amount *big.Int, // AuctionTokensReceived(operator, from, to ethCommon.Address, amount *big.Int,
// userData, operatorData []byte) error // Only called from another smart contract // userData, operatorData []byte) error // Only called from another smart contract
AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (*types.Transaction, error) AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (*types.Transaction, error)
AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool,
maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (*types.Transaction, error)
AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (*types.Transaction, error)
// Forge // Forge
AuctionCanForge(forger ethCommon.Address, blockNum int64) (bool, error) AuctionCanForge(forger ethCommon.Address, blockNum int64) (bool, error)
@ -265,17 +267,19 @@ type AuctionInterface interface {
// AuctionClient is the implementation of the interface to the Auction Smart Contract in ethereum. // AuctionClient is the implementation of the interface to the Auction Smart Contract in ethereum.
type AuctionClient struct { type AuctionClient struct {
client *EthereumClient
address ethCommon.Address
gasLimit uint64
client *EthereumClient
address ethCommon.Address
tokenAddress ethCommon.Address
gasLimit uint64
} }
// NewAuctionClient creates a new AuctionClient
func NewAuctionClient(client *EthereumClient, address ethCommon.Address) *AuctionClient {
// NewAuctionClient creates a new AuctionClient. `tokenAddress` is the address of the HEZ tokens.
func NewAuctionClient(client *EthereumClient, address, tokenAddress ethCommon.Address) *AuctionClient {
return &AuctionClient{ return &AuctionClient{
client: client,
address: address,
gasLimit: 1000000, //nolint:gomnd
client: client,
address: address,
tokenAddress: tokenAddress,
gasLimit: 1000000, //nolint:gomnd
} }
} }
@ -539,11 +543,27 @@ func (c *AuctionClient) AuctionChangeDefaultSlotSetBid(slotSet int64, newInitial
return auction.ChangeDefaultSlotSetBid(auth, slotSetToSend, newInitialMinBid) return auction.ChangeDefaultSlotSetBid(auth, slotSetToSend, newInitialMinBid)
}, },
); err != nil { ); err != nil {
return nil, fmt.Errorf("Failed changing epoch minBid: %w", err)
return nil, fmt.Errorf("Failed changing slotSet Bid: %w", err)
} }
return tx, nil return tx, nil
} }
// AuctionGetClaimableHEZ is the interface to call the smart contract function
func (c *AuctionClient) AuctionGetClaimableHEZ(claimAddress ethCommon.Address) (*big.Int, error) {
var claimableHEZ *big.Int
if err := c.client.Call(func(ec *ethclient.Client) error {
auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
if err != nil {
return err
}
claimableHEZ, err = auction.GetClaimableHEZ(nil, claimAddress)
return err
}); err != nil {
return nil, err
}
return claimableHEZ, nil
}
// AuctionRegisterCoordinator is the interface to call the smart contract function // AuctionRegisterCoordinator is the interface to call the smart contract function
func (c *AuctionClient) AuctionRegisterCoordinator(forgerAddress ethCommon.Address, URL string) (*types.Transaction, error) { func (c *AuctionClient) AuctionRegisterCoordinator(forgerAddress ethCommon.Address, URL string) (*types.Transaction, error) {
var tx *types.Transaction var tx *types.Transaction
@ -632,6 +652,23 @@ func (c *AuctionClient) AuctionGetMinBidBySlot(slot int64) (*big.Int, error) {
return minBid, nil return minBid, nil
} }
// AuctionGetSlotSet is the interface to call the smart contract function
func (c *AuctionClient) AuctionGetSlotSet(slot int64) (*big.Int, error) {
var slotSet *big.Int
if err := c.client.Call(func(ec *ethclient.Client) error {
auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(c.address, ec)
if err != nil {
return err
}
slotToSend := big.NewInt(slot)
slotSet, err = auction.GetSlotSet(nil, slotToSend)
return err
}); err != nil {
return big.NewInt(0), err
}
return slotSet, nil
}
// AuctionGetDefaultSlotSetBid is the interface to call the smart contract function // AuctionGetDefaultSlotSetBid is the interface to call the smart contract function
func (c *AuctionClient) AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, error) { func (c *AuctionClient) AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, error) {
var minBidSlotSet *big.Int var minBidSlotSet *big.Int
@ -655,14 +692,89 @@ func (c *AuctionClient) AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, er
// AuctionBid is the interface to call the smart contract function // AuctionBid is the interface to call the smart contract function
func (c *AuctionClient) AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (*types.Transaction, error) { func (c *AuctionClient) AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (*types.Transaction, error) {
log.Error("TODO")
return nil, errTODO
var tx *types.Transaction
var err error
if tx, err = c.client.CallAuth(
c.gasLimit,
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
tokens, err := ERC777.NewERC777(c.tokenAddress, ec)
if err != nil {
return nil, err
}
bidFnSignature := []byte("bid(uint128,uint128,address)")
hash := sha3.NewLegacyKeccak256()
_, err = hash.Write(bidFnSignature)
if err != nil {
return nil, err
}
methodID := hash.Sum(nil)[:4]
slotBytes := make([]byte, 8)
binary.BigEndian.PutUint64(slotBytes, uint64(slot))
paddedSlot := ethCommon.LeftPadBytes(slotBytes, 32)
paddedAmount := ethCommon.LeftPadBytes(bidAmount.Bytes(), 32)
paddedAddress := ethCommon.LeftPadBytes(forger.Bytes(), 32)
var userData []byte
userData = append(userData, methodID...)
userData = append(userData, paddedSlot...)
userData = append(userData, paddedAmount...)
userData = append(userData, paddedAddress...)
return tokens.Send(auth, c.address, bidAmount, userData)
},
); err != nil {
return nil, fmt.Errorf("Failed bid: %w", err)
}
return tx, nil
} }
// AuctionMultiBid is the interface to call the smart contract function // AuctionMultiBid is the interface to call the smart contract function
func (c *AuctionClient) AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (*types.Transaction, error) { func (c *AuctionClient) AuctionMultiBid(startingSlot int64, endingSlot int64, slotSet [6]bool, maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (*types.Transaction, error) {
log.Error("TODO")
return nil, errTODO
var tx *types.Transaction
var err error
if tx, err = c.client.CallAuth(
c.gasLimit,
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
tokens, err := ERC777.NewERC777(c.tokenAddress, ec)
if err != nil {
return nil, err
}
multiBidFnSignature := []byte("multiBid(uint128,uint128,bool[6],uint128,uint128,address)")
hash := sha3.NewLegacyKeccak256()
_, err = hash.Write(multiBidFnSignature)
if err != nil {
return nil, err
}
methodID := hash.Sum(nil)[:4]
startingSlotBytes := make([]byte, 8)
binary.BigEndian.PutUint64(startingSlotBytes, uint64(startingSlot))
paddedStartingSlot := ethCommon.LeftPadBytes(startingSlotBytes, 32)
endingSlotBytes := make([]byte, 8)
binary.BigEndian.PutUint64(endingSlotBytes, uint64(endingSlot))
paddedEndingSlot := ethCommon.LeftPadBytes(endingSlotBytes, 32)
paddedMinBid := ethCommon.LeftPadBytes(closedMinBid.Bytes(), 32)
paddedMaxBid := ethCommon.LeftPadBytes(maxBid.Bytes(), 32)
paddedAddress := ethCommon.LeftPadBytes(forger.Bytes(), 32)
var userData []byte
userData = append(userData, methodID...)
userData = append(userData, paddedStartingSlot...)
userData = append(userData, paddedEndingSlot...)
for i := 0; i < len(slotSet); i++ {
if slotSet[i] {
paddedSlotSet := ethCommon.LeftPadBytes([]byte{1}, 32)
userData = append(userData, paddedSlotSet...)
} else {
paddedSlotSet := ethCommon.LeftPadBytes([]byte{0}, 32)
userData = append(userData, paddedSlotSet...)
}
}
userData = append(userData, paddedMaxBid...)
userData = append(userData, paddedMinBid...)
userData = append(userData, paddedAddress...)
return tokens.Send(auth, c.address, budget, userData)
},
); err != nil {
return nil, fmt.Errorf("Failed multibid: %w", err)
}
return tx, nil
} }
// AuctionCanForge is the interface to call the smart contract function // AuctionCanForge is the interface to call the smart contract function

+ 66
- 15
eth/auction_test.go

@ -26,28 +26,31 @@ var auctionClient *AuctionClient
/*var donationAddressStr = os.Getenv("DONATION_ADDRESS") /*var donationAddressStr = os.Getenv("DONATION_ADDRESS")
var bootCoordinatorStr = os.Getenv("BOOT_COORDINATOR_ADDRESS") var bootCoordinatorStr = os.Getenv("BOOT_COORDINATOR_ADDRESS")
var ehtClientDialURL = os.Getenv("ETHCLIENT_DIAL_URL")
var auctionAddressStr = os.Getenv("AUCTION_ADDRESS")*/
var auctionAddressStr = os.Getenv("AUCTION_ADDRESS")
var tokenHezStr = os.Getenv("TOKEN_ADDRESS")
var hermezStr = os.Getenv("HERMEZ_ADDRESS")
var governanceAddressStr = os.Getenv("GOV_ADDRESS")
var governancePrivateKey = os.Getenv("GOV_PK")
var ehtClientDialURL = os.Getenv("ETHCLIENT_DIAL_URL")*/
var integration = os.Getenv("INTEGRATION") var integration = os.Getenv("INTEGRATION")
var donationAddressStr = "0x6c365935CA8710200C7595F0a72EB6023A7706Cd" var donationAddressStr = "0x6c365935CA8710200C7595F0a72EB6023A7706Cd"
var bootCoordinatorStr = "0xc783df8a850f42e7f7e57013759c285caa701eb6" var bootCoordinatorStr = "0xc783df8a850f42e7f7e57013759c285caa701eb6"
var DONATION = common.HexToAddress(donationAddressStr)
var BOOTCOORDINATOR = common.HexToAddress(bootCoordinatorStr)
var ehtClientDialURL = "http://localhost:8545"
var auctionAddressStr = "0x3619DbE27d7c1e7E91aA738697Ae7Bc5FC3eACA5" var auctionAddressStr = "0x3619DbE27d7c1e7E91aA738697Ae7Bc5FC3eACA5"
// var ownerAddressStr = "0xc783df8a850f42e7F7e57013759C285caa701eB6"
var tokenHezStr = "0xf4e77E5Da47AC3125140c470c71cBca77B5c638c" //nolint:gosec
var hermezStr = "0xc4905364b78a742ccce7B890A89514061E47068D"
var governanceAddressStr = "0xead9c93b79ae7c1591b1fb5323bd777e86e150d4" var governanceAddressStr = "0xead9c93b79ae7c1591b1fb5323bd777e86e150d4"
var governancePrivateKey = "d49743deccbccc5dc7baa8e69e5be03298da8688a15dd202e20f15d5e0e9a9fb" var governancePrivateKey = "d49743deccbccc5dc7baa8e69e5be03298da8688a15dd202e20f15d5e0e9a9fb"
var ehtClientDialURL = "http://localhost:8545"
var DONATION = common.HexToAddress(donationAddressStr)
var BOOTCOORDINATOR = common.HexToAddress(bootCoordinatorStr)
var TOKENHEZ = common.HexToAddress(tokenHezStr)
var HERMEZROLLUP = common.HexToAddress(hermezStr)
var minBidStr = "10000000000000000000" var minBidStr = "10000000000000000000"
var URL = "http://localhost:3000" var URL = "http://localhost:3000"
var newURL = "http://localhost:3002" var newURL = "http://localhost:3002"
var BLOCKSPERSLOT = uint8(40) var BLOCKSPERSLOT = uint8(40)
var TOKENHEZ = common.HexToAddress("0xf4e77E5Da47AC3125140c470c71cBca77B5c638c")
var HERMEZROLLUP = common.HexToAddress("0xc4905364b78a742ccce7B890A89514061E47068D")
var password = "pass" var password = "pass"
func TestNewAction(t *testing.T) { func TestNewAction(t *testing.T) {
@ -65,8 +68,9 @@ func TestNewAction(t *testing.T) {
require.Nil(t, err) require.Nil(t, err)
ethereumClient := NewEthereumClient(ethClient, &account, ks, nil) ethereumClient := NewEthereumClient(ethClient, &account, ks, nil)
auctionAddress := common.HexToAddress(auctionAddressStr) auctionAddress := common.HexToAddress(auctionAddressStr)
tokenAddress := common.HexToAddress(tokenHezStr)
if integration != "" { if integration != "" {
auctionClient = NewAuctionClient(ethereumClient, auctionAddress)
auctionClient = NewAuctionClient(ethereumClient, auctionAddress, tokenAddress)
} }
} }
@ -101,10 +105,10 @@ func TestAuctionVariables(t *testing.T) {
auctionVariables, err := auctionClient.AuctionVariables() auctionVariables, err := auctionClient.AuctionVariables()
require.Nil(t, err) require.Nil(t, err)
assert.Equal(t, auctionVariables.AllocationRatio, allocationRatioConst) assert.Equal(t, auctionVariables.AllocationRatio, allocationRatioConst)
assert.Equal(t, auctionVariables.BootCoordinator, &BOOTCOORDINATOR)
assert.Equal(t, auctionVariables.BootCoordinator, BOOTCOORDINATOR)
assert.Equal(t, auctionVariables.ClosedAuctionSlots, closedAuctionSlotsConst) assert.Equal(t, auctionVariables.ClosedAuctionSlots, closedAuctionSlotsConst)
assert.Equal(t, auctionVariables.DefaultSlotSetBid, defaultSlotSetBid) assert.Equal(t, auctionVariables.DefaultSlotSetBid, defaultSlotSetBid)
assert.Equal(t, auctionVariables.DonationAddress, &DONATION)
assert.Equal(t, auctionVariables.DonationAddress, DONATION)
assert.Equal(t, auctionVariables.OpenAuctionSlots, openAuctionSlotsConst) assert.Equal(t, auctionVariables.OpenAuctionSlots, openAuctionSlotsConst)
assert.Equal(t, auctionVariables.Outbidding, outbiddingConst) assert.Equal(t, auctionVariables.Outbidding, outbiddingConst)
assert.Equal(t, auctionVariables.SlotDeadline, slotDeadlineConst) assert.Equal(t, auctionVariables.SlotDeadline, slotDeadlineConst)
@ -262,6 +266,15 @@ func TestAuctionSetBootCoordinator(t *testing.T) {
} }
} }
func TestAuctionGetSlotSet(t *testing.T) {
slot := int64(10)
if auctionClient != nil {
slotSet, err := auctionClient.AuctionGetSlotSet(slot)
require.Nil(t, err)
assert.Equal(t, slotSet, big.NewInt(4))
}
}
func TestAuctionGetDefaultSlotSetBid(t *testing.T) { func TestAuctionGetDefaultSlotSetBid(t *testing.T) {
slotSet := uint8(3) slotSet := uint8(3)
if auctionClient != nil { if auctionClient != nil {
@ -271,7 +284,7 @@ func TestAuctionGetDefaultSlotSetBid(t *testing.T) {
} }
} }
func TestAuctionChangeEpochMinBid(t *testing.T) {
func TestAuctionChangeDefaultSlotSetBid(t *testing.T) {
slotSet := int64(3) slotSet := int64(3)
set := uint8(3) set := uint8(3)
newInitialMinBid := new(big.Int) newInitialMinBid := new(big.Int)
@ -289,6 +302,15 @@ func TestAuctionChangeEpochMinBid(t *testing.T) {
} }
} }
func TestAuctionGetClaimableHEZ(t *testing.T) {
forgerAddress := common.HexToAddress(governanceAddressStr)
if auctionClient != nil {
claimableHEZ, err := auctionClient.AuctionGetClaimableHEZ(forgerAddress)
require.Nil(t, err)
assert.Equal(t, claimableHEZ.Int64(), int64(0))
}
}
func TestAuctionIsRegisteredCoordinator(t *testing.T) { func TestAuctionIsRegisteredCoordinator(t *testing.T) {
forgerAddress := common.HexToAddress(governanceAddressStr) forgerAddress := common.HexToAddress(governanceAddressStr)
if auctionClient != nil { if auctionClient != nil {
@ -322,3 +344,32 @@ func TestAuctionUpdateCoordinatorInfo(t *testing.T) {
require.Nil(t, err) require.Nil(t, err)
} }
} }
func TestAuctionBid(t *testing.T) {
if auctionClient != nil {
currentSlot, err := auctionClient.AuctionGetCurrentSlotNumber()
require.Nil(t, err)
bidAmount := new(big.Int)
bidAmount.SetString("11000000000000000000", 10)
forgerAddress := common.HexToAddress(governanceAddressStr)
_, err = auctionClient.AuctionBid(currentSlot+4, bidAmount, forgerAddress)
require.Nil(t, err)
}
}
func TestAuctionMultiBid(t *testing.T) {
if auctionClient != nil {
currentSlot, err := auctionClient.AuctionGetCurrentSlotNumber()
require.Nil(t, err)
slotSet := [6]bool{false, true, false, true, false, true}
maxBid := new(big.Int)
maxBid.SetString("11000000000000000000", 10)
minBid := new(big.Int)
minBid.SetString("11000000000000000000", 10)
budget := new(big.Int)
budget.SetString("110000000000000000000", 10)
forgerAddress := common.HexToAddress(governanceAddressStr)
_, err = auctionClient.AuctionMultiBid(currentSlot+5, currentSlot+10, slotSet, maxBid, minBid, budget, forgerAddress)
require.Nil(t, err)
}
}

+ 1696
- 0
eth/contracts/erc777/ERC777.go
File diff suppressed because it is too large
View File


+ 214
- 0
eth/wdelayer.go

@ -0,0 +1,214 @@
package eth
import (
"math/big"
ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
// WDelayerConstants are the constants of the Rollup Smart Contract
type WDelayerConstants struct {
// Max Withdrawal Delay
MaxWithdrawalDelay uint64
// Max Emergency mode time
MaxEmergencyModeTime uint64
// HermezRollup smartcontract address
HermezRollup ethCommon.Address
}
// DepositState is the state of Deposit
type DepositState struct {
Amount *big.Int
DepositTimestamp uint64
}
// WDelayerEventDeposit is an event of the WithdrawalDelayer Smart Contract
type WDelayerEventDeposit struct {
Owner ethCommon.Address
Token ethCommon.Address
Amount *big.Int
DepositTimestamp uint64
}
// WDelayerEventWithdraw is an event of the WithdrawalDelayer Smart Contract
type WDelayerEventWithdraw struct {
Owner ethCommon.Address
Token ethCommon.Address
Amount *big.Int
}
// WDelayerEventEmergencyModeEnabled an event of the WithdrawalDelayer Smart Contract
type WDelayerEventEmergencyModeEnabled struct {
}
// WDelayerEventNewWithdrawalDelay an event of the WithdrawalDelayer Smart Contract
type WDelayerEventNewWithdrawalDelay struct {
WithdrawalDelay uint64
}
// WDelayerEventEscapeHatchWithdrawal an event of the WithdrawalDelayer Smart Contract
type WDelayerEventEscapeHatchWithdrawal struct {
Who ethCommon.Address
To ethCommon.Address
Token ethCommon.Address
}
// WDelayerEventNewHermezKeeperAddress an event of the WithdrawalDelayer Smart Contract
type WDelayerEventNewHermezKeeperAddress struct {
NewHermezKeeperAddress ethCommon.Address
}
// WDelayerEventNewWhiteHackGroupAddress an event of the WithdrawalDelayer Smart Contract
type WDelayerEventNewWhiteHackGroupAddress struct {
NewWhiteHackGroupAddress ethCommon.Address
}
// WDelayerEventNewHermezGovernanceDAOAddress an event of the WithdrawalDelayer Smart Contract
type WDelayerEventNewHermezGovernanceDAOAddress struct {
NewHermezGovernanceDAOAddress ethCommon.Address
}
// WDelayerEvents is the lis of events in a block of the WithdrawalDelayer Smart Contract
type WDelayerEvents struct { //nolint:structcheck
Deposit []WDelayerEventDeposit
Withdraw []WDelayerEventWithdraw
EmergencyModeEnabled []WDelayerEventEmergencyModeEnabled
NewWithdrawalDelay []WDelayerEventNewWithdrawalDelay
EscapeHatchWithdrawal []WDelayerEventEscapeHatchWithdrawal
NewHermezKeeperAddress []WDelayerEventNewHermezKeeperAddress
NewWhiteHackGroupAddress []WDelayerEventNewWhiteHackGroupAddress
NewHermezGovernanceDAOAddress []WDelayerEventNewHermezGovernanceDAOAddress
}
// NewWDelayerEvents creates an empty WDelayerEvents with the slices initialized.
func NewWDelayerEvents() WDelayerEvents {
return WDelayerEvents{
Deposit: make([]WDelayerEventDeposit, 0),
Withdraw: make([]WDelayerEventWithdraw, 0),
EmergencyModeEnabled: make([]WDelayerEventEmergencyModeEnabled, 0),
NewWithdrawalDelay: make([]WDelayerEventNewWithdrawalDelay, 0),
EscapeHatchWithdrawal: make([]WDelayerEventEscapeHatchWithdrawal, 0),
NewHermezKeeperAddress: make([]WDelayerEventNewHermezKeeperAddress, 0),
NewWhiteHackGroupAddress: make([]WDelayerEventNewWhiteHackGroupAddress, 0),
NewHermezGovernanceDAOAddress: make([]WDelayerEventNewHermezGovernanceDAOAddress, 0),
}
}
// WDelayerInterface is the inteface to WithdrawalDelayer Smart Contract
type WDelayerInterface interface {
//
// Smart Contract Methods
//
WDelayerGetHermezGovernanceDAOAddress() (*ethCommon.Address, error)
WDelayerSetHermezGovernanceDAOAddress(newAddress ethCommon.Address) (*types.Transaction, error)
WDelayerGetHermezKeeperAddress() (*ethCommon.Address, error)
WDelayerSetHermezKeeperAddress(newAddress ethCommon.Address) (*types.Transaction, error)
WDelayerGetWhiteHackGroupAddress() (*ethCommon.Address, error)
WDelayerSetWhiteHackGroupAddress(newAddress ethCommon.Address) (*types.Transaction, error)
WDelayerIsEmergencyMode() (bool, error)
WDelayerGetWithdrawalDelay() (*big.Int, error)
WDelayerGetEmergencyModeStartingTime() (*big.Int, error)
WDelayerEnableEmergencyMode() (*types.Transaction, error)
WDelayerChangeWithdrawalDelay(newWithdrawalDelay uint64) (*types.Transaction, error)
WDelayerDepositInfo(owner, token ethCommon.Address) (*big.Int, uint64)
WDelayerDeposit(onwer, token ethCommon.Address, amount *big.Int) (*types.Transaction, error)
WDelayerWithdrawal(owner, token ethCommon.Address) (*types.Transaction, error)
WDelayerEscapeHatchWithdrawal(to, token ethCommon.Address) (*types.Transaction, error)
}
//
// Implementation
//
// WDelayerClient is the implementation of the interface to the WithdrawDelayer Smart Contract in ethereum.
type WDelayerClient struct {
client *EthereumClient
address ethCommon.Address
gasLimit uint64
}
// NewWDelayerClient creates a new WDelayerClient
func NewWDelayerClient(client *EthereumClient, address ethCommon.Address) *WDelayerClient {
return &WDelayerClient{
client: client,
address: address,
gasLimit: 1000000, //nolint:gomnd
}
}
// WDelayerGetHermezGovernanceDAOAddress is the interface to call the smart contract function
func (c *WDelayerClient) WDelayerGetHermezGovernanceDAOAddress() (*ethCommon.Address, error) {
return nil, errTODO
}
// WDelayerSetHermezGovernanceDAOAddress is the interface to call the smart contract function
func WDelayerSetHermezGovernanceDAOAddress(newAddress ethCommon.Address) (*types.Transaction, error) {
return nil, errTODO
}
// WDelayerGetHermezKeeperAddress is the interface to call the smart contract function
func WDelayerGetHermezKeeperAddress() (*ethCommon.Address, error) {
return nil, errTODO
}
// WDelayerSetHermezKeeperAddress is the interface to call the smart contract function
func WDelayerSetHermezKeeperAddress(newAddress ethCommon.Address) (*types.Transaction, error) {
return nil, errTODO
}
// WDelayerGetWhiteHackGroupAddress is the interface to call the smart contract function
func WDelayerGetWhiteHackGroupAddress() (*ethCommon.Address, error) {
return nil, errTODO
}
// WDelayerSetWhiteHackGroupAddress is the interface to call the smart contract function
func WDelayerSetWhiteHackGroupAddress(newAddress ethCommon.Address) (*types.Transaction, error) {
return nil, errTODO
}
// WDelayerIsEmergencyMode is the interface to call the smart contract function
func WDelayerIsEmergencyMode() (bool, error) {
return false, errTODO
}
// WDelayerGetWithdrawalDelay is the interface to call the smart contract function
func WDelayerGetWithdrawalDelay() (*big.Int, error) {
return nil, errTODO
}
// WDelayerGetEmergencyModeStartingTime is the interface to call the smart contract function
func WDelayerGetEmergencyModeStartingTime() (*big.Int, error) {
return nil, errTODO
}
// WDelayerEnableEmergencyMode is the interface to call the smart contract function
func WDelayerEnableEmergencyMode() (*types.Transaction, error) {
return nil, errTODO
}
// WDelayerChangeWithdrawalDelay is the interface to call the smart contract function
func WDelayerChangeWithdrawalDelay(newWithdrawalDelay uint64) (*types.Transaction, error) {
return nil, errTODO
}
// WDelayerDepositInfo is the interface to call the smart contract function
func WDelayerDepositInfo(owner, token ethCommon.Address) (*big.Int, uint64, error) {
return big.NewInt(0), 0, errTODO
}
// WDelayerDeposit is the interface to call the smart contract function
func WDelayerDeposit(onwer, token ethCommon.Address, amount *big.Int) (*types.Transaction, error) {
return nil, errTODO
}
// WDelayerWithdrawal is the interface to call the smart contract function
func WDelayerWithdrawal(owner, token ethCommon.Address) (*types.Transaction, error) {
return nil, errTODO
}
// WDelayerEscapeHatchWithdrawal is the interface to call the smart contract function
func WDelayerEscapeHatchWithdrawal(to, token ethCommon.Address) (*types.Transaction, error) {
return nil, errTODO
}

+ 1
- 0
go.mod

@ -22,5 +22,6 @@ require (
github.com/urfave/cli/v2 v2.2.0 github.com/urfave/cli/v2 v2.2.0
go.uber.org/multierr v1.6.0 // indirect go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.16.0 go.uber.org/zap v1.16.0
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
gopkg.in/go-playground/validator.v9 v9.29.1 gopkg.in/go-playground/validator.v9 v9.29.1
) )

Loading…
Cancel
Save