Skip to content

Commit

Permalink
test: add assets for vaults-auctions coreEval
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Sep 5, 2024
1 parent 7933b51 commit 34d84ee
Show file tree
Hide file tree
Showing 10 changed files with 509 additions and 0 deletions.
45 changes: 45 additions & 0 deletions proposals/76:vaults-auctions/assets/add-auction-permit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"consume": {
"agoricNamesAdmin": "makeCoreProposalBehavior",
"auctioneerKit": true,
"board": true,
"chainStorage": true,
"chainTimerService": true,
"econCharterKit": true,
"economicCommitteeCreatorFacet": true,
"priceAuthority": true,
"zoe": "makeCoreProposalBehavior",
"vatAdminSvc": "makeCoreProposalBehavior"
},
"produce": {
"auctioneerKit": true,
"auctionUpgradeNewInstance": true
},
"instance": {
"consume": {
"reserve": true
},
"produce": {
"auctioneer": true
}
},
"installation": {
"consume": {
"contractGovernor": true
},
"produce": {
"auctioneer": true
}
},
"issuer": {
"consume": {
"IST": true
}
},
"evaluateBundleCap": "makeCoreProposalBehavior",
"modules": {
"utils": {
"runModuleBehaviors": "makeCoreProposalBehavior"
}
}
}
17 changes: 17 additions & 0 deletions proposals/76:vaults-auctions/assets/add-auction-plan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "add-auction",
"script": "add-auction.js",
"permit": "add-auction-permit.json",
"bundles": [
{
"entrypoint": "@agoric/inter-protocol/src/auction/auctioneer.js",
"bundleID": "b1-31bf1ef20dd190a9f541471bc15238a51f621ff2340e6eb225214b9fdf3970f2bc3bc4fe151a79ef2e740b2679cf03f553b89a828da704dec9ccba9463fc3f79",
"fileName": "/Users/cth/.agoric/cache/b1-31bf1ef20dd190a9f541471bc15238a51f621ff2340e6eb225214b9fdf3970f2bc3bc4fe151a79ef2e740b2679cf03f553b89a828da704dec9ccba9463fc3f79.json"
},
{
"entrypoint": "@agoric/inter-protocol/src/proposals/add-auction.js",
"bundleID": "b1-db1bbd2645ec486cbe70867bb56b01ab71c0f4042fb2e4d8e07c3ed7b84e0647867fba17761c1a0784dc186049fc06ed057c7a736c6574f27f5b5dcd93bc6b1b",
"fileName": "/Users/cth/.agoric/cache/b1-db1bbd2645ec486cbe70867bb56b01ab71c0f4042fb2e4d8e07c3ed7b84e0647867fba17761c1a0784dc186049fc06ed057c7a736c6574f27f5b5dcd93bc6b1b.json"
}
]
}
197 changes: 197 additions & 0 deletions proposals/76:vaults-auctions/assets/add-auction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
// This is generated by writeCoreEval; please edit!
/* eslint-disable */

const manifestBundleRef = {bundleID:"b1-db1bbd2645ec486cbe70867bb56b01ab71c0f4042fb2e4d8e07c3ed7b84e0647867fba17761c1a0784dc186049fc06ed057c7a736c6574f27f5b5dcd93bc6b1b"};
const getManifestCall = harden([
"getManifestForAddAuction",
{
auctionsRef: {
bundleID: "b1-31bf1ef20dd190a9f541471bc15238a51f621ff2340e6eb225214b9fdf3970f2bc3bc4fe151a79ef2e740b2679cf03f553b89a828da704dec9ccba9463fc3f79",
},
},
]);
const customManifest = {
addAuction: {
consume: {
agoricNamesAdmin: true,
auctioneerKit: true,
board: true,
chainStorage: true,
chainTimerService: true,
econCharterKit: true,
economicCommitteeCreatorFacet: true,
priceAuthority: true,
zoe: true,
},
installation: {
consume: {
contractGovernor: true,
},
produce: {
auctioneer: true,
},
},
instance: {
consume: {
reserve: true,
},
produce: {
auctioneer: true,
},
},
issuer: {
consume: {
IST: true,
},
},
produce: {
auctionUpgradeNewInstance: true,
auctioneerKit: true,
},
},
};

