Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Bowman committed Mar 9, 2024
1 parent 7389fce commit 2f2108d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
40 changes: 31 additions & 9 deletions app/upgrades/v1_5.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ func V010500UpgradeHandler(
}

func addProtocolData(ctx sdk.Context, keeper *prkeeper.Keeper, prtype prtypes.ProtocolDataType, data prtypes.ProtocolDataI) error {
json, err := json.Marshal(data)
jsonData, err := json.Marshal(data)
if err != nil {
return err
}

protocolData := prtypes.ProtocolData{
Type: prtypes.ProtocolDataType_name[int32(prtype)],
Data: json,
Data: jsonData,
}

keeper.SetProtocolData(ctx, data.GenerateKey(), &protocolData)
Expand All @@ -121,49 +121,68 @@ func initialiseClaimsMetaData(ctx sdk.Context, appKeepers *keepers.AppKeepers) e
"umee-1": "channel-49",
"secret-4": "channel-52",
}

var err error
// ProtocolDataTypeConnection
appKeepers.InterchainstakingKeeper.IterateZones(ctx, func(index int64, zone *icstypes.Zone) (stop bool) {
// add connection for each zone
addProtocolData(ctx, prk, prtypes.ProtocolDataTypeConnection, &prtypes.ConnectionProtocolData{
err = addProtocolData(ctx, prk, prtypes.ProtocolDataTypeConnection, &prtypes.ConnectionProtocolData{
ConnectionID: zone.ConnectionId,
ChainID: zone.ChainId,
Prefix: zone.AccountPrefix,
})
if err != nil {
return true
}

// add local (QS) denom for each chain
addProtocolData(ctx, prk, prtypes.ProtocolDataTypeLiquidToken, &prtypes.LiquidAllowedDenomProtocolData{
err = addProtocolData(ctx, prk, prtypes.ProtocolDataTypeLiquidToken, &prtypes.LiquidAllowedDenomProtocolData{
ChainID: ctx.ChainID(),
RegisteredZoneChainID: zone.ChainId,
QAssetDenom: zone.LocalDenom,
IbcDenom: zone.LocalDenom,
})

Check failure on line 144 in app/upgrades/v1_5.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
if err != nil {
return true
}

// add liquid tokens for qasset on osmosis, secret, umee and the host zone itself.
chainsToAdd := []string{"osmosis-1", "secret-4", "umee-1", zone.ChainId}
for _, chain := range chainsToAdd {
channel, found := appKeepers.IBCKeeper.ChannelKeeper.GetChannel(ctx, "transfer", channels[chain])
if !found {
panic(fmt.Errorf("unable to find channel %s", channels[chain]))
err = fmt.Errorf("unable to find channel %s", channels[chain])
return true
}

addProtocolData(ctx, prk, prtypes.ProtocolDataTypeLiquidToken, &prtypes.LiquidAllowedDenomProtocolData{
err = addProtocolData(ctx, prk, prtypes.ProtocolDataTypeLiquidToken, &prtypes.LiquidAllowedDenomProtocolData{
ChainID: chain,
RegisteredZoneChainID: zone.ChainId,
QAssetDenom: zone.LocalDenom,
IbcDenom: utils.DeriveIbcDenom("transfer", channels[chain], "transfer", channel.Counterparty.ChannelId, zone.LocalDenom),
})

Check failure on line 164 in app/upgrades/v1_5.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
if err != nil {
return true
}
}

return false
})

if err != nil {
return err
}

// osmosis params
addProtocolData(ctx, prk, prtypes.ProtocolDataTypeOsmosisParams, &prtypes.OsmosisParamsProtocolData{
err = addProtocolData(ctx, prk, prtypes.ProtocolDataTypeOsmosisParams, &prtypes.OsmosisParamsProtocolData{
ChainID: "osmosis-1",
BaseChain: "osmosis-1",
BaseDenom: "uosmo",
})
if err != nil {
return err
}

osmoPools := []*prtypes.OsmosisPoolProtocolData{
// incentivised pools
Expand Down Expand Up @@ -281,7 +300,10 @@ func initialiseClaimsMetaData(ctx sdk.Context, appKeepers *keepers.AppKeepers) e
}
// osmosis pools
for _, pool := range osmoPools {
addProtocolData(ctx, prk, prtypes.ProtocolDataTypeOsmosisPool, pool)
err = addProtocolData(ctx, prk, prtypes.ProtocolDataTypeOsmosisPool, pool)
if err != nil {
return err
}
}

// enable params
Expand Down
2 changes: 1 addition & 1 deletion x/participationrewards/keeper/distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (suite *KeeperTestSuite) TestCalcTokenValues() {
PoolName: "atom/qAtom",
LastUpdated: time.Now().UTC(),
PoolType: "stableswap",
PoolData: []byte(`{"address":"osmo1awr39mc2hrkt8gq8gt3882ru40ay45k8a3yg69nyypqe9g0ryycs66lhkh","id":"944","pool_params":{"swap_fee":"0.003000000000000000","exit_fee":"0.000000000000000000"},"future_pool_governor":"168h","total_shares":{"denom":"gamm/pool/944","amount":"6108537302303463956540"},"pool_liquidity":[{"denom":"ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2","amount":"42678069500"},{"denom":"ibc/FA602364BEC305A696CBDF987058E99D8B479F0318E47314C49173E8838C5BAC","amount":"70488173547"}],"scaling_factors":["1202853876","1000000000"],"scaling_factor_controller":"osmo16x03wcp37kx5e8ehckjxvwcgk9j0cqnhm8m3yy"}`),
PoolData: json.RawMessage(`{"address":"osmo1awr39mc2hrkt8gq8gt3882ru40ay45k8a3yg69nyypqe9g0ryycs66lhkh","id":"944","pool_params":{"swap_fee":"0.003000000000000000","exit_fee":"0.000000000000000000"},"future_pool_governor":"168h","total_shares":{"denom":"gamm/pool/944","amount":"6108537302303463956540"},"pool_liquidity":[{"denom":"ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2","amount":"42678069500"},{"denom":"ibc/FA602364BEC305A696CBDF987058E99D8B479F0318E47314C49173E8838C5BAC","amount":"70488173547"}],"scaling_factors":["1202853876","1000000000"],"scaling_factor_controller":"osmo16x03wcp37kx5e8ehckjxvwcgk9j0cqnhm8m3yy"}`),
Denoms: map[string]types.DenomWithZone{
"ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2": {Denom: "uatom", ChainID: "cosmoshub-4"},
"ibc/FA602364BEC305A696CBDF987058E99D8B479F0318E47314C49173E8838C5BAC": {Denom: "uqatom", ChainID: "cosmoshub-4"},
Expand Down

0 comments on commit 2f2108d

Please sign in to comment.