Skip to content

Commit

Permalink
Merge pull request #2 from DongLieu/dong/v2.2.0-giulaiibc
Browse files Browse the repository at this point in the history
Dong/v2.2.0 giulaiibc
  • Loading branch information
DongLieu authored Nov 21, 2024
2 parents 78e47d7 + c7f4b83 commit d0df442
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
6 changes: 6 additions & 0 deletions app/upgrades/v2.2.0/ibc-anom
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
transfer channel-10: onomy1fp9wuhq58pz53wxvv3tnrxkw8m8s6swph55z88 : 223034150190500000000020
transfer channel-11: onomy1kx2k3mpugtwtajd4zsykx90cn8xawe54u4qmr3 : 1405
transfer channel-2 : onomy12k2pyuylm9t7ugdvz67h9pg4gmmvhn5v983yq3 : 10
transfer channel-5 : onomy16h2ynrzwhxgjnd0hswkvdvq9nav9kklqkdaavu : 19190000999999995010
transfer channel-6 : onomy1a9gzwgqf8069v9j500paye5dm2p54tlxufzc0w : 500
transfer channel-0 : onomy1a53udazy8ayufvy0s434pfwjcedzqv34vdkn6t : 481781795811625803519160
24 changes: 20 additions & 4 deletions app/upgrades/v2.2.0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package v2_1_0 //nolint:revive,stylecheck // app version

import (
"context"
"slices"

"cosmossdk.io/collections"
"cosmossdk.io/math"
upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibctypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"

"github.com/onomyprotocol/onomy/app/keepers"
)
Expand All @@ -36,7 +39,13 @@ func CreateUpgradeHandler(
return vm, err
}

// distribution.
// ibc
var escrowAddress []string
balancesIBCTranfer := keepers.TransferKeeper.GetAllTotalEscrowed(ctx)
keepers.IBCKeeper.ChannelKeeper.IterateChannels(ctx, func(ic ibctypes.IdentifiedChannel) bool {
escrowAddress = append(escrowAddress, transfertypes.GetEscrowAddress(ic.PortId, ic.ChannelId).String())
return false
})

// bank.
keepers.BankKeeper.SetDenomMetaData(ctx, banktypes.Metadata{
Expand All @@ -54,8 +63,12 @@ func CreateUpgradeHandler(
})

err = keepers.BankKeeper.Balances.Walk(ctx, nil, func(key collections.Pair[sdk.AccAddress, string], value math.Int) (stop bool, err error) {
addr := sdk.AccAddress(key.K1())
if slices.Contains(escrowAddress, addr.String()) {
return false, nil
}
if key.K2() == "anom" {
err = keepers.BankKeeper.Balances.Set(ctx, collections.Join(sdk.AccAddress(key.K1()), "ono"), value)
err = keepers.BankKeeper.Balances.Set(ctx, collections.Join(addr, "ono"), value)
if err != nil {
return true, err
}
Expand All @@ -73,8 +86,11 @@ func CreateUpgradeHandler(

err = keepers.BankKeeper.Supply.Walk(ctx, nil, func(key string, value math.Int) (stop bool, err error) {
if key == "anom" {
err = keepers.BankKeeper.Supply.Set(ctx, "ono", value)
err = keepers.BankKeeper.Supply.Remove(ctx, "anom")
err = keepers.BankKeeper.Supply.Set(ctx, "ono", value.Sub(balancesIBCTranfer.AmountOf("anom")))
if err != nil {
return true, err
}
err = keepers.BankKeeper.Supply.Set(ctx, "anom", balancesIBCTranfer.AmountOf("anom"))
}
return false, err
})
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ require (

replace (
github.com/cosmos/cosmos-sdk => github.com/DongLieu/cosmos-sdk v0.50.8-onomy
github.com/cosmos/ibc-go/v8 => github.com/DongLieu/ibc-go/v8 v8.3.2-onomy
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=
github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/DongLieu/cosmos-sdk v0.50.8-onomy h1:+VnpHmxjUzTBc6eGM5B8quC2tEPU2VXBqzI1Cl1xFDc=
github.com/DongLieu/cosmos-sdk v0.50.8-onomy/go.mod h1:Zb+DgHtiByNwgj71IlJBXwOq6dLhtyAq3AgqpXm/jHo=
github.com/DongLieu/ibc-go/v8 v8.3.2-onomy h1:hauIZedHlTC1CFk3owStqaDr1MRxrmGo3tbCR6VItbA=
github.com/DongLieu/ibc-go/v8 v8.3.2-onomy/go.mod h1:WVVIsG39jGrF9Cjggjci6LzySyWGloz194sjTxiGNIE=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
Expand Down Expand Up @@ -357,8 +359,6 @@ github.com/cosmos/iavl v1.1.2 h1:zL9FK7C4L/P4IF1Dm5fIwz0WXCnn7Bp1M2FxH0ayM7Y=
github.com/cosmos/iavl v1.1.2/go.mod h1:jLeUvm6bGT1YutCaL2fIar/8vGUE8cPZvh/gXEWDaDM=
github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE=
github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco=
github.com/cosmos/ibc-go/v8 v8.3.2 h1:8X1oHHKt2Bh9hcExWS89rntLaCKZp2EjFTUSxKlPhGI=
github.com/cosmos/ibc-go/v8 v8.3.2/go.mod h1:WVVIsG39jGrF9Cjggjci6LzySyWGloz194sjTxiGNIE=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0=
github.com/cosmos/interchain-security/v5 v5.2.0 h1:ZB4sMH5kG4Fmuk+WLKykXv8qSSoafo1eVlSo0G5scKE=
Expand Down

0 comments on commit d0df442

Please sign in to comment.