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

subscription service contract II #101

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4958702
buid: upgrade Yarn to berry (4.4.1)
turadg Sep 5, 2024
3478836
ci: corepack enable
turadg Sep 5, 2024
c210214
chore(deps): bump ses to latest (1.8.0)
turadg Sep 5, 2024
520a9de
chore(deps): fix yarn install warnings
turadg Sep 5, 2024
0078442
lint: fix new errors
turadg Sep 5, 2024
a491108
build: script to update dependencies
turadg Sep 5, 2024
e2b4c59
chore(deps): scripts/update-dependencies.js agoric agoric-upgrade-16
turadg Sep 5, 2024
cf3e3fa
chore(deps): scripts/update-dependencies.js endo latest
turadg Sep 5, 2024
84c677f
chore(deps):rm agoric/eventual-send
turadg Sep 5, 2024
b2fd3fc
chore(deps): bump agoric/web-components to latest
turadg Sep 5, 2024
4312e6b
chore(deps): bump agoric/rpc to latest (0.10.0)
turadg Sep 6, 2024
dcfbefe
chore(deps): resolve agoric dep
turadg Sep 6, 2024
950b052
initial
Muneeb147 Sep 4, 2024
d2952a0
test updated and coins alotted
mujahidkay Sep 4, 2024
f1c5c37
lint: format code
rabi-siddique Sep 5, 2024
af285da
test: update tests to work with contract changes
rabi-siddique Sep 5, 2024
f245f58
revert changes in package.json and yarn.lock
rabi-siddique Sep 5, 2024
ec63260
chore: fix lint errors
rabi-siddique Sep 5, 2024
f13cd16
`getSubscriptionResources` publicfacet added;
Muneeb147 Sep 5, 2024
da3459d
time service comment added;
Muneeb147 Sep 5, 2024
2437a63
M.eq used;
Muneeb147 Sep 5, 2024
d3f93b0
serviceType added;
Muneeb147 Sep 5, 2024
3eb7343
address lint errors
rabi-siddique Sep 5, 2024
7fc7729
minor serviceType renaming
Muneeb147 Sep 5, 2024
ab62223
service ui
mujahidkay Sep 5, 2024
b9c5b5d
Timeservice commented && View subscription access implemented;
Muneeb147 Sep 6, 2024
ac6d3f9
fixup provide chainTimerService
turadg Sep 6, 2024
30bc2d5
ui changes and timeservice logic
rabi-siddique Sep 6, 2024
d2c145f
tests fix
rabi-siddique Sep 6, 2024
dd0762a
flakiness of wallet subscription fixed;
Muneeb147 Sep 6, 2024
bee23b1
delay timer added;
Muneeb147 Sep 6, 2024
7326ca2
offerArgs.offerType condition removed;
Muneeb147 Sep 6, 2024
e0f078c
Update Trade.tsx
Muneeb147 Sep 6, 2024
f1256f3
minor msg changed and timer extended;
Muneeb147 Sep 6, 2024
9ebd546
Update Trade.tsx
Muneeb147 Sep 6, 2024
70e9cb8
Update test-contract.js
Muneeb147 Sep 6, 2024
e05c97f
async removed
Muneeb147 Sep 10, 2024
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
Prev Previous commit
Next Next commit
test updated and coins alotted
  • Loading branch information
