@agoric/orchestration 0.1.1-dev-bc48a8b.0 → 0.1.1-dev-0b6d5f3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/orchestration",
3
- "version": "0.1.1-dev-bc48a8b.0+bc48a8b",
3
+ "version": "0.1.1-dev-0b6d5f3.0+0b6d5f3",
4
4
  "description": "Chain abstraction for Agoric's orchestration clients",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -33,19 +33,19 @@
33
33
  },
34
34
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
35
35
  "dependencies": {
36
- "@agoric/async-flow": "0.1.1-dev-bc48a8b.0+bc48a8b",
37
- "@agoric/cosmic-proto": "0.4.1-dev-bc48a8b.0+bc48a8b",
38
- "@agoric/ertp": "0.16.3-dev-bc48a8b.0+bc48a8b",
39
- "@agoric/internal": "0.3.3-dev-bc48a8b.0+bc48a8b",
40
- "@agoric/network": "0.1.1-dev-bc48a8b.0+bc48a8b",
41
- "@agoric/notifier": "0.6.3-dev-bc48a8b.0+bc48a8b",
42
- "@agoric/store": "0.9.3-dev-bc48a8b.0+bc48a8b",
43
- "@agoric/time": "0.3.3-dev-bc48a8b.0+bc48a8b",
44
- "@agoric/vat-data": "0.5.3-dev-bc48a8b.0+bc48a8b",
45
- "@agoric/vats": "0.15.2-dev-bc48a8b.0+bc48a8b",
46
- "@agoric/vow": "0.1.1-dev-bc48a8b.0+bc48a8b",
47
- "@agoric/zoe": "0.26.3-dev-bc48a8b.0+bc48a8b",
48
- "@agoric/zone": "0.2.3-dev-bc48a8b.0+bc48a8b",
36
+ "@agoric/async-flow": "0.1.1-dev-0b6d5f3.0+0b6d5f3",
37
+ "@agoric/cosmic-proto": "0.4.1-dev-0b6d5f3.0+0b6d5f3",
38
+ "@agoric/ertp": "0.16.3-dev-0b6d5f3.0+0b6d5f3",
39
+ "@agoric/internal": "0.3.3-dev-0b6d5f3.0+0b6d5f3",
40
+ "@agoric/network": "0.1.1-dev-0b6d5f3.0+0b6d5f3",
41
+ "@agoric/notifier": "0.6.3-dev-0b6d5f3.0+0b6d5f3",
42
+ "@agoric/store": "0.9.3-dev-0b6d5f3.0+0b6d5f3",
43
+ "@agoric/time": "0.3.3-dev-0b6d5f3.0+0b6d5f3",
44
+ "@agoric/vat-data": "0.5.3-dev-0b6d5f3.0+0b6d5f3",
45
+ "@agoric/vats": "0.15.2-dev-0b6d5f3.0+0b6d5f3",
46
+ "@agoric/vow": "0.1.1-dev-0b6d5f3.0+0b6d5f3",
47
+ "@agoric/zoe": "0.26.3-dev-0b6d5f3.0+0b6d5f3",
48
+ "@agoric/zone": "0.2.3-dev-0b6d5f3.0+0b6d5f3",
49
49
  "@endo/base64": "^1.0.5",
50
50
  "@endo/errors": "^1.2.2",
51
51
  "@endo/far": "^1.1.2",
@@ -53,7 +53,7 @@
53
53
  "@endo/patterns": "^1.4.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@agoric/swingset-liveslots": "0.10.3-dev-bc48a8b.0+bc48a8b",
56
+ "@agoric/swingset-liveslots": "0.10.3-dev-0b6d5f3.0+0b6d5f3",
57
57
  "@chain-registry/client": "^1.47.4",
58
58
  "@cosmjs/amino": "^0.32.3",
59
59
  "@cosmjs/proto-signing": "^0.32.3",
@@ -91,5 +91,5 @@
91
91
  "typeCoverage": {
92
92
  "atLeast": 97.1
93
93
  },
94
- "gitHead": "bc48a8b2d76799c9c07a0888c496039c29049194"
94
+ "gitHead": "0b6d5f36027dce27b81f9dab3a37d4fb3f23d81e"
95
95
  }
@@ -1,9 +1,28 @@
1
+ /**
2
+ * @import {TimerService} from '@agoric/time';
3
+ * @import {LocalChain} from '@agoric/vats/src/localchain.js';
4
+ * @import {NameHub} from '@agoric/vats';
5
+ * @import {Remote} from '@agoric/vow';
6
+ * @import {Zone} from '@agoric/zone';
7
+ * @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api';
8
+ * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js';
9
+ * @import {OrchestrationTools} from '../utils/start-helper.js';
10
+ */
11
+ /**
12
+ * @typedef {{
13
+ * localchain: Remote<LocalChain>;
14
+ * orchestrationService: Remote<CosmosInterchainService>;
15
+ * storageNode: Remote<StorageNode>;
16
+ * timerService: Remote<TimerService>;
17
+ * agoricNames: Remote<NameHub>;
18
+ * }} OrchestrationPowers
19
+ */
1
20
  export const SingleAmountRecord: import("@endo/patterns").Matcher;
