@agoric/orchestration 0.1.1-dev-80db38c.0 → 0.1.1-dev-23e1921.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-23e1921.0+23e1921",
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-23e1921.0+23e1921",
37
+ "@agoric/async-flow": "0.1.1-dev-23e1921.0+23e1921",
38
+ "@agoric/cosmic-proto": "0.4.1-dev-23e1921.0+23e1921",
39
+ "@agoric/ertp": "0.16.3-dev-23e1921.0+23e1921",
40
+ "@agoric/internal": "0.3.3-dev-23e1921.0+23e1921",
41
+ "@agoric/network": "0.1.1-dev-23e1921.0+23e1921",
42
+ "@agoric/notifier": "0.6.3-dev-23e1921.0+23e1921",
43
+ "@agoric/store": "0.9.3-dev-23e1921.0+23e1921",
44
+ "@agoric/time": "0.3.3-dev-23e1921.0+23e1921",
45
+ "@agoric/vat-data": "0.5.3-dev-23e1921.0+23e1921",
46
+ "@agoric/vats": "0.15.2-dev-23e1921.0+23e1921",
47
+ "@agoric/vow": "0.1.1-dev-23e1921.0+23e1921",
48
+ "@agoric/zoe": "0.26.3-dev-23e1921.0+23e1921",
49
+ "@agoric/zone": "0.2.3-dev-23e1921.0+23e1921",
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": "23e1921342fd4d3601b036d69d8791e7437707d2"
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;;;;;QAsDZ;;;WAGG;4BAFQ,eAAe,kBACf,iBAAiB;;GAmBjC;kCAlJY;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,17 @@ 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
+ const contractState = makeStateRecord(
112
+ /** @type {{ account: OrchestrationAccount<any> | undefined }} */ {
113
+ account: undefined,
114
+ },
115
+ );
60
116
 
61
117
  /** @type {OfferHandler} */
62
118
  const sendIt = orchestrate(
63
119
  'sendIt',
64
- { zcf, agoricNamesTools },
65
- // 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
- },
120
+ { zcf, agoricNamesTools, contractState },
121
+ sendItFn,
104
122
  );
105
123
 
106
124
  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 = () =>
@@ -10,7 +10,7 @@ export const ChainAccountI: import("@endo/patterns").InterfaceGuard<{
10
10
  close: import("@endo/patterns").MethodGuard;
11
11
  getPurse: import("@endo/patterns").MethodGuard;
12
12
  }>;
