@agoric/orchestration 0.1.1-dev-2f0f355.0.2f0f355 → 0.1.1-dev-aa6629d.0.aa6629d
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 -16
- package/src/examples/stake-bld.contract.d.ts +1 -0
- package/src/examples/stake-bld.contract.d.ts.map +1 -1
- package/src/examples/stake-bld.contract.js +6 -0
- package/src/examples/stake-ica.contract.d.ts +1 -0
- package/src/examples/stake-ica.contract.d.ts.map +1 -1
- package/src/examples/stake-ica.contract.js +9 -0
- package/src/exos/cosmos-orchestration-account.d.ts +45 -9
- package/src/exos/cosmos-orchestration-account.d.ts.map +1 -1
- package/src/exos/cosmos-orchestration-account.js +184 -10
- package/src/exos/ibc-packet.d.ts.map +1 -1
- package/src/exos/ibc-packet.js +20 -0
- package/src/exos/local-chain-facade.d.ts +36 -0
- package/src/exos/local-chain-facade.d.ts.map +1 -1
- package/src/exos/local-orchestration-account.d.ts +5 -2
- package/src/exos/local-orchestration-account.d.ts.map +1 -1
- package/src/exos/local-orchestration-account.js +46 -3
- package/src/exos/orchestrator.d.ts +287 -612
- package/src/exos/orchestrator.d.ts.map +1 -1
- package/src/exos/packet-tools.d.ts +8 -0
- package/src/exos/packet-tools.d.ts.map +1 -1
- package/src/exos/packet-tools.js +5 -0
- package/src/exos/portfolio-holder-kit.d.ts +6 -0
- package/src/exos/portfolio-holder-kit.d.ts.map +1 -1
- package/src/exos/remote-chain-facade.d.ts +36 -0
- package/src/exos/remote-chain-facade.d.ts.map +1 -1
- package/src/orchestration-api.d.ts +7 -2
- package/src/orchestration-api.d.ts.map +1 -1
- package/src/orchestration-api.ts +8 -1
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +6 -1
- package/src/types.d.ts +1 -0
- package/src/types.d.ts.map +1 -1
- package/src/types.ts +1 -0
- package/src/utils/orchestrationAccount.d.ts +79 -0
- package/src/utils/orchestrationAccount.d.ts.map +1 -1
- package/src/utils/orchestrationAccount.js +204 -0
- package/src/utils/progress.d.ts +41 -0
- package/src/utils/progress.d.ts.map +1 -0
- package/src/utils/progress.js +180 -0
- package/src/utils/start-helper.d.ts.map +1 -1
- package/src/utils/start-helper.js +6 -0
|
@@ -3,6 +3,7 @@ import { Shape as NetworkShape } from '@agoric/network';
|
|
|
3
3
|
import { VowShape } from '@agoric/vow';
|
|
4
4
|
import { TopicsRecordShape } from '@agoric/zoe/src/contractSupport/topics.js';
|
|
5
5
|
import { M } from '@endo/patterns';
|
|
6
|
+
import { Fail } from '@endo/errors';
|
|
6
7
|
import {
|
|
7
8
|
AccountIdArgShape,
|
|
8
9
|
AmountArgShape,
|
|
@@ -13,6 +14,24 @@ import {
|
|
|
13
14
|
|
|
14
15
|
const { Vow$ } = NetworkShape; // TODO #9611
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @import {TypedPattern} from '@agoric/internal';
|
|
19
|
+
* @import {IBCEndpoint} from '@agoric/vats/tools/ibc-utils.js';
|
|
20
|
+
* @import {CaipChainId, IBCConnectionInfo, TrafficEntry} from '../types.js';
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {object} SliceDescriptor
|
|
25
|
+
* @property {number} start beginning index of the range (inclusive)
|
|
26
|
+
* @property {number} end ending index of the range (exclusive)
|
|
27
|
+
*/
|
|
28
|
+
/** @type {TypedPattern<SliceDescriptor>} */
|
|
29
|
+
export const SliceDescriptorShape = M.splitRecord({
|
|
30
|
+
start: M.number(),
|
|
31
|
+
end: M.number(),
|
|
32
|
+
});
|
|
33
|
+
harden(SliceDescriptorShape);
|
|
34
|
+
|
|
16
35
|
/** @see {OrchestrationAccountCommon} */
|
|
17
36
|
export const orchestrationAccountMethods = {
|
|
18
37
|
getAddress: M.call().returns(CosmosChainAddressShape),
|
|
@@ -38,4 +57,189 @@ export const orchestrationAccountMethods = {
|
|
|
38
57
|
}),
|
|
39
58
|
),
|
|
40
59
|
getPublicTopics: M.call().returns(Vow$(TopicsRecordShape)),
|
|
60
|
+
makeProgressTracker: M.call().returns(M.remotable('ProgressTracker')),
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {CaipChainId} srcChain
|
|
65
|
+
* @param {CaipChainId} dstChain
|
|
66
|
+
* @param {IBCConnectionInfo['transferChannel']} ibcChannel
|
|
67
|
+
* @returns {(TrafficEntry<'ibc'> & { incomplete: true })[]}
|
|
68
|
+
*/
|
|
69
|
+
const startIbcTransfer = (srcChain, dstChain, ibcChannel) =>
|
|
70
|
+
harden([
|
|
71
|
+
{
|
|
72
|
+
op: 'transfer',
|
|
73
|
+
src: [
|
|
74
|
+
'ibc',
|
|
75
|
+
['chain', srcChain],
|
|
76
|
+
['port', ibcChannel.portId],
|
|
77
|
+
['channel', ibcChannel.channelId],
|
|
78
|
+
],
|
|
79
|
+
dst: [
|
|
80
|
+
'ibc',
|
|
81
|
+
['chain', dstChain],
|
|
82
|
+
['port', ibcChannel.counterPartyPortId],
|
|
83
|
+
['channel', ibcChannel.counterPartyChannelId],
|
|
84
|
+
],
|
|
85
|
+
seq: { status: 'pending' },
|
|
86
|
+
incomplete: true,
|
|
87
|
+
},
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @template {TrafficEntry} T
|
|
92
|
+
* @param {T} entry
|
|
93
|
+
* @param {TrafficEntry['seq']} sequence
|
|
94
|
+
* @returns {T}
|
|
95
|
+
*/
|
|
96
|
+
const attachGenericSequence = (entry, sequence) => {
|
|
97
|
+
const baseSequence = entry.seq;
|
|
98
|
+
Object(baseSequence)?.status === 'pending' ||
|
|
99
|
+
Fail`expected entry.seq ${baseSequence} to be pending`;
|
|
100
|
+
sequence != null || Fail`expected sequence ${sequence} to be non-nullish`;
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
...entry,
|
|
104
|
+
seq: sequence,
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param {(TrafficEntry<'ibc'> & { incomplete?: any })[]} entries
|
|
110
|
+
* @param {TrafficEntry<'ibc'>['seq']} sequence
|
|
111
|
+
* @returns {TrafficEntry<'ibc'>[]}
|
|
112
|
+
*/
|
|
113
|
+
const finishIbcTransfer = (entries, sequence) => {
|
|
114
|
+
entries.length === 1 || Fail`expected single traffic entry to finish`;
|
|
115
|
+
const [{ incomplete, ...entry }] = entries;
|
|
116
|
+
incomplete || Fail`expected incomplete traffic entry`;
|
|
117
|
+
entry.op === 'transfer' ||
|
|
118
|
+
Fail`expected transfer traffic entry, got ${entry.op}`;
|
|
119
|
+
entry.src[0] === 'ibc' || Fail`expected ibc source in transfer traffic entry`;
|
|
120
|
+
entry.dst[0] === 'ibc' || Fail`expected ibc dest in transfer traffic entry`;
|
|
121
|
+
|
|
122
|
+
return harden([attachGenericSequence(entry, sequence)]);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {CaipChainId} dstChain
|
|
127
|
+
* @returns {(TrafficEntry<'ibc'> & { incomplete: true })[]}
|
|
128
|
+
*/
|
|
129
|
+
const startIbcICA = dstChain =>
|
|
130
|
+
harden([
|
|
131
|
+
{
|
|
132
|
+
op: 'ICA',
|
|
133
|
+
src: ['ibc'],
|
|
134
|
+
dst: ['ibc', ['chain', dstChain]],
|
|
135
|
+
// the rest is filled in by ICA processing
|
|
136
|
+
seq: { status: 'pending' },
|
|
137
|
+
incomplete: true,
|
|
138
|
+
},
|
|
139
|
+
]);
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @param {(TrafficEntry<'ibc'> & { incomplete?: any })[]} entries
|
|
143
|
+
* @param {CaipChainId} srcChain
|
|
144
|
+
* @param {Pick<IBCEndpoint, 'portID' | 'channelID'>} srcEndpoint
|
|
145
|
+
* @param {Pick<IBCEndpoint, 'portID' | 'channelID'>} dstEndpoint
|
|
146
|
+
* @param {TrafficEntry<'ibc'>['seq']} sequence
|
|
147
|
+
* @returns {TrafficEntry<'ibc'>[]}
|
|
148
|
+
*/
|
|
149
|
+
const finishIbcICA = (
|
|
150
|
+
entries,
|
|
151
|
+
srcChain,
|
|
152
|
+
srcEndpoint,
|
|
153
|
+
dstEndpoint,
|
|
154
|
+
sequence,
|
|
155
|
+
) => {
|
|
156
|
+
entries.length === 1 || Fail`expected single traffic entry to finish`;
|
|
157
|
+
const [{ incomplete, ...entry }] = entries;
|
|
158
|
+
incomplete || Fail`expected incomplete traffic entry`;
|
|
159
|
+
entry.op === 'ICA' || Fail`expected ICA traffic entry`;
|
|
160
|
+
|
|
161
|
+
entry.src.length === 1 || Fail`expected source length 1 in ICA traffic entry`;
|
|
162
|
+
entry.src[0] === 'ibc' || Fail`expected ibc source in ICA traffic entry`;
|
|
163
|
+
const src = [
|
|
164
|
+
...entry.src,
|
|
165
|
+
['chain', srcChain],
|
|
166
|
+
['port', srcEndpoint.portID],
|
|
167
|
+
['channel', srcEndpoint.channelID],
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
entry.dst.length === 2 || Fail`expected dest length 2 in ICA traffic entry`;
|
|
171
|
+
entry.dst[0] === 'ibc' || Fail`expected ibc dest in ICA traffic entry`;
|
|
172
|
+
const dst = [
|
|
173
|
+
...entry.dst,
|
|
174
|
+
['port', dstEndpoint.portID],
|
|
175
|
+
['channel', dstEndpoint.channelID],
|
|
176
|
+
];
|
|
177
|
+
return [
|
|
178
|
+
attachGenericSequence(
|
|
179
|
+
/** @type {TrafficEntry<'ibc'>} */ ({
|
|
180
|
+
...entry,
|
|
181
|
+
src,
|
|
182
|
+
dst,
|
|
183
|
+
}),
|
|
184
|
+
sequence,
|
|
185
|
+
),
|
|
186
|
+
];
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export const trafficTransforms = /** @type {const} */ ({
|
|
190
|
+
IbcTransfer: {
|
|
191
|
+
start: startIbcTransfer,
|
|
192
|
+
finish: finishIbcTransfer,
|
|
193
|
+
},
|
|
194
|
+
IbcICA: {
|
|
195
|
+
start: startIbcICA,
|
|
196
|
+
finish: finishIbcICA,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
harden(trafficTransforms);
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @param {TrafficEntry[] | undefined} priorTraffic
|
|
203
|
+
* @param {TrafficEntry[]} newEntries
|
|
204
|
+
* @returns {{ traffic: TrafficEntry[]; slice: SliceDescriptor }}
|
|
205
|
+
*/
|
|
206
|
+
export const addTrafficEntries = (priorTraffic, newEntries) => {
|
|
207
|
+
const entries = priorTraffic ?? [];
|
|
208
|
+
const start = entries.length;
|
|
209
|
+
const end = start + newEntries.length;
|
|
210
|
+
return harden({
|
|
211
|
+
traffic: [...entries, ...newEntries],
|
|
212
|
+
slice: {
|
|
213
|
+
start,
|
|
214
|
+
end,
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
harden(addTrafficEntries);
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @param {TrafficEntry[] | undefined} priorTraffic
|
|
222
|
+
* @param {SliceDescriptor | undefined} sliceDescriptor
|
|
223
|
+
* @param {(entries: TrafficEntry[]) => TrafficEntry[]} finisher
|
|
224
|
+
* @returns {TrafficEntry[]}
|
|
225
|
+
*/
|
|
226
|
+
export const finishTrafficEntries = (
|
|
227
|
+
priorTraffic,
|
|
228
|
+
sliceDescriptor,
|
|
229
|
+
finisher,
|
|
230
|
+
) => {
|
|
231
|
+
const entries = priorTraffic ?? [];
|
|
232
|
+
const slice = sliceDescriptor ?? { start: 0, end: entries.length };
|
|
233
|
+
|
|
234
|
+
const toTransform = harden(entries.slice(slice.start, slice.end));
|
|
235
|
+
toTransform.length > 0 || Fail`no traffic entries to finish`;
|
|
236
|
+
|
|
237
|
+
const transformed = harden(finisher(toTransform));
|
|
238
|
+
transformed.length === toTransform.length ||
|
|
239
|
+
Fail`traffic entry transform must not change length; expected ${toTransform.length}, got ${transformed.length}`;
|
|
240
|
+
|
|
241
|
+
const pre = entries.slice(0, slice.start);
|
|
242
|
+
const post = entries.slice(slice.end);
|
|
243
|
+
return harden([...pre, ...transformed, ...post]);
|
|
41
244
|
};
|
|
245
|
+
harden(finishTrafficEntries);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export namespace progressTrackerAsyncFlowUtils {
|
|
2
|
+
function promiseFromVow<T>(specimen: T): Promise<Fulfilled<T>>;
|
|
3
|
+
function reduceProgressReports<A = unknown>(tracker: ProgressTracker, reducer: PublicationReducer<ProgressReport, A>, initialAccum: A): Promise<A>;
|
|
4
|
+
}
|
|
5
|
+
export function prepareProgressTracker(zone: Zone, { vowTools: { makeVowKit } }: {
|
|
6
|
+
vowTools: Pick<VowTools, "makeVowKit">;
|
|
7
|
+
}): () => import("@endo/exo").Guarded<{
|
|
8
|
+
getCurrentProgressReport(): ProgressReport;
|
|
9
|
+
/**
|
|
10
|
+
* @param {ProgressReport} progressReport
|
|
11
|
+
*/
|
|
12
|
+
update(progressReport: ProgressReport): ProgressReport;
|
|
13
|
+
finish(): ProgressReport;
|
|
14
|
+
/**
|
|
15
|
+
* CAVEAT: Intended for use only by `progress.js` utilities.
|
|
16
|
+
*
|
|
17
|
+
* @returns {PublicationInternals<ProgressReport>}
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
exposePublicationInternals(): PublicationInternals<ProgressReport>;
|
|
21
|
+
}>;
|
|
22
|
+
export type ProgressReport = Record<string, any>;
|
|
23
|
+
export type PublicationInternals<T> = {
|
|
24
|
+
value: T;
|
|
25
|
+
tail: EVow<PublicationInternals<T>>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Called on the value of each linked T. This
|
|
29
|
+
* function should perform any side-effects it can when it receives a new
|
|
30
|
+
* value, since there is no guarantee that the ProgressRecord tail will be
|
|
31
|
+
* prompt (it may take a long time with cross-chain communication) or ever
|
|
32
|
+
* fulfill (it may result in a rejection).
|
|
33
|
+
*/
|
|
34
|
+
export type PublicationReducer<T, A = unknown> = (value: T | undefined | null, accum: A) => EVow<A | null>;
|
|
35
|
+
export type MakeProgressTracker = ReturnType<typeof prepareProgressTracker>;
|
|
36
|
+
export type ProgressTracker = ReturnType<MakeProgressTracker>;
|
|
37
|
+
import type { Fulfilled } from '@agoric/vow';
|
|
38
|
+
import type { Zone } from '@agoric/base-zone';
|
|
39
|
+
import type { VowTools } from '@agoric/vow';
|
|
40
|
+
import type { EVow } from '@agoric/vow';
|
|
41
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["progress.js"],"names":[],"mappings":";IAgDkB,wBAJH,CAAC,YACH,CAAC,GACC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAQjC;IAcsB,+BATT,CAAC,qBACJ,eAAe,WACf,kBAAkB,CAAC,cAAc,EAAE,CAAC,CAAC,gBACrC,CAAC,GAIC,OAAO,CAAC,CAAC,CAAC,CA0BtB;;AAYI,6CAJI,IAAI,gCAEZ;IAA6C,QAAQ,EAA7C,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC;CACtC;;IA0BO;;OAEG;2BADQ,cAAc;;IAyBzB;;;;;OAKG;kCAFU,oBAAoB,CAAC,cAAc,CAAC;GAYxD;6BA9JY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;iCAInB,CAAC;WAEA,CAAC;UACD,KAAK,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;;;;;;+BAI9B,CAAC,EACA,CAAC,sBAMJ,CAAC,GAAG,SAAS,GAAG,IAAI,SAEpB,CAAC,KACC,KAAK,CAAC,GAAG,IAAI,CAAC;kCA6Id,UAAU,CAAC,OAAO,sBAAsB,CAAC;8BAIzC,UAAU,CAAC,mBAAmB,CAAC;+BA3KA,aAAa;0BAClC,mBAAmB;8BADE,aAAa;0BAAb,aAAa"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Utilities for working with ResultMeta<T>.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { isVow } from '@agoric/vow/src/vow-utils.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @import {EVow, VowTools, Fulfilled} from '@agoric/vow';
|
|
9
|
+
* @import {Zone} from '@agoric/base-zone';
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {Record<string, any>} ProgressReport
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @template T
|
|
18
|
+
* @typedef {object} PublicationInternals
|
|
19
|
+
* @property {T} value
|
|
20
|
+
* @property {EVow<PublicationInternals<T>>} tail
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @template T
|
|
25
|
+
* @template [A=unknown]
|
|
26
|
+
* @callback PublicationReducer Called on the value of each linked T. This
|
|
27
|
+
* function should perform any side-effects it can when it receives a new
|
|
28
|
+
* value, since there is no guarantee that the ProgressRecord tail will be
|
|
29
|
+
* prompt (it may take a long time with cross-chain communication) or ever
|
|
30
|
+
* fulfill (it may result in a rejection).
|
|
31
|
+
* @param {T | undefined | null} value `value == null` is a sentinel for the
|
|
32
|
+
* final reducer call.
|
|
33
|
+
* @param {A} accum previous reduction value
|
|
34
|
+
* @returns {EVow<A | null>} Returning `null` exits the reduction
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Utilities for working with ResultMeta within an async flow.
|
|
39
|
+
*/
|
|
40
|
+
export const progressTrackerAsyncFlowUtils = {
|
|
41
|
+
/**
|
|
42
|
+
* Converts a specimen to a Promise. Since the use of Vows is only needed
|
|
43
|
+
* outside of async-flows, we currently reject if we encounter one.
|
|
44
|
+
*
|
|
45
|
+
* @template T
|
|
46
|
+
* @param {T} specimen
|
|
47
|
+
* @returns {Promise<Fulfilled<T>>}
|
|
48
|
+
*/
|
|
49
|
+
promiseFromVow: async specimen => {
|
|
50
|
+
const maybeVow = await specimen;
|
|
51
|
+
!isVow(maybeVow) ||
|
|
52
|
+
assert.Fail`Unexpected Vow ${maybeVow}; only use progress utilities within async flows (withOrchestration)`;
|
|
53
|
+
|
|
54
|
+
return /** @type {Fulfilled<T>} */ (maybeVow);
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Extracts reports from a tracker, calling `reducer` on each.
|
|
59
|
+
*
|
|
60
|
+
* @template [A=unknown]
|
|
61
|
+
* @param {ProgressTracker} tracker
|
|
62
|
+
* @param {PublicationReducer<ProgressReport, A>} reducer
|
|
63
|
+
* @param {A} initialAccum accumulator to pass to the reducer on the first
|
|
64
|
+
* call. Providing the initial accumulator avoids having to deal with
|
|
65
|
+
* `undefined` values in the reducer or explicitly specify the desired
|
|
66
|
+
* type.
|
|
67
|
+
* @returns {Promise<A>} the accumulated result
|
|
68
|
+
*/
|
|
69
|
+
reduceProgressReports: async (tracker, reducer, initialAccum) => {
|
|
70
|
+
const { promiseFromVow } = progressTrackerAsyncFlowUtils;
|
|
71
|
+
|
|
72
|
+
/** @type {PublicationInternals<ProgressReport> | null} */
|
|
73
|
+
let nextReport = await promiseFromVow(tracker.exposePublicationInternals());
|
|
74
|
+
let accum = harden(initialAccum);
|
|
75
|
+
|
|
76
|
+
while (true) {
|
|
77
|
+
const reduction = await promiseFromVow(
|
|
78
|
+
reducer(nextReport?.value ?? null, accum),
|
|
79
|
+
);
|
|
80
|
+
harden(reduction);
|
|
81
|
+
|
|
82
|
+
if (reduction == null) {
|
|
83
|
+
nextReport = null;
|
|
84
|
+
} else {
|
|
85
|
+
accum = /** @type {A} */ (reduction);
|
|
86
|
+
}
|
|
87
|
+
if (nextReport == null) {
|
|
88
|
+
return accum;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
nextReport = (await promiseFromVow(nextReport?.tail)) ?? null;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
harden(progressTrackerAsyncFlowUtils);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A helper for ProgressPublication operations via VowTools.
|
|
100
|
+
*
|
|
101
|
+
* @param {Zone} zone
|
|
102
|
+
* @param {object} powers
|
|
103
|
+
* @param {Pick<VowTools, 'makeVowKit'>} powers.vowTools
|
|
104
|
+
*/
|
|
105
|
+
export const prepareProgressTracker = (zone, { vowTools: { makeVowKit } }) => {
|
|
106
|
+
const makeProgressTrackerKit = zone.exoClassKit(
|
|
107
|
+
'ProgressTrackerKit',
|
|
108
|
+
undefined,
|
|
109
|
+
() => {
|
|
110
|
+
const { vow: nextReport, resolver: tailResolver } = makeVowKit();
|
|
111
|
+
|
|
112
|
+
/** @type {PublicationInternals<ProgressReport>} */
|
|
113
|
+
const currentPublication = harden({
|
|
114
|
+
value: {},
|
|
115
|
+
tail: nextReport,
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
currentPublication,
|
|
119
|
+
done: false,
|
|
120
|
+
tailResolver,
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
helper: {},
|
|
125
|
+
public: {
|
|
126
|
+
getCurrentProgressReport() {
|
|
127
|
+
const { currentPublication } = this.state;
|
|
128
|
+
return currentPublication.value;
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* @param {ProgressReport} progressReport
|
|
132
|
+
*/
|
|
133
|
+
update(progressReport) {
|
|
134
|
+
const { currentPublication, tailResolver, done } = this.state;
|
|
135
|
+
if (done) {
|
|
136
|
+
return currentPublication.value;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const { vow: nextTail, resolver: nextTailResolver } = makeVowKit();
|
|
140
|
+
|
|
141
|
+
const tail = harden({ value: progressReport, tail: nextTail });
|
|
142
|
+
this.state.currentPublication = tail;
|
|
143
|
+
tailResolver.resolve(tail);
|
|
144
|
+
this.state.tailResolver = nextTailResolver;
|
|
145
|
+
return progressReport;
|
|
146
|
+
},
|
|
147
|
+
finish() {
|
|
148
|
+
const { currentPublication, tailResolver, done } = this.state;
|
|
149
|
+
if (!done) {
|
|
150
|
+
tailResolver.resolve(null);
|
|
151
|
+
this.state.done = true;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return currentPublication.value;
|
|
155
|
+
},
|
|
156
|
+
/**
|
|
157
|
+
* CAVEAT: Intended for use only by `progress.js` utilities.
|
|
158
|
+
*
|
|
159
|
+
* @returns {PublicationInternals<ProgressReport>}
|
|
160
|
+
* @internal
|
|
161
|
+
*/
|
|
162
|
+
exposePublicationInternals() {
|
|
163
|
+
return this.state.currentPublication;
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
const makeProgressTracker = () => makeProgressTrackerKit().public;
|
|
170
|
+
return harden(makeProgressTracker);
|
|
171
|
+
};
|
|
172
|
+
harden(prepareProgressTracker);
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @typedef {ReturnType<typeof prepareProgressTracker>} MakeProgressTracker
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @typedef {ReturnType<MakeProgressTracker>} ProgressTracker
|
|
180
|
+
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-helper.d.ts","sourceRoot":"","sources":["start-helper.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start-helper.d.ts","sourceRoot":"","sources":["start-helper.js"],"names":[],"mappings":"AAgEO,0CARI,GAAG,WACH,OAAO,gBACP,mBAAmB,oBACnB,OAAO,UAAU,CAAC,SAE1B;IAA4D,mBAAmB,GAAvE,qBAAqB,CAAC,qBAAqB,CAAC;CACpD;+BA6GU,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAnF8C,CAAC;;;;;;;;;;;;;;;;;;;;;sBAyK6sV,CAAC;;;;;;;;;;;;;;;;;;;;;;;;EApD7wV;AA+BM,kCAfgC,EAAE,SAA3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,EAGhC,EAAE,SAFM,mBAAmB,GAAG;IAC/B,UAAU,EAAE,OAAO,UAAU,CAAC,CAAC;CAC/B,EACQ,CAAC,cACH,CACN,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EACZ,WAAW,EAAE,EAAE,EACf,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,kBAAkB,KACtB,OAAO,CAAC,CAAC,CAAC,SACP,qBAAqB,GACnB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAsBzE;kCAhOU;IACR,UAAU,EAAE,OAAO,UAAU,CAAC,CAAC;IAC/B,oBAAoB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IACtD,WAAW,CAAC,EAAE,OAAO,WAAW,CAAC,CAAC;IAClC,YAAY,EAAE,OAAO,YAAY,CAAC,CAAC;IACnC,WAAW,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;;;;;;;;;;;;;0BAQU,OAAO;;iCAmKP,IAAI,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,EAAE,MAAM,CAAC;6BA1LzC,kBAAkB;4BAEnB,aAAa;0BACf,cAAc;6BACX,gBAAgB;gCANb,gCAAgC;6CAOnB,2BAA2B;iCATvC,0CAA0C;kCAGzC,cAAc;6BAEnB,cAAc"}
|
|
@@ -7,6 +7,7 @@ import { makeChainHub } from '../exos/chain-hub.js';
|
|
|
7
7
|
import { prepareCosmosOrchestrationAccount } from '../exos/cosmos-orchestration-account.js';
|
|
8
8
|
import { prepareLocalChainFacade } from '../exos/local-chain-facade.js';
|
|
9
9
|
import { prepareLocalOrchestrationAccountKit } from '../exos/local-orchestration-account.js';
|
|
10
|
+
import { prepareProgressTracker } from './progress.js';
|
|
10
11
|
import { prepareOrchestrator } from '../exos/orchestrator.js';
|
|
11
12
|
import { prepareRemoteChainFacade } from '../exos/remote-chain-facade.js';
|
|
12
13
|
import { makeOrchestrationFacade } from '../facade.js';
|
|
@@ -103,9 +104,13 @@ export const provideOrchestration = (
|
|
|
103
104
|
baggage,
|
|
104
105
|
cachingMarshaller,
|
|
105
106
|
);
|
|
107
|
+
const makeProgressTracker = prepareProgressTracker(zones.orchestration, {
|
|
108
|
+
vowTools,
|
|
109
|
+
});
|
|
106
110
|
const makeLocalOrchestrationAccountKit = prepareLocalOrchestrationAccountKit(
|
|
107
111
|
zones.orchestration,
|
|
108
112
|
{
|
|
113
|
+
makeProgressTracker,
|
|
109
114
|
makeRecorderKit,
|
|
110
115
|
zcf,
|
|
111
116
|
timerService,
|
|
@@ -124,6 +129,7 @@ export const provideOrchestration = (
|
|
|
124
129
|
zones.orchestration,
|
|
125
130
|
{
|
|
126
131
|
chainHub,
|
|
132
|
+
makeProgressTracker,
|
|
127
133
|
makeRecorderKit,
|
|
128
134
|
timerService,
|
|
129
135
|
vowTools,
|