// Make a behavior function and "export" it by way of script completion value.
// It is constructed by an anonymous invocation to ensure the absence of a global binding
// for makeCoreProposalBehavior, which may not be necessary but preserves behavior pre-dating
// https://github.com/Agoric/agoric-sdk/pull/8712 .
const behavior = (({
manifestBundleRef,
getManifestCall: [manifestGetterName, ...manifestGetterArgs],
customManifest,
E,
log = console.info,
customRestoreRef,
}) => {
const { entries, fromEntries } = Object;

/**
* Given an object whose properties may be promise-valued, return a promise
* for an analogous object in which each such value has been replaced with its
* fulfillment.
* This is a non-recursive form of endo `deeplyFulfilled`.
*
* @template T
* @param {{[K in keyof T]: (T[K] | Promise<T[K]>)}} obj
* @returns {Promise<T>}
*/
const shallowlyFulfilled = async obj => {
if (!obj) {
return obj;
}
const awaitedEntries = await Promise.all(
entries(obj).map(async ([key, valueP]) => {
const value = await valueP;
return [key, value];
}),
);
return fromEntries(awaitedEntries);
};

const makeRestoreRef = (vatAdminSvc, zoe) => {
/** @type {(ref: import\('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */
const defaultRestoreRef = async bundleRef => {
// extract-proposal.js creates these records, and bundleName is
// the optional name under which the bundle was installed into
// config.bundles
const bundleIdP =
'bundleName' in bundleRef
? E(vatAdminSvc).getBundleIDByName(bundleRef.bundleName)
: bundleRef.bundleID;
const bundleID = await bundleIdP;
const label = bundleID.slice(0, 8);
return E(zoe).installBundleID(bundleID, label);
};
return defaultRestoreRef;
};

/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers */
const coreProposalBehavior = async powers => {
// NOTE: `powers` is expected to match or be a superset of the above `permits` export,
// which should therefore be kept in sync with this deconstruction code.
// HOWEVER, do note that this function is invoked with at least the *union* of powers
// required by individual moduleBehaviors declared by the manifest getter, which is
// necessary so it can use `runModuleBehaviors` to provide the appropriate subset to
// each one (see ./writeCoreEvalParts.js).
// Handle `powers` with the requisite care.
const {
consume: { vatAdminSvc, zoe, agoricNamesAdmin },
evaluateBundleCap,
installation: { produce: produceInstallations },
modules: {
utils: { runModuleBehaviors },
},
} = powers;

// Get the on-chain installation containing the manifest and behaviors.
log('evaluateBundleCap', {
manifestBundleRef,
manifestGetterName,
vatAdminSvc,
});
let bcapP;
if ('bundleName' in manifestBundleRef) {
bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName);
} else if ('bundleID' in manifestBundleRef) {
bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID);
} else {
const keys = Reflect.ownKeys(manifestBundleRef).map(key =>
typeof key === 'string' ? JSON.stringify(key) : String(key),
);
const keysStr = `[${keys.join(', ')}]`;
throw Error(
`bundleRef must have own bundleName or bundleID, missing in ${keysStr}`,
);
}
const bundleCap = await bcapP;

const proposalNS = await evaluateBundleCap(bundleCap);

// Get the manifest and its metadata.
log('execute', {
manifestGetterName,
bundleExports: Object.keys(proposalNS),
});
const restoreRef = customRestoreRef || makeRestoreRef(vatAdminSvc, zoe);
const {
manifest,
options: rawOptions,
installations: rawInstallations,
} = await proposalNS[manifestGetterName](
harden({ restoreRef }),
...manifestGetterArgs,
);

// Await promises in the returned options and installations records.
const [options, installations] = await Promise.all(
[rawOptions, rawInstallations].map(shallowlyFulfilled),
);

// Publish the installations for our dependencies.
const installationEntries = entries(installations || {});
if (installationEntries.length > 0) {
const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation');
await Promise.all(
installationEntries.map(([key, value]) => {
produceInstallations[key].resolve(value);
return E(installAdmin).update(key, value);
}),
);
}

// Evaluate the manifest.
return runModuleBehaviors({
// Remember that `powers` may be arbitrarily broad.
allPowers: powers,
behaviors: proposalNS,
manifest: customManifest || manifest,
makeConfig: (name, _permit) => {
log('coreProposal:', name);
return { options };
},
});
};

return coreProposalBehavior;
})({ manifestBundleRef, getManifestCall, customManifest, E });
behavior;

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions proposals/76:vaults-auctions/assets/upgrade-vaults-permit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"consume": {
"auctionUpgradeNewInstance": "upgradeVaults",
"chainTimerService": "upgradeVaults",
"economicCommitteeCreatorFacet": "upgradeVaults",
"reserveKit": "upgradeVaults",
"vaultFactoryKit": "upgradeVaults",
"zoe": "upgradeVaults",
"agoricNamesAdmin": "makeCoreProposalBehavior",
"vatAdminSvc": "makeCoreProposalBehavior"
},
"produce": {
"auctionUpgradeNewInstance": "upgradeVaults"
},
"installation": {
"produce": {
"VaultFactory": true
}
},
"instance": {
"consume": {
"auctioneer": true
}
},
"evaluateBundleCap": "makeCoreProposalBehavior",
"modules": {
"utils": {
"runModuleBehaviors": "makeCoreProposalBehavior"
}
}
}
17 changes: 17 additions & 0 deletions proposals/76:vaults-auctions/assets/upgrade-vaults-plan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "upgrade-vaults",
"script": "upgrade-vaults.js",
"permit": "upgrade-vaults-permit.json",
"bundles": [
{
"entrypoint": "@agoric/inter-protocol/src/vaultFactory/vaultFactory.js",
"bundleID": "b1-8859b141114716b24cca1bd8bc14f81c066880556b5e94eb1767c0ca3d5f4917a6762dcbab85d84bcdf06ba64179a34bfd7cbb5b43c9ab459b5abe09aeb7cdd9",
"fileName": "/Users/cth/.agoric/cache/b1-8859b141114716b24cca1bd8bc14f81c066880556b5e94eb1767c0ca3d5f4917a6762dcbab85d84bcdf06ba64179a34bfd7cbb5b43c9ab459b5abe09aeb7cdd9.json"
},
{
"entrypoint": "@agoric/inter-protocol/src/proposals/upgrade-vaults.js",
"bundleID": "b1-7db1fff8ee711a4bffe21a81f731d540c3d88c671b2ba6a457c4c9677df123008c310633f738b0eae3042e9593bb2569d0ca59a3f1d12752bcc2124c3240ee97",
"fileName": "/Users/cth/.agoric/cache/b1-7db1fff8ee711a4bffe21a81f731d540c3d88c671b2ba6a457c4c9677df123008c310633f738b0eae3042e9593bb2569d0ca59a3f1d12752bcc2124c3240ee97.json"
}
]
}
Loading

0 comments on commit 34d84ee

Please sign in to comment.