@agoric/orchestration 0.1.1-dev-989aa19.0 → 0.1.1-dev-9274bc7.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.
Files changed (56) hide show
  1. package/package.json +18 -16
  2. package/src/chain-info.js +1 -1
  3. package/src/examples/stakeBld.contract.d.ts +10 -20
  4. package/src/examples/stakeBld.contract.d.ts.map +1 -1
  5. package/src/examples/stakeBld.contract.js +4 -2
  6. package/src/examples/stakeIca.contract.d.ts +9 -9
  7. package/src/examples/stakeIca.contract.d.ts.map +1 -1
  8. package/src/examples/stakeIca.contract.js +4 -1
  9. package/src/exos/chain-account-kit.d.ts +10 -1
  10. package/src/exos/chain-account-kit.d.ts.map +1 -1
  11. package/src/exos/chain-account-kit.js +35 -13
  12. package/src/exos/chain-hub.d.ts +2392 -0
  13. package/src/{utils/chainHub.d.ts.map → exos/chain-hub.d.ts.map} +1 -1
  14. package/src/{utils/chainHub.js → exos/chain-hub.js} +69 -9
  15. package/src/exos/cosmos-orchestration-account.d.ts +50 -15
  16. package/src/exos/cosmos-orchestration-account.d.ts.map +1 -1
  17. package/src/exos/cosmos-orchestration-account.js +113 -57
  18. package/src/exos/icq-connection-kit.d.ts +10 -1
  19. package/src/exos/icq-connection-kit.d.ts.map +1 -1
  20. package/src/exos/icq-connection-kit.js +27 -11
  21. package/src/exos/local-chain-facade.d.ts +46 -9
  22. package/src/exos/local-chain-facade.d.ts.map +1 -1
  23. package/src/exos/local-chain-facade.js +1 -1
  24. package/src/exos/local-orchestration-account.d.ts +115 -2343
  25. package/src/exos/local-orchestration-account.d.ts.map +1 -1
  26. package/src/exos/local-orchestration-account.js +185 -56
  27. package/src/exos/orchestrator.d.ts +9 -2313
  28. package/src/exos/orchestrator.d.ts.map +1 -1
  29. package/src/exos/orchestrator.js +1 -1
  30. package/src/exos/remote-chain-facade.d.ts +6 -6
  31. package/src/facade.d.ts +48 -11
  32. package/src/facade.d.ts.map +1 -1
  33. package/src/facade.js +2 -2
  34. package/src/proposals/orchestration-proposal.d.ts +36 -6
  35. package/src/proposals/orchestration-proposal.js +1 -1
  36. package/src/proposals/start-stakeAtom.d.ts +9 -9
  37. package/src/proposals/start-stakeAtom.d.ts.map +1 -1
  38. package/src/proposals/start-stakeAtom.js +5 -6
  39. package/src/proposals/start-stakeBld.d.ts +10 -20
  40. package/src/proposals/start-stakeBld.d.ts.map +1 -1
  41. package/src/proposals/start-stakeOsmo.d.ts +9 -9
  42. package/src/proposals/start-stakeOsmo.d.ts.map +1 -1
  43. package/src/proposals/start-stakeOsmo.js +5 -6
  44. package/src/service.d.ts +92 -9
  45. package/src/service.d.ts.map +1 -1
  46. package/src/service.js +143 -66
  47. package/src/utils/start-helper.d.ts +8 -2320
  48. package/src/utils/start-helper.d.ts.map +1 -1
  49. package/src/utils/start-helper.js +5 -2
  50. package/src/utils/time.d.ts +2 -0
  51. package/src/utils/time.d.ts.map +1 -1
  52. package/src/utils/time.js +2 -0
  53. package/src/vat-orchestration.d.ts +36 -6
  54. package/src/vat-orchestration.d.ts.map +1 -1
  55. package/src/vat-orchestration.js +3 -0
  56. package/src/utils/chainHub.d.ts +0 -2404
