@agoric/orchestration 0.1.1-dev-8a8fed3.0 → 0.1.1-dev-bf791ed.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-8a8fed3.0+8a8fed3",
3
+ "version": "0.1.1-dev-bf791ed.0+bf791ed",
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-8a8fed3.0+8a8fed3",
37
- "@agoric/cosmic-proto": "0.4.1-dev-8a8fed3.0+8a8fed3",
38
- "@agoric/ertp": "0.16.3-dev-8a8fed3.0+8a8fed3",
39
- "@agoric/internal": "0.3.3-dev-8a8fed3.0+8a8fed3",
40
- "@agoric/network": "0.1.1-dev-8a8fed3.0+8a8fed3",
41
- "@agoric/notifier": "0.6.3-dev-8a8fed3.0+8a8fed3",
42
- "@agoric/store": "0.9.3-dev-8a8fed3.0+8a8fed3",
43
- "@agoric/time": "0.3.3-dev-8a8fed3.0+8a8fed3",
44
- "@agoric/vat-data": "0.5.3-dev-8a8fed3.0+8a8fed3",
45
- "@agoric/vats": "0.15.2-dev-8a8fed3.0+8a8fed3",
46
- "@agoric/vow": "0.1.1-dev-8a8fed3.0+8a8fed3",
47
- "@agoric/zoe": "0.26.3-dev-8a8fed3.0+8a8fed3",
48
- "@agoric/zone": "0.2.3-dev-8a8fed3.0+8a8fed3",
36
+ "@agoric/async-flow": "0.1.1-dev-bf791ed.0+bf791ed",
37
+ "@agoric/cosmic-proto": "0.4.1-dev-bf791ed.0+bf791ed",
38
+ "@agoric/ertp": "0.16.3-dev-bf791ed.0+bf791ed",
39
+ "@agoric/internal": "0.3.3-dev-bf791ed.0+bf791ed",
40
+ "@agoric/network": "0.1.1-dev-bf791ed.0+bf791ed",
41
+ "@agoric/notifier": "0.6.3-dev-bf791ed.0+bf791ed",
42
+ "@agoric/store": "0.9.3-dev-bf791ed.0+bf791ed",
43
+ "@agoric/time": "0.3.3-dev-bf791ed.0+bf791ed",
44
+ "@agoric/vat-data": "0.5.3-dev-bf791ed.0+bf791ed",
45
+ "@agoric/vats": "0.15.2-dev-bf791ed.0+bf791ed",
46
+ "@agoric/vow": "0.1.1-dev-bf791ed.0+bf791ed",
47
+ "@agoric/zoe": "0.26.3-dev-bf791ed.0+bf791ed",
48
+ "@agoric/zone": "0.2.3-dev-bf791ed.0+bf791ed",
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-8a8fed3.0+8a8fed3",
57
+ "@agoric/swingset-liveslots": "0.10.3-dev-bf791ed.0+bf791ed",
58
58
  "@chain-registry/client": "^1.47.4",
59
59
  "@cosmjs/amino": "^0.32.3",
60
60
  "@cosmjs/proto-signing": "^0.32.3",
@@ -94,5 +94,5 @@
94
94
  "typeCoverage": {
95
95
  "atLeast": 98.05
96
96
  },
97
- "gitHead": "8a8fed33ee6e578227775ed5ad9297f7336fb4be"
97
+ "gitHead": "bf791ed1c7dac4e69fefd5bf478724a273679579"
98
98
  }
