-
Notifications
You must be signed in to change notification settings - Fork 23
/
request.go
56 lines (48 loc) · 1.28 KB
/
request.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
47
48
49
50
51
52
53
54
55
56
package types
import (
"math/big"
)
const (
// VersionOffset is the offset of the version.
VersionOffset = 0
// GasLimitOffset if the offset of the gas limit.
GasLimitOffset = 4
// GasDropOffset is the gas drop offset.
GasDropOffset = 12
// RequestSize is the size of the request.
RequestSize = 24
)
// Request is an interface that contains the request from the base message.
//
//nolint:interfacebloat
type Request interface {
// Version is the base message version to pass to the recipient.
Version() uint32
// GasLimit is the minimum amount of gas units to supply for execution.
GasLimit() uint64
// GasDrop is the minimum amount of gas token to drop to the recipient.
GasDrop() *big.Int
}
// requestImpl implements a request. It is used for testutils. Real requests are emitted by the contract.
type requestImpl struct {
version uint32
gasLimit uint64
gasDrop *big.Int
}
// NewRequest creates a new request from fields passed in.
func NewRequest(version uint32, gasLimit uint64, gasDrop *big.Int) Request {
return &requestImpl{
version: version,
gasLimit: gasLimit,
gasDrop: gasDrop,
}
}
func (m requestImpl) Version() uint32 {
return m.version
}
func (m requestImpl) GasLimit() uint64 {
return m.gasLimit
}
func (m requestImpl) GasDrop() *big.Int {
return m.gasDrop
}