2
21
  export const start: (zcf: ZCF<Record<string, unknown>>, privateArgs: OrchestrationPowers & {
3
22
  marshaller: Marshaller;
4
23
  }, baggage: import("@agoric/vat-data").Baggage) => Promise<{
5
24
  publicFacet: import("@endo/exo").Guarded<{
6
- makeSendInvitation(): Promise<Invitation<unknown, never>>;
25
+ makeSendInvitation(): Promise<Invitation<any, any>>;
7
26
  }>;
8
27
  creatorFacet: import("@endo/exo").Guarded<{
9
28
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sendAnywhere.contract.d.ts","sourceRoot":"","sources":["sendAnywhere.contract.js"],"names":[],"mappings":"AAoFA,kEAKE;AAwFF;gBAjFiB,UAAU;;;;;;QAwDrB;;;WAGG;;;;;;;;4BADQ,iBAAiB;;GAuBe;kCAtJpC;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;uCAdiD,eAAe;gCAJvC,gCAAgC;4BAEpC,aAAa;6CAGI,sCAAsC;kCANjD,cAAc;6BAEnB,cAAc"}
1
+ {"version":3,"file":"sendAnywhere.contract.d.ts","sourceRoot":"","sources":["sendAnywhere.contract.js"],"names":[],"mappings":"AAWA;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AAEH,kEAKE;AAkGF;gBA3FiB,UAAU;;;;;;QAkErB;;;WAGG;;;;;;;;4BADQ,iBAAiB;;GAuBe;kCAhHpC;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;uCAZiD,eAAe;gCAJvC,gCAAgC;4BAEpC,aAAa;6CAGI,sCAAsC;kCANjD,cAAc;6BAEnB,cAAc"}
@@ -1,15 +1,13 @@
1
1
  import { makeStateRecord } from '@agoric/async-flow';
2
2
  import { AmountShape } from '@agoric/ertp';
3
3
  import { heapVowE } from '@agoric/vow/vat.js';
4
- import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
5
4
  import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
5
+ import { Fail } from '@endo/errors';
6
6
  import { E } from '@endo/far';
7
- import { M, mustMatch } from '@endo/patterns';
8
- import { makeResumableAgoricNamesHack } from '../exos/agoric-names-tools.js';
7
+ import { M } from '@endo/patterns';
9
8
  import { CosmosChainInfoShape } from '../typeGuards.js';
10
9
  import { withOrchestration } from '../utils/start-helper.js';
11
-
12
- const { entries } = Object;
10
+ import { orchestrationFns } from './sendAnywhereFlows.js';
13
11
 
14
12
  /**
15
13
  * @import {TimerService} from '@agoric/time';
@@ -19,9 +17,7 @@ const { entries } = Object;
19
17
  * @import {Zone} from '@agoric/zone';
20
18
  * @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api';
21
19
  * @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js';
22
- * @import {Orchestrator} from '../types.js'
23
20
  * @import {OrchestrationTools} from '../utils/start-helper.js';
24
- * @import {OrchestrationAccount} from '../orchestration-api.js'
25
21
  */
26
22
 
27
23
  /**
@@ -34,54 +30,6 @@ const { entries } = Object;
34
30
  * }} OrchestrationPowers
35
31
  */
36
32
 
37
- /**
38
- * @param {Orchestrator} orch
39
- * @param {object} ctx
40
- * @param {ZCF} ctx.zcf
41
- * @param {any} ctx.agoricNamesTools TODO Give this a better type
42
- * @param {{ account: OrchestrationAccount<any> | undefined }} ctx.contractState
43
- * @param {ZCFSeat} seat
44
- * @param {object} offerArgs
45
- * @param {string} offerArgs.chainName
46
- * @param {string} offerArgs.destAddr
47
- */
48
- const sendItFn = async (
49
- orch,
50
- { zcf, agoricNamesTools, contractState },
51
- seat,
52
- offerArgs,
53
- ) => {
54
- mustMatch(offerArgs, harden({ chainName: M.scalar(), destAddr: M.string() }));
55
- const { chainName, destAddr } = offerArgs;
56
- const { give } = seat.getProposal();
57
- const [[kw, amt]] = entries(give);
58
- const { denom } = await agoricNamesTools.findBrandInVBank(amt.brand);
59
- const chain = await orch.getChain(chainName);
60
-
61
- if (!contractState.account) {
62
- const agoricChain = await orch.getChain('agoric');
63
- contractState.account = await agoricChain.makeAccount();
64
- console.log('contractState.account', contractState.account);
65
- }
66
-
67
- const info = await chain.getChainInfo();
68
- console.log('info', info);
69
- const { chainId } = info;
70
- assert(typeof chainId === 'string', 'bad chainId');
71
- const { [kw]: pmtP } = await withdrawFromSeat(zcf, seat, give);
72
- // #9212 types for chain account helpers
73
- // @ts-expect-error LCA should have .deposit() method
74
- await E.when(pmtP, pmt => contractState.account?.deposit(pmt));
75
- await contractState.account?.transfer(
76
- { denom, value: amt.value },
77
- {
78
- value: destAddr,
79
- encoding: 'bech32',
80
- chainId,
81
- },
82
- );
83
- };
84
-
85
33
  export const SingleAmountRecord = M.and(
86
34
  M.recordOf(M.string(), AmountShape, {
87
35
  numPropertiesLimit: 1,
@@ -103,26 +51,36 @@ const contract = async (
103
51
  zcf,
104
52
  privateArgs,
105
53
  zone,
106
- { chainHub, orchestrate, vowTools },
54
+ { chainHub, orchestrateAll, vowTools, zoeTools },
107
55
  ) => {
108
- const agoricNamesTools = makeResumableAgoricNamesHack(zone, {
109
- agoricNames: privateArgs.agoricNames,
110
- vowTools,
111
- });
112
-
113
56
  const contractState = makeStateRecord(
114
57
  /** @type {{ account: OrchestrationAccount<any> | undefined }} */ {
115
58
  account: undefined,
116
59
  },
117
60
  );
118
61
 
119
- /** @type {OfferHandler} */
120
- const sendIt = orchestrate(
121
- 'sendIt',
122
- { zcf, agoricNamesTools, contractState },
123
- sendItFn,
62
+ // TODO should be a provided helper
63
+ const findBrandInVBank = vowTools.retriable(
64
+ zone,
65
+ 'findBrandInVBank',
66
+ /** @param {Brand} brand */
67
+ async brand => {
68
+ const { agoricNames } = privateArgs;
69
+ const assets = await E(E(agoricNames).lookup('vbankAsset')).values();
70
+ const it = assets.find(a => a.brand === brand);
71
+ it || Fail`brand ${brand} not in agoricNames.vbankAsset`;
72
+ return it;
73
+ },
124
74
  );
125
75
 
76
+ // orchestrate uses the names on orchestrationFns to do a "prepare" of the associated behavior
77
+ const orchFns = orchestrateAll(orchestrationFns, {
78
+ zcf,
79
+ contractState,
80
+ localTransfer: zoeTools.localTransfer,
81
+ findBrandInVBank,
82
+ });
83
+
126
84
  const publicFacet = zone.exo(
127
85
  'Send PF',
128
86
  M.interface('Send PF', {
@@ -131,7 +89,7 @@ const contract = async (
131
89
  {
132
90
  makeSendInvitation() {
133
91
  return zcf.makeInvitation(
134
- sendIt,
92
+ orchFns.sendIt,
135
93
  'send',
136
94
  undefined,
137
95
  M.splitRecord({ give: SingleAmountRecord }),
@@ -0,0 +1,24 @@
1
+ export namespace orchestrationFns {
2
+ /**
3
+ * @param {Orchestrator} orch
4
+ * @param {object} ctx
5
+ * @param {{ account: OrchestrationAccount<any> }} ctx.contractState
6
+ * @param {any} ctx.localTransfer
7
+ * @param {any} ctx.findBrandInVBank
8
+ * @param {ZCFSeat} seat
9
+ * @param {{ chainName: string; destAddr: string }} offerArgs
10
+ */
11
+ function sendIt(orch: Orchestrator, { contractState, localTransfer, findBrandInVBank }: {
12
+ contractState: {
13
+ account: OrchestrationAccount<any>;
14
+ };
15
+ localTransfer: any;
16
+ findBrandInVBank: any;
17
+ }, seat: ZCFSeat, offerArgs: {
18
+ chainName: string;
19
+ destAddr: string;
20
+ }): Promise<void>;
21
+ }
22
+ import type { Orchestrator } from '../types.js';
23
+ import type { OrchestrationAccount } from '../types.js';
24
+ //# sourceMappingURL=sendAnywhereFlows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendAnywhereFlows.d.ts","sourceRoot":"","sources":["sendAnywhereFlows.js"],"names":[],"mappings":";IAYE;;;;;;;;OAQG;IACH,sBARW,YAAY,sDAEpB;QAAoD,aAAa,EAAzD;YAAE,OAAO,EAAE,qBAAqB,GAAG,CAAC,CAAA;SAAE;QAC7B,aAAa,EAAtB,GAAG;QACM,gBAAgB,EAAzB,GAAG;KACX,QAAQ,OAAO,aACP;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,iBAsCjD;;kCAtDkD,aAAa;0CAAb,aAAa"}
@@ -0,0 +1,59 @@
1
+ import { M, mustMatch } from '@endo/patterns';
2
+
3
+ /**
4
+ * @import {Orchestrator, OrchestrationAccount} from '../types.js';
5
+ */
6
+
7
+ const { entries } = Object;
8
+
9
+ // in guest file (the orchestration functions)
10
+ // the second argument is all the endowments provided
11
+
12
+ export const orchestrationFns = harden({
13
+ /**
14
+ * @param {Orchestrator} orch
15
+ * @param {object} ctx
16
+ * @param {{ account: OrchestrationAccount<any> }} ctx.contractState
17
+ * @param {any} ctx.localTransfer
18
+ * @param {any} ctx.findBrandInVBank
19
+ * @param {ZCFSeat} seat
20
+ * @param {{ chainName: string; destAddr: string }} offerArgs
21
+ */
22
+ async sendIt(
23
+ orch,
24
+ { contractState, localTransfer, findBrandInVBank },
25
+ seat,
26
+ offerArgs,
27
+ ) {
28
+ mustMatch(
29
+ offerArgs,
30
+ harden({ chainName: M.scalar(), destAddr: M.string() }),
31
+ );
32
+ const { chainName, destAddr } = offerArgs;
33
+ // NOTE the proposal shape ensures that the `give` is a single asset
34
+ const { give } = seat.getProposal();
35
+ const [[_kw, amt]] = entries(give);
36
+ const { denom } = await findBrandInVBank(amt.brand);
37
+ const chain = await orch.getChain(chainName);
38
+
39
+ if (!contractState.account) {
40
+ const agoricChain = await orch.getChain('agoric');
41
+ contractState.account = await agoricChain.makeAccount();
42
+ }
43
+
44
+ const info = await chain.getChainInfo();
45
+ const { chainId } = info;
46
+ assert(typeof chainId === 'string', 'bad chainId');
47
+
48
+ await localTransfer(seat, contractState.account, give);
49
+
50
+ await contractState.account.transfer(
51
+ { denom, value: amt.value },
52
+ {
53
+ value: destAddr,
54
+ encoding: 'bech32',
55
+ chainId,
56
+ },
57
+ );
58
+ },
59
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"AAoEA,yCAAyC;AACzC,mBADW,YAAY,CAAC,OAAO,KAAK,CAAC,CAWnC;AASK,0CAHI,KAAK;;;EAIsC;AA+CtD;iBAxCkB,OAAO,OAAO,CAAC;gBAChB,OAAO,UAAU,CAAC;0BACR,OAAO,uBAAuB,CAAC;iBACxC,OAAO,WAAW,CAAC;kBAClB,OAAO,YAAY,CAAC;gBACtB,UAAU;;;;oBAYV,MAAM,CAAC,KAAK,CAAC;uBAAa,sBAAsB;;;GAuBhB;6BA1HvB,cAAc;4BAFf,kBAAkB;gCADd,gCAAgC;6CAEnB,sCAAsC;kCAHjD,cAAc;4CADsB,aAAa"}
1
+ {"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"AA8DA,yCAAyC;AACzC,mBADW,YAAY,CAAC,OAAO,KAAK,CAAC,CAWnC;AASK,0CAHI,KAAK;;;EAIsC;AAmDtD;iBA5CkB,OAAO,OAAO,CAAC;gBAChB,OAAO,UAAU,CAAC;0BACR,OAAO,uBAAuB,CAAC;iBACxC,OAAO,WAAW,CAAC;kBAClB,OAAO,YAAY,CAAC;gBACtB,UAAU;;;;oBAYV,MAAM,CAAC,KAAK,CAAC;uBAAa,sBAAsB;;;GA2BhB;6BA1HvB,cAAc;4BAFf,kBAAkB;gCADd,gCAAgC;6CAEnB,sCAAsC;kCAHjD,cAAc;4CADU,aAAa"}
@@ -1,13 +1,11 @@
1
1
  import { StorageNodeShape } from '@agoric/internal';
2
2
  import { TimerServiceShape } from '@agoric/time';
3
- import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
4
- import { deeplyFulfilled } from '@endo/marshal';
5
- import { M, objectMap } from '@endo/patterns';
3
+ import { M } from '@endo/patterns';
6
4
  import { orcUtils } from '../utils/orc.js';
7
5
  import { withOrchestration } from '../utils/start-helper.js';
8
6
 
9
7
  /**
10
- * @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
8
+ * @import {Orchestrator, CosmosValidatorAddress} from '../types.js'
11
9
  * @import {TimerService} from '@agoric/time';
12
10
  * @import {LocalChain} from '@agoric/vats/src/localchain.js';
13
11
  * @import {Remote} from '@agoric/internal';
@@ -20,13 +18,13 @@ import { withOrchestration } from '../utils/start-helper.js';
20
18
  /**
21
19
  * @param {Orchestrator} orch
22
20
  * @param {object} ctx
23
- * @param {ZCF} ctx.zcf
21
+ * @param {OrchestrationTools['zoeTools']['localTransfer']} ctx.localTransfer
24
22
  * @param {ZCFSeat} seat
25
23
  * @param {object} offerArgs
26
24
  * @param {Amount<'nat'>} offerArgs.staked
27
25
  * @param {CosmosValidatorAddress} offerArgs.validator
28
26
  */
29
- const stackAndSwapFn = async (orch, { zcf }, seat, offerArgs) => {
27
+ const stackAndSwapFn = async (orch, { localTransfer }, seat, offerArgs) => {
30
28
  const { give } = seat.getProposal();
31
29
 
32
30
  const omni = await orch.getChain('omniflixhub');
@@ -40,13 +38,9 @@ const stackAndSwapFn = async (orch, { zcf }, seat, offerArgs) => {
40
38
  const omniAddress = omniAccount.getAddress();
41
39
 
42
40
  // deposit funds from user seat to LocalChainAccount
43
- const payments = await withdrawFromSeat(zcf, seat, give);
44
- await deeplyFulfilled(
45
- objectMap(payments, payment =>
46
- // @ts-expect-error payment is ERef<Payment> which happens to work but isn't officially supported
47
- localAccount.deposit(payment),
48
- ),
49
- );
41
+ // TODO localTransfer type returns vow but in the guest context it should be a promise
42
+ // @ts-expect-error XXX localAccount type
43
+ await localTransfer(seat, localAccount, give);
50
44
  seat.exit();
51
45
 
52
46
  // build swap instructions with orcUtils library
@@ -104,7 +98,7 @@ export const makeNatAmountShape = (brand, min) =>
104
98
  * @param {Zone} zone
105
99
  * @param {OrchestrationTools} tools
106
100
  */
107
- const contract = async (zcf, privateArgs, zone, { orchestrate }) => {
101
+ const contract = async (zcf, privateArgs, zone, { orchestrate, zoeTools }) => {
108
102
  const { brands } = zcf.getTerms();
109
103
 
110
104
  /** deprecated historical example */
@@ -114,7 +108,11 @@ const contract = async (zcf, privateArgs, zone, { orchestrate }) => {
114
108
  * { staked: Amount<'nat'>; validator: CosmosValidatorAddress }
115
109
  * >}
116
110
  */
117
- const swapAndStakeHandler = orchestrate('LSTTia', { zcf }, stackAndSwapFn);
111
+ const swapAndStakeHandler = orchestrate(
112
+ 'LSTTia',
113
+ { zcf, localTransfer: zoeTools.localTransfer },
114
+ stackAndSwapFn,
115
+ );
118
116
 
119
117
  const publicFacet = zone.exo('publicFacet', undefined, {
120
118
  makeSwapAndStakeInvitation() {
@@ -71,6 +71,11 @@ export function prepareOrchestratorKit(zone: Zone, { chainHub, localchain, makeL
71
71
  asAmount: () => never;
72
72
  };
73
73
  }>;
74
+ /**
75
+ * Host side of the Orchestrator interface. (Methods return vows instead of
76
+ * promises as the interface within the guest function.)
77
+ */
78
+ export type HostOrchestrator = ReturnType<ReturnType<typeof prepareOrchestratorKit>>["orchestrator"];
74
79
  import type { Zone } from '@agoric/base-zone';
75
80
  import type { AsyncFlowTools } from '@agoric/async-flow';
76
81
  import type { ChainHub } from './chain-hub.js';
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["orchestrator.js"],"names":[],"mappings":"AAmCA,0BAA0B;AAC1B;;;;;GAKG;AAkBI,6CAfI,IAAI,+FACJ;IACV,cAAkB,EAAE,cAAc,CAAC;IACnC,QAAY,EAAE,QAAQ,CAAC;IACvB,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,eAAmB,EAAE,eAAe,CAAC;IACrC,oBAAwB,EAAE,oBAAoB,CAAC;IAC/C,qBAAyB,EAAE,qBAAqB,CAAC;IACjD,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,QAAY,EAAE,QAAQ,CAAC;IACvB,GAAO,EAAE,GAAG,CAAC;CACV;IAmCE,2DAA2D;;QAEzD,yCAAyC;;;;;;;;;;;;;IAK3C;;;OAGG;;QAED;;;;;WAKG;;;;;;;;;;;;;;QAMH,qDAAqD;;;;;;;;;;;;;GAwB1D;0BA5HoB,mBAAmB;oCAET,oBAAoB;8BAD1B,gBAAgB;gCAId,gCAAgC;4BAEpC,kBAAkB;qCADI,6CAA6C;0CAKrD,yBAAyB;2CACxB,0BAA0B;6CAHxB,gCAAgC;kCAL3C,cAAc;8BADb,aAAa;+BAU4E,aAAa;uCAAb,aAAa;yBAVtG,aAAa;0CAU4E,aAAa;kCAAb,aAAa;2BAAb,aAAa"}
1
+ {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["orchestrator.js"],"names":[],"mappings":"AAmCA,0BAA0B;AAC1B;;;;;GAKG;AAkBI,6CAfI,IAAI,+FACJ;IACV,cAAkB,EAAE,cAAc,CAAC;IACnC,QAAY,EAAE,QAAQ,CAAC;IACvB,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,eAAmB,EAAE,eAAe,CAAC;IACrC,oBAAwB,EAAE,oBAAoB,CAAC;IAC/C,qBAAyB,EAAE,qBAAqB,CAAC;IACjD,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,QAAY,EAAE,QAAQ,CAAC;IACvB,GAAO,EAAE,GAAG,CAAC;CACV;IAmCE,2DAA2D;;QAEzD,yCAAyC;;;;;;;;;;;;;IAK3C;;;OAGG;;QAED;;;;;WAKG;;;;;;;;;;;;;;QAMH,qDAAqD;;;;;;;;;;;;;GAwB1D;;;;;+BAMU,UAAU,CACtB,UAAc,CAAC,OAAO,sBAAsB,CAAC,CAC1C,CAAC,cAAc,CAAC;0BApIG,mBAAmB;oCAET,oBAAoB;8BAD1B,gBAAgB;gCAId,gCAAgC;4BAEpC,kBAAkB;qCADI,6CAA6C;0CAKrD,yBAAyB;2CACxB,0BAA0B;6CAHxB,gCAAgC;kCAL3C,cAAc;8BADb,aAAa;+BAU4E,aAAa;uCAAb,aAAa;yBAVtG,aAAa;0CAU4E,aAAa;kCAAb,aAAa;2BAAb,aAAa"}
@@ -139,3 +139,11 @@ export const prepareOrchestratorKit = (
139
139
  },
140
140
  );
141
141
  harden(prepareOrchestratorKit);
142
+ /**
143
+ * Host side of the Orchestrator interface. (Methods return vows instead of
144
+ * promises as the interface within the guest function.)
145
+ *
146
+ * @typedef {ReturnType<
147
+ * ReturnType<typeof prepareOrchestratorKit>
148
+ * >['orchestrator']} HostOrchestrator
149
+ */
package/src/facade.d.ts CHANGED
@@ -1,56 +1,33 @@
1
- export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode, orchestrationService, localchain, chainHub, makeLocalOrchestrationAccountKit, makeRecorderKit, makeLocalChainFacade, makeRemoteChainFacade, vowTools, asyncFlowTools, }: {
1
+ export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode, orchestrationService, makeRecorderKit, makeOrchestrator, vowTools, asyncFlowTools, }: {
2
2
  zone: Zone;
3
3
  timerService: Remote<TimerService>;
4
4
  zcf: ZCF;
5
5
  storageNode: Remote<StorageNode>;
6
6
  orchestrationService: Remote<CosmosInterchainService>;
7
- localchain: Remote<LocalChain>;
8
- chainHub: import("./exos/chain-hub.js").ChainHub;
9
- makeLocalOrchestrationAccountKit: MakeLocalOrchestrationAccountKit;
10
7
  makeRecorderKit: MakeRecorderKit;
11
- makeCosmosOrchestrationAccount: any;
12
- makeLocalChainFacade: MakeLocalChainFacade;
13
- makeRemoteChainFacade: MakeRemoteChainFacade;
8
+ makeOrchestrator: () => HostOrchestrator;
14
9
  vowTools: VowTools;
15
10
  asyncFlowTools: AsyncFlowTools;
16
11
  }): {
17
- /**
18
- * @template GuestReturn
19
- * @template HostReturn
20
- * @template GuestContext
21
- * @template HostContext
22
- * @template {any[]} GuestArgs
23
- * @template {any[]} HostArgs
24
- * @param {string} durableName - the orchestration flow identity in the zone
25
- * (to resume across upgrades)
26
- * @param {HostContext} hostCtx - values to pass through the async flow
27
- * membrane
28
- * @param {(
29
- * guestOrc: Orchestrator,
30
- * guestCtx: GuestContext,
31
- * ...args: GuestArgs
32
- * ) => Promise<GuestReturn>} guestFn
33
- * @returns {(...args: HostArgs) => Promise<HostReturn>} TODO returns a
34
- * Promise for now for compat before use of asyncFlow. But really should
35
- * be `Vow<HostReturn>`
36
- */
37
- orchestrate<GuestReturn, HostReturn, GuestContext, HostContext, GuestArgs extends any[], HostArgs extends any[]>(durableName: string, hostCtx: HostContext, guestFn: (guestOrc: Orchestrator, guestCtx: GuestContext, ...args: GuestArgs) => Promise<GuestReturn>): (...args: HostArgs) => Promise<HostReturn>;
38
12
  adminAsyncFlow: import("@endo/exo").Guarded<{
39
13
  getFailures(): import("@endo/patterns").CopyMap<any, import("@endo/pass-style").Passable>;
40
14
  wakeAll(): void;
41
15
  getFlowForOutcomeVow(outcomeVow: any): any;
42
16
  }>;
17
+ orchestrate: <GuestReturn, HostReturn, GuestContext, HostContext, GuestArgs extends any[], HostArgs extends any[]>(durableName: string, hostCtx: HostContext, guestFn: (guestOrc: Orchestrator, guestCtx: GuestContext, ...args: GuestArgs) => Promise<GuestReturn>) => (...args: HostArgs) => Promise<HostReturn>;
18
+ orchestrateAll: (guestFns: {
19
+ [durableName: string]: (...args: any[]) => any;
20
+ }, hostCtx: any) => {
21
+ [k: string]: (...args: any[]) => Promise<any>;
22
+ };
43
23
  };
44
24
  export type OrchestrationFacade = ReturnType<typeof makeOrchestrationFacade>;
45
25
  import type { Zone } from '@agoric/zone';
46
26
  import type { TimerService } from '@agoric/time';
47
27
  import type { Remote } from '@agoric/internal';
48
28
  import type { CosmosInterchainService } from './exos/cosmos-interchain-service.js';
49
- import type { LocalChain } from '@agoric/vats/src/localchain.js';
50
- import type { MakeLocalOrchestrationAccountKit } from './exos/local-orchestration-account.js';
51
29
  import type { MakeRecorderKit } from '@agoric/zoe/src/contractSupport/recorder.js';
52
- import type { MakeLocalChainFacade } from './exos/local-chain-facade.js';
53
- import type { MakeRemoteChainFacade } from './exos/remote-chain-facade.js';
30
+ import type { HostOrchestrator } from './exos/orchestrator.js';
54
31
  import type { VowTools } from '@agoric/vow';
55
32
  import type { AsyncFlowTools } from '@agoric/async-flow';
56
33
  import type { Orchestrator } from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"AAwCO,yPAjBI;IACV,IAAQ,EAAE,IAAI,CAAC;IACf,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,GAAO,EAAE,GAAG,CAAC;IACb,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,QAAY,EAAE,OAAO,qBAAqB,EAAE,QAAQ,CAAC;IACrD,gCAAoC,EAAE,gCAAgC,CAAC;IACvE,eAAmB,EAAE,eAAe,CAAC;IACrC,8BAAkC,EAAE,GAAG,CAAC;IACxC,oBAAwB,EAAE,oBAAoB,CAAC;IAC/C,qBAAyB,EAAE,qBAAqB,CAAC;IACjD,QAAY,EAAE,QAAQ,CAAC;IACvB,cAAkB,EAAE,cAAc,CAAC;CAChC;IAmDA;;;;;;;;;;;;;;;;;;;OAmBG;gBAlBU,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACH,SAAS,SAAhB,GAAG,EAAG,EACC,QAAQ,SAAf,GAAG,EAAG,eACT,MAAM,WAEN,WAAW,WAEX,CACV,QAAY,EAAE,YAAY,EAC1B,QAAY,EAAE,YAAY,EAC1B,GAAO,IAAI,EAAE,SAAS,KACf,OAAO,CAAC,WAAW,CAAC,GACf,CAAC,GAAG,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,UAAU,CAAC;;;;;;EAwB1D;kCAEa,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BA3HjC,cAAc;kCAEN,cAAc;4BAIpB,kBAAkB;6CACD,qCAAqC;gCAHlD,gCAAgC;sDAOV,uCAAuC;qCAN3C,6CAA6C;0CAIrD,8BAA8B;2CAC7B,+BAA+B;8BATvC,aAAa;oCAFZ,oBAAoB;kCASsD,YAAY"}
1
+ {"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"AA6BO,sKAZI;IACV,IAAQ,EAAE,IAAI,CAAC;IACf,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,GAAO,EAAE,GAAG,CAAC;IACb,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,eAAmB,EAAE,eAAe,CAAC;IACrC,gBAAoB,EAAE,MAAM,gBAAgB,CAAC;IAC7C,QAAY,EAAE,QAAQ,CAAC;IACvB,cAAkB,EAAE,cAAc,CAAC;CAChC;;;;;;kBA8BW,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACH,SAAS,SAAhB,GAAG,EAAG,EACC,QAAQ,SAAf,GAAG,EAAG,eACT,MAAM,WAEN,WAAW,WAEX,CACV,QAAY,EAAE,YAAY,EAC1B,QAAY,EAAE,YAAY,EAC1B,GAAO,IAAI,EAAE,SAAS,KACf,OAAO,CAAC,WAAW,CAAC,KACf,CAAC,GAAG,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,UAAU,CAAC;+BA4B5C;QAAE,CAAC,WAAW,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;KAAE,WAClD,GAAG;yCA7BsB,OAAO,KAAY;;EA4CxD;kCAEa,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BAhHjC,cAAc;kCAEN,cAAc;4BAGpB,kBAAkB;6CACD,qCAAqC;qCAHhC,6CAA6C;sCACzD,wBAAwB;8BAH3B,aAAa;oCAFZ,oBAAoB;kCAQsD,YAAY"}
package/src/facade.js CHANGED
@@ -1,23 +1,17 @@
1
- /** @file Orchestration service */
1
+ /** @file Orchestration facade */
2
2
 
3
3
  import { Fail } from '@endo/errors';
4
- import { pickFacet } from '@agoric/vat-data';
5
- import { prepareOrchestratorKit } from './exos/orchestrator.js';
6
4
 
7
5
  /**
8
6
  * @import {AsyncFlowTools} from '@agoric/async-flow';
9
7
  * @import {Zone} from '@agoric/zone';
10
8
  * @import {Vow, VowTools} from '@agoric/vow';
11
9
  * @import {TimerService} from '@agoric/time';
12
- * @import {IBCConnectionID} from '@agoric/vats';
13
- * @import {LocalChain} from '@agoric/vats/src/localchain.js';
14
10
  * @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'.
11
+ * @import {HostOrchestrator} from './exos/orchestrator.js';
15
12
  * @import {Remote} from '@agoric/internal';
16
13
  * @import {CosmosInterchainService} from './exos/cosmos-interchain-service.js';
17
14
  * @import {Chain, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, Orchestrator} from './types.js';
18
- * @import {MakeLocalChainFacade} from './exos/local-chain-facade.js';
19
- * @import {MakeRemoteChainFacade} from './exos/remote-chain-facade.js';
20
- * @import {MakeLocalOrchestrationAccountKit} from './exos/local-orchestration-account.js';
21
15
  */
22
16
 
23
17
  /**
@@ -27,13 +21,8 @@ import { prepareOrchestratorKit } from './exos/orchestrator.js';
27
21
  * zcf: ZCF;
28
22
  * storageNode: Remote<StorageNode>;
29
23
  * orchestrationService: Remote<CosmosInterchainService>;
30
- * localchain: Remote<LocalChain>;
31
- * chainHub: import('./exos/chain-hub.js').ChainHub;
32
- * makeLocalOrchestrationAccountKit: MakeLocalOrchestrationAccountKit;
33
24
  * makeRecorderKit: MakeRecorderKit;
34
- * makeCosmosOrchestrationAccount: any;
35
- * makeLocalChainFacade: MakeLocalChainFacade;
36
- * makeRemoteChainFacade: MakeRemoteChainFacade;
25
+ * makeOrchestrator: () => HostOrchestrator;
37
26
  * vowTools: VowTools;
38
27
  * asyncFlowTools: AsyncFlowTools;
39
28
  * }} powers
@@ -44,12 +33,8 @@ export const makeOrchestrationFacade = ({
44
33
  zcf,
45
34
  storageNode,
46
35
  orchestrationService,
47
- localchain,
48
- chainHub,
49
- makeLocalOrchestrationAccountKit,
50
36
  makeRecorderKit,
51
- makeLocalChainFacade,
52
- makeRemoteChainFacade,
37
+ makeOrchestrator,
53
38
  vowTools,
54
39
  asyncFlowTools,
55
40
  }) => {
@@ -59,73 +44,75 @@ export const makeOrchestrationFacade = ({
59
44
  storageNode &&
60
45
  orchestrationService &&
61
46
  // @ts-expect-error type says defined but double check
62
- makeLocalOrchestrationAccountKit &&
63
- // @ts-expect-error type says defined but double check
64
47
  makeRecorderKit &&
65
48
  // @ts-expect-error type says defined but double check
66
- makeRemoteChainFacade &&
49
+ makeOrchestrator &&
67
50
  asyncFlowTools) ||
68
51
  Fail`params missing`;
69
52
 
70
- const makeOrchestratorKit = prepareOrchestratorKit(zone, {
71
- asyncFlowTools,
72
- chainHub,
73
- localchain,
74
- makeRecorderKit,
75
- makeLocalChainFacade,
76
- makeRemoteChainFacade,
77
- orchestrationService,
78
- storageNode,
79
- timerService,
80
- vowTools,
81
- zcf,
82
- });
83
- const makeOrchestrator = pickFacet(makeOrchestratorKit, 'orchestrator');
84
-
85
53
  const { prepareEndowment, asyncFlow, adminAsyncFlow } = asyncFlowTools;
86
54
 
87
55
  const { when } = vowTools;
88
56
 
89
- return {
90
- /**
91
- * @template GuestReturn
92
- * @template HostReturn
93
- * @template GuestContext
94
- * @template HostContext
95
- * @template {any[]} GuestArgs
96
- * @template {any[]} HostArgs
97
- * @param {string} durableName - the orchestration flow identity in the zone
98
- * (to resume across upgrades)
99
- * @param {HostContext} hostCtx - values to pass through the async flow
100
- * membrane
101
- * @param {(
102
- * guestOrc: Orchestrator,
103
- * guestCtx: GuestContext,
104
- * ...args: GuestArgs
105
- * ) => Promise<GuestReturn>} guestFn
106
- * @returns {(...args: HostArgs) => Promise<HostReturn>} TODO returns a
107
- * Promise for now for compat before use of asyncFlow. But really should
108
- * be `Vow<HostReturn>`
109
- */
110
- orchestrate(durableName, hostCtx, guestFn) {
111
- const subZone = zone.subZone(durableName);
57
+ /**
58
+ * @template GuestReturn
59
+ * @template HostReturn
60
+ * @template GuestContext
61
+ * @template HostContext
62
+ * @template {any[]} GuestArgs
63
+ * @template {any[]} HostArgs
64
+ * @param {string} durableName - the orchestration flow identity in the zone
65
+ * (to resume across upgrades)
66
+ * @param {HostContext} hostCtx - values to pass through the async flow
67
+ * membrane
68
+ * @param {(
69
+ * guestOrc: Orchestrator,
70
+ * guestCtx: GuestContext,
71
+ * ...args: GuestArgs
72
+ * ) => Promise<GuestReturn>} guestFn
73
+ * @returns {(...args: HostArgs) => Promise<HostReturn>} TODO returns a
74
+ * Promise for now for compat before use of asyncFlow. But really should be
75
+ * `Vow<HostReturn>`
76
+ */
77
+ const orchestrate = (durableName, hostCtx, guestFn) => {
78
+ const subZone = zone.subZone(durableName);
112
79
 
113
- const hostOrc = makeOrchestrator();
80
+ const hostOrc = makeOrchestrator();
114
81
 
115
- const [wrappedOrc, wrappedCtx] = prepareEndowment(subZone, 'endowments', [
116
- hostOrc,
117
- hostCtx,
118
- ]);
82
+ const [wrappedOrc, wrappedCtx] = prepareEndowment(subZone, 'endowments', [
83
+ hostOrc,
84
+ hostCtx,
85
+ ]);
119
86
 
120
- const hostFn = asyncFlow(subZone, 'asyncFlow', guestFn);
87
+ const hostFn = asyncFlow(subZone, 'asyncFlow', guestFn);
121
88
 
122
- const orcFn = (...args) =>
123
- // TODO remove the `when` after fixing the return type
124
- // to `Vow<HostReturn>`
125
- when(hostFn(wrappedOrc, wrappedCtx, ...args));
126
- return harden(orcFn);
127
- },
89
+ const orcFn = (...args) =>
90
+ // TODO remove the `when` after fixing the return type
91
+ // to `Vow<HostReturn>`
92
+ when(hostFn(wrappedOrc, wrappedCtx, ...args));
93
+ return harden(orcFn);
94
+ };
95
+
96
+ /**
97
+ * Orchestrate all the guest functions.
98
+ *
99
+ * NOTE multiple calls to this with the same guestFn name will fail
100
+ *
101
+ * @param {{ [durableName: string]: (...args: any[]) => any }} guestFns
102
+ * @param {any} hostCtx
103
+ */
104
+ const orchestrateAll = (guestFns, hostCtx) =>
105
+ Object.fromEntries(
106
+ Object.entries(guestFns).map(([name, guestFn]) => [
107
+ name,
108
+ orchestrate(name, hostCtx, guestFn),
109
+ ]),
110
+ );
111
+
112
+ return {
128
113
  adminAsyncFlow,
114
+ orchestrate,
115
+ orchestrateAll,
129
116
  };
130
117
  };
131
118
  harden(makeOrchestrationFacade);
@@ -17,15 +17,46 @@ export function provideOrchestration(zcf: ZCF, baggage: Baggage, remotePowers: O
17
17
  allVows: (maybeVows: import("@agoric/vow").EVow<unknown>[]) => import("@agoric/vow").Vow<any[]>;
18
18
  asVow: <T extends unknown>(fn: (...args: any[]) => import("@agoric/vow").Vow<Awaited<T>> | Awaited<T> | import("@agoric/vow").PromiseVow<T>) => import("@agoric/vow").Vow<Awaited<T>>;
19
19
  asPromise: import("@agoric/vow").AsPromiseFunction;
20
- retriable: <T>(fnZone: Zone, name: string, fn: (...args: unknown[]) => import("@agoric/vow").ERef<T>) => (...args: unknown[]) => import("@agoric/vow").Vow<T>;
20
+ retriable: <F extends (...args: any[]) => any>(fnZone: Zone, name: string, fn: F) => PromiseToVow<F>;
21
+ };
22
+ zoeTools: {
23
+ localTransfer: (srcSeat: ZCFSeat, localAccount: import("@endo/exo").Guarded<{
24
+ getBalance(denom: import("../orchestration-api.js").DenomArg): import("@agoric/vow").Vow<import("../orchestration-api.js").DenomAmount>;
25
+ getBalances(): import("@agoric/vow").Vow<never>;
26
+ getPublicTopics(): {
27
+ account: {
28
+ description: string;
29
+ subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
30
+ storagePath: Promise<string>;
31
+ };
32
+ };
33
+ delegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<Record<unknown, unknown>>;
34
+ undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<void | import("@agoric/time").TimestampRecord>;
35
+ deposit(payment: globalThis.Payment<"nat">, optAmountShape?: globalThis.Pattern): import("@agoric/vow").Vow<import("@agoric/ertp/src/types.js").NatAmount | import("@agoric/vow").Vow<import("@agoric/ertp/src/types.js").NatAmount>>;
36
+ withdraw(amount: import("@agoric/ertp/src/types.js").NatAmount): import("@agoric/vow").Vow<globalThis.Payment<"nat"> | import("@agoric/vow").Vow<globalThis.Payment<"nat">>>;
37
+ executeTx(messages: {
38
+ '@type': string;
39
+ }[]): import("@agoric/vow").Vow<import("@agoric/cosmic-proto").JsonSafe<{
40
+ '@type': string;
41
+ }>[]>;
42
+ getAddress(): import("../orchestration-api.js").ChainAddress;
43
+ send(toAccount: any, amount: any): import("@agoric/vow").Vow<never>;
44
+ transfer(amount: import("../orchestration-api.js").AmountArg, destination: import("../orchestration-api.js").ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): import("@agoric/vow").Vow<void>;
45
+ transferSteps(amount: import("../orchestration-api.js").AmountArg, msg: import("../orchestration-api.js").TransferMsg): import("@agoric/vow").Vow<void>;
46
+ }>, give: AmountKeywordRecord) => import("@agoric/vow").Vow<void>;
21
47
  };
22
48
  zone: Zone;
23
- orchestrate<GuestReturn, HostReturn, GuestContext, HostContext, GuestArgs extends any[], HostArgs extends any[]>(durableName: string, hostCtx: HostContext, guestFn: (guestOrc: import("../orchestration-api.js").Orchestrator, guestCtx: GuestContext, ...args: GuestArgs) => Promise<GuestReturn>): (...args: HostArgs) => Promise<HostReturn>;
24
49
  adminAsyncFlow: import("@endo/exo").Guarded<{
25
50
  getFailures(): import("@endo/patterns").CopyMap<any, import("@endo/pass-style").Passable>;
26
51
  wakeAll(): void;
27
52
  getFlowForOutcomeVow(outcomeVow: any): any;
28
53
  }>;
54
+ orchestrate: <GuestReturn, HostReturn, GuestContext, HostContext, GuestArgs extends any[], HostArgs extends any[]>(durableName: string, hostCtx: HostContext, guestFn: (guestOrc: import("../orchestration-api.js").Orchestrator, guestCtx: GuestContext, ...args: GuestArgs) => Promise<GuestReturn>) => (...args: HostArgs) => Promise<HostReturn>;
55
+ orchestrateAll: (guestFns: {
56
+ [durableName: string]: (...args: any[]) => any;
57
+ }, hostCtx: any) => {
58
+ [k: string]: (...args: any[]) => Promise<any>;
59
+ };
29
60
  };
30
61
  export function withOrchestration<CT extends Record<string, unknown>, PA extends OrchestrationPowers & {
31
62
  marshaller: Marshaller;
@@ -1 +1 @@
1
- {"version":3,"file":"start-helper.d.ts","sourceRoot":"","sources":["start-helper.js"],"names":[],"mappings":"AAyCO,0CALI,GAAG,WACH,OAAO,gBACP,mBAAmB,cACnB,UAAU;;;;;;;;;;;;;;;;;wCAwC0B,GAAG;;wDA9Cd,GAAG,uDAC9B,GAAG;;;4PAsEK,GAAa,4CAK1B,GAAG;;;;;;EAaN;AAuBM,kCAdgC,EAAE,SAA3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,EAGhC,EAAE,SAFM,mBAAmB,GAAG;IACnC,UAAc,EAAE,UAAU,CAAC;CACvB,EACQ,CAAC,cACH,CACV,GAAO,EAAE,GAAG,CAAC,EAAE,CAAC,EAChB,WAAe,EAAE,EAAE,EACnB,IAAQ,EAAE,IAAI,EACd,KAAS,EAAE,kBAAkB,KACtB,OAAO,CAAC,CAAC,CAAC,GACL,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAYzE;kCAnIU;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;iCAgGU,IAAI,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,EAAE,MAAM,CAAC;6BA9GzC,kBAAkB;0BAGrB,cAAc;gCALR,gCAAgC;4BAIpC,aAAa;6CAEI,sCAAsC;kCALrC,cAAc;6BAE/B,cAAc"}
1
+ {"version":3,"file":"start-helper.d.ts","sourceRoot":"","sources":["start-helper.js"],"names":[],"mappings":"AA8CO,0CALI,GAAG,WACH,OAAO,gBACP,mBAAmB,cACnB,UAAU;;;;;;;;;;;;;;;;;wCA+B+B,GAAG;;+BA/BtD,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8PAeA,GAAO,8CAEe,GAAG;;gCAgCzB,GAAE;;;;EAuDL;AAuBM,kCAdgC,EAAE,SAA3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,EAGhC,EAAE,SAFM,mBAAmB,GAAG;IACnC,UAAc,EAAE,UAAU,CAAC;CACvB,EACQ,CAAC,cACH,CACV,GAAO,EAAE,GAAG,CAAC,EAAE,CAAC,EAChB,WAAe,EAAE,EAAE,EACnB,IAAQ,EAAE,IAAI,EACd,KAAS,EAAE,kBAAkB,KACtB,OAAO,CAAC,CAAC,CAAC,GACL,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAYzE;kCA1JU;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;iCAuHU,IAAI,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,EAAE,MAAM,CAAC;6BArIzC,kBAAkB;0BAGrB,cAAc;gCALR,gCAAgC;4BAIpC,aAAa;6CAEI,sCAAsC;kCALrC,cAAc;6BAE/B,cAAc"}
@@ -1,13 +1,16 @@
1
1
  import { prepareAsyncFlowTools } from '@agoric/async-flow';
2
+ import { pickFacet } from '@agoric/vat-data';
2
3
  import { prepareVowTools } from '@agoric/vow';
3
4
  import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
4
5
  import { makeDurableZone } from '@agoric/zone/durable.js';
5
- import { prepareLocalOrchestrationAccountKit } from '../exos/local-orchestration-account.js';
6
- import { makeOrchestrationFacade } from '../facade.js';
7
6
  import { makeChainHub } from '../exos/chain-hub.js';
8
- import { prepareRemoteChainFacade } from '../exos/remote-chain-facade.js';
9
7
  import { prepareCosmosOrchestrationAccount } from '../exos/cosmos-orchestration-account.js';
10
8
  import { prepareLocalChainFacade } from '../exos/local-chain-facade.js';
9
+ import { prepareLocalOrchestrationAccountKit } from '../exos/local-orchestration-account.js';
10
+ import { prepareOrchestratorKit } from '../exos/orchestrator.js';
11
+ import { prepareRemoteChainFacade } from '../exos/remote-chain-facade.js';
12
+ import { makeOrchestrationFacade } from '../facade.js';
13
+ import { makeZoeTools } from './zoe-tools.js';
11
14
 
12
15
  /**
13
16
  * @import {PromiseKit} from '@endo/promise-kit'
@@ -34,6 +37,8 @@ import { prepareLocalChainFacade } from '../exos/local-chain-facade.js';
34
37
  * Helper that a contract start function can use to set up the objects needed
35
38
  * for orchestration.
36
39
  *
40
+ * TODO strip problematic operations from ZCF (e.g., getPayouts)
41
+ *
37
42
  * @param {ZCF} zcf
38
43
  * @param {Baggage} baggage
39
44
  * @param {OrchestrationPowers} remotePowers
@@ -58,6 +63,7 @@ export const provideOrchestration = (
58
63
  contract: zone.subZone('contract'),
59
64
  orchestration: zone.subZone('orchestration'),
60
65
  vows: zone.subZone('vows'),
66
+ zoe: zone.subZone('zoe'),
61
67
  };
62
68
  })();
63
69
 
@@ -67,6 +73,8 @@ export const provideOrchestration = (
67
73
 
68
74
  const chainHub = makeChainHub(agoricNames, vowTools);
69
75
 
76
+ const zoeTools = makeZoeTools(zones.zoe, { zcf, vowTools });
77
+
70
78
  const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);
71
79
  const makeLocalOrchestrationAccountKit = prepareLocalOrchestrationAccountKit(
72
80
  zones.orchestration,
@@ -106,20 +114,38 @@ export const provideOrchestration = (
106
114
  vowTools,
107
115
  });
108
116
 
109
- const facade = makeOrchestrationFacade({
110
- zcf,
111
- zone: zones.orchestration,
117
+ const makeOrchestratorKit = prepareOrchestratorKit(zones.orchestration, {
118
+ asyncFlowTools,
112
119
  chainHub,
113
- makeLocalOrchestrationAccountKit,
120
+ localchain: remotePowers.localchain,
114
121
  makeRecorderKit,
115
- makeCosmosOrchestrationAccount,
116
122
  makeLocalChainFacade,
117
123
  makeRemoteChainFacade,
124
+ storageNode: remotePowers.storageNode,
125
+ orchestrationService: remotePowers.orchestrationService,
126
+ timerService,
127
+ vowTools,
128
+ zcf,
129
+ });
130
+
131
+ const makeOrchestrator = pickFacet(makeOrchestratorKit, 'orchestrator');
132
+
133
+ const facade = makeOrchestrationFacade({
134
+ zcf,
135
+ zone: zones.orchestration,
136
+ makeRecorderKit,
137
+ makeOrchestrator,
118
138
  asyncFlowTools,
119
139
  vowTools,
120
140
  ...remotePowers,
121
141
  });
122
- return { ...facade, chainHub, vowTools, zone: zones.contract };
142
+ return {
143
+ ...facade,
144
+ chainHub,
145
+ vowTools,
146
+ zoeTools,
147
+ zone: zones.contract,
148
+ };
123
149
  };
124
150
  harden(provideOrchestration);
125
151
 
@@ -0,0 +1,33 @@
1
+ export function makeZoeTools(zone: Zone, { zcf, vowTools }: {
2
+ zcf: ZCF;
3
+ vowTools: VowTools;
4
+ }): {
5
+ localTransfer: (srcSeat: ZCFSeat, localAccount: import("@endo/exo").Guarded<{
6
+ getBalance(denom: import("../orchestration-api.js").DenomArg): Vow<import("../orchestration-api.js").DenomAmount>;
7
+ getBalances(): Vow<never>;
8
+ getPublicTopics(): {
9
+ account: {
10
+ description: string;
11
+ subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
12
+ storagePath: Promise<string>;
13
+ };
14
+ };
15
+ delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Vow<Record<unknown, unknown>>;
16
+ undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Vow<void | import("@agoric/time").TimestampRecord>;
17
+ deposit(payment: globalThis.Payment<"nat">, optAmountShape?: globalThis.Pattern): Vow<import("@agoric/ertp/src/types.js").NatAmount | Vow<import("@agoric/ertp/src/types.js").NatAmount>>;
18
+ withdraw(amount: import("@agoric/ertp/src/types.js").NatAmount): Vow<globalThis.Payment<"nat"> | Vow<globalThis.Payment<"nat">>>;
19
+ executeTx(messages: {
20
+ '@type': string;
21
+ }[]): Vow<import("@agoric/cosmic-proto").JsonSafe<{
22
+ '@type': string;
23
+ }>[]>;
24
+ getAddress(): import("../orchestration-api.js").ChainAddress;
25
+ send(toAccount: any, amount: any): Vow<never>;
26
+ transfer(amount: import("../orchestration-api.js").AmountArg, destination: import("../orchestration-api.js").ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): Vow<void>;
27
+ transferSteps(amount: import("../orchestration-api.js").AmountArg, msg: import("../orchestration-api.js").TransferMsg): Vow<void>;
28
+ }>, give: AmountKeywordRecord) => Vow<void>;
29
+ };
30
+ import type { Zone } from '@agoric/zone';
31
+ import type { VowTools } from '@agoric/vow';
32
+ import type { Vow } from '@agoric/vow';
33
+ //# sourceMappingURL=zoe-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zoe-tools.d.ts","sourceRoot":"","sources":["zoe-tools.js"],"names":[],"mappings":"AAcO,mCAHI,IAAI,qBACJ;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;EAmD1C;0BAzDsB,cAAc;8BADL,aAAa;yBAAb,aAAa"}
@@ -0,0 +1,64 @@
1
+ import { Fail } from '@endo/errors';
2
+ import { atomicTransfer } from '@agoric/zoe/src/contractSupport/index.js';
3
+
4
+ /**
5
+ * @import {LocalOrchestrationAccountKit} from '../exos/local-orchestration-account.js';
6
+ * @import {Vow, VowTools} from '@agoric/vow';
7
+ * @import {Zone} from '@agoric/zone';
8
+ * @import {OrchestrationAccount} from '../orchestration-api.js'
9
+ */
10
+
11
+ /**
12
+ * @param {Zone} zone
13
+ * @param {{ zcf: ZCF; vowTools: VowTools }} io
14
+ */
15
+ export const makeZoeTools = (zone, { zcf, vowTools }) => {
16
+ /**
17
+ * Transfer the `give` a seat to a local account.
18
+ */
19
+ const localTransfer = vowTools.retriable(
20
+ zone,
21
+ 'localTransfer',
22
+ /**
23
+ * @type {(
24
+ * srcSeat: ZCFSeat,
25
+ * localAccount: LocalOrchestrationAccountKit['holder'],
26
+ * give: AmountKeywordRecord,
27
+ * ) => Promise<void>}
28
+ */
29
+ async (srcSeat, localAccount, give) => {
30
+ !srcSeat.hasExited() || Fail`The seat cannot have exited.`;
31
+ const { zcfSeat: tempSeat, userSeat: userSeatP } = zcf.makeEmptySeatKit();
32
+ const userSeat = await userSeatP;
33
+ atomicTransfer(zcf, srcSeat, tempSeat, give);
34
+ tempSeat.exit();
35
+ // TODO get the userSeat into baggage so it's at least recoverable
36
+ // const userSeat = await subzone.makeOnce(
37
+ // 'localTransferHelper',
38
+ // async () => {
39
+ // const { zcfSeat: tempSeat, userSeat: userSeatP } =
40
+ // zcf.makeEmptySeatKit();
41
+ // const uSeat = await userSeatP;
42
+ // // TODO how do I store in the place for this retriable?
43
+ // atomicTransfer(zcf, srcSeat, tempSeat, give);
44
+ // tempSeat.exit();
45
+ // return uSeat;
46
+ // },
47
+ // );
48
+
49
+ // Now all the `give` are accessible, so we can move them to the localAccount`
50
+
51
+ const promises = Object.entries(give).map(async ([kw, _amount]) => {
52
+ const pmt = await userSeat.getPayout(kw);
53
+ // TODO arrange recovery on upgrade of pmt?
54
+ return localAccount.deposit(pmt);
55
+ });
56
+ await Promise.all(promises);
57
+ // TODO remove userSeat from baggage
58
+ },
59
+ );
60
+
61
+ return harden({
62
+ localTransfer,
63
+ });
64
+ };