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

refactor: extract @agoric/contracts package #7399

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion packages/SwingSet/src/kernel/state/storageHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/agoric-cli/src/sdk-package-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default [
"@agoric/builders",
"@agoric/cache",
"@agoric/casting",
"@agoric/contracts",
"@agoric/cosmic-proto",
"@agoric/cosmic-swingset",
"@agoric/cosmos",
Expand Down
5 changes: 5 additions & 0 deletions packages/contracts/README.md
Original file line number Diff line number Diff line change
@@ -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.
48 changes: 48 additions & 0 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
6 changes: 6 additions & 0 deletions packages/contracts/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"./tsconfig.json",
"../../tsconfig-build-options.json"
]
}
18 changes: 18 additions & 0 deletions packages/contracts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
Loading