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

feat: create initial skeleton for dapp-agoric-basics #1

Closed
wants to merge 10 commits into from
22 changes: 22 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Lint and Test

on:
pull_request:

jobs:
all:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Use Node.js 18.8.x
uses: actions/setup-node@v3
with:
# use node 18.8.x until Agoric/agoric-sdk#8636
node-version: "18.8.x"
- name: yarn install
run: yarn
- name: yarn lint
run: yarn lint
- name: yarn test
run: yarn test
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Empty file added _agstate/.keep
Empty file.
16 changes: 16 additions & 0 deletions _agstate/agoric-servers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "agoric-basics-agservers",
"version": "0.0.1",
"description": "Agoric server instances for dapp-agoric-basics",
"private": true,
"type": "module",
"scripts": {
"build": "exit 0",
"test": "exit 0",
"lint": "exit 0",
"lint-check": "exit 0",
"lint-fix": "exit 0"
},
"author": "Agoric",
"license": "Apache-2.0"
}
1 change: 1 addition & 0 deletions api/README-no-api.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This dapp has no API.
5 changes: 5 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$note": "@agoric/[email protected] expects an api/package.json",
"name": "agoric-basics-api",
"version": "0.1.0"
}
13 changes: 13 additions & 0 deletions contract/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "ES2022",

"noEmit": true,
"downlevelIteration": true,
"strictNullChecks": true,
"moduleResolution": "node"
},
"include": ["src/**/*.js", "test/**/*.js", "exported.js", "globals.d.ts"]
}
78 changes: 78 additions & 0 deletions contract/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"name": "agoric-basics-contract",
"version": "0.1.0",
"private": true,
"description": "Agoric Basics Contract",
"type": "module",
"scripts": {
"test": "ava --verbose",
"lint": "eslint '**/*.js'",
"lint:fix": "eslint --fix '**/*.js'"
},
"devDependencies": {
"@agoric/deploy-script-support": "^0.10.4-u12.0",
"@agoric/eslint-config": "dev",
"@endo/bundle-source": "^2.8.0",
"@endo/eslint-plugin": "^0.5.2",
"@endo/init": "^0.5.60",
"@endo/promise-kit": "0.2.56",
"@endo/ses-ava": "^0.2.44",
"@jessie.js/eslint-plugin": "^0.4.0",
"@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-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",
"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"
},
"dependencies": {
"@agoric/ertp": "^0.16.3-u12.0",
"@agoric/zoe": "^0.26.3-u12.0",
"@endo/far": "^0.2.22",
"@endo/marshal": "^0.8.9",
"@endo/patterns": "^0.2.5"
},
"ava": {
"files": [
"test/**/test-*.js"
],
"timeout": "10m"
},
"keywords": [],
"repository": {
"type": "git",
"url": "git+https://github.com/Agoric/dapp-agoric-basics"
},
"author": "Agoric",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/Agoric/dapp-agoric-basics/issues"
},
"homepage": "https://github.com/Agoric/dapp-agoric-basics#readme",
"eslintConfig": {
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2021
},
"extends": [
"@agoric"
]
},
Comment on lines +64 to +72
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. As a heads up, dapp-offer-up has a backlog item to expand this configuration to include type checking, and no-void + no-floating-promises rules: Agoric/dapp-offer-up#35 (comment)

This has been blocked by lack of type support in the current releases, which prevents us from checking this sort of thing into CI: Agoric/dapp-offer-up#31 (This assumption may need to be revisited, as the two eslint rules seem separate from typechecking)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, created #2 to track this

"prettier": {
"trailingComma": "all",
"arrowParens": "avoid",
"singleQuote": true
}
}
10 changes: 10 additions & 0 deletions contract/src/agoric-basics-contract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @ts-check
import { Far } from '@endo/far';

const greet = who => `Hello, ${who}!`;

export const start = () => {
return {
publicFacet: Far('Hello', { greet }),
};
};
13 changes: 13 additions & 0 deletions contract/test/test-agoric-basics-contract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @ts-check
import '@endo/init';
import { E } from '@endo/far';
// eslint-disable-next-line import/no-unresolved -- https://github.com/avajs/ava/issues/2951
import test from 'ava';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might need to do import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';... but I am not up to date on latest best practices here and could use a 2nd opinion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


import { start } from '../src/agoric-basics-contract.js';

test('contract greets by name', async t => {
const { publicFacet } = start();
const actual = await E(publicFacet).greet('Bob');
t.is(actual, 'Hello, Bob!');
});
28 changes: 28 additions & 0 deletions contract/test/test-bundle-source.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @file Test using bundleSource() on the contract.
*/

// @ts-check

// eslint-disable-next-line import/no-unresolved -- https://github.com/avajs/ava/issues/2951
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import bundleSource from '@endo/bundle-source';
import { makeZoeKitForTest } from '@agoric/zoe/tools/setup-zoe.js';
import { E, passStyleOf } from '@endo/far';
import { createRequire } from 'module';

const myRequire = createRequire(import.meta.url);
const contractPath = myRequire.resolve(`../src/agoric-basics-contract.js`);

test('bundleSource() bundles the contract for use with zoe', async t => {
const bundle = await bundleSource(contractPath);
t.is(bundle.moduleFormat, 'endoZipBase64');
t.log(bundle.endoZipBase64Sha512);
t.true(bundle.endoZipBase64.length > 10_000);

const { zoeService: zoe } = makeZoeKitForTest();
const installation = await E(zoe).install(bundle);
t.log(installation);
t.is(passStyleOf(installation), 'remotable');
});
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "agoric-basics",
"version": "0.1.0",
"license": "Apache-2.0",
"private": true,
"useWorkspaces": true,
"workspaces": [
"contract"
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. no endo resolutions to work around Agoric/agoric-sdk#8621

I was expecting something started with yarn create @agoric/dapp --dapp-template dapp-offer-up with support for starting the chain in docker, deploying the contract, testing that it's not >1MB compressed, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"scripts": {
"lint": "yarn workspaces run lint",
"test": "yarn workspaces run test"
}
}
Loading
Loading