aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-11-08 14:08:40 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-11-08 14:08:40 +0800
commitd7742029c7ff991e60352cddeb52c2cdc1589a57 (patch)
tree8a7118ba2b74a3f3b1871015f8f43e931c1b21db /packages/instant/src/components
parent1151371e57643662b14c0c940ec558e74a6d1120 (diff)
downloaddexon-sol-tools-d7742029c7ff991e60352cddeb52c2cdc1589a57.tar
dexon-sol-tools-d7742029c7ff991e60352cddeb52c2cdc1589a57.tar.gz
dexon-sol-tools-d7742029c7ff991e60352cddeb52c2cdc1589a57.tar.bz2
dexon-sol-tools-d7742029c7ff991e60352cddeb52c2cdc1589a57.tar.lz
dexon-sol-tools-d7742029c7ff991e60352cddeb52c2cdc1589a57.tar.xz
dexon-sol-tools-d7742029c7ff991e60352cddeb52c2cdc1589a57.tar.zst
dexon-sol-tools-d7742029c7ff991e60352cddeb52c2cdc1589a57.zip
feat: implement copy-to-clipboard
Diffstat (limited to 'packages/instant/src/components')
-rw-r--r--packages/instant/src/components/payment_method_dropdown.tsx16
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/instant/src/components/payment_method_dropdown.tsx b/packages/instant/src/components/payment_method_dropdown.tsx
index 09d21e384..d1586f2c7 100644
--- a/packages/instant/src/components/payment_method_dropdown.tsx
+++ b/packages/instant/src/components/payment_method_dropdown.tsx
@@ -1,6 +1,9 @@
import { BigNumber } from '@0x/utils';
+import copy from 'copy-to-clipboard';
import * as React from 'react';
+import { Network } from '../types';
+import { etherscanUtil } from '../util/etherscan';
import { format } from '../util/format';
import { Dropdown, DropdownItemConfig } from './ui/dropdown';
@@ -8,12 +11,14 @@ import { Dropdown, DropdownItemConfig } from './ui/dropdown';
export interface PaymentMethodDropdownProps {
selectedEthAddress: string;
addressEthBaseAmount: BigNumber;
+ network: Network;
}
export class PaymentMethodDropdown extends React.Component<PaymentMethodDropdownProps> {
public static defaultProps = {
selectedEthAddress: '0xa1b2c3d4e5f6g7h8j9k10',
addressEthBaseAmount: new BigNumber(10500000000000000000),
+ network: Network.Mainnet,
};
public render(): React.ReactNode {
const { selectedEthAddress, addressEthBaseAmount } = this.props;
@@ -24,10 +29,21 @@ export class PaymentMethodDropdown extends React.Component<PaymentMethodDropdown
private readonly _getDropdownItemConfigs = (): DropdownItemConfig[] => {
const viewOnEtherscan = {
text: 'View on Etherscan',
+ onClick: this._handleEtherscanClick,
};
const copyAddressToClipboard = {
text: 'Copy address to clipboard',
+ onClick: this._handleCopyToClipboardClick,
};
return [viewOnEtherscan, copyAddressToClipboard];
};
+ private readonly _handleEtherscanClick = (): void => {
+ const { selectedEthAddress, network } = this.props;
+ const etherscanUrl = etherscanUtil.getEtherScanEthAddressIfExists(selectedEthAddress, network);
+ window.open(etherscanUrl, '_blank');
+ };
+ private readonly _handleCopyToClipboardClick = (): void => {
+ const { selectedEthAddress } = this.props;
+ copy(selectedEthAddress);
+ };
}