Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce package dependency cycles #6823

Merged
merged 16 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions golang/cosmos/x/swingset/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"errors"
"fmt"
"strconv"
"math"
"strconv"

"github.com/tendermint/tendermint/libs/log"

Expand All @@ -20,7 +20,7 @@ import (
)

// Top-level paths for chain storage should remain synchronized with
// packages/vats/src/chain-storage-paths.js
// packages/internal/src/chain-storage-paths.js
const (
StoragePathActionQueue = "actionQueue"
StoragePathActivityhash = "activityhash"
Expand Down
1 change: 0 additions & 1 deletion packages/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"@agoric/notifier": "^0.5.1",
"@agoric/store": "^0.8.3",
"@agoric/vat-data": "^0.4.3",
"@agoric/vats": "^0.13.0",
"@endo/far": "^0.2.14",
"@endo/marshal": "^0.8.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/test/test-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import '@agoric/swingset-vat/tools/prepare-test-env.js';

import test from 'ava';
import { makeChainStorageRoot } from '@agoric/vats/src/lib-chainStorage.js';
import { makeChainStorageRoot } from '@agoric/internal/src/lib-chainStorage.js';

import { Far, makeMarshal } from '@endo/marshal';
import { M } from '@agoric/store';
Expand Down
3 changes: 0 additions & 3 deletions packages/cosmic-swingset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,12 @@
"@agoric/swing-store": "^0.8.1",
"@agoric/swingset-vat": "^0.30.2",
"@agoric/telemetry": "^0.4.0",
"@agoric/vats": "^0.13.0",
"@agoric/xsnap": "^0.13.2",
"@endo/far": "^0.2.14",
"@endo/import-bundle": "^0.3.0",
"@endo/init": "^0.5.52",
"@endo/marshal": "^0.8.1",
"@iarna/toml": "^2.2.3",
"@opentelemetry/sdk-metrics-base": "^0.27.0",
"agoric": "^0.18.2",
"anylogger": "^0.21.0",
"deterministic-json": "^1.0.5",
"import-meta-resolve": "^2.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-swingset/src/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import { makeBufferedStorage } from '@agoric/swingset-vat/src/lib/storageAPI.js'
import { Fail } from '@agoric/assert';
import { makeSlogSender } from '@agoric/telemetry';

import { makeChainStorageRoot } from '@agoric/vats/src/lib-chainStorage.js';
import { makeChainStorageRoot } from '@agoric/internal/src/lib-chainStorage.js';
import { makeMarshal } from '@endo/marshal';
import { makeStoredSubscriber, makePublishKit } from '@agoric/notifier';

import * as STORAGE_PATH from '@agoric/vats/src/chain-storage-paths.js';
import * as STORAGE_PATH from '@agoric/internal/src/chain-storage-paths.js';
import { BridgeId as BRIDGE_ID } from '@agoric/internal';
import stringify from './json-stable-stringify.js';
import { launch } from './launch-chain.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { assert, Fail } from '@agoric/assert';
import { openSwingStore } from '@agoric/swing-store';
import { BridgeId as BRIDGE_ID } from '@agoric/internal';
import * as ActionType from '@agoric/internal/src/action-types.js';

import { extractCoreProposalBundles } from '@agoric/deploy-script-support/src/extract-proposal.js';

Expand All @@ -33,7 +34,6 @@ import {
BeansPerXsnapComputron,
QueueInbound,
} from './sim-params.js';
import * as ActionType from './action-types.js';
import { parseParams, serializeQueueSizes } from './params.js';
import { makeQueue } from './make-queue.js';

Expand Down
10 changes: 7 additions & 3 deletions packages/cosmic-swingset/src/sim-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { makeSlogSender } from '@agoric/telemetry';

import { resolve as importMetaResolve } from 'import-meta-resolve';
import { assert, Fail } from '@agoric/assert';
import { makeWithQueue } from '@agoric/vats/src/queue.js';
import { makeBatchedDeliver } from '@agoric/vats/src/batched-deliver.js';
import { makeWithQueue } from '@agoric/internal/src/queue.js';
import { makeBatchedDeliver } from '@agoric/internal/src/batched-deliver.js';
import stringify from './json-stable-stringify.js';
import { launch } from './launch-chain.js';
import { getTelemetryProviders } from './kernel-stats.js';
Expand Down Expand Up @@ -220,5 +220,9 @@ export async function connectToFakeChain(basedir, GCI, delay, inbound) {
});

const batchDelayMs = delay ? delay * 1000 : undefined;
return makeBatchedDeliver(deliver, batchDelayMs);
return makeBatchedDeliver(
deliver,
{ clearTimeout, setTimeout },
batchDelayMs,
);
}
1 change: 0 additions & 1 deletion packages/deploy-script-support/exported.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import '@endo/bundle-source/exported.js';
import '@agoric/vats/exported.js';

