Skip to content

Commit

Permalink
refactor: pull offers.js and payments.js into smartWallets
Browse files Browse the repository at this point in the history
Fix imports in quite a few places
  • Loading branch information
Chris-Hibbert committed Nov 1, 2023
1 parent b58f004 commit 2096070
Show file tree
Hide file tree
Showing 20 changed files with 123 additions and 562 deletions.
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const makeAuctionCommand = (
path: { paramPath: { key: 'governedParams' } },
};

/** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
/** @type {import('@agoric/smart-wallet/src/smartWallet.js').OfferSpec} */
const offer = {
id: opts.offerId,
invitationSpec: {
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/gov.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
sendAction,
} from '../lib/wallet.js';

/** @typedef {import('@agoric/smart-wallet/src/offers.js').OfferSpec} OfferSpec */
/** @typedef {import('@agoric/smart-wallet/src/smartWallet.js').OfferSpec} OfferSpec */

const collectValues = (val, memo) => {
memo.push(val);
Expand Down
8 changes: 4 additions & 4 deletions packages/agoric-cli/src/commands/inter.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const makeFormatters = assets => {
/**
* Dynamic check that an OfferStatus is also a BidSpec.
*
* @param {import('@agoric/smart-wallet/src/offers.js').OfferStatus} offerStatus
* @param {import('@agoric/smart-wallet/src/smartWallet.js').OfferStatus} offerStatus
* @param {import('../lib/wallet.js').AgoricNamesRemotes} agoricNames
* @param {typeof console.warn} warn
* returns null if offerStatus is not a BidSpec
Expand All @@ -125,7 +125,7 @@ const coerceBid = (offerStatus, agoricNames, warn) => {
}

/**
* @type {import('@agoric/smart-wallet/src/offers.js').OfferStatus &
* @type {import('@agoric/smart-wallet/src/smartWallet.js').OfferStatus &
* { offerArgs: BidSpec}}
*/
// @ts-expect-error dynamic cast
Expand All @@ -136,7 +136,7 @@ const coerceBid = (offerStatus, agoricNames, warn) => {
/**
* Format amounts etc. in a BidSpec OfferStatus
*
* @param {import('@agoric/smart-wallet/src/offers.js').OfferStatus &
* @param {import('@agoric/smart-wallet/src/smartWallet.js').OfferStatus &
* { offerArgs: BidSpec}} bid
* @param {import('agoric/src/lib/format.js').AssetDescriptor[]} assets
*/
Expand Down Expand Up @@ -328,7 +328,7 @@ inter auction status

/**
* @param {string} from
* @param {import('@agoric/smart-wallet/src/offers.js').OfferSpec} offer
* @param {import('@agoric/smart-wallet/src/smartWallet.js').OfferSpec} offer
* @param {Awaited<ReturnType<tryMakeUtils>>} tools
* @param {boolean?} dryRun
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const makeOracleCommand = (logger, io = {}) => {
const { lookupPriceAggregatorInstance } = await rpcTools();
const instance = lookupPriceAggregatorInstance(opts.pair);

/** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
/** @type {import('@agoric/smart-wallet/src/smartWallet.js').OfferSpec} */
const offer = {
id: opts.offerId,
invitationSpec: {
Expand Down
4 changes: 2 additions & 2 deletions packages/agoric-cli/src/commands/psm.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const makePsmCommand = logger => {
const { lookupPsmInstance } = await rpcTools();
const psmInstance = lookupPsmInstance(opts.pair);

/** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
/** @type {import('@agoric/smart-wallet/src/smartWallet.js').OfferSpec} */
const offer = {
id: opts.offerId,
invitationSpec: {
Expand Down Expand Up @@ -255,7 +255,7 @@ export const makePsmCommand = logger => {
brand: istBrand,
value: BigInt(opts.limit * 1_000_000),
});
/** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
/** @type {import('@agoric/smart-wallet/src/smartWallet.js').OfferSpec} */
const offer = {
id: opts.offerId,
invitationSpec: {
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/reserve.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const makeReserveCommand = (_logger, io = {}) => {

const feesToBurn = { brand: agoricNames.brand.IST, value: opts.value };

/** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
/** @type {import('@agoric/smart-wallet/src/smartWallet.js').OfferSpec} */
const offer = {
id: opts.offerId,
invitationSpec: {
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/test-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const makeTestCommand = (
const { home, keyringBackend: backend } = testCmd.opts();

const io = { ...networkConfig, execFileSync, delay, stdout };
/** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
/** @type {import('@agoric/smart-wallet/src/smartWallet.js').OfferSpec} */
const offer = {
id: opts.offerId,
invitationSpec: {
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/lib/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const outputActionAndHint = (bridgeAction, { stdout, stderr }) => {
};

/**
* @param {import('@agoric/smart-wallet/src/offers.js').OfferSpec} offer
* @param {import('@agoric/smart-wallet/src/smartWallet.js').OfferSpec} offer
* @param {Pick<import('stream').Writable,'write'>} [stdout]
*/
export const outputExecuteOfferAction = (offer, stdout = process.stdout) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/agoric-cli/test/test-inter-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const makeProcess = (t, keyring, out) => {
};

/**
* @type {import('@agoric/smart-wallet/src/offers.js').OfferStatus &
* @type {import('@agoric/smart-wallet/src/smartWallet.js').OfferStatus &
* { offerArgs: import('@agoric/inter-protocol/src/auction/auctionBook.js').OfferSpec}}
*/
const offerStatus2 = harden({
Expand Down Expand Up @@ -253,7 +253,7 @@ test('amount parsing', t => {
test.todo('want as max collateral wanted');

/**
* @type {import('@agoric/smart-wallet/src/offers.js').OfferStatus &
* @type {import('@agoric/smart-wallet/src/smartWallet.js').OfferStatus &
* { offerArgs: import('@agoric/inter-protocol/src/auction/auctionBook.js').OfferSpec}}
*/
const offerStatus1 = harden({
Expand Down
31 changes: 26 additions & 5 deletions packages/boot/test/bootstrapTests/liquidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ export const likePayouts = ({ Bid, Collateral }) => ({
},
});

export const makeLiquidationTestContext = async t => {
console.time('DefaultTestContext');
export const makeWalletFactoryContext = async t => {
const swingsetTestKit = await makeSwingsetTestKit(t.log, 'bundles/vaults', {
configSpecifier: '@agoric/vm-config/decentral-main-vaults-config.json',
configSpecifier: '@agoric/vm-config/decentral-main-vaults-config.json'
});

const { runUtils, storage } = swingsetTestKit;
Expand All @@ -83,7 +82,7 @@ export const makeLiquidationTestContext = async t => {
const refreshAgoricNamesRemotes = () => {
Object.assign(
agoricNamesRemotes,
makeAgoricNamesRemotesFromFakeStorage(swingsetTestKit.storage),
makeAgoricNamesRemotesFromFakeStorage(swingsetTestKit.storage)
);
};
agoricNamesRemotes.brand.ATOM || Fail`ATOM missing from agoricNames`;
Expand All @@ -92,8 +91,30 @@ export const makeLiquidationTestContext = async t => {
const walletFactoryDriver = await makeWalletFactoryDriver(
runUtils,
storage,
agoricNamesRemotes,
agoricNamesRemotes
);
return {
...swingsetTestKit,
swingsetTestKit,
agoricNamesRemotes,
refreshAgoricNamesRemotes,
walletFactoryDriver,
};
};

export type WalletFactoryTestContext = Awaited<
ReturnType<typeof makeWalletFactoryContext>
>;

export const makeLiquidationTestContext = async t => {
console.time('DefaultTestContext');
const {
swingsetTestKit,
agoricNamesRemotes,
refreshAgoricNamesRemotes,
walletFactoryDriver
} = await makeWalletFactoryContext(t);

console.timeLog('DefaultTestContext', 'walletFactoryDriver');

const governanceDriver = await makeGovernanceDriver(
Expand Down
Loading

0 comments on commit 2096070

Please sign in to comment.