Commit e464da6a authored by Jason Salyers's avatar Jason Salyers

[JES] Older accounts don't always get the transfer history. If hivemind...

[JES] Older accounts don't always get the transfer history. If hivemind responds with an error and suggests a new starting sequence, retry the call from the new starting sequence
parent f4422883
......@@ -64,7 +64,7 @@
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.12.1",
"@babel/runtime": "^7.12.5",
"@hiveio/hive-js": "0.8.8",
"@hiveio/hive-js": "0.8.13",
"@steem/crypto-session": "git+https://github.com/steemit/crypto-session.git#83a90b319ce5bc6a70362d52a15a815de7e729bb",
"assert": "1.4.1",
"autoprefixer": "^9.6.1",
......
......@@ -78,6 +78,38 @@ async function getGenericState(user) {
return result;
}
async function getTransferHistory(account)
{
let transfer_history = null;
let start_sequence = -1;
try
{
transfer_history = await api.getAccountHistoryAsync(account, start_sequence, 500, ...wallet_operations_bitmask);
}
catch (err)
{
let error_string = err.toString();
if (error_string.includes("start="))
{
let index = error_string.indexOf("=");
start_sequence = error_string.substr(index+1);
if (start_sequence.indexOf(".") > 0)
start_sequence = start_sequence.substr(0, start_sequence.length - 1);
try
{
transfer_history = await api.getAccountHistoryAsync(account, start_sequence, 500, ...wallet_operations_bitmask);
}
catch (err)
{
console.log("Unable to fetch account history for account: ", account, err);
}
}
}
return transfer_history;
}
export async function getStateAsync(url) {
// strip off query string
if (url === 'trending') {
......@@ -108,12 +140,9 @@ export async function getStateAsync(url) {
if (fetch_transfers) {
let account_name = path.split('@')[1];
let account_history = await api.getAccountHistoryAsync(
account_name,
-1,
500,
...wallet_operations_bitmask
);
let account_history = null;
account_history = await getTransferHistory(account_name);
let account = await api.getAccountsAsync([account_name]);
account = account[0];
account['transfer_history'] = account_history;
......
......@@ -1166,8 +1166,8 @@
lodash "^4.17.19"
to-fast-properties "^2.0.0"
"@hiveio/hive-js@0.8.8":
version "0.8.8"
"@hiveio/hive-js@0.8.13":
version "0.8.13"
resolved "https://registry.yarnpkg.com/@hiveio/hive-js/-/hive-js-0.8.8.tgz#4880ceabb9e1d7580d8f48a4ed2825076f79cda9"
integrity sha512-xFgSfrAhlrm/K9QMpQ47bOfSg21/tWJQzEVSZl8eWfgqnWtTsQolyMvBNZNzrbRa6118Ewsm2APDbwTfs6Q34g==
dependencies:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment