diff --git a/contract/src/postalSvc.js b/contract/src/postal-service.contract.js similarity index 96% rename from contract/src/postalSvc.js rename to contract/src/postal-service.contract.js index 045d8374..2fdd4880 100644 --- a/contract/src/postalSvc.js +++ b/contract/src/postal-service.contract.js @@ -14,7 +14,7 @@ const { keys, values } = Object; export const start = zcf => { const { namesByAddress, issuers } = zcf.getTerms(); mustMatch(namesByAddress, M.remotable('namesByAddress')); - console.log('postalSvc issuers', Object.keys(issuers)); + console.log('postal-service issuers', Object.keys(issuers)); /** * @param {string} addr diff --git a/contract/src/start-postalSvc.js b/contract/src/start-postalSvc.js index fdfb30b7..e0eaba65 100644 --- a/contract/src/start-postalSvc.js +++ b/contract/src/start-postalSvc.js @@ -1,5 +1,5 @@ /** - * @file core eval script* to start the postalSvc contract. + * @file core eval script* to start the postalService contract. * * * see rollup.config.mjs to make a script from this file. * @@ -10,53 +10,53 @@ import { E } from '@endo/far'; import { fixHub } from './fixHub.js'; -const trace = (...args) => console.log('start-postalSvc', ...args); +const trace = (...args) => console.log('start-postalService', ...args); const { Fail } = assert; /** - * @typedef { typeof import('../src/postalSvc.js').start } PostalSvcFn + * @typedef { typeof import('./postal-service.contract.js').start } PostalServiceFn * * @typedef {{ - * produce: { postalSvcKit: Producer }, + * produce: { postalServiceKit: Producer }, * installation: { - * consume: { postalSvc: Promise> }, - * produce: { postalSvc: Producer> }, + * consume: { postalService: Promise> }, + * produce: { postalService: Producer> }, * } * instance: { - * consume: { postalSvc: Promise['instance']> }, - * produce: { postalSvc: Producer['instance']> }, + * consume: { postalService: Promise['instance']> }, + * produce: { postalService: Producer['instance']> }, * } - * }} PostalSvcPowers + * }} PostalServicePowers */ /** * @param {BootstrapPowers} powers - * @param {{ options?: { postalSvc: { + * @param {{ options?: { postalService: { * bundleID: string; * issuerNames?: string[]; * }}}} [config] */ -export const startPostalSvc = async (powers, config) => { - /** @type { BootstrapPowers & PostalSvcPowers} */ +export const startPostalService = async (powers, config) => { + /** @type { BootstrapPowers & PostalServicePowers} */ // @ts-expect-error bootstrap powers evolve with BLD staker governance const postalPowers = powers; const { consume: { zoe, namesByAddressAdmin, agoricNames }, installation: { - produce: { postalSvc: produceInstallation }, + produce: { postalService: produceInstallation }, }, instance: { - produce: { postalSvc: produceInstance }, + produce: { postalService: produceInstance }, }, } = postalPowers; const { // separate line for bundling bundleID = Fail`no bundleID`, issuerNames = ['IST', 'Invitation', 'BLD', 'ATOM'], - } = config?.options?.postalSvc ?? {}; + } = config?.options?.postalService ?? {}; - /** @type {Installation} */ + /** @type {Installation} */ const installation = await E(zoe).installBundleID(bundleID); produceInstallation.resolve(installation); @@ -71,11 +71,11 @@ export const startPostalSvc = async (powers, config) => { }); produceInstance.resolve(instance); - trace('postalSvc started'); + trace('postalService started'); }; export const manifest = /** @type {const} */ ({ - [startPostalSvc.name]: { + [startPostalService.name]: { consume: { agoricNames: true, namesByAddress: true, @@ -83,14 +83,14 @@ export const manifest = /** @type {const} */ ({ zoe: true, }, installation: { - produce: { postalSvc: true }, + produce: { postalService: true }, }, instance: { - produce: { postalSvc: true }, + produce: { postalService: true }, }, }, }); export const permit = Object.values(manifest)[0]; -export const main = startPostalSvc; +export const main = startPostalService; diff --git a/contract/test/market-actors.js b/contract/test/market-actors.js index 04d35be7..f0176eb3 100644 --- a/contract/test/market-actors.js +++ b/contract/test/market-actors.js @@ -42,7 +42,7 @@ export const payerPete = async ( /** @type {WellKnown} */ const agoricNames = makeNameProxy(hub); - const instance = await agoricNames.instance.postalSvc; + const instance = await agoricNames.instance.postalService; t.log('Pete offers to send to', rxAddr, 'via contract', instance); /** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */ @@ -142,11 +142,11 @@ export const receiverRex = async (t, { wallet }, { toSend }) => { export const senderContract = async ( t, - { zoe, terms: { postalSvc: instance, destAddr: addr1 } }, + { zoe, terms: { postalService: instance, destAddr: addr1 } }, ) => { const iIssuer = await E(zoe).getInvitationIssuer(); const iBrand = await E(iIssuer).getBrand(); - const postalSvc = E(zoe).getPublicFacet(instance); + const postalService = E(zoe).getPublicFacet(instance); const purse = await E(iIssuer).makeEmptyPurse(); const noInvitations = AmountMath.make(iBrand, harden([])); @@ -154,13 +154,13 @@ export const senderContract = async ( t.log( 'senderContract: E(', - getInterfaceOf(await postalSvc), + getInterfaceOf(await postalService), ').sendTo(', addr1, ',', noInvitations, ')', ); - const sent = await E(postalSvc).sendTo(addr1, pmt1); + const sent = await E(postalService).sendTo(addr1, pmt1); t.deepEqual(sent, noInvitations); }; diff --git a/contract/test/test-postalSvc.js b/contract/test/test-postalSvc.js index 43a2aabf..74187d47 100644 --- a/contract/test/test-postalSvc.js +++ b/contract/test/test-postalSvc.js @@ -7,7 +7,7 @@ import { createRequire } from 'module'; import { E, passStyleOf } from '@endo/far'; import { AmountMath } from '@agoric/ertp/src/amountMath.js'; -import { startPostalSvc } from '../src/start-postalSvc.js'; +import { startPostalService } from '../src/start-postalSvc.js'; import { bootAndInstallBundles, makeMockTools } from './boot-tools.js'; import { makeBundleCacheContext, getBundleId } from './bundle-tools.js'; import { mockWalletFactory } from './wallet-tools.js'; @@ -58,7 +58,7 @@ test.serial('well-known brand (ATOM) is available', async t => { t.is(passStyleOf(brand.ATOM), 'remotable'); }); -test.serial('install bundle: postalSvc / send', async t => { +test.serial('install bundle: postalService / send', async t => { const { installBundles } = t.context; console.time('installBundles'); console.timeLog('installBundles', Object.keys(bundleRoots).length, 'todo'); @@ -67,27 +67,27 @@ test.serial('install bundle: postalSvc / send', async t => { ); console.timeEnd('installBundles'); - const id = getBundleId(bundles.postalSvc); + const id = getBundleId(bundles.postalService); const shortId = id.slice(0, 8); - t.log('postalSvc', shortId); + t.log('postalService', shortId); t.is(id.length, 3 + 128, 'bundleID length'); t.regex(id, /^b1-.../); Object.assign(t.context.shared, { bundles }); }); -test.serial('deploy contract with core eval: postalSvc / send', async t => { +test.serial('deploy contract with core eval: postalService / send', async t => { const { runCoreEval } = t.context; const { bundles } = t.context.shared; - const bundleID = getBundleId(bundles.postalSvc); + const bundleID = getBundleId(bundles.postalService); const name = 'send'; const result = await runCoreEval({ name, - behavior: startPostalSvc, - entryFile: scriptRoots.postalSvc, + behavior: startPostalService, + entryFile: scriptRoots.postalService, config: { - options: { postalSvc: { bundleID, issuerNames: ['ATOM', 'Item'] } }, + options: { postalService: { bundleID, issuerNames: ['ATOM', 'Item'] } }, }, }); @@ -100,12 +100,12 @@ test.serial('deploy contract with core eval: postalSvc / send', async t => { }); }); -test.serial('agoricNames.instances has contract: postalSvc', async t => { +test.serial('agoricNames.instances has contract: postalService', async t => { const { makeQueryTool } = t.context; const hub0 = makeAgoricNames(makeQueryTool()); const agoricNames = makeNameProxy(hub0); await null; - const instance = await agoricNames.instance.postalSvc; + const instance = await agoricNames.instance.postalService; t.log(instance); t.is(passStyleOf(instance), 'remotable'); }); @@ -151,12 +151,14 @@ test.serial('deliver payment using offer', async t => { test.todo('E2E: send using publicFacet using contract'); -test('send invitation* from contract using publicFacet of postalSvc', async t => { +test('send invitation* from contract using publicFacet of postalService', async t => { const { powers, bundles } = await bootAndInstallBundles(t, bundleRoots); - const bundleID = getBundleId(bundles.postalSvc); - await startPostalSvc(powers, { - options: { postalSvc: { bundleID, issuerNames: ['IST', 'Invitation'] } }, + const bundleID = getBundleId(bundles.postalService); + await startPostalService(powers, { + options: { + postalService: { bundleID, issuerNames: ['IST', 'Invitation'] }, + }, }); const { zoe, namesByAddressAdmin } = powers.consume; @@ -171,10 +173,10 @@ test('send invitation* from contract using publicFacet of postalSvc', async t => { zoe, namesByAddressAdmin }, smartWalletIssuers, ); - /** @type {import('../src/start-postalSvc.js').PostalSvcPowers} */ + /** @type {import('../src/start-postalSvc.js').PostalServicePowers} */ // @ts-expect-error cast const postalSpace = powers; - const instance = await postalSpace.instance.consume.postalSvc; + const instance = await postalSpace.instance.consume.postalService; const shared = { rxAddr: 'agoric1receiverRex', @@ -187,7 +189,7 @@ test('send invitation* from contract using publicFacet of postalSvc', async t => }; const wallet = await walletFactory.makeSmartWallet(shared.rxAddr); - const terms = { postalSvc: instance, destAddr: shared.rxAddr }; + const terms = { postalService: instance, destAddr: shared.rxAddr }; await Promise.all([ senderContract(t, { zoe, terms }), receiverRex(t, { wallet }, shared),