Skip to content

Commit

Permalink
chore: clean up auctioneer file
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Sep 3, 2024
1 parent 94ad5fa commit b9ea726
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
17 changes: 2 additions & 15 deletions a3p-integration/proposals/a:vaults-auctions/saveAuctionInstance.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
#!/usr/bin/env node
/* eslint-env node */
import { writeFile } from 'fs/promises';
import { getInstanceBoardId } from '@agoric/synthetic-chain';
import assert from 'node:assert/strict';
import { recordAuctioneerInstance } from './vatDetails.js';

const { env } = process;

const oldAuctionInstance = await getInstanceBoardId('auctioneer');
assert(oldAuctionInstance, 'no auction instance found');
console.log('old auction instance ', oldAuctionInstance, env.HOME);

await writeFile(
`${env.HOME}/.agoric/previousInstance.json`,
oldAuctionInstance,
);
await recordAuctioneerInstance();
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import {
pushPrices,
USER1ADDR,
} from '@agoric/synthetic-chain';
import { readFile } from 'node:fs/promises';
import { getDetailsMatchingVats } from './vatDetails.js';

const { env } = process;
import { readFile, rm } from 'node:fs/promises';
import {
getDetailsMatchingVats,
lastAuctionInstancePathname,
} from './vatDetails.js';

const oraclesByBrand = new Map();

Expand Down Expand Up @@ -106,11 +107,9 @@ const verifyVaultPriceUpdate = async t => {
};

const verifyAuctionInstance = async t => {
const newAuctionInstance = await getInstanceBoardId('auctioneer');
const oldInstance = await readFile(
`${env.HOME}/.agoric/previousInstance.json`,
'utf-8',
);
const newAuctionInstance = getInstanceBoardId('auctioneer');
const oldInstance = await readFile(lastAuctionInstancePathname, 'utf-8');
await rm(lastAuctionInstancePathname);

console.log(
`new: ${newAuctionInstance} should be different from ${oldInstance}`,
Expand Down
16 changes: 16 additions & 0 deletions a3p-integration/proposals/a:vaults-auctions/vatDetails.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/* eslint-env node */
import { getInstanceBoardId } from '@agoric/synthetic-chain';
import dbOpenAmbient from 'better-sqlite3';
import { writeFile } from 'fs/promises';
import assert from 'node:assert/strict';

const { env } = process;

const HOME = process.env.HOME;

Expand Down Expand Up @@ -99,3 +105,13 @@ export const getDetailsMatchingVats = async vatName => {

return infos;
};

export const lastAuctionInstancePathname = `${env.HOME}/.agoric/lastAuctioneerInstance.json`;

export const recordAuctioneerInstance = async () => {
const oldAuctionInstance = getInstanceBoardId('auctioneer');
assert(oldAuctionInstance, 'no auction instance found');
console.log('old auction instance ', oldAuctionInstance, env.HOME);

await writeFile(lastAuctionInstancePathname, oldAuctionInstance);
};

0 comments on commit b9ea726

Please sign in to comment.