@agoric/vats 0.15.2-dev-81a66f2.0 → 0.15.2-dev-e468caa.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/vats",
3
- "version": "0.15.2-dev-81a66f2.0+81a66f2",
3
+ "version": "0.15.2-dev-e468caa.0+e468caa",
4
4
  "description": "Agoric's Vat library",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -22,18 +22,19 @@
22
22
  "author": "Agoric",
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@agoric/assert": "0.6.1-dev-81a66f2.0+81a66f2",
26
- "@agoric/ertp": "0.16.3-dev-81a66f2.0+81a66f2",
27
- "@agoric/governance": "0.10.4-dev-81a66f2.0+81a66f2",
28
- "@agoric/internal": "0.3.3-dev-81a66f2.0+81a66f2",
29
- "@agoric/network": "0.1.1-dev-81a66f2.0+81a66f2",
30
- "@agoric/notifier": "0.6.3-dev-81a66f2.0+81a66f2",
31
- "@agoric/store": "0.9.3-dev-81a66f2.0+81a66f2",
32
- "@agoric/swingset-vat": "0.32.3-dev-81a66f2.0+81a66f2",
33
- "@agoric/time": "0.3.3-dev-81a66f2.0+81a66f2",
34
- "@agoric/vat-data": "0.5.3-dev-81a66f2.0+81a66f2",
35
- "@agoric/zoe": "0.26.3-dev-81a66f2.0+81a66f2",
36
- "@agoric/zone": "0.2.3-dev-81a66f2.0+81a66f2",
25
+ "@agoric/assert": "0.6.1-dev-e468caa.0+e468caa",
26
+ "@agoric/cosmic-proto": "0.4.1-dev-e468caa.0+e468caa",
27
+ "@agoric/ertp": "0.16.3-dev-e468caa.0+e468caa",
28
+ "@agoric/governance": "0.10.4-dev-e468caa.0+e468caa",
29
+ "@agoric/internal": "0.3.3-dev-e468caa.0+e468caa",
30
+ "@agoric/network": "0.1.1-dev-e468caa.0+e468caa",
31
+ "@agoric/notifier": "0.6.3-dev-e468caa.0+e468caa",
32
+ "@agoric/store": "0.9.3-dev-e468caa.0+e468caa",
33
+ "@agoric/swingset-vat": "0.32.3-dev-e468caa.0+e468caa",
34
+ "@agoric/time": "0.3.3-dev-e468caa.0+e468caa",
35
+ "@agoric/vat-data": "0.5.3-dev-e468caa.0+e468caa",
36
+ "@agoric/zoe": "0.26.3-dev-e468caa.0+e468caa",
37
+ "@agoric/zone": "0.2.3-dev-e468caa.0+e468caa",
37
38
  "@endo/far": "^1.1.1",
38
39
  "@endo/import-bundle": "^1.1.1",
39
40
  "@endo/marshal": "^1.4.1",
@@ -44,7 +45,7 @@
44
45
  "jessie.js": "^0.3.4"
45
46
  },
46
47
  "devDependencies": {
47
- "@agoric/swingset-liveslots": "0.10.3-dev-81a66f2.0+81a66f2",
48
+ "@agoric/swingset-liveslots": "0.10.3-dev-e468caa.0+e468caa",
48
49
  "@endo/bundle-source": "^3.2.2",
49
50
  "@endo/init": "^1.1.1",
50
51
  "ava": "^5.3.0",
@@ -77,5 +78,5 @@
77
78
  "typeCoverage": {
78
79
  "atLeast": 89.58
79
80
  },
80
- "gitHead": "81a66f2f88ba213ace95a598e9ef1f95b0ff9e39"
81
+ "gitHead": "e468caafe7b1bb0a4b105d2acadb30874c5c30d5"
81
82
  }
