AccessKeyView Unmarshal failed
vic-dayou opened this issue · 1 comments
vic-dayou commented
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
how to fix it?
mikroskeem commented
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
}