@agoric/vat-data 0.5.3-dev-dcc80f2.0.dcc80f2 → 0.5.3-dev-a6c0604.0.a6c0604

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/index.test-d.ts +0 -189
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/vat-data",
3
- "version": "0.5.3-dev-dcc80f2.0.dcc80f2",
3
+ "version": "0.5.3-dev-a6c0604.0.a6c0604",
4
4
  "description": "Safe access to VatData global",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/Agoric/agoric-sdk",
@@ -18,9 +18,9 @@
18
18
  "author": "Agoric",
19
19
  "license": "Apache-2.0",
20
20
  "dependencies": {
21
- "@agoric/base-zone": "0.1.1-dev-dcc80f2.0.dcc80f2",
22
- "@agoric/store": "0.9.3-dev-dcc80f2.0.dcc80f2",
23
- "@agoric/swingset-liveslots": "0.10.3-dev-dcc80f2.0.dcc80f2",
21
+ "@agoric/base-zone": "0.1.1-dev-a6c0604.0.a6c0604",
22
+ "@agoric/store": "0.9.3-dev-a6c0604.0.a6c0604",
23
+ "@agoric/swingset-liveslots": "0.10.3-dev-a6c0604.0.a6c0604",
24
24
  "@endo/errors": "^1.2.13",
25
25
  "@endo/exo": "^1.5.12",
26
26
  "@endo/patterns": "^1.7.0"
@@ -52,5 +52,5 @@
52
52
  "typeCoverage": {
53
53
  "atLeast": 99.33
54
54
  },
55
- "gitHead": "dcc80f24250a2f7221c8ffbc913d6f289c366313"
55
+ "gitHead": "a6c06040100171553fdf07d11e906d073c019dee"
56
56
  }
