@@ -6,6 +6,7 @@ import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
6
6
import { Fail } from '@endo/errors' ;
7
7
import { E } from '@endo/far' ;
8
8
import { M } from '@endo/patterns' ;
9
+ import * as flows from './orca.flows.js' ;
9
10
10
11
import '@agoric/zoe/src/zoeService/types-ambient.js' ;
11
12
@@ -21,7 +22,6 @@ import '@agoric/zoe/src/zoeService/types-ambient.js';
21
22
*/
22
23
23
24
const trace = makeTracer ( 'OrchDev1' ) ;
24
- const { entries } = Object ;
25
25
26
26
const SingleAmountRecord = M . and (
27
27
M . recordOf ( M . string ( ) , AmountShape , {
@@ -30,39 +30,6 @@ const SingleAmountRecord = M.and(
30
30
M . not ( harden ( { } ) ) ,
31
31
) ;
32
32
33
- /**
34
- * Create an account on a Cosmos chain and return a continuing offer with
35
- * invitations makers for Delegate, WithdrawRewards, Transfer, etc.
36
- *
37
- * @param {Orchestrator } orch
38
- * @param {undefined } _ctx
39
- * @param {ZCFSeat } seat
40
- * @param {{ chainName: string } } offerArgs
41
- */
42
- const createAccountsFn = async ( orch , _ctx , seat , { chainName } ) => {
43
- const { give } = seat . getProposal ( ) ;
44
- trace ( 'version 0.1.36' ) ;
45
- trace ( 'give' ) ;
46
- trace ( give ) ;
47
- trace ( 'inside createAccounts' ) ;
48
- trace ( 'orch' ) ;
49
- trace ( orch ) ;
50
- trace ( 'seat' ) ;
51
- trace ( seat ) ;
52
- trace ( chainName ) ;
53
- seat . exit ( ) ;
54
- const chain = await orch . getChain ( chainName ) ;
55
- trace ( 'chain object' ) ;
56
- trace ( chain ) ;
57
- const info = await chain . getChainInfo ( ) ;
58
- trace ( 'chain info' , info ) ;
59
- const chainAccount = await chain . makeAccount ( ) ;
60
- console . log ( 'chainAccount' ) ;
61
- console . log ( chainAccount ) ;
62
-
63
- return chainAccount . asContinuingOffer ( ) ;
64
- } ;
65
-
66
33
/**
67
34
* @typedef {(
68
35
* srcSeat: ZCFSeat,
@@ -75,82 +42,6 @@ const createAccountsFn = async (orch, _ctx, seat, { chainName }) => {
75
42
* ) => Promise<void>} Transfer
76
43
*/
77
44
78
- /**
79
- * Create an account on a Cosmos chain and return a continuing offer with
80
- * invitations makers for Delegate, WithdrawRewards, Transfer, etc.
81
- *
82
- * @param {Orchestrator } orch
83
- * @param {object } ctx
84
- * @param {Transfer } ctx.transfer
85
- * @param {StorageNode['setValue'] } ctx.setValue
86
- * @param {ZCFSeat } seat
87
- * @param {{ chainName: string } } offerArgs
88
- */
89
- const createAndFundFn = async (
90
- orch ,
91
- {
92
- transfer,
93
- // write,
94
- // makeChildNode,
95
- setValue,
96
- } ,
97
- seat ,
98
- { chainName } ,
99
- ) => {
100
- const { give } = seat . getProposal ( ) ;
101
- const [ [ _kw , amt ] ] = entries ( give ) ;
102
- trace ( 'orch' , orch ) ;
103
- trace ( '_kw' , _kw ) ;
104
- trace ( 'amt' , amt ) ;
105
- trace ( 'give:' , give ) ;
106
- // trace("write:", write);
107
- // trace("makeChildNode:", makeChildNode);
108
- trace ( 'setValue:' , setValue ) ;
109
-
110
- const [ agoric , chain ] = await Promise . all ( [
111
- orch . getChain ( 'agoric' ) ,
112
- orch . getChain ( chainName ) ,
113
- ] ) ;
114
-
115
- const info = await chain . getChainInfo ( ) ;
116
- trace ( 'chain info' , info ) ;
117
-
118
- const assets = await agoric . getVBankAssetInfo ( ) ;
119
- trace ( 'fetched assets:' , assets ) ;
120
-
121
- const localAccount = await agoric . makeAccount ( ) ;
122
- trace ( 'localAccount' , localAccount ) ;
123
-
124
- const remoteAccount = await chain . makeAccount ( ) ;
125
- trace ( 'remoteAccount' , remoteAccount ) ;
126
- const [ localAddress , remoteAddress ] = await Promise . all ( [
127
- localAccount . getAddress ( ) ,
128
- remoteAccount . getAddress ( ) ,
129
- ] ) ;
130
-
131
- // vstorage tests
132
- trace ( 'writing' ) ;
133
- // setValue(`status x`)
134
- // const node1 = await makeChildNode(`orca-createAndFund-${localAddress.value}-${localAddress.value}`);
135
-
136
- trace ( 'localAddress' , localAddress ) ;
137
- trace ( 'remoteAddress' , remoteAddress ) ;
138
- trace ( 'fund new orch account' ) ;
139
- trace ( 'seat' , seat ) ;
140
- trace ( 'transfer' , transfer ) ;
141
- await transfer (
142
- seat ,
143
- localAccount ,
144
- remoteAccount ,
145
- give ,
146
- amt ,
147
- localAddress ,
148
- remoteAddress ,
149
- ) ;
150
- seat . exit ( ) ;
151
- return remoteAccount . asContinuingOffer ( ) ;
152
- } ;
153
-
154
45
/**
155
46
* @param {ZCF } zcf
156
47
* @param {OrchestrationPowers & {
@@ -163,7 +54,7 @@ const contract = async (
163
54
zcf ,
164
55
privateArgs ,
165
56
zone ,
166
- { orchestrate , vowTools, zoeTools } ,
57
+ { orchestrateAll , vowTools, zoeTools } ,
167
58
) => {
168
59
trace ( 'inside start function: v1.1.95' ) ;
169
60
trace ( 'privateArgs' , privateArgs ) ;
@@ -263,24 +154,15 @@ const contract = async (
263
154
const wrap = wrapper ( ) ;
264
155
trace ( 'wrapper.transfer' , wrapper ) ;
265
156
266
- /** @type {OfferHandler } */
267
- // @ts -expect-error ZCFSeat not Passable
268
- const makeAccount = orchestrate ( 'makeAccount' , undefined , createAccountsFn ) ;
269
-
270
- /** @type {OfferHandler } */
271
- const makeCreateAndFund = orchestrate (
272
- 'makeCreateAndFund' ,
273
- {
274
- localTransfer : zoeTools . localTransfer ,
275
- transfer : wrap . transfer ,
276
- // write: E(storageNode).write),
277
- // makeChildNode: E(storageNode).makeChildNode,
278
- // setValue: E(storageNode).setValue,
279
- setValue : privateArgs . storageNode . setValue ,
280
- } ,
281
- // @ts -expect-error ZCFSeat not Passable
282
- createAndFundFn ,
283
- ) ;
157
+ // @ts -expect-error XXX ZCFSeat not Passable
158
+ const { makeAccount, makeCreateAndFund } = orchestrateAll ( flows , {
159
+ localTransfer : zoeTools . localTransfer ,
160
+ transfer : wrap . transfer ,
161
+ // write: E(storageNode).write),
162
+ // makeChildNode: E(storageNode).makeChildNode,
163
+ // setValue: E(storageNode).setValue,
164
+ setValue : privateArgs . storageNode . setValue ,
165
+ } ) ;
284
166
285
167
const publicFacet = zone . exo (
286
168
'Orca Public Facet' ,
0 commit comments