Skip to content

Commit

Permalink
osmo genesis modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
bekauz committed Jan 19, 2024
1 parent af8fda3 commit 52fd1da
Showing 1 changed file with 69 additions and 69 deletions.
138 changes: 69 additions & 69 deletions interchaintest/utils/genesis_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,75 +172,75 @@ func SetupOsmoGenesis(allowed_messages []string) func(ibc.ChainConfig, []byte) (
return nil, fmt.Errorf("failed to set allow_messages for interchainaccount host in genesis json: %w. \ngenesis json: %s", err, g)
}

type Fee struct {
Amount string `json:"amount"`
Denom string `json:"denom"`
}
zeroCreationFee := []Fee{
{
Amount: "10",
Denom: "uosmo",
},
}

if err := dyno.Set(g, zeroCreationFee, "app_state", "gamm", "params", "pool_creation_fee"); err != nil {
return nil, fmt.Errorf("failed to set poolmanager pool creation fee")
}

// Retrieve tokenfactory params map
tokenfactoryParams, err := dyno.Get(g, "app_state", "tokenfactory", "params")
if err != nil {
return nil, fmt.Errorf("failed to get params for tokenfactory: %w", err)
}

// Assert the type of the params to be map[string]interface{}
tokenfactoryParamsMap, ok := tokenfactoryParams.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("params for tokenfactory is not a map")
}

// Update only the denom_creation_gas_consume field
tokenfactoryParamsMap["denom_creation_gas_consume"] = "1"

// Set the modified params map back
if err := dyno.Set(g, tokenfactoryParamsMap, "app_state", "tokenfactory", "params"); err != nil {
return nil, fmt.Errorf("failed to set modified params for tokenfactory: %w", err)
}

// genutil gas_limits
// Retrieve the gen_txs array
genTxs, err := dyno.Get(g, "app_state", "genutil", "gen_txs")
if err != nil {
return nil, fmt.Errorf("failed to get gen_txs for genutil: %w", err)
}

genTxsSlice, ok := genTxs.([]interface{})
if !ok {
return nil, fmt.Errorf("gen_txs in genutil is not a slice")
}

// Update the gas_limit for each item in the slice
for _, genTx := range genTxsSlice {
genTxMap, ok := genTx.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("gen_tx item is not a map")
}

if authInfo, ok := genTxMap["auth_info"].(map[string]interface{}); ok {
if fee, ok := authInfo["fee"].(map[string]interface{}); ok {
fee["gas_limit"] = "350000"
}
}
}

// Set the modified gen_txs slice back
if err := dyno.Set(g, genTxsSlice, "app_state", "genutil", "gen_txs"); err != nil {
return nil, fmt.Errorf("failed to set modified gen_txs for genutil: %w", err)
}

if err := dyno.Set(g, "100000000", "consensus_params", "block", "max_gas"); err != nil {
return nil, fmt.Errorf("failed to set block max gas: %w", err)
}
// type Fee struct {
// Amount string `json:"amount"`
// Denom string `json:"denom"`
// }
// zeroCreationFee := []Fee{
// {
// Amount: "10",
// Denom: "uosmo",
// },
// }

// if err := dyno.Set(g, zeroCreationFee, "app_state", "gamm", "params", "pool_creation_fee"); err != nil {
// return nil, fmt.Errorf("failed to set poolmanager pool creation fee")
// }

// // Retrieve tokenfactory params map
// // tokenfactoryParams, err := dyno.Get(g, "app_state", "tokenfactory", "params")
// // if err != nil {
// // return nil, fmt.Errorf("failed to get params for tokenfactory: %w", err)
// // }

// // // Assert the type of the params to be map[string]interface{}
// // tokenfactoryParamsMap, ok := tokenfactoryParams.(map[string]interface{})
// // if !ok {
// // return nil, fmt.Errorf("params for tokenfactory is not a map")
// // }

// // // Update only the denom_creation_gas_consume field
// // tokenfactoryParamsMap["denom_creation_gas_consume"] = "1"

// // // Set the modified params map back
// // if err := dyno.Set(g, tokenfactoryParamsMap, "app_state", "tokenfactory", "params"); err != nil {
// // return nil, fmt.Errorf("failed to set modified params for tokenfactory: %w", err)
// // }

// // genutil gas_limits
// // Retrieve the gen_txs array
// genTxs, err := dyno.Get(g, "app_state", "genutil", "gen_txs")
// if err != nil {
// return nil, fmt.Errorf("failed to get gen_txs for genutil: %w", err)
// }

// genTxsSlice, ok := genTxs.([]interface{})
// if !ok {
// return nil, fmt.Errorf("gen_txs in genutil is not a slice")
// }

// // Update the gas_limit for each item in the slice
// for _, genTx := range genTxsSlice {
// genTxMap, ok := genTx.(map[string]interface{})
// if !ok {
// return nil, fmt.Errorf("gen_tx item is not a map")
// }

// if authInfo, ok := genTxMap["auth_info"].(map[string]interface{}); ok {
// if fee, ok := authInfo["fee"].(map[string]interface{}); ok {
// fee["gas_limit"] = "350000"
// }
// }
// }

// // Set the modified gen_txs slice back
// if err := dyno.Set(g, genTxsSlice, "app_state", "genutil", "gen_txs"); err != nil {
// return nil, fmt.Errorf("failed to set modified gen_txs for genutil: %w", err)
// }

// if err := dyno.Set(g, "100000000", "consensus_params", "block", "max_gas"); err != nil {
// return nil, fmt.Errorf("failed to set block max gas: %w", err)
// }

out, err := json.Marshal(g)
println("osmo genesis:")
Expand Down

0 comments on commit 52fd1da

Please sign in to comment.