@agoric/kmarshal 0.1.1-upgrade-16-dev-0df76a7.0 → 0.1.1-upgrade-17-dev-3b97a9f.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/CHANGELOG.md CHANGED
@@ -1,11 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ### 0.1.1-u16.0 (2024-07-02)
7
-
8
-
9
- ### Features
10
-
11
- * **SwingSet:** Add a tool for classifying unsettled promises ([feb1f93](https://github.com/Agoric/agoric-sdk/commit/feb1f93c81e68c680e07bdac8c64917ad69af602)), closes [#8336](https://github.com/Agoric/agoric-sdk/issues/8336)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/kmarshal",
3
- "version": "0.1.1-upgrade-16-dev-0df76a7.0+0df76a7",
3
+ "version": "0.1.1-upgrade-17-dev-3b97a9f.0+3b97a9f",
4
4
  "description": "Token-only marshaller for kernel and tests",
5
5
  "type": "module",
6
6
  "main": "./src/kmarshal.js",
@@ -21,9 +21,9 @@
21
21
  "lint:eslint": "eslint ."
22
22
  },
23
23
  "dependencies": {
24
- "@agoric/assert": "0.6.1-upgrade-16-dev-0df76a7.0+0df76a7",
25
- "@endo/far": "^1.1.2",
26
- "@endo/marshal": "^1.5.0"
24
+ "@endo/errors": "^1.2.5",
25
+ "@endo/far": "^1.1.5",
26
+ "@endo/marshal": "^1.5.3"
27
27
  },
28
28
  "devDependencies": {
29
29
  "ava": "^5.3.0"
@@ -40,5 +40,5 @@
40
40
  ],
41
41
  "timeout": "2m"
42
42
  },
43
- "gitHead": "0df76a71058eda04cdc75a54fb4312d286f323a3"
43
+ "gitHead": "3b97a9f0bc7d5dcd24d20dd81ca2af5d59d6e43d"
44
44
  }
package/src/kmarshal.js CHANGED
@@ -1,9 +1,8 @@
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
4
 
5
5
  /**
6
- * @import { ERef } from '@endo/far';
7
6
  * @import {ConvertSlotToVal} from '@endo/marshal';
8
7
  */
9
8
 
@@ -19,7 +18,7 @@ import { assert, Fail } from '@agoric/assert';
19
18
 
20
19
  const { toStringTag } = Symbol;
21
20
 
22
- const makeStringStandinPromise = kref => {
21
+ const makeStandinPromise = kref => {
23
22
  const p = Promise.resolve(`${kref} stand in`);
24
23
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
25
24
  Object.defineProperty(p, toStringTag, {
@@ -28,8 +27,9 @@ const makeStringStandinPromise = kref => {
28
27
  });
29
28
  return harden(p);
30
29
  };
30
+ harden(makeStandinPromise);
31
31
 
32
- const getStringStandinPromiseTag = p => {
32
+ const getStandinPromiseTag = p => {
33
33
  const desc = Object.getOwnPropertyDescriptor(p, toStringTag);
34
34
  assert(desc !== undefined, 'promise lacks own @@toStringTag property');
35
35
  const kref = desc.value;
@@ -37,69 +37,6 @@ const getStringStandinPromiseTag = p => {
37
37
  return kref;
38
38
  };
39
39
 
40
- const makeAccessorStandinPromise = kref => {
41
- // TODO This Bizarro world hack is only for the version of Endo that
42
- // agoric-sdk currently depends on, and is already inconsistent with
43
- // the "current" endo. Once agoric-sdk depends only on the next endo,
44
- // we should delete this code, and rename `makeStringStandinPromise`
45
- // above to `makeStandinPromise`.
46
- //
47
- // Bizarro World hack for attaching a string property to a Promise, courtesy
48
- // of MarkM. Even though the @@toStringTag property nominally *is* a
49
- // string, some unfortunate stuff in our hardened JS safety checks blows up
50
- // if it actually is. Eventually that will be fixed and we'll be able to
51
- // use the @@toStringTag property directly, but for now we need to use this
52
- // weird construct employing a sneaky getter function. Note that this is
53
- // only necessary in the first place because smallcaps encodes promise
54
- // references differently from remotable object references, and the current
55
- // version of the smallcaps decoder annoyingly insists that if the encoded
56
- // body string says a slot is a promise, then convertSlotToVal had better by
57
- // damn return an actual Promise, even if, as in the intended use case here,
58
- // we neither want nor need a promise nor are capable of making any use of
59
- // the fact that it is one.
60
- const p = Promise.resolve(`${kref} stand in`);
61
- // Bizarro World makes eslint hallucinate
62
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
63
- Object.defineProperty(p, toStringTag, {
64
- get: reveal => (reveal ? kref : NaN),
65
- enumerable: false,
66
- });
67
- return harden(p);
68
- };
69
-
70
- const getAccessorStandinPromiseTag = p => {
71
- // Other half of Bizarro World hack for handling promises. Note the
72
- // peculiar way the @@toStringTag getter is used.
73
- const desc = Object.getOwnPropertyDescriptor(p, toStringTag);
74
- assert(desc !== undefined, 'promise lacks toStringTag getter');
75
-
76
- const getter = desc.get;
77
- assert.typeof(getter, 'function', 'toStringTag getter is not a function');
78
- // @ts-expect-error violates the norm that getters have zero parameters
79
- const kref = getter(true);
80
- assert.typeof(kref, 'string');
81
- return kref;
82
- };
83
-
84
- const [makeStandinPromise, getStandinPromiseTag] = (() => {
85
- // Use whatever works
86
- try {
87
- const p = makeStringStandinPromise('string mascot');
88
- assert(passStyleOf(p) === 'promise');
89
- return [makeStringStandinPromise, getStringStandinPromiseTag];
90
- } catch (_1) {
91
- try {
92
- const p = makeAccessorStandinPromise('accessor mascot');
93
- assert(passStyleOf(p) === 'promise');
94
- return [makeAccessorStandinPromise, getAccessorStandinPromiseTag];
95
- } catch (_2) {
96
- throw Error('One of the promise tagging schemes should have worked');
97
- }
98
- }
99
- })();
100
- export { makeStandinPromise };
101
- harden(makeStandinPromise);
102
-
103
40
  /**
104
41
  * @type {ConvertSlotToVal<string>}
105
42
  */