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

refactor: use @endo/errors #9513

Merged
merged 31 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
271d05e
fix: endow with original unstructured assert
erights Jun 15, 2024
ae69296
fixup! add type comment
erights Jun 15, 2024
00619c6
fixup! moved from #9513
erights Jun 16, 2024
63793b3
refactor: use @endo/errors
erights Jun 15, 2024
e8beb42
fixup! NonNullish in internal
erights Jun 15, 2024
76b01b1
fixup! semi-manual mostly import QuickFix
erights Jun 15, 2024
537e990
fixup! lint driven manual fixes
erights Jun 15, 2024
b1ec7a0
fixup! revert CHANGELOG.md
erights Jun 15, 2024
e733280
fixup! restore weird automated comment motion
erights Jun 15, 2024
8635da2
fixup! revert mystery jessie directive text
erights Jun 15, 2024
af1a547
fixup! revert mystery ts-check directive text
erights Jun 15, 2024
3c130a4
fixup! manually fixed some unnecessary "as"s
erights Jun 15, 2024
f643c89
fixup! canonical short forms
erights Jun 15, 2024
8edee70
fixup! track-turns init order note
erights Jun 15, 2024
22f3527
fixup! missing Details type
erights Jun 15, 2024
456958f
fixup! remove packages/assert from CI
erights Jun 15, 2024
10dfe06
fixup! somehow missed device-bundle.js
erights Jun 16, 2024
e1bd82a
fixup! more details to X
erights Jun 16, 2024
c275682
Merge branch 'master' into markm-5672-endo-errors-2
erights Jun 17, 2024
0d8ce53
Merge branch 'master' into markm-5672-endo-errors-2
erights Jul 1, 2024
457d10a
fixup! merge repair
erights Jul 1, 2024
f5c6f1c
fixup! newlines
erights Jul 1, 2024
a73fcb1
Merge branch 'master' into markm-5672-endo-errors-2
erights Jul 1, 2024
4142e21
fixup! review clarification
erights Jul 1, 2024
b80921f
fixup! review suggestions
erights Jul 1, 2024
cbdd8c1
fixup! layered import order
erights Jul 1, 2024
0f2ea4d
fixup! layered import order
erights Jul 2, 2024
e1b7b96
fixup! layered import order
erights Jul 2, 2024
23731b0
Merge branch 'master' into markm-5672-endo-errors-2
erights Jul 2, 2024
e7824d8
Merge branch 'master' into markm-5672-endo-errors-2
erights Jul 2, 2024
2a07b36
Merge branch 'master' into markm-5672-endo-errors-2
mergify[bot] Jul 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 0 additions & 3 deletions .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ jobs:
- name: yarn test (access-token)
if: (success() || failure())
run: cd packages/access-token && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT
- name: yarn test (assert)
if: (success() || failure())
run: cd packages/assert && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT
- name: yarn test (benchmark)
if: (success() || failure())
run: cd packages/benchmark && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT
Expand Down
2 changes: 1 addition & 1 deletion a3p-integration/proposals/c:stake-bld/test-lib/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// @ts-check
/* global Buffer */

import { Fail } from '@endo/errors';
import {
boardSlottingMarshaller,
makeBoardRemote,
} from '@agoric/internal/src/marshal.js';
import { Fail } from '@endo/errors';

export { boardSlottingMarshaller };

Expand Down
2 changes: 1 addition & 1 deletion multichain-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"packageManager": "yarn@4.1.1",
"devDependencies": {
"@agoric/assert": "^0.6.0",
"@endo/errors": "^1.2.2",
"@agoric/cosmic-proto": "0.4.1-dev-08f8549.0",
"@cosmjs/crypto": "^0.32.2",
"@cosmjs/proto-signing": "^0.32.2",
Expand Down
2 changes: 1 addition & 1 deletion multichain-testing/tools/batchQuery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert } from '@agoric/assert';
import { assert } from '@endo/errors';
import { E } from '@endo/far';

