diff --git a/go.mod b/go.mod index cd235a4..7194c7f 100644 --- a/go.mod +++ b/go.mod @@ -154,7 +154,7 @@ require ( replace ( // Use the cosmos-flavored keyring library github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 - github.com/CosmWasm/wasmvm => github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.1 + github.com/CosmWasm/wasmvm => github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.2 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.45 github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.1.9 diff --git a/go.sum b/go.sum index 64ef1a1..41ee4cb 100644 --- a/go.sum +++ b/go.sum @@ -782,8 +782,8 @@ github.com/sei-protocol/sei-tendermint v0.3.3 h1:zH6xxrSRwHERaj/AcCR76U9daVY3Ub8 github.com/sei-protocol/sei-tendermint v0.3.3/go.mod h1:4LSlJdhl3nf3OmohliwRNUFLOB1XWlrmSodrIP7fLh4= github.com/sei-protocol/sei-tm-db v0.0.5 h1:3WONKdSXEqdZZeLuWYfK5hP37TJpfaUa13vAyAlvaQY= github.com/sei-protocol/sei-tm-db v0.0.5/go.mod h1:Cpa6rGyczgthq7/0pI31jys2Fw0Nfrc+/jKdP1prVqY= -github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.1 h1:OhDRa2VSvc5cjygSY15+ymLlWqsuVJNm3PibTPlR2IE= -github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.1/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys= +github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.2 h1:bhfjHJFhYe/Ffq83UsSJrCcZPkAx5TSEJl1z5lBd6ow= +github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.2/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys= github.com/sei-protocol/tm-db v0.0.4 h1:7Y4EU62Xzzg6wKAHEotm7SXQR0aPLcGhKHkh3qd0tnk= github.com/sei-protocol/tm-db v0.0.4/go.mod h1:PWsIWOTwdwC7Ow/GUvx8HgUJTO691pBuorIQD8JvwAs= github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= diff --git a/x/wasm/keeper/query_plugins.go b/x/wasm/keeper/query_plugins.go index 4a2dcef..395b403 100644 --- a/x/wasm/keeper/query_plugins.go +++ b/x/wasm/keeper/query_plugins.go @@ -3,6 +3,7 @@ package keeper import ( "encoding/json" "errors" + "math" "time" "github.com/cosmos/cosmos-sdk/baseapp" @@ -379,6 +380,26 @@ func StakingQuerier(keeper types.StakingKeeper, distKeeper types.DistributionKee } return json.Marshal(res) } + if request.UnbondingDelegations != nil { + delegator, err := sdk.AccAddressFromBech32(request.UnbondingDelegations.Delegator) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, request.UnbondingDelegations.Delegator) + } + + delegations := keeper.GetUnbondingDelegations(ctx, delegator, math.MaxUint16) + var res wasmvmtypes.UnbondingDelegationsResponse + for _, delegation := range delegations { + for _, e := range delegation.Entries { + res.Entries = append(res.Entries, wasmvmtypes.UnbondingDelegationEntry{ + CreationHeight: e.CreationHeight, + CompletionTime: e.CompletionTime.Format(time.RFC3339), + InitialBalance: e.InitialBalance.String(), + Balance: e.Balance.String(), + }) + } + } + return json.Marshal(res) + } return nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown Staking variant"} } } diff --git a/x/wasm/types/expected_keepers.go b/x/wasm/types/expected_keepers.go index 651c87a..de60113 100644 --- a/x/wasm/types/expected_keepers.go +++ b/x/wasm/types/expected_keepers.go @@ -67,6 +67,7 @@ type StakingKeeper interface { HasReceivingRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) bool GetUnbondingDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (stakingtypes.UnbondingDelegation, bool) + GetUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) []stakingtypes.UnbondingDelegation } // ChannelKeeper defines the expected IBC channel keeper