aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-11-14 02:14:20 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-11-14 02:29:21 +0800
commit5527de62ffda68c00ae5fb68781c2e081fcc372e (patch)
tree61d3fb172de49a194bb5e5f4fe78365696818692 /packages/instant/src/components
parente8afc66a5afd65ee1ae640b43dee927ee57dceea (diff)
downloaddexon-sol-tools-5527de62ffda68c00ae5fb68781c2e081fcc372e.tar
dexon-sol-tools-5527de62ffda68c00ae5fb68781c2e081fcc372e.tar.gz
dexon-sol-tools-5527de62ffda68c00ae5fb68781c2e081fcc372e.tar.bz2
dexon-sol-tools-5527de62ffda68c00ae5fb68781c2e081fcc372e.tar.lz
dexon-sol-tools-5527de62ffda68c00ae5fb68781c2e081fcc372e.tar.xz
dexon-sol-tools-5527de62ffda68c00ae5fb68781c2e081fcc372e.tar.zst
dexon-sol-tools-5527de62ffda68c00ae5fb68781c2e081fcc372e.zip
chore(instant): update selectedAssetAmount in the redux state to be named selectedAssetUnitAmount
Diffstat (limited to 'packages/instant/src/components')
-rw-r--r--packages/instant/src/components/instant_heading.tsx14
-rw-r--r--packages/instant/src/components/order_details.tsx32
-rw-r--r--packages/instant/src/components/payment_method_dropdown.tsx2
-rw-r--r--packages/instant/src/components/zero_ex_instant_provider.tsx2
4 files changed, 26 insertions, 24 deletions
diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx
index b07776b2c..7f9567454 100644
--- a/packages/instant/src/components/instant_heading.tsx
+++ b/packages/instant/src/components/instant_heading.tsx
@@ -15,8 +15,8 @@ import { Spinner } from './ui/spinner';
import { Text } from './ui/text';
export interface InstantHeadingProps {
- selectedAssetAmount?: BigNumber;
- totalEthBaseAmount?: BigNumber;
+ selectedAssetUnitAmount?: BigNumber;
+ totalEthBaseUnitAmount?: BigNumber;
ethUsdPrice?: BigNumber;
quoteRequestState: AsyncProcessState;
buyOrderState: OrderState;
@@ -104,7 +104,7 @@ export class InstantHeading extends React.Component<InstantHeadingProps, {}> {
if (this.props.quoteRequestState === AsyncProcessState.Pending) {
return <AmountPlaceholder isPulsating={true} color={PLACEHOLDER_COLOR} />;
}
- if (_.isUndefined(this.props.selectedAssetAmount)) {
+ if (_.isUndefined(this.props.selectedAssetUnitAmount)) {
return <AmountPlaceholder isPulsating={false} color={PLACEHOLDER_COLOR} />;
}
return amountFunction();
@@ -113,8 +113,8 @@ export class InstantHeading extends React.Component<InstantHeadingProps, {}> {
private readonly _renderEthAmount = (): React.ReactNode => {
return (
<Text fontSize="16px" fontColor={ColorOption.white} fontWeight={500}>
- {format.ethBaseAmount(
- this.props.totalEthBaseAmount,
+ {format.ethBaseUnitAmount(
+ this.props.totalEthBaseUnitAmount,
4,
<AmountPlaceholder isPulsating={false} color={PLACEHOLDER_COLOR} />,
)}
@@ -125,8 +125,8 @@ export class InstantHeading extends React.Component<InstantHeadingProps, {}> {
private readonly _renderDollarAmount = (): React.ReactNode => {
return (
<Text fontSize="16px" fontColor={ColorOption.white}>
- {format.ethBaseAmountInUsd(
- this.props.totalEthBaseAmount,
+ {format.ethBaseUnitAmountInUsd(
+ this.props.totalEthBaseUnitAmount,
this.props.ethUsdPrice,
2,
<AmountPlaceholder isPulsating={false} color={ColorOption.white} />,
diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx
index fc316b9f8..5fc956e1c 100644
--- a/packages/instant/src/components/order_details.tsx
+++ b/packages/instant/src/components/order_details.tsx
@@ -16,22 +16,22 @@ import { Text } from './ui/text';
export interface OrderDetailsProps {
buyQuoteInfo?: BuyQuoteInfo;
- selectedAssetAmount?: BigNumber;
+ selectedAssetUnitAmount?: BigNumber;
ethUsdPrice?: BigNumber;
isLoading: boolean;
}
export class OrderDetails extends React.Component<OrderDetailsProps> {
public render(): React.ReactNode {
- const { buyQuoteInfo, ethUsdPrice, selectedAssetAmount } = this.props;
+ const { buyQuoteInfo, ethUsdPrice, selectedAssetUnitAmount } = this.props;
const buyQuoteAccessor = oc(buyQuoteInfo);
- const assetEthAmount = buyQuoteAccessor.assetEthAmount();
- const feeEthAmount = buyQuoteAccessor.feeEthAmount();
- const totalEthAmount = buyQuoteAccessor.totalEthAmount();
- const perUnitEthAmount =
- !_.isUndefined(assetEthAmount) &&
- !_.isUndefined(selectedAssetAmount) &&
- !selectedAssetAmount.eq(BIG_NUMBER_ZERO)
- ? assetEthAmount.div(selectedAssetAmount).ceil()
+ const assetEthBaseUnitAmount = buyQuoteAccessor.assetEthAmount();
+ const feeEthBaseUnitAmount = buyQuoteAccessor.feeEthAmount();
+ const totalEthBaseUnitAmount = buyQuoteAccessor.totalEthAmount();
+ const pricePerTokenEth =
+ !_.isUndefined(assetEthBaseUnitAmount) &&
+ !_.isUndefined(selectedAssetUnitAmount) &&
+ !selectedAssetUnitAmount.eq(BIG_NUMBER_ZERO)
+ ? assetEthBaseUnitAmount.div(selectedAssetUnitAmount).ceil()
: undefined;
return (
<Container padding="20px" width="100%" flexGrow={1}>
@@ -48,19 +48,19 @@ export class OrderDetails extends React.Component<OrderDetailsProps> {
</Container>
<EthAmountRow
rowLabel="Token Price"
- ethAmount={perUnitEthAmount}
+ ethAmount={pricePerTokenEth}
ethUsdPrice={ethUsdPrice}
isLoading={this.props.isLoading}
/>
<EthAmountRow
rowLabel="Fee"
- ethAmount={feeEthAmount}
+ ethAmount={feeEthBaseUnitAmount}
ethUsdPrice={ethUsdPrice}
isLoading={this.props.isLoading}
/>
<EthAmountRow
rowLabel="Total Cost"
- ethAmount={totalEthAmount}
+ ethAmount={totalEthBaseUnitAmount}
ethUsdPrice={ethUsdPrice}
shouldEmphasize={true}
isLoading={this.props.isLoading}
@@ -88,7 +88,7 @@ export class EthAmountRow extends React.Component<EthAmountRowProps> {
const { rowLabel, ethAmount, isEthAmountInBaseUnits, shouldEmphasize, isLoading } = this.props;
const fontWeight = shouldEmphasize ? 700 : 400;
- const ethFormatter = isEthAmountInBaseUnits ? format.ethBaseAmount : format.ethUnitAmount;
+ const ethFormatter = isEthAmountInBaseUnits ? format.ethBaseUnitAmount : format.ethUnitAmount;
return (
<Container padding="10px 0px" borderTop="1px dashed" borderColor={ColorOption.feintGrey}>
<Flex justify="space-between">
@@ -112,7 +112,9 @@ export class EthAmountRow extends React.Component<EthAmountRowProps> {
);
}
private _renderUsdSection(): React.ReactNode {
- const usdFormatter = this.props.isEthAmountInBaseUnits ? format.ethBaseAmountInUsd : format.ethUnitAmountInUsd;
+ const usdFormatter = this.props.isEthAmountInBaseUnits
+ ? format.ethBaseUnitAmountInUsd
+ : format.ethUnitAmountInUsd;
const shouldHideUsdPriceSection = _.isUndefined(this.props.ethUsdPrice) || _.isUndefined(this.props.ethAmount);
return shouldHideUsdPriceSection ? null : (
<Container marginRight="3px" display="inline-block">
diff --git a/packages/instant/src/components/payment_method_dropdown.tsx b/packages/instant/src/components/payment_method_dropdown.tsx
index bdce2a49d..58f1cc044 100644
--- a/packages/instant/src/components/payment_method_dropdown.tsx
+++ b/packages/instant/src/components/payment_method_dropdown.tsx
@@ -18,7 +18,7 @@ export class PaymentMethodDropdown extends React.Component<PaymentMethodDropdown
public render(): React.ReactNode {
const { accountAddress, accountEthBalanceInWei } = this.props;
const value = format.ethAddress(accountAddress);
- const label = format.ethBaseAmount(accountEthBalanceInWei, 4, '') as string;
+ const label = format.ethBaseUnitAmount(accountEthBalanceInWei, 4, '') as string;
return <Dropdown value={value} label={label} items={this._getDropdownItemConfigs()} />;
}
private readonly _getDropdownItemConfigs = (): DropdownItemConfig[] => {
diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index 411f118cc..e64579518 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -73,7 +73,7 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
completeAssetMetaDataMap,
networkId,
),
- selectedAssetAmount: _.isUndefined(props.defaultAssetBuyAmount)
+ selectedAssetUnitAmount: _.isUndefined(props.defaultAssetBuyAmount)
? undefined
: new BigNumber(props.defaultAssetBuyAmount),
availableAssets: _.isUndefined(props.availableAssetDatas)