@agoric/internal 0.4.0-u20.0 → 0.4.0-u21.0.1

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.
package/package.json CHANGED
@@ -1,29 +1,30 @@
1
1
  {
2
2
  "name": "@agoric/internal",
3
- "version": "0.4.0-u20.0",
3
+ "version": "0.4.0-u21.0.1",
4
4
  "description": "Externally unsupported utilities internal to agoric-sdk",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "engines": {
8
- "node": "^18.12 || ^20.9"
8
+ "node": "^20.9 || ^22.11"
9
9
  },
10
10
  "scripts": {
11
11
  "build": "exit 0",
12
- "prepack": "tsc --build tsconfig.build.json",
12
+ "prepack": "yarn run -T tsc --build tsconfig.build.json",
13
13
  "postpack": "git clean -f '*.d.ts*' '*.tsbuildinfo'",
14
14
  "test": "ava",
15
15
  "test:nyc": "exit 0",
16
16
  "test:xs": "exit 0",
17
17
  "lint-fix": "yarn lint:eslint --fix",
18
- "lint": "run-s --continue-on-error lint:*",
19
- "lint:eslint": "eslint .",
20
- "lint:types": "tsc"
18
+ "lint": "yarn run -T run-s --continue-on-error 'lint:*'",
19
+ "lint:eslint": "yarn run -T eslint .",
20
+ "lint:types": "yarn run -T tsc"
21
21
  },
22
22
  "dependencies": {
23
- "@agoric/base-zone": "^0.1.1-u20.0",
23
+ "@agoric/base-zone": "0.1.1-u21.0.1",
24
24
  "@endo/common": "^1.2.10",
25
25
  "@endo/compartment-mapper": "^1.6.0",
26
26
  "@endo/errors": "^1.2.10",
27
+ "@endo/eventual-send": "^1.3.1",
27
28
  "@endo/far": "^1.1.11",
28
29
  "@endo/init": "^1.1.9",
29
30
  "@endo/marshal": "^1.6.4",
@@ -36,7 +37,7 @@
36
37
  "jessie.js": "^0.3.4"
37
38
  },
38
39
  "devDependencies": {
39
- "@agoric/cosmic-proto": "^0.5.0-u20.0",
40
+ "@agoric/cosmic-proto": "0.5.0-u21.0.1",
40
41
  "@endo/exo": "^1.5.9",
41
42
  "@endo/init": "^1.1.9",
42
43
  "@fast-check/ava": "^2.0.1",
@@ -61,7 +62,7 @@
61
62
  "access": "public"
62
63
  },
63
64
  "typeCoverage": {
64
- "atLeast": 92.65
65
+ "atLeast": 92.98
65
66
  },
66
- "gitHead": "8e4207fa19dabf76c1f91f8779b5b5b93570ecea"
67
+ "gitHead": "16519b2de1eb2afda2b4ec866f55eadd4bb18223"
67
68
  }
package/src/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from "./errors.js";
4
4
  export * from "./js-utils.js";
5
5
  export * from "./method-tools.js";
6
6
  export * from "./metrics.js";
7
+ export * from "./natural-sort.js";
7
8
  export * from "./ses-utils.js";
8
9
  export * from "./tmpDir.js";
9
10
  export * from "./typeCheck.js";
package/src/index.js CHANGED
@@ -9,6 +9,7 @@ export * from './js-utils.js';
9
9
  export { pureDataMarshaller } from './marshal.js';
10
10
  export * from './method-tools.js';
11
11
  export * from './metrics.js';
12
+ export * from './natural-sort.js';
12
13
  export * from './ses-utils.js';
13
14
  export * from './tmpDir.js';
14
15
  export * from './typeCheck.js';
@@ -31,8 +31,31 @@ export function makeChainStorageRoot(handleStorageMessage: (message: StorageMess
31
31
  * @returns {Promise<StorageNode>}
32
32
  */
33
33
  export function makeStorageNodeChild(storageNodeRef: ERef<StorageNode | null>, childName: string): Promise<StorageNode>;
34
+ /**
35
+ * @import {ERef} from '@endo/far';
36
+ * @import {PassableCap} from '@endo/marshal';
37
+ * @import {TypedPattern} from './types.js';
38
+ */
39
+ /** @typedef {ReturnType<typeof import('@endo/marshal').makeMarshal>} Marshaller */
40
+ /** @typedef {Pick<Marshaller, 'fromCapData'>} Unserializer */
41
+ /**
42
+ * Defined by vstorageStoreKey in vstorage.go
43
+ *
44
+ * @typedef VStorageKey
45
+ * @property {string} storeName
46
+ * @property {string} storeSubkey
47
+ * @property {string} dataPrefixBytes
48
+ * @property {string} [noDataValue]
49
+ */
50
+ /**
51
+ * @template [T=unknown]
52
+ * @typedef StreamCell
53
+ * @property {string} blockHeight decimal representation of a natural number
54
+ * @property {T[]} values
55
+ */
56
+ /** @type {TypedPattern<StreamCell>} */
57
+ export const StreamCellShape: TypedPattern<StreamCell>;
34
58
  export function isStreamCell(cell: any): cell is StreamCell;
35
- export function assertCapData(data: unknown): asserts data is import("@endo/marshal").CapData<string>;
36
59
  /** @type {(name: string) => void} */
37
60
  export const assertPathSegment: (name: string) => void;
38
61
  export function prepareChainStorageNode(zone: import("@agoric/base-zone").Zone): (messenger: import("./types.js").Callback<(message: StorageMessage) => any>, path: string, args_2?: {
@@ -143,5 +166,6 @@ export type StorageMessage = {
143
166
  args: StorageUpdateEntriesMessageArgs;
144
167
  };
145
168
  import type { ERef } from '@endo/far';
169
+ import type { TypedPattern } from './types.js';
146
170
  import type { PassableCap } from '@endo/marshal';
147
171
  //# sourceMappingURL=lib-chainStorage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lib-chainStorage.d.ts","sourceRoot":"","sources":["lib-chainStorage.js"],"names":[],"mappings":"AAyPA;;;;;;;;;;;;GAYG;AACH,2DATW,CAAC,OAAO,EAAE,cAAc,KAAK,GAAG,YAGhC,MAAM,gBAEd;IAA8B,QAAQ;CAGxC;;mBAnEqB,OAAO,CAAC,WAAW,CAAC;wBAWzB,MAAM,qBACO;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GACtC,WAAW;oBAYA,MAAM,GAAK,OAAO,CAAC,IAAI,CAAC;GAqDhD;AAcD;;;;;;;;GAQG;AACH,qDAJW,KAAK,WAAW,OAAC,CAAC,aAClB,MAAM,GACJ,OAAO,CAAC,WAAW,CAAC,CAMhC;AApOM,mCAHI,GAAG,GACD,IAAI,IAAI,UAAU,CAOa;AASrC,oCAHI,OAAO,GACL,QAAQ,IAAI,IAAI,OAAO,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,CAQnE;AAmBD,qCAAqC;AACrC,gCADW,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CA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IAAI,CAAC,CAQjD;yBApSa,UAAU,CAAC,cAAc,eAAe,EAAE,WAAW,CAAC;2BACtD,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC;;;;;eAM/B,MAAM;iBACN,MAAM;qBACN,MAAM;;;uBAKN,CAAC;;;;iBAED,MAAM;YACN,CAAC,EAAE;;;;;;;;;;;;;;;;cAoBH,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;;;;;aAC/B,MAAM,MAAM;;;;iBAEZ,MAAM,OAAO,CAAC,WAAW,CAAC;mBAC1B,CACT,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAC7B,WAAW;;;;;;;aA8BL,MAAM,OAAO,CAAC,MAAM,CAAC;;;;iBAErB,WAAW,CAAC,aAAa,CAAC;;;;;qBAC1B,MAAM,YAAY;;;;;4CAqBnB,KAAK,GACX,aAAa,GACb,KAAK,GACL,UAAU,GACV,SAAS,GACT,QAAQ,GACR,MAAM;;;;gDAGA,KAAK,GAAG,kBAAkB,GAAG,QAAQ;;;;mCAGrC,6BAA6B,GACnC,iCAAiC;;;;0CAG3B,CAAC,IAAI,EAAE,MAAM,CAAC;;;;2BAEd,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;;;;8CAErC,YAAY,EAAE;;;;6BAEd;IACJ,MAAM,EAAE,6BAA6B,CAAC;IACtC,IAAI,EAAE,2BAA2B,CAAC;CACnC,GACD;IACE,MAAM,EAAE,iCAAiC,CAAC;IAC1C,IAAI,EAAE,+BAA+B,CAAC;CACvC;0BApIe,WAAW;kCAEH,YAAY;iCADb,eAAe"}
@@ -9,6 +9,7 @@ import * as cb from './callback.js';
9
9
  /**
10
10
  * @import {ERef} from '@endo/far';
11
11
  * @import {PassableCap} from '@endo/marshal';
12
+ * @import {TypedPattern} from './types.js';
12
13
  */
13
14
 
14
15
  /** @typedef {ReturnType<typeof import('@endo/marshal').makeMarshal>} Marshaller */
@@ -31,6 +32,12 @@ import * as cb from './callback.js';
31
32
  * @property {T[]} values
32
33
  */
33
34
 
35
+ /** @type {TypedPattern<StreamCell>} */
36
+ export const StreamCellShape = harden({
37
+ blockHeight: M.string(),
38
+ values: M.array(),
39
+ });
40
+
34
41
  /**
35
42
  * This represents a node in an IAVL tree.
36
43
  *
@@ -77,21 +84,6 @@ export const isStreamCell = cell =>
77
84
  /^0$|^[1-9][0-9]*$/.test(cell.blockHeight);
78
85
  harden(isStreamCell);
79
86
 
80
- // TODO: Consolidate with `insistCapData` functions from swingset-liveslots,
81
- // swingset-xsnap-supervisor, etc.
82
- /**
83
- * @param {unknown} data
84
- * @returns {asserts data is import('@endo/marshal').CapData<string>}
85
- */
86
- export const assertCapData = data => {
87
- assert.typeof(data, 'object');
88
- assert(data);
89
- assert.typeof(data.body, 'string');
90
- assert(Array.isArray(data.slots));
91
- // XXX check that the .slots array elements are actually strings
92
- };
93
- harden(assertCapData);
94
-
95
87
  /**
96
88
  * @typedef {object} StoredFacet
97
89
  * @property {() => Promise<string>} getPath the chain storage path at which the
package/src/marshal.d.ts CHANGED
@@ -4,6 +4,11 @@ export function makeBoardRemote({ boardId, iface }: {
4
4
  }): BoardRemote;
5
5
  export function slotToBoardRemote(boardId: string, iface: string): BoardRemote;
6
6
  export function boardSlottingMarshaller(slotToVal?: (slot: string, iface: string) => any): Omit<import("@endo/marshal").Marshal<string | null>, "serialize" | "unserialize">;
7
+ /**
8
+ * @type {TypedPattern<CapData<any>>}
9
+ */
10
+ export const CapDataShape: TypedPattern<CapData<any>>;
11
+ export function assertCapData(data: unknown): asserts data is CapData<unknown>;
7
12
  export function unmarshalFromVstorage(data: Map<string, string>, key: string, fromCapData: ReturnType<typeof import("@endo/marshal").makeMarshal>["fromCapData"], index: number): any;
8
13
  export function makeHistoryReviver(entries: [string, string][], slotToVal?: (slot: string, iface?: string) => any): {
9
14
  getItem: (key: string) => any;
@@ -11,10 +16,10 @@ export function makeHistoryReviver(entries: [string, string][], slotToVal?: (slo
11
16
  has: (k: string) => boolean;
12
17
  };
13
18
  export const pureDataMarshaller: {
14
- toCapData: import("@endo/marshal").ToCapData<import("@endo/marshal").CapData<unknown>>;
15
- fromCapData: import("@endo/marshal").FromCapData<import("@endo/marshal").CapData<unknown>>;
16
- serialize: import("@endo/marshal").ToCapData<import("@endo/marshal").CapData<unknown>>;
17
- unserialize: import("@endo/marshal").FromCapData<import("@endo/marshal").CapData<unknown>>;
19
+ toCapData: import("@endo/marshal").ToCapData<CapData<unknown>>;
20
+ fromCapData: import("@endo/marshal").FromCapData<CapData<unknown>>;
21
+ serialize: import("@endo/marshal").ToCapData<CapData<unknown>>;
22
+ unserialize: import("@endo/marshal").FromCapData<CapData<unknown>>;
18
23
  };
19
24
  /**
20
25
  * Should be a union with Remotable, but that's `any`, making this type
@@ -23,4 +28,6 @@ export const pureDataMarshaller: {
23
28
  export type BoardRemote = {
24
29
  getBoardId: () => string | null;
25
30
  };
31
+ import type { CapData } from '@endo/marshal';
32
+ import type { TypedPattern } from './types.js';
26
33
  //# sourceMappingURL=marshal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"marshal.d.ts","sourceRoot":"","sources":["marshal.js"],"names":[],"mappings":"AAiBO,oDAHI;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,WAAW,CAKvB;AAMM,2CAHI,MAAM,SACN,MAAM,eAGoB;AAqB9B,oDANI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,GAClC,IAAI,CAChB,OAAW,eAAe,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAClD,WAAe,GAAG,aAAa,CAC5B,CAMH;AA6BM,4CATI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OACnB,MAAM,eACN,UAAU,CACpB,cAAkB,eAAe,EA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,MAAM,GAAG,IAAI,CAAA;CAAE;6BARtB,eAAe;kCACV,YAAY"}
package/src/marshal.js CHANGED
@@ -2,8 +2,14 @@
2
2
  import { Fail } from '@endo/errors';
3
3
  import { Far } from '@endo/far';
4
4
  import { makeMarshal } from '@endo/marshal';
5
+ import { M } from '@endo/patterns';
5
6
  import { isStreamCell } from './lib-chainStorage.js';
6
7
 
8
+ /**
9
+ * @import {CapData} from '@endo/marshal';
10
+ * @import {TypedPattern} from './types.js';
11
+ */
12
+
7
13
  /**
8
14
  * Should be a union with Remotable, but that's `any`, making this type
9
15
  * meaningless
@@ -52,18 +58,24 @@ export const boardSlottingMarshaller = (slotToVal = undefined) => {
52
58
  });
53
59
  };
54
60
 
55
- // TODO: Consolidate with `insistCapData` functions from swingset-liveslots,
56
- // swingset-xsnap-supervisor, etc.
61
+ // TODO move CapDataShape to Endo
57
62
  /**
63
+ * @type {TypedPattern<CapData<any>>}
64
+ */
65
+ export const CapDataShape = { body: M.string(), slots: M.array() };
66
+ harden(CapDataShape);
67
+
68
+ /**
69
+ * Assert that this is CapData
70
+ *
58
71
  * @param {unknown} data
59
- * @returns {asserts data is import('@endo/marshal').CapData<string>}
72
+ * @returns {asserts data is CapData<unknown>}
60
73
  */
61
- const assertCapData = data => {
74
+ export const assertCapData = data => {
62
75
  assert.typeof(data, 'object');
63
76
  assert(data);
64
- assert.typeof(data.body, 'string');
65
- assert(Array.isArray(data.slots));
66
- // XXX check that the .slots array elements are actually strings
77
+ typeof data.body === 'string' || Fail`data has non-string .body ${data.body}`;
78
+ Array.isArray(data.slots) || Fail`data has non-Array slots ${data.slots}`;
67
79
  };
68
80
  harden(assertCapData);
69
81
 
@@ -1 +1 @@
1
- {"version":3,"file":"method-tools.d.ts","sourceRoot":"","sources":["method-tools.js"],"names":[],"mappings":"AA0CO,+BAJoB,CAAC,SAAd,WAAY,OACf,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GACZ,CAAC,EAAE,CAsBf;AAUM,qCAJoB,CAAC,SAAd,WAAY,OACf,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GACZ,MAAM,EAAE,CAKlB;AA+BI,+BAJiC,CAAC,SAA3B,MAAM,CAAC,WAAW,EAAE,GAAG,CAAE,OAC5B,CAAC,GACC,CAAC,CAiBX"}
1
+ {"version":3,"file":"method-tools.d.ts","sourceRoot":"","sources":["method-tools.js"],"names":[],"mappings":"AAmBO,+BAJoB,CAAC,SAAd,WAAY,OACf,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GACZ,CAAC,EAAE,CAG8B;AAUvC,qCAJoB,CAAC,SAAd,WAAY,OACf,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GACZ,MAAM,EAAE,CAKlB;AA+BI,+BAJiC,CAAC,SAA3B,MAAM,CAAC,WAAW,EAAE,GAAG,CAAE,OAC5B,CAAC,GACC,CAAC,CAiBX"}
@@ -1,66 +1,24 @@
1
1
  // @ts-check
2
- import { isObject } from '@endo/marshal';
2
+ import { getMethodNames as realGetMethodNames } from '@endo/eventual-send/utils.js';
3
3
 
4
4
  /**
5
5
  * @file method-tools use dynamic property lookup, which is not
6
6
  * Jessie-compatible
7
7
  */
8
8
 
9
- const { getPrototypeOf, create, fromEntries, getOwnPropertyDescriptors } =
10
- Object;
11
- const { ownKeys, apply } = Reflect;
12
-
13
- /**
14
- * Prioritize symbols as earlier than strings.
15
- *
16
- * @param {string | symbol} a
17
- * @param {string | symbol} b
18
- * @returns {-1 | 0 | 1}
19
- */
20
- const compareStringified = (a, b) => {
21
- if (typeof a === typeof b) {
22
- const left = String(a);
23
- const right = String(b);
24
- // eslint-disable-next-line no-nested-ternary
25
- return left < right ? -1 : left > right ? 1 : 0;
26
- }
27
- if (typeof a === 'symbol') {
28
- assert(typeof b === 'string');
29
- return -1;
30
- }
31
- assert(typeof a === 'string');
32
- assert(typeof b === 'symbol');
33
- return 1;
34
- };
9
+ const { create, fromEntries } = Object;
10
+ const { apply } = Reflect;
35
11
 
36
12
  /**
37
13
  * TODO Consolidate with the `getMethodNames` in `@endo/eventual-send`
38
14
  *
15
+ * @deprecated Use `getMethodNames` from `@endo/eventual-send/utils.js` instead.
39
16
  * @template {PropertyKey} K
40
17
  * @param {Record<K, any>} val
41
18
  * @returns {K[]}
42
19
  */
43
- export const getMethodNames = val => {
44
- let layer = val;
45
- const names = new Set(); // Set to deduplicate
46
- while (layer !== null && layer !== Object.prototype) {
47
- // be tolerant of non-objects
48
- const descs = getOwnPropertyDescriptors(layer);
49
- const ownNames = /** @type {K[]} */ (ownKeys(descs));
50
- for (const name of ownNames) {
51
- // In case a method is overridden by a non-method,
52
- // test `val[name]` rather than `layer[name]`
53
- if (typeof val[name] === 'function') {
54
- names.add(name);
55
- }
56
- }
57
- if (!isObject(val)) {
58
- break;
59
- }
60
- layer = getPrototypeOf(layer);
61
- }
62
- return harden([...names].sort(compareStringified));
63
- };
20
+ export const getMethodNames = val =>
21
+ /** @type {K[]} */ (realGetMethodNames(val));
64
22
  harden(getMethodNames);
65
23
 
66
24
  /**
@@ -72,7 +30,7 @@ harden(getMethodNames);
72
30
  */
73
31
  export const getStringMethodNames = val =>
74
32
  /** @type {string[]} */ (
75
- getMethodNames(val).filter(name => typeof name === 'string')
33
+ realGetMethodNames(val).filter(name => typeof name === 'string')
76
34
  );
77
35
 
78
36
  /**
@@ -109,7 +67,7 @@ export const bindAllMethods = obj =>
109
67
  create(
110
68
  obj,
111
69
  fromEntries(
112
- getMethodNames(obj).map(name => [
70
+ realGetMethodNames(obj).map(name => [
113
71
  name,
114
72
  {
115
73
  value: (/** @type {unknown[]} */ ...args) =>
@@ -1 +1 @@
1
- {"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AAyBO,yCAHI,MAAM,UACN,MAAM,6GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;;eAMU,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO;mBAEzB,CAAC,GAAG,EAAE,GAAG,KAAK,MA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