@@ -4,15 +4,15 @@ export const start: (zcf: ZCF<Record<string, unknown>>, privateArgs: Orchestrati
4
4
  publicFacet: import("@endo/exo").Guarded<{
5
5
  makeAccountsInvitation(): Promise<Invitation<import("@agoric/vow").Vow<import("@agoric/vow").Vow<{
6
6
  publicSubscribers: {
7
- [k: string]: ResolvedPublicTopic<unknown>;
7
+ [k: string]: import("@agoric/zoe/src/contractSupport/topics.js").ResolvedPublicTopic<unknown>;
8
8
  };
9
9
  invitationMakers: import("@endo/exo").Guarded<{
10
10
  MakeInvitation<IA extends unknown[]>(chainName: string, action: string, invitationArgs: IA): Promise<Invitation<unknown, IA>>;
11
11
  }>;
12
12
  }>>, {
13
13
  chainName: string;
14
- validator: CosmosValidatorAddress;
15
- localDenom: Denom;
14
+ validator: import("@agoric/orchestration").CosmosValidatorAddress;
15
+ localDenom: import("@agoric/orchestration").Denom;
16
16
  }>>;
17
17
  }>;
18
18
  creatorFacet: import("@endo/exo").Guarded<{
@@ -34,9 +34,6 @@ export type OrchestrationPowers = {
34
34
  agoricNames: Remote<NameHub>;
35
35
  };
36
36
  export type AutoStakeItSF = typeof start;
37
- import type { ResolvedPublicTopic } from '@agoric/zoe/src/contractSupport/topics.js';
38
- import type { CosmosValidatorAddress } from '@agoric/orchestration';
39
- import type { Denom } from '@agoric/orchestration';
40
37
  import type { LocalChain } from '@agoric/vats/src/localchain.js';
41
38
  import type { Remote } from '@agoric/vow';
42
39
  import type { CosmosInterchainService } from '@agoric/orchestration';
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"auto-stake-it.contract.d.ts","sourceRoot":"","sources":["auto-stake-it.contract.js"],"names":[],"mappings":"AAuFA;gBAhDiB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDsB;kCAjEpC;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;4BA6DU,OAAO,KAAK;gCA5EG,gCAAgC;4BAEpC,aAAa;6CAEI,uBAAuB;kCALlC,cAAc;6BAEnB,cAAc"}
@@ -2,25 +2,20 @@ import {
2
2
  EmptyProposalShape,
3
3
  InvitationShape,
4
4
  } from '@agoric/zoe/src/typeGuards.js';
5
- import { Fail } from '@endo/errors';
6
5
  import { M } from '@endo/patterns';
7
- import { withOrchestration } from '../utils/start-helper.js';
8
6
  import { prepareChainHubAdmin } from '../exos/chain-hub-admin.js';
9
- import { prepareStakingTap } from './auto-stake-it-tap-kit.js';
10
7
  import { preparePortfolioHolder } from '../exos/portfolio-holder-kit.js';
8
+ import { withOrchestration } from '../utils/start-helper.js';
9
+ import { prepareStakingTap } from './auto-stake-it-tap-kit.js';
10
+ import * as flows from './auto-stake-it.flows.js';
11
11
 
12
12
  /**
13
13
  * @import {TimerService} from '@agoric/time';
14
- * @import {ResolvedPublicTopic} from '@agoric/zoe/src/contractSupport/topics.js';
15
14
  * @import {LocalChain} from '@agoric/vats/src/localchain.js';
16
15
  * @import {NameHub} from '@agoric/vats';
17
16
  * @import {Remote} from '@agoric/vow';
18
17
  * @import {Zone} from '@agoric/zone';
19
- * @import {GuestInterface} from '@agoric/async-flow';
20
- * @import {CosmosValidatorAddress, Orchestrator, CosmosInterchainService, Denom, OrchestrationAccount, StakingAccountActions, OrchestrationFlow} from '@agoric/orchestration';
21
- * @import {MakeStakingTap} from './auto-stake-it-tap-kit.js';
22
- * @import {MakePortfolioHolder} from '../exos/portfolio-holder-kit.js';
23
- * @import {ChainHub} from '../exos/chain-hub.js';
18
+ * @import {CosmosInterchainService} from '@agoric/orchestration';
24
19
  * @import {OrchestrationTools} from '../utils/start-helper.js';
25
20
  */
26
21
 
@@ -34,100 +29,6 @@ import { preparePortfolioHolder } from '../exos/portfolio-holder-kit.js';
34
29
  * }} OrchestrationPowers
35
30
  */
36
31
 
