Skip to content

Commit

Permalink
chore(vats): postpone getRUN bootstrap to later PR
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Jan 25, 2022
1 parent 8c9413b commit 42b96fa
Showing 1 changed file with 1 addition and 134 deletions.
135 changes: 1 addition & 134 deletions packages/vats/src/core/econ-behaviors.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// @ts-check

import { E } from '@agoric/far';
import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';

import { installOnChain as installVaultFactoryOnChain } from '@agoric/run-protocol/bundles/install-on-chain.js';
import { bootstrapRunLoC } from '@agoric/run-protocol/src/bootstrapRunLoC.js';
import getRUNBundle from '@agoric/run-protocol/bundles/bundle-getRUN.js';
import contractGovernorBundle from '@agoric/run-protocol/bundles/bundle-contractGovernor.js';
import committeeBundle from '@agoric/run-protocol/bundles/bundle-committee.js';
import { makeStakeReporter } from '../my-lien.js';
import { CENTRAL_ISSUER_NAME, collectNameAdmins, shared } from './utils.js';
import { BLD_ISSUER_ENTRY } from '../issuers.js';
import { CENTRAL_ISSUER_NAME } from './utils.js';

/**
* @param {{
Expand Down Expand Up @@ -68,129 +61,3 @@ export const startVaultFactory = async ({
});
};
harden(startVaultFactory);

/**
* @param {{ consume: {
* zoe: ERef<ZoeService>,
* agoricNames: ERef<NameHub>,
* nameAdmins: ERef<Store<NameHub, NameAdmin>>,
* }}} powers
*/
export const installEconomicGovernance = async ({
consume: { zoe, agoricNames, nameAdmins },
}) => {
const [contractGovernorInstall, committeeInstall] = await Promise.all([
E(zoe).install(contractGovernorBundle),
E(zoe).install(committeeBundle),
]);

const [installAdmin] = await collectNameAdmins(
['installation'],
agoricNames,
nameAdmins,
);

assert(shared.contract.contractGovernor);
assert(shared.contract.committee);
return Promise.all([
E(installAdmin).update('contractGovernor', contractGovernorInstall),
E(installAdmin).update('committee', committeeInstall),
]);
};
harden(installEconomicGovernance);

/**
* @param {{ consume: {
* zoe: ERef<ZoeService>,
* feeMintAccess: ERef<FeeMintAccess>,
* agoricNames: ERef<NameHub>,
* bridgeManager: ERef<import('../bridge.js').BridgeManager>,
* client: ERef<ClientManager>,
* chainTimerService: ERef<TimerService>,
* nameAdmins: ERef<Store<NameHub, NameAdmin>>,
* }}} powers
*/
export const startGetRun = async ({
consume: {
zoe,
// ISSUE: is there some reason Zoe shouldn't await this???
feeMintAccess: feeMintAccessP,
agoricNames,
bridgeManager,
client,
chainTimerService,
nameAdmins,
},
}) => {
const [stakeName] = BLD_ISSUER_ENTRY;

const [
feeMintAccess,
bldIssuer,
bldBrand,
runBrand,
governor,
electorate,
installation,
] = await Promise.all([
feeMintAccessP,
E(agoricNames).lookup('issuer', stakeName),
E(agoricNames).lookup('brand', stakeName),
E(agoricNames).lookup('brand', 'RUN'),
// TODO: manage string constants that need to match
E(agoricNames).lookup('installation', 'contractGovernor'),
E(agoricNames).lookup('installation', 'committee'),
E(zoe).install(getRUNBundle),
]);
const collateralPrice = makeRatio(65n, runBrand, 100n, bldBrand); // arbitrary price
const collateralizationRatio = makeRatio(5n, runBrand, 1n); // arbitrary raio

const installations = {
governor,
electorate,
getRUN: installation,
};

// TODO: finish renaming bootstrapRunLoC etc.
const { instance, publicFacet, creatorFacet } = await bootstrapRunLoC(
zoe,
chainTimerService,
feeMintAccess,
installations,
{ collateralPrice, collateralizationRatio },
bldIssuer,
);
const attIssuer = E(publicFacet).getIssuer();
const attBrand = await E(attIssuer).getBrand();

const reporter = makeStakeReporter(bridgeManager, bldBrand);

const [
brandAdmin,
issuerAdmin,
installAdmin,
instanceAdmin,
] = await collectNameAdmins(
['brand', 'issuer', 'installation', 'instance'],
agoricNames,
nameAdmins,
);

const key = 'getRUN';
const attKey = 'Attestation';
assert(shared.contract[key]);
assert(shared.assets[attKey]);
return Promise.all([
E(installAdmin).update(key, installation),
E(instanceAdmin).update(key, instance),
E(brandAdmin).update(attKey, attBrand),
E(issuerAdmin).update(attKey, attIssuer),
// @ts-ignore threading types thru governance is WIP
E(creatorFacet).addAuthority(reporter),
E(client).assignBundle({
// @ts-ignore threading types thru governance is WIP
attMaker: address => E(creatorFacet).getAttMaker(address),
}),
]);
};
harden(startGetRun);

0 comments on commit 42b96fa

Please sign in to comment.