Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Invalid cast from type #146

Closed
jcalfee opened this issue Aug 8, 2017 · 11 comments
Closed

Invalid cast from type #146

jcalfee opened this issue Aug 8, 2017 · 11 comments

Comments

@jcalfee
Copy link
Contributor

jcalfee commented Aug 8, 2017

Copy the "processed" block output from this command (except for output):

eosc transfer eos inita 1

And send the json to the push_transaction API call. I'm getting the following error:

> eos.pushTransaction({
...     "refBlockNum": "76",
...     "refBlockPrefix": "110915365",
...     "expiration": "2017-08-08T20:55:13",
...     "scope": [
...       "eos",
...       "inita"
...     ],
...     "signatures": [],
...     "authorizations": [{
.....         "account": "eos",
.....         "permission": "active"
.....       }
...     ],
...     "messages": [{
.....         "code": "eos",
.....         "type": "transfer",
.....         "data": {
.......           "from": "eos",
.......           "to": "inita",
.......           "amount": "1"
.......         },
.....         "hex_data": "000000000000e62b000000008040934b0100000000000000"
.....       }
...     ]}, callback)
undefined
> { Error: 7 bad_cast_exception: Bad Cast
Invalid cast from object_type to string
    {"type":"object_type"}
    thread-1  variant.cpp:476 as_string
    at response.text.then.bodyResp (/home/jcalfee/eosjs/eosjs/node_modules/eosjs-api/src/apigen.js:48:25)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7) status: 500, statusText: 'Internal Server Error' }

This is the error in eosd:

3049398ms thread-1   http_plugin.cpp:134           operator()           ] {"refBlockNum":18,"refBlockPrefix":1130539283,"expiration":"2017-08-08T20:51:48","scope":["inita","initb"],"messages":[{"code":"eos","type":"transfer","data":{"from":"eos","to":"inita","amount":13}}],"signatures":["1f4fce0334cd50294659a6f07163af56ea5aec8dc3e4b447efd79f491af70089431c229c55aeaeb9b15bbd294440be860277d8bc67d4aeb225fd5e3cdb03d9cc5b"],"authorizations":[{"account":"eos","permission":"active"}]}
3049400ms thread-1   chain_api_plugin.cpp:59       operator()           ] Exception encountered while processing chain.push_transaction: {"code":7,"name":"bad_cast_exception","message":"Bad Cast","stack":[{"context":{"level":"error","file":"variant.cpp","line":565,"method":"get_string","hostname":"","thread_name":"thread-1","timestamp":"2017-08-08T20:50:49"},"format":"Invalid cast from type '${type}' to Object","data":{"type":"uint64_type"}}]}

3049398ms thread-1   http_plugin.cpp:133           operator()           ] handle http request: http://127.0.0.1:8888/v1/chain/push_transaction
3049398ms thread-1   http_plugin.cpp:134           operator()           ] {"refBlockNum":18,"refBlockPrefix":1130539283,"expiration":"2017-08-08T20:51:48","scope":["inita","initb"],"messages":[{"code":"eos","type":"transfer","data":{"from":"eos","to":"inita","amount":13}}],"signatures":["1f4fce0334cd50294659a6f07163af56ea5aec8dc3e4b447efd79f491af70089431c229c55aeaeb9b15bbd294440be860277d8bc67d4aeb225fd5e3cdb03d9cc5b"],"authorizations":[{"account":"eos","permission":"active"}]}
3049400ms thread-1   chain_api_plugin.cpp:59       operator()           ] Exception encountered while processing chain.push_transaction: {"code":7,"name":"bad_cast_exception","message":"Bad Cast","stack":[{"context":{"level":"error","file":"variant.cpp","line":565,"method":"get_string","hostname":"","thread_name":"thread-1","timestamp":"2017-08-08T20:50:49"},"format":"Invalid cast from type '${type}' to Object","data":{"type":"uint64_type"}}]}
@nathanielhourt
Copy link
Contributor

Transaction no longer has a field "authorizations" -- this got moved down to Message::authorization. It might be dying trying to parse Message::authorization, which you don't have in your json.

@jcalfee
Copy link
Contributor Author

jcalfee commented Aug 8, 2017

nope