@@ -1 +1 @@
1
- {"version":3,"file":"local-orchestration-account.d.ts","sourceRoot":"","sources":["local-orchestration-account.js"],"names":[],"mappings":"AA4DO,kGA4EO,WAAE,GAAE,QAAS,OAAO,WAAW,EAAE,MAAM,CACvC,WAAH,CAAC,CAAC,0HAjFF,GAAG;;;;;;;;;8CAoBI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iEAsDX,sDAAsD;;;;;;;;;;;;;;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CAAmC,CAAC;2CACtD,UAAU,CAAC,gCAAgC,CAAC;0BArZnC,cAAc;iCADU,6CAA6C;kCAGhC,cAAc;4BADjD,kBAAkB;uCAHuF,uBAAuB;gCAKlH,aAAa;kCAL8E,uBAAuB;qCAI7F,cAAc;+BAJwD,uBAAuB;2CAAvB,uBAAuB;iCAAvB,uBAAuB;+BAAvB,uBAAuB"}
@@ -7,18 +7,25 @@ import { V } from '@agoric/vow/vat.js';
7
7
  import { TopicsRecordShape } from '@agoric/zoe/src/contractSupport/index.js';
8
8
  import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
9
9
  import { E } from '@endo/far';
10
+ import {
11
+ ChainAddressShape,
12
+ ChainAmountShape,
13
+ IBCTransferOptionsShape,
14
+ } from '../typeGuards.js';
10
15
  import { maxClockSkew } from '../utils/cosmos.js';
11
16
  import { orchestrationAccountMethods } from '../utils/orchestrationAccount.js';
12
17
  import { dateInSeconds, makeTimestampHelper } from '../utils/time.js';
13
18
 
14
19
  /**
15
20
  * @import {LocalChainAccount} from '@agoric/vats/src/localchain.js';
16
- * @import {AmountArg, ChainAddress, DenomAmount, IBCMsgTransferOptions, OrchestrationAccount, OrchestrationAccountI} from '@agoric/orchestration';
21
+ * @import {AmountArg, ChainAddress, DenomAmount, IBCMsgTransferOptions, OrchestrationAccount, ChainInfo, IBCConnectionInfo} from '@agoric/orchestration';
17
22
  * @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'.
18
23
  * @import {Zone} from '@agoric/zone';
19
24
  * @import {Remote} from '@agoric/internal';
20
- * @import {TimerService, TimerBrand} from '@agoric/time';
21
- * @import {ChainHub} from '../utils/chainHub.js';
25
+ * @import {TimerService, TimerBrand, TimestampRecord} from '@agoric/time';
26
+ * @import {PromiseVow, VowTools} from '@agoric/vow';
27
+ * @import {TypedJson} from '@agoric/cosmic-proto';
28
+ * @import {ChainHub} from './chain-hub.js';
22
29
  */
23
30
 
24
31
  const trace = makeTracer('LOA');
