mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
Wrap all errors with tracerr
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/hermeznetwork/hermez-node/common"
|
||||
"github.com/hermeznetwork/hermez-node/eth"
|
||||
"github.com/hermeznetwork/hermez-node/log"
|
||||
"github.com/hermeznetwork/tracerr"
|
||||
"github.com/iden3/go-iden3-crypto/babyjub"
|
||||
"github.com/mitchellh/copystructure"
|
||||
)
|
||||
@@ -111,7 +112,7 @@ func (a *AuctionBlock) getSlotSet(slot int64) int64 {
|
||||
|
||||
func (a *AuctionBlock) getMinBidBySlot(slot int64) (*big.Int, error) {
|
||||
if slot < a.getCurrentSlotNumber()+int64(a.Vars.ClosedAuctionSlots) {
|
||||
return nil, errBidClosed
|
||||
return nil, tracerr.Wrap(errBidClosed)
|
||||
}
|
||||
|
||||
slotSet := a.getSlotSet(slot)
|
||||
@@ -140,9 +141,9 @@ func (a *AuctionBlock) getMinBidBySlot(slot int64) (*big.Int, error) {
|
||||
|
||||
func (a *AuctionBlock) forge(forger ethCommon.Address) error {
|
||||
if ok, err := a.canForge(forger, a.Eth.BlockNum); err != nil {
|
||||
return err
|
||||
return tracerr.Wrap(err)
|
||||
} else if !ok {
|
||||
return fmt.Errorf("Can't forge")
|
||||
return tracerr.Wrap(fmt.Errorf("Can't forge"))
|
||||
}
|
||||
|
||||
slotToForge := a.getSlotNumber(a.Eth.BlockNum)
|
||||
@@ -162,7 +163,7 @@ func (a *AuctionBlock) forge(forger ethCommon.Address) error {
|
||||
|
||||
func (a *AuctionBlock) canForge(forger ethCommon.Address, blockNum int64) (bool, error) {
|
||||
if blockNum < a.Constants.GenesisBlockNum {
|
||||
return false, fmt.Errorf("Auction has not started yet")
|
||||
return false, tracerr.Wrap(fmt.Errorf("Auction has not started yet"))
|
||||
}
|
||||
|
||||
slotToForge := a.getSlotNumber(blockNum)
|
||||
@@ -616,7 +617,7 @@ func (c *Client) EthERC20Consts(tokenAddr ethCommon.Address) (*eth.ERC20Consts,
|
||||
if constants, ok := e.Tokens[tokenAddr]; ok {
|
||||
return &constants, nil
|
||||
}
|
||||
return nil, fmt.Errorf("tokenAddr not found")
|
||||
return nil, tracerr.Wrap(fmt.Errorf("tokenAddr not found"))
|
||||
}
|
||||
|
||||
// func newHeader(number *big.Int) *types.Header {
|
||||
@@ -656,7 +657,7 @@ func (c *Client) EthBlockByNumber(ctx context.Context, blockNum int64) (*common.
|
||||
// EthAddress returns the ethereum address of the account loaded into the Client
|
||||
func (c *Client) EthAddress() (*ethCommon.Address, error) {
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
return c.addr, nil
|
||||
}
|
||||
@@ -697,7 +698,7 @@ var errTODO = fmt.Errorf("TODO: Not implemented yet")
|
||||
// RollupL1UserTxERC20Permit is the interface to call the smart contract function
|
||||
func (c *Client) RollupL1UserTxERC20Permit(fromBJJ *babyjub.PublicKey, fromIdx int64, loadAmount *big.Int, amount *big.Int, tokenID uint32, toIdx int64, deadline *big.Int) (tx *types.Transaction, err error) {
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// RollupL1UserTxERC20ETH sends an L1UserTx to the Rollup.
|
||||
@@ -716,11 +717,11 @@ func (c *Client) RollupL1UserTxERC20ETH(
|
||||
|
||||
_, err = common.NewFloat16(amount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
_, err = common.NewFloat16(loadAmount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
|
||||
nextBlock := c.nextBlock()
|
||||
@@ -751,7 +752,7 @@ func (c *Client) RollupL1UserTxERC20ETH(
|
||||
UserOrigin: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
|
||||
queue.L1TxQueue = append(queue.L1TxQueue, *l1Tx)
|
||||
@@ -770,7 +771,7 @@ func (c *Client) RollupL1UserTxERC20ETH(
|
||||
// RollupRegisterTokensCount is the interface to call the smart contract function
|
||||
func (c *Client) RollupRegisterTokensCount() (*big.Int, error) {
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// RollupLastForgedBatch is the interface to call the smart contract function
|
||||
@@ -786,7 +787,7 @@ func (c *Client) RollupLastForgedBatch() (int64, error) {
|
||||
// RollupWithdrawCircuit is the interface to call the smart contract function
|
||||
func (c *Client) RollupWithdrawCircuit(proofA, proofC [2]*big.Int, proofB [2][2]*big.Int, tokenID uint32, numExitRoot, idx int64, amount *big.Int, instantWithdraw bool) (*types.Transaction, error) {
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// RollupWithdrawMerkleProof is the interface to call the smart contract function
|
||||
@@ -800,10 +801,10 @@ func (c *Client) RollupWithdrawMerkleProof(babyPubKey *babyjub.PublicKey, tokenI
|
||||
r := nextBlock.Rollup
|
||||
|
||||
if int(numExitRoot) >= len(r.State.ExitRoots) {
|
||||
return nil, fmt.Errorf("numExitRoot >= len(r.State.ExitRoots)")
|
||||
return nil, tracerr.Wrap(fmt.Errorf("numExitRoot >= len(r.State.ExitRoots)"))
|
||||
}
|
||||
if _, ok := r.State.ExitNullifierMap[numExitRoot][idx]; ok {
|
||||
return nil, fmt.Errorf("exit already withdrawn")
|
||||
return nil, tracerr.Wrap(fmt.Errorf("exit already withdrawn"))
|
||||
}
|
||||
r.State.ExitNullifierMap[numExitRoot][idx] = true
|
||||
|
||||
@@ -860,16 +861,16 @@ func (c *Client) RollupForgeBatch(args *eth.RollupForgeBatchArgs) (tx *types.Tra
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
a := c.nextBlock().Auction
|
||||
ok, err := a.canForge(*c.addr, a.Eth.BlockNum)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("incorrect slot")
|
||||
return nil, tracerr.Wrap(fmt.Errorf("incorrect slot"))
|
||||
}
|
||||
|
||||
// TODO: Verify proof
|
||||
@@ -877,7 +878,7 @@ func (c *Client) RollupForgeBatch(args *eth.RollupForgeBatchArgs) (tx *types.Tra
|
||||
// Auction
|
||||
err = a.forge(*c.addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
|
||||
// TODO: If successful, store the tx in a successful array.
|
||||
@@ -902,7 +903,7 @@ func (c *Client) addBatch(args *eth.RollupForgeBatchArgs) (*types.Transaction, e
|
||||
r := nextBlock.Rollup
|
||||
r.State.StateRoot = args.NewStRoot
|
||||
if args.NewLastIdx < r.State.CurrentIdx {
|
||||
return nil, fmt.Errorf("args.NewLastIdx < r.State.CurrentIdx")
|
||||
return nil, tracerr.Wrap(fmt.Errorf("args.NewLastIdx < r.State.CurrentIdx"))
|
||||
}
|
||||
r.State.CurrentIdx = args.NewLastIdx
|
||||
r.State.ExitNullifierMap[int64(len(r.State.ExitRoots))] = make(map[int64]bool)
|
||||
@@ -938,16 +939,16 @@ func (c *Client) RollupAddToken(tokenAddress ethCommon.Address, feeAddToken *big
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
nextBlock := c.nextBlock()
|
||||
r := nextBlock.Rollup
|
||||
if _, ok := r.State.TokenMap[tokenAddress]; ok {
|
||||
return nil, fmt.Errorf("Token %v already registered", tokenAddress)
|
||||
return nil, tracerr.Wrap(fmt.Errorf("Token %v already registered", tokenAddress))
|
||||
}
|
||||
if feeAddToken.Cmp(r.Vars.FeeAddToken) != 0 {
|
||||
return nil, fmt.Errorf("Expected fee: %v but got: %v", r.Vars.FeeAddToken, feeAddToken)
|
||||
return nil, tracerr.Wrap(fmt.Errorf("Expected fee: %v but got: %v", r.Vars.FeeAddToken, feeAddToken))
|
||||
}
|
||||
|
||||
r.State.TokenMap[tokenAddress] = true
|
||||
@@ -963,7 +964,7 @@ func (c *Client) RollupGetCurrentTokens() (*big.Int, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// RollupUpdateForgeL1L2BatchTimeout is the interface to call the smart contract function
|
||||
@@ -973,7 +974,7 @@ func (c *Client) RollupUpdateForgeL1L2BatchTimeout(newForgeL1Timeout int64) (tx
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
nextBlock := c.nextBlock()
|
||||
@@ -992,11 +993,11 @@ func (c *Client) RollupUpdateFeeAddToken(newFeeAddToken *big.Int) (tx *types.Tra
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// RollupUpdateTokensHEZ is the interface to call the smart contract function
|
||||
@@ -1030,7 +1031,7 @@ func (c *Client) RollupEventsByBlock(blockNum int64) (*eth.RollupEvents, *ethCom
|
||||
|
||||
block, ok := c.blocks[blockNum]
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("Block %v doesn't exist", blockNum)
|
||||
return nil, nil, tracerr.Wrap(fmt.Errorf("Block %v doesn't exist", blockNum))
|
||||
}
|
||||
return &block.Rollup.Events, &block.Eth.Hash, nil
|
||||
}
|
||||
@@ -1042,7 +1043,7 @@ func (c *Client) RollupForgeBatchArgs(ethTxHash ethCommon.Hash) (*eth.RollupForg
|
||||
|
||||
batch, ok := c.forgeBatchArgs[ethTxHash]
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("transaction not found")
|
||||
return nil, nil, tracerr.Wrap(fmt.Errorf("transaction not found"))
|
||||
}
|
||||
return &batch.ForgeBatchArgs, &batch.Sender, nil
|
||||
}
|
||||
@@ -1058,11 +1059,11 @@ func (c *Client) AuctionSetSlotDeadline(newDeadline uint8) (tx *types.Transactio
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionGetSlotDeadline is the interface to call the smart contract function
|
||||
@@ -1071,7 +1072,7 @@ func (c *Client) AuctionGetSlotDeadline() (uint8, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return 0, errTODO
|
||||
return 0, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionSetOpenAuctionSlots is the interface to call the smart contract function
|
||||
@@ -1081,7 +1082,7 @@ func (c *Client) AuctionSetOpenAuctionSlots(newOpenAuctionSlots uint16) (tx *typ
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
nextBlock := c.nextBlock()
|
||||
@@ -1099,7 +1100,7 @@ func (c *Client) AuctionGetOpenAuctionSlots() (uint16, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return 0, errTODO
|
||||
return 0, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionSetClosedAuctionSlots is the interface to call the smart contract function
|
||||
@@ -1109,11 +1110,11 @@ func (c *Client) AuctionSetClosedAuctionSlots(newClosedAuctionSlots uint16) (tx
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionGetClosedAuctionSlots is the interface to call the smart contract function
|
||||
@@ -1122,7 +1123,7 @@ func (c *Client) AuctionGetClosedAuctionSlots() (uint16, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return 0, errTODO
|
||||
return 0, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionSetOutbidding is the interface to call the smart contract function
|
||||
@@ -1132,11 +1133,11 @@ func (c *Client) AuctionSetOutbidding(newOutbidding uint16) (tx *types.Transacti
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionGetOutbidding is the interface to call the smart contract function
|
||||
@@ -1145,7 +1146,7 @@ func (c *Client) AuctionGetOutbidding() (uint16, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return 0, errTODO
|
||||
return 0, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionSetAllocationRatio is the interface to call the smart contract function
|
||||
@@ -1155,11 +1156,11 @@ func (c *Client) AuctionSetAllocationRatio(newAllocationRatio [3]uint16) (tx *ty
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionGetAllocationRatio is the interface to call the smart contract function
|
||||
@@ -1168,7 +1169,7 @@ func (c *Client) AuctionGetAllocationRatio() ([3]uint16, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return [3]uint16{}, errTODO
|
||||
return [3]uint16{}, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionSetDonationAddress is the interface to call the smart contract function
|
||||
@@ -1178,11 +1179,11 @@ func (c *Client) AuctionSetDonationAddress(newDonationAddress ethCommon.Address)
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionGetDonationAddress is the interface to call the smart contract function
|
||||
@@ -1191,7 +1192,7 @@ func (c *Client) AuctionGetDonationAddress() (*ethCommon.Address, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionSetBootCoordinator is the interface to call the smart contract function
|
||||
@@ -1201,11 +1202,11 @@ func (c *Client) AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address)
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionGetBootCoordinator is the interface to call the smart contract function
|
||||
@@ -1226,11 +1227,11 @@ func (c *Client) AuctionChangeDefaultSlotSetBid(slotSet int64, newInitialMinBid
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionSetCoordinator is the interface to call the smart contract function
|
||||
@@ -1240,7 +1241,7 @@ func (c *Client) AuctionSetCoordinator(forger ethCommon.Address, URL string) (tx
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
nextBlock := c.nextBlock()
|
||||
@@ -1272,7 +1273,7 @@ func (c *Client) AuctionIsRegisteredCoordinator(forgerAddress ethCommon.Address)
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return false, errTODO
|
||||
return false, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionUpdateCoordinatorInfo is the interface to call the smart contract function
|
||||
@@ -1282,11 +1283,11 @@ func (c *Client) AuctionUpdateCoordinatorInfo(forgerAddress ethCommon.Address, n
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionGetSlotNumber is the interface to call the smart contract function
|
||||
@@ -1305,7 +1306,7 @@ func (c *Client) AuctionGetCurrentSlotNumber() (int64, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return 0, errTODO
|
||||
return 0, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionGetMinBidBySlot is the interface to call the smart contract function
|
||||
@@ -1314,7 +1315,7 @@ func (c *Client) AuctionGetMinBidBySlot(slot int64) (*big.Int, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionGetDefaultSlotSetBid is the interface to call the smart contract function
|
||||
@@ -1323,7 +1324,7 @@ func (c *Client) AuctionGetDefaultSlotSetBid(slotSet uint8) (*big.Int, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionGetSlotSet is the interface to call the smart contract function
|
||||
@@ -1332,7 +1333,7 @@ func (c *Client) AuctionGetSlotSet(slot int64) (*big.Int, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionTokensReceived is the interface to call the smart contract function
|
||||
@@ -1354,30 +1355,30 @@ func (c *Client) AuctionBid(amount *big.Int, slot int64, bidAmount *big.Int,
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { func() { c.revertIfErr(err, cpy) }() }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
nextBlock := c.nextBlock()
|
||||
a := nextBlock.Auction
|
||||
|
||||
if slot < a.getCurrentSlotNumber()+int64(a.Vars.ClosedAuctionSlots) {
|
||||
return nil, errBidClosed
|
||||
return nil, tracerr.Wrap(errBidClosed)
|
||||
}
|
||||
|
||||
if slot >= a.getCurrentSlotNumber()+int64(a.Vars.ClosedAuctionSlots)+int64(a.Vars.OpenAuctionSlots) {
|
||||
return nil, errBidNotOpen
|
||||
return nil, tracerr.Wrap(errBidNotOpen)
|
||||
}
|
||||
|
||||
minBid, err := a.getMinBidBySlot(slot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
if bidAmount.Cmp(minBid) == -1 {
|
||||
return nil, errBidBelowMin
|
||||
return nil, tracerr.Wrap(errBidBelowMin)
|
||||
}
|
||||
|
||||
if _, ok := a.State.Coordinators[*c.addr]; !ok {
|
||||
return nil, errCoordNotReg
|
||||
return nil, tracerr.Wrap(errCoordNotReg)
|
||||
}
|
||||
|
||||
slotState, ok := a.State.Slots[slot]
|
||||
@@ -1408,11 +1409,11 @@ func (c *Client) AuctionMultiBid(amount *big.Int, startingSlot int64, endingSlot
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionCanForge is the interface to call the smart contract function
|
||||
@@ -1432,11 +1433,11 @@ func (c *Client) AuctionForge(forger ethCommon.Address) (tx *types.Transaction,
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionClaimHEZ is the interface to call the smart contract function
|
||||
@@ -1446,11 +1447,11 @@ func (c *Client) AuctionClaimHEZ() (tx *types.Transaction, err error) {
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionGetClaimableHEZ is the interface to call the smart contract function
|
||||
@@ -1459,7 +1460,7 @@ func (c *Client) AuctionGetClaimableHEZ(bidder ethCommon.Address) (*big.Int, err
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// AuctionConstants returns the Constants of the Auction Smart Contract
|
||||
@@ -1477,7 +1478,7 @@ func (c *Client) AuctionEventsByBlock(blockNum int64) (*eth.AuctionEvents, *ethC
|
||||
|
||||
block, ok := c.blocks[blockNum]
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("Block %v doesn't exist", blockNum)
|
||||
return nil, nil, tracerr.Wrap(fmt.Errorf("Block %v doesn't exist", blockNum))
|
||||
}
|
||||
return &block.Auction.Events, &block.Eth.Hash, nil
|
||||
}
|
||||
@@ -1492,7 +1493,7 @@ func (c *Client) WDelayerGetHermezGovernanceDAOAddress() (*ethCommon.Address, er
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerSetHermezGovernanceDAOAddress is the interface to call the smart contract function
|
||||
@@ -1502,11 +1503,11 @@ func (c *Client) WDelayerSetHermezGovernanceDAOAddress(newAddress ethCommon.Addr
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerGetHermezKeeperAddress is the interface to call the smart contract function
|
||||
@@ -1515,7 +1516,7 @@ func (c *Client) WDelayerGetHermezKeeperAddress() (*ethCommon.Address, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerSetHermezKeeperAddress is the interface to call the smart contract function
|
||||
@@ -1525,11 +1526,11 @@ func (c *Client) WDelayerSetHermezKeeperAddress(newAddress ethCommon.Address) (t
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerGetWhiteHackGroupAddress is the interface to call the smart contract function
|
||||
@@ -1538,7 +1539,7 @@ func (c *Client) WDelayerGetWhiteHackGroupAddress() (*ethCommon.Address, error)
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerSetWhiteHackGroupAddress is the interface to call the smart contract function
|
||||
@@ -1548,11 +1549,11 @@ func (c *Client) WDelayerSetWhiteHackGroupAddress(newAddress ethCommon.Address)
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerIsEmergencyMode is the interface to call the smart contract function
|
||||
@@ -1561,7 +1562,7 @@ func (c *Client) WDelayerIsEmergencyMode() (bool, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return false, errTODO
|
||||
return false, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerGetWithdrawalDelay is the interface to call the smart contract function
|
||||
@@ -1570,7 +1571,7 @@ func (c *Client) WDelayerGetWithdrawalDelay() (*big.Int, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerGetEmergencyModeStartingTime is the interface to call the smart contract function
|
||||
@@ -1579,7 +1580,7 @@ func (c *Client) WDelayerGetEmergencyModeStartingTime() (*big.Int, error) {
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerEnableEmergencyMode is the interface to call the smart contract function
|
||||
@@ -1589,11 +1590,11 @@ func (c *Client) WDelayerEnableEmergencyMode() (tx *types.Transaction, err error
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerChangeWithdrawalDelay is the interface to call the smart contract function
|
||||
@@ -1603,7 +1604,7 @@ func (c *Client) WDelayerChangeWithdrawalDelay(newWithdrawalDelay uint64) (tx *t
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
nextBlock := c.nextBlock()
|
||||
@@ -1621,7 +1622,7 @@ func (c *Client) WDelayerDepositInfo(owner, token ethCommon.Address) (eth.Deposi
|
||||
defer c.rw.RUnlock()
|
||||
|
||||
log.Error("TODO")
|
||||
return eth.DepositState{}, errTODO
|
||||
return eth.DepositState{}, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerDeposit is the interface to call the smart contract function
|
||||
@@ -1631,11 +1632,11 @@ func (c *Client) WDelayerDeposit(onwer, token ethCommon.Address, amount *big.Int
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerWithdrawal is the interface to call the smart contract function
|
||||
@@ -1645,11 +1646,11 @@ func (c *Client) WDelayerWithdrawal(owner, token ethCommon.Address) (tx *types.T
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerEscapeHatchWithdrawal is the interface to call the smart contract function
|
||||
@@ -1659,11 +1660,11 @@ func (c *Client) WDelayerEscapeHatchWithdrawal(to, token ethCommon.Address, amou
|
||||
cpy := c.nextBlock().copy()
|
||||
defer func() { c.revertIfErr(err, cpy) }()
|
||||
if c.addr == nil {
|
||||
return nil, eth.ErrAccountNil
|
||||
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||
}
|
||||
|
||||
log.Error("TODO")
|
||||
return nil, errTODO
|
||||
return nil, tracerr.Wrap(errTODO)
|
||||
}
|
||||
|
||||
// WDelayerEventsByBlock returns the events in a block that happened in the WDelayer Contract
|
||||
@@ -1673,7 +1674,7 @@ func (c *Client) WDelayerEventsByBlock(blockNum int64) (*eth.WDelayerEvents, *et
|
||||
|
||||
block, ok := c.blocks[blockNum]
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("Block %v doesn't exist", blockNum)
|
||||
return nil, nil, tracerr.Wrap(fmt.Errorf("Block %v doesn't exist", blockNum))
|
||||
}
|
||||
return &block.WDelayer.Events, &block.Eth.Hash, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user