Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace TSX with ts-blank-space #10305

Merged
merged 7 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions packages/benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,5 @@
"*.json",
"globals.d.ts",
"exported.js"
],
"engines": {
"node": ">=14.15.0"
},
"ava": {
"extensions": {
"js": true,
"ts": "module"
},
"files": [
"test/**/*.test.*"
],
"nodeArguments": [
"--loader=tsx",
"--no-warnings"
],
"require": [
"@endo/init/debug.js"
],
"timeout": "20m",
"workerThreads": false
}
]
}
12 changes: 0 additions & 12 deletions packages/boot/ava.bench.config.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/boot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@endo/patterns": "^1.4.4",
"ava": "^5.3.0",
"c8": "^9.1.0",
"tsx": "3.12.8"
"ts-blank-space": "^0.4.1"
},
"files": [
"CHANGELOG.md",
Expand All @@ -81,7 +81,7 @@
"test/**/*.test.*"
],
"nodeArguments": [
"--loader=tsx",
"--loader=ts-blank-space/register",
"--no-warnings"
],
"require": [
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/addAssets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { TestFn } from 'ava';

import { TimeMath } from '@agoric/time';
import {
LiquidationTestContext,
type LiquidationTestContext,
makeLiquidationTestContext,
} from '../../tools/liquidation.js';
import { makeProposalExtractor } from '../../tools/supports.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { TestFn } from 'ava';
import type { TestFn } from 'ava';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import {
makeAgoricNamesRemotesFromFakeStorage,
Expand Down
4 changes: 2 additions & 2 deletions packages/boot/test/bootstrapTests/liquidation-1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import type { ExecutionContext, TestFn } from 'ava';
import type { ScheduleNotification } from '@agoric/inter-protocol/src/auction/scheduler.js';
import {
ensureVaultCollateral,
LiquidationTestContext,
type LiquidationTestContext,
likePayouts,
makeLiquidationTestContext,
scale6,
LiquidationSetup,
type LiquidationSetup,
} from '../../tools/liquidation.js';

const test = anyTest as TestFn<LiquidationTestContext>;
Expand Down
7 changes: 3 additions & 4 deletions packages/boot/test/bootstrapTests/liquidation-2b.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { NonNullish } from '@agoric/internal';
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
import type { TestFn } from 'ava';
import { ScheduleNotification } from '@agoric/inter-protocol/src/auction/scheduler.js';
import type { ScheduleNotification } from '@agoric/inter-protocol/src/auction/scheduler.js';
import {
LiquidationSetup,
LiquidationTestContext,
type LiquidationSetup,
type LiquidationTestContext,
makeLiquidationTestContext,
scale6,
} from '../../tools/liquidation.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { NonNullish } from '@agoric/internal';
import process from 'process';
import { TestFn } from 'ava';
import type { TestFn } from 'ava';
import {
LiquidationSetup,
LiquidationTestContext,
type LiquidationSetup,
type LiquidationTestContext,
ensureVaultCollateral,
likePayouts,
makeLiquidationTestContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { NonNullish } from '@agoric/internal';
import { ExecutionContext, TestFn } from 'ava';
import type { ExecutionContext, TestFn } from 'ava';
import {
LiquidationTestContext,
type LiquidationTestContext,
ensureVaultCollateral,
makeLiquidationTestContext,
scale6,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import type { TestFn } from 'ava';
import { ScheduleNotification } from '@agoric/inter-protocol/src/auction/scheduler.js';
import type { ScheduleNotification } from '@agoric/inter-protocol/src/auction/scheduler.js';
import { NonNullish } from '@agoric/internal';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { Fail } from '@endo/errors';

import {
LiquidationTestContext,
type LiquidationTestContext,
likePayouts,
makeLiquidationTestContext,
scale6,
LiquidationSetup,
type LiquidationSetup,
} from '../../tools/liquidation.js';
import {
updateVaultDirectorParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import type { TestFn } from 'ava';
import { makeAgoricNamesRemotesFromFakeStorage } from '@agoric/vats/tools/board-utils';
import { makeAgoricNamesRemotesFromFakeStorage } from '@agoric/vats/tools/board-utils.js';
import { Fail } from '@endo/errors';

import { makeSwingsetTestKit } from '../../tools/supports.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import type { TestFn } from 'ava';
import { makeAgoricNamesRemotesFromFakeStorage } from '@agoric/vats/tools/board-utils';
import { makeAgoricNamesRemotesFromFakeStorage } from '@agoric/vats/tools/board-utils.js';
import { Fail } from '@endo/errors';

import { makeSwingsetTestKit } from '../../tools/supports.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/boot/test/bootstrapTests/vats-restart.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/** @file Bootstrap test of restarting (almost) all vats */
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { TestFn } from 'ava';
import type { TestFn } from 'ava';

import { Fail } from '@endo/errors';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
import { makeAgoricNamesRemotesFromFakeStorage } from '@agoric/vats/tools/board-utils.js';
import { BridgeHandler, ScopedBridgeManager } from '@agoric/vats';
import type { ScopedBridgeManager } from '@agoric/vats';
import { makeSwingsetTestKit } from '../../tools/supports.js';
import { makeWalletFactoryDriver } from '../../tools/drivers.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
slotToBoardRemote,
} from '@agoric/vats/tools/board-utils.js';
import type { TestFn } from 'ava';
import { ParamChangesOfferArgs } from '@agoric/inter-protocol/src/econCommitteeCharter.js';
import type { ParamChangesOfferArgs } from '@agoric/inter-protocol/src/econCommitteeCharter.js';

import { makeSwingsetTestKit } from '../../tools/supports.js';
import { makeWalletFactoryDriver } from '../../tools/drivers.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/boot/test/bootstrapTests/vaults-upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
import { Far, makeMarshal } from '@endo/marshal';
import { SECONDS_PER_YEAR } from '@agoric/inter-protocol/src/interest.js';
import { makeAgoricNamesRemotesFromFakeStorage } from '@agoric/vats/tools/board-utils.js';
import { ExecutionContext, TestFn } from 'ava';
import { FakeStorageKit } from '@agoric/internal/src/storage-test-utils.js';
import type { ExecutionContext, TestFn } from 'ava';
import type { FakeStorageKit } from '@agoric/internal/src/storage-test-utils.js';
import { makeSwingsetTestKit } from '../../tools/supports.js';
import { makeWalletFactoryDriver } from '../../tools/drivers.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/walletFactory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Fail } from '@endo/errors';
import {
AgoricNamesRemotes,
type AgoricNamesRemotes,
makeAgoricNamesRemotesFromFakeStorage,
} from '@agoric/vats/tools/board-utils.js';
import { makeSwingsetTestKit } from '../../tools/supports.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/** @file Bootstrap test of liquidation across multiple collaterals */
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import process from 'process';
import type { TestFn } from 'ava';
import process from 'process';

import { BridgeHandler } from '@agoric/vats';
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
import {
LiquidationTestContext,
makeLiquidationTestContext,
LiquidationSetup,
type LiquidationSetup,
type LiquidationTestContext,
} from '../../tools/liquidation.js';

const test = anyTest as TestFn<LiquidationTestContext>;
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/zcf-upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import bundleSource from '@endo/bundle-source';
import path from 'path';

import { makeAgoricNamesRemotesFromFakeStorage } from '@agoric/vats/tools/board-utils.js';
import { TestFn } from 'ava';
import type { TestFn } from 'ava';
import { matchAmount, makeSwingsetTestKit } from '../../tools/supports.js';
import { makeZoeDriver } from '../../tools/drivers.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @file Bootstrap test of restarting contracts using orchestration */
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { TestFn } from 'ava';
import type { TestFn } from 'ava';

import { BridgeId } from '@agoric/internal';
import { buildVTransferEvent } from '@agoric/orchestration/tools/ibc-mocks.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @file Bootstrap test of restarting contracts using orchestration */
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { TestFn } from 'ava';
import type { TestFn } from 'ava';

import { BridgeId } from '@agoric/internal';
import type { CosmosValidatorAddress } from '@agoric/orchestration';
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/tools/changeVaultParams.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ParamChangesOfferArgs } from '@agoric/inter-protocol/src/econCommitteeCharter';
import type { ParamChangesOfferArgs } from '@agoric/inter-protocol/src/econCommitteeCharter.js';

export const updateVaultManagerParams = async (t, gd, brand, newDebtLimit) => {
const { agoricNamesRemotes } = t.context;
Expand Down
4 changes: 2 additions & 2 deletions packages/boot/tools/drivers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
unmarshalFromVstorage,
} from '@agoric/internal/src/marshal.js';
import {
FakeStorageKit,
type FakeStorageKit,
slotToRemotable,
} from '@agoric/internal/src/storage-test-utils.js';
import { oracleBrandFeedName } from '@agoric/inter-protocol/src/proposals/utils.js';

import {
AgoricNamesRemotes,
type AgoricNamesRemotes,
boardSlottingMarshaller,
} from '@agoric/vats/tools/board-utils.js';
import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/tools/liquidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
SECONDS_PER_MINUTE,
} from '@agoric/inter-protocol/src/proposals/econ-behaviors.js';
import {
AgoricNamesRemotes,
type AgoricNamesRemotes,
makeAgoricNamesRemotesFromFakeStorage,
} from '@agoric/vats/tools/board-utils.js';
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/tools/supports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { krefOf } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';
import { loadSwingsetConfigFile } from '@agoric/swingset-vat';
import { makeSlogSender } from '@agoric/telemetry';
import { TimeMath, Timestamp } from '@agoric/time';
import { TimeMath, type Timestamp } from '@agoric/time';
import {
fakeLocalChainBridgeTxMsgHandler,
LOCALCHAIN_DEFAULT_ADDRESS,
Expand Down
43 changes: 37 additions & 6 deletions packages/cosmic-proto/scripts/codegen.cjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
const { spawnSync } = require('child_process');
const { join } = require('path');
const { exec, spawnSync } = require('child_process');
const path = require('path');
const process = require('process');
const telescope = require('@cosmology/telescope').default;
const rimraf = require('rimraf').rimrafSync;

const protoDirs = [join(__dirname, '/../proto')];
const outPath = join(__dirname, '../src/codegen');
const protoDirs = [path.join(__dirname, '/../proto')];
const outPath = path.join(__dirname, '../src/codegen');
rimraf(outPath);

/**
* Make the JsonSafe type import compatible with TS verbatimImportSyntax
*
* @param {string} directory
*/
function fixTypeImport(directory) {
const fullPath = path.resolve(directory);
const command = `
find ${fullPath} -type f -exec sed -i '' \
-e 's/import { JsonSafe/import {type JsonSafe/g' \
-e 's/\\([{,]\\) \\([[:alnum:]_]*SDKType\\)/\\1 type \\2/g' {} +
`;

exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`Error during replacement: ${error.message}`);
return;
}
if (stderr) {
console.error(`Standard error: ${stderr}`);
return;
}
});
}

