Skip to content

Commit

Permalink
fix (scheduler): inject expected wrapping in payload (#1336)
Browse files Browse the repository at this point in the history
# Related Github tickets

fixes VolumeFi#2543

# Testing completed

- [x] test coverage exists or has been added/updated
- [x] tested in a private testnet

# Breaking changes

- [x] I have checked my code for breaking changes
- [x] If there are breaking changes, there is a supporting migration.
  • Loading branch information
byte-bandit authored Jan 28, 2025
1 parent 9c3197c commit 90e1e81
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion x/scheduler/bindings/msg_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package bindings

import (
"context"
"encoding/hex"
"fmt"

sdkerrors "cosmossdk.io/errors"
wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types"
Expand Down Expand Up @@ -99,9 +101,12 @@ func (m *customMessenger) executeJob(ctx sdk.Context, contractAddr sdk.AccAddres
return nil, nil, nil, wasmvmtypes.InvalidRequest{Err: "missing payload"}
}

hexString := hex.EncodeToString(e.Payload)
injected := []byte(fmt.Sprintf("{\"hexPayload\":\"%s\"}", hexString))

// We use the keeper method here instead of going via msg server,
// as that will allow us to set the sender contract address.
_, err := m.k.ExecuteJob(ctx, e.JobID, e.Payload, contractAddr, contractAddr)
_, err := m.k.ExecuteJob(ctx, e.JobID, injected, contractAddr, contractAddr)
if err != nil {
return nil, nil, nil, sdkerrors.Wrap(err, "failed to trigger job execution.")
}
Expand Down

0 comments on commit 90e1e81

Please sign in to comment.