13
- export function prepareChainAccountKit(zone: Zone, { watch, when }: VowTools): (chainId: string, port: Port, requestedRemoteAddress: string) => import("@endo/exo").GuardedKit<{
13
+ export function prepareChainAccountKit(zone: Zone, { watch, asVow }: VowTools): (chainId: string, port: Port, requestedRemoteAddress: string) => import("@endo/exo").GuardedKit<{
14
14
  parseTxPacketWatcher: {
15
15
  /** @param {string} ack */
16
16
  onFulfilled(ack: string): string;
@@ -18,31 +18,36 @@ export function prepareChainAccountKit(zone: Zone, { watch, when }: VowTools): (
18
18
  account: {
19
19
  /** @returns {ChainAddress} */
20
20
  getAddress(): ChainAddress;
21
- getBalance(_denom: any): never;
22
- getBalances(): never;
21
+ getBalance(_denom: any): Vow<never>;
22
+ getBalances(): Vow<never>;
23
23
  getLocalAddress(): `/ibc-port/${string}`;
24
24
  getRemoteAddress(): `/${string}ibc-port/${string}/ordered/${string}` | `/${string}ibc-port/${string}/unordered/${string}`;
25
25
  getPort(): Port;
26
- executeTx(): never;
26
+ executeTx(): Vow<never>;
27
27
  /**
28
28
  * Submit a transaction on behalf of the remote account for execution on
29
29
  * the remote chain.
30
30
  *
31
31
  * @param {AnyJson[]} msgs
32
32
  * @param {Omit<TxBody, 'messages'>} [opts]
33
- * @returns {Promise<string>} - base64 encoded bytes string. Can be
34
- * decoded using the corresponding `Msg*Response` object.
33
+ * @returns {Vow<string>} - base64 encoded bytes string. Can be decoded
34
+ * using the corresponding `Msg*Response` object.
35
35
  * @throws {Error} if packet fails to send or an error is returned
36
36
  */
37
- executeEncodedTx(msgs: AnyJson[], opts?: Omit<TxBody, "messages"> | undefined): Promise<string>;
38
- /** Close the remote account */
39
- close(): Promise<void>;
37
+ executeEncodedTx(msgs: AnyJson[], opts?: Omit<TxBody, "messages"> | undefined): Vow<string>;
38
+ /**
39
+ * Close the remote account
40
+ *
41
+ * @returns {Vow<void>}
42
+ * @throws {Error} if connection is not available or already closed
43
+ */
44
+ close(): Vow<void>;
40
45
  /**
41
46
  * get Purse for a brand to .withdraw() a Payment from the account
42
47
  *
43
48
  * @param {Brand} brand
44
49
  */
45
- getPurse(brand: Brand): Promise<never>;
50
+ getPurse(brand: Brand): Vow<never>;
46
51
  };
47
52
  connectionHandler: {
48
53
  /**
@@ -51,8 +56,11 @@ export function prepareChainAccountKit(zone: Zone, { watch, when }: VowTools): (
51
56
  * @param {RemoteIbcAddress} remoteAddr
52
57
  */
53
58
  onOpen(connection: Remote<Connection>, localAddr: LocalIbcAddress, remoteAddr: RemoteIbcAddress): Promise<void>;
54
- onClose(_connection: any, reason: any): Promise<void>;
55
- onReceive(connection: any, bytes: any): Promise<string>;
59
+ /**
60
+ * @param {Remote<Connection>} _connection
61
+ * @param {unknown} reason
62
+ */
63
+ onClose(_connection: Remote<Connection>, reason: unknown): Promise<void>;
56
64
  };
57
65
  }>;
58
66
  export type UnparsableChainAddress = "UNPARSABLE_CHAIN_ADDRESS";
@@ -70,6 +78,7 @@ import type { Zone } from '@agoric/base-zone';
70
78
  import type { VowTools } from '@agoric/vow';
71
79
  import type { Port } from '@agoric/network';
72
80
  import type { ChainAddress } from '../types.js';
81
+ import type { Vow } from '@agoric/vow';
73
82
  import type { AnyJson } from '@agoric/cosmic-proto';
74
83
  import type { TxBody } from '@agoric/cosmic-proto/cosmos/tx/v1beta1/tx.js';
75
84
  import type { Connection } from '@agoric/network';
@@ -1 +1 @@
1
- {"version":3,"file":"chain-account-kit.d.ts","sourceRoot":"","sources":["chain-account-kit.js"],"names":[],"mappings":"AA8BA;;;;;;;;;;;GAaG;AAkBI,6CAHI,IAAI,mBACJ,QAAQ;;QA+BX,0BAA0B;yBAAd,MAAM;;;QAMlB,8BAA8B;sBAAhB,YAAY;;;;;;;QAiC1B;;;;;;;;;WASG;+BALQ,OAAO,EAAE,gDAEP,OAAO,CAAC,MAAM,CAAC;QA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c,EAAE,OAAO,UAAU,CAAC,GAAG,SAAS,CAAC;IAC/C,YAAgB,EAAE,eAAe,GAAG,SAAS,CAAC;IAC9C,sBAA0B,EAAE,MAAM,CAAC;IACnC,aAAiB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChD,YAAgB,EAAE,YAAY,GAAG,SAAS,CAAC;CACxC;8BAyJU,UAAU,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;0BAhM5C,mBAAmB;8BAEF,aAAa;0BADlB,iBAAiB;kCAKrB,aAAa;yBAJJ,aAAa;6BAC3B,sBAAsB;4BACvB,8CAA8C;gCAHpC,iBAAiB;4BACZ,aAAa;qCAGD,iCAAiC;sCAAjC,iCAAiC"}
@@ -1,12 +1,12 @@
1
1
  /** @file ChainAccount exo */
2
2
  import { NonNullish } from '@agoric/assert';
3
- import { PurseShape } from '@agoric/ertp';
4
3
  import { makeTracer } from '@agoric/internal';
4
+ import { VowShape } from '@agoric/vow';
5
5
  import { E } from '@endo/far';
6
6
  import { M } from '@endo/patterns';
7
7
  import {
8
8
  ChainAddressShape,
9
- ConnectionHandlerI,
9
+ OutboundConnectionHandlerI,
10
10
  Proto3Shape,
11
11
  } from '../typeGuards.js';
12
12
  import { findAddressField } from '../utils/address.js';
@@ -15,7 +15,7 @@ import { makeTxPacket, parseTxPacket } from '../utils/packet.js';
15
15
  /**
16
16
  * @import {Zone} from '@agoric/base-zone';
17
17
  * @import {Connection, Port} from '@agoric/network';
18
- * @import {Remote, VowTools} from '@agoric/vow';
18
+ * @import {Remote, Vow, VowTools} from '@agoric/vow';
19
19
  * @import {AnyJson} from '@agoric/cosmic-proto';
20
20
  * @import {TxBody} from '@agoric/cosmic-proto/cosmos/tx/v1beta1/tx.js';
21
21
  * @import {LocalIbcAddress, RemoteIbcAddress} from '@agoric/vats/tools/ibc-utils.js';
@@ -30,17 +30,17 @@ const UNPARSABLE_CHAIN_ADDRESS = 'UNPARSABLE_CHAIN_ADDRESS';
30
30
 
31
31
  export const ChainAccountI = M.interface('ChainAccount', {
32
32
  getAddress: M.call().returns(ChainAddressShape),
33
- getBalance: M.callWhen(M.string()).returns(M.any()),
34
- getBalances: M.callWhen().returns(M.any()),
33
+ getBalance: M.call(M.string()).returns(VowShape),
34
+ getBalances: M.call().returns(VowShape),
35
35
  getLocalAddress: M.call().returns(M.string()),
36
36
  getRemoteAddress: M.call().returns(M.string()),
37
37
  getPort: M.call().returns(M.remotable('Port')),
38
- executeTx: M.call(M.arrayOf(M.record())).returns(M.promise()),
38
+ executeTx: M.call(M.arrayOf(M.record())).returns(VowShape),
39
39
  executeEncodedTx: M.call(M.arrayOf(Proto3Shape))
40
40
  .optional(M.record())
41
- .returns(M.promise()),
42
- close: M.callWhen().returns(M.undefined()),
43
- getPurse: M.callWhen().returns(PurseShape),
41
+ .returns(VowShape),
42
+ close: M.call().returns(VowShape),
43
+ getPurse: M.call().returns(VowShape),
44
44
  });
45
45
 
46
46
  /**
@@ -59,12 +59,12 @@ export const ChainAccountI = M.interface('ChainAccount', {
59
59
  * @param {Zone} zone
60
60
  * @param {VowTools} vowTools
61
61
  */
62
- export const prepareChainAccountKit = (zone, { watch, when }) =>
62
+ export const prepareChainAccountKit = (zone, { watch, asVow }) =>
63
63
  zone.exoClassKit(
64
64
  'ChainAccountKit',
65
65
  {
66
66
  account: ChainAccountI,
67
- connectionHandler: ConnectionHandlerI,
67
+ connectionHandler: OutboundConnectionHandlerI,
68
68
  parseTxPacketWatcher: M.interface('ParseTxPacketWatcher', {
69
69
  onFulfilled: M.call(M.string())
70
70
  .optional(M.arrayOf(M.undefined())) // does not need watcherContext
@@ -103,11 +103,11 @@ export const prepareChainAccountKit = (zone, { watch, when }) =>
103
103
  },
104
104
  getBalance(_denom) {
105
105
  // UNTIL https://github.com/Agoric/agoric-sdk/issues/9326
106
- throw new Error('not yet implemented');
106
+ return asVow(() => Fail`'not yet implemented'`);
107
107
  },
108
108
  getBalances() {
109
109
  // UNTIL https://github.com/Agoric/agoric-sdk/issues/9326
110
- throw new Error('not yet implemented');
110
+ return asVow(() => Fail`'not yet implemented'`);
111
111
  },
112
112
  getLocalAddress() {
113
113
  return NonNullish(
@@ -125,7 +125,7 @@ export const prepareChainAccountKit = (zone, { watch, when }) =>
125
125
  return this.state.port;
126
126
  },
127
127
  executeTx() {
128
- throw new Error('not yet implemented');
128
+ return asVow(() => Fail`'not yet implemented'`);
129
129
  },
130
130
  /**
131
131
  * Submit a transaction on behalf of the remote account for execution on
@@ -133,41 +133,44 @@ export const prepareChainAccountKit = (zone, { watch, when }) =>
133
133
  *
134
134
  * @param {AnyJson[]} msgs
135
135
  * @param {Omit<TxBody, 'messages'>} [opts]
136
- * @returns {Promise<string>} - base64 encoded bytes string. Can be
137
- * decoded using the corresponding `Msg*Response` object.
136
+ * @returns {Vow<string>} - base64 encoded bytes string. Can be decoded
137
+ * using the corresponding `Msg*Response` object.
138
138
  * @throws {Error} if packet fails to send or an error is returned
139
139
  */
140
- async executeEncodedTx(msgs, opts) {
141
- const { connection } = this.state;
142
- // TODO #9281 do not throw synchronously when returning a promise; return a rejected Vow
143
- /// see https://github.com/Agoric/agoric-sdk/pull/9454#discussion_r1626898694
144
- if (!connection) throw Fail`connection not available`;
145
- return when(
146
- watch(
140
+ executeEncodedTx(msgs, opts) {
141
+ return asVow(() => {
142
+ const { connection } = this.state;
143
+ if (!connection) throw Fail`connection not available`;
144
+ return watch(
147
145
  E(connection).send(makeTxPacket(msgs, opts)),
148
146
  this.facets.parseTxPacketWatcher,
149
- ),
150
- );
147
+ );
148
+ });
151
149
  },
152
- /** Close the remote account */
153
- async close() {
154
- /// TODO #9192 what should the behavior be here? and `onClose`?
155
- // - retrieve assets?
156
- // - revoke the port?
157
- const { connection } = this.state;
158
- // TODO #9281 do not throw synchronously when returning a promise; return a rejected Vow
159
- /// see https://github.com/Agoric/agoric-sdk/pull/9454#discussion_r1626898694
160
- if (!connection) throw Fail`connection not available`;
161
- return when(watch(E(connection).close()));
150
+ /**
151
+ * Close the remote account
152
+ *
153
+ * @returns {Vow<void>}
154
+ * @throws {Error} if connection is not available or already closed
155
+ */
156
+ close() {
157
+ return asVow(() => {
158
+ /// TODO #9192 what should the behavior be here? and `onClose`?
159
+ // - retrieve assets?
160
+ // - revoke the port?
161
+ const { connection } = this.state;
162
+ if (!connection) throw Fail`connection not available`;
163
+ return E(connection).close();
164
+ });
162
165
  },
163
166
  /**
164
167
  * get Purse for a brand to .withdraw() a Payment from the account
165
168
  *
166
169
  * @param {Brand} brand
167
170
  */
168
- async getPurse(brand) {
171
+ getPurse(brand) {
169
172
  console.log('getPurse got', brand);
170
- throw new Error('not yet implemented');
173
+ return asVow(() => Fail`'not yet implemented'`);
171
174
  },
172
175
  },
173
176
  connectionHandler: {
@@ -189,15 +192,15 @@ export const prepareChainAccountKit = (zone, { watch, when }) =>
189
192
  addressEncoding: 'bech32',
190
193
  });
191
194
  },
195
+ /**
196
+ * @param {Remote<Connection>} _connection
197
+ * @param {unknown} reason
198
+ */
192
199
  async onClose(_connection, reason) {
193
200
  trace(`ICA Channel closed. Reason: ${reason}`);
194
201
  // FIXME handle connection closing https://github.com/Agoric/agoric-sdk/issues/9192
195
202
  // XXX is there a scenario where a connection will unexpectedly close? _I think yes_
196
203
  },
197
- async onReceive(connection, bytes) {
198
- trace(`ICA Channel onReceive`, connection, bytes);
199
- return '';
200
- },
201
204
  },
202
205
  },
203
206
  );
@@ -27,7 +27,6 @@ export function prepareICQConnectionKit(zone: Zone, { watch, when }: VowTools):
27
27
  */
28
28
  onOpen(connection: Remote<Connection>, localAddr: LocalIbcAddress, remoteAddr: RemoteIbcAddress): Promise<void>;
29
29
  onClose(_connection: any, reason: any): Promise<void>;
30
- onReceive(connection: any, bytes: any): Promise<string>;
31
30
  };
32
31
  }>;
33
32
  export type ICQConnectionKitState = {
@@ -1 +1 @@
1
- {"version":3,"file":"icq-connection-kit.d.ts","sourceRoot":"","sources":["icq-connection-kit.js"],"names":[],"mappings":"AAoBA,2DAGE;AAEF;;;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S,CAAC;CAC7C;+BAgGU,UAAU,CAAC,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;4BACtD,gBAAgB,CAAC,YAAY,CAAC;0BA7HrB,mBAAmB;8BAEP,aAAa;0BADb,iBAAiB;kCAGN,+CAA+C;8BADlE,sBAAsB;mCACH,+CAA+C;gCAH1D,iBAAiB;4BACjB,aAAa;qCAGI,iCAAiC;sCAAjC,iCAAiC"}
@@ -4,7 +4,7 @@ import { makeTracer } from '@agoric/internal';
4
4
  import { E } from '@endo/far';
5
5
  import { M } from '@endo/patterns';
6
6
  import { makeQueryPacket, parseQueryPacket } from '../utils/packet.js';
7
- import { ConnectionHandlerI } from '../typeGuards.js';
7
+ import { OutboundConnectionHandlerI } from '../typeGuards.js';
8
8
 
9
9
  /**
10
10
  * @import {Zone} from '@agoric/base-zone';
@@ -59,7 +59,7 @@ export const prepareICQConnectionKit = (zone, { watch, when }) =>
59
59
  'ICQConnectionKit',
60
60
  {
61
61
  connection: ICQConnectionI,
62
- connectionHandler: ConnectionHandlerI,
62
+ connectionHandler: OutboundConnectionHandlerI,
63
63
  parseQueryPacketWatcher: M.interface('ParseQueryPacketWatcher', {
64
64
  onFulfilled: M.call(M.string())
65
65
  .optional(M.arrayOf(M.undefined())) // does not need watcherContext
@@ -127,10 +127,6 @@ export const prepareICQConnectionKit = (zone, { watch, when }) =>
127
127
  async onClose(_connection, reason) {
128
128
  trace(`ICQ Channel closed. Reason: ${reason}`);
129
129
  },
130
- async onReceive(connection, bytes) {
131
- trace(`ICQ Channel onReceive`, connection, bytes);
132
- return '';
133
- },
134
130
  },
135
131
  },
136
132
  );
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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AC;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);
@@ -1,7 +1,11 @@
1
- export const ConnectionHandlerI: import("@endo/patterns").InterfaceGuard<{
1
+ /**
2
+ * Used for IBC Channel Connections that only send outgoing transactions. If
3
+ * your channel expects incoming transactions, please extend this interface to
4
+ * include the `onReceive` handler.
5
+ */
6
+ export const OutboundConnectionHandlerI: import("@endo/patterns").InterfaceGuard<{
2
7
  onOpen: import("@endo/patterns").MethodGuard;
3
8
  onClose: import("@endo/patterns").MethodGuard;
4
- onReceive: import("@endo/patterns").MethodGuard;
5
9
  }>;
6
10
  export namespace ChainAddressShape {
7
11
  let address: import("@endo/patterns").Matcher;
@@ -1 +1 @@
1
- {"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;AAiBH,8DAAkE;;;;;AAOlE,uEAUE;AAEF,iEAA4C;AAC5C,mEAQG;AACH,oEAA+C;AAC/C,sEAYG;AAEH,oEAUE;AAGF,8DAAsC;AACtC,sEAAuE;AACvE,0DAAqC;AAErC,8DAAsC;;;;;;AAItC,mBAAmB;AACnB;;;GAGG"}
1
+ {"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH;;;GAQE;;;;;;;;;;;;;;;;;;;;;AAiBF,8DAAkE;;;;;AAOlE,uEAUE;AAEF,iEAA4C;AAC5C,mEAQG;AACH,oEAA+C;AAC/C,sEAYG;AAEH,oEAUE;AAGF,8DAAsC;AACtC,sEAAuE;AACvE,0DAAqC;AAErC,8DAAsC;;;;;;AAItC,mBAAmB;AACnB;;;GAGG"}
package/src/typeGuards.js CHANGED
@@ -2,11 +2,20 @@ import { AmountShape } from '@agoric/ertp';
2
2
  import { VowShape } from '@agoric/vow';
3
3
  import { M } from '@endo/patterns';
4
4
 
5
- export const ConnectionHandlerI = M.interface('ConnectionHandler', {
6
- onOpen: M.callWhen(M.any(), M.string(), M.string(), M.any()).returns(M.any()),
7
- onClose: M.callWhen(M.any(), M.any(), M.any()).returns(M.any()),
8
- onReceive: M.callWhen(M.any(), M.string()).returns(M.any()),
9
- });
5
+ /**
6
+ * Used for IBC Channel Connections that only send outgoing transactions. If
7
+ * your channel expects incoming transactions, please extend this interface to
8
+ * include the `onReceive` handler.
9
+ */
10
+ export const OutboundConnectionHandlerI = M.interface(
11
+ 'OutboundConnectionHandler',
12
+ {
13
+ onOpen: M.callWhen(M.any(), M.string(), M.string(), M.any()).returns(
14
+ M.any(),
15
+ ),
16
+ onClose: M.callWhen(M.any(), M.any(), M.any()).returns(M.any()),
17
+ },
18
+ );
10
19
 
11
20
  export const ChainAddressShape = {
12
21
  address: M.string(),
@@ -15,10 +15,15 @@ export function provideOrchestration(zcf: ZCF, baggage: Baggage, remotePowers: O
15
15
  watch: <T = any, TResult1 = T, TResult2 = never, C extends any[] = any[]>(specimenP: import("@agoric/vow").ERef<T | import("@agoric/vow").Vow<T>>, watcher?: import("@agoric/vow").Watcher<T, TResult1, TResult2, C> | undefined, ...watcherArgs: C) => import("@agoric/vow").Vow<Exclude<TResult1, void> | Exclude<TResult2, void> extends never ? TResult1 : Exclude<TResult1, void> | Exclude<TResult2, void>>;
16
16
  makeVowKit: <T>() => import("@agoric/vow").VowKit<T>;
17
17
  allVows: (vows: unknown[]) => import("@agoric/vow").Vow<any[]>;
18
- asVow: <T extends unknown>(fn: (...args: any[]) => import("@agoric/vow").Vow<Awaited<T>> | Awaited<T>) => import("@agoric/vow").Vow<Awaited<T>>;
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
  };
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;;;;;;;;;;;;;;;;;wCAyCV,GAAG;;;4PA6BS,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"}