-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
starknet_chain.go
57 lines (48 loc) · 1.55 KB
/
starknet_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
package presenters
import (
"time"
"github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/db"
starknet "github.com/smartcontractkit/chainlink/core/chains/starknet/types"
)
// StarkNetChainResource is an StarkNet chain JSONAPI resource.
type StarkNetChainResource struct {
chainResource[*db.ChainCfg]
}
// GetName implements the api2go EntityNamer interface
func (r StarkNetChainResource) GetName() string {
return "starknet_chain"
}
// NewStarkNetChainResource returns a new StarkNetChainResource for chain.
func NewStarkNetChainResource(chain starknet.DBChain) StarkNetChainResource {
return StarkNetChainResource{chainResource[*db.ChainCfg]{
JAID: NewJAID(chain.ID),
Config: chain.Cfg,
Enabled: chain.Enabled,
CreatedAt: chain.CreatedAt,
UpdatedAt: chain.UpdatedAt,
}}
}
// StarkNetNodeResource is a StarkNet node JSONAPI resource.
type StarkNetNodeResource struct {
JAID
Name string `json:"name"`
ChainID string `json:"chainID"`
URL string `json:"url"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// GetName implements the api2go EntityNamer interface
func (r StarkNetNodeResource) GetName() string {
return "starknet_node"
}
// NewStarkNetNodeResource returns a new StarkNetNodeResource for node.
func NewStarkNetNodeResource(node db.Node) StarkNetNodeResource {
return StarkNetNodeResource{
JAID: NewJAIDInt32(node.ID),
Name: node.Name,
ChainID: node.ChainID,
URL: node.URL,
CreatedAt: node.CreatedAt,
UpdatedAt: node.UpdatedAt,
}
}