Skip to content

Commit

Permalink
chore(types): DeployScriptFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jun 7, 2023
1 parent 6da461b commit 0d4bab8
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>
],
});

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const helperEndowments = {
...endowments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>
],
});

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const helperEndowments = {
...endowments,
Expand Down
38 changes: 38 additions & 0 deletions packages/deploy-script-support/src/externalTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,41 @@ export {};
* @param {...any} args
* @returns {Promise<ProposalResult>}
*/

/**
* @typedef {{
* bundleSource: typeof import('@endo/bundle-source').default,
* now: () => number,
* lookup: (...path: string[]) => unknown,
* publishBundle: PublishBundleRef,
* pathResolve: (...path: string[]) => string,
* cacheDir: string,
* }} DeployScriptEndownments
*/

/**
* @typedef {{
* agoricNames: ERef<NameHub>,
* bank: ERef<import("@agoric/vats/src/vat-bank.js").Bank>,
* board: ERef<import("@agoric/vats").Board>,
* faucet: unknown,
* myAddressNameAdmin: ERef<import("@agoric/vats").NameAdmin>,
* namesByAddress: ERef<NameHub>,
* scratch: ERef<import('@agoric/internal/src/scratch.js').ScratchPad>,
* zoe: ERef<ZoeService>,
* }} CanonicalHome
*/

// TODO wallet as import('@agoric/wallet-backend/src/types').WalletAdmin once it's a module
/**
* @typedef {CanonicalHome & {
* wallet?: any,
* }} AgSoloHome
*/

/**
* @callback DeployScriptFunction
* @param {Promise<CanonicalHome>} homeP
* @param {DeployScriptEndownments} endowments
* @returns {Promise<void>}
*/
4 changes: 4 additions & 0 deletions packages/deploy-script-support/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const makeLazyObject = sourceObject => {
return /** @type {T} */ (lazyObject);
};

/**
* @param {Promise<import('./externalTypes.js').AgSoloHome>} homePromise
* @param {import('./externalTypes.js').DeployScriptEndownments} endowments
*/
export const makeHelpers = async (homePromise, endowments) => {
// Endowments provided via `agoric run` or `agoric deploy`.
const {
Expand Down
1 change: 1 addition & 0 deletions packages/inter-protocol/scripts/add-collateral-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const psmProposalBuilder = async (
});
};

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);

Expand Down
1 change: 1 addition & 0 deletions packages/inter-protocol/scripts/deploy-contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const provideWhen = async (store, key, make) => {
return value;
};

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const home = await homeP;
const { zoe, scratch, board } = home;
Expand Down
1 change: 1 addition & 0 deletions packages/inter-protocol/scripts/init-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const defaultProposalBuilder = async (
});
};

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);

Expand Down
1 change: 1 addition & 0 deletions packages/inter-protocol/scripts/invite-committee-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const defaultProposalBuilder = async (
});
};

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('gov-invite-committee', defaultProposalBuilder);
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/proposals/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const provideWhen = async (store, key, make) => {
};

/**
* @param {{ scratch: ERef<import('@agoric/internal/src/scratch.js').ScratchPad> }} homeP
* @param {Promise<{ scratch: ERef<import('@agoric/internal/src/scratch.js').ScratchPad> }>} homeP
* @param {object} opts
* @param {(specifier: string) => Promise<{default: Bundle}>} opts.loadBundle
* @param {string} [opts.installCacheKey]
Expand Down
1 change: 1 addition & 0 deletions packages/pegasus/scripts/init-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>
],
});

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('gov-pegasus', defaultProposalBuilder);
Expand Down
1 change: 1 addition & 0 deletions packages/vats/scripts/init-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>
],
});

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('gov-vats', defaultProposalBuilder);
Expand Down
1 change: 1 addition & 0 deletions packages/vats/scripts/init-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>
],
});

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('gov-network', defaultProposalBuilder);
Expand Down
1 change: 1 addition & 0 deletions packages/vats/scripts/restart-vats.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const defaultProposalBuilder = async () => {
});
};

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('restart-vats', defaultProposalBuilder);
Expand Down

0 comments on commit 0d4bab8

Please sign in to comment.