-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
evm_chain.go
62 lines (53 loc) · 1.65 KB
/
evm_chain.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
57
58
59
60
61
62
package presenters
import (
"time"
"gopkg.in/guregu/null.v4"
evmtypes "github.com/smartcontractkit/chainlink/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/core/utils"
)
// EVMChainResource is an EVM chain JSONAPI resource.
type EVMChainResource struct {
chainResource[*evmtypes.ChainCfg]
}
// GetName implements the api2go EntityNamer interface
func (r EVMChainResource) GetName() string {
return "evm_chain"
}
// NewEVMChainResource returns a new EVMChainResource for chain.
func NewEVMChainResource(chain evmtypes.DBChain) EVMChainResource {
return EVMChainResource{chainResource[*evmtypes.ChainCfg]{
JAID: NewJAIDInt64(chain.ID.ToInt().Int64()),
Config: chain.Cfg,
Enabled: chain.Enabled,
CreatedAt: chain.CreatedAt,
UpdatedAt: chain.UpdatedAt,
}}
}
// EVMNodeResource is an EVM node JSONAPI resource.
type EVMNodeResource struct {
JAID
Name string `json:"name"`
EVMChainID utils.Big `json:"evmChainID"`
WSURL null.String `json:"wsURL"`
HTTPURL null.String `json:"httpURL"`
State string `json:"state"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// GetName implements the api2go EntityNamer interface
func (r EVMNodeResource) GetName() string {
return "evm_node"
}
// NewEVMNodeResource returns a new EVMNodeResource for node.
func NewEVMNodeResource(node evmtypes.Node) EVMNodeResource {
return EVMNodeResource{
JAID: NewJAIDInt32(node.ID),
Name: node.Name,
EVMChainID: node.EVMChainID,
WSURL: node.WSURL,
HTTPURL: node.HTTPURL,
State: node.State,
CreatedAt: node.CreatedAt,
UpdatedAt: node.UpdatedAt,
}
}