-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.go
executable file
·41 lines (33 loc) · 1.37 KB
/
helper.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
package contractsapi
import (
"math/big"
"github.com/definenulls/komerco-chain/types"
"github.com/umbracle/ethgo/abi"
)
// StateTransactionInput is an abstraction for different state transaction inputs
type StateTransactionInput interface {
// EncodeAbi contains logic for encoding arbitrary data into ABI format
EncodeAbi() ([]byte, error)
// DecodeAbi contains logic for decoding given ABI data
DecodeAbi(b []byte) error
}
var (
// stateSyncABIType is a specific case where we need to encode state sync event as a tuple of tuple
stateSyncABIType = abi.MustNewType(
"tuple(tuple(uint256 id, address sender, address receiver, bytes data))")
// GetCheckpointBlockABIResponse is the ABI type for getCheckpointBlock function return value
GetCheckpointBlockABIResponse = abi.MustNewType("tuple(bool isFound, uint256 checkpointBlock)")
)
// ToABI converts StateSyncEvent to ABI
func (sse *StateSyncedEvent) EncodeAbi() ([]byte, error) {
return stateSyncABIType.Encode([]interface{}{sse})
}
// AddValidatorUptime is an extension (helper) function on a generated Uptime type
// that adds uptime data for given validator to Uptime struct
func (u *Uptime) AddValidatorUptime(address types.Address, count int64) {
u.UptimeData = append(u.UptimeData, &UptimeData{
Validator: address,
SignedBlocks: big.NewInt(count),
})
}
var _ StateTransactionInput = &CommitEpochChildValidatorSetFn{}