Skip to content

Commit

Permalink
Fix json encoding for transaction result (#1768)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryokik authored Sep 24, 2024
1 parent 30eaa63 commit fd6649d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion internal/transactions/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (
"github.com/onflow/flow-cli/internal/command"
"github.com/onflow/flow-cli/internal/events"
"github.com/onflow/flow-cli/internal/util"

jsoncdc "github.com/onflow/cadence/encoding/json"
)

var Cmd = &cobra.Command{
Expand Down Expand Up @@ -82,7 +84,7 @@ func (r *transactionResult) JSON() any {
"index": event.EventIndex,
"type": event.Type,
"values": json.RawMessage(
event.Payload,
jsoncdc.MustEncode(event.Value),
),
})
}
Expand Down
3 changes: 1 addition & 2 deletions internal/transactions/transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ func Test_Result(t *testing.T) {
[]cadence.Field{{Type: cadence.StringType, Identifier: "bar"}},
[]cadence.Value{cadence.NewInt(1)},
)
event.Payload = []byte("mock_payload")

withdrawFlowEvent := tests.NewEvent(
1,
Expand Down Expand Up @@ -446,7 +445,7 @@ Fee Events (hidden, use --include fee-events)`, output.OkEmoji()), "\n")
map[string]any{
"index": 0,
"type": "A.foo",
"values": json.RawMessage{0x6d, 0x6f, 0x63, 0x6b, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64},
"values": json.RawMessage{0x7b, 0x22, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x7b, 0x22, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x41, 0x2e, 0x66, 0x6f, 0x6f, 0x22, 0x2c, 0x22, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x7b, 0x22, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x22, 0x31, 0x22, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x49, 0x6e, 0x74, 0x22, 0x7d, 0x2c, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x22, 0x62, 0x61, 0x72, 0x22, 0x7d, 0x5d, 0x7d, 0x2c, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x22, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x7d, 0xa},
},
},
"id": "e913d1f3e431c7df49c99845bea9ebff9db11bbf25d507b9ad0fad45652d515f",
Expand Down

0 comments on commit fd6649d

Please sign in to comment.