@@ -1,189 +0,0 @@
1
- import { expectType } from 'tsd';
2
- import type {
3
- KindFacets,
4
- DurableKindHandle,
5
- KindFacet,
6
- FunctionsPlusContext,
7
- } from '@agoric/swingset-liveslots';
8
- import type { VirtualObjectManager } from '@agoric/swingset-liveslots/src/virtualObjectManager.js';
9
- import {
10
- defineKind,
11
- defineKindMulti,
12
- makeKindHandle,
13
- defineDurableKind,
14
- partialAssign,
15
- watchPromise,
16
- } from './index.js';
17
-
18
- // for use in assignments below
19
- const anyVal = null as any;
20
-
21
- /*
22
- export const makePaymentMaker = (allegedName: string, brand: unknown) => {
23
- const makePayment = defineKind(
24
- `${allegedName} payment`,
25
- () => ({}),
26
- // @ts-expect-error "state" type implied by init() doesn't provide "a"
27
- ({ a: something }) => ({
28
- getAllegedBrand: () => brand,
29
- }),
30
- );
31
- return makePayment;
32
- };
33
-
34
- type FlorgState = { str: string };
35
- const makeFlorg = defineKind(
36
- 'florg',
37
- (num: number) => ({ str: String(num), extra: 'extra' }),
38
- ({ str }: FlorgState) => str,
39
- );
40
- const f = makeFlorg(42);
41
- f.concat; // string
42
- // @ts-expect-error
43
- makeFlorg('notnumber');
44
- */
45
-
46
- // Single-faceted example from virtual-objects.md
47
- type SingleCounterState = { counter: number; name: string };
48
- type SingleCounterContext = {
49
- state: SingleCounterState;
50
- self: KindFacet<typeof counterBehavior>;
51
- };
52
- const initCounter = (name: string, _str: string): SingleCounterState => ({
53
- counter: 0,
54
- name,
55
- });
56
-
57
- const counterBehavior = {
58
- inc: ({ state }: SingleCounterContext) => {
59
- state.counter += 1;
60
- },
61
- dec: ({ state }: SingleCounterContext) => {
62
- state.counter -= 1;
63
- },
64
- reset: ({ state }: SingleCounterContext) => {
65
- state.counter = 0;
66
- },
67
- rename: ({ state }: SingleCounterContext, newName: string) => {
68
- state.name = newName;
69
- },
70
- getCount: ({ state }: SingleCounterContext) => state.counter,
71
- getName: ({ state }: SingleCounterContext) => state.name,
72
- };
73
-
74
- const finishCounter = ({ state, self }: SingleCounterContext) => {
75
- expectType<string>(state.name);
76
- expectType<number>(self.getCount());
77
- };
78
-
79
- const makeCounter = defineKind('counter', initCounter, counterBehavior, {
80
- finish: finishCounter,
81
- });
82
-
83
- // Multi-faceted example from virtual-objects.md
84
- type MultiCounterContext = {
85
- state: ReturnType<typeof initFacetedCounter>;
86
- facets: KindFacets<typeof facetedCounterBehavior>;
87
- };
88
- const initFacetedCounter = () => ({ counter: 0 });
89
- const getCount = ({ state }: MultiCounterContext) => state.counter;
90
- const facetedCounterBehavior = {
91
- incr: {
92
- step: ({ state }: MultiCounterContext) => {
93
- state.counter += 1;
94
- },
95
- getCount,
96
- },
97
- decr: {
98
- step: (context: MultiCounterContext) => {
99
- // Destructure within method because doing so in params creates a circular reference
100
- const { state, facets } = context;
101
- const { other } = facets;
102
- other.echo('hi');
103
- state.counter -= 1;
104
- },
105
- getCount,
106
- },
107
- other: {
108
- emptyFn: () => null,
109
- echo: (_context: MultiCounterContext, toEcho: string) => toEcho,
110
- },
111
- };
112
-
113
- const makeFacetedCounter = defineKindMulti(
114
- 'counter',
115
- initFacetedCounter,
116
- facetedCounterBehavior,
117
- );
118
-
119
- const fc = makeFacetedCounter();
120
- expectType<void>(fc.incr.step());
121
- expectType<void>(fc.decr.step());
122
- expectType<number>(fc.decr.getCount());
123
- // @ts-expect-error missing argument
124
- fc.decr.echo();
125
- expectType<string>(fc.other.echo('foo'));
126
- // @ts-expect-error missing method
127
- fc.incr.echo('foo');
128
- expectType<null>(fc.other.emptyFn());
129
-
130
- // durable kind
131
- const fooHandle = makeKindHandle('foo');
132
- expectType<DurableKindHandle>(fooHandle);
133
- const fooInit = (name: string) => ({ name });
134
- const fooBehavior = {
135
- sayHi: ({ state }: { state: { name: string } }) => `Howdy, ${state.name}`,
136
- };
137
- const makeFoo = defineDurableKind(fooHandle, fooInit, fooBehavior);
138
- const foo = makeFoo('Doody');
139
- expectType<string>(foo.sayHi());
140
- // @ts-expect-error missing method
141
- foo.sayBye();
142
-
143
- // partialAssign
144
- const state = { name: 'ted', color: 'red' };
145
- partialAssign(state, { name: 'ed' });
146
- // @ts-expect-error
147
- partialAssign(state, { key: 'ted' });
148
- // @ts-expect-error
149
- partialAssign(state, { name: 3 });
150
-
151
- // test FunctionsPlusContext
152
- type SomeFacet = {
153
- gt(b: number): boolean;
154
- };
155
- type SomeContext = { state: { a: number } };
156
- const someBehavior: FunctionsPlusContext<SomeContext, SomeFacet> = {
157
- gt(context: SomeContext, b: number) {
158
- return b > context.state.a;
159
- },
160
- };
161
- const someFacet: KindFacet<typeof someBehavior> = anyVal;
162
- // @ts-expect-error
163
- someFacet.gt();
164
- expectType<boolean>(someFacet.gt(1));
165
-
166
- const vom: VirtualObjectManager = anyVal;
167
- // @ts-expect-error
168
- vom.missingMethod;
169
- // @ts-expect-error Expected 0-4 arguments but got 5
170
- vom.defineDurableKind(anyVal, anyVal, anyVal, anyVal, 'extra');
171
-
172
- const p: Promise<bigint> = anyVal;
173
- watchPromise(
174
- p,
175
- {
176
- onFulfilled(value, extra1, extra2) {
177
- expectType<bigint>(value);
178
- expectType<string>(extra1);
179
- // @ts-expect-error str
180
- expectType<number>(extra2);
181
- },
182
- onRejected(reason, extra1) {
183
- expectType<unknown>(reason);
184
- expectType<string>(extra1);
185
- },
186
- },
187
- 'extraString',
188
- 'alsoString',
189
- );