@agoric/orchestration 0.1.1-dev-989aa19.0 → 0.1.1-dev-f3f87b1.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 +18 -16
- package/src/examples/stakeBld.contract.d.ts +10 -20
- package/src/examples/stakeBld.contract.d.ts.map +1 -1
- package/src/examples/stakeBld.contract.js +3 -1
- package/src/examples/stakeIca.contract.d.ts +9 -9
- package/src/examples/stakeIca.contract.d.ts.map +1 -1
- package/src/examples/stakeIca.contract.js +4 -1
- package/src/exos/chain-account-kit.d.ts +10 -1
- package/src/exos/chain-account-kit.d.ts.map +1 -1
- package/src/exos/chain-account-kit.js +35 -13
- package/src/exos/cosmos-orchestration-account.d.ts +50 -15
- package/src/exos/cosmos-orchestration-account.d.ts.map +1 -1
- package/src/exos/cosmos-orchestration-account.js +113 -57
- package/src/exos/icq-connection-kit.d.ts +10 -1
- package/src/exos/icq-connection-kit.d.ts.map +1 -1
- package/src/exos/icq-connection-kit.js +27 -11
- package/src/exos/local-chain-facade.d.ts +46 -9
- package/src/exos/local-chain-facade.d.ts.map +1 -1
- package/src/exos/local-chain-facade.js +1 -1
- package/src/exos/local-orchestration-account.d.ts +114 -2342
- package/src/exos/local-orchestration-account.d.ts.map +1 -1
- package/src/exos/local-orchestration-account.js +184 -55
- package/src/exos/orchestrator.d.ts +6 -2310
- package/src/exos/orchestrator.d.ts.map +1 -1
- package/src/exos/remote-chain-facade.d.ts +6 -6
- package/src/facade.d.ts +47 -10
- package/src/facade.d.ts.map +1 -1
- package/src/facade.js +1 -1
- package/src/proposals/orchestration-proposal.d.ts +36 -6
- package/src/proposals/start-stakeAtom.d.ts +9 -9
- package/src/proposals/start-stakeAtom.d.ts.map +1 -1
- package/src/proposals/start-stakeAtom.js +5 -6
- package/src/proposals/start-stakeBld.d.ts +10 -20
- package/src/proposals/start-stakeBld.d.ts.map +1 -1
- package/src/proposals/start-stakeOsmo.d.ts +9 -9
- package/src/proposals/start-stakeOsmo.d.ts.map +1 -1
- package/src/proposals/start-stakeOsmo.js +5 -6
- package/src/service.d.ts +92 -9
- package/src/service.d.ts.map +1 -1
- package/src/service.js +143 -66
- package/src/utils/chainHub.d.ts +2278 -2279
- package/src/utils/chainHub.d.ts.map +1 -1
- package/src/utils/chainHub.js +37 -8
- package/src/utils/start-helper.d.ts +6 -2318
- package/src/utils/start-helper.d.ts.map +1 -1
- package/src/utils/start-helper.js +4 -1
- package/src/utils/time.d.ts +2 -0
- package/src/utils/time.d.ts.map +1 -1
- package/src/utils/time.js +2 -0
- package/src/vat-orchestration.d.ts +36 -6
- package/src/vat-orchestration.d.ts.map +1 -1
- package/src/vat-orchestration.js +3 -0
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
MsgBeginRedelegate,
|
|
13
13
|
MsgDelegate,
|
|
14
|
-
MsgDelegateResponse,
|
|
15
14
|
MsgUndelegate,
|
|
16
15
|
MsgUndelegateResponse,
|
|
17
16
|
} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js';
|
|
@@ -26,13 +25,10 @@ import {
|
|
|
26
25
|
AmountArgShape,
|
|
27
26
|
ChainAddressShape,
|
|
28
27
|
ChainAmountShape,
|
|
28
|
+
CoinShape,
|
|
29
29
|
DelegationShape,
|
|
30
30
|
} from '../typeGuards.js';
|
|
31
|
-
import {
|
|
32
|
-
encodeTxResponse,
|
|
33
|
-
maxClockSkew,
|
|
34
|
-
tryDecodeResponse,
|
|
35
|
-
} from '../utils/cosmos.js';
|
|
31
|
+
import { maxClockSkew, tryDecodeResponse } from '../utils/cosmos.js';
|
|
36
32
|
import { orchestrationAccountMethods } from '../utils/orchestrationAccount.js';
|
|
37
33
|
import { dateInSeconds } from '../utils/time.js';
|
|
38
34
|
|
|
@@ -43,7 +39,10 @@ import { dateInSeconds } from '../utils/time.js';
|
|
|
43
39
|
* @import {Delegation} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js';
|
|
44
40
|
* @import {Remote} from '@agoric/internal';
|
|
45
41
|
* @import {TimerService} from '@agoric/time';
|
|
42
|
+
* @import {VowTools} from '@agoric/vow';
|
|
46
43
|
* @import {Zone} from '@agoric/zone';
|
|
44
|
+
* @import {ResponseQuery} from '@agoric/cosmic-proto/tendermint/abci/types.js';
|
|
45
|
+
* @import {JsonSafe} from '@agoric/cosmic-proto';
|
|
47
46
|
*/
|
|
48
47
|
|
|
49
48
|
const trace = makeTracer('ComosOrchestrationAccountHolder');
|
|
@@ -94,28 +93,19 @@ const PUBLIC_TOPICS = {
|
|
|
94
93
|
account: ['Staking Account holder status', M.any()],
|
|
95
94
|
};
|
|
96
95
|
|
|
97
|
-
export const trivialDelegateResponse = encodeTxResponse(
|
|
98
|
-
{},
|
|
99
|
-
MsgDelegateResponse.toProtoMsg,
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
const expect = (actual, expected, message) => {
|
|
103
|
-
if (actual !== expected) {
|
|
104
|
-
console.log(message, { actual, expected });
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
96
|
/** @type {(c: { denom: string; amount: string }) => DenomAmount} */
|
|
109
97
|
const toDenomAmount = c => ({ denom: c.denom, value: BigInt(c.amount) });
|
|
110
98
|
|
|
111
99
|
/**
|
|
112
100
|
* @param {Zone} zone
|
|
113
101
|
* @param {MakeRecorderKit} makeRecorderKit
|
|
102
|
+
* @param {VowTools} vowTools
|
|
114
103
|
* @param {ZCF} zcf
|
|
115
104
|
*/
|
|
116
105
|
export const prepareCosmosOrchestrationAccountKit = (
|
|
117
106
|
zone,
|
|
118
107
|
makeRecorderKit,
|
|
108
|
+
{ when, watch },
|
|
119
109
|
zcf,
|
|
120
110
|
) => {
|
|
121
111
|
const makeCosmosOrchestrationAccountKit = zone.exoClassKit(
|
|
@@ -126,6 +116,26 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
126
116
|
getUpdater: M.call().returns(M.remotable()),
|
|
127
117
|
amountToCoin: M.call(AmountArgShape).returns(M.record()),
|
|
128
118
|
}),
|
|
119
|
+
returnVoidWatcher: M.interface('returnVoidWatcher', {
|
|
120
|
+
onFulfilled: M.call(M.or(M.string(), M.record()))
|
|
121
|
+
.optional(M.arrayOf(M.undefined()))
|
|
122
|
+
.returns(M.undefined()),
|
|
123
|
+
}),
|
|
124
|
+
balanceQueryWatcher: M.interface('balanceQueryWatcher', {
|
|
125
|
+
onFulfilled: M.call(M.arrayOf(M.record()))
|
|
126
|
+
.optional(M.arrayOf(M.undefined())) // empty context
|
|
127
|
+
.returns(M.or(M.record(), M.undefined())),
|
|
128
|
+
}),
|
|
129
|
+
undelegateWatcher: M.interface('undelegateWatcher', {
|
|
130
|
+
onFulfilled: M.call(M.string())
|
|
131
|
+
.optional(M.arrayOf(M.undefined())) // empty context
|
|
132
|
+
.returns(M.promise()),
|
|
133
|
+
}),
|
|
134
|
+
withdrawRewardWatcher: M.interface('withdrawRewardWatcher', {
|
|
135
|
+
onFulfilled: M.call(M.string())
|
|
136
|
+
.optional(M.arrayOf(M.undefined())) // empty context
|
|
137
|
+
.returns(M.arrayOf(CoinShape)),
|
|
138
|
+
}),
|
|
129
139
|
holder: IcaAccountHolderI,
|
|
130
140
|
invitationMakers: M.interface('invitationMakers', {
|
|
131
141
|
Delegate: M.callWhen(ChainAddressShape, AmountArgShape).returns(
|
|
@@ -195,6 +205,59 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
195
205
|
});
|
|
196
206
|
},
|
|
197
207
|
},
|
|
208
|
+
balanceQueryWatcher: {
|
|
209
|
+
/**
|
|
210
|
+
* @param {JsonSafe<ResponseQuery>[]} results
|
|
211
|
+
*/
|
|
212
|
+
onFulfilled([result]) {
|
|
213
|
+
if (!result?.key) throw Fail`Error parsing result ${result}`;
|
|
214
|
+
const { balance } = QueryBalanceResponse.decode(
|
|
215
|
+
decodeBase64(result.key),
|
|
216
|
+
);
|
|
217
|
+
if (!balance) throw Fail`Result lacked balance key: ${result}`;
|
|
218
|
+
return harden(toDenomAmount(balance));
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
undelegateWatcher: {
|
|
222
|
+
/**
|
|
223
|
+
* @param {string} result
|
|
224
|
+
*/
|
|
225
|
+
onFulfilled(result) {
|
|
226
|
+
const response = tryDecodeResponse(
|
|
227
|
+
result,
|
|
228
|
+
MsgUndelegateResponse.fromProtoMsg,
|
|
229
|
+
);
|
|
230
|
+
trace('undelegate response', response);
|
|
231
|
+
const { completionTime } = response;
|
|
232
|
+
completionTime || Fail`No completion time result ${result}`;
|
|
233
|
+
return E(this.state.timer).wakeAt(
|
|
234
|
+
dateInSeconds(completionTime) + maxClockSkew,
|
|
235
|
+
);
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
/**
|
|
239
|
+
* takes an array of results (from `executeEncodedTx`) and returns void
|
|
240
|
+
* since we are not interested in the result
|
|
241
|
+
*/
|
|
242
|
+
returnVoidWatcher: {
|
|
243
|
+
/** @param {string | Record<string, unknown>} result */
|
|
244
|
+
onFulfilled(result) {
|
|
245
|
+
trace('Result', result);
|
|
246
|
+
return undefined;
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
withdrawRewardWatcher: {
|
|
250
|
+
/** @param {string} result */
|
|
251
|
+
onFulfilled(result) {
|
|
252
|
+
const response = tryDecodeResponse(
|
|
253
|
+
result,
|
|
254
|
+
MsgWithdrawDelegatorRewardResponse.fromProtoMsg,
|
|
255
|
+
);
|
|
256
|
+
trace('withdrawReward response', response);
|
|
257
|
+
const { amount: coins } = response;
|
|
258
|
+
return harden(coins.map(toDenomAmount));
|
|
259
|
+
},
|
|
260
|
+
},
|
|
198
261
|
invitationMakers: {
|
|
199
262
|
/**
|
|
200
263
|
* @param {CosmosValidatorAddress} validator
|
|
@@ -292,7 +355,7 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
292
355
|
const { helper } = this.facets;
|
|
293
356
|
const { chainAddress } = this.state;
|
|
294
357
|
|
|
295
|
-
const
|
|
358
|
+
const results = E(helper.owned()).executeEncodedTx([
|
|
296
359
|
Any.toJSON(
|
|
297
360
|
MsgDelegate.toProtoMsg({
|
|
298
361
|
delegatorAddress: chainAddress.address,
|
|
@@ -301,8 +364,7 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
301
364
|
}),
|
|
302
365
|
),
|
|
303
366
|
]);
|
|
304
|
-
|
|
305
|
-
expect(result, trivialDelegateResponse, 'MsgDelegateResponse');
|
|
367
|
+
return when(watch(results, this.facets.returnVoidWatcher));
|
|
306
368
|
},
|
|
307
369
|
async deposit(payment) {
|
|
308
370
|
trace('deposit', payment);
|
|
@@ -325,8 +387,7 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
325
387
|
const { helper } = this.facets;
|
|
326
388
|
const { chainAddress } = this.state;
|
|
327
389
|
|
|
328
|
-
|
|
329
|
-
await E(helper.owned()).executeEncodedTx([
|
|
390
|
+
const results = E(helper.owned()).executeEncodedTx([
|
|
330
391
|
Any.toJSON(
|
|
331
392
|
MsgBeginRedelegate.toProtoMsg({
|
|
332
393
|
delegatorAddress: chainAddress.address,
|
|
@@ -336,8 +397,15 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
336
397
|
}),
|
|
337
398
|
),
|
|
338
399
|
]);
|
|
339
|
-
},
|
|
340
400
|
|
|
401
|
+
return when(
|
|
402
|
+
watch(
|
|
403
|
+
results,
|
|
404
|
+
// NOTE: response, including completionTime, is currently discarded.
|
|
405
|
+
this.facets.returnVoidWatcher,
|
|
406
|
+
),
|
|
407
|
+
);
|
|
408
|
+
},
|
|
341
409
|
/**
|
|
342
410
|
* @param {CosmosValidatorAddress} validator
|
|
343
411
|
* @returns {Promise<DenomAmount[]>}
|
|
@@ -351,14 +419,9 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
351
419
|
validatorAddress: validator.address,
|
|
352
420
|
});
|
|
353
421
|
const account = helper.owned();
|
|
354
|
-
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
MsgWithdrawDelegatorRewardResponse.fromProtoMsg,
|
|
358
|
-
);
|
|
359
|
-
trace('withdrawReward response', response);
|
|
360
|
-
const { amount: coins } = response;
|
|
361
|
-
return harden(coins.map(toDenomAmount));
|
|
422
|
+
|
|
423
|
+
const results = E(account).executeEncodedTx([Any.toJSON(msg)]);
|
|
424
|
+
return when(watch(results, this.facets.withdrawRewardWatcher));
|
|
362
425
|
},
|
|
363
426
|
/**
|
|
364
427
|
* @param {DenomArg} denom
|
|
@@ -372,7 +435,7 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
372
435
|
// TODO #9211 lookup denom from brand
|
|
373
436
|
assert.typeof(denom, 'string');
|
|
374
437
|
|
|
375
|
-
const
|
|
438
|
+
const results = E(icqConnection).query([
|
|
376
439
|
toRequestQueryJson(
|
|
377
440
|
QueryBalanceRequest.toProtoMsg({
|
|
378
441
|
address: chainAddress.address,
|
|
@@ -380,12 +443,7 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
380
443
|
}),
|
|
381
444
|
),
|
|
382
445
|
]);
|
|
383
|
-
|
|
384
|
-
const { balance } = QueryBalanceResponse.decode(
|
|
385
|
-
decodeBase64(result.key),
|
|
386
|
-
);
|
|
387
|
-
if (!balance) throw Fail`Result lacked balance key: ${result}`;
|
|
388
|
-
return harden(toDenomAmount(balance));
|
|
446
|
+
return when(watch(results, this.facets.balanceQueryWatcher));
|
|
389
447
|
},
|
|
390
448
|
|
|
391
449
|
send(toAccount, amount) {
|
|
@@ -411,28 +469,23 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
411
469
|
async undelegate(delegations) {
|
|
412
470
|
trace('undelegate', delegations);
|
|
413
471
|
const { helper } = this.facets;
|
|
414
|
-
const { chainAddress, bondDenom
|
|
415
|
-
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
472
|
+
const { chainAddress, bondDenom } = this.state;
|
|
473
|
+
|
|
474
|
+
const undelegateV = watch(
|
|
475
|
+
E(helper.owned()).executeEncodedTx(
|
|
476
|
+
delegations.map(d =>
|
|
477
|
+
Any.toJSON(
|
|
478
|
+
MsgUndelegate.toProtoMsg({
|
|
479
|
+
delegatorAddress: chainAddress.address,
|
|
480
|
+
validatorAddress: d.validatorAddress,
|
|
481
|
+
amount: { denom: bondDenom, amount: d.shares },
|
|
482
|
+
}),
|
|
483
|
+
),
|
|
424
484
|
),
|
|
425
485
|
),
|
|
486
|
+
this.facets.undelegateWatcher,
|
|
426
487
|
);
|
|
427
|
-
|
|
428
|
-
const response = tryDecodeResponse(
|
|
429
|
-
result,
|
|
430
|
-
MsgUndelegateResponse.fromProtoMsg,
|
|
431
|
-
);
|
|
432
|
-
trace('undelegate response', response);
|
|
433
|
-
const { completionTime } = response;
|
|
434
|
-
|
|
435
|
-
await E(timer).wakeAt(dateInSeconds(completionTime) + maxClockSkew);
|
|
488
|
+
return when(watch(undelegateV, this.facets.returnVoidWatcher));
|
|
436
489
|
},
|
|
437
490
|
},
|
|
438
491
|
},
|
|
@@ -450,6 +503,7 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
450
503
|
/**
|
|
451
504
|
* @param {Zone} zone
|
|
452
505
|
* @param {MakeRecorderKit} makeRecorderKit
|
|
506
|
+
* @param {VowTools} vowTools
|
|
453
507
|
* @param {ZCF} zcf
|
|
454
508
|
* @returns {(
|
|
455
509
|
* ...args: Parameters<
|
|
@@ -460,11 +514,13 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
460
514
|
export const prepareCosmosOrchestrationAccount = (
|
|
461
515
|
zone,
|
|
462
516
|
makeRecorderKit,
|
|
517
|
+
vowTools,
|
|
463
518
|
zcf,
|
|
464
519
|
) => {
|
|
465
520
|
const makeKit = prepareCosmosOrchestrationAccountKit(
|
|
466
521
|
zone,
|
|
467
522
|
makeRecorderKit,
|
|
523
|
+
vowTools,
|
|
468
524
|
zcf,
|
|
469
525
|
);
|
|
470
526
|
return (...args) => makeKit(...args).holder;
|
|
@@ -4,7 +4,12 @@ export const ICQConnectionI: import("@endo/patterns").InterfaceGuard<{
|
|
|
4
4
|
getRemoteAddress: import("@endo/patterns").MethodGuard;
|
|
5
5
|
query: import("@endo/patterns").MethodGuard;
|
|
6
6
|
}>;
|
|
7
|
-
export function prepareICQConnectionKit(zone: Zone
|
|
7
|
+
export function prepareICQConnectionKit(zone: Zone, { watch, when }: {
|
|
8
|
+
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>;
|
|
9
|
+
watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = never, C = any>(specimenP: import("@agoric/vow").ERef<T_1 | import("@agoric/vow").Vow<T_1>>, watcher?: import("@agoric/vow").Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: C | undefined) => import("@agoric/vow").Vow<Exclude<TResult1_1, void> | Exclude<TResult2_1, void> extends never ? TResult1_1 : Exclude<TResult1_1, void> | Exclude<TResult2_1, void>>;
|
|
10
|
+
makeVowKit: <T_2>() => import("@agoric/vow").VowKit<T_2>;
|
|
11
|
+
allVows: (vows: unknown[]) => import("@agoric/vow").Vow<any[]>;
|
|
12
|
+
}): (port: Port) => import("@endo/exo").GuardedKit<{
|
|
8
13
|
connection: {
|
|
9
14
|
getLocalAddress(): `/ibc-port/${string}`;
|
|
10
15
|
getRemoteAddress(): `/${string}ibc-port/${string}/ordered/${string}` | `/${string}ibc-port/${string}/unordered/${string}`;
|
|
@@ -15,6 +20,10 @@ export function prepareICQConnectionKit(zone: Zone): (port: Port) => import("@en
|
|
|
15
20
|
*/
|
|
16
21
|
query(msgs: JsonSafe<RequestQuery>[]): Promise<JsonSafe<ResponseQuery>[]>;
|
|
17
22
|
};
|
|
23
|
+
parseQueryPacketWatcher: {
|
|
24
|
+
/** @param {string} ack packet acknowledgement string */
|
|
25
|
+
onFulfilled(ack: string): JsonSafe<ResponseQuery>[];
|
|
26
|
+
};
|
|
18
27
|
connectionHandler: {
|
|
19
28
|
/**
|
|
20
29
|
* @param {Remote<Connection>} connection
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icq-connection-kit.d.ts","sourceRoot":"","sources":["icq-connection-kit.js"],"names":[],"mappings":"AAoBA,2DAGE;AAEF;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"icq-connection-kit.d.ts","sourceRoot":"","sources":["icq-connection-kit.js"],"names":[],"mappings":"AAoBA,2DAGE;AAEF;;;;GAIG;AA2BI;wFA7CqC,CAAC;;;oBAW7B,SAAS;;;;;QAoEjB;;;;WAIG;;;;QAeH,wDAAwD;yBAA5C,MAAM;;;QAMlB;;;;WAIG;;;;;GAgBR;;;;;;;+BAEW,UAAU,CAAC,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;4BACtD,gBAAgB,CAAC,YAAY,CAAC;0BAjIrB,mBAAmB;0BACP,iBAAiB;kCAGN,+CAA+C;8BADlE,sBAAsB;mCACH,+CAA+C;gCAH1D,iBAAiB;4BACjB,aAAa"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @file ICQConnection Exo */
|
|
2
2
|
import { NonNullish } from '@agoric/assert';
|
|
3
3
|
import { makeTracer } from '@agoric/internal';
|
|
4
|
-
import {
|
|
4
|
+
import { E } from '@endo/far';
|
|
5
5
|
import { M } from '@endo/patterns';
|
|
6
6
|
import { makeQueryPacket, parseQueryPacket } from '../utils/packet.js';
|
|
7
7
|
import { ConnectionHandlerI } from '../typeGuards.js';
|
|
@@ -9,7 +9,7 @@ import { ConnectionHandlerI } from '../typeGuards.js';
|
|
|
9
9
|
/**
|
|
10
10
|
* @import {Zone} from '@agoric/base-zone';
|
|
11
11
|
* @import {Connection, Port} from '@agoric/network';
|
|
12
|
-
* @import {Remote} from '@agoric/vow';
|
|
12
|
+
* @import {Remote, VowTools} from '@agoric/vow';
|
|
13
13
|
* @import {JsonSafe} from '@agoric/cosmic-proto';
|
|
14
14
|
* @import {RequestQuery, ResponseQuery} from '@agoric/cosmic-proto/tendermint/abci/types.js';
|
|
15
15
|
* @import {LocalIbcAddress, RemoteIbcAddress} from '@agoric/vats/tools/ibc-utils.js';
|
|
@@ -52,14 +52,21 @@ export const ICQConnectionI = M.interface('ICQConnection', {
|
|
|
52
52
|
* sending queries and handling connection events.
|
|
53
53
|
*
|
|
54
54
|
* @param {Zone} zone
|
|
55
|
+
* @param {VowTools} vowTools
|
|
55
56
|
*/
|
|
56
|
-
export const prepareICQConnectionKit = zone =>
|
|
57
|
+
export const prepareICQConnectionKit = (zone, { watch, when }) =>
|
|
57
58
|
zone.exoClassKit(
|
|
58
59
|
'ICQConnectionKit',
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
{
|
|
61
|
+
connection: ICQConnectionI,
|
|
62
|
+
connectionHandler: ConnectionHandlerI,
|
|
63
|
+
parseQueryPacketWatcher: M.interface('ParseQueryPacketWatcher', {
|
|
64
|
+
onFulfilled: M.call(M.string())
|
|
65
|
+
.optional(M.arrayOf(M.undefined())) // does not need watcherContext
|
|
66
|
+
.returns(M.arrayOf(M.record())),
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
/** @param {Port} port */
|
|
63
70
|
port =>
|
|
64
71
|
/** @type {ICQConnectionKitState} */ ({
|
|
65
72
|
port,
|
|
@@ -88,14 +95,23 @@ export const prepareICQConnectionKit = zone =>
|
|
|
88
95
|
*/
|
|
89
96
|
query(msgs) {
|
|
90
97
|
const { connection } = this.state;
|
|
98
|
+
// TODO #9281 do not throw synchronously when returning a promise; return a rejected Vow
|
|
99
|
+
/// see https://github.com/Agoric/agoric-sdk/pull/9454#discussion_r1626898694
|
|
91
100
|
if (!connection) throw Fail`connection not available`;
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
return when(
|
|
102
|
+
watch(
|
|
103
|
+
E(connection).send(makeQueryPacket(msgs)),
|
|
104
|
+
this.facets.parseQueryPacketWatcher,
|
|
105
|
+
),
|
|
96
106
|
);
|
|
97
107
|
},
|
|
98
108
|
},
|
|
109
|
+
parseQueryPacketWatcher: {
|
|
110
|
+
/** @param {string} ack packet acknowledgement string */
|
|
111
|
+
onFulfilled(ack) {
|
|
112
|
+
return parseQueryPacket(ack);
|
|
113
|
+
},
|
|
114
|
+
},
|
|
99
115
|
connectionHandler: {
|
|
100
116
|
/**
|
|
101
117
|
* @param {Remote<Connection>} connection
|
|
@@ -14,12 +14,50 @@ export function prepareLocalChainFacade(zone: Zone, { makeLocalOrchestrationAcco
|
|
|
14
14
|
storageNode: Remote<globalThis.StorageNode>;
|
|
15
15
|
}) => import("@endo/exo").GuardedKit<{
|
|
16
16
|
invitationMakers: {
|
|
17
|
-
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<
|
|
18
|
-
|
|
19
|
-
}>, undefined>>;
|
|
20
|
-
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<void, undefined>>;
|
|
17
|
+
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<Record<unknown, unknown>, undefined>>;
|
|
18
|
+
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<void | import("@agoric/time").TimestampRecord | import("@agoric/vow").Vow<void | import("@agoric/time").TimestampRecord>, undefined>>;
|
|
21
19
|
CloseAccount(): never;
|
|
22
20
|
};
|
|
21
|
+
undelegateWatcher: {
|
|
22
|
+
onFulfilled(response: [import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgUndelegateResponse & {
|
|
23
|
+
'@type': "/cosmos.staking.v1beta1.MsgUndelegateResponse";
|
|
24
|
+
}]): Promise<import("@agoric/time").TimestampRecord>;
|
|
25
|
+
};
|
|
26
|
+
getChainInfoWatcher: {
|
|
27
|
+
onFulfilled(agoricChainInfo: ChainInfo, { destination }: {
|
|
28
|
+
destination: import("../orchestration-api.js").ChainAddress;
|
|
29
|
+
}): Promise<IBCConnectionInfo>;
|
|
30
|
+
};
|
|
31
|
+
getTimeoutTimestampWatcher: {
|
|
32
|
+
onFulfilled(timeoutTimestamp: bigint, { opts }: {
|
|
33
|
+
opts: import("../cosmos-api.js").IBCMsgTransferOptions;
|
|
34
|
+
}): bigint;
|
|
35
|
+
};
|
|
36
|
+
transferWatcher: {
|
|
37
|
+
onFulfilled([{ transferChannel }, timeoutTimestamp]: [{
|
|
38
|
+
transferChannel: {
|
|
39
|
+
portId: string;
|
|
40
|
+
channelId: `channel-${number}`;
|
|
41
|
+
counterPartyPortId: string;
|
|
42
|
+
counterPartyChannelId: `channel-${number}`;
|
|
43
|
+
ordering: import("@agoric/cosmic-proto/ibc/core/channel/v1/channel.js").Order;
|
|
44
|
+
state: import("@agoric/cosmic-proto/ibc/core/channel/v1/channel.js").State;
|
|
45
|
+
version: string;
|
|
46
|
+
};
|
|
47
|
+
}, bigint], { opts, amount, destination }: {
|
|
48
|
+
destination: import("../orchestration-api.js").ChainAddress;
|
|
49
|
+
opts: import("../cosmos-api.js").IBCMsgTransferOptions;
|
|
50
|
+
amount: import("../orchestration-api.js").DenomAmount;
|
|
51
|
+
}): import("@agoric/vats/src/localchain.js").PromiseVowOfTupleMappedToGenerics<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/ibc/applications/transfer/v1/tx.js").MsgTransferResponse & {
|
|
52
|
+
'@type': "/ibc.applications.transfer.v1.MsgTransferResponse";
|
|
53
|
+
}>[]>;
|
|
54
|
+
};
|
|
55
|
+
extractFirstResultWatcher: {
|
|
56
|
+
onFulfilled(results: Record<unknown, unknown>[]): Record<unknown, unknown>;
|
|
57
|
+
};
|
|
58
|
+
returnVoidWatcher: {
|
|
59
|
+
onFulfilled(results: Record<unknown, unknown>[]): undefined;
|
|
60
|
+
};
|
|
23
61
|
holder: {
|
|
24
62
|
getBalance(denom: DenomArg): Promise<import("../orchestration-api.js").DenomAmount>;
|
|
25
63
|
getBalances(): never;
|
|
@@ -30,10 +68,8 @@ export function prepareLocalChainFacade(zone: Zone, { makeLocalOrchestrationAcco
|
|
|
30
68
|
storagePath: Promise<string>;
|
|
31
69
|
};
|
|
32
70
|
};
|
|
33
|
-
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<
|
|
34
|
-
|
|
35
|
-
}>>;
|
|
36
|
-
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<void>;
|
|
71
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Record<unknown, unknown>>;
|
|
72
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").PromiseVow<void | import("@agoric/time").TimestampRecord>;
|
|
37
73
|
deposit(payment: globalThis.Payment<"nat">): Promise<void>;
|
|
38
74
|
withdraw(amount: Amount<"nat">): import("@agoric/vow").PromiseVow<globalThis.Payment<"nat">>;
|
|
39
75
|
executeTx<MT extends {
|
|
@@ -100,6 +136,7 @@ export function prepareLocalChainFacade(zone: Zone, { makeLocalOrchestrationAcco
|
|
|
100
136
|
export type MakeLocalChainFacade = ReturnType<typeof prepareLocalChainFacade>;
|
|
101
137
|
import type { Zone } from '@agoric/base-zone';
|
|
102
138
|
import type { Remote } from '@agoric/internal';
|
|
103
|
-
import type {
|
|
139
|
+
import type { ChainInfo } from '../types.js';
|
|
104
140
|
import type { IBCConnectionInfo } from '../types.js';
|
|
141
|
+
import type { TimerService } from '@agoric/time';
|
|
105
142
|
//# sourceMappingURL=local-chain-facade.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-chain-facade.d.ts","sourceRoot":"","sources":["local-chain-facade.js"],"names":[],"mappings":"AAyBO;;;;
|
|
1
|
+
{"version":3,"file":"local-chain-facade.d.ts","sourceRoot":"","sources":["local-chain-facade.js"],"names":[],"mappings":"AAyBO;;;;8BA0C4mC,MAAM,KAAK,CAAC;6BAA6gB,QAAQ,KAAK,CAAC,mBAA6B,OAAO;6BAAwjB,OAAO,KAAK,CAAC;;;2BAA6rB,EAAE;;;;;;;2DAAiI,OAAO,KAAK,CAAC;6DAAid,OAAO,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAAgkG,wBAAwB,EAAE;;;iCAAsZ,wBAAwB,EAAE;;;8BAAzgJ,QAAS;;;;;;;;;2DAAywL,OAAO,KAAK,CAAC;6DAAksB,OAAO,KAAK,CAAC;;6BAAvyN,OAAO,KAAK,CAAC;;;2BAA6rB,EAAE;;;;kCAA46B,SAAU,OAAM,WAAY;;;;;;;;;;;;;;;;8BAAvxF,MAAM,KAAK,CAAC;6BAA6gB,QAAQ,KAAK,CAAC,mBAA6B,OAAO;6BAAwjB,OAAO,KAAK,CAAC;;;2BAA6rB,EAAE;;;;;;;oBAAqjG,CAAC;;;uBAA6lB,EAAE;;;;;;;;;;;;;;;;;;;;;IAtBjlN,0DAA0D;;GAmB7D;mCAEW,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BA5DjC,mBAAmB;4BAEjB,kBAAkB;+BAI2C,aAAa;uCAAb,aAAa;kCALpE,cAAc"}
|