package/src/ibc.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export function prepareIBCConnectionHandler(zone: import('@agoric/base-zone').Zone): (args_0?: any, args_1?: any) => import("@endo/exo").Guarded<{
1
+ export function prepareIBCConnectionHandler(zone: Zone): (args_0?: any, args_1?: any) => import("@endo/exo").Guarded<{
2
2
  onOpen(conn: any, localAddr: any, remoteAddr: any, _handler: any): Promise<void>;
3
3
  /**
4
4
  * @param {Connection} _conn
@@ -13,15 +13,12 @@ export function prepareIBCConnectionHandler(zone: import('@agoric/base-zone').Zo
13
13
  }): PromiseVow<Bytes>;
14
14
  onClose(_conn: any, _reason: any, _handler: any): Promise<void>;
15
15
  }>;
16
- export function prepareIBCProtocol(zone: import('@agoric/base-zone').Zone, powers: ReturnType<(zone: import("@agoric/base-zone").Zone, powers?: {
17
- isRetryableReason?: ((reason: any) => boolean) | undefined;
18
- watchPromise?: ((p: PromiseLike<any>, watcher: import("@agoric/vow/src/watch-promise.js").PromiseWatcher, ...args: unknown[]) => void) | undefined;
19
- } | undefined) => {
16
+ export function prepareIBCProtocol(zone: Zone, powers: {
20
17
  when: <T, TResult1 = import("@agoric/vow").Unwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("@agoric/vow").Unwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
21
18
  watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = T_1>(specimenP: import("@agoric/vow").ERef<T_1 | import("@agoric/vow").Vow<T_1>>, watcher?: import("@agoric/vow").Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: unknown) => import("@agoric/vow").Vow<TResult1_1 | TResult2_1>;
22
- makeVowKit: <T_2>() => import("@agoric/vow").VowKit<T_2>;
19
+ makeVowKit: <T_2>() => VowKit<T_2>;
23
20
  allVows: (vows: any) => import("@agoric/vow").Vow<any>;
24
- }>): (ibcdev: any) => {
21
+ }): (ibcdev: any) => {
25
22
  protocolHandler: ProtocolHandler;
26
23
  bridgeHandler: BridgeHandler;
27
24
  } | {
@@ -39,38 +36,24 @@ export function prepareIBCProtocol(zone: import('@agoric/base-zone').Zone, power
39
36
  fromBridge(obj: any): Promise<import("@agoric/vow").Vow<any> | undefined>;
40
37
  }>;
41
38
  };
42
- export function prepareCallbacks(zone: import('@agoric/base-zone').Zone): (dibcBridgeManager: import("@agoric/vats").ScopedBridgeManager) => import("@endo/exo").Guarded<{
39
+ export function prepareCallbacks(zone: Zone): (dibcBridgeManager: ScopedBridgeManager) => import("@endo/exo").Guarded<{
43
40
  downcall(method: any, obj: any): Promise<any>;
44
41
  }>;
45
- export type IBCPortID = string;
46
- export type IBCChannelID = string;
47
- export type IBCConnectionID = string;
48
- export type IBCPacket = {
49
- data?: string | undefined;
50
- source_channel: IBCChannelID;
51
- source_port: IBCPortID;
52
- destination_channel: IBCChannelID;
53
- destination_port: IBCPortID;
42
+ export type OnConnectP = {
43
+ vow: import("@agoric/vow").Vow<AttemptDescription>;
44
+ resolver: VowResolver<AttemptDescription>;
54
45
  };
55
- export type Counterparty = {
56
- port_id: string;
57
- channel_id: string;
58
- };
59
- export type ConnectingInfo = {
60
- order: 'ORDERED' | 'UNORDERED';
61
- connectionHops: string[];
62
- portID: string;
63
- channelID: string;
64
- counterparty: Counterparty;
65
- version: string;
66
- };
67
- export type OnConnectP = import('@agoric/vow').VowKit<AttemptDescription>;
68
- export type Outbound = Omit<ConnectingInfo, 'counterparty' | 'channelID'> & {
46
+ export type Outbound = Omit<ConnectingInfo, "counterparty" | "channelID" | "counterpartyVersion"> & {
69
47
  localAddr: Endpoint;
70
48
  onConnectP: OnConnectP;
71
49
  counterparty: {
72
50
  port_id: string;
73
51
  };
74
52
  };
53
+ import type { Zone } from '@agoric/base-zone';
54
+ import type { VowKit } from '@agoric/vow';
75
55
  import type { BridgeHandler } from './types.js';
56
+ import type { ScopedBridgeManager } from './types.js';
57
+ import type { VowResolver } from '@agoric/vow';
58
+ import type { ConnectingInfo } from './types.js';
76
59
  //# sourceMappingURL=ibc.d.ts.map
package/src/ibc.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ibc.d.ts","sourceRoot":"","sources":["ibc.js"],"names":[],"mappings":"AA2DO,kDADK,OAAO,mBAAmB,EAAE,IAAI;;IA+CtC;;;;;;;OAOG;qBANQ,UAAU,eACV,KAAK,YACL,iBAAiB;QAEF,iBAAiB;QAC9B,WAAW,KAAK,CAAC;;GA6CnC;AAMM,yCAHI,OAAO,mBAAmB,EAAE,IAAI,UAChC;;;;;;;;EAAiD;qBAgBlC,eAAe;;;;;;;;;;;;;;;;EAsmBxC;AAKM,uCADK,OAAO,mBAAmB,EAAE,IAAI;;GAkB3C;wBAxxBY,MAAM;2BAEN,MAAM;8BAEN,MAAM;;;oBAML,YAAY;iBACZ,SAAS;yBACT,YAAY;sBACZ,SAAS;;;aAKT,MAAM;gBACN,MAAM;;;WAGN,SAAS,GAAG,WAAW;oBACvB,MAAM,EAAE;YACR,MAAM;eACN,MAAM;kBACN,YAAY;aACZ,MAAM;;yBAEP,OAAO,aAAa,EAAE,MAAM,CAAC,kBAAkB,CAAC;uBAEhD,KAAK,cAAc,EAAE,cAAc,GAAG,WAAW,CAAC,GAAG;IACjE,SAAa,EAAE,QAAQ,CAAC;IACxB,UAAc,EAAE,UAAU,CAAC;IAC3B,YAAgB,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACnC;mCAtC6B,YAAY"}
1
+ {"version":3,"file":"ibc.d.ts","sourceRoot":"","sources":["ibc.js"],"names":[],"mappings":"AAqCO;;IA8CD;;;;;;;OAOG;qBANQ,UAAU,eACV,KAAK,YACL,iBAAiB;QAEF,iBAAiB;QAC9B,WAAW,KAAK,CAAC;;GA8CnC;AAMM;;;;;;qBAcmB,eAAe;;;;;;;;;;;;;;;;EAumBxC;AAKM;;GAiBN;;;;;;eA1vBe,QAAQ;gBACP,UAAU;kBACR;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;;0BAbf,mBAAmB;4BACc,aAAa;mCAFqH,YAAY;yCAAZ,YAAY;iCAE9I,aAAa;oCAFqH,YAAY"}
package/src/ibc.js CHANGED
@@ -15,55 +15,33 @@ const DEFAULT_ACKNOWLEDGEMENT = '\x00';
15
15
  // Default timeout after 60 minutes.
16
16
  const DEFAULT_PACKET_TIMEOUT_NS = 60n * 60n * 1_000_000_000n;
17
17
 
18
- /** @import {BridgeHandler} from './types.js' */
19
-
20
- /**
21
- * @typedef {string} IBCPortID
22
- *
23
- * @typedef {string} IBCChannelID
24
- *
25
- * @typedef {string} IBCConnectionID
26
- */
27
-
28
18
  /**
29
- * @typedef {object} IBCPacket
30
- * @property {Bytes} [data]
31
- * @property {IBCChannelID} source_channel
32
- * @property {IBCPortID} source_port
33
- * @property {IBCChannelID} destination_channel
34
- * @property {IBCPortID} destination_port
19
+ * @import {BridgeHandler, ScopedBridgeManager, ConnectingInfo, IBCChannelID, IBCChannelOrdering, IBCEvent, IBCPacket, IBCPortID, IBCDowncall, IBCDowncallPacket, IBCDowncallMethod} from './types.js';
20
+ * @import {Zone} from '@agoric/base-zone';
21
+ * @import {Remote, VowKit, VowResolver, VowTools} from '@agoric/vow';
35
22
  */
36
23
 
37
24
  /**
38
- * @typedef {object} Counterparty
39
- * @property {string} port_id
40
- * @property {string} channel_id
41
- *
42
- * @typedef {object} ConnectingInfo
43
- * @property {'ORDERED' | 'UNORDERED'} order
44
- * @property {string[]} connectionHops
45
- * @property {string} portID
46
- * @property {string} channelID
47
- * @property {Counterparty} counterparty
48
- * @property {string} version
49
- *
50
- * @typedef {import('@agoric/vow').VowKit<AttemptDescription>} OnConnectP
25
+ * @typedef {VowKit<AttemptDescription>} OnConnectP
51
26
  *
52
- * @typedef {Omit<ConnectingInfo, 'counterparty' | 'channelID'> & {
27
+ * @typedef {Omit<
28
+ * ConnectingInfo,
29
+ * 'counterparty' | 'channelID' | 'counterpartyVersion'
30
+ * > & {
53
31
  * localAddr: Endpoint;
54
32
  * onConnectP: OnConnectP;
55
33
  * counterparty: { port_id: string };
56
34
  * }} Outbound
57
35
  */
58
36
 
59
- /** @param {import('@agoric/base-zone').Zone} zone */
37
+ /** @param {Zone} zone */
60
38
  export const prepareIBCConnectionHandler = zone => {
61
39
  /**
62
- * @param {string} channelID
63
- * @param {string} portID
64
- * @param {string} rChannelID
65
- * @param {string} rPortID
66
- * @param {'ORDERED' | 'UNORDERED'} order
40
+ * @param {IBCChannelID} channelID
41
+ * @param {IBCPortID} portID
42
+ * @param {IBCChannelID} rChannelID
43
+ * @param {IBCPortID} rPortID
44
+ * @param {IBCChannelOrdering} order
67
45
  * @returns {ConnectionHandler}
68
46
  */
69
47
  const makeIBCConnectionHandler = zone.exoClass(
@@ -120,6 +98,7 @@ export const prepareIBCConnectionHandler = zone => {
120
98
  const { portID, channelID, rPortID, rChannelID } = this.state;
121
99
  const { protocolUtils } = this.state;
122
100
  // console.error(`Remote IBC Handler ${portID} ${channelID}`);
101
+ /** @type {IBCPacket} */
123
102
  const packet = {
124
103
  source_port: portID,
125
104
  source_channel: channelID,
@@ -157,8 +136,8 @@ export const prepareIBCConnectionHandler = zone => {
157
136
  };
158
137
 
159
138
  /**
160
- * @param {import('@agoric/base-zone').Zone} zone
161
- * @param {ReturnType<import('@agoric/vow').prepareVowTools>} powers
139
+ * @param {Zone} zone
140
+ * @param {VowTools} powers
162
141
  */
163
142
  export const prepareIBCProtocol = (zone, powers) => {
164
143
  const { makeVowKit, watch } = powers;
@@ -194,37 +173,22 @@ export const prepareIBCProtocol = (zone, powers) => {
194
173
  'IBCProtocolHandler',
195
174
  undefined,
196
175
  ibcdev => {
197
- /** @type {MapStore<string, import('@agoric/vow').Remote<Connection>>} */
176
+ /** @type {MapStore<string, Remote<Connection>>} */
198
177
  const channelKeyToConnP = detached.mapStore('channelKeyToConnP');
199
178
 
200
179
  /** @type {MapStore<string, ConnectingInfo>} */
201
180
  const channelKeyToInfo = detached.mapStore('channelKeyToInfo');
202
181
 
203
- /**
204
- * @type {MapStore<
205
- * string,
206
- * import('@agoric/vow').Remote<InboundAttempt>
207
- * >}
208
- */
182
+ /** @type {MapStore<string, Remote<InboundAttempt>>} */
209
183
  const channelKeyToAttempt = detached.mapStore('channelKeyToAttempt');
210
184
 
211
185
  /** @type {MapStore<string, Outbound[]>} */
212
186
  const srcPortToOutbounds = detached.mapStore('srcPortToOutbounds');
213
187
 
214
- /**
215
- * @type {MapStore<
216
- * string,
217
- * MapStore<number, import('@agoric/vow').VowKit<Bytes>>
218
- * >}
219
- */
188
+ /** @type {MapStore<string, MapStore<number, VowKit<Bytes>>>} */
220
189
  const channelKeyToSeqAck = detached.mapStore('channelKeyToSeqAck');
221
190
 
222
- /**
223
- * @type {MapStore<
224
- * string,
225
- * SetStore<import('@agoric/vow').VowResolver>
226
- * >}
227
- */
191
+ /** @type {MapStore<string, SetStore<VowResolver>>} */
228
192
  const portToPendingConns = detached.mapStore('portToPendingConns');
229
193
 
230
194
  return {
@@ -236,7 +200,7 @@ export const prepareIBCProtocol = (zone, powers) => {
236
200
  channelKeyToSeqAck,
237
201
  portToPendingConns,
238
202
  lastPortID: 0n, // Nonce for creating port identifiers.
239
- /** @type {import('@agoric/vow').Remote<ProtocolImpl> | null} */
203
+ /** @type {Remote<ProtocolImpl> | null} */
240
204
  protocolImpl: null,
241
205
  };
242
206
  },
@@ -304,7 +268,9 @@ export const prepareIBCProtocol = (zone, powers) => {
304
268
  }
305
269
 
306
270
  // Generate a circuit.
271
+ /** @type {IBCPortID} */
307
272
  const rPortID = match[2];
273
+ /** @type {IBCChannelOrdering} */
308
274
  const order = match[3] === 'ordered' ? 'ORDERED' : 'UNORDERED';
309
275
  const version = match[4];
310
276
 
@@ -329,6 +295,7 @@ export const prepareIBCProtocol = (zone, powers) => {
329
295
  }
330
296
 
331
297
  // Initialise the channel, which a listening relayer should pick up.
298
+ /** @type {IBCDowncallPacket<'startChannelOpenInit'>} */
332
299
  const packet = {
333
300
  source_port: portID,
334
301
  destination_port: rPortID,
@@ -381,6 +348,7 @@ export const prepareIBCProtocol = (zone, powers) => {
381
348
  await null;
382
349
  switch (obj.event) {
383
350
  case 'channelOpenInit': {
351
+ /** @type {IBCEvent<'channelOpenInit'>} */
384
352
  const {
385
353
  channelID,
386
354
  portID,
@@ -413,6 +381,7 @@ export const prepareIBCProtocol = (zone, powers) => {
413
381
  }
414
382
  case 'channelOpenTry': {
415
383
  // They're (more or less politely) asking if we are listening, so make an attempt.
384
+ /** @type {IBCEvent<'channelOpenTry'>} */
416
385
  const {
417
386
  portID,
418
387
  counterparty: { port_id: rPortID, channel_id: rChannelID },
@@ -451,6 +420,7 @@ export const prepareIBCProtocol = (zone, powers) => {
451
420
 
452
421
  case 'channelOpenAck': {
453
422
  // Complete the pending outbound connection.
423
+ /** @type {IBCEvent<'channelOpenAck'>} */
454
424
  const {
455
425
  portID,
456
426
  channelID,
@@ -516,6 +486,7 @@ export const prepareIBCProtocol = (zone, powers) => {
516
486
  }
517
487
 
518
488
  case 'channelOpenConfirm': {
489
+ /** @type {IBCEvent<'channelOpenConfirm'>} */
519
490
  const { portID, channelID } = obj;
520
491
  const channelKey = `${channelID}:${portID}`;
521
492
  channelKeyToAttempt.has(channelKey) ||
@@ -554,6 +525,7 @@ export const prepareIBCProtocol = (zone, powers) => {
554
525
  }
555
526
 
556
527
  case 'receivePacket': {
528
+ /** @type {IBCEvent<'receivePacket'>} */
557
529
  const { packet } = obj;
558
530
  const {
559
531
  data: data64,
@@ -570,6 +542,7 @@ export const prepareIBCProtocol = (zone, powers) => {
570
542
  }
571
543
 
572
544
  case 'acknowledgementPacket': {
545
+ /** @type {IBCEvent<'acknowledgementPacket'>} */
573
546
  const { packet, acknowledgement } = obj;
574
547
  const {
575
548
  sequence,
@@ -582,6 +555,7 @@ export const prepareIBCProtocol = (zone, powers) => {
582
555
  }
583
556
 
584
557
  case 'timeoutPacket': {
558
+ /** @type {IBCEvent<'timeoutPacket'>} */
585
559
  const { packet } = obj;
586
560
  const {
587
561
  sequence,
@@ -606,6 +580,7 @@ export const prepareIBCProtocol = (zone, powers) => {
606
580
  }
607
581
 
608
582
  case 'sendPacket': {
583
+ /** @type {IBCEvent<'sendPacket'>} */
609
584
  const { packet, relativeTimeoutNs } = obj;
610
585
  util.ibcSendPacket(packet, relativeTimeoutNs).then(
611
586
  ack => console.info('Manual packet', packet, 'acked:', ack),
@@ -621,6 +596,11 @@ export const prepareIBCProtocol = (zone, powers) => {
621
596
  },
622
597
  },
623
598
  util: {
599
+ /**
600
+ * @template {IBCDowncallMethod} M
601
+ * @param {M} method
602
+ * @param {IBCDowncall<M>} args
603
+ */
624
604
  downcall(method, args) {
625
605
  return E(this.state.ibcdev).downcall(method, args);
626
606
  },
@@ -649,7 +629,7 @@ export const prepareIBCProtocol = (zone, powers) => {
649
629
  source_port: portID,
650
630
  } = fullPacket;
651
631
 
652
- /** @type {import('@agoric/vow').VowKit<Bytes>} */
632
+ /** @type {VowKit<Bytes>} */
653
633
  const { vow } = util.findAckKit(channelID, portID, sequence);
654
634
  return vow;
655
635
  },
@@ -792,12 +772,12 @@ export const prepareIBCProtocol = (zone, powers) => {
792
772
 
793
773
  harden(prepareIBCProtocol);
794
774
 
795
- /** @param {import('@agoric/base-zone').Zone} zone */
775
+ /** @param {Zone} zone */
796
776
  export const prepareCallbacks = zone => {
797
777
  return zone.exoClass(
798
778
  'callbacks',
799
779
  undefined,
800
- /** @param {import('@agoric/vats').ScopedBridgeManager} dibcBridgeManager */
780
+ /** @param {ScopedBridgeManager} dibcBridgeManager */
801
781
  dibcBridgeManager => ({ dibcBridgeManager }),
802
782
  {
803
783
  downcall(method, obj) {
@@ -44,39 +44,40 @@ export function prepareLocalChainTools(zone: import('@agoric/base-zone').Zone):
44
44
  */
45
45
  deposit(payment: Payment): Promise<globalThis.Amount<globalThis.AssetKind>>;
46
46
  /**
47
- * @param {Proto3Jsonable[]} messages
48
- * @returns {Promise<Proto3Jsonable[]>}
47
+ * @param {import('@agoric/cosmic-proto').TypedJson<unknown>[]} messages
48
+ * @returns {Promise<import('@agoric/cosmic-proto').TypedJson[]>}
49
49
  */
50
- executeTx(messages: Proto3Jsonable[]): Promise<Proto3Jsonable[]>;
50
+ executeTx(messages: import('@agoric/cosmic-proto').TypedJson<unknown>[]): Promise<import('@agoric/cosmic-proto').TypedJson[]>;
51
51
  }>>;
52
52
  /**
53
53
  * Make a single query to the local chain. Will reject with an error if
54
54
  * the query fails. Otherwise, return the response as a JSON-compatible
55
55
  * object.
56
56
  *
57
- * @param {Proto3Jsonable} request
58
- * @returns {Promise<Proto3Jsonable>}
57
+ * @param {import('@agoric/cosmic-proto').TypedJson} request
58
+ * @returns {Promise<import('@agoric/cosmic-proto').TypedJson>}
59
59
  */
60
- query(request: Proto3Jsonable): Promise<Proto3Jsonable>;
60
+ query(request: import('@agoric/cosmic-proto').TypedJson): Promise<import('@agoric/cosmic-proto').TypedJson>;
61
61
  /**
62
62
  * Send a batch of query requests to the local chain. Unless there is a
63
63
  * system error, will return all results to indicate their success or
64
64
  * failure.
65
65
  *
66
- * @param {Proto3Jsonable[]} requests
67
- * @returns {Promise<{ error?: string; reply: Proto3Jsonable }[]>}
66
+ * @param {import('@agoric/cosmic-proto').TypedJson[]} requests
67
+ * @returns {Promise<
68
+ * {
69
+ * error?: string;
70
+ * reply: import('@agoric/cosmic-proto').TypedJson;
71
+ * }[]
72
+ * >}
68
73
  */
69
- queryMany(requests: Proto3Jsonable[]): Promise<{
74
+ queryMany(requests: import('@agoric/cosmic-proto').TypedJson[]): Promise<{
70
75
  error?: string;
71
- reply: Proto3Jsonable;
76
+ reply: import('@agoric/cosmic-proto').TypedJson;
72
77
  }[]>;
73
78
  };
74
79
  }>;
75
80
  };
76
- export type Proto3Jsonable = {
77
- '@type': string;
78
- [x: string]: unknown;
79
- };
80
81
  export type LocalChainPowers = {
81
82
  system: import('./types.js').ScopedBridgeManager;
82
83
  bankManager: import('./vat-bank.js').BankManager;
@@ -98,10 +99,10 @@ declare function prepareLocalChainAccount(zone: import('@agoric/base-zone').Zone
98
99
  */
99
100
  deposit(payment: Payment): Promise<globalThis.Amount<globalThis.AssetKind>>;
100
101
  /**
101
- * @param {Proto3Jsonable[]} messages
102
- * @returns {Promise<Proto3Jsonable[]>}
102
+ * @param {import('@agoric/cosmic-proto').TypedJson<unknown>[]} messages
103
+ * @returns {Promise<import('@agoric/cosmic-proto').TypedJson[]>}
103
104
  */
104
- executeTx(messages: Proto3Jsonable[]): Promise<Proto3Jsonable[]>;
105
+ executeTx(messages: import('@agoric/cosmic-proto').TypedJson<unknown>[]): Promise<import('@agoric/cosmic-proto').TypedJson[]>;
105
106
  }>;
106
107
  export {};
107
108
  //# sourceMappingURL=localchain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localchain.d.ts","sourceRoot":"","sources":["localchain.js"],"names":[],"mappings":"AAoCA;;;;GAMG;AAqDH;;;;GAIG;AAEH;;;;GAIG;AAEH;;GAEG;AAiGI,6CADK,OAAO,mBAAmB,EAAE,IAAI;;;YAzEpC;;;;eAIG;;;;YAgBH;;;;;eAKG;;;gBAlGL;;;;;;mBAMG;iCADQ,OAAO;gBAYlB;;;mBAGG;oCAFQ,cAAc,EAAE,GACd,QAAQ,cAAc,EAAE,CAAC;;YAwFpC;;;;;;;eAOG;2BAFQ,cAAc,GACZ,QAAQ,cAAc,CAAC;YAapC;;;;;;;eAOG;gCAFQ,cAAc,EAAE,GACd,QAAQ;gBAAE,KAAK,CAAC,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,cAAc,CAAA;aAAE,EAAE,CAAC;;;EAoBxE;6BA3MY;IACZ,OAAW,EAAE,MAAM,CAAC;IACpB,CAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;+BAIS;IACZ,MAAU,EAAE,OAAO,YAAY,EAAE,mBAAmB,CAAC;IACrD,WAAe,EAAE,OAAO,eAAe,EAAE,WAAW,CAAC;CAClD;yBAES,SACZ,MAAU,gBAAgB,EAC1B,gBAAoB,CAAC,MAAM,gBAAgB,CAAC,CACzC;gCAyES,QACZ,WAAe,QAAQ,WAAW,+BAA+B,CAAC,CAAC,CAAC,CACjE;8BAoHU,WAAW,6BAA6B,CAAC;4BACzC,WAAW,eAAe,CAAC,gBAAgB,CAAC,CAAC;yBAC7C,aAAa,CAAC,QAAQ,CAAC;AA5KrC,qDAAqD;AACrD,gDADY,OAAO,mBAAmB,EAAE,IAAI;;IAetC;;;;;;OAMG;qBADQ,OAAO;IAYlB;;;OAGG;wBAFQ,cAAc,EAAE,GACd,QAAQ,cAAc,EAAE,CAAC;GAgBzC"}
1
+ {"version":3,"file":"localchain.d.ts","sourceRoot":"","sources":["localchain.js"],"names":[],"mappings":"AA6BA;;;;GAMG;AAuDH;;;;GAIG;AAEH;;;;GAIG;AAEH;;GAEG;AAsGI,6CADK,OAAO,mBAAmB,EAAE,IAAI;;;YA9EpC;;;;eAIG;;;;YAgBH;;;;;eAKG;;;gBApGL;;;;;;mBAMG;iCADQ,OAAO;gBAYlB;;;mBAGG;oCAFQ,OAAO,sBAAsB,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,GACjD,QAAQ,OAAO,sBAAsB,EAAE,SAAS,EAAE,CAAC;;YA0F9D;;;;;;;eAOG;2BAFQ,OAAO,sBAAsB,EAAE,SAAS,GACtC,QAAQ,OAAO,sBAAsB,EAAE,SAAS,CAAC;YAa9D;;;;;;;;;;;;eAYG;gCAPQ,OAAO,sBAAsB,EAAE,SAAS,EAAE,GACxC,QACZ;gBACA,KAAW,CAAC,EAAE,MAAM,CAAC;gBACrB,KAAW,EAAE,OAAO,sBAAsB,EAAE,SAAS,CAAC;aACjD,EAAE,CACJ;;;EAoBX;+BA3MY;IACZ,MAAU,EAAE,OAAO,YAAY,EAAE,mBAAmB,CAAC;IACrD,WAAe,EAAE,OAAO,eAAe,EAAE,WAAW,CAAC;CAClD;yBAES,SACZ,MAAU,gBAAgB,EAC1B,gBAAoB,CAAC,MAAM,gBAAgB,CAAC,CACzC;gCA2ES,QACZ,WAAe,QAAQ,WAAW,+BAA+B,CAAC,CAAC,CAAC,CACjE;8BAyHU,WAAW,6BAA6B,CAAC;4BACzC,WAAW,eAAe,CAAC,gBAAgB,CAAC,CAAC;yBAC7C,aAAa,CAAC,QAAQ,CAAC;AAnLrC,qDAAqD;AACrD,gDADY,OAAO,mBAAmB,EAAE,IAAI;;IAetC;;;;;;OAMG;qBADQ,OAAO;IAYlB;;;OAGG;wBAFQ,OAAO,sBAAsB,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,GACjD,QAAQ,OAAO,sBAAsB,EAAE,SAAS,EAAE,CAAC;GAkBnE"}
package/src/localchain.js CHANGED
@@ -5,13 +5,6 @@ import { AmountShape } from '@agoric/ertp';
5
5
 
6
6
  const { Fail, bare } = assert;
7
7
 
8
- /**
9
- * @typedef {{
10
- * '@type': string;
11
- * [x: string]: unknown;
12
- * }} Proto3Jsonable
13
- */
14
-
15
8
  /**
16
9
  * @typedef {{
17
10
  * system: import('./types.js').ScopedBridgeManager;
@@ -75,11 +68,13 @@ const prepareLocalChainAccount = zone =>
75
68
  return E(allegedPurse).deposit(payment);
76
69
  },
77
70
  /**
78
- * @param {Proto3Jsonable[]} messages
79
- * @returns {Promise<Proto3Jsonable[]>}
71
+ * @param {import('@agoric/cosmic-proto').TypedJson<unknown>[]} messages
72
+ * @returns {Promise<import('@agoric/cosmic-proto').TypedJson[]>}
80
73
  */
81
74
  async executeTx(messages) {
82
75
  const { address, powers } = this.state;
76
+ messages.length > 0 || Fail`need at least one message to execute`;
77
+
83
78
  const obj = {
84
79
  type: 'VLOCALCHAIN_EXECUTE_TX',
85
80
  // This address is the only one that `VLOCALCHAIN_EXECUTE_TX` will
@@ -169,8 +164,8 @@ const prepareLocalChain = (zone, createAccount) =>
169
164
  * the query fails. Otherwise, return the response as a JSON-compatible
170
165
  * object.
171
166
  *
172
- * @param {Proto3Jsonable} request
173
- * @returns {Promise<Proto3Jsonable>}
167
+ * @param {import('@agoric/cosmic-proto').TypedJson} request
168
+ * @returns {Promise<import('@agoric/cosmic-proto').TypedJson>}
174
169
  */
175
170
  async query(request) {
176
171
  const requests = harden([request]);
@@ -188,8 +183,13 @@ const prepareLocalChain = (zone, createAccount) =>
188
183
  * system error, will return all results to indicate their success or
189
184
  * failure.
190
185
  *
191
- * @param {Proto3Jsonable[]} requests
192
- * @returns {Promise<{ error?: string; reply: Proto3Jsonable }[]>}
186
+ * @param {import('@agoric/cosmic-proto').TypedJson[]} requests
187
+ * @returns {Promise<
188
+ * {
189
+ * error?: string;
190
+ * reply: import('@agoric/cosmic-proto').TypedJson;
191
+ * }[]
192
+ * >}
193
193
  */
194
194
  async queryMany(requests) {
195
195
  const { powers } = this.state;
@@ -68,12 +68,24 @@ export type LocalChainVats = {
68
68
  createAccount(): Promise<import("@endo/exo").Guarded<{
69
69
  getAddress(): Promise<string>;
70
70
  deposit(payment: globalThis.Payment): Promise<globalThis.Amount<globalThis.AssetKind>>;
71
- executeTx(messages: import("../localchain.js").Proto3Jsonable[]): Promise<import("../localchain.js").Proto3Jsonable[]>;
71
+ executeTx(messages: {
72
+ '@type': string;
73
+ }[]): Promise<{
74
+ '@type': string;
75
+ }[]>;
72
76
  }>>;
73
- query(request: import("../localchain.js").Proto3Jsonable): Promise<import("../localchain.js").Proto3Jsonable>;
74
- queryMany(requests: import("../localchain.js").Proto3Jsonable[]): Promise<{
77
+ query(request: {
78
+ '@type': string;
79
+ }): Promise<{
80
+ '@type': string;
81
+ }>;
82
+ queryMany(requests: {
83
+ '@type': string;
84
+ }[]): Promise<{
75
85
  error?: string | undefined;
76
- reply: import("../localchain.js").Proto3Jsonable;
86
+ reply: {
87
+ '@type': string;
88
+ };
77
89
  }[]>;
78
90
  };
79
91
  }>;
@@ -86,12 +98,24 @@ export type LocalChainVats = {
86
98
  createAccount(): Promise<import("@endo/exo").Guarded<{
87
99
  getAddress(): Promise<string>;
88
100
  deposit(payment: globalThis.Payment): Promise<globalThis.Amount<globalThis.AssetKind>>;
89
- executeTx(messages: import("../localchain.js").Proto3Jsonable[]): Promise<import("../localchain.js").Proto3Jsonable[]>;
101
+ executeTx(messages: {
102
+ '@type': string;
103
+ }[]): Promise<{
104
+ '@type': string;
105
+ }[]>;
90
106
  }>>;
91
- query(request: import("../localchain.js").Proto3Jsonable): Promise<import("../localchain.js").Proto3Jsonable>;
92
- queryMany(requests: import("../localchain.js").Proto3Jsonable[]): Promise<{
107
+ query(request: {
108
+ '@type': string;
109
+ }): Promise<{
110
+ '@type': string;
111
+ }>;
112
+ queryMany(requests: {
113
+ '@type': string;
114
+ }[]): Promise<{
93
115
  error?: string | undefined;
94
- reply: import("../localchain.js").Proto3Jsonable;
116
+ reply: {
117
+ '@type': string;
118
+ };
95
119
  }[]>;
96
120
  };
97
121
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"localchain-test.d.ts","sourceRoot":"","sources":["localchain-test.js"],"names":[],"mappings":"AAYO,0EARI,eAAe,GAAG;IAC5B,OAAW,EAAE;QACb,UAAgB,EAAE,OAAO,kBAAkB,EAAE,UAAU,CAAC;KACnD,CAAC;CACH;IAE2C,OAAO,EAA3C;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;kBA2DpC;AAEM;;;;;;;;;;;;;;EAYL"}
1
+ {"version":3,"file":"localchain-test.d.ts","sourceRoot":"","sources":["localchain-test.js"],"names":[],"mappings":"AAaO,0EARI,eAAe,GAAG;IAC5B,OAAW,EAAE;QACb,UAAgB,EAAE,OAAO,kBAAkB,EAAE,UAAU,CAAC;KACnD,CAAC;CACH;IAE2C,OAAO,EAA3C;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;kBA4DpC;AAEM;;;;;;;;;;;;;;EAYL"}
@@ -1,5 +1,6 @@
1
1
  // @ts-check
2
2
  import { E } from '@endo/far';
3
+ import { typedJson } from '@agoric/cosmic-proto';
3
4
 
4
5
  /**
5
6
  * @param {BootstrapPowers & {
@@ -31,19 +32,20 @@ export const testLocalChain = async (
31
32
  console.info('created account', lca);
32
33
  const address = await E(lca).getAddress();
33
34
  console.info('address', address);
34
- const balances = await E(localchain).query({
35
- '@type': '/cosmos.bank.v1beta1.QueryAllBalancesRequest',
35
+
36
+ const queryMsg = typedJson('/cosmos.bank.v1beta1.QueryAllBalancesRequest', {
36
37
  address,
37
38
  });
39
+ const balances = await E(localchain).query(queryMsg);
38
40
  console.info('balances', balances);
41
+
39
42
  await E(lca)
40
43
  .executeTx([
41
- {
42
- '@type': '/cosmos.bank.v1beta1.MsgSend',
43
- from_address: address,
44
- to_address: address,
44
+ typedJson('/cosmos.bank.v1beta1.MsgSend', {
45
+ fromAddress: address,
46
+ toAddress: address,
45
47
  amount: [{ denom: 'ucosm', amount: '1' }],
46
- },
48
+ }),
47
49
  ])
48
50
  .then(
49
51
  res => console.info('unexpected executeTx result', res),
package/src/types.d.ts CHANGED
@@ -105,3 +105,140 @@ export type BridgeManager = {
105
105
  handler?: ERef<BridgeHandler | undefined>,
106
106
  ) => ScopedBridgeManager;
107
107
  };
108
+
109
+ export type IBCPortID = string;
110
+ export type IBCChannelID = `channel-${number}`;
111
+ export type IBCConnectionID = `connection-${number}`;
112
+ export type IBCChannelOrdering = 'ORDERED' | 'UNORDERED';
113
+
114
+ export type IBCPacket = {
115
+ data: Bytes;
116
+ source_channel: IBCChannelID;
117
+ source_port: IBCPortID;
118
+ destination_channel: IBCChannelID;
119
+ destination_port: IBCPortID;
120
+ sequence?: number;
121
+ timeout_height?: number;
122
+ timeout_timestamp?: number;
123
+ };
124
+
125
+ export type IBCCounterParty = {
126
+ port_id: IBCPortID;
127
+ channel_id: IBCChannelID;
128
+ };
129
+
130
+ export type ConnectingInfo = {
131
+ order: IBCChannelOrdering;
132
+ connectionHops: IBCConnectionID[];
133
+ portID: IBCPortID;
134
+ channelID: IBCChannelID;
135
+ counterparty: IBCCounterParty;
136
+ counterpartyVersion: string;
137
+ version: string;
138
+ asyncVersions?: boolean;
139
+ };
140
+
141
+ /** see [ibc_module.go](../../../golang/cosmos/x/vibc/types/ibc_module.go) */
142
+ type IBCBridgeEvent =
143
+ | 'channelOpenInit'
144
+ | 'channelOpenTry'
145
+ | 'channelOpenAck'
146
+ | 'channelOpenConfirm'
147
+ | 'receivePacket'
148
+ | 'acknowledgementPacket'
149
+ | 'timeoutPacket'
150
+ | 'channelCloseInit'
151
+ | 'channelCloseConfirm'
152
+ | 'sendPacket';
153
+
154
+ type IBCPacketEvents = {
155
+ channelOpenInit: ConnectingInfo;
156
+ channelOpenTry: ConnectingInfo;
157
+ channelOpenAck: ConnectingInfo;
158
+ channelOpenConfirm: ConnectingInfo;
159
+ receivePacket: {
160
+ packet: IBCPacket;
161
+ };
162
+ acknowledgementPacket: {
163
+ acknowledgement: Bytes;
164
+ packet: IBCPacket;
165
+ relayer: string; // chain address
166
+ };
167
+ timeoutPacket: {
168
+ packet: IBCPacket;
169
+ };
170
+ channelCloseInit: {}; // TODO update
171
+ channelCloseConfirm: {}; // TODO update
172
+ sendPacket: { relativeTimeoutNs: bigint; packet: IBCPacket };
173
+ };
174
+
175
+ export type IBCEvent<E extends IBCBridgeEvent> = {
176
+ type: 'IBC_EVENT';
177
+ blockHeight: number;
178
+ blockTime: number;
179
+ event: E;
180
+ } & {
181
+ [K in keyof IBCPacketEvents[E]]: IBCPacketEvents[E][K];
182
+ };
183
+
184
+ /** see [receiver.go](../../../golang/cosmos/x/vibc/types/receiver.go) */
185
+ type IBCDowncallMethod =
186
+ | 'sendPacket'
187
+ | 'tryOpenExecuted'
188
+ | 'receiveExecuted'
189
+ | 'startChannelOpenInit'
190
+ | 'startChannelCloseInit'
191
+ | 'bindPort'
192
+ | 'timeoutExecuted'
193
+ | 'initOpenExecuted';
194
+
195
+ type IBCMethodEvents = {
196
+ sendPacket: SendPacketDownCall;
197
+ tryOpenExecuted: ChannelOpenAckDowncall;
198
+ receiveExecuted: {}; // TODO update
199
+ startChannelOpenInit: ChannelOpenInitDowncall;
200
+ startChannelCloseInit: {}; // TODO update
201
+ bindPort: {}; // TODO update
202
+ timeoutExecuted: {}; // TODO update
203
+ // XXX why isn't this in receiver.go?
204
+ initOpenExecuted: ChannelOpenAckDowncall;
205
+ };
206
+
207
+ export type IBCMethod<M extends IBCDowncallMethod> = {
208
+ type: 'IBC_METHOD';
209
+ method: M;
210
+ } & {
211
+ [K in keyof IBCMethodEvents[M]]: IBCMethodEvents[M][K];
212
+ };
213
+
214
+ export type IBCDowncall<M extends IBCDowncallMethod> = {
215
+ [K in keyof IBCMethodEvents[M]]: IBCMethodEvents[M][K];
216
+ };
217
+
218
+ export type IBCDowncallPacket<M extends IBCDowncallMethod> =
219
+ IBCMethodEvents[M] extends { packet: infer P } ? P : never;
220
+
221
+ type ChannelOpenDowncallBase = {
222
+ hops: IBCConnectionID[];
223
+ order: IBCChannelOrdering;
224
+ version: string;
225
+ };
226
+
227
+ type ChannelOpenInitDowncall = ChannelOpenDowncallBase & {
228
+ packet: Pick<IBCPacket, 'destination_port' | 'source_port'>;
229
+ };
230
+
231
+ type ChannelOpenAckDowncall = ChannelOpenDowncallBase & {
232
+ packet: Pick<
233
+ IBCPacket,
234
+ | 'destination_port'
235
+ | 'source_port'
236
+ | 'destination_channel'
237
+ | 'source_channel'
238
+ >;
239
+ };
240
+
241
+ type SendPacketDownCall = {
242
+ packet: IBCPacket;
243
+ relativeTimeoutNs: bigint;
244
+ };
@@ -13,12 +13,24 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
13
13
  createAccount(): Promise<import("@endo/exo").Guarded<{
14
14
  getAddress(): Promise<string>;
15
15
  deposit(payment: globalThis.Payment): Promise<globalThis.Amount<globalThis.AssetKind>>;
16
- executeTx(messages: import("./localchain.js").Proto3Jsonable[]): Promise<import("./localchain.js").Proto3Jsonable[]>;
16
+ executeTx(messages: {
17
+ '@type': string;
18
+ }[]): Promise<{
19
+ '@type': string;
20
+ }[]>;
17
21
  }>>;
18
- query(request: import("./localchain.js").Proto3Jsonable): Promise<import("./localchain.js").Proto3Jsonable>;
19
- queryMany(requests: import("./localchain.js").Proto3Jsonable[]): Promise<{
22
+ query(request: {
23
+ '@type': string;
24
+ }): Promise<{
25
+ '@type': string;
26
+ }>;
27
+ queryMany(requests: {
28
+ '@type': string;
29
+ }[]): Promise<{
20
30
  error?: string | undefined;
21
- reply: import("./localchain.js").Proto3Jsonable;
31
+ reply: {
32
+ '@type': string;
33
+ };
22
34
  }[]>;
23
35
  };
24
36
  }>;
@@ -37,12 +49,24 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
37
49
  createAccount(): Promise<import("@endo/exo").Guarded<{
38
50
  getAddress(): Promise<string>;
39
51
  deposit(payment: globalThis.Payment): Promise<globalThis.Amount<globalThis.AssetKind>>;
40
- executeTx(messages: import("./localchain.js").Proto3Jsonable[]): Promise<import("./localchain.js").Proto3Jsonable[]>;
52
+ executeTx(messages: {
53
+ '@type': string;
54
+ }[]): Promise<{
55
+ '@type': string;
56
+ }[]>;
41
57
  }>>;
42
- query(request: import("./localchain.js").Proto3Jsonable): Promise<import("./localchain.js").Proto3Jsonable>;
43
- queryMany(requests: import("./localchain.js").Proto3Jsonable[]): Promise<{
58
+ query(request: {
59
+ '@type': string;
60
+ }): Promise<{
61
+ '@type': string;
62
+ }>;
63
+ queryMany(requests: {
64
+ '@type': string;
65
+ }[]): Promise<{
44
66
  error?: string | undefined;
45
- reply: import("./localchain.js").Proto3Jsonable;
67
+ reply: {
68
+ '@type': string;
69
+ };
46
70
  }[]>;
47
71
  };
48
72
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"vat-localchain.d.ts","sourceRoot":"","sources":["vat-localchain.js"],"names":[],"mappings":"AAMO;IAKH;;;;;OAKG;;;;;;;;;;;;;;;;;;;IALH;;;;;OAKG;;;;;;;;;;;;;;;;;;GAKN;4BAEa,WAAW,sBAAsB,CAAC"}
1
+ {"version":3,"file":"vat-localchain.d.ts","sourceRoot":"","sources":["vat-localchain.js"],"names":[],"mappings":"AAMO;IAKH;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IALH;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKN;4BAEa,WAAW,sBAAsB,CAAC"}