@agoric/vats 0.15.2-dev-c19f1b5.0 → 0.15.2-dev-27cc9b8.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 +17 -18
- package/src/bridge-target.d.ts +193 -0
- package/src/bridge-target.d.ts.map +1 -0
- package/src/bridge-target.js +316 -0
- package/src/core/types-ambient.d.ts +3 -2
- package/src/ibc.d.ts +3 -33
- package/src/ibc.d.ts.map +1 -1
- package/src/ibc.js +3 -3
- package/src/localchain.d.ts +7 -0
- package/src/localchain.d.ts.map +1 -1
- package/src/localchain.js +11 -2
- package/src/proposals/localchain-proposal.d.ts +4 -1
- package/src/proposals/localchain-proposal.d.ts.map +1 -1
- package/src/proposals/localchain-proposal.js +5 -0
- package/src/proposals/localchain-test.d.ts.map +1 -1
- package/src/proposals/localchain-test.js +7 -4
- package/src/proposals/restart-vats-proposal.d.ts.map +1 -1
- package/src/proposals/restart-vats-proposal.js +6 -2
- package/src/proposals/transfer-proposal.d.ts +41 -0
- package/src/proposals/transfer-proposal.d.ts.map +1 -0
- package/src/proposals/transfer-proposal.js +120 -0
- package/src/proposals/vtransfer-echoer.d.ts +24 -0
- package/src/proposals/vtransfer-echoer.d.ts.map +1 -0
- package/src/proposals/vtransfer-echoer.js +42 -0
- package/src/transfer.d.ts +124 -0
- package/src/transfer.d.ts.map +1 -0
- package/src/transfer.js +271 -0
- package/src/types.d.ts +4 -3
- package/src/vat-ibc.d.ts +0 -28
- package/src/vat-ibc.d.ts.map +1 -1
- package/src/vat-localchain.d.ts +2 -0
- package/src/vat-localchain.d.ts.map +1 -1
- package/src/vat-transfer.d.ts +81 -0
- package/src/vat-transfer.d.ts.map +1 -0
- package/src/vat-transfer.js +63 -0
- package/tools/fake-bridge.d.ts +1 -0
- package/tools/fake-bridge.d.ts.map +1 -1
- package/tools/fake-bridge.js +45 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/vats",
|
|
3
|
-
"version": "0.15.2-dev-
|
|
3
|
+
"version": "0.15.2-dev-27cc9b8.0+27cc9b8",
|
|
4
4
|
"description": "Agoric's Vat library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -22,21 +22,20 @@
|
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/assert": "0.6.1-dev-
|
|
26
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
27
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
28
|
-
"@agoric/governance": "0.10.4-dev-
|
|
29
|
-
"@agoric/internal": "0.3.3-dev-
|
|
30
|
-
"@agoric/network": "0.1.1-dev-
|
|
31
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
32
|
-
"@agoric/store": "0.9.3-dev-
|
|
33
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
34
|
-
"@agoric/time": "0.3.3-dev-
|
|
35
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
36
|
-
"@agoric/vow": "0.1.1-dev-
|
|
37
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
38
|
-
"@agoric/zone": "0.2.3-dev-
|
|
39
|
-
"@endo/base64": "^1.0.5",
|
|
25
|
+
"@agoric/assert": "0.6.1-dev-27cc9b8.0+27cc9b8",
|
|
26
|
+
"@agoric/cosmic-proto": "0.4.1-dev-27cc9b8.0+27cc9b8",
|
|
27
|
+
"@agoric/ertp": "0.16.3-dev-27cc9b8.0+27cc9b8",
|
|
28
|
+
"@agoric/governance": "0.10.4-dev-27cc9b8.0+27cc9b8",
|
|
29
|
+
"@agoric/internal": "0.3.3-dev-27cc9b8.0+27cc9b8",
|
|
30
|
+
"@agoric/network": "0.1.1-dev-27cc9b8.0+27cc9b8",
|
|
31
|
+
"@agoric/notifier": "0.6.3-dev-27cc9b8.0+27cc9b8",
|
|
32
|
+
"@agoric/store": "0.9.3-dev-27cc9b8.0+27cc9b8",
|
|
33
|
+
"@agoric/swingset-vat": "0.32.3-dev-27cc9b8.0+27cc9b8",
|
|
34
|
+
"@agoric/time": "0.3.3-dev-27cc9b8.0+27cc9b8",
|
|
35
|
+
"@agoric/vat-data": "0.5.3-dev-27cc9b8.0+27cc9b8",
|
|
36
|
+
"@agoric/vow": "0.1.1-dev-27cc9b8.0+27cc9b8",
|
|
37
|
+
"@agoric/zoe": "0.26.3-dev-27cc9b8.0+27cc9b8",
|
|
38
|
+
"@agoric/zone": "0.2.3-dev-27cc9b8.0+27cc9b8",
|
|
40
39
|
"@endo/far": "^1.1.2",
|
|
41
40
|
"@endo/import-bundle": "^1.1.2",
|
|
42
41
|
"@endo/marshal": "^1.5.0",
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
"jessie.js": "^0.3.4"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
49
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-27cc9b8.0+27cc9b8",
|
|
51
50
|
"@endo/bundle-source": "^3.2.3",
|
|
52
51
|
"@endo/init": "^1.1.2",
|
|
53
52
|
"ava": "^5.3.0",
|
|
@@ -79,5 +78,5 @@
|
|
|
79
78
|
"typeCoverage": {
|
|
80
79
|
"atLeast": 91.21
|
|
81
80
|
},
|
|
82
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "27cc9b8be59abb048f1ea226b96697c3dccc4d0f"
|
|
83
82
|
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {object} TargetApp an object representing the app that receives
|
|
3
|
+
* upcalls from the low-level TargetHost on the other side of a bridge
|
|
4
|
+
* @property {(obj: MostlyPureData) => Promise<MostlyPureData>} receiveUpcall
|
|
5
|
+
* receive data from the TargetHost, and return a data result
|
|
6
|
+
*/
|
|
7
|
+
export const TargetAppI: import("@endo/patterns").InterfaceGuard<{
|
|
8
|
+
receiveUpcall: import("@endo/patterns").MethodGuard;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {object} TargetHost an object representing the host that receives
|
|
12
|
+
* downcalls from the high-level TargetApp over a bridge
|
|
13
|
+
* @property {(obj: MostlyPureData) => Promise<MostlyPureData>} sendDowncall
|
|
14
|
+
* send data to the TargetHost, which returns a data result
|
|
15
|
+
*/
|
|
16
|
+
export const TargetHostI: import("@endo/patterns").InterfaceGuard<{
|
|
17
|
+
sendDowncall: import("@endo/patterns").MethodGuard;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {object} AppTransformer an object for replacing a TargetApp,
|
|
21
|
+
* generally with a wrapper that intercepts its inputs and/or results to
|
|
22
|
+
* ensure conformance with a protocol and/or interface (e.g., an active tap
|
|
23
|
+
* can encode results of the wrapped TargetApp into an acknowledgement
|
|
24
|
+
* message)
|
|
25
|
+
* @property {(
|
|
26
|
+
* app: ERef<TargetApp>,
|
|
27
|
+
* targetHost: ERef<TargetHost>,
|
|
28
|
+
* ...args: unknown[]
|
|
29
|
+
* ) => ERef<TargetApp>} wrapApp
|
|
30
|
+
*/
|
|
31
|
+
export const AppTransformerI: import("@endo/patterns").InterfaceGuard<{
|
|
32
|
+
wrapApp: import("@endo/patterns").MethodGuard;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {object} TargetRegistration is an ExoClass of its own, and each
|
|
36
|
+
* instance is an attenuation of a BridgeTargetKit `targetRegistry` facet that
|
|
37
|
+
* has access to internal state thereof but has been scoped down to a single
|
|
38
|
+
* target.
|
|
39
|
+
* @property {() => Promise<void>} revoke performs unregistration (and sends the
|
|
40
|
+
* corresponding "BRIDGE_TARGET_UNREGISTER" message to the targetHost).
|
|
41
|
+
* @property {(targetApp: ERef<TargetApp>) => Promise<void>} updateTargetApp
|
|
42
|
+
* replaces the app associated with the target (but with no corresponding
|
|
43
|
+
* message).
|
|
44
|
+
*/
|
|
45
|
+
export const TargetRegistrationI: import("@endo/patterns").InterfaceGuard<{
|
|
46
|
+
updateTargetApp: import("@endo/patterns").MethodGuard;
|
|
47
|
+
revoke: import("@endo/patterns").MethodGuard;
|
|
48
|
+
}>;
|
|
49
|
+
export function prepareTargetRegistration(zone: import("@agoric/base-zone").Zone): (target: string, registry: TargetRegistry, args: unknown[] | null) => import("@endo/exo").Guarded<{
|
|
50
|
+
/**
|
|
51
|
+
* Atomically point the registration at a different app.
|
|
52
|
+
*
|
|
53
|
+
* @param {TargetApp} app new app to handle messages for the target
|
|
54
|
+
*/
|
|
55
|
+
updateTargetApp(app: TargetApp): Promise<void>;
|
|
56
|
+
/** Atomically delete the registration. */
|
|
57
|
+
revoke(): Promise<void>;
|
|
58
|
+
}>;
|
|
59
|
+
export function prepareBridgeTargetKit(zone: import("@agoric/base-zone").Zone, makeTargetRegistration: ReturnType<typeof prepareTargetRegistration>): (manager: import("./types").ScopedBridgeManager<import("@agoric/internal").BridgeIdValue>, inboundEventType: string, appTransformer?: AppTransformer | undefined) => import("@endo/exo").GuardedKit<{
|
|
60
|
+
bridgeHandler: {
|
|
61
|
+
fromBridge(obj: any): Promise<any>;
|
|
62
|
+
};
|
|
63
|
+
targetHost: {
|
|
64
|
+
sendDowncall(obj: any): Promise<any>;
|
|
65
|
+
};
|
|
66
|
+
targetRegistry: {
|
|
67
|
+
/**
|
|
68
|
+
* Register an app to handle messages for a target.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} target
|
|
71
|
+
* @param {TargetApp} app
|
|
72
|
+
* @param {unknown[]} [args]
|
|
73
|
+
* @returns {Promise<TargetRegistration>} power to set or delete the
|
|
74
|
+
* registration
|
|
75
|
+
*/
|
|
76
|
+
register(target: string, app: TargetApp, args?: unknown[] | undefined): Promise<TargetRegistration>;
|
|
77
|
+
/**
|
|
78
|
+
* Update the app that handles messages for a target.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} target
|
|
81
|
+
* @param {TargetApp} app
|
|
82
|
+
* @param {unknown[]} [args]
|
|
83
|
+
* @returns {Promise<void>}
|
|
84
|
+
*/
|
|
85
|
+
reregister(target: string, app: TargetApp, args?: unknown[] | undefined): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Unregister the target, bypassing the attenuated `TargetRegistration`
|
|
88
|
+
* API.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} target
|
|
91
|
+
* @returns {Promise<void>}
|
|
92
|
+
*/
|
|
93
|
+
unregister(target: string): Promise<void>;
|
|
94
|
+
};
|
|
95
|
+
}>;
|
|
96
|
+
export function prepareBridgeTargetModule(zone: import("@agoric/base-zone").Zone): {
|
|
97
|
+
makeBridgeTargetKit: (manager: import("./types").ScopedBridgeManager<import("@agoric/internal").BridgeIdValue>, inboundEventType: string, appTransformer?: AppTransformer | undefined) => import("@endo/exo").GuardedKit<{
|
|
98
|
+
bridgeHandler: {
|
|
99
|
+
fromBridge(obj: any): Promise<any>;
|
|
100
|
+
};
|
|
101
|
+
targetHost: {
|
|
102
|
+
sendDowncall(obj: any): Promise<any>;
|
|
103
|
+
};
|
|
104
|
+
targetRegistry: {
|
|
105
|
+
/**
|
|
106
|
+
* Register an app to handle messages for a target.
|
|
107
|
+
*
|
|
108
|
+
* @param {string} target
|
|
109
|
+
* @param {TargetApp} app
|
|
110
|
+
* @param {unknown[]} [args]
|
|
111
|
+
* @returns {Promise<TargetRegistration>} power to set or delete the
|
|
112
|
+
* registration
|
|
113
|
+
*/
|
|
114
|
+
register(target: string, app: TargetApp, args?: unknown[] | undefined): Promise<TargetRegistration>;
|
|
115
|
+
/**
|
|
116
|
+
* Update the app that handles messages for a target.
|
|
117
|
+
*
|
|
118
|
+
* @param {string} target
|
|
119
|
+
* @param {TargetApp} app
|
|
120
|
+
* @param {unknown[]} [args]
|
|
121
|
+
* @returns {Promise<void>}
|
|
122
|
+
*/
|
|
123
|
+
reregister(target: string, app: TargetApp, args?: unknown[] | undefined): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Unregister the target, bypassing the attenuated `TargetRegistration`
|
|
126
|
+
* API.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} target
|
|
129
|
+
* @returns {Promise<void>}
|
|
130
|
+
*/
|
|
131
|
+
unregister(target: string): Promise<void>;
|
|
132
|
+
};
|
|
133
|
+
}>;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* ideally should be PureData, but that type is
|
|
137
|
+
* too restrictive to work out-of-the-box.
|
|
138
|
+
*/
|
|
139
|
+
export type MostlyPureData = any;
|
|
140
|
+
/**
|
|
141
|
+
* an object representing the app that receives
|
|
142
|
+
* upcalls from the low-level TargetHost on the other side of a bridge
|
|
143
|
+
*/
|
|
144
|
+
export type TargetApp = {
|
|
145
|
+
/**
|
|
146
|
+
* receive data from the TargetHost, and return a data result
|
|
147
|
+
*/
|
|
148
|
+
receiveUpcall: (obj: MostlyPureData) => Promise<MostlyPureData>;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* an object representing the host that receives
|
|
152
|
+
* downcalls from the high-level TargetApp over a bridge
|
|
153
|
+
*/
|
|
154
|
+
export type TargetHost = {
|
|
155
|
+
/**
|
|
156
|
+
* send data to the TargetHost, which returns a data result
|
|
157
|
+
*/
|
|
158
|
+
sendDowncall: (obj: MostlyPureData) => Promise<MostlyPureData>;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* an object for replacing a TargetApp,
|
|
162
|
+
* generally with a wrapper that intercepts its inputs and/or results to
|
|
163
|
+
* ensure conformance with a protocol and/or interface (e.g., an active tap
|
|
164
|
+
* can encode results of the wrapped TargetApp into an acknowledgement
|
|
165
|
+
* message)
|
|
166
|
+
*/
|
|
167
|
+
export type AppTransformer = {
|
|
168
|
+
wrapApp: (app: ERef<TargetApp>, targetHost: ERef<TargetHost>, ...args: unknown[]) => ERef<TargetApp>;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* is an ExoClass of its own, and each
|
|
172
|
+
* instance is an attenuation of a BridgeTargetKit `targetRegistry` facet that
|
|
173
|
+
* has access to internal state thereof but has been scoped down to a single
|
|
174
|
+
* target.
|
|
175
|
+
*/
|
|
176
|
+
export type TargetRegistration = {
|
|
177
|
+
/**
|
|
178
|
+
* performs unregistration (and sends the
|
|
179
|
+
* corresponding "BRIDGE_TARGET_UNREGISTER" message to the targetHost).
|
|
180
|
+
*/
|
|
181
|
+
revoke: () => Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* replaces the app associated with the target (but with no corresponding
|
|
184
|
+
* message).
|
|
185
|
+
*/
|
|
186
|
+
updateTargetApp: (targetApp: ERef<TargetApp>) => Promise<void>;
|
|
187
|
+
};
|
|
188
|
+
export type TargetRegistry = {
|
|
189
|
+
register: (target: string, targetApp: ERef<TargetApp>, args?: unknown[]) => Promise<TargetRegistration>;
|
|
190
|
+
reregister: (target: string, targetApp: ERef<TargetApp>, args?: unknown[]) => Promise<void>;
|
|
191
|
+
unregister: (target: string) => Promise<void>;
|
|
192
|
+
};
|
|
193
|
+
//# sourceMappingURL=bridge-target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-target.d.ts","sourceRoot":"","sources":["bridge-target.js"],"names":[],"mappings":"AAYA;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;;;;;;;GAWG;AAEH;;GAOG;AAEH;;;;;;;;;;GAUG;AAEH;;;GAGG;AA4BI,gDADK,OAAO,mBAAmB,EAAE,IAAI;IAiBtC;;;;OAIG;yBADQ,SAAS;IAapB,0CAA0C;;GAW7C;AAyBI,6CAHI,OAAO,mBAAmB,EAAE,IAAI,0BAChC,UAAU,CAAC,OAAO,yBAAyB,CAAC;;;;;;;;QA6C/C;;;;;;;;WAQG;yBALQ,MAAM,OACN,SAAS,iCAEP,OAAO,CAAC,kBAAkB,CAAC;QAoCxC;;;;;;;WAOG;2BAJQ,MAAM,OACN,SAAS,iCAEP,OAAO,CAAC,IAAI,CAAC;QAyB1B;;;;;;WAMG;2BAFQ,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC;;GAc/B;AAII,gDADK,OAAO,mBAAmB,EAAE,IAAI;;;;;;;;;YA/FpC;;;;;;;;eAQG;6BALQ,MAAM,OACN,SAAS,iCAEP,OAAO,CAAC,kBAAkB,CAAC;YAoCxC;;;;;;;eAOG;+BAJQ,MAAM,OACN,SAAS,iCAEP,OAAO,CAAC,IAAI,CAAC;YAyB1B;;;;;;eAMG;+BAFQ,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC;;;EA0BjC;;;;;6BApTY,GAAG;;;;;;;;;mBASF,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,cAAc,CAAC;;;;;;;;;;kBAWhD,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,cAAc,CAAC;;;;;;;;;;aAchD,CACb,GAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EACxB,UAAc,EAAE,IAAI,CAAC,UAAU,CAAC,EAChC,GAAO,IAAI,EAAE,OAAO,EAAE,KACf,IAAI,CAAC,SAAS,CAAC;;;;;;;;;;;;;YAiBT,MAAM,OAAO,CAAC,IAAI,CAAC;;;;;qBAEnB,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC;;;cAY7C,CACb,MAAU,EAAE,MAAM,EAClB,SAAa,EAAE,IAAI,CAAC,SAAS,CAAC,EAC9B,IAAQ,CAAC,EAAE,OAAO,EAAE,KACb,OAAO,CAAC,kBAAkB,CAAC;gBACrB,CACb,MAAU,EAAE,MAAM,EAClB,SAAa,EAAE,IAAI,CAAC,SAAS,CAAC,EAC9B,IAAQ,CAAC,EAAE,OAAO,EAAE,KACb,OAAO,CAAC,IAAI,CAAC;gBACP,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { E } from '@endo/far';
|
|
2
|
+
import { M } from '@endo/patterns';
|
|
3
|
+
|
|
4
|
+
import { BridgeHandlerI } from './bridge.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {any} MostlyPureData ideally should be PureData, but that type is
|
|
8
|
+
* too restrictive to work out-of-the-box.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const { details: X, Fail } = assert;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {object} TargetApp an object representing the app that receives
|
|
15
|
+
* upcalls from the low-level TargetHost on the other side of a bridge
|
|
16
|
+
* @property {(obj: MostlyPureData) => Promise<MostlyPureData>} receiveUpcall
|
|
17
|
+
* receive data from the TargetHost, and return a data result
|
|
18
|
+
*/
|
|
19
|
+
// TODO unwrap type https://github.com/Agoric/agoric-sdk/issues/9163
|
|
20
|
+
export const TargetAppI = M.interface('TargetApp', {
|
|
21
|
+
receiveUpcall: M.callWhen(M.any()).returns(M.any()),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {object} TargetHost an object representing the host that receives
|
|
26
|
+
* downcalls from the high-level TargetApp over a bridge
|
|
27
|
+
* @property {(obj: MostlyPureData) => Promise<MostlyPureData>} sendDowncall
|
|
28
|
+
* send data to the TargetHost, which returns a data result
|
|
29
|
+
*/
|
|
30
|
+
// TODO unwrap type https://github.com/Agoric/agoric-sdk/issues/9163
|
|
31
|
+
export const TargetHostI = M.interface('TargetHost', {
|
|
32
|
+
sendDowncall: M.callWhen(M.any()).returns(M.any()),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {object} AppTransformer an object for replacing a TargetApp,
|
|
37
|
+
* generally with a wrapper that intercepts its inputs and/or results to
|
|
38
|
+
* ensure conformance with a protocol and/or interface (e.g., an active tap
|
|
39
|
+
* can encode results of the wrapped TargetApp into an acknowledgement
|
|
40
|
+
* message)
|
|
41
|
+
* @property {(
|
|
42
|
+
* app: ERef<TargetApp>,
|
|
43
|
+
* targetHost: ERef<TargetHost>,
|
|
44
|
+
* ...args: unknown[]
|
|
45
|
+
* ) => ERef<TargetApp>} wrapApp
|
|
46
|
+
*/
|
|
47
|
+
// TODO unwrap type https://github.com/Agoric/agoric-sdk/issues/9163
|
|
48
|
+
export const AppTransformerI = M.interface('AppTransformer', {
|
|
49
|
+
wrapApp: M.callWhen(
|
|
50
|
+
M.await(M.remotable('TargetAppI')),
|
|
51
|
+
M.await(M.remotable('TargetHostI')),
|
|
52
|
+
)
|
|
53
|
+
.rest(M.any())
|
|
54
|
+
.returns(M.remotable('TargetAppI')),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @typedef {object} TargetRegistration is an ExoClass of its own, and each
|
|
59
|
+
* instance is an attenuation of a BridgeTargetKit `targetRegistry` facet that
|
|
60
|
+
* has access to internal state thereof but has been scoped down to a single
|
|
61
|
+
* target.
|
|
62
|
+
* @property {() => Promise<void>} revoke performs unregistration (and sends the
|
|
63
|
+
* corresponding "BRIDGE_TARGET_UNREGISTER" message to the targetHost).
|
|
64
|
+
* @property {(targetApp: ERef<TargetApp>) => Promise<void>} updateTargetApp
|
|
65
|
+
* replaces the app associated with the target (but with no corresponding
|
|
66
|
+
* message).
|
|
67
|
+
*/
|
|
68
|
+
// TODO unwrap type https://github.com/Agoric/agoric-sdk/issues/9163
|
|
69
|
+
export const TargetRegistrationI = M.interface('TargetRegistration', {
|
|
70
|
+
updateTargetApp: M.callWhen(M.await(M.remotable('TargetAppI'))).returns(),
|
|
71
|
+
revoke: M.callWhen().returns(),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @typedef {object} TargetRegistry
|
|
76
|
+
* @property {(
|
|
77
|
+
* target: string,
|
|
78
|
+
* targetApp: ERef<TargetApp>,
|
|
79
|
+
* args?: unknown[],
|
|
80
|
+
* ) => Promise<TargetRegistration>} register
|
|
81
|
+
* @property {(
|
|
82
|
+
* target: string,
|
|
83
|
+
* targetApp: ERef<TargetApp>,
|
|
84
|
+
* args?: unknown[],
|
|
85
|
+
* ) => Promise<void>} reregister
|
|
86
|
+
* @property {(target: string) => Promise<void>} unregister
|
|
87
|
+
*/
|
|
88
|
+
// TODO unwrap type https://github.com/Agoric/agoric-sdk/issues/9163
|
|
89
|
+
const TargetRegistryI = M.interface('TargetRegistry', {
|
|
90
|
+
register: M.callWhen(M.string(), M.await(M.remotable('TargetAppI')))
|
|
91
|
+
.optional(M.array())
|
|
92
|
+
.returns(M.remotable('TargetRegistration')),
|
|
93
|
+
reregister: M.callWhen(M.string(), M.await(M.remotable('TargetAppI')))
|
|
94
|
+
.optional(M.array())
|
|
95
|
+
.returns(),
|
|
96
|
+
unregister: M.callWhen(M.string()).returns(),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/** @param {import('@agoric/base-zone').Zone} zone */
|
|
100
|
+
export const prepareTargetRegistration = zone =>
|
|
101
|
+
zone.exoClass(
|
|
102
|
+
'TargetRegistration',
|
|
103
|
+
TargetRegistrationI,
|
|
104
|
+
/**
|
|
105
|
+
* @param {string} target
|
|
106
|
+
* @param {TargetRegistry} registry
|
|
107
|
+
* @param {unknown[] | null} args
|
|
108
|
+
*/
|
|
109
|
+
(target, registry, args) => ({
|
|
110
|
+
target,
|
|
111
|
+
/** @type {TargetRegistry | null} */
|
|
112
|
+
registry,
|
|
113
|
+
args,
|
|
114
|
+
}),
|
|
115
|
+
{
|
|
116
|
+
/**
|
|
117
|
+
* Atomically point the registration at a different app.
|
|
118
|
+
*
|
|
119
|
+
* @param {TargetApp} app new app to handle messages for the target
|
|
120
|
+
*/
|
|
121
|
+
async updateTargetApp(app) {
|
|
122
|
+
const { target, registry, args } = this.state;
|
|
123
|
+
if (!registry) {
|
|
124
|
+
throw Fail`Registration for ${target} is already revoked`;
|
|
125
|
+
}
|
|
126
|
+
return E(registry).reregister(
|
|
127
|
+
target,
|
|
128
|
+
app,
|
|
129
|
+
/** @type {unknown[]} */ (args),
|
|
130
|
+
);
|
|
131
|
+
},
|
|
132
|
+
/** Atomically delete the registration. */
|
|
133
|
+
async revoke() {
|
|
134
|
+
const { target, registry } = this.state;
|
|
135
|
+
if (!registry) {
|
|
136
|
+
throw Fail`Registration for ${target} is already revoked`;
|
|
137
|
+
}
|
|
138
|
+
this.state.registry = null;
|
|
139
|
+
this.state.args = null;
|
|
140
|
+
return E(registry).unregister(target);
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A BridgeTargetKit is associated with a ScopedBridgeManager (essentially a
|
|
147
|
+
* specific named channel on a bridge, cf. {@link ./bridge.js}) and a particular
|
|
148
|
+
* inbound event type and an optional app transformer. It consists of three
|
|
149
|
+
* facets:
|
|
150
|
+
*
|
|
151
|
+
* - `targetHost` has a `downcall` method for sending outbound messages via the
|
|
152
|
+
* bridge to the VM host.
|
|
153
|
+
* - `targetRegistry` has `register`, `reregister` and `unregister` methods to
|
|
154
|
+
* register/reregister/unregister an "app" (or rather its transformation) with
|
|
155
|
+
* a "target" corresponding to an address on the targetHost. Each target may
|
|
156
|
+
* be associated with at most one app at any given time, and registration and
|
|
157
|
+
* unregistration each send a message to the targetHost of the state change
|
|
158
|
+
* (of type "BRIDGE_TARGET_REGISTER" and "BRIDGE_TARGET_UNREGISTER",
|
|
159
|
+
* respectively). `reregister` is a method that atomically redirects the
|
|
160
|
+
* target to a new (transformed) app.
|
|
161
|
+
* - `bridgeHandler` has a `fromBridge` method for receiving from the
|
|
162
|
+
* ScopedBridgeManager inbound messages of the associated event type and
|
|
163
|
+
* dispatching them to the app registered for their target.
|
|
164
|
+
*
|
|
165
|
+
* @param {import('@agoric/base-zone').Zone} zone
|
|
166
|
+
* @param {ReturnType<typeof prepareTargetRegistration>} makeTargetRegistration
|
|
167
|
+
*/
|
|
168
|
+
export const prepareBridgeTargetKit = (zone, makeTargetRegistration) =>
|
|
169
|
+
zone.exoClassKit(
|
|
170
|
+
'BridgeTargetKit',
|
|
171
|
+
{
|
|
172
|
+
bridgeHandler: BridgeHandlerI,
|
|
173
|
+
targetHost: TargetHostI,
|
|
174
|
+
targetRegistry: TargetRegistryI,
|
|
175
|
+
},
|
|
176
|
+
/**
|
|
177
|
+
* @template {import('@agoric/internal').BridgeIdValue} T
|
|
178
|
+
* @param {import('./types').ScopedBridgeManager<T>} manager
|
|
179
|
+
* @param {string} inboundEventType
|
|
180
|
+
* @param {AppTransformer} [appTransformer]
|
|
181
|
+
*/
|
|
182
|
+
(manager, inboundEventType, appTransformer = undefined) => ({
|
|
183
|
+
manager,
|
|
184
|
+
inboundEventType,
|
|
185
|
+
appTransformer,
|
|
186
|
+
/** @type {MapStore<string, ERef<TargetApp>>} */
|
|
187
|
+
targetToApp: zone.detached().mapStore('targetToApp'),
|
|
188
|
+
}),
|
|
189
|
+
{
|
|
190
|
+
bridgeHandler: {
|
|
191
|
+
fromBridge(obj) {
|
|
192
|
+
const { inboundEventType, targetToApp } = this.state;
|
|
193
|
+
const { type, target } = obj;
|
|
194
|
+
|
|
195
|
+
type === inboundEventType ||
|
|
196
|
+
Fail`Invalid inbound event type ${type}; expected ${inboundEventType}`;
|
|
197
|
+
|
|
198
|
+
target || Fail`Missing target property in ${obj}`;
|
|
199
|
+
|
|
200
|
+
const app = targetToApp.get(target);
|
|
201
|
+
return E(app).receiveUpcall(obj);
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
targetHost: {
|
|
205
|
+
async sendDowncall(obj) {
|
|
206
|
+
const { manager } = this.state;
|
|
207
|
+
return E(manager).toBridge(obj);
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
targetRegistry: {
|
|
211
|
+
/**
|
|
212
|
+
* Register an app to handle messages for a target.
|
|
213
|
+
*
|
|
214
|
+
* @param {string} target
|
|
215
|
+
* @param {TargetApp} app
|
|
216
|
+
* @param {unknown[]} [args]
|
|
217
|
+
* @returns {Promise<TargetRegistration>} power to set or delete the
|
|
218
|
+
* registration
|
|
219
|
+
*/
|
|
220
|
+
async register(target, app, args = []) {
|
|
221
|
+
const { targetHost } = this.facets;
|
|
222
|
+
const { appTransformer, targetToApp } = this.state;
|
|
223
|
+
|
|
224
|
+
// Because wrapping an app is async, we verify absence of an existing
|
|
225
|
+
// registration twice (once to avoid the unnecessary invocation and
|
|
226
|
+
// once inside `init`), but attempt to throw similar errors in both
|
|
227
|
+
// cases.
|
|
228
|
+
!targetToApp.has(target) || Fail`Target ${target} already registered`;
|
|
229
|
+
const wrappedApp = await (appTransformer
|
|
230
|
+
? E(appTransformer).wrapApp(app, targetHost, ...args)
|
|
231
|
+
: app);
|
|
232
|
+
try {
|
|
233
|
+
targetToApp.init(target, wrappedApp);
|
|
234
|
+
} catch (cause) {
|
|
235
|
+
throw assert.error(
|
|
236
|
+
X`Target ${target} already registered`,
|
|
237
|
+
undefined,
|
|
238
|
+
{ cause },
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
await E(targetHost).sendDowncall({
|
|
243
|
+
type: 'BRIDGE_TARGET_REGISTER',
|
|
244
|
+
target,
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
return makeTargetRegistration(
|
|
248
|
+
target,
|
|
249
|
+
this.facets.targetRegistry,
|
|
250
|
+
args,
|
|
251
|
+
);
|
|
252
|
+
},
|
|
253
|
+
/**
|
|
254
|
+
* Update the app that handles messages for a target.
|
|
255
|
+
*
|
|
256
|
+
* @param {string} target
|
|
257
|
+
* @param {TargetApp} app
|
|
258
|
+
* @param {unknown[]} [args]
|
|
259
|
+
* @returns {Promise<void>}
|
|
260
|
+
*/
|
|
261
|
+
async reregister(target, app, args = []) {
|
|
262
|
+
const { targetHost } = this.facets;
|
|
263
|
+
const { appTransformer, targetToApp } = this.state;
|
|
264
|
+
|
|
265
|
+
// Because wrapping an app is async, we verify absence of an existing
|
|
266
|
+
// registration twice (once to avoid the unnecessary invocation and
|
|
267
|
+
// once inside `set`), but attempt to throw similar errors in both
|
|
268
|
+
// cases.
|
|
269
|
+
targetToApp.has(target) ||
|
|
270
|
+
Fail`Target ${target} is already unregistered`;
|
|
271
|
+
const wrappedApp = await (appTransformer
|
|
272
|
+
? E(appTransformer).wrapApp(app, targetHost, ...args)
|
|
273
|
+
: app);
|
|
274
|
+
try {
|
|
275
|
+
targetToApp.set(target, wrappedApp);
|
|
276
|
+
} catch (cause) {
|
|
277
|
+
throw assert.error(
|
|
278
|
+
X`Target ${target} is already unregistered`,
|
|
279
|
+
undefined,
|
|
280
|
+
{ cause },
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
/**
|
|
285
|
+
* Unregister the target, bypassing the attenuated `TargetRegistration`
|
|
286
|
+
* API.
|
|
287
|
+
*
|
|
288
|
+
* @param {string} target
|
|
289
|
+
* @returns {Promise<void>}
|
|
290
|
+
*/
|
|
291
|
+
async unregister(target) {
|
|
292
|
+
const { targetHost } = this.facets;
|
|
293
|
+
const { targetToApp } = this.state;
|
|
294
|
+
targetToApp.has(target) || Fail`Target ${target} is already deleted`;
|
|
295
|
+
targetToApp.delete(target);
|
|
296
|
+
await E(targetHost).sendDowncall({
|
|
297
|
+
type: 'BRIDGE_TARGET_UNREGISTER',
|
|
298
|
+
target,
|
|
299
|
+
});
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
);
|
|
304
|
+
harden(prepareBridgeTargetKit);
|
|
305
|
+
|
|
306
|
+
/** @param {import('@agoric/base-zone').Zone} zone */
|
|
307
|
+
export const prepareBridgeTargetModule = zone => {
|
|
308
|
+
const makeTargetRegistration = prepareTargetRegistration(zone);
|
|
309
|
+
const makeBridgeTargetKit = prepareBridgeTargetKit(
|
|
310
|
+
zone,
|
|
311
|
+
makeTargetRegistration,
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
return harden({ makeBridgeTargetKit });
|
|
315
|
+
};
|
|
316
|
+
harden(prepareBridgeTargetModule);
|
|
@@ -381,14 +381,15 @@ type ChainBootstrapSpaceT = {
|
|
|
381
381
|
storageBridgeManager:
|
|
382
382
|
| import('../types.js').ScopedBridgeManager<'storage'>
|
|
383
383
|
| undefined;
|
|
384
|
+
transferMiddleware: import('../transfer.js').TransferMiddleware;
|
|
384
385
|
/**
|
|
385
|
-
*
|
|
386
|
+
* Convenience function for starting a contract (ungoverned) and saving its
|
|
386
387
|
* facets (including adminFacet)
|
|
387
388
|
*/
|
|
388
389
|
startUpgradable: StartUpgradable;
|
|
389
390
|
/** kits stored by startUpgradable */
|
|
390
391
|
contractKits: MapStore<Instance, StartedInstanceKitWithLabel>;
|
|
391
|
-
/**
|
|
392
|
+
/** Convenience function for starting contracts governed by the Econ Committee */
|
|
392
393
|
startGovernedUpgradable: StartGovernedUpgradable;
|
|
393
394
|
/** kits stored by startGovernedUpgradable */
|
|
394
395
|
governedContractKits: MapStore<
|
package/src/ibc.d.ts
CHANGED
|
@@ -1,37 +1,14 @@
|
|
|
1
1
|
export function prepareIBCConnectionHandler(zone: Zone): any;
|
|
2
2
|
export function prepareIBCProtocol(zone: Zone, powers: {
|
|
3
3
|
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>;
|
|
4
|
-
watch: <T_1 =
|
|
4
|
+
watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = never, C = any>(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?: C | undefined) => import("@agoric/vow").Vow<Exclude<TResult1_1, void> | Exclude<TResult2_1, void> extends never ? TResult1_1 : Exclude<TResult1_1, void> | Exclude<TResult2_1, void>>;
|
|
5
5
|
makeVowKit: <T_2>() => VowKit<T_2>;
|
|
6
|
-
allVows: (vows:
|
|
6
|
+
allVows: (vows: unknown[]) => import("@agoric/vow").Vow<any[]>;
|
|
7
7
|
}): (ibcdev: {
|
|
8
8
|
downcall: (method: string, args: object) => Promise<any>;
|
|
9
9
|
}) => {
|
|
10
10
|
protocolHandler: ProtocolHandler;
|
|
11
11
|
bridgeHandler: BridgeHandler;
|
|
12
|
-
} | {
|
|
13
|
-
protocolHandler: import("@endo/exo").Guarded<{
|
|
14
|
-
/** @type {Required<ProtocolHandler>['onCreate']} */
|
|
15
|
-
onCreate(protocol: Remote<ProtocolImpl>, p: Remote<ProtocolHandler>): PromiseVow<void>;
|
|
16
|
-
/** @type {Required<ProtocolHandler>['onInstantiate']} */
|
|
17
|
-
onInstantiate(port: Remote<import("@agoric/network").Port>, localAddr: Endpoint, remote: Endpoint, p: Remote<ProtocolHandler>): PromiseVow<string>;
|
|
18
|
-
/** @type {Required<ProtocolHandler>['generatePortID']} */
|
|
19
|
-
generatePortID(localAddr: Endpoint, p: Remote<ProtocolHandler>): PromiseVow<string>;
|
|
20
|
-
/** @type {Required<ProtocolHandler>['onBind']} */
|
|
21
|
-
onBind(port: Remote<import("@agoric/network").Port>, localAddr: Endpoint, p: Remote<ProtocolHandler>): PromiseVow<void>;
|
|
22
|
-
/** @type {Required<ProtocolHandler>['onConnect']} */
|
|
23
|
-
onConnect(port: Remote<import("@agoric/network").Port>, localAddr: Endpoint, remote: Endpoint, c: Remote<ConnectionHandler>, p: Remote<ProtocolHandler>): PromiseVow<AttemptDescription>;
|
|
24
|
-
/** @type {Required<ProtocolHandler>['onListen']} */
|
|
25
|
-
onListen(port: Remote<import("@agoric/network").Port>, localAddr: Endpoint, listenHandler: Remote<import("@agoric/network").ListenHandler>, p: Remote<ProtocolHandler>): PromiseVow<void>;
|
|
26
|
-
/** @type {Required<ProtocolHandler>['onListenRemove']} */
|
|
27
|
-
onListenRemove(port: Remote<import("@agoric/network").Port>, localAddr: Endpoint, listenHandler: Remote<import("@agoric/network").ListenHandler>, p: Remote<ProtocolHandler>): PromiseVow<void>;
|
|
28
|
-
/** @type {Required<ProtocolHandler>['onRevoke']} */
|
|
29
|
-
onRevoke(port: Remote<import("@agoric/network").Port>, localAddr: Endpoint, p: Remote<ProtocolHandler>): PromiseVow<void>;
|
|
30
|
-
}>;
|
|
31
|
-
bridgeHandler: import("@endo/exo").Guarded<{
|
|
32
|
-
/** @param {IBCEvent<IBCBridgeEvent>} obj */
|
|
33
|
-
fromBridge(obj: IBCEvent<IBCBridgeEvent>): Promise<import("@agoric/vow").Vow<any> | undefined>;
|
|
34
|
-
}>;
|
|
35
12
|
};
|
|
36
13
|
export function prepareCallbacks(zone: Zone): (dibcBridgeManager: ScopedBridgeManager<"dibc">) => import("@endo/exo").Guarded<{
|
|
37
14
|
/**
|
|
@@ -55,15 +32,8 @@ import type { Zone } from '@agoric/base-zone';
|
|
|
55
32
|
import type { VowKit } from '@agoric/vow';
|
|
56
33
|
import type { ProtocolHandler } from '@agoric/network';
|
|
57
34
|
import type { BridgeHandler } from './types.js';
|
|
58
|
-
import type { ProtocolImpl } from '@agoric/network';
|
|
59
|
-
import type { Remote } from '@agoric/vow';
|
|
60
|
-
import type { PromiseVow } from '@agoric/vow';
|
|
61
|
-
import type { Endpoint } from '@agoric/network';
|
|
62
|
-
import type { ConnectionHandler } from '@agoric/network';
|
|
63
|
-
import type { AttemptDescription } from '@agoric/network';
|
|
64
|
-
import type { IBCBridgeEvent } from './types.js';
|
|
65
|
-
import type { IBCEvent } from './types.js';
|
|
66
35
|
import type { ScopedBridgeManager } from './types.js';
|
|
36
|
+
import type { AttemptDescription } from '@agoric/network';
|
|
67
37
|
import type { VowResolver } from '@agoric/vow';
|
|
68
38
|
import type { ConnectingInfo } from './types.js';
|
|
69
39
|
//# 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":"AAmDO,yDAFM,GAAG,CAmHf;AAMM;
|
|
1
|
+
{"version":3,"file":"ibc.d.ts","sourceRoot":"","sources":["ibc.js"],"names":[],"mappings":"AAmDO,yDAFM,GAAG,CAmHf;AAMM;uFA1JK,CAAC;;;oBAW4C,SAAS;;cAsJlD,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC;;;;EAunB7D;AAIM;IAOD;;;OAGG;qBAFQ,MAAM,OACN,GAAG;GAYnB;;;;;;;gBAxxBgB,UAAU;kBACR;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;;0BAbf,mBAAmB;4BAC0B,aAAa;qCAH+B,iBAAiB;mCACyE,YAAY;yCAAZ,YAAY;wCAZjL,iBAAiB;iCAcc,aAAa;oCAFyH,YAAY"}
|