@@ -56,6 +63,7 @@ const PUBLIC_TOPICS = {
56
63
  * @param {MakeRecorderKit} makeRecorderKit
57
64
  * @param {ZCF} zcf
58
65
  * @param {Remote<TimerService>} timerService
66
+ * @param {VowTools} vowTools
59
67
  * @param {ChainHub} chainHub
60
68
  */
61
69
  export const prepareLocalOrchestrationAccountKit = (
@@ -63,6 +71,7 @@ export const prepareLocalOrchestrationAccountKit = (
63
71
  makeRecorderKit,
64
72
  zcf,
65
73
  timerService,
74
+ { watch, when, allVows },
66
75
  chainHub,
67
76
  ) => {
68
77
  const timestampHelper = makeTimestampHelper(timerService);
@@ -72,6 +81,40 @@ export const prepareLocalOrchestrationAccountKit = (
72
81
  'Local Orchestration Account Kit',
73
82
  {
74
83
  holder: HolderI,
84
+ undelegateWatcher: M.interface('undelegateWatcher', {
85
+ onFulfilled: M.call(M.arrayOf(M.record())) // XXX consider specifying `completionTime`
86
+ .optional(M.arrayOf(M.undefined())) // empty context
87
+ .returns(M.promise()),
88
+ }),
89
+ getChainInfoWatcher: M.interface('getChainInfoWatcher', {
90
+ onFulfilled: M.call(M.record()) // agoric chain info
91
+ .optional({ destination: ChainAddressShape }) // empty context
92
+ .returns(M.promise()), // transfer channel
93
+ }),
94
+ getTimeoutTimestampWatcher: M.interface('getTimeoutTimestampWatcher', {
95
+ onFulfilled: M.call(M.bigint())
96
+ .optional(IBCTransferOptionsShape)
97
+ .returns(M.bigint()),
98
+ }),
99
+ transferWatcher: M.interface('transferWatcher', {
100
+ onFulfilled: M.call(M.any())
101
+ .optional({
102
+ destination: ChainAddressShape,
103
+ opts: M.or(M.undefined(), IBCTransferOptionsShape),
104
+ amount: ChainAmountShape,
105
+ })
106
+ .returns(M.promise()),
107
+ }),
108
+ extractFirstResultWatcher: M.interface('extractFirstResultWatcher', {
109
+ onFulfilled: M.call(M.arrayOf(M.record()))
110
+ .optional(M.arrayOf(M.undefined()))
111
+ .returns(M.record()),
112
+ }),
113
+ returnVoidWatcher: M.interface('returnVoidWatcher', {
114
+ onFulfilled: M.call(M.arrayOf(M.record()))
115
+ .optional(M.arrayOf(M.undefined()))
116
+ .returns(M.undefined()),
117
+ }),
75
118
  invitationMakers: M.interface('invitationMakers', {
76
119
  Delegate: M.callWhen(M.string(), AmountShape).returns(InvitationShape),
77
120
  Undelegate: M.callWhen(M.string(), AmountShape).returns(
@@ -127,6 +170,110 @@ export const prepareLocalOrchestrationAccountKit = (
127
170
  throw Error('not yet implemented');
128
171
  },
129
172
  },
173
+ undelegateWatcher: {
174
+ /**
175
+ * @param {[
176
+ * TypedJson<'/cosmos.staking.v1beta1.MsgUndelegateResponse'>,
177
+ * ]} response
178
+ */
179
+ onFulfilled(response) {
180
+ const { completionTime } = response[0];
181
+ return E(timerService).wakeAt(
182
+ // TODO clean up date handling once we have real data
183
+ dateInSeconds(new Date(completionTime)) + maxClockSkew,
184
+ );
185
+ },
186
+ },
187
+ getChainInfoWatcher: {
188
+ /**
189
+ * @param {ChainInfo} agoricChainInfo
190
+ * @param {{ destination: ChainAddress }} ctx
191
+ */
192
+ onFulfilled(agoricChainInfo, { destination }) {
193
+ return chainHub.getConnectionInfo(
194
+ agoricChainInfo.chainId,
195
+ destination.chainId,
196
+ );
197
+ },
198
+ },
199
+ getTimeoutTimestampWatcher: {
200
+ /**
201
+ * @param {bigint} timeoutTimestamp
202
+ * @param {{ opts: IBCMsgTransferOptions }} ctx
203
+ */
204
+ onFulfilled(timeoutTimestamp, { opts }) {
205
+ // FIXME: do not call `getTimeoutTimestampNS` if `opts.timeoutTimestamp` or `opts.timeoutHeight` is provided
206
+ return (
207
+ opts?.timeoutTimestamp ??
208
+ (opts?.timeoutHeight ? 0n : timeoutTimestamp)
209
+ );
210
+ },
211
+ },
212
+ transferWatcher: {
213
+ /**
214
+ * @param {[
215
+ * { transferChannel: IBCConnectionInfo['transferChannel'] },
216
+ * bigint,
217
+ * ]} params
218
+ * @param {{
219
+ * destination: ChainAddress;
220
+ * opts: IBCMsgTransferOptions;
221
+ * amount: DenomAmount;
222
+ * }} ctx
223
+ */
224
+ onFulfilled(
225
+ [{ transferChannel }, timeoutTimestamp],
226
+ { opts, amount, destination },
227
+ ) {
228
+ return E(this.state.account).executeTx([
229
+ typedJson('/ibc.applications.transfer.v1.MsgTransfer', {
230
+ sourcePort: transferChannel.portId,
231
+ sourceChannel: transferChannel.channelId,
232
+ token: {
233
+ amount: String(amount.value),
234
+ denom: amount.denom,
235
+ },
236
+ sender: this.state.address.address,
237
+ receiver: destination.address,
238
+ timeoutHeight: opts?.timeoutHeight ?? {
239
+ revisionHeight: 0n,
240
+ revisionNumber: 0n,
241
+ },
242
+ timeoutTimestamp,
243
+ memo: opts?.memo ?? '',
244
+ }),
245
+ ]);
246
+ },
247
+ },
248
+ /**
249
+ * takes an array of results (from `executeEncodedTx`) and returns the
250
+ * first result
251
+ */
252
+ extractFirstResultWatcher: {
253
+ /**
254
+ * @param {Record<unknown, unknown>[]} results
255
+ */
256
+ onFulfilled(results) {
257
+ results.length === 1 ||
258
+ Fail`expected exactly one result; got ${results}`;
259
+ return results[0];
260
+ },
261
+ },
262
+ /**
263
+ * takes an array of results (from `executeEncodedTx`) and returns void
264
+ * since we are not interested in the result
265
+ */
266
+ returnVoidWatcher: {
267
+ /**
268
+ * @param {Record<unknown, unknown>[]} results
269
+ */
270
+ onFulfilled(results) {
271
+ results.length === 1 ||
272
+ Fail`expected exactly one result; got ${results}`;
273
+ trace('Result', results[0]);
274
+ return undefined;
275
+ },
276
+ },
130
277
  holder: {
131
278
  /** @type {OrchestrationAccount<any>['getBalance']} */
132
279
  async getBalance(denomArg) {
@@ -167,23 +314,21 @@ export const prepareLocalOrchestrationAccountKit = (
167
314
  denom: 'ubld',
168
315
  };
169
316
  const { account: lca } = this.state;
170
- trace('lca', lca);
171
- const delegatorAddress = await V(lca).getAddress();
172
- trace('delegatorAddress', delegatorAddress);
173
- const [result] = await V(lca).executeTx([
317
+
318
+ const results = E(lca).executeTx([
174
319
  typedJson('/cosmos.staking.v1beta1.MsgDelegate', {
175
320
  amount,
176
321
  validatorAddress,
177
- delegatorAddress,
322
+ delegatorAddress: this.state.address.address,
178
323
  }),
179
324
  ]);
180
- trace('got result', result);
181
- return result;
325
+
326
+ return when(watch(results, this.facets.extractFirstResultWatcher));
182
327
  },
183
328
  /**
184
329
  * @param {string} validatorAddress
185
330
  * @param {Amount<'nat'>} ertpAmount
186
- * @returns {Promise<void>}
331
+ * @returns {PromiseVow<void | TimestampRecord>}
187
332
  */
188
333
  async undelegate(validatorAddress, ertpAmount) {
189
334
  // TODO #9211 lookup denom from brand
@@ -192,23 +337,15 @@ export const prepareLocalOrchestrationAccountKit = (
192
337
  denom: 'ubld',
193
338
  };
194
339
  const { account: lca } = this.state;
195
- trace('lca', lca);
196
- const delegatorAddress = await V(lca).getAddress();
197
- trace('delegatorAddress', delegatorAddress);
198
- const [response] = await V(lca).executeTx([
340
+ const results = E(lca).executeTx([
199
341
  typedJson('/cosmos.staking.v1beta1.MsgUndelegate', {
200
342
  amount,
201
343
  validatorAddress,
202
- delegatorAddress,
344
+ delegatorAddress: this.state.address.address,
203
345
  }),
204
346
  ]);
205
- trace('undelegate response', response);
206
- const { completionTime } = response;
207
-
208
- await E(timerService).wakeAt(
209
- // TODO clean up date handling once we have real data
210
- dateInSeconds(new Date(completionTime)) + maxClockSkew,
211
- );
347
+ // @ts-expect-error Type 'JsonSafe<MsgUndelegateResponse & { '@type': "/cosmos.staking.v1beta1.MsgUndelegateResponse"; }>' is not assignable to type 'MsgUndelegateResponse'.
348
+ return when(watch(results, this.facets.undelegateWatcher));
212
349
  },
213
350
  /**
214
351
  * Starting a transfer revokes the account holder. The associated
@@ -217,16 +354,21 @@ export const prepareLocalOrchestrationAccountKit = (
217
354
  */
218
355
  /** @type {OrchestrationAccount<any>['deposit']} */
219
356
  async deposit(payment) {
220
- await V(this.state.account).deposit(payment);
357
+ return when(
358
+ watch(
359
+ E(this.state.account)
360
+ .deposit(payment)
361
+ .then(() => {}),
362
+ ),
363
+ );
221
364
  },
222
365
  /** @type {LocalChainAccount['withdraw']} */
223
366
  async withdraw(amount) {
224
- return V(this.state.account).withdraw(amount);
367
+ return when(watch(E(this.state.account).withdraw(amount)));
225
368
  },
226
369
  /** @type {LocalChainAccount['executeTx']} */
227
370
  async executeTx(messages) {
228
- // @ts-expect-error subtype
229
- return V(this.state.account).executeTx(messages);
371
+ return when(watch(E(this.state.account).executeTx(messages)));
230
372
  },
231
373
  /** @returns {ChainAddress} */
232
374
  getAddress() {
@@ -250,40 +392,27 @@ export const prepareLocalOrchestrationAccountKit = (
250
392
  // TODO #9211 lookup denom from brand
251
393
  if ('brand' in amount) throw Fail`ERTP Amounts not yet supported`;
252
394
 
253
- const agoricChainInfo = await chainHub.getChainInfo('agoric');
254
- const { transferChannel } = await chainHub.getConnectionInfo(
255
- agoricChainInfo.chainId,
256
- destination.chainId,
395
+ const connectionInfoV = watch(
396
+ chainHub.getChainInfo('agoric'),
397
+ this.facets.getChainInfoWatcher,
398
+ { destination },
257
399
  );
258
400
 
259
- await null;
260
401
  // set a `timeoutTimestamp` if caller does not supply either `timeoutHeight` or `timeoutTimestamp`
261
402
  // TODO #9324 what's a reasonable default? currently 5 minutes
262
- const timeoutTimestamp =
263
- opts?.timeoutTimestamp ??
264
- (opts?.timeoutHeight
265
- ? 0n
266
- : await timestampHelper.getTimeoutTimestampNS());
403
+ // FIXME: do not call `getTimeoutTimestampNS` if `opts.timeoutTimestamp` or `opts.timeoutHeight` is provided
404
+ const timeoutTimestampV = watch(
405
+ timestampHelper.getTimeoutTimestampNS(),
406
+ this.facets.getTimeoutTimestampWatcher,
407
+ { opts },
408
+ );
267
409
 
268
- const [result] = await V(this.state.account).executeTx([
269
- typedJson('/ibc.applications.transfer.v1.MsgTransfer', {
270
- sourcePort: transferChannel.portId,
271
- sourceChannel: transferChannel.channelId,
272
- token: {
273
- amount: String(amount.value),
274
- denom: amount.denom,
275
- },
276
- sender: this.state.address.address,
277
- receiver: destination.address,
278
- timeoutHeight: opts?.timeoutHeight ?? {
279
- revisionHeight: 0n,
280
- revisionNumber: 0n,
281
- },
282
- timeoutTimestamp,
283
- memo: opts?.memo ?? '',
284
- }),
285
- ]);
286
- trace('MsgTransfer result', result);
410
+ const transferV = watch(
411
+ allVows([connectionInfoV, timeoutTimestampV]),
412
+ this.facets.transferWatcher,
413
+ { opts, amount, destination },
414
+ );
415
+ return when(watch(transferV, this.facets.returnVoidWatcher));
287
416
  },
288
417
  /** @type {OrchestrationAccount<any>['transferSteps']} */
289
418
  transferSteps(amount, msg) {