1781497ms thread-1   http_plugin.cpp:134           operator()           ] {"refBlockNum":795,"refBlockPrefix":59287120,"expiration":"2017-08-08T21:30:39","scope":["eos","inita"],"messages":[{"code":"eos","type":"transfer","data":{"from":"eos","to":"inita","amount":1}}],"signatures":["1f0563bfec4653f815b992a3f115910c472e70df018f2d783ddfe60aeffe2cf54441f69d06102260c09fe5d90b422f263f89c0cc234b933e994b8d11229f5b31a0"]}
1781497ms thread-1   chain_api_plugin.cpp:59       operator()           ] Exception encountered while processing chain.push_transaction: {"code":7,"name":"bad_cast_exception","message":"Bad Cast","stack":[{"context":{"level":"error","file":"variant.cpp","line":565,"method":"get_string","hostname":"","thread_name":"thread-1","timestamp":"2017-08-08T21:29:41"},"format":"Invalid cast from type '${type}' to Object","data":{"type":"uint64_type"}}]}

@jcalfee
Copy link
Contributor Author

jcalfee commented Aug 8, 2017

It might be the dreaded Message.type ..

@nathanielhourt
Copy link
Contributor

It might be. I'm not sure how that gets serialized to json...

@jcalfee jcalfee closed this as completed Aug 8, 2017
@jcalfee
Copy link
Contributor Author

jcalfee commented Aug 9, 2017

Here is my test command .. The api seems to be an issue if we assume the eosc output transaction is formatted correctly:

echo '{"refBlockNum":"18885","refBlockPrefix":"1955828998","expiration":"2017-08-09T13:05:25","scope":["eos","inita"],"signatures":[],"authorizations":[{"account":"eos","permission":"active"}],"messages":[{"code":"eos","type":"transfer","data":{"from":"eos","to":"inita","amount":"1"},"hex_data":"000000000000e62b000000008040934b0100000000000000"}]}' | curl http://127.0.0.1:8888/v1/chain/push_transaction -d @-

@jcalfee jcalfee reopened this Aug 9, 2017
@nathanielhourt
Copy link
Contributor

That transaction still has an authorizations field and the message lacks its authorization field.

@jcalfee
Copy link
Contributor Author

jcalfee commented Aug 15, 2017

nope

{"refBlockNum":1428,"refBlockPrefix":376491140,"expiration":"2017-08-15T18:29:09","scope":["inita","initb"],"messages":[{"code":"eos","type":"transfer","authorization":[{"account":"inita","permission":"active"}],"data":{"from":"inita","to":"initb","amount":"13"}}],"signatures":["1f095cf2fabaedd81f42e33dda85c3327bcb078f126d4993e014067f465cbad79577281a350c563ccee874546a385585885f224e1c46c1841413d28ce03fdcba8a"]}

Exception encountered while processing chain.push_transaction: {"code":7,"name":"bad_cast_exception","message":"Bad Cast","stack":[{"context":{"level":"error","file":"variant.cpp","line":565,"method":"get_string","hostname":"","thread_name":"thread-1","timestamp":"2017-08-15T18:28:11"},"format":"Invalid cast from type '${type}' to Object","data":{"type":"uint64_type"}}]}

@elmato
Copy link
Contributor

elmato commented Aug 16, 2017

@jcalfee just rename the hex_data field to data

{
    "refBlockNum": "111",
    "refBlockPrefix": "2018069090",
    "expiration": "2017-08-16T15:50:49",
    "scope": ["inita", "initb"],
    "messages": [
    {
        "code": "eos",
        "type": "transfer",
        "authorization": [
        {
            "account": "inita",
            "permission": "active"
        }],
        "data": "000000008040934b000000000041934b0a00000000000000"
    }],
    "signatures": []
}

Since the eos contract has the ABI defined, the output from push_transaction is prettyfied (decoded) before sending it back.

...
if( code_account.abi.size() > 4 ) { /// 4 == packsize of empty Abi
  try {
     msg_mvo( "data", message_from_binary( msg.code, msg.type, msg.data ) ); 
     msg_mvo( "hex_data", msg.data );
  } catch ( ... ) {
    SET_FIELD( msg_mvo, msg, data );
  }
}
...

@elmato elmato closed this as completed Aug 16, 2017
@jcalfee
Copy link
Contributor Author

jcalfee commented Aug 22, 2017

@elmato Why is the transaction in JSON decoded but the data is not? Is it like this transaction is 1/2 decoded.

@jcalfee
Copy link
Contributor Author

jcalfee commented Aug 22, 2017

Dan explained to me that if it has an ABI the data could be JSON. Otherwise the "data" would be hex.

