@agoric/orchestration 0.1.1-dev-80db38c.0 → 0.1.1-dev-4390d8c.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-80db38c.0+80db38c",
3
+ "version": "0.1.1-dev-4390d8c.0+4390d8c",
4
4
  "description": "Chain abstraction for Agoric's orchestration clients",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -33,20 +33,20 @@
33
33
  },
34
34
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
35
35
  "dependencies": {
36
- "@agoric/assert": "0.6.1-dev-80db38c.0+80db38c",
37
- "@agoric/async-flow": "0.1.1-dev-80db38c.0+80db38c",
38
- "@agoric/cosmic-proto": "0.4.1-dev-80db38c.0+80db38c",
39
- "@agoric/ertp": "0.16.3-dev-80db38c.0+80db38c",
40
- "@agoric/internal": "0.3.3-dev-80db38c.0+80db38c",
41
- "@agoric/network": "0.1.1-dev-80db38c.0+80db38c",
42
- "@agoric/notifier": "0.6.3-dev-80db38c.0+80db38c",
43
- "@agoric/store": "0.9.3-dev-80db38c.0+80db38c",
44
- "@agoric/time": "0.3.3-dev-80db38c.0+80db38c",
45
- "@agoric/vat-data": "0.5.3-dev-80db38c.0+80db38c",
46
- "@agoric/vats": "0.15.2-dev-80db38c.0+80db38c",
47
- "@agoric/vow": "0.1.1-dev-80db38c.0+80db38c",
48
- "@agoric/zoe": "0.26.3-dev-80db38c.0+80db38c",
49
- "@agoric/zone": "0.2.3-dev-80db38c.0+80db38c",
36
+ "@agoric/assert": "0.6.1-dev-4390d8c.0+4390d8c",
37
+ "@agoric/async-flow": "0.1.1-dev-4390d8c.0+4390d8c",
38
+ "@agoric/cosmic-proto": "0.4.1-dev-4390d8c.0+4390d8c",
39
+ "@agoric/ertp": "0.16.3-dev-4390d8c.0+4390d8c",
40
+ "@agoric/internal": "0.3.3-dev-4390d8c.0+4390d8c",
41
+ "@agoric/network": "0.1.1-dev-4390d8c.0+4390d8c",
42
+ "@agoric/notifier": "0.6.3-dev-4390d8c.0+4390d8c",
43
+ "@agoric/store": "0.9.3-dev-4390d8c.0+4390d8c",
44
+ "@agoric/time": "0.3.3-dev-4390d8c.0+4390d8c",
45
+ "@agoric/vat-data": "0.5.3-dev-4390d8c.0+4390d8c",
46
+ "@agoric/vats": "0.15.2-dev-4390d8c.0+4390d8c",
47
+ "@agoric/vow": "0.1.1-dev-4390d8c.0+4390d8c",
48
+ "@agoric/zoe": "0.26.3-dev-4390d8c.0+4390d8c",
49
+ "@agoric/zone": "0.2.3-dev-4390d8c.0+4390d8c",
50
50
  "@endo/base64": "^1.0.5",
51
51
  "@endo/far": "^1.1.2",
52
52
  "@endo/marshal": "^1.5.0",
@@ -90,5 +90,5 @@
90
90
  "typeCoverage": {
91
91
  "atLeast": 97.1
92
92
  },
93
- "gitHead": "80db38cafed64c67a087c38bda5dd3373564e50e"
93
+ "gitHead": "4390d8c21fd8ac80a9c83f55d38c52e3f98faa1e"
94
94
  }