/** @typedef {'children' | 'data'} AgoricChainStoragePathKind */
Expand Down
2 changes: 1 addition & 1 deletion multichain-testing/tools/e2e-tools.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** global harden */
import { assert } from '@agoric/assert';
import { assert } from '@endo/errors';
import { E, Far } from '@endo/far';
import { Nat } from '@endo/nat';
import { makePromiseKit } from '@endo/promise-kit';
Expand Down
2 changes: 1 addition & 1 deletion multichain-testing/tools/makeHttpClient.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert } from '@agoric/assert';
import { assert } from '@endo/errors';
import { Far } from '@endo/far';

const { freeze } = Object;
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
"dependencies": {
"@agoric/assert": "^0.6.0",
"@endo/errors": "^1.2.2",
"@agoric/notifier": "^0.6.2",
"@agoric/store": "^0.9.2",
"@agoric/vat-data": "^0.5.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/ERTP/src/amountMath.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { q, Fail } from '@endo/errors';
import { passStyleOf, assertRemotable, assertRecord } from '@endo/marshal';

import { M, matches } from '@agoric/store';
Expand All @@ -11,8 +12,6 @@ import { copyBagMathHelpers } from './mathHelpers/copyBagMathHelpers.js';
* @import {Amount, AssetKind, AmountValue, AssetKindForValue, AssetValueForKind, Brand, CopyBagAmount, CopySetAmount, MathHelpers, NatAmount, NatValue, SetAmount, SetValue} from './types.js';
*/

const { quote: q, Fail } = assert;

/**
* Constants for the kinds of assets we support.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/src/displayInfo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @jessie-check

import { Fail } from '@agoric/assert';
import { Fail } from '@endo/errors';
import { mustMatch } from '@agoric/store';

import { DisplayInfoShape } from './typeGuards.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/src/issuerKit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @jessie-check

import { assert, Fail } from '@agoric/assert';
import { assert, Fail } from '@endo/errors';
import { assertPattern } from '@agoric/store';
import { makeScalarBigMapStore } from '@agoric/vat-data';
import { makeDurableZone } from '@agoric/zone/durable.js';
Expand Down
5 changes: 2 additions & 3 deletions packages/ERTP/src/legacy-payment-helpers.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// @jessie-check

import { mustMatch } from '@agoric/store';
import { Fail } from '@endo/errors';
import { E } from '@endo/far';
import { mustMatch } from '@agoric/store';
import { AmountMath } from './amountMath.js';

/**
* @import {ERef} from '@endo/far');
* @import {Amount, AssetKind, AmountValue, AssetKindForValue, Payment, Brand, Purse} from './types.js'
*/

const { Fail } = assert;

/**
* @file This file contains safer helper function alternatives to the similarly
* named methods on issuer. These are parameterized by a purse used for
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/src/mathHelpers/natMathHelpers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @jessie-check

import { Fail } from '@endo/errors';
import { Nat, isNat } from '@endo/nat';

/** @import {MathHelpers, NatValue} from '../types.js' */

const { Fail } = assert;
const empty = 0n;

/**
Expand Down
5 changes: 2 additions & 3 deletions packages/ERTP/src/paymentLedger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/// <reference types="@agoric/store/exported.js" />

/* eslint-disable no-use-before-define */
import { X, q, Fail, annotateError } from '@endo/errors';
import { isPromise } from '@endo/promise-kit';
import { mustMatch, M, keyEQ } from '@agoric/store';
import { AmountMath } from './amountMath.js';
Expand All @@ -17,8 +18,6 @@ import { BrandI, makeIssuerInterfaces } from './typeGuards.js';
* @import {Key} from '@endo/patterns';
*/

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

/**
* @param {Brand} brand
* @param {AssetKind} assetKind
Expand Down Expand Up @@ -133,7 +132,7 @@ export const preparePaymentLedger = (
try {
optShutdownWithFailure(reason);
} catch (errInShutdown) {
assert.note(errInShutdown, X`Caused by: ${reason}`);
annotateError(errInShutdown, X`Caused by: ${reason}`);
throw errInShutdown;
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/ERTP/src/purse.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Fail } from '@endo/errors';
import { M, makeCopySet } from '@agoric/store';
import { AmountMath } from './amountMath.js';
import { makeTransientNotifierKit } from './transientNotifier.js';
import { makeAmountStore } from './amountStore.js';

/** @import {Amount, AssetKind, AmountValue, AssetKindForValue, RecoverySetsOption, Brand, Payment} from './types.js' */

const { Fail } = assert;

const EMPTY_COPY_SET = makeCopySet([]);

// TODO Type InterfaceGuard better than InterfaceGuard<any>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { E } from '@endo/eventual-send';
import { assert, details as X } from '@agoric/assert';
import { assert, X } from '@endo/errors';
import { Far } from '@endo/marshal';
import { makeIssuerKit, AmountMath } from '../../../src/index.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';

import { assert } from '@agoric/assert';
import { assert } from '@endo/errors';
import { buildVatController } from '@agoric/swingset-vat';

const bfile = name => new URL(name, import.meta.url).pathname;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { E } from '@endo/eventual-send';
import { assert, details as X } from '@agoric/assert';
import { assert, X } from '@endo/errors';
import { Far } from '@endo/marshal';
import { makeIssuerKit, AmountMath } from '../../../src/index.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/test/unitTests/mintObj.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';

import { assert } from '@endo/errors';
import { initEmpty, M } from '@agoric/store';
import { assert } from '@agoric/assert';

import { defineDurableKind, makeKindHandle } from '@agoric/vat-data';
import { makeIssuerKit, AssetKind, AmountMath } from '../../src/index.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/yargs-parser": "^21.0.0"
},
"dependencies": {
"@agoric/assert": "^0.6.0",
"@endo/errors": "^1.2.2",
"@agoric/internal": "^0.3.2",
"@agoric/kmarshal": "^0.1.0",
"@agoric/store": "^0.9.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { tmpName } from 'tmp';
import anylogger from 'anylogger';
import microtime from 'microtime';

import { assert, Fail } from '@agoric/assert';
import { assert, Fail } from '@endo/errors';
import { importBundle } from '@endo/import-bundle';
import { initSwingStore } from '@agoric/swing-store';

Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/controller/initializeKernel.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-use-before-define */

import { assert, Fail } from '@endo/errors';
import { makeMarshal } from '@endo/marshal';
import { Far } from '@endo/far';
import { assert, Fail } from '@agoric/assert';
import { kser, kunser } from '@agoric/kmarshal';
import { assertKnownOptions } from '../lib/assertOptions.js';
import { insistVatID } from '../lib/id.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/controller/initializeSwingset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import fs from 'fs';
import path from 'path';

import { assert, Fail } from '@agoric/assert';
import { assert, Fail } from '@endo/errors';
import { makeTracer } from '@agoric/internal';
import { mustMatch } from '@agoric/store';
import bundleSource from '@endo/bundle-source';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/controller/startXSnap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { Fail } from '@agoric/assert';
import { Fail } from '@endo/errors';
import { type as osType } from 'os';
import { xsnap, recordXSnap } from '@agoric/xsnap';

Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/bridge/device-bridge.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fail } from '@agoric/assert';
import { Fail } from '@endo/errors';
import { Far } from '@endo/far';

