@agoric/vats 0.15.2-dev-0b1501a.0 → 0.15.2-dev-e3b41dc.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./src/types.js";
1
+ export * from "./src/types-index.js";
2
2
  export * from "./src/nameHub.js";
3
3
  export * from "./src/bridge.js";
4
4
  export { makePromiseSpace } from "./src/core/promise-space.js";
package/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import './src/core/types-ambient.js';
3
3
 
4
4
  // eslint-disable-next-line import/export -- no named exports
5
- export * from './src/types.js';
5
+ export * from './src/types-index.js';
6
6
  export * from './src/nameHub.js';
7
7
  export * from './src/bridge.js';
8
8
  export { makePromiseSpace } from './src/core/promise-space.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/vats",
3
- "version": "0.15.2-dev-0b1501a.0+0b1501a",
3
+ "version": "0.15.2-dev-e3b41dc.0+e3b41dc",
4
4
  "description": "Agoric's Vat library",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -22,19 +22,19 @@
22
22
  "author": "Agoric",
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@agoric/cosmic-proto": "0.4.1-dev-0b1501a.0+0b1501a",
26
- "@agoric/ertp": "0.16.3-dev-0b1501a.0+0b1501a",
27
- "@agoric/governance": "0.10.4-dev-0b1501a.0+0b1501a",
28
- "@agoric/internal": "0.3.3-dev-0b1501a.0+0b1501a",
29
- "@agoric/network": "0.1.1-dev-0b1501a.0+0b1501a",
30
- "@agoric/notifier": "0.6.3-dev-0b1501a.0+0b1501a",
31
- "@agoric/store": "0.9.3-dev-0b1501a.0+0b1501a",
32
- "@agoric/swingset-vat": "0.32.3-dev-0b1501a.0+0b1501a",
33
- "@agoric/time": "0.3.3-dev-0b1501a.0+0b1501a",
34
- "@agoric/vat-data": "0.5.3-dev-0b1501a.0+0b1501a",
35
- "@agoric/vow": "0.1.1-dev-0b1501a.0+0b1501a",
36
- "@agoric/zoe": "0.26.3-dev-0b1501a.0+0b1501a",
37
- "@agoric/zone": "0.2.3-dev-0b1501a.0+0b1501a",
25
+ "@agoric/cosmic-proto": "0.4.1-dev-e3b41dc.0+e3b41dc",
26
+ "@agoric/ertp": "0.16.3-dev-e3b41dc.0+e3b41dc",
27
+ "@agoric/governance": "0.10.4-dev-e3b41dc.0+e3b41dc",
28
+ "@agoric/internal": "0.3.3-dev-e3b41dc.0+e3b41dc",
29
+ "@agoric/network": "0.1.1-dev-e3b41dc.0+e3b41dc",
30
+ "@agoric/notifier": "0.6.3-dev-e3b41dc.0+e3b41dc",
31
+ "@agoric/store": "0.9.3-dev-e3b41dc.0+e3b41dc",
32
+ "@agoric/swingset-vat": "0.32.3-dev-e3b41dc.0+e3b41dc",
33
+ "@agoric/time": "0.3.3-dev-e3b41dc.0+e3b41dc",
34
+ "@agoric/vat-data": "0.5.3-dev-e3b41dc.0+e3b41dc",
35
+ "@agoric/vow": "0.1.1-dev-e3b41dc.0+e3b41dc",
36
+ "@agoric/zoe": "0.26.3-dev-e3b41dc.0+e3b41dc",
37
+ "@agoric/zone": "0.2.3-dev-e3b41dc.0+e3b41dc",
38
38
  "@endo/errors": "^1.2.5",
39
39
  "@endo/far": "^1.1.5",
40
40
  "@endo/import-bundle": "^1.2.2",
@@ -47,7 +47,7 @@
47
47
  "jessie.js": "^0.3.4"
48
48
  },
49
49
  "devDependencies": {
50
- "@agoric/swingset-liveslots": "0.10.3-dev-0b1501a.0+0b1501a",
50
+ "@agoric/swingset-liveslots": "0.10.3-dev-e3b41dc.0+e3b41dc",
51
51
  "@endo/bundle-source": "^3.4.0",
52
52
  "@endo/init": "^1.1.4",
53
53
  "ava": "^5.3.0",
@@ -79,5 +79,5 @@
79
79
  "typeCoverage": {
80
80
  "atLeast": 91.51
81
81
  },
82
- "gitHead": "0b1501ace92d3f53ba37e1c83f508f61c14fcd7d"
82
+ "gitHead": "e3b41dc204ce335217bf18ed4889aba18734d8f6"
83
83
  }
