Operation claim_reward_balance seems not to work correctly
So...
I've tried couple different approaches.
First of all I have to cast operation name into OperationName.
Second string values for rewards provides serialization errors:
VError [SerializationError]: Unable to serialize transaction: operations: claim_reward_balance: reward_steem: Invalid asset 'undefined'
at transactionDigest (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/crypto.js:315:15)
at Object.signTransaction (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/crypto.js:329:20)
at BroadcastAPI.sign (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/helpers/broadcast.js:262:37)
at BroadcastAPI.<anonymous> (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/helpers/broadcast.js:253:49)
at Generator.next (<anonymous>)
at fulfilled (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/helpers/broadcast.js:39:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
jse_shortmsg: 'Unable to serialize transaction',
jse_cause: Error: operations: claim_reward_balance: reward_steem: Invalid asset 'undefined'
at Function.from (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/chain/asset.js:82:19)
at AssetSerializer (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/chain/serializer.js:85:33)
at /home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/chain/serializer.js:136:13
at /home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/chain/serializer.js:183:9
at OperationSerializer (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/chain/serializer.js:498:9)
at /home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/chain/serializer.js:130:9
at Object.Transaction (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/chain/serializer.js:136:13)
at transactionDigest (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/crypto.js:312:28)
at Object.signTransaction (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/crypto.js:329:20)
at BroadcastAPI.sign (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/helpers/broadcast.js:262:37),
jse_info: {}
}
It was while I tried to pass strings (while obviously this values where directly taken from account inforatiom so have format like 'X HIVE':
const operation = {
0: 'claim_reward_balance' as OperationName,
1: {
account: process.env.SENDER_ACCOUNT_NAME,
reward_hive: reward_steem_balance,
reward_hbd: reward_sbd_balance,
reward_vests: reward_vesting_balance,
},
};
And at the end I tries with Asset objects which also produces error:
VError [RPCError]: Internal Error
at Client.<anonymous> (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/client.js:206:23)
at Generator.next (<anonymous>)
at fulfilled (/home/nero12/projects/personal/hive-bot/node_modules/@hiveio/dhive/lib/client.js:39:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
jse_shortmsg: 'Internal Error',
jse_info: {
error_id: 'a066d967-aa8b-4e84-8a35-8de069c925ed',
jussi_request_id: '000085900880279767'
}
}
Code:
const operation = {
0: 'claim_reward_balance' as OperationName,
1: {
account: process.env.SENDER_ACCOUNT_NAME,
reward_hive: Asset.from(reward_steem_balance),
reward_hbd: Asset.from(reward_sbd_balance),
reward_vests: Asset.from(reward_vesting_balance),
reward_steem: new Asset(0, 'STEEM'),
reward_sbd: new Asset(0, 'SBD'),
},
};
Decided to fill every field, even if unnecessary.
await client.broadcast.sendOperations([operation], PrivateKey.from(process.env.SENDER_ACCOUNT_KEY));
Thanks in advance with help or investigation ;)
Edited by Piotr