Example scripts: accept GROUP_NUM env var

This commit is contained in:
Christian Kamm 2022-07-13 19:17:26 +02:00
parent bbca1d8763
commit 33d4412ff8
3 changed files with 10 additions and 4 deletions

View File

@ -30,6 +30,8 @@ const DEVNET_ORACLES = new Map([
['ORCA', 'A1WttWF7X3Rg6ZRpB2YQUFHCRh1kiXV8sKKLV3S9neJV'],
]);
const GROUP_NUM = Number(process.env.GROUP_NUM || 0);
async function main() {
const options = AnchorProvider.defaultOptions();
const connection = new Connection(
@ -55,11 +57,11 @@ async function main() {
console.log(`Creating Group...`);
const insuranceMint = new PublicKey(DEVNET_MINTS.get('USDC')!);
try {
await client.groupCreate(0, true, insuranceMint);
await client.groupCreate(GROUP_NUM, true, insuranceMint);
} catch (error) {
console.log(error);
}
const group = await client.getGroupForAdmin(admin.publicKey);
const group = await client.getGroupForAdmin(admin.publicKey, GROUP_NUM);
console.log(`...registered group ${group.publicKey}`);
// register token 1

View File

@ -21,6 +21,8 @@ import { toUiDecimals } from '../utils';
// This script deposits some tokens, places some serum orders, cancels them, places some perp orders
//
const GROUP_NUM = Number(process.env.GROUP_NUM || 0);
async function main() {
const options = AnchorProvider.defaultOptions();
const connection = new Connection(
@ -48,7 +50,7 @@ async function main() {
JSON.parse(fs.readFileSync(process.env.ADMIN_KEYPAIR!, 'utf-8')),
),
);
const group = await client.getGroupForAdmin(admin.publicKey, 0);
const group = await client.getGroupForAdmin(admin.publicKey, GROUP_NUM);
console.log(group.toString());
// create + fetch account

View File

@ -4,6 +4,8 @@ import fs from 'fs';
import { MangoClient } from '../../client';
import { MANGO_V4_ID } from '../../constants';
const GROUP_NUM = Number(process.env.GROUP_NUM || 0);
async function main() {
const options = AnchorProvider.defaultOptions();
const connection = new Connection(
@ -31,7 +33,7 @@ async function main() {
JSON.parse(fs.readFileSync(process.env.ADMIN_KEYPAIR!, 'utf-8')),
),
);
const group = await user1Client.getGroupForAdmin(admin.publicKey, 0);
const group = await user1Client.getGroupForAdmin(admin.publicKey, GROUP_NUM);
console.log(`Found group ${group.publicKey.toBase58()}`);
const user1MangoAccount = await user1Client.getOrCreateMangoAccount(