eoscanada / eos-go

EOS.IO Go API library
MIT License
561 stars 216 forks source link

Does not support action parameter of std::map<string, string> #137

Closed mgravitt closed 4 years ago

mgravitt commented 4 years ago

@maoueh

I receive an error when attempting to push a transaction that has a std::map<string, string> parameter. I debugged a bit and I think the problem is in json.Encode. Here is the error message:

2020/03/15 22:33:14 Error signing transaction: get_required_keys: json: error calling MarshalJSON for type *eos.Action: Encode: unsupported type map[string]string
panic: get_required_keys: json: error calling MarshalJSON for type *eos.Action: Encode: unsupported type map[string]string

goroutine 1 [running]:
main.main()
        /home/max/map-parms/main.go:67 +0x1ba
exit status 2

You can reproduce this by running main.go from this repo: https://github.com/dappdever/map-parms

The contract is deployed to messengerbus on kylin.

The source for the contract is located here: https://github.com/eosio-enterprise/chappe/blob/master/contracts/messenger/include/messenger.hpp#L11

maoueh commented 4 years ago

@dappdever Added support for map<string, string> (and in fact, any map<K, V> types, as long as K is the same type over the entire map).

This requires a bump to a unreleased version of eos-go that contain a breaking change. We added a ctx context.Context argument to almost all call sites performing any long running work like signing a transaction or calling the API.

The update is relatively straightforward, you can simply start with adding context.Background() at the front of function now requiring at their first argument a context.Context object.

I created https://github.com/dappdever/map-parms/pull/1 on your test repository to show case how to update to master version.

You can also take a look at this bigger commit if required: https://github.com/eoscanada/eosc/commit/76d29d2b4d43317bc32ab902d91334885c9a9c3e