-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
chain.go
59 lines (51 loc) · 1.41 KB
/
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
package presenters
import (
"time"
"github.com/smartcontractkit/chainlink/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/core/utils"
"gopkg.in/guregu/null.v4"
)
type ChainResource struct {
JAID
Enabled bool `json:"enabled"`
Config types.ChainCfg `json:"config"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// GetName implements the api2go EntityNamer interface
func (r ChainResource) GetName() string {
return "chain"
}
func NewChainResource(chain types.Chain) ChainResource {
return ChainResource{
JAID: NewJAIDInt64(chain.ID.ToInt().Int64()),
Config: chain.Cfg,
Enabled: chain.Enabled,
CreatedAt: chain.CreatedAt,
UpdatedAt: chain.UpdatedAt,
}
}
type NodeResource struct {
JAID
Name string `json:"name"`
EVMChainID utils.Big `json:"evmChainID"`
WSURL null.String `json:"wsURL"`
HTTPURL null.String `json:"httpURL"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// GetName implements the api2go EntityNamer interface
func (r NodeResource) GetName() string {
return "node"
}
func NewNodeResource(node types.Node) NodeResource {
return NodeResource{
JAID: NewJAIDInt32(node.ID),
Name: node.Name,
EVMChainID: node.EVMChainID,
WSURL: node.WSURL,
HTTPURL: node.HTTPURL,
CreatedAt: node.CreatedAt,
UpdatedAt: node.UpdatedAt,
}
}