mujahidkay authored and turadg committed Sep 6, 2024
commit d2952a05f8f35590737b37eaf99edae77f032e43
2 changes: 1 addition & 1 deletion contract/src/offer-up-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const startOfferUpContract = async permittedPowers => {

// Subscription Service Terms

const subscriptionTerms = { subscriptionPrice: AmountMath.make(istBrand, 10n * CENT) }
const subscriptionTerms = { subscriptionPrice: AmountMath.make(istBrand, 500n) }


// agoricNames gets updated each time; the promise space only once XXXXXXX
Expand Down
24 changes: 11 additions & 13 deletions contract/src/offer-up.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import { Far } from '@endo/far';
import { M, getCopyBagEntries } from '@endo/patterns';
import { AmountMath, AssetKind } from '@agoric/ertp/src/amountMath.js';
import { makeCopyBag } from '@endo/patterns';
import { AmountShape } from '@agoric/ertp/src/typeGuards.js';
import { atomicRearrange } from '@agoric/zoe/src/contractSupport/atomicTransfer.js';
import { makeIssuerKit } from '@agoric/ertp';
Expand Down Expand Up @@ -88,6 +89,9 @@ export const start = async zcf => {
* AssetKind.COPY_BAG can express non-fungible (or rather: semi-fungible)
* amounts such as: 3 potions and 1 map.
*/
const itemMint = await zcf.makeZCFMint('Item', AssetKind.COPY_BAG);

const { brand } = itemMint.getIssuerRecord();

/**
* a pattern to constrain proposals given to {@link tradeHandler}
Expand All @@ -96,8 +100,8 @@ export const start = async zcf => {
* The `Items` amount must use the `Item` brand and a bag value.
*/
const proposalShape = harden({
give: { Price: M.eq(subscriptionPrice) },
want: { Items: { brand: M.any(), value: 1 } },
give: { Price: subscriptionPrice },
want: { Items: { brand: M.any(), value: M.bag() } },
exit: M.any(),
});

Expand Down Expand Up @@ -126,33 +130,27 @@ export const start = async zcf => {

// mint.mintPayment()

const itemMint = await zcf.makeZCFMint('Item', AssetKind.COPY_BAG);

const { brand } = itemMint.getIssuerRecord();

// give and want are guaranteed by Zoe to match proposalShape

// const { want } = buyerSeat.getProposal();
const amountObject = AmountMath.make(
brand,
harden({ expiryTime: Date.now() }),
makeCopyBag([[{ expiryTime: '123' }, 1n]]),
);
const _want = { Subs: amountObject };
const want = { Items: amountObject };

const newSubscription = itemMint.mintGains(_want);
const newSubscription = itemMint.mintGains(want);

// itemMint.
debugger;
atomicRearrange(
zcf,
harden([
// price from buyer to proceeds
[buyerSeat, proceeds, { Price: subscriptionPrice }],
// new items to buyer
[newSubscription, buyerSeat, _want],
[newSubscription, buyerSeat, want],
]),
);
debugger;

buyerSeat.exit(true);
newSubscription.exit();
return 'Subscription Granted';
Expand Down
23 changes: 13 additions & 10 deletions contract/test/test-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,17 @@ const alice = async (t, zoe, instance, purse, choices = ['map', 'scroll']) => {
const publicFacet = E(zoe).getPublicFacet(instance);
// @ts-expect-error Promise<Instance> seems to work
const terms = await E(zoe).getTerms(instance);
const { issuers, brands, tradePrice } = terms;
const { issuers, brands, subscriptionPrice } = terms;

const choiceBag = makeCopyBag(choices.map(name => [name, 1n]));
const choiceBag = makeCopyBag([[{expiryTime: '123'}, 1n]]);

const subscriptionPriceV2 = { ...subscriptionPrice, value: 500n }
//
const proposal = {
give: { Price: tradePrice },
give: { Price: subscriptionPriceV2},
want: { Items: AmountMath.make(brands.Item, choiceBag) },
};
const pmt = await E(purse).withdraw(tradePrice);
const pmt = await E(purse).withdraw(subscriptionPriceV2);
t.log('Alice gives', proposal.give);
// #endregion makeProposal

Expand All @@ -113,8 +116,8 @@ test('Alice trades: give some play money, want items', async t => {

const money = makeIssuerKit('PlayMoney');
const issuers = { Price: money.issuer };
const terms = { tradePrice: AmountMath.make(money.brand, 5n) };

const terms = { subscriptionPrice: AmountMath.make(money.brand, 5n) };
t.log('terms:', terms);
/** @type {ERef<Installation<AssetContractFn>>} */
const installation = E(zoe).install(bundle);
const { instance } = await E(zoe).startInstance(installation, issuers, terms);
Expand Down Expand Up @@ -220,10 +223,10 @@ test('use the code that will go on chain to start the contract', async t => {
// When the BLD staker governance proposal passes,
// the startup function gets called.
await startOfferUpContract(powers);
// const instance = await sync.instance.promise;
const instance = await sync.instance.promise;

// Now that we have the instance, resume testing as above.
// const { feeMintAccess, bundleCache } = t.context;
// const { faucet } = makeStableFaucet({ bundleCache, feeMintAccess, zoe });
// await alice(t, zoe, instance, await faucet(5n * UNIT6));
const { feeMintAccess, bundleCache } = t.context;
const { faucet } = makeStableFaucet({ bundleCache, feeMintAccess, zoe });
await alice(t, zoe, instance, await faucet(5n * UNIT6));
});