-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-finance-filters
- Loading branch information
Showing
54 changed files
with
4,297 additions
and
12,329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import BN from 'bn.js' | ||
import { hasLoadedTokenSettings } from './token-settings' | ||
|
||
// Convert tokenSupply and holders balances to BNs, | ||
// and calculate tokenDecimalsBase. | ||
function appStateReducer(state) { | ||
const appStateReady = hasLoadedTokenSettings(state) | ||
if (!appStateReady) { | ||
return { | ||
...state, | ||
appStateReady, | ||
} | ||
} | ||
|
||
const { | ||
holders, | ||
maxAccountTokens, | ||
tokenDecimals, | ||
tokenSupply, | ||
tokenTransfersEnabled, | ||
} = state | ||
|
||
const tokenDecimalsBase = new BN(10).pow(new BN(tokenDecimals)) | ||
|
||
return { | ||
...state, | ||
appStateReady, | ||
tokenDecimalsBase, | ||
|
||
// Note that numbers in `numData` are not safe for accurate computations | ||
// (but are useful for making divisions easier) | ||
numData: { | ||
tokenDecimals: parseInt(tokenDecimals, 10), | ||
tokenSupply: parseInt(tokenSupply, 10), | ||
}, | ||
holders: holders | ||
? holders | ||
.map(holder => ({ ...holder, balance: new BN(holder.balance) })) | ||
.sort((a, b) => b.balance.cmp(a.balance)) | ||
: [], | ||
tokenDecimals: new BN(tokenDecimals), | ||
tokenSupply: new BN(tokenSupply), | ||
maxAccountTokens: new BN(maxAccountTokens), | ||
groupMode: tokenTransfersEnabled && maxAccountTokens === '1', | ||
} | ||
} | ||
|
||
export default appStateReducer |
Oops, something went wrong.