diff --git a/packages/ERTP/src/amountMath.js b/packages/ERTP/src/amountMath.js index 5d6a12c459f..c71faeab2e1 100644 --- a/packages/ERTP/src/amountMath.js +++ b/packages/ERTP/src/amountMath.js @@ -1,6 +1,6 @@ // @ts-check -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { Far } from '@agoric/marshal'; import { mustBeComparable } from '@agoric/same-structure'; @@ -87,7 +87,7 @@ function makeAmountMath(brand, amountMathKind) { const helpers = mathHelpers[amountMathKind]; assert( helpers !== undefined, - details`unrecognized amountMathKind: ${amountMathKind}`, + X`unrecognized amountMathKind: ${amountMathKind}`, ); // Cache the amount if we can. @@ -126,11 +126,11 @@ function makeAmountMath(brand, amountMathKind) { const { brand: allegedBrand, value } = allegedAmount; assert( allegedBrand !== undefined, - details`The brand in allegedAmount ${allegedAmount} is undefined. Did you pass a value rather than an amount?`, + X`The brand in allegedAmount ${allegedAmount} is undefined. Did you pass a value rather than an amount?`, ); assert( brand === allegedBrand, - details`The brand in the allegedAmount ${allegedAmount} in 'coerce' didn't match the amountMath brand ${brand}.`, + X`The brand in the allegedAmount ${allegedAmount} in 'coerce' didn't match the amountMath brand ${brand}.`, ); // Will throw on inappropriate value return amountMath.make(value); diff --git a/packages/ERTP/src/displayInfo.js b/packages/ERTP/src/displayInfo.js index 0857c00e297..0a2012cbd52 100644 --- a/packages/ERTP/src/displayInfo.js +++ b/packages/ERTP/src/displayInfo.js @@ -1,4 +1,4 @@ -import { assert, details, q } from '@agoric/assert'; +import { assert, details as X, q } from '@agoric/assert'; import { pureCopy, passStyleOf, @@ -21,7 +21,7 @@ export const assertSubset = (whole, part) => { assert.typeof(key, 'string'); assert( whole.includes(key), - details`key ${q(key)} was not one of the expected keys ${q(whole)}`, + X`key ${q(key)} was not one of the expected keys ${q(whole)}`, ); }); }; @@ -35,7 +35,7 @@ export const assertKeysAllowed = (allowedKeys, record) => { // assert that there are no symbol properties. assert( Object.getOwnPropertySymbols(record).length === 0, - details`no symbol properties allowed`, + X`no symbol properties allowed`, ); }; diff --git a/packages/ERTP/src/issuer.js b/packages/ERTP/src/issuer.js index 174f212bd81..490d7059723 100644 --- a/packages/ERTP/src/issuer.js +++ b/packages/ERTP/src/issuer.js @@ -2,7 +2,7 @@ // @ts-check -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { makeExternalStore } from '@agoric/store'; import { E } from '@agoric/eventual-send'; import { Far } from '@agoric/marshal'; @@ -56,10 +56,7 @@ function makeIssuerKit( const paymentLedger = makePaymentWeakStore(); function assertKnownPayment(payment) { - assert( - paymentLedger.has(payment), - details`payment not found for ${allegedName}`, - ); + assert(paymentLedger.has(payment), X`payment not found for ${allegedName}`); } // Methods like deposit() have an optional second parameter `amount` @@ -69,7 +66,7 @@ function makeIssuerKit( if (amount !== undefined) { assert( amountMath.isEqual(amount, paymentBalance), - details`payment balance ${paymentBalance} must equal amount ${amount}`, + X`payment balance ${paymentBalance} must equal amount ${amount}`, ); } }; diff --git a/packages/ERTP/src/mathHelpers/setMathHelpers.js b/packages/ERTP/src/mathHelpers/setMathHelpers.js index f924ed64916..0a13d590ad2 100644 --- a/packages/ERTP/src/mathHelpers/setMathHelpers.js +++ b/packages/ERTP/src/mathHelpers/setMathHelpers.js @@ -1,7 +1,7 @@ // @ts-check import { passStyleOf } from '@agoric/marshal'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { sameStructure } from '@agoric/same-structure'; import '../types'; @@ -43,7 +43,7 @@ const checkForDupes = buckets => { for (let j = i + 1; j < maybeMatches.length; j += 1) { assert( !sameStructure(maybeMatches[i], maybeMatches[j]), - details`value has duplicates: ${maybeMatches[i]} and ${maybeMatches[j]}`, + X`value has duplicates: ${maybeMatches[i]} and ${maybeMatches[j]}`, ); } } @@ -92,7 +92,7 @@ const setMathHelpers = harden({ right.forEach(rightElem => { assert( hasElement(leftBuckets, rightElem), - details`right element ${rightElem} was not in left`, + X`right element ${rightElem} was not in left`, ); }); const leftElemNotInRight = leftElem => !hasElement(rightBuckets, leftElem); diff --git a/packages/ERTP/src/mathHelpers/strSetMathHelpers.js b/packages/ERTP/src/mathHelpers/strSetMathHelpers.js index 812f24b1adf..fb65dc9b668 100644 --- a/packages/ERTP/src/mathHelpers/strSetMathHelpers.js +++ b/packages/ERTP/src/mathHelpers/strSetMathHelpers.js @@ -1,13 +1,13 @@ // @ts-check import { passStyleOf } from '@agoric/marshal'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; const identity = harden([]); const checkForDupes = list => { const set = new Set(list); - assert(set.size === list.length, details`value has duplicates: ${list}`); + assert(set.size === list.length, X`value has duplicates: ${list}`); }; /** @@ -43,10 +43,7 @@ const strSetMathHelpers = harden({ doAdd: (left, right) => { const union = new Set(left); const addToUnion = elem => { - assert( - !union.has(elem), - details`left and right have same element ${elem}`, - ); + assert(!union.has(elem), X`left and right have same element ${elem}`); union.add(elem); }; right.forEach(addToUnion); @@ -58,7 +55,7 @@ const strSetMathHelpers = harden({ const allRemovedCorrectly = right.every(remove); assert( allRemovedCorrectly, - details`some of the elements in right (${right}) were not present in left (${left})`, + X`some of the elements in right (${right}) were not present in left (${left})`, ); return harden(Array.from(leftSet)); }, diff --git a/packages/ERTP/test/swingsetTests/splitPayments/bootstrap.js b/packages/ERTP/test/swingsetTests/splitPayments/bootstrap.js index 666d58568dd..33455bbf991 100644 --- a/packages/ERTP/test/swingsetTests/splitPayments/bootstrap.js +++ b/packages/ERTP/test/swingsetTests/splitPayments/bootstrap.js @@ -1,9 +1,10 @@ import { E } from '@agoric/eventual-send'; +import { assert, details as X } from '@agoric/assert'; import { makeIssuerKit } from '../../../src'; -const { details: X } = assert; - export function buildRootObject(vatPowers, vatParameters) { + const arg0 = vatParameters.argv[0]; + function testSplitPayments(aliceMaker) { vatPowers.testLog('start test splitPayments'); const { mint: moolaMint, issuer, amountMath } = makeIssuerKit('moola'); @@ -14,15 +15,14 @@ export function buildRootObject(vatPowers, vatParameters) { } const obj0 = { - // eslint-disable-next-line consistent-return async bootstrap(vats) { - switch (vatParameters.argv[0]) { + switch (arg0) { case 'splitPayments': { const aliceMaker = await E(vats.alice).makeAliceMaker(); return testSplitPayments(aliceMaker); } default: { - assert.fail(X`unrecognized argument value ${vatParameters.argv[0]}`); + assert.fail(X`unrecognized argument value ${arg0}`); } } }, diff --git a/packages/SwingSet/src/capdata.js b/packages/SwingSet/src/capdata.js index 8e88d813788..ce8dc149cd4 100644 --- a/packages/SwingSet/src/capdata.js +++ b/packages/SwingSet/src/capdata.js @@ -1,4 +1,4 @@ -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; /* eslint-disable jsdoc/valid-types,jsdoc/require-returns-check */ /** @@ -15,11 +15,11 @@ export function insistCapData(capdata) { assert.typeof( capdata.body, 'string', - details`capdata has non-string .body ${capdata.body}`, + X`capdata has non-string .body ${capdata.body}`, ); assert( Array.isArray(capdata.slots), - details`capdata has non-Array slots ${capdata.slots}`, + X`capdata has non-Array slots ${capdata.slots}`, ); // TODO check that the .slots array elements are actually strings } diff --git a/packages/SwingSet/src/devices/bridge-src.js b/packages/SwingSet/src/devices/bridge-src.js index 8b0cb94e2ef..4e9f0d287ce 100644 --- a/packages/SwingSet/src/devices/bridge-src.js +++ b/packages/SwingSet/src/devices/bridge-src.js @@ -1,4 +1,4 @@ -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; function sanitize(data) { // TODO: Use @agoric/marshal:pureCopy when it exists. diff --git a/packages/SwingSet/src/devices/command-src.js b/packages/SwingSet/src/devices/command-src.js index f2031d1f92c..917bccc0175 100644 --- a/packages/SwingSet/src/devices/command-src.js +++ b/packages/SwingSet/src/devices/command-src.js @@ -1,6 +1,6 @@ import Nat from '@agoric/nat'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootDeviceNode(tools) { const { SO, getDeviceState, setDeviceState, endowments } = tools; diff --git a/packages/SwingSet/src/devices/command.js b/packages/SwingSet/src/devices/command.js index 5bafed5be59..233afe6bcbb 100644 --- a/packages/SwingSet/src/devices/command.js +++ b/packages/SwingSet/src/devices/command.js @@ -1,7 +1,7 @@ import Nat from '@agoric/nat'; import { makePromiseKit } from '@agoric/promise-kit'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export default function buildCommand(broadcastCallback) { assert(broadcastCallback, X`broadcastCallback must be provided.`); @@ -46,10 +46,9 @@ export default function buildCommand(broadcastCallback) { if (kResponseString !== undefined) { obj = JSON.parse(`${kResponseString}`); } - if (!responses.has(count)) { - // maybe just ignore it - assert.fail(X`unknown response index ${count}`); - } + // TODO this might not qualify as an error, it needs more thought + // See https://github.com/Agoric/agoric-sdk/pull/2406#discussion_r575561554 + assert(responses.has(count), X`unknown response index ${count}`); const { resolve, reject } = responses.get(count); if (isReject) { reject(obj); diff --git a/packages/SwingSet/src/devices/loopbox-src.js b/packages/SwingSet/src/devices/loopbox-src.js index 0d61b54c2f7..9f6c02956ee 100644 --- a/packages/SwingSet/src/devices/loopbox-src.js +++ b/packages/SwingSet/src/devices/loopbox-src.js @@ -1,4 +1,4 @@ -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootDeviceNode(tools) { const { SO, endowments } = tools; diff --git a/packages/SwingSet/src/devices/loopbox.js b/packages/SwingSet/src/devices/loopbox.js index f3275871f93..4fefb5d2039 100644 --- a/packages/SwingSet/src/devices/loopbox.js +++ b/packages/SwingSet/src/devices/loopbox.js @@ -1,4 +1,4 @@ -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; /* * The "loopbox" is a special device used for unit tests, which glues one diff --git a/packages/SwingSet/src/devices/mailbox-src.js b/packages/SwingSet/src/devices/mailbox-src.js index 91d75b3ebf2..90b5d8093b3 100644 --- a/packages/SwingSet/src/devices/mailbox-src.js +++ b/packages/SwingSet/src/devices/mailbox-src.js @@ -1,6 +1,6 @@ import Nat from '@agoric/nat'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootDeviceNode(tools) { const { SO, getDeviceState, setDeviceState, endowments } = tools; diff --git a/packages/SwingSet/src/devices/mailbox.js b/packages/SwingSet/src/devices/mailbox.js index 3df6a3e023f..11896369929 100644 --- a/packages/SwingSet/src/devices/mailbox.js +++ b/packages/SwingSet/src/devices/mailbox.js @@ -66,7 +66,7 @@ import Nat from '@agoric/nat'; -const { details: X } = assert; +import { assert, details as X } 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 @@ -135,11 +135,11 @@ export function buildMailboxStateMap(state = harden(new Map())) { assert(!state.size, X`cannot populateFromData: outbox is not empty`); for (const peer of Object.getOwnPropertyNames(data)) { const inout = getOrCreatePeer(peer); - const dp = data[peer]; + const d = data[peer]; importMailbox( { - ack: dp.inboundAck, - outbox: dp.outbox, + ack: d.inboundAck, + outbox: d.outbox, }, inout, ); diff --git a/packages/SwingSet/src/devices/plugin-src.js b/packages/SwingSet/src/devices/plugin-src.js index 857b876d471..f1a140eac82 100644 --- a/packages/SwingSet/src/devices/plugin-src.js +++ b/packages/SwingSet/src/devices/plugin-src.js @@ -2,7 +2,7 @@ import { makeCapTP } from '@agoric/captp'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootDeviceNode(tools) { const { SO, getDeviceState, setDeviceState, endowments } = tools; diff --git a/packages/SwingSet/src/devices/timer-src.js b/packages/SwingSet/src/devices/timer-src.js index 8785f52dd18..193e98a6d6f 100644 --- a/packages/SwingSet/src/devices/timer-src.js +++ b/packages/SwingSet/src/devices/timer-src.js @@ -23,7 +23,7 @@ */ import Nat from '@agoric/nat'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; // Since we use harden when saving the state, we need to copy the arrays so they // will continue to be mutable. each record inside handlers is immutable, so we @@ -229,7 +229,7 @@ export function buildRootDeviceNode(tools) { function updateTime(time) { assert( time >= lastPolled, - details`Time is monotonic. ${time} cannot be less than ${lastPolled}`, + X`Time is monotonic. ${time} cannot be less than ${lastPolled}`, ); lastPolled = time; saveState(); diff --git a/packages/SwingSet/src/devices/timer.js b/packages/SwingSet/src/devices/timer.js index 13ca0ffc6e0..2770ae5baf7 100644 --- a/packages/SwingSet/src/devices/timer.js +++ b/packages/SwingSet/src/devices/timer.js @@ -1,6 +1,6 @@ import Nat from '@agoric/nat'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; /** * Endowments for a Timer device that can be made available to SwingSet vats. diff --git a/packages/SwingSet/src/hostStorage.js b/packages/SwingSet/src/hostStorage.js index 13c3ba87cf0..7316b57bd61 100644 --- a/packages/SwingSet/src/hostStorage.js +++ b/packages/SwingSet/src/hostStorage.js @@ -1,6 +1,6 @@ import { initSwingStore } from '@agoric/swing-store-simple'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; /* The "Storage API" is a set of functions { has, getKeys, get, set, delete } that diff --git a/packages/SwingSet/src/kernel/id.js b/packages/SwingSet/src/kernel/id.js index 81ba802c2ff..24d4af54617 100644 --- a/packages/SwingSet/src/kernel/id.js +++ b/packages/SwingSet/src/kernel/id.js @@ -1,6 +1,6 @@ import Nat from '@agoric/nat'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; // Vats are identified by an integer index, which (for typechecking purposes) // is encoded as `vNN`. Devices are similarly identified as `dNN`. Both have diff --git a/packages/SwingSet/src/kernel/kdebug.js b/packages/SwingSet/src/kernel/kdebug.js index 67541ad6553..3b950d2df74 100644 --- a/packages/SwingSet/src/kernel/kdebug.js +++ b/packages/SwingSet/src/kernel/kdebug.js @@ -1,4 +1,4 @@ -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; let enableKDebug = false; diff --git a/packages/SwingSet/src/kernel/vatManager/deliver.js b/packages/SwingSet/src/kernel/vatManager/deliver.js index 2a20d1fe8d1..e4e2feb22a0 100644 --- a/packages/SwingSet/src/kernel/vatManager/deliver.js +++ b/packages/SwingSet/src/kernel/vatManager/deliver.js @@ -1,7 +1,6 @@ +import { assert, details as X } from '@agoric/assert'; import { insistMessage } from '../../message'; -const { details: X } = assert; - export function makeDeliver(tools, dispatch) { const { meterRecord, diff --git a/packages/SwingSet/src/kernel/vatManager/manager-subprocess-xsnap.js b/packages/SwingSet/src/kernel/vatManager/manager-subprocess-xsnap.js index 9b293a3a4cc..55ac58cf6c5 100644 --- a/packages/SwingSet/src/kernel/vatManager/manager-subprocess-xsnap.js +++ b/packages/SwingSet/src/kernel/vatManager/manager-subprocess-xsnap.js @@ -1,13 +1,11 @@ // @ts-check -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { makeTranscriptManager } from './transcript'; import { createSyscall } from './syscall'; import '../../types'; import './types'; -const { details: X } = assert; - // eslint-disable-next-line no-unused-vars function parentLog(first, ...args) { // console.error(`--parent: ${first}`, ...args); @@ -134,7 +132,7 @@ export function makeXsSubprocessFactory({ parentLog(vatID, 'eval bundle', it); assert( superCode.moduleFormat === 'getExport', - details`${it} unexpected: ${superCode.moduleFormat}`, + X`${it} unexpected: ${superCode.moduleFormat}`, ); await worker.evaluate(`(${superCode.source}\n)()`.trim()); } diff --git a/packages/SwingSet/src/kernel/vatManager/supervisor-subprocess-xsnap.js b/packages/SwingSet/src/kernel/vatManager/supervisor-subprocess-xsnap.js index 05124448f9c..8e88bb76701 100644 --- a/packages/SwingSet/src/kernel/vatManager/supervisor-subprocess-xsnap.js +++ b/packages/SwingSet/src/kernel/vatManager/supervisor-subprocess-xsnap.js @@ -1,5 +1,5 @@ // @ts-check -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { importBundle } from '@agoric/import-bundle'; import { Remotable, getInterfaceOf, makeMarshal } from '@agoric/marshal'; // grumble... waitUntilQuiescent is exported and closes over ambient authority @@ -7,8 +7,6 @@ import { waitUntilQuiescent } from '../../waitUntilQuiescent'; import { makeLiveSlots } from '../liveSlots'; -const { details: X } = assert; - const encoder = new TextEncoder(); const decoder = new TextDecoder(); @@ -38,8 +36,8 @@ function managerPort(issueCommand) { function decode(msg) { /** @type { Tagged } */ const item = decodeData(msg); - assert(Array.isArray(item), details`expected array`); - assert(item.length > 0, details`empty array lacks tag`); + assert(Array.isArray(item), X`expected array`); + assert(item.length > 0, X`empty array lacks tag`); return item; } diff --git a/packages/SwingSet/src/message.js b/packages/SwingSet/src/message.js index 65a76c7bf90..810e495863f 100644 --- a/packages/SwingSet/src/message.js +++ b/packages/SwingSet/src/message.js @@ -1,4 +1,4 @@ -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { insistCapData } from './capdata'; /** @@ -18,14 +18,14 @@ export function insistMessage(message) { assert.typeof( message.method, 'string', - details`message has non-string .method ${message.method}`, + X`message has non-string .method ${message.method}`, ); insistCapData(message.args); if (message.result) { assert.typeof( message.result, 'string', - details`message has non-string non-null .result ${message.result}`, + X`message has non-string non-null .result ${message.result}`, ); } } diff --git a/packages/SwingSet/src/netstring.js b/packages/SwingSet/src/netstring.js index e12c4d94d90..b6ead9dd2d4 100644 --- a/packages/SwingSet/src/netstring.js +++ b/packages/SwingSet/src/netstring.js @@ -1,8 +1,8 @@ +import { assert, details as X, q } from '@agoric/assert'; + // adapted from 'netstring-stream', https://github.com/tlivings/netstring-stream/ const { Transform } = require('stream'); -const { details: X, quote: q } = assert; - const COLON = 58; const COMMA = 44; diff --git a/packages/SwingSet/src/storageAPI.js b/packages/SwingSet/src/storageAPI.js index c519ddd8308..8e91793579b 100644 --- a/packages/SwingSet/src/storageAPI.js +++ b/packages/SwingSet/src/storageAPI.js @@ -1,4 +1,4 @@ -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; /** * Assert function to ensure that something expected to be a storage object diff --git a/packages/SwingSet/src/vats/vat-timerWrapper.js b/packages/SwingSet/src/vats/vat-timerWrapper.js index 34e00fd937c..29eaf42d4e6 100644 --- a/packages/SwingSet/src/vats/vat-timerWrapper.js +++ b/packages/SwingSet/src/vats/vat-timerWrapper.js @@ -1,5 +1,5 @@ import Nat from '@agoric/nat'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { makeNotifierKit } from '@agoric/notifier'; export function buildRootObject(vatPowers) { @@ -28,7 +28,7 @@ export function buildRootObject(vatPowers) { Nat(delaySecs); assert( Nat(interval) > 0, - details`makeRepeater's second parameter must be a positive integer: ${interval}`, + X`makeRepeater's second parameter must be a positive integer: ${interval}`, ); const index = D(timerNode).makeRepeater(delaySecs, interval); @@ -49,7 +49,7 @@ export function buildRootObject(vatPowers) { Nat(delaySecs); assert( Nat(interval) > 0, - details`makeNotifier's second parameter must be a positive integer: ${interval}`, + X`makeNotifier's second parameter must be a positive integer: ${interval}`, ); const index = D(timerNode).makeRepeater(delaySecs, interval); diff --git a/packages/SwingSet/test/basedir-promises-2/bootstrap.js b/packages/SwingSet/test/basedir-promises-2/bootstrap.js index 9dbe4d14255..ab0d9d835a3 100644 --- a/packages/SwingSet/test/basedir-promises-2/bootstrap.js +++ b/packages/SwingSet/test/basedir-promises-2/bootstrap.js @@ -1,7 +1,7 @@ import { E } from '@agoric/eventual-send'; import { makePromiseKit } from '@agoric/promise-kit'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootObject(vatPowers, vatParameters) { const log = vatPowers.testLog; diff --git a/packages/SwingSet/test/basedir-promises/bootstrap.js b/packages/SwingSet/test/basedir-promises/bootstrap.js index 54ae31356c8..3d1a5607630 100644 --- a/packages/SwingSet/test/basedir-promises/bootstrap.js +++ b/packages/SwingSet/test/basedir-promises/bootstrap.js @@ -1,7 +1,7 @@ import { E } from '@agoric/eventual-send'; import { makePromiseKit } from '@agoric/promise-kit'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootObject(vatPowers, vatParameters) { const log = vatPowers.testLog; diff --git a/packages/SwingSet/test/basedir-transcript/bootstrap.js b/packages/SwingSet/test/basedir-transcript/bootstrap.js index 86d24e69732..83ab4014d49 100644 --- a/packages/SwingSet/test/basedir-transcript/bootstrap.js +++ b/packages/SwingSet/test/basedir-transcript/bootstrap.js @@ -1,6 +1,6 @@ import { E } from '@agoric/eventual-send'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootObject(vatPowers, vatParameters) { return harden({ diff --git a/packages/SwingSet/test/device-plugin/bootstrap.js b/packages/SwingSet/test/device-plugin/bootstrap.js index 135f271d905..0ee66a925e0 100644 --- a/packages/SwingSet/test/device-plugin/bootstrap.js +++ b/packages/SwingSet/test/device-plugin/bootstrap.js @@ -1,8 +1,7 @@ import { E } from '@agoric/eventual-send'; +import { assert, details as X } from '@agoric/assert'; import { makePluginManager } from '../../src/vats/plugin-manager'; -const { details: X } = assert; - export function buildRootObject(vatPowers, vatParameters) { const { D } = vatPowers; const log = vatPowers.testLog; diff --git a/packages/SwingSet/test/device-plugin/vat-bridge.js b/packages/SwingSet/test/device-plugin/vat-bridge.js index f1f5b0216af..da019271890 100644 --- a/packages/SwingSet/test/device-plugin/vat-bridge.js +++ b/packages/SwingSet/test/device-plugin/vat-bridge.js @@ -1,6 +1,6 @@ import { E } from '@agoric/eventual-send'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootObject(vatPowers, _vatParameters) { const log = vatPowers.testLog; diff --git a/packages/SwingSet/test/files-devices/bootstrap-1.js b/packages/SwingSet/test/files-devices/bootstrap-1.js index b25b93be73e..5c569d65948 100644 --- a/packages/SwingSet/test/files-devices/bootstrap-1.js +++ b/packages/SwingSet/test/files-devices/bootstrap-1.js @@ -1,4 +1,4 @@ -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export default function setup(syscall, state, _helpers, vatPowers) { const { testLog } = vatPowers; diff --git a/packages/SwingSet/test/files-devices/bootstrap-2.js b/packages/SwingSet/test/files-devices/bootstrap-2.js index 4701d5ec6c1..c2748f9da95 100644 --- a/packages/SwingSet/test/files-devices/bootstrap-2.js +++ b/packages/SwingSet/test/files-devices/bootstrap-2.js @@ -1,6 +1,6 @@ import { E } from '@agoric/eventual-send'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootObject(vatPowers, vatParameters) { const { D, testLog: log } = vatPowers; diff --git a/packages/SwingSet/test/files-devices/bootstrap-3.js b/packages/SwingSet/test/files-devices/bootstrap-3.js index daf0f68bd77..c6e646b37ce 100644 --- a/packages/SwingSet/test/files-devices/bootstrap-3.js +++ b/packages/SwingSet/test/files-devices/bootstrap-3.js @@ -1,4 +1,4 @@ -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootObject(vatPowers, vatParameters) { const { D, testLog: log } = vatPowers; diff --git a/packages/SwingSet/test/files-vattp/bootstrap-test-vattp.js b/packages/SwingSet/test/files-vattp/bootstrap-test-vattp.js index 5bbfdf1dc8c..e4e25190d3b 100644 --- a/packages/SwingSet/test/files-vattp/bootstrap-test-vattp.js +++ b/packages/SwingSet/test/files-vattp/bootstrap-test-vattp.js @@ -1,6 +1,6 @@ import { E } from '@agoric/eventual-send'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootObject(vatPowers, vatParameters) { const { D, testLog: log } = vatPowers; diff --git a/packages/SwingSet/test/test-kernel.js b/packages/SwingSet/test/test-kernel.js index 3d8575e65f0..7085c7e1a8a 100644 --- a/packages/SwingSet/test/test-kernel.js +++ b/packages/SwingSet/test/test-kernel.js @@ -2,6 +2,7 @@ import '@agoric/install-ses'; import test from 'ava'; import anylogger from 'anylogger'; import { initSwingStore } from '@agoric/swing-store-simple'; +import { assert, details as X } from '@agoric/assert'; import { WeakRef, FinalizationRegistry } from '../src/weakref'; import { waitUntilQuiescent } from '../src/waitUntilQuiescent'; @@ -10,8 +11,6 @@ import { initializeKernel } from '../src/kernel/initializeKernel'; import { makeVatSlot } from '../src/parseVatSlots'; import { checkKT } from './util'; -const { details: X } = assert; - function capdata(body, slots = []) { return harden({ body, slots }); } diff --git a/packages/SwingSet/test/test-liveslots.js b/packages/SwingSet/test/test-liveslots.js index 1281b83a3c2..d32e05d944a 100644 --- a/packages/SwingSet/test/test-liveslots.js +++ b/packages/SwingSet/test/test-liveslots.js @@ -2,12 +2,11 @@ import '@agoric/install-ses'; import test from 'ava'; import { E } from '@agoric/eventual-send'; import { Far } from '@agoric/marshal'; +import { assert, details as X } from '@agoric/assert'; import { WeakRef, FinalizationRegistry } from '../src/weakref'; import { waitUntilQuiescent } from '../src/waitUntilQuiescent'; import { makeLiveSlots } from '../src/kernel/liveSlots'; -const { details: X } = assert; - function capdata(body, slots = []) { return harden({ body, slots }); } diff --git a/packages/SwingSet/test/test-vpid-kernel.js b/packages/SwingSet/test/test-vpid-kernel.js index cd12e44ccb9..e64e6bb95ff 100644 --- a/packages/SwingSet/test/test-vpid-kernel.js +++ b/packages/SwingSet/test/test-vpid-kernel.js @@ -2,6 +2,7 @@ import '@agoric/install-ses'; import test from 'ava'; import anylogger from 'anylogger'; import { initSwingStore } from '@agoric/swing-store-simple'; +import { assert, details as X } from '@agoric/assert'; import { WeakRef, FinalizationRegistry } from '../src/weakref'; import { waitUntilQuiescent } from '../src/waitUntilQuiescent'; @@ -10,8 +11,6 @@ import { initializeKernel } from '../src/kernel/initializeKernel'; import { buildDispatch } from './util'; -const { details: X } = assert; - function capdata(body, slots = []) { return harden({ body, slots }); } @@ -391,9 +390,9 @@ async function doTest4567(t, which, mode) { await kernel.start(undefined); // no bootstrapVatName, so no bootstrap call // vatA is our primary actor let onDispatchCallback; - function odc(dp) { + function odc(d) { if (onDispatchCallback) { - onDispatchCallback(dp); + onDispatchCallback(d); } } const { log: logA, getSyscall: getSyscallA } = await buildRawVat( @@ -546,8 +545,8 @@ async function doTest4567(t, which, mode) { localTarget: localTargetA, p1: dataPromiseA, }; - onDispatchCallback = function odc1(dp) { - t.deepEqual(dp, resolutionOf(p1VatA, mode, targetsA)); + onDispatchCallback = function odc1(d) { + t.deepEqual(d, resolutionOf(p1VatA, mode, targetsA)); t.is(inCList(kernel, vatA, p1kernel, p1VatA), false); }; const targetsB = { diff --git a/packages/SwingSet/test/test-vpid-liveslots.js b/packages/SwingSet/test/test-vpid-liveslots.js index 89bc3762b63..38d478a4075 100644 --- a/packages/SwingSet/test/test-vpid-liveslots.js +++ b/packages/SwingSet/test/test-vpid-liveslots.js @@ -6,11 +6,10 @@ import test from 'ava'; import { E } from '@agoric/eventual-send'; import { makePromiseKit } from '@agoric/promise-kit'; +import { assert, details as X } from '@agoric/assert'; import { WeakRef, FinalizationRegistry } from '../src/weakref'; import { makeLiveSlots } from '../src/kernel/liveSlots'; -const { details: X } = assert; - function capdata(body, slots = []) { return harden({ body, slots }); } diff --git a/packages/SwingSet/test/timer-device/bootstrap.js b/packages/SwingSet/test/timer-device/bootstrap.js index 76da48bacf0..c8b31f73f93 100644 --- a/packages/SwingSet/test/timer-device/bootstrap.js +++ b/packages/SwingSet/test/timer-device/bootstrap.js @@ -1,4 +1,4 @@ -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootObject(vatPowers, vatParameters) { const { D } = vatPowers; diff --git a/packages/SwingSet/test/vat-admin/bootstrap.js b/packages/SwingSet/test/vat-admin/bootstrap.js index e7c0af1f740..11408f44982 100644 --- a/packages/SwingSet/test/vat-admin/bootstrap.js +++ b/packages/SwingSet/test/vat-admin/bootstrap.js @@ -1,6 +1,6 @@ import { E } from '@agoric/eventual-send'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export function buildRootObject(vatPowers, vatParameters) { const log = vatPowers.testLog; diff --git a/packages/agoric-cli/lib/main.js b/packages/agoric-cli/lib/main.js index c63940b2b00..a2dc0735356 100644 --- a/packages/agoric-cli/lib/main.js +++ b/packages/agoric-cli/lib/main.js @@ -1,5 +1,6 @@ import { Command } from 'commander'; +import { assert, details as X } from '@agoric/assert'; import cosmosMain from './cosmos'; import deployMain from './deploy'; import initMain from './init'; @@ -8,8 +9,6 @@ import setDefaultsMain from './set-defaults'; import startMain from './start'; import walletMain from './open'; -const { details: X } = assert; - const DEFAULT_DAPP_TEMPLATE = 'dapp-fungible-faucet'; const DEFAULT_DAPP_URL_BASE = 'git://github.com/Agoric/'; @@ -77,13 +76,12 @@ const main = async (progname, rawArgs, powers) => { '--repl [yes | only | no]', 'whether to show the Read-eval-print loop [yes]', value => { - if (['yes', 'only', 'no'].includes(value)) { - return value; - } - assert.fail( + assert( + ['yes', 'only', 'no'].includes(value), X`--repl must be one of 'yes', 'no', or 'only'`, TypeError, ); + return value; }, ) .action(async cmd => { diff --git a/packages/agoric-cli/lib/open.js b/packages/agoric-cli/lib/open.js index 570084c2ffc..bfe5659c056 100644 --- a/packages/agoric-cli/lib/open.js +++ b/packages/agoric-cli/lib/open.js @@ -5,7 +5,7 @@ import path from 'path'; import { openSwingStore } from '@agoric/swing-store-simple'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; // Adapted from https://stackoverflow.com/a/43866992/14073862 export function generateAccessToken({ diff --git a/packages/agoric-cli/lib/set-defaults.js b/packages/agoric-cli/lib/set-defaults.js index b12b1aa188c..5a512a88fc8 100644 --- a/packages/agoric-cli/lib/set-defaults.js +++ b/packages/agoric-cli/lib/set-defaults.js @@ -1,12 +1,11 @@ import { basename } from 'path'; +import { assert, details as X } from '@agoric/assert'; import { finishCosmosApp, finishCosmosConfig, finishCosmosGenesis, } from './chain-config'; -const { details: X } = assert; - export default async function setDefaultsMain(progname, rawArgs, powers, opts) { const { anylogger, fs } = powers; const log = anylogger('agoric:set-defaults'); diff --git a/packages/agoric-cli/package.json b/packages/agoric-cli/package.json index 6a237ce17a4..63af498f08a 100644 --- a/packages/agoric-cli/package.json +++ b/packages/agoric-cli/package.json @@ -26,6 +26,7 @@ "tmp": "^0.1.0" }, "dependencies": { + "@agoric/assert": "^0.2.0", "@agoric/bundle-source": "^1.2.0", "@agoric/captp": "^1.7.0", "@agoric/install-ses": "^0.5.0", diff --git a/packages/cosmic-swingset/calc-rpcport.js b/packages/cosmic-swingset/calc-rpcport.js index 5cf30027fb0..78175ef47e2 100755 --- a/packages/cosmic-swingset/calc-rpcport.js +++ b/packages/cosmic-swingset/calc-rpcport.js @@ -1,11 +1,11 @@ #!/usr/bin/env node +// NOTE: Runs outside SES + const process = require('process'); const fs = require('fs'); const toml = require('@iarna/toml'); -const { details: X } = assert; - // point this at ~/.ag-cosmos-chain/config/config.toml const configString = fs.readFileSync(process.argv[2]).toString(); @@ -13,7 +13,9 @@ const config = toml.parse(configString); const { laddr } = config.rpc; // like tcp://0.0.0.0:26657 // eslint-disable-next-line no-useless-escape const m = laddr.match(/^tcp:\/\/([\d\.]+):(\d+)$/); -assert(m, X`error, unexpected laddr format ${laddr}`); +if (!m) { + throw new Error(`error, unexpected laddr format ${laddr}`); +} let addr = m[1]; if (addr === '0.0.0.0') { addr = '127.0.0.1'; diff --git a/packages/cosmic-swingset/lib/ag-solo/add-chain.js b/packages/cosmic-swingset/lib/ag-solo/add-chain.js index 17a75ab4555..0e41eaee601 100644 --- a/packages/cosmic-swingset/lib/ag-solo/add-chain.js +++ b/packages/cosmic-swingset/lib/ag-solo/add-chain.js @@ -4,10 +4,9 @@ import djson from 'deterministic-json'; import path from 'path'; import fs from 'fs'; +import { assert, details as X } from '@agoric/assert'; import setGCIIngress from './set-gci-ingress'; -const { details: X } = assert; - const DEFAULT_CHAIN_CONFIG = 'https://testnet.agoric.com/network-config'; /** diff --git a/packages/cosmic-swingset/lib/ag-solo/chain-cosmos-sdk.js b/packages/cosmic-swingset/lib/ag-solo/chain-cosmos-sdk.js index f2220fabf99..92565d23281 100644 --- a/packages/cosmic-swingset/lib/ag-solo/chain-cosmos-sdk.js +++ b/packages/cosmic-swingset/lib/ag-solo/chain-cosmos-sdk.js @@ -9,10 +9,9 @@ import anylogger from 'anylogger'; import { makeNotifierKit } from '@agoric/notifier'; import { makePromiseKit } from '@agoric/promise-kit'; +import { assert, details as X } from '@agoric/assert'; import { makeBatchedDeliver } from './batched-deliver'; -const { details: X } = assert; - const log = anylogger('chain-cosmos-sdk'); const HELPER = 'ag-cosmos-helper'; @@ -112,7 +111,6 @@ export async function connectToChain( throwIfCancelled = () => undefined, defaultIfCancelled = WAS_CANCELLED_EXCEPTION, ) { - // eslint-disable-next-line consistent-return return retryRpcAddr(async rpcAddr => { await throwIfCancelled(); diff --git a/packages/cosmic-swingset/lib/ag-solo/fake-chain.js b/packages/cosmic-swingset/lib/ag-solo/fake-chain.js index 96915b823b4..d7377a1a1b9 100644 --- a/packages/cosmic-swingset/lib/ag-solo/fake-chain.js +++ b/packages/cosmic-swingset/lib/ag-solo/fake-chain.js @@ -9,13 +9,12 @@ import { import anylogger from 'anylogger'; +import { assert, details as X } from '@agoric/assert'; import { launch } from '../launch-chain'; import makeBlockManager from '../block-manager'; import { makeWithQueue } from './vats/queue'; import { makeBatchedDeliver } from './batched-deliver'; -const { details: X } = assert; - const log = anylogger('fake-chain'); const PRETEND_BLOCK_DELAY = 5; diff --git a/packages/cosmic-swingset/lib/ag-solo/html/main.js b/packages/cosmic-swingset/lib/ag-solo/html/main.js index 86aa28c2700..fa4bdb6bd00 100644 --- a/packages/cosmic-swingset/lib/ag-solo/html/main.js +++ b/packages/cosmic-swingset/lib/ag-solo/html/main.js @@ -1,4 +1,4 @@ -const { details: X } = assert; +// NOTE: Runs outside SES /* global WebSocket fetch document window walletFrame localStorage */ const RECONNECT_BACKOFF_SECONDS = 3; @@ -65,7 +65,7 @@ function run() { if (j.ok) { return j.res; } - assert.fail(X`server error: ${JSON.stringify(j.rej)}`); + throw new Error(`server error: ${JSON.stringify(j.rej)}`); } const protocol = window.location.protocol.replace(/^http/, 'ws'); @@ -302,7 +302,9 @@ run(); const fetches = []; const fgr = fetch('/git-revision.txt') .then(resp => { - assert(resp.status >= 200 && resp.status < 300, X`status ${resp.status}`); + if (resp.status < 200 || resp.status >= 300) { + throw Error(`status ${resp.status}`); + } return resp.text(); }) .then(text => { @@ -329,7 +331,9 @@ if ( ) { fetch(`wallet/${accessTokenParams}`) .then(resp => { - assert(resp.status >= 200 && resp.status < 300, X`status ${resp.status}`); + if (resp.status < 200 || resp.status >= 300) { + throw Error(`status ${resp.status}`); + } walletFrame.style.display = 'block'; walletFrame.src = `wallet/#${accessTokenParams.slice(1)}`; }) diff --git a/packages/cosmic-swingset/lib/ag-solo/outbound.js b/packages/cosmic-swingset/lib/ag-solo/outbound.js index f26419e464b..fe6f1ecbc09 100644 --- a/packages/cosmic-swingset/lib/ag-solo/outbound.js +++ b/packages/cosmic-swingset/lib/ag-solo/outbound.js @@ -1,6 +1,6 @@ import anylogger from 'anylogger'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; const log = anylogger('outbound'); diff --git a/packages/cosmic-swingset/lib/ag-solo/start.js b/packages/cosmic-swingset/lib/ag-solo/start.js index c8becac2cf0..70e12c5307f 100644 --- a/packages/cosmic-swingset/lib/ag-solo/start.js +++ b/packages/cosmic-swingset/lib/ag-solo/start.js @@ -279,7 +279,7 @@ export default async function start(basedir, argv) { const vatsDir = path.join(basedir, 'vats'); const stateDBDir = path.join(basedir, 'swingset-kernel-state'); - const dp = await buildSwingset( + const d = await buildSwingset( stateDBDir, mailboxStateFile, vatsDir, @@ -293,7 +293,7 @@ export default async function start(basedir, argv) { deliverOutbound, startTimer, resetOutdatedState, - } = dp; + } = d; // Remove wallet traces. await unlink('html/wallet').catch(_ => {}); diff --git a/packages/cosmic-swingset/lib/ag-solo/upload-contract.js b/packages/cosmic-swingset/lib/ag-solo/upload-contract.js index 64cb29a2cbf..1b1f037a940 100644 --- a/packages/cosmic-swingset/lib/ag-solo/upload-contract.js +++ b/packages/cosmic-swingset/lib/ag-solo/upload-contract.js @@ -6,7 +6,7 @@ import { E } from '@agoric/eventual-send'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export default async function uploadContracts({ home, bundle }) { console.error(`Installing targeted contracts...`); diff --git a/packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js b/packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js index c6d156e41bf..f494e6f7725 100644 --- a/packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js +++ b/packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js @@ -9,11 +9,10 @@ import { E } from '@agoric/eventual-send'; // this will return { undefined } until `ag-solo set-gci-ingress` // has been run to update gci.js import { makePluginManager } from '@agoric/swingset-vat/src/vats/plugin-manager'; +import { assert, details as X } from '@agoric/assert'; import { GCI } from './gci'; import { makeBridgeManager } from './bridge'; -const { details: X } = assert; - const NUM_IBC_PORTS = 3; const CENTRAL_ISSUER_NAME = 'Testnet.$USD'; const QUOTE_INTERVAL = 30; diff --git a/packages/cosmic-swingset/lib/ag-solo/vats/lib-board.js b/packages/cosmic-swingset/lib/ag-solo/vats/lib-board.js index 8656d0c5768..eed4db85abd 100644 --- a/packages/cosmic-swingset/lib/ag-solo/vats/lib-board.js +++ b/packages/cosmic-swingset/lib/ag-solo/vats/lib-board.js @@ -1,7 +1,7 @@ // @ts-check import { generateSparseInts } from '@agoric/sparse-ints'; -import { assert, details, q } from '@agoric/assert'; +import { assert, details as X, q } from '@agoric/assert'; import makeStore from '@agoric/store'; import { models as crcmodels } from 'polycrc'; @@ -57,10 +57,10 @@ function makeBoard(seed = 0) { return valToId.get(value); }, getValue: id => { - assert.equal(typeof id, 'string', details`id must be string ${id}`); + assert.equal(typeof id, 'string', X`id must be string ${id}`); assert( id.match(ID_REGEXP), - details`id must consist of at least ${q(CRC_NUM_DIGITS + 1)} digits`, + X`id must consist of at least ${q(CRC_NUM_DIGITS + 1)} digits`, ); const num = Number(id.slice(0, -CRC_NUM_DIGITS)); const allegedCrc = id.slice(-CRC_NUM_DIGITS); @@ -68,9 +68,9 @@ function makeBoard(seed = 0) { assert.equal( allegedCrc, crc, - details`id is probably a typo, cannot verify CRC: ${id}`, + X`id is probably a typo, cannot verify CRC: ${id}`, ); - assert(idToVal.has(id), details`board does not have id: ${id}`); + assert(idToVal.has(id), X`board does not have id: ${id}`); return idToVal.get(id); }, has: valToId.has, diff --git a/packages/cosmic-swingset/lib/ag-solo/vats/vat-http.js b/packages/cosmic-swingset/lib/ag-solo/vats/vat-http.js index ffe57ee8cdf..594539094c6 100644 --- a/packages/cosmic-swingset/lib/ag-solo/vats/vat-http.js +++ b/packages/cosmic-swingset/lib/ag-solo/vats/vat-http.js @@ -1,10 +1,9 @@ import { makeNotifierKit } from '@agoric/notifier'; import { E } from '@agoric/eventual-send'; +import { assert, details as X } from '@agoric/assert'; import { getReplHandler } from './repl'; import { getCapTPHandler } from './captp'; -const { details: X } = assert; - // This vat contains the HTTP request handler. export function buildRootObject(vatPowers) { const { D } = vatPowers; diff --git a/packages/cosmic-swingset/lib/block-manager.js b/packages/cosmic-swingset/lib/block-manager.js index 76749f73985..ce6c06f1083 100644 --- a/packages/cosmic-swingset/lib/block-manager.js +++ b/packages/cosmic-swingset/lib/block-manager.js @@ -1,6 +1,6 @@ import anylogger from 'anylogger'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; const log = anylogger('block-manager'); diff --git a/packages/cosmic-swingset/lib/chain-main.js b/packages/cosmic-swingset/lib/chain-main.js index b9d8e2d6445..b83bc598dce 100644 --- a/packages/cosmic-swingset/lib/chain-main.js +++ b/packages/cosmic-swingset/lib/chain-main.js @@ -7,11 +7,10 @@ import { import { MeterProvider } from '@opentelemetry/metrics'; import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'; +import { assert, details as X } from '@agoric/assert'; import { launch } from './launch-chain'; import makeBlockManager from './block-manager'; -const { details: X } = assert; - const AG_COSMOS_INIT = 'AG_COSMOS_INIT'; const toNumber = specimen => { @@ -217,9 +216,7 @@ export default async function main(progname, args, { path, env, agcc }) { try { return JSON.parse(retStr); } catch (e) { - assert.fail( - X`cannot JSON.parse(${JSON.stringify(retStr)}): ${e}`, - ); + assert.fail(X`cannot JSON.parse(${JSON.stringify(retStr)}): ${e}`); } } diff --git a/packages/cosmic-swingset/lib/check-lmdb.js b/packages/cosmic-swingset/lib/check-lmdb.js index 0ef9866baea..331f4669149 100644 --- a/packages/cosmic-swingset/lib/check-lmdb.js +++ b/packages/cosmic-swingset/lib/check-lmdb.js @@ -8,7 +8,7 @@ import { initSwingStore as initSwingStoreSimple, } from '@agoric/swing-store-simple'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; /* * Return an 'openSwingStore' function for the best kind of DB that works on diff --git a/packages/cosmic-swingset/lib/launch-chain.js b/packages/cosmic-swingset/lib/launch-chain.js index 5b81bcbe1d3..980579096b6 100644 --- a/packages/cosmic-swingset/lib/launch-chain.js +++ b/packages/cosmic-swingset/lib/launch-chain.js @@ -14,11 +14,10 @@ import { loadBasedir, loadSwingsetConfigFile, } from '@agoric/swingset-vat'; +import { assert, details as X } from '@agoric/assert'; import { getBestSwingStore } from './check-lmdb'; import { exportKernelStats } from './kernel-stats'; -const { details: X } = assert; - const log = anylogger('launch-chain'); const SWING_STORE_META_KEY = 'cosmos/meta'; diff --git a/packages/dapp-svelte-wallet/api/src/findOrMakeInvitation.js b/packages/dapp-svelte-wallet/api/src/findOrMakeInvitation.js index 9cf64ecb73f..4b9f540d613 100644 --- a/packages/dapp-svelte-wallet/api/src/findOrMakeInvitation.js +++ b/packages/dapp-svelte-wallet/api/src/findOrMakeInvitation.js @@ -141,7 +141,5 @@ export const findOrMakeInvitation = async ( ); } - assert.fail( - X`no invitation was found or made for this offer ${offer.id}`, - ); + assert.fail(X`no invitation was found or made for this offer ${offer.id}`); }; diff --git a/packages/dapp-svelte-wallet/ui/package.json b/packages/dapp-svelte-wallet/ui/package.json index 13303a7f8a0..95a8d54ee5d 100644 --- a/packages/dapp-svelte-wallet/ui/package.json +++ b/packages/dapp-svelte-wallet/ui/package.json @@ -36,6 +36,7 @@ "access": "public" }, "dependencies": { + "@agoric/assert": "^0.2.0", "@rollup/plugin-replace": "^2.3.4" } } diff --git a/packages/dapp-svelte-wallet/ui/src/display.js b/packages/dapp-svelte-wallet/ui/src/display.js index d45276fda5b..1fe233f9803 100644 --- a/packages/dapp-svelte-wallet/ui/src/display.js +++ b/packages/dapp-svelte-wallet/ui/src/display.js @@ -1,6 +1,6 @@ // @ts-check import JSON5 from 'json5'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { MathKind } from '@agoric/ertp'; const CONVENTIONAL_DECIMAL_PLACES = 2; @@ -15,13 +15,10 @@ const CONVENTIONAL_DECIMAL_PLACES = 2; * @param {AmountDisplayInfo} displayInfo */ export function parseValue(str, displayInfo) { - const { amountMathKind = MathKind.NAT, decimalPlaces = 0 } = displayInfo || {}; + const { amountMathKind = MathKind.NAT, decimalPlaces = 0 } = + displayInfo || {}; - assert.typeof( - str, - 'string', - details`valueString ${str} is not a string`, - ); + assert.typeof(str, 'string', X`valueString ${str} is not a string`); if (amountMathKind !== MathKind.NAT) { // Punt to JSON5 parsing. @@ -30,17 +27,14 @@ export function parseValue(str, displayInfo) { // Parse the string as a number. const match = str.match(/^0*(\d+)(\.(\d*[1-9])?0*)?$/); - assert( - match, - details`${str} must be a non-negative decimal number`, - ); + assert(match, X`${str} must be a non-negative decimal number`); const unitstr = match[1]; const dec0str = match[3] || ''; const dec0str0 = dec0str.padEnd(decimalPlaces, '0'); assert( dec0str0.length <= decimalPlaces, - details`${str} exceeds ${decimalPlaces} decimal places`, + X`${str} exceeds ${decimalPlaces} decimal places`, ); return parseInt(`${unitstr}${dec0str0}`, 10); diff --git a/packages/deploy-script-support/src/assertOfferResult.js b/packages/deploy-script-support/src/assertOfferResult.js index cf490e4e956..d5a8a8a49b3 100644 --- a/packages/deploy-script-support/src/assertOfferResult.js +++ b/packages/deploy-script-support/src/assertOfferResult.js @@ -1,5 +1,5 @@ // @ts-check -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { E } from '@agoric/eventual-send'; /** @type {AssertOfferResult} */ @@ -7,6 +7,6 @@ export const assertOfferResult = async (seat, expectedOfferResult) => { const actualOfferResult = await E(seat).getOfferResult(); assert( actualOfferResult === expectedOfferResult, - details`offerResult (${actualOfferResult}) did not equal expected: ${expectedOfferResult}`, + X`offerResult (${actualOfferResult}) did not equal expected: ${expectedOfferResult}`, ); }; diff --git a/packages/deployment/files.js b/packages/deployment/files.js index 5f8fca803d8..3b3909230a9 100644 --- a/packages/deployment/files.js +++ b/packages/deployment/files.js @@ -17,7 +17,7 @@ import { Readable } from 'stream'; import { open as tempOpen } from 'temp'; import chalk from 'chalk'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export const chmod = util.promisify(rawChmod); export const exists = util.promisify(rawExists); @@ -32,8 +32,9 @@ const fsWrite = util.promisify(rawWrite); const fsClose = util.promisify(rawClose); export { resolve, dirname, basename }; -export const needNotExists = async filename => { - assert(!(await exists(filename)), X`${filename} already exists`); +export const mustNotExist = async filename => { + const fileExists = await exists(filename); + assert(!fileExists, X`${filename} already exists`); }; export const createFile = async (path, contents) => { diff --git a/packages/deployment/init.js b/packages/deployment/init.js index 7b37903fcc8..73213440746 100644 --- a/packages/deployment/init.js +++ b/packages/deployment/init.js @@ -1,18 +1,17 @@ import fetch from 'node-fetch'; import inquirer from 'inquirer'; +import { assert, details as X } from '@agoric/assert'; import { SETUP_HOME, PLAYBOOK_WRAPPER, SETUP_DIR, SSH_TYPE } from './setup'; import { basename, chmod, createFile, mkdir, - needNotExists, + mustNotExist, resolve, } from './files'; import { chdir, needDoRun, shellEscape } from './run'; -const { details: X } = assert; - const calculateTotal = placement => (placement ? Object.values(placement) : []).reduce( (prior, cur) => prior + cur, @@ -255,7 +254,7 @@ const doInit = async (progname, args) => { dir = SETUP_HOME; } assert(dir, X`Need: [dir] [[network name]]`); - await needNotExists(`${dir}/network.txt`); + await mustNotExist(`${dir}/network.txt`); const adir = resolve(process.cwd(), dir); const SSH_PRIVATE_KEY_FILE = resolve(adir, `id_${SSH_TYPE}`); diff --git a/packages/deployment/main.js b/packages/deployment/main.js index ee0a8de35bb..c6a133901da 100644 --- a/packages/deployment/main.js +++ b/packages/deployment/main.js @@ -4,6 +4,7 @@ import djson from 'deterministic-json'; import crypto from 'crypto'; import chalk from 'chalk'; import parseArgs from 'minimist'; +import { assert, details as X } from '@agoric/assert'; import doInit from './init'; import { chdir, @@ -33,8 +34,6 @@ import { SSH_TYPE, } from './setup'; -const { details: X } = assert; - const PROVISION_DIR = 'provision'; const PROVISIONER_NODE = 'node0'; // FIXME: Allow configuration. const COSMOS_DIR = 'ag-chain-cosmos'; @@ -580,7 +579,7 @@ ${chalk.yellow.bold(`ag-setup-solo --netconfig='${dwebHost}/network-config'`)} } const nodes = Object.keys(nodeMap).sort(); - assert(nodes.length !== 0, X`Need at least one node`); + assert(nodes.length > 0, X`Need at least one node`); for (const node of nodes) { const nodePlaybook = (book, ...pbargs) => @@ -689,7 +688,7 @@ ${chalk.yellow.bold(`ag-setup-solo --netconfig='${dwebHost}/network-config'`)} const raw = await trimReadFile(idPath); const ID = String(raw); - assert(ID, X`${idPath} does not contain a node ID`); + assert(ID, X`${idPath} must contain a node ${ID}`); assert( ID.match(/^[a-f0-9]+/), X`${idPath} contains an invalid ID ${ID}`, diff --git a/packages/deployment/package.json b/packages/deployment/package.json index 3845b244400..7b68015570e 100644 --- a/packages/deployment/package.json +++ b/packages/deployment/package.json @@ -17,6 +17,7 @@ "author": "Agoric", "license": "Apache-2.0", "dependencies": { + "@agoric/assert": "^0.2.0", "@agoric/install-ses": "^0.5.0", "chalk": "^2.4.2", "deterministic-json": "^1.0.5", diff --git a/packages/deployment/run.js b/packages/deployment/run.js index 5ef198ead12..d9b02ac908c 100644 --- a/packages/deployment/run.js +++ b/packages/deployment/run.js @@ -1,7 +1,7 @@ import { exec as rawExec, spawn } from 'child_process'; import { Writable } from 'stream'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; export const shellMetaRegexp = /(\s|[[\]'"\\`$;*?{}])/; export const shellEscape = arg => diff --git a/packages/eventual-send/test/test-eventual-send.js b/packages/eventual-send/test/test-eventual-send.js index 6fc3154a368..6351d09fb5c 100644 --- a/packages/eventual-send/test/test-eventual-send.js +++ b/packages/eventual-send/test/test-eventual-send.js @@ -1,11 +1,10 @@ import '@agoric/install-ses'; import test from 'ava'; +import { assert, details as X } from '@agoric/assert'; import { HandledPromise } from './get-hp'; const { getPrototypeOf } = Object; -const { details: X } = assert; - if (typeof window !== 'undefined') { // Let the browser detect when the tests are done. /* eslint-disable-next-line no-undef */ diff --git a/packages/import-bundle/src/index.js b/packages/import-bundle/src/index.js index bfae68961a9..581b29f1567 100644 --- a/packages/import-bundle/src/index.js +++ b/packages/import-bundle/src/index.js @@ -1,9 +1,8 @@ import { parseArchive } from '@agoric/compartment-mapper'; import { decodeBase64 } from '@agoric/base64'; +import { assert, details as X } from '@agoric/assert'; import { wrapInescapableCompartment } from './compartment-wrapper'; -const { details: X } = assert; - // importBundle takes the output of bundle-source, and returns a namespace // object (with .default, and maybe other properties for named exports) diff --git a/packages/import-bundle/test/test-compartment-wrapper.js b/packages/import-bundle/test/test-compartment-wrapper.js index 2be99286adb..77b09fe1083 100644 --- a/packages/import-bundle/test/test-compartment-wrapper.js +++ b/packages/import-bundle/test/test-compartment-wrapper.js @@ -1,9 +1,8 @@ import '@agoric/install-ses'; import test from 'ava'; +import { assert, details as X } from '@agoric/assert'; import { wrapInescapableCompartment } from '../src/compartment-wrapper.js'; -const { details: X } = assert; - // We build a transform that allows oldSrc to increment the odometer, but not // read it. Note, of course, that SES provides a far easier way to accomplish // this (pass in a hardened `addMilage` endowment), but there are metering diff --git a/packages/marshal/src/marshal.js b/packages/marshal/src/marshal.js index 68b7dd48f96..dacdc33b381 100644 --- a/packages/marshal/src/marshal.js +++ b/packages/marshal/src/marshal.js @@ -36,7 +36,6 @@ export function getInterfaceOf(maybeRemotable) { * @param {WeakMap} [already=new WeakMap()] * @returns {T & PureData} pure, hardened copy */ -// eslint-disable-next-line consistent-return function pureCopy(val, already = new WeakMap()) { // eslint-disable-next-line no-use-before-define const passStyle = passStyleOf(val); @@ -97,12 +96,10 @@ function pureCopy(val, already = new WeakMap()) { )} cannot be copied as it must be passed by reference`, TypeError, ); - break; } case 'promise': { assert.fail(X`Promises cannot be copied`, TypeError); - break; } default: @@ -353,7 +350,6 @@ export function sameValueZero(x, y) { * @param {Passable} val * @returns {PassStyle} */ -// eslint-disable-next-line consistent-return export function passStyleOf(val) { const typestr = typeof val; switch (typestr) { @@ -393,7 +389,6 @@ export function passStyleOf(val) { } case 'function': { assert.fail(X`Bare functions like ${val} are disabled for now`); - break; } case 'undefined': case 'string': @@ -455,7 +450,6 @@ function makeReviverIbidTable(cyclePolicy) { } case 'forbidCycles': { assert.fail(X`Ibid cycle at ${q(index)}`, TypeError); - break; } default: { assert.fail( @@ -592,7 +586,6 @@ export function makeMarshal( * @param {Passable} val * @returns {PlainJSONData} */ - // eslint-disable-next-line consistent-return const encode = val => { // First we handle all primitives. Some can be represented directly as // JSON, and some must be encoded as [QCLASS] composites. @@ -640,7 +633,6 @@ export function makeMarshal( assert.fail(X`Unsupported symbol ${q(String(val))}`); } } - break; } default: { // if we've seen this object before, serialize a backref @@ -752,7 +744,6 @@ export function makeMarshal( // produced by JSON.stringify on the replacer above, i.e., it // cannot rely on it being a valid marshalled // representation. Rather, fullRevive must validate that. - // eslint-disable-next-line consistent-return return function fullRevive(rawTree) { if (Object(rawTree) !== rawTree) { // primitives pass through diff --git a/packages/registrar/src/registrar.js b/packages/registrar/src/registrar.js index 9b3ef0adc7b..c5eecf8eea8 100644 --- a/packages/registrar/src/registrar.js +++ b/packages/registrar/src/registrar.js @@ -1,7 +1,7 @@ // Copyright (C) 2019 Agoric, under Apache License 2.0 import { generateSparseInts } from '@agoric/sparse-ints'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; // TODO(https://github.com/Agoric/agoric-sdk/issues/827), rename internally to // match teh way it's now published. @@ -44,13 +44,13 @@ function makeRegistrar(systemVersion, seed = 0) { return key; }, get(key, version = null) { - assert.typeof(key, 'string', details`Key must be string ${key}`); - assert(keyFormat.test(key), details`Key must end with _ ${key}`); + assert.typeof(key, 'string', X`Key must be string ${key}`); + assert(keyFormat.test(key), X`Key must end with _ ${key}`); if (version) { assert.equal( version, systemVersion, - details`Key is from incompatible version: ${version} should be ${systemVersion}`, + X`Key is from incompatible version: ${version} should be ${systemVersion}`, ); } return contents.get(key); diff --git a/packages/same-structure/src/sameStructure.js b/packages/same-structure/src/sameStructure.js index df26391dbf9..1ebc8dc18cc 100644 --- a/packages/same-structure/src/sameStructure.js +++ b/packages/same-structure/src/sameStructure.js @@ -55,7 +55,6 @@ function objectFromEntries(iter) { * @param {Passable} passable * @returns {Promise} */ -// eslint-disable-next-line consistent-return function allComparable(passable) { const passStyle = passStyleOf(passable); switch (passStyle) { @@ -103,7 +102,6 @@ harden(allComparable); * @param {Comparable} right * @returns {boolean} */ -// eslint-disable-next-line consistent-return function sameStructure(left, right) { const leftStyle = passStyleOf(left); const rightStyle = passStyleOf(right); diff --git a/packages/sharing-service/src/sharedMap.js b/packages/sharing-service/src/sharedMap.js index 30d70907a14..5fdf044c320 100644 --- a/packages/sharing-service/src/sharedMap.js +++ b/packages/sharing-service/src/sharedMap.js @@ -1,6 +1,6 @@ // Copyright (C) 2019 Agoric, under Apache License 2.0 -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; // Allows multiple parties to store values for retrieval by others. function makeSharedMap(name) { diff --git a/packages/sharing-service/test/swingsetTests/sharingService/bootstrap.js b/packages/sharing-service/test/swingsetTests/sharingService/bootstrap.js index b4c67b36b34..d0d46b7a740 100644 --- a/packages/sharing-service/test/swingsetTests/sharingService/bootstrap.js +++ b/packages/sharing-service/test/swingsetTests/sharingService/bootstrap.js @@ -1,11 +1,10 @@ // Copyright (C) 2019 Agoric, under Apache License 2.0 import { E } from '@agoric/eventual-send'; +import { assert, details as X } from '@agoric/assert'; import { makeSharedMap } from '../../../src/sharedMap'; import { makeSharingService } from '../../../src/sharing'; -const { details: X } = assert; - export function buildRootObject(vatPowers, vatParameters) { const log = vatPowers.testLog; function testSharedMapStorage() { @@ -82,7 +81,6 @@ export function buildRootObject(vatPowers, vatParameters) { } const obj0 = { - // eslint-disable-next-line consistent-return async bootstrap(vats) { switch (vatParameters.argv[0]) { case 'sharedMap': { diff --git a/packages/spawner/src/contractHost.js b/packages/spawner/src/contractHost.js index 6f28dd4f2e5..e1d72690ead 100644 --- a/packages/spawner/src/contractHost.js +++ b/packages/spawner/src/contractHost.js @@ -2,7 +2,7 @@ import { importBundle } from '@agoric/import-bundle'; import { makeWeakStore } from '@agoric/store'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { allComparable } from '@agoric/same-structure'; import { makeIssuerKit } from '@agoric/ertp'; @@ -35,7 +35,7 @@ function makeContractHost(vatPowers, additionalEndowments = {}) { function redeem(allegedInvitePayment) { return inviteIssuer.getAmountOf(allegedInvitePayment).then(inviteAmount => { - assert(!inviteAmountMath.isEmpty(inviteAmount), details`No invites left`); + assert(!inviteAmountMath.isEmpty(inviteAmount), X`No invites left`); const [{ seatIdentity }] = inviteAmountMath.getValue(inviteAmount); return Promise.resolve( inviteIssuer.burn(allegedInvitePayment, inviteAmount), diff --git a/packages/spawner/test/swingsetTests/contractHost/bootstrap.js b/packages/spawner/test/swingsetTests/contractHost/bootstrap.js index d9748a78108..d1d13dc2a28 100644 --- a/packages/spawner/test/swingsetTests/contractHost/bootstrap.js +++ b/packages/spawner/test/swingsetTests/contractHost/bootstrap.js @@ -2,13 +2,12 @@ import { E } from '@agoric/eventual-send'; import { makeLocalAmountMath } from '@agoric/ertp'; +import { assert, details as X } from '@agoric/assert'; import { bundleFunction } from '../../make-function-bundle'; import { escrowExchangeSrcs } from '../../../src/escrow'; import { coveredCallSrcs } from '../../../src/coveredCall'; -const { details: X } = assert; - export function buildRootObject(vatPowers, vatParameters) { const log = vatPowers.testLog; @@ -356,7 +355,6 @@ export function buildRootObject(vatPowers, vatParameters) { } const obj0 = { - // eslint-disable-next-line consistent-return async bootstrap(vats) { switch (vatParameters.argv[0]) { case 'trivial-oldformat': { diff --git a/packages/spawner/test/swingsetTests/contractHost/vat-bob.js b/packages/spawner/test/swingsetTests/contractHost/vat-bob.js index ca04b288e23..0c6bf29983b 100644 --- a/packages/spawner/test/swingsetTests/contractHost/vat-bob.js +++ b/packages/spawner/test/swingsetTests/contractHost/vat-bob.js @@ -4,10 +4,9 @@ import { E } from '@agoric/eventual-send'; import { makeLocalAmountMath } from '@agoric/ertp'; +import { assert, details as X } from '@agoric/assert'; import { makeCollect } from '../../../src/makeCollect'; -const { details: X } = assert; - function makeBobMaker(host, log) { const collect = makeCollect(E, log); diff --git a/packages/spawner/test/swingsetTests/escrow/bootstrap.js b/packages/spawner/test/swingsetTests/escrow/bootstrap.js index 0e563a15c24..5f5effb8003 100644 --- a/packages/spawner/test/swingsetTests/escrow/bootstrap.js +++ b/packages/spawner/test/swingsetTests/escrow/bootstrap.js @@ -174,7 +174,6 @@ export function buildRootObject(vatPowers, vatParameters) { } const obj0 = { - // eslint-disable-next-line consistent-return async bootstrap(vats) { const host = await E(vats.host).makeHost(); const { mint: randMintP } = E(vats.mint).makeIssuerKit('rand'); diff --git a/packages/store/src/store.js b/packages/store/src/store.js index 0fb4cf2aca7..9e116304af2 100644 --- a/packages/store/src/store.js +++ b/packages/store/src/store.js @@ -2,7 +2,7 @@ // @ts-check -import { assert, details, q } from '@agoric/assert'; +import { assert, details as X, q } from '@agoric/assert'; /** * Distinguishes between adding a new key (init) and updating or @@ -18,9 +18,9 @@ import { assert, details, q } from '@agoric/assert'; export function makeStore(keyName = 'key') { const store = new Map(); const assertKeyDoesNotExist = key => - assert(!store.has(key), details`${q(keyName)} already registered: ${key}`); + assert(!store.has(key), X`${q(keyName)} already registered: ${key}`); const assertKeyExists = key => - assert(store.has(key), details`${q(keyName)} not found: ${key}`); + assert(store.has(key), X`${q(keyName)} not found: ${key}`); return harden({ has: key => store.has(key), init: (key, value) => { diff --git a/packages/store/src/weak-store.js b/packages/store/src/weak-store.js index 5217c0fab79..35d202ede34 100644 --- a/packages/store/src/weak-store.js +++ b/packages/store/src/weak-store.js @@ -2,7 +2,7 @@ // @ts-check -import { assert, details, q } from '@agoric/assert'; +import { assert, details as X, q } from '@agoric/assert'; import './types'; /** @@ -14,9 +14,9 @@ import './types'; export function makeWeakStore(keyName = 'key') { const wm = new WeakMap(); const assertKeyDoesNotExist = key => - assert(!wm.has(key), details`${q(keyName)} already registered: ${key}`); + assert(!wm.has(key), X`${q(keyName)} already registered: ${key}`); const assertKeyExists = key => - assert(wm.has(key), details`${q(keyName)} not found: ${key}`); + assert(wm.has(key), X`${q(keyName)} not found: ${key}`); return harden({ has: key => wm.has(key), init: (key, value) => { diff --git a/packages/swingset-runner/demo/vatStore2/bootstrap.js b/packages/swingset-runner/demo/vatStore2/bootstrap.js index 270bea8906f..3c9415b1903 100644 --- a/packages/swingset-runner/demo/vatStore2/bootstrap.js +++ b/packages/swingset-runner/demo/vatStore2/bootstrap.js @@ -1,8 +1,7 @@ import { E } from '@agoric/eventual-send'; +import { assert, details as X } from '@agoric/assert'; import { makeXorShift128 } from './xorshift128'; -const { details: X } = assert; - const p = console.log; const randomness = makeXorShift128(); diff --git a/packages/swingset-runner/demo/zoeTests/vat-alice.js b/packages/swingset-runner/demo/zoeTests/vat-alice.js index 522aba9456c..57bfeacea2a 100644 --- a/packages/swingset-runner/demo/zoeTests/vat-alice.js +++ b/packages/swingset-runner/demo/zoeTests/vat-alice.js @@ -1,11 +1,10 @@ import { E } from '@agoric/eventual-send'; import { makeLocalAmountMath } from '@agoric/ertp'; +import { assert, details as X } from '@agoric/assert'; import { showPurseBalance, setupIssuers } from './helpers'; import { makePrintLog } from './printLog'; -const { details: X } = assert; - const build = async (log, zoe, issuers, payments, installations, timer) => { const { moola, simoleans, bucks, purses } = await setupIssuers(zoe, issuers); const [moolaPurseP, simoleanPurseP] = purses; @@ -486,7 +485,6 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { }; return harden({ - // eslint-disable-next-line consistent-return startTest: async (testName, bobP, carolP, daveP) => { switch (testName) { case 'automaticRefundOk': { diff --git a/packages/swingset-runner/demo/zoeTests/vat-bob.js b/packages/swingset-runner/demo/zoeTests/vat-bob.js index 484ce7282c6..a6a8270f33c 100644 --- a/packages/swingset-runner/demo/zoeTests/vat-bob.js +++ b/packages/swingset-runner/demo/zoeTests/vat-bob.js @@ -1,5 +1,5 @@ import { E } from '@agoric/eventual-send'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { sameStructure } from '@agoric/same-structure'; import { makeLocalAmountMath } from '@agoric/ertp'; import { showPurseBalance, setupIssuers } from './helpers'; @@ -33,16 +33,16 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { // Bob ensures it's the contract he expects assert( installations.automaticRefund === installation, - details`should be the expected automaticRefund`, + X`should be the expected automaticRefund`, ); assert( issuerKeywordRecord.Contribution1 === moolaIssuer, - details`The first issuer should be the moola issuer`, + X`The first issuer should be the moola issuer`, ); assert( issuerKeywordRecord.Contribution2 === simoleanIssuer, - details`The second issuer should be the simolean issuer`, + X`The second issuer should be the simolean issuer`, ); // 1. Bob escrows his offer @@ -89,13 +89,10 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { const { value: optionValue } = await E(invitationIssuer).getAmountOf( exclInvitation, ); - assert( - installation === installations.coveredCall, - details`wrong installation`, - ); + assert(installation === installations.coveredCall, X`wrong installation`); assert( optionValue[0].description === 'exerciseOption', - details`wrong invitation`, + X`wrong invitation`, ); assert( moolaAmountMath.isEqual( @@ -109,20 +106,17 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { simoleans(7), ), ); - assert( - optionValue[0].expirationDate === 1, - details`wrong expirationDate`, - ); + assert(optionValue[0].expirationDate === 1, X`wrong expirationDate`); assert(optionValue[0].timeAuthority === timer, 'wrong timer'); const { UnderlyingAsset, StrikePrice } = issuerKeywordRecord; assert( UnderlyingAsset === moolaIssuer, - details`The underlying asset issuer should be the moola issuer`, + X`The underlying asset issuer should be the moola issuer`, ); assert( StrikePrice === simoleanIssuer, - details`The strike price issuer should be the simolean issuer`, + X`The strike price issuer should be the simolean issuer`, ); const bobPayments = { StrikePrice: simoleanPayment }; @@ -161,40 +155,34 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { ); const optionValue = optionAmounts.value; - assert( - installation === installations.coveredCall, - details`wrong installation`, - ); + assert(installation === installations.coveredCall, X`wrong installation`); assert( optionValue[0].description === 'exerciseOption', - details`wrong invitation`, + X`wrong invitation`, ); assert( moolaAmountMath.isEqual( optionValue[0].underlyingAssets.UnderlyingAsset, moola(3), ), - details`wrong underlying asset`, + X`wrong underlying asset`, ); assert( simoleanAmountMath.isEqual( optionValue[0].strikePrice.StrikePrice, simoleans(7), ), - details`wrong strike price`, + X`wrong strike price`, ); - assert( - optionValue[0].expirationDate === 100, - details`wrong expiration date`, - ); - assert(optionValue[0].timeAuthority === timer, details`wrong timer`); + assert(optionValue[0].expirationDate === 100, X`wrong expiration date`); + assert(optionValue[0].timeAuthority === timer, X`wrong timer`); assert( UnderlyingAsset === moolaIssuer, - details`The underlyingAsset issuer should be the moola issuer`, + X`The underlyingAsset issuer should be the moola issuer`, ); assert( StrikePrice === simoleanIssuer, - details`The strikePrice issuer should be the simolean issuer`, + X`The strikePrice issuer should be the simolean issuer`, ); // Let's imagine that Bob wants to create a swap to trade this @@ -248,14 +236,14 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { assert( installation === installations.secondPriceAuction, - details`wrong installation`, + X`wrong installation`, ); assert( sameStructure( harden({ Asset: moolaIssuer, Ask: simoleanIssuer }), issuerKeywordRecord, ), - details`issuerKeywordRecord was not as expected`, + X`issuerKeywordRecord was not as expected`, ); assert(sameStructure(invitationValue[0].minimumBid, simoleans(3))); assert(sameStructure(invitationValue[0].auctionedAssets, moola(1))); @@ -292,25 +280,22 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { exclInvitation, ); - assert( - installation === installations.atomicSwap, - details`wrong installation`, - ); + assert(installation === installations.atomicSwap, X`wrong installation`); assert( sameStructure( harden({ Asset: moolaIssuer, Price: simoleanIssuer }), issuerKeywordRecord, ), - details`issuers were not as expected`, + X`issuers were not as expected`, ); assert( sameStructure(invitationValue[0].asset, moola(3)), - details`Alice made a different offer than expected`, + X`Alice made a different offer than expected`, ); assert( sameStructure(invitationValue[0].price, simoleans(7)), - details`Alice made a different offer than expected`, + X`Alice made a different offer than expected`, ); const proposal = harden({ @@ -345,15 +330,15 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { assert( installation === installations.simpleExchange, - details`wrong installation`, + X`wrong installation`, ); assert( issuerKeywordRecord.Asset === moolaIssuer, - details`The first issuer should be the moola issuer`, + X`The first issuer should be the moola issuer`, ); assert( issuerKeywordRecord.Price === simoleanIssuer, - details`The second issuer should be the simolean issuer`, + X`The second issuer should be the simolean issuer`, ); const bobBuyOrderProposal = harden({ @@ -388,15 +373,15 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { assert( installation === installations.simpleExchange, - details`wrong installation`, + X`wrong installation`, ); assert( issuerKeywordRecord.Asset === moolaIssuer, - details`The first issuer should be the moola issuer`, + X`The first issuer should be the moola issuer`, ); assert( issuerKeywordRecord.Price === simoleanIssuer, - details`The second issuer should be the simolean issuer`, + X`The second issuer should be the simolean issuer`, ); const bobBuyOrderProposal = harden({ want: { Asset: moola(m) }, @@ -435,10 +420,7 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { const buyBInvitation = await E(publicFacet).makeSwapInInvitation(); const installation = await E(zoe).getInstallation(buyBInvitation); const issuerKeywordRecord = await E(zoe).getIssuers(instance); - assert( - installation === installations.autoswap, - details`wrong installation`, - ); + assert(installation === installations.autoswap, X`wrong installation`); const liquidityIssuer = await E(publicFacet).getLiquidityIssuer(); assert( sameStructure( @@ -449,7 +431,7 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { }), issuerKeywordRecord, ), - details`issuers were not as expected`, + X`issuers were not as expected`, ); // bob checks how many simoleans he can get for 3 moola diff --git a/packages/swingset-runner/demo/zoeTests/vat-carol.js b/packages/swingset-runner/demo/zoeTests/vat-carol.js index 9644390777b..73c2b8c521e 100644 --- a/packages/swingset-runner/demo/zoeTests/vat-carol.js +++ b/packages/swingset-runner/demo/zoeTests/vat-carol.js @@ -1,5 +1,5 @@ import { E } from '@agoric/eventual-send'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { sameStructure } from '@agoric/same-structure'; import { showPurseBalance, setupIssuers } from './helpers'; @@ -26,14 +26,14 @@ const build = async (log, zoe, issuers, payments, installations) => { assert( installation === installations.secondPriceAuction, - details`wrong installation`, + X`wrong installation`, ); assert( sameStructure( harden({ Asset: moolaIssuer, Ask: simoleanIssuer }), issuerKeywordRecord, ), - details`issuerKeywordRecord were not as expected`, + X`issuerKeywordRecord were not as expected`, ); assert(sameStructure(invitationValue[0].minimumBid, simoleans(3))); assert(sameStructure(invitationValue[0].auctionedAssets, moola(1))); diff --git a/packages/swingset-runner/demo/zoeTests/vat-dave.js b/packages/swingset-runner/demo/zoeTests/vat-dave.js index a2372c1f4a5..3d017737fd8 100644 --- a/packages/swingset-runner/demo/zoeTests/vat-dave.js +++ b/packages/swingset-runner/demo/zoeTests/vat-dave.js @@ -1,5 +1,5 @@ import { E } from '@agoric/eventual-send'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { sameStructure } from '@agoric/same-structure'; import { showPurseBalance, setupIssuers } from './helpers'; @@ -33,14 +33,14 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { assert( installation === installations.secondPriceAuction, - details`wrong installation`, + X`wrong installation`, ); assert( sameStructure( harden({ Asset: moolaIssuer, Ask: simoleanIssuer }), issuerKeywordRecord, ), - details`issuerKeywordRecord were not as expected`, + X`issuerKeywordRecord were not as expected`, ); assert(sameStructure(invitationValue[0].minimumBid, simoleans(3))); assert(sameStructure(invitationValue[0].auctionedAssets, moola(1))); @@ -84,62 +84,56 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { // pick some arbitrary code points as a signature. assert( source.includes('asset: give.Asset,'), - details`source bundle didn't match at "asset: give.Asset,"`, + X`source bundle didn't match at "asset: give.Asset,"`, ); assert( source.includes('swap(zcf, firstSeat, matchingSeat)'), - details`source bundle didn't match at "swap(zcf, firstSeat, matchingSeat)"`, + X`source bundle didn't match at "swap(zcf, firstSeat, matchingSeat)"`, ); assert( source.includes('makeMatchingInvitation'), - details`source bundle didn't match at "makeMatchingInvitation"`, - ); - assert( - installation === installations.atomicSwap, - details`wrong installation`, + X`source bundle didn't match at "makeMatchingInvitation"`, ); + assert(installation === installations.atomicSwap, X`wrong installation`); assert( sameStructure( harden({ Asset: invitationIssuer, Price: bucksIssuer }), issuerKeywordRecord, ), - details`issuerKeywordRecord were not as expected`, + X`issuerKeywordRecord were not as expected`, ); // Dave expects that Bob has already made an offer in the swap // with the following rules: assert( sameStructure(invitationValue[0].asset, optionAmounts), - details`asset is the option`, + X`asset is the option`, ); assert( sameStructure(invitationValue[0].price, bucks(1)), - details`price is 1 buck`, + X`price is 1 buck`, ); const optionValue = optionAmounts.value; assert( optionValue[0].description === 'exerciseOption', - details`wrong invitation`, + X`wrong invitation`, ); assert( moolaAmountMath.isEqual( optionValue[0].underlyingAssets.UnderlyingAsset, moola(3), ), - details`wrong underlying asset`, + X`wrong underlying asset`, ); assert( simoleanAmountMath.isEqual( optionValue[0].strikePrice.StrikePrice, simoleans(7), ), - details`wrong strike price`, - ); - assert( - optionValue[0].expirationDate === 100, - details`wrong expiration date`, + X`wrong strike price`, ); - assert(optionValue[0].timeAuthority === timer, details`wrong timer`); + assert(optionValue[0].expirationDate === 100, X`wrong expiration date`); + assert(optionValue[0].timeAuthority === timer, X`wrong timer`); // Dave escrows his 1 buck with Zoe and forms his proposal const daveSwapProposal = harden({ diff --git a/packages/swingset-runner/src/auditstore.js b/packages/swingset-runner/src/auditstore.js index 19781d36747..4bbcc2e8d85 100644 --- a/packages/swingset-runner/src/auditstore.js +++ b/packages/swingset-runner/src/auditstore.js @@ -1,4 +1,4 @@ -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; /* eslint-disable no-use-before-define */ export function auditRefCounts(store) { diff --git a/packages/swingset-runner/src/slogulator.js b/packages/swingset-runner/src/slogulator.js index 4f86d2662db..b4e4733fffe 100644 --- a/packages/swingset-runner/src/slogulator.js +++ b/packages/swingset-runner/src/slogulator.js @@ -3,7 +3,7 @@ import process from 'process'; import Readlines from 'n-readlines'; import yargs from 'yargs'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; /* eslint-disable no-use-before-define */ diff --git a/packages/zoe/src/cleanProposal.js b/packages/zoe/src/cleanProposal.js index 7a48bd139cc..22dca4410b0 100644 --- a/packages/zoe/src/cleanProposal.js +++ b/packages/zoe/src/cleanProposal.js @@ -1,4 +1,4 @@ -import { assert, details, q } from '@agoric/assert'; +import { assert, details as X, q } from '@agoric/assert'; import { mustBeComparable } from '@agoric/same-structure'; import '../exported'; @@ -20,13 +20,13 @@ export const assertKeywordName = keyword => { const firstCapASCII = /^[A-Z][a-zA-Z0-9_$]*$/; assert( firstCapASCII.test(keyword), - details`keyword ${q( + X`keyword ${q( keyword, )} must be ascii and must start with a capital letter.`, ); assert( keyword !== 'NaN' && keyword !== 'Infinity', - details`keyword ${q(keyword)} must not be a number's name`, + X`keyword ${q(keyword)} must not be a number's name`, ); }; @@ -39,7 +39,7 @@ const assertKeysAllowed = (allowedKeys, record) => { // assert that there are no symbol properties. assert( Object.getOwnPropertySymbols(record).length === 0, - details`no symbol properties allowed`, + X`no symbol properties allowed`, ); }; @@ -77,7 +77,7 @@ export const cleanKeywords = keywordRecord => { // Insist that there are no symbol properties. assert( Object.getOwnPropertySymbols(keywordRecord).length === 0, - details`no symbol properties allowed`, + X`no symbol properties allowed`, ); // Assert all key characters are ascii and keys start with a @@ -118,7 +118,7 @@ export const cleanProposal = (getAmountMath, proposal) => { // Check exit assert( Object.getOwnPropertyNames(exit).length === 1, - details`exit ${proposal.exit} should only have one key`, + X`exit ${proposal.exit} should only have one key`, ); // We expect the single exit key to be one of the following: const allowedExitKeys = ['onDemand', 'afterDeadline', 'waived']; @@ -132,13 +132,10 @@ export const cleanProposal = (getAmountMath, proposal) => { if (exitKey === 'afterDeadline') { const expectedAfterDeadlineKeys = ['timer', 'deadline']; assertKeysAllowed(expectedAfterDeadlineKeys, exit.afterDeadline); - assert( - exit.afterDeadline.timer !== undefined, - details`timer must be defined`, - ); + assert(exit.afterDeadline.timer !== undefined, X`timer must be defined`); assert( exit.afterDeadline.deadline !== undefined, - details`deadline must be defined`, + X`deadline must be defined`, ); // timers must have a 'setWakeup' function which takes a deadline // and an object as arguments. @@ -154,7 +151,7 @@ export const cleanProposal = (getAmountMath, proposal) => { giveKeywords.forEach(keyword => { assert( !wantKeywordSet.has(keyword), - details`a keyword cannot be in both 'want' and 'give'`, + X`a keyword cannot be in both 'want' and 'give'`, ); }); diff --git a/packages/zoe/src/contractFacet/contractFacet.js b/packages/zoe/src/contractFacet/contractFacet.js index 2908fb73b3c..858ef46ea14 100644 --- a/packages/zoe/src/contractFacet/contractFacet.js +++ b/packages/zoe/src/contractFacet/contractFacet.js @@ -7,7 +7,7 @@ // time this file is edited, the bundle must be manually rebuilt with // `yarn build-zcfBundle`. -import { assert, details, q } from '@agoric/assert'; +import { assert, details as X, q } from '@agoric/assert'; import { E } from '@agoric/eventual-send'; import { makeStore, makeWeakStore } from '@agoric/store'; @@ -85,7 +85,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { assertKeywordName(keyword); assert( !getKeywords(instanceRecord.terms.issuers).includes(keyword), - details`keyword ${q(keyword)} must be unique`, + X`keyword ${q(keyword)} must be unique`, ); return registerIssuerRecord(keyword, issuerRecord); }; @@ -111,12 +111,12 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { seatStagings.forEach(seatStaging => { assert( allSeatStagings.has(seatStaging), - details`The seatStaging ${seatStaging} was not recognized`, + X`The seatStaging ${seatStaging} was not recognized`, ); const seat = seatStaging.getSeat(); assert( !seatsSoFar.has(seat), - details`Seat (${seat}) was already an argument to reallocate`, + X`Seat (${seat}) was already an argument to reallocate`, ); seatsSoFar.add(seat); }); @@ -199,7 +199,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { ) => { assert( !(keyword in instanceRecord.terms.issuers), - details`Keyword ${keyword} already registered`, + X`Keyword ${keyword} already registered`, ); const zoeMintP = E(zoeInstanceAdmin).makeZoeMint( @@ -229,7 +229,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { assert.typeof( gains, 'object', - details`gains ${gains} must be an amountKeywordRecord`, + X`gains ${gains} must be an amountKeywordRecord`, ); if (zcfSeat === undefined) { zcfSeat = makeEmptySeatKit().zcfSeat; @@ -239,7 +239,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { const updates = objectMap(gains, ([seatKeyword, amountToAdd]) => { assert( totalToMint.brand === amountToAdd.brand, - details`Only digital assets of brand ${totalToMint.brand} can be minted in this call. ${amountToAdd} has the wrong brand.`, + X`Only digital assets of brand ${totalToMint.brand} can be minted in this call. ${amountToAdd} has the wrong brand.`, ); totalToMint = mintyAmountMath.add(totalToMint, amountToAdd); const oldAmount = oldAllocation[seatKeyword]; @@ -267,7 +267,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { assert.typeof( losses, 'object', - details`losses ${losses} must be an amountKeywordRecord`, + X`losses ${losses} must be an amountKeywordRecord`, ); let totalToBurn = mintyAmountMath.getEmpty(); const oldAllocation = zcfSeat.getCurrentAllocation(); @@ -276,7 +276,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { ([seatKeyword, amountToSubtract]) => { assert( totalToBurn.brand === amountToSubtract.brand, - details`Only digital assets of brand ${totalToBurn.brand} can be burned in this call. ${amountToSubtract} has the wrong brand.`, + X`Only digital assets of brand ${totalToBurn.brand} can be burned in this call. ${amountToSubtract} has the wrong brand.`, ); totalToBurn = mintyAmountMath.add(totalToBurn, amountToSubtract); const oldAmount = oldAllocation[seatKeyword]; @@ -311,7 +311,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { // Discussion at: https://github.com/Agoric/agoric-sdk/issues/1017 assert( seatStagings.length >= 2, - details`reallocating must be done over two or more seats`, + X`reallocating must be done over two or more seats`, ); // Ensure that rights are conserved overall. Offer safety was @@ -337,7 +337,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { assertKeywordName(keyword); assert( !getKeywords(instanceRecord.terms.issuers).includes(keyword), - details`keyword ${q(keyword)} must be unique`, + X`keyword ${q(keyword)} must be unique`, ); }, saveIssuer: async (issuerP, keyword) => { @@ -359,7 +359,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { assert.typeof( description, 'string', - details`invitations must have a description string: ${description}`, + X`invitations must have a description string: ${description}`, ); const invitationHandle = makeHandle('Invitation'); diff --git a/packages/zoe/src/contractFacet/exit.js b/packages/zoe/src/contractFacet/exit.js index cf7cb163207..df05231b84a 100644 --- a/packages/zoe/src/contractFacet/exit.js +++ b/packages/zoe/src/contractFacet/exit.js @@ -1,4 +1,4 @@ -import { assert, details, q } from '@agoric/assert'; +import { assert, details as X, q } from '@agoric/assert'; import { E } from '@agoric/eventual-send'; /** @@ -56,7 +56,7 @@ export const makeExitObj = (proposal, zoeSeatAdmin, zcfSeatAdmin) => { // on demand assert( exitKind === 'waived', - details`exit kind was not recognized: ${q(exitKind)}`, + X`exit kind was not recognized: ${q(exitKind)}`, ); } return exitObj; diff --git a/packages/zoe/src/contractFacet/fakeVatAdmin.js b/packages/zoe/src/contractFacet/fakeVatAdmin.js index 4b4d7af18ba..d99a9c0c76e 100644 --- a/packages/zoe/src/contractFacet/fakeVatAdmin.js +++ b/packages/zoe/src/contractFacet/fakeVatAdmin.js @@ -1,10 +1,9 @@ import { E } from '@agoric/eventual-send'; import { makePromiseKit } from '@agoric/promise-kit'; +import { assert, details as X } from '@agoric/assert'; import { evalContractBundle } from './evalContractCode'; -const { details: X } = assert; - function makeFakeVatAdmin(testContextSetter = undefined, makeRemote = x => x) { // FakeVatPowers isn't intended to support testing of vat termination, it is // provided to allow unit testing of contracts that call zcf.shutdown() diff --git a/packages/zoe/src/contractFacet/rightsConservation.js b/packages/zoe/src/contractFacet/rightsConservation.js index d2ce2114baa..01a0942ef94 100644 --- a/packages/zoe/src/contractFacet/rightsConservation.js +++ b/packages/zoe/src/contractFacet/rightsConservation.js @@ -1,7 +1,7 @@ // @ts-check import makeStore from '@agoric/store'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import '../../exported'; import '../internal-types'; @@ -49,7 +49,7 @@ const assertEqualPerBrand = ( assert.equal( leftKeys.length, rightKeys.length, - details`${leftKeys.length} should be equal to ${rightKeys.length}`, + X`${leftKeys.length} should be equal to ${rightKeys.length}`, ); leftSumsByBrand .keys() @@ -59,7 +59,7 @@ const assertEqualPerBrand = ( leftSumsByBrand.get(brand), rightSumsByBrand.get(brand), ), - details`rights were not conserved for brand ${brand}`, + X`rights were not conserved for brand ${brand}`, ), ); }; diff --git a/packages/zoe/src/contractSupport/bondingCurves.js b/packages/zoe/src/contractSupport/bondingCurves.js index 01809547969..8cb7da32aa3 100644 --- a/packages/zoe/src/contractSupport/bondingCurves.js +++ b/packages/zoe/src/contractSupport/bondingCurves.js @@ -1,4 +1,4 @@ -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import Nat from '@agoric/nat'; import { natSafeMath } from './safeMath'; @@ -37,15 +37,9 @@ export const getInputPrice = ( outputReserve, feeBasisPoints = 30, ) => { - assert(inputValue > 0, details`inputValue ${inputValue} must be positive`); - assert( - inputReserve > 0, - details`inputReserve ${inputReserve} must be positive`, - ); - assert( - outputReserve > 0, - details`outputReserve ${outputReserve} must be positive`, - ); + assert(inputValue > 0, X`inputValue ${inputValue} must be positive`); + assert(inputReserve > 0, X`inputReserve ${inputReserve} must be positive`); + assert(outputReserve > 0, X`outputReserve ${outputReserve} must be positive`); const oneMinusFeeScaled = BIG_10000 - BigInt(feeBasisPoints); const inputWithFee = BigInt(inputValue) * oneMinusFeeScaled; @@ -79,17 +73,11 @@ export const getOutputPrice = ( outputReserve, feeBasisPoints = 30, ) => { - assert( - inputReserve > 0, - details`inputReserve ${inputReserve} must be positive`, - ); - assert( - outputReserve > 0, - details`outputReserve ${outputReserve} must be positive`, - ); + assert(inputReserve > 0, X`inputReserve ${inputReserve} must be positive`); + assert(outputReserve > 0, X`outputReserve ${outputReserve} must be positive`); assert( outputReserve > outputValue, - details`outputReserve ${outputReserve} must be greater than outputValue ${outputValue}`, + X`outputReserve ${outputReserve} must be greater than outputValue ${outputValue}`, ); const oneMinusFeeScaled = BIG_10000 - BigInt(feeBasisPoints); @@ -100,7 +88,7 @@ export const getOutputPrice = ( }; function assertDefined(label, value) { - assert(value !== undefined, details`${label} value required`); + assert(value !== undefined, X`${label} value required`); } // Calculate how many liquidity tokens we should be minting to send back to the diff --git a/packages/zoe/src/contractSupport/priceAuthority.js b/packages/zoe/src/contractSupport/priceAuthority.js index 81c0ec90ceb..d40781c9a27 100644 --- a/packages/zoe/src/contractSupport/priceAuthority.js +++ b/packages/zoe/src/contractSupport/priceAuthority.js @@ -1,5 +1,5 @@ import { E } from '@agoric/eventual-send'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { makePromiseKit } from '@agoric/promise-kit'; import '../../exported'; @@ -141,12 +141,12 @@ export function makeOnewayPriceAuthorityKit(opts) { assert.equal( brandIn, paBrandIn, - details`Desired brandIn ${brandIn} must match ${paBrandIn}`, + X`Desired brandIn ${brandIn} must match ${paBrandIn}`, ); assert.equal( brandOut, paBrandOut, - details`Desired brandOut ${brandOut} must match ${paBrandOut}`, + X`Desired brandOut ${brandOut} must match ${paBrandOut}`, ); }; @@ -186,7 +186,7 @@ export function makeOnewayPriceAuthorityKit(opts) { assert( mathOut.isGTE(actualAmountOut, amountOut), - details`Calculation of ${actualAmountOut} didn't cover expected ${amountOut}`, + X`Calculation of ${actualAmountOut} didn't cover expected ${amountOut}`, ); return { amountIn, amountOut }; }); diff --git a/packages/zoe/src/contracts/auction/assertBidSeat.js b/packages/zoe/src/contracts/auction/assertBidSeat.js index c0852faacae..89aa240c7f1 100644 --- a/packages/zoe/src/contracts/auction/assertBidSeat.js +++ b/packages/zoe/src/contracts/auction/assertBidSeat.js @@ -1,4 +1,4 @@ -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; export const assertBidSeat = (zcf, sellSeat, bidSeat) => { const { @@ -8,12 +8,12 @@ export const assertBidSeat = (zcf, sellSeat, bidSeat) => { const bid = bidSeat.getAmountAllocated('Bid', minBid.brand); assert( bidMath.isGTE(bid, minBid), - details`bid ${bid} is under the minimum bid ${minBid}`, + X`bid ${bid} is under the minimum bid ${minBid}`, ); const assetAtAuction = sellSeat.getProposal().give.Asset; const assetWanted = bidSeat.getAmountAllocated('Asset', assetAtAuction.brand); assert( assetMath.isGTE(assetAtAuction, assetWanted), - details`more assets were wanted ${assetWanted} than were available ${assetAtAuction}`, + X`more assets were wanted ${assetWanted} than were available ${assetAtAuction}`, ); }; diff --git a/packages/zoe/src/contracts/callSpread/fundedCallSpread.js b/packages/zoe/src/contracts/callSpread/fundedCallSpread.js index 51192c26152..821cd98423f 100644 --- a/packages/zoe/src/contracts/callSpread/fundedCallSpread.js +++ b/packages/zoe/src/contracts/callSpread/fundedCallSpread.js @@ -2,7 +2,7 @@ import '../../../exported'; import './types'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { makePromiseKit } from '@agoric/promise-kit'; import { E } from '@agoric/eventual-send'; import { @@ -65,7 +65,7 @@ const start = async zcf => { assert( strikeMath.isGTE(terms.strikePrice2, terms.strikePrice1), - details`strikePrice2 must be greater than strikePrice1`, + X`strikePrice2 must be greater than strikePrice1`, ); await zcf.saveIssuer(zcf.getInvitationIssuer(), 'Options'); diff --git a/packages/zoe/src/contracts/callSpread/pricedCallSpread.js b/packages/zoe/src/contracts/callSpread/pricedCallSpread.js index c99da43fa70..907c31df642 100644 --- a/packages/zoe/src/contracts/callSpread/pricedCallSpread.js +++ b/packages/zoe/src/contracts/callSpread/pricedCallSpread.js @@ -2,7 +2,7 @@ import '../../../exported'; import './types'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { makePromiseKit } from '@agoric/promise-kit'; import { E } from '@agoric/eventual-send'; import { @@ -64,7 +64,7 @@ const start = zcf => { assert( strikeMath.isGTE(terms.strikePrice2, terms.strikePrice1), - details`strikePrice2 must be greater than strikePrice1`, + X`strikePrice2 must be greater than strikePrice1`, ); zcf.saveIssuer(zcf.getInvitationIssuer(), 'Options'); @@ -115,14 +115,14 @@ const start = zcf => { // assert that the allocation includes the amount of collateral required assert( collateralMath.isEqual(newCollateral, required), - details`Collateral required: ${required.value}`, + X`Collateral required: ${required.value}`, ); // assert that the requested option was the right one. assert( spreadAmount.Option.value[0].instance === desiredOption.value[0].instance, - details`wanted option not a match`, + X`wanted option not a match`, ); trade( diff --git a/packages/zoe/src/contracts/loan/borrow.js b/packages/zoe/src/contracts/loan/borrow.js index b4c3c65da50..daab23dd1bd 100644 --- a/packages/zoe/src/contracts/loan/borrow.js +++ b/packages/zoe/src/contracts/loan/borrow.js @@ -1,7 +1,7 @@ // @ts-check import '../../../exported'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { E } from '@agoric/eventual-send'; import { makePromiseKit } from '@agoric/promise-kit'; @@ -59,7 +59,7 @@ export const makeBorrowInvitation = (zcf, config) => { loanMath.make(collateralPriceInLoanBrand.value), mmr.scale(loanWanted), ), - details`The required margin is approximately ${approxForMsg.value}% but collateral only had value of ${collateralPriceInLoanBrand.value}`, + X`The required margin is approximately ${approxForMsg.value}% but collateral only had value of ${collateralPriceInLoanBrand.value}`, ); // Assert that the collateralGiven has not changed after the AWAIT @@ -74,7 +74,7 @@ export const makeBorrowInvitation = (zcf, config) => { // Assert that loanWanted <= maxLoan assert( loanMath.isGTE(maxLoan, loanWanted), - details`The wanted loan ${loanWanted} must be below or equal to the maximum possible loan ${maxLoan}`, + X`The wanted loan ${loanWanted} must be below or equal to the maximum possible loan ${maxLoan}`, ); const { zcfSeat: collateralSeat } = zcf.makeEmptySeatKit(); diff --git a/packages/zoe/src/contracts/loan/close.js b/packages/zoe/src/contracts/loan/close.js index 419d1729c7c..5b3b36adf40 100644 --- a/packages/zoe/src/contracts/loan/close.js +++ b/packages/zoe/src/contracts/loan/close.js @@ -2,7 +2,7 @@ import './types'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { assertProposalShape, trade } from '../../contractSupport'; @@ -35,7 +35,7 @@ export const makeCloseLoanInvitation = (zcf, config) => { // All debt must be repaid. assert( loanMath.isGTE(repaid, debt), - details`Not enough Loan assets have been repaid. ${debt} is required, but only ${repaid} was repaid.`, + X`Not enough Loan assets have been repaid. ${debt} is required, but only ${repaid} was repaid.`, ); // We cannot use `swap` or `swapExact` helper because the collateralSeat diff --git a/packages/zoe/src/contracts/multipoolAutoswap/getCurrentPrice.js b/packages/zoe/src/contracts/multipoolAutoswap/getCurrentPrice.js index c08c823fe9d..27960d4491e 100644 --- a/packages/zoe/src/contracts/multipoolAutoswap/getCurrentPrice.js +++ b/packages/zoe/src/contracts/multipoolAutoswap/getCurrentPrice.js @@ -1,6 +1,6 @@ import '../../../exported'; -const { details: X } = assert; +import { assert, details as X } from '@agoric/assert'; /** * Build functions to calculate prices for multipoolAutoswap. Four methods are diff --git a/packages/zoe/src/contracts/multipoolAutoswap/multipoolAutoswap.js b/packages/zoe/src/contracts/multipoolAutoswap/multipoolAutoswap.js index 1222e2fba9d..374401c3c26 100644 --- a/packages/zoe/src/contracts/multipoolAutoswap/multipoolAutoswap.js +++ b/packages/zoe/src/contracts/multipoolAutoswap/multipoolAutoswap.js @@ -1,6 +1,6 @@ // @ts-check -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { makeWeakStore } from '@agoric/store'; import { assertIssuerKeywords } from '../../contractSupport'; @@ -59,7 +59,7 @@ const start = zcf => { brands: { Central: centralBrand }, } = zcf.getTerms(); assertIssuerKeywords(zcf, ['Central']); - assert(centralBrand !== undefined, details`centralBrand must be present`); + assert(centralBrand !== undefined, X`centralBrand must be present`); /** @type {WeakStore} */ const secondaryBrandToPool = makeWeakStore(); diff --git a/packages/zoe/src/contracts/multipoolAutoswap/pool.js b/packages/zoe/src/contracts/multipoolAutoswap/pool.js index 67b0d4fe7f3..664bba9a853 100644 --- a/packages/zoe/src/contracts/multipoolAutoswap/pool.js +++ b/packages/zoe/src/contracts/multipoolAutoswap/pool.js @@ -1,7 +1,7 @@ // @ts-check import { E } from '@agoric/eventual-send'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { MathKind } from '@agoric/ertp/src/amountMath'; import { @@ -62,7 +62,7 @@ export const makeAddPool = (zcf, isSecondary, initPool, centralBrand) => { const assertPoolInitialized = pool => assert( !pool.getAmountMath().isEmpty(pool.getSecondaryAmount()), - details`pool not initialized`, + X`pool not initialized`, ); const reservesAndMath = (pool, inputBrand, outputBrand) => { @@ -242,11 +242,11 @@ export const makeAddPool = (zcf, isSecondary, initPool, centralBrand) => { assert( !isSecondary(secondaryBrand), - details`issuer ${secondaryIssuer} already has a pool`, + X`issuer ${secondaryIssuer} already has a pool`, ); assert( secondaryMathKind === MathKind.NAT, - details`${keyword} issuer must use NAT math`, + X`${keyword} issuer must use NAT math`, ); // We've checked all the foreseeable exceptions (except diff --git a/packages/zoe/src/contracts/multipoolAutoswap/swap.js b/packages/zoe/src/contracts/multipoolAutoswap/swap.js index 100bc407fe9..89e3d95fd80 100644 --- a/packages/zoe/src/contracts/multipoolAutoswap/swap.js +++ b/packages/zoe/src/contracts/multipoolAutoswap/swap.js @@ -1,9 +1,9 @@ +import { assert, details as X } from '@agoric/assert'; + import { assertProposalShape, trade } from '../../contractSupport'; import '../../../exported'; -const { details: X } = assert; - /** * typedef {Object} PriceAmountTriple * diff --git a/packages/zoe/src/contracts/oracle.js b/packages/zoe/src/contracts/oracle.js index e15eedb3131..5c6ea63b1c7 100644 --- a/packages/zoe/src/contracts/oracle.js +++ b/packages/zoe/src/contracts/oracle.js @@ -1,5 +1,5 @@ // @ts-check -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import '../../exported'; import { E } from '@agoric/eventual-send'; @@ -68,7 +68,7 @@ const start = async zcf => { const { requiredFee, reply } = await E(handler).onQuery(query, noFee); assert( !requiredFee || feeMath.isGTE(noFee, requiredFee), - details`Oracle required a fee but the query had none`, + X`Oracle required a fee but the query had none`, ); return reply; } catch (e) { diff --git a/packages/zoe/src/contracts/priceAggregator.js b/packages/zoe/src/contracts/priceAggregator.js index 9d4662d17c6..822999dd1c0 100644 --- a/packages/zoe/src/contracts/priceAggregator.js +++ b/packages/zoe/src/contracts/priceAggregator.js @@ -2,7 +2,7 @@ import { E } from '@agoric/eventual-send'; import { makeNotifierKit } from '@agoric/notifier'; import makeStore from '@agoric/store'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { calculateMedian, natSafeMath, @@ -224,10 +224,7 @@ const start = async zcf => { ({ priceAuthority, adminFacet: priceAuthorityAdmin } = paKit); }, async initOracle(oracleInstance, query = undefined) { - assert( - quoteKit, - details`Must initializeQuoteMint before adding an oracle`, - ); + assert(quoteKit, X`Must initializeQuoteMint before adding an oracle`); /** @type {OracleRecord} */ const record = { querier: undefined, lastSample: NaN }; @@ -252,15 +249,12 @@ const start = async zcf => { // Obtain the oracle's publicFacet. const oracle = await E(zoe).getPublicFacet(oracleInstance); - assert(records.has(record), details`Oracle record is already deleted`); + assert(records.has(record), X`Oracle record is already deleted`); /** @type {OracleAdmin} */ const oracleAdmin = { async delete() { - assert( - records.has(record), - details`Oracle record is already deleted`, - ); + assert(records.has(record), X`Oracle record is already deleted`); // The actual deletion is synchronous. oracleRecords.delete(record); diff --git a/packages/zoe/src/contracts/sellItems.js b/packages/zoe/src/contracts/sellItems.js index 7c18c794791..2bba6ac7cc9 100644 --- a/packages/zoe/src/contracts/sellItems.js +++ b/packages/zoe/src/contracts/sellItems.js @@ -1,7 +1,7 @@ /* eslint-disable no-use-before-define */ // @ts-check -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { assertIssuerKeywords, trade, @@ -12,8 +12,6 @@ import { import '../../exported'; -const { details: X } = assert; - /** * Sell items in exchange for money. Items may be fungible or * non-fungible and multiple items may be bought at once. Money must @@ -88,7 +86,7 @@ const start = zcf => { // Check that the money provided to pay for the items is greater than the totalCost. assert( moneyMath.isGTE(providedMoney, totalCost), - details`More money (${totalCost}) is required to buy these items`, + X`More money (${totalCost}) is required to buy these items`, ); // Reallocate. We are able to trade by only defining the gains @@ -116,7 +114,7 @@ const start = zcf => { const itemsAmount = sellerSeat.getAmountAllocated('Items'); assert( sellerSeat && !itemsMath.isEmpty(itemsAmount), - details`no items are for sale`, + X`no items are for sale`, ); return zcf.makeInvitation(buy, 'buyer'); }, diff --git a/packages/zoe/src/objArrayConversion.js b/packages/zoe/src/objArrayConversion.js index 8315d6121da..6e552ec8b82 100644 --- a/packages/zoe/src/objArrayConversion.js +++ b/packages/zoe/src/objArrayConversion.js @@ -1,6 +1,6 @@ // @ts-check -import { assert, details, q } from '@agoric/assert'; +import { assert, details as X, q } from '@agoric/assert'; /** * @typedef {bigint|boolean|null|number|string|symbol|undefined} Primitive @@ -16,7 +16,7 @@ import { assert, details, q } from '@agoric/assert'; export const arrayToObj = (array, keys) => { assert( array.length === keys.length, - details`array and keys must be of equal length`, + X`array and keys must be of equal length`, ); const obj = /** @type {Record} */ @@ -36,7 +36,7 @@ export const assertSubset = (whole, part) => { assert.typeof(key, 'string'); assert( whole.includes(key), - details`key ${q(key)} was not one of the expected keys ${q(whole)}`, + X`key ${q(key)} was not one of the expected keys ${q(whole)}`, ); }); }; diff --git a/packages/zoe/test/swingsetTests/zoe/vat-alice.js b/packages/zoe/test/swingsetTests/zoe/vat-alice.js index 493e4bfe668..7bb64f574fb 100644 --- a/packages/zoe/test/swingsetTests/zoe/vat-alice.js +++ b/packages/zoe/test/swingsetTests/zoe/vat-alice.js @@ -1,9 +1,8 @@ import { E } from '@agoric/eventual-send'; import { makeLocalAmountMath } from '@agoric/ertp'; +import { assert, details as X } from '@agoric/assert'; import { showPurseBalance, setupIssuers } from '../helpers'; -const { details: X } = assert; - const build = async (log, zoe, issuers, payments, installations, timer) => { const { moola, simoleans, bucks, purses } = await setupIssuers(zoe, issuers); const [moolaPurseP, simoleanPurseP] = purses; diff --git a/packages/zoe/test/swingsetTests/zoe/vat-bob.js b/packages/zoe/test/swingsetTests/zoe/vat-bob.js index 414f779e462..39c2bf6ba26 100644 --- a/packages/zoe/test/swingsetTests/zoe/vat-bob.js +++ b/packages/zoe/test/swingsetTests/zoe/vat-bob.js @@ -1,5 +1,5 @@ import { E } from '@agoric/eventual-send'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { sameStructure } from '@agoric/same-structure'; import { makeLocalAmountMath } from '@agoric/ertp'; import { showPurseBalance, setupIssuers } from '../helpers'; @@ -31,16 +31,16 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { // Bob ensures it's the contract he expects assert( installations.automaticRefund === installation, - details`should be the expected automaticRefund`, + X`should be the expected automaticRefund`, ); assert( issuerKeywordRecord.Contribution1 === moolaIssuer, - details`The first issuer should be the moola issuer`, + X`The first issuer should be the moola issuer`, ); assert( issuerKeywordRecord.Contribution2 === simoleanIssuer, - details`The second issuer should be the simolean issuer`, + X`The second issuer should be the simolean issuer`, ); // 1. Bob escrows his offer @@ -87,13 +87,10 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { const { value: optionValue } = await E(invitationIssuer).getAmountOf( exclInvitation, ); - assert( - installation === installations.coveredCall, - details`wrong installation`, - ); + assert(installation === installations.coveredCall, X`wrong installation`); assert( optionValue[0].description === 'exerciseOption', - details`wrong invitation`, + X`wrong invitation`, ); assert( moolaAmountMath.isEqual( @@ -107,20 +104,17 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { simoleans(7), ), ); - assert( - optionValue[0].expirationDate === 1, - details`wrong expirationDate`, - ); + assert(optionValue[0].expirationDate === 1, X`wrong expirationDate`); assert(optionValue[0].timeAuthority === timer, 'wrong timer'); const { UnderlyingAsset, StrikePrice } = issuerKeywordRecord; assert( UnderlyingAsset === moolaIssuer, - details`The underlying asset issuer should be the moola issuer`, + X`The underlying asset issuer should be the moola issuer`, ); assert( StrikePrice === simoleanIssuer, - details`The strike price issuer should be the simolean issuer`, + X`The strike price issuer should be the simolean issuer`, ); const bobPayments = { StrikePrice: simoleanPayment }; @@ -159,40 +153,34 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { ); const optionValue = optionAmounts.value; - assert( - installation === installations.coveredCall, - details`wrong installation`, - ); + assert(installation === installations.coveredCall, X`wrong installation`); assert( optionValue[0].description === 'exerciseOption', - details`wrong invitation`, + X`wrong invitation`, ); assert( moolaAmountMath.isEqual( optionValue[0].underlyingAssets.UnderlyingAsset, moola(3), ), - details`wrong underlying asset`, + X`wrong underlying asset`, ); assert( simoleanAmountMath.isEqual( optionValue[0].strikePrice.StrikePrice, simoleans(7), ), - details`wrong strike price`, + X`wrong strike price`, ); - assert( - optionValue[0].expirationDate === 100, - details`wrong expiration date`, - ); - assert(optionValue[0].timeAuthority === timer, details`wrong timer`); + assert(optionValue[0].expirationDate === 100, X`wrong expiration date`); + assert(optionValue[0].timeAuthority === timer, X`wrong timer`); assert( UnderlyingAsset === moolaIssuer, - details`The underlyingAsset issuer should be the moola issuer`, + X`The underlyingAsset issuer should be the moola issuer`, ); assert( StrikePrice === simoleanIssuer, - details`The strikePrice issuer should be the simolean issuer`, + X`The strikePrice issuer should be the simolean issuer`, ); // Let's imagine that Bob wants to create a swap to trade this @@ -246,14 +234,14 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { assert( installation === installations.secondPriceAuction, - details`wrong installation`, + X`wrong installation`, ); assert( sameStructure( harden({ Asset: moolaIssuer, Ask: simoleanIssuer }), issuerKeywordRecord, ), - details`issuerKeywordRecord was not as expected`, + X`issuerKeywordRecord was not as expected`, ); assert(sameStructure(invitationValue[0].minimumBid, simoleans(3))); assert(sameStructure(invitationValue[0].auctionedAssets, moola(1))); @@ -290,25 +278,22 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { exclInvitation, ); - assert( - installation === installations.atomicSwap, - details`wrong installation`, - ); + assert(installation === installations.atomicSwap, X`wrong installation`); assert( sameStructure( harden({ Asset: moolaIssuer, Price: simoleanIssuer }), issuerKeywordRecord, ), - details`issuers were not as expected`, + X`issuers were not as expected`, ); assert( sameStructure(invitationValue[0].asset, moola(3)), - details`Alice made a different offer than expected`, + X`Alice made a different offer than expected`, ); assert( sameStructure(invitationValue[0].price, simoleans(7)), - details`Alice made a different offer than expected`, + X`Alice made a different offer than expected`, ); const proposal = harden({ @@ -343,15 +328,15 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { assert( installation === installations.simpleExchange, - details`wrong installation`, + X`wrong installation`, ); assert( issuerKeywordRecord.Asset === moolaIssuer, - details`The first issuer should be the moola issuer`, + X`The first issuer should be the moola issuer`, ); assert( issuerKeywordRecord.Price === simoleanIssuer, - details`The second issuer should be the simolean issuer`, + X`The second issuer should be the simolean issuer`, ); const bobBuyOrderProposal = harden({ @@ -386,15 +371,15 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { assert( installation === installations.simpleExchange, - details`wrong installation`, + X`wrong installation`, ); assert( issuerKeywordRecord.Asset === moolaIssuer, - details`The first issuer should be the moola issuer`, + X`The first issuer should be the moola issuer`, ); assert( issuerKeywordRecord.Price === simoleanIssuer, - details`The second issuer should be the simolean issuer`, + X`The second issuer should be the simolean issuer`, ); const bobBuyOrderProposal = harden({ want: { Asset: moola(m) }, @@ -433,10 +418,7 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { const buyBInvitation = await E(publicFacet).makeSwapInInvitation(); const installation = await E(zoe).getInstallation(buyBInvitation); const issuerKeywordRecord = await E(zoe).getIssuers(instance); - assert( - installation === installations.autoswap, - details`wrong installation`, - ); + assert(installation === installations.autoswap, X`wrong installation`); const liquidityIssuer = await E(publicFacet).getLiquidityIssuer(); assert( sameStructure( @@ -447,7 +429,7 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { }), issuerKeywordRecord, ), - details`issuers were not as expected`, + X`issuers were not as expected`, ); // bob checks how many simoleans he can get for 3 moola diff --git a/packages/zoe/test/swingsetTests/zoe/vat-carol.js b/packages/zoe/test/swingsetTests/zoe/vat-carol.js index c85dda15590..81722a537a4 100644 --- a/packages/zoe/test/swingsetTests/zoe/vat-carol.js +++ b/packages/zoe/test/swingsetTests/zoe/vat-carol.js @@ -1,5 +1,5 @@ import { E } from '@agoric/eventual-send'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { sameStructure } from '@agoric/same-structure'; import { showPurseBalance, setupIssuers } from '../helpers'; @@ -24,14 +24,14 @@ const build = async (log, zoe, issuers, payments, installations) => { assert( installation === installations.secondPriceAuction, - details`wrong installation`, + X`wrong installation`, ); assert( sameStructure( harden({ Asset: moolaIssuer, Ask: simoleanIssuer }), issuerKeywordRecord, ), - details`issuerKeywordRecord were not as expected`, + X`issuerKeywordRecord were not as expected`, ); assert(sameStructure(invitationValue[0].minimumBid, simoleans(3))); assert(sameStructure(invitationValue[0].auctionedAssets, moola(1))); diff --git a/packages/zoe/test/swingsetTests/zoe/vat-dave.js b/packages/zoe/test/swingsetTests/zoe/vat-dave.js index e94a37e5b48..df37b46165f 100644 --- a/packages/zoe/test/swingsetTests/zoe/vat-dave.js +++ b/packages/zoe/test/swingsetTests/zoe/vat-dave.js @@ -1,5 +1,5 @@ import { E } from '@agoric/eventual-send'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { sameStructure } from '@agoric/same-structure'; import { showPurseBalance, setupIssuers } from '../helpers'; @@ -31,14 +31,14 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { assert( installation === installations.secondPriceAuction, - details`wrong installation`, + X`wrong installation`, ); assert( sameStructure( harden({ Asset: moolaIssuer, Ask: simoleanIssuer }), issuerKeywordRecord, ), - details`issuerKeywordRecord were not as expected`, + X`issuerKeywordRecord were not as expected`, ); assert(sameStructure(invitationValue[0].minimumBid, simoleans(3))); assert(sameStructure(invitationValue[0].auctionedAssets, moola(1))); @@ -82,62 +82,56 @@ const build = async (log, zoe, issuers, payments, installations, timer) => { // pick some arbitrary code points as a signature. assert( source.includes('asset: give.Asset,'), - details`source bundle didn't match at "asset: give.Asset,"`, + X`source bundle didn't match at "asset: give.Asset,"`, ); assert( source.includes('swap(zcf, firstSeat, matchingSeat)'), - details`source bundle didn't match at "swap(zcf, firstSeat, matchingSeat)"`, + X`source bundle didn't match at "swap(zcf, firstSeat, matchingSeat)"`, ); assert( source.includes('makeMatchingInvitation'), - details`source bundle didn't match at "makeMatchingInvitation"`, - ); - assert( - installation === installations.atomicSwap, - details`wrong installation`, + X`source bundle didn't match at "makeMatchingInvitation"`, ); + assert(installation === installations.atomicSwap, X`wrong installation`); assert( sameStructure( harden({ Asset: invitationIssuer, Price: bucksIssuer }), issuerKeywordRecord, ), - details`issuerKeywordRecord were not as expected`, + X`issuerKeywordRecord were not as expected`, ); // Dave expects that Bob has already made an offer in the swap // with the following rules: assert( sameStructure(invitationValue[0].asset, optionAmounts), - details`asset is the option`, + X`asset is the option`, ); assert( sameStructure(invitationValue[0].price, bucks(1)), - details`price is 1 buck`, + X`price is 1 buck`, ); const optionValue = optionAmounts.value; assert( optionValue[0].description === 'exerciseOption', - details`wrong invitation`, + X`wrong invitation`, ); assert( moolaAmountMath.isEqual( optionValue[0].underlyingAssets.UnderlyingAsset, moola(3), ), - details`wrong underlying asset`, + X`wrong underlying asset`, ); assert( simoleanAmountMath.isEqual( optionValue[0].strikePrice.StrikePrice, simoleans(7), ), - details`wrong strike price`, - ); - assert( - optionValue[0].expirationDate === 100, - details`wrong expiration date`, + X`wrong strike price`, ); - assert(optionValue[0].timeAuthority === timer, details`wrong timer`); + assert(optionValue[0].expirationDate === 100, X`wrong expiration date`); + assert(optionValue[0].timeAuthority === timer, X`wrong timer`); // Dave escrows his 1 buck with Zoe and forms his proposal const daveSwapProposal = harden({ diff --git a/packages/zoe/test/unitTests/bounty.js b/packages/zoe/test/unitTests/bounty.js index 49db549da6f..1c3696d0938 100644 --- a/packages/zoe/test/unitTests/bounty.js +++ b/packages/zoe/test/unitTests/bounty.js @@ -1,5 +1,5 @@ import { E } from '@agoric/eventual-send'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; /** * This contract lets a funder endow a bounty that will pay out if an Oracle @@ -51,7 +51,7 @@ const start = async zcf => { const feeAmount = bountySeat.getCurrentAllocation().Fee; assert( feeMath.isGTE(feeAmount, fee), - details`Fee was required to be at least ${fee}`, + X`Fee was required to be at least ${fee}`, ); // The funder gets the fee regardless of the outcome. diff --git a/packages/zoe/test/unitTests/contracts/escrowToVote.js b/packages/zoe/test/unitTests/contracts/escrowToVote.js index bc58a1858a4..df3d770c012 100644 --- a/packages/zoe/test/unitTests/contracts/escrowToVote.js +++ b/packages/zoe/test/unitTests/contracts/escrowToVote.js @@ -1,6 +1,6 @@ // @ts-check -import { assert, details, q } from '@agoric/assert'; +import { assert, details as X, q } from '@agoric/assert'; import makeStore from '@agoric/store'; // Eventually will be importable from '@agoric/zoe-contract-support' import { @@ -40,7 +40,7 @@ const start = zcf => { const assertResponse = response => { assert( response === 'NO' || response === 'YES', - details`the answer ${q(response)} was not 'YES' or 'NO'`, + X`the answer ${q(response)} was not 'YES' or 'NO'`, ); // Throw an error if the response is not valid, but do not // exit the seat. We should allow the voter to recast their vote. @@ -59,7 +59,7 @@ const start = zcf => { vote: response => { // Throw if the offer is no longer active, i.e. the user has // completed their offer and the assets are no longer escrowed. - assert(!voterSeat.hasExited(), details`the voter seat has exited`); + assert(!voterSeat.hasExited(), X`the voter seat has exited`); assertResponse(response); diff --git a/packages/zoe/test/unitTests/contracts/test-oracle.js b/packages/zoe/test/unitTests/contracts/test-oracle.js index 83aa81710b1..42f905ba90b 100644 --- a/packages/zoe/test/unitTests/contracts/test-oracle.js +++ b/packages/zoe/test/unitTests/contracts/test-oracle.js @@ -6,7 +6,7 @@ import test from 'ava'; import bundleSource from '@agoric/bundle-source'; import { makeIssuerKit, MathKind } from '@agoric/ertp'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { E } from '@agoric/eventual-send'; import { makeFakeVatAdmin } from '../../../src/contractFacet/fakeVatAdmin'; @@ -60,7 +60,7 @@ test.before( requiredFee = feeAmount; assert( link.amountMath.isGTE(fee, requiredFee), - details`Minimum fee of ${feeAmount} not met; have ${fee}`, + X`Minimum fee of ${feeAmount} not met; have ${fee}`, ); } const reply = { pong: query }; diff --git a/packages/zoe/test/unitTests/contracts/test-simpleExchange.js b/packages/zoe/test/unitTests/contracts/test-simpleExchange.js index 5fa19e9c60f..ed2ce5f3cea 100644 --- a/packages/zoe/test/unitTests/contracts/test-simpleExchange.js +++ b/packages/zoe/test/unitTests/contracts/test-simpleExchange.js @@ -6,7 +6,7 @@ import test from 'ava'; // eslint-disable-next-line import/no-extraneous-dependencies import { E } from '@agoric/eventual-send'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; // noinspection ES6PreferShortImport import { setup } from '../setupBasicMints'; import { setupNonFungible } from '../setupNonFungibleMints'; @@ -121,11 +121,11 @@ test('simpleExchange with valid offers', async t => { assert( bobIssuers.Asset === moolaIssuer, - details`The Asset issuer should be the moola issuer`, + X`The Asset issuer should be the moola issuer`, ); assert( bobIssuers.Price === simoleanIssuer, - details`The Price issuer should be the simolean issuer`, + X`The Price issuer should be the simolean issuer`, ); // Bob creates a buy order, saying that he wants exactly 3 moola, @@ -350,11 +350,11 @@ test('simpleExchange with non-fungible assets', async t => { const bobIssuers = zoe.getIssuers(bobInstance); assert( bobIssuers.Asset === rpgIssuer, - details`The Asset issuer should be the RPG issuer`, + X`The Asset issuer should be the RPG issuer`, ); assert( bobIssuers.Price === ccIssuer, - details`The Price issuer should be the CryptoCat issuer`, + X`The Price issuer should be the CryptoCat issuer`, ); // Bob creates a buy order, saying that he wants the Spell of Binding, diff --git a/packages/zoe/tools/fakePriceAuthority.js b/packages/zoe/tools/fakePriceAuthority.js index 4a5ad393ec3..743177c1136 100644 --- a/packages/zoe/tools/fakePriceAuthority.js +++ b/packages/zoe/tools/fakePriceAuthority.js @@ -6,7 +6,7 @@ import { makeNotifierFromAsyncIterable, } from '@agoric/notifier'; import { E } from '@agoric/eventual-send'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; import { natSafeMath } from '../src/contractSupport'; @@ -46,7 +46,7 @@ export async function makeFakePriceAuthority(options) { assert( tradeList || priceList, - details`One of priceList or tradeList must be specified`, + X`One of priceList or tradeList must be specified`, ); const unitValueIn = mathIn.getValue(unitAmountIn); @@ -71,12 +71,12 @@ export async function makeFakePriceAuthority(options) { assert.equal( brandIn, mathIn.getBrand(), - details`${brandIn} is not an expected input brand`, + X`${brandIn} is not an expected input brand`, ); assert.equal( brandOut, mathOut.getBrand(), - details`${brandOut} is not an expected output brand`, + X`${brandOut} is not an expected output brand`, ); }; diff --git a/packages/zoe/tools/priceAuthorityRegistry.js b/packages/zoe/tools/priceAuthorityRegistry.js index 33fed5bd372..85fb7ec2086 100644 --- a/packages/zoe/tools/priceAuthorityRegistry.js +++ b/packages/zoe/tools/priceAuthorityRegistry.js @@ -2,7 +2,7 @@ import { E } from '@agoric/eventual-send'; import { makeStore } from '@agoric/store'; -import { assert, details } from '@agoric/assert'; +import { assert, details as X } from '@agoric/assert'; /** * @typedef {Object} Deleter @@ -139,7 +139,7 @@ export const makePriceAuthorityRegistry = () => { assert.equal( priceStore.has(brandOut) && priceStore.get(brandOut), record, - details`Price authority already dropped`, + X`Price authority already dropped`, ); priceStore.delete(brandOut); },