@agoric/internal 0.3.3-other-dev-8f8782b.0 → 0.3.3-other-dev-fbe72e7.0.fbe72e7
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/README.md +7 -2
- package/exported.js +2 -0
- package/package.json +41 -19
- package/src/action-types.d.ts +51 -5
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +74 -15
- package/src/batched-deliver.d.ts +9 -6
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +9 -3
- package/src/callback.d.ts +24 -17
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +55 -61
- package/src/chain-storage-paths.d.ts +2 -3
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-storage-paths.js +2 -3
- package/src/chain-utils.d.ts +27 -0
- package/src/chain-utils.d.ts.map +1 -0
- package/src/chain-utils.js +62 -0
- package/src/cli-utils.d.ts +2 -0
- package/src/cli-utils.d.ts.map +1 -0
- package/src/cli-utils.js +21 -0
- package/src/config.d.ts +22 -12
- package/src/config.d.ts.map +1 -1
- package/src/config.js +23 -10
- package/src/debug.d.ts +1 -1
- package/src/errors.d.ts +2 -0
- package/src/errors.d.ts.map +1 -0
- package/src/errors.js +16 -0
- package/src/hex.d.ts +15 -0
- package/src/hex.d.ts.map +1 -0
- package/src/hex.js +105 -0
- package/src/index.d.ts +10 -1
- package/src/index.js +13 -2
- package/src/install-ses-debug.d.ts +2 -0
- package/src/install-ses-debug.d.ts.map +1 -0
- package/src/install-ses-debug.js +6 -0
- package/src/js-utils.d.ts +40 -0
- package/src/js-utils.d.ts.map +1 -0
- package/src/js-utils.js +237 -0
- package/src/lib-chainStorage.d.ts +59 -67
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +95 -92
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts +13 -0
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts.map +1 -0
- package/src/lib-nodejs/ava-unhandled-rejection.js +66 -0
- package/src/lib-nodejs/engine-gc.d.ts +3 -0
- package/src/lib-nodejs/engine-gc.d.ts.map +1 -0
- package/src/lib-nodejs/engine-gc.js +22 -0
- package/src/lib-nodejs/gc-and-finalize.d.ts +2 -0
- package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -0
- package/src/lib-nodejs/gc-and-finalize.js +91 -0
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts +15 -0
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -0
- package/src/lib-nodejs/spawnSubprocessWorker.js +89 -0
- package/src/lib-nodejs/waitUntilQuiescent.d.ts +2 -0
- package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -0
- package/src/lib-nodejs/waitUntilQuiescent.js +18 -0
- package/src/lib-nodejs/worker-protocol.d.ts +4 -0
- package/src/lib-nodejs/worker-protocol.d.ts.map +1 -0
- package/src/lib-nodejs/worker-protocol.js +54 -0
- package/src/magic-cookie-test-only.js +2 -2
- package/src/marshal.d.ts +33 -0
- package/src/marshal.d.ts.map +1 -0
- package/src/marshal.js +156 -0
- package/src/method-tools.d.ts +1 -0
- package/src/method-tools.d.ts.map +1 -1
- package/src/method-tools.js +33 -62
- package/src/metrics.d.ts +183 -0
- package/src/metrics.d.ts.map +1 -0
- package/src/metrics.js +476 -0
- package/src/module-utils.d.ts +2 -0
- package/src/module-utils.d.ts.map +1 -0
- package/src/module-utils.js +27 -0
- package/src/natural-sort.d.ts +2 -0
- package/src/natural-sort.d.ts.map +1 -0
- package/src/natural-sort.js +48 -0
- package/src/netstring.d.ts +24 -0
- package/src/netstring.d.ts.map +1 -0
- package/src/netstring.js +125 -0
- package/src/node/buffer-line-transform.d.ts +20 -16
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +12 -9
- package/src/node/createBundles.d.ts.map +1 -1
- package/src/node/createBundles.js +12 -3
- package/src/node/fs-stream.d.ts +1 -1
- package/src/node/fs-stream.d.ts.map +1 -1
- package/src/node/fs-stream.js +48 -37
- package/src/node/shutdown.d.ts.map +1 -1
- package/src/node/shutdown.js +0 -1
- package/src/priority-senders.d.ts +2 -1
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +10 -4
- package/src/queue.d.ts +1 -1
- package/src/queue.d.ts.map +1 -1
- package/src/queue.js +7 -8
- package/src/scratch.d.ts +1 -1
- package/src/scratch.d.ts.map +1 -1
- package/src/ses-utils.d.ts +68 -0
- package/src/ses-utils.d.ts.map +1 -0
- package/src/ses-utils.js +422 -0
- package/src/storage-test-utils.d.ts +49 -84
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +234 -116
- package/src/tagged.d.ts +152 -0
- package/src/testing-utils.d.ts +2 -0
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +44 -5
- package/src/tmpDir.d.ts +2 -0
- package/src/tmpDir.d.ts.map +1 -0
- package/src/tmpDir.js +17 -0
- package/src/tokens.d.ts +34 -0
- package/src/tokens.d.ts.map +1 -0
- package/src/tokens.js +35 -0
- package/src/typeCheck.d.ts +9 -0
- package/src/typeCheck.d.ts.map +1 -0
- package/src/typeCheck.js +23 -0
- package/src/typeGuards.d.ts +17 -0
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +20 -0
- package/src/types-index.d.ts +1 -0
- package/src/types-index.js +2 -0
- package/src/types.d.ts +83 -18
- package/src/types.d.ts.map +1 -0
- package/src/types.ts +129 -0
- package/src/upgrade-api.d.ts +14 -4
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +50 -18
- package/CHANGELOG.md +0 -106
- package/src/utils.d.ts +0 -67
- package/src/utils.d.ts.map +0 -1
- package/src/utils.js +0 -451
package/src/callback.js
CHANGED
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
import { Fail, makeError, q } from '@endo/errors';
|
|
2
3
|
import { E } from '@endo/far';
|
|
3
|
-
import {
|
|
4
|
+
import { isPrimitive, isPassableSymbol } from '@endo/pass-style';
|
|
5
|
+
import { getInterfaceMethodKeys } from '@endo/patterns';
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
/** @import {ERef} from '@endo/far' */
|
|
8
|
+
/** @import {Callback, SyncCallback} from './types.js' */
|
|
6
9
|
|
|
7
10
|
const { fromEntries } = Object;
|
|
8
11
|
|
|
9
12
|
const { ownKeys: rawOwnKeys } = Reflect;
|
|
10
13
|
const ownKeys =
|
|
11
|
-
/** @type {<T extends PropertyKey>(obj: {[K in T]?: unknown}) => T[]} */ (
|
|
14
|
+
/** @type {<T extends PropertyKey>(obj: { [K in T]?: unknown }) => T[]} */ (
|
|
12
15
|
rawOwnKeys
|
|
13
16
|
);
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
|
-
* @template T
|
|
17
|
-
* @typedef {(
|
|
19
|
+
* @template {import('@endo/exo').Methods} T
|
|
20
|
+
* @typedef {(
|
|
21
|
+
* ...args: Parameters<ReturnType<prepareAttenuator>>
|
|
22
|
+
* ) => import('@endo/exo').Farable<T>} MakeAttenuator
|
|
18
23
|
*/
|
|
19
24
|
|
|
20
|
-
/**
|
|
21
|
-
* @template {(...args: unknown[]) => any} I
|
|
22
|
-
* @typedef {import('./types').Callback<I>} Callback
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @template {(...args: unknown[]) => any} I
|
|
27
|
-
* @typedef {import('./types').SyncCallback<I>} SyncCallback
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/** @template T @typedef {import('@endo/eventual-send').RemotableBrand<{}, T> & T} Farable */
|
|
31
|
-
|
|
32
25
|
/**
|
|
33
26
|
* @param {unknown} key
|
|
34
27
|
* @returns {key is PropertyKey} FIXME: should be just `PropertyKey` but TS
|
|
35
|
-
*
|
|
28
|
+
* complains it can't be used as an index type.
|
|
36
29
|
*/
|
|
37
30
|
const isPropertyKey = key => {
|
|
38
31
|
switch (typeof key) {
|
|
@@ -48,7 +41,7 @@ const isPropertyKey = key => {
|
|
|
48
41
|
/**
|
|
49
42
|
* Synchronously call a callback.
|
|
50
43
|
*
|
|
51
|
-
* @template {(...args:
|
|
44
|
+
* @template {(...args: any[]) => any} I
|
|
52
45
|
* @param {SyncCallback<I>} callback
|
|
53
46
|
* @param {Parameters<I>} args
|
|
54
47
|
* @returns {ReturnType<I>}
|
|
@@ -65,7 +58,7 @@ harden(callSync);
|
|
|
65
58
|
/**
|
|
66
59
|
* Eventual send to a callback.
|
|
67
60
|
*
|
|
68
|
-
* @template {(...args:
|
|
61
|
+
* @template {(...args: any[]) => any} I
|
|
69
62
|
* @param {Callback<I>} callback
|
|
70
63
|
* @param {Parameters<I>} args
|
|
71
64
|
* @returns {Promise<Awaited<ReturnType<I>>>}
|
|
@@ -82,9 +75,9 @@ harden(callE);
|
|
|
82
75
|
/**
|
|
83
76
|
* Create a callback from a near function.
|
|
84
77
|
*
|
|
85
|
-
* @template {(...args:
|
|
78
|
+
* @template {(...args: any[]) => any} I
|
|
86
79
|
* @template {(...args: [...B, ...Parameters<I>]) => ReturnType<I>} [T=I]
|
|
87
|
-
* @template {
|
|
80
|
+
* @template {any[]} [B=[]]
|
|
88
81
|
* @param {T} target
|
|
89
82
|
* @param {B} bound
|
|
90
83
|
* @returns {SyncCallback<I>}
|
|
@@ -101,17 +94,15 @@ harden(makeSyncFunctionCallback);
|
|
|
101
94
|
/**
|
|
102
95
|
* Create a callback from a potentially far function.
|
|
103
96
|
*
|
|
104
|
-
* @template {(...args:
|
|
105
|
-
* @template {
|
|
106
|
-
*
|
|
107
|
-
* >} [T=import('@endo/far').ERef<I>]
|
|
108
|
-
* @template {unknown[]} [B=[]]
|
|
97
|
+
* @template {(...args: any[]) => any} I
|
|
98
|
+
* @template {ERef<(...args: [...B, ...Parameters<I>]) => ReturnType<I>>} [T=ERef<I>]
|
|
99
|
+
* @template {any[]} [B=[]]
|
|
109
100
|
* @param {T} target
|
|
110
101
|
* @param {B} bound
|
|
111
102
|
* @returns {Callback<I>}
|
|
112
103
|
*/
|
|
113
104
|
export const makeFunctionCallback = (target, ...bound) => {
|
|
114
|
-
|
|
105
|
+
!isPrimitive(target) ||
|
|
115
106
|
Fail`function callback target must be a function presence: ${target}`;
|
|
116
107
|
/** @type {unknown} */
|
|
117
108
|
const cb = harden({ target, bound });
|
|
@@ -122,19 +113,19 @@ harden(makeFunctionCallback);
|
|
|
122
113
|
/**
|
|
123
114
|
* Create a callback from a near method.
|
|
124
115
|
*
|
|
125
|
-
* @template {(...args:
|
|
116
|
+
* @template {(...args: any[]) => any} I
|
|
126
117
|
* @template {PropertyKey} P
|
|
127
118
|
* @template {{
|
|
128
|
-
* [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I
|
|
119
|
+
* [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I>;
|
|
129
120
|
* }} [T={ [x in P]: I }]
|
|
130
|
-
* @template {
|
|
121
|
+
* @template {any[]} [B=[]]
|
|
131
122
|
* @param {T} target
|
|
132
123
|
* @param {P} methodName
|
|
133
124
|
* @param {B} bound
|
|
134
125
|
* @returns {SyncCallback<I>}
|
|
135
126
|
*/
|
|
136
127
|
export const makeSyncMethodCallback = (target, methodName, ...bound) => {
|
|
137
|
-
|
|
128
|
+
!isPrimitive(target) ||
|
|
138
129
|
Fail`sync method callback target must be an object: ${target}`;
|
|
139
130
|
typeof methodName === 'string' ||
|
|
140
131
|
isPassableSymbol(methodName) ||
|
|
@@ -148,19 +139,20 @@ harden(makeSyncMethodCallback);
|
|
|
148
139
|
/**
|
|
149
140
|
* Create a callback from a potentially far method.
|
|
150
141
|
*
|
|
151
|
-
* @template {(...args:
|
|
142
|
+
* @template {(...args: any[]) => any} I
|
|
152
143
|
* @template {PropertyKey} P
|
|
153
|
-
* @template {
|
|
154
|
-
* [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I
|
|
155
|
-
* }>} [T=
|
|
156
|
-
* @template {
|
|
144
|
+
* @template {ERef<{
|
|
145
|
+
* [x in P]: (...args: [...B, ...Parameters<I>]) => ReturnType<I>;
|
|
146
|
+
* }>} [T=ERef<{ [x in P]: I }>]
|
|
147
|
+
* @template {any[]} [B=[]]
|
|
157
148
|
* @param {T} target
|
|
158
149
|
* @param {P} methodName
|
|
159
150
|
* @param {B} bound
|
|
160
151
|
* @returns {Callback<I>}
|
|
161
152
|
*/
|
|
162
153
|
export const makeMethodCallback = (target, methodName, ...bound) => {
|
|
163
|
-
|
|
154
|
+
!isPrimitive(target) ||
|
|
155
|
+
Fail`method callback target must be an object: ${target}`;
|
|
164
156
|
typeof methodName === 'string' ||
|
|
165
157
|
isPassableSymbol(methodName) ||
|
|
166
158
|
Fail`method name must be a string or passable symbol: ${methodName}`;
|
|
@@ -175,12 +167,12 @@ harden(makeMethodCallback);
|
|
|
175
167
|
* @returns {callback is Callback<any>}
|
|
176
168
|
*/
|
|
177
169
|
export const isCallback = callback => {
|
|
178
|
-
if (
|
|
170
|
+
if (isPrimitive(callback)) {
|
|
179
171
|
return false;
|
|
180
172
|
}
|
|
181
173
|
const { target, methodName, bound } = callback;
|
|
182
174
|
return (
|
|
183
|
-
|
|
175
|
+
!isPrimitive(target) &&
|
|
184
176
|
(methodName === undefined ||
|
|
185
177
|
typeof methodName === 'string' ||
|
|
186
178
|
isPassableSymbol(methodName)) &&
|
|
@@ -193,11 +185,14 @@ harden(isCallback);
|
|
|
193
185
|
* Prepare an attenuator class whose methods can be redirected via callbacks.
|
|
194
186
|
*
|
|
195
187
|
* @template {PropertyKey} M
|
|
196
|
-
* @param {import('@agoric/zone').Zone} zone The zone in which to allocate
|
|
188
|
+
* @param {import('@agoric/base-zone').Zone} zone The zone in which to allocate
|
|
189
|
+
* attenuators.
|
|
197
190
|
* @param {M[]} methodNames Methods to forward.
|
|
198
191
|
* @param {object} opts
|
|
199
|
-
* @param {InterfaceGuard
|
|
200
|
-
*
|
|
192
|
+
* @param {import('@endo/patterns').InterfaceGuard<{
|
|
193
|
+
* [K in M]: import('@endo/patterns').MethodGuard;
|
|
194
|
+
* }>} [opts.interfaceGuard]
|
|
195
|
+
* An interface guard for the new attenuator.
|
|
201
196
|
* @param {string} [opts.tag] A tag for the new attenuator exoClass.
|
|
202
197
|
*/
|
|
203
198
|
export const prepareAttenuator = (
|
|
@@ -206,9 +201,11 @@ export const prepareAttenuator = (
|
|
|
206
201
|
{ interfaceGuard, tag = 'Attenuator' } = {},
|
|
207
202
|
) => {
|
|
208
203
|
/**
|
|
209
|
-
* @typedef {(this: any, ...args:
|
|
210
|
-
*
|
|
211
|
-
* @typedef {{ [K in M]
|
|
204
|
+
* @typedef {(this: any, ...args: any[]) => any} Method
|
|
205
|
+
*
|
|
206
|
+
* @typedef {{ [K in M]?: Callback<any> | null }} Overrides
|
|
207
|
+
*
|
|
208
|
+
* @typedef {{ [K in M]: (this: any, ...args: any[]) => any }} Methods
|
|
212
209
|
*/
|
|
213
210
|
const methods = /** @type {Methods} */ (
|
|
214
211
|
fromEntries(
|
|
@@ -226,9 +223,7 @@ export const prepareAttenuator = (
|
|
|
226
223
|
// Support both synchronous and async callbacks.
|
|
227
224
|
const cb = this.state.cbs[key];
|
|
228
225
|
if (!cb) {
|
|
229
|
-
const err =
|
|
230
|
-
`unimplemented ${q(tag)} method ${q(key)}`,
|
|
231
|
-
);
|
|
226
|
+
const err = makeError(`unimplemented ${q(tag)} method ${q(key)}`);
|
|
232
227
|
if (this.state.isSync) {
|
|
233
228
|
throw err;
|
|
234
229
|
}
|
|
@@ -250,14 +245,13 @@ export const prepareAttenuator = (
|
|
|
250
245
|
* and/or individual method override callbacks.
|
|
251
246
|
*
|
|
252
247
|
* @param {object} opts
|
|
253
|
-
* @param {unknown} [opts.target] The target for any methods that
|
|
254
|
-
*
|
|
248
|
+
* @param {unknown} [opts.target] The target for any methods that weren't
|
|
249
|
+
* specified in `opts.overrides`.
|
|
255
250
|
* @param {boolean} [opts.isSync=false] Whether the target should be treated
|
|
256
|
-
*
|
|
257
|
-
* @param {Overrides} [opts.overrides] Set individual
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
* mean to throw.
|
|
251
|
+
* as synchronously available.
|
|
252
|
+
* @param {Overrides} [opts.overrides] Set individual callbacks for methods
|
|
253
|
+
* (whose names must be defined in the `prepareAttenuator` or
|
|
254
|
+
* `prepareGuardedAttenuator` call). Nullish overrides mean to throw.
|
|
261
255
|
*/
|
|
262
256
|
const makeAttenuator = zone.exoClass(
|
|
263
257
|
tag,
|
|
@@ -265,7 +259,7 @@ export const prepareAttenuator = (
|
|
|
265
259
|
/**
|
|
266
260
|
* @param {object} opts
|
|
267
261
|
* @param {any} [opts.target]
|
|
268
|
-
* @param {boolean} [opts.isSync
|
|
262
|
+
* @param {boolean} [opts.isSync]
|
|
269
263
|
* @param {Overrides} [opts.overrides]
|
|
270
264
|
*/
|
|
271
265
|
({
|
|
@@ -305,14 +299,14 @@ harden(prepareAttenuator);
|
|
|
305
299
|
/**
|
|
306
300
|
* Prepare an attenuator whose methodNames are derived from the interfaceGuard.
|
|
307
301
|
*
|
|
308
|
-
* @
|
|
309
|
-
* @param {
|
|
302
|
+
* @template {import('@endo/patterns').InterfaceGuard} G
|
|
303
|
+
* @param {import('@agoric/base-zone').Zone} zone
|
|
304
|
+
* @param {G} interfaceGuard
|
|
310
305
|
* @param {object} [opts]
|
|
311
306
|
* @param {string} [opts.tag]
|
|
312
307
|
*/
|
|
313
308
|
export const prepareGuardedAttenuator = (zone, interfaceGuard, opts = {}) => {
|
|
314
|
-
const
|
|
315
|
-
const methodNames = ownKeys(methodGuards);
|
|
309
|
+
const methodNames = getInterfaceMethodKeys(interfaceGuard);
|
|
316
310
|
const makeAttenuator = prepareAttenuator(zone, methodNames, {
|
|
317
311
|
...opts,
|
|
318
312
|
interfaceGuard,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* These identify top-level paths for SwingSet chain storage
|
|
3
|
-
*
|
|
4
|
-
* To avoid collisions, they should remain synchronized with
|
|
2
|
+
* These identify top-level paths for SwingSet chain storage (and serve as
|
|
3
|
+
* prefixes). To avoid collisions, they should remain synchronized with
|
|
5
4
|
* golang/cosmos/x/swingset/keeper/keeper.go
|
|
6
5
|
*/
|
|
7
6
|
export const ACTION_QUEUE: "actionQueue";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-storage-paths.d.ts","sourceRoot":"","sources":["chain-storage-paths.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"chain-storage-paths.d.ts","sourceRoot":"","sources":["chain-storage-paths.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,2BAA4B,aAAa,CAAC;AAC1C,kCAAmC,mBAAmB,CAAC;AACvD,oCAAqC,qBAAqB,CAAC;AAC3D,yBAA0B,YAAY,CAAC;AACvC,qBAAsB,QAAQ,CAAC;AAC/B,sBAAuB,SAAS,CAAC;AACjC,sBAAuB,SAAS,CAAC;AACjC,qBAAsB,WAAW,CAAC;AAClC,0BAA2B,YAAY,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* These identify top-level paths for SwingSet chain storage
|
|
5
|
-
*
|
|
6
|
-
* To avoid collisions, they should remain synchronized with
|
|
4
|
+
* These identify top-level paths for SwingSet chain storage (and serve as
|
|
5
|
+
* prefixes). To avoid collisions, they should remain synchronized with
|
|
7
6
|
* golang/cosmos/x/swingset/keeper/keeper.go
|
|
8
7
|
*/
|
|
9
8
|
export const ACTION_QUEUE = 'actionQueue';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function makeInitMsg(initAction: any): InitMsg;
|
|
2
|
+
export type NatString = `${bigint}`;
|
|
3
|
+
export type BlockInfo = {
|
|
4
|
+
blockHeight: number;
|
|
5
|
+
/**
|
|
6
|
+
* POSIX Seconds Since the Epoch
|
|
7
|
+
*/
|
|
8
|
+
blockTime: number;
|
|
9
|
+
params: JsonSafe<ParamsSDKType>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* cosmosInitAction fields that are subject to consensus. See cosmosInitAction
|
|
13
|
+
* in {@link ../../../golang/cosmos/app/app.go}.
|
|
14
|
+
*/
|
|
15
|
+
export type InitMsg = BlockInfo & {
|
|
16
|
+
type: typeof _ActionType.AG_COSMOS_INIT;
|
|
17
|
+
chainID: string;
|
|
18
|
+
isBootstrap?: boolean;
|
|
19
|
+
supplyCoins: {
|
|
20
|
+
denom: string;
|
|
21
|
+
amount: NatString;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
import type { ParamsSDKType } from '@agoric/cosmic-proto/swingset/swingset.js';
|
|
25
|
+
import type { JsonSafe } from '@agoric/cosmic-proto/json-safe';
|
|
26
|
+
import * as _ActionType from './action-types.js';
|
|
27
|
+
//# sourceMappingURL=chain-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-utils.d.ts","sourceRoot":"","sources":["chain-utils.js"],"names":[],"mappings":"AA2CO,wCAHI,GAAG,GACD,OAAO,CAoBnB;wBA/Ca,GAAG,MAAM,EAAE;;iBASX,MAAM;;;;eACN,MAAM;YACN,SAAS,aAAa,CAAC;;;;;;sBAIxB,SAAS,GAAG;IACpB,IAAI,EAAE,OAAO,WAAW,CAAC,cAAc,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,SAAS,CAAA;KAAE,EAAE,CAAC;CACrD;mCAjB4B,2CAA2C;8BAChD,gCAAgC;6BAN9B,mBAAmB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Types and utilities for supporting blockchain functionality without
|
|
3
|
+
* risking import cycles.
|
|
4
|
+
*
|
|
5
|
+
* TODO: Integrate (or integrate with) any/all of:
|
|
6
|
+
*
|
|
7
|
+
* - ./action-types.js
|
|
8
|
+
* - ./chain-storage-paths.js
|
|
9
|
+
* - ./config.js
|
|
10
|
+
* - ../../cosmic-proto (if comfortable co-residing with generated code)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as _ActionType from './action-types.js';
|
|
14
|
+
|
|
15
|
+
/** @typedef {`${bigint}`} NatString */
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @import {ParamsSDKType} from '@agoric/cosmic-proto/swingset/swingset.js'
|
|
19
|
+
* @import {JsonSafe} from '@agoric/cosmic-proto/json-safe'
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {object} BlockInfo
|
|
24
|
+
* @property {number} blockHeight
|
|
25
|
+
* @property {number} blockTime POSIX Seconds Since the Epoch
|
|
26
|
+
* @property {JsonSafe<ParamsSDKType>} params
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {BlockInfo & {
|
|
31
|
+
* type: typeof _ActionType.AG_COSMOS_INIT;
|
|
32
|
+
* chainID: string;
|
|
33
|
+
* isBootstrap?: boolean;
|
|
34
|
+
* supplyCoins: { denom: string; amount: NatString }[];
|
|
35
|
+
* }} InitMsg
|
|
36
|
+
* cosmosInitAction fields that are subject to consensus. See cosmosInitAction
|
|
37
|
+
* in {@link ../../../golang/cosmos/app/app.go}.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {any} initAction
|
|
42
|
+
* @returns {InitMsg}
|
|
43
|
+
*/
|
|
44
|
+
export const makeInitMsg = initAction => {
|
|
45
|
+
const {
|
|
46
|
+
type,
|
|
47
|
+
blockHeight,
|
|
48
|
+
blockTime,
|
|
49
|
+
chainID,
|
|
50
|
+
params,
|
|
51
|
+
// NB: resolvedConfig is independent of consensus and MUST NOT be included
|
|
52
|
+
supplyCoins,
|
|
53
|
+
} = initAction;
|
|
54
|
+
return {
|
|
55
|
+
type,
|
|
56
|
+
blockHeight,
|
|
57
|
+
blockTime,
|
|
58
|
+
chainID,
|
|
59
|
+
params,
|
|
60
|
+
supplyCoins,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-utils.d.ts","sourceRoot":"","sources":["cli-utils.js"],"names":[],"mappings":"AAUO,qCAJI,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,GAErD,MAAM,EAAE,CAYjB"}
|
package/src/cli-utils.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a string-keyed object into an array of CLI options, using each key as
|
|
3
|
+
* the name of a GNU-style long option `--${key}`, ignoring each key with an
|
|
4
|
+
* undefined value and converting boolean values into no-argument `--${key}` or
|
|
5
|
+
* `--no-${key}` options.
|
|
6
|
+
*
|
|
7
|
+
* @param {Record<string, undefined | boolean | string | string[]>} record -
|
|
8
|
+
* e.g. { color: 'blue' }
|
|
9
|
+
* @returns {string[]} - e.g. ['--color', 'blue']
|
|
10
|
+
*/
|
|
11
|
+
export const toCLIOptions = record =>
|
|
12
|
+
Object.entries(record).flatMap(([key, value]) => {
|
|
13
|
+
if (value === undefined) return [];
|
|
14
|
+
if (value === true) return [`--${key}`];
|
|
15
|
+
if (value === false) return [`--no-${key}`];
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
// Represent as a repeated option.
|
|
18
|
+
return value.flatMap(v => [`--${key}`, v]);
|
|
19
|
+
}
|
|
20
|
+
return [`--${key}`, value];
|
|
21
|
+
});
|
package/src/config.d.ts
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event source ids used by the bridge device.
|
|
3
|
+
*/
|
|
4
|
+
export type BridgeId = (typeof BridgeId)[keyof typeof BridgeId];
|
|
1
5
|
export namespace BridgeId {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
let BANK: "bank";
|
|
7
|
+
let CORE: "core";
|
|
8
|
+
let DIBC: "dibc";
|
|
9
|
+
let STORAGE: "storage";
|
|
10
|
+
let PROVISION: "provision";
|
|
11
|
+
let PROVISION_SMART_WALLET: "provisionWallet";
|
|
12
|
+
let VLOCALCHAIN: "vlocalchain";
|
|
13
|
+
let VTRANSFER: "vtransfer";
|
|
14
|
+
let WALLET: "wallet";
|
|
15
|
+
}
|
|
16
|
+
export namespace CosmosInitKeyToBridgeId {
|
|
17
|
+
let vbankPort: "bank";
|
|
18
|
+
let vibcPort: "dibc";
|
|
9
19
|
}
|
|
10
20
|
export namespace WalletName {
|
|
11
|
-
|
|
21
|
+
let depositFacet: "depositFacet";
|
|
12
22
|
}
|
|
13
23
|
export namespace VBankAccount {
|
|
14
24
|
namespace reserve {
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
let module: "vbank/reserve";
|
|
26
|
+
let address: "agoric1ae0lmtzlgrcnla9xjkpaarq5d5dfez63h3nucl";
|
|
17
27
|
}
|
|
18
28
|
namespace provision {
|
|
19
|
-
|
|
29
|
+
let module_1: "vbank/provision";
|
|
20
30
|
export { module_1 as module };
|
|
21
|
-
|
|
31
|
+
let address_1: "agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346";
|
|
22
32
|
export { address_1 as address };
|
|
23
33
|
}
|
|
24
34
|
}
|
package/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.js"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.js"],"names":[],"mappings":";;;uBAkBU,CAAC,OAAO,QAAQ,EAAE,MAAM,OAAO,QAAQ,CAAC"}
|
package/src/config.js
CHANGED
|
@@ -4,34 +4,47 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @file
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Some of this config info may make more sense in a particular package. However
|
|
8
|
+
* due to https://github.com/Agoric/agoric-sdk/issues/4620 and our lax package
|
|
9
|
+
* dependency graph, sometimes rational placements cause type resolution
|
|
10
|
+
* errors.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
+
* So as a work-around some constants that need access from more than one
|
|
13
|
+
* package are placed here.
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Event source ids used by the bridge device.
|
|
18
|
+
*
|
|
19
|
+
* @enum {(typeof BridgeId)[keyof typeof BridgeId]}
|
|
16
20
|
*/
|
|
17
|
-
export const BridgeId = {
|
|
21
|
+
export const BridgeId = /** @type {const} */ ({
|
|
18
22
|
BANK: 'bank',
|
|
19
23
|
CORE: 'core',
|
|
20
24
|
DIBC: 'dibc',
|
|
21
25
|
STORAGE: 'storage',
|
|
22
26
|
PROVISION: 'provision',
|
|
23
27
|
PROVISION_SMART_WALLET: 'provisionWallet',
|
|
28
|
+
VLOCALCHAIN: 'vlocalchain',
|
|
29
|
+
VTRANSFER: 'vtransfer',
|
|
24
30
|
WALLET: 'wallet',
|
|
25
|
-
};
|
|
31
|
+
});
|
|
26
32
|
harden(BridgeId);
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
/** @satisfies {Record<string, BridgeId>} */
|
|
35
|
+
export const CosmosInitKeyToBridgeId = {
|
|
36
|
+
vbankPort: 'bank',
|
|
37
|
+
vibcPort: 'dibc',
|
|
30
38
|
};
|
|
39
|
+
harden(CosmosInitKeyToBridgeId);
|
|
40
|
+
|
|
41
|
+
export const WalletName = /** @type {const} */ ({
|
|
42
|
+
depositFacet: 'depositFacet',
|
|
43
|
+
});
|
|
31
44
|
harden(WalletName);
|
|
32
45
|
|
|
33
46
|
// defined in golang/cosmos/x/vbank
|
|
34
|
-
export const VBankAccount = {
|
|
47
|
+
export const VBankAccount = /** @type {const} */ ({
|
|
35
48
|
reserve: {
|
|
36
49
|
module: 'vbank/reserve',
|
|
37
50
|
address: 'agoric1ae0lmtzlgrcnla9xjkpaarq5d5dfez63h3nucl',
|
|
@@ -40,5 +53,5 @@ export const VBankAccount = {
|
|
|
40
53
|
module: 'vbank/provision',
|
|
41
54
|
address: 'agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346',
|
|
42
55
|
},
|
|
43
|
-
};
|
|
56
|
+
});
|
|
44
57
|
harden(VBankAccount);
|
package/src/debug.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function makeTracer(name: string, enable?: boolean |
|
|
1
|
+
export function makeTracer(name: string, enable?: boolean | "verbose"): (..._args: any[]) => void;
|
|
2
2
|
//# sourceMappingURL=debug.d.ts.map
|
package/src/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["errors.js"],"names":[],"mappings":"AAQO,2BALM,CAAC,OACH,CAAC,GAAG,IAAI,GAAG,SAAS,eACpB,MAAM,GACJ,CAAC,CAQb"}
|
package/src/errors.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { q } from '@endo/errors';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @template T
|
|
5
|
+
* @param {T | null | undefined} val
|
|
6
|
+
* @param {string} [optDetails]
|
|
7
|
+
* @returns {T}
|
|
8
|
+
*/
|
|
9
|
+
export const NonNullish = (val, optDetails = `unexpected ${q(val)}`) => {
|
|
10
|
+
if (val != null) {
|
|
11
|
+
// This `!= null` idiom checks that `val` is neither `null` nor `undefined`.
|
|
12
|
+
return val;
|
|
13
|
+
}
|
|
14
|
+
assert.fail(optDetails);
|
|
15
|
+
};
|
|
16
|
+
harden(NonNullish);
|
package/src/hex.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function makePortableHexCodec(): HexCodec;
|
|
2
|
+
export function makeBufferishHexCodec(Bufferish: BufferishConstructor): HexCodec;
|
|
3
|
+
export const encodeHex: (buf: Uint8Array) => string;
|
|
4
|
+
export const decodeHex: (hex: string) => Uint8Array;
|
|
5
|
+
export type HexCodec = {
|
|
6
|
+
encodeHex: (buf: Uint8Array) => string;
|
|
7
|
+
decodeHex: (hex: string) => Uint8Array;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* is the portion of the Node.js Buffer API we need for hex conversion.
|
|
11
|
+
*/
|
|
12
|
+
export type BufferishConstructor = Pick<BufferConstructor, "from" | "isBuffer"> & {
|
|
13
|
+
prototype: Pick<Buffer, "toString"> & Uint8Array;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=hex.d.ts.map
|
package/src/hex.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["hex.js"],"names":[],"mappings":"AAsCO,wCAFM,QAAQ,CAyBpB;AAgBM,iDAJI,oBAAoB,GAElB,QAAQ,CAoBpB;8BA7FmB,UAAU,KAAK,MAAM;8BACrB,MAAM,KAAK,UAAU;;eAD3B,CAAC,GAAG,EAAE,UAAU,KAAK,MAAM;eAC3B,CAAC,GAAG,EAAE,MAAM,KAAK,UAAU;;;;;mCA6D5B,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG;IACvD,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,UAAU,CAAC;CAClD"}
|