Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions cmd/fetchd/cmd/gen_asi_upgrade_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,24 @@ type ValueUpdate struct {
To string `json:"to"`
}

type MainParams struct {
type NetworkParams struct {
GenesisTime *ValueUpdate `json:"genesis_time,omitempty"`
ChainID *ValueUpdate `json:"chain_id,omitempty"`
AddressPrefix *ValueUpdate `json:"address_prefix,omitempty"`
Supply *ASIUpgradeSupply `json:"supply,omitempty"`
}

type Contracts struct {
StateCleaned []string `json:"contracts_state_cleaned,omitempty"`
AdminUpdated []ContractValueUpdate `json:"contracts_admin_updated,omitempty"`
LabelUpdated []ContractValueUpdate `json:"contracts_label_updated,omitempty"`
}

type ASIUpgradeManifest struct {
Main *MainParams `json:"main,omitempty"`
IBC *ASIUpgradeIBCTransfers `json:"ibc,omitempty"`
Reconciliation *ASIUpgradeReconciliation `json:"reconciliation,omitempty"`
ContractsStateCleaned []string `json:"contracts_state_cleaned,omitempty"`
ContractsAdminUpdated []ContractValueUpdate `json:"contracts_admin_updated,omitempty"`
ContractsLabelUpdated []ContractValueUpdate `json:"contracts_label_updated,omitempty"`
Network *NetworkParams `json:"network,omitempty"`
IBC *ASIUpgradeIBCTransfers `json:"ibc,omitempty"`
Reconciliation *ASIUpgradeReconciliation `json:"reconciliation,omitempty"`
Contracts *Contracts `json:"contracts,omitempty"`
}

func SaveASIManifest(manifest *ASIUpgradeManifest, config *config2.Config) error {
Expand Down
25 changes: 13 additions & 12 deletions cmd/fetchd/cmd/genesis-asi-upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var networkInfos = map[string]NetworkConfig{
TargetAddress: "fetch1tynmzk68pq6kzawqffrqdhquq475gw9ccmlf9gk24mxjjy6ugl3q70aeyd",
InputCSVRecords: readInputReconciliationData(reconciliationData),
},
Contracts: &Contracts{
Contracts: &ContractSet{
Almanac: &Almanac{
ProdAddr: "fetch1mezzhfj7qgveewzwzdk6lz5sae4dunpmmsjr9u7z0tpmdsae8zmquq3y0y",
},
Expand Down Expand Up @@ -141,7 +141,7 @@ var networkInfos = map[string]NetworkConfig{
TargetAddress: "fetch1g5ur2wc5xnlc7sw9wd895lw7mmxz04r5syj3s6ew8md6pvwuweqqavkgt0",
InputCSVRecords: readInputReconciliationData(reconciliationDataTestnet),
},
Contracts: &Contracts{
Contracts: &ContractSet{
Almanac: &Almanac{
ProdAddr: "fetch1tjagw8g8nn4cwuw00cf0m5tl4l6wfw9c0ue507fhx9e3yrsck8zs0l3q4w",
DevAddr: "fetch135h26ys2nwqealykzey532gamw4l4s07aewpwc0cyd8z6m92vyhsplf0vp",
Expand Down Expand Up @@ -194,7 +194,8 @@ func ASIGenesisUpgradeCmd(defaultNodeHome string) *cobra.Command {

// create a new manifest
manifest := ASIUpgradeManifest{
Main: &MainParams{},
Network: &NetworkParams{},
Contracts: &Contracts{},
}

_, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile)
Expand Down Expand Up @@ -362,7 +363,7 @@ func ASIGenesisUpgradeUpdateGenesisTime(genDoc *types.GenesisDoc, newGenesisTime
panic(err)
}
genDoc.GenesisTime = tmtime.Canonical(genesisTime)
manifest.Main.GenesisTime = &ValueUpdate{
manifest.Network.GenesisTime = &ValueUpdate{
From: oldGenesisTime.String(),
To: genDoc.GenesisTime.String(),
}
Expand Down Expand Up @@ -735,7 +736,7 @@ func ASIGenesisUpgradeReplaceDenomMetadata(jsonData map[string]interface{}, netw
func ASIGenesisUpgradeReplaceChainID(genesisData *types.GenesisDoc, networkInfo NetworkConfig, manifest *ASIUpgradeManifest) {
oldChainID := genesisData.ChainID
genesisData.ChainID = networkInfo.NewChainID
manifest.Main.ChainID = &ValueUpdate{
manifest.Network.ChainID = &ValueUpdate{
From: oldChainID,
To: genesisData.ChainID,
}
Expand Down Expand Up @@ -836,7 +837,7 @@ func ASIGenesisUpgradeReplaceAddresses(jsonData map[string]interface{}, networkI
// contract addresses
replaceAddresses(AccAddressPrefix, jsonData, WasmAddrDataLength+AddrChecksumLength)

manifest.Main.AddressPrefix = &ValueUpdate{
manifest.Network.AddressPrefix = &ValueUpdate{
From: OldAddrPrefix,
To: NewAddrPrefix,
}
Expand Down Expand Up @@ -1067,7 +1068,7 @@ func ASIGenesisUpgradeASISupply(jsonData map[string]interface{}, networkInfo Net
MintedAmount: sdk.NewCoins(additionalSupplyCoin),
ResultingTotalSupply: sdk.NewCoins(newSupplyCoins),
}
manifest.Main.Supply = &supplyRecord
manifest.Network.Supply = &supplyRecord

// update the supply in the bank module
supply[curSupplyIdx].(map[string]interface{})["amount"] = newSupplyCoins.Amount.String()
Expand Down Expand Up @@ -1099,19 +1100,19 @@ func replaceContractAdminAndLabel(genesisContractStruct map[string]interface{},
if newAdmin != nil {
oldAdmin := contractInfo["admin"].(string)
contractInfo["admin"] = *newAdmin
manifest.ContractsAdminUpdated = append(manifest.ContractsAdminUpdated, ContractValueUpdate{Address: contractAddress, From: oldAdmin, To: *newAdmin})
manifest.Contracts.AdminUpdated = append(manifest.Contracts.AdminUpdated, ContractValueUpdate{contractAddress, oldAdmin, *newAdmin})
}
if newLabel != nil {
oldLabel := contractInfo["label"].(string)
contractInfo["label"] = *newLabel
manifest.ContractsLabelUpdated = append(manifest.ContractsLabelUpdated, ContractValueUpdate{Address: contractAddress, From: oldLabel, To: *newLabel})
manifest.Contracts.LabelUpdated = append(manifest.Contracts.LabelUpdated, ContractValueUpdate{contractAddress, oldLabel, *newLabel})
}
}

func deleteContractState(genesisContractStruct map[string]interface{}, manifest *ASIUpgradeManifest) {
contractAddress := genesisContractStruct["contract_address"].(string)
genesisContractStruct["contract_state"] = []interface{}{}
manifest.ContractsStateCleaned = append(manifest.ContractsStateCleaned, contractAddress)
manifest.Contracts.StateCleaned = append(manifest.Contracts.StateCleaned, contractAddress)
}

func crawlJson(key string, value interface{}, idx int, strHandler func(string, interface{}, int) interface{}) interface{} {
Expand Down Expand Up @@ -1196,7 +1197,7 @@ type NetworkConfig struct {
ReconciliationInfo *ReconciliationInfo
SupplyInfo SupplyInfo
DenomInfo DenomInfo
Contracts *Contracts
Contracts *ContractSet
}

type ReconciliationInfo struct {
Expand All @@ -1215,7 +1216,7 @@ type DenomInfo struct {
OldDenom string
}

type Contracts struct {
type ContractSet struct {
TokenBridge *TokenBridge
Almanac *Almanac
AName *AName
Expand Down