aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-16 08:06:06 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-16 08:06:06 +0800
commitfcf345144835cf142da2cbca544151100791700f (patch)
treedad863c8be31e6ec1c12fb91f302943a68027ca9
parent43f8f2abbd0363cdccbd23fd698e87e2e5f45815 (diff)
downloaddexon-sol-tools-fcf345144835cf142da2cbca544151100791700f.tar
dexon-sol-tools-fcf345144835cf142da2cbca544151100791700f.tar.gz
dexon-sol-tools-fcf345144835cf142da2cbca544151100791700f.tar.bz2
dexon-sol-tools-fcf345144835cf142da2cbca544151100791700f.tar.lz
dexon-sol-tools-fcf345144835cf142da2cbca544151100791700f.tar.xz
dexon-sol-tools-fcf345144835cf142da2cbca544151100791700f.tar.zst
dexon-sol-tools-fcf345144835cf142da2cbca544151100791700f.zip
Add tnxHash to buy button callbacks
-rw-r--r--packages/instant/src/components/asset_amount_input.tsx4
-rw-r--r--packages/instant/src/components/buy_button.tsx14
2 files changed, 8 insertions, 10 deletions
diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/asset_amount_input.tsx
index 915c66e1e..72bcfb8fb 100644
--- a/packages/instant/src/components/asset_amount_input.tsx
+++ b/packages/instant/src/components/asset_amount_input.tsx
@@ -25,13 +25,13 @@ export class AssetAmountInput extends React.Component<AssetAmountInputProps> {
<AmountInput {...rest} onChange={this._handleChange} />
<Container display="inline-block" marginLeft="10px">
<Text fontSize={rest.fontSize} fontColor={ColorOption.white} textTransform="uppercase">
- {this._getLabel()}
+ {this._getAssetSymbolLabel()}
</Text>
</Container>
</Container>
);
}
- private readonly _getLabel = (): string => {
+ private readonly _getAssetSymbolLabel = (): string => {
const unknownLabel = '???';
if (_.isUndefined(this.props.assetData)) {
return unknownLabel;
diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx
index 097b8e547..e9466619e 100644
--- a/packages/instant/src/components/buy_button.tsx
+++ b/packages/instant/src/components/buy_button.tsx
@@ -11,8 +11,8 @@ import { Button, Container, Text } from './ui';
export interface BuyButtonProps {
buyQuote?: BuyQuote;
onClick: (buyQuote: BuyQuote) => void;
- onBuySuccess: (buyQuote: BuyQuote) => void;
- onBuyFailure: (buyQuote: BuyQuote) => void;
+ onBuySuccess: (buyQuote: BuyQuote, txnHash: string) => void;
+ onBuyFailure: (buyQuote: BuyQuote, tnxHash?: string) => void;
text: string;
}
@@ -42,15 +42,13 @@ export class BuyButton extends React.Component<BuyButtonProps> {
return;
}
this.props.onClick(this.props.buyQuote);
+ let txnHash;
try {
- const txnHash = await assetBuyer.executeBuyQuoteAsync(this.props.buyQuote, {
- // HACK: There is a calculation issue in asset-buyer. ETH is refunded anyway so just over-estimate.
- ethAmount: this.props.buyQuote.worstCaseQuoteInfo.totalEthAmount.mul(2),
- });
+ txnHash = await assetBuyer.executeBuyQuoteAsync(this.props.buyQuote);
await web3Wrapper.awaitTransactionSuccessAsync(txnHash);
+ this.props.onBuySuccess(this.props.buyQuote, txnHash);
} catch {
- this.props.onBuyFailure(this.props.buyQuote);
+ this.props.onBuyFailure(this.props.buyQuote, txnHash);
}
- this.props.onBuySuccess(this.props.buyQuote);
};
}