-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(swingset-vat): move VatData to new vat-data package (#4603)
* refactor(swingset-vat): provide an export for VatData * create vat-data package * bend less to missing VatData global * working types * stop exporting VatData from swingset-vat package so there's one package to get it
- Loading branch information
Showing
41 changed files
with
224 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/SwingSet/test/virtualObjects/vat-representative-bootstrap.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/SwingSet/test/virtualObjects/vat-weakcollections-alice.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "@agoric/vat-data", | ||
"version": "0.1.0", | ||
"description": "Safe access to VatData global", | ||
"type": "module", | ||
"repository": "https://github.com/Agoric/agoric-sdk", | ||
"main": "./src/index.js", | ||
"scripts": { | ||
"build": "exit 0", | ||
"test": "ava", | ||
"test:c8": "exit 0", | ||
"test:xs": "exit 0", | ||
"lint-fix": "yarn lint:eslint --fix", | ||
"lint": "run-s --continue-on-error lint:*", | ||
"lint:eslint": "eslint '**/*.js'", | ||
"lint:types": "tsc" | ||
}, | ||
"keywords": [], | ||
"author": "Agoric", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@agoric/assert": "*", | ||
"@agoric/store": "^0.6.10" | ||
}, | ||
"devDependencies": { | ||
"ava": "^3.12.1", | ||
"@agoric/swingset-vat": "*" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"@agoric" | ||
] | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"engines": { | ||
"node": ">=14.15.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* global globalThis */ | ||
import { assert } from '@agoric/assert'; | ||
import { | ||
M, | ||
makeScalarMapStore, | ||
makeScalarWeakMapStore, | ||
makeScalarSetStore, | ||
makeScalarWeakSetStore, | ||
} from '@agoric/store'; | ||
|
||
export { | ||
M, | ||
makeScalarMapStore, | ||
makeScalarWeakMapStore, | ||
makeScalarSetStore, | ||
makeScalarWeakSetStore, | ||
}; | ||
|
||
/** @type {import('./types').VatData} */ | ||
let VatDataGlobal; | ||
if ('VatData' in globalThis) { | ||
assert(globalThis.VatData, 'VatData defined in global as null or undefined'); | ||
VatDataGlobal = globalThis.VatData; | ||
} else { | ||
// XXX this module has been known to get imported (transitively) in cases that | ||
// never use it so we make a version that will satisfy module resolution but | ||
// fail at runtime. | ||
const unvailable = () => assert.fail('VatData unavailable'); | ||
VatDataGlobal = { | ||
defineKind: unvailable, | ||
defineDurableKind: unvailable, | ||
makeKindHandle: unvailable, | ||
makeScalarBigMapStore: unvailable, | ||
makeScalarBigWeakMapStore: unvailable, | ||
makeScalarBigSetStore: unvailable, | ||
makeScalarBigWeakSetStore: unvailable, | ||
}; | ||
} | ||
|
||
export const { | ||
defineKind, | ||
defineDurableKind, | ||
makeKindHandle, | ||
makeScalarBigMapStore, | ||
makeScalarBigWeakMapStore, | ||
makeScalarBigSetStore, | ||
makeScalarBigWeakSetStore, | ||
} = VatDataGlobal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { defineKind } from '.'; | ||
|
||
export const makePaymentMaker = (allegedName: string, brand: unknown) => { | ||
const makePayment = defineKind( | ||
`${allegedName} payment`, | ||
() => ({}), | ||
// @ts-expect-error "state" type implied by init() doesn't provide "a" | ||
({ a: something }) => ({ | ||
getAllegedBrand: () => brand, | ||
}), | ||
); | ||
return makePayment; | ||
}; | ||
|
||
type FlorgState = { str: string }; | ||
const makeFlorg = defineKind( | ||
'florg', | ||
(num: number) => ({ str: String(num), extra: 'extra' }), | ||
({ str }: FlorgState) => str, | ||
); | ||
const f = makeFlorg(42); | ||
f.concat; // string | ||
// @ts-expect-error | ||
makeFlorg('notnumber'); |
Oops, something went wrong.