fix account json bug, improve error messages

This commit is contained in:
feruz 2020-01-20 19:53:40 +02:00
parent 1b429ade87
commit b186b6d23b
6 changed files with 27 additions and 26 deletions

View File

@ -280,6 +280,7 @@
"success_moved": "Moved to draft",
"permission_denied": "Permission denied",
"permission_text": "Please, go to phone Settings and change eSteem app permissions.",
"key_warning": "Check private key permission!",
"success_rebloged": "Reblogged!",
"already_rebloged": "You have already reblogged!",
"success_favorite": "Favorite added!",

View File

@ -203,7 +203,7 @@ const PointsContainer = ({
.catch(error => {
if (error) {
setIsLoading(false);
dispatch(toastNotification(intl.formatMessage({ id: 'alert.fail' })));
dispatch(toastNotification(intl.formatMessage({ id: 'alert.key_warning' })));
}
});
};

View File

@ -80,7 +80,7 @@ class RedeemContainer extends Component {
})
.catch(error => {
if (error) {
dispatch(toastNotification(intl.formatMessage({ id: 'alert.fail' })));
dispatch(toastNotification(intl.formatMessage({ id: 'alert.key_warning' })));
}
});

View File

@ -281,7 +281,7 @@ export const ignoreUser = async (currentAccount, pin, data) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
/**
@ -514,7 +514,7 @@ const _vote = async (currentAccount, pin, author, permlink, weight) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
/**
@ -562,7 +562,7 @@ export const transferToken = (currentAccount, pin, data) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const transferToSavings = (currentAccount, pin, data) => {
@ -596,7 +596,7 @@ export const transferToSavings = (currentAccount, pin, data) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const transferFromSavings = (currentAccount, pin, data) => {
@ -630,7 +630,7 @@ export const transferFromSavings = (currentAccount, pin, data) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const transferToVesting = (currentAccount, pin, data) => {
@ -662,7 +662,7 @@ export const transferToVesting = (currentAccount, pin, data) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const withdrawVesting = (currentAccount, pin, data) => {
@ -693,7 +693,7 @@ export const withdrawVesting = (currentAccount, pin, data) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const delegateVestingShares = (currentAccount, pin, data) => {
@ -725,7 +725,7 @@ export const delegateVestingShares = (currentAccount, pin, data) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const setWithdrawVestingRoute = (currentAccount, pin, data) => {
@ -758,7 +758,7 @@ export const setWithdrawVestingRoute = (currentAccount, pin, data) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const getWithdrawRoutes = account =>
@ -805,7 +805,7 @@ export const followUser = async (currentAccount, pin, data) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const unfollowUser = async (currentAccount, pin, data) => {
@ -850,7 +850,7 @@ export const unfollowUser = async (currentAccount, pin, data) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const lookupAccounts = async username => {
@ -1014,7 +1014,7 @@ const _postContent = async (
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
// Re-blog
@ -1061,7 +1061,7 @@ const _reblog = async (account, pinCode, author, permlink) => {
return client.broadcast.json(json, privateKey);
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const claimRewardBalance = (account, pinCode, rewardSteem, rewardSbd, rewardVests) => {
@ -1095,7 +1095,7 @@ export const claimRewardBalance = (account, pinCode, rewardSteem, rewardSbd, rew
return client.broadcast.sendOperations(opArray, privateKey);
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const transferPoint = (currentAccount, pinCode, data) => {
@ -1123,7 +1123,7 @@ export const transferPoint = (currentAccount, pinCode, data) => {
return client.broadcast.json(op, privateKey);
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const promote = (currentAccount, pinCode, duration, permlink, author) => {
@ -1149,7 +1149,7 @@ export const promote = (currentAccount, pinCode, duration, permlink, author) =>
return client.broadcast.json(json, privateKey);
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const boost = (currentAccount, pinCode, point, permlink, author) => {
@ -1175,10 +1175,10 @@ export const boost = (currentAccount, pinCode, point, permlink, author) => {
return client.broadcast.json(json, privateKey);
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const grantPostingPermission = async (params, pin, currentAccount) => {
export const grantPostingPermission = async (json, pin, currentAccount) => {
const digitPinCode = getDigitPinCode(pin);
const key = getActiveKey(get(currentAccount, 'local'), digitPinCode);
@ -1201,7 +1201,7 @@ export const grantPostingPermission = async (params, pin, currentAccount) => {
account: get(currentAccount, 'name'),
posting: newPosting,
memo_key: get(currentAccount, 'memo_key'),
json_metadata: jsonStringify(params),
json_metadata: json,
};
const opArray = [['account_update', _params]];
@ -1220,7 +1220,7 @@ export const grantPostingPermission = async (params, pin, currentAccount) => {
{
account: get(currentAccount, 'name'),
memo_key: get(currentAccount, 'memo_key'),
json_metadata: jsonStringify(params),
json_metadata: json,
posting: newPosting,
},
],
@ -1242,7 +1242,7 @@ export const grantPostingPermission = async (params, pin, currentAccount) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
export const profileUpdate = async (params, pin, currentAccount) => {
@ -1298,7 +1298,7 @@ export const profileUpdate = async (params, pin, currentAccount) => {
});
}
return Promise.reject(new Error('Private key permission issue!'));
return Promise.reject(new Error('Check private key permission!'));
};
// HELPERS

View File

@ -452,7 +452,7 @@ class EditorContainer extends Component {
_handleDatePickerChange = async (datePickerValue, fields) => {
const { currentAccount, pinCode, intl } = this.props;
const params = get(currentAccount, 'json_metadata', '');
const json = get(currentAccount, 'json_metadata', '');
let hasPostingPerm = false;
@ -464,7 +464,7 @@ class EditorContainer extends Component {
if (hasPostingPerm) {
this._submitPost(fields, datePickerValue);
} else {
await grantPostingPermission(params, pinCode, currentAccount)
await grantPostingPermission(json, pinCode, currentAccount)
.then(() => {
this._submitPost(fields, datePickerValue);
})