@agoric/internal 0.3.3-dev-e87ca23.0.e87ca23 → 0.3.3-dev-35107d8.0.35107d8

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/internal",
3
- "version": "0.3.3-dev-e87ca23.0.e87ca23",
3
+ "version": "0.3.3-dev-35107d8.0.35107d8",
4
4
  "description": "Externally unsupported utilities internal to agoric-sdk",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -20,7 +20,7 @@
20
20
  "lint:types": "yarn run -T tsc"
21
21
  },
22
22
  "dependencies": {
23
- "@agoric/base-zone": "0.1.1-dev-e87ca23.0.e87ca23",
23
+ "@agoric/base-zone": "0.1.1-dev-35107d8.0.35107d8",
24
24
  "@endo/cache-map": "^1.1.0",
25
25
  "@endo/common": "^1.2.13",
26
26
  "@endo/compartment-mapper": "^1.6.3",
@@ -39,7 +39,7 @@
39
39
  "jessie.js": "^0.3.4"
40
40
  },
41
41
  "devDependencies": {
42
- "@agoric/cosmic-proto": "0.4.1-dev-e87ca23.0.e87ca23",
42
+ "@agoric/cosmic-proto": "0.4.1-dev-35107d8.0.35107d8",
43
43
  "@endo/exo": "^1.5.12",
44
44
  "@endo/init": "^1.1.12",
45
45
  "@endo/ses-ava": "^1.3.2",
@@ -67,5 +67,5 @@
67
67
  "typeCoverage": {
68
68
  "atLeast": 92.89
69
69
  },
70
- "gitHead": "e87ca231a5d69ff2c5de914250079e9c0dc80bac"
70
+ "gitHead": "35107d8a0c85cc363e80568e5226f663e29cf6ab"
71
71
  }
@@ -11,14 +11,28 @@
11
11
  * - ../../cosmic-swingset/src/launch-chain.js
12
12
  */
13
13
  export type SwingsetMessageType = (typeof SwingsetMessageType)[keyof typeof SwingsetMessageType];
14
- export namespace SwingsetMessageType {
15
- let AG_COSMOS_INIT: "AG_COSMOS_INIT";
16
- let BEGIN_BLOCK: "BEGIN_BLOCK";
17
- let END_BLOCK: "END_BLOCK";
18
- let COMMIT_BLOCK: "COMMIT_BLOCK";
19
- let AFTER_COMMIT_BLOCK: "AFTER_COMMIT_BLOCK";
20
- let SWING_STORE_EXPORT: "SWING_STORE_EXPORT";
21
- }
14
+ /**
15
+ * Types of messages used for communication between a cosmos-sdk blockchain node
16
+ * and its paired swingset VM, especially for the ABCI lifecycle. See:
17
+ *
18
+ * - https://github.com/tendermint/tendermint/blob/v0.34.x/spec/abci/abci.md#block-execution
19
+ * - ../../../golang/cosmos/vm/action.go
20
+ * - ../../../golang/cosmos/app/app.go
21
+ * - ../../../golang/cosmos/x/swingset/abci.go
22
+ * - ../../../golang/cosmos/x/swingset/keeper/swing_store_exports_handler.go
23
+ * - ../../cosmic-swingset/src/chain-main.js
24
+ * - ../../cosmic-swingset/src/launch-chain.js
25
+ *
26
+ * @enum {(typeof SwingsetMessageType)[keyof typeof SwingsetMessageType]}
27
+ */
28
+ export const SwingsetMessageType: import("./keyMirror.js").KeyMirrorResult<{
29
+ AG_COSMOS_INIT: null;
30
+ BEGIN_BLOCK: null;
31
+ END_BLOCK: null;
32
+ COMMIT_BLOCK: null;
33
+ AFTER_COMMIT_BLOCK: null;
34
+ SWING_STORE_EXPORT: null;
35
+ }>;
22
36
  export const AG_COSMOS_INIT: "AG_COSMOS_INIT";
23
37
  export const BEGIN_BLOCK: "BEGIN_BLOCK";
24
38
  export const END_BLOCK: "END_BLOCK";
@@ -37,18 +51,31 @@ export const SWING_STORE_EXPORT: "SWING_STORE_EXPORT";
37
51
  * - ../../../golang/cosmos/x/vibc/types/ibc_module.go
