Merge pull request #1803 from 0xProject/instant-callback-done
Added performedCallback attribute for Redux state, and added a hook f…
This commit is contained in:
@@ -203,6 +203,9 @@
|
|||||||
onClose: () => {
|
onClose: () => {
|
||||||
console.log('0x Instant Closed');
|
console.log('0x Instant Closed');
|
||||||
},
|
},
|
||||||
|
onSuccess: (txHash) => {
|
||||||
|
console.log(`Success! Transaction hash is: ${txHash}`)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const renderOptions = Object.assign({}, renderOptionsDefaults, removeUndefined(renderOptionsOverrides));
|
const renderOptions = Object.assign({}, renderOptionsDefaults, removeUndefined(renderOptionsOverrides));
|
||||||
zeroExInstant.render(renderOptions);
|
zeroExInstant.render(renderOptions);
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ export class ZeroExInstantProvider extends React.PureComponent<ZeroExInstantProv
|
|||||||
),
|
),
|
||||||
assetMetaDataMap: completeAssetMetaDataMap,
|
assetMetaDataMap: completeAssetMetaDataMap,
|
||||||
affiliateInfo: props.affiliateInfo,
|
affiliateInfo: props.affiliateInfo,
|
||||||
|
onSuccess: props.onSuccess,
|
||||||
};
|
};
|
||||||
return storeStateFromProps;
|
return storeStateFromProps;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { AssetBuyer, AssetBuyerError, BuyQuote } from '@0x/asset-buyer';
|
|||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as React from 'react';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { Dispatch } from 'redux';
|
import { Dispatch } from 'redux';
|
||||||
|
|
||||||
@@ -24,6 +23,7 @@ interface ConnectedState {
|
|||||||
affiliateInfo?: AffiliateInfo;
|
affiliateInfo?: AffiliateInfo;
|
||||||
selectedAsset?: Asset;
|
selectedAsset?: Asset;
|
||||||
onViewTransaction: () => void;
|
onViewTransaction: () => void;
|
||||||
|
onSuccess?: (txHash: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ConnectedDispatch {
|
interface ConnectedDispatch {
|
||||||
@@ -52,6 +52,7 @@ const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyOrderStateButt
|
|||||||
buyQuote: state.latestBuyQuote,
|
buyQuote: state.latestBuyQuote,
|
||||||
affiliateInfo: state.affiliateInfo,
|
affiliateInfo: state.affiliateInfo,
|
||||||
selectedAsset,
|
selectedAsset,
|
||||||
|
onSuccess: state.onSuccess,
|
||||||
onViewTransaction: () => {
|
onViewTransaction: () => {
|
||||||
if (
|
if (
|
||||||
state.buyOrderState.processState === OrderProcessState.Processing ||
|
state.buyOrderState.processState === OrderProcessState.Processing ||
|
||||||
@@ -107,7 +108,26 @@ const mapDispatchToProps = (
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const SelectedAssetBuyOrderStateButtons: React.ComponentClass<SelectedAssetBuyOrderStateButtons> = connect(
|
const mergeProps = (
|
||||||
|
connectedState: ConnectedState,
|
||||||
|
connectedDispatch: ConnectedDispatch,
|
||||||
|
ownProps: SelectedAssetBuyOrderStateButtons,
|
||||||
|
) => {
|
||||||
|
return {
|
||||||
|
...ownProps,
|
||||||
|
...connectedState,
|
||||||
|
...connectedDispatch,
|
||||||
|
onBuySuccess: (buyQuote: BuyQuote, txHash: string) => {
|
||||||
|
connectedDispatch.onBuySuccess(buyQuote, txHash);
|
||||||
|
if (connectedState.onSuccess) {
|
||||||
|
connectedState.onSuccess(txHash);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SelectedAssetBuyOrderStateButtons = connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps,
|
mapDispatchToProps,
|
||||||
|
mergeProps,
|
||||||
)(BuyOrderStateButtons);
|
)(BuyOrderStateButtons);
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ interface OptionalState {
|
|||||||
latestErrorMessage: string;
|
latestErrorMessage: string;
|
||||||
affiliateInfo: AffiliateInfo;
|
affiliateInfo: AffiliateInfo;
|
||||||
walletDisplayName: string;
|
walletDisplayName: string;
|
||||||
|
onSuccess: (txHash: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type State = DefaultState & PropsDerivedState & Partial<OptionalState>;
|
export type State = DefaultState & PropsDerivedState & Partial<OptionalState>;
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ export interface ZeroExInstantOptionalBaseConfig {
|
|||||||
networkId: Network;
|
networkId: Network;
|
||||||
affiliateInfo: AffiliateInfo;
|
affiliateInfo: AffiliateInfo;
|
||||||
shouldDisableAnalyticsTracking: boolean;
|
shouldDisableAnalyticsTracking: boolean;
|
||||||
|
onSuccess?: (txHash: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ZeroExInstantBaseConfig = ZeroExInstantRequiredBaseConfig & Partial<ZeroExInstantOptionalBaseConfig>;
|
export type ZeroExInstantBaseConfig = ZeroExInstantRequiredBaseConfig & Partial<ZeroExInstantOptionalBaseConfig>;
|
||||||
|
|||||||
Reference in New Issue
Block a user