Skip to content

Commit

Permalink
refactor: modernize @endo/errors @agoric/store imports
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Jan 21, 2024
1 parent 01baa28 commit 2d4114f
Show file tree
Hide file tree
Showing 145 changed files with 427 additions and 259 deletions.
2 changes: 2 additions & 0 deletions packages/ERTP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"@agoric/notifier": "^0.6.2",
"@agoric/store": "^0.9.2",
"@agoric/vat-data": "^0.5.2",
"@endo/errors": "^1.0.2",
"@endo/eventual-send": "^1.1.0",
"@endo/exo": "^1.1.0",
"@endo/far": "^1.0.2",
"@endo/marshal": "^1.1.0",
"@endo/nat": "^5.0.2",
Expand Down
5 changes: 2 additions & 3 deletions packages/ERTP/src/amountMath.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { quote as q, throwRedacted as Fail } from '@endo/errors';
import { passStyleOf, assertRemotable, assertRecord } from '@endo/marshal';
import { M, matches } from '@endo/patterns';

import { M, matches } from '@agoric/store';
import { natMathHelpers } from './mathHelpers/natMathHelpers.js';
import { setMathHelpers } from './mathHelpers/setMathHelpers.js';
import { copySetMathHelpers } from './mathHelpers/copySetMathHelpers.js';
import { copyBagMathHelpers } from './mathHelpers/copyBagMathHelpers.js';

const { quote: q, Fail } = assert;

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

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

import { DisplayInfoShape } from './typeGuards.js';

Expand Down
4 changes: 2 additions & 2 deletions packages/ERTP/src/issuerKit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @jessie-check

import { assert } from '@agoric/assert';
import { assertPattern } from '@agoric/store';
import { assert } from '@endo/errors';
import { assertPattern } from '@endo/patterns';
import { makeScalarBigMapStore } from '@agoric/vat-data';

import { AssetKind, assertAssetKind } from './amountMath.js';
Expand Down
6 changes: 3 additions & 3 deletions packages/ERTP/src/legacy-payment-helpers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @jessie-check

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

const { Fail } = assert;
import { AmountMath } from './amountMath.js';

/**
* @file This file contains safer helper function alternatives to the similarly
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/src/mathHelpers/copyBagMathHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
bagIsSuperbag,
bagUnion,
bagDisjointSubtract,
} from '@agoric/store';
} from '@endo/patterns';
import '../types-ambient.js';

/** @type {CopyBag} */
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/src/mathHelpers/copySetMathHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
setIsSuperset,
setDisjointUnion,
setDisjointSubtract,
} from '@agoric/store';
} from '@endo/patterns';
import '../types-ambient.js';

/** @type {CopySet} */
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 { throwRedacted as Fail } from '@endo/errors';
import { Nat, isNat } from '@endo/nat';

import '../types-ambient.js';

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

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/src/mathHelpers/setMathHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
elementsDisjointSubtract,
coerceToElements,
elementsCompare,
} from '@agoric/store';
} from '@endo/patterns';
import '../types-ambient.js';

// Operations for arrays with unique objects identifying and providing
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/src/payment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @jessie-check

import { initEmpty } from '@agoric/store';
import { initEmpty } from '@endo/exo';
import { prepareExoClass } from '@agoric/vat-data';

/** @typedef {import('@endo/patterns').MethodGuard} MethodGuard */
Expand Down
13 changes: 9 additions & 4 deletions packages/ERTP/src/paymentLedger.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
// @jessie-check

/* eslint-disable no-use-before-define */
import {
redacted as X,
quote as q,
throwRedacted as Fail,
note as errorNote,
} from '@endo/errors';
import { isPromise } from '@endo/promise-kit';
import { mustMatch, M, keyEQ } from '@agoric/store';
import { mustMatch, M, keyEQ } from '@endo/patterns';

