@agoric/orchestration 0.1.1-dev-0ad10c6.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 +16 -16
- package/src/examples/sendAnywhere.contract.d.ts +0 -19
- package/src/examples/sendAnywhere.contract.d.ts.map +1 -1
- package/src/examples/sendAnywhere.contract.js +66 -58
- package/src/examples/swapExample.contract.d.ts +0 -9
- package/src/examples/swapExample.contract.d.ts.map +1 -1
- package/src/examples/swapExample.contract.js +52 -49
- package/src/examples/unbondExample.contract.d.ts.map +1 -1
- package/src/examples/unbondExample.contract.js +31 -25
- package/src/exos/agoric-names-tools.d.ts +27 -0
- package/src/exos/agoric-names-tools.d.ts.map +1 -0
- package/src/exos/agoric-names-tools.js +109 -0
- package/src/facade.d.ts +21 -10
- package/src/facade.d.ts.map +1 -1
- package/src/facade.js +36 -12
- package/src/utils/start-helper.d.ts +13 -1
- package/src/utils/start-helper.d.ts.map +1 -1
- package/src/utils/start-helper.js +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/orchestration",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
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-
|
|
37
|
-
"@agoric/async-flow": "0.1.1-dev-
|
|
38
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
39
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
40
|
-
"@agoric/internal": "0.3.3-dev-
|
|
41
|
-
"@agoric/network": "0.1.1-dev-
|
|
42
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
43
|
-
"@agoric/store": "0.9.3-dev-
|
|
44
|
-
"@agoric/time": "0.3.3-dev-
|
|
45
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
46
|
-
"@agoric/vats": "0.15.2-dev-
|
|
47
|
-
"@agoric/vow": "0.1.1-dev-
|
|
48
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
49
|
-
"@agoric/zone": "0.2.3-dev-
|
|
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": "
|
|
93
|
+
"gitHead": "4390d8c21fd8ac80a9c83f55d38c52e3f98faa1e"
|
|
94
94
|
}
|
|
@@ -1,22 +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 {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js';
|
|
9
|
-
* @import {Remote} from '@agoric/vow';
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {{
|
|
13
|
-
* localchain: Remote<LocalChain>;
|
|
14
|
-
* orchestrationService: Remote<OrchestrationService>;
|
|
15
|
-
* storageNode: Remote<StorageNode>;
|
|
16
|
-
* timerService: Remote<TimerService>;
|
|
17
|
-
* agoricNames: Remote<NameHub>;
|
|
18
|
-
* }} OrchestrationPowers
|
|
19
|
-
*/
|
|
20
1
|
export const SingleAmountRecord: import("@endo/patterns").Matcher;
|
|
21
2
|
export function start(zcf: ZCF, privateArgs: OrchestrationPowers & {
|
|
22
3
|
marshaller: Marshaller;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendAnywhere.contract.d.ts","sourceRoot":"","sources":["sendAnywhere.contract.js"],"names":[],"mappings":"
|
|
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,22 +2,24 @@ 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';
|
|
9
|
+
import { makeResumableAgoricNamesHack } from '../exos/agoric-names-tools.js';
|
|
8
10
|
|
|
9
11
|
const { entries } = Object;
|
|
10
|
-
const { Fail } = assert;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @import {Baggage} from '@agoric/vat-data';
|
|
14
|
-
* @import {
|
|
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
|
-
* @import {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js';
|
|
20
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'
|
|
21
23
|
*/
|
|
22
24
|
|
|
23
25
|
/**
|
|
@@ -30,6 +32,56 @@ const { Fail } = assert;
|
|
|
30
32
|
* }} OrchestrationPowers
|
|
31
33
|
*/
|
|
32
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
|
+
|
|
33
85
|
export const SingleAmountRecord = M.and(
|
|
34
86
|
M.recordOf(M.string(), AmountShape, {
|
|
35
87
|
numPropertiesLimit: 1,
|
|
@@ -45,70 +97,26 @@ export const SingleAmountRecord = M.and(
|
|
|
45
97
|
* @param {Baggage} baggage
|
|
46
98
|
*/
|
|
47
99
|
export const start = async (zcf, privateArgs, baggage) => {
|
|
48
|
-
const { chainHub, orchestrate, zone } = provideOrchestration(
|
|
100
|
+
const { chainHub, orchestrate, vowTools, zone } = provideOrchestration(
|
|
49
101
|
zcf,
|
|
50
102
|
baggage,
|
|
51
103
|
privateArgs,
|
|
52
104
|
privateArgs.marshaller,
|
|
53
105
|
);
|
|
106
|
+
const agoricNamesTools = makeResumableAgoricNamesHack(zone, {
|
|
107
|
+
agoricNames: privateArgs.agoricNames,
|
|
108
|
+
vowTools,
|
|
109
|
+
});
|
|
54
110
|
|
|
55
|
-
/** @type {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const findBrandInVBank = async brand => {
|
|
59
|
-
const assets = await E(
|
|
60
|
-
// XXX heapVowE
|
|
61
|
-
/** @type {Promise<Promise<NameHub<VBankAssetDetail>>>} */ (
|
|
62
|
-
E(privateArgs.agoricNames).lookup('vbankAsset')
|
|
63
|
-
),
|
|
64
|
-
).values();
|
|
65
|
-
const it = assets.find(a => a.brand === brand);
|
|
66
|
-
if (!it) {
|
|
67
|
-
throw Fail`brand ${brand} not in agoricNames.vbankAsset`;
|
|
68
|
-
}
|
|
69
|
-
return it;
|
|
70
|
-
};
|
|
111
|
+
/** @type {{ account: OrchestrationAccount<any> | undefined }} */
|
|
112
|
+
const contractState = makeStateRecord({ account: undefined });
|
|
71
113
|
|
|
72
114
|
/** @type {OfferHandler} */
|
|
73
115
|
const sendIt = orchestrate(
|
|
74
116
|
'sendIt',
|
|
75
|
-
{ zcf },
|
|
117
|
+
{ zcf, agoricNamesTools, contractState },
|
|
76
118
|
// eslint-disable-next-line no-shadow -- this `zcf` is enclosed in a membrane
|
|
77
|
-
|
|
78
|
-
mustMatch(
|
|
79
|
-
offerArgs,
|
|
80
|
-
harden({ chainName: M.scalar(), destAddr: M.string() }),
|
|
81
|
-
);
|
|
82
|
-
const { chainName, destAddr } = offerArgs;
|
|
83
|
-
const { give } = seat.getProposal();
|
|
84
|
-
const [[kw, amt]] = entries(give);
|
|
85
|
-
const { denom } = await findBrandInVBank(amt.brand);
|
|
86
|
-
const chain = await orch.getChain(chainName);
|
|
87
|
-
|
|
88
|
-
// FIXME ok to use a heap var crossing the membrane scope this way?
|
|
89
|
-
if (!contractAccount) {
|
|
90
|
-
const agoricChain = await orch.getChain('agoric');
|
|
91
|
-
// XXX when() until membrane
|
|
92
|
-
contractAccount = await E.when(agoricChain.makeAccount());
|
|
93
|
-
console.log('contractAccount', contractAccount);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// XXX when() until membrane
|
|
97
|
-
const info = await E.when(chain.getChainInfo());
|
|
98
|
-
console.log('info', info);
|
|
99
|
-
const { chainId } = info;
|
|
100
|
-
assert(typeof chainId === 'string', 'bad chainId');
|
|
101
|
-
const { [kw]: pmtP } = await withdrawFromSeat(zcf, seat, give);
|
|
102
|
-
await E.when(pmtP, pmt => contractAccount.deposit(pmt));
|
|
103
|
-
await contractAccount.transfer(
|
|
104
|
-
{ denom, value: amt.value },
|
|
105
|
-
{
|
|
106
|
-
address: destAddr,
|
|
107
|
-
addressEncoding: 'bech32',
|
|
108
|
-
chainId,
|
|
109
|
-
},
|
|
110
|
-
);
|
|
111
|
-
},
|
|
119
|
+
sendItFn,
|
|
112
120
|
);
|
|
113
121
|
|
|
114
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":"
|
|
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":"
|
|
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
|
-
|
|
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 = () =>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function makeResumableAgoricNamesHack(zone: Zone, { agoricNames, vowTools: { watch, asVow } }: {
|
|
2
|
+
agoricNames: Remote<NameHub>;
|
|
3
|
+
vowTools: VowTools;
|
|
4
|
+
}): import("@endo/exo").Guarded<{
|
|
5
|
+
/** @param {...string} args */
|
|
6
|
+
lookup(...args: string[]): Vow<any>;
|
|
7
|
+
/**
|
|
8
|
+
* Look up asset info, like denom, in agoricNames.vbankAsset using a
|
|
9
|
+
* Brand.
|
|
10
|
+
*
|
|
11
|
+
* Caches the query to agoricNames in the first call. Subsequent lookups
|
|
12
|
+
* are via cache unless a refetch is specified or a brand is not found.
|
|
13
|
+
*
|
|
14
|
+
* @param {Brand<'nat'>} brand
|
|
15
|
+
* @param {boolean} [refetch] if true, will invalidate the cache
|
|
16
|
+
* @returns {Vow<AssetInfo>}
|
|
17
|
+
*/
|
|
18
|
+
findBrandInVBank(brand: Brand<"nat">, refetch?: boolean | undefined): Vow<AssetInfo>;
|
|
19
|
+
}>;
|
|
20
|
+
export type AgNamesTools = ReturnType<typeof makeResumableAgoricNamesHack>;
|
|
21
|
+
import type { Zone } from '@agoric/zone';
|
|
22
|
+
import type { NameHub } from '@agoric/vats';
|
|
23
|
+
import type { Remote } from '@agoric/internal';
|
|
24
|
+
import type { VowTools } from '@agoric/vow';
|
|
25
|
+
import type { Vow } from '@agoric/vow';
|
|
26
|
+
import type { AssetInfo } from '@agoric/vats/src/vat-bank.js';
|
|
27
|
+
//# sourceMappingURL=agoric-names-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agoric-names-tools.d.ts","sourceRoot":"","sources":["agoric-names-tools.js"],"names":[],"mappings":"AA4BO,mDAHI,IAAI,+CACJ;IAAE,WAAW,EAAE,OAAO,OAAO,CAAC,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE;IA8CvD,8BAA8B;oBAAf,MAAM,EAAA;IAIrB;;;;;;;;;;OAUG;4BAHQ,KAAK,CAAC,KAAK,CAAC,kCAEV,IAAI,SAAS,CAAC;GAsBlC;2BACa,UAAU,CAAC,OAAO,4BAA4B,CAAC;0BAhGtC,cAAc;6BAJX,cAAc;4BAEf,kBAAkB;8BACX,aAAa;yBAAb,aAAa;+BAFjB,8BAA8B"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { VowShape } from '@agoric/vow';
|
|
2
|
+
import { E } from '@endo/far';
|
|
3
|
+
import { M, makeCopyMap } from '@endo/patterns';
|
|
4
|
+
import { BrandShape } from '@agoric/ertp';
|
|
5
|
+
|
|
6
|
+
const { Fail } = assert;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @import {NameHub} from '@agoric/vats';
|
|
10
|
+
* @import {AssetInfo} from '@agoric/vats/src/vat-bank.js';
|
|
11
|
+
* @import {Remote} from '@agoric/internal';
|
|
12
|
+
* @import {Vow, VowTools} from '@agoric/vow';
|
|
13
|
+
* @import {Zone} from '@agoric/zone';
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Perform remote calls to agoricNames in membrane-friendly way. This is an
|
|
18
|
+
* interim approach until https://github.com/Agoric/agoric-sdk/issues/9541,
|
|
19
|
+
* https://github.com/Agoric/agoric-sdk/pull/9322, or
|
|
20
|
+
* https://github.com/Agoric/agoric-sdk/pull/9519.
|
|
21
|
+
*
|
|
22
|
+
* XXX only works once per zone.
|
|
23
|
+
*
|
|
24
|
+
* XXX consider exposing `has`, `entries`, `keys`, `values` from `NameHub`
|
|
25
|
+
*
|
|
26
|
+
* @param {Zone} zone
|
|
27
|
+
* @param {{ agoricNames: Remote<NameHub>; vowTools: VowTools }} powers
|
|
28
|
+
*/
|
|
29
|
+
export const makeResumableAgoricNamesHack = (
|
|
30
|
+
zone,
|
|
31
|
+
{ agoricNames, vowTools: { watch, asVow } },
|
|
32
|
+
) => {
|
|
33
|
+
const makeResumableAgoricNamesHackKit = zone.exoClassKit(
|
|
34
|
+
'ResumableAgoricNamesHack',
|
|
35
|
+
{
|
|
36
|
+
public: M.interface('ResumableAgoricNamesHackI', {
|
|
37
|
+
lookup: M.call().rest(M.arrayOf(M.string())).returns(VowShape),
|
|
38
|
+
findBrandInVBank: M.call(BrandShape)
|
|
39
|
+
.optional(M.boolean())
|
|
40
|
+
.returns(VowShape),
|
|
41
|
+
}),
|
|
42
|
+
vbankAssetEntriesWatcher: M.interface('vbankAssetEntriesWatcher', {
|
|
43
|
+
onFulfilled: M.call(M.arrayOf(M.record()))
|
|
44
|
+
.optional({ brand: BrandShape })
|
|
45
|
+
.returns(VowShape),
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
() => ({
|
|
49
|
+
vbankAssetsByBrand: zone.mapStore('vbankAssetsByBrand', {
|
|
50
|
+
keyShape: BrandShape,
|
|
51
|
+
valueShape: M.any(),
|
|
52
|
+
}),
|
|
53
|
+
}),
|
|
54
|
+
{
|
|
55
|
+
vbankAssetEntriesWatcher: {
|
|
56
|
+
/**
|
|
57
|
+
* @param {AssetInfo[]} assets
|
|
58
|
+
* @param {{ brand: Brand<'nat'> }} ctx
|
|
59
|
+
*/
|
|
60
|
+
onFulfilled(assets, { brand }) {
|
|
61
|
+
return asVow(() => {
|
|
62
|
+
const { vbankAssetsByBrand } = this.state;
|
|
63
|
+
vbankAssetsByBrand.addAll(
|
|
64
|
+
makeCopyMap(assets.map(a => [a.brand, a])),
|
|
65
|
+
);
|
|
66
|
+
vbankAssetsByBrand.has(brand) ||
|
|
67
|
+
Fail`brand ${brand} not in agoricNames.vbankAsset`;
|
|
68
|
+
return vbankAssetsByBrand.get(brand);
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
public: {
|
|
73
|
+
/** @param {...string} args */
|
|
74
|
+
lookup(...args) {
|
|
75
|
+
return watch(E(agoricNames).lookup(...args));
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Look up asset info, like denom, in agoricNames.vbankAsset using a
|
|
79
|
+
* Brand.
|
|
80
|
+
*
|
|
81
|
+
* Caches the query to agoricNames in the first call. Subsequent lookups
|
|
82
|
+
* are via cache unless a refetch is specified or a brand is not found.
|
|
83
|
+
*
|
|
84
|
+
* @param {Brand<'nat'>} brand
|
|
85
|
+
* @param {boolean} [refetch] if true, will invalidate the cache
|
|
86
|
+
* @returns {Vow<AssetInfo>}
|
|
87
|
+
*/
|
|
88
|
+
findBrandInVBank(brand, refetch) {
|
|
89
|
+
return asVow(() => {
|
|
90
|
+
const { vbankAssetsByBrand } = this.state;
|
|
91
|
+
if (vbankAssetsByBrand.has(brand) && !refetch) {
|
|
92
|
+
return vbankAssetsByBrand.get(brand);
|
|
93
|
+
}
|
|
94
|
+
const vbankAssetNameHubP = E(agoricNames).lookup('vbankAsset');
|
|
95
|
+
const vbankAssetEntriesP = E(vbankAssetNameHubP).values();
|
|
96
|
+
return watch(
|
|
97
|
+
vbankAssetEntriesP,
|
|
98
|
+
this.facets.vbankAssetEntriesWatcher,
|
|
99
|
+
{ brand },
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
);
|
|
106
|
+
// XXX only works once per zone.
|
|
107
|
+
return makeResumableAgoricNamesHackKit().public;
|
|
108
|
+
};
|
|
109
|
+
/** @typedef {ReturnType<typeof makeResumableAgoricNamesHack>} AgNamesTools */
|
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
|
|
19
|
-
* @template
|
|
20
|
-
* @template
|
|
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 {
|
|
26
|
+
* @param {HostContext} hostCtx - values to pass through the async flow
|
|
27
|
+
* membrane
|
|
24
28
|
* @param {(
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* ...args:
|
|
28
|
-
* ) => Promise<
|
|
29
|
-
* @returns {(...args:
|
|
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<
|
|
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';
|
package/src/facade.d.ts.map
CHANGED
|
@@ -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;
|
|
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
|
|
88
|
-
* @template
|
|
89
|
-
* @template
|
|
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 {
|
|
99
|
+
* @param {HostContext} hostCtx - values to pass through the async flow
|
|
100
|
+
* membrane
|
|
93
101
|
* @param {(
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* ...args:
|
|
97
|
-
* ) => Promise<
|
|
98
|
-
* @returns {(...args:
|
|
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,
|
|
101
|
-
const
|
|
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
|
-
|
|
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);
|
|
@@ -10,8 +10,20 @@ export function provideOrchestration(zcf: ZCF, baggage: Baggage, remotePowers: O
|
|
|
10
10
|
}): import("@agoric/vow").Vow<import("../cosmos-api.js").IBCConnectionInfo>;
|
|
11
11
|
getChainsAndConnection<C1 extends string, C2 extends string>(chainName1: C1, chainName2: C2): import("@agoric/vow").Vow<[ActualChainInfo<C1>, ActualChainInfo<C2>, import("../cosmos-api.js").IBCConnectionInfo]>;
|
|
12
12
|
}>;
|
|
13
|
+
vowTools: {
|
|
14
|
+
when: <T, TResult1 = import("@agoric/vow").EUnwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("@agoric/vow").EUnwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
|
|
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
|
+
makeVowKit: <T>() => import("@agoric/vow").VowKit<T>;
|
|
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>>;
|
|
19
|
+
};
|
|
13
20
|
zone: import("@agoric/base-zone").Zone;
|
|
14
|
-
orchestrate<
|
|
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
|
+
}>;
|
|
15
27
|
};
|
|
16
28
|
export type OrchestrationPowers = {
|
|
17
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
|
|
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"}
|
|
@@ -45,8 +45,9 @@ export const provideOrchestration = (
|
|
|
45
45
|
marshaller,
|
|
46
46
|
) => {
|
|
47
47
|
const zone = makeDurableZone(baggage);
|
|
48
|
+
const { agoricNames, timerService } = remotePowers;
|
|
48
49
|
|
|
49
|
-
const chainHub = makeChainHub(
|
|
50
|
+
const chainHub = makeChainHub(agoricNames);
|
|
50
51
|
|
|
51
52
|
const vowTools = prepareVowTools(zone.subZone('vows'));
|
|
52
53
|
|
|
@@ -55,7 +56,7 @@ export const provideOrchestration = (
|
|
|
55
56
|
zone,
|
|
56
57
|
makeRecorderKit,
|
|
57
58
|
zcf,
|
|
58
|
-
|
|
59
|
+
timerService,
|
|
59
60
|
vowTools,
|
|
60
61
|
chainHub,
|
|
61
62
|
);
|
|
@@ -103,6 +104,6 @@ export const provideOrchestration = (
|
|
|
103
104
|
vowTools,
|
|
104
105
|
...remotePowers,
|
|
105
106
|
});
|
|
106
|
-
return { ...facade, chainHub, zone };
|
|
107
|
+
return { ...facade, chainHub, vowTools, zone };
|
|
107
108
|
};
|
|
108
109
|
harden(provideOrchestration);
|