onflow / onflow/flow-cli

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

Open
#2,045 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
209
Forks
87
Avg merge
1d 17h
Merged PRs (30d)
3

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the documented flow transactions get command with -o json and inspect the output and the error from cadence/json.Decode. Then compare that output with the format expected by the cadence Go dependency. Done means the transaction output can be decoded into an in-memory representation in Go.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
blockchain, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.