38
52
  */
39
53
  export type QueuedActionType = (typeof QueuedActionType)[keyof typeof QueuedActionType];
40
- export namespace QueuedActionType {
41
- let CORE_EVAL: "CORE_EVAL";
42
- let DELIVER_INBOUND: "DELIVER_INBOUND";
43
- let IBC_EVENT: "IBC_EVENT";
44
- let INSTALL_BUNDLE: "INSTALL_BUNDLE";
45
- let PLEASE_PROVISION: "PLEASE_PROVISION";
46
- let VBANK_BALANCE_UPDATE: "VBANK_BALANCE_UPDATE";
47
- let WALLET_ACTION: "WALLET_ACTION";
48
- let WALLET_SPEND_ACTION: "WALLET_SPEND_ACTION";
49
- let VTRANSFER_IBC_EVENT: "VTRANSFER_IBC_EVENT";
50
- let KERNEL_UPGRADE_EVENTS: "KERNEL_UPGRADE_EVENTS";
51
- }
54
+ /**
55
+ * Types of "action" messages consumed by the swingset VM from actionQueue or
56
+ * highPriorityQueue during END_BLOCK. See:
57
+ *
58
+ * - ../../../golang/cosmos/x/swingset/keeper/msg_server.go
59
+ * - ../../../golang/cosmos/x/swingset/keeper/proposal.go
60
+ * - ../../../golang/cosmos/x/vbank/vbank.go
61
+ * - ../../../golang/cosmos/x/vibc/handler.go
62
+ * - ../../../golang/cosmos/x/vibc/keeper/triggers.go
63
+ * - ../../../golang/cosmos/x/vibc/types/ibc_module.go
64
+ *
65
+ * @enum {(typeof QueuedActionType)[keyof typeof QueuedActionType]}
66
+ */
67
+ export const QueuedActionType: import("./keyMirror.js").KeyMirrorResult<{
68
+ CORE_EVAL: null;
69
+ DELIVER_INBOUND: null;
70
+ IBC_EVENT: null;
71
+ INSTALL_BUNDLE: null;
72
+ PLEASE_PROVISION: null;
73
+ VBANK_BALANCE_UPDATE: null;
74
+ WALLET_ACTION: null;
75
+ WALLET_SPEND_ACTION: null;
76
+ VTRANSFER_IBC_EVENT: null;
77
+ KERNEL_UPGRADE_EVENTS: null;
78
+ }>;
52
79
  export const CORE_EVAL: "CORE_EVAL";
53
80
  export const DELIVER_INBOUND: "DELIVER_INBOUND";
54
81
  export const IBC_EVENT: "IBC_EVENT";
@@ -1 +1 @@
1
- {"version":3,"file":"action-types.d.ts","sourceRoot":"","sources":["action-types.js"],"names":[],"mappings":";;;;;;;;;;;;kCAcU,CAAC,OAAO,mBAAmB,EAAE,MAAM,OAAO,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;+BAiC9D,CAAC,OAAO,gBAAgB,EAAE,MAAM,OAAO,gBAAgB,CAAC"}
1
+ {"version":3,"file":"action-types.d.ts","sourceRoot":"","sources":["action-types.js"],"names":[],"mappings":";;;;;;;;;;;;kCAgBU,CAAC,OAAO,mBAAmB,EAAE,MAAM,OAAO,mBAAmB,CAAC;AAZxE;;;;;;;;;;;;;GAaG;AACH;;;;;;;GAOG;;;;;;;;;;;;;;;;;;+BAwBO,CAAC,OAAO,gBAAgB,EAAE,MAAM,OAAO,gBAAgB,CAAC;AAXlE;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;GAWG"}
@@ -1,5 +1,7 @@
1
1
  // @jessie-check
2
2
 
3
+ import { keyMirror } from './keyMirror.js';
4
+
3
5
  /**
4
6
  * Types of messages used for communication between a cosmos-sdk blockchain node
5
7
  * and its paired swingset VM, especially for the ABCI lifecycle. See:
@@ -14,13 +16,13 @@
14
16
  *
15
17
  * @enum {(typeof SwingsetMessageType)[keyof typeof SwingsetMessageType]}
16
18
  */
