support keypair or wallet_path

This commit is contained in:
SpaceMonkey 2023-02-01 13:55:20 +02:00
parent 40742594b2
commit 380cefa3db
2 changed files with 10 additions and 3 deletions

View File

@ -14,7 +14,13 @@ yarn install
make sure to create a JSON file containing the keypair formatted as a byte array e.g. [1,3,4...]
```
ENDPOINT_URL=... KEYPAIR=./path/to/wallet.json ./start-cranker.sh
ENDPOINT_URL=... WALLET_PATH=./path/to/wallet.json ./start-cranker.sh
```
Or run with KEYPAIR directly:
```
ENDPOINT_URL=... KEYPAIR=[1,3,4...] ./start-cranker.sh
```
to run in the background, pass "-d" or "--daemon"

View File

@ -24,6 +24,7 @@ import { Logger } from 'tslog';
const {
ENDPOINT_URL,
WALLET_PATH,
KEYPAIR,
PROGRAM_ID,
INTERVAL,
@ -51,11 +52,11 @@ const serumProgramId = new PublicKey(
? 'srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX'
: 'EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj',
);
const walletFile = KEYPAIR || os.homedir() + '/.config/solana/devnet.json';
const walletFile = WALLET_PATH || os.homedir() + '/.config/solana/devnet.json';
const payer = Keypair.fromSecretKey(
Uint8Array.from(
JSON.parse(
fs.readFileSync(walletFile, 'utf-8'),
KEYPAIR || fs.readFileSync(walletFile, 'utf-8'),
),
),
);