Skip to content

Commit

Permalink
fix: rename vivify to prepare (#6825)
Browse files Browse the repository at this point in the history
  • Loading branch information
erights authored Jan 21, 2023
1 parent 67ab902 commit 9261e42
Show file tree
Hide file tree
Showing 48 changed files with 315 additions and 283 deletions.
10 changes: 5 additions & 5 deletions packages/ERTP/src/issuerKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { makeScalarBigMapStore } from '@agoric/vat-data';

import { AssetKind, assertAssetKind } from './amountMath.js';
import { coerceDisplayInfo } from './displayInfo.js';
import { vivifyPaymentLedger } from './paymentLedger.js';
import { preparePaymentLedger } from './paymentLedger.js';

import './types-ambient.js';

Expand All @@ -24,7 +24,7 @@ import './types-ambient.js';
* See https://github.com/Agoric/agoric-sdk/issues/3434
* @returns {IssuerKit<K>}
*/
export const vivifyIssuerKit = (
export const prepareIssuerKit = (
issuerBaggage,
optShutdownWithFailure = undefined,
) => {
Expand All @@ -49,7 +49,7 @@ export const vivifyIssuerKit = (
// Attenuate the powerful authority to mint and change balances
/** @type {PaymentLedger<K>} */
// @ts-expect-error could be instantiated with different subtype of AssetKind
const { issuer, mint, brand } = vivifyPaymentLedger(
const { issuer, mint, brand } = preparePaymentLedger(
issuerBaggage,
name,
assetKind,
Expand All @@ -65,7 +65,7 @@ export const vivifyIssuerKit = (
displayInfo: cleanDisplayInfo,
});
};
harden(vivifyIssuerKit);
harden(prepareIssuerKit);

/**
* @template {AssetKind} K
Expand Down Expand Up @@ -109,7 +109,7 @@ export const makeDurableIssuerKit = (
issuerBaggage.init('assetKind', assetKind);
issuerBaggage.init('displayInfo', displayInfo);
issuerBaggage.init('elementShape', elementShape);
return vivifyIssuerKit(issuerBaggage, optShutdownWithFailure);
return prepareIssuerKit(issuerBaggage, optShutdownWithFailure);
};
harden(makeDurableIssuerKit);

Expand Down
8 changes: 4 additions & 4 deletions packages/ERTP/src/payment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { initEmpty } from '@agoric/store';
import { vivifyFarClass } from '@agoric/vat-data';
import { prepareFarClass } from '@agoric/vat-data';

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

Expand All @@ -11,8 +11,8 @@ import { vivifyFarClass } from '@agoric/vat-data';
* @param {InterfaceGuard} PaymentI
* @returns {() => Payment<K>}
*/
export const vivifyPaymentKind = (issuerBaggage, name, brand, PaymentI) => {
const makePayment = vivifyFarClass(
export const preparePaymentKind = (issuerBaggage, name, brand, PaymentI) => {
const makePayment = prepareFarClass(
issuerBaggage,
`${name} payment`,
PaymentI,
Expand All @@ -25,4 +25,4 @@ export const vivifyPaymentKind = (issuerBaggage, name, brand, PaymentI) => {
);
return makePayment;
};
harden(vivifyPaymentKind);
harden(preparePaymentKind);
20 changes: 10 additions & 10 deletions packages/ERTP/src/paymentLedger.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { assertCopyArray } from '@endo/marshal';
import { fit, M } from '@agoric/store';
import {
provideDurableWeakMapStore,
vivifyFarInstance,
prepareFarInstance,
} from '@agoric/vat-data';
import { AmountMath } from './amountMath.js';
import { vivifyPaymentKind } from './payment.js';
import { vivifyPurseKind } from './purse.js';
import { preparePaymentKind } from './payment.js';
import { preparePurseKind } from './purse.js';

import '@agoric/store/exported.js';
import { BrandI, makeIssuerInterfaces } from './typeGuards.js';
Expand Down Expand Up @@ -75,7 +75,7 @@ const amountShapeFromElementShape = (brand, assetKind, elementShape) => {
* @param {ShutdownWithFailure=} optShutdownWithFailure
* @returns {PaymentLedger<K>}
*/
export const vivifyPaymentLedger = (
export const preparePaymentLedger = (
issuerBaggage,
name,
assetKind,
Expand All @@ -84,7 +84,7 @@ export const vivifyPaymentLedger = (
optShutdownWithFailure = undefined,
) => {
/** @type {Brand<K>} */
const brand = vivifyFarInstance(issuerBaggage, `${name} brand`, BrandI, {
const brand = prepareFarInstance(issuerBaggage, `${name} brand`, BrandI, {
isMyIssuer(allegedIssuer) {
// BrandI delays calling this method until `allegedIssuer` is a Remotable
return allegedIssuer === issuer;
Expand Down Expand Up @@ -114,7 +114,7 @@ export const vivifyPaymentLedger = (
amountShape,
);

const makePayment = vivifyPaymentKind(issuerBaggage, name, brand, PaymentI);
const makePayment = preparePaymentKind(issuerBaggage, name, brand, PaymentI);

/** @type {ShutdownWithFailure} */
const shutdownLedgerWithFailure = reason => {
Expand Down Expand Up @@ -366,7 +366,7 @@ export const vivifyPaymentLedger = (
return payment;
};

const makeEmptyPurse = vivifyPurseKind(
const makeEmptyPurse = preparePurseKind(
issuerBaggage,
name,
assetKind,
Expand All @@ -379,7 +379,7 @@ export const vivifyPaymentLedger = (
);

/** @type {Issuer<K>} */
const issuer = vivifyFarInstance(issuerBaggage, `${name} issuer`, IssuerI, {
const issuer = prepareFarInstance(issuerBaggage, `${name} issuer`, IssuerI, {
getBrand() {
return brand;
},
Expand Down Expand Up @@ -477,7 +477,7 @@ export const vivifyPaymentLedger = (
});

/** @type {Mint<K>} */
const mint = vivifyFarInstance(issuerBaggage, `${name} mint`, MintI, {
const mint = prepareFarInstance(issuerBaggage, `${name} mint`, MintI, {
getIssuer() {
return issuer;
},
Expand All @@ -493,4 +493,4 @@ export const vivifyPaymentLedger = (
const issuerKit = harden({ issuer, mint, brand });
return issuerKit;
};
harden(vivifyPaymentLedger);
harden(preparePaymentLedger);
8 changes: 4 additions & 4 deletions packages/ERTP/src/purse.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { vivifyFarClassKit, makeScalarBigSetStore } from '@agoric/vat-data';
import { prepareFarClassKit, makeScalarBigSetStore } from '@agoric/vat-data';
import { AmountMath } from './amountMath.js';
import { makeTransientNotifierKit } from './transientNotifier.js';

const { Fail } = assert;

export const vivifyPurseKind = (
export const preparePurseKind = (
issuerBaggage,
name,
assetKind,
Expand All @@ -28,7 +28,7 @@ export const vivifyPurseKind = (
// that created depositFacet as needed. But this approach ensures a constant
// identity for the facet and exercises the multi-faceted object style.
const { depositInternal, withdrawInternal } = purseMethods;
const makePurseKit = vivifyFarClassKit(
const makePurseKit = prepareFarClassKit(
issuerBaggage,
`${name} Purse`,
PurseIKit,
Expand Down Expand Up @@ -112,4 +112,4 @@ export const vivifyPurseKind = (
);
return () => makePurseKit().purse;
};
harden(vivifyPurseKind);
harden(preparePurseKind);
18 changes: 11 additions & 7 deletions packages/ERTP/test/swingsetTests/ertpService/vat-ertp-service.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { Far } from '@endo/marshal';
import {
makeScalarBigMapStore,
vivifySingleton,
prepareSingleton,
provideDurableSetStore,
} from '@agoric/vat-data';

import { AssetKind, makeDurableIssuerKit, vivifyIssuerKit } from '../../../src';
import {
AssetKind,
makeDurableIssuerKit,
prepareIssuerKit,
} from '../../../src';

export const vivifyErtpService = (baggage, exitVatWithFailure) => {
export const prepareErtpService = (baggage, exitVatWithFailure) => {
const issuerBaggageSet = provideDurableSetStore(baggage, 'BaggageSet');
const ertpService = vivifySingleton(baggage, 'ERTPService', {
const ertpService = prepareSingleton(baggage, 'ERTPService', {
makeIssuerKit: (
name,
assetKind = AssetKind.NAT,
Expand All @@ -32,15 +36,15 @@ export const vivifyErtpService = (baggage, exitVatWithFailure) => {
});

for (const issuerBaggage of issuerBaggageSet.values()) {
vivifyIssuerKit(issuerBaggage);
prepareIssuerKit(issuerBaggage);
}

return ertpService;
};
harden(vivifyErtpService);
harden(prepareErtpService);

export const buildRootObject = async (vatPowers, _vatParams, baggage) => {
const ertpService = vivifyErtpService(baggage, vatPowers.exitVatWithFailure);
const ertpService = prepareErtpService(baggage, vatPowers.exitVatWithFailure);
return Far('root', {
getErtpService: () => ertpService,
});
Expand Down
22 changes: 11 additions & 11 deletions packages/SwingSet/src/vats/timer/vat-timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
provideDurableMapStore,
provideDurableWeakMapStore,
defineDurableKindMulti,
vivifyKind,
vivifySingleton,
prepareKind,
prepareSingleton,
} from '@agoric/vat-data';
import { makeScalarWeakMapStore } from '@agoric/store';
import { TimeMath } from './timeMath.js';
Expand Down Expand Up @@ -241,7 +241,7 @@ export const buildRootObject = (vatPowers, _vatParameters, baggage) => {

// These Kinds are the ongoing obligations of the vat: all future
// versions must define behaviors for these. Search for calls to
// 'vivifyKind', 'vivifySingleton', or 'defineDurableKindMulti'.
// 'prepareKind', 'prepareSingleton', or 'defineDurableKindMulti'.
// * oneShotEvent
// * promiseEvent
// * repeaterEvent
Expand Down Expand Up @@ -397,7 +397,7 @@ export const buildRootObject = (vatPowers, _vatParameters, baggage) => {
},
};

const makeOneShotEvent = vivifyKind(
const makeOneShotEvent = prepareKind(
baggage,
'oneShotEvent',
initOneShotEvent,
Expand Down Expand Up @@ -443,7 +443,7 @@ export const buildRootObject = (vatPowers, _vatParameters, baggage) => {
/**
* @returns { PromiseEvent }
*/
const makePromiseEvent = vivifyKind(
const makePromiseEvent = prepareKind(
baggage,
'promiseEvent',
initPromiseEvent,
Expand Down Expand Up @@ -546,7 +546,7 @@ export const buildRootObject = (vatPowers, _vatParameters, baggage) => {
},
};

const makeRepeaterEvent = vivifyKind(
const makeRepeaterEvent = prepareKind(
baggage,
'repeaterEvent',
initRepeaterEvent,
Expand Down Expand Up @@ -740,7 +740,7 @@ export const buildRootObject = (vatPowers, _vatParameters, baggage) => {
});
},
};
const createIterator = vivifyKind(
const createIterator = prepareKind(
baggage,
'timerIterator',
initIterator,
Expand Down Expand Up @@ -882,11 +882,11 @@ export const buildRootObject = (vatPowers, _vatParameters, baggage) => {

// -- now we finally build the TimerService

const wakeupHandler = vivifySingleton(baggage, 'wakeupHandler', {
const wakeupHandler = prepareSingleton(baggage, 'wakeupHandler', {
wake: processAndReschedule,
});

const timerService = vivifySingleton(baggage, 'timerService', {
const timerService = prepareSingleton(baggage, 'timerService', {
getCurrentTimestamp,
setWakeup /* one-shot with handler (absolute) */,
wakeAt /* one-shot with Promise (absolute) */,
Expand All @@ -900,13 +900,13 @@ export const buildRootObject = (vatPowers, _vatParameters, baggage) => {
});

// attenuated read-only facet
const timerClock = vivifySingleton(baggage, 'timerClock', {
const timerClock = prepareSingleton(baggage, 'timerClock', {
getCurrentTimestamp,
getTimerBrand: () => timerBrand,
});

// powerless identifier
const timerBrand = vivifySingleton(baggage, 'timerBrand', {
const timerBrand = prepareSingleton(baggage, 'timerBrand', {
isMyTimerService: alleged => alleged === timerService,
isMyClock: alleged => alleged === timerClock,
});
Expand Down
Loading

0 comments on commit 9261e42

Please sign in to comment.