Skip to content

Commit

Permalink
Fixes to precision
Browse files Browse the repository at this point in the history
Fixes #927
  • Loading branch information
aaroncox committed Sep 4, 2020
1 parent 37db9a9 commit a36359c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/shared/actions/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ export function getCurrencyBalance(account, requestedTokens = false) {
// Expects array of balance strings, e.g. ['1.2345 EOS']
function formatPrecisions(balances, symbol, connection = undefined) {
const precision = {
[symbol]: connection.tokenPrecision
// [symbol]: connection.tokenPrecision
};
for (let i = 0; i < balances.length; i += 1) {
const [amount] = balances[i].split(' ');
Expand Down
5 changes: 3 additions & 2 deletions app/shared/components/Wallet/Panel/Form/Transfer/Send.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class WalletPanelFormTransferSend extends Component<Props> {
asset
} = this.state;
const balance = balances[settings.account];
const { precision } = balances.__contracts[asset.toUpperCase()]
const { precision } = balances.__contracts[asset.toUpperCase()];
let precisionValue = connection.tokenPrecision;
if (precision) {
precisionValue = precision[asset.toUpperCase()];
Expand Down Expand Up @@ -283,6 +283,7 @@ class WalletPanelFormTransferSend extends Component<Props> {
} = this.state;

const balance = balances[settings.account];
const { precision } = balances.__contracts[asset.toUpperCase()];

if (!balance) return false;

Expand Down Expand Up @@ -384,7 +385,7 @@ class WalletPanelFormTransferSend extends Component<Props> {
onClick={this.fillMax}
style={{ cursor: 'pointer' }}
>
{(balance[asset] && balance[asset].toFixed(connection.tokenPrecision)) || '0.0000'}
{(balance[asset] && balance[asset].toFixed(precision[asset.toUpperCase()])) || '0.0000'}
{' '}
{asset}
</a>
Expand Down
4 changes: 3 additions & 1 deletion app/shared/reducers/balances.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export default function balances(state = initialState, action) {
let modified;
const account = account_name.replace('.', '\\.');
modified = set(state, account, Object.assign({}, state[account_name], tokens));
modified = set(modified, `__contracts.${symbol.toUpperCase()}`, { contract, precision });
if (precision[symbol.toUpperCase()]) {
modified = set(modified, `__contracts.${symbol.toUpperCase()}`, { contract, precision });
}
return modified;
}
default: {
Expand Down

0 comments on commit a36359c

Please sign in to comment.