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

Linting dapp-agoric-basics #67

Merged
merged 13 commits into from
Oct 1, 2024
2 changes: 2 additions & 0 deletions contract/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bundles
dist
25 changes: 0 additions & 25 deletions contract/jsconfig.json

This file was deleted.

55 changes: 38 additions & 17 deletions contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,53 +14,53 @@
"build": "yarn build:deployer",
"build:deployer": "rollup -c rollup.config.mjs",
"test": "ava --verbose",
"lint": "eslint '**/*.js'",
"lint:types": "tsc -p jsconfig.json",
"lint": "tsc && eslint '**/*.js'",
"lint:fix": "eslint --fix '**/*.js'"
},
"devDependencies": {
"@agoric/deploy-script-support": "^0.10.4-u14.0",
"@agoric/eslint-config": "dev",
"@agoric/eslint-config": "^0.4.1-u16.0",
"@agoric/smart-wallet": "0.5.4-u14.0",
"@agoric/store": "0.9.3-u14.0",
"@agoric/xsnap": "0.14.3-u14.0",
"@agoric/zone": "0.2.3-u14.0",
"@endo/eslint-plugin": "^0.5.2",
"@endo/eslint-plugin": "^2.2.1",
"@endo/nat": "^4.1.27",
"@endo/promise-kit": "0.2.56",
"@endo/ses-ava": "^0.2.44",
"@jessie.js/eslint-plugin": "^0.4.0",
"@jessie.js/eslint-plugin": "^0.4.1",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"agoric": "^0.21.2-u12.0",
"ava": "^5.3.0",
"eslint": "^8.47.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-jessie": "^0.0.6",
"eslint-config-prettier": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-ava": "^14.0.0",
"eslint-plugin-github": "^4.10.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsdoc": "^46.4.3",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.5.2",
"eslint-plugin-prettier": "^5.1.3",
"import-meta-resolve": "^2.2.1",
"prettier": "^3.0.3",
"prettier-plugin-jsdoc": "^1.0.0",
"type-coverage": "^2.26.3",
"typescript": "~5.2.2"
"typescript": "^5.5.3",
"typescript-eslint": "^7.2.0"
},
"dependencies": {
"@agoric/ertp": "^0.16.3-u14.0",
"@agoric/ertp": "^0.16.3-u16.1",
"@agoric/governance": "^0.10.4-u14.0",
"@agoric/inter-protocol": "0.16.2-u14.1",
"@agoric/vats": "0.15.2-u14.0",
"@agoric/vat-data": "0.5.3-u14.0",
"@agoric/zoe": "^0.26.3-u14.0",
"@endo/bundle-source": "^2.8.0",
"@agoric/zoe": "^0.26.3-u16.1",
"@endo/bundle-source": "^3.4.0",
"@endo/far": "^0.2.22",
"@endo/init": "^0.5.60",
"@endo/marshal": "^0.8.9",
"@endo/patterns": "^0.2.5"
"@endo/init": "^1.1.4",
"@endo/marshal": "^1.5.3",
"@endo/patterns": "^1.4.3"
},
"ava": {
"files": [
Expand All @@ -80,14 +80,35 @@
},
"homepage": "https://github.com/Agoric/dapp-agoric-basics#readme",
"eslintConfig": {
"env": {
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2021
},
"ignorePatterns": "bundles/**.js",
"extends": [
"plugin:@typescript-eslint/recommended",
"@agoric"
]
],
"plugins": [
"@typescript-eslint",
"prettier"
],
"rules": {
"prettier/prettier": "warn",
"@typescript-eslint/no-unused-vars": [
"error",
{
"vars": "all",
"args": "all",
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
]
}
},
"prettier": {
"trailingComma": "all",
Expand Down
1 change: 0 additions & 1 deletion contract/scripts/deploy-contract.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node
/* global process, fetch, setTimeout */
// @ts-check
import '@endo/init';
import fsp from 'node:fs/promises';
Expand Down
2 changes: 2 additions & 0 deletions contract/src/collectFees.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { atomicTransfer } from '@agoric/zoe/src/contractSupport/index.js';

/** @import {Brand} from '@agoric/ertp/src/types.js'; */

/**
* Provide shared support for providing access to fees from a service contract.
*
Expand Down
7 changes: 6 additions & 1 deletion contract/src/fixHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import { E, Far } from '@endo/far';

const { Fail } = assert;

/**
* @import {ERef} from '@endo/far';
* @import {NameAdmin} from '@agoric/vats';
*/

/**
* ref https://github.com/Agoric/agoric-sdk/issues/8408#issuecomment-1741445458
*
* @param {ERef<import('@agoric/vats').NameAdmin>} namesByAddressAdmin
* @param {ERef<NameAdmin>} namesByAddressAdmin
*/
export const fixHub = async namesByAddressAdmin => {
assert(namesByAddressAdmin, 'no namesByAddressAdmin???');
Expand Down
2 changes: 2 additions & 0 deletions contract/src/objectTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { E } from '@endo/far';

const { entries, fromEntries } = Object;

/** @import {ERef} from '@endo/far'; */

/**
* Given a record whose values may be promise, return a promise for a record with all the values resolved.
*
Expand Down
21 changes: 15 additions & 6 deletions contract/src/platform-goals/board-aux.core.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
// @ts-check
/// <reference types="@agoric/vats/src/core/types-ambient.js"/>
import { E, Far } from '@endo/far';

/**
* @import {ERef} from '@endo/far';
* @import {StorageNode,Marshaller} from '@agoric/internal/src/lib-chainStorage.js';
* @import {Zone} from '@agoric/zone';
* @import {Brand} from '@agoric/ertp/src/types.js';
* @import {Board} from '@agoric/vats';
*/

const { Fail } = assert;

// vstorage paths under published.*
// and zone store key
export const BOARD_AUX = 'boardAux';

/**
* @param {import('@agoric/zone').Zone} zone
* @param {Zone} zone
* @param {Marshaller} marshalData
* @param {{
* board: ERef<import('@agoric/vats').Board>;
* board: ERef<Board>;
* chainStorage: ERef<StorageNode>;
* }} powers
*/
Expand Down Expand Up @@ -73,7 +82,6 @@ export const makeBoardAuxManager = (zone, marshalData, powers) => {
/**
* @typedef {PromiseSpaceOf<{
* brandAuxPublisher: BrandAuxPublisher;
* boardAuxTOFU: BoardAuxTOFU;
* boardAuxAdmin: BoardAuxAdmin;
* }>} BoardAuxPowers
*/
Expand All @@ -86,12 +94,12 @@ export const marshalData = harden({
unserialize: () => Fail`not implemented`,
});

/** @param {BootstrapPowers} powers */
/**
* @param {BootstrapPowers} powers
*/
export const produceBoardAuxManager = async powers => {
const { zone } = powers;
const { board } = powers.consume;
/** @type {import('../types').NonNullChainStorage['consume']} */
// @ts-expect-error cast
const { chainStorage } = powers.consume;

/** @type {BoardAuxPowers['produce']} */
Expand All @@ -100,6 +108,7 @@ export const produceBoardAuxManager = async powers => {

const mgr = makeBoardAuxManager(zone, marshalData, { board, chainStorage });
produce.brandAuxPublisher.reset();

// TODO: powers.produce.boardAuxTOFU.reset();
produce.boardAuxAdmin.reset();
produce.brandAuxPublisher.resolve(mgr.brandAuxPublisher);
Expand Down
5 changes: 3 additions & 2 deletions contract/src/platform-goals/endo1.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import * as marshal from '@endo/marshal';
import * as patterns from '@endo/patterns';

/** @import {BootstrapManifestPermit} from '@agoric/vats/src/core/lib-boot.js'; */

/**
* @typedef {{
* endo1: {
Expand All @@ -23,9 +25,8 @@ export const produceEndoModules = permittedPowers => {
produce.endo1.resolve(endo);
};

/** @type {import('@agoric/vats/src/core/lib-boot').BootstrapManifestPermit} */
/** @type {BootstrapManifestPermit} */
export const permit = {
/** @type {Record<keyof Endo1Modules, true>} */
produce: { endo1: true },
};

Expand Down
7 changes: 6 additions & 1 deletion contract/src/platform-goals/start-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

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

/**
* @import {AssetKind, Brand} from '@agoric/ertp/src/types.js';
* @import {BoardAuxPowers} from './board-aux.core.js';
*/

const { Fail } = assert;

/**
Expand Down Expand Up @@ -63,7 +68,7 @@ export const startContract = async (
console.log(name, 'started');

if (issuerNames) {
/** @type {BootstrapPowers & import('./board-aux.core').BoardAuxPowers} */
/** @type {BootstrapPowers & BoardAuxPowers} */
// @ts-expect-error cast
const auxPowers = powers;

Expand Down
46 changes: 22 additions & 24 deletions contract/src/platform-goals/start-governed-contract.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
// @ts-check
/// <reference types="@agoric/zoe/src/zoeService/types-ambient.js";/>
import { E } from '@endo/far';

import { allValues, zip } from '../objectTools.js';
import { sanitizePathSegment } from './start-contract.js';

const { values } = Object;

/**
* @template SF
* @typedef {import('@agoric/zoe/src/zoeService/utils').StartResult<SF>} StartResult<SF>
*/

/**
* @template SF
* @typedef {import('@agoric/zoe/src/zoeService/utils').StartParams<SF>} StartParams<SF>
* @import {StartResult, StartParams} from '@agoric/zoe/src/zoeService/utils.js';
* @import {prepare} from '@agoric/governance/src/committee.js';
* @import {ERef} from '@endo/far';
* @import {GovernableStartFn, GovernanceFacetKit} from '@agoric/governance/src/types.js';
* @import {NameHub} from '@agoric/vats';
* @import {TimerService} from '@agoric/time';
*/
const { values } = Object;

/**
* @typedef {StartResult<
* typeof import('@agoric/governance/src/committee.js').prepare
* typeof prepare
* >} CommitteeStart
*/

Expand Down Expand Up @@ -55,12 +54,14 @@ export const ParamTypes = /** @type {const} */ ({
* governedContractInstallation: ERef<Installation<SF>>;
* issuerKeywordRecord?: IssuerKeywordRecord;
* terms: Record<string, unknown>;
* privateArgs: StartParams<SF>['privateArgs'];
* privateArgs?: StartParams<SF> extends { privateArgs: unknown }
turadg marked this conversation as resolved.
Show resolved Hide resolved
* ? StartParams<SF>['privateArgs']
* : Record<string, unknown>; // XXX workaround for 'privateArgs cannot be used to index StartParams'
* label: string;
* }} zoeArgs
* @param {{
* governedParams: Record<string, unknown>;
* timer: ERef<import('@agoric/time/src/types').TimerService>;
* timer: ERef<TimerService>;
* contractGovernor: ERef<Installation>;
* governorTerms: Record<string, unknown>;
* committeeCreatorFacet: CommitteeStart['creatorFacet'];
Expand Down Expand Up @@ -176,14 +177,13 @@ export const startMyCharter = async (contractName, powers, config) => {

const {
consume: { namesByAddress, zoe },
produce: { [`${charterName}Kit`]: produceKit },
produce,
installation: {
consume: { binaryVoteCounter: counterP, econCommitteeCharter: installP },
},
instance: {
produce: { [charterName]: instanceP },
},
instance: { produce: produceInstance },
} = powers;

const {
[committeeName]: { voterAddresses },
} = config?.options || {};
Expand All @@ -204,8 +204,8 @@ export const startMyCharter = async (contractName, powers, config) => {
undefined,
'econCommitteeCharter',
);
instanceP.resolve(startResult.instance);
produceKit.resolve(startResult);
produceInstance[charterName].resolve(startResult.instance);
produce[`${charterName}Kit`].resolve(startResult);

await inviteToMyCharter(
startResult.creatorFacet,
Expand All @@ -225,13 +225,11 @@ export const startMyCommittee = async (contractName, powers, config) => {
const committeeName = `${contractName}Committee`;
const {
consume: { board, chainStorage, namesByAddress, startUpgradable },
produce: { [`${committeeName}Kit`]: produceKit },
produce,
installation: {
consume: { committee },
},
instance: {
produce: { [committeeName]: produceInstance },
},
instance: { produce: produceInstance },
} = powers;
const {
[committeeName]: { voterAddresses },
Expand All @@ -255,8 +253,8 @@ export const startMyCommittee = async (contractName, powers, config) => {
terms: { committeeName, committeeSize: values(voterAddresses).length },
privateArgs,
});
produceKit.resolve(started);
produceInstance.resolve(started.instance);
produce[`${committeeName}Kit`].resolve(started);
produceInstance[committeeName].resolve(started.instance);
console.log(committeeName, 'started');

/** @param {[string, Promise<Invitation>][]} addrInvitations */
Expand Down
Loading