Skip to content

Commit

Permalink
filter contract msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
edjroz committed Nov 21, 2024
1 parent e7a1384 commit 54a4121
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
12 changes: 8 additions & 4 deletions integration_tests/abstract_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
cometClient "github.com/cometbft/cometbft/rpc/client"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
cometRpcCoreTypes "github.com/cometbft/cometbft/rpc/core/types"
cometTypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
aatypes "github.com/larry0x/abstract-account/x/abstractaccount/types"
Expand Down Expand Up @@ -817,15 +816,18 @@ func TestXionClientEvent(t *testing.T) {
err = cometWsClient.Start()
require.NoError(t, err)

eventStream, err := subscribeToEvent(t, ctx, cometTypes.EventTx, cometWsClient)
//eventStream, err := subscribeToEvent(t, ctx, cometTypes.EventTx, cometWsClient)
eventStream, err := subscribeToEvent(t, ctx, aaContractAddr, cometWsClient)

require.NoError(t, err)

// note: MASSIVELY unsafe, need to be able to cancel, consider wrapping around a separate goroutine and adding a work timer
var wg sync.WaitGroup
wg.Add(1)
go receiveEvents(t, &wg, eventStream)

time.Sleep(5 * time.Second) // sleeping for 5 seconds to make sure we intercept transactions
time.Sleep(10 * time.Second) // sleeping for 5 seconds to make sure we intercept transactions
fmt.Println("slept for 10s")
jsonExecMsgStr, err = GenerateTx(t, ctx, xion.GetNode(),
xionUser.KeyName(),
"xion", "emit", "arbitrary_data", aaContractAddr,
Expand Down Expand Up @@ -872,7 +874,9 @@ func getCometClient(hostAddr string) (cometClient.Client, error) {
}

func subscribeToEvent(t *testing.T, ctx context.Context, eventType string, cli cometClient.Client) (<-chan cometRpcCoreTypes.ResultEvent, error) {
return cli.Subscribe(ctx, "helpers", cometTypes.QueryForEvent(eventType).String())
ev := fmt.Sprintf("message.module='wasm' AND message.action='/cosmwasm.wasm.v1.MsgExecuteContract' AND wasm-account_emit._contract_address='%s'", eventType)
fmt.Printf("%s\n\n\n", ev)
return cli.Subscribe(ctx, "helpers", "message.module='wasm' AND message.action='/cosmwasm.wasm.v1.MsgExecuteContract' AND eventType.eventAttribute='wasm-account_emit._contract_address'")
}

func receiveEvents(t *testing.T, wg *sync.WaitGroup, eventStream <-chan cometRpcCoreTypes.ResultEvent) {
Expand Down
15 changes: 0 additions & 15 deletions x/xion/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,23 +531,8 @@ func NewEmitArbitraryDataCmd() *cobra.Command {

contractAddr := args[1]

signMode := signing.SignMode_SIGN_MODE_UNSPECIFIED
switch clientCtx.SignModeStr {
case flags.SignModeDirect:
signMode = signing.SignMode_SIGN_MODE_DIRECT
case flags.SignModeLegacyAminoJSON:
signMode = signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON
case flags.SignModeDirectAux:
signMode = signing.SignMode_SIGN_MODE_DIRECT_AUX
case flags.SignModeTextual:
signMode = signing.SignMode_SIGN_MODE_TEXTUAL
case flags.SignModeEIP191:
signMode = signing.SignMode_SIGN_MODE_EIP_191
}

data := map[string]interface{}{}
data["data"] = arbitraryData

msg := map[string]interface{}{}
msg["emit"] = data

Expand Down

0 comments on commit 54a4121

Please sign in to comment.