aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/containers
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-11-01 10:50:37 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-11-01 10:50:37 +0800
commit3f918622bcce21ba104e0f13e71247796345ab0f (patch)
treefe0e6dd540871a17abe1274fa2c7e4a1ad40d90b /packages/instant/src/containers
parent6091ee732d208eaf9889087b8308dfd0427b9be5 (diff)
downloaddexon-sol-tools-3f918622bcce21ba104e0f13e71247796345ab0f.tar
dexon-sol-tools-3f918622bcce21ba104e0f13e71247796345ab0f.tar.gz
dexon-sol-tools-3f918622bcce21ba104e0f13e71247796345ab0f.tar.bz2
dexon-sol-tools-3f918622bcce21ba104e0f13e71247796345ab0f.tar.lz
dexon-sol-tools-3f918622bcce21ba104e0f13e71247796345ab0f.tar.xz
dexon-sol-tools-3f918622bcce21ba104e0f13e71247796345ab0f.tar.zst
dexon-sol-tools-3f918622bcce21ba104e0f13e71247796345ab0f.zip
feat: implement basic erc20 token selector
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r--packages/instant/src/containers/available_erc20_token_selector.ts36
1 files changed, 36 insertions, 0 deletions
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<Action>,
+ ownProps: AvailableERC20TokenSelectorProps,
+): ConnectedDispatch => ({
+ onTokenSelect: (token: ERC20Asset) => dispatch(actions.updateSelectedAsset(token)),
+});
+
+export const AvailableERC20TokenSelector: React.ComponentClass<AvailableERC20TokenSelectorProps> = connect(
+ mapStateToProps,
+ mapDispatchToProps,
+)(ERC20TokenSelector);