Skip to content

Commit

Permalink
refactor: convert performActions to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Nov 3, 2023
1 parent 54b5876 commit a75ba58
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 646 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ const acceptEC = async () => {
};

const acceptOracles = oracles => {
const promiseArray = [];
const promiseArray = [] as Promise<void>[];

for (const oracle of oracles) {
console.log(`${oracle.address}: Accept oracle invitations`);
promiseArray.push(
executeOffer(
oracle.address,
agops.oracle('accept', '--offerId', oracle.id),
agops.oracle('accept', '--offerId', oracle.acceptanceOfferId),
),
);
}
Expand Down Expand Up @@ -267,7 +267,7 @@ export const raiseDebtCeiling = async address => {

export const pushPrice = (oracles, price = 10.0) => {
console.log(`ACTIONS pushPrice ${price}`);
const promiseArray = [];
const promiseArray = [] as Promise<void>[];

for (const oracle of oracles) {
console.log(`Pushing Price from oracle ${oracle.address}`);
Expand All @@ -280,7 +280,7 @@ export const pushPrice = (oracles, price = 10.0) => {
'--price',
price,
'--oracleAdminAcceptOfferId',
oracle.id,
oracle.acceptanceOfferId,
),
),
);
Expand Down
2 changes: 0 additions & 2 deletions proposals/34:upgrade-10/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"type": "module",
"license": "Apache-2.0",
"devDependencies": {},
"dependencies": {
"ava": "^5.3.1",
"better-sqlite3": "^8.5.1",
"execa": "^7.2.0"
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env tsx

// FIXME get TypeScript to resolve these, probably with lib:ES2022
import assert from 'node:assert/strict';
Expand All @@ -19,7 +19,6 @@ import {
} from '../../upgrade-test-scripts/lib/constants.js';
import {
getUser,
newOfferId,
waitForBlock,
} from '../../upgrade-test-scripts/lib/commonUpgradeHelpers.js';
import { submitDeliverInbound } from './upgradeHelpers.js';
Expand All @@ -37,25 +36,14 @@ const oraclesAddresses = [GOV1ADDR, GOV2ADDR];
await waitForBlock(2);
await submitDeliverInbound('user1');

const oracles = [];
for (const oracle of oraclesAddresses) {
const offerId = await newOfferId();
oracles.push({ address: oracle, id: offerId });
}
const oracles = oraclesAddresses.map((address, i) => ({
address,
acceptanceOfferId: i, // for re-use between accept and push
}));

console.log('Ensure user2 provisioned');
await provisionWallet('user2');

// XXX no need to test the helper function here
// const user2Address = await getUser('user2');
// const data = await agd.query(
// 'vstorage',
// 'data',
// `published.wallet.${user2Address}`,
// );

// assert.equal(data.value, '');

console.log('Ensure auction params have changed');
await implementNewAuctionParams(
GOV1ADDR,
Expand Down
3 changes: 2 additions & 1 deletion proposals/34:upgrade-10/use.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ yarn install --frozen-lockfile

yarn ava pre.test.js

./performActions.js
yarn global add tsx
./performActions.ts

./legacy.sh
Loading

0 comments on commit a75ba58

Please sign in to comment.