-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat(contract): linting and typedefs #26
Changes from 1 commit
4a7fdbd
a6496a0
7e3d0ed
f2d6dfc
a78ea8f
fdae180
799e40f
647f561
454c8c7
3ce6458
ad81605
f0a60ba
ca54045
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,7 +1,8 @@ | ||||||||
// @ts-check | ||||||||
import { E } from '@endo/far'; | ||||||||
import { E } from '@endo/eventual-send'; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||
import { makeMarshal } from '@endo/marshal'; | ||||||||
import { AmountMath } from '@agoric/ertp/src/amountMath.js'; | ||||||||
import '@agoric/zoe/exported.js'; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These bloat bundles. Ugh. Please add an important |
||||||||
|
||||||||
console.warn('start-game1-proposal.js module evaluating'); | ||||||||
|
||||||||
|
@@ -26,6 +27,11 @@ const makeBoardAuxNode = async (chainStorage, boardId) => { | |||||||
return E(boardAux).makeChildNode(boardId); | ||||||||
}; | ||||||||
|
||||||||
/** | ||||||||
* @param {ERef<StorageNode>} chainStorage | ||||||||
* @param {ERef<import('@agoric/vats/src/types').Board>} board | ||||||||
* @param {ERef<Brand>} brand | ||||||||
*/ | ||||||||
const publishBrandInfo = async (chainStorage, board, brand) => { | ||||||||
const [id, displayInfo] = await Promise.all([ | ||||||||
E(board).getId(brand), | ||||||||
|
@@ -38,28 +44,25 @@ const publishBrandInfo = async (chainStorage, board, brand) => { | |||||||
|
||||||||
/** | ||||||||
* Core eval script to start contract | ||||||||
* | ||||||||
* @param {BootstrapPowers} permittedPowers | ||||||||
* XXX FIXME File '~/agoric-sdk/packages/vats/src/core/types.js' is not a module | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. importing the ambient for side-effects should work. |
||||||||
* @param {import('@agoric/vats/src/core/types').BootstrapPowers} permittedPowers | ||||||||
*/ | ||||||||
export const startGameContract = async permittedPowers => { | ||||||||
console.error('startGameContract()...'); | ||||||||
const { | ||||||||
consume: { board, chainStorage, startUpgradable, zoe }, | ||||||||
brand: { | ||||||||
consume: { IST: istBrandP }, | ||||||||
// @ts-expect-error dynamic extension to promise space | ||||||||
produce: { Place: producePlaceBrand }, | ||||||||
}, | ||||||||
issuer: { | ||||||||
consume: { IST: istIssuerP }, | ||||||||
// @ts-expect-error dynamic extension to promise space | ||||||||
produce: { Place: producePlaceIssuer }, | ||||||||
}, | ||||||||
installation: { | ||||||||
consume: { game1: game1InstallationP }, | ||||||||
}, | ||||||||
instance: { | ||||||||
// @ts-expect-error dynamic extension to promise space | ||||||||
produce: { game1: produceInstance }, | ||||||||
}, | ||||||||
} = permittedPowers; | ||||||||
|
@@ -117,6 +120,9 @@ const gameManifest = { | |||||||
}; | ||||||||
harden(gameManifest); | ||||||||
|
||||||||
/** | ||||||||
* @param {{restoreRef: (ref: unknown) => Promise<unknown> }} r | ||||||||
* @param {{ game1Ref: unknown }} g */ | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
export const getManifestForGame1 = ({ restoreRef }, { game1Ref }) => { | ||||||||
return harden({ | ||||||||
manifest: gameManifest, | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
*/ | ||
|
||
// @ts-check | ||
import { E } from '@endo/far'; | ||
import { E } from '@endo/eventual-send'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as before, no, please. |
||
import { createRequire } from 'module'; | ||
|
||
const myRequire = createRequire(import.meta.url); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ import { test } from './prepare-test-env-ava.js'; | |
|
||
import { createRequire } from 'module'; | ||
import bundleSource from '@endo/bundle-source'; | ||
import { E, passStyleOf } from '@endo/far'; | ||
import { E } from '@endo/eventual-send'; | ||
import { passStyleOf } from '@endo/far'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls revert There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds like a bug in Either way, eventual-send is the source: https://github.com/endojs/endo/blob/2179108cb9247e9499c1f319de907d7cd365f314/packages/far/src/index.js#L1
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as noted above, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tracking this here #31 to keep this PR moving |
||
import { makeZoeKitForTest } from '@agoric/zoe/tools/setup-zoe.js'; | ||
|
||
const myRequire = createRequire(import.meta.url); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ | |
import { test as anyTest } from './prepare-test-env-ava.js'; | ||
|
||
import { createRequire } from 'module'; | ||
import { E, Far } from '@endo/far'; | ||
import { E } from '@endo/eventual-send'; | ||
import { Far } from '@endo/far'; | ||
import { makePromiseKit } from '@endo/promise-kit'; | ||
0xpatrickdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { makeCopyBag } from '@endo/patterns'; | ||
import { makeNodeBundleCache } from '@endo/bundle-source/cache.js'; | ||
|
@@ -78,8 +79,8 @@ test('Start the contract', async t => { | |
* | ||
* @param {import('ava').ExecutionContext} t | ||
* @param {ZoeService} zoe | ||
* @param {ERef<import('@agoric/zoe/src/zoeService/utils').Instance<GameContractFn>} instance | ||
* @param {Purse} purse | ||
* @param {import('@agoric/zoe/src/zoeService/utils').Instance<GameContractFn>} instance | ||
* @param {Purse<"nat">} purse | ||
0xpatrickdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @param {string[]} choices | ||
*/ | ||
const alice = async ( | ||
|
@@ -90,7 +91,7 @@ const alice = async ( | |
choices = ['Park Place', 'Boardwalk'], | ||
) => { | ||
const publicFacet = E(zoe).getPublicFacet(instance); | ||
// @ts-expect-error Promise<Instance> seems to work | ||
/** @type {import('../src/gameAssetContract.js').GamePlacesTerms} */ | ||
const terms = await E(zoe).getTerms(instance); | ||
const { issuers, brands, joinPrice } = terms; | ||
|
||
|
@@ -188,6 +189,14 @@ test('use the code that will go on chain to start the contract', async t => { | |
}); | ||
|
||
const { zoe } = t.context; | ||
/** | ||
* @param {{ | ||
* installation: ERef<Installation<GameContractFn>>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* issuerKeywordRecord: IssuerKeywordRecord; | ||
* label: string; | ||
* terms: import('../src/gameAssetContract.js').GamePlacesTerms; | ||
* }} opts | ||
*/ | ||
const startUpgradable = async ({ | ||
installation, | ||
issuerKeywordRecord, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
important: Why constrain it to
nat
amounts?StandardTerms
is redundant here. The parameter to theZCF<...>
type is custom terms.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree/ack. This was added in an attempt to get
const terms = await E(zoe).getTerms(instance);
insidetest-contract.js
to not complainProperty 'brands' does not exist on type 'GamePlacesTerms'.
.Open to hints for getting
StandardTerms
recognized properly in the testing context.