forked from aragon/aragon-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Token Manager: use aragonAPI for React (aragon#764)
Only contains the changes needed to support aragonAPI for React: this is not a full conversion to React Hooks.
- Loading branch information
Showing
12 changed files
with
129 additions
and
192 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 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 |
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
15 changes: 0 additions & 15 deletions
15
apps/token-manager/app/src/components/MenuButton/IconMenu.js
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
Oops, something went wrong.