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 3 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
11 changes: 9 additions & 2 deletions cmd/fetchd/cmd/gen_asi_upgrade_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ type ASIUpgradeTransfers struct {
To string `json:"to"`
}

type ASIUpgradeSupplyMint struct {
LandingAddress string `json:"landing_address"`
Amount types.Coins `json:"amount"`
NewSupplyTotal types.Coins `json:"new_supply_total"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to rename data members:

Suggested change
Amount types.Coins `json:"amount"`
NewSupplyTotal types.Coins `json:"new_supply_total"`
MintedAmount types.Coins `json:"minted_amount"`
ResultingSupplyTotal types.Coins `json:"resulting_supply_total"`

}

type ASIUpgradeManifest struct {
IBC *ASIUpgradeTransfers `json:"ibc,omitempty"`
Reconciliation *ASIUpgradeTransfers `json:"reconciliation,omitempty"`
SupplyMint []ASIUpgradeSupplyMint `json:"supply_mint"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I'm not quite sure why is this an array. This can be simply directly value type, or pointer to type.
    • In the example below I used the pointer to type in order to have additional degree of freedom - to enable complete exclusion of the Supply data member from json completelly, if really required. Though honestly, it is not required - it can be directly value type ASIUpgradeSupplyMint, since its Coins data members are arrays themselves.
  2. I would rename this data member to simply Supply:
Suggested change
SupplyMint []ASIUpgradeSupplyMint `json:"supply_mint"`
SupplyMint *ASIUpgradeSupplyMint `json:"supply_mint"`

IBC *ASIUpgradeTransfers `json:"ibc,omitempty"`
Reconciliation *ASIUpgradeTransfers `json:"reconciliation,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SupplyMint []ASIUpgradeSupplyMint `json:"supply_mint"`
IBC *ASIUpgradeTransfers `json:"ibc,omitempty"`
Reconciliation *ASIUpgradeTransfers `json:"reconciliation,omitempty"`
Supply *ASIUpgradeSupply `json:"supply,omitempty"`
IBC *ASIUpgradeTransfers `json:"ibc,omitempty"`
Reconciliation *ASIUpgradeTransfers `json:"reconciliation,omitempty"`

}

func SaveASIManifest(manifest *ASIUpgradeManifest, config *config2.Config) error {
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
mintRecord := ASIUpgradeSupplyMint{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit pick - feel free to ignore.

Suggested change
mintRecord := ASIUpgradeSupplyMint{
supplyRecord := ASIUpgradeSupplyMint{

LandingAddress: supplyInfo.UpdatedSupplyOverflowAddr,
Amount: sdk.NewCoins(additionalSupplyCoin),
NewSupplyTotal: sdk.NewCoins(newSupplyCoins),
}
manifest.SupplyMint = append(manifest.SupplyMint, mintRecord)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per my inline comments above:

Suggested change
manifest.SupplyMint = append(manifest.SupplyMint, mintRecord)
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