From 8c1e8e5853d1ee7bf8484379d21f7e5a3e5d4c25 Mon Sep 17 00:00:00 2001 From: dydxwill <119354122+dydxwill@users.noreply.github.com> Date: Thu, 7 Dec 2023 15:14:17 -0500 Subject: [PATCH] [IND-519] add local config to v4-clients for e2e testing (#88) --- v4-client-js/.gitignore | 3 +++ v4-client-js/examples/constants.ts | 2 ++ v4-client-js/src/clients/constants.ts | 20 ++++++++++++++++++++ v4-client-js/src/index.ts | 1 + 4 files changed, 26 insertions(+) diff --git a/v4-client-js/.gitignore b/v4-client-js/.gitignore index 639069f1..302827d5 100644 --- a/v4-client-js/.gitignore +++ b/v4-client-js/.gitignore @@ -21,3 +21,6 @@ npm-debug.log # vim *.swo *.swp + +# IDE +.idea diff --git a/v4-client-js/examples/constants.ts b/v4-client-js/examples/constants.ts index 6565ecff..9ead2887 100644 --- a/v4-client-js/examples/constants.ts +++ b/v4-client-js/examples/constants.ts @@ -6,6 +6,8 @@ import { IPlaceOrder, OrderFlags } from '../src/clients/types'; export const DYDX_TEST_ADDRESS = 'dydx14zzueazeh0hj67cghhf9jypslcf9sh2n5k6art'; export const DYDX_TEST_PRIVATE_KEY = 'e92a6595c934c991d3b3e987ea9b3125bf61a076deab3a9cb519787b7b3e8d77'; export const DYDX_TEST_MNEMONIC = 'mirror actor skill push coach wait confirm orchard lunch mobile athlete gossip awake miracle matter bus reopen team ladder lazy list timber render wait'; +export const DYDX_LOCAL_ADDRESS = 'dydx199tqg4wdlnu4qjlxchpd7seg454937hjrknju4'; +export const DYDX_LOCAL_MNEMONIC = 'merge panther lobster crazy road hollow amused security before critic about cliff exhibit cause coyote talent happy where lion river tobacco option coconut small'; export const MARKET_BTC_USD: string = 'BTC-USD'; export const PERPETUAL_PAIR_BTC_USD: number = 0; diff --git a/v4-client-js/src/clients/constants.ts b/v4-client-js/src/clients/constants.ts index d78b4539..1979bee4 100644 --- a/v4-client-js/src/clients/constants.ts +++ b/v4-client-js/src/clients/constants.ts @@ -9,16 +9,19 @@ export * from '../lib/constants'; export const DEV_CHAIN_ID = 'dydxprotocol-testnet'; export const STAGING_CHAIN_ID = 'dydxprotocol-testnet'; export const TESTNET_CHAIN_ID = 'dydx-testnet-4'; +export const LOCAL_CHAIN_ID = 'localdydxprotocol'; // ------------ API URLs ------------ export enum IndexerApiHost { TESTNET = 'https://dydx-testnet.imperator.co', + LOCAL = 'http://localhost:3002' // TODO: Add MAINNET } export enum IndexerWSHost { TESTNET = 'wss://dydx-testnet.imperator.co/v4/ws', // TODO: Add MAINNET + LOCAL = 'ws://localhost:3003' } export enum FaucetApiHost { @@ -28,6 +31,7 @@ export enum FaucetApiHost { export enum ValidatorApiHost { TESTNET = 'https://dydx-testnet-archive.allthatnode.com', // TODO: Add MAINNET + LOCAL = 'http://localhost:26657' } // ------------ Network IDs ------------ @@ -180,6 +184,22 @@ export class Network { return new Network('testnet', indexerConfig, validatorConfig); } + static local(): Network { + const indexerConfig = new IndexerConfig( + IndexerApiHost.LOCAL, + IndexerWSHost.LOCAL, + ); + const validatorConfig = new ValidatorConfig(ValidatorApiHost.LOCAL, LOCAL_CHAIN_ID, + { + CHAINTOKEN_DENOM: 'adv4tnt', + USDC_DENOM: 'ibc/8E27BA2D5493AF5636760E354E46004562C46AB7EC0CC4C1CA14E9E20E2545B5', + USDC_GAS_DENOM: 'uusdc', + USDC_DECIMALS: 6, + CHAINTOKEN_DECIMALS: 18, + }); + return new Network('local', indexerConfig, validatorConfig); + } + // TODO: Add mainnet(): Network getString(): string { diff --git a/v4-client-js/src/index.ts b/v4-client-js/src/index.ts index 325f8166..955b97d9 100644 --- a/v4-client-js/src/index.ts +++ b/v4-client-js/src/index.ts @@ -16,3 +16,4 @@ export { FaucetClient } from './clients/faucet-client'; export { SocketClient } from './clients/socket-client'; export { NetworkOptimizer } from './network_optimizer'; export { encodeJson } from './lib/helpers'; +export { SubaccountInfo } from './clients/subaccount';