function sanitize(data) {
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/bundle/device-bundle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert } from '@agoric/assert';
import { assert } from '@endo/errors';
import { buildSerializationTools } from '../lib/deviceTools.js';

/*
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/src/devices/command/command.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Fail } from '@endo/errors';
import { makePromiseKit } from '@endo/promise-kit';
import { Nat } from '@endo/nat';

import { Fail } from '@agoric/assert';

export default function buildCommand(broadcastCallback) {
broadcastCallback || Fail`broadcastCallback must be provided.`;
let inboundCallback;
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/src/devices/command/device-command.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Fail } from '@endo/errors';
import { Nat } from '@endo/nat';
import { Far } from '@endo/far';

import { Fail } from '@agoric/assert';

export function buildRootDeviceNode(tools) {
const { SO, getDeviceState, setDeviceState, endowments } = tools;
const { registerInboundCallback, deliverResponse, sendBroadcast } =
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/lib/deviceTools.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, Fail } from '@agoric/assert';
import { assert, Fail } from '@endo/errors';
import { makeMarshal } from '@endo/marshal';
import { Far } from '@endo/far';
import { parseVatSlot } from '../../lib/parseVatSlots.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/loopbox/device-loopbox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fail } from '@agoric/assert';
import { Fail } from '@endo/errors';
import { Far } from '@endo/far';

export function buildRootDeviceNode(tools) {
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/loopbox/loopbox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fail } from '@agoric/assert';
import { Fail } from '@endo/errors';

/*
* The "loopbox" is a special device used for unit tests, which glues one
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/src/devices/mailbox/device-mailbox.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { assert, Fail } from '@endo/errors';
import { Nat } from '@endo/nat';
import { Far } from '@endo/far';

import { assert, Fail } from '@agoric/assert';

export function buildRootDeviceNode(tools) {
const { SO, getDeviceState, setDeviceState, endowments } = tools;

Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/src/devices/mailbox/mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@

*/

