Skip to content

Commit

Permalink
better names post scope cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed May 31, 2019
1 parent f9417b6 commit 3ae77b4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 38 deletions.
68 changes: 42 additions & 26 deletions demo/contractHost/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function build(E, log) {
});
}

function betterContractTestAliceFirst(host, mint, aliceI, bobI) {
function betterContractTestAliceFirst(host, mint, aliceMaker, bobMaker) {
const escrowExchangeInstallationP = E(host).install(escrowExchangeSrc);
const coveredCallInstallationP = E(host).install(coveredCallSrc);

Expand All @@ -129,14 +129,14 @@ function build(E, log) {
const aliceStockPurseP = E(stockMintP).mint(2002);
const bobStockPurseP = E(stockMintP).mint(2003);

const aliceP = E(aliceI).init(
const aliceP = E(aliceMaker).make(
escrowExchangeInstallationP,
coveredCallInstallationP,
fakeNeverTimer,
aliceMoneyPurseP,
aliceStockPurseP,
);
const bobP = E(bobI).init(
const bobP = E(bobMaker).make(
escrowExchangeInstallationP,
coveredCallInstallationP,
fakeNeverTimer,
Expand All @@ -156,7 +156,7 @@ function build(E, log) {
});
}

function betterContractTestBobFirst(host, mint, aliceI, bobI) {
function betterContractTestBobFirst(host, mint, aliceMaker, bobMaker) {
const escrowExchangeInstallationP = E(host).install(escrowExchangeSrc);
const coveredCallInstallationP = E(host).install(coveredCallSrc);

Expand All @@ -168,14 +168,14 @@ function build(E, log) {
const aliceStockPurseP = E(stockMintP).mint(2002, 'aliceMainStock');
const bobStockPurseP = E(stockMintP).mint(2003, 'bobMainStock');

const aliceP = E(aliceI).init(
const aliceP = E(aliceMaker).make(
escrowExchangeInstallationP,
coveredCallInstallationP,
fakeNeverTimer,
aliceMoneyPurseP,
aliceStockPurseP,
);
const bobP = E(bobI).init(
const bobP = E(bobMaker).make(
escrowExchangeInstallationP,
coveredCallInstallationP,
fakeNeverTimer,
Expand All @@ -201,7 +201,7 @@ function build(E, log) {
});
}

function coveredCallTest(host, mint, aliceI, bobI) {
function coveredCallTest(host, mint, aliceMaker, bobMaker) {
const escrowExchangeInstallationP = E(host).install(escrowExchangeSrc);
const coveredCallInstallationP = E(host).install(coveredCallSrc);

Expand All @@ -213,14 +213,14 @@ function build(E, log) {
const aliceStockPurseP = E(stockMintP).mint(2002, 'aliceMainStock');
const bobStockPurseP = E(stockMintP).mint(2003, 'bobMainStock');

const aliceP = E(aliceI).init(
const aliceP = E(aliceMaker).make(
escrowExchangeInstallationP,
coveredCallInstallationP,
fakeNeverTimer,
aliceMoneyPurseP,
aliceStockPurseP,
);
const bobP = E(bobI).init(
const bobP = E(bobMaker).make(
escrowExchangeInstallationP,
coveredCallInstallationP,
fakeNeverTimer,
Expand All @@ -246,7 +246,7 @@ function build(E, log) {
});
}

function coveredCallSaleTest(host, mint, aliceI, bobI, fredI) {
function coveredCallSaleTest(host, mint, aliceMaker, bobMaker, fredMaker) {
const escrowExchangeInstallationP = E(host).install(escrowExchangeSrc);
const coveredCallInstallationP = E(host).install(coveredCallSrc);

Expand All @@ -264,22 +264,22 @@ function build(E, log) {
const aliceFinPurseP = E(finMintP).mint(3000, 'aliceFins');
const fredFinPurseP = E(finMintP).mint(3001, 'fredFins');

const bobP = E(bobI).init(
const bobP = E(bobMaker).make(
escrowExchangeInstallationP,
coveredCallInstallationP,
fakeNeverTimer,
bobDoughPurseP,
bobStockPurseP,
);
const fredP = E(fredI).init(
const fredP = E(fredMaker).make(
escrowExchangeInstallationP,
coveredCallInstallationP,
fakeNeverTimer,
fredDoughPurseP,
fredStockPurseP,
fredFinPurseP,
);
const aliceP = E(aliceI).init(
const aliceP = E(aliceMaker).make(
escrowExchangeInstallationP,
coveredCallInstallationP,
fakeNeverTimer,
Expand Down Expand Up @@ -327,28 +327,44 @@ function build(E, log) {
}
case 'alice-first': {
const host = await E(vats.host).makeHost();
const aliceI = await E(vats.alice).makeAlice(host);
const bobI = await E(vats.bob).makeBob(host);
return betterContractTestAliceFirst(host, vats.mint, aliceI, bobI);
const aliceMaker = await E(vats.alice).makeAliceMaker(host);
const bobMaker = await E(vats.bob).makeBobMaker(host);
return betterContractTestAliceFirst(
host,
vats.mint,
aliceMaker,
bobMaker,
);
}
case 'bob-first': {
const host = await E(vats.host).makeHost();
const aliceI = await E(vats.alice).makeAlice(host);
const bobI = await E(vats.bob).makeBob(host);
return betterContractTestBobFirst(host, vats.mint, aliceI, bobI);
const aliceMaker = await E(vats.alice).makeAliceMaker(host);
const bobMaker = await E(vats.bob).makeBobMaker(host);
return betterContractTestBobFirst(
host,
vats.mint,
aliceMaker,
bobMaker,
);
}
case 'covered-call': {
const host = await E(vats.host).makeHost();
const aliceI = await E(vats.alice).makeAlice(host);
const bobI = await E(vats.bob).makeBob(host);
return coveredCallTest(host, vats.mint, aliceI, bobI);
const aliceMaker = await E(vats.alice).makeAliceMaker(host);
const bobMaker = await E(vats.bob).makeBobMaker(host);
return coveredCallTest(host, vats.mint, aliceMaker, bobMaker);
}
case 'covered-call-sale': {
const host = await E(vats.host).makeHost();
const aliceI = await E(vats.alice).makeAlice(host);
const bobI = await E(vats.bob).makeBob(host);
const fredI = await E(vats.fred).makeFred(host);
return coveredCallSaleTest(host, vats.mint, aliceI, bobI, fredI);
const aliceMaker = await E(vats.alice).makeAliceMaker(host);
const bobMaker = await E(vats.bob).makeBobMaker(host);
const fredMaker = await E(vats.fred).makeFredMaker(host);
return coveredCallSaleTest(
host,
vats.mint,
aliceMaker,
bobMaker,
fredMaker,
);
}
default: {
throw new Error(`unrecognized argument value ${argv[0]}`);
Expand Down
8 changes: 4 additions & 4 deletions demo/contractHost/vat-alice.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import harden from '@agoric/harden';
import { allComparable } from '../../collections/sameStructure';
import { makeCollect } from './contractHost';

function makeAlice(E, host, log) {
function makeAliceMaker(E, host, log) {
const collect = makeCollect(E, log);

// TODO BUG: All callers should wait until settled before doing
Expand All @@ -19,7 +19,7 @@ function makeAlice(E, host, log) {
}

return harden({
init(
make(
escrowExchangeInstallationP,
coveredCallInstallationP,
timerP,
Expand Down Expand Up @@ -214,8 +214,8 @@ function setup(syscall, state, helpers) {
}
return helpers.makeLiveSlots(syscall, state, E =>
harden({
makeAlice(host) {
return harden(makeAlice(E, host, log));
makeAliceMaker(host) {
return harden(makeAliceMaker(E, host, log));
},
}),
);
Expand Down
8 changes: 4 additions & 4 deletions demo/contractHost/vat-bob.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import harden from '@agoric/harden';

import { makeCollect } from './contractHost';

function makeBob(E, host, log) {
function makeBobMaker(E, host, log) {
const collect = makeCollect(E, log);

return harden({
init(
make(
escrowExchangeInstallationP,
coveredCallInstallationP,
timerP,
Expand Down Expand Up @@ -109,8 +109,8 @@ function setup(syscall, state, helpers) {
}
return helpers.makeLiveSlots(syscall, state, E =>
harden({
makeBob(host) {
return harden(makeBob(E, host, log));
makeBobMaker(host) {
return harden(makeBobMaker(E, host, log));
},
}),
);
Expand Down
8 changes: 4 additions & 4 deletions demo/contractHost/vat-fred.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import harden from '@agoric/harden';
import { allComparable } from '../../collections/sameStructure';
import { makeCollect } from './contractHost';

function makeFred(E, host, log) {
function makeFredMaker(E, host, log) {
const collect = makeCollect(E, log);

return harden({
init(
make(
escrowExchangeInstallationP,
coveredCallInstallationP,
timerP,
Expand Down Expand Up @@ -134,8 +134,8 @@ function setup(syscall, state, helpers) {
}
return helpers.makeLiveSlots(syscall, state, E =>
harden({
makeFred(host) {
return harden(makeFred(E, host, log));
makeFredMaker(host) {
return harden(makeFredMaker(E, host, log));
},
}),
);
Expand Down

0 comments on commit 3ae77b4

Please sign in to comment.