2022-06-21 23:20:53 +00:00
|
|
|
import z from 'zod';
|
2023-02-28 16:51:02 +00:00
|
|
|
|
|
|
|
export enum Networks {
|
|
|
|
VALIDATOR_TESTNET = 'VALIDATOR_TESTNET',
|
2023-07-18 11:23:58 +00:00
|
|
|
MAINNET_MIRROR = 'MAINNET_MIRROR',
|
2023-02-28 16:51:02 +00:00
|
|
|
CUSTOM = 'CUSTOM',
|
|
|
|
TESTNET = 'TESTNET',
|
|
|
|
STAGNET1 = 'STAGNET1',
|
|
|
|
DEVNET = 'DEVNET',
|
|
|
|
MAINNET = 'MAINNET',
|
|
|
|
}
|
2022-06-21 23:20:53 +00:00
|
|
|
|
|
|
|
const schemaObject = {
|
|
|
|
VEGA_URL: z.optional(z.string()),
|
2022-07-27 10:28:29 +00:00
|
|
|
VEGA_WALLET_URL: z.optional(z.string()),
|
2022-06-21 23:20:53 +00:00
|
|
|
VEGA_CONFIG_URL: z.optional(z.string()),
|
2022-07-08 10:19:05 +00:00
|
|
|
GIT_BRANCH: z.optional(z.string()),
|
|
|
|
GIT_COMMIT_HASH: z.optional(z.string()),
|
|
|
|
GIT_ORIGIN_URL: z.optional(z.string()),
|
2022-07-06 15:53:35 +00:00
|
|
|
GITHUB_FEEDBACK_URL: z.optional(z.string()),
|
2023-03-31 08:06:21 +00:00
|
|
|
ORACLE_PROOFS_URL: z.optional(z.string().url()),
|
2022-06-21 23:20:53 +00:00
|
|
|
VEGA_ENV: z.nativeEnum(Networks),
|
2023-05-22 15:50:13 +00:00
|
|
|
VEGA_CONSOLE_URL: z.optional(z.string()),
|
2022-07-12 16:34:54 +00:00
|
|
|
VEGA_EXPLORER_URL: z.optional(z.string()),
|
2022-09-05 12:06:58 +00:00
|
|
|
VEGA_TOKEN_URL: z.optional(z.string()),
|
Feat/800 better proposal ux round 1 (#1223)
* Feat/800: Configured routes for different proposal types
* Feat/800: Refactored propose.tsx to be a hub for the new proposal routes
* Feat/800: Link style tweak for proposals guide
* Feat/927: Hydrating the new proposal forms
* chore: fix typings for shared components
* Feat/927: Proposal forms built with reusable components
* Feat/800: Updated network params, added new method to get param keys as well as values, updated generated types
* Feat/800: Updated and built more reusable proposal form components
* Feat/800: Removed old catchall file of reusable proposal form components
* Feat/800: Added utils for vote deadline and enactment timestamps
* Feat/800: Readded necessary 'color-scheme-dark' class for dark-theme date and datetime inputs
* Feat/800: Tweak to icon positioning on the dialog component
* Feat/800: Regenerated types for network params
* Feat/800: Added iso8601-duration package for working with API vote deadline and enactment data
* Feat/800: Reworked the proposal forms
* Feat/800: Couple of translation additions
* Feat/800: Another translation addition
* Feat/800: Raw proposal test (tests as per old proposal form test)
* Feat/800: Some basic proposal form tests
* Feat/800: Fixing small types error in test
* Feat/800: Updating simple proposal form tests
* Feat/800: Set up env-specific proposal docs links
* Feat/800: Deadlines to the bottom of proposal forms
* Feat/800: Another type error from API changes fixed
* Feat/800: Added the spam protection min tokens network param to proposal forms requests, and the min requirements now displays the larger value of spam protection or min proposer balance
* Feat/800: Network param value change now a textarea
* Feat/800: Improved way to pass docs url
* Feat/800: Added useful explorer links to proposal forms
* Feat/800: Show current value of selected network param in proposal form
* Feat/800: Removed wallet-confirmation buffer, suspect it is not necessary
* Feat/800: Condense vote and enactment ui into single component for simpler state management, memoised some stuff
* Feat/800: Set a default select option for the market selector
* Feat/800: For network params that aren't JSON, display the network param current value in a readonly text input rather than the syntax highlighter
* Feat/800: Corrected network param form network params
* Feat/800: Timestamp functions for closing, enactment and validation, with tests
* Feat/800: More translations
* Feat/800: Added validation options to proposal-form-vote-and-enactment-deadline.tsx, generally improved the component and added tests
* Feat/800: Improved workings of proposal-form-min-requirements.tsx and wrote tests
* Feat/800: Tests for the other reusable form components
* Feat/800: Improved tests for the proposal forms
* Feat/800: Corrected mistake in get-enactment-timestamp.ts
* Feat/800: Fixed type issues that were preventing spotting an error
* Feat/800: Added some extra docs links
* Feat/800: Using renamed Dialog passed in from useProposalSubmit
* refactor: network params to return an object
* fix: update net param form, remove old net params obj
* fix: check for params before rendering
* Feat/800: Rename and simplify isJson based off PR comment
* Feat/800: Small tweaks to timestamp helpers based on PR comments
* Feat/800: Removed proposal-docs-link.tsx
* Feat/800: Used bignumber for min-requirements calculation
* Feat/800: Update tests to work with merged network params branch
* Feat/800: Removed unnecessary translations splitting
* Feat/800: Removed unwanted test
* Feat/800: Removed unwanted tests
* Feat/800: Consistent arrow functions
* Feat/800: Sorted links
* Feat/800: Removed unnecessary typecasting
* Feat/800: Refactored routing
* Feat/800: Refactored mocking of proposal forms to use MockedProvider
* Feat/800: Correct response from the raw proposal submission test
* Feat/800: Removed console.logs added for debugging
* Feat/800: Result of running 'nx format:write'
* Feat/800: Cleaning up lint warnings
* Update apps/token/.env.stagnet3
Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com>
* Feat/800: Added extra test for docs link in the proposal-form-terms component
* Feat/800: Removed stray console.log
* Feat/800: Added basic render test for proposal-form-terms and cleaned up a bit
* Feat/800: Added tests for the correct form components for the different forms
* Feat/800: Split up the proposal-form-vote-and-enactment-deadline components inside the file to make things a bit more readable
* Feat/800: router config webpack chunk name tweak
* Feat/800: Lint issue fixed
* Feat/800: Fixed timing issue with get-[deadline]-timestamp tests
* Feat/800: Setting a system time in proposal-form-vote-and-enactment-deadline.spec.tsx that doesn't get affected by British Summer Time
* Feat/800: Skipping a cypress test as the newProposalButton no longer takes a user directly to a proposal form. Leaving it in the codebase as the test is very likely to be updated.
* Feat/800: Adding comment on why I've skipped a cypress test
Co-authored-by: Dexter <dexter@vega.xyz>
Co-authored-by: Matthew Russell <mattrussell36@gmail.com>
Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com>
2022-09-23 10:10:13 +00:00
|
|
|
VEGA_DOCS_URL: z.optional(z.string()),
|
2022-06-21 23:20:53 +00:00
|
|
|
VEGA_NETWORKS: z
|
|
|
|
.object(
|
|
|
|
Object.keys(Networks).reduce(
|
|
|
|
(acc, env) => ({
|
|
|
|
...acc,
|
|
|
|
[env]: z.optional(z.string()),
|
|
|
|
}),
|
|
|
|
{}
|
2023-02-16 03:52:54 +00:00
|
|
|
) as Record<Networks, z.ZodOptional<z.ZodString>>
|
2022-06-21 23:20:53 +00:00
|
|
|
)
|
|
|
|
.strict({
|
|
|
|
message: `All keys in NX_VEGA_NETWORKS must represent a valid environment: ${Object.keys(
|
|
|
|
Networks
|
|
|
|
).join(' | ')}`,
|
|
|
|
}),
|
2022-07-12 16:34:54 +00:00
|
|
|
ETHEREUM_PROVIDER_URL: z.string().url({
|
|
|
|
message:
|
|
|
|
'The NX_ETHEREUM_PROVIDER_URL environment variable must be a valid url',
|
|
|
|
}),
|
|
|
|
ETHERSCAN_URL: z.string().url({
|
|
|
|
message: 'The NX_ETHERSCAN_URL environment variable must be a valid url',
|
|
|
|
}),
|
2022-10-03 18:12:34 +00:00
|
|
|
HOSTED_WALLET_URL: z.optional(z.string()),
|
2023-01-04 12:45:50 +00:00
|
|
|
MAINTENANCE_PAGE: z.optional(z.boolean()),
|
2023-01-24 14:02:17 +00:00
|
|
|
ETH_LOCAL_PROVIDER_URL: z.optional(z.string()),
|
|
|
|
ETH_WALLET_MNEMONIC: z.optional(z.string()),
|
2023-03-29 13:20:49 +00:00
|
|
|
ANNOUNCEMENTS_CONFIG_URL: z.optional(z.string()),
|
2023-03-21 15:19:54 +00:00
|
|
|
VEGA_INCIDENT_URL: z.optional(z.string()),
|
2023-05-22 19:53:40 +00:00
|
|
|
APP_VERSION: z.optional(z.string()),
|
2023-06-27 06:40:42 +00:00
|
|
|
SENTRY_DSN: z.optional(z.string()),
|
2023-07-20 08:27:43 +00:00
|
|
|
TENDERMINT_URL: z.optional(z.string()),
|
|
|
|
TENDERMINT_WEBSOCKET_URL: z.optional(z.string()),
|
2022-06-21 23:20:53 +00:00
|
|
|
};
|
|
|
|
|
2023-02-16 03:52:54 +00:00
|
|
|
// combine schema above with custom rule to ensure either
|
|
|
|
// VEGA_URL or VEGA_CONFIG_URL are provided
|
2022-06-21 23:20:53 +00:00
|
|
|
export const envSchema = z.object(schemaObject).refine(
|
|
|
|
(data) => {
|
|
|
|
return !(!data.VEGA_URL && !data.VEGA_CONFIG_URL);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
message:
|
|
|
|
'Must provide either NX_VEGA_CONFIG_URL or NX_VEGA_URL in the environment.',
|
|
|
|
}
|
|
|
|
);
|