import { Fail } from '@endo/errors';
import { Nat } from '@endo/nat';

import { Fail } from '@agoric/assert';

// This Map-based mailboxState object is a good starting point, but we may
// replace it with one that tracks which parts of the state have been
// modified, to build more efficient Merkle proofs.
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/plugin/device-plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Fail } from '@endo/errors';
import { makeCapTP } from '@endo/captp';
import { Far } from '@endo/far';
import { Fail } from '@agoric/assert';

export function buildRootDeviceNode(tools) {
const { SO, getDeviceState, setDeviceState, endowments } = tools;
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/timer/device-timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { Nat } from '@endo/nat';
import { assert, Fail } from '@agoric/assert';
import { assert, Fail } from '@endo/errors';
import { Far } from '@endo/far';

// Since we use harden when saving the state, we need to copy the arrays so they
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/timer/timer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Nat } from '@endo/nat';

import { Fail } from '@agoric/assert';
import { Fail } from '@endo/errors';

/**
* Endowments for a Timer device that can be made available to SwingSet vats.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Nat } from '@endo/nat';
import { assert } from '@agoric/assert';
import { assert } from '@endo/errors';
import { kunser } from '@agoric/kmarshal';
import { buildSerializationTools } from '../lib/deviceTools.js';
import { insistVatID } from '../../lib/id.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/deviceManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, Fail } from '@agoric/assert';
import { assert, Fail } from '@endo/errors';
import { makeDeviceSlots } from './deviceSlots.js';
import { insistCapData } from '../lib/capdata.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/deviceSlots.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Remotable, makeMarshal } from '@endo/marshal';
import { passStyleOf } from '@endo/far';
import { assert, Fail } from '@agoric/assert';
import { assert, Fail } from '@endo/errors';
import {
insistVatType,
makeVatSlot,
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/deviceTranslator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-nocheck
import { assert, Fail } from '@agoric/assert';
import { assert, Fail } from '@endo/errors';
import { insistMessage } from '../lib/message.js';
import { insistKernelType } from './parseKernelSlots.js';
import { insistVatType, parseVatSlot } from '../lib/parseVatSlots.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/dummyMeterControl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert } from '@agoric/assert';
import { assert } from '@endo/errors';

export function makeDummyMeterControl() {
let meteringDisabled = 0;
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/gc-actions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fail } from '@agoric/assert';
import { Fail } from '@endo/errors';
import { insistKernelType } from './parseKernelSlots.js';
import { insistVatID } from '../lib/id.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global globalThis */

import { assert, Fail } from '@agoric/assert';
import { assert, Fail } from '@endo/errors';
import { isNat } from '@endo/nat';
import { importBundle } from '@endo/import-bundle';
import { makeUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/kernelSyscall.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, Fail } from '@agoric/assert';
import { assert, Fail } from '@endo/errors';
import { insistKernelType } from './parseKernelSlots.js';
import { insistCapData } from '../lib/capdata.js';
import { insistDeviceID, insistVatID } from '../lib/id.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/parseKernelSlots.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Nat } from '@endo/nat';
import { assert, Fail } from '@agoric/assert';
import { assert, Fail } from '@endo/errors';

// Object/promise references (in the kernel) contain a two-tuple of (type,
// index). All object references point to entries in the kernel Object
Expand Down
Loading
Loading