Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Filter past events related to tbtc specific actions #608

Merged
merged 11 commits into from
Nov 18, 2020
Next Next commit
Using generated function to retrieve past events
  • Loading branch information
dimpar committed Nov 18, 2020
commit fef6714262a8a0a907e045d01a614270b5244880
18 changes: 6 additions & 12 deletions pkg/chain/ethereum/ethereum.go
Original file line number Diff line number Diff line change
@@ -8,8 +8,6 @@ import (
"sort"
"time"

"github.com/keep-network/keep-ecdsa/pkg/chain/gen/eventlog"

"github.com/ethereum/go-ethereum/common"

"github.com/ipfs/go-log"
@@ -516,24 +514,20 @@ func (ec *EthereumChain) GetOpenedTimestamp(keepAddress common.Address) (time.Ti
// for the given keep which occurred after the provided start block.
// Returned events are sorted by the block number in the ascending order.
func (ec *EthereumChain) PastSignatureSubmittedEvents(
keepAddress string,
keepAddress common.Address,
startBlock uint64,
) ([]*eth.SignatureSubmittedEvent, error) {
if !common.IsHexAddress(keepAddress) {
return nil, fmt.Errorf("invalid keep address: [%v]", keepAddress)
}
pdyraga marked this conversation as resolved.
Show resolved Hide resolved

keepContractEventLog, err := eventlog.NewBondedECDSAKeepEventLog(
common.HexToAddress(keepAddress),
ec.client,
)
keepContract, err := ec.getKeepContract(keepAddress)
if err != nil {
return nil, err
}

events, err := keepContractEventLog.PastSignatureSubmittedEvents(
// 2nd nil denotes latest block
events, err := keepContract.PastSignatureSubmittedEvents(
startBlock,
nil,
lukasz-zimnoch marked this conversation as resolved.
Show resolved Hide resolved
nil,
)
if err != nil {
return nil, err
@@ -547,7 +541,7 @@ func (ec *EthereumChain) PastSignatureSubmittedEvents(
R: event.R,
S: event.S,
RecoveryID: event.RecoveryID,
BlockNumber: event.BlockNumber,
BlockNumber: event.Raw.BlockNumber,
})
}