Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: import secp256k1 for amino parsing (gnolang#1178)
## Amino failed to parse crypto.PubKey ### Description This simple client isn't working to get account because amino don't know the struct `BaseAccount.Pubkey crypto.PubKey` This simple main can be fixed by importing, i believe it will make dev experience easier by putting it in `std` rather than clients ``` _ "github.com/gnolang/gno/tm2/pkg/crypto/secp256k1" ``` ```go package main import ( "fmt" "github.com/gnolang/gno/tm2/pkg/amino" rpcClient "github.com/gnolang/gno/tm2/pkg/bft/rpc/client" "github.com/gnolang/gno/tm2/pkg/std" ) // Client is the TM2 HTTP client type Client struct { client rpcClient.Client } // NewClient creates a new TM2 HTTP client func NewClient(remote string) *Client { return &Client{ client: rpcClient.NewHTTP(remote, ""), } } func (c *Client) GetAccount(address string) (std.Account, error) { path := fmt.Sprintf("auth/accounts/%s", address) queryResponse, err := c.client.ABCIQuery(path, []byte{}) if err != nil { return nil, fmt.Errorf("unable to execute ABCI query, %w", err) } var queryData struct{ BaseAccount std.BaseAccount } if err := amino.UnmarshalJSON(queryResponse.Response.Data, &queryData); err != nil { return nil, err } return &queryData.BaseAccount, nil } func main() { c := NewClient("http://rpc.gnochess.com:80") acc, err := c.GetAccount("g1x90eh5ejc22548hjqznm2egyvn8ny36lqu460f") fmt.Println(acc, err) } ``` ``` runtime: goroutine stack exceeds 1000000000-byte limit runtime: sp=0xc020780390 stack=[0xc020780000, 0xc040780000] fatal error: stack overflow runtime stack: runtime.throw({0x9842fa?, 0xd4dea0?}) /nix/store/akhjsmrrsakcnj8x3xgygvizhccbyn0v-go-1.19.3/share/go/src/runtime/panic.go:1047 +0x5d fp=0x7f681368cc18 sp=0x7f681368cbe8 pc=0x43907d runtime.newstack() /nix/store/akhjsmrrsakcnj8x3xgygvizhccbyn0v-go-1.19.3/share/go/src/runtime/stack.go:1103 +0x5cc fp=0x7f681368cdd0 sp=0x7f681368cc18 pc=0x452d0c runtime.morestack() /nix/store/akhjsmrrsakcnj8x3xgygvizhccbyn0v-go-1.19.3/share/go/src/runtime/asm_amd64.s:570 +0x8b fp=0x7f681368cdd8 sp=0x7f681368cdd0 pc=0x46a32b goroutine 1 [running]: fmt.(*fmt).padString(0xc00de1ff20?, {0x8961be, 0x7}) /nix/store/akhjsmrrsakcnj8x3xgygvizhccbyn0v-go-1.19.3/share/go/src/fmt/format.go:108 +0x299 fp=0xc0207803a0 sp=0xc020780398 pc=0x4dac39 fmt.(*fmt).fmtS(0xc0207803f8?, {0x8961be?, 0x8961bd?}) /nix/store/akhjsmrrsakcnj8x3xgygvizhccbyn0v-go-1.19.3/share/go/src/fmt/format.go:359 +0x3f fp=0xc0207803d8 sp=0xc0207803a0 pc=0x4db75f fmt.(*pp).fmtString(0x8ca000?, {0x8961be?, 0x8ca000?}, 0x0?) /nix/store/akhjsmrrsakcnj8x3xgygvizhccbyn0v-go-1.19.3/share/go/src/fmt/print.go:474 +0x86 fp=0xc020780428 sp=0xc0207803d8 pc=0x4de566 fmt.(*pp).handleMethods(0xc00de1fee0, 0x100800?) /nix/store/akhjsmrrsakcnj8x3xgygvizhccbyn0v-go-1.19.3/share/go/src/fmt/print.go:65 [....] It's a stack overflow due to recursion ``` <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details>
- Loading branch information