I think I see what is going on.. The EOS contract does not have an ABI.

@jcalfee
Copy link
Contributor Author

jcalfee commented Aug 22, 2017

moved to: #215

ljrprocc pushed a commit to bithacks-tech/myeosio that referenced this issue Jul 4, 2018
taokayan pushed a commit to taokayan/eos that referenced this issue May 15, 2019
NorseGaud pushed a commit that referenced this issue Jul 30, 2019
# This is the 1st commit message:

various improvements

# This is the commit message #2:

new hash

# This is the commit message #3:

fix for script path

# This is the commit message #4:

fixes

# This is the commit message #5:

fixes

# This is the commit message #6:

fixes

# This is the commit message #7:

fixes

# This is the commit message #8:

fixes

# This is the commit message #9:

fixes

# This is the commit message #10:

fixes

# This is the commit message #11:

fixes

# This is the commit message #12:

fixes

# This is the commit message #13:

fixes

# This is the commit message #14:

fixes

# This is the commit message #15:

fixes

# This is the commit message #16:

fixes

# This is the commit message #17:

fixes

# This is the commit message #18:

fixes

# This is the commit message #19:

fixes

# This is the commit message #20:

fixes

# This is the commit message #21:

fixes

# This is the commit message #22:

fixes

# This is the commit message #23:

fixes

# This is the commit message #24:

fixes

# This is the commit message #25:

fixes

# This is the commit message #26:

testing

# This is the commit message #27:

testing

# This is the commit message #28:

testing

# This is the commit message #29:

testing

# This is the commit message #30:

testing

# This is the commit message #31:

testing

# This is the commit message #32:

testing

# This is the commit message #33:

testing

# This is the commit message #34:

testing

# This is the commit message #35:

testing

# This is the commit message #36:

testing

# This is the commit message #37:

testing

# This is the commit message #38:

testing

# This is the commit message #39:

testing

# This is the commit message #40:

testing

# This is the commit message #41:

testing

# This is the commit message #42:

testing

# This is the commit message #43:

testing

# This is the commit message #44:

fixes

# This is the commit message #45:

fixes

# This is the commit message #46:

fixes

# This is the commit message #47:

fixes

# This is the commit message #48:

fixes

# This is the commit message #49:

fixes

# This is the commit message #50:

fixes

# This is the commit message #51:

fixes

# This is the commit message #52:

fixes

# This is the commit message #53:

fixes

# This is the commit message #54:

fixes

# This is the commit message #55:

fixes

# This is the commit message #56:

fixes

# This is the commit message #57:

fixes

# This is the commit message #58:

fixes

# This is the commit message #59:

fixes

# This is the commit message #60:

fixes

# This is the commit message #61:

fixes

# This is the commit message #62:

fixes

# This is the commit message #63:

fixes

# This is the commit message #64:

fixes

# This is the commit message #65:

fixes

# This is the commit message #66:

fixes

# This is the commit message #67:

fixes

# This is the commit message #68:

fixes

# This is the commit message #69:

fixes

# This is the commit message #70:

fixes

# This is the commit message #71:

fixes

# This is the commit message #72:

fixes

# This is the commit message #73:

fixes

# This is the commit message #74:

fixes

# This is the commit message #75:

fixes

# This is the commit message #76:

fixes

# This is the commit message #77:

fixes

# This is the commit message #78:

fixes

# This is the commit message #79:

more testing

# This is the commit message #80:

testing

# This is the commit message #81:

fixes

# This is the commit message #82:

fixes

# This is the commit message #83:

fixes

# This is the commit message #84:

fixes

# This is the commit message #85:

fixes

# This is the commit message #86:

fixes

# This is the commit message #87:

fixes

# This is the commit message #88:

fixes

# This is the commit message #89:

fixes

# This is the commit message #90:

fixes

# This is the commit message #91:

fixes

# This is the commit message #92:

fixes

# This is the commit message #93:

propagate-environment for buildkite-agent

# This is the commit message #94:

propagate-environment for buildkite-agent

# This is the commit message #95:

propagate-environment for buildkite-agent

# This is the commit message #96:

propagate-environment for buildkite-agent

# This is the commit message #97:

fixes

# This is the commit message #98:

fixes

# This is the commit message #99:

fixes

# This is the commit message #100:

fixes

# This is the commit message #101:

fixes

# This is the commit message #102:

fixes

# This is the commit message #103:

fixes

# This is the commit message #104:

fixes