package/src/ibc.js CHANGED
@@ -222,7 +222,7 @@ export const prepareIBCProtocol = (zone, powers) => {
222
222
  /** @type {MapStore<string, Outbound[]>} */
223
223
  const srcPortToOutbounds = detached.mapStore('srcPortToOutbounds');
224
224
 
225
- /** @type {MapStore<string, MapStore<number, VowKit<Bytes>>>} */
225
+ /** @type {MapStore<string, MapStore<bigint, VowKit<Bytes>>>} */
226
226
  const channelKeyToSeqAck = detached.mapStore('channelKeyToSeqAck');
227
227
 
228
228
  /** @type {MapStore<string, SetStore<VowResolver>>} */
@@ -669,7 +669,7 @@ export const prepareIBCProtocol = (zone, powers) => {
669
669
  /**
670
670
  * @param {IBCChannelID} channelID
671
671
  * @param {IBCPortID} portID
672
- * @param {number} sequence
672
+ * @param {bigint} sequence
673
673
  */
674
674
  findAckKit(channelID, portID, sequence) {
675
675
  const { channelKeyToSeqAck } = this.state;
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line import/export -- no named exports
2
+ export * from './types.js';
@@ -0,0 +1,2 @@
1
+ // Empty JS file to correspond with types.d.ts
2
+ export {};
package/src/types.d.ts CHANGED
@@ -1,14 +1,8 @@
1
- import type { FungibleTokenPacketData } from '@agoric/cosmic-proto/ibc/applications/transfer/v2/packet.js';
2
1
  import type { BridgeIdValue, Remote } from '@agoric/internal';
3
2
  import type { Bytes } from '@agoric/network';
4
3
  import type { Guarded } from '@endo/exo';
5
- import type { LocalChainAccount } from './localchain.js';
6
- import type { TargetApp } from './bridge-target.js';
7
-
8
- export type Board = ReturnType<
9
- ReturnType<typeof import('./lib-board.js').prepareBoardKit>
10
- >['board'];
11
-
4
+ import type { PacketSDKType } from '@agoric/cosmic-proto/ibc/core/channel/v1/channel.js';
5
+ export type Board = ReturnType<ReturnType<typeof import('./lib-board.js').prepareBoardKit>>['board'];
12
6
  /**
13
7
  * read-only access to a node in a name hierarchy
14
8
  *
@@ -17,279 +11,237 @@ export type Board = ReturnType<
17
11
  * trips for the contents of even the simplest nameHub.
18
12
  */
19
13
  export type NameHub<Value = any> = {
20
- has: (key: string) => boolean;
21
- /**
22
- * Look up a path of keys starting from the current NameHub. Wait on any
23
- * reserved promises.
24
- */
25
- lookup: (...path: string[]) => Promise<any>;
26
- /** get all the entries available in the current NameHub */
27
- entries: (includeReserved?: boolean) => [string, Value][];
28
- /** get all names available in the current NameHub */
29
- keys: () => string[];
30
- /** get all values available in the current NameHub */
31
- values: () => Value[];
14
+ has: (key: string) => boolean;
15
+ /**
16
+ * Look up a path of keys starting from the current NameHub. Wait on any
17
+ * reserved promises.
18
+ */
19
+ lookup: (...path: string[]) => Promise<any>;
20
+ /** get all the entries available in the current NameHub */
21
+ entries: (includeReserved?: boolean) => [string, Value][];
22
+ /** get all names available in the current NameHub */
23
+ keys: () => string[];
24
+ /** get all values available in the current NameHub */
25
+ values: () => Value[];
32
26
  };
33
-
34
27
  /** write access to a node in a name hierarchy */
35
28
  export type NameAdmin = {
36
- provideChild: (key: string, reserved?: string[]) => Promise<NameHubKit>;
37
- /**
38
- * Mark a key as reserved; will return a promise that is fulfilled when the
39
- * key is updated (or rejected when deleted). If the key was already set it
40
- * does nothing.
41
- */
42
- reserve: (key: string) => Promise<void>;
43
- /**
44
- * Update if not already updated. Return existing value, or newValue if not
45
- * existing.
46
- */
47
- default: <T>(key: string, newValue: T, newAdmin?: NameAdmin) => T;
48
- /** Update only if already initialized. Reject if not. */
49
- set: (key: string, newValue: any, newAdmin?: NameAdmin) => void;
50
- /**
51
- * Fulfill an outstanding reserved promise (if any) to the newValue and set
52
- * the key to the newValue. If newAdmin is provided, set that to return via
53
- * lookupAdmin.
54
- */
55
- update: (key: string, newValue: any, newAdmin?: NameAdmin) => void;
56
- /**
57
- * Look up the `newAdmin` from the path of keys starting from the current
58
- * NameAdmin. Wait on any reserved promises.
59
- */
60
- lookupAdmin: (...path: string[]) => Promise<NameAdmin>;
61
- /** Delete a value and reject an outstanding reserved promise (if any). */
62
- delete: (key: string) => void;
63
- /** get the NameHub corresponding to the current NameAdmin */
64
- readonly: () => NameHub;
65
- /**
66
- * Set a function to be called whenever an update or deletion is made, with all the entries as of that point.
67
- *
68
- * Note: can be called at most once.
69
- */
70
- onUpdate: (fn: undefined | NameHubUpdateHandler) => void;
29
+ provideChild: (key: string, reserved?: string[]) => Promise<NameHubKit>;
30
+ /**
31
+ * Mark a key as reserved; will return a promise that is fulfilled when the
32
+ * key is updated (or rejected when deleted). If the key was already set it
33
+ * does nothing.
34
+ */
35
+ reserve: (key: string) => Promise<void>;
36
+ /**
37
+ * Update if not already updated. Return existing value, or newValue if not
38
+ * existing.
39
+ */
40
+ default: <T>(key: string, newValue: T, newAdmin?: NameAdmin) => T;
41
+ /** Update only if already initialized. Reject if not. */
42
+ set: (key: string, newValue: any, newAdmin?: NameAdmin) => void;
43
+ /**
44
+ * Fulfill an outstanding reserved promise (if any) to the newValue and set
45
+ * the key to the newValue. If newAdmin is provided, set that to return via
46
+ * lookupAdmin.
47
+ */
48
+ update: (key: string, newValue: any, newAdmin?: NameAdmin) => void;
49
+ /**
50
+ * Look up the `newAdmin` from the path of keys starting from the current
51
+ * NameAdmin. Wait on any reserved promises.
52
+ */
53
+ lookupAdmin: (...path: string[]) => Promise<NameAdmin>;
54
+ /** Delete a value and reject an outstanding reserved promise (if any). */
55
+ delete: (key: string) => void;
56
+ /** get the NameHub corresponding to the current NameAdmin */
57
+ readonly: () => NameHub;
58
+ /**
59
+ * Set a function to be called whenever an update or deletion is made, with all the entries as of that point.
60
+ *
61
+ * Note: can be called at most once.
62
+ */
63
+ onUpdate: (fn: undefined | NameHubUpdateHandler) => void;
71
64
  };
72
-
73
65
  export type NameHubUpdateHandler = {
74
- /** Called when an update or deletion is made, with all entries as of that point. */
75
- write: (entries: [string, any][]) => void;
66
+ /** Called when an update or deletion is made, with all entries as of that point. */
67
+ write: (entries: [string, any][]) => void;
76
68
  };
77
-
78
69
  /** a node in a name hierarchy */
79
70
  export type NameHubKit = {
80
- /** read access */
81
- nameHub: NameHub;
82
- /** write access */
83
- nameAdmin: NameAdmin;
71
+ /** read access */
72
+ nameHub: NameHub;
73
+ /** write access */
74
+ nameAdmin: NameAdmin;
84
75
  };
85
-
86
76
  export type MyAddressNameAdmin = NameAdmin & {
87
- getMyAddress(): string;
77
+ getMyAddress(): string;
88
78
  };
89
79
  export type NamesByAddressAdmin = NameAdmin & {
90
- provideChild(
91
- addr: string,
92
- reserved?: string[],
93
- ): Promise<{
94
- nameHub: NameHub;
95
- nameAdmin: MyAddressNameAdmin;
96
- }>;
97
- lookupAdmin(addr: string): Promise<MyAddressNameAdmin>;
80
+ provideChild(addr: string, reserved?: string[]): Promise<{
81
+ nameHub: NameHub;
82
+ nameAdmin: MyAddressNameAdmin;
83
+ }>;
84
+ lookupAdmin(addr: string): Promise<MyAddressNameAdmin>;
98
85
  };
99
-
100
86
  /** An object that can receive messages from the bridge device */
101
87
  export type BridgeHandler = {
102
- /** Handle an inbound message */
103
- fromBridge: (obj: any) => Promise<unknown>;
88
+ /** Handle an inbound message */
89
+ fromBridge: (obj: any) => Promise<unknown>;
104
90
  };
105
-
106
91
  export type ScopedBridgeManagerMethods<BridgeId extends BridgeIdValue> = {
107
- /**
108
- * Optional bridge ID getter. Not part of the production bridge vat but
109
- * available in fake bridges as a means for test reflection and for the type
110
- * system to hang the bridgeId
111
- */
112
- getBridgeId?: () => BridgeId;
113
- /** Downcall from the VM into Golang */
114
- toBridge: (obj: any) => Promise<any>;
115
- /** Upcall from Golang into the VM */
116
- fromBridge: (obj: any) => Promise<unknown>;
117
- initHandler: (handler: Remote<BridgeHandler>) => void;
118
- setHandler: (handler: Remote<BridgeHandler>) => void;
92
+ /**
93
+ * Optional bridge ID getter. Not part of the production bridge vat but
94
+ * available in fake bridges as a means for test reflection and for the type
95
+ * system to hang the bridgeId
96
+ */
97
+ getBridgeId?: () => BridgeId;
98
+ /** Downcall from the VM into Golang */
99
+ toBridge: (obj: any) => Promise<any>;
100
+ /** Upcall from Golang into the VM */
101
+ fromBridge: (obj: any) => Promise<unknown>;
102
+ initHandler: (handler: Remote<BridgeHandler>) => void;
103
+ setHandler: (handler: Remote<BridgeHandler>) => void;
119
104
  };
120
-
121
105
  /** An object which handles messages for a specific bridge */
122
- export type ScopedBridgeManager<BridgeId extends BridgeIdValue> = Guarded<
123
- ScopedBridgeManagerMethods<BridgeId>
124
- >;
125
-
106
+ export type ScopedBridgeManager<BridgeId extends BridgeIdValue> = Guarded<ScopedBridgeManagerMethods<BridgeId>>;
126
107
  /** The object to manage this bridge */
127
108
  export type BridgeManager = {
128
- register: <BridgeId extends BridgeIdValue>(
129
- bridgeId: BridgeId,
130
- handler?: Remote<BridgeHandler>,
131
- ) => ScopedBridgeManager<BridgeId>;
109
+ register: <BridgeId extends BridgeIdValue>(bridgeId: BridgeId, handler?: Remote<BridgeHandler>) => ScopedBridgeManager<BridgeId>;
132
110
  };
133
-
134
111
  export type IBCPortID = string;
135
112
  export type IBCChannelID = `channel-${number}`;
136
113
  export type IBCConnectionID = `connection-${number}`;
137
114
  export type IBCChannelOrdering = 'ORDERED' | 'UNORDERED';
138
-
139
115
  export type IBCPacket = {
140
- data: Bytes;
141
- source_channel: IBCChannelID;
142
- source_port: IBCPortID;
143
- destination_channel: IBCChannelID;
144
- destination_port: IBCPortID;
145
- sequence?: PacketSDKType['sequence'];
146
- timeout_height?: PacketSDKType['timeout_height'];
147
- timeout_timestamp?: PacketSDKType['timeout_timestamp'];
116
+ data: Bytes;
117
+ source_channel: IBCChannelID;
118
+ source_port: IBCPortID;
119
+ destination_channel: IBCChannelID;
120
+ destination_port: IBCPortID;
121
+ sequence?: PacketSDKType['sequence'];
122
+ timeout_height?: PacketSDKType['timeout_height'];
123
+ timeout_timestamp?: PacketSDKType['timeout_timestamp'];
148
124
  };
149
-
150
125
  export type IBCCounterParty = {
151
- port_id: IBCPortID;
152
- channel_id: IBCChannelID;
126
+ port_id: IBCPortID;
127
+ channel_id: IBCChannelID;
153
128
  };
154
-
155
129
  export type ConnectingInfo = {
156
- order: IBCChannelOrdering;
157
- connectionHops: IBCConnectionID[];
158
- portID: IBCPortID;
159
- channelID: IBCChannelID;
160
- counterparty: IBCCounterParty;
161
- counterpartyVersion: string;
162
- version: string;
163
- asyncVersions?: boolean;
130
+ order: IBCChannelOrdering;
131
+ connectionHops: IBCConnectionID[];
132
+ portID: IBCPortID;
133
+ channelID: IBCChannelID;
134
+ counterparty: IBCCounterParty;
135
+ counterpartyVersion: string;
136
+ version: string;
137
+ asyncVersions?: boolean;
164
138
  };
165
-
166
139
  /** see [ibc_module.go](../../../golang/cosmos/x/vibc/types/ibc_module.go) */
167
- export type IBCBridgeEvent =
168
- | 'channelOpenInit'
169
- | 'channelOpenTry'
170
- | 'channelOpenAck'
171
- | 'channelOpenConfirm'
172
- | 'receivePacket'
173
- | 'acknowledgementPacket'
174
- | 'timeoutPacket'
175
- | 'channelCloseInit'
176
- | 'channelCloseConfirm'
177
- | 'sendPacket';
178
-
140
+ export type IBCBridgeEvent = 'channelOpenInit' | 'channelOpenTry' | 'channelOpenAck' | 'channelOpenConfirm' | 'receivePacket' | 'acknowledgementPacket' | 'timeoutPacket' | 'channelCloseInit' | 'channelCloseConfirm' | 'sendPacket';
179
141
  type IBCPacketEvents = {
180
- channelOpenInit: ConnectingInfo;
181
- channelOpenTry: ConnectingInfo;
182
- channelOpenAck: ConnectingInfo;
183
- channelOpenConfirm: ConnectingInfo;
184
- receivePacket: {
185
- packet: IBCPacket;
186
- };
187
- acknowledgementPacket: {
188
- acknowledgement: Bytes;
189
- packet: IBCPacket;
190
- relayer: string; // chain address
191
- };
192
- timeoutPacket: {
193
- packet: IBCPacket;
194
- };
195
- channelCloseInit: { channelID: IBCChannelID; portID: IBCPortID };
196
- channelCloseConfirm: { channelID: IBCChannelID; portID: IBCPortID };
197
- sendPacket: { relativeTimeoutNs: bigint; packet: IBCPacket };
142
+ channelOpenInit: ConnectingInfo;
143
+ channelOpenTry: ConnectingInfo;
144
+ channelOpenAck: ConnectingInfo;
145
+ channelOpenConfirm: ConnectingInfo;
146
+ receivePacket: {
147
+ packet: IBCPacket;
148
+ };
149
+ acknowledgementPacket: {
150
+ acknowledgement: Bytes;
151
+ packet: IBCPacket;
152
+ relayer: string;
153
+ };
154
+ timeoutPacket: {
155
+ packet: IBCPacket;
156
+ };
157
+ channelCloseInit: {
158
+ channelID: IBCChannelID;
159
+ portID: IBCPortID;
160
+ };
161
+ channelCloseConfirm: {
162
+ channelID: IBCChannelID;
163
+ portID: IBCPortID;
164
+ };
165
+ sendPacket: {
166
+ relativeTimeoutNs: bigint;
167
+ packet: IBCPacket;
168
+ };
198
169
  };
199
-
200
170
  export type IBCEvent<E extends IBCBridgeEvent> = {
201
- type: 'IBC_EVENT';
202
- blockHeight: number;
203
- blockTime: number;
204
- event: E;
171
+ type: 'IBC_EVENT';
172
+ blockHeight: number;
173
+ blockTime: number;
174
+ event: E;
205
175
  } & {
206
- [K in keyof IBCPacketEvents[E]]: IBCPacketEvents[E][K];
176
+ [K in keyof IBCPacketEvents[E]]: IBCPacketEvents[E][K];
207
177
  };
208
-
209
178
  /** see [receiver.go](../../../golang/cosmos/x/vibc/types/receiver.go) */
210
- export type IBCDowncallMethod =
211
- | 'sendPacket'
212
- | 'tryOpenExecuted'
213
- | 'receiveExecuted'
214
- | 'startChannelOpenInit'
215
- | 'startChannelCloseInit'
216
- | 'bindPort'
217
- | 'timeoutExecuted'
218
- | 'initOpenExecuted';
219
-
179
+ export type IBCDowncallMethod = 'sendPacket' | 'tryOpenExecuted' | 'receiveExecuted' | 'startChannelOpenInit' | 'startChannelCloseInit' | 'bindPort' | 'timeoutExecuted' | 'initOpenExecuted';
220
180
  type IBCMethodEvents = {
221
- sendPacket: SendPacketDownCall;
222
- tryOpenExecuted: ChannelOpenAckDowncall;
223
- receiveExecuted: {}; // TODO update
224
- startChannelOpenInit: ChannelOpenInitDowncall;
225
- startChannelCloseInit: {}; // TODO update
226
- bindPort: { packet: { source_port: IBCPortID } };
227
- timeoutExecuted: {}; // TODO update
228
- // XXX why isn't this in receiver.go?
229
- initOpenExecuted: ChannelOpenAckDowncall;
181
+ sendPacket: SendPacketDownCall;
182
+ tryOpenExecuted: ChannelOpenAckDowncall;
183
+ receiveExecuted: {};
184
+ startChannelOpenInit: ChannelOpenInitDowncall;
185
+ startChannelCloseInit: {};
186
+ bindPort: {
187
+ packet: {
188
+ source_port: IBCPortID;
189
+ };
190
+ };
191
+ timeoutExecuted: {};
192
+ initOpenExecuted: ChannelOpenAckDowncall;
230
193
  };
231
-
232
194
  export type IBCMethod<M extends IBCDowncallMethod> = {
233
- type: 'IBC_METHOD';
234
- method: M;
195
+ type: 'IBC_METHOD';
196
+ method: M;
235
197
  } & {
236
- [K in keyof IBCMethodEvents[M]]: IBCMethodEvents[M][K];
198
+ [K in keyof IBCMethodEvents[M]]: IBCMethodEvents[M][K];
237
199
  };
238
-
239
200
  export type IBCDowncall<M extends IBCDowncallMethod> = {
240
- [K in keyof IBCMethodEvents[M]]: IBCMethodEvents[M][K];
201
+ [K in keyof IBCMethodEvents[M]]: IBCMethodEvents[M][K];
241
202
  };
242
-
243
- export type IBCDowncallPacket<M extends IBCDowncallMethod> =
244
- IBCMethodEvents[M] extends { packet: infer P } ? P : never;
245
-
203
+ export type IBCDowncallPacket<M extends IBCDowncallMethod> = IBCMethodEvents[M] extends {
204
+ packet: infer P;
205
+ } ? P : never;
246
206
  type ChannelOpenDowncallBase = {
247
- hops: IBCConnectionID[];
248
- order: IBCChannelOrdering;
249
- version: string;
207
+ hops: IBCConnectionID[];
208
+ order: IBCChannelOrdering;
209
+ version: string;
250
210
  };
251
-
252
211
  type ChannelOpenInitDowncall = ChannelOpenDowncallBase & {
253
- packet: Pick<IBCPacket, 'destination_port' | 'source_port'>;
212
+ packet: Pick<IBCPacket, 'destination_port' | 'source_port'>;
254
213
  };
255
-
256
214
  type ChannelOpenAckDowncall = ChannelOpenDowncallBase & {
257
- packet: Pick<
258
- IBCPacket,
259
- | 'destination_port'
260
- | 'source_port'
261
- | 'destination_channel'
262
- | 'source_channel'
263
- >;
215
+ packet: Pick<IBCPacket, 'destination_port' | 'source_port' | 'destination_channel' | 'source_channel'>;
264
216
  };
265
-
266
217
  type SendPacketDownCall = {
267
- packet: IBCPacket;
268
- relativeTimeoutNs: bigint;
218
+ packet: IBCPacket;
219
+ relativeTimeoutNs: bigint;
269
220
  };
270
-
271
221
  /**
272
222
  * This event is emitted when a FungibleTokenPacket is sent or received
273
223
  * by a target (e.g. a {@link LocalChainAccount}) that has a registered
274
224
  * {@link TargetApp}. It is passed through the `receiveUpcall` handler.
275
225
  */
276
226
  export type VTransferIBCEvent = {
277
- type: 'VTRANSFER_IBC_EVENT';
278
- blockHeight: number;
279
- blockTime: number;
280
- /**
281
- * Indicates the type of IBC packet event:
282
- * - 'acknowledgementPacket': passive tap that communicates the result of an acknowledged packet
283
- * - 'writeAcknowledgement': active tap where the receiver can return a write acknowledgement
284
- */
285
- event: 'acknowledgementPacket' | 'writeAcknowledgement';
286
- acknowledgement: Bytes;
287
- /**
288
- * Use `JSON.parse(atob(packet.data))` to get a
289
- * {@link FungibleTokenPacketData} object.
290
- */
291
- packet: IBCPacket;
292
- relayer: string;
293
- /** e.g. the chain address of the LocalChainAccount */
294
- target: string;
227
+ type: 'VTRANSFER_IBC_EVENT';
228
+ blockHeight: number;
229
+ blockTime: number;
230
+ /**
231
+ * Indicates the type of IBC packet event:
232
+ * - 'acknowledgementPacket': passive tap that communicates the result of an acknowledged packet
233
+ * - 'writeAcknowledgement': active tap where the receiver can return a write acknowledgement
234
+ */
235
+ event: 'acknowledgementPacket' | 'writeAcknowledgement';
236
+ acknowledgement: Bytes;
237
+ /**
238
+ * Use `JSON.parse(atob(packet.data))` to get a
239
+ * {@link FungibleTokenPacketData} object.
240
+ */
241
+ packet: IBCPacket;
242
+ relayer: string;
243
+ /** e.g. the chain address of the LocalChainAccount */
244
+ target: string;
295
245
  };
246
+ export {};
247
+ //# sourceMappingURL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AAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,KAAK,EAAE,uBAAuB,GAAG,sBAAsB,CAAC;IACxD,eAAe,EAAE,KAAK,CAAC;IACvB;;;OAGG;IACH,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
package/src/types.ts ADDED
@@ -0,0 +1,297 @@
1
+ /* eslint-disable no-use-before-define */
2
+ import type { FungibleTokenPacketData } from '@agoric/cosmic-proto/ibc/applications/transfer/v2/packet.js';
3
+ import type { BridgeIdValue, Remote } from '@agoric/internal';
4
+ import type { Bytes } from '@agoric/network';
5
+ import type { Guarded } from '@endo/exo';
6
+ import type { PacketSDKType } from '@agoric/cosmic-proto/ibc/core/channel/v1/channel.js';
7
+ import type { LocalChainAccount } from './localchain.js';
8
+ import type { TargetApp } from './bridge-target.js';
9
+
10
+ export type Board = ReturnType<
11
+ ReturnType<typeof import('./lib-board.js').prepareBoardKit>
12
+ >['board'];
13
+
14
+ /**
15
+ * read-only access to a node in a name hierarchy
16
+ *
17
+ * NOTE: We need to return arrays, not iterables, because even if marshal could
18
+ * allow passing a remote iterable, there would be an inordinate number of round
19
+ * trips for the contents of even the simplest nameHub.
20
+ */
21
+ export type NameHub<Value = any> = {
22
+ has: (key: string) => boolean;
23
+ /**
24
+ * Look up a path of keys starting from the current NameHub. Wait on any
25
+ * reserved promises.
26
+ */
27
+ lookup: (...path: string[]) => Promise<any>;
28
+ /** get all the entries available in the current NameHub */
29
+ entries: (includeReserved?: boolean) => [string, Value][];
30
+ /** get all names available in the current NameHub */
31
+ keys: () => string[];
32
+ /** get all values available in the current NameHub */
33
+ values: () => Value[];
34
+ };
35
+
36
+ /** write access to a node in a name hierarchy */
37
+ export type NameAdmin = {
38
+ provideChild: (key: string, reserved?: string[]) => Promise<NameHubKit>;
39
+ /**
40
+ * Mark a key as reserved; will return a promise that is fulfilled when the
41
+ * key is updated (or rejected when deleted). If the key was already set it
42
+ * does nothing.
43
+ */
44
+ reserve: (key: string) => Promise<void>;
45
+ /**
46
+ * Update if not already updated. Return existing value, or newValue if not
47
+ * existing.
48
+ */
49
+ default: <T>(key: string, newValue: T, newAdmin?: NameAdmin) => T;
50
+ /** Update only if already initialized. Reject if not. */
51
+ set: (key: string, newValue: any, newAdmin?: NameAdmin) => void;
52
+ /**
53
+ * Fulfill an outstanding reserved promise (if any) to the newValue and set
54
+ * the key to the newValue. If newAdmin is provided, set that to return via
55
+ * lookupAdmin.
56
+ */
57
+ update: (key: string, newValue: any, newAdmin?: NameAdmin) => void;
58
+ /**
59
+ * Look up the `newAdmin` from the path of keys starting from the current
60
+ * NameAdmin. Wait on any reserved promises.
61
+ */
62
+ lookupAdmin: (...path: string[]) => Promise<NameAdmin>;
63
+ /** Delete a value and reject an outstanding reserved promise (if any). */
64
+ delete: (key: string) => void;
65
+ /** get the NameHub corresponding to the current NameAdmin */
66
+ readonly: () => NameHub;
67
+ /**
68
+ * Set a function to be called whenever an update or deletion is made, with all the entries as of that point.
69
+ *
70
+ * Note: can be called at most once.
71
+ */
72
+ onUpdate: (fn: undefined | NameHubUpdateHandler) => void;
73
+ };
74
+
75
+ export type NameHubUpdateHandler = {
76
+ /** Called when an update or deletion is made, with all entries as of that point. */
77
+ write: (entries: [string, any][]) => void;
78
+ };
79
+
80
+ /** a node in a name hierarchy */
81
+ export type NameHubKit = {
82
+ /** read access */
83
+ nameHub: NameHub;
84
+ /** write access */
85
+ nameAdmin: NameAdmin;
86
+ };
87
+
88
+ export type MyAddressNameAdmin = NameAdmin & {
89
+ getMyAddress(): string;
90
+ };
91
+ export type NamesByAddressAdmin = NameAdmin & {
92
+ provideChild(
93
+ addr: string,
94
+ reserved?: string[],
95
+ ): Promise<{
96
+ nameHub: NameHub;
97
+ nameAdmin: MyAddressNameAdmin;
98
+ }>;
99
+ lookupAdmin(addr: string): Promise<MyAddressNameAdmin>;
100
+ };
101
+
102
+ /** An object that can receive messages from the bridge device */
103
+ export type BridgeHandler = {
104
+ /** Handle an inbound message */
105
+ fromBridge: (obj: any) => Promise<unknown>;
106
+ };
107
+
108
+ export type ScopedBridgeManagerMethods<BridgeId extends BridgeIdValue> = {
109
+ /**
110
+ * Optional bridge ID getter. Not part of the production bridge vat but
111
+ * available in fake bridges as a means for test reflection and for the type
112
+ * system to hang the bridgeId
113
+ */
114
+ getBridgeId?: () => BridgeId;
115
+ /** Downcall from the VM into Golang */
116
+ toBridge: (obj: any) => Promise<any>;
117
+ /** Upcall from Golang into the VM */
118
+ fromBridge: (obj: any) => Promise<unknown>;
119
+ initHandler: (handler: Remote<BridgeHandler>) => void;
120
+ setHandler: (handler: Remote<BridgeHandler>) => void;
121
+ };
122
+
123
+ /** An object which handles messages for a specific bridge */
124
+ export type ScopedBridgeManager<BridgeId extends BridgeIdValue> = Guarded<
125
+ ScopedBridgeManagerMethods<BridgeId>
126
+ >;
127
+
128
+ /** The object to manage this bridge */
129
+ export type BridgeManager = {
130
+ register: <BridgeId extends BridgeIdValue>(
131
+ bridgeId: BridgeId,
132
+ handler?: Remote<BridgeHandler>,
133
+ ) => ScopedBridgeManager<BridgeId>;
134
+ };
135
+
136
+ export type IBCPortID = string;
137
+ export type IBCChannelID = `channel-${number}`;
138
+ export type IBCConnectionID = `connection-${number}`;
139
+ export type IBCChannelOrdering = 'ORDERED' | 'UNORDERED';
140
+
141
+ export type IBCPacket = {
142
+ data: Bytes;
143
+ source_channel: IBCChannelID;
144
+ source_port: IBCPortID;
145
+ destination_channel: IBCChannelID;
146
+ destination_port: IBCPortID;
147
+ sequence?: PacketSDKType['sequence'];
148
+ timeout_height?: PacketSDKType['timeout_height'];
149
+ timeout_timestamp?: PacketSDKType['timeout_timestamp'];
150
+ };
151
+
152
+ export type IBCCounterParty = {
153
+ port_id: IBCPortID;
154
+ channel_id: IBCChannelID;
155
+ };
156
+
157
+ export type ConnectingInfo = {
158
+ order: IBCChannelOrdering;
159
+ connectionHops: IBCConnectionID[];
160
+ portID: IBCPortID;
161
+ channelID: IBCChannelID;
162
+ counterparty: IBCCounterParty;
163
+ counterpartyVersion: string;
164
+ version: string;
165
+ asyncVersions?: boolean;
166
+ };
167
+
168
+ /** see [ibc_module.go](../../../golang/cosmos/x/vibc/types/ibc_module.go) */
169
+ export type IBCBridgeEvent =
170
+ | 'channelOpenInit'
171
+ | 'channelOpenTry'
172
+ | 'channelOpenAck'
173
+ | 'channelOpenConfirm'
174
+ | 'receivePacket'
175
+ | 'acknowledgementPacket'
176
+ | 'timeoutPacket'
177
+ | 'channelCloseInit'
178
+ | 'channelCloseConfirm'
179
+ | 'sendPacket';
180
+
181
+ type IBCPacketEvents = {
182
+ channelOpenInit: ConnectingInfo;
183
+ channelOpenTry: ConnectingInfo;
184
+ channelOpenAck: ConnectingInfo;
185
+ channelOpenConfirm: ConnectingInfo;
186
+ receivePacket: {
187
+ packet: IBCPacket;
188
+ };
189
+ acknowledgementPacket: {
190
+ acknowledgement: Bytes;
191
+ packet: IBCPacket;
192
+ relayer: string; // chain address
193
+ };
194
+ timeoutPacket: {
195
+ packet: IBCPacket;
196
+ };
197
+ channelCloseInit: { channelID: IBCChannelID; portID: IBCPortID };
198
+ channelCloseConfirm: { channelID: IBCChannelID; portID: IBCPortID };
199
+ sendPacket: { relativeTimeoutNs: bigint; packet: IBCPacket };
200
+ };
201
+
202
+ export type IBCEvent<E extends IBCBridgeEvent> = {
203
+ type: 'IBC_EVENT';
204
+ blockHeight: number;
205
+ blockTime: number;
206
+ event: E;
207
+ } & {
208
+ [K in keyof IBCPacketEvents[E]]: IBCPacketEvents[E][K];
209
+ };
210
+
211
+ /** see [receiver.go](../../../golang/cosmos/x/vibc/types/receiver.go) */
212
+ export type IBCDowncallMethod =
213
+ | 'sendPacket'
214
+ | 'tryOpenExecuted'
215
+ | 'receiveExecuted'
216
+ | 'startChannelOpenInit'
217
+ | 'startChannelCloseInit'
218
+ | 'bindPort'
219
+ | 'timeoutExecuted'
220
+ | 'initOpenExecuted';
221
+
222
+ type IBCMethodEvents = {
223
+ sendPacket: SendPacketDownCall;
224
+ tryOpenExecuted: ChannelOpenAckDowncall;
225
+ receiveExecuted: {}; // TODO update
226
+ startChannelOpenInit: ChannelOpenInitDowncall;
227
+ startChannelCloseInit: {}; // TODO update
228
+ bindPort: { packet: { source_port: IBCPortID } };
229
+ timeoutExecuted: {}; // TODO update
230
+ // XXX why isn't this in receiver.go?
231
+ initOpenExecuted: ChannelOpenAckDowncall;
232
+ };
233
+
234
+ export type IBCMethod<M extends IBCDowncallMethod> = {
235
+ type: 'IBC_METHOD';
236
+ method: M;
237
+ } & {
238
+ [K in keyof IBCMethodEvents[M]]: IBCMethodEvents[M][K];
239
+ };
240
+
241
+ export type IBCDowncall<M extends IBCDowncallMethod> = {
242
+ [K in keyof IBCMethodEvents[M]]: IBCMethodEvents[M][K];
243
+ };
244
+
245
+ export type IBCDowncallPacket<M extends IBCDowncallMethod> =
246
+ IBCMethodEvents[M] extends { packet: infer P } ? P : never;
247
+
248
+ type ChannelOpenDowncallBase = {
249
+ hops: IBCConnectionID[];
250
+ order: IBCChannelOrdering;
251
+ version: string;
252
+ };
253
+
254
+ type ChannelOpenInitDowncall = ChannelOpenDowncallBase & {
255
+ packet: Pick<IBCPacket, 'destination_port' | 'source_port'>;
256
+ };
257
+
258
+ type ChannelOpenAckDowncall = ChannelOpenDowncallBase & {
259
+ packet: Pick<
260
+ IBCPacket,
261
+ | 'destination_port'
262
+ | 'source_port'
263
+ | 'destination_channel'
264
+ | 'source_channel'
265
+ >;
266
+ };
267
+
268
+ type SendPacketDownCall = {
269
+ packet: IBCPacket;
270
+ relativeTimeoutNs: bigint;
271
+ };
272
+
273
+ /**
274
+ * This event is emitted when a FungibleTokenPacket is sent or received
275
+ * by a target (e.g. a {@link LocalChainAccount}) that has a registered
276
+ * {@link TargetApp}. It is passed through the `receiveUpcall` handler.
277
+ */
278
+ export type VTransferIBCEvent = {
279
+ type: 'VTRANSFER_IBC_EVENT';
280
+ blockHeight: number;
281
+ blockTime: number;
282
+ /**
283
+ * Indicates the type of IBC packet event:
284
+ * - 'acknowledgementPacket': passive tap that communicates the result of an acknowledged packet
285
+ * - 'writeAcknowledgement': active tap where the receiver can return a write acknowledgement
286
+ */
287
+ event: 'acknowledgementPacket' | 'writeAcknowledgement';
288
+ acknowledgement: Bytes;
289
+ /**
290
+ * Use `JSON.parse(atob(packet.data))` to get a
291
+ * {@link FungibleTokenPacketData} object.
292
+ */
293
+ packet: IBCPacket;
294
+ relayer: string;
295
+ /** e.g. the chain address of the LocalChainAccount */
296
+ target: string;
297
+ };