Skip to content

Commit

Permalink
Merge branch 'master' into mfig-zones
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Mar 6, 2023
2 parents 685e64c + 398b70f commit 2effb18
Show file tree
Hide file tree
Showing 157 changed files with 5,333 additions and 1,197 deletions.
14 changes: 2 additions & 12 deletions packages/ERTP/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"checkJs": true,
"noEmit": true,
"strictNullChecks": true,
"noImplicitThis": true,
"moduleResolution": "node",
"types": [
"node"
]
},
"extends": "../../tsconfig.json",
"include": [
"src/**/*.js",
"src/**/*.ts",
Expand Down
10 changes: 5 additions & 5 deletions packages/ERTP/src/paymentLedger.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,11 @@ export const preparePaymentLedger = (
srcPayment,
optAmountShape = undefined,
) => {
assert(
!isPromise(srcPayment),
`deposit does not accept promises as first argument. Instead of passing the promise (deposit(paymentPromise)), consider unwrapping the promise first: E.when(paymentPromise, (actualPayment => deposit(actualPayment))`,
TypeError,
);
!isPromise(srcPayment) ||
assert.fail(
`deposit does not accept promises as first argument. Instead of passing the promise (deposit(paymentPromise)), consider unwrapping the promise first: E.when(paymentPromise, (actualPayment => deposit(actualPayment))`,
TypeError,
);
assertLivePayment(srcPayment);
const srcPaymentBalance = paymentLedger.get(srcPayment);
assertAmountConsistent(srcPaymentBalance, optAmountShape);
Expand Down
10 changes: 1 addition & 9 deletions packages/SwingSet/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"checkJs": true,
"noEmit": true,
"strictNullChecks": true,
"noImplicitThis": true,
"moduleResolution": "node",
},
"extends": "../../tsconfig.json",
"include": [
"lib/**/*.js",
"src/**/*.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
"lint:eslint": "eslint ."
},
"devDependencies": {
"@types/microtime": "^2.1.0",
"better-sqlite3": "^7.5.0",
"@types/better-sqlite3": "^7.5.0",
"@types/microtime": "^2.1.0",
"@types/tmp": "^0.2.0",
"better-sqlite3": "^7.5.0",
"tmp": "^0.2.1"
},
"dependencies": {
"@agoric/assert": "^0.5.1",
"@agoric/internal": "^0.2.1",
"@endo/nat": "^4.1.0",
"@agoric/notifier": "^0.5.1",
"@agoric/store": "^0.8.3",
"@agoric/swing-store": "^0.8.1",
Expand All @@ -51,6 +50,7 @@
"@endo/nat": "^4.1.23",
"@endo/promise-kit": "^0.2.52",
"@endo/zip": "^0.2.28",
"ansi-styles": "^6.2.1",
"anylogger": "^0.21.0",
"import-meta-resolve": "^2.2.1",
"microtime": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/types-external.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export {};
* @typedef { { enableDisavow?: boolean } } HasEnableDisavow
* @typedef { DynamicVatOptions & HasEnableDisavow } StaticVatOptions
*
* @typedef { { vatParameters?: object, upgradeMessage: string } } VatUpgradeOptions
* @typedef { { vatParameters?: object, upgradeMessage?: string } } VatUpgradeOptions
* @typedef { { incarnationNumber: number } } VatUpgradeResults
*
* @callback ShutdownWithFailure
Expand Down
8 changes: 6 additions & 2 deletions packages/SwingSet/test/metering/vat-load-dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export function buildRootObject(vatPowers) {
const { testLog: log } = vatPowers;
let service;
let control;
const notifierToUpdateCount = new WeakMap();

return Far('root', {
async bootstrap(vats, devices) {
Expand Down Expand Up @@ -33,8 +34,11 @@ export function buildRootObject(vatPowers) {

async whenMeterNotifiesNext(meter) {
const notifier = await E(meter).getNotifier();
const initial = await E(notifier).getUpdateSince();
return E(notifier).getUpdateSince(initial);
const update = await E(notifier).getUpdateSince(
notifierToUpdateCount.get(notifier),
);
notifierToUpdateCount.set(notifier, update.updateCount);
return update;
},

async createVat(name, dynamicOptions) {
Expand Down
10 changes: 9 additions & 1 deletion packages/SwingSet/tools/bundleTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import bundleSource from '@endo/bundle-source';
import { makeReadPowers } from '@endo/compartment-mapper/node-powers.js';
import { makePromiseKit } from '@endo/promise-kit';
import styles from 'ansi-styles'; // less authority than 'chalk'

const { details: X, quote: q, Fail } = assert;

Expand Down Expand Up @@ -166,15 +167,22 @@ export const makeBundleCache = (wr, bundleOptions, cwd, readPowers) => {
meta = await validate(targetName, rootPath);
const { bundleTime, contents } = meta;
log(
styles.dim.open,
`${wr}`,
toBundleName(targetName),
'valid:',
contents.length,
'files bundled at',
bundleTime,
styles.dim.close,
);
} catch (invalid) {
console.error('ERROR in bundleTool:', invalid.message);
console.error(
styles.red.open,
'ERROR in bundleTool:',
invalid.message,
styles.red.close,
);
}
}
if (!meta) {
Expand Down
3 changes: 2 additions & 1 deletion packages/SwingSet/tools/manual-timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const setup = () => {
* kernel. You can make time pass by calling `advanceTo(when)`.
*
* @param {{ startTime?: Timestamp }} [options]
* @returns {TimerService & { advanceTo: (when: Timestamp) => void; }}
* @returns {TimerService & { advanceTo: (when: Timestamp) => bigint; }}
*/
export const buildManualTimer = (options = {}) => {
const { startTime = 0n, ...other } = options;
Expand All @@ -79,6 +79,7 @@ export const buildManualTimer = (options = {}) => {
assert(when > state.now, `advanceTo(${when}) < current ${state.now}`);
state.now = when;
wake();
return when;
};

return Far('ManualTimer', { ...bindAllMethods(timerService), advanceTo });
Expand Down
9 changes: 1 addition & 8 deletions packages/access-token/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"noEmit": true,
"strictNullChecks": true,
"noImplicitThis": true,
"moduleResolution": "node",
},
"extends": "../../tsconfig.json",
"include": [
"src/**/*.js",
"test/**/*.js"
Expand Down
8 changes: 2 additions & 6 deletions packages/agoric-cli/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// This file can contain .js-specific Typescript compiler config.
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"noEmit": true,
"strictNullChecks": true,
"noImplicitThis": true,
"moduleResolution": "node",
"checkJs": false,
},
"include": [
"*.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@endo/promise-kit": "^0.2.52",
"@iarna/toml": "^2.2.3",
"anylogger": "^0.21.0",
"chalk": "^2.4.2",
"chalk": "^5.2.0",
"commander": "^10.0.0",
"dd-trace": "^3.3.0",
"deterministic-json": "^1.0.5",
Expand Down
9 changes: 1 addition & 8 deletions packages/assert/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"noEmit": true,
"strictNullChecks": true,
"noImplicitThis": true,
"moduleResolution": "node",
},
"extends": "../../tsconfig.json",
"include": [
"src/**/*.js",
],
Expand Down
4 changes: 2 additions & 2 deletions packages/assert/src/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (globalAssert === undefined) {
);
}

const missing = [
const missing = /** @type {const} */ ([
'fail',
'equal',
'typeof',
Expand All @@ -43,7 +43,7 @@ const missing = [
'Fail',
'quote',
'makeAssert',
].filter(name => globalAssert[name] === undefined);
]).filter(name => globalAssert[name] === undefined);
if (missing.length > 0) {
throw new Error(
`Cannot initialize @agoric/assert, missing globalThis.assert methods ${missing.join(
Expand Down
10 changes: 1 addition & 9 deletions packages/cache/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"checkJs": true,
"noEmit": true,
"strictNullChecks": true,
"noImplicitThis": true,
"moduleResolution": "node",
},
"extends": "../../tsconfig.json",
"include": [
"*.js",
"public/**/*.js",
Expand Down
10 changes: 1 addition & 9 deletions packages/casting/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"checkJs": true,
"noEmit": true,
"strictNullChecks": true,
"noImplicitThis": true,
"moduleResolution": "node",
},
"extends": "../../tsconfig.json",
"include": [
"*.js",
"public/**/*.js",
Expand Down
12 changes: 6 additions & 6 deletions packages/casting/src/follower.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Far } from '@endo/far';
import {
mapAsyncIterable,
makeNotifierIterable,
makeSubscriptionIterable,
subscribeEach,
subscribeLatest,
} from './iterable.js';
import { makeCosmjsFollower } from './follower-cosmjs.js';
import { makeCastingSpec } from './casting-spec.js';
Expand All @@ -20,10 +20,10 @@ const makeSubscriptionFollower = spec => {
const { notifier, subscription } = await spec;
let ai;
if (notifier) {
ai = makeNotifierIterable(notifier);
ai = subscribeLatest(notifier);
} else {
assert(subscription);
ai = makeSubscriptionIterable(subscription);
ai = subscribeEach(subscription);
}
return mapAsyncIterable(ai, transform);
},
Expand All @@ -32,10 +32,10 @@ const makeSubscriptionFollower = spec => {
const { notifier, subscription } = await spec;
let ai;
if (subscription) {
ai = makeSubscriptionIterable(subscription);
ai = subscribeEach(subscription);
} else {
assert(notifier);
ai = makeNotifierIterable(notifier);
ai = subscribeLatest(notifier);
}
return mapAsyncIterable(ai, transform);
},
Expand Down
43 changes: 1 addition & 42 deletions packages/casting/src/iterable.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,6 @@
import { E, Far } from '@endo/far';
import { makeNotifier } from '@agoric/notifier';

/**
* @template T
* @param {ERef<Notifier<T>>} notifier
* @returns {ConsistentAsyncIterable<T>}
*/
export const makeNotifierIterable = notifier =>
makeNotifier(E(notifier).getSharableNotifierInternals());

/**
* TODO: Remove this function when we have an @endo/publish-kit that suppports pull topics
*
* @template T
* @param {ERef<PublicationRecord<T>>} tailP
* @returns {AsyncIterator<T>}
*/
const makeSubscriptionIterator = tailP => {
// To understand the implementation, start with
// https://web.archive.org/web/20160404122250/http://wiki.ecmascript.org/doku.php?id=strawman:concurrency#infinite_queue
return Far('SubscriptionIterator', {
next: async () => {
const resultP = E.get(tailP).head;
tailP = E.get(tailP).tail;
return resultP;
},
});
};

/**
* TODO: Remove this function when we have an @endo/publish-kit that suppports pull topics
*
* @template T
* @param {ERef<Subscription<T>>} subscription
* @returns {ConsistentAsyncIterable<T>}
*/
export const makeSubscriptionIterable = subscription =>
harden({
[Symbol.asyncIterator]: () =>
makeSubscriptionIterator(
E(subscription).getSharableSubscriptionInternals(),
),
});
export { subscribeEach, subscribeLatest } from '@agoric/notifier/subscribe.js';

/**
* @template TIn
Expand Down
6 changes: 1 addition & 5 deletions packages/cosmic-proto/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": false,
"declaration": true,
"target": "esnext",
"module": "esnext",
"allowSyntheticDefaultImports": true,
"strictNullChecks": true,
"noImplicitThis": true,
"moduleResolution": "node",
"outDir": "dist"
},
"include": [
Expand Down
8 changes: 2 additions & 6 deletions packages/cosmic-swingset/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// This file can contain .js-specific Typescript compiler config.
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"noEmit": true,
"strictNullChecks": true,
"noImplicitThis": true,
"moduleResolution": "node",
"checkJs": false,
},
"include": [
"calc-*.js",
Expand Down
9 changes: 1 addition & 8 deletions packages/deploy-script-support/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"noEmit": true,
"strictNullChecks": true,
"noImplicitThis": true,
"moduleResolution": "node",
},
"extends": "../../tsconfig.json",
"include": [
"*.js",
"src/**/*.js",
Expand Down
Loading

0 comments on commit 2effb18

Please sign in to comment.