@agoric/network 0.2.0 → 0.2.1-upgrade-23-dev-bd79330.0.bd79330
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 -1
- package/package.json +14 -15
- package/src/network.d.ts +15 -12
- package/src/network.d.ts.map +1 -1
- package/src/network.js +18 -15
- package/src/router.d.ts +7 -2
- package/src/router.d.ts.map +1 -1
- package/src/router.js +6 -4
- package/src/types.d.ts +4 -2
- package/src/types.d.ts.map +1 -1
- package/src/types.js +4 -2
package/README.md
CHANGED
|
@@ -48,7 +48,13 @@ You must also prepare a `ConnectionHandler` object to manage the connection you'
|
|
|
48
48
|
Then you will call the `connect()` method on your local `Port`. This will return a `Promise` that will fire with a new `Connection` object, on which you can send data. Your `ConnectionHandler` will be notified about the new channel, and will receive inbound data from the other side.
|
|
49
49
|
|
|
50
50
|
```js
|
|
51
|
-
|
|
51
|
+
import { encodeIbcEndpoint } from '@agoric/vats/tools/ibc-utils.js';
|
|
52
|
+
const remoteEndpoint = encodeIbcEndpoint({
|
|
53
|
+
hops: [connectionID],
|
|
54
|
+
portID,
|
|
55
|
+
order: 'ordered',
|
|
56
|
+
version
|
|
57
|
+
});;
|
|
52
58
|
E(home.ibcport[0]).connect(remoteEndpoint, connectionHandler)
|
|
53
59
|
.then(conn => doSomethingWithConnection(conn));
|
|
54
60
|
```
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/network",
|
|
3
|
-
"version": "0.2.0",
|
|
3
|
+
"version": "0.2.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
4
4
|
"description": "Agoric's network protocol API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "exit 0",
|
|
10
|
-
"prepack": "yarn run -T
|
|
11
|
-
"postpack": "
|
|
10
|
+
"prepack": "yarn run -T prepack-package",
|
|
11
|
+
"postpack": "yarn run -T postpack-package",
|
|
12
12
|
"test": "ava",
|
|
13
13
|
"test:c8": "c8 --all ${C8_OPTIONS:-} ava",
|
|
14
14
|
"test:xs": "exit 0",
|
|
15
15
|
"lint-fix": "yarn lint:eslint --fix",
|
|
16
16
|
"lint": "yarn run -T run-s --continue-on-error 'lint:*'",
|
|
17
17
|
"lint:types": "yarn run -T tsc",
|
|
18
|
-
"lint:eslint": "
|
|
18
|
+
"lint:eslint": "node ../../scripts/eslint-repo.mjs ."
|
|
19
19
|
},
|
|
20
20
|
"keywords": [],
|
|
21
21
|
"author": "Agoric",
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@agoric/internal": "0.4.0",
|
|
25
|
-
"@agoric/store": "0.10.0",
|
|
26
|
-
"@agoric/vat-data": "0.6.0",
|
|
24
|
+
"@agoric/internal": "0.4.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
25
|
+
"@agoric/store": "0.10.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
26
|
+
"@agoric/vat-data": "0.6.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
27
27
|
"@endo/base64": "^1.0.12",
|
|
28
28
|
"@endo/errors": "^1.2.13",
|
|
29
29
|
"@endo/far": "^1.1.14",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"@endo/promise-kit": "^1.1.13"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@agoric/swingset-liveslots": "0.11.0",
|
|
36
|
-
"@agoric/swingset-vat": "0.33.0",
|
|
37
|
-
"@agoric/vow": "0.2.0",
|
|
38
|
-
"@agoric/zone": "0.3.0",
|
|
35
|
+
"@agoric/swingset-liveslots": "0.11.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
36
|
+
"@agoric/swingset-vat": "0.33.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
37
|
+
"@agoric/vow": "0.2.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
38
|
+
"@agoric/zone": "0.3.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
39
39
|
"@endo/bundle-source": "^4.1.2",
|
|
40
|
-
"ava": "^
|
|
40
|
+
"ava": "^6.4.1",
|
|
41
41
|
"c8": "^10.1.3"
|
|
42
42
|
},
|
|
43
43
|
"exports": {
|
|
@@ -62,11 +62,10 @@
|
|
|
62
62
|
"require": [
|
|
63
63
|
"@endo/init/debug.js"
|
|
64
64
|
],
|
|
65
|
-
"timeout": "20m"
|
|
66
|
-
"workerThreads": false
|
|
65
|
+
"timeout": "20m"
|
|
67
66
|
},
|
|
68
67
|
"typeCoverage": {
|
|
69
68
|
"atLeast": 91.16
|
|
70
69
|
},
|
|
71
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "bd79330f78dae2faf9cc3d8b10063567700da07b"
|
|
72
71
|
}
|
package/src/network.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ export function getPrefixes(addr: string): string[];
|
|
|
8
8
|
/**
|
|
9
9
|
* Create a protocol handler that just connects to itself.
|
|
10
10
|
*
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {Zone} zone
|
|
12
12
|
* @param {VowTools} powers
|
|
13
13
|
*/
|
|
14
|
-
export function prepareLoopbackProtocolHandler(zone:
|
|
14
|
+
export function prepareLoopbackProtocolHandler(zone: Zone, { watch, allVows }: VowTools): (instancePrefix?: string) => import("@endo/exo").Guarded<{
|
|
15
15
|
onCreate(_impl: any, _protocolHandler: any): Promise<void>;
|
|
16
16
|
generatePortID(_localAddr: any, _protocolHandler: any): Promise<string>;
|
|
17
17
|
onBind(_port: any, _localAddr: any, _protocolHandler: any): Promise<void>;
|
|
@@ -19,9 +19,9 @@ export function prepareLoopbackProtocolHandler(zone: import("@agoric/base-zone")
|
|
|
19
19
|
* @param {*} _port
|
|
20
20
|
* @param {Endpoint} localAddr
|
|
21
21
|
* @param {Endpoint} remoteAddr
|
|
22
|
-
* @returns {
|
|
22
|
+
* @returns {PromiseVow<AttemptDescription>}}
|
|
23
23
|
*/
|
|
24
|
-
onConnect(_port: any, localAddr: Endpoint, remoteAddr: Endpoint):
|
|
24
|
+
onConnect(_port: any, localAddr: Endpoint, remoteAddr: Endpoint): PromiseVow<AttemptDescription>;
|
|
25
25
|
onInstantiate(_port: any, _localAddr: any, _remote: any, _protocol: any): Promise<string>;
|
|
26
26
|
onListen(port: any, localAddr: any, listenHandler: any, _protocolHandler: any): Promise<void>;
|
|
27
27
|
/**
|
|
@@ -40,9 +40,9 @@ export function prepareLoopbackProtocolHandler(zone: import("@agoric/base-zone")
|
|
|
40
40
|
export const ENDPOINT_SEPARATOR: "/";
|
|
41
41
|
export const CLOSE_REASON_FINALIZER: "closed-by-finalizer";
|
|
42
42
|
export function rethrowUnlessMissing(err: unknown): undefined;
|
|
43
|
-
export function crossoverConnection(zone:
|
|
44
|
-
export function prepareNetworkProtocol(zone:
|
|
45
|
-
export function prepareEchoConnectionKit(zone:
|
|
43
|
+
export function crossoverConnection(zone: Zone, handler0: Remote<Required<ConnectionHandler>>, addr0: Endpoint, handler1: Remote<Required<ConnectionHandler>>, addr1: Endpoint, makeConnection: (opts: ConnectionOpts) => Connection, finalizer: Finalizer, current?: WeakSetStore<Closable>): Connection[];
|
|
44
|
+
export function prepareNetworkProtocol(zone: Zone, powers: Powers): (protocolHandler: Remote<ProtocolHandler>) => Protocol;
|
|
45
|
+
export function prepareEchoConnectionKit(zone: Zone): () => import("@endo/exo").GuardedKit<{
|
|
46
46
|
handler: {
|
|
47
47
|
/**
|
|
48
48
|
* @param {Connection} _connection
|
|
@@ -75,7 +75,7 @@ export function prepareEchoConnectionKit(zone: import("@agoric/base-zone").Zone)
|
|
|
75
75
|
onListen(port: any, _listenHandler: any): Promise<void>;
|
|
76
76
|
};
|
|
77
77
|
}>;
|
|
78
|
-
export function preparePortAllocator(zone:
|
|
78
|
+
export function preparePortAllocator(zone: Zone, { watch }: Powers): (args_0: {
|
|
79
79
|
protocol: Protocol;
|
|
80
80
|
}) => import("@endo/exo").Guarded<{
|
|
81
81
|
allocateCustomIBCPort(specifiedName?: string): Promise<import("@agoric/vow").Vow<Port>>;
|
|
@@ -83,7 +83,7 @@ export function preparePortAllocator(zone: import("@agoric/base-zone").Zone, { w
|
|
|
83
83
|
allocateICQControllerPort(): Promise<import("@agoric/vow").Vow<Port>>;
|
|
84
84
|
allocateCustomLocalPort(specifiedName?: string): Promise<import("@agoric/vow").Vow<Port>>;
|
|
85
85
|
}>;
|
|
86
|
-
export function prepareNetworkPowers(zone:
|
|
86
|
+
export function prepareNetworkPowers(zone: Zone, vowTools: VowTools): Powers;
|
|
87
87
|
export type MakeEchoConnectionKit = ReturnType<typeof prepareEchoConnectionKit>;
|
|
88
88
|
export type Powers = VowTools & {
|
|
89
89
|
finalizer: Finalizer;
|
|
@@ -98,19 +98,23 @@ export type ConnectionOpts = {
|
|
|
98
98
|
};
|
|
99
99
|
export type PortAllocator = ReturnType<ReturnType<typeof preparePortAllocator>>;
|
|
100
100
|
export type Finalizer = ReturnType<typeof prepareFinalizer>;
|
|
101
|
+
import type { Zone } from '@agoric/base-zone';
|
|
101
102
|
import type { VowTools } from '@agoric/vow';
|
|
102
103
|
import type { Endpoint } from './types.js';
|
|
103
104
|
import type { AttemptDescription } from './types.js';
|
|
105
|
+
import type { PromiseVow } from '@agoric/vow';
|
|
104
106
|
import type { Port } from './types.js';
|
|
105
107
|
import type { Remote } from '@agoric/vow';
|
|
106
108
|
import type { ListenHandler } from './types.js';
|
|
107
109
|
import type { ConnectionHandler } from './types.js';
|
|
108
110
|
import type { Connection } from './types.js';
|
|
109
111
|
import type { Closable } from './types.js';
|
|
112
|
+
import type { WeakSetStore } from '@agoric/store';
|
|
110
113
|
import type { ProtocolHandler } from './types.js';
|
|
111
114
|
import type { Protocol } from './types.js';
|
|
112
115
|
import type { Bytes } from './types.js';
|
|
113
116
|
import type { CloseReason } from './types.js';
|
|
117
|
+
import type { MapStore } from '@agoric/store';
|
|
114
118
|
/** @typedef {ReturnType<ReturnType<typeof preparePortAllocator>>} PortAllocator */
|
|
115
119
|
/**
|
|
116
120
|
* Return a package-specific singleton that pins objects until they are
|
|
@@ -120,10 +124,10 @@ import type { CloseReason } from './types.js';
|
|
|
120
124
|
* The reason this functionality wasn't just baked into the other network exos
|
|
121
125
|
* is to maintain upgrade-compatible with minimal additional changes.
|
|
122
126
|
*
|
|
123
|
-
* @param {
|
|
127
|
+
* @param {Zone} zone
|
|
124
128
|
* @param {VowTools} vowTools
|
|
125
129
|
*/
|
|
126
|
-
declare function prepareFinalizer(zone:
|
|
130
|
+
declare function prepareFinalizer(zone: Zone, { watch }: VowTools): import("@endo/exo").Guarded<{
|
|
127
131
|
has(obj: any): boolean;
|
|
128
132
|
/**
|
|
129
133
|
* Add a connection and handler for an `onClose` method to be called upon
|
|
@@ -143,6 +147,5 @@ declare function prepareFinalizer(zone: import("@agoric/base-zone").Zone, { watc
|
|
|
143
147
|
finalize(obj: any): import("@agoric/vow").Vow<any> | undefined;
|
|
144
148
|
unpin(obj: any): void;
|
|
145
149
|
}>;
|
|
146
|
-
import type { PromiseVow } from '@agoric/vow';
|
|
147
150
|
export {};
|
|
148
151
|
//# sourceMappingURL=network.d.ts.map
|
package/src/network.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["network.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["network.js"],"names":[],"mappings":"AA6CA;;;;GAIG;AACH,kCAFW,MAAM,YAahB;AA4tCD,mFAAmF;AAEnF;;;;;GAKG;AACH,qDAHW,IAAI,sBACJ,QAAQ,qBAkJL,MAAM;;;;IA/GZ;;;;;OAKG;qBAJQ,GAAC,aACD,QAAQ,cACR,QAAQ,GACN,WAAW,kBAAkB,CAAC;;;IA+D3C;;;;;OAKG;yBAJQ,OAAO,IAAI,CAAC,aACZ,Q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AAmB;8BADK,aAAa;8BAD2H,YAAY;wCAAZ,YAAY;gCACpJ,aAAa;0BAD2H,YAAY;4BACpJ,aAAa;mCAD2H,YAAY;uCAAZ,YAAY;gCAAZ,YAAY;8BAAZ,YAAY;kCAIpK,eAAe;qCAJyI,YAAY;8BAAZ,YAAY;2BAAZ,YAAY;iCAAZ,YAAY;8BAGxK,eAAe;AAq/C1C,mFAAmF;AAEnF;;;;;;;;;;GAUG;AACH,wCAHW,IAAI,aACJ,QAAQ;;IAcf;;;;;OAKG;yBAFQ,OAAO,UAAU,CAAC,WAClB,OAAO,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAK9C;;;;OAIG;uBADQ,OAAO;QAAE,KAAK,IAAI,WAAW,GAAG,CAAC,CAAA;KAAE,CAAC;;;GA2BlD"}
|
package/src/network.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
/// <reference types="@agoric/store/exported.js" />
|
|
4
|
-
|
|
5
3
|
import { Fail } from '@endo/errors';
|
|
6
4
|
import { E } from '@endo/far';
|
|
7
5
|
import { M } from '@endo/patterns';
|
|
@@ -12,6 +10,10 @@ import { Shape } from './shapes.js';
|
|
|
12
10
|
/**
|
|
13
11
|
* @import {AttemptDescription, Bytes, CloseReason, Closable, Connection, ConnectionHandler, Endpoint, ListenHandler, Port, Protocol, ProtocolHandler, ProtocolImpl, SendOptions} from './types.js';
|
|
14
12
|
* @import {PromiseVow, Remote, VowTools} from '@agoric/vow';
|
|
13
|
+
* @import {Zone} from '@agoric/base-zone';
|
|
14
|
+
* @import {MapStore} from '@agoric/store';
|
|
15
|
+
* @import {WeakSetStore} from '@agoric/store';
|
|
16
|
+
* @import {SetStore} from '@agoric/store';
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
19
|
/** @typedef {VowTools & { finalizer: Finalizer }} Powers */
|
|
@@ -84,7 +86,7 @@ function throwIfInvalidPortName(specifiedName) {
|
|
|
84
86
|
*/
|
|
85
87
|
|
|
86
88
|
/**
|
|
87
|
-
* @param {
|
|
89
|
+
* @param {Zone} zone
|
|
88
90
|
* @param {Powers} powers
|
|
89
91
|
*/
|
|
90
92
|
const prepareHalfConnection = (zone, { watch, allVows, finalizer }) => {
|
|
@@ -190,7 +192,7 @@ const prepareHalfConnection = (zone, { watch, allVows, finalizer }) => {
|
|
|
190
192
|
};
|
|
191
193
|
|
|
192
194
|
/**
|
|
193
|
-
* @param {
|
|
195
|
+
* @param {Zone} zone
|
|
194
196
|
* @param {Remote<Required<ConnectionHandler>>} handler0
|
|
195
197
|
* @param {Endpoint} addr0
|
|
196
198
|
* @param {Remote<Required<ConnectionHandler>>} handler1
|
|
@@ -252,7 +254,7 @@ export const crossoverConnection = (
|
|
|
252
254
|
};
|
|
253
255
|
|
|
254
256
|
/**
|
|
255
|
-
* @param {
|
|
257
|
+
* @param {Zone} zone
|
|
256
258
|
* @param {(opts: ConnectionOpts) => Connection} makeConnection
|
|
257
259
|
* @param {Powers} powers
|
|
258
260
|
*/
|
|
@@ -417,7 +419,7 @@ const RevokeState = /** @type {const} */ ({
|
|
|
417
419
|
harden(RevokeState);
|
|
418
420
|
|
|
419
421
|
/**
|
|
420
|
-
* @param {
|
|
422
|
+
* @param {Zone} zone
|
|
421
423
|
* @param {Powers} powers
|
|
422
424
|
*/
|
|
423
425
|
const preparePort = (zone, powers) => {
|
|
@@ -665,7 +667,7 @@ const preparePort = (zone, powers) => {
|
|
|
665
667
|
};
|
|
666
668
|
|
|
667
669
|
/**
|
|
668
|
-
* @param {
|
|
670
|
+
* @param {Zone} zone
|
|
669
671
|
* @param {Powers} powers
|
|
670
672
|
*/
|
|
671
673
|
const prepareBinder = (zone, powers) => {
|
|
@@ -1182,7 +1184,7 @@ const prepareBinder = (zone, powers) => {
|
|
|
1182
1184
|
};
|
|
1183
1185
|
|
|
1184
1186
|
/**
|
|
1185
|
-
* @param {
|
|
1187
|
+
* @param {Zone} zone
|
|
1186
1188
|
* @param {Powers} powers
|
|
1187
1189
|
*/
|
|
1188
1190
|
export const prepareNetworkProtocol = (zone, powers) => {
|
|
@@ -1222,7 +1224,7 @@ export const prepareNetworkProtocol = (zone, powers) => {
|
|
|
1222
1224
|
/**
|
|
1223
1225
|
* Create a ConnectionHandler that just echoes its packets.
|
|
1224
1226
|
*
|
|
1225
|
-
* @param {
|
|
1227
|
+
* @param {Zone} zone
|
|
1226
1228
|
*/
|
|
1227
1229
|
export const prepareEchoConnectionKit = zone => {
|
|
1228
1230
|
const makeEchoConnectionKit = zone.exoClassKit(
|
|
@@ -1306,7 +1308,7 @@ export const prepareEchoConnectionKit = zone => {
|
|
|
1306
1308
|
/**
|
|
1307
1309
|
* Create a protocol handler that just connects to itself.
|
|
1308
1310
|
*
|
|
1309
|
-
* @param {
|
|
1311
|
+
* @param {Zone} zone
|
|
1310
1312
|
* @param {VowTools} powers
|
|
1311
1313
|
*/
|
|
1312
1314
|
export function prepareLoopbackProtocolHandler(zone, { watch, allVows }) {
|
|
@@ -1346,7 +1348,7 @@ export function prepareLoopbackProtocolHandler(zone, { watch, allVows }) {
|
|
|
1346
1348
|
* @param {*} _port
|
|
1347
1349
|
* @param {Endpoint} localAddr
|
|
1348
1350
|
* @param {Endpoint} remoteAddr
|
|
1349
|
-
* @returns {
|
|
1351
|
+
* @returns {PromiseVow<AttemptDescription>}}
|
|
1350
1352
|
*/
|
|
1351
1353
|
async onConnect(_port, localAddr, remoteAddr) {
|
|
1352
1354
|
const { listeners } = this.state;
|
|
@@ -1464,7 +1466,7 @@ export function prepareLoopbackProtocolHandler(zone, { watch, allVows }) {
|
|
|
1464
1466
|
|
|
1465
1467
|
/**
|
|
1466
1468
|
*
|
|
1467
|
-
* @param {
|
|
1469
|
+
* @param {Zone} zone
|
|
1468
1470
|
* @param {Powers} powers
|
|
1469
1471
|
*/
|
|
1470
1472
|
export const preparePortAllocator = (zone, { watch }) =>
|
|
@@ -1544,7 +1546,7 @@ export const preparePortAllocator = (zone, { watch }) =>
|
|
|
1544
1546
|
* The reason this functionality wasn't just baked into the other network exos
|
|
1545
1547
|
* is to maintain upgrade-compatible with minimal additional changes.
|
|
1546
1548
|
*
|
|
1547
|
-
* @param {
|
|
1549
|
+
* @param {Zone} zone
|
|
1548
1550
|
* @param {VowTools} vowTools
|
|
1549
1551
|
*/
|
|
1550
1552
|
const prepareFinalizer = (zone, { watch }) => {
|
|
@@ -1578,7 +1580,7 @@ const prepareFinalizer = (zone, { watch }) => {
|
|
|
1578
1580
|
},
|
|
1579
1581
|
finalize(obj) {
|
|
1580
1582
|
if (!objToFinalizerInfo.has(obj)) {
|
|
1581
|
-
return;
|
|
1583
|
+
return undefined;
|
|
1582
1584
|
}
|
|
1583
1585
|
const disposeInfo = objToFinalizerInfo.get(obj);
|
|
1584
1586
|
if ('conn' in disposeInfo) {
|
|
@@ -1592,6 +1594,7 @@ const prepareFinalizer = (zone, { watch }) => {
|
|
|
1592
1594
|
objToFinalizerInfo.delete(obj);
|
|
1593
1595
|
return watch(E(closer).close());
|
|
1594
1596
|
}
|
|
1597
|
+
return undefined;
|
|
1595
1598
|
},
|
|
1596
1599
|
unpin(obj) {
|
|
1597
1600
|
objToFinalizerInfo.delete(obj);
|
|
@@ -1601,7 +1604,7 @@ const prepareFinalizer = (zone, { watch }) => {
|
|
|
1601
1604
|
harden(prepareFinalizer);
|
|
1602
1605
|
|
|
1603
1606
|
/**
|
|
1604
|
-
* @param {
|
|
1607
|
+
* @param {Zone} zone
|
|
1605
1608
|
* @param {VowTools} vowTools
|
|
1606
1609
|
* @returns {Powers}
|
|
1607
1610
|
*/
|
package/src/router.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @import {Endpoint, Port, Protocol, ProtocolHandler} from './types.js';
|
|
3
3
|
* @import {PromiseVow, Remote, VowTools} from '@agoric/vow';
|
|
4
|
+
* @import {Zone} from '@agoric/base-zone';
|
|
5
|
+
* @import {Powers} from './network.js';
|
|
6
|
+
* @import {MapStore} from '@agoric/store';
|
|
4
7
|
*/
|
|
5
8
|
/**
|
|
6
9
|
* @template T
|
|
@@ -17,7 +20,7 @@ export const RouterI: import("@endo/patterns").InterfaceGuard<{
|
|
|
17
20
|
register: import("@endo/patterns").MethodGuard;
|
|
18
21
|
unregister: import("@endo/patterns").MethodGuard;
|
|
19
22
|
}>;
|
|
20
|
-
export function prepareRouter<T>(zone:
|
|
23
|
+
export function prepareRouter<T>(zone: Zone): () => import("@endo/exo").Guarded<{
|
|
21
24
|
/** @param {Endpoint} addr */
|
|
22
25
|
getRoutes(addr: Endpoint): [string, T][];
|
|
23
26
|
/**
|
|
@@ -31,7 +34,7 @@ export function prepareRouter<T>(zone: import("@agoric/base-zone").Zone): () =>
|
|
|
31
34
|
*/
|
|
32
35
|
unregister(prefix: string, route: T): void;
|
|
33
36
|
}>;
|
|
34
|
-
export function prepareRouterProtocol(zone:
|
|
37
|
+
export function prepareRouterProtocol(zone: Zone, powers: Powers, E?: typeof defaultE): () => import("@endo/exo").Guarded<{
|
|
35
38
|
/**
|
|
36
39
|
* @param {string[]} paths
|
|
37
40
|
* @param {Remote<ProtocolHandler>} protocolHandler
|
|
@@ -70,7 +73,9 @@ export type RouterProtocol = {
|
|
|
70
73
|
registerProtocolHandler: (paths: string[], protocolHandler: ProtocolHandler) => void;
|
|
71
74
|
unregisterProtocolHandler: (prefix: string, protocolHandler: ProtocolHandler) => void;
|
|
72
75
|
};
|
|
76
|
+
import type { Zone } from '@agoric/base-zone';
|
|
73
77
|
import type { Endpoint } from './types.js';
|
|
78
|
+
import type { Powers } from './network.js';
|
|
74
79
|
import { E as defaultE } from '@endo/far';
|
|
75
80
|
import type { ProtocolHandler } from './types.js';
|
|
76
81
|
import type { Remote } from '@agoric/vow';
|
package/src/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["router.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["router.js"],"names":[],"mappings":"AAUA;;;;;;GAMG;AAEH;;;;;;;;;GASG;AAEH;;;;GAIG;AAMI,8BAHM,CAAC,QACH,IAAI;IAiBT,6BAA6B;oBAAjB,QAAQ;IAyBpB;;;OAGG;qBAFQ,MAAM,SACN,CAAC;IAKZ;;;OAGG;uBAFQ,MAAM,SACN,CAAC;GAWjB;AAgBM,4CAJI,IAAI,UACJ,MAAM,MACN,OAAO,QAAQ;IAmCpB;;;OAGG;mCAFQ,MAAM,EAAE,mBACR,OAAO,eAAe,CAAC;IAYlC;;;OAGG;sCAFQ,MAAM,mBACN,OAAO,eAAe,CAAC;IAclC,kCAAkC;wBAAtB,QAAQ;GAUzB;;;;mBAzKY,CAAC;;;;;eAEA,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE;;;;;cAE/B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI;;;;;gBAElC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI;;;cA8ElC,CAAC,MAAM,EAAE,MAAM,KAAK,WAAW,IAAI,CAAC;6BACpC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,eAAe,KAAK,IAAI;+BAC3D,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,KAAK,IAAI;;0BA5FjD,mBAAmB;8BAFkB,YAAY;4BAG/C,cAAc;8BATT,WAAW;qCAMmB,YAAY;4BACzB,aAAa;0BADA,YAAY;gCACzB,aAAa"}
|
package/src/router.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
/// <reference types="@agoric/store/exported.js" />
|
|
4
3
|
/// <reference path="./types.js" />
|
|
5
4
|
|
|
6
5
|
import { Fail } from '@endo/errors';
|
|
@@ -12,6 +11,9 @@ import { Shape } from './shapes.js';
|
|
|
12
11
|
/**
|
|
13
12
|
* @import {Endpoint, Port, Protocol, ProtocolHandler} from './types.js';
|
|
14
13
|
* @import {PromiseVow, Remote, VowTools} from '@agoric/vow';
|
|
14
|
+
* @import {Zone} from '@agoric/base-zone';
|
|
15
|
+
* @import {Powers} from './network.js';
|
|
16
|
+
* @import {MapStore} from '@agoric/store';
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
19
|
/**
|
|
@@ -33,7 +35,7 @@ export const RouterI = M.interface('Router', {
|
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* @template T
|
|
36
|
-
* @param {
|
|
38
|
+
* @param {Zone} zone
|
|
37
39
|
*/
|
|
38
40
|
export const prepareRouter = zone => {
|
|
39
41
|
const detached = zone.detached();
|
|
@@ -107,8 +109,8 @@ export const prepareRouter = zone => {
|
|
|
107
109
|
/**
|
|
108
110
|
* Create a router that behaves like a Protocol.
|
|
109
111
|
*
|
|
110
|
-
* @param {
|
|
111
|
-
* @param {
|
|
112
|
+
* @param {Zone} zone
|
|
113
|
+
* @param {Powers} powers
|
|
112
114
|
* @param {typeof defaultE} [E] Eventual sender
|
|
113
115
|
*/
|
|
114
116
|
export const prepareRouterProtocol = (zone, powers, E = defaultE) => {
|
package/src/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Rearrange the exo types to make a cast of the methods (M) and init function (I) to a specific type.
|
|
3
3
|
*/
|
|
4
|
-
export type ExoClassMethods<M extends
|
|
5
|
-
self:
|
|
4
|
+
export type ExoClassMethods<M extends Methods, I extends (...args: any[]) => any> = M & ThisType<{
|
|
5
|
+
self: Guarded<M>;
|
|
6
6
|
state: ReturnType<I>;
|
|
7
7
|
}>;
|
|
8
8
|
/**
|
|
@@ -219,6 +219,8 @@ export type ProtocolImpl = {
|
|
|
219
219
|
*/
|
|
220
220
|
outbound: (port: Remote<Port>, remoteAddr: Endpoint, connectionHandler: Remote<ConnectionHandler>) => PromiseVow<Connection>;
|
|
221
221
|
};
|
|
222
|
+
import type { Methods } from '@endo/exo';
|
|
223
|
+
import type { Guarded } from '@endo/exo';
|
|
222
224
|
import type { PromiseVow } from '@agoric/vow';
|
|
223
225
|
import type { RemotableObject } from '@endo/pass-style';
|
|
224
226
|
import type { Remote } from '@agoric/vow';
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":";;;4BAauB,CAAC,SAAX,OAAS,EACiB,CAAC,SAA3B,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAI,IACzB,CAAC,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC;;;;oBAKxD,MAAM;;;;;uBAIN,MAAM;;;;;;;;WAML,MAAM,WAAW,IAAI,CAAC;;uBAGvB,eAAe,GAAG,SAAS;;;;;;;;;cAK1B,CAAC,MAAM,EAAE,QAAQ,KAAK,WAAW,IAAI,CAAC;;;;;;;;;;qBAMtC,MAAM,QAAQ;;;;iBAEd,CAAC,aAAa,EAAE,OAAO,aAAa,CAAC,KAAK,WAAW,IAAI,CAAC;;;;aAE1D,CACT,MAAM,EAAE,QAAQ,EAChB,iBAAiB,CAAC,EAAE,OAAO,iBAAiB,CAAC,KAC1C,WAAW,UAAU,CAAC;;;;oBAEhB,CAAC,aAAa,EAAE,OAAO,aAAa,CAAC,KAAK,WAAW,IAAI,CAAC;;;;;YAE1D,MAAM,WAAW,IAAI,CAAC;;;;;;;;;uBAMf,OAAO,IAAI,CAAC,KAAK,OAAO,aAAa,CAAC,KAAK,WAAW,IAAI,CAAC;;;;cAClE,CACT,IAAI,EAAE,OAAO,IAAI,CAAC,EAClB,SAAS,EA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;cAEpB,CACT,IAAI,EAAE,OAAO,IAAI,CAAC,EAClB,UAAU,EAAE,QAAQ,EACpB,iBAAiB,EAAE,OAAO,iBAAiB,CAAC,KACzC,WAAW,UAAU,CAAC;;6BA1MJ,WAAW;6BACX,WAAW;gCAFA,aAAa;qCADN,kBAAkB;4BACzB,aAAa"}
|
package/src/types.js
CHANGED
|
@@ -6,12 +6,14 @@ export {};
|
|
|
6
6
|
/**
|
|
7
7
|
* @import {Passable, RemotableObject} from '@endo/pass-style';
|
|
8
8
|
* @import {PromiseVow, Remote} from '@agoric/vow';
|
|
9
|
+
* @import {Methods} from '@endo/exo';
|
|
10
|
+
* @import {Guarded} from '@endo/exo';
|
|
9
11
|
*/
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
|
-
* @template {
|
|
14
|
+
* @template {Methods} M
|
|
13
15
|
* @template {(...args: any[]) => any} I
|
|
14
|
-
* @typedef {M & ThisType<{ self:
|
|
16
|
+
* @typedef {M & ThisType<{ self: Guarded<M>, state: ReturnType<I> }>} ExoClassMethods
|
|
15
17
|
* Rearrange the exo types to make a cast of the methods (M) and init function (I) to a specific type.
|
|
16
18
|
*/
|
|
17
19
|
|