37
- /**
38
- * @satisfies {OrchestrationFlow}
39
- * @param {Orchestrator} orch
40
- * @param {{
41
- * makeStakingTap: MakeStakingTap;
42
- * makePortfolioHolder: MakePortfolioHolder;
43
- * chainHub: GuestInterface<ChainHub>;
44
- * }} ctx
45
- * @param {ZCFSeat} seat
46
- * @param {{
47
- * chainName: string;
48
- * validator: CosmosValidatorAddress;
49
- * localDenom: Denom;
50
- * }} offerArgs
51
- */
52
- const makeAccountsHandler = async (
53
- orch,
54
- { makeStakingTap, makePortfolioHolder, chainHub },
55
- seat,
56
- {
57
- chainName,
58
- validator,
59
- // TODO localDenom is user supplied, until #9211
60
- localDenom,
61
- },
62
- ) => {
63
- seat.exit(); // no funds exchanged
64
- const [agoric, remoteChain] = await Promise.all([
65
- orch.getChain('agoric'),
66
- orch.getChain(chainName),
67
- ]);
68
- const { chainId, stakingTokens } = await remoteChain.getChainInfo();
69
- const remoteDenom = stakingTokens[0].denom;
70
- remoteDenom ||
71
- Fail`${chainId || chainName} does not have stakingTokens in config`;
72
- if (chainId !== validator.chainId) {
73
- Fail`validator chainId ${validator.chainId} does not match remote chainId ${chainId}`;
74
- }
75
- const [localAccount, stakingAccount] = await Promise.all([
76
- agoric.makeAccount(),
77
- /** @type {Promise<OrchestrationAccount<any> & StakingAccountActions>} */ (
78
- remoteChain.makeAccount()
79
- ),
80
- ]);
81
-
82
- const [localChainAddress, remoteChainAddress] = await Promise.all([
83
- localAccount.getAddress(),
84
- stakingAccount.getAddress(),
85
- ]);
86
- const agoricChainId = (await agoric.getChainInfo()).chainId;
87
- const { transferChannel } = await chainHub.getConnectionInfo(
88
- agoricChainId,
89
- chainId,
90
- );
91
- assert(transferChannel.counterPartyChannelId, 'unable to find sourceChannel');
92
-
93
- // Every time the `localAccount` receives `remoteDenom` over IBC, delegate it.
94
- const tap = makeStakingTap({
95
- localAccount,
96
- stakingAccount,
97
- validator,
98
- localChainAddress,
99
- remoteChainAddress,
100
- sourceChannel: transferChannel.counterPartyChannelId,
101
- remoteDenom,
102
- localDenom,
103
- });
104
- // XXX consider storing appRegistration, so we can .revoke() or .updateTargetApp()
105
- // @ts-expect-error tap.receiveUpcall: 'Vow<void> | undefined' not assignable to 'Promise<any>'
106
- await localAccount.monitorTransfers(tap);
107
-
108
- const accountEntries = harden(
109
- /** @type {[string, OrchestrationAccount<any>][]} */ ([
110
- ['agoric', localAccount],
111
- [chainName, stakingAccount],
112
- ]),
113
- );
114
- const publicTopicEntries = harden(
115
- /** @type {[string, ResolvedPublicTopic<unknown>][]} */ (
116
- await Promise.all(
117
- accountEntries.map(async ([name, account]) => {
118
- const { account: topicRecord } = await account.getPublicTopics();
119
- return [name, topicRecord];
120
- }),
121
- )
122
- ),
123
- );
124
- const portfolioHolder = makePortfolioHolder(
125
- accountEntries,
126
- publicTopicEntries,
127
- );
128
- return portfolioHolder.asContinuingOffer();
129
- };
130
-
131
32
  /**
132
33
  * AutoStakeIt allows users to to create an auto-forwarding address that
133
34
  * transfers and stakes tokens on a remote chain when received.
@@ -145,7 +46,7 @@ const contract = async (
145
46
  zcf,
146
47
  _privateArgs,
147
48
  zone,
148
- { chainHub, orchestrate, vowTools },
49
+ { chainHub, orchestrateAll, vowTools },
149
50
  ) => {
150
51
  const makeStakingTap = prepareStakingTap(
151
52
  zone.subZone('stakingTap'),
@@ -156,11 +57,11 @@ const contract = async (
156
57
  vowTools,
157
58
  );
158
59
 
159
- const makeAccounts = orchestrate(
160
- 'makeAccounts',
161
- { makeStakingTap, makePortfolioHolder, chainHub },
162
- makeAccountsHandler,
163
- );
60
+ const { makeAccounts } = orchestrateAll(flows, {
61
+ makeStakingTap,
62
+ makePortfolioHolder,
63
+ chainHub,
64
+ });
164
65
 
165
66
  const publicFacet = zone.exo(
166
67
  'AutoStakeIt Public Facet',
@@ -0,0 +1,25 @@
1
+ export function makeAccounts(orch: Orchestrator, { makeStakingTap, makePortfolioHolder, chainHub }: {
2
+ makeStakingTap: MakeStakingTap;
3
+ makePortfolioHolder: MakePortfolioHolder;
4
+ chainHub: GuestInterface<ChainHub>;
5
+ }, seat: ZCFSeat, { chainName, validator, localDenom, }: {
6
+ chainName: string;
7
+ validator: CosmosValidatorAddress;
8
+ localDenom: Denom;
9
+ }): Promise<import("@agoric/vow").Vow<{
10
+ publicSubscribers: {
11
+ [k: string]: ResolvedPublicTopic<unknown>;
12
+ };
13
+ invitationMakers: import("@endo/exo").Guarded<{
14
+ MakeInvitation<IA extends unknown[]>(chainName: string, action: string, invitationArgs: IA): Promise<Invitation<unknown, IA>>;
15
+ }>;
16
+ }>>;
17
+ import type { Orchestrator } from '@agoric/orchestration';
18
+ import type { MakeStakingTap } from './auto-stake-it-tap-kit.js';
19
+ import type { MakePortfolioHolder } from '../exos/portfolio-holder-kit.js';
20
+ import type { ChainHub } from '../exos/chain-hub.js';
21
+ import type { GuestInterface } from '@agoric/async-flow';
22
+ import type { CosmosValidatorAddress } from '@agoric/orchestration';
23
+ import type { Denom } from '@agoric/orchestration';
24
+ import type { ResolvedPublicTopic } from '@agoric/zoe/src/contractSupport/topics.js';
25
+ //# sourceMappingURL=auto-stake-it.flows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-stake-it.flows.d.ts","sourceRoot":"","sources":["auto-stake-it.flows.js"],"names":[],"mappings":"AA0BO,mCAbI,YAAY,qDACZ;IACV,cAAkB,EAAE,cAAc,CAAC;IACnC,mBAAuB,EAAE,mBAAmB,CAAC;IAC7C,QAAY,EAAE,eAAe,QAAQ,CAAC,CAAC;CACpC,QACO,OAAO,yCACP;IACV,SAAa,EAAE,MAAM,CAAC;IACtB,SAAa,EAAE,sBAAsB,CAAC;IACtC,UAAc,EAAE,KAAK,CAAC;CACnB;;;;;;;IA+EH;kCAlGsJ,uBAAuB;oCAC7I,4BAA4B;yCACvB,iCAAiC;8BAC5C,sBAAsB;oCAJhB,oBAAoB;4CACkG,uBAAuB;2BAAvB,uBAAuB;yCAFxI,2CAA2C"}
@@ -0,0 +1,104 @@
1
+ import { Fail } from '@endo/errors';
2
+
3
+ /**
4
+ * @import {ResolvedPublicTopic} from '@agoric/zoe/src/contractSupport/topics.js';
5
+ * @import {GuestInterface} from '@agoric/async-flow';
6
+ * @import {CosmosValidatorAddress, Orchestrator, CosmosInterchainService, Denom, OrchestrationAccount, StakingAccountActions, OrchestrationFlow} from '@agoric/orchestration';
7
+ * @import {MakeStakingTap} from './auto-stake-it-tap-kit.js';
8
+ * @import {MakePortfolioHolder} from '../exos/portfolio-holder-kit.js';
9
+ * @import {ChainHub} from '../exos/chain-hub.js';
10
+ */
11
+
12
+ /**
13
+ * @satisfies {OrchestrationFlow}
14
+ * @param {Orchestrator} orch
15
+ * @param {{
16
+ * makeStakingTap: MakeStakingTap;
17
+ * makePortfolioHolder: MakePortfolioHolder;
18
+ * chainHub: GuestInterface<ChainHub>;
19
+ * }} ctx
20
+ * @param {ZCFSeat} seat
21
+ * @param {{
22
+ * chainName: string;
23
+ * validator: CosmosValidatorAddress;
24
+ * localDenom: Denom;
25
+ * }} offerArgs
26
+ */
27
+ export const makeAccounts = async (
28
+ orch,
29
+ { makeStakingTap, makePortfolioHolder, chainHub },
30
+ seat,
31
+ {
32
+ chainName,
33
+ validator,
34
+ // TODO localDenom is user supplied, until #9211
35
+ localDenom,
36
+ },
37
+ ) => {
38
+ seat.exit(); // no funds exchanged
39
+ const [agoric, remoteChain] = await Promise.all([
40
+ orch.getChain('agoric'),
41
+ orch.getChain(chainName),
42
+ ]);
43
+ const { chainId, stakingTokens } = await remoteChain.getChainInfo();
44
+ const remoteDenom = stakingTokens[0].denom;
45
+ remoteDenom ||
46
+ Fail`${chainId || chainName} does not have stakingTokens in config`;
47
+ if (chainId !== validator.chainId) {
48
+ Fail`validator chainId ${validator.chainId} does not match remote chainId ${chainId}`;
49
+ }
50
+ const [localAccount, stakingAccount] = await Promise.all([
51
+ agoric.makeAccount(),
52
+ /** @type {Promise<OrchestrationAccount<any> & StakingAccountActions>} */ (
53
+ remoteChain.makeAccount()
54
+ ),
55
+ ]);
56
+
57
+ const [localChainAddress, remoteChainAddress] = await Promise.all([
58
+ localAccount.getAddress(),
59
+ stakingAccount.getAddress(),
60
+ ]);
61
+ const agoricChainId = (await agoric.getChainInfo()).chainId;
62
+ const { transferChannel } = await chainHub.getConnectionInfo(
63
+ agoricChainId,
64
+ chainId,
65
+ );
66
+ assert(transferChannel.counterPartyChannelId, 'unable to find sourceChannel');
67
+
68
+ // Every time the `localAccount` receives `remoteDenom` over IBC, delegate it.
69
+ const tap = makeStakingTap({
70
+ localAccount,
71
+ stakingAccount,
72
+ validator,
73
+ localChainAddress,
74
+ remoteChainAddress,
75
+ sourceChannel: transferChannel.counterPartyChannelId,
76
+ remoteDenom,
77
+ localDenom,
78
+ });
79
+ // XXX consider storing appRegistration, so we can .revoke() or .updateTargetApp()
80
+ // @ts-expect-error tap.receiveUpcall: 'Vow<void> | undefined' not assignable to 'Promise<any>'
81
+ await localAccount.monitorTransfers(tap);
82
+
83
+ const accountEntries = harden(
84
+ /** @type {[string, OrchestrationAccount<any>][]} */ ([
85
+ ['agoric', localAccount],
86
+ [chainName, stakingAccount],
87
+ ]),
88
+ );
89
+ const publicTopicEntries = harden(
90
+ /** @type {[string, ResolvedPublicTopic<unknown>][]} */ (
91
+ await Promise.all(
92
+ accountEntries.map(async ([name, account]) => {
93
+ const { account: topicRecord } = await account.getPublicTopics();
94
+ return [name, topicRecord];
95
+ }),
96
+ )
97
+ ),
98
+ );
99
+ const portfolioHolder = makePortfolioHolder(
100
+ accountEntries,
101
+ publicTopicEntries,
102
+ );
103
+ return portfolioHolder.asContinuingOffer();
104
+ };
@@ -7,7 +7,7 @@ export const start: (zcf: ZCF<Record<string, unknown>>, privateArgs: Orchestrati
7
7
  }>>;
