feat: allow default wallet url to be configured (#875)
* feat: allow default wallet url to be configured * docs: add docs to environement package
This commit is contained in:
parent
54cf70fa42
commit
e275460c76
@ -12,6 +12,7 @@ NX_ETHEREUM_CHAIN_ID=1440
|
||||
NX_ETH_URL_CONNECT=1
|
||||
NX_ETH_WALLET_MNEMONIC=ozone access unlock valid olympic save include omit supply green clown session
|
||||
NX_LOCAL_PROVIDER_URL=http://localhost:8545/
|
||||
NX_VEGA_WALLET_URL=http://localhost:1789/api/v1
|
||||
|
||||
#Test configuration variables
|
||||
CYPRESS_FAIRGROUND=false
|
||||
|
@ -8,6 +8,7 @@ NX_FAIRGROUND=false
|
||||
NX_IS_NEW_BRIDGE_CONTRACT=true
|
||||
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
|
||||
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||
NX_VEGA_WALLET_URL=http://localhost:1789/api/v1
|
||||
|
||||
#Test configuration variables
|
||||
CYPRESS_FAIRGROUND=false
|
||||
|
@ -1 +1,2 @@
|
||||
NX_USE_ENV_OVERRIDES=0
|
||||
NX_VEGA_WALLET_URL=http://localhost:1789/api/v1
|
||||
|
@ -6,3 +6,4 @@ NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||
NX_VEGA_NETWORKS={\"MAINNET\":\"https://alpha.console.vega.xyz\"}
|
||||
NX_USE_ENV_OVERRIDES=1
|
||||
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
|
||||
NX_VEGA_WALLET_URL=http://localhost:1789/api/v1
|
||||
|
@ -12,6 +12,8 @@ The environment variables needed to be present for any app consuming this librar
|
||||
|
||||
`NX_VEGA_URL` OR `NX_VEGA_CONFIG_URL` - either the network configuration url or a url to a node to directly connect to
|
||||
|
||||
`NX_VEGA_WALLET_URL` the default vega wallet URL
|
||||
|
||||
For examples, see Block Explorer's .env files [here](../../apps/explorer)
|
||||
|
||||
## Running unit tests
|
||||
|
@ -68,6 +68,8 @@ const getBundledEnvironmentValue = (key: EnvKey) => {
|
||||
return process.env['NX_GITHUB_FEEDBACK_URL'];
|
||||
case 'VEGA_EXPLORER_URL':
|
||||
return process.env['NX_VEGA_EXPLORER_URL'];
|
||||
case 'VEGA_WALLET_URL':
|
||||
return process.env['NX_VEGA_WALLET_URL'];
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -14,6 +14,7 @@ export enum Networks {
|
||||
|
||||
const schemaObject = {
|
||||
VEGA_URL: z.optional(z.string()),
|
||||
VEGA_WALLET_URL: z.optional(z.string()),
|
||||
VEGA_CONFIG_URL: z.optional(z.string()),
|
||||
GIT_BRANCH: z.optional(z.string()),
|
||||
GIT_COMMIT_HASH: z.optional(z.string()),
|
||||
|
@ -10,6 +10,7 @@ import { VegaWalletContext } from '../context';
|
||||
import { VegaConnectDialog } from './connect-dialog';
|
||||
import type { VegaConnectDialogProps } from '..';
|
||||
import { RestConnector } from '../connectors';
|
||||
import { EnvironmentProvider } from '@vegaprotocol/environment';
|
||||
|
||||
let defaultProps: VegaConnectDialogProps;
|
||||
let defaultContextValue: VegaWalletContextShape;
|
||||
@ -35,16 +36,28 @@ beforeEach(() => {
|
||||
|
||||
const DEFAULT_URL = 'http://localhost:1789/api/v1';
|
||||
|
||||
const mockEnvironment = {
|
||||
VEGA_ENV: 'TESTNET',
|
||||
VEGA_URL: 'https://vega-node.url',
|
||||
VEGA_NETWORKS: JSON.stringify({}),
|
||||
GIT_BRANCH: 'test',
|
||||
GIT_COMMIT_HASH: 'abcdef',
|
||||
GIT_ORIGIN_URL: 'https://github.com/test/repo',
|
||||
VEGA_WALLET_URL: DEFAULT_URL,
|
||||
};
|
||||
|
||||
function generateJSX(
|
||||
props?: Partial<VegaConnectDialogProps>,
|
||||
contextValue?: Partial<VegaWalletContextShape>
|
||||
) {
|
||||
return (
|
||||
<EnvironmentProvider definitions={mockEnvironment}>
|
||||
<VegaWalletContext.Provider
|
||||
value={{ ...defaultContextValue, ...contextValue }}
|
||||
>
|
||||
<VegaConnectDialog {...defaultProps} {...props} />
|
||||
</VegaWalletContext.Provider>
|
||||
</EnvironmentProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { useEnvironment } from '@vegaprotocol/environment';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
import { Button, FormGroup, Input, InputError } from '@vegaprotocol/ui-toolkit';
|
||||
import { useState } from 'react';
|
||||
@ -15,21 +16,19 @@ interface RestConnectorFormProps {
|
||||
onAuthenticate: () => void;
|
||||
}
|
||||
|
||||
const VEGA_DEFAULT_URL = 'http://localhost:1789/api/v1';
|
||||
|
||||
export function RestConnectorForm({
|
||||
connector,
|
||||
onAuthenticate,
|
||||
}: RestConnectorFormProps) {
|
||||
const [error, setError] = useState('');
|
||||
|
||||
const { VEGA_WALLET_URL } = useEnvironment();
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm<FormFields>({
|
||||
defaultValues: {
|
||||
url: VEGA_DEFAULT_URL,
|
||||
url: VEGA_WALLET_URL,
|
||||
},
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user