@agoric/vats 0.15.1 → 0.15.2-calypso-dev-84eb287.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.
Files changed (208) hide show
  1. package/README.md +3 -0
  2. package/index.d.ts +6 -0
  3. package/index.d.ts.map +1 -0
  4. package/index.js +9 -0
  5. package/package.json +43 -48
  6. package/scripts/build-bundles.js +19 -0
  7. package/src/bridge-target.d.ts +193 -0
  8. package/src/bridge-target.d.ts.map +1 -0
  9. package/src/bridge-target.js +316 -0
  10. package/src/bridge.d.ts +14 -4
  11. package/src/bridge.d.ts.map +1 -1
  12. package/src/bridge.js +45 -16
  13. package/src/centralSupply.d.ts +3 -3
  14. package/src/centralSupply.d.ts.map +1 -1
  15. package/src/centralSupply.js +3 -5
  16. package/src/core/README.md +1 -1
  17. package/src/core/basic-behaviors.d.ts +24 -39
  18. package/src/core/basic-behaviors.d.ts.map +1 -1
  19. package/src/core/basic-behaviors.js +63 -63
  20. package/src/core/boot-chain.d.ts +178 -44
  21. package/src/core/boot-chain.d.ts.map +1 -1
  22. package/src/core/boot-chain.js +5 -5
  23. package/src/core/boot-sim.d.ts +5 -43
  24. package/src/core/boot-sim.d.ts.map +1 -1
  25. package/src/core/boot-sim.js +3 -4
  26. package/src/core/boot-solo.d.ts +5 -43
  27. package/src/core/boot-solo.d.ts.map +1 -1
  28. package/src/core/boot-solo.js +4 -5
  29. package/src/core/chain-behaviors.d.ts +10 -26
  30. package/src/core/chain-behaviors.d.ts.map +1 -1
  31. package/src/core/chain-behaviors.js +38 -42
  32. package/src/core/client-behaviors.d.ts +2 -1
  33. package/src/core/client-behaviors.d.ts.map +1 -1
  34. package/src/core/client-behaviors.js +6 -5
  35. package/src/core/core-eval-env.d.ts +40 -0
  36. package/src/core/demoIssuers.d.ts +24 -26
  37. package/src/core/demoIssuers.d.ts.map +1 -1
  38. package/src/core/demoIssuers.js +37 -37
  39. package/src/core/lib-boot.d.ts +17 -53
  40. package/src/core/lib-boot.d.ts.map +1 -1
  41. package/src/core/lib-boot.js +52 -60
  42. package/src/core/promise-space.d.ts +4 -7
  43. package/src/core/promise-space.d.ts.map +1 -1
  44. package/src/core/promise-space.js +15 -16
  45. package/src/core/sim-behaviors.d.ts +3 -3
  46. package/src/core/sim-behaviors.d.ts.map +1 -1
  47. package/src/core/sim-behaviors.js +1 -1
  48. package/src/core/startWalletFactory.d.ts +23 -27
  49. package/src/core/startWalletFactory.d.ts.map +1 -1
  50. package/src/core/startWalletFactory.js +32 -18
  51. package/src/core/types-ambient.d.ts +538 -0
  52. package/src/core/types-ambient.js +1 -0
  53. package/src/core/utils.d.ts +47 -92
  54. package/src/core/utils.d.ts.map +1 -1
  55. package/src/core/utils.js +58 -50
  56. package/src/crc.d.ts +2 -6
  57. package/src/crc.d.ts.map +1 -1
  58. package/src/crc.js +5 -16
  59. package/src/ibc.d.ts +30 -35
  60. package/src/ibc.d.ts.map +1 -1
  61. package/src/ibc.js +740 -491
  62. package/src/lib-board.d.ts +49 -121
  63. package/src/lib-board.d.ts.map +1 -1
  64. package/src/lib-board.js +49 -50
  65. package/src/localchain.d.ts +195 -0
  66. package/src/localchain.d.ts.map +1 -0
  67. package/src/localchain.js +324 -0
  68. package/src/mintHolder.d.ts +6 -4
  69. package/src/mintHolder.d.ts.map +1 -1
  70. package/src/mintHolder.js +19 -21
  71. package/src/nameHub.d.ts +27 -5
  72. package/src/nameHub.d.ts.map +1 -1
  73. package/src/nameHub.js +33 -26
  74. package/src/priceAuthorityRegistry.d.ts +21 -0
  75. package/src/priceAuthorityRegistry.d.ts.map +1 -0
  76. package/src/priceAuthorityRegistry.js +220 -0
  77. package/src/proposals/kread-proposal.d.ts +15 -0
  78. package/src/proposals/kread-proposal.d.ts.map +1 -0
  79. package/src/proposals/kread-proposal.js +24 -0
  80. package/src/proposals/localchain-proposal.d.ts +62 -0
  81. package/src/proposals/localchain-proposal.d.ts.map +1 -0
  82. package/src/proposals/localchain-proposal.js +128 -0
  83. package/src/proposals/localchain-test.d.ts +25 -0
  84. package/src/proposals/localchain-test.d.ts.map +1 -0
  85. package/src/proposals/localchain-test.js +89 -0
  86. package/src/proposals/namesByAddress-fix-proposal.d.ts +22 -0
  87. package/src/proposals/namesByAddress-fix-proposal.d.ts.map +1 -0
  88. package/src/proposals/namesByAddress-fix-proposal.js +55 -0
  89. package/src/proposals/network-proposal.d.ts +23 -8
  90. package/src/proposals/network-proposal.d.ts.map +1 -1
  91. package/src/proposals/network-proposal.js +90 -65
  92. package/src/proposals/probeZcfBundle.d.ts +26 -0
  93. package/src/proposals/probeZcfBundle.d.ts.map +1 -0
  94. package/src/proposals/probeZcfBundle.js +72 -0
  95. package/src/proposals/restart-vats-proposal.d.ts +4 -2
  96. package/src/proposals/restart-vats-proposal.d.ts.map +1 -1
  97. package/src/proposals/restart-vats-proposal.js +20 -8
  98. package/src/proposals/transfer-proposal.d.ts +37 -0
  99. package/src/proposals/transfer-proposal.d.ts.map +1 -0
  100. package/src/proposals/transfer-proposal.js +115 -0
  101. package/src/proposals/upgrade-bank-proposal.d.ts +27 -0
  102. package/src/proposals/upgrade-bank-proposal.d.ts.map +1 -0
  103. package/src/proposals/upgrade-bank-proposal.js +42 -0
  104. package/src/proposals/upgrade-provisionPool-proposal.d.ts +27 -0
  105. package/src/proposals/upgrade-provisionPool-proposal.d.ts.map +1 -0
  106. package/src/proposals/upgrade-provisionPool-proposal.js +67 -0
  107. package/src/proposals/upgrade-zoe-proposal.d.ts +27 -0
  108. package/src/proposals/upgrade-zoe-proposal.d.ts.map +1 -0
  109. package/src/proposals/upgrade-zoe-proposal.js +42 -0
  110. package/src/proposals/vtransfer-echoer.d.ts +24 -0
  111. package/src/proposals/vtransfer-echoer.d.ts.map +1 -0
  112. package/src/proposals/vtransfer-echoer.js +42 -0
  113. package/src/proposals/zcf-only-proposal.d.ts +33 -0
  114. package/src/proposals/zcf-only-proposal.d.ts.map +1 -0
  115. package/src/proposals/zcf-only-proposal.js +36 -0
  116. package/src/proposals/zcf-proposal.d.ts +30 -0
  117. package/src/proposals/zcf-proposal.d.ts.map +1 -0
  118. package/src/proposals/zcf-proposal.js +50 -0
  119. package/src/repl.d.ts +3 -3
  120. package/src/repl.d.ts.map +1 -1
  121. package/src/repl.js +11 -5
  122. package/src/transfer.d.ts +111 -0
  123. package/src/transfer.d.ts.map +1 -0
  124. package/src/transfer.js +260 -0
  125. package/src/types.d.ts +237 -105
  126. package/src/types.js +1 -97
  127. package/src/vat-agoricNames.d.ts +4 -4
  128. package/src/vat-agoricNames.d.ts.map +1 -1
  129. package/src/vat-agoricNames.js +2 -4
  130. package/src/vat-bank.d.ts +217 -149
  131. package/src/vat-bank.d.ts.map +1 -1
  132. package/src/vat-bank.js +96 -68
  133. package/src/vat-board.d.ts +24 -24
  134. package/src/vat-board.d.ts.map +1 -1
  135. package/src/vat-board.js +0 -1
  136. package/src/vat-bridge.d.ts +9 -23
  137. package/src/vat-bridge.d.ts.map +1 -1
  138. package/src/vat-bridge.js +1 -2
  139. package/src/vat-ibc.d.ts +16 -4
  140. package/src/vat-ibc.d.ts.map +1 -1
  141. package/src/vat-ibc.js +20 -9
  142. package/src/vat-localchain.d.ts +37 -0
  143. package/src/vat-localchain.d.ts.map +1 -0
  144. package/src/vat-localchain.js +29 -0
  145. package/src/vat-mints.d.ts +31 -31
  146. package/src/vat-mints.d.ts.map +1 -1
  147. package/src/vat-mints.js +6 -7
  148. package/src/vat-network.d.ts +69 -1
  149. package/src/vat-network.d.ts.map +1 -1
  150. package/src/vat-network.js +45 -3
  151. package/src/vat-priceAuthority.d.ts +4 -4
  152. package/src/vat-priceAuthority.d.ts.map +1 -1
  153. package/src/vat-priceAuthority.js +1 -1
  154. package/src/vat-provisioning.d.ts +6 -6
  155. package/src/vat-provisioning.d.ts.map +1 -1
  156. package/src/vat-provisioning.js +15 -12
  157. package/src/vat-transfer.d.ts +81 -0
  158. package/src/vat-transfer.d.ts.map +1 -0
  159. package/src/vat-transfer.js +63 -0
  160. package/src/vat-zoe.d.ts +4 -1
  161. package/src/vat-zoe.d.ts.map +1 -1
  162. package/src/vat-zoe.js +10 -2
  163. package/src/virtual-purse.d.ts +46 -21
  164. package/src/virtual-purse.d.ts.map +1 -1
  165. package/src/virtual-purse.js +57 -46
  166. package/src/walletFlags.d.ts +2 -2
  167. package/src/walletFlags.js +1 -2
  168. package/tools/bank-utils.d.ts +20 -0
  169. package/tools/bank-utils.d.ts.map +1 -0
  170. package/tools/bank-utils.js +92 -0
  171. package/tools/board-utils.d.ts +39 -0
  172. package/tools/board-utils.d.ts.map +1 -0
  173. package/tools/board-utils.js +92 -0
  174. package/tools/boot-test-utils.d.ts +88 -0
  175. package/tools/boot-test-utils.d.ts.map +1 -0
  176. package/tools/boot-test-utils.js +157 -0
  177. package/tools/fake-bridge.d.ts +18 -0
  178. package/tools/fake-bridge.d.ts.map +1 -0
  179. package/tools/fake-bridge.js +289 -0
  180. package/tools/ibc-utils.d.ts +29 -0
  181. package/tools/ibc-utils.d.ts.map +1 -0
  182. package/tools/ibc-utils.js +115 -0
  183. package/decentral-core-config.json +0 -66
  184. package/decentral-demo-config.json +0 -155
  185. package/decentral-devnet-config.json +0 -216
  186. package/decentral-itest-vaults-config.json +0 -210
  187. package/decentral-main-vaults-config.json +0 -229
  188. package/decentral-test-vaults-config.json +0 -195
  189. package/demo-proposals.json +0 -5
  190. package/exported.js +0 -1
  191. package/jsconfig.build.json +0 -12
  192. package/jsconfig.json +0 -13
  193. package/src/core/types.d.ts +0 -764
  194. package/src/core/types.d.ts.map +0 -1
  195. package/src/core/types.js +0 -347
  196. package/src/provisionPool.d.ts +0 -164
  197. package/src/provisionPool.d.ts.map +0 -1
  198. package/src/provisionPool.js +0 -113
  199. package/src/provisionPoolKit.d.ts +0 -392
  200. package/src/provisionPoolKit.d.ts.map +0 -1
  201. package/src/provisionPoolKit.js +0 -464
  202. package/src/tokens.d.ts +0 -36
  203. package/src/tokens.d.ts.map +0 -1
  204. package/src/tokens.js +0 -37
  205. package/src/types.d.ts.map +0 -1
  206. package/src/vat-sharing.d.ts +0 -54
  207. package/src/vat-sharing.d.ts.map +0 -1
  208. package/src/vat-sharing.js +0 -14
