Skip to content

Parse json output of flow-cli for transaction using cadence/json #2045

@bjartek

Description

@bjartek

Instructions

I am trying to parse the output of flow-cli`s -o json flag into a cadence transaction using cadence go dependency. This used to work, but now it does not work anymore

Problem

flow transactions get c82243bb504e49a0bd55191d8a7b6001ef391ce6fa5e69f580e2e3ca8524372e -n mainnet -o json | ./overflow-json

this does not work where code is

package main

import (
	"fmt"
	"io"
	"os"

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

func main() {
	_, err := os.Stdin.Stat()
	if err != nil {
		panic(err)
	}

	bytes, err := io.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}
	value, err := jsoncdc.Decode(nil, bytes)
	if err != nil {
		panic(err)
	}
	output, err := underflow.CadenceValueToJsonString(value)
	if err != nil {
		panic(err)
	}
	fmt.Println(output)
}

It fails on line 24, so before my code even runs.

Steps to Reproduce

Build the binary from the code above and try to run the cli command

Acceptance Criteria

It is possible to parse flow-cli transaction output into a in memory representation in golang.

Context

Debugging things

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions