"jsonPermits":"{
"consume": {
"agoricNamesAdmin": "priceFeed",
"board": "priceFeed",
"chainStorage": "priceFeed",
"chainTimerService": "priceFeed",
"client": "priceFeed",
"econCharterKit": "priceFeed",
"highPrioritySendersManager": "priceFeed",
"namesByAddressAdmin": "priceFeed",
"priceAuthority": "priceFeed",
"priceAuthorityAdmin": "priceFeed",
"startGovernedUpgradable": "priceFeed",
"zoe": "priceFeed",
"vatAdminSvc": "makeCoreProposalBehavior"
},
"instance": {
"produce": "priceFeed"
},
"namedVat": true,
"oracleBrand": {
"produce": "priceFeed"
},
"evaluateBundleCap": "makeCoreProposalBehavior",
"installation": {
"produce": "makeCoreProposalBehavior"
},
"modules": {
"utils": {
"runModuleBehaviors": "makeCoreProposalBehavior"
}
}
}
"
"jsCode":"// This is generated by writeCoreEval; please edit!
/* eslint-disable */
const manifestBundleRef = {
bundleID:
"b1-c016d741a13041e8eefbd05fc5f645113e10beba55fdce2d5ed979bbb1c95077cf2edbe359d588e28bf68d837665458e65c1d534d32f090125951458c461a829"
};
const getManifestCall = harden([
"getManifestForPriceFeed",
{
AGORIC_INSTANCE_NAME: "dATOM-USD price feed",
IN_BRAND_DECIMALS: 6,
IN_BRAND_LOOKUP: ["agoricNames", "oracleBrand", "dATOM"],
IN_BRAND_NAME: "dATOM",
OUT_BRAND_DECIMALS: 4,
OUT_BRAND_LOOKUP: ["agoricNames", "oracleBrand", "USD"],
OUT_BRAND_NAME: "USD",
brandInRef: undefined,
brandOutRef: undefined,
contractTerms: {
POLL_INTERVAL: 30n,
maxSubmissionCount: 1000,
maxSubmissionValue:
115792089237316195423570985008687907853269984665640564039457584007913129639936n,
minSubmissionCount: 3, // TODO: parameterize
minSubmissionValue: 1n,
restartDelay: 1,
timeout: 10,
},
oracleAddresses: [
"agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr",
"agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8",
"agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78",
"agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p",
"agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj",
],
priceAggregatorRef: {
bundleID: "b1-eca5ebeecb317450e049b450fa6449287844a324b0385cbc73e320adef79a168c71ffe441e95ef4ce7b4d15e62bb01ed87dace27d09646609ae3f20c5496a3e9",
},
},
]);
const customManifest = {
createPriceFeed: {
consume: {
agoricNamesAdmin: "priceFeed",
board: "priceFeed",
chainStorage: "priceFeed",
chainTimerService: "priceFeed",
client: "priceFeed",
econCharterKit: "priceFeed",
highPrioritySendersManager: "priceFeed",
namesByAddressAdmin: "priceFeed",
priceAuthority: "priceFeed",
priceAuthorityAdmin: "priceFeed",
startGovernedUpgradable: "priceFeed",
zoe: "priceFeed",
},
instance: {
produce: "priceFeed",
},
},
ensureOracleBrands: {
namedVat: {
consume: {
agoricNames: "agoricNames",
},
},
oracleBrand: {
produce: "priceFeed",
},
},
};
// 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].reset();
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;
"