@@ -1,141 +1,71 @@
1
+ /**
2
+ * @import {RemotableObject} from '@endo/pass-style';
3
+ * @import {Key} from '@endo/patterns');
4
+ */
1
5
  export const DEFAULT_CRC_DIGITS: 2;
2
6
  export const DEFAULT_PREFIX: "board0";
3
- export function prepareBoardKit(baggage: MapStore<string, unknown>): (args_0?: number | bigint | undefined, args_1?: {
7
+ export function prepareBoardKit(baggage: import("@agoric/vat-data").Baggage): (initSequence?: number | bigint | undefined, args_1?: {
4
8
  prefix?: string | undefined;
5
9
  crcDigits?: number | undefined;
6
- } | undefined) => {
7
- board: {
8
- /**
9
- * Provide an ID for a value, generating one if not already present.
10
- *
11
- * Each board ID includes a CRC so that the last part is well-distributed,
12
- * which mitigates typo risks.
13
- *
14
- * Scaling Consideration: since we cannot know when consumers
15
- * are no longer interested in an ID, a board holds a strong reference
16
- * to `value` for its entire lifetime. For a well-known board, this
17
- * is essentially forever.
18
- *
19
- * @param {Key} value
20
- * @throws if `value` is not a Key in the @agoric/store sense
21
- */
22
- getId(value: Key): string;
23
- /**
24
- * @param {BoardId} id
25
- * @throws if id is not in the mapping
26
- */
27
- getValue(id: BoardId): any;
28
- /**
29
- * Convenience method for recursively traversing boards and
30
- * board-like remotables to get data associated with a sequence of ids
31
- * corresponding to each successive board.
32
- * For example, `lookup("foo", "bar")` gets the value associated with
33
- * id "foo" and returns the result of invoking `lookup("bar")` upon it
34
- * to get the value it associates with id "bar".
35
- *
36
- * @param {...string} path
37
- */
38
- lookup(...path: string[]): Promise<any>;
39
- /** @param {Key} val */
40
- has(val: Key): boolean;
41
- ids(): string[];
42
- /**
43
- * Get a marshaller that implements the convertValToSlot hook using getId(),
44
- * "publishing" previously un-mapped objects.
45
- */
46
- getPublishingMarshaller(): {
47
- toCapData(val: any): import("@endo/marshal").CapData<string>;
48
- fromCapData(data: any): any;
49
- serialize(data: any): import("@endo/marshal").CapData<string>;
50
- unserialize(data: any): any;
51
- };
52
- /**
53
- * Get a marshaller that implements the convertValToSlot hook using getId(),
54
- * only for objects that the board has().
55
- *
56
- * For other objects, we don't throw, but we emit a null slot.
57
- * Un-serializing a null slot always produces a fresh object
58
- * rather than preserving object identity.
59
- */
60
- getReadonlyMarshaller(): {
61
- toCapData(val: any): import("@endo/marshal").CapData<string | null>;
62
- fromCapData(data: any): any;
63
- serialize(data: any): import("@endo/marshal").CapData<string | null>;
64
- unserialize(data: any): any;
65
- };
66
- };
67
- readonlyMarshaller: {
68
- toCapData(val: any): import("@endo/marshal").CapData<string | null>;
69
- fromCapData(data: any): any;
70
- serialize(data: any): import("@endo/marshal").CapData<string | null>;
71
- unserialize(data: any): any;
72
- };
73
- publishingMarshaller: {
74
- toCapData(val: any): import("@endo/marshal").CapData<string>;
75
- fromCapData(data: any): any;
76
- serialize(data: any): import("@endo/marshal").CapData<string>;
77
- unserialize(data: any): any;
78
- };
79
- } & import("@endo/eventual-send").RemotableBrand<{}, {
10
+ } | undefined) => import("@endo/exo").GuardedKit<{
80
11
  board: {
81
12
  /**
82
13
  * Provide an ID for a value, generating one if not already present.
83
14
  *
84
- * Each board ID includes a CRC so that the last part is well-distributed,
85
- * which mitigates typo risks.
15
+ * Each board ID includes a CRC so that the last part is
16
+ * well-distributed, which mitigates typo risks.
86
17
  *
87
- * Scaling Consideration: since we cannot know when consumers
88
- * are no longer interested in an ID, a board holds a strong reference
89
- * to `value` for its entire lifetime. For a well-known board, this
90
- * is essentially forever.
18
+ * Scaling Consideration: since we cannot know when consumers are no
19
+ * longer interested in an ID, a board holds a strong reference to
20
+ * `value` for its entire lifetime. For a well-known board, this is
21
+ * essentially forever.
91
22
  *
92
- * @param {Key} value
93
- * @throws if `value` is not a Key in the @agoric/store sense
23
+ * @param {RemotableObject} value
94
24
  */
95
- getId(value: Key): string;
25
+ getId(value: RemotableObject): string;
96
26
  /**
97
27
  * @param {BoardId} id
98
28
  * @throws if id is not in the mapping
99
29
  */
100
- getValue(id: BoardId): any;
30
+ getValue(id: BoardId): RemotableObject;
101
31
  /**
102
- * Convenience method for recursively traversing boards and
103
- * board-like remotables to get data associated with a sequence of ids
104
- * corresponding to each successive board.
105
- * For example, `lookup("foo", "bar")` gets the value associated with
106
- * id "foo" and returns the result of invoking `lookup("bar")` upon it
107
- * to get the value it associates with id "bar".
32
+ * Convenience method for recursively traversing boards and board-like
33
+ * remotables to get data associated with a sequence of ids
34
+ * corresponding to each successive board. For example, `lookup("foo",
35
+ * "bar")` gets the value associated with id "foo" and returns the
36
+ * result of invoking `lookup("bar")` upon it to get the value it
37
+ * associates with id "bar".
108
38
  *
109
- * @param {...string} path
39
+ * @param {...string} path
110
40
  */
111
41
  lookup(...path: string[]): Promise<any>;
112
- /** @param {Key} val */
113
- has(val: Key): boolean;
42
+ /** @param {RemotableObject} val */
43
+ has(val: RemotableObject): boolean;
114
44
  ids(): string[];
115
45
  /**
116
- * Get a marshaller that implements the convertValToSlot hook using getId(),
117
- * "publishing" previously un-mapped objects.
46
+ * Get a marshaller that implements the convertValToSlot hook using
47
+ * getId(), "publishing" previously un-mapped objects.
118
48
  */
119
- getPublishingMarshaller(): {
49
+ getPublishingMarshaller(): import("@endo/exo").Guarded<{
120
50
  toCapData(val: any): import("@endo/marshal").CapData<string>;
121
51
  fromCapData(data: any): any;
122
52
  serialize(data: any): import("@endo/marshal").CapData<string>;
123
53
  unserialize(data: any): any;
124
- };
54
+ }>;
125
55
  /**
126
- * Get a marshaller that implements the convertValToSlot hook using getId(),
127
- * only for objects that the board has().
56
+ * Get a marshaller that implements the convertValToSlot hook using
57
+ * getId(), only for objects that the board has().
128
58
  *
129
59
  * For other objects, we don't throw, but we emit a null slot.
130
- * Un-serializing a null slot always produces a fresh object
131
- * rather than preserving object identity.
60
+ * Un-serializing a null slot always produces a fresh object rather than
61
+ * preserving object identity.
132
62
  */
133
- getReadonlyMarshaller(): {
63
+ getReadonlyMarshaller(): import("@endo/exo").Guarded<{
134
64
  toCapData(val: any): import("@endo/marshal").CapData<string | null>;
135
65
  fromCapData(data: any): any;
136
66
  serialize(data: any): import("@endo/marshal").CapData<string | null>;
137
67
  unserialize(data: any): any;
138
- };
68
+ }>;
139
69
  };
140
70
  readonlyMarshaller: {
141
71
  toCapData(val: any): import("@endo/marshal").CapData<string | null>;
@@ -150,32 +80,29 @@ export function prepareBoardKit(baggage: MapStore<string, unknown>): (args_0?: n
150
80
  unserialize(data: any): any;
151
81
  };
152
82
  }>;
153
- export function prepareRecorderFactory(zone: import('@agoric/zone').Zone): (label: string, marshaller: Marshaller) => <T>(storageNode: StorageNode, valueShape?: import("@agoric/zoe/src/contractSupport/recorder.js").TypedMatcher<T> | undefined) => import("@agoric/zoe/src/contractSupport/recorder.js").RecorderKit<T>;
83
+ export function prepareRecorderFactory(zone: import("@agoric/zone").Zone): (label: string, marshaller: Marshaller) => <T>(storageNode: StorageNode | Awaited<import("@endo/far").FarRef<StorageNode>>, valueShape?: import("@agoric/zoe/src/contractSupport/recorder.js").TypedMatcher<T> | undefined) => RecorderKit<T>;
154
84
  /**
155
- * For a value with a known id in the board, we can use
156
- * that board id as a slot to preserve identity when marshaling.
85
+ * For a value with a known id in the board, we can use that board id as a slot
86
+ * to preserve identity when marshaling.
157
87
  *
158
88
  * The contents of the string depend on the `prefix` and `crcDigits` options:
159
- * \`${prefix}${crc}${seq}\`
89
+ * `${prefix}${crc}${seq}`
160
90
  *
161
91
  * For example, 'board0371' for prefix: 'board0', seq: 1, 2 digits crc.
162
92
  */
163
93
  export type BoardId = string;
164
94
  /**
165
- * // TODO: use Key from
95
+ * // TODO: use
96
+ * Key from
166
97
  */
167
98
  export type BoardState = ReturnType<typeof initDurableBoardState>;
168
- export type Key = import('@endo/marshal').Passable;
99
+ import type { RemotableObject } from '@endo/pass-style';
169
100
  /**
101
+ * @typedef {ReturnType<typeof initDurableBoardState>} BoardState // TODO: use
102
+ * Key from @agoric/store when available
103
+ * @import {Passable} from '@endo/marshal'
170
104
  * @see {prepareExoClassKit}
171
- * @see {@link ../../SwingSet/docs/virtual-objects.md|SwingSet Virtual Objects}
172
- *
173
- * Hoisting this function makes defining the state type concise.
174
- * @typedef {ReturnType<typeof initDurableBoardState>} BoardState
175
- *
176
- *
177
- * // TODO: use Key from @agoric/store when available
178
- * @typedef {import('@endo/marshal').Passable} Key
105
+ * @see {@link ../../SwingSet/docs/virtual-objects.md|SwingSet Virtual Objects} Hoisting this function makes defining the state type concise.
179
106
  */
180
107
  /**
181
108
  * Make state for the board. Hoisted up to define the BoardState type.
@@ -183,15 +110,16 @@ export type Key = import('@endo/marshal').Passable;
183
110
  * @param {bigint | number} [initSequence]
184
111
  * @param {object} [options]
185
112
  * @param {string} [options.prefix] prefix for all ids generated
186
- * @param {number} [options.crcDigits] count of digits to use in CRC at end of the id
113
+ * @param {number} [options.crcDigits] count of digits to use in CRC at end of
114
+ * the id
187
115
  */
188
116
  declare function initDurableBoardState(initSequence?: number | bigint | undefined, { prefix, crcDigits }?: {
189
117
  prefix?: string | undefined;
190
118
  crcDigits?: number | undefined;
191
119
  } | undefined): {
192
120
  lastSequence: bigint;
193
- idToVal: MapStore<string, any>;
194
- valToId: MapStore<any, string>;
121
+ idToVal: globalThis.MapStore<string, RemotableObject>;
122
+ valToId: globalThis.MapStore<RemotableObject, string>;
195
123
  prefix: string;
196
124
  crcDigits: number;
197
125
  };
@@ -1 +1 @@
1
- {"version":3,"file":"lib-board.d.ts","sourceRoot":"","sources":["lib-board.js"],"names":[],"mappings":"AAmBA,mCAAoC;AACpC,sCAAuC;AAwOhC;;;;;QAQC;;;;;;;;;;;;;WAaG;qBAFQ,GAAG;QAMd;;;WAGG;qBAFQ,OAAO;QAMlB;;;;;;;;;WASG;wBADY,MAAM;QAgBrB,uBAAuB;iBAAX,GAAG;;QASf;;;WAGG;;;;;;;QAIH;;;;;;;WAOG;;;;;;;;;;;;;;;;;;;;;;QAvEH;;;;;;;;;;;;;WAaG;qBAFQ,GAAG;QAMd;;;WAGG;qBAFQ,OAAO;QAMlB;;;;;;;;;WASG;wBADY,MAAM;QAgBrB,uBAAuB;iBAAX,GAAG;;QASf;;;WAGG;;;;;;;QAIH;;;;;;;WAOG;;;;;;;;;;;;;;;;;;;;GAuCV;AAKM,6CAFI,OAAO,cAAc,EAAE,IAAI,WAUzB,MAAM,cACN,UAAU,2MAYtB;;;;;;;;;;sBAlVY,MAAM;;;;yBAuBN,WAAW,4BAA4B,CAAC;kBAIxC,OAAO,eAAe,EAAE,QAAQ;AAT7C;;;;;;;;;;GAUG;AAGH;;;;;;;GAOG;AACH;;;;;;;;;EA0BC"}
1
+ {"version":3,"file":"lib-board.d.ts","sourceRoot":"","sources":["lib-board.js"],"names":[],"mappings":"AAiBA;;;GAGG;AAEH,mCAAoC;AACpC,sCAAuC;AAsOhC,yCAHI,OAAO,kBAAkB,EAAE,OAAO;;;yBAdpB,WAAW;;QAyB5B;;;;;;;;;;;;WAYG;qBADQ,eAAe;QAK1B;;;WAGG;qBAFQ,OAAO;QAMlB;;;;;;;;;WASG;wBADW,MAAM,EAAA;QAiBpB,mCAAmC;iBAAvB,eAAe;;QAS3B;;;WAGG;;;;;;;QAIH;;;;;;;WAOG;;;;;;;;;;;;;;;;;;;;GAuCV;AAGM,6CADK,OAAO,cAAc,EAAE,IAAI,WAS1B,MAAM,cACN,UAAU,mDA7NuB,WAAW,0IAyOxD;;;;;;;;;;sBA9UY,MAAM;;;;;yBAmBN,UAAU,CAAC,OAAO,qBAAqB,CAAC;qCA9DnB,kBAAkB;AA6DpD;;;;;;GAMG;AAGH;;;;;;;;GAQG;AACH;;;;;;;;;EA0BC"}
package/src/lib-board.js CHANGED
@@ -1,7 +1,5 @@
1
- // @ts-check
2
1
  /**
3
2
  * @file lib-board: share objects by way of plain-data ids
4
- *
5
3
  * @see prepareBoardKit()
6
4
  */
7
5
 
@@ -13,10 +11,15 @@ import {
13
11
  prepareRecorder,
14
12
  } from '@agoric/zoe/src/contractSupport/recorder.js';
15
13
  import { E, Far } from '@endo/far';
16
- import { makeMarshal } from '@endo/marshal';
14
+ import { isRemotable, makeMarshal } from '@endo/marshal';
17
15
 
18
16
  import { crc6 } from './crc.js';
19
17
 
18
+ /**
19
+ * @import {RemotableObject} from '@endo/pass-style';
20
+ * @import {Key} from '@endo/patterns');
21
+ */
22
+
20
23
  export const DEFAULT_CRC_DIGITS = 2;
21
24
  export const DEFAULT_PREFIX = 'board0';
22
25
 
@@ -48,11 +51,11 @@ const BoardKitIKit = {
48
51
  //#endregion
49
52
 
50
53
  /**
51
- * For a value with a known id in the board, we can use
52
- * that board id as a slot to preserve identity when marshaling.
54
+ * For a value with a known id in the board, we can use that board id as a slot
55
+ * to preserve identity when marshaling.
53
56
  *
54
57
  * The contents of the string depend on the `prefix` and `crcDigits` options:
55
- * \`${prefix}${crc}${seq}\`
58
+ * `${prefix}${crc}${seq}`
56
59
  *
57
60
  * For example, 'board0371' for prefix: 'board0', seq: 1, 2 digits crc.
58
61
  *
@@ -75,15 +78,11 @@ const calcCrc = (data, crcDigits) => {
75
78
  };
76
79
 
77
80
  /**
81
+ * @typedef {ReturnType<typeof initDurableBoardState>} BoardState // TODO: use
82
+ * Key from @agoric/store when available
83
+ * @import {Passable} from '@endo/marshal'
78
84
  * @see {prepareExoClassKit}
79
- * @see {@link ../../SwingSet/docs/virtual-objects.md|SwingSet Virtual Objects}
80
- *
81
- * Hoisting this function makes defining the state type concise.
82
- * @typedef {ReturnType<typeof initDurableBoardState>} BoardState
83
- *
84
- *
85
- * // TODO: use Key from @agoric/store when available
86
- * @typedef {import('@endo/marshal').Passable} Key
85
+ * @see {@link ../../SwingSet/docs/virtual-objects.md|SwingSet Virtual Objects} Hoisting this function makes defining the state type concise.
87
86
  */
88
87
 
89
88
  // TODO consider tightening initSequence to bigint only
@@ -93,7 +92,8 @@ const calcCrc = (data, crcDigits) => {
93
92
  * @param {bigint | number} [initSequence]
94
93
  * @param {object} [options]
95
94
  * @param {string} [options.prefix] prefix for all ids generated
96
- * @param {number} [options.crcDigits] count of digits to use in CRC at end of the id
95
+ * @param {number} [options.crcDigits] count of digits to use in CRC at end of
96
+ * the id
97
97
  */
98
98
  const initDurableBoardState = (
99
99
  initSequence = 0,
@@ -102,13 +102,13 @@ const initDurableBoardState = (
102
102
  const immutable = { prefix, crcDigits };
103
103
 
104
104
  const lastSequence = BigInt(initSequence);
105
- /** @type {MapStore<BoardId, Key>} */
105
+ /** @type {MapStore<BoardId, RemotableObject>} */
106
106
  const idToVal = makeScalarBigMapStore('idToVal', {
107
107
  durable: true,
108
108
  keyShape: IdShape,
109
109
  valueShape: ValShape,
110
110
  });
111
- /** @type {MapStore<Key, BoardId>} */
111
+ /** @type {MapStore<RemotableObject, BoardId>} */
112
112
  const valToId = makeScalarBigMapStore('valToId', {
113
113
  durable: true,
114
114
  keyShape: ValShape,
@@ -130,11 +130,14 @@ const initDurableBoardState = (
130
130
  // transient marshallers that get GCed when the function completes.
131
131
 
132
132
  /**
133
- * @param {Key} value
133
+ * @param {RemotableObject} value
134
134
  * @param {BoardState} state
135
135
  */
136
136
  const getId = (value, state) => {
137
137
  const { idToVal, valToId, prefix, crcDigits } = state;
138
+ if (!isRemotable(value)) {
139
+ Fail`Board cannot create id for non-remotable`;
140
+ }
138
141
 
139
142
  if (valToId.has(value)) {
140
143
  return valToId.get(value);
@@ -180,9 +183,7 @@ const getValue = (id, { prefix, crcDigits, idToVal }) => {
180
183
  throw Fail`board does not have id: ${id}`;
181
184
  };
182
185
 
183
- /**
184
- * @param {BoardState} state
185
- */
186
+ /** @param {BoardState} state */
186
187
  const makeSlotToVal = state => {
187
188
  const ifaceAllegedPrefix = 'Alleged: ';
188
189
  const ifaceInaccessiblePrefix = 'SEVERED: ';
@@ -190,7 +191,7 @@ const makeSlotToVal = state => {
190
191
  /**
191
192
  * @param {BoardId} slot
192
193
  * @param {string} iface
193
- * @returns {unknown}
194
+ * @returns {any}
194
195
  */
195
196
  const slotToVal = (slot, iface) => {
196
197
  if (slot !== null) {
@@ -243,9 +244,9 @@ const makePublishingMarshaller = state => {
243
244
  //#endregion
244
245
 
245
246
  /**
246
- * A board is a two-way mapping between objects (such as issuers,
247
- * brands, installation handles) and plain-data string IDs.
248
- * A well-known board allows sharing objects by way of their ids.
247
+ * A board is a two-way mapping between objects (such as issuers, brands,
248
+ * installation handles) and plain-data string IDs. A well-known board allows
249
+ * sharing objects by way of their ids.
249
250
  *
250
251
  * @param {import('@agoric/vat-data').Baggage} baggage for upgrade successors
251
252
  * @see {@link packages/SwingSet/docs/vat-upgrade.md|Vat Upgrade}
@@ -261,16 +262,15 @@ export const prepareBoardKit = baggage => {
261
262
  /**
262
263
  * Provide an ID for a value, generating one if not already present.
263
264
  *
264
- * Each board ID includes a CRC so that the last part is well-distributed,
265
- * which mitigates typo risks.
265
+ * Each board ID includes a CRC so that the last part is
266
+ * well-distributed, which mitigates typo risks.
266
267
  *
267
- * Scaling Consideration: since we cannot know when consumers
268
- * are no longer interested in an ID, a board holds a strong reference
269
- * to `value` for its entire lifetime. For a well-known board, this
270
- * is essentially forever.
268
+ * Scaling Consideration: since we cannot know when consumers are no
269
+ * longer interested in an ID, a board holds a strong reference to
270
+ * `value` for its entire lifetime. For a well-known board, this is
271
+ * essentially forever.
271
272
  *
272
- * @param {Key} value
273
- * @throws if `value` is not a Key in the @agoric/store sense
273
+ * @param {RemotableObject} value
274
274
  */
275
275
  getId(value) {
276
276
  return getId(value, this.state);
@@ -283,14 +283,14 @@ export const prepareBoardKit = baggage => {
283
283
  return getValue(id, this.state);
284
284
  },
285
285
  /**
286
- * Convenience method for recursively traversing boards and
287
- * board-like remotables to get data associated with a sequence of ids
288
- * corresponding to each successive board.
289
- * For example, `lookup("foo", "bar")` gets the value associated with
290
- * id "foo" and returns the result of invoking `lookup("bar")` upon it
291
- * to get the value it associates with id "bar".
286
+ * Convenience method for recursively traversing boards and board-like
287
+ * remotables to get data associated with a sequence of ids
288
+ * corresponding to each successive board. For example, `lookup("foo",
289
+ * "bar")` gets the value associated with id "foo" and returns the
290
+ * result of invoking `lookup("bar")` upon it to get the value it
291
+ * associates with id "bar".
292
292
  *
293
- * @param {...string} path
293
+ * @param {...string} path
294
294
  */
295
295
  async lookup(...path) {
296
296
  const {
@@ -300,13 +300,14 @@ export const prepareBoardKit = baggage => {
300
300
  return board;
301
301
  }
302
302
  const [first, ...rest] = path;
303
+ /** @type {any} */
303
304
  const firstValue = board.getValue(/** @type {BoardId} */ (first));
304
305
  if (rest.length === 0) {
305
306
  return firstValue;
306
307
  }
307
308
  return E(firstValue).lookup(...rest);
308
309
  },
309
- /** @param {Key} val */
310
+ /** @param {RemotableObject} val */
310
311
  has(val) {
311
312
  const { state } = this;
312
313
  return state.valToId.has(val);
@@ -316,19 +317,19 @@ export const prepareBoardKit = baggage => {
316
317
  return harden([...state.idToVal.keys()]);
317
318
  },
318
319
  /**
319
- * Get a marshaller that implements the convertValToSlot hook using getId(),
320
- * "publishing" previously un-mapped objects.
320
+ * Get a marshaller that implements the convertValToSlot hook using
321
+ * getId(), "publishing" previously un-mapped objects.
321
322
  */
322
323
  getPublishingMarshaller() {
323
324
  return this.facets.publishingMarshaller;
324
325
  },
325
326
  /**
326
- * Get a marshaller that implements the convertValToSlot hook using getId(),
327
- * only for objects that the board has().
327
+ * Get a marshaller that implements the convertValToSlot hook using
328
+ * getId(), only for objects that the board has().
328
329
  *
329
330
  * For other objects, we don't throw, but we emit a null slot.
330
- * Un-serializing a null slot always produces a fresh object
331
- * rather than preserving object identity.
331
+ * Un-serializing a null slot always produces a fresh object rather than
332
+ * preserving object identity.
332
333
  */
333
334
  getReadonlyMarshaller() {
334
335
  return this.facets.readonlyMarshaller;
@@ -370,9 +371,7 @@ export const prepareBoardKit = baggage => {
370
371
  );
371
372
  };
372
373
 
373
- /**
374
- * @param {import('@agoric/zone').Zone} zone
375
- */
374
+ /** @param {import('@agoric/zone').Zone} zone */
376
375
  export const prepareRecorderFactory = zone => {
377
376
  const baggage = zone.mapStore(`Recorder Baggage`);
378
377
  const makeDurablePublishKit = prepareDurablePublishKit(
@@ -0,0 +1,195 @@
1
+ /**
2
+ * @import {TypedJson, ResponseTo, JsonSafe} from '@agoric/cosmic-proto';
3
+ * @import {PromiseVow, VowTools} from '@agoric/vow';
4
+ * @import {TargetApp, TargetRegistration} from './bridge-target.js';
5
+ * @import {BankManager, Bank} from './vat-bank.js';
6
+ * @import {ScopedBridgeManager} from './types.js';
7
+ */
8
+ /**
9
+ * @template {unknown[]} T
10
+ * @typedef {Promise<T>} PromiseVowOfTupleMappedToGenerics Temporary hack
11
+ *
12
+ * UNTIL(microsoft/TypeScript#57122): This type should be replaced with just
13
+ * PromiseVow<T>, but TypeScript doesn't understand that the result of a
14
+ * mapping a tuple type using generics is iterable:
15
+ *
16
+ * 'JsonSafe<MsgTransferResponse & { '@type':
17
+ * "/ibc.applications.transfer.v1.MsgTransferResponse"; }>[] |
18
+ * Vow<JsonSafe<MsgTransferResponse & { ...; }>[]>' must have a
19
+ * '[Symbol.iterator]()' method that returns an iterator.
20
+ */
21
+ /**
22
+ * @typedef {{
23
+ * system: ScopedBridgeManager<'vlocalchain'>;
24
+ * bank: Bank;
25
+ * transfer: import('./transfer.js').TransferMiddleware;
26
+ * }} AccountPowers
27
+ */
28
+ /**
29
+ * @typedef {{
30
+ * system: ScopedBridgeManager<'vlocalchain'>;
31
+ * bankManager: BankManager;
32
+ * transfer: import('./transfer.js').TransferMiddleware;
33
+ * }} LocalChainPowers
34
+ */
35
+ export const LocalChainAccountI: import("@endo/patterns").InterfaceGuard<{
36
+ getAddress: import("@endo/patterns").MethodGuard;
37
+ getBalance: import("@endo/patterns").MethodGuard;
38
+ deposit: import("@endo/patterns").MethodGuard;
39
+ withdraw: import("@endo/patterns").MethodGuard;
40
+ executeTx: import("@endo/patterns").MethodGuard;
41
+ monitorTransfers: import("@endo/patterns").MethodGuard;
42
+ }>;
43
+ export function prepareLocalChainAccountKit(zone: import("@agoric/base-zone").Zone, { watch }: VowTools): (address: string, powers: AccountPowers) => import("@endo/exo").GuardedKit<{
44
+ depositPaymentWatcher: {
45
+ /**
46
+ * @param {Brand<'nat'>} brand
47
+ * @param {{
48
+ * payment: Payment<'nat'>;
49
+ * optAmountShape: Amount<'nat'>;
50
+ * }} ctx
51
+ */
52
+ onFulfilled(brand: Brand<"nat">, { payment, optAmountShape }: {
53
+ payment: Payment<"nat">;
54
+ optAmountShape: Amount<"nat">;
55
+ }): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
56
+ };
57
+ account: {
58
+ getAddress(): string;
59
+ /**
60
+ * @param {Brand<'nat'>} brand
61
+ * @returns {PromiseVow<Amount<'nat'>>}
62
+ */
63
+ getBalance(brand: Brand<"nat">): PromiseVow<Amount<"nat">>;
64
+ /**
65
+ * Deposit a payment into the bank purse that matches the alleged brand.
66
+ * This is safe, since even if the payment lies about its brand, ERTP
67
+ * will reject spoofed payment objects when depositing into a purse.
68
+ *
69
+ * @param {Payment<'nat'>} payment
70
+ * @param {Pattern} [optAmountShape] throws if the Amount of the Payment
71
+ * does not match the provided Pattern
72
+ * @returns {PromiseVow<Amount<'nat'>>}
73
+ */
74
+ deposit(payment: Payment<"nat">, optAmountShape?: Pattern): PromiseVow<Amount<"nat">>;
75
+ /**
76
+ * Withdraw a payment from the account's bank purse of the amount's
77
+ * brand.
78
+ *
79
+ * @param {Amount<'nat'>} amount
80
+ * @returns {PromiseVow<Payment<'nat'>>} payment
81
+ */
82
+ withdraw(amount: Amount<"nat">): PromiseVow<Payment<"nat">>;
83
+ /**
84
+ * Execute a batch of messages in order as a single atomic transaction
85
+ * and return the responses. If any of the messages fails, the entire
86
+ * batch will be rolled back. Use `typedJson()` on the arguments to get
87
+ * typed return values.
88
+ *
89
+ * @template {TypedJson[]} MT messages tuple (use const with multiple
90
+ * elements or it will be a mixed array)
91
+ * @param {MT} messages
92
+ * @returns {PromiseVowOfTupleMappedToGenerics<{
93
+ * [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>>;
94
+ * }>}
95
+ */
96
+ executeTx<MT extends TypedJson[]>(messages: MT): PromiseVowOfTupleMappedToGenerics<{ [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>>; }>;
97
+ /**
98
+ * @param {TargetApp} tap
99
+ * @returns {PromiseVow<TargetRegistration>}
100
+ */
101
+ monitorTransfers(tap: TargetApp): PromiseVow<TargetRegistration>;
102
+ };
103
+ }>;
104
+ /**
105
+ * @typedef {Awaited<
106
+ * ReturnType<ReturnType<typeof prepareLocalChainAccountKit>>
107
+ * >} LocalChainAccountKit
108
+ */
109
+ /** @typedef {LocalChainAccountKit['account']} LocalChainAccount */
110
+ export const LocalChainI: import("@endo/patterns").InterfaceGuard<{
111
+ makeAccount: import("@endo/patterns").MethodGuard;
112
+ query: import("@endo/patterns").MethodGuard;
113
+ queryMany: import("@endo/patterns").MethodGuard;
114
+ }>;
115
+ export function prepareLocalChainTools(zone: import("@agoric/base-zone").Zone, vowTools: VowTools): {
116
+ makeLocalChain: (powers: LocalChainPowers) => import("@endo/exo").Guarded<{
117
+ /**
118
+ * Allocate a fresh address that doesn't correspond with a public key,
119
+ * and follows the ICA guidelines to help reduce collisions. See
120
+ * x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
121
+ * hash and block data hash.
122
+ *
123
+ * @returns {PromiseVow<LocalChainAccount>}
124
+ */
125
+ makeAccount(): PromiseVow<LocalChainAccount>;
126
+ /**
127
+ * Make a single query to the local chain. Will reject with an error if
128
+ * the query fails. Otherwise, return the response as a JSON-compatible
129
+ * object.
130
+ *
131
+ * @template {TypedJson} [T=TypedJson]
132
+ * @param {T} request
133
+ * @returns {PromiseVow<JsonSafe<ResponseTo<T>>>}
134
+ */
135
+ query<T extends TypedJson = {
136
+ '@type': string;
137
+ }>(request: T): PromiseVow<JsonSafe<ResponseTo<T>>>;
138
+ /**
139
+ * Send a batch of query requests to the local chain. Unless there is a
140
+ * system error, will return all results to indicate their success or
141
+ * failure.
142
+ *
143
+ * @template {import('@agoric/cosmic-proto').TypedJson[]} RT
144
+ * @param {RT} requests
145
+ * @returns {PromiseVowOfTupleMappedToGenerics<{
146
+ * [K in keyof RT]: JsonSafe<{
147
+ * error?: string;
148
+ * reply: ResponseTo<RT[K]>;
149
+ * }>;
150
+ * }>}
151
+ */
152
+ queryMany<RT extends import("@agoric/cosmic-proto").TypedJson[]>(requests: RT): PromiseVowOfTupleMappedToGenerics<{ [K in keyof RT]: JsonSafe<{
153
+ error?: string;
154
+ reply: ResponseTo<RT[K]>;
155
+ }>; }>;
156
+ }>;
157
+ };
158
+ /**
159
+ * Temporary hack
160
+ *
161
+ * UNTIL(microsoft/TypeScript#57122): This type should be replaced with just
162
+ * PromiseVow<T>, but TypeScript doesn't understand that the result of a
163
+ * mapping a tuple type using generics is iterable:
164
+ *
165
+ * 'JsonSafe<MsgTransferResponse & { '@type':
166
+ * "/ibc.applications.transfer.v1.MsgTransferResponse"; }>[] |
167
+ * Vow<JsonSafe<MsgTransferResponse & { ...; }>[]>' must have a
168
+ * '[Symbol.iterator]()' method that returns an iterator.
169
+ */
170
+ export type PromiseVowOfTupleMappedToGenerics<T extends unknown[]> = Promise<T>;
171
+ export type AccountPowers = {
172
+ system: ScopedBridgeManager<"vlocalchain">;
173
+ bank: Bank;
174
+ transfer: import("./transfer.js").TransferMiddleware;
175
+ };
176
+ export type LocalChainPowers = {
177
+ system: ScopedBridgeManager<"vlocalchain">;
178
+ bankManager: BankManager;
179
+ transfer: import("./transfer.js").TransferMiddleware;
180
+ };
181
+ export type LocalChainAccountKit = Awaited<ReturnType<ReturnType<typeof prepareLocalChainAccountKit>>>;
182
+ export type LocalChainAccount = LocalChainAccountKit["account"];
183
+ export type LocalChainTools = ReturnType<typeof prepareLocalChainTools>;
184
+ export type LocalChain = ReturnType<LocalChainTools["makeLocalChain"]>;
185
+ import type { VowTools } from '@agoric/vow';
186
+ import type { PromiseVow } from '@agoric/vow';
187
+ import type { TypedJson } from '@agoric/cosmic-proto';
188
+ import type { ResponseTo } from '@agoric/cosmic-proto';
189
+ import type { JsonSafe } from '@agoric/cosmic-proto';
190
+ import type { TargetApp } from './bridge-target.js';
191
+ import type { TargetRegistration } from './bridge-target.js';
192
+ import type { ScopedBridgeManager } from './types.js';
193
+ import type { Bank } from './vat-bank.js';
194
+ import type { BankManager } from './vat-bank.js';
195
+ //# sourceMappingURL=localchain.d.ts.map