17
- export const SwingsetMessageType = /** @type {const} */ ({
18
- AG_COSMOS_INIT: 'AG_COSMOS_INIT', // used to synchronize at process launch
19
- BEGIN_BLOCK: 'BEGIN_BLOCK',
20
- END_BLOCK: 'END_BLOCK',
21
- COMMIT_BLOCK: 'COMMIT_BLOCK',
22
- AFTER_COMMIT_BLOCK: 'AFTER_COMMIT_BLOCK',
23
- SWING_STORE_EXPORT: 'SWING_STORE_EXPORT', // used to synchronize data export
19
+ export const SwingsetMessageType = keyMirror({
20
+ AG_COSMOS_INIT: null, // used to synchronize at process launch
21
+ BEGIN_BLOCK: null,
22
+ END_BLOCK: null,
23
+ COMMIT_BLOCK: null,
24
+ AFTER_COMMIT_BLOCK: null,
25
+ SWING_STORE_EXPORT: null, // used to synchronize data export
24
26
  });
25
27
  harden(SwingsetMessageType);
26
28
 
@@ -47,17 +49,17 @@ export const {
47
49
  *
48
50
  * @enum {(typeof QueuedActionType)[keyof typeof QueuedActionType]}
49
51
  */
50
- export const QueuedActionType = /** @type {const} */ ({
51
- CORE_EVAL: 'CORE_EVAL',
52
- DELIVER_INBOUND: 'DELIVER_INBOUND',
53
- IBC_EVENT: 'IBC_EVENT',
54
- INSTALL_BUNDLE: 'INSTALL_BUNDLE',
55
- PLEASE_PROVISION: 'PLEASE_PROVISION',
56
- VBANK_BALANCE_UPDATE: 'VBANK_BALANCE_UPDATE',
57
- WALLET_ACTION: 'WALLET_ACTION',
58
- WALLET_SPEND_ACTION: 'WALLET_SPEND_ACTION',
59
- VTRANSFER_IBC_EVENT: 'VTRANSFER_IBC_EVENT',
60
- KERNEL_UPGRADE_EVENTS: 'KERNEL_UPGRADE_EVENTS',
52
+ export const QueuedActionType = keyMirror({
53
+ CORE_EVAL: null,
54
+ DELIVER_INBOUND: null,
55
+ IBC_EVENT: null,
56
+ INSTALL_BUNDLE: null,
57
+ PLEASE_PROVISION: null,
58
+ VBANK_BALANCE_UPDATE: null,
59
+ WALLET_ACTION: null,
60
+ WALLET_SPEND_ACTION: null,
61
+ VTRANSFER_IBC_EVENT: null,
62
+ KERNEL_UPGRADE_EVENTS: null,
61
63
  });
62
64
  harden(QueuedActionType);
63
65
 
package/src/config.d.ts CHANGED
@@ -17,9 +17,9 @@ export namespace CosmosInitKeyToBridgeId {
17
17
  let vbankPort: "bank";
18
18
  let vibcPort: "dibc";
19
19
  }
20
- export namespace WalletName {
21
- let depositFacet: "depositFacet";
22
- }
20
+ export const WalletName: import("./keyMirror.js").KeyMirrorResult<{
21
+ depositFacet: null;
22
+ }>;
23
23
  export namespace VBankAccount {
24
24
  namespace reserve {
25
25
  let module: "vbank/reserve";
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.js"],"names":[],"mappings":";;;uBAuCU,CAAC,OAAO,QAAQ,EAAE,MAAM,OAAO,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BANrC,OAAO,GAAG,SAAS,GAAG,SAAS"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.js"],"names":[],"mappings":";;;uBAyCU,CAAC,OAAO,QAAQ,EAAE,MAAM,OAAO,QAAQ,CAAC;;;;;;;;;;;;;;;;AAsBlD;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BA9BU,OAAO,GAAG,SAAS,GAAG,SAAS"}
package/src/config.js CHANGED
@@ -1,6 +1,8 @@
1
1
  // @ts-check
2
2
  // @jessie-check
3
3
 
4
+ import { keyMirror } from './keyMirror.js';
5
+
4
6
  /**
5
7
  * @file
6
8
  *
@@ -59,8 +61,8 @@ export const CosmosInitKeyToBridgeId = {
59
61
  };
60
62
  harden(CosmosInitKeyToBridgeId);
61
63
 
62
- export const WalletName = /** @type {const} */ ({
63
- depositFacet: 'depositFacet',
64
+ export const WalletName = keyMirror({
65
+ depositFacet: null,
64
66
  });
65
67
  harden(WalletName);
66
68
 
package/src/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./config.js";
3
3
  export * from "./debug.js";
4
4
  export * from "./errors.js";
5
5
  export * from "./js-utils.js";
6
+ export * from "./keyMirror.js";
6
7
  export * from "./method-tools.js";
7
8
  export * from "./metrics.js";
8
9
  export * from "./natural-sort.js";
package/src/index.js CHANGED
@@ -15,6 +15,7 @@ export * from './config.js';
15
15
  export * from './debug.js';
16
16
  export * from './errors.js';
17
17
  export * from './js-utils.js';
18
+ export * from './keyMirror.js';
18
19
  export { pureDataMarshaller } from './marshal/pure-data.js';
19
20
  export * from './method-tools.js';
20
21
  export * from './metrics.js';
@@ -0,0 +1,3 @@
1
+ export function keyMirror<Init extends Record<string, string | null> & Record<Exclude<PropertyKey, string>, never>>(record: Init & { readonly [K in keyof Init]: Init[K] extends null ? null : K; }): KeyMirrorResult<Init>;
2
+ export type KeyMirrorResult<Init extends Record<string, string | null> & Record<Exclude<PropertyKey, string>, never>> = { readonly [K in keyof Init]: K; };
3
+ //# sourceMappingURL=keyMirror.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyMirror.d.ts","sourceRoot":"","sources":["keyMirror.js"],"names":[],"mappings":"AAuBO,0BAJoF,IAAI,SAAjF,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,KAAK,CAAE,UAC/E,IAAI,GAAG,EAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,CAAC,GAAE,GACpE,eAAe,CAAC,IAAI,CAAC,CAqBjC;4BArC0F,IAAI,SAAjF,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,KAAK,CAAE,IAC7E,EAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,IAAI,GAAG,CAAC,GAAE"}
@@ -0,0 +1,45 @@
1
+ // @ts-check
2
+
3
+ const { freeze, entries } = Object;
4
+
5
+ /**
6
+ * @template {Record<string, string | null> & Record<Exclude<PropertyKey, string>, never>} Init
7
+ * @typedef {{ readonly [K in keyof Init]: K }} KeyMirrorResult
8
+ */
9
+
10
+ /**
11
+ * Mirror the keys of an object to string values that match the key names. This
12
+ * works well to define a TypeScript enum type compatible with erasable syntax:
13
+ *
14
+ * `@enum {(typeof MyEnum)[keyof typeof MyEnum]}`
15
+ *
16
+ * The provided record must only map property names to either `null` or the
17
+ * property name itself. The returned object has identical keys whose values are
18
+ * the string form of the key.
19
+ *
20
+ * @template {Record<string, string | null> & Record<Exclude<PropertyKey, string>, never>} Init
21
+ * @param {Init & { readonly [K in keyof Init]: Init[K] extends null ? null : K }} record
22
+ * @returns {KeyMirrorResult<Init>}
23
+ */
24
+ export const keyMirror = record => {
25
+ if (record === null || typeof record !== 'object') {
26
+ throw TypeError('keyMirror expects a record of string keys.');
27
+ }
28
+
29
+ /** @type {Record<string, string>} */
30
+ const mirrored = {
31
+ // @ts-expect-error Record confused by null prototype
32
+ __proto__: null,
33
+ };
34
+ for (const [key, value] of entries(record)) {
35
+ if (value !== null && value !== key) {
36
+ throw TypeError(
37
+ `Value for key "${key}" must be null or the key string; got ${String(value)}.`,
38
+ );
39
+ }
40
+ mirrored[key] = key;
41
+ }
42
+ return /** @type {KeyMirrorResult<Init>} */ (freeze(mirrored));
43
+ };
44
+
45
+ freeze(keyMirror);