From 3f918622bcce21ba104e0f13e71247796345ab0f Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 31 Oct 2018 19:50:37 -0700 Subject: feat: implement basic erc20 token selector --- .../containers/available_erc20_token_selector.ts | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 packages/instant/src/containers/available_erc20_token_selector.ts (limited to 'packages/instant/src/containers') diff --git a/packages/instant/src/containers/available_erc20_token_selector.ts b/packages/instant/src/containers/available_erc20_token_selector.ts new file mode 100644 index 000000000..6b5ecb6ac --- /dev/null +++ b/packages/instant/src/containers/available_erc20_token_selector.ts @@ -0,0 +1,36 @@ +import * as React from 'react'; +import { connect } from 'react-redux'; +import { Dispatch } from 'redux'; + +import { State } from '../redux/reducer'; +import { ERC20Asset } from '../types'; +import { assetUtils } from '../util/asset'; + +import { ERC20TokenSelector } from '../components/erc20_token_selector'; +import { Action, actions } from '../redux/actions'; + +export interface AvailableERC20TokenSelectorProps {} + +interface ConnectedState { + tokens: ERC20Asset[]; +} + +interface ConnectedDispatch { + onTokenSelect: (token: ERC20Asset) => void; +} + +const mapStateToProps = (state: State, _ownProps: AvailableERC20TokenSelectorProps): ConnectedState => ({ + tokens: assetUtils.getERC20AssetsFromAssets(state.availableAssets), +}); + +const mapDispatchToProps = ( + dispatch: Dispatch, + ownProps: AvailableERC20TokenSelectorProps, +): ConnectedDispatch => ({ + onTokenSelect: (token: ERC20Asset) => dispatch(actions.updateSelectedAsset(token)), +}); + +export const AvailableERC20TokenSelector: React.ComponentClass = connect( + mapStateToProps, + mapDispatchToProps, +)(ERC20TokenSelector); -- cgit