Removed code for unnecessary requirement to include a private key for an existing account

This commit is contained in:
Luke Steyn
2023-06-01 12:31:52 +09:00
parent 6a872ec7e4
commit 75f2ea56ae
3 changed files with 4 additions and 64 deletions

View File

@@ -1,4 +1,4 @@
import { program, Option } from 'commander';
import { program } from 'commander';
import responseTime = require('response-time');
import express from 'express';
@@ -7,7 +7,7 @@ import compression from 'compression';
import morgan from 'morgan';
import cors from 'cors';
import { Connection, Commitment, PublicKey } from '@solana/web3.js';
import { Connection, Commitment, PublicKey, Keypair } from '@solana/web3.js';
import {
getVariant,
@@ -32,11 +32,11 @@ import {
BN,
groupL2,
L2OrderBook,
Wallet,
} from '@drift-labs/sdk';
import { Mutex } from 'async-mutex';
import { getWallet } from './utils';
import { logger, setLogLevel } from './logger';
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
@@ -104,18 +104,6 @@ app.use((req, _res, next) => {
next();
});
program
.option('-d, --dry-run', 'Dry run, do not send transactions on chain')
.option('--test-liveness', 'Purposefully fail liveness test after 1 minute')
.addOption(
new Option(
'-p, --private-key <string>',
'private key, supports path to id.json, or list of comma separate numbers'
).env('ANCHOR_PRIVATE_KEY')
)
.option('--debug', 'Enable debug logging')
.parse();
const opts = program.opts();
setLogLevel(opts.debug ? 'debug' : 'info');
@@ -301,7 +289,7 @@ const initializeAllMarketSubscribers = async (
};
const main = async () => {
const wallet = getWallet();
const wallet = new Wallet(new Keypair());
const clearingHousePublicKey = new PublicKey(sdkConfig.DRIFT_PROGRAM_ID);
const connection = new Connection(endpoint, {
@@ -362,17 +350,6 @@ const main = async () => {
});
});
if (!(await driftClient.getUser().exists())) {
logger.error(`User for ${wallet.publicKey} does not exist`);
if (opts.initUser) {
logger.info(`Creating User for ${wallet.publicKey}`);
const [txSig] = await driftClient.initializeUserAccount();
logger.info(`Initialized user account in transaction: ${txSig}`);
} else {
throw new Error("Run with '--init-user' flag to initialize a User");
}
}
const userMap = new UserMap(
driftClient,
driftClient.userAccountSubscriptionConfig,