Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccessKeyView Unmarshal failed #19

Closed
vic-dayou opened this issue Jun 22, 2022 · 1 comment
Closed

AccessKeyView Unmarshal failed #19

vic-dayou opened this issue Jun 22, 2022 · 1 comment
Labels
invalid This doesn't seem right

Comments

@vic-dayou
Copy link

        c, _ := NewClient("https://rpc.testnet.near.org")
	var resp AccessKeyView
	_, _ = c.doRPC(context.Background(), &resp, "query", block.FinalityFinal(), map[string]interface{}{
		"request_type": "view_access_key",
		"account_id":   "yuhainan.testnet",
		"public_key":   "ed25519:AWRz5BzmJUbjKgr6Ln2VcwkuEh8QipRjxGt9YdjNeJn",
	})
        fmt.Println(resp)

Result:

{{91568545000006 {true {<nil>  []}}} {0 11111111111111111111111111111111}}

when i use postman everything is ok
image

how to fix it?

@mikroskeem
Copy link
Member

mikroskeem commented Jun 22, 2022

Do not use internal doRPC method for this, because it is not guaranteed to handle more complex structures.

You rather want to do something like this:

func main() {
        c := config.Networks["testnet"]
        rpc, err := client.NewClient(c.NodeURL)
        if err != nil {
                panic(err)
        }

        publicKey, err := key.NewBase58PublicKey("ed25519:AWRz5BzmJUbjKgr6Ln2VcwkuEh8QipRjxGt9YdjNeJn")
        if err != nil {
                panic(err)
        }

        ctx := context.Background()
        res, err := rpc.AccessKeyView(ctx, "yuhainan.testnet", publicKey, block.FinalityFinal())
        if err != nil {
                panic(err)
        }
        
        // TODO: use res
        _ = res
}

@mikroskeem mikroskeem added the invalid This doesn't seem right label Jun 22, 2022
mikroskeem added a commit that referenced this issue Jun 23, 2022
Reported in #19, didn't actually realize the issue at first glance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants