diff options
Diffstat (limited to 'packages/instant')
-rw-r--r-- | packages/instant/.dogfood.discharge.json | 2 | ||||
-rw-r--r-- | packages/instant/.env_example | 4 | ||||
-rw-r--r-- | packages/instant/.gitignore | 3 | ||||
-rw-r--r-- | packages/instant/.npmignore | 3 | ||||
-rw-r--r-- | packages/instant/.production.discharge.json | 2 | ||||
-rw-r--r-- | packages/instant/.staging.discharge.json | 2 | ||||
-rw-r--r-- | packages/instant/README.md | 2 | ||||
-rw-r--r-- | packages/instant/package.json | 7 | ||||
-rw-r--r-- | packages/instant/public/index.html | 1 | ||||
-rw-r--r-- | packages/instant/src/components/payment_method.tsx | 12 | ||||
-rw-r--r-- | packages/instant/src/components/zero_ex_instant_provider.tsx | 2 | ||||
-rw-r--r-- | packages/instant/src/containers/connected_account_payment_method.ts | 4 | ||||
-rw-r--r-- | packages/instant/src/index.umd.ts | 3 | ||||
-rw-r--r-- | packages/instant/src/redux/reducer.ts | 1 |
14 files changed, 34 insertions, 14 deletions
diff --git a/packages/instant/.dogfood.discharge.json b/packages/instant/.dogfood.discharge.json index b0e4edaff..5d6a09a16 100644 --- a/packages/instant/.dogfood.discharge.json +++ b/packages/instant/.dogfood.discharge.json @@ -1,6 +1,6 @@ { "domain": "0x-instant-dogfood", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build --env.discharge_target=dogfood", + "build_command": "WEBPACK_OUTPUT_PATH=public dotenv yarn build --env.discharge_target=dogfood", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", diff --git a/packages/instant/.env_example b/packages/instant/.env_example new file mode 100644 index 000000000..ebbbebc06 --- /dev/null +++ b/packages/instant/.env_example @@ -0,0 +1,4 @@ +INSTANT_ROLLBAR_PUBLISH_TOKEN= +INSTANT_ROLLBAR_CLIENT_TOKEN= +INSTANT_HEAP_ANALYTICS_ID_PRODUCTION= +INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT=
\ No newline at end of file diff --git a/packages/instant/.gitignore b/packages/instant/.gitignore index a99cea187..2e65f192d 100644 --- a/packages/instant/.gitignore +++ b/packages/instant/.gitignore @@ -1,3 +1,4 @@ public/instant.js public/instant.js.map -umd/*
\ No newline at end of file +umd/* +.env
\ No newline at end of file diff --git a/packages/instant/.npmignore b/packages/instant/.npmignore index a4f7810c0..563923652 100644 --- a/packages/instant/.npmignore +++ b/packages/instant/.npmignore @@ -2,4 +2,5 @@ * */ !lib/**/* -!umd/**/*
\ No newline at end of file +!umd/**/* +.env
\ No newline at end of file diff --git a/packages/instant/.production.discharge.json b/packages/instant/.production.discharge.json index 4aa5337ba..947f68b1a 100644 --- a/packages/instant/.production.discharge.json +++ b/packages/instant/.production.discharge.json @@ -1,6 +1,6 @@ { "domain": "instant.0xproject.com", - "build_command": "yarn build --env.discharge_target=production", + "build_command": "dotenv yarn build --env.discharge_target=production", "upload_directory": "umd", "index_key": "instant.js", "error_key": "404.html", diff --git a/packages/instant/.staging.discharge.json b/packages/instant/.staging.discharge.json index 56ffee4e9..bd5f28ba8 100644 --- a/packages/instant/.staging.discharge.json +++ b/packages/instant/.staging.discharge.json @@ -1,6 +1,6 @@ { "domain": "0x-instant-staging", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build --env.discharge_target=staging", + "build_command": "dotenv WEBPACK_OUTPUT_PATH=public yarn build --env.discharge_target=staging", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", diff --git a/packages/instant/README.md b/packages/instant/README.md index 45a871124..2092b45d9 100644 --- a/packages/instant/README.md +++ b/packages/instant/README.md @@ -20,6 +20,8 @@ The package is available as a UMD module named `zeroExInstant` at https://instan ## Deploying +To run any of the following commands you need to configure your `.env` file. There is an example `.env_example` file to show you what values are required. + You can deploy a work-in-progress version of 0x Instant at http://0x-instant-dogfood.s3-website-us-east-1.amazonaws.com/instant.js for easy sharing. To build and deploy the bundle run diff --git a/packages/instant/package.json b/packages/instant/package.json index 62904949b..4daec883b 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -7,7 +7,6 @@ "private": true, "description": "0x Instant React Component", "main": "umd/instant.js", - "private": true, "scripts": { "build": "webpack --mode production", "build:ci": "yarn build", @@ -25,7 +24,10 @@ }, "config": { "postpublish": { - "assets": ["packages/instant/umd/instant.js", "packages/instant/umd/instant.js.map"] + "assets": [ + "packages/instant/umd/instant.js", + "packages/instant/umd/instant.js.map" + ] } }, "repository": { @@ -75,6 +77,7 @@ "@types/redux": "^3.6.0", "@types/styled-components": "^4.0.1", "awesome-typescript-loader": "^5.2.1", + "dotenv-cli": "^1.4.0", "enzyme": "^3.6.0", "enzyme-adapter-react-16": "^1.5.0", "ip": "^1.1.5", diff --git a/packages/instant/public/index.html b/packages/instant/public/index.html index df39994ef..d10618c58 100644 --- a/packages/instant/public/index.html +++ b/packages/instant/public/index.html @@ -175,6 +175,7 @@ defaultSelectedAssetData: queryParams.getQueryParamValue('defaultSelectedAssetData'), affiliateInfo: affiliateInfoOverride, shouldDisablePushToHistory: !!queryParams.getQueryParamValue('shouldDisablePushToHistory'), + walletDisplayName: queryParams.getQueryParamValue('walletDisplayName') || undefined, }; return renderOptionsOverrides; }; diff --git a/packages/instant/src/components/payment_method.tsx b/packages/instant/src/components/payment_method.tsx index c23b43267..4efe5b28e 100644 --- a/packages/instant/src/components/payment_method.tsx +++ b/packages/instant/src/components/payment_method.tsx @@ -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: diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx index a4a03bbf4..b544b86ff 100644 --- a/packages/instant/src/components/zero_ex_instant_provider.tsx +++ b/packages/instant/src/components/zero_ex_instant_provider.tsx @@ -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( diff --git a/packages/instant/src/containers/connected_account_payment_method.ts b/packages/instant/src/containers/connected_account_payment_method.ts index e9327a288..bb68fdd57 100644 --- a/packages/instant/src/containers/connected_account_payment_method.ts +++ b/packages/instant/src/containers/connected_account_payment_method.ts @@ -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(); diff --git a/packages/instant/src/index.umd.ts b/packages/instant/src/index.umd.ts index 7391e2844..b92fa3a7c 100644 --- a/packages/instant/src/index.umd.ts +++ b/packages/instant/src/index.umd.ts @@ -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); } diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts index dfc2b89f3..a9a407b7d 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -49,6 +49,7 @@ interface OptionalState { latestBuyQuote: BuyQuote; latestErrorMessage: string; affiliateInfo: AffiliateInfo; + walletDisplayName: string; } export type State = DefaultState & PropsDerivedState & Partial<OptionalState>; |