Skip to content

Commit

Permalink
WIP: launchIt tests passing
Browse files Browse the repository at this point in the history
 - larry returns instance so others can subscribe / deposit
 - Larry's wallet needs to know about MNY
   (recall upcoming HACK to add stuff to agoricNames)
  • Loading branch information
dckc committed Jan 15, 2024
1 parent 058ba8f commit 2029597
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
3 changes: 1 addition & 2 deletions contract/src/launchIt.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
import { E, Far } from '@endo/far';
import { Far } from '@endo/far';
import { M, mustMatch } from '@endo/patterns';
import {
BrandShape,
Expand All @@ -13,7 +13,6 @@ import {
TimestampRecordShape,
TimestampValueShape,
} from '@agoric/time/src/typeGuards.js';
import { makeDurableZone } from '@agoric/zone/durable.js';
import { atomicRearrange } from '@agoric/zoe/src/contractSupport/index.js';

const { Fail, quote: q } = assert;
Expand Down
20 changes: 14 additions & 6 deletions contract/test/market-actors.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,12 @@ export const launcherLarry = async (t, { wallet }, wellKnown) => {
let offerSeq = 0;

const launch = async (
customTerms = { name: 'CDOG', supplyQty: 1_000_000n },
installation,
customTerms = { name: 'CDOG', supplyQty: 1_000_000n },
) => {
t.log('Larry prepares to launch', customTerms);
const starterAux = await wellKnown.boardAux(instance.contractStarter);
const { startInstance } = starterAux.terms.prices;
const deadline = harden({ timerBrand, absValue: 10n });

const startOpts = {
label: 'CDOG-launch',
Expand All @@ -345,6 +345,7 @@ export const launcherLarry = async (t, { wallet }, wellKnown) => {
/** @type {import('@agoric/smart-wallet').OfferSpec} */

const launchOfferId = `launch-${(offerSeq += 1)}`;
t.log('Larry pays', startInstance, 'to start', startOpts.label);
const updates = await E(wallet.offers).executeOffer({
id: launchOfferId,
invitationSpec: {
Expand All @@ -358,10 +359,15 @@ export const launcherLarry = async (t, { wallet }, wellKnown) => {
},
});

t.log('TODO: 1,000,000 CDOG tokens are minted');

const result = await E(seatLike(updates)).getOfferResult();
const seat = seatLike(updates);
const result = await E(seat).getOfferResult();
t.log('larry launch result', result);
const { Handles } = await E(seat).getPayouts();
const { instance: launched } = Handles.value[0].customDetails;
t.log('larry launch instance', launched);

const deadline = harden({ timerBrand, absValue: 10n });
t.log('Larry opens pool thru', deadline);
const up2 = await E(wallet.offers).executeOffer({
id: `kickoff-${(offerSeq += 1)}`,
invitationSpec: {
Expand All @@ -370,11 +376,13 @@ export const launcherLarry = async (t, { wallet }, wellKnown) => {
invitationMakerName: 'Launch',
},
proposal: {
want: { Deposit: AmountMath.make(MNY.brand, 0n) },
exit: { afterDeadline: { timer, deadline } },
},
});
const kickoffResult = await E(seatLike(up2)).getOfferResult();
t.is(result, '@@@');
t.is(kickoffResult, 'CDOG');
return launched;
};

return { launch };
Expand Down
33 changes: 12 additions & 21 deletions contract/test/test-launchIt.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getBundleId,
} from './boot-tools.js';
import { makeWalletFactory } from './wallet-tools.js';
import { AssetKind } from '@agoric/ertp/src/amountMath.js';
import { AmountMath, AssetKind } from '@agoric/ertp/src/amountMath.js';
import { makeIssuerKit } from '@agoric/ertp';
import { launcherLarry, starterSam } from './market-actors.js';
import {
Expand Down Expand Up @@ -76,37 +76,28 @@ test.serial('start launchIt instance to launch token', async t => {
boardAux,
};

const sam = starterSam(
t,
{ wallet: await walletFactory.makeSmartWallet('agoric1sam') },
wellKnown,
);
const wallet = {
sam: await walletFactory.makeSmartWallet('agoric1sam'),
larry: await walletFactory.makeSmartWallet('agoric1larry'),
};
const sam = starterSam(t, { wallet: wallet.sam }, wellKnown);

const installation = await E(sam).install({ bundleID, label: 'launchIt' });

// issuerKeywordRecord: { MNY: MNY.issuer },

t.is(typeof installation, 'object');

t.log('Creator Cathy chooses to launch a new token, CDOG, paired with MNY');

powers.brand.produce.MNY.resolve(MNY.brand);
powers.issuer.produce.MNY.resolve(MNY.issuer);

await E(wallet.larry.offers).addIssuer(MNY.issuer);
assert(await wellKnown.brand.timer, 'no timer brand???');
const larry = await launcherLarry(
t,
{ wallet: await walletFactory.makeSmartWallet('agoric1cathy') },
wellKnown,
);
const x = await E(larry).launch(
{ name: 'CDOG', supplyQty: 1_000_000n },
installation,
);
t.deepEqual(x, '@@@');
t.log('TODO: pool is open for contributions');
const larry = await launcherLarry(t, { wallet: wallet.larry }, wellKnown);
const instance = await E(larry).launch(installation);
t.log('TODO: pool is open for contributions:', instance);
t.log('TODO: boostrap time is up. swap contributions');
t.log('TODO Cathy withdraws proceeds');
t.log('TODO: 1,000,000 CDOG tokens are distributed to subscribers');
t.log('TODO Larry withdraws proceeds');
});

const albert = async (wellKnown, wallet) => {
Expand Down

0 comments on commit 2029597

Please sign in to comment.