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

Add PoE staking query plugin #170

Merged
merged 6 commits into from
Nov 8, 2021
Merged

Add PoE staking query plugin #170

merged 6 commits into from
Nov 8, 2021

Conversation

alpe
Copy link
Contributor

@alpe alpe commented Oct 27, 2021

Resolves #96

Wasm query plugin to communicates with PoE contracts.

With this PR the wasm query setup moves into the app level so that different modules can provide their own extensions without creating dependency issues. Similar to the ante setup

Base automatically changed from contract_abstraction to main October 28, 2021 15:02
@alpe alpe changed the title WIP: staking query plugin Add PoE staking query plugin Nov 4, 2021
@alpe alpe marked this pull request as ready for review November 4, 2021 09:04
@alpe alpe requested a review from ethanfrey November 4, 2021 09:04
Copy link
Contributor

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

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

Nice work, a few comments to polish it off.

app/wasm.go Show resolved Hide resolved
twasmKeeper := twasmkeeper.NewKeeper(

var twasmKeeper twasmkeeper.Keeper
handler := wasmkeeper.WithMessageHandlerDecorator(func(nested wasmkeeper.Messenger) wasmkeeper.Messenger {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to ensure this is in sync with the version in app/wasm.go, then maybe we just pull this decoration into a function in app/wasm.go and call the same wrapping function from the test code.

Copy link
Contributor Author

@alpe alpe Nov 4, 2021

Choose a reason for hiding this comment

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

I see your point but we would have cyclic dependencies in app.
We don't need the full set of custom queries/messages here but only the twasm ones for genesis/ boostrap tests in this module.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. Cyclic dependencies are annoying and Go is not terribly good at handling them,

x/poe/wasm/query_plugin.go Show resolved Hide resolved
x/poe/wasm/query_plugin.go Outdated Show resolved Hide resolved
x/poe/wasm/query_plugin.go Show resolved Hide resolved
x/poe/wasm/query_plugin.go Outdated Show resolved Hide resolved
x/poe/wasm/query_plugin.go Outdated Show resolved Hide resolved
@@ -257,7 +261,24 @@ func createTestInput(
stakingtypes.RegisterQueryServer(querier, stakingkeeper.Querier{Keeper: stakingKeeper})
distributiontypes.RegisterQueryServer(querier, distKeeper)

keeper := NewKeeper(
var keeper Keeper
handler := wasmkeeper.WithMessageHandlerDecorator(func(nested wasmkeeper.Messenger) wasmkeeper.Messenger {
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, good to reuse a function from app/wasm.go

Copy link
Contributor

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

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

nice fixes

example.BankKeeper.SetBalances(ctx, myOperatorAddr, sdk.NewCoins(sdk.NewCoin(types.DefaultBondDenom, sdk.NewInt(100))))

var oneInt = sdk.OneInt()
specs := map[string]struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

good set of queries and high-level integration test for the contracts

reward, err := poeKeeper.DistributionContract(ctx).ValidatorOutstandingReward(ctx, delegator)
if err != nil {
return nil, err
CanRedelegate: wasmvmtypes.NewCoin(0, bondDenom),
Copy link
Contributor

Choose a reason for hiding this comment

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

looks good

@ethanfrey ethanfrey merged commit b9fa236 into main Nov 8, 2021
@ethanfrey ethanfrey deleted the 156-handlers branch November 8, 2021 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support staking queries for contract
2 participants