steemit / steem-js

Steem.js the official JavaScript library for Steem blockchain
https://www.npmjs.com/package/steem
MIT License
472 stars 225 forks source link

RPCError: Bad Cast:Invalid cast from type 'array_type' to Object #407

Open ptrio42 opened 6 years ago

ptrio42 commented 6 years ago

Expected behavior

Once the account_create operation is called an appropriate STEEM amount should be burned and a corresponding account should be created.

Actual behavior

A Bad Cast:Invalid cast from type 'array_type' to Object error is raised.

How to reproduce

Sample code:

steem.api.setOptions({ url: 'https://api.steem.house' });

var newAccountName = 'blaney',
    newAccountWif = steem.formatter.createSuggestedPassword(),
    publicKeys = steem.auth.generateKeys(newAccountName, newAccountWif, ['owner', 'active', 'posting', 'memo']);

steem.broadcast.accountCreate(
    '...', // ownerWif
    '3.000 STEEM', // fee
    'piotr42', // creator
    newAccountName, // newAccountName
    { weight_threshold: 1, account_auths: [], key_auths: [[publicKeys.owner, 1]] }, // owner
    { weight_threshold: 1, account_auths: [], key_auths: [[publicKeys.active, 1]] }, // active
    { weight_threshold: 1, account_auths: [], key_auths: [[publicKeys.posting, 1]] }, // posting
    publicKeys.memo, // memo
    '', // jsonMetadata
    function(err, response) {
        console.log(err, response);
});

Response:

{…}​cause: RPCError​​code: -32000​​columnNumber: 24327​​data: Object { code: 7, name: "bad_cast_exception", message: "Bad Cast", … }​​fileName: "file:///Users/piotr.cz/Documents/steem-client/node_modules/steem/dist/steem.min.js"​​lineNumber: 4​​message: "Bad Cast:Invalid cast from type 'array_type' to Object"​​name: "RPCError"​​stack: "e@file:///Users/piotr.cz/Documents/steem-client/node_modules/steem/dist/steem.min.js:4:24327\na/<@file:///Users/piotr.cz/Documents/steem-client/node_modules/steem/dist/steem.min.js:4:23853\n"​​<prototype>: Object { … }​code: -32000​data: {…}​​code: 7​​message: "Bad Cast"​​name: "bad_cast_exception"​​stack: Array [ {…} ]​​<prototype>: Object { … }​isOperational: true​message: "Bad Cast:Invalid cast from type 'array_type' to Object"​name: "RPCError"​stack: "e@file:///Users/piotr.cz/Documents/steem-client/node_modules/steem/dist/steem.min.js:4:24327\na/<@file:///Users/piotr.cz/Documents/steem-client/node_modules/steem/dist/steem.min.js:4:23853\n"​<prototype>: Object { constructor: i(), "constructor$": Error(), stack: "" } undefined main.js:28:9

Environment information

OS: Mac OS High Sierra Node: v8.11.4 Npm: 5.6.0

syvb commented 6 years ago

Does it work when you run JSON.stringify on the owner, active, and posting authorities?

ptrio42 commented 6 years ago

Thanks for the suggestion @Smittyvb. Unfortunately it does not work that way either.