diff --git a/.github/workflows/test-all-packages.yml b/.github/workflows/test-all-packages.yml index 2fbbbd5af0e..559a932bdcf 100644 --- a/.github/workflows/test-all-packages.yml +++ b/.github/workflows/test-all-packages.yml @@ -220,6 +220,9 @@ jobs: - name: yarn test (casting) if: (success() || failure()) run: cd packages/casting && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT + - name: yarn test (contracts) + if: (success() || failure()) + run: cd packages/contracts && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT - name: yarn test (internal) if: (success() || failure()) run: cd packages/internal && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT diff --git a/packages/SwingSet/src/kernel/state/storageHelper.js b/packages/SwingSet/src/kernel/state/storageHelper.js index 835153c785e..86b2b0d4dfa 100644 --- a/packages/SwingSet/src/kernel/state/storageHelper.js +++ b/packages/SwingSet/src/kernel/state/storageHelper.js @@ -26,7 +26,10 @@ export function* enumeratePrefixedKeys(kvStore, prefix, exclusiveEnd) { } } -// NOTE: awkward naming: the thing that returns a stream of keys is named +/** + * @param {KVStore} kvStore + * @param {string} prefix + */ // NOTE: awkward naming: the thing that returns a stream of keys is named // "enumerate..." while the thing that returns a stream of values is named // "get..." function* enumerateNumericPrefixedKeys(kvStore, prefix) { @@ -43,12 +46,20 @@ function* enumerateNumericPrefixedKeys(kvStore, prefix) { } } +/** + * @param {KVStore} kvStore + * @param {string} prefix + */ export function* getPrefixedValues(kvStore, prefix) { for (const key of enumerateNumericPrefixedKeys(kvStore, prefix)) { yield kvStore.get(key) || Fail`enumerate ensures get`; } } +/** + * @param {KVStore} kvStore + * @param {string} prefix + */ export function deletePrefixedKeys(kvStore, prefix) { // this is kind of like a deleteRange() would be, but can be implemented // efficiently without backend DB support because it only looks at numeric diff --git a/packages/agoric-cli/src/sdk-package-names.js b/packages/agoric-cli/src/sdk-package-names.js index 1f2908ddf7b..23e5b277de0 100644 --- a/packages/agoric-cli/src/sdk-package-names.js +++ b/packages/agoric-cli/src/sdk-package-names.js @@ -10,6 +10,7 @@ export default [ "@agoric/builders", "@agoric/cache", "@agoric/casting", + "@agoric/contracts", "@agoric/cosmic-proto", "@agoric/cosmic-swingset", "@agoric/cosmos", diff --git a/packages/contracts/README.md b/packages/contracts/README.md new file mode 100644 index 00000000000..06d36083f31 --- /dev/null +++ b/packages/contracts/README.md @@ -0,0 +1,5 @@ +# Contracts Support + +This package contains utilities that contracts tend to need. + +It also includes sample contracts to learn from and play with. diff --git a/packages/contracts/package.json b/packages/contracts/package.json new file mode 100755 index 00000000000..0e68998183a --- /dev/null +++ b/packages/contracts/package.json @@ -0,0 +1,48 @@ +{ + "name": "@agoric/contracts", + "version": "0.0.1", + "description": "Utilities and sample contracts to support contract development", + "type": "module", + "main": "src/index.js", + "engines": { + "node": ">=14.15.0" + }, + "scripts": { + "build": "exit 0", + "prepack": "tsc --build tsconfig.build.json", + "postpack": "git clean -f '*.d.ts*'", + "test": "ava", + "test:xs": "exit 0", + "lint-fix": "yarn lint:eslint --fix", + "lint": "run-s --continue-on-error lint:*", + "lint:eslint": "eslint .", + "lint:types": "tsc" + }, + "dependencies": { + "@agoric/assert": "^0.6.0", + "@agoric/ertp": "^0.16.2", + "@agoric/internal": "^0.3.2", + "@agoric/notifier": "^0.6.2", + "@agoric/store": "^0.9.2", + "@agoric/vat-data": "^0.5.2", + "@agoric/zoe": "^0.26.2", + "@endo/eventual-send": "^0.17.5", + "@endo/marshal": "^0.8.8", + "@endo/nat": "^4.1.31", + "@endo/promise-kit": "^0.2.59", + "anylogger": "^0.21.0", + "jessie.js": "^0.3.2" + }, + "devDependencies": { + "@endo/init": "^0.5.59", + "ava": "^5.3.0" + }, + "author": "Agoric", + "license": "Apache-2.0", + "files": [ + "src" + ], + "publishConfig": { + "access": "public" + } +} diff --git a/packages/contracts/tsconfig.build.json b/packages/contracts/tsconfig.build.json new file mode 100644 index 00000000000..fe5ea57d603 --- /dev/null +++ b/packages/contracts/tsconfig.build.json @@ -0,0 +1,6 @@ +{ + "extends": [ + "./tsconfig.json", + "../../tsconfig-build-options.json" + ] +} diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json new file mode 100644 index 00000000000..f18d3125001 --- /dev/null +++ b/packages/contracts/tsconfig.json @@ -0,0 +1,18 @@ +// This file can contain .js-specific Typescript compiler config. +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "checkJs": false, // Disable b/c @endo/init can't pass noImplicitAny + "noImplicitAny": true, + "allowSyntheticDefaultImports": true, + "maxNodeModuleJsDepth": 2, + }, + "include": [ + "*.js", + "*.ts", + "src/**/*.js", + "src/**/*.ts", + "test/**/*.js", + "test/**/*.ts" + ] +}