import {
provideDurableWeakMapStore,
prepareExo,
Expand All @@ -17,8 +24,6 @@ import { BrandI, makeIssuerInterfaces } from './typeGuards.js';

/** @typedef {import('@agoric/vat-data').Baggage} Baggage */

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

/**
* @param {Brand} brand
* @param {AssetKind} assetKind
Expand Down Expand Up @@ -131,7 +136,7 @@ export const preparePaymentLedger = (
try {
optShutdownWithFailure(reason);
} catch (errInShutdown) {
assert.note(errInShutdown, X`Caused by: ${reason}`);
errorNote(errInShutdown, X`Caused by: ${reason}`);
throw errInShutdown;
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/ERTP/src/purse.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { M } from '@agoric/store';
import { throwRedacted as Fail } from '@endo/errors';
import { M } from '@endo/patterns';

import { prepareExoClassKit, makeScalarBigSetStore } from '@agoric/vat-data';
import { AmountMath } from './amountMath.js';
import { makeTransientNotifierKit } from './transientNotifier.js';
Expand All @@ -7,8 +9,6 @@ import { makeTransientNotifierKit } from './transientNotifier.js';
/** @typedef {import('@endo/patterns').InterfaceGuard} InterfaceGuard */
/** @typedef {import('@agoric/vat-data').Baggage} Baggage */

const { Fail } = assert;

/**
* @param {Baggage} issuerBaggage
* @param {string} name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { makeTagged } from '@endo/marshal';
import {
getCopyBagEntries,
makeCopyBagFromElements as makeBag,
} from '@agoric/store';
} from '@endo/patterns';

import { AmountMath as m, AssetKind } from '../../../src/index.js';
import { mockBrand } from './mockBrand.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
import { getCopySetKeys, makeCopySet } from '@agoric/store';

import { getCopySetKeys, makeCopySet } from '@endo/patterns';

import { AmountMath as m, AssetKind } from '../../../src/index.js';
import { mockBrand } from './mockBrand.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
import { M } from '@agoric/store';

import { Far } from '@endo/marshal';
import { M } from '@endo/patterns';

import { AmountMath as m, AssetKind } from '../../../src/index.js';
import { mockBrand } from './mockBrand.js';

Expand Down
3 changes: 2 additions & 1 deletion packages/ERTP/test/unitTests/test-amountProperties.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
import { makeCopyBag } from '@agoric/store';

import { makeCopyBag } from '@endo/patterns';
import { fc } from '@fast-check/ava';

import { AmountMath as m, AssetKind } from '../../src/index.js';
Expand Down
5 changes: 3 additions & 2 deletions packages/ERTP/test/unitTests/test-mintObj.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';

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

import { defineDurableKind, makeKindHandle } from '@agoric/vat-data';
import { makeIssuerKit, AssetKind, AmountMath } from '../../src/index.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/test/unitTests/test-recovery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
import { getCopySetKeys, keyEQ, makeCopySet } from '@agoric/store';
import { getCopySetKeys, keyEQ, makeCopySet } from '@endo/patterns';

import { makeIssuerKit, AmountMath } from '../../src/index.js';

Expand Down
3 changes: 3 additions & 0 deletions packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@
"@agoric/xsnap-lockdown": "^0.14.0",
"@endo/base64": "^1.0.1",
"@endo/bundle-source": "^3.0.2",
"@endo/common": "^1.0.2",
"@endo/captp": "^4.0.2",
"@endo/check-bundle": "^1.0.2",
"@endo/compartment-mapper": "^1.1.0",
"@endo/errors": "^1.0.2",
"@endo/eventual-send": "^1.1.0",
"@endo/exo": "^1.1.0",
"@endo/far": "^1.0.2",
"@endo/import-bundle": "^1.0.2",
"@endo/init": "^1.0.2",
Expand Down
7 changes: 4 additions & 3 deletions packages/SwingSet/src/controller/initializeSwingset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import fs from 'fs';
import path from 'path';

import { assert, Fail } from '@agoric/assert';
import { makeTracer } from '@agoric/internal';
import { mustMatch } from '@agoric/store';
import { assert, throwRedacted as Fail } from '@endo/errors';
import bundleSource from '@endo/bundle-source';
import { mustMatch } from '@endo/patterns';

import { makeTracer } from '@agoric/internal';
import { resolve as resolveModuleSpecifier } from 'import-meta-resolve';
import { ManagerType } from '../typeGuards.js';
import { provideBundleCache } from '../../tools/bundleTool.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/typeGuards.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @jessie-check
import { M } from '@agoric/store';
import { M } from '@endo/patterns';

export const ManagerType = M.or(
'xsnap',
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/upgrade/test-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { test } from '../../tools/prepare-test-env-ava.js';

import { assert } from '@agoric/assert';
import bundleSource from '@endo/bundle-source';
import { objectMap } from '@agoric/internal';
import { objectMap } from '@endo/common/object-map.js';
import { kser, kunser, krefOf } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';
import { parseReachableAndVatSlot } from '../../src/kernel/state/reachable.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/upgrade/vat-ulrik-1.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Far, E } from '@endo/far';
import { makePromiseKit } from '@endo/promise-kit';
import { initEmpty } from '@agoric/store';
import { initEmpty } from '@endo/exo';
import {
makeKindHandle,
defineDurableKind,
Expand Down
5 changes: 3 additions & 2 deletions packages/SwingSet/test/upgrade/vat-ulrik-2.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Far, E } from '@endo/far';
import { assert } from '@agoric/assert';
import { initEmpty } from '@agoric/store';
import { assert } from '@endo/errors';
import { initEmpty } from '@endo/exo';

import { defineDurableKind, defineDurableKindMulti } from '@agoric/vat-data';

const initialize = (name, imp, value) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/SwingSet/test/vat-exporter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Far } from '@endo/far';
import { M, defineExoClass } from '@agoric/store';
import { M } from '@endo/patterns';
import { defineExoClass } from '@endo/exo';

import {
defineVirtualExoClass,
prepareExoClass,
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/virtualObjects/vat-orphan-bob.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Far } from '@endo/far';
import { initEmpty } from '@agoric/store';
import { initEmpty } from '@endo/exo';
import { defineKind, defineKindMulti } from '@agoric/vat-data';

const { getPrototypeOf } = Object;
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/tools/bootstrap-relay.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from '@agoric/assert';
import { objectMap } from '@agoric/internal';
import { objectMap } from '@endo/common/object-map.js';
import { Far, E } from '@endo/far';
import { buildManualTimer } from './manual-timer.js';

Expand Down
3 changes: 2 additions & 1 deletion packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@
"@cosmjs/proto-signing": "^0.30.1",
"@cosmjs/stargate": "^0.30.1",
"@endo/bundle-source": "^3.0.2",
"@endo/captp": "^4.0.2",
"@endo/common": "^1.0.2",
"@endo/compartment-mapper": "^1.1.0",
"@endo/captp": "^4.0.2",
"@endo/far": "^1.0.2",
"@endo/init": "^1.0.2",
"@endo/marshal": "^1.1.0",
Expand Down
5 changes: 2 additions & 3 deletions packages/agoric-cli/src/commands/inter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

// @ts-check
import { CommanderError, InvalidArgumentError } from 'commander';
// TODO: should get M from endo https://github.com/Agoric/agoric-sdk/issues/7090
import { objectMap } from '@endo/common/object-map.js';
import { M, matches } from '@endo/patterns';
import { makeOfferSpecShape } from '@agoric/inter-protocol/src/auction/auctionBook.js';
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
import { objectMap } from '@agoric/internal';
import { M, matches } from '@agoric/store';

import { normalizeAddressWithOptions, pollBlocks } from '../lib/chain.js';
import {
Expand Down
1 change: 1 addition & 0 deletions packages/base-zone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"license": "Apache-2.0",
"dependencies": {
"@agoric/store": "^0.9.2",
"@endo/errors": "^1.0.2",
"@endo/exo": "^1.1.0",
"@endo/far": "^1.0.2",
"@endo/pass-style": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/base-zone/src/make-once.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
const { Fail } = assert;
import { throwRedacted as Fail } from '@endo/errors';

/** @param {string} label */
const defaultLabelToKeys = label => harden([label]);
Expand Down
1 change: 1 addition & 0 deletions packages/boot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@endo/eventual-send": "^1.1.0",
"@endo/init": "^1.0.2",
"@endo/far": "^1.0.2",
"@endo/patterns": "^1.1.0",
"@endo/promise-kit": "^1.0.2",
"@endo/stream": "^1.0.2",
"import-meta-resolve": "^2.2.1"
Expand Down
6 changes: 4 additions & 2 deletions packages/boot/test/bootstrapTests/zcfProbe.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import '@agoric/zoe/exported.js';

import { makeTracer } from '@agoric/internal';
import { E } from '@endo/far';
import { M } from '@endo/patterns';

import { makeTracer } from '@agoric/internal';
import {
atomicRearrange,
provideAll,
} from '@agoric/zoe/src/contractSupport/index.js';
import { M, prepareExoClass, provide } from '@agoric/vat-data';
import { prepareExoClass, provide } from '@agoric/vat-data';
import { AmountMath } from '@agoric/ertp';

const trace = makeTracer('ZCF Probe');
Expand Down
3 changes: 2 additions & 1 deletion packages/boot/test/test-boot-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { promises as fsPromises } from 'fs';
import { resolve as importMetaResolve } from 'import-meta-resolve';
import path from 'path';

import { mustMatch } from '@endo/patterns';

import { extractCoreProposalBundles } from '@agoric/deploy-script-support/src/extract-proposal.js';
import { mustMatch } from '@agoric/store';
import { loadSwingsetConfigFile, shape as ssShape } from '@agoric/swingset-vat';
import { provideBundleCache } from '@agoric/swingset-vat/tools/bundleTool.js';

Expand Down
1 change: 1 addition & 0 deletions packages/builders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@agoric/vats": "^0.15.1",
"@agoric/zoe": "^0.26.2",
"@endo/bundle-source": "^3.0.2",
"@endo/common": "^1.0.2",
"@endo/captp": "^4.0.2",
"@endo/eventual-send": "^1.1.0",
"@endo/far": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/scripts/inter-protocol/init-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* chain state) Only works with "local" chain and not sim-chain b/c it needs
* governance votes (n/a on sim-chain).
*/
import { objectMap } from '@endo/common/object-map.js';
import { makeHelpers } from '@agoric/deploy-script-support';
import { objectMap } from '@agoric/internal';

import {
getManifestForInterProtocol,
Expand Down
Loading

0 comments on commit 2d4114f

Please sign in to comment.