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

fix: fulfill trade transfer fee logic #436

Merged
merged 4 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- [#421](https://github.com/Pylons-tech/pylons/pull/421) Add game simulation testing to cli test suite. Tests cover CEL environment execution, item modification and cookbook coin generation.

### Fixes:
- [#346](https://github.com/Pylons-tech/pylons/pull/436) Fixes a bug in `x/pylons/keeper/msg_server_fulfill_trade.go` where a transfer fees were being matched from itemInputs where they should have been from itemOutputs.
- [#346](https://github.com/Pylons-tech/pylons/pull/436) Fixes a bug in `x/pylons/keeper/msg_server_fulfill_trade.go` where a `MatchItemInputsForTrade()` would return an error incorrectly.
- [#434](https://github.com/Pylons-tech/pylons/pull/434) Add missing `RegisterStoreDecoder()` functionality in `x/pylons/module.go` to enable module simulation tests.
- [#429](https://github.com/Pylons-tech/pylons/pull/429) Dependabot security upgrade
- [#421](https://github.com/Pylons-tech/pylons/pull/421) Recipe execution validation and item matching logic fixed.
Expand Down
5 changes: 2 additions & 3 deletions contrib/devtools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ RUNSIM = $(TOOLS_DESTDIR)/runsim
runsim: $(RUNSIM)
$(RUNSIM):
@echo "Installing runsim..."
@(cd /tmp && go install github.com/cosmos/tools/cmd/runsim@v1.0.0)
@(cd /tmp && go install github.com/cosmos/tools/cmd/runsim@master)

tools-clean:
rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM)
rm -f proto-tools-stamp tools-stamp
rm -f $(RUNSIM)

.PHONY: tools-clean runsim
26 changes: 26 additions & 0 deletions testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import (
"testing"
"time"

"github.com/cosmos/cosmos-sdk/client/flags"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/stretchr/testify/require"

"github.com/Pylons-tech/pylons/x/pylons/client/cli"

"github.com/cosmos/cosmos-sdk/codec"

"github.com/Pylons-tech/pylons/x/pylons/types"
Expand Down Expand Up @@ -45,6 +51,26 @@ func New(t *testing.T, configs ...network.Config) *network.Network {
}
net := network.New(t, cfg)
t.Cleanup(net.Cleanup)

// create accounts for the validators
for i, val := range net.Validators {
ctx := val.ClientCtx
addr := val.Address.String()
flags := []string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, addr),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdk.NewInt(10))).String()),
}

args := []string{fmt.Sprintf("val%d", i)}
args = append(args, flags...)
_, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateAccount(), args)
require.NoError(t, err)
// var resp sdk.TxResponse
// require.NoError(t, ctx.JSONCodec.UnmarshalJSON(out.Bytes(), &resp))
}

