Skip to content

Commit

Permalink
fix: rename from FarClass to ExoClass, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Jan 21, 2023
1 parent efe227a commit 906d4a7
Show file tree
Hide file tree
Showing 44 changed files with 269 additions and 270 deletions.
4 changes: 2 additions & 2 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 { prepareFarClass } from '@agoric/vat-data';
import { prepareExoClass } from '@agoric/vat-data';

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

Expand All @@ -12,7 +12,7 @@ import { prepareFarClass } from '@agoric/vat-data';
* @returns {() => Payment<K>}
*/
export const preparePaymentKind = (issuerBaggage, name, brand, PaymentI) => {
const makePayment = prepareFarClass(
const makePayment = prepareExoClass(
issuerBaggage,
`${name} payment`,
PaymentI,
Expand Down
11 changes: 4 additions & 7 deletions packages/ERTP/src/paymentLedger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
import { isPromise } from '@endo/promise-kit';
import { assertCopyArray } from '@endo/marshal';
import { fit, M } from '@agoric/store';
import {
provideDurableWeakMapStore,
prepareFarInstance,
} from '@agoric/vat-data';
import { provideDurableWeakMapStore, prepareExo } from '@agoric/vat-data';
import { AmountMath } from './amountMath.js';
import { preparePaymentKind } from './payment.js';
import { preparePurseKind } from './purse.js';
Expand Down Expand Up @@ -84,7 +81,7 @@ export const preparePaymentLedger = (
optShutdownWithFailure = undefined,
) => {
/** @type {Brand<K>} */
const brand = prepareFarInstance(issuerBaggage, `${name} brand`, BrandI, {
const brand = prepareExo(issuerBaggage, `${name} brand`, BrandI, {
isMyIssuer(allegedIssuer) {
// BrandI delays calling this method until `allegedIssuer` is a Remotable
return allegedIssuer === issuer;
Expand Down Expand Up @@ -379,7 +376,7 @@ export const preparePaymentLedger = (
);

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

/** @type {Mint<K>} */
const mint = prepareFarInstance(issuerBaggage, `${name} mint`, MintI, {
const mint = prepareExo(issuerBaggage, `${name} mint`, MintI, {
getIssuer() {
return issuer;
},
Expand Down
4 changes: 2 additions & 2 deletions packages/ERTP/src/purse.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prepareFarClassKit, makeScalarBigSetStore } from '@agoric/vat-data';
import { prepareExoClassKit, makeScalarBigSetStore } from '@agoric/vat-data';
import { AmountMath } from './amountMath.js';
import { makeTransientNotifierKit } from './transientNotifier.js';

Expand Down Expand Up @@ -28,7 +28,7 @@ export const preparePurseKind = (
// 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 = prepareFarClassKit(
const makePurseKit = prepareExoClassKit(
issuerBaggage,
`${name} Purse`,
PurseIKit,
Expand Down
80 changes: 48 additions & 32 deletions packages/SwingSet/src/vats/vat-admin/vat-vat-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,38 +268,54 @@ export function buildRootObject(vatPowers, _vatParameters, baggage) {
);
}

const makeAdminNode = prepareKind(
baggage,
'adminNode',
vatID => ({ vatID }),
{
terminateWithFailure({ state }, reason) {
insistVatAdminServiceNotPaused();
assertRunningVat(state.vatID, 'terminateWithFailure');
exitingVats.add(state.vatID);
D(vatAdminDev).terminateWithFailure(state.vatID, reason);
},
done({ state }) {
// In some world it might make sense to allow this operation on
// terminated vats (since they *do* have a 'done' status after all,
// i.e., non-running) but we expect the promise that's returned here to
// reject if the vat fails, and if the vat has already exited then its
// exit status has been lost. However, by rejecting the 'done'
// operation itself we can signal the non-running condition without
// promoting the illusion that we know whether it exited cleanly or not.
assertRunningVat(state.vatID, 'done', true);
const [doneP] = runningVats.get(state.vatID);
return doneP;
},
upgrade({ state }, bundlecap, options) {
insistVatAdminServiceNotPaused();
assertRunningVat(state.vatID, 'upgrade');
let bundleID;
try {
bundleID = D(bundlecap).getBundleID();
} catch (e) {
// 'bundlecap' probably wasn't a bundlecap
Fail`vatAdmin.upgrade() requires a bundlecap: ${e}`;
const makeAdminNode = prepareKind(baggage, 'adminNode', vatID => ({ vatID }), {
terminateWithFailure({ state }, reason) {
insistVatAdminServiceNotPaused();
assertRunningVat(state.vatID, 'terminateWithFailure');
exitingVats.add(state.vatID);
D(vatAdminDev).terminateWithFailure(state.vatID, reason);
},
done({ state }) {
// In some world it might make sense to allow this operation on
// terminated vats (since they *do* have a 'done' status after all,
// i.e., non-running) but we expect the promise that's returned here to
// reject if the vat fails, and if the vat has already exited then its
// exit status has been lost. However, by rejecting the 'done'
// operation itself we can signal the non-running condition without
// promoting the illusion that we know whether it exited cleanly or not.
assertRunningVat(state.vatID, 'done', true);
const [doneP] = runningVats.get(state.vatID);
return doneP;
},
upgrade({ state }, bundlecap, options) {
insistVatAdminServiceNotPaused();
assertRunningVat(state.vatID, 'upgrade');
let bundleID;
try {
bundleID = D(bundlecap).getBundleID();
} catch (e) {
// 'bundlecap' probably wasn't a bundlecap
Fail`vatAdmin.upgrade() requires a bundlecap: ${e}`;
}
return upgradeVat(state.vatID, bundleID, options);
},
changeOptions({ state }, options) {
insistVatAdminServiceNotPaused();
assertRunningVat(state.vatID, 'changeOptions');
for (const option of Object.getOwnPropertyNames(options)) {
const value = options[option];
switch (option) {
case 'reapInterval':
assert(
value === 'never' || isNat(value),
'invalid reapInterval value',
);
break;
case 'virtualObjectCacheSize':
assert(isNat(value), 'invalid virtualObjectCacheSize value');
break;
default:
assert.fail(`invalid option "${option}"`);
}
return upgradeVat(state.vatID, bundleID, options);
},
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/test/vat-durable-singleton.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Far } from '@endo/marshal';
import { M } from '@agoric/store';
import { provide, prepareFarClassKit } from '@agoric/vat-data';
import { provide, prepareExoClassKit } from '@agoric/vat-data';

export const buildRootObject = (_vatPowers, vatParameters, baggage) => {
const { version } = vatParameters;
Expand All @@ -9,7 +9,7 @@ export const buildRootObject = (_vatPowers, vatParameters, baggage) => {
const emptyFacetI = M.interface('Facet', {});
const iKit = harden({ facet1: emptyFacetI, facet2: emptyFacetI });
const initState = () => ({});
const makeInstance = prepareFarClassKit(
const makeInstance = prepareExoClassKit(
baggage,
'ClassKit',
iKit,
Expand Down
8 changes: 4 additions & 4 deletions packages/governance/src/binaryVoteCounter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makePromiseKit } from '@endo/promise-kit';
import { makeHeapFarInstance, keyEQ, makeStore } from '@agoric/store';
import { makeHeapExo, keyEQ, makeStore } from '@agoric/store';
import { E } from '@endo/eventual-send';

import {
Expand Down Expand Up @@ -133,7 +133,7 @@ const makeBinaryVoteCounter = (
});
};

const closeFacet = makeHeapFarInstance(
const closeFacet = makeHeapExo(
'BinaryVoteCounter close',
BinaryVoteCounterCloseI,
{
Expand All @@ -144,7 +144,7 @@ const makeBinaryVoteCounter = (
},
);

const creatorFacet = makeHeapFarInstance(
const creatorFacet = makeHeapExo(
'BinaryVoteCounter creator',
BinaryVoteCounterAdminI,
{
Expand All @@ -165,7 +165,7 @@ const makeBinaryVoteCounter = (
},
);

const publicFacet = makeHeapFarInstance(
const publicFacet = makeHeapExo(
'BinaryVoteCounter public',
BinaryVoteCounterPublicI,
{
Expand Down
66 changes: 29 additions & 37 deletions packages/governance/src/committee.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeStoredPublishKit } from '@agoric/notifier';
import { makeStore, makeHeapFarInstance, M } from '@agoric/store';
import { makeStore, makeHeapExo, M } from '@agoric/store';
import { natSafeMath } from '@agoric/zoe/src/contractSupport/index.js';
import { E } from '@endo/eventual-send';

Expand Down Expand Up @@ -79,27 +79,23 @@ const start = (zcf, privateArgs) => {
// Ensure that the voter can't get access to the unwrapped voteCap, and
// has no control over the voteHandle or weight
return harden({
voter: makeHeapFarInstance(`voter${index}`, VoterI, {
voter: makeHeapExo(`voter${index}`, VoterI, {
castBallotFor(questionHandle, positions) {
const { voteCap } = allQuestions.get(questionHandle);
return E(voteCap).submitVote(voterHandle, positions, 1n);
},
}),
invitationMakers: makeHeapFarInstance(
'invitation makers',
InvitationMakerI,
{
makeVoteInvitation(positions, questionHandle) {
const continuingVoteHandler = cSeat => {
cSeat.exit();
const { voteCap } = allQuestions.get(questionHandle);
return E(voteCap).submitVote(voterHandle, positions, 1n);
};

return zcf.makeInvitation(continuingVoteHandler, 'vote');
},
invitationMakers: makeHeapExo('invitation makers', InvitationMakerI, {
makeVoteInvitation(positions, questionHandle) {
const continuingVoteHandler = cSeat => {
cSeat.exit();
const { voteCap } = allQuestions.get(questionHandle);
return E(voteCap).submitVote(voterHandle, positions, 1n);
};

return zcf.makeInvitation(continuingVoteHandler, 'vote');
},
),
}),
});
};

Expand All @@ -116,29 +112,25 @@ const start = (zcf, privateArgs) => {
[...Array(committeeSize).keys()].map(makeCommitteeVoterInvitation),
);

const publicFacet = makeHeapFarInstance(
'Committee publicFacet',
ElectoratePublicI,
{
getQuestionSubscriber() {
return questionsSubscriber;
},
getOpenQuestions() {
return getOpenQuestions(allQuestions);
},
getName() {
return committeeName;
},
getInstance() {
return zcf.getInstance();
},
getQuestion(handleP) {
return getQuestion(handleP, allQuestions);
},
const publicFacet = makeHeapExo('Committee publicFacet', ElectoratePublicI, {
getQuestionSubscriber() {
return questionsSubscriber;
},
);
getOpenQuestions() {
return getOpenQuestions(allQuestions);
},
getName() {
return committeeName;
},
getInstance() {
return zcf.getInstance();
},
getQuestion(handleP) {
return getQuestion(handleP, allQuestions);
},
});

const creatorFacet = makeHeapFarInstance(
const creatorFacet = makeHeapExo(
'Committee creatorFacet',
ElectorateCreatorI,
{
Expand Down
8 changes: 4 additions & 4 deletions packages/governance/src/multiCandidateVoteCounter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { keyEQ, makeHeapFarInstance, makeStore } from '@agoric/store';
import { keyEQ, makeHeapExo, makeStore } from '@agoric/store';
import { E } from '@endo/eventual-send';
import { makePromiseKit } from '@endo/promise-kit';
import {
Expand Down Expand Up @@ -150,7 +150,7 @@ const makeMultiCandidateVoteCounter = (
});
};

const closeFacet = makeHeapFarInstance(
const closeFacet = makeHeapExo(
'MultiCandidateVoteCounter close',
VoteCounterCloseI,
{
Expand All @@ -161,7 +161,7 @@ const makeMultiCandidateVoteCounter = (
},
);

const creatorFacet = makeHeapFarInstance(
const creatorFacet = makeHeapExo(
'MultiCandidateVoteCounter creator',
VoteCounterAdminI,
{
Expand All @@ -184,7 +184,7 @@ const makeMultiCandidateVoteCounter = (
},
);

const publicFacet = makeHeapFarInstance(
const publicFacet = makeHeapExo(
'MultiCandidateVoteCounter public',
VoteCounterPublicI,
{
Expand Down
6 changes: 3 additions & 3 deletions packages/governance/src/noActionElectorate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { makePublishKit } from '@agoric/notifier';
import { makePromiseKit } from '@endo/promise-kit';
import { makeHeapFarInstance } from '@agoric/store';
import { makeHeapExo } from '@agoric/store';

import { ElectoratePublicI, ElectorateCreatorI } from './typeGuards.js';

Expand All @@ -13,7 +13,7 @@ import { ElectoratePublicI, ElectorateCreatorI } from './typeGuards.js';
const start = zcf => {
const { subscriber } = makePublishKit();

const publicFacet = makeHeapFarInstance('publicFacet', ElectoratePublicI, {
const publicFacet = makeHeapExo('publicFacet', ElectoratePublicI, {
getQuestionSubscriber() {
return subscriber;
},
Expand All @@ -35,7 +35,7 @@ const start = zcf => {
},
});

const creatorFacet = makeHeapFarInstance('creatorFacet', ElectorateCreatorI, {
const creatorFacet = makeHeapExo('creatorFacet', ElectorateCreatorI, {
getPoserInvitation() {
return zcf.makeInvitation(() => {},
`noActionElectorate doesn't allow posing questions`);
Expand Down
4 changes: 2 additions & 2 deletions packages/governance/src/question.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeHeapFarInstance, fit, keyEQ, M } from '@agoric/store';
import { makeHeapExo, fit, keyEQ, M } from '@agoric/store';
import { makeHandle } from '@agoric/zoe/src/makeHandle.js';

import { QuestionI, QuestionSpecShape } from './typeGuards.js';
Expand Down Expand Up @@ -83,7 +83,7 @@ const buildQuestion = (questionSpec, counterInstance) => {
const questionHandle = makeHandle('Question');

/** @type {Question} */
return makeHeapFarInstance('question details', QuestionI, {
return makeHeapExo('question details', QuestionI, {
getVoteCounter() {
return counterInstance;
},
Expand Down
Loading

0 comments on commit 906d4a7

Please sign in to comment.