diff --git a/packages/ERTP/src/displayInfo.js b/packages/ERTP/src/displayInfo.js index e13578e4d54..e669a9d456d 100644 --- a/packages/ERTP/src/displayInfo.js +++ b/packages/ERTP/src/displayInfo.js @@ -6,7 +6,6 @@ import { passStyleOf, REMOTE_STYLE, getInterfaceOf, - Data, } from '@agoric/marshal'; // TODO: assertSubset and assertKeysAllowed are copied from Zoe. Move @@ -64,7 +63,7 @@ export const coerceDisplayInfo = allegedDisplayInfo => { assert.equal(Reflect.ownKeys(allegedDisplayInfo).length, 0); assert.equal(Object.getPrototypeOf(allegedDisplayInfo), Object.prototype); assert.equal(getInterfaceOf(allegedDisplayInfo), undefined); - return Data({}); + return harden({}); } allegedDisplayInfo = pureCopy(allegedDisplayInfo); assertDisplayInfo(allegedDisplayInfo); diff --git a/packages/ERTP/test/unitTests/mathHelpers/test-setMathHelpers.js b/packages/ERTP/test/unitTests/mathHelpers/test-setMathHelpers.js index 4b0714b10b0..70217d0ac93 100644 --- a/packages/ERTP/test/unitTests/mathHelpers/test-setMathHelpers.js +++ b/packages/ERTP/test/unitTests/mathHelpers/test-setMathHelpers.js @@ -3,7 +3,7 @@ // eslint-disable-next-line import/no-extraneous-dependencies import test from 'ava'; -import { Far, Data } from '@agoric/marshal'; +import { Far } from '@agoric/marshal'; import { amountMath as m, MathKind } from '../../../src'; import { mockBrand } from './mockBrand'; @@ -115,7 +115,7 @@ const runSetMathHelpersTests = (t, [a, b, c], a2 = undefined) => { `m.isEmpty([]) is true`, ); t.throws( - () => m.isEmpty({ brand: mockBrand, value: Data({}) }), + () => m.isEmpty({ brand: mockBrand, value: harden({}) }), { message: `value (an object) must be a Nat or an array` }, `m.isEmpty({}) throws`, ); diff --git a/packages/ERTP/test/unitTests/test-issuerObj.js b/packages/ERTP/test/unitTests/test-issuerObj.js index 9179a70f8e0..1b2d3ee6632 100644 --- a/packages/ERTP/test/unitTests/test-issuerObj.js +++ b/packages/ERTP/test/unitTests/test-issuerObj.js @@ -3,7 +3,6 @@ // eslint-disable-next-line import/no-extraneous-dependencies import test from 'ava'; import { E } from '@agoric/eventual-send'; -import { Data } from '@agoric/marshal'; import { MathKind, makeIssuerKit, amountMath } from '../../src'; test('issuer.getBrand, brand.isMyIssuer', t => { @@ -48,7 +47,7 @@ test('bad display info', t => { }); test('empty display info', t => { - const displayInfo = Data({}); + const displayInfo = harden({}); const { brand } = makeIssuerKit('fungible', MathKind.NAT, displayInfo); t.deepEqual(brand.getDisplayInfo(), displayInfo); }); diff --git a/packages/SwingSet/src/kernel/initializeKernel.js b/packages/SwingSet/src/kernel/initializeKernel.js index 4bc4b72ca97..dd4ea4125ac 100644 --- a/packages/SwingSet/src/kernel/initializeKernel.js +++ b/packages/SwingSet/src/kernel/initializeKernel.js @@ -1,6 +1,6 @@ /* eslint-disable no-use-before-define */ -import { makeMarshal, Far, Data } from '@agoric/marshal'; +import { makeMarshal, Far } from '@agoric/marshal'; import { assert, details as X } from '@agoric/assert'; import { assertKnownOptions } from '../assertOptions'; import { insistVatID } from './id'; @@ -169,7 +169,7 @@ export function initializeKernel(config, hostStorage, verbose = false) { const m = makeMarshal(convertValToSlot, undefined, { marshalName: 'kernel:bootstrap', }); - const args = harden([Data(vatObj0s), Data(deviceObj0s)]); + const args = harden([vatObj0s, deviceObj0s]); // queueToExport() takes kernel-refs (ko+NN, kd+NN) in s.slots const rootSlot = makeVatRootObjectSlot(); const resultKpid = doQueueToExport( diff --git a/packages/cosmic-swingset/lib/ag-solo/vats/captp.js b/packages/cosmic-swingset/lib/ag-solo/vats/captp.js index 3c2ed577d8e..abb775b04d0 100644 --- a/packages/cosmic-swingset/lib/ag-solo/vats/captp.js +++ b/packages/cosmic-swingset/lib/ag-solo/vats/captp.js @@ -2,7 +2,6 @@ // in its own makeHardener, etc. import { makeCapTP } from '@agoric/captp/lib/captp'; import { E } from '@agoric/eventual-send'; -import { Data } from '@agoric/marshal'; export const getCapTPHandler = ( send, @@ -12,7 +11,7 @@ export const getCapTPHandler = ( const chans = new Map(); const doFallback = async (method, ...args) => { if (!fallback) { - return Data({}); + return harden({}); } return E(fallback)[method](...args); }; 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 b55437dee9a..37ef5910213 100644 --- a/packages/cosmic-swingset/lib/ag-solo/vats/vat-http.js +++ b/packages/cosmic-swingset/lib/ag-solo/vats/vat-http.js @@ -114,7 +114,7 @@ export function buildRootObject(vatPowers) { ...decentralObjects, // TODO: Remove; replaced by .agoric ...privateObjects, // TODO: Remove; replaced by .local ...handyObjects, - agoric: { ...decentralObjects }, // TODO: maybe needs Data()??? + agoric: { ...decentralObjects }, local: { ...privateObjects }, }; diff --git a/packages/dapp-svelte-wallet/api/src/lib-wallet.js b/packages/dapp-svelte-wallet/api/src/lib-wallet.js index 417ab60fee9..e63f2e6f07e 100644 --- a/packages/dapp-svelte-wallet/api/src/lib-wallet.js +++ b/packages/dapp-svelte-wallet/api/src/lib-wallet.js @@ -17,7 +17,7 @@ import { makeIssuerTable } from '@agoric/zoe/src/issuerTable'; import { E } from '@agoric/eventual-send'; -import { makeMarshal, passStyleOf, Far, Data } from '@agoric/marshal'; +import { makeMarshal, passStyleOf, Far } from '@agoric/marshal'; import { makeNotifierKit, observeNotifier } from '@agoric/notifier'; import { makePromiseKit } from '@agoric/promise-kit'; @@ -470,7 +470,7 @@ export function makeWallet({ // Payments are made for the keywords in proposal.give. const keywords = []; - const paymentPs = Object.entries(proposal.give || Data({})).map( + const paymentPs = Object.entries(proposal.give || harden({})).map( ([keyword, amount]) => { const purse = purseKeywordRecord[keyword]; assert( @@ -491,7 +491,7 @@ export function makeWallet({ // for the offer. const payments = await Promise.all(paymentPs); - const paymentKeywordRecord = Data( + const paymentKeywordRecord = harden( Object.fromEntries(keywords.map((keyword, i) => [keyword, payments[i]])), ); @@ -691,15 +691,15 @@ export function makeWallet({ const compileProposal = proposalTemplate => { const { - want = Data({}), - give = Data({}), + want = harden({}), + give = harden({}), exit = { onDemand: null }, } = proposalTemplate; const purseKeywordRecord = {}; const compile = amountKeywordRecord => { - return Data( + return harden( Object.fromEntries( Object.entries(amountKeywordRecord).map( ([keyword, { pursePetname, value }]) => { diff --git a/packages/dapp-svelte-wallet/api/test/test-lib-wallet.js b/packages/dapp-svelte-wallet/api/test/test-lib-wallet.js index 5a875e54537..123f234d027 100644 --- a/packages/dapp-svelte-wallet/api/test/test-lib-wallet.js +++ b/packages/dapp-svelte-wallet/api/test/test-lib-wallet.js @@ -7,7 +7,6 @@ import test from 'ava'; // eslint-disable-next-line import/no-extraneous-dependencies import bundleSource from '@agoric/bundle-source'; import { makeIssuerKit, makeLocalAmountMath } from '@agoric/ertp'; -import { Data } from '@agoric/marshal'; import { makeZoe } from '@agoric/zoe'; import fakeVatAdmin from '@agoric/zoe/src/contractFacet/fakeVatAdmin'; @@ -276,7 +275,7 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t inviteHandleBoardId, - proposalTemplate: Data({}), + proposalTemplate: {}, }); const rawId = '1588645041696'; @@ -1201,7 +1200,7 @@ test('addOffer makeContinuingInvitation', async t => { instance, description: 'FirstThing', }, - proposalTemplate: Data({}), + proposalTemplate: harden({}), }; await wallet.addOffer(offer); @@ -1224,7 +1223,7 @@ test('addOffer makeContinuingInvitation', async t => { priorOfferId: rawId, description: 'SecondThing', }, - proposalTemplate: Data({}), + proposalTemplate: harden({}), }; await wallet.addOffer(offer2); diff --git a/packages/swingset-runner/src/vat-launcher.js b/packages/swingset-runner/src/vat-launcher.js index f0905f191eb..6d3f2c5e35a 100644 --- a/packages/swingset-runner/src/vat-launcher.js +++ b/packages/swingset-runner/src/vat-launcher.js @@ -1,5 +1,5 @@ import { E } from '@agoric/eventual-send'; -import { Far, Data } from '@agoric/marshal'; +import { Far } from '@agoric/marshal'; /* * Vat to launch other vats. @@ -41,14 +41,14 @@ export function buildRootObject(_vatPowers, vatParameters) { // eslint-disable-next-line no-await-in-loop const vat = await E(vatMaker).createVatByName( bundleName, - { metered: vatParameters.metered, vatParameters: Data(subvatParameters) }, + { metered: vatParameters.metered, vatParameters: harden(subvatParameters) }, ); vatRoots[vatName] = vat.root; } vatRoots.vatAdmin = vats.vatAdmin; bootstrapRoot = vatRoots[vatParameters.config.bootstrap]; // prettier-ignore - return E(bootstrapRoot).bootstrap(Data(vatRoots), devices); + return E(bootstrapRoot).bootstrap(harden(vatRoots), devices); }, runBenchmarkRound() { return E(bootstrapRoot).runBenchmarkRound(); diff --git a/packages/zoe/src/cleanProposal.js b/packages/zoe/src/cleanProposal.js index 982bb100eae..1bbcc24f570 100644 --- a/packages/zoe/src/cleanProposal.js +++ b/packages/zoe/src/cleanProposal.js @@ -1,7 +1,6 @@ import { assert, details as X, q } from '@agoric/assert'; import { mustBeComparable } from '@agoric/same-structure'; import { isNat } from '@agoric/nat'; -import { Data } from '@agoric/marshal'; import '../exported'; import './internal-types'; @@ -111,7 +110,7 @@ export const cleanProposal = (getAmountMath, proposal) => { assertKeysAllowed(rootKeysAllowed, proposal); // We fill in the default values if the keys are undefined. - let { want = Data({}), give = Data({}) } = proposal; + let { want = harden({}), give = harden({}) } = proposal; const { exit = harden({ onDemand: null }) } = proposal; want = coerceAmountKeywordRecord(getAmountMath, want); diff --git a/packages/zoe/src/contractFacet/contractFacet.js b/packages/zoe/src/contractFacet/contractFacet.js index 8a1ca3e02f1..20ed0de0966 100644 --- a/packages/zoe/src/contractFacet/contractFacet.js +++ b/packages/zoe/src/contractFacet/contractFacet.js @@ -10,7 +10,7 @@ import { assert, details as X, q, makeAssert } from '@agoric/assert'; import { E } from '@agoric/eventual-send'; import { makeStore, makeWeakStore } from '@agoric/store'; -import { Far, Data } from '@agoric/marshal'; +import { Far } from '@agoric/marshal'; import { makeAmountMath, MathKind } from '@agoric/ertp'; import { makeNotifierKit, observeNotifier } from '@agoric/notifier'; @@ -148,7 +148,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { }; const makeEmptySeatKit = (exit = undefined) => { - const initialAllocation = Data({}); + const initialAllocation = harden({}); const proposal = cleanProposal(getAmountMath, harden({ exit })); const { notifier, updater } = makeNotifierKit(); /** @type {PromiseRecord} */ @@ -252,7 +252,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { : amountToAdd; return [seatKeyword, newAmount]; }); - const newAllocation = Data({ + const newAllocation = harden({ ...oldAllocation, ...updates, }); @@ -291,7 +291,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { return [seatKeyword, newAmount]; }, ); - const newAllocation = Data({ + const newAllocation = harden({ ...oldAllocation, ...updates, }); @@ -368,7 +368,7 @@ export function buildRootObject(powers, _params, testJigSetter = undefined) { makeInvitation: ( offerHandler = () => {}, description, - customProperties = Data({}), + customProperties = harden({}), ) => { assert.typeof( description, diff --git a/packages/zoe/src/contractFacet/seat.js b/packages/zoe/src/contractFacet/seat.js index 9ad34dfe2ed..31481ac04d3 100644 --- a/packages/zoe/src/contractFacet/seat.js +++ b/packages/zoe/src/contractFacet/seat.js @@ -2,7 +2,7 @@ import { E } from '@agoric/eventual-send'; import { assert, details as X } from '@agoric/assert'; -import { Data, Far } from '@agoric/marshal'; +import { Far } from '@agoric/marshal'; import { isOfferSafe } from './offerSafety'; @@ -88,7 +88,7 @@ export const makeZcfSeatAdminKit = ( }, isOfferSafe: newAllocation => { assertExitedFalse(); - const reallocation = Data({ + const reallocation = harden({ ...currentAllocation, ...newAllocation, }); @@ -98,7 +98,7 @@ export const makeZcfSeatAdminKit = ( stage: newAllocation => { assertExitedFalse(); // Check offer safety. - const allocation = Data({ + const allocation = harden({ ...currentAllocation, ...newAllocation, }); diff --git a/packages/zoe/src/contractSupport/zoeHelpers.js b/packages/zoe/src/contractSupport/zoeHelpers.js index 61e0eb08924..60ebd67718b 100644 --- a/packages/zoe/src/contractSupport/zoeHelpers.js +++ b/packages/zoe/src/contractSupport/zoeHelpers.js @@ -7,7 +7,6 @@ import { E } from '@agoric/eventual-send'; import { makePromiseKit } from '@agoric/promise-kit'; import { MathKind } from '@agoric/ertp'; -import { Data } from '@agoric/marshal'; import { satisfiesWant } from '../contractFacet/offerSafety'; import { objectMap } from '../objArrayConversion'; @@ -409,7 +408,7 @@ export async function withdrawFromSeat(zcf, seat, amounts) { * @param {IssuerKeywordRecord} issuerKeywordRecord Issuers to save to * ZCF */ -export async function saveAllIssuers(zcf, issuerKeywordRecord = Data({})) { +export async function saveAllIssuers(zcf, issuerKeywordRecord = harden({})) { const { issuers } = zcf.getTerms(); const issuersPSaved = Object.entries(issuerKeywordRecord).map( ([keyword, issuer]) => { diff --git a/packages/zoe/src/contracts/otcDesk.js b/packages/zoe/src/contracts/otcDesk.js index f8935544708..315a0c4d69c 100644 --- a/packages/zoe/src/contracts/otcDesk.js +++ b/packages/zoe/src/contracts/otcDesk.js @@ -2,7 +2,7 @@ import { E } from '@agoric/eventual-send'; import { assert } from '@agoric/assert'; -import { Data, Far } from '@agoric/marshal'; +import { Far } from '@agoric/marshal'; import { trade, offerTo, @@ -125,7 +125,7 @@ const start = zcf => { * @param {IssuerKeywordRecord=} issuerKeywordRecord * @returns {Promise} */ - makeAddInventoryInvitation: async (issuerKeywordRecord = Data({})) => { + makeAddInventoryInvitation: async (issuerKeywordRecord = harden({})) => { await saveAllIssuers(zcf, issuerKeywordRecord); return zcf.makeInvitation(addInventory, 'addInventory'); }, diff --git a/packages/zoe/src/objArrayConversion.js b/packages/zoe/src/objArrayConversion.js index 14da64d04a4..b88bd71646d 100644 --- a/packages/zoe/src/objArrayConversion.js +++ b/packages/zoe/src/objArrayConversion.js @@ -1,6 +1,5 @@ // @ts-check -import { Data } from '@agoric/marshal'; import { assert, details as X, q } from '@agoric/assert'; /** @@ -23,7 +22,7 @@ export const arrayToObj = (array, keys) => { /** @type {Record} */ ({}); keys.forEach((key, i) => (obj[key] = array[i])); - return Data(obj); + return harden(obj); }; /** @@ -88,5 +87,5 @@ export const assertSubset = (whole, part) => { export const objectMap = (original, mapPairFn) => { const ents = /** @type {[K, T][]} */ (Object.entries(original)); const mapEnts = ents.map(ent => mapPairFn(ent)); - return /** @type {Record} */ (Data(Object.fromEntries(mapEnts))); + return /** @type {Record} */ (harden(Object.fromEntries(mapEnts))); }; diff --git a/packages/zoe/src/zoeService/zoe.js b/packages/zoe/src/zoeService/zoe.js index 11ae30a2beb..cd2d703811a 100644 --- a/packages/zoe/src/zoeService/zoe.js +++ b/packages/zoe/src/zoeService/zoe.js @@ -14,7 +14,7 @@ import { makeIssuerKit, MathKind } from '@agoric/ertp'; import '../../exported'; import '../internal-types'; -import { Data, Far } from '@agoric/marshal'; +import { Far } from '@agoric/marshal'; import { makeIssuerTable } from '../issuerTable'; import { makeZoeSeatAdminKit } from './zoeSeat'; import zcfContractBundle from '../../bundles/bundle-contractFacet'; @@ -97,8 +97,8 @@ function makeZoe(vatAdminSvc, zcfBundleName = undefined) { }, startInstance: async ( installationP, - uncleanIssuerKeywordRecord = Data({}), - customTerms = Data({}), + uncleanIssuerKeywordRecord = harden({}), + customTerms = harden({}), ) => { /** @param {Issuer[]} issuers */ const initIssuers = issuers => @@ -356,7 +356,7 @@ function makeZoe(vatAdminSvc, zcfBundleName = undefined) { zoeService, invitationIssuer, zoeInstanceAdminForZcf, - Data({ ...instanceRecord }), + harden({ ...instanceRecord }), ); addSeatObjPromiseKit.resolve(addSeatObj); @@ -395,8 +395,8 @@ function makeZoe(vatAdminSvc, zcfBundleName = undefined) { }, offer: async ( invitation, - uncleanProposal = Data({}), - paymentKeywordRecord = Data({}), + uncleanProposal = harden({}), + paymentKeywordRecord = harden({}), ) => { return invitationKit.issuer.burn(invitation).then( invitationAmount => { diff --git a/packages/zoe/test/unitTests/contractSupport/test-offerTo.js b/packages/zoe/test/unitTests/contractSupport/test-offerTo.js index 6736ee08f2f..a559c36d835 100644 --- a/packages/zoe/test/unitTests/contractSupport/test-offerTo.js +++ b/packages/zoe/test/unitTests/contractSupport/test-offerTo.js @@ -7,7 +7,6 @@ import '@agoric/install-ses'; import test from 'ava'; import { E } from '@agoric/eventual-send'; -import { Data } from '@agoric/marshal'; import bundleSource from '@agoric/bundle-source'; import { setup } from '../setupBasicMints'; @@ -98,7 +97,7 @@ test(`offerTo - basic usage`, async t => { const { zcfSeat: fromSeatContractA } = await makeOffer( zoe, zcfA, - harden({ want: Data({}), give: { TokenK: bucks(5) } }), + harden({ want: harden({}), give: { TokenK: bucks(5) } }), harden({ TokenK: bucksMint.mintPayment(bucks(5)) }), ); diff --git a/packages/zoe/test/unitTests/contractSupport/test-zoeHelpers.js b/packages/zoe/test/unitTests/contractSupport/test-zoeHelpers.js index 2d7f1060bf3..4adc4fecaff 100644 --- a/packages/zoe/test/unitTests/contractSupport/test-zoeHelpers.js +++ b/packages/zoe/test/unitTests/contractSupport/test-zoeHelpers.js @@ -2,7 +2,7 @@ import '@agoric/install-ses'; // eslint-disable-next-line import/no-extraneous-dependencies import test from 'ava'; -import { Far, Data } from '@agoric/marshal'; +import { Far } from '@agoric/marshal'; import makeStore from '@agoric/store'; import { setup } from '../setupBasicMints'; @@ -48,7 +48,7 @@ test('ZoeHelpers satisfies blank proposal', t => { const { moolaR, moola } = setup(); const fakeZcfSeat = Far('fakeZcfSeat', { getCurrentAllocation: () => harden({ Asset: moola(10) }), - getProposal: () => Data({}), + getProposal: () => harden({}), }); const mockZCFBuilder = makeMockTradingZcfBuilder(); mockZCFBuilder.addBrand(moolaR); diff --git a/packages/zoe/test/unitTests/contracts/loan/test-liquidate.js b/packages/zoe/test/unitTests/contracts/loan/test-liquidate.js index 39ad12f5728..df3f6eb88ee 100644 --- a/packages/zoe/test/unitTests/contracts/loan/test-liquidate.js +++ b/packages/zoe/test/unitTests/contracts/loan/test-liquidate.js @@ -7,7 +7,6 @@ import '@agoric/install-ses'; // eslint-disable-next-line import/no-extraneous-dependencies import test from 'ava'; -import { Data } from '@agoric/marshal'; import { doLiquidation } from '../../../../src/contracts/loan/liquidate'; import { @@ -24,8 +23,8 @@ test('test doLiquidation with mocked autoswap', async t => { // Set up the lender seat. At this point the lender has nothing. const { zcfSeat: lenderSeat, userSeat: lenderUserSeat } = await makeSeatKit( zcf, - { give: Data({}) }, - Data({}), + { give: harden({}) }, + harden({}), ); const collateral = collateralKit.amountMath.make(10); @@ -113,8 +112,8 @@ test('test with malfunctioning autoswap', async t => { // Set up the lender seat. At this point the lender has nothing. const { zcfSeat: lenderSeat, userSeat: lenderUserSeat } = await makeSeatKit( zcf, - { give: Data({}) }, - Data({}), + { give: harden({}) }, + harden({}), ); const collateral = collateralKit.amountMath.make(10); diff --git a/packages/zoe/test/unitTests/test-cleanProposal.js b/packages/zoe/test/unitTests/test-cleanProposal.js index 99cb691ceec..74fab64f007 100644 --- a/packages/zoe/test/unitTests/test-cleanProposal.js +++ b/packages/zoe/test/unitTests/test-cleanProposal.js @@ -3,7 +3,6 @@ import '@agoric/install-ses'; // eslint-disable-next-line import/no-extraneous-dependencies import test from 'ava'; import { makeWeakStore } from '@agoric/store'; -import { Data } from '@agoric/marshal'; import { cleanProposal } from '../../src/cleanProposal'; import { setup } from './setupBasicMints'; import buildManualTimer from '../../tools/manualTimer'; @@ -45,14 +44,14 @@ test('cleanProposal - all empty', t => { const getAmountMathForBrand = brandToAmountMath.get; const proposal = harden({ - give: Data({}), - want: Data({}), + give: harden({}), + want: harden({}), exit: { waived: null }, }); const expected = harden({ - give: Data({}), - want: Data({}), + give: harden({}), + want: harden({}), exit: { waived: null }, });