Skip to content

Commit

Permalink
feat: ASI manifest (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathansumner authored May 22, 2024
1 parent 35e4419 commit 3e6b6a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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 @@ -182,7 +182,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 @@ -500,7 +500,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 @@ -543,6 +543,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

0 comments on commit 3e6b6a7

Please sign in to comment.