forked from ava-labs/ortelius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.go
53 lines (47 loc) · 1.39 KB
/
index.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
// (c) 2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package api
import (
"encoding/json"
"github.com/corpetty/avalanchego/ids"
"github.com/corpetty/ortelius/services/indexes/models"
)
const (
AVMName = "avm"
XChainAlias = "x"
PVMName = "pvm"
PChainAlias = "p"
)
func newIndexResponse(networkID uint32, xChainID ids.ID, avaxAssetID ids.ID) ([]byte, error) {
return json.Marshal(&struct {
NetworkID uint32 `json:"network_id"`
Chains map[string]models.ChainInfo `json:"chains"`
}{
NetworkID: networkID,
Chains: map[string]models.ChainInfo{
xChainID.String(): {
VM: AVMName,
Alias: XChainAlias,
NetworkID: networkID,
AVAXAssetID: models.StringID(avaxAssetID.String()),
ID: models.StringID(xChainID.String()),
},
ids.Empty.String(): {
VM: PVMName,
Alias: PChainAlias,
NetworkID: networkID,
AVAXAssetID: models.StringID(avaxAssetID.String()),
ID: models.StringID(ids.Empty.String()),
},
},
})
}
func newLegacyIndexResponse(networkID uint32, xChainID ids.ID, avaxAssetID ids.ID) ([]byte, error) {
return json.Marshal(&models.ChainInfo{
VM: AVMName,
NetworkID: networkID,
Alias: XChainAlias,
AVAXAssetID: models.StringID(avaxAssetID.String()),
ID: models.StringID(xChainID.String()),
})
}