-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.go
72 lines (66 loc) · 2.01 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (C) 2022, Chain4Travel AG. All rights reserved.
//
// This file is a derived work, based on ava-labs code whose
// original notices appear below.
//
// It is distributed under the same license conditions as the
// original code from which it is derived.
//
// Much love to the original authors for their work.
// **********************************************************
// (c) 2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package api
import (
"encoding/json"
"github.com/lasthyphen/dijetsnodego/ids"
"github.com/lasthyphen/mages/models"
)
const (
AVMName = "avm"
XChainAlias = "v"
PVMName = "pvm"
PChainAlias = "m"
CVMName = "cvm"
CChainAlias = "m"
)
func newIndexResponse(networkID uint32, xChainID, cChainID, djtxAssetID 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,
DJTXAssetID: models.StringID(djtxAssetID.String()),
ID: models.StringID(xChainID.String()),
},
ids.Empty.String(): {
VM: PVMName,
Alias: PChainAlias,
NetworkID: networkID,
DJTXAssetID: models.StringID(djtxAssetID.String()),
ID: models.StringID(ids.Empty.String()),
},
cChainID.String(): {
VM: CVMName,
Alias: CChainAlias,
NetworkID: networkID,
DJTXAssetID: models.StringID(djtxAssetID.String()),
ID: models.StringID(cChainID.String()),
},
},
})
}
func newLegacyIndexResponse(networkID uint32, xChainID ids.ID, djtxAssetID ids.ID) ([]byte, error) {
return json.Marshal(&models.ChainInfo{
VM: AVMName,
NetworkID: networkID,
Alias: XChainAlias,
DJTXAssetID: models.StringID(djtxAssetID.String()),
ID: models.StringID(xChainID.String()),
})
}