import './src/externalTypes.js';
5 changes: 3 additions & 2 deletions packages/deploy-script-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"@agoric/assert": "^0.5.1",
"@agoric/ertp": "^0.15.3",
"@agoric/import-manager": "^0.3.6",
"@agoric/internal": "^0.2.1",
"@agoric/nat": "^4.1.0",
"@agoric/notifier": "^0.5.1",
"@agoric/store": "^0.8.3",
"@agoric/vats": "^0.13.0",
"@agoric/zoe": "^0.25.3",
"@endo/base64": "^0.2.28",
"@endo/bundle-source": "^2.4.2",
Expand All @@ -50,7 +50,8 @@
"@endo/zip": "^0.2.28"
},
"devDependencies": {
"@agoric/swingset-vat": "^0.30.2",
"@agoric/vats": "^0.13.0",
"@endo/init": "^0.5.52",
"ava": "^5.1.0",
"import-meta-resolve": "^2.2.1"
},
Expand Down
6 changes: 5 additions & 1 deletion packages/deploy-script-support/src/assertOfferResult.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Fail } from '@agoric/assert';
import { E } from '@endo/far';

/** @type {AssertOfferResult} */
/**
* @param {ERef<UserSeat>} seat
* @param {string} expectedOfferResult
* @returns {Promise<void>}
*/
export const assertOfferResult = async (seat, expectedOfferResult) => {
const actualOfferResult = await E(seat).getOfferResult();
actualOfferResult === expectedOfferResult ||
Expand Down
7 changes: 7 additions & 0 deletions packages/deploy-script-support/src/coreProposalBehavior.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const t = 'makeCoreProposalBehavior';

/**
* TODO import these from @agoric/vats when the types are better managed
*
* @typedef {*} ChainBootstrapSpace
* @typedef {*} BootstrapPowers
*/

export const permits = {
consume: { board: t, agoricNamesAdmin: t },
evaluateInstallation: t,
Expand Down
6 changes: 4 additions & 2 deletions packages/deploy-script-support/src/depositInvitation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { E } from '@endo/far';

/**
* @param {ERef<Purse>} zoeInvitationPurse
* @returns {DepositInvitation}
*/
export const makeDepositInvitation = zoeInvitationPurse => {
/** @type {DepositInvitation} */
/**
* @param {ERef<Invitation>} invitationP
* @returns {Promise<InvitationDetails>}
* */
const depositInvitation = async invitationP => {
const invitation = await invitationP;
// Deposit returns the amount deposited
Expand Down
61 changes: 2 additions & 59 deletions packages/deploy-script-support/src/externalTypes.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,6 @@
/**
* @callback InstallSaveAndPublish
* @param {string} resolvedPath
* @param {Petname} contractPetname
* @returns {{ installation: Installation, id: string}}
*/

/**
* @typedef {object} StartInstanceResultWithDetailsNoInvitation
* @property {any} creatorFacet
* @property {any} publicFacet
* @property {Instance} instance
* @property {InvitationDetails} creatorInvitationDetails
* @property {AdminFacet} adminFacet
*/

/**
* @typedef {object} OfferHelperConfig
* @property {ERef<Invitation>=} invitation
* @property {Partial<InvitationDetails>=} partialInvitationDetails
* @property {Proposal} proposal
* @property {Record<Keyword, Petname>} paymentsWithPursePetnames
* @property {Record<Keyword, Petname>} payoutPursePetnames
*/

/**
* @callback OfferHelper
* @param {OfferHelperConfig} config
* @returns {{seat: Promise<UserSeat>, deposited:
* Promise<Array<Promise<Amount>>>, invitationDetails:
* InvitationDetails}}
*/

/**
* @callback FindInvitationAmount
* @param {Record<string, any>} invitationDetailsCriteria
* @returns {Amount} invitationAmount
*/

/**
* @callback DepositInvitation
* @param {ERef<Invitation>} invitationP
* @returns {InvitationDetails}
*/

/**
* @callback SaveIssuerHelper
* @param {ERef<Issuer>} issuer
* @param {Petname} brandPetname
* @param {Petname} pursePetname
* @returns {Promise<Petname>}
*/

/**
* @callback AssertOfferResult
* @param {ERef<UserSeat>} seat
* @param {string} expectedOfferResult
* @returns {Promise<void>}
*/
export {};

// TODO move this type somewhere better
/**
* @typedef {string | string[]} Petname A petname can either be a plain string
* or a path for which the first element is a petname for the origin, and the
Expand Down
2 changes: 1 addition & 1 deletion packages/deploy-script-support/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { assertOfferResult } from './assertOfferResult.js';
import { installInPieces } from './installInPieces.js';
import { makeWriteCoreProposal } from './writeCoreProposal.js';

export * from './createBundles.js';
export * from '@agoric/internal/src/createBundles.js';

// These are also hard-coded in lib-wallet.js.
// TODO: Add methods to the wallet to access these without hard-coding
Expand Down
9 changes: 7 additions & 2 deletions packages/deploy-script-support/src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import './externalTypes.js';

import { E } from '@endo/far';

/** @typedef {import('@agoric/deploy-script-support/src/externalTypes').Petname} Petname */

/**
* @callback BundleSource
* @param {string} startFilename - the filepath to start the bundling from
Expand All @@ -17,10 +19,13 @@ import { E } from '@endo/far';
* @param {ERef<ZoeService>} zoe
* @param {ERef<import('./startInstance.js').InstallationManager>} installationManager
* @param {ERef<any>} board
* @returns {InstallSaveAndPublish}
*/
export const makeInstall = (bundleSource, zoe, installationManager, board) => {
/** @type {InstallSaveAndPublish} */
/**
* @param {string} resolvedPath
* @param {Petname} contractPetname
* @returns {Promise<{ installation: Installation, id: string}>}
* */
const install = async (resolvedPath, contractPetname) => {
console.log(`- Installing Contract Name: ${contractPetname}`);

Expand Down
21 changes: 18 additions & 3 deletions packages/deploy-script-support/src/offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,32 @@ import { E } from '@endo/far';
import { assert } from '@agoric/assert';
import { AmountMath } from '@agoric/ertp';

/** @typedef {import('@agoric/deploy-script-support/src/externalTypes').Petname} Petname */

/**
* @typedef {object} OfferHelperConfig
* @property {ERef<Invitation>=} invitation
* @property {Partial<InvitationDetails>=} partialInvitationDetails
* @property {Proposal} proposal
* @property {Record<Keyword, Petname>} paymentsWithPursePetnames
* @property {Record<Keyword, Petname>} payoutPursePetnames
*/

/**
* @param {ERef<any>} walletAdmin - an internal type of the
* wallet, not defined here
* @param {ERef<ZoeService>} zoe
* @param {ERef<Purse>} zoeInvitationPurse
* @returns {{ offer: OfferHelper, findInvitationAmount: FindInvitationAmount }}
*/
export const makeOfferAndFindInvitationAmount = (
walletAdmin,
zoe,
zoeInvitationPurse,
) => {
/** @type {FindInvitationAmount} */
/**
* @param {Record<string, any>} invitationDetailsCriteria
* @returns {Promise<Amount>} invitationAmount
*/
const findInvitationAmount = async invitationDetailsCriteria => {
const invitationAmount = await E(zoeInvitationPurse).getCurrentAmount();

Expand Down Expand Up @@ -86,7 +99,9 @@ export const makeOfferAndFindInvitationAmount = (
return E.when(paymentsPP, handlePayments);
};

/** @type {OfferHelper} */
/**
* @param {OfferHelperConfig} config
*/
const offer = async config => {
const {
invitation,
Expand Down
10 changes: 8 additions & 2 deletions packages/deploy-script-support/src/saveIssuer.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { E } from '@endo/far';

/** @typedef {import('@agoric/deploy-script-support/src/externalTypes').Petname} Petname */

/**
* @param {ERef<any>} walletAdmin - an internal type of the
* wallet, not defined here
* @param {ERef<import('./startInstance').IssuerManager>} issuerManager
* @returns {SaveIssuerHelper}
*/
export const makeSaveIssuer = (walletAdmin, issuerManager) => {
/** @type {SaveIssuerHelper} */
/**
* @param {ERef<Issuer>} issuerP
* @param {Petname} brandPetname
* @param {Petname} pursePetname
* @returns {Promise<Petname>}
*/
const saveIssuer = async (issuerP, brandPetname, pursePetname) => {
console.log(`-- Installing issuer for: ${brandPetname}`);

Expand Down
2 changes: 2 additions & 0 deletions packages/deploy-script-support/src/startInstance.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { assert } from '@agoric/assert';
import { E, passStyleOf } from '@endo/far';

/** @typedef {import('@agoric/deploy-script-support/src/externalTypes').Petname} Petname */

/**
* @template T
* @typedef {object} PetnameManager
Expand Down
2 changes: 1 addition & 1 deletion packages/deploy-script-support/src/writeCoreProposal.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import fs from 'fs';
import { E } from '@endo/far';

import { createBundles } from '@agoric/internal/src/createBundles.js';
import {
deeplyFulfilled,
defangAndTrim,
mergePermits,
stringify,
} from './code-gen.js';
import { makeCoreProposalBehavior, permits } from './coreProposalBehavior.js';
import { createBundles } from './createBundles.js';

export const makeWriteCoreProposal = (
homeP,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
import test from 'ava';
import '@endo/init';
Comment on lines -1 to +2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really the same semantics. Did you do this to be able to drop the devDependency on swingset?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. the rest of it wasn't totally necessary.

It affects redactions but there's work scheduled to address that broadly endojs/endo#1235


import { assertOfferResult } from '../../src/assertOfferResult.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { makeIssuerKit } from '@agoric/ertp';
import { resolve as importMetaResolve } from 'import-meta-resolve';
import { E } from '@endo/far';

import '../../exported.js';

import { makeStartInstance } from '../../src/startInstance.js';

/** @typedef {import('@agoric/deploy-script-support/src/externalTypes').Petname} Petname */

test('startInstance', async t => {
const MOOLA_BRAND_PETNAME = 'moola';
const USD_BRAND_PETNAME = 'usd';
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/scripts/build-bundles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env node
import '@endo/init';
import { createBundles } from '@agoric/deploy-script-support';
import { createBundles } from '@agoric/internal/src/createBundles.js';
import url from 'url';

const dirname = url.fileURLToPath(new URL('.', import.meta.url));
Expand Down
Loading