Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ASI manifest #353

Merged
merged 5 commits into from
May 22, 2024
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
7 changes: 7 additions & 0 deletions cmd/fetchd/cmd/gen_asi_upgrade_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ type ASIUpgradeTransfers struct {
To string `json:"to"`
}

type ASIUpgradeSupply struct {
LandingAddress string `json:"landing_address"`
MintedAmount types.Coins `json:"minted_amount"`
ResultingSupplyTotal types.Coins `json:"resulting_supply_total"`
}

type ASIUpgradeManifest struct {
Supply *ASIUpgradeSupply `json:"supply,omitempty"`
IBC *ASIUpgradeTransfers `json:"ibc,omitempty"`
Reconciliation *ASIUpgradeTransfers `json:"reconciliation,omitempty"`
}
Expand Down
12 changes: 10 additions & 2 deletions cmd/fetchd/cmd/genesis-asi-upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func ASIGenesisUpgradeCmd(defaultNodeHome string) *cobra.Command {
ASIGenesisUpgradeReplaceDenom(jsonData, networkConfig)

// supplement the genesis supply
ASIGenesisUpgradeASISupply(jsonData, networkConfig)
ASIGenesisUpgradeASISupply(jsonData, networkConfig, &manifest)

// replace addresses across the genesis file
ASIGenesisUpgradeReplaceAddresses(jsonData, networkConfig)
Expand Down Expand Up @@ -453,7 +453,7 @@ func ASIGenesisUpgradeWithdrawReconciliationBalances(jsonData map[string]interfa
return nil
}

func ASIGenesisUpgradeASISupply(jsonData map[string]interface{}, networkInfo NetworkConfig) {
func ASIGenesisUpgradeASISupply(jsonData map[string]interface{}, networkInfo NetworkConfig, manifest *ASIUpgradeManifest) {
denomInfo := networkInfo.DenomInfo
supplyInfo := networkInfo.SupplyInfo
additionalSupply, ok := sdk.NewIntFromString(supplyInfo.SupplyToMint)
Expand Down Expand Up @@ -496,6 +496,14 @@ func ASIGenesisUpgradeASISupply(jsonData map[string]interface{}, networkInfo Net
// add the additional coins to the overflow address balance
overflowAddressBalanceCoins = overflowAddressBalanceCoins.Add(additionalSupplyCoin)

// add the new supply mint record to the manifest
supplyRecord := ASIUpgradeSupply{
LandingAddress: supplyInfo.UpdatedSupplyOverflowAddr,
MintedAmount: sdk.NewCoins(additionalSupplyCoin),
ResultingSupplyTotal: sdk.NewCoins(newSupplyCoins),
}
manifest.Supply = &supplyRecord

// update the supply in the bank module
supply[curSupplyIdx].(map[string]interface{})["amount"] = newSupplyCoins.Amount.String()
balances[(*balancesMap)[supplyInfo.UpdatedSupplyOverflowAddr]].(map[string]interface{})["coins"] = getInterfaceSliceFromCoins(overflowAddressBalanceCoins)
Expand Down
Loading