Skip to content

Commit

Permalink
feat: allow $NO_FAKE_CURRENCIES=1 to eliminate default purses
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jan 12, 2021
1 parent fc560d5 commit 0a2d054
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/cosmic-swingset/lib/ag-solo/fake-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export async function connectToFakeChain(basedir, GCI, delay, inbound) {
ROLE: 'sim-chain',
giveMeAllTheAgoricPowers: true,
hardcodedClientAddresses: [bootAddress],
noFakeCurrencies: process.env.NO_FAKE_CURRENCIES,
};
const stateDBdir = path.join(basedir, `fake-chain-${GCI}-state`);
function doOutboundBridge(dstID, _obj) {
Expand Down
24 changes: 18 additions & 6 deletions packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ export function buildRootObject(vatPowers, vatParameters) {
}

// Make services that are provided on the real or virtual chain side
async function makeChainBundler(vats, timerDevice, vatAdminSvc) {
async function makeChainBundler(
vats,
timerDevice,
vatAdminSvc,
noFakeCurrencies,
) {
// Create singleton instances.
const [
sharingService,
Expand Down Expand Up @@ -67,7 +72,7 @@ export function buildRootObject(vatPowers, vatParameters) {
* @property {Array<[number, number]>} [fakeTradesGivenCentral]
*/
/** @type {Map<string, IssuerRecord>} */
const issuerNameToRecord = new Map(
const fakeIssuerNameToRecord = new Map(
harden([
[
CENTRAL_ISSUER_NAME,
Expand Down Expand Up @@ -133,13 +138,13 @@ export function buildRootObject(vatPowers, vatParameters) {
],
]),
);
const issuerNameToRecord = noFakeCurrencies
? new Map()
: fakeIssuerNameToRecord;
const issuerNames = [...issuerNameToRecord.keys()];
const centralIssuerIndex = issuerNames.findIndex(
issuerName => issuerName === CENTRAL_ISSUER_NAME,
);
if (centralIssuerIndex < 0) {
throw Error(`Cannot find issuer ${CENTRAL_ISSUER_NAME}`);
}
const issuers = await Promise.all(
issuerNames.map(issuerName =>
E(vats.mints).makeMintAndIssuer(
Expand Down Expand Up @@ -396,6 +401,7 @@ export function buildRootObject(vatPowers, vatParameters) {
const {
ROLE,
giveMeAllTheAgoricPowers,
noFakeCurrencies,
hardcodedClientAddresses,
} = vatParameters.argv;

Expand Down Expand Up @@ -424,7 +430,12 @@ export function buildRootObject(vatPowers, vatParameters) {
// provisioning vat can ask the demo server for bundles, and can
// register client pubkeys with comms
await E(vats.provisioning).register(
await makeChainBundler(vats, devices.timer, vatAdminSvc),
await makeChainBundler(
vats,
devices.timer,
vatAdminSvc,
noFakeCurrencies,
),
vats.comms,
vats.vattp,
);
Expand Down Expand Up @@ -469,6 +480,7 @@ export function buildRootObject(vatPowers, vatParameters) {
vats,
devices.timer,
vatAdminSvc,
noFakeCurrencies,
);

// Allow manual provisioning requests via `agoric cosmos`.
Expand Down
5 changes: 4 additions & 1 deletion packages/cosmic-swingset/lib/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ export default async function main(progname, args, { path, env, agcc }) {
}

const vatsdir = path.resolve(__dirname, '../lib/ag-solo/vats');
const argv = { ROLE: 'chain' };
const argv = {
ROLE: 'chain',
noFakeCurrencies: process.env.NO_FAKE_CURRENCIES,
};
const s = await launch(
stateDBDir,
mailboxStorage,
Expand Down

0 comments on commit 0a2d054

Please sign in to comment.