@agoric/orchestration 0.1.1-dev-be74a2b.0 → 0.1.1-dev-1578064.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-
|
|
3
|
+
"version": "0.1.1-dev-1578064.0+1578064",
|
|
4
4
|
"description": "Chain abstraction for Agoric's orchestration clients",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"typeCoverage": {
|
|
101
101
|
"atLeast": 97.7
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "1578064491a1f19cbd45f8ec5b85476077ffaa01"
|
|
104
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmos-orchestration-account.d.ts","sourceRoot":"","sources":["cosmos-orchestration-account.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cosmos-orchestration-account.d.ts","sourceRoot":"","sources":["cosmos-orchestration-account.js"],"names":[],"mappings":"AAkLA,wCAAwC;AACxC;;;;;;;;;;;;;;;;;;;;;;;;;;GAUG;AAOH;;;;;;;;;;;GAoBE;AAYK,2DARI,IAAI,gGAEZ;IAAyB,QAAQ,EAAzB,QAAQ;IACgB,eAAe,EAAvC,eAAe;IACc,YAAY,EAAzC,OAAO,YAAY,CAAC;IACH,QAAQ,EAAzB,QAAQ;IACI,GAAG,EAAf,GAAG;CACb;kBAsGc,kBAAkB;kBAClB,eAAe;mBACf,gBAAgB;;aAEhB,UAAU;;;;;;;WAGV,OAAO,YAAY,CAAC;;;QAuC3B,wDAAwD;;;QAYxD;;;WAGG;6BAFQ,SAAS,GACP,IAAI;;;QASjB;;WAEG;8BADQ,SAAS,aAAa,CAAC,EAAE;;;QASpC;;;WAGG;8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b,aAAa;uCAAb,aAAa;2CAAb,aAAa;4CAAb,aAAa;gCACjQ,aAAa;kCADuO,aAAa;mCAAb,aAAa;iCAEzR,6CAA6C"}
|
|
@@ -97,6 +97,31 @@ const { Vow$ } = NetworkShape; // TODO #9611
|
|
|
97
97
|
* @property {CosmosChainAddress} chainAddress
|
|
98
98
|
*/
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Decodes the reply from the result of an InterChainQuery.
|
|
102
|
+
*
|
|
103
|
+
* @template R - response type returned by `codec.decode()`
|
|
104
|
+
* @param {{
|
|
105
|
+
* typeUrl: string;
|
|
106
|
+
* decode(input: Uint8Array, length?: number): R;
|
|
107
|
+
* }} codec
|
|
108
|
+
* @param {JsonSafe<ResponseQuery>} result
|
|
109
|
+
* @returns {R} returned by `codec.decode(...)`
|
|
110
|
+
*/
|
|
111
|
+
const decodeIcqResult = (codec, result) => {
|
|
112
|
+
try {
|
|
113
|
+
// We prefer the key over the value, for backwards compatibility.
|
|
114
|
+
const bytes = decodeBase64(result.key || result.value);
|
|
115
|
+
return codec.decode(bytes);
|
|
116
|
+
} catch (cause) {
|
|
117
|
+
throw makeError(
|
|
118
|
+
`Failed to parse ${codec.typeUrl} from result ${q(result)}`,
|
|
119
|
+
undefined,
|
|
120
|
+
{ cause },
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
100
125
|
/**
|
|
101
126
|
* @private
|
|
102
127
|
* @typedef {{
|
|
@@ -375,10 +400,7 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
375
400
|
* @param {JsonSafe<ResponseQuery>[]} results
|
|
376
401
|
*/
|
|
377
402
|
onFulfilled([result]) {
|
|
378
|
-
|
|
379
|
-
const { balance } = QueryBalanceResponse.decode(
|
|
380
|
-
decodeBase64(result.key),
|
|
381
|
-
);
|
|
403
|
+
const { balance } = decodeIcqResult(QueryBalanceResponse, result);
|
|
382
404
|
if (!balance) throw Fail`Result lacked balance key: ${result}`;
|
|
383
405
|
return harden(toDenomAmount(balance));
|
|
384
406
|
},
|
|
@@ -389,9 +411,9 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
389
411
|
* @returns {CosmosDelegationResponse}
|
|
390
412
|
*/
|
|
391
413
|
onFulfilled([result]) {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
414
|
+
const { delegationResponse } = decodeIcqResult(
|
|
415
|
+
QueryDelegationResponse,
|
|
416
|
+
result,
|
|
395
417
|
);
|
|
396
418
|
if (!delegationResponse)
|
|
397
419
|
throw Fail`Result lacked delegationResponse key: ${result}`;
|
|
@@ -407,9 +429,10 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
407
429
|
* @returns {CosmosDelegationResponse[]}
|
|
408
430
|
*/
|
|
409
431
|
onFulfilled([result]) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
432
|
+
const { delegationResponses } = decodeIcqResult(
|
|
433
|
+
QueryDelegatorDelegationsResponse,
|
|
434
|
+
result,
|
|
435
|
+
);
|
|
413
436
|
if (!delegationResponses)
|
|
414
437
|
throw Fail`Result lacked delegationResponses key: ${result}`;
|
|
415
438
|
const { chainAddress } = this.state;
|
|
@@ -425,9 +448,9 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
425
448
|
* @param {JsonSafe<ResponseQuery>[]} results
|
|
426
449
|
*/
|
|
427
450
|
onFulfilled([result]) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
451
|
+
const { unbond } = decodeIcqResult(
|
|
452
|
+
QueryUnbondingDelegationResponse,
|
|
453
|
+
result,
|
|
431
454
|
);
|
|
432
455
|
if (!unbond) throw Fail`Result lacked unbond key: ${result}`;
|
|
433
456
|
return harden(unbond);
|
|
@@ -438,11 +461,10 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
438
461
|
* @param {JsonSafe<ResponseQuery>[]} results
|
|
439
462
|
*/
|
|
440
463
|
onFulfilled([result]) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
);
|
|
464
|
+
const { unbondingResponses } = decodeIcqResult(
|
|
465
|
+
QueryDelegatorUnbondingDelegationsResponse,
|
|
466
|
+
result,
|
|
467
|
+
);
|
|
446
468
|
if (!unbondingResponses)
|
|
447
469
|
throw Fail`Result lacked unbondingResponses key: ${result}`;
|
|
448
470
|
return harden(unbondingResponses);
|
|
@@ -453,9 +475,9 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
453
475
|
* @param {JsonSafe<ResponseQuery>[]} results
|
|
454
476
|
*/
|
|
455
477
|
onFulfilled([result]) {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
478
|
+
const { redelegationResponses } = decodeIcqResult(
|
|
479
|
+
QueryRedelegationsResponse,
|
|
480
|
+
result,
|
|
459
481
|
);
|
|
460
482
|
if (!redelegationResponses)
|
|
461
483
|
throw Fail`Result lacked redelegationResponses key: ${result}`;
|
|
@@ -467,9 +489,9 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
467
489
|
* @param {JsonSafe<ResponseQuery>[]} results
|
|
468
490
|
*/
|
|
469
491
|
onFulfilled([result]) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
492
|
+
const { redelegationResponses } = decodeIcqResult(
|
|
493
|
+
QueryRedelegationsResponse,
|
|
494
|
+
result,
|
|
473
495
|
);
|
|
474
496
|
if (!redelegationResponses)
|
|
475
497
|
throw Fail`Result lacked redelegationResponses key: ${result}`;
|
|
@@ -481,9 +503,9 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
481
503
|
* @param {JsonSafe<ResponseQuery>[]} results
|
|
482
504
|
*/
|
|
483
505
|
onFulfilled([result]) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
506
|
+
const { rewards } = decodeIcqResult(
|
|
507
|
+
QueryDelegationRewardsResponse,
|
|
508
|
+
result,
|
|
487
509
|
);
|
|
488
510
|
if (!rewards) throw Fail`Result lacked rewards key: ${result}`;
|
|
489
511
|
return harden(rewards.map(toTruncatedDenomAmount));
|
|
@@ -495,9 +517,9 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
495
517
|
* @returns {CosmosRewardsResponse}
|
|
496
518
|
*/
|
|
497
519
|
onFulfilled([result]) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
520
|
+
const { rewards, total } = decodeIcqResult(
|
|
521
|
+
QueryDelegationTotalRewardsResponse,
|
|
522
|
+
result,
|
|
501
523
|
);
|
|
502
524
|
if (!rewards || !total)
|
|
503
525
|
throw Fail`Result lacked rewards or total key: ${result}`;
|
|
@@ -516,20 +538,10 @@ export const prepareCosmosOrchestrationAccountKit = (
|
|
|
516
538
|
* @param {JsonSafe<ResponseQuery>[]} results
|
|
517
539
|
*/
|
|
518
540
|
onFulfilled([result]) {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
decodeBase64(result.key),
|
|
524
|
-
);
|
|
525
|
-
} catch (cause) {
|
|
526
|
-
throw makeError(
|
|
527
|
-
`Error parsing QueryAllBalances result ${q(result)}`,
|
|
528
|
-
undefined,
|
|
529
|
-
{ cause },
|
|
530
|
-
);
|
|
531
|
-
}
|
|
532
|
-
const { balances } = response;
|
|
541
|
+
const { balances } = decodeIcqResult(
|
|
542
|
+
QueryAllBalancesResponse,
|
|
543
|
+
result,
|
|
544
|
+
);
|
|
533
545
|
if (!balances) throw Fail`Result lacked balances key: ${q(result)}`;
|
|
534
546
|
return harden(balances.map(coin => toDenomAmount(coin)));
|
|
535
547
|
},
|