return net
}

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { StdFee } from "@cosmjs/launchpad";
import { OfflineSigner, EncodeObject } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgFulfillTrade } from "./types/pylons/tx";
import { MsgCompleteExecutionEarly } from "./types/pylons/tx";
import { MsgCancelTrade } from "./types/pylons/tx";
import { MsgSetItemString } from "./types/pylons/tx";
import { MsgCreateCookbook } from "./types/pylons/tx";
import { MsgTransferCookbook } from "./types/pylons/tx";
import { MsgGoogleInAppPurchaseGetCoins } from "./types/pylons/tx";
import { MsgUpdateAccount } from "./types/pylons/tx";
import { MsgSendItems } from "./types/pylons/tx";
import { MsgCreateTrade } from "./types/pylons/tx";
import { MsgFulfillTrade } from "./types/pylons/tx";
import { MsgUpdateRecipe } from "./types/pylons/tx";
import { MsgCompleteExecutionEarly } from "./types/pylons/tx";
import { MsgGoogleInAppPurchaseGetCoins } from "./types/pylons/tx";
import { MsgCreateAccount } from "./types/pylons/tx";
import { MsgTransferCookbook } from "./types/pylons/tx";
import { MsgCancelTrade } from "./types/pylons/tx";
import { MsgExecuteRecipe } from "./types/pylons/tx";
import { MsgCreateRecipe } from "./types/pylons/tx";
import { MsgUpdateCookbook } from "./types/pylons/tx";
import { MsgUpdateAccount } from "./types/pylons/tx";
import { MsgCreateAccount } from "./types/pylons/tx";
import { MsgCreateTrade } from "./types/pylons/tx";
import { MsgCreateRecipe } from "./types/pylons/tx";
import { MsgCreateCookbook } from "./types/pylons/tx";
export declare const MissingWalletError: Error;
interface TxClientOptions {
addr: string;
Expand All @@ -26,21 +26,21 @@ interface SignAndBroadcastOptions {
}
declare const txClient: (wallet: OfflineSigner, { addr: addr }?: TxClientOptions) => Promise<{
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }?: SignAndBroadcastOptions) => Promise<import("@cosmjs/stargate").BroadcastTxResponse>;
msgFulfillTrade: (data: MsgFulfillTrade) => EncodeObject;
msgCompleteExecutionEarly: (data: MsgCompleteExecutionEarly) => EncodeObject;
msgCancelTrade: (data: MsgCancelTrade) => EncodeObject;
msgSetItemString: (data: MsgSetItemString) => EncodeObject;
msgCreateCookbook: (data: MsgCreateCookbook) => EncodeObject;
msgTransferCookbook: (data: MsgTransferCookbook) => EncodeObject;
msgGoogleInAppPurchaseGetCoins: (data: MsgGoogleInAppPurchaseGetCoins) => EncodeObject;
msgUpdateAccount: (data: MsgUpdateAccount) => EncodeObject;
msgSendItems: (data: MsgSendItems) => EncodeObject;
msgCreateTrade: (data: MsgCreateTrade) => EncodeObject;
msgFulfillTrade: (data: MsgFulfillTrade) => EncodeObject;
msgUpdateRecipe: (data: MsgUpdateRecipe) => EncodeObject;
msgCompleteExecutionEarly: (data: MsgCompleteExecutionEarly) => EncodeObject;
msgGoogleInAppPurchaseGetCoins: (data: MsgGoogleInAppPurchaseGetCoins) => EncodeObject;
msgCreateAccount: (data: MsgCreateAccount) => EncodeObject;
msgTransferCookbook: (data: MsgTransferCookbook) => EncodeObject;
msgCancelTrade: (data: MsgCancelTrade) => EncodeObject;
msgExecuteRecipe: (data: MsgExecuteRecipe) => EncodeObject;
msgCreateRecipe: (data: MsgCreateRecipe) => EncodeObject;
msgUpdateCookbook: (data: MsgUpdateCookbook) => EncodeObject;
msgUpdateAccount: (data: MsgUpdateAccount) => EncodeObject;
msgCreateAccount: (data: MsgCreateAccount) => EncodeObject;
msgCreateTrade: (data: MsgCreateTrade) => EncodeObject;
msgCreateRecipe: (data: MsgCreateRecipe) => EncodeObject;
msgCreateCookbook: (data: MsgCreateCookbook) => EncodeObject;
}>;
interface QueryClientOptions {
addr: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
import { SigningStargateClient } from "@cosmjs/stargate";
import { Registry } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgFulfillTrade } from "./types/pylons/tx";
import { MsgCompleteExecutionEarly } from "./types/pylons/tx";
import { MsgCancelTrade } from "./types/pylons/tx";
import { MsgSetItemString } from "./types/pylons/tx";
import { MsgCreateCookbook } from "./types/pylons/tx";
import { MsgTransferCookbook } from "./types/pylons/tx";
import { MsgGoogleInAppPurchaseGetCoins } from "./types/pylons/tx";
import { MsgUpdateAccount } from "./types/pylons/tx";
import { MsgSendItems } from "./types/pylons/tx";
import { MsgCreateTrade } from "./types/pylons/tx";
import { MsgFulfillTrade } from "./types/pylons/tx";
import { MsgUpdateRecipe } from "./types/pylons/tx";
import { MsgCompleteExecutionEarly } from "./types/pylons/tx";
import { MsgGoogleInAppPurchaseGetCoins } from "./types/pylons/tx";
import { MsgCreateAccount } from "./types/pylons/tx";
import { MsgTransferCookbook } from "./types/pylons/tx";
import { MsgCancelTrade } from "./types/pylons/tx";
import { MsgExecuteRecipe } from "./types/pylons/tx";
import { MsgCreateRecipe } from "./types/pylons/tx";
import { MsgUpdateCookbook } from "./types/pylons/tx";
import { MsgUpdateAccount } from "./types/pylons/tx";
import { MsgCreateAccount } from "./types/pylons/tx";
import { MsgCreateTrade } from "./types/pylons/tx";
import { MsgCreateRecipe } from "./types/pylons/tx";
import { MsgCreateCookbook } from "./types/pylons/tx";
const types = [
["/Pylonstech.pylons.pylons.MsgFulfillTrade", MsgFulfillTrade],
["/Pylonstech.pylons.pylons.MsgCompleteExecutionEarly", MsgCompleteExecutionEarly],
["/Pylonstech.pylons.pylons.MsgCancelTrade", MsgCancelTrade],
["/Pylonstech.pylons.pylons.MsgSetItemString", MsgSetItemString],
["/Pylonstech.pylons.pylons.MsgCreateCookbook", MsgCreateCookbook],
["/Pylonstech.pylons.pylons.MsgTransferCookbook", MsgTransferCookbook],
["/Pylonstech.pylons.pylons.MsgGoogleInAppPurchaseGetCoins", MsgGoogleInAppPurchaseGetCoins],
["/Pylonstech.pylons.pylons.MsgUpdateAccount", MsgUpdateAccount],
["/Pylonstech.pylons.pylons.MsgSendItems", MsgSendItems],
["/Pylonstech.pylons.pylons.MsgCreateTrade", MsgCreateTrade],
["/Pylonstech.pylons.pylons.MsgFulfillTrade", MsgFulfillTrade],
["/Pylonstech.pylons.pylons.MsgUpdateRecipe", MsgUpdateRecipe],
["/Pylonstech.pylons.pylons.MsgCompleteExecutionEarly", MsgCompleteExecutionEarly],
["/Pylonstech.pylons.pylons.MsgGoogleInAppPurchaseGetCoins", MsgGoogleInAppPurchaseGetCoins],
["/Pylonstech.pylons.pylons.MsgCreateAccount", MsgCreateAccount],
["/Pylonstech.pylons.pylons.MsgTransferCookbook", MsgTransferCookbook],
["/Pylonstech.pylons.pylons.MsgCancelTrade", MsgCancelTrade],
["/Pylonstech.pylons.pylons.MsgExecuteRecipe", MsgExecuteRecipe],
["/Pylonstech.pylons.pylons.MsgCreateRecipe", MsgCreateRecipe],
["/Pylonstech.pylons.pylons.MsgUpdateCookbook", MsgUpdateCookbook],
["/Pylonstech.pylons.pylons.MsgUpdateAccount", MsgUpdateAccount],
["/Pylonstech.pylons.pylons.MsgCreateAccount", MsgCreateAccount],
["/Pylonstech.pylons.pylons.MsgCreateTrade", MsgCreateTrade],
["/Pylonstech.pylons.pylons.MsgCreateRecipe", MsgCreateRecipe],
["/Pylonstech.pylons.pylons.MsgCreateCookbook", MsgCreateCookbook],
];
export const MissingWalletError = new Error("wallet is required");
const registry = new Registry(types);
Expand All @@ -47,21 +47,21 @@ const txClient = async (wallet, { addr: addr } = { addr: "http://localhost:26657
const { address } = (await wallet.getAccounts())[0];
return {
signAndBroadcast: (msgs, { fee, memo } = { fee: defaultFee, memo: "" }) => client.signAndBroadcast(address, msgs, fee, memo),
msgFulfillTrade: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgFulfillTrade", value: data }),
msgCompleteExecutionEarly: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCompleteExecutionEarly", value: data }),
msgCancelTrade: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCancelTrade", value: data }),
msgSetItemString: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgSetItemString", value: data }),
msgCreateCookbook: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCreateCookbook", value: data }),
msgTransferCookbook: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgTransferCookbook", value: data }),
msgGoogleInAppPurchaseGetCoins: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgGoogleInAppPurchaseGetCoins", value: data }),
msgUpdateAccount: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgUpdateAccount", value: data }),
msgSendItems: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgSendItems", value: data }),
msgCreateTrade: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCreateTrade", value: data }),
msgFulfillTrade: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgFulfillTrade", value: data }),
msgUpdateRecipe: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgUpdateRecipe", value: data }),
msgCompleteExecutionEarly: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCompleteExecutionEarly", value: data }),
msgGoogleInAppPurchaseGetCoins: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgGoogleInAppPurchaseGetCoins", value: data }),
msgCreateAccount: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCreateAccount", value: data }),
msgTransferCookbook: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgTransferCookbook", value: data }),
msgCancelTrade: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCancelTrade", value: data }),
msgExecuteRecipe: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgExecuteRecipe", value: data }),
msgCreateRecipe: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCreateRecipe", value: data }),
msgUpdateCookbook: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgUpdateCookbook", value: data }),
msgUpdateAccount: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgUpdateAccount", value: data }),
msgCreateAccount: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCreateAccount", value: data }),
msgCreateTrade: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCreateTrade", value: data }),
msgCreateRecipe: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCreateRecipe", value: data }),
msgCreateCookbook: (data) => ({ typeUrl: "/Pylonstech.pylons.pylons.MsgCreateCookbook", value: data }),
};
};
const queryClient = async ({ addr: addr } = { addr: "http://localhost:1317" }) => {
Expand Down
Loading