-
Notifications
You must be signed in to change notification settings - Fork 18
/
mapprotocol.go
46 lines (39 loc) · 1.34 KB
/
mapprotocol.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package mapprotocol
import (
eth "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/mapprotocol/atlas/accounts/abi"
"math/big"
)
type EventSig string
const (
//event ValidatorEpochPaymentDistributed(address indexed validator, uint256 validatorPayment);
ValidatorEpochPaymentDistributed EventSig = "ValidatorEpochPaymentDistributed(address,uint256)"
//event EpochRewardsDistributedToVoters(address indexed voterAddress, uint256 value);
EpochRewardsDistributedToVoters EventSig = "EpochRewardsDistributedToVoters(address,uint256)"
)
type ProposalStatus int
func (es EventSig) GetTopic() common.Hash {
return crypto.Keccak256Hash([]byte(es))
}
func PackInput(abi *abi.ABI, abiMethod string, params ...interface{}) []byte {
input, err := abi.Pack(abiMethod, params...)
if err != nil {
log.Error(abiMethod, " error", err)
}
return input
}
// buildQuery constructs a query for the bridgeContract by hashing sig to get the event topic
func BuildQuery(contract common.Address, sig EventSig, startBlock *big.Int, endBlock *big.Int) eth.FilterQuery {
query := eth.FilterQuery{
FromBlock: startBlock,
ToBlock: endBlock,
Addresses: []common.Address{contract},
Topics: [][]common.Hash{
{sig.GetTopic()},
},
}
return query
}