Skip to content

Commit

Permalink
[IND-519] add local config to v4-clients for e2e testing (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
dydxwill authored Dec 7, 2023
1 parent 274107d commit 8c1e8e5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions v4-client-js/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ npm-debug.log
# vim
*.swo
*.swp

# IDE
.idea
2 changes: 2 additions & 0 deletions v4-client-js/examples/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions v4-client-js/src/clients/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 ------------
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions v4-client-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 8c1e8e5

Please sign in to comment.