# This is the commit message #105:

fixes

# This is the commit message #106:

fixes

# This is the commit message #107:

fixes

# This is the commit message #108:

fixes

# This is the commit message #109:

fixes

# This is the commit message #110:

fixes

# This is the commit message #111:

fixes

# This is the commit message #112:

fixes

# This is the commit message #113:

fixes

# This is the commit message #114:

fixes

# This is the commit message #115:

fixes

# This is the commit message #116:

fixes

# This is the commit message #117:

fixes

# This is the commit message #118:

fixes

# This is the commit message #119:

fixes

# This is the commit message #120:

fixes

# This is the commit message #121:

fixes

# This is the commit message #122:

fixes

# This is the commit message #123:

fixes

# This is the commit message #124:

fixes

# This is the commit message #125:

fixes

# This is the commit message #126:

fixes

# This is the commit message #127:

fixes

# This is the commit message #128:

fixes

# This is the commit message #129:

fixes

# This is the commit message #130:

fixes

# This is the commit message #131:

fixes

# This is the commit message #132:

fixes

# This is the commit message #133:

fixes

# This is the commit message #134:

fixes

# This is the commit message #135:

fixes

# This is the commit message #136:

fixes

# This is the commit message #137:

fixes

# This is the commit message #138:

fixes

# This is the commit message #139:

fixes

# This is the commit message #140:

fixes

# This is the commit message #141:

fixes

# This is the commit message #142:

fixes

# This is the commit message #143:

fixes

# This is the commit message #144:

fixes

# This is the commit message #145:

fixes

# This is the commit message #146:

fixes

# This is the commit message #147:

fixes

# This is the commit message #148:

fixes

# This is the commit message #149:

fixes

# This is the commit message #150:

fixes

# This is the commit message #151:

fixes

# This is the commit message #152:

fixes

# This is the commit message #153:

testing

# This is the commit message #154:

fixes

# This is the commit message #155:

fixes

# This is the commit message #156:

fixes

# This is the commit message #157:

fixes

# This is the commit message #158:

fixes

# This is the commit message #159:

fixes

# This is the commit message #160:

fixes

# This is the commit message #161:

fixes

# This is the commit message #162:

fixes

# This is the commit message #163:

fixes

# This is the commit message #164:

fixes

# This is the commit message #165:

fixes

# This is the commit message #166:

fixes

# This is the commit message #167:

fixes

# This is the commit message #168:

fixes

# This is the commit message #169:

fixes

# This is the commit message #170:

fixes

# This is the commit message #171:

fixes

# This is the commit message #172:

fixes

# This is the commit message #173:

fixes

# This is the commit message #174:

fixes

# This is the commit message #175:

fixes

# This is the commit message #176:

fixes

# This is the commit message #177:

fixes

# This is the commit message #178:

fixes

# This is the commit message #179:

fixes

# This is the commit message #180:

fixes

# This is the commit message #181:

fixes

# This is the commit message #182:

fixes

# This is the commit message #183:

fixes

# This is the commit message #184:

fixes

# This is the commit message #185:

fixes

# This is the commit message #186:

fixes
Frank-AFN added a commit to eosiosg/eos that referenced this issue Mar 11, 2020
…OSIO#146)

bos intrinsic action seed and has contract

extrace contract code from account

Fix: excutor visit

Upgrade fc

change fc version to ac3bee8

Fix: state history plugin get account code compile error

Remove protocol state in state history plugin

reset wasm compilation result

adjust order of intrisic_mapping

Add set upgrade param in intrisic mapping

reorder action time seed  in intrisic mapping

Add cmake modules

Modify: builder dockerfile llvm to 7.0

modify llvm and clang version in eosio_build script

remove fcolor-diagnostics for docker build

Add: txn_test_gen_plugin

Add: unittest build

Remove: kafka plugin build and modify unittest cmakefile

Modify: unittest cmakelist to generate eosio.contract

remove: llvm unittest 7.1 version

Modify: wast import in unittest

remove memory test case and config.hpp header

Modify: forked  delay api  test

Add wasm file

Modify: unittest cmakelist

Modify: txn_test_gen_plugin

Fix: get code with wasm in txn_test_gen_plugin

Change: global property object2

data migration for upgrade vm

Add: privileged in account metadata object

Fix: multi testcases

Fix: test case except api tests

Fix: test crypto api bug

Fix: api deferred transaction test

Data migration for eos-vm upgrade
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants