@agoric/kmarshal 0.1.1-orchestration-dev-096c4e8.0 → 0.1.1-other-dev-3eb1a1d.0

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/kmarshal",
3
- "version": "0.1.1-orchestration-dev-096c4e8.0+096c4e8",
3
+ "version": "0.1.1-other-dev-3eb1a1d.0+3eb1a1d",
4
4
  "description": "Token-only marshaller for kernel and tests",
5
5
  "type": "module",
6
6
  "main": "./src/kmarshal.js",
@@ -13,7 +13,7 @@
13
13
  "scripts": {
14
14
  "build": "exit 0",
15
15
  "test": "ava",
16
- "test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
16
+ "test:c8": "c8 --all $C8_OPTIONS ava",
17
17
  "test:xs": "exit 0",
18
18
  "lint-fix": "yarn lint:eslint --fix",
19
19
  "lint": "run-s --continue-on-error lint:*",
@@ -21,9 +21,9 @@
21
21
  "lint:eslint": "eslint ."
22
22
  },
23
23
  "dependencies": {
24
- "@agoric/assert": "0.6.1-orchestration-dev-096c4e8.0+096c4e8",
25
- "@endo/far": "^1.0.4",
26
- "@endo/marshal": "^1.3.0"
24
+ "@endo/errors": "^1.2.8",
25
+ "@endo/far": "^1.1.9",
26
+ "@endo/marshal": "^1.6.2"
27
27
  },
28
28
  "devDependencies": {
29
29
  "ava": "^5.3.0"
@@ -33,12 +33,12 @@
33
33
  },
34
34
  "ava": {
35
35
  "files": [
36
- "test/**/test-*.js"
36
+ "test/**/*.test.*"
37
37
  ],
38
38
  "require": [
39
39
  "@endo/init/debug.js"
40
40
  ],
41
41
  "timeout": "2m"
42
42
  },
43
- "gitHead": "096c4e8fce80e9a509b0e1a30fda11736c4570e1"
43
+ "gitHead": "3eb1a1d2d75b2b4a94807cd3bf759bc9fc531f05"
44
44
  }
package/src/kmarshal.js CHANGED
@@ -1,6 +1,10 @@
1
+ import { assert, Fail } from '@endo/errors';
1
2
  import { Far, passStyleOf } from '@endo/far';
2
3
  import { makeMarshal } from '@endo/marshal';
3
- import { assert, Fail } from '@agoric/assert';
4
+
5
+ /**
6
+ * @import {ConvertSlotToVal} from '@endo/marshal';
7
+ */
4
8
 
5
9
  // Simple wrapper for serializing and unserializing marshalled values inside the
6
10
  // kernel, where we don't actually want to use clists nor actually allocate real
@@ -14,7 +18,7 @@ import { assert, Fail } from '@agoric/assert';
14
18
 
15
19
  const { toStringTag } = Symbol;
16
20
 
17
- const makeStringStandinPromise = kref => {
21
+ const makeStandinPromise = kref => {
18
22
  const p = Promise.resolve(`${kref} stand in`);
19
23
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
20
24
  Object.defineProperty(p, toStringTag, {
@@ -23,8 +27,9 @@ const makeStringStandinPromise = kref => {
23
27
  });
24
28
  return harden(p);
25
29
  };
30
+ harden(makeStandinPromise);
26
31
 
27
- const getStringStandinPromiseTag = p => {
32
+ const getStandinPromiseTag = p => {
28
33
  const desc = Object.getOwnPropertyDescriptor(p, toStringTag);
29
34
  assert(desc !== undefined, 'promise lacks own @@toStringTag property');
30
35
  const kref = desc.value;
@@ -32,73 +37,8 @@ const getStringStandinPromiseTag = p => {
32
37
  return kref;
33
38
  };
34
39
 
35
- const makeAccessorStandinPromise = kref => {
36
- // TODO This Bizarro world hack is only for the version of Endo that
37
- // agoric-sdk currently depends on, and is already inconsistent with
38
- // the "current" endo. Once agoric-sdk depends only on the next endo,
39
- // we should delete this code, and rename `makeStringStandinPromise`
40
- // above to `makeStandinPromise`.
41
- //
42
- // Bizarro World hack for attaching a string property to a Promise, courtesy
43
- // of MarkM. Even though the @@toStringTag property nominally *is* a
44
- // string, some unfortunate stuff in our hardened JS safety checks blows up
45
- // if it actually is. Eventually that will be fixed and we'll be able to
46
- // use the @@toStringTag property directly, but for now we need to use this
47
- // weird construct employing a sneaky getter function. Note that this is
48
- // only necessary in the first place because smallcaps encodes promise
49
- // references differently from remotable object references, and the current
50
- // version of the smallcaps decoder annoyingly insists that if the encoded
51
- // body string says a slot is a promise, then convertSlotToVal had better by
52
- // damn return an actual Promise, even if, as in the intended use case here,
53
- // we neither want nor need a promise nor are capable of making any use of
54
- // the fact that it is one.
55
- const p = Promise.resolve(`${kref} stand in`);
56
- // Bizarro World makes eslint hallucinate
57
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
58
- Object.defineProperty(p, toStringTag, {
59
- get: reveal => (reveal ? kref : NaN),
60
- enumerable: false,
61
- });
62
- return harden(p);
63
- };
64
-
65
- const getAccessorStandinPromiseTag = p => {
66
- // Other half of Bizarro World hack for handling promises. Note the
67
- // peculiar way the @@toStringTag getter is used.
68
- const desc = Object.getOwnPropertyDescriptor(p, toStringTag);
69
- assert(desc !== undefined, 'promise lacks toStringTag getter');
70
-
71
- const getter = desc.get;
72
- assert.typeof(getter, 'function', 'toStringTag getter is not a function');
73
- // @ts-expect-error violates the norm that getters have zero parameters
74
- const kref = getter(true);
75
- assert.typeof(kref, 'string');
76
- return kref;
77
- };
78
-
79
- const [makeStandinPromise, getStandinPromiseTag] = (() => {
80
- // Use whatever works
81
- try {
82
- const p = makeStringStandinPromise('string mascot');
83
- assert(passStyleOf(p) === 'promise');
84
- return [makeStringStandinPromise, getStringStandinPromiseTag];
85
- } catch (_1) {
86
- try {
87
- const p = makeAccessorStandinPromise('accessor mascot');
88
- assert(passStyleOf(p) === 'promise');
89
- return [makeAccessorStandinPromise, getAccessorStandinPromiseTag];
90
- } catch (_2) {
91
- throw Error('One of the promise tagging schemes should have worked');
92
- }
93
- }
94
- })();
95
- export { makeStandinPromise };
96
- harden(makeStandinPromise);
97
-
98
40
  /**
99
- * @param {string} kref
100
- * @param {string} [iface]
101
- * @returns {import('@endo/eventual-send').ERef<KCap>}
41
+ * @type {ConvertSlotToVal<string>}
102
42
  */
103
43
  export const kslot = (kref, iface = 'undefined') => {
104
44
  assert.typeof(kref, 'string');
package/tsconfig.json CHANGED
@@ -1,10 +1,7 @@
1
1
  // This file can contain .js-specific Typescript compiler config.
2
2
  {
3
3
  "extends": "../../tsconfig.json",
4
- "compilerOptions": {
5
- "allowSyntheticDefaultImports": true,
6
- "maxNodeModuleJsDepth": 2,
7
- },
4
+ "compilerOptions": {},
8
5
  "include": [
9
6
  "src/**/*.js",
10
7
  "test/**/*.js"
File without changes