telescope({
protoDirs,
outPath,
Expand Down Expand Up @@ -98,11 +123,17 @@ telescope({
},
})
.then(() => {
console.log('🔨 code generated by Telescope');

// for all files under codegen/ replace "import { JsonSafe" with "import type { JsonSafe"
fixTypeImport('./src/codegen');
console.log('🔧 type keyword added');

spawnSync('yarn', ['prettier', '--write', 'src'], {
cwd: join(__dirname, '..'),
cwd: path.join(__dirname, '..'),
});
console.log('💅 code formatted by Prettier');

console.log('💅 code generated and formatted');
console.log('ℹ️ `yarn build && yarn test` to test it.');
})
.catch(e => {
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-proto/src/codegen/agoric/lien/genesis.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ts-nocheck
import { Lien, LienSDKType } from './lien.js';
import { Lien, type LienSDKType } from './lien.js';
import { BinaryReader, BinaryWriter } from '../../binary.js';
import { JsonSafe } from '../../json-safe.js';
import { type JsonSafe } from '../../json-safe.js';
import { isSet } from '../../helpers.js';
/** The initial or exported state. */
export interface GenesisState {
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-proto/src/codegen/agoric/lien/lien.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ts-nocheck
import { Coin, CoinSDKType } from '../../cosmos/base/v1beta1/coin.js';
import { Coin, type CoinSDKType } from '../../cosmos/base/v1beta1/coin.js';
import { BinaryReader, BinaryWriter } from '../../binary.js';
import { JsonSafe } from '../../json-safe.js';
import { type JsonSafe } from '../../json-safe.js';
/** Lien contains the lien state of a particular account. */
export interface Lien {
/** coins holds the amount liened */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
//@ts-nocheck
import { Params, ParamsSDKType, State, StateSDKType } from './swingset.js';
import {
Params,
type ParamsSDKType,
State,
type StateSDKType,
} from './swingset.js';
import { BinaryReader, BinaryWriter } from '../../binary.js';
import { isSet } from '../../helpers.js';
import { JsonSafe } from '../../json-safe.js';
import { type JsonSafe } from '../../json-safe.js';
/** The initial or exported state. */
export interface GenesisState {
params: Params;
Expand Down
Loading
Loading