[RPCError] trying to claim discounted account
I am not sure what I am doing wrong. I tried switching several things around but with no luck.
One odd thing I noticed is when I put "https://anyx.io/" as the first url, I get a cast object to array error on the [op]
SIDE NOTE: I have to use ts-ignore on res.blockchain_version as 'blockchain_version' does not exist on type 'object'
I am getting 0.23.0 blockchain_version for the client, should I be connecting to a node that is 0.24.0? ie HF24 node?
Feel free to correct any misunderstanding I am presenting
import { Asset, Client, PrivateKey } from "@hiveio/dhive";
const hive = new Client([
"https://api.hive.blog",
"https://api.hivekings.com",
"https://anyx.io",
"https://api.openhive.network",
]);
hive.database.getVersion().then((res) => {
// @ts-ignore
if (res.blockchain_version !== "0.23.0") {
hive.updateOperations(true);
}
});
export const claimAcct = async () => {
console.log("Process Started ");
console.log(
"user: " +
process.env.HIVE_ACCOUNT! +
" - Thresold: " +
process.env.RC_THRESHOLD!.toString()
);
const op = {
0: "claim_account" as const,
1: {
creator: process.env.HIVE_ACCOUNT!,
fee: Asset.from("0.000 HIVE"),
extensions: [],
},
};
try {
const ac = await hive.call("rc_api", "find_rc_accounts", {
accounts: [process.env.HIVE_ACCOUNT!],
});
if (ac.rc_accounts.length > 0) {
const rc = Number(ac.rc_accounts[0].rc_manabar.current_mana);
console.log(process.env.HIVE_ACCOUNT! + "'s RC is " + rc.toString());
if (rc > parseInt(process.env.RC_THRESHOLD!) * 1000000000000) {
hive.broadcast
.sendOperations([op], PrivateKey.from(process.env.ACTIVE_WIF!))
.then((res) => {
console.log(res);
console.log("You have successfully claimed a discounted account");
})
.catch((err) => {
console.log("broadcast error");
console.log(err);
});
} else {
console.log(
`you are short ${
parseInt(process.env.RC_THRESHOLD!) * 1000000000000 - rc
} RC`
);
}
}
} catch (e) {
console.log("couldnt get RC");
console.log(e.message);
}
};
I receive
Process Started
user: memehub - Thresold: 30
memehub's RC is 117535839742096
broadcast error
VError [RPCError]: Internal Error
at Client.<anonymous> (/app/node_modules/@hiveio/dhive/lib/client.js:206:23)
at Generator.next (<anonymous>)
at fulfilled (/app/node_modules/@hiveio/dhive/lib/client.js:39:58)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
jse_shortmsg: 'Internal Error',
jse_info: {
error_id: 'd300e681-391c-45fb-97c4-70a61c941514',
jussi_request_id: '000744197682737420'
}
}