Skip to content

Commit bdfc0b6

Browse files
chore: asi manifest restructure (#368)
1 parent fe9f811 commit bdfc0b6

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

cmd/fetchd/cmd/gen_asi_upgrade_manifest.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,24 @@ type ValueUpdate struct {
7474
To string `json:"to"`
7575
}
7676

77-
type MainParams struct {
77+
type NetworkParams struct {
7878
GenesisTime *ValueUpdate `json:"genesis_time,omitempty"`
7979
ChainID *ValueUpdate `json:"chain_id,omitempty"`
8080
AddressPrefix *ValueUpdate `json:"address_prefix,omitempty"`
8181
Supply *ASIUpgradeSupply `json:"supply,omitempty"`
8282
}
8383

84+
type Contracts struct {
85+
StateCleaned []string `json:"contracts_state_cleaned,omitempty"`
86+
AdminUpdated []ContractValueUpdate `json:"contracts_admin_updated,omitempty"`
87+
LabelUpdated []ContractValueUpdate `json:"contracts_label_updated,omitempty"`
88+
}
89+
8490
type ASIUpgradeManifest struct {
85-
Main *MainParams `json:"main,omitempty"`
86-
IBC *ASIUpgradeIBCTransfers `json:"ibc,omitempty"`
87-
Reconciliation *ASIUpgradeReconciliation `json:"reconciliation,omitempty"`
88-
ContractsStateCleaned []string `json:"contracts_state_cleaned,omitempty"`
89-
ContractsAdminUpdated []ContractValueUpdate `json:"contracts_admin_updated,omitempty"`
90-
ContractsLabelUpdated []ContractValueUpdate `json:"contracts_label_updated,omitempty"`
91+
Network *NetworkParams `json:"network,omitempty"`
92+
IBC *ASIUpgradeIBCTransfers `json:"ibc,omitempty"`
93+
Reconciliation *ASIUpgradeReconciliation `json:"reconciliation,omitempty"`
94+
Contracts *Contracts `json:"contracts,omitempty"`
9195
}
9296

9397
func SaveASIManifest(manifest *ASIUpgradeManifest, config *config2.Config) error {

cmd/fetchd/cmd/genesis-asi-upgrade.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ var networkInfos = map[string]NetworkConfig{
9999
TargetAddress: "fetch1tynmzk68pq6kzawqffrqdhquq475gw9ccmlf9gk24mxjjy6ugl3q70aeyd",
100100
InputCSVRecords: readInputReconciliationData(reconciliationData),
101101
},
102-
Contracts: &Contracts{
102+
Contracts: &ContractSet{
103103
Almanac: &Almanac{
104104
ProdAddr: "fetch1mezzhfj7qgveewzwzdk6lz5sae4dunpmmsjr9u7z0tpmdsae8zmquq3y0y",
105105
},
@@ -141,7 +141,7 @@ var networkInfos = map[string]NetworkConfig{
141141
TargetAddress: "fetch1g5ur2wc5xnlc7sw9wd895lw7mmxz04r5syj3s6ew8md6pvwuweqqavkgt0",
142142
InputCSVRecords: readInputReconciliationData(reconciliationDataTestnet),
143143
},
144-
Contracts: &Contracts{
144+
Contracts: &ContractSet{
145145
Almanac: &Almanac{
146146
ProdAddr: "fetch1tjagw8g8nn4cwuw00cf0m5tl4l6wfw9c0ue507fhx9e3yrsck8zs0l3q4w",
147147
DevAddr: "fetch135h26ys2nwqealykzey532gamw4l4s07aewpwc0cyd8z6m92vyhsplf0vp",
@@ -194,7 +194,8 @@ func ASIGenesisUpgradeCmd(defaultNodeHome string) *cobra.Command {
194194

195195
// create a new manifest
196196
manifest := ASIUpgradeManifest{
197-
Main: &MainParams{},
197+
Network: &NetworkParams{},
198+
Contracts: &Contracts{},
198199
}
199200

200201
_, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile)
@@ -362,7 +363,7 @@ func ASIGenesisUpgradeUpdateGenesisTime(genDoc *types.GenesisDoc, newGenesisTime
362363
panic(err)
363364
}
364365
genDoc.GenesisTime = tmtime.Canonical(genesisTime)
365-
manifest.Main.GenesisTime = &ValueUpdate{
366+
manifest.Network.GenesisTime = &ValueUpdate{
366367
From: oldGenesisTime.String(),
367368
To: genDoc.GenesisTime.String(),
368369
}
@@ -735,7 +736,7 @@ func ASIGenesisUpgradeReplaceDenomMetadata(jsonData map[string]interface{}, netw
735736
func ASIGenesisUpgradeReplaceChainID(genesisData *types.GenesisDoc, networkInfo NetworkConfig, manifest *ASIUpgradeManifest) {
736737
oldChainID := genesisData.ChainID
737738
genesisData.ChainID = networkInfo.NewChainID
738-
manifest.Main.ChainID = &ValueUpdate{
739+
manifest.Network.ChainID = &ValueUpdate{
739740
From: oldChainID,
740741
To: genesisData.ChainID,
741742
}
@@ -836,7 +837,7 @@ func ASIGenesisUpgradeReplaceAddresses(jsonData map[string]interface{}, networkI
836837
// contract addresses
837838
replaceAddresses(AccAddressPrefix, jsonData, WasmAddrDataLength+AddrChecksumLength)
838839

839-
manifest.Main.AddressPrefix = &ValueUpdate{
840+
manifest.Network.AddressPrefix = &ValueUpdate{
840841
From: OldAddrPrefix,
841842
To: NewAddrPrefix,
842843
}
@@ -1067,7 +1068,7 @@ func ASIGenesisUpgradeASISupply(jsonData map[string]interface{}, networkInfo Net
10671068
MintedAmount: sdk.NewCoins(additionalSupplyCoin),
10681069
ResultingTotalSupply: sdk.NewCoins(newSupplyCoins),
10691070
}
1070-
manifest.Main.Supply = &supplyRecord
1071+
manifest.Network.Supply = &supplyRecord
10711072

10721073
// update the supply in the bank module
10731074
supply[curSupplyIdx].(map[string]interface{})["amount"] = newSupplyCoins.Amount.String()
@@ -1099,19 +1100,19 @@ func replaceContractAdminAndLabel(genesisContractStruct map[string]interface{},
10991100
if newAdmin != nil {
11001101
oldAdmin := contractInfo["admin"].(string)
11011102
contractInfo["admin"] = *newAdmin
1102-
manifest.ContractsAdminUpdated = append(manifest.ContractsAdminUpdated, ContractValueUpdate{Address: contractAddress, From: oldAdmin, To: *newAdmin})
1103+
manifest.Contracts.AdminUpdated = append(manifest.Contracts.AdminUpdated, ContractValueUpdate{contractAddress, oldAdmin, *newAdmin})
11031104
}
11041105
if newLabel != nil {
11051106
oldLabel := contractInfo["label"].(string)
11061107
contractInfo["label"] = *newLabel
1107-
manifest.ContractsLabelUpdated = append(manifest.ContractsLabelUpdated, ContractValueUpdate{Address: contractAddress, From: oldLabel, To: *newLabel})
1108+
manifest.Contracts.LabelUpdated = append(manifest.Contracts.LabelUpdated, ContractValueUpdate{contractAddress, oldLabel, *newLabel})
11081109
}
11091110
}
11101111

11111112
func deleteContractState(genesisContractStruct map[string]interface{}, manifest *ASIUpgradeManifest) {
11121113
contractAddress := genesisContractStruct["contract_address"].(string)
11131114
genesisContractStruct["contract_state"] = []interface{}{}
1114-
manifest.ContractsStateCleaned = append(manifest.ContractsStateCleaned, contractAddress)
1115+
manifest.Contracts.StateCleaned = append(manifest.Contracts.StateCleaned, contractAddress)
11151116
}
11161117

11171118
func crawlJson(key string, value interface{}, idx int, strHandler func(string, interface{}, int) interface{}) interface{} {
@@ -1196,7 +1197,7 @@ type NetworkConfig struct {
11961197
ReconciliationInfo *ReconciliationInfo
11971198
SupplyInfo SupplyInfo
11981199
DenomInfo DenomInfo
1199-
Contracts *Contracts
1200+
Contracts *ContractSet
12001201
}
12011202

12021203
type ReconciliationInfo struct {
@@ -1215,7 +1216,7 @@ type DenomInfo struct {
12151216
OldDenom string
12161217
}
12171218

1218-
type Contracts struct {
1219+
type ContractSet struct {
12191220
TokenBridge *TokenBridge
12201221
Almanac *Almanac
12211222
AName *AName

0 commit comments

Comments
 (0)