diff --git a/package.json b/package.json index 743fc6cc2..bf125fd2b 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@datadog/browser-logs": "^5.23.3", "@dydxprotocol/v4-abacus": "1.13.16", "@dydxprotocol/v4-client-js": "1.12.1", - "@dydxprotocol/v4-localization": "^1.1.237", + "@dydxprotocol/v4-localization": "^1.1.238", "@dydxprotocol/v4-proto": "^7.0.0-dev.0", "@funkit/connect": "^3.4.9", "@emotion/is-prop-valid": "^1.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 48bdee4ce..c1a16cf66 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,8 +36,8 @@ dependencies: specifier: 1.12.1 version: 1.12.1 '@dydxprotocol/v4-localization': - specifier: ^1.1.237 - version: 1.1.237 + specifier: ^1.1.238 + version: 1.1.238 '@dydxprotocol/v4-proto': specifier: ^7.0.0-dev.0 version: 7.0.0-dev.0 @@ -3320,8 +3320,8 @@ packages: - utf-8-validate dev: false - /@dydxprotocol/v4-localization@1.1.237: - resolution: {integrity: sha512-d6pdYr5C8TyrHT3yGkQo8iDkiDxR5y3HynJTQESnDOCNLfcR/g8qPv2D0eQq18bWAdSOIUoGTjv21Te+j777rA==} + /@dydxprotocol/v4-localization@1.1.238: + resolution: {integrity: sha512-Hmkr4LLL2yrulL500sODiAPK3h9fEhNf44ugTKfCQ2vz8P389KBAeYu2jQMYM5D2jab3J5sLo03z5U0XoC3gXQ==} dev: false /@dydxprotocol/v4-proto@7.0.0-dev.0: diff --git a/public/configs/v1/env.json b/public/configs/v1/env.json index 77f6e0637..972c1fb3d 100644 --- a/public/configs/v1/env.json +++ b/public/configs/v1/env.json @@ -92,7 +92,8 @@ "getInTouch": "", "deployerTermsAndConditions": "", "dydxLearnMore": "https://www.mintscan.io/dydx", - "affiliateProgram": "" + "affiliateProgram": "", + "launchMarketTos": null }, "dydxprotocol-testnet": { "tos": "https://dydx.exchange/v4-terms", @@ -133,7 +134,8 @@ "getInTouch": "", "deployerTermsAndConditions": "", "dydxLearnMore": "https://www.mintscan.io/dydx", - "affiliateProgram": "" + "affiliateProgram": "", + "launchMarketTos": null }, "dydx-testnet-4": { "tos": "https://dydx.exchange/v4-terms", @@ -175,7 +177,8 @@ "getInTouch": "", "deployerTermsAndConditions": "", "dydxLearnMore": "https://www.mintscan.io/dydx", - "affiliateProgram": "" + "affiliateProgram": "", + "launchMarketTos": null }, "[mainnet chain id]": { "tos": "[HTTP link to TOS]", @@ -217,7 +220,8 @@ "getInTouch": "[HTTP link to get in touch with traders]", "deployerTermsAndConditions": "[HTTP link to terms and conditions, can be null]", "dydxLearnMore": "[HTTP link to information about the dYdX blockchain]", - "affiliateProgram": "[HTTP link to information about the affiliate program]" + "affiliateProgram": "[HTTP link to information about the affiliate program]", + "launchMarketTos": "[HTTP link to launch market ToS]" } }, "wallets": { diff --git a/src/hooks/useURLConfigs.ts b/src/hooks/useURLConfigs.ts index d0490d31e..4de0ce734 100644 --- a/src/hooks/useURLConfigs.ts +++ b/src/hooks/useURLConfigs.ts @@ -46,6 +46,7 @@ export interface LinksConfigs { deployerTermsAndConditions?: string; dydxLearnMore?: string; affiliateProgram?: string; + launchMarketTos?: string; } export const useURLConfigs = (): LinksConfigs => { @@ -94,5 +95,6 @@ export const useURLConfigs = (): LinksConfigs => { deployerTermsAndConditions: linksConfigs.deployerTermsAndConditions, dydxLearnMore: linksConfigs.dydxLearnMore ?? FALLBACK_URL, affiliateProgram: linksConfigs.affiliateProgram, + launchMarketTos: linksConfigs.launchMarketTos ?? FALLBACK_URL, }; }; diff --git a/src/views/forms/NewMarketForm/v7/NewMarketPreviewStep.tsx b/src/views/forms/NewMarketForm/v7/NewMarketPreviewStep.tsx index 12b877ae0..9eb322b2f 100644 --- a/src/views/forms/NewMarketForm/v7/NewMarketPreviewStep.tsx +++ b/src/views/forms/NewMarketForm/v7/NewMarketPreviewStep.tsx @@ -16,6 +16,7 @@ import { useNow } from '@/hooks/useNow'; import { useStringGetter } from '@/hooks/useStringGetter'; import { useSubaccount } from '@/hooks/useSubaccount'; import { useTokenConfigs } from '@/hooks/useTokenConfigs'; +import { useURLConfigs } from '@/hooks/useURLConfigs'; import { formMixins } from '@/styles/formMixins'; import { layoutMixins } from '@/styles/layoutMixins'; @@ -23,8 +24,10 @@ import { layoutMixins } from '@/styles/layoutMixins'; import { AlertMessage } from '@/components/AlertMessage'; import { AssetIcon } from '@/components/AssetIcon'; import { Button } from '@/components/Button'; +import { Checkbox } from '@/components/Checkbox'; import { Details, type DetailsItem } from '@/components/Details'; import { Icon, IconName } from '@/components/Icon'; +import { Link } from '@/components/Link'; import { LoadingSpinner } from '@/components/Loading/LoadingSpinner'; import { Output, OutputType } from '@/components/Output'; import { MegaVaultYieldOutput } from '@/views/MegaVaultYieldOutput'; @@ -37,8 +40,6 @@ import { getDisplayableAssetFromTicker } from '@/lib/assetUtils'; import { MustBigNumber } from '@/lib/numbers'; import { log } from '@/lib/telemetry'; -import { NewMarketAgreement } from '../NewMarketAgreement'; - const ESTIMATED_LAUNCH_TIMEOUT = timeUnits.minute; type NewMarketPreviewStepProps = { @@ -61,8 +62,8 @@ export const NewMarketPreviewStep = ({ const stringGetter = useStringGetter(); const [errorMessage, setErrorMessage] = useState(); const [hasAcceptedTerms, setHasAcceptedTerms] = useState(false); + const { launchMarketTos } = useURLConfigs(); const [isLoading, setIsLoading] = useState(false); - const [showAgreement, setShowAgreement] = useState(false); const baseAsset = getDisplayableAssetFromTicker(ticker); const launchableAsset = useMetadataServiceAssetFromId(ticker); const { createPermissionlessMarket } = useSubaccount(); @@ -230,95 +231,98 @@ export const NewMarketPreviewStep = ({ onSubmit={async (e: FormEvent) => { e.preventDefault(); - if (!hasAcceptedTerms) { - setShowAgreement(true); - } else { - setIsLoading(true); - setIsParentLoading?.(true); - setErrorMessage(undefined); - - try { - const tx = await createPermissionlessMarket(ticker); + setIsLoading(true); + setIsParentLoading?.(true); + setErrorMessage(undefined); - // Add try/catch for encode/parse so that it doesn't mess with loading states below - try { - if ((tx as IndexedTx | undefined)?.code === 0) { - const encodedTx = encodeJson(tx); - const parsedTx = JSON.parse(encodedTx); - const hash = parsedTx.hash.toUpperCase(); + try { + const tx = await createPermissionlessMarket(ticker); - if (!hash) { - throw new Error('Invalid transaction hash'); - } + // Add try/catch for encode/parse so that it doesn't mess with loading states below + try { + if ((tx as IndexedTx | undefined)?.code === 0) { + const encodedTx = encodeJson(tx); + const parsedTx = JSON.parse(encodedTx); + const hash = parsedTx.hash.toUpperCase(); - setTxHash(hash); + if (!hash) { + throw new Error('Invalid transaction hash'); } - } catch (error) { - setErrorMessage(error.message); - } - setEta(Date.now() + ESTIMATED_LAUNCH_TIMEOUT); + setTxHash(hash); + } } catch (error) { - log('NewMarketPreviewForm/createPermissionlessMarket', error); setErrorMessage(error.message); - setIsLoading(false); - setIsParentLoading?.(false); } + + setEta(Date.now() + ESTIMATED_LAUNCH_TIMEOUT); + } catch (error) { + log('NewMarketPreviewForm/createPermissionlessMarket', error); + setErrorMessage(error.message); + setIsLoading(false); + setIsParentLoading?.(false); } }} > - {showAgreement ? ( - { - setHasAcceptedTerms(true); - setShowAgreement(false); - }} - onCancel={() => setShowAgreement(false)} - /> - ) : ( - <> - {heading} - - {launchVisualization} - - {liquidityTier} - - {alertMessage} - -
- -
- - -
- - - {secondsLeft > 0 && - stringGetter({ - key: - Math.ceil(secondsLeft) === 1 - ? STRING_KEYS.WAIT_SECONDS_SINGULAR - : STRING_KEYS.WAIT_SECONDS, - params: { - SECONDS: String(Math.ceil(secondsLeft)), - }, - })} + {heading} + + {launchVisualization} + + {liquidityTier} + + {alertMessage} + +
+ + setHasAcceptedTerms(checked)} + id="launch-market-ack" + label={ + + {stringGetter({ + key: STRING_KEYS.MEGAVAULT_TERMS_TEXT, + params: { + CONFIRM_BUTTON_TEXT: stringGetter({ key: STRING_KEYS.DEPOSIT_AND_LAUNCH }), + LINK: ( + + {stringGetter({ key: STRING_KEYS.LAUNCH_MARKET_TERMS })} + + ), + }, + })} - - )} + } + /> + +
+ + +
+ + + {secondsLeft > 0 && + stringGetter({ + key: + Math.ceil(secondsLeft) === 1 + ? STRING_KEYS.WAIT_SECONDS_SINGULAR + : STRING_KEYS.WAIT_SECONDS, + params: { + SECONDS: String(Math.ceil(secondsLeft)), + }, + })} + ); };