@@ -1,21 +1,3 @@
1
- /**
2
- * @import {Baggage} from '@agoric/vat-data';
3
- * @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api';
4
- * @import {TimerService, TimerBrand} from '@agoric/time';
5
- * @import {LocalChain} from '@agoric/vats/src/localchain.js';
6
- * @import {OrchestrationService} from '../service.js';
7
- * @import {NameHub} from '@agoric/vats';
8
- * @import {Remote} from '@agoric/vow';
9
- */
10
- /**
11
- * @typedef {{
12
- * localchain: Remote<LocalChain>;
13
- * orchestrationService: Remote<OrchestrationService>;
14
- * storageNode: Remote<StorageNode>;
15
- * timerService: Remote<TimerService>;
16
- * agoricNames: Remote<NameHub>;
17
- * }} OrchestrationPowers
18
- */
19
1
  export const SingleAmountRecord: import("@endo/patterns").Matcher;
20
2
  export function start(zcf: ZCF, privateArgs: OrchestrationPowers & {
21
3
  marshaller: Marshaller;
@@ -1 +1 @@
1
- {"version":3,"file":"sendAnywhere.contract.d.ts","sourceRoot":"","sources":["sendAnywhere.contract.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AAEH;;;;;;;;GAQG;AAEH,kEAKE;AASK,2BANI,GAAG,eACH,mBAAmB,GAAG;IAChC,UAAc,EAAE,UAAU,CAAC;CACxB,WACO,OAAO;;;;;QAyFZ;;;WAGG;4BAFQ,eAAe,kBACf,iBAAiB;;GAmBjC;kCAnIY;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;6BAhBsB,kBAAkB;qCACS,eAAe;uCAAf,eAAe;gCAEvC,gCAAgC;4BAGpC,aAAa;0CAFC,eAAe;kCAFX,cAAc;6BAG/B,cAAc"}
1
+ {"version":3,"file":"sendAnywhere.contract.d.ts","sourceRoot":"","sources":["sendAnywhere.contract.js"],"names":[],"mappings":"AAoFA,kEAKE;AASK,2BANI,GAAG,eACH,mBAAmB,GAAG;IAChC,UAAc,EAAE,UAAU,CAAC;CACxB,WACO,OAAO;;;;;QAoDZ;;;WAGG;4BAFQ,eAAe,kBACf,iBAAiB;;GAmBjC;kCAhJY;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;6BAlBsB,kBAAkB;qCAKS,eAAe;uCAAf,eAAe;gCAHvC,gCAAgC;4BAEpC,aAAa;0CAEC,eAAe;kCALvB,cAAc;6BAEnB,cAAc"}
@@ -2,6 +2,7 @@ import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js'
2
2
  import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
3
3
  import { M, mustMatch } from '@endo/patterns';
4
4
  import { heapVowE as E } from '@agoric/vow/vat.js';
5
+ import { makeStateRecord } from '@agoric/async-flow';
5
6
  import { AmountShape } from '@agoric/ertp';
6
7
  import { CosmosChainInfoShape } from '../typeGuards.js';
7
8
  import { provideOrchestration } from '../utils/start-helper.js';
@@ -11,12 +12,14 @@ const { entries } = Object;
11
12
 
12
13
  /**
13
14
  * @import {Baggage} from '@agoric/vat-data';
14
- * @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api';
15
- * @import {TimerService, TimerBrand} from '@agoric/time';
15
+ * @import {TimerService} from '@agoric/time';
16
16
  * @import {LocalChain} from '@agoric/vats/src/localchain.js';
17
- * @import {OrchestrationService} from '../service.js';
18
17
  * @import {NameHub} from '@agoric/vats';
19
18
  * @import {Remote} from '@agoric/vow';
19
+ * @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api';
20
+ * @import {OrchestrationService} from '../service.js';
21
+ * @import {Orchestrator} from '../types.js'
22
+ * @import {OrchestrationAccount} from '../orchestration-api.js'
20
23
  */
21
24
 
22
25
  /**
@@ -29,6 +32,56 @@ const { entries } = Object;
29
32
  * }} OrchestrationPowers
30
33
  */
31
34
 
35
+ /**
36
+ * @param {Orchestrator} orch
37
+ * @param {object} ctx
38
+ * @param {ZCF} ctx.zcf
39
+ * @param {any} ctx.agoricNamesTools TODO Give this a better type
40
+ * @param {{ account: OrchestrationAccount<any> }} ctx.contractState
41
+ * @param {ZCFSeat} seat
42
+ * @param {object} offerArgs
43
+ * @param {string} offerArgs.chainName
44
+ * @param {string} offerArgs.destAddr
45
+ */
46
+ const sendItFn = async (
47
+ orch,
48
+ { zcf, agoricNamesTools, contractState },
49
+ seat,
50
+ offerArgs,
51
+ ) => {
52
+ mustMatch(offerArgs, harden({ chainName: M.scalar(), destAddr: M.string() }));
53
+ const { chainName, destAddr } = offerArgs;
54
+ const { give } = seat.getProposal();
55
+ const [[kw, amt]] = entries(give);
56
+ // XXX when() until membrane
57
+ const { denom } = await E.when(agoricNamesTools.findBrandInVBank(amt.brand));
58
+ const chain = await orch.getChain(chainName);
59
+
60
+ // FIXME ok to use a heap var crossing the membrane scope this way?
61
+ if (!contractState.account) {
62
+ const agoricChain = await orch.getChain('agoric');
63
+ // XXX when() until membrane
64
+ contractState.account = await E.when(agoricChain.makeAccount());
65
+ console.log('contractState.account', contractState.account);
66
+ }
67
+
68
+ // XXX when() until membrane
69
+ const info = await E.when(chain.getChainInfo());
70
+ console.log('info', info);
71
+ const { chainId } = info;
72
+ assert(typeof chainId === 'string', 'bad chainId');
73
+ const { [kw]: pmtP } = await withdrawFromSeat(zcf, seat, give);
74
+ await E.when(pmtP, pmt => contractState.account.deposit(pmt));
75
+ await contractState.account.transfer(
76
+ { denom, value: amt.value },
77
+ {
78
+ address: destAddr,
79
+ addressEncoding: 'bech32',
80
+ chainId,
81
+ },
82
+ );
83
+ };
84
+
32
85
  export const SingleAmountRecord = M.and(
33
86
  M.recordOf(M.string(), AmountShape, {
34
87
  numPropertiesLimit: 1,
@@ -55,52 +108,15 @@ export const start = async (zcf, privateArgs, baggage) => {
55
108
  vowTools,
56
109
  });
57
110
 
58
- /** @type {import('../orchestration-api.js').OrchestrationAccount<any>} */
59
- let contractAccount;
111
+ /** @type {{ account: OrchestrationAccount<any> | undefined }} */
112
+ const contractState = makeStateRecord({ account: undefined });
60
113
 
61
114
  /** @type {OfferHandler} */
62
115
  const sendIt = orchestrate(
63
116
  'sendIt',
64
- { zcf, agoricNamesTools },
117
+ { zcf, agoricNamesTools, contractState },
65
118
  // eslint-disable-next-line no-shadow -- this `zcf` is enclosed in a membrane
66
- async (orch, { zcf, agoricNamesTools }, seat, offerArgs) => {
67
- mustMatch(
68
- offerArgs,
69
- harden({ chainName: M.scalar(), destAddr: M.string() }),
70
- );
71
- const { chainName, destAddr } = offerArgs;
72
- const { give } = seat.getProposal();
73
- const [[kw, amt]] = entries(give);
74
- // XXX when() until membrane
75
- const { denom } = await E.when(
76
- agoricNamesTools.findBrandInVBank(amt.brand),
77
- );
78
- const chain = await orch.getChain(chainName);
79
-
80
- // FIXME ok to use a heap var crossing the membrane scope this way?
81
- if (!contractAccount) {
82
- const agoricChain = await orch.getChain('agoric');
83
- // XXX when() until membrane
84
- contractAccount = await E.when(agoricChain.makeAccount());
85
- console.log('contractAccount', contractAccount);
86
- }
87
-
88
- // XXX when() until membrane
89
- const info = await E.when(chain.getChainInfo());
90
- console.log('info', info);
91
- const { chainId } = info;
92
- assert(typeof chainId === 'string', 'bad chainId');
93
- const { [kw]: pmtP } = await withdrawFromSeat(zcf, seat, give);
94
- await E.when(pmtP, pmt => contractAccount.deposit(pmt));
95
- await contractAccount.transfer(
96
- { denom, value: amt.value },
97
- {
98
- address: destAddr,
99
- addressEncoding: 'bech32',
100
- chainId,
101
- },
102
- );
103
- },
119
+ sendItFn,
104
120
  );
105
121
 
106
122
  const publicFacet = zone.exo(
@@ -1,12 +1,3 @@
1
- /**
2
- * @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
3
- * @import {TimerService} from '@agoric/time';
4
- * @import {LocalChain} from '@agoric/vats/src/localchain.js';
5
- * @import {Remote} from '@agoric/internal';
6
- * @import {OrchestrationService} from '../service.js';
7
- * @import {Baggage} from '@agoric/vat-data'
8
- * @import {NameHub} from '@agoric/vats';
9
- */
10
1
  /** @type {ContractMeta<typeof start>} */
11
2
  export const meta: ContractMeta<typeof start>;
12
3
  export function makeNatAmountShape(brand: Brand, min?: bigint | undefined): {
@@ -1 +1 @@
1
- {"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AAEH,yCAAyC;AACzC,mBADW,YAAY,CAAC,OAAO,KAAK,CAAC,CAWnC;AASK,0CAHI,KAAK;;;EAIsC;AAc/C,2BAXI,GAAG,eACH;IACV,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;IACjC,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,UAAc,EAAE,UAAU,CAAC;CACxB,WACO,OAAO;;;oBA+BD,MAAM,CAAC,KAAK,CAAC;uBAAa,sBAAsB;;;;oBAAhD,MAAM,CAAC,KAAK,CAAC;uBAAa,sBAAsB;;;GAsEhE;6BAzIyB,cAAc;4BAHf,kBAAkB;gCADd,gCAAgC;0CAEtB,eAAe;kCAHvB,cAAc;6BAInB,kBAAkB;4CALuB,aAAa"}
1
+ {"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"AAuEA,yCAAyC;AACzC,mBADW,YAAY,CAAC,OAAO,KAAK,CAAC,CAWnC;AASK,0CAHI,KAAK;;;EAIsC;AAc/C,2BAXI,GAAG,eACH;IACV,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;IACjC,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,UAAc,EAAE,UAAU,CAAC;CACxB,WACO,OAAO;;;oBA+BD,MAAM,CAAC,KAAK,CAAC;uBAAa,sBAAsB;;;;oBAAhD,MAAM,CAAC,KAAK,CAAC;uBAAa,sBAAsB;;;GAsBhE;6BA5IyB,cAAc;4BAHf,kBAAkB;gCADd,gCAAgC;0CAEtB,eAAe;kCAHvB,cAAc;6BAInB,kBAAkB;4CALuB,aAAa"}
@@ -18,6 +18,57 @@ import { provideOrchestration } from '../utils/start-helper.js';
18
18
  * @import {NameHub} from '@agoric/vats';
19
19
  */
20
20
 
21
+ /**
22
+ * @param {Orchestrator} orch
23
+ * @param {object} ctx
24
+ * @param {ZCF} ctx.zcf
25
+ * @param {ZCFSeat} seat
26
+ * @param {object} offerArgs
27
+ * @param {Amount<'nat'>} offerArgs.staked
28
+ * @param {CosmosValidatorAddress} offerArgs.validator
29
+ */
30
+ const stackAndSwapFn = async (orch, { zcf }, seat, offerArgs) => {
31
+ const { give } = seat.getProposal();
32
+
33
+ const omni = await orch.getChain('omniflixhub');
34
+ const agoric = await orch.getChain('agoric');
35
+
36
+ const [omniAccount, localAccount] = await Promise.all([
37
+ // XXX when() until membrane
38
+ heapVowTools.when(omni.makeAccount()),
39
+ // XXX when() until membrane
40
+ heapVowTools.when(agoric.makeAccount()),
41
+ ]);
42
+
43
+ const omniAddress = omniAccount.getAddress();
44
+
45
+ // deposit funds from user seat to LocalChainAccount
46
+ const payments = await withdrawFromSeat(zcf, seat, give);
47
+ await deeplyFulfilled(
48
+ objectMap(payments, payment =>
49
+ // @ts-expect-error payment is ERef<Payment> which happens to work but isn't officially supported
50
+ localAccount.deposit(payment),
51
+ ),
52
+ );
53
+ seat.exit();
54
+
55
+ // build swap instructions with orcUtils library
56
+ const transferMsg = orcUtils.makeOsmosisSwap({
57
+ destChain: 'omniflixhub',
58
+ destAddress: omniAddress,
59
+ amountIn: give.Stable,
60
+ brandOut: /** @type {any} */ ('FIXME'),
61
+ slippage: 0.03,
62
+ });
63
+
64
+ await localAccount
65
+ .transferSteps(give.Stable, transferMsg)
66
+ .then(_txResult =>
67
+ omniAccount.delegate(offerArgs.validator, offerArgs.staked),
68
+ )
69
+ .catch(e => console.error(e));
70
+ };
71
+
21
72
  /** @type {ContractMeta<typeof start>} */
22
73
  export const meta = {
23
74
  privateArgsShape: {
@@ -85,55 +136,7 @@ export const start = async (zcf, privateArgs, baggage) => {
85
136
  * { staked: Amount<'nat'>; validator: CosmosValidatorAddress }
86
137
  * >}
87
138
  */
88
- const swapAndStakeHandler = orchestrate(
89
- 'LSTTia',
90
- { zcf },
91
- // eslint-disable-next-line no-shadow -- this `zcf` is enclosed in a membrane
92
- async (/** @type {Orchestrator} */ orch, { zcf }, seat, offerArgs) => {
93
- const { give } = seat.getProposal();
94
-
95
- const omni = await orch.getChain('omniflixhub');
96
- const agoric = await orch.getChain('agoric');
97
-
98
- const [omniAccount, localAccount] = await Promise.all([
99
- // XXX when() until membrane
100
- heapVowTools.when(omni.makeAccount()),
101
- // XXX when() until membrane
102
- heapVowTools.when(agoric.makeAccount()),
103
- ]);
104
-
105
- const omniAddress = omniAccount.getAddress();
106
-
107
- // deposit funds from user seat to LocalChainAccount
108
- const payments = await withdrawFromSeat(zcf, seat, give);
109
- await deeplyFulfilled(
110
- objectMap(payments, payment =>
111
- // @ts-expect-error payment is ERef<Payment> which happens to work but isn't officially supported
112
- localAccount.deposit(payment),
113
- ),
114
- );
115
- seat.exit();
116
-
117
- // build swap instructions with orcUtils library
118
- const transferMsg = orcUtils.makeOsmosisSwap({
119
- destChain: 'omniflixhub',
120
- destAddress: omniAddress,
121
- amountIn: give.Stable,
122
- brandOut: /** @type {any} */ ('FIXME'),
123
- slippage: 0.03,
124
- });
125
-
126
- await localAccount
127
- .transferSteps(give.Stable, transferMsg)
128
- .then(_txResult =>
129
- omniAccount.delegate(offerArgs.validator, offerArgs.staked),
130
- )
131
- .catch(e => console.error(e));
132
-
133
- // XXX close localAccount?
134
- // return continuing inv since this is an offer?
135
- },
136
- );
139
+ const swapAndStakeHandler = orchestrate('LSTTia', { zcf }, stackAndSwapFn);
137
140
 
138
141
  const makeSwapAndStakeInvitation = () =>
139
142
  zcf.makeInvitation(
@@ -1 +1 @@
1
- {"version":3,"file":"unbondExample.contract.d.ts","sourceRoot":"","sources":["unbondExample.contract.js"],"names":[],"mappings":"AA0BO,2BAXI,GAAG,eACH;IACV,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;IACjC,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,UAAc,EAAE,UAAU,CAAC;IAC3B,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;CACpC,WACO,OAAO;;;;;;GA0EjB;6BAzFyB,cAAc;4BACf,kBAAkB;gCAFd,gCAAgC;0CAGtB,eAAe;kCALvB,cAAc;6BACnB,kBAAkB"}
1
+ {"version":3,"file":"unbondExample.contract.d.ts","sourceRoot":"","sources":["unbondExample.contract.js"],"names":[],"mappings":"AAwDO,2BAXI,GAAG,eACH;IACV,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;IACjC,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,UAAc,EAAE,UAAU,CAAC;IAC3B,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;CACpC,WACO,OAAO;;;;;;GAkDjB;6BA/FyB,cAAc;4BACf,kBAAkB;gCAFd,gCAAgC;0CAGtB,eAAe;kCALvB,cAAc;6BACnB,kBAAkB"}
@@ -12,6 +12,36 @@ import { provideOrchestration } from '../utils/start-helper.js';
12
12
  * @import {OrchestrationService} from '../service.js';
13
13
  */
14
14
 
15
+ /**
16
+ * @param {Orchestrator} orch
17
+ * @param {object} ctx
18
+ * @param {ZCF} ctx.zcf
19
+ * @param {ZCFSeat} _seat
20
+ * @param {undefined} _offerArgs
21
+ */
22
+ const unbondAndLiquidStakeFn = async (orch, { zcf }, _seat, _offerArgs) => {
23
+ console.log('zcf within the membrane', zcf);
24
+ // We would actually alreaady have the account from the orchestrator
25
+ // ??? could these be passed in? It would reduce the size of this handler,
26
+ // keeping it focused on long-running operations.
27
+ const omni = await orch.getChain('omniflixhub');
28
+ const omniAccount = await omni.makeAccount();
29
+
30
+ // TODO implement these
31
+ // const delegations = await celestiaAccount.getDelegations();
32
+ // // wait for the undelegations to be complete (may take weeks)
33
+ // await celestiaAccount.undelegate(delegations);
34
+ // ??? should this be synchronous? depends on how names are resolved.
35
+ const stride = await orch.getChain('stride');
36
+ const strideAccount = await stride.makeAccount();
37
+
38
+ // TODO the `TIA` string actually needs to be the Brand from AgoricNames
39
+ // const tiaAmt = await celestiaAccount.getBalance('TIA');
40
+ // await celestiaAccount.transfer(tiaAmt, strideAccount.getAddress());
41
+ // await strideAccount.liquidStake(tiaAmt);
42
+ console.log(omniAccount, strideAccount);
43
+ };
44
+
15
45
  /**
16
46
  * @param {ZCF} zcf
17
47
  * @param {{
@@ -51,31 +81,7 @@ export const start = async (zcf, privateArgs, baggage) => {
51
81
  const unbondAndLiquidStake = orchestrate(
52
82
  'LSTTia',
53
83
  { zcf },
54
- // eslint-disable-next-line no-shadow -- this `zcf` is enclosed in a membrane
55
- async (/** @type {Orchestrator} */ orch, { zcf }, _seat, _offerArgs) => {
56
- console.log('zcf within the membrane', zcf);
57
- // We would actually alreaady have the account from the orchestrator
58
- // ??? could these be passed in? It would reduce the size of this handler,
59
- // keeping it focused on long-running operations.
60
- const omni = await orch.getChain('omniflixhub');
61
- const omniAccount = await omni.makeAccount();
62
-
63
- // TODO implement these
64
- // const delegations = await celestiaAccount.getDelegations();
65
- // // wait for the undelegations to be complete (may take weeks)
66
- // await celestiaAccount.undelegate(delegations);
67
-
68
- // ??? should this be synchronous? depends on how names are resolved.
69
- const stride = await orch.getChain('stride');
70
- const strideAccount = await stride.makeAccount();
71
-
72
- // TODO the `TIA` string actually needs to be the Brand from AgoricNames
73
- // const tiaAmt = await celestiaAccount.getBalance('TIA');
74
- // await celestiaAccount.transfer(tiaAmt, strideAccount.getAddress());
75
-
76
- // await strideAccount.liquidStake(tiaAmt);
77
- console.log(omniAccount, strideAccount);
78
- },
84
+ unbondAndLiquidStakeFn,
79
85
  );
80
86
 
81
87
  const makeUnbondAndLiquidStakeInvitation = () =>
package/src/facade.d.ts CHANGED
@@ -15,20 +15,31 @@ export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode,
15
15
  asyncFlowTools: AsyncFlowTools;
16
16
  }): {
17
17
  /**
18
- * @template Return
19
- * @template Context
20
- * @template {any[]} Args
18
+ * @template GuestReturn
19
+ * @template HostReturn
20
+ * @template GuestContext
21
+ * @template HostContext
22
+ * @template {any[]} GuestArgs
23
+ * @template {any[]} HostArgs
21
24
  * @param {string} durableName - the orchestration flow identity in the zone
22
25
  * (to resume across upgrades)
23
- * @param {Context} ctx - values to pass through the async flow membrane
26
+ * @param {HostContext} hostCtx - values to pass through the async flow
27
+ * membrane
24
28
  * @param {(
25
- * orc: Orchestrator,
26
- * ctx2: Context,
27
- * ...args: Args
28
- * ) => Promise<Return>} fn
29
- * @returns {(...args: Args) => Promise<Return>}
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>`
30
36
  */
31
- orchestrate<Return, Context, Args extends any[]>(durableName: string, ctx: Context, fn: (orc: Orchestrator, ctx2: Context, ...args: Args) => Promise<Return>): (...args: Args) => Promise<Return>;
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
+ adminAsyncFlow: import("@endo/exo").Guarded<{
39
+ getFailures(): import("@endo/patterns").CopyMap<any, import("@endo/pass-style").Passable>;
40
+ wakeAll(): void;
41
+ getFlowForOutcomeVow(outcomeVow: any): any;
42
+ }>;
32
43
  };
33
44
  export type OrchestrationFacade = ReturnType<typeof makeOrchestrationFacade>;
34
45
  import type { Zone } from '@agoric/zone';
@@ -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,oBAAoB,CAAC,CAAC;IACvD,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;IA+CA;;;;;;;;;;;;;OAaG;gBAZU,MAAM,EACN,OAAO,EACC,IAAI,SAAX,GAAG,EAAG,eACT,MAAM,OAEN,OAAO,MACP,CACV,GAAO,EAAE,YAAY,EACrB,IAAQ,EAAE,OAAO,EACjB,GAAO,IAAI,EAAE,IAAI,KACV,OAAO,CAAC,MAAM,CAAC,GACV,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC;EAQlD;kCAEa,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BAnGjC,cAAc;kCAEN,cAAc;4BAIpB,kBAAkB;0CACJ,cAAc;gCAHxB,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":"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,oBAAoB,CAAC,CAAC;IACvD,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;0CACJ,cAAc;gCAHxB,gCAAgC;sDAOV,uCAAuC;qCAN3C,6CAA6C;0CAIrD,8BAA8B;2CAC7B,+BAA+B;8BATvC,aAAa;oCAFZ,oBAAoB;kCASsD,YAAY"}
package/src/facade.js CHANGED
@@ -82,26 +82,50 @@ export const makeOrchestrationFacade = ({
82
82
  });
83
83
  const makeOrchestrator = pickFacet(makeOrchestratorKit, 'orchestrator');
84
84
 
85
+ const { prepareEndowment, asyncFlow, adminAsyncFlow } = asyncFlowTools;
86
+
87
+ const { when } = vowTools;
88
+
85
89
  return {
86
90
  /**
87
- * @template Return
88
- * @template Context
89
- * @template {any[]} Args
91
+ * @template GuestReturn
92
+ * @template HostReturn
93
+ * @template GuestContext
94
+ * @template HostContext
95
+ * @template {any[]} GuestArgs
96
+ * @template {any[]} HostArgs
90
97
  * @param {string} durableName - the orchestration flow identity in the zone
91
98
  * (to resume across upgrades)
92
- * @param {Context} ctx - values to pass through the async flow membrane
99
+ * @param {HostContext} hostCtx - values to pass through the async flow
100
+ * membrane
93
101
  * @param {(
94
- * orc: Orchestrator,
95
- * ctx2: Context,
96
- * ...args: Args
97
- * ) => Promise<Return>} fn
98
- * @returns {(...args: Args) => Promise<Return>}
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>`
99
109
  */
100
- orchestrate(durableName, ctx, fn) {
101
- const orc = makeOrchestrator();
110
+ orchestrate(durableName, hostCtx, guestFn) {
111
+ const subZone = zone.subZone(durableName);
112
+
113
+ const hostOrc = makeOrchestrator();
114
+
115
+ const [wrappedOrc, wrappedCtx] = prepareEndowment(subZone, 'endowments', [
116
+ hostOrc,
117
+ hostCtx,
118
+ ]);
119
+
120
+ const hostFn = asyncFlow(subZone, 'asyncFlow', guestFn);
102
121
 
103
- return async (...args) => vowTools.when(fn(orc, ctx, ...args));
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);
104
127
  },
128
+ adminAsyncFlow,
105
129
  };
106
130
  };
107
131
  harden(makeOrchestrationFacade);
@@ -18,7 +18,12 @@ export function provideOrchestration(zcf: ZCF, baggage: Baggage, remotePowers: O
18
18
  asVow: <T extends unknown>(fn: (...args: any[]) => import("@agoric/vow").Vow<Awaited<T>> | Awaited<T>) => import("@agoric/vow").Vow<Awaited<T>>;
19
19
  };
20
20
  zone: import("@agoric/base-zone").Zone;
21
- orchestrate<Return, Context, Args extends any[]>(durableName: string, ctx: Context, fn: (orc: import("../orchestration-api.js").Orchestrator, ctx2: Context, ...args: Args) => Promise<Return>): (...args: Args) => Promise<Return>;
21
+ 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>;
22
+ adminAsyncFlow: import("@endo/exo").Guarded<{
23
+ getFailures(): import("@endo/patterns").CopyMap<any, import("@endo/pass-style").Passable>;
24
+ wakeAll(): void;
25
+ getFlowForOutcomeVow(outcomeVow: any): any;
26
+ }>;
22
27
  };
23
28
  export type OrchestrationPowers = {
24
29
  localchain: Remote<LocalChain>;
@@ -1 +1 @@
1
- {"version":3,"file":"start-helper.d.ts","sourceRoot":"","sources":["start-helper.js"],"names":[],"mappings":"AAwCO,0CALI,GAAG,WACH,OAAO,gBACP,mBAAmB,cACnB,UAAU;;;;;;;;;;;;;;;;;wCAyCjB,GAAF;;;iKAmBG,GAAa,kCAEI,GAAG;EAOxB;kCArFY;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;6BAbsB,kBAAkB;gCAFf,gCAAgC;4BAIpC,aAAa;0CACC,eAAe;kCAJX,cAAc;6BAE/B,cAAc"}
1
+ {"version":3,"file":"start-helper.d.ts","sourceRoot":"","sources":["start-helper.js"],"names":[],"mappings":"AAwCO,0CALI,GAAG,WACH,OAAO,gBACP,mBAAmB,cACnB,UAAU;;;;;;;;;;;;;;;;;wCAyCjB,GAAF;;;4PA6BqB,GACjB,4CAA4E,GAAG;;;;;;EAFpF;kCArFY;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;6BAbsB,kBAAkB;gCAFf,gCAAgC;4BAIpC,aAAa;0CACC,eAAe;kCAJX,cAAc;6BAE/B,cAAc"}