8
8
  makePortfolioAccountInvitation(): Promise<Invitation<import("@agoric/vow").Vow<import("@agoric/vow").Vow<{
9
9
  publicSubscribers: {
10
- [k: string]: ResolvedPublicTopic<unknown>;
10
+ [k: string]: import("@agoric/zoe/src/contractSupport/topics.js").ResolvedPublicTopic<unknown>;
11
11
  };
12
12
  invitationMakers: import("@endo/exo").Guarded<{
13
13
  MakeInvitation<IA extends unknown[]>(chainName: string, action: string, invitationArgs: IA): Promise<Invitation<unknown, IA>>;
@@ -19,5 +19,4 @@ export const start: (zcf: ZCF<Record<string, unknown>>, privateArgs: Orchestrati
19
19
  }>;
20
20
  export type BasicFlowsSF = typeof start;
21
21
  import type { OrchestrationPowers } from '../utils/start-helper.js';
22
- import type { ResolvedPublicTopic } from '@agoric/zoe/src/contractSupport/topics.js';
23
22
  //# sourceMappingURL=basic-flows.contract.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"basic-flows.contract.d.ts","sourceRoot":"","sources":["basic-flows.contract.js"],"names":[],"mappings":"AA8DA;gBA3CiB,UAAU;;;;;;;;;;;;;;;;;GA2CsB;2BAEnC,OAAO,KAAK;yCApDY,0BAA0B"}
@@ -3,83 +3,17 @@
3
3
  * leverage basic functionality of the Orchestration API with async-flow.
4
4
  */
5
5
  import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
6
- import { M, mustMatch } from '@endo/patterns';
7
- import { withOrchestration } from '../utils/start-helper.js';
6
+ import { M } from '@endo/patterns';
8
7
  import { preparePortfolioHolder } from '../exos/portfolio-holder-kit.js';
8
+ import { withOrchestration } from '../utils/start-helper.js';
9
+ import * as flows from './basic-flows.flows.js';
9
10
 
10
11
  /**
11
12
  * @import {Zone} from '@agoric/zone';
12
- * @import {OrchestrationAccount, OrchestrationFlow, Orchestrator} from '@agoric/orchestration';
13
- * @import {ResolvedPublicTopic} from '@agoric/zoe/src/contractSupport/topics.js';
14
13
  * @import {OrchestrationPowers} from '../utils/start-helper.js';
15
- * @import {MakePortfolioHolder} from '../exos/portfolio-holder-kit.js';
16
14
  * @import {OrchestrationTools} from '../utils/start-helper.js';
17
15
  */
18
16
 
19
- /**
20
- * Create an account on a Cosmos chain and return a continuing offer with
21
- * invitations makers for Delegate, WithdrawRewards, Transfer, etc.
22
- *
23
- * @satisfies {OrchestrationFlow}
24
- * @param {Orchestrator} orch
25
- * @param {undefined} _ctx
26
- * @param {ZCFSeat} seat
27
- * @param {{ chainName: string }} offerArgs
28
- */
29
- const makeOrchAccountHandler = async (orch, _ctx, seat, { chainName }) => {
30
- seat.exit(); // no funds exchanged
31
- mustMatch(chainName, M.string());
32
- const remoteChain = await orch.getChain(chainName);
33
- const cosmosAccount = await remoteChain.makeAccount();
34
- return cosmosAccount.asContinuingOffer();
35
- };
36
-
37
- /**
38
- * Create accounts on multiple chains and return them in a single continuing
39
- * offer with invitations makers for Delegate, WithdrawRewards, Transfer, etc.
40
- * Calls to the underlying invitationMakers are proxied through the
41
- * `MakeInvitation` invitation maker.
42
- *
43
- * @satisfies {OrchestrationFlow}
44
- * @param {Orchestrator} orch
45
- * @param {MakePortfolioHolder} makePortfolioHolder
46
- * @param {ZCFSeat} seat
47
- * @param {{ chainNames: string[] }} offerArgs
48
- */
49
- const makePortfolioAcctHandler = async (
50
- orch,
51
- makePortfolioHolder,
52
- seat,
53
- { chainNames },
54
- ) => {
55
- seat.exit(); // no funds exchanged
56
- mustMatch(chainNames, M.arrayOf(M.string()));
57
- const allChains = await Promise.all(chainNames.map(n => orch.getChain(n)));
58
- const allAccounts = await Promise.all(allChains.map(c => c.makeAccount()));
59
-
60
- const accountEntries = harden(
61
- /** @type {[string, OrchestrationAccount<any>][]} */ (
62
- chainNames.map((chainName, index) => [chainName, allAccounts[index]])
63
- ),
64
- );
65
- const publicTopicEntries = harden(
66
- /** @type {[string, ResolvedPublicTopic<unknown>][]} */ (
67
- await Promise.all(
68
- accountEntries.map(async ([name, account]) => {
69
- const { account: topicRecord } = await account.getPublicTopics();
70
- return [name, topicRecord];
71
- }),
72
- )
73
- ),
74
- );
75
- const portfolioHolder = makePortfolioHolder(
76
- accountEntries,
77
- publicTopicEntries,
78
- );
79
-
80
- return portfolioHolder.asContinuingOffer();
81
- };
82
-
83
17
  /**
84
18
  * @param {ZCF} zcf
85
19
  * @param {OrchestrationPowers & {
@@ -88,23 +22,18 @@ const makePortfolioAcctHandler = async (
88
22
  * @param {Zone} zone
89
23
  * @param {OrchestrationTools} tools
90
24
  */
91
- const contract = async (zcf, _privateArgs, zone, { orchestrate, vowTools }) => {
25
+ const contract = async (
26
+ zcf,
27
+ _privateArgs,
28
+ zone,
29
+ { orchestrateAll, vowTools },
30
+ ) => {
92
31
  const makePortfolioHolder = preparePortfolioHolder(
93
32
  zone.subZone('portfolio'),
94
33
  vowTools,
95
34
  );
96
35
 
97
- const makeOrchAccount = orchestrate(
98
- 'makeOrchAccount',
99
- undefined,
100
- makeOrchAccountHandler,
101
- );
102
-
103
- const makePortfolioAccount = orchestrate(
104
- 'makePortfolioAccount',
105
- makePortfolioHolder,
106
- makePortfolioAcctHandler,
107
- );
36
+ const orchFns = orchestrateAll(flows, { makePortfolioHolder });
108
37
 
109
38
  const publicFacet = zone.exo(
110
39
  'Basic Flows Public Facet',
@@ -115,13 +44,13 @@ const contract = async (zcf, _privateArgs, zone, { orchestrate, vowTools }) => {
115
44
  {
116
45
  makeOrchAccountInvitation() {
117
46
  return zcf.makeInvitation(
118
- makeOrchAccount,
47
+ orchFns.makeOrchAccount,
119
48
  'Make an Orchestration Account',
120
49
  );
121
50
  },
122
51
  makePortfolioAccountInvitation() {
123
52
  return zcf.makeInvitation(
124
- makePortfolioAccount,
53
+ orchFns.makePortfolioAccount,
125
54
  'Make an Orchestration Account',
126
55
  );
127
56
  },
@@ -0,0 +1,19 @@
1
+ export function makeOrchAccount(orch: Orchestrator, _ctx: any, seat: ZCFSeat, { chainName }: {
2
+ chainName: string;
3
+ }): Promise<import("../utils/zoe-tools.js").ResolvedContinuingOfferResult>;
4
+ export function makePortfolioAccount(orch: Orchestrator, { makePortfolioHolder }: {
5
+ makePortfolioHolder: MakePortfolioHolder;
6
+ }, seat: ZCFSeat, { chainNames }: {
7
+ chainNames: string[];
8
+ }): Promise<import("@agoric/vow").Vow<{
9
+ publicSubscribers: {
10
+ [k: string]: ResolvedPublicTopic<unknown>;
11
+ };
12
+ invitationMakers: import("@endo/exo").Guarded<{
13
+ MakeInvitation<IA extends unknown[]>(chainName: string, action: string, invitationArgs: IA): Promise<Invitation<unknown, IA>>;
14
+ }>;
15
+ }>>;
16
+ import type { Orchestrator } from '@agoric/orchestration';
17
+ import type { MakePortfolioHolder } from '../exos/portfolio-holder-kit.js';
18
+ import type { ResolvedPublicTopic } from '@agoric/zoe/src/contractSupport/topics.js';
19
+ //# sourceMappingURL=basic-flows.flows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basic-flows.flows.d.ts","sourceRoot":"","sources":["basic-flows.flows.js"],"names":[],"mappings":"AAyBO,sCALI,YAAY,QACZ,GAAG,QACH,OAAO,iBACP;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,0EAQ/B;AAeM,2CANI,YAAY,2BAEpB;IAAiC,mBAAmB,EAA5C,mBAAmB;CAC3B,QAAQ,OAAO,kBACP;IAAE,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE;;;;;;;IAkClC;kCAtEuE,uBAAuB;yCAGzD,iCAAiC;yCAFjC,2CAA2C"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @file Primarily a testing fixture, but also serves as an example of how to
3
+ * leverage basic functionality of the Orchestration API with async-flow.
4
+ */
5
+ import { M, mustMatch } from '@endo/patterns';
6
+
7
+ /**
8
+ * @import {Zone} from '@agoric/zone';
9
+ * @import {OrchestrationAccount, OrchestrationFlow, Orchestrator} from '@agoric/orchestration';
10
+ * @import {ResolvedPublicTopic} from '@agoric/zoe/src/contractSupport/topics.js';
11
+ * @import {OrchestrationPowers} from '../utils/start-helper.js';
12
+ * @import {MakePortfolioHolder} from '../exos/portfolio-holder-kit.js';
13
+ * @import {OrchestrationTools} from '../utils/start-helper.js';
14
+ */
15
+
16
+ /**
17
+ * Create an OrchestrationAccount for a specific chain and return a continuing
18
+ * offer with invitations makers for Delegate, WithdrawRewards, Transfer, etc.
19
+ *
20
+ * @satisfies {OrchestrationFlow}
21
+ * @param {Orchestrator} orch
22
+ * @param {any} _ctx
23
+ * @param {ZCFSeat} seat
24
+ * @param {{ chainName: string }} offerArgs
25
+ */
26
+ export const makeOrchAccount = async (orch, _ctx, seat, { chainName }) => {
27
+ seat.exit(); // no funds exchanged
28
+ mustMatch(chainName, M.string());
29
+ const remoteChain = await orch.getChain(chainName);
30
+ const orchAccount = await remoteChain.makeAccount();
31
+ return orchAccount.asContinuingOffer();
32
+ };
33
+
34
+ /**
35
+ * Create accounts on multiple chains and return them in a single continuing
36
+ * offer with invitations makers for Delegate, WithdrawRewards, Transfer, etc.
37
+ * Calls to the underlying invitationMakers are proxied through the
38
+ * `MakeInvitation` invitation maker.
39
+ *
40
+ * @satisfies {OrchestrationFlow}
41
+ * @param {Orchestrator} orch
42
+ * @param {object} ctx
43
+ * @param {MakePortfolioHolder} ctx.makePortfolioHolder
44
+ * @param {ZCFSeat} seat
45
+ * @param {{ chainNames: string[] }} offerArgs
46
+ */
47
+ export const makePortfolioAccount = async (
48
+ orch,
49
+ { makePortfolioHolder },
50
+ seat,
51
+ { chainNames },
52
+ ) => {
53
+ seat.exit(); // no funds exchanged
54
+ mustMatch(chainNames, M.arrayOf(M.string()));
55
+ const allChains = await Promise.all(chainNames.map(n => orch.getChain(n)));
56
+ const allAccounts = await Promise.all(allChains.map(c => c.makeAccount()));
57
+
58
+ const accountEntries = harden(
59
+ /** @type {[string, OrchestrationAccount<any>][]} */ (
60
+ chainNames.map((chainName, index) => [chainName, allAccounts[index]])
61
+ ),
62
+ );
63
+ const publicTopicEntries = harden(
64
+ /** @type {[string, ResolvedPublicTopic<unknown>][]} */ (
65
+ await Promise.all(
66
+ accountEntries.map(async ([name, account]) => {
67
+ const { account: topicRecord } = await account.getPublicTopics();
68
+ return [name, topicRecord];
69
+ }),
70
+ )
71
+ ),
72
+ );
73
+ const portfolioHolder = makePortfolioHolder(
74
+ accountEntries,
75
+ publicTopicEntries,
76
+ );
77
+
78
+ return portfolioHolder.asContinuingOffer();
79
+ };
@@ -54,7 +54,7 @@ const contract = async (
54
54
  ) => {
55
55
  const contractState = makeStateRecord(
56
56
  /** @type {{ account: OrchestrationAccount<any> | undefined }} */ {
57
- account: undefined,
57
+ localAccount: undefined,
58
58
  },
59
59
  );
60
60
 
@@ -2,7 +2,7 @@
2
2
  * @satisfies {OrchestrationFlow}
3
3
  * @param {Orchestrator} orch
4
4
  * @param {object} ctx
5
- * @param {{ account?: OrchestrationAccountI & LocalAccountMethods }} ctx.contractState
5
+ * @param {{ localAccount?: OrchestrationAccountI & LocalAccountMethods }} ctx.contractState
6
6
  * @param {GuestOf<ZoeTools['localTransfer']>} ctx.localTransfer
7
7
  * @param {(brand: Brand) => Promise<VBankAssetDetail>} ctx.findBrandInVBank
8
8
  * @param {ZCFSeat} seat
@@ -10,7 +10,7 @@
10
10
  */
11
11
  export function sendIt(orch: Orchestrator, { contractState, localTransfer, findBrandInVBank }: {
12
12
  contractState: {
13
- account?: OrchestrationAccountI & LocalAccountMethods;
13
+ localAccount?: OrchestrationAccountI & LocalAccountMethods;
14
14
  };
15
15
  localTransfer: GuestOf<ZoeTools["localTransfer"]>;
16
16
  findBrandInVBank: (brand: Brand) => Promise<VBankAssetDetail>;
@@ -1 +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"}
1
+ {"version":3,"file":"sendAnywhere.flows.d.ts","sourceRoot":"","sources":["sendAnywhere.flows.js"],"names":[],"mappings":"AAcA;;;;;;;;;GASG;AACH,6BARW,YAAY,sDAEpB;IAA4E,aAAa,EAAjF;QAAE,YAAY,CAAC,EAAE,qBAAqB,GAAG,mBAAmB,CAAA;KAAE;IACtB,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"}
@@ -16,7 +16,7 @@ const { entries } = Object;
16
16
  * @satisfies {OrchestrationFlow}
17
17
  * @param {Orchestrator} orch
18
18
  * @param {object} ctx
19
- * @param {{ account?: OrchestrationAccountI & LocalAccountMethods }} ctx.contractState
19
+ * @param {{ localAccount?: OrchestrationAccountI & LocalAccountMethods }} ctx.contractState
20
20
  * @param {GuestOf<ZoeTools['localTransfer']>} ctx.localTransfer
21
21
  * @param {(brand: Brand) => Promise<VBankAssetDetail>} ctx.findBrandInVBank
22
22
  * @param {ZCFSeat} seat
@@ -36,18 +36,18 @@ export async function sendIt(
36
36
  const { denom } = await findBrandInVBank(amt.brand);
37
37
  const chain = await orch.getChain(chainName);
38
38
 
39
- if (!contractState.account) {
39
+ if (!contractState.localAccount) {
40
40
  const agoricChain = await orch.getChain('agoric');
41
- contractState.account = await agoricChain.makeAccount();
41
+ contractState.localAccount = await agoricChain.makeAccount();
42
42
  }
43
43
 
44
44
  const info = await chain.getChainInfo();
45
45
  const { chainId } = info;
46
46
  assert(typeof chainId === 'string', 'bad chainId');
47
47
 
48
- await localTransfer(seat, contractState.account, give);
48
+ await localTransfer(seat, contractState.localAccount, give);
49
49
 
50
- await contractState.account.transfer(
50
+ await contractState.localAccount.transfer(
51
51
  { denom, value: amt.value },
52
52
  {
53
53
  value: destAddr,
@@ -1 +1 @@
1
- {"version":3,"file":"zoe-tools.d.ts","sourceRoot":"","sources":["zoe-tools.js"],"names":[],"mappings":"AAiCO,mCAHI,IAAI,qBACJ;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE;;EA+C1C;4CAjEY;IACZ,gBAAoB,EAAE,gBAAgB,CAAC;IACvC,iBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,CAAC,CAAC,CAAC;CAC7D;4BAMS,CACZ,OAAW,EAAE,OAAO,EACpB,YAAgB,EAAE,mBAAmB,EACrC,IAAQ,EAAE,mBAAmB,KACtB,OAAO,CAAC,IAAI,CAAC;uBAqDP,UAAU,CAAC,OAAO,YAAY,CAAC;0BAxEtB,cAAc;8BADL,aAAa;yCAGP,aAAa;yBAHnB,aAAa;sCAFV,mCAAmC;yCAChC,2CAA2C"}
1
+ {"version":3,"file":"zoe-tools.d.ts","sourceRoot":"","sources":["zoe-tools.js"],"names":[],"mappings":"AAkCO,mCAHI,IAAI,qBACJ;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE;;EA+C1C;4CAjEY;IACZ,gBAAoB,EAAE,gBAAgB,CAAC;IACvC,iBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,CAAC,CAAC,CAAC;CAC7D;4BAMS,CACZ,OAAW,EAAE,OAAO,EACpB,YAAgB,EAAE,mBAAmB,EACrC,IAAQ,EAAE,mBAAmB,KACtB,OAAO,CAAC,IAAI,CAAC;uBAqDP,UAAU,CAAC,OAAO,YAAY,CAAC;0BAxEtB,cAAc;8BADL,aAAa;yCAGP,aAAa;yBAHnB,aAAa;sCAFV,mCAAmC;yCAChC,2CAA2C"}
@@ -1,5 +1,6 @@
1
1
  import { Fail } from '@endo/errors';
2
2
  import { atomicTransfer } from '@agoric/zoe/src/contractSupport/index.js';
3
+ import { E } from '@endo/far';
3
4
 
4
5
  /**
5
6
  * @import {InvitationMakers} from '@agoric/smart-wallet/src/types.js';
@@ -64,7 +65,7 @@ export const makeZoeTools = (zone, { zcf, vowTools }) => {
64
65
  // Now all the `give` are accessible, so we can move them to the localAccount`
65
66
 
66
67
  const promises = Object.entries(give).map(async ([kw, _amount]) => {
67
- const pmt = await userSeat.getPayout(kw);
68
+ const pmt = await E(userSeat).getPayout(kw);
68
69
  // TODO arrange recovery on upgrade of pmt?
69
70
  return localAccount.deposit(pmt);
70
71
  });