@agoric/orchestration 0.1.1-dev-81ac381.0 → 0.1.1-dev-c3009d4.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/README.md +15 -0
- package/package.json +17 -17
- package/src/examples/auto-stake-it.contract.d.ts.map +1 -1
- package/src/examples/auto-stake-it.contract.js +2 -1
- package/src/examples/basic-flows.contract.d.ts.map +1 -1
- package/src/examples/basic-flows.contract.js +3 -1
- package/src/examples/sendAnywhere.contract.js +2 -2
- package/src/examples/sendAnywhere.flows.d.ts +27 -0
- package/src/examples/sendAnywhere.flows.d.ts.map +1 -0
- package/src/examples/sendAnywhere.flows.js +59 -0
- package/src/examples/swapExample.contract.d.ts.map +1 -1
- package/src/examples/swapExample.contract.js +2 -1
- package/src/examples/unbondExample.contract.d.ts.map +1 -1
- package/src/examples/unbondExample.contract.js +2 -1
- package/src/facade.d.ts +5 -4
- package/src/facade.d.ts.map +1 -1
- package/src/facade.js +7 -16
- package/src/orchestration-api.d.ts +4 -0
- package/src/orchestration-api.d.ts.map +1 -1
- package/src/orchestration-api.ts +5 -0
- package/src/utils/start-helper.d.ts +2 -2
- package/src/utils/start-helper.d.ts.map +1 -1
- package/src/examples/sendAnywhereFlows.d.ts +0 -28
- package/src/examples/sendAnywhereFlows.d.ts.map +0 -1
- package/src/examples/sendAnywhereFlows.js +0 -62
package/README.md
CHANGED
|
@@ -3,3 +3,18 @@
|
|
|
3
3
|
Build feature-rich applications that can orchestrate assets and services across the interchain.
|
|
4
4
|
|
|
5
5
|
Usage examples can be found under [src/examples](https://github.com/Agoric/agoric-sdk/tree/master/packages/orchestration/src/examples). They are exported for integration testing with other packages.
|
|
6
|
+
|
|
7
|
+
## Orchestration flows
|
|
8
|
+
|
|
9
|
+
Flows to orchestrate are regular Javascript functions but have some constraints to fulfill the requirements of resumability after termination of the enclosing vat. Some requirements for each orchestration flow:
|
|
10
|
+
- must not close over any values that could change between invocations
|
|
11
|
+
- must satisfy the `OrchestrationFlow` interface
|
|
12
|
+
- must be hardened
|
|
13
|
+
- must not use `E()` (eventual send)
|
|
14
|
+
|
|
15
|
+
The call to `orchestrate` using a flow function in reincarnations of the vat must have the same `durableName` as before. To help enforce these constraints, we recommend:
|
|
16
|
+
|
|
17
|
+
- keeping flows in a `.flows.js` module
|
|
18
|
+
- importing them all with `import * as flows` to get a single object keyed by the export name
|
|
19
|
+
- using `orchestrateAll` to treat each export name as the `durableName` of the flow
|
|
20
|
+
- adopting `@agoric/eslint-config` that has rules to help detect problems
|
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-c3009d4.0+c3009d4",
|
|
4
4
|
"description": "Chain abstraction for Agoric's orchestration clients",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@agoric/async-flow": "0.1.1-dev-
|
|
37
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
38
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
39
|
-
"@agoric/internal": "0.3.3-dev-
|
|
40
|
-
"@agoric/network": "0.1.1-dev-
|
|
41
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
42
|
-
"@agoric/store": "0.9.3-dev-
|
|
43
|
-
"@agoric/time": "0.3.3-dev-
|
|
44
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
45
|
-
"@agoric/vats": "0.15.2-dev-
|
|
46
|
-
"@agoric/vow": "0.1.1-dev-
|
|
47
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
48
|
-
"@agoric/zone": "0.2.3-dev-
|
|
36
|
+
"@agoric/async-flow": "0.1.1-dev-c3009d4.0+c3009d4",
|
|
37
|
+
"@agoric/cosmic-proto": "0.4.1-dev-c3009d4.0+c3009d4",
|
|
38
|
+
"@agoric/ertp": "0.16.3-dev-c3009d4.0+c3009d4",
|
|
39
|
+
"@agoric/internal": "0.3.3-dev-c3009d4.0+c3009d4",
|
|
40
|
+
"@agoric/network": "0.1.1-dev-c3009d4.0+c3009d4",
|
|
41
|
+
"@agoric/notifier": "0.6.3-dev-c3009d4.0+c3009d4",
|
|
42
|
+
"@agoric/store": "0.9.3-dev-c3009d4.0+c3009d4",
|
|
43
|
+
"@agoric/time": "0.3.3-dev-c3009d4.0+c3009d4",
|
|
44
|
+
"@agoric/vat-data": "0.5.3-dev-c3009d4.0+c3009d4",
|
|
45
|
+
"@agoric/vats": "0.15.2-dev-c3009d4.0+c3009d4",
|
|
46
|
+
"@agoric/vow": "0.1.1-dev-c3009d4.0+c3009d4",
|
|
47
|
+
"@agoric/zoe": "0.26.3-dev-c3009d4.0+c3009d4",
|
|
48
|
+
"@agoric/zone": "0.2.3-dev-c3009d4.0+c3009d4",
|
|
49
49
|
"@endo/base64": "^1.0.5",
|
|
50
50
|
"@endo/errors": "^1.2.2",
|
|
51
51
|
"@endo/far": "^1.1.2",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@noble/hashes": "github:paulmillr/noble-hashes#ae060da"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
57
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-c3009d4.0+c3009d4",
|
|
58
58
|
"@chain-registry/client": "^1.47.4",
|
|
59
59
|
"@cosmjs/amino": "^0.32.3",
|
|
60
60
|
"@cosmjs/proto-signing": "^0.32.3",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
|
94
94
|
"typeCoverage": {
|
|
95
|
-
"atLeast": 98.
|
|
95
|
+
"atLeast": 98.05
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "c3009d4f42964b2810efe09d38e14bde66c9e9b6"
|
|
98
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-stake-it.contract.d.ts","sourceRoot":"","sources":["auto-stake-it.contract.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auto-stake-it.contract.d.ts","sourceRoot":"","sources":["auto-stake-it.contract.js"],"names":[],"mappings":"AA0LA;gBAhDiB,UAAU;;;;;;;;;;;uBA5FX,MAAM;uBACN,sBAAsB;wBACrB,KAAK;;;;;;;;;;;;;GA0I2B;kCA/JpC;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;4BA2JU,OAAO,KAAK;yCA/KY,2CAA2C;4CAMsE,uBAAuB;2BAAvB,uBAAuB;gCALjJ,gCAAgC;4BAEpC,aAAa;6CAGiH,uBAAuB;kCAP/I,cAAc;6BAGnB,cAAc"}
|
|
@@ -17,7 +17,7 @@ import { preparePortfolioHolder } from '../exos/portfolio-holder-kit.js';
|
|
|
17
17
|
* @import {Remote} from '@agoric/vow';
|
|
18
18
|
* @import {Zone} from '@agoric/zone';
|
|
19
19
|
* @import {GuestInterface} from '@agoric/async-flow';
|
|
20
|
-
* @import {CosmosValidatorAddress, Orchestrator, CosmosInterchainService, Denom, OrchestrationAccount, StakingAccountActions} from '@agoric/orchestration';
|
|
20
|
+
* @import {CosmosValidatorAddress, Orchestrator, CosmosInterchainService, Denom, OrchestrationAccount, StakingAccountActions, OrchestrationFlow} from '@agoric/orchestration';
|
|
21
21
|
* @import {MakeStakingTap} from './auto-stake-it-tap-kit.js';
|
|
22
22
|
* @import {MakePortfolioHolder} from '../exos/portfolio-holder-kit.js';
|
|
23
23
|
* @import {ChainHub} from '../exos/chain-hub.js';
|
|
@@ -35,6 +35,7 @@ import { preparePortfolioHolder } from '../exos/portfolio-holder-kit.js';
|
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
+
* @satisfies {OrchestrationFlow}
|
|
38
39
|
* @param {Orchestrator} orch
|
|
39
40
|
* @param {{
|
|
40
41
|
* makeStakingTap: MakeStakingTap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic-flows.contract.d.ts","sourceRoot":"","sources":["basic-flows.contract.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"basic-flows.contract.d.ts","sourceRoot":"","sources":["basic-flows.contract.js"],"names":[],"mappings":"AAqIA;gBAhDiB,UAAU;;;;uBA3DH,MAAM;;;;;;;;;;wBAoBL,MAAM,EAAE;;;GAuFgB;2BAEnC,OAAO,KAAK;yCA1HY,0BAA0B;yCAD1B,2CAA2C"}
|
|
@@ -9,7 +9,7 @@ import { preparePortfolioHolder } from '../exos/portfolio-holder-kit.js';
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @import {Zone} from '@agoric/zone';
|
|
12
|
-
* @import {OrchestrationAccount, Orchestrator} from '@agoric/orchestration';
|
|
12
|
+
* @import {OrchestrationAccount, OrchestrationFlow, Orchestrator} from '@agoric/orchestration';
|
|
13
13
|
* @import {ResolvedPublicTopic} from '@agoric/zoe/src/contractSupport/topics.js';
|
|
14
14
|
* @import {OrchestrationPowers} from '../utils/start-helper.js';
|
|
15
15
|
* @import {MakePortfolioHolder} from '../exos/portfolio-holder-kit.js';
|
|
@@ -20,6 +20,7 @@ import { preparePortfolioHolder } from '../exos/portfolio-holder-kit.js';
|
|
|
20
20
|
* Create an account on a Cosmos chain and return a continuing offer with
|
|
21
21
|
* invitations makers for Delegate, WithdrawRewards, Transfer, etc.
|
|
22
22
|
*
|
|
23
|
+
* @satisfies {OrchestrationFlow}
|
|
23
24
|
* @param {Orchestrator} orch
|
|
24
25
|
* @param {undefined} _ctx
|
|
25
26
|
* @param {ZCFSeat} seat
|
|
@@ -39,6 +40,7 @@ const makeOrchAccountHandler = async (orch, _ctx, seat, { chainName }) => {
|
|
|
39
40
|
* Calls to the underlying invitationMakers are proxied through the
|
|
40
41
|
* `MakeInvitation` invitation maker.
|
|
41
42
|
*
|
|
43
|
+
* @satisfies {OrchestrationFlow}
|
|
42
44
|
* @param {Orchestrator} orch
|
|
43
45
|
* @param {MakePortfolioHolder} makePortfolioHolder
|
|
44
46
|
* @param {ZCFSeat} seat
|
|
@@ -5,7 +5,7 @@ import { Fail } from '@endo/errors';
|
|
|
5
5
|
import { E } from '@endo/far';
|
|
6
6
|
import { M } from '@endo/patterns';
|
|
7
7
|
import { withOrchestration } from '../utils/start-helper.js';
|
|
8
|
-
import
|
|
8
|
+
import * as flows from './sendAnywhere.flows.js';
|
|
9
9
|
import { prepareChainHubAdmin } from '../exos/chain-hub-admin.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -76,7 +76,7 @@ const contract = async (
|
|
|
76
76
|
);
|
|
77
77
|
|
|
78
78
|
// orchestrate uses the names on orchestrationFns to do a "prepare" of the associated behavior
|
|
79
|
-
const orchFns = orchestrateAll(
|
|
79
|
+
const orchFns = orchestrateAll(flows, {
|
|
80
80
|
zcf,
|
|
81
81
|
contractState,
|
|
82
82
|
localTransfer: zoeTools.localTransfer,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @satisfies {OrchestrationFlow}
|
|
3
|
+
* @param {Orchestrator} orch
|
|
4
|
+
* @param {object} ctx
|
|
5
|
+
* @param {{ account?: OrchestrationAccountI & LocalAccountMethods }} ctx.contractState
|
|
6
|
+
* @param {GuestOf<ZoeTools['localTransfer']>} ctx.localTransfer
|
|
7
|
+
* @param {(brand: Brand) => Promise<VBankAssetDetail>} ctx.findBrandInVBank
|
|
8
|
+
* @param {ZCFSeat} seat
|
|
9
|
+
* @param {{ chainName: string; destAddr: string }} offerArgs
|
|
10
|
+
*/
|
|
11
|
+
export function sendIt(orch: Orchestrator, { contractState, localTransfer, findBrandInVBank }: {
|
|
12
|
+
contractState: {
|
|
13
|
+
account?: OrchestrationAccountI & LocalAccountMethods;
|
|
14
|
+
};
|
|
15
|
+
localTransfer: GuestOf<ZoeTools["localTransfer"]>;
|
|
16
|
+
findBrandInVBank: (brand: Brand) => Promise<VBankAssetDetail>;
|
|
17
|
+
}, seat: ZCFSeat, offerArgs: {
|
|
18
|
+
chainName: string;
|
|
19
|
+
destAddr: string;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
import type { Orchestrator } from '../types.js';
|
|
22
|
+
import type { OrchestrationAccountI } from '../types.js';
|
|
23
|
+
import type { LocalAccountMethods } from '../types.js';
|
|
24
|
+
import type { ZoeTools } from '../utils/zoe-tools.js';
|
|
25
|
+
import type { GuestOf } from '@agoric/async-flow';
|
|
26
|
+
import type { VBankAssetDetail } from '@agoric/vats/tools/board-utils.js';
|
|
27
|
+
//# sourceMappingURL=sendAnywhere.flows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendAnywhere.flows.d.ts","sourceRoot":"","sources":["sendAnywhere.flows.js"],"names":[],"mappings":"AAcA;;;;;;;;;GASG;AACH,6BARW,YAAY,sDAEpB;IAAuE,aAAa,EAA5E;QAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,mBAAmB,CAAA;KAAE;IACjB,aAAa,EAArD,QAAQ,QAAQ,CAAC,eAAe,CAAC,CAAC;IACe,gBAAgB,EAAjE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,gBAAgB,CAAC;CACnD,QAAQ,OAAO,aACP;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,iBAmCjD;kCAnD6F,aAAa;2CAAb,aAAa;yCAAb,aAAa;8BADhF,uBAAuB;6BAFxB,oBAAoB;sCACX,mCAAmC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { M, mustMatch } from '@endo/patterns';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @import {GuestOf} from '@agoric/async-flow';
|
|
5
|
+
* @import {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js';
|
|
6
|
+
* @import {ZoeTools} from '../utils/zoe-tools.js';
|
|
7
|
+
* @import {Orchestrator, LocalAccountMethods, OrchestrationAccountI, OrchestrationFlow} from '../types.js';
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { entries } = Object;
|
|
11
|
+
|
|
12
|
+
// in guest file (the orchestration functions)
|
|
13
|
+
// the second argument is all the endowments provided
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @satisfies {OrchestrationFlow}
|
|
17
|
+
* @param {Orchestrator} orch
|
|
18
|
+
* @param {object} ctx
|
|
19
|
+
* @param {{ account?: OrchestrationAccountI & LocalAccountMethods }} ctx.contractState
|
|
20
|
+
* @param {GuestOf<ZoeTools['localTransfer']>} ctx.localTransfer
|
|
21
|
+
* @param {(brand: Brand) => Promise<VBankAssetDetail>} ctx.findBrandInVBank
|
|
22
|
+
* @param {ZCFSeat} seat
|
|
23
|
+
* @param {{ chainName: string; destAddr: string }} offerArgs
|
|
24
|
+
*/
|
|
25
|
+
export async function sendIt(
|
|
26
|
+
orch,
|
|
27
|
+
{ contractState, localTransfer, findBrandInVBank },
|
|
28
|
+
seat,
|
|
29
|
+
offerArgs,
|
|
30
|
+
) {
|
|
31
|
+
mustMatch(offerArgs, harden({ chainName: M.scalar(), destAddr: M.string() }));
|
|
32
|
+
const { chainName, destAddr } = offerArgs;
|
|
33
|
+
// NOTE the proposal shape ensures that the `give` is a single asset
|
|
34
|
+
const { give } = seat.getProposal();
|
|
35
|
+
const [[_kw, amt]] = entries(give);
|
|
36
|
+
const { denom } = await findBrandInVBank(amt.brand);
|
|
37
|
+
const chain = await orch.getChain(chainName);
|
|
38
|
+
|
|
39
|
+
if (!contractState.account) {
|
|
40
|
+
const agoricChain = await orch.getChain('agoric');
|
|
41
|
+
contractState.account = await agoricChain.makeAccount();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const info = await chain.getChainInfo();
|
|
45
|
+
const { chainId } = info;
|
|
46
|
+
assert(typeof chainId === 'string', 'bad chainId');
|
|
47
|
+
|
|
48
|
+
await localTransfer(seat, contractState.account, give);
|
|
49
|
+
|
|
50
|
+
await contractState.account.transfer(
|
|
51
|
+
{ denom, value: amt.value },
|
|
52
|
+
{
|
|
53
|
+
value: destAddr,
|
|
54
|
+
encoding: 'bech32',
|
|
55
|
+
chainId,
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
harden(sendIt);
|
|
@@ -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":"AA8DA,yCAAyC;AACzC,mBADW,YAAY,CAAC,OAAO,KAAK,CAAC,CAWnC;AASK,0CAHI,KAAK;;;EAIsC;AA6CtD;iBAtCkB,OAAO,OAAO,CAAC;gBAChB,OAAO,UAAU,CAAC;0BACR,OAAO,uBAAuB,CAAC;iBACxC,OAAO,WAAW,CAAC;kBAClB,OAAO,YAAY,CAAC;gBACtB,UAAU;;;;oBAtEhB,MAAM,CAAC,KAAK,CAAC;uBACb,sBAAsB;;;GAsGgB;6BAnHvB,cAAc;4BAFf,kBAAkB;gCADd,gCAAgC;6CAEnB,sCAAsC;kCAHjD,cAAc;4CAD6B,aAAa"}
|
|
@@ -6,7 +6,7 @@ import { withOrchestration } from '../utils/start-helper.js';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @import {LocalTransfer} from '../utils/zoe-tools.js';
|
|
9
|
-
* @import {Orchestrator, CosmosValidatorAddress} from '../types.js'
|
|
9
|
+
* @import {Orchestrator, CosmosValidatorAddress, OrchestrationFlow} from '../types.js'
|
|
10
10
|
* @import {TimerService} from '@agoric/time';
|
|
11
11
|
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
12
12
|
* @import {Remote} from '@agoric/internal';
|
|
@@ -17,6 +17,7 @@ import { withOrchestration } from '../utils/start-helper.js';
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
+
* @satisfies {OrchestrationFlow}
|
|
20
21
|
* @param {Orchestrator} orch
|
|
21
22
|
* @param {object} ctx
|
|
22
23
|
* @param {LocalTransfer} ctx.localTransfer
|
|
@@ -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":"AAsFA;iBApCkB,OAAO,OAAO,CAAC;gBAChB,OAAO,UAAU,CAAC;0BACR,OAAO,uBAAuB,CAAC;iBACxC,OAAO,WAAW,CAAC;gBACpB,UAAU;kBACR,OAAO,YAAY,CAAC;;;;;GA+BU;6BA/EvB,cAAc;4BACf,kBAAkB;gCAFd,gCAAgC;6CAInB,sCAAsC;kCALjD,cAAc"}
|
|
@@ -2,7 +2,7 @@ import { M } from '@endo/patterns';
|
|
|
2
2
|
import { withOrchestration } from '../utils/start-helper.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @import {Orchestrator,
|
|
5
|
+
* @import {Orchestrator, OrchestrationFlow} from '../types.js'
|
|
6
6
|
* @import {TimerService} from '@agoric/time';
|
|
7
7
|
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
8
8
|
* @import {NameHub} from '@agoric/vats';
|
|
@@ -13,6 +13,7 @@ import { withOrchestration } from '../utils/start-helper.js';
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
+
* @satisfies {OrchestrationFlow}
|
|
16
17
|
* @param {Orchestrator} orch
|
|
17
18
|
* @param {object} ctx
|
|
18
19
|
* @param {ZCF} ctx.zcf
|
package/src/facade.d.ts
CHANGED
|
@@ -14,15 +14,15 @@ export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode,
|
|
|
14
14
|
wakeAll(): void;
|
|
15
15
|
getFlowForOutcomeVow(outcomeVow: any): any;
|
|
16
16
|
}>;
|
|
17
|
-
orchestrate: <
|
|
17
|
+
orchestrate: <HC, GF extends OrchestrationFlow<GuestInterface<HC>>>(durableName: string, hostCtx: HC, guestFn: GF) => HostForGuest<GF>;
|
|
18
18
|
orchestrateAll: <HC, GFM extends {
|
|
19
|
-
[durableName: string]:
|
|
19
|
+
[durableName: string]: OrchestrationFlow<GuestInterface<HC>>;
|
|
20
20
|
}>(guestFns: GFM, hostCtx: HC) => { [N in keyof GFM]: HostForGuest<GFM[N]>; };
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* For a given guest passed to orchestrate(), return the host-side form.
|
|
24
24
|
*/
|
|
25
|
-
export type HostForGuest<GF extends
|
|
25
|
+
export type HostForGuest<GF extends OrchestrationFlow> = GF extends (orc: Orchestrator, ctx: any, ...args: infer GA) => Promise<infer GR> ? (...args: HostArgs<GA>) => Vow<GR> : never;
|
|
26
26
|
export type OrchestrationFacade = ReturnType<typeof makeOrchestrationFacade>;
|
|
27
27
|
import type { Zone } from '@agoric/zone';
|
|
28
28
|
import type { TimerService } from '@agoric/time';
|
|
@@ -32,8 +32,9 @@ import type { MakeRecorderKit } from '@agoric/zoe/src/contractSupport/recorder.j
|
|
|
32
32
|
import type { HostOrchestrator } from './exos/orchestrator.js';
|
|
33
33
|
import type { VowTools } from '@agoric/vow';
|
|
34
34
|
import type { AsyncFlowTools } from '@agoric/async-flow';
|
|
35
|
-
import type { Orchestrator } from './types.js';
|
|
36
35
|
import type { GuestInterface } from '@agoric/async-flow';
|
|
36
|
+
import type { OrchestrationFlow } from './types.js';
|
|
37
|
+
import type { Orchestrator } from './types.js';
|
|
37
38
|
import type { HostArgs } from '@agoric/async-flow';
|
|
38
39
|
import type { Vow } from '@agoric/vow';
|
|
39
40
|
//# sourceMappingURL=facade.d.ts.map
|
package/src/facade.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"AA0CO,sKAZI;IACV,IAAQ,EAAE,IAAI,CAAC;IACf,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,GAAO,EAAE,GAAG,CAAC;IACb,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,eAAmB,EAAE,eAAe,CAAC;IACrC,gBAAoB,EAAE,MAAM,gBAAgB,CAAC;IAC7C,QAAY,EAAE,QAAQ,CAAC;IACvB,cAAkB,EAAE,cAAc,CAAC;CAChC;;;;;;kBA4BW,EAAE,
|
|
1
|
+
{"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"AA0CO,sKAZI;IACV,IAAQ,EAAE,IAAI,CAAC;IACf,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,GAAO,EAAE,GAAG,CAAC;IACb,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,eAAmB,EAAE,eAAe,CAAC;IACrC,gBAAoB,EAAE,MAAM,gBAAgB,CAAC;IAC7C,QAAY,EAAE,QAAQ,CAAC;IACvB,cAAkB,EAAE,cAAc,CAAC;CAChC;;;;;;kBA4BW,EAAE,EACsC,EAAE,SAA1C,kBAAmB,eAAe,EAAE,CAAC,CAAE,eACzC,MAAM,WAEN,EAAE,WACF,EAAE,KACA,YAAY,CAAC,EAAE,CAAC;qBA2BhB,EAAE,EAGT,GAAG,SAFI;QACZ,CAAK,WAAW,EAAE,MAAM,GAAG,kBAAkB,eAAe,EAAE,CAAC,CAAC,CAAC;KAC7D,YAEM,GAAG,WACH,EAAE,KACA,GAAG,CAAc,IAAT,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAE;EAiBxD;;;;yBA1GgC,EAAE,SAAtB,iBAAmB,IACnB,EAAE,SAAS,CACvB,GAAO,EAAE,YAAY,EACrB,GAAO,EAAE,GAAG,EACZ,GAAO,IAAI,EAAE,MAAM,EAAE,KACd,OAAO,CAAC,MAAM,EAAE,CAAC,GAClB,CAAC,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,GAClC,KAAK;kCAqGE,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BAzHjC,cAAc;kCAEN,cAAc;4BAGpB,kBAAkB;6CACD,qCAAqC;qCAHhC,6CAA6C;sCACzD,wBAAwB;8BAH3B,aAAa;oCAFsB,oBAAoB;oCAApB,oBAAoB;uCAQuC,YAAY;kCAAZ,YAAY;8BARvE,oBAAoB;yBAEvD,aAAa"}
|
package/src/facade.js
CHANGED
|
@@ -11,13 +11,13 @@ import { assertAllDefined } from '@agoric/internal';
|
|
|
11
11
|
* @import {HostOrchestrator} from './exos/orchestrator.js';
|
|
12
12
|
* @import {Remote} from '@agoric/internal';
|
|
13
13
|
* @import {CosmosInterchainService} from './exos/cosmos-interchain-service.js';
|
|
14
|
-
* @import {Chain, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, Orchestrator} from './types.js';
|
|
14
|
+
* @import {Chain, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, OrchestrationFlow, Orchestrator} from './types.js';
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* For a given guest passed to orchestrate(), return the host-side form.
|
|
19
19
|
*
|
|
20
|
-
* @template {
|
|
20
|
+
* @template {OrchestrationFlow} GF
|
|
21
21
|
* @typedef {GF extends (
|
|
22
22
|
* orc: Orchestrator,
|
|
23
23
|
* ctx: any,
|
|
@@ -66,18 +66,13 @@ export const makeOrchestrationFacade = ({
|
|
|
66
66
|
const { prepareEndowment, asyncFlow, adminAsyncFlow } = asyncFlowTools;
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
* @template GR - return type
|
|
70
69
|
* @template HC - host context
|
|
71
|
-
* @template {
|
|
70
|
+
* @template {OrchestrationFlow<GuestInterface<HC>>} GF guest fn
|
|
72
71
|
* @param {string} durableName - the orchestration flow identity in the zone
|
|
73
72
|
* (to resume across upgrades)
|
|
74
73
|
* @param {HC} hostCtx - values to pass through the async flow membrane
|
|
75
|
-
* @param {
|
|
76
|
-
*
|
|
77
|
-
* guestCtx: GuestInterface<HC>,
|
|
78
|
-
* ...args: GA
|
|
79
|
-
* ) => Promise<GR>} guestFn
|
|
80
|
-
* @returns {(...args: HostArgs<GA>) => Vow<GR>}
|
|
74
|
+
* @param {GF} guestFn
|
|
75
|
+
* @returns {HostForGuest<GF>}
|
|
81
76
|
*/
|
|
82
77
|
const orchestrate = (durableName, hostCtx, guestFn) => {
|
|
83
78
|
const subZone = zone.subZone(durableName);
|
|
@@ -92,7 +87,7 @@ export const makeOrchestrationFacade = ({
|
|
|
92
87
|
const hostFn = asyncFlow(subZone, 'asyncFlow', guestFn);
|
|
93
88
|
|
|
94
89
|
// cast because return could be arbitrary subtype
|
|
95
|
-
const orcFn = /** @type {
|
|
90
|
+
const orcFn = /** @type {HostForGuest<GF>} */ (
|
|
96
91
|
(...args) => hostFn(wrappedOrc, wrappedCtx, ...args)
|
|
97
92
|
);
|
|
98
93
|
|
|
@@ -106,11 +101,7 @@ export const makeOrchestrationFacade = ({
|
|
|
106
101
|
*
|
|
107
102
|
* @template HC - host context
|
|
108
103
|
* @template {{
|
|
109
|
-
* [durableName: string]:
|
|
110
|
-
* orc: Orchestrator,
|
|
111
|
-
* ctx: GuestInterface<HC>,
|
|
112
|
-
* ...args: any[]
|
|
113
|
-
* ) => Promise<any>;
|
|
104
|
+
* [durableName: string]: OrchestrationFlow<GuestInterface<HC>>;
|
|
114
105
|
* }} GFM
|
|
115
106
|
* guest fn map
|
|
116
107
|
* @param {GFM} guestFns
|
|
@@ -7,6 +7,7 @@ import type { Amount, Brand, NatAmount } from '@agoric/ertp/src/types.js';
|
|
|
7
7
|
import type { Timestamp } from '@agoric/time';
|
|
8
8
|
import type { LocalChainAccount } from '@agoric/vats/src/localchain.js';
|
|
9
9
|
import type { ResolvedPublicTopic } from '@agoric/zoe/src/contractSupport/topics.js';
|
|
10
|
+
import type { Passable } from '@endo/marshal';
|
|
10
11
|
import type { ChainInfo, CosmosChainAccountMethods, CosmosChainInfo, IBCMsgTransferOptions, KnownChains, LocalAccountMethods } from './types.js';
|
|
11
12
|
import type { ResolvedContinuingOfferResult } from './utils/zoe-tools.js';
|
|
12
13
|
/**
|
|
@@ -141,6 +142,9 @@ export interface OrchestrationAccountI {
|
|
|
141
142
|
*/
|
|
142
143
|
getPublicTopics: () => Promise<Record<string, ResolvedPublicTopic<unknown>>>;
|
|
143
144
|
}
|
|
145
|
+
export interface OrchestrationFlow<CT = unknown> {
|
|
146
|
+
(orc: Orchestrator, ctx: CT, ...args: Passable[]): Promise<unknown>;
|
|
147
|
+
}
|
|
144
148
|
/**
|
|
145
149
|
* Internal structure for TransferMsgs.
|
|
146
150
|
* The type must be able to express transfers across different chains and transports.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestration-api.d.ts","sourceRoot":"","sources":["orchestration-api.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EA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C,IAAI,CAAC,CAAC;IAEnB;;;;;;OAMG;IACH,aAAa,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtE;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAEhE;;;;;OAKG;IACH,eAAe,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;CAC9E;AAED,MAAM,WAAW,iBAAiB,CAAC,EAAE,GAAG,OAAO;IAC7C,CAAC,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrE;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,YAAY,CAAC;IACxB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,YAAY,CAAA;CAAE,CAAC;AAC3E,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
package/src/orchestration-api.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { CurrentWalletRecord } from '@agoric/smart-wallet/src/smartWallet.j
|
|
|
9
9
|
import type { Timestamp } from '@agoric/time';
|
|
10
10
|
import type { LocalChainAccount } from '@agoric/vats/src/localchain.js';
|
|
11
11
|
import type { ResolvedPublicTopic } from '@agoric/zoe/src/contractSupport/topics.js';
|
|
12
|
+
import type { Passable } from '@endo/marshal';
|
|
12
13
|
import type {
|
|
13
14
|
ChainInfo,
|
|
14
15
|
CosmosChainAccountMethods,
|
|
@@ -192,6 +193,10 @@ export interface OrchestrationAccountI {
|
|
|
192
193
|
getPublicTopics: () => Promise<Record<string, ResolvedPublicTopic<unknown>>>;
|
|
193
194
|
}
|
|
194
195
|
|
|
196
|
+
export interface OrchestrationFlow<CT = unknown> {
|
|
197
|
+
(orc: Orchestrator, ctx: CT, ...args: Passable[]): Promise<unknown>;
|
|
198
|
+
}
|
|
199
|
+
|
|
195
200
|
/**
|
|
196
201
|
* Internal structure for TransferMsgs.
|
|
197
202
|
* The type must be able to express transfers across different chains and transports.
|
|
@@ -28,9 +28,9 @@ export function provideOrchestration(zcf: ZCF, baggage: Baggage, remotePowers: O
|
|
|
28
28
|
wakeAll(): void;
|
|
29
29
|
getFlowForOutcomeVow(outcomeVow: any): any;
|
|
30
30
|
}>;
|
|
31
|
-
orchestrate: <
|
|
31
|
+
orchestrate: <HC, GF extends import("../orchestration-api.js").OrchestrationFlow<import("@agoric/async-flow").GuestInterface<HC>>>(durableName: string, hostCtx: HC, guestFn: GF) => HostForGuest<GF>;
|
|
32
32
|
orchestrateAll: <HC, GFM extends {
|
|
33
|
-
[durableName: string]:
|
|
33
|
+
[durableName: string]: import("../orchestration-api.js").OrchestrationFlow<import("@agoric/async-flow").GuestInterface<HC>>;
|
|
34
34
|
}>(guestFns: GFM, hostCtx: HC) => { [N in keyof GFM]: HostForGuest<GFM[N]>; };
|
|
35
35
|
};
|
|
36
36
|
export function withOrchestration<CT extends Record<string, unknown>, PA extends OrchestrationPowers & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-helper.d.ts","sourceRoot":"","sources":["start-helper.js"],"names":[],"mappings":"AA8CO,0CALI,GAAG,WACH,OAAO,gBACP,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|
-
/**
|
|
3
|
-
* @param {Orchestrator} orch
|
|
4
|
-
* @param {object} ctx
|
|
5
|
-
* @param {{ account?: OrchestrationAccountI & LocalAccountMethods }} ctx.contractState
|
|
6
|
-
* @param {GuestOf<ZoeTools['localTransfer']>} ctx.localTransfer
|
|
7
|
-
* @param {(brand: Brand) => Promise<VBankAssetDetail>} ctx.findBrandInVBank
|
|
8
|
-
* @param {ZCFSeat} seat
|
|
9
|
-
* @param {{ chainName: string; destAddr: string }} offerArgs
|
|
10
|
-
*/
|
|
11
|
-
function sendIt(orch: Orchestrator, { contractState, localTransfer, findBrandInVBank }: {
|
|
12
|
-
contractState: {
|
|
13
|
-
account?: OrchestrationAccountI & LocalAccountMethods;
|
|
14
|
-
};
|
|
15
|
-
localTransfer: GuestOf<ZoeTools["localTransfer"]>;
|
|
16
|
-
findBrandInVBank: (brand: Brand) => Promise<VBankAssetDetail>;
|
|
17
|
-
}, seat: ZCFSeat, offerArgs: {
|
|
18
|
-
chainName: string;
|
|
19
|
-
destAddr: string;
|
|
20
|
-
}): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
import type { Orchestrator } from '../types.js';
|
|
23
|
-
import type { OrchestrationAccountI } from '../types.js';
|
|
24
|
-
import type { LocalAccountMethods } from '../types.js';
|
|
25
|
-
import type { ZoeTools } from '../utils/zoe-tools.js';
|
|
26
|
-
import type { GuestOf } from '@agoric/async-flow';
|
|
27
|
-
import type { VBankAssetDetail } from '@agoric/vats/tools/board-utils.js';
|
|
28
|
-
//# sourceMappingURL=sendAnywhereFlows.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sendAnywhereFlows.d.ts","sourceRoot":"","sources":["sendAnywhereFlows.js"],"names":[],"mappings":";IAeE;;;;;;;;OAQG;IACH,sBARW,YAAY,sDAEpB;QAAuE,aAAa,EAA5E;YAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,mBAAmB,CAAA;SAAE;QACjB,aAAa,EAArD,QAAQ,QAAQ,CAAC,eAAe,CAAC,CAAC;QACe,gBAAgB,EAAjE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,gBAAgB,CAAC;KACnD,QAAQ,OAAO,aACP;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,iBAsCjD;;kCAtD8F,aAAa;2CAAb,aAAa;yCAAb,aAAa;8BADnF,uBAAuB;6BAFxB,oBAAoB;sCACX,mCAAmC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { M, mustMatch } from '@endo/patterns';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @import {GuestOf} from '@agoric/async-flow';
|
|
5
|
-
* @import {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js';
|
|
6
|
-
* @import {ZoeTools} from '../utils/zoe-tools.js';
|
|
7
|
-
* @import {Orchestrator, OrchestrationAccount, LocalAccountMethods, OrchestrationAccountI} from '../types.js';
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const { entries } = Object;
|
|
11
|
-
|
|
12
|
-
// in guest file (the orchestration functions)
|
|
13
|
-
// the second argument is all the endowments provided
|
|
14
|
-
|
|
15
|
-
export const orchestrationFns = harden({
|
|
16
|
-
/**
|
|
17
|
-
* @param {Orchestrator} orch
|
|
18
|
-
* @param {object} ctx
|
|
19
|
-
* @param {{ account?: OrchestrationAccountI & LocalAccountMethods }} ctx.contractState
|
|
20
|
-
* @param {GuestOf<ZoeTools['localTransfer']>} ctx.localTransfer
|
|
21
|
-
* @param {(brand: Brand) => Promise<VBankAssetDetail>} ctx.findBrandInVBank
|
|
22
|
-
* @param {ZCFSeat} seat
|
|
23
|
-
* @param {{ chainName: string; destAddr: string }} offerArgs
|
|
24
|
-
*/
|
|
25
|
-
async sendIt(
|
|
26
|
-
orch,
|
|
27
|
-
{ contractState, localTransfer, findBrandInVBank },
|
|
28
|
-
seat,
|
|
29
|
-
offerArgs,
|
|
30
|
-
) {
|
|
31
|
-
mustMatch(
|
|
32
|
-
offerArgs,
|
|
33
|
-
harden({ chainName: M.scalar(), destAddr: M.string() }),
|
|
34
|
-
);
|
|
35
|
-
const { chainName, destAddr } = offerArgs;
|
|
36
|
-
// NOTE the proposal shape ensures that the `give` is a single asset
|
|
37
|
-
const { give } = seat.getProposal();
|
|
38
|
-
const [[_kw, amt]] = entries(give);
|
|
39
|
-
const { denom } = await findBrandInVBank(amt.brand);
|
|
40
|
-
const chain = await orch.getChain(chainName);
|
|
41
|
-
|
|
42
|
-
if (!contractState.account) {
|
|
43
|
-
const agoricChain = await orch.getChain('agoric');
|
|
44
|
-
contractState.account = await agoricChain.makeAccount();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const info = await chain.getChainInfo();
|
|
48
|
-
const { chainId } = info;
|
|
49
|
-
assert(typeof chainId === 'string', 'bad chainId');
|
|
50
|
-
|
|
51
|
-
await localTransfer(seat, contractState.account, give);
|
|
52
|
-
|
|
53
|
-
await contractState.account.transfer(
|
|
54
|
-
{ denom, value: amt.value },
|
|
55
|
-
{
|
|
56
|
-
value: destAddr,
|
|
57
|
-
encoding: 'bech32',
|
|
58
|
-
chainId,
|
|
59
|
-
},
|
|
60
|
-
);
|
|
61
|
-
},
|
|
62
|
-
});
|