feat(instant): provide a custom wallet display name
This commit is contained in:
parent
502e9c7be4
commit
f4e0f74a6d
@ -175,6 +175,7 @@
|
||||
defaultSelectedAssetData: queryParams.getQueryParamValue('defaultSelectedAssetData'),
|
||||
affiliateInfo: affiliateInfoOverride,
|
||||
shouldDisablePushToHistory: !!queryParams.getQueryParamValue('shouldDisablePushToHistory'),
|
||||
walletDisplayName: queryParams.getQueryParamValue('walletDisplayName') || undefined,
|
||||
};
|
||||
return renderOptionsOverrides;
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ import { WalletPrompt } from './wallet_prompt';
|
||||
export interface PaymentMethodProps {
|
||||
account: Account;
|
||||
network: Network;
|
||||
walletName: string;
|
||||
walletDisplayName: string;
|
||||
onInstallWalletClick: () => void;
|
||||
onUnlockWalletClick: () => void;
|
||||
}
|
||||
@ -62,11 +62,11 @@ export class PaymentMethod extends React.Component<PaymentMethodProps> {
|
||||
if (account.state === AccountState.Ready || account.state === AccountState.Locked) {
|
||||
const circleColor: ColorOption = account.state === AccountState.Ready ? ColorOption.green : ColorOption.red;
|
||||
return (
|
||||
<Flex>
|
||||
<Flex align="center">
|
||||
<Circle diameter={8} color={circleColor} />
|
||||
<Container marginLeft="3px">
|
||||
<Text fontColor={ColorOption.darkGrey} fontSize="12px">
|
||||
{this.props.walletName}
|
||||
<Container marginLeft="5px">
|
||||
<Text fontColor={ColorOption.darkGrey} fontSize="12px" lineHeight="30px">
|
||||
{this.props.walletDisplayName}
|
||||
</Text>
|
||||
</Container>
|
||||
</Flex>
|
||||
@ -91,7 +91,7 @@ export class PaymentMethod extends React.Component<PaymentMethodProps> {
|
||||
image={<Icon width={13} icon="lock" color={ColorOption.black} />}
|
||||
{...colors}
|
||||
>
|
||||
Please Unlock {this.props.walletName}
|
||||
Please Unlock {this.props.walletDisplayName}
|
||||
</WalletPrompt>
|
||||
);
|
||||
case AccountState.None:
|
||||
|
@ -29,6 +29,7 @@ export interface ZeroExInstantProviderRequiredProps {
|
||||
|
||||
export interface ZeroExInstantProviderOptionalProps {
|
||||
provider: Provider;
|
||||
walletDisplayName: string;
|
||||
availableAssetDatas: string[];
|
||||
defaultAssetBuyAmount: number;
|
||||
defaultSelectedAssetData: string;
|
||||
@ -66,6 +67,7 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
|
||||
...defaultState,
|
||||
providerState,
|
||||
network: networkId,
|
||||
walletDisplayName: props.walletDisplayName,
|
||||
selectedAsset: _.isUndefined(props.defaultSelectedAssetData)
|
||||
? undefined
|
||||
: assetUtils.createAssetFromAssetDataOrThrow(
|
||||
|
@ -20,6 +20,7 @@ export interface ConnectedAccountPaymentMethodProps {}
|
||||
interface ConnectedState {
|
||||
network: Network;
|
||||
providerState: ProviderState;
|
||||
walletDisplayName?: string;
|
||||
}
|
||||
|
||||
interface ConnectedDispatch {
|
||||
@ -34,6 +35,7 @@ type FinalProps = ConnectedProps & ConnectedAccountPaymentMethodProps;
|
||||
const mapStateToProps = (state: State, _ownProps: ConnectedAccountPaymentMethodProps): ConnectedState => ({
|
||||
network: state.network,
|
||||
providerState: state.providerState,
|
||||
walletDisplayName: state.walletDisplayName,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (
|
||||
@ -56,7 +58,7 @@ const mergeProps = (
|
||||
...ownProps,
|
||||
network: connectedState.network,
|
||||
account: connectedState.providerState.account,
|
||||
walletName: connectedState.providerState.name,
|
||||
walletDisplayName: connectedState.walletDisplayName || connectedState.providerState.name,
|
||||
onUnlockWalletClick: () => connectedDispatch.unlockWalletAndDispatchToStore(connectedState.providerState),
|
||||
onInstallWalletClick: () => {
|
||||
const isMobile = envUtil.isMobileOperatingSystem();
|
||||
|
@ -39,6 +39,9 @@ const validateInstantRenderConfig = (config: ZeroExInstantConfig, selector: stri
|
||||
if (!_.isUndefined(config.provider)) {
|
||||
assert.isWeb3Provider('provider', config.provider);
|
||||
}
|
||||
if (!_.isUndefined(config.walletDisplayName)) {
|
||||
assert.isString('walletDisplayName', config.walletDisplayName);
|
||||
}
|
||||
if (!_.isUndefined(config.shouldDisablePushToHistory)) {
|
||||
assert.isBoolean('shouldDisablePushToHistory', config.shouldDisablePushToHistory);
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ interface OptionalState {
|
||||
latestBuyQuote: BuyQuote;
|
||||
latestErrorMessage: string;
|
||||
affiliateInfo: AffiliateInfo;
|
||||
walletDisplayName: string;
|
||||
}
|
||||
|
||||
export type State = DefaultState & PropsDerivedState & Partial<OptionalState>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user