@agoric/orchestration 0.2.0 → 0.2.1-upgrade-23-dev-bd79330.0.bd79330

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 (234) hide show
  1. package/index.js +0 -4
  2. package/package.json +27 -27
  3. package/src/axelar-types.d.ts +2 -0
  4. package/src/axelar-types.d.ts.map +1 -1
  5. package/src/axelar-types.js +2 -0
  6. package/src/cctp-chain-info.js +4 -1
  7. package/src/chain-info.d.ts +21 -6
  8. package/src/chain-info.d.ts.map +1 -1
  9. package/src/chain-info.js +9 -8
  10. package/src/cosmos-api.d.ts +102 -29
  11. package/src/cosmos-api.d.ts.map +1 -1
  12. package/src/cosmos-api.js +585 -0
  13. package/src/{ethereum-api.ts → ethereum-api.js} +1 -1
  14. package/src/examples/auto-stake-it-tap-kit.d.ts +4 -3
  15. package/src/examples/auto-stake-it-tap-kit.d.ts.map +1 -1
  16. package/src/examples/auto-stake-it-tap-kit.js +3 -4
  17. package/src/examples/auto-stake-it.contract.d.ts +6 -4
  18. package/src/examples/auto-stake-it.contract.d.ts.map +1 -1
  19. package/src/examples/auto-stake-it.contract.js +3 -1
  20. package/src/examples/auto-stake-it.flows.d.ts +2 -1
  21. package/src/examples/auto-stake-it.flows.d.ts.map +1 -1
  22. package/src/examples/auto-stake-it.flows.js +1 -0
  23. package/src/examples/axelar-gmp-account-kit.d.ts +6 -4
  24. package/src/examples/axelar-gmp-account-kit.d.ts.map +1 -1
  25. package/src/examples/axelar-gmp-account-kit.js +4 -2
  26. package/src/examples/axelar-gmp.contract.d.ts +8 -8
  27. package/src/examples/axelar-gmp.contract.d.ts.map +1 -1
  28. package/src/examples/axelar-gmp.contract.js +2 -2
  29. package/src/examples/axelar-gmp.flows.d.ts +1 -1
  30. package/src/examples/basic-flows.contract.d.ts +7 -5
  31. package/src/examples/basic-flows.contract.d.ts.map +1 -1
  32. package/src/examples/basic-flows.contract.js +3 -1
  33. package/src/examples/basic-flows.flows.d.ts +2 -1
  34. package/src/examples/basic-flows.flows.d.ts.map +1 -1
  35. package/src/examples/basic-flows.flows.js +1 -0
  36. package/src/examples/send-anywhere.contract.d.ts +12 -6
  37. package/src/examples/send-anywhere.contract.d.ts.map +1 -1
  38. package/src/examples/send-anywhere.contract.js +4 -1
  39. package/src/examples/send-anywhere.flows.d.ts +3 -2
  40. package/src/examples/send-anywhere.flows.d.ts.map +1 -1
  41. package/src/examples/send-anywhere.flows.js +3 -6
  42. package/src/examples/stake-bld.contract.d.ts +206 -25
  43. package/src/examples/stake-bld.contract.d.ts.map +1 -1
  44. package/src/examples/stake-bld.contract.js +19 -4
  45. package/src/examples/stake-ica.contract.d.ts +434 -71
  46. package/src/examples/stake-ica.contract.d.ts.map +1 -1
  47. package/src/examples/stake-ica.contract.js +28 -6
  48. package/src/examples/staking-combinations.contract.d.ts +4 -2
  49. package/src/examples/staking-combinations.contract.d.ts.map +1 -1
  50. package/src/examples/staking-combinations.contract.js +5 -3
  51. package/src/examples/staking-combinations.flows.d.ts +3 -2
  52. package/src/examples/staking-combinations.flows.d.ts.map +1 -1
  53. package/src/examples/staking-combinations.flows.js +7 -6
  54. package/src/examples/swap-anything.contract.d.ts +14 -7
  55. package/src/examples/swap-anything.contract.d.ts.map +1 -1
  56. package/src/examples/swap-anything.contract.js +12 -8
  57. package/src/examples/swap.contract.d.ts +18 -6
  58. package/src/examples/swap.contract.d.ts.map +1 -1
  59. package/src/examples/swap.contract.js +9 -3
  60. package/src/examples/swap.flows.d.ts +2 -0
  61. package/src/examples/swap.flows.d.ts.map +1 -1
  62. package/src/examples/swap.flows.js +2 -0
  63. package/src/examples/unbond.contract.d.ts +7 -4
  64. package/src/examples/unbond.contract.d.ts.map +1 -1
  65. package/src/examples/unbond.contract.js +6 -3
  66. package/src/exos/chain-hub-admin.d.ts +1 -19
  67. package/src/exos/chain-hub-admin.d.ts.map +1 -1
  68. package/src/exos/chain-hub-admin.js +1 -1
  69. package/src/exos/chain-hub.d.ts +4 -2
  70. package/src/exos/chain-hub.d.ts.map +1 -1
  71. package/src/exos/chain-hub.js +2 -1
  72. package/src/exos/combine-invitation-makers.d.ts +2 -1
  73. package/src/exos/combine-invitation-makers.d.ts.map +1 -1
  74. package/src/exos/combine-invitation-makers.js +2 -1
  75. package/src/exos/cosmos-orchestration-account.d.ts +615 -98
  76. package/src/exos/cosmos-orchestration-account.d.ts.map +1 -1
  77. package/src/exos/cosmos-orchestration-account.js +695 -306
  78. package/src/exos/exo-interfaces.js +35 -0
  79. package/src/exos/ibc-packet.d.ts +11 -9
  80. package/src/exos/ibc-packet.d.ts.map +1 -1
  81. package/src/exos/ibc-packet.js +33 -8
  82. package/src/exos/ica-account-kit.d.ts +4 -9
  83. package/src/exos/ica-account-kit.d.ts.map +1 -1
  84. package/src/exos/ica-account-kit.js +10 -7
  85. package/src/exos/icq-connection-kit.d.ts +1 -1
  86. package/src/exos/local-chain-facade.d.ts +1542 -5
  87. package/src/exos/local-chain-facade.d.ts.map +1 -1
  88. package/src/exos/local-chain-facade.js +4 -2
  89. package/src/exos/local-orchestration-account.d.ts +201 -56
  90. package/src/exos/local-orchestration-account.d.ts.map +1 -1
  91. package/src/exos/local-orchestration-account.js +260 -51
  92. package/src/exos/orchestrator.d.ts +35813 -73
  93. package/src/exos/orchestrator.d.ts.map +1 -1
  94. package/src/exos/orchestrator.js +7 -10
  95. package/src/exos/packet-tools.d.ts +19 -8
  96. package/src/exos/packet-tools.d.ts.map +1 -1
  97. package/src/exos/packet-tools.js +92 -9
  98. package/src/exos/portfolio-holder-kit.d.ts +90 -2
  99. package/src/exos/portfolio-holder-kit.d.ts.map +1 -1
  100. package/src/exos/remote-chain-facade.d.ts +1499 -1
  101. package/src/exos/remote-chain-facade.d.ts.map +1 -1
  102. package/src/exos/remote-chain-facade.js +8 -3
  103. package/src/facade.d.ts +1 -0
  104. package/src/facade.d.ts.map +1 -1
  105. package/src/facade.js +4 -6
  106. package/src/fixtures/query-flows.contract.d.ts +8 -6
  107. package/src/fixtures/query-flows.contract.d.ts.map +1 -1
  108. package/src/fixtures/query-flows.contract.js +3 -1
  109. package/src/fixtures/query-flows.flows.d.ts +1 -0
  110. package/src/fixtures/query-flows.flows.d.ts.map +1 -1
  111. package/src/fixtures/query-flows.flows.js +1 -0
  112. package/src/orchestration-api.d.ts +46 -16
  113. package/src/orchestration-api.d.ts.map +1 -1
  114. package/src/orchestration-api.js +410 -0
  115. package/src/proposals/init-chain-info.js +10 -2
  116. package/src/proposals/orchestration-proposal.js +3 -0
  117. package/src/proposals/revise-chain-info.js +4 -1
  118. package/src/proposals/start-auto-stake-it.js +1 -0
  119. package/src/proposals/start-axelar-gmp.js +2 -2
  120. package/src/proposals/start-basic-flows.js +5 -0
  121. package/src/proposals/start-send-anywhere.js +4 -2
  122. package/src/proposals/start-stakeAtom.js +5 -4
  123. package/src/proposals/start-stakeBld.js +8 -6
  124. package/src/proposals/start-stakeOsmo.js +5 -4
  125. package/src/proposals/start-swap-anything.js +4 -2
  126. package/src/stubs/{viem-abi.d.ts → viem-typedData.js} +10 -4
  127. package/src/typeGuards.d.ts +38 -5
  128. package/src/typeGuards.d.ts.map +1 -1
  129. package/src/typeGuards.js +92 -22
  130. package/src/types.d.ts +1 -0
  131. package/src/types.d.ts.map +1 -1
  132. package/src/types.js +27 -0
  133. package/src/utils/abitype.d.ts +6 -0
  134. package/src/utils/abitype.d.ts.map +1 -0
  135. package/src/utils/abitype.js +13 -0
  136. package/src/utils/address.d.ts +3 -1
  137. package/src/utils/address.d.ts.map +1 -1
  138. package/src/utils/address.js +24 -2
  139. package/src/utils/agd-lib.d.ts +1 -51
  140. package/src/utils/agd-lib.d.ts.map +1 -1
  141. package/src/utils/agd-lib.js +1 -1
  142. package/src/utils/amounts.d.ts +1 -0
  143. package/src/utils/amounts.d.ts.map +1 -1
  144. package/src/utils/amounts.js +1 -0
  145. package/src/utils/asset.d.ts +1 -0
  146. package/src/utils/asset.d.ts.map +1 -1
  147. package/src/utils/asset.js +1 -0
  148. package/src/utils/chain-hub-helper.d.ts +1 -0
  149. package/src/utils/chain-hub-helper.d.ts.map +1 -1
  150. package/src/utils/chain-hub-helper.js +1 -0
  151. package/src/utils/codecs.d.ts +145 -0
  152. package/src/utils/codecs.d.ts.map +1 -0
  153. package/src/utils/codecs.js +206 -0
  154. package/src/utils/cosmos.d.ts +5 -4
  155. package/src/utils/cosmos.d.ts.map +1 -1
  156. package/src/utils/cosmos.js +29 -9
  157. package/src/utils/exo-helpers.d.ts +156 -0
  158. package/src/utils/exo-helpers.d.ts.map +1 -0
  159. package/src/utils/exo-helpers.js +241 -0
  160. package/src/utils/gmp.d.ts +2 -2
  161. package/src/utils/gmp.d.ts.map +1 -1
  162. package/src/utils/gmp.js +31 -15
  163. package/src/utils/orchestrationAccount.d.ts +79 -0
  164. package/src/utils/orchestrationAccount.d.ts.map +1 -1
  165. package/src/utils/orchestrationAccount.js +210 -6
  166. package/src/utils/packet.d.ts.map +1 -1
  167. package/src/utils/packet.js +5 -0
  168. package/src/utils/permit2/signatureTransfer.d.ts +221 -0
  169. package/src/utils/permit2/signatureTransfer.d.ts.map +1 -0
  170. package/src/utils/permit2/signatureTransfer.js +265 -0
  171. package/src/utils/permit2/signatureTransferHelpers.d.ts +334 -0
  172. package/src/utils/permit2/signatureTransferHelpers.d.ts.map +1 -0
  173. package/src/utils/permit2/signatureTransferHelpers.js +270 -0
  174. package/src/utils/permit2.d.ts +11 -0
  175. package/src/utils/permit2.d.ts.map +1 -0
  176. package/src/utils/permit2.js +11 -0
  177. package/src/utils/progress.d.ts +41 -0
  178. package/src/utils/progress.d.ts.map +1 -0
  179. package/src/utils/progress.js +180 -0
  180. package/src/utils/start-helper.d.ts +28 -10
  181. package/src/utils/start-helper.d.ts.map +1 -1
  182. package/src/utils/start-helper.js +30 -7
  183. package/src/utils/time.d.ts +2 -2
  184. package/src/utils/time.d.ts.map +1 -1
  185. package/src/utils/time.js +1 -1
  186. package/src/utils/viem-utils/hashTypedData.d.ts +21 -0
  187. package/src/utils/viem-utils/hashTypedData.d.ts.map +1 -0
  188. package/src/utils/viem-utils/hashTypedData.js +61 -0
  189. package/src/utils/viem-utils/types.d.ts +6 -0
  190. package/src/utils/viem-utils/types.d.ts.map +1 -0
  191. package/src/utils/viem-utils/types.js +18 -0
  192. package/src/utils/viem.d.ts +11 -0
  193. package/src/utils/viem.d.ts.map +1 -0
  194. package/src/utils/viem.js +11 -0
  195. package/src/utils/zcf-tools.d.ts +15 -1
  196. package/src/utils/zcf-tools.d.ts.map +1 -1
  197. package/src/utils/zcf-tools.js +19 -3
  198. package/src/utils/zoe-tools.d.ts +5 -2
  199. package/src/utils/zoe-tools.d.ts.map +1 -1
  200. package/src/utils/zoe-tools.js +8 -2
  201. package/src/vat-orchestration.d.ts +5 -3
  202. package/src/vat-orchestration.d.ts.map +1 -1
  203. package/src/vat-orchestration.js +4 -3
  204. package/src/vendor/viem/{_esm-YOAV66U4.js → _esm-OKAICHVC.js} +2 -2
  205. package/src/vendor/viem/{ccip-AAQDZF3N.js → ccip-34BSSMV5.js} +1 -2
  206. package/src/vendor/viem/{chunk-4EF4K2MH.js → chunk-GCI53Z2G.js} +35 -1
  207. package/src/vendor/viem/chunk-ZKSIP2AM.js +326 -0
  208. package/src/vendor/viem/viem-abi.js +2 -2
  209. package/src/vendor/viem/viem-typedData.d.ts +19 -0
  210. package/src/vendor/viem/viem-typedData.js +59 -0
  211. package/tools/contract-tests.d.ts +34 -19
  212. package/tools/contract-tests.d.ts.map +1 -1
  213. package/tools/contract-tests.ts +15 -3
  214. package/tools/ibc-mock-fixtures.d.ts +49 -0
  215. package/tools/ibc-mock-fixtures.d.ts.map +1 -0
  216. package/tools/ibc-mock-fixtures.ts +161 -0
  217. package/tools/ibc-mocks.d.ts +2 -3
  218. package/tools/ibc-mocks.d.ts.map +1 -1
  219. package/tools/ibc-mocks.ts +2 -1
  220. package/tools/make-test-address.d.ts +1 -1
  221. package/tools/make-test-address.d.ts.map +1 -1
  222. package/tools/make-test-address.js +1 -2
  223. package/tools/network-fakes.d.ts +142 -0
  224. package/tools/network-fakes.d.ts.map +1 -0
  225. package/tools/network-fakes.ts +388 -0
  226. package/tsup.config.ts +3 -1
  227. package/src/cosmos-api.ts +0 -469
  228. package/src/exos/exo-interfaces.ts +0 -35
  229. package/src/orchestration-api.ts +0 -365
  230. package/src/stubs/viem-abi.d.ts.map +0 -1
  231. package/src/types.ts +0 -26
  232. package/src/vendor/viem/chunk-XN4LUOIH.js +0 -253
  233. package/src/vendor/viem/secp256k1-WHBDSQB2.js +0 -1914
  234. /package/src/stubs/{viem-abi.ts → viem-abi.js} +0 -0
@@ -1,46 +1,5 @@
1
1
  /** @file Use-object for the owner of a staking account */
2
- import { toRequestQueryJson, CodecHelper } from '@agoric/cosmic-proto';
3
- import {
4
- MsgDepositForBurn as MsgDepositForBurnType,
5
- MsgDepositForBurnWithCaller as MsgDepositForBurnWithCallerType,
6
- } from '@agoric/cosmic-proto/circle/cctp/v1/tx.js';
7
- import {
8
- QueryAllBalancesRequest as QueryAllBalancesRequestType,
9
- QueryAllBalancesResponse as QueryAllBalancesResponseType,
10
- QueryBalanceRequest as QueryBalanceRequestType,
11
- QueryBalanceResponse as QueryBalanceResponseType,
12
- } from '@agoric/cosmic-proto/cosmos/bank/v1beta1/query.js';
13
- import { MsgSend as MsgSendType } from '@agoric/cosmic-proto/cosmos/bank/v1beta1/tx.js';
14
- import {
15
- QueryDelegationRewardsRequest as QueryDelegationRewardsRequestType,
16
- QueryDelegationRewardsResponse as QueryDelegationRewardsResponseType,
17
- QueryDelegationTotalRewardsRequest as QueryDelegationTotalRewardsRequestType,
18
- QueryDelegationTotalRewardsResponse as QueryDelegationTotalRewardsResponseType,
19
- } from '@agoric/cosmic-proto/cosmos/distribution/v1beta1/query.js';
20
- import {
21
- MsgWithdrawDelegatorReward as MsgWithdrawDelegatorRewardType,
22
- MsgWithdrawDelegatorRewardResponse as MsgWithdrawDelegatorRewardResponseType,
23
- } from '@agoric/cosmic-proto/cosmos/distribution/v1beta1/tx.js';
24
- import {
25
- QueryDelegationRequest as QueryDelegationRequestType,
26
- QueryDelegationResponse as QueryDelegationResponseType,
27
- QueryDelegatorDelegationsRequest as QueryDelegatorDelegationsRequestType,
28
- QueryDelegatorDelegationsResponse as QueryDelegatorDelegationsResponseType,
29
- QueryDelegatorUnbondingDelegationsRequest as QueryDelegatorUnbondingDelegationsRequestType,
30
- QueryDelegatorUnbondingDelegationsResponse as QueryDelegatorUnbondingDelegationsResponseType,
31
- QueryRedelegationsRequest as QueryRedelegationsRequestType,
32
- QueryRedelegationsResponse as QueryRedelegationsResponseType,
33
- QueryUnbondingDelegationRequest as QueryUnbondingDelegationRequestType,
34
- QueryUnbondingDelegationResponse as QueryUnbondingDelegationResponseType,
35
- } from '@agoric/cosmic-proto/cosmos/staking/v1beta1/query.js';
36
- import {
37
- MsgBeginRedelegate as MsgBeginRedelegateType,
38
- MsgDelegate as MsgDelegateType,
39
- MsgUndelegate as MsgUndelegateType,
40
- MsgUndelegateResponse as MsgUndelegateResponseType,
41
- } from '@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js';
42
- import { Any as AnyType } from '@agoric/cosmic-proto/google/protobuf/any.js';
43
- import { MsgTransfer as MsgTransferType } from '@agoric/cosmic-proto/ibc/applications/transfer/v1/tx.js';
2
+ import { toRequestQueryJson } from '@agoric/cosmic-proto';
44
3
  import { makeTracer } from '@agoric/internal';
45
4
  import { Shape as NetworkShape } from '@agoric/network';
46
5
  import { M } from '@agoric/vat-data';
@@ -48,14 +7,18 @@ import { VowShape } from '@agoric/vow';
48
7
  import { decodeBase64 } from '@endo/base64';
49
8
  import { Fail, makeError, q } from '@endo/errors';
50
9
  import { E } from '@endo/far';
10
+ import { decodeIbcEndpoint } from '@agoric/vats/tools/ibc-utils.js';
51
11
  import {
52
12
  AmountArgShape,
13
+ CoinShape,
14
+ CosmosActionOptionsShape,
53
15
  CosmosChainAddressShape,
16
+ CosmosQuerierOptionsShape,
54
17
  DelegationShape,
55
18
  DenomAmountShape,
56
19
  IBCTransferOptionsShape,
20
+ LegacyExecuteEncodedTxOptionsShape,
57
21
  Proto3Shape,
58
- ExecuteICATxOptsShape,
59
22
  } from '../typeGuards.js';
60
23
  import { coerceCoin, coerceDenom } from '../utils/amounts.js';
61
24
  import {
@@ -64,88 +27,100 @@ import {
64
27
  toCosmosValidatorAddress,
65
28
  toDenomAmount,
66
29
  toTruncatedDenomAmount,
67
- tryDecodeResponse,
30
+ tryDecodeResponses,
68
31
  } from '../utils/cosmos.js';
69
- import { orchestrationAccountMethods } from '../utils/orchestrationAccount.js';
32
+ import { makeVowExoHelpers } from '../utils/exo-helpers.js';
33
+ import {
34
+ orchestrationAccountMethods,
35
+ addTrafficEntries,
36
+ finishTrafficEntries,
37
+ trafficTransforms,
38
+ SliceDescriptorShape,
39
+ } from '../utils/orchestrationAccount.js';
70
40
  import { makeTimestampHelper } from '../utils/time.js';
71
41
  import { accountIdTo32Bytes, parseAccountId } from '../utils/address.js';
72
-
73
- const MsgDepositForBurn = CodecHelper(MsgDepositForBurnType);
74
- const MsgDepositForBurnWithCaller = CodecHelper(
75
- MsgDepositForBurnWithCallerType,
76
- );
77
- const QueryAllBalancesRequest = CodecHelper(QueryAllBalancesRequestType);
78
- const QueryAllBalancesResponse = CodecHelper(QueryAllBalancesResponseType);
79
- const QueryBalanceRequest = CodecHelper(QueryBalanceRequestType);
80
- const QueryBalanceResponse = CodecHelper(QueryBalanceResponseType);
81
- const MsgSend = CodecHelper(MsgSendType);
82
- const QueryDelegationRewardsRequest = CodecHelper(
83
- QueryDelegationRewardsRequestType,
84
- );
85
- const QueryDelegationRewardsResponse = CodecHelper(
86
- QueryDelegationRewardsResponseType,
87
- );
88
- const QueryDelegationTotalRewardsRequest = CodecHelper(
89
- QueryDelegationTotalRewardsRequestType,
90
- );
91
- const QueryDelegationTotalRewardsResponse = CodecHelper(
92
- QueryDelegationTotalRewardsResponseType,
93
- );
94
- const MsgWithdrawDelegatorReward = CodecHelper(MsgWithdrawDelegatorRewardType);
95
- const MsgWithdrawDelegatorRewardResponse = CodecHelper(
96
- MsgWithdrawDelegatorRewardResponseType,
97
- );
98
- const QueryDelegationRequest = CodecHelper(QueryDelegationRequestType);
99
- const QueryDelegationResponse = CodecHelper(QueryDelegationResponseType);
100
- const QueryDelegatorDelegationsRequest = CodecHelper(
101
- QueryDelegatorDelegationsRequestType,
102
- );
103
- const QueryDelegatorDelegationsResponse = CodecHelper(
104
- QueryDelegatorDelegationsResponseType,
105
- );
106
- const QueryDelegatorUnbondingDelegationsRequest = CodecHelper(
107
- QueryDelegatorUnbondingDelegationsRequestType,
108
- );
109
- const QueryDelegatorUnbondingDelegationsResponse = CodecHelper(
110
- QueryDelegatorUnbondingDelegationsResponseType,
111
- );
112
- const QueryRedelegationsRequest = CodecHelper(QueryRedelegationsRequestType);
113
- const QueryRedelegationsResponse = CodecHelper(QueryRedelegationsResponseType);
114
- const QueryUnbondingDelegationRequest = CodecHelper(
115
- QueryUnbondingDelegationRequestType,
116
- );
117
- const QueryUnbondingDelegationResponse = CodecHelper(
118
- QueryUnbondingDelegationResponseType,
119
- );
120
- const MsgBeginRedelegate = CodecHelper(MsgBeginRedelegateType);
121
- const MsgDelegate = CodecHelper(MsgDelegateType);
122
- const MsgUndelegate = CodecHelper(MsgUndelegateType);
123
- const MsgUndelegateResponse = CodecHelper(MsgUndelegateResponseType);
124
- const Any = CodecHelper(AnyType);
125
- const MsgTransfer = CodecHelper(MsgTransferType);
42
+ import {
43
+ Any,
44
+ MsgBeginRedelegate,
45
+ MsgDelegate,
46
+ MsgDepositForBurn,
47
+ MsgDepositForBurnWithCaller,
48
+ MsgSend,
49
+ MsgTransfer,
50
+ MsgUndelegate,
51
+ MsgWithdrawDelegatorReward,
52
+ QueryAllBalancesRequest,
53
+ QueryAllBalancesResponse,
54
+ QueryBalanceRequest,
55
+ QueryBalanceResponse,
56
+ QueryDelegationRequest,
57
+ QueryDelegationResponse,
58
+ QueryDelegationRewardsRequest,
59
+ QueryDelegationRewardsResponse,
60
+ QueryDelegationTotalRewardsRequest,
61
+ QueryDelegationTotalRewardsResponse,
62
+ QueryDelegatorDelegationsRequest,
63
+ QueryDelegatorDelegationsResponse,
64
+ QueryDelegatorUnbondingDelegationsRequest,
65
+ QueryDelegatorUnbondingDelegationsResponse,
66
+ QueryRedelegationsRequest,
67
+ QueryRedelegationsResponse,
68
+ QueryUnbondingDelegationRequest,
69
+ QueryUnbondingDelegationResponse,
70
+ responseCodecForTypeUrl,
71
+ } from '../utils/codecs.js';
126
72
 
127
73
  /**
128
74
  * @import {HostOf} from '@agoric/async-flow';
129
- * @import {AmountArg, IcaAccount, CosmosChainAddress, CosmosValidatorAddress, ICQConnection, StakingAccountActions, StakingAccountQueries, NobleMethods, OrchestrationAccountCommon, CosmosRewardsResponse, IBCConnectionInfo, IBCMsgTransferOptions, ChainHub, CosmosDelegationResponse, CaipChainId, AccountIdArg} from '../types.js';
130
- * @import {ContractMeta, Invitation, OfferHandler, ZCF, ZCFSeat} from '@agoric/zoe';
75
+ * @import {AmountArg, IcaAccount, CosmosChainAddress, CosmosValidatorAddress,
76
+ * ICQConnection, StakingAccountActions, StakingAccountQueries, NobleMethods,
77
+ * OrchestrationAccountCommon, CosmosRewardsResponse, IBCConnectionInfo,
78
+ * IBCMsgTransferOptions, ChainHub, CosmosDelegationResponse, CaipChainId,
79
+ * ChainInfo, AccountIdArg, CosmosActionOptions, IcaAccountMethods,
80
+ * ProgressTracker, MakeProgressTracker} from '../types.js';
81
+ * @import {OfferHandler, ZCF} from '@agoric/zoe';
131
82
  * @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js';
132
83
  * @import {Coin} from '@agoric/cosmic-proto/cosmos/base/v1beta1/coin.js';
133
84
  * @import {Remote} from '@agoric/internal';
134
- * @import {DelegationResponse} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js';
135
85
  * @import {InvitationMakers} from '@agoric/smart-wallet/src/types.js';
136
86
  * @import {TimerService} from '@agoric/time';
137
87
  * @import {Vow, VowTools} from '@agoric/vow';
138
88
  * @import {Zone} from '@agoric/zone';
139
89
  * @import {ResponseQuery} from '@agoric/cosmic-proto/tendermint/abci/types.js';
140
- * @import {JsonSafe} from '@agoric/cosmic-proto';
90
+ * @import {AnyJson, JsonSafe, MessageBody, TypeFromUrl,
91
+ * ResponseTypeUrl} from '@agoric/cosmic-proto';
141
92
  * @import {Matcher} from '@endo/patterns';
142
93
  * @import {LocalIbcAddress, RemoteIbcAddress} from '@agoric/vats/tools/ibc-utils.js';
94
+ * @import {AnyType, MsgDepositForBurnType, MsgUndelegateResponseType} from '../utils/codecs.js';
95
+ * @import {SliceDescriptor} from '../utils/orchestrationAccount.js';
96
+ * @import {ProgressReport} from '../utils/progress.js';
97
+ * @import {StorageNode} from '@agoric/internal/src/lib-chainStorage.js';
143
98
  */
144
99
 
100
+ /**
101
+ * Watcher facets of the exoClassKit that have been removed from service, but
102
+ * need to leave behind a dummy facet to allow older contracts that use
103
+ * orchestration to be upgraded.
104
+ *
105
+ * Add new watchers here as they are removed from service. Maybe someday
106
+ * contract upgrade will allow us to prune this list.
107
+ */
108
+ const TOMBSTONED_WATCHERS = /** @type {const} */ ([
109
+ // 'attachTxMetaWatcher', // deprecated but not yet tombstoned
110
+ // 'parseTransferWatcher', // deprecated but not yet tombstoned
111
+ 'redelegationQueryWatcher',
112
+ 'transferWatcher',
113
+ // 'transferWithMetaWatcher', // deprecated but not yet tombstoned
114
+ // 'undelegateWatcher', // deprecated but not yet tombstoned
115
+ // 'withdrawRewardWatcher', // deprecated but not yet tombstoned
116
+ ]);
117
+
145
118
  const trace = makeTracer('CosmosOrchAccount');
146
119
 
147
120
  const { Vow$ } = NetworkShape; // TODO #9611
148
121
 
122
+ const EVow$ = shape => M.or(Vow$(shape), M.promise(/* shape */));
123
+
149
124
  /**
150
125
  * @typedef {object} CosmosOrchestrationAccountNotification
151
126
  * @property {CosmosChainAddress} chainAddress
@@ -199,48 +174,79 @@ const decodeIcqResult = (codec, result) => {
199
174
 
200
175
  /** @see {StakingAccountActions} */
201
176
  const stakingAccountActionsMethods = {
202
- delegate: M.call(CosmosChainAddressShape, AmountArgShape).returns(VowShape),
177
+ delegate: M.call(CosmosChainAddressShape, AmountArgShape)
178
+ .optional(CosmosActionOptionsShape)
179
+ .returns(VowShape),
203
180
  redelegate: M.call(
204
181
  CosmosChainAddressShape,
205
182
  CosmosChainAddressShape,
206
183
  AmountArgShape,
207
- ).returns(VowShape),
208
- undelegate: M.call(M.arrayOf(DelegationShape)).returns(VowShape),
209
- withdrawReward: M.call(CosmosChainAddressShape).returns(
210
- Vow$(M.arrayOf(DenomAmountShape)),
211
- ),
212
- withdrawRewards: M.call().returns(Vow$(M.arrayOf(DenomAmountShape))),
184
+ )
185
+ .optional(CosmosActionOptionsShape)
186
+ .returns(VowShape),
187
+ undelegate: M.call(M.arrayOf(DelegationShape))
188
+ .optional(CosmosActionOptionsShape)
189
+ .returns(VowShape),
190
+ withdrawReward: M.call(CosmosChainAddressShape)
191
+ .optional(CosmosActionOptionsShape)
192
+ .returns(Vow$(M.arrayOf(DenomAmountShape))),
193
+ withdrawRewards: M.call()
194
+ .optional(CosmosActionOptionsShape)
195
+ .returns(Vow$(M.arrayOf(DenomAmountShape))),
213
196
  };
214
197
 
215
198
  /** @see {StakingAccountQueries} */
216
199
  const stakingAccountQueriesMethods = {
217
- getDelegation: M.call(CosmosChainAddressShape).returns(VowShape),
218
- getDelegations: M.call().returns(VowShape),
219
- getUnbondingDelegation: M.call(CosmosChainAddressShape).returns(VowShape),
220
- getUnbondingDelegations: M.call().returns(VowShape),
221
- getRedelegations: M.call().returns(VowShape),
222
- getReward: M.call(CosmosChainAddressShape).returns(VowShape),
223
- getRewards: M.call().returns(VowShape),
200
+ getDelegation: M.call(CosmosChainAddressShape)
201
+ .optional(CosmosQuerierOptionsShape)
202
+ .returns(VowShape),
203
+ getDelegations: M.call()
204
+ .optional(CosmosQuerierOptionsShape)
205
+ .returns(VowShape),
206
+ getUnbondingDelegation: M.call(CosmosChainAddressShape)
207
+ .optional(CosmosQuerierOptionsShape)
208
+ .returns(VowShape),
209
+ getUnbondingDelegations: M.call()
210
+ .optional(CosmosQuerierOptionsShape)
211
+ .returns(VowShape),
212
+ getRedelegations: M.call()
213
+ .optional(CosmosQuerierOptionsShape)
214
+ .returns(VowShape),
215
+ getReward: M.call(CosmosChainAddressShape)
216
+ .optional(CosmosQuerierOptionsShape)
217
+ .returns(VowShape),
218
+ getRewards: M.call().optional(CosmosQuerierOptionsShape).returns(VowShape),
224
219
  };
225
220
 
226
221
  /** @see {NobleMethods} */
227
222
  const nobleMethods = {
228
223
  depositForBurn: M.call(M.string(), AmountArgShape)
229
- .optional(M.string())
224
+ .optional(M.string(), CosmosActionOptionsShape)
230
225
  .returns(VowShape),
231
226
  };
232
227
 
228
+ /** @see {IcaAccountMethods} */
229
+ const icaAccountMethods = {
230
+ deactivate: M.call().returns(VowShape),
231
+ reactivate: M.call().returns(VowShape),
232
+ executeEncodedTx: M.call(M.arrayOf(Proto3Shape))
233
+ .optional(LegacyExecuteEncodedTxOptionsShape)
234
+ .returns(EVow$(M.string())),
235
+ executeTxProto3: M.call(M.arrayOf(Proto3Shape))
236
+ .optional(CosmosActionOptionsShape)
237
+ .returns(EVow$(M.array())),
238
+ executeTxProto3Undecoded: M.call(M.arrayOf(Proto3Shape))
239
+ .optional(CosmosActionOptionsShape)
240
+ .returns(EVow$(M.string())),
241
+ };
242
+
233
243
  /** @see {OrchestrationAccountCommon} */
234
244
  export const IcaAccountHolderI = M.interface('IcaAccountHolder', {
235
245
  ...nobleMethods,
236
246
  ...orchestrationAccountMethods,
237
247
  ...stakingAccountActionsMethods,
238
248
  ...stakingAccountQueriesMethods,
239
- deactivate: M.call().returns(VowShape),
240
- reactivate: M.call().returns(VowShape),
241
- executeEncodedTx: M.call(M.arrayOf(Proto3Shape))
242
- .optional(ExecuteICATxOptsShape)
243
- .returns(VowShape),
249
+ ...icaAccountMethods,
244
250
  });
245
251
 
246
252
  /** @type {{ [name: string]: [description: string, valueShape: Matcher] }} */
@@ -275,6 +281,7 @@ harden(CosmosOrchestrationInvitationMakersI);
275
281
  * @param {Zone} zone
276
282
  * @param {object} powers
277
283
  * @param {ChainHub} powers.chainHub
284
+ * @param {MakeProgressTracker} powers.makeProgressTracker
278
285
  * @param {MakeRecorderKit} powers.makeRecorderKit
279
286
  * @param {Remote<TimerService>} powers.timerService
280
287
  * @param {VowTools} powers.vowTools
@@ -284,25 +291,97 @@ export const prepareCosmosOrchestrationAccountKit = (
284
291
  zone,
285
292
  {
286
293
  chainHub,
294
+ makeProgressTracker,
287
295
  makeRecorderKit,
288
296
  timerService,
289
- vowTools: { watch, asVow, when, allVows },
297
+ vowTools,
290
298
  zcf,
291
299
  },
292
300
  ) => {
301
+ /**
302
+ * Abandon the icaAccountToDetails weakMapStore, since it introduced a caching
303
+ * layer that was never properly invalidated. So, we mark it as a tombstone
304
+ * (null) that's part of new contract instance baggage, while leaving older
305
+ * contracts with the undisturbed zone slot assignment.
306
+ */
307
+ void zone.makeOnce('icaAccountToDetails', () => null);
308
+
309
+ const { watch, asVow, when, allVows } = vowTools;
310
+
311
+ const vowExo = makeVowExoHelpers({ watch });
293
312
  const timestampHelper = makeTimestampHelper(timerService);
294
313
  const makeCosmosOrchestrationAccountKit = zone.exoClassKit(
295
314
  'Cosmos Orchestration Account Holder',
296
315
  {
316
+ /** @deprecated only used by obsolete *WithMeta methods */
317
+ attachTxMetaWatcher: M.interface('attachTxMetaWatcher', {
318
+ onFulfilled: M.call(
319
+ M.arrayOf(M.any()),
320
+ EVow$(M.splitRecord({ result: EVow$(M.any()), meta: M.record() })),
321
+ M.string(),
322
+ ).returns(EVow$(M.any())),
323
+ }),
324
+ /** @deprecated only used by obsolete *WithMeta methods */
325
+ transferWithMetaWatcher: M.interface('transferWithMetaWatcher', {
326
+ onFulfilled: M.call([M.record(), M.nat()])
327
+ .optional({
328
+ destination: CosmosChainAddressShape,
329
+ opts: M.or(M.undefined(), IBCTransferOptionsShape),
330
+ token: {
331
+ denom: M.string(),
332
+ amount: M.string(),
333
+ },
334
+ })
335
+ .returns(Vow$({ result: Vow$(M.any()), meta: M.record() })),
336
+ }),
337
+ /** @deprecated only used by obsolete *WithMeta methods */
338
+ parseTransferWatcher: M.interface('parseTransferWatcher', {
339
+ onFulfilled: M.call([M.string(), M.record()], M.record()).returns(
340
+ Vow$(M.record()),
341
+ ),
342
+ }),
343
+ /** @deprecated only used before executeTxProto3 */
344
+ undelegateWatcher: M.interface('undelegateWatcher', {
345
+ onFulfilled: M.call(M.string())
346
+ .optional(M.arrayOf(M.undefined())) // empty context
347
+ .returns(Vow$(M.promise())),
348
+ }),
349
+ /** @deprecated only used before executeTxProto3 */
350
+ withdrawRewardWatcher: M.interface('withdrawRewardWatcher', {
351
+ onFulfilled: M.call(M.string())
352
+ .optional(M.arrayOf(M.undefined())) // empty context
353
+ .returns(M.arrayOf(DenomAmountShape)),
354
+ }),
355
+ /** Facets above this line are deprecated. */
356
+ ...vowExo.makeTombstonedWatcherShapes(TOMBSTONED_WATCHERS),
357
+ ...vowExo.watcherShapes,
297
358
  helper: M.interface('helper', {
359
+ ...vowExo.helperShapes,
298
360
  owned: M.call().returns(M.remotable()),
299
361
  getUpdater: M.call().returns(M.remotable()),
300
362
  amountToCoin: M.call(AmountArgShape).returns(M.record()),
301
363
  }),
364
+ updateTxProgressWatcher: M.interface('updateTxProgressWatcher', {
365
+ onFulfilled: M.call(
366
+ M.arrayOf(M.any()),
367
+ M.splitRecord(
368
+ {
369
+ progressTracker: M.remotable('ProgressTracker'),
370
+ protocol: M.string(),
371
+ },
372
+ {
373
+ trafficeSlice: SliceDescriptorShape,
374
+ },
375
+ ),
376
+ ).returns(),
377
+ }),
302
378
  returnVoidWatcher: M.interface('returnVoidWatcher', {
303
- onFulfilled: M.call(M.any())
304
- .optional(M.arrayOf(M.undefined()))
305
- .returns(M.undefined()),
379
+ onFulfilled: M.call().rest(M.any()).returns(M.undefined()),
380
+ }),
381
+ decodeResponsesWatcher: M.interface('decodeResponsesWatcher', {
382
+ onFulfilled: M.call(M.string(), M.arrayOf(M.string())).returns(
383
+ M.arrayOf(M.any()),
384
+ ),
306
385
  }),
307
386
  balanceQueryWatcher: M.interface('balanceQueryWatcher', {
308
387
  onFulfilled: M.call(M.arrayOf(M.record()))
@@ -314,27 +393,34 @@ export const prepareCosmosOrchestrationAccountKit = (
314
393
  M.arrayOf(M.record()),
315
394
  ),
316
395
  }),
317
- undelegateWatcher: M.interface('undelegateWatcher', {
318
- onFulfilled: M.call(M.string())
319
- .optional(M.arrayOf(M.undefined())) // empty context
320
- .returns(Vow$(M.promise())),
321
- }),
322
- withdrawRewardWatcher: M.interface('withdrawRewardWatcher', {
323
- onFulfilled: M.call(M.string())
324
- .optional(M.arrayOf(M.undefined())) // empty context
325
- .returns(M.arrayOf(DenomAmountShape)),
396
+ decodedUndelegateWatcher: M.interface('decodedUndelegateWatcher', {
397
+ onFulfilled: M.call(M.arrayOf(M.any())).returns(Vow$(M.promise())),
326
398
  }),
327
- transferWatcher: M.interface('transferWatcher', {
328
- onFulfilled: M.call([M.record(), M.nat()])
399
+ decodedWithdrawRewardWatcher: M.interface(
400
+ 'decodedWithdrawRewardWatcher',
401
+ {
402
+ onFulfilled: M.call(M.splitRecord({ amount: M.arrayOf(CoinShape) }))
403
+ .optional(M.arrayOf(M.undefined())) // empty context
404
+ .returns(M.arrayOf(DenomAmountShape)),
405
+ },
406
+ ),
407
+ beginTransferWatcher: M.interface('beginTransferWatcher', {
408
+ onFulfilled: M.call([M.any(), M.opt(M.nat())])
329
409
  .optional({
330
410
  destination: CosmosChainAddressShape,
331
- opts: M.or(M.undefined(), IBCTransferOptionsShape),
411
+ opts: M.opt(IBCTransferOptionsShape),
332
412
  token: {
333
413
  denom: M.string(),
334
414
  amount: M.string(),
335
415
  },
336
416
  })
337
- .returns(Vow$(M.record())),
417
+ .returns(Vow$(M.any())),
418
+ }),
419
+ fillSequenceWatcher: M.interface('fillSequenceWatcher', {
420
+ onFulfilled: M.call(
421
+ [M.splitRecord({ sequence: M.bigint() })],
422
+ M.record(),
423
+ ).returns(),
338
424
  }),
339
425
  delegationQueryWatcher: M.interface('delegationQueryWatcher', {
340
426
  onFulfilled: M.call(M.arrayOf(M.record())).returns(M.record()),
@@ -358,11 +444,6 @@ export const prepareCosmosOrchestrationAccountKit = (
358
444
  ),
359
445
  },
360
446
  ),
361
- redelegationQueryWatcher: M.interface('redelegationQueryWatcher', {
362
- onFulfilled: M.call(M.arrayOf(M.record())).returns(
363
- M.arrayOf(M.record()),
364
- ),
365
- }),
366
447
  redelegationsQueryWatcher: M.interface('redelegationsQueryWatcher', {
367
448
  onFulfilled: M.call(M.arrayOf(M.record())).returns(
368
449
  M.arrayOf(M.record()),
@@ -426,7 +507,90 @@ export const prepareCosmosOrchestrationAccountKit = (
426
507
  };
427
508
  },
428
509
  {
510
+ /** @deprecated only used by obsolete *WithMeta methods */
511
+ attachTxMetaWatcher: {
512
+ /**
513
+ * TODO(#1994): Subsume with IcaAccount.executeEncodedTxWithMeta().
514
+ *
515
+ * @param {readonly [
516
+ * agoric: ChainInfo<'cosmos'>,
517
+ * la: LocalIbcAddress,
518
+ * counterparty: CaipChainId,
519
+ * ra: RemoteIbcAddress,
520
+ * ]} _param0
521
+ * @param {{ result: Vow<any>; meta: Record<string, any> }} param1
522
+ * @param {string} _protocol
523
+ */
524
+ onFulfilled(_param0, { result, meta }, _protocol) {
525
+ return { result, meta };
526
+ },
527
+ },
528
+
529
+ /** @deprecated only used by obsolete *WithMeta methods */
530
+ parseTransferWatcher: {
531
+ onFulfilled() {
532
+ // Result is unknown, so return Vow<null>.
533
+ const result = watch(null);
534
+ return { result, meta: {} };
535
+ },
536
+ },
537
+
538
+ /** @deprecated only used by obsolete *WithMeta methods */
539
+ transferWithMetaWatcher: {
540
+ /**
541
+ * @param {readonly [
542
+ * { transferChannel: IBCConnectionInfo['transferChannel'] },
543
+ * bigint | undefined,
544
+ * ]} results
545
+ * @param {{
546
+ * destination: CosmosChainAddress;
547
+ * opts?: IBCMsgTransferOptions;
548
+ * token: Coin;
549
+ * }} ctx
550
+ */
551
+ onFulfilled(results, ctx) {
552
+ const result = this.facets.beginTransferWatcher.onFulfilled(
553
+ results,
554
+ ctx,
555
+ );
556
+ return harden({ result, meta: {} });
557
+ },
558
+ },
559
+
560
+ /** @deprecated only used before executeTxProto3 */
561
+ undelegateWatcher: {
562
+ /**
563
+ * @param {string} txResult
564
+ */
565
+ onFulfilled(txResult) {
566
+ const responses = this.facets.decodeResponsesWatcher.onFulfilled(
567
+ txResult,
568
+ /** @type {const} */ (['/cosmos.staking.v1beta1.MsgUndelegate']),
569
+ );
570
+ return this.facets.decodedUndelegateWatcher.onFulfilled(responses);
571
+ },
572
+ },
573
+
574
+ /** @deprecated only used before executeTxProto3 */
575
+ withdrawRewardWatcher: {
576
+ /** @param {string} result */
577
+ onFulfilled(result) {
578
+ const [response] = this.facets.decodeResponsesWatcher.onFulfilled(
579
+ result,
580
+ /** @type {const} */ ([
581
+ '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward',
582
+ ]),
583
+ );
584
+ return this.facets.decodedWithdrawRewardWatcher.onFulfilled(response);
585
+ },
586
+ },
587
+
588
+ /** Facets above this line are deprecated. */
589
+ ...vowExo.makeTombstonedWatchers(TOMBSTONED_WATCHERS),
590
+ ...vowExo.watchers,
591
+
429
592
  helper: {
593
+ ...vowExo.helper,
430
594
  /** @throws if this holder no longer owns the account */
431
595
  owned() {
432
596
  const { account } = this.state;
@@ -449,6 +613,50 @@ export const prepareCosmosOrchestrationAccountKit = (
449
613
  return coerceCoin(chainHub, amount);
450
614
  },
451
615
  },
616
+
617
+ updateTxProgressWatcher: {
618
+ /**
619
+ * @param {readonly [
620
+ * srcChainInfo: ChainInfo<'cosmos'>,
621
+ * la: LocalIbcAddress,
622
+ * ra: RemoteIbcAddress,
623
+ * ]} param0
624
+ * @param {{
625
+ * progressTracker: ProgressTracker;
626
+ * trafficSlice: SliceDescriptor;
627
+ * protocol: 'ibc';
628
+ * }} opts
629
+ */
630
+ onFulfilled(
631
+ [srcChainInfo, la, ra],
632
+ { progressTracker, trafficSlice, protocol },
633
+ ) {
634
+ protocol;
635
+ const lad = decodeIbcEndpoint(la);
636
+ const rad = decodeIbcEndpoint(ra);
637
+ // TODO(#11994): Need to expose from Network API `conn.sendWithMeta(...)`
638
+ const sequence = /** @type {const} */ ({ status: 'unknown' });
639
+
640
+ const priorReport = progressTracker.getCurrentProgressReport();
641
+ const traffic = finishTrafficEntries(
642
+ priorReport.traffic,
643
+ trafficSlice,
644
+ entries =>
645
+ trafficTransforms.IbcICA.finish(
646
+ entries,
647
+ `${srcChainInfo.namespace}:${srcChainInfo.reference}`,
648
+ lad,
649
+ rad,
650
+ sequence,
651
+ ),
652
+ );
653
+ const report = harden({
654
+ ...priorReport,
655
+ traffic,
656
+ });
657
+ progressTracker.update(report);
658
+ },
659
+ },
452
660
  balanceQueryWatcher: {
453
661
  /**
454
662
  * @param {JsonSafe<ResponseQuery>[]} results
@@ -524,20 +732,6 @@ export const prepareCosmosOrchestrationAccountKit = (
524
732
  return harden(unbondingResponses);
525
733
  },
526
734
  },
527
- redelegationQueryWatcher: {
528
- /**
529
- * @param {JsonSafe<ResponseQuery>[]} results
530
- */
531
- onFulfilled([result]) {
532
- const { redelegationResponses } = decodeIcqResult(
533
- QueryRedelegationsResponse,
534
- result,
535
- );
536
- if (!redelegationResponses)
537
- throw Fail`Result lacked redelegationResponses key: ${result}`;
538
- return harden(redelegationResponses);
539
- },
540
- },
541
735
  redelegationsQueryWatcher: {
542
736
  /**
543
737
  * @param {JsonSafe<ResponseQuery>[]} results
@@ -548,7 +742,7 @@ export const prepareCosmosOrchestrationAccountKit = (
548
742
  result,
549
743
  );
550
744
  if (!redelegationResponses)
551
- throw Fail`Result lacked redelegationResponses key: ${result}`;
745
+ throw Fail`Result lacked redelegationsResponses key: ${result}`;
552
746
  return harden(redelegationResponses);
553
747
  },
554
748
  },
@@ -600,52 +794,90 @@ export const prepareCosmosOrchestrationAccountKit = (
600
794
  return harden(balances.map(coin => toDenomAmount(coin)));
601
795
  },
602
796
  },
603
- undelegateWatcher: {
797
+ decodedUndelegateWatcher: {
604
798
  /**
605
- * @param {string} result
799
+ * @param {readonly MsgUndelegateResponseType[]} responses
606
800
  */
607
- onFulfilled(result) {
608
- const response = tryDecodeResponse(
609
- result,
610
- MsgUndelegateResponse.fromProtoMsg,
611
- );
612
- trace('undelegate response', response);
613
- const { completionTime } = response;
614
- completionTime || Fail`No completion time result ${result}`;
615
- return watch(
801
+ onFulfilled(responses) {
802
+ trace('undelegate responses', responses);
803
+ const completionSeconds = responses.reduce((maxTime, resp) => {
616
804
  // ignore nanoseconds and just use seconds from Timestamp
617
- E(this.state.timer).wakeAt(completionTime.seconds + maxClockSkew),
805
+ const completionS = resp?.completionTime?.seconds ?? 0n;
806
+ return completionS > maxTime ? completionS : maxTime;
807
+ }, 0n);
808
+ completionSeconds ||
809
+ Fail`No completion time in responses ${responses}`;
810
+ return watch(
811
+ E(this.state.timer).wakeAt(completionSeconds + maxClockSkew),
618
812
  );
619
813
  },
620
814
  },
621
815
  /**
622
- * takes an array of results (from `executeEncodedTx`) and returns void
623
- * since we are not interested in the result
816
+ * takes any arguments and returns void since we are not interested in the
817
+ * result
624
818
  */
625
819
  returnVoidWatcher: {
626
- /** @param {string | Record<string, unknown>} result */
627
- onFulfilled(result) {
628
- trace('Result', result);
820
+ /**
821
+ * @param {unknown[]} args
822
+ * @returns {void}
823
+ */
824
+ onFulfilled(...args) {
825
+ trace('Voiding result', args);
629
826
  return undefined;
630
827
  },
631
828
  },
632
- withdrawRewardWatcher: {
633
- /** @param {string} result */
634
- onFulfilled(result) {
635
- const response = tryDecodeResponse(
636
- result,
637
- MsgWithdrawDelegatorRewardResponse.fromProtoMsg,
638
- );
829
+ decodedWithdrawRewardWatcher: {
830
+ /** @param {{ amount: Coin[] }} response */
831
+ onFulfilled(response) {
639
832
  trace('withdrawReward response', response);
640
833
  const { amount: coins } = response;
641
834
  return harden(coins.map(toDenomAmount));
642
835
  },
643
836
  },
644
- transferWatcher: {
837
+
838
+ /**
839
+ * Decode responses based on the typeUrls of the original requests.
840
+ */
841
+ decodeResponsesWatcher: {
645
842
  /**
646
- * @param {[
843
+ * @template {readonly (keyof TypeFromUrl | unknown)[]} [TUS=(keyof TypeFromUrl)[]]
844
+ * @param {string} resultStr
845
+ * @param {TUS} typeUrls
846
+ * @returns {{
847
+ * [P in keyof TUS]: MessageBody<ResponseTypeUrl<TUS[P]>>;
848
+ * }}
849
+ */
850
+ onFulfilled(resultStr, typeUrls) {
851
+ const responseCodecs = typeUrls.map(
852
+ typeUrl =>
853
+ responseCodecForTypeUrl[typeUrl] || {
854
+ /**
855
+ * Pass through an Any if we don't have a codec for the request
856
+ * typeUrl.
857
+ *
858
+ * @param {AnyType} msg
859
+ */
860
+ fromProtoMsg(msg) {
861
+ return msg;
862
+ },
863
+ },
864
+ );
865
+
866
+ const decoded = tryDecodeResponses(resultStr, responseCodecs);
867
+
868
+ /**
869
+ * @typedef {{
870
+ * [P in keyof TUS]: MessageBody<ResponseTypeUrl<TUS[P]>>;
871
+ * }} Result
872
+ */
873
+ return /** @type {Result} */ (harden(decoded));
874
+ },
875
+ },
876
+ beginTransferWatcher: {
877
+ /**
878
+ * @param {readonly [
647
879
  * { transferChannel: IBCConnectionInfo['transferChannel'] },
648
- * bigint,
880
+ * bigint | undefined,
649
881
  * ]} results
650
882
  * @param {{
651
883
  * destination: CosmosChainAddress;
@@ -655,23 +887,88 @@ export const prepareCosmosOrchestrationAccountKit = (
655
887
  */
656
888
  onFulfilled(
657
889
  [{ transferChannel }, timeoutTimestamp],
658
- { opts, token, destination },
890
+ { opts = {}, token, destination },
659
891
  ) {
660
- const results = E(this.facets.helper.owned()).executeEncodedTx([
661
- Any.toJSON(
662
- MsgTransfer.toProtoMsg({
663
- sourcePort: transferChannel.portId,
664
- sourceChannel: transferChannel.channelId,
665
- token,
666
- sender: this.state.chainAddress.value,
667
- receiver: destination.value,
668
- timeoutHeight: opts?.timeoutHeight,
669
- timeoutTimestamp,
670
- memo: opts?.memo,
671
- }),
672
- ),
673
- ]);
674
- return watch(results, this.facets.returnVoidWatcher);
892
+ const { chainAddress } = this.state;
893
+ const { holder } = this.facets;
894
+ const {
895
+ // Strip out the timeout information and memo from the executeOpts,
896
+ // since they're used in the MsgTransfer.
897
+ timeoutHeight,
898
+ timeoutTimestamp: _,
899
+ memo,
900
+ ...executeOpts
901
+ } = opts;
902
+ const results = holder.executeTxProto3(
903
+ [
904
+ Any.toJSON(
905
+ MsgTransfer.toProtoMsg({
906
+ sourcePort: transferChannel.portId,
907
+ sourceChannel: transferChannel.channelId,
908
+ token,
909
+ sender: chainAddress.value,
910
+ receiver: destination.value,
911
+ timeoutHeight,
912
+ timeoutTimestamp,
913
+ memo,
914
+ }),
915
+ ),
916
+ ],
917
+ executeOpts,
918
+ );
919
+
920
+ const { progressTracker } = executeOpts;
921
+ if (progressTracker) {
922
+ const priorReport = progressTracker.getCurrentProgressReport();
923
+ const { traffic, slice: trafficSlice } = addTrafficEntries(
924
+ priorReport.traffic,
925
+ trafficTransforms.IbcTransfer.start(
926
+ `cosmos:${chainAddress.chainId}`,
927
+ `cosmos:${destination.chainId}`,
928
+ transferChannel,
929
+ ),
930
+ );
931
+
932
+ const report = harden({
933
+ ...priorReport,
934
+ traffic,
935
+ });
936
+ progressTracker.update(report);
937
+ watch(results, this.facets.fillSequenceWatcher, {
938
+ progressTracker,
939
+ trafficSlice,
940
+ });
941
+ }
942
+ return this.facets.helper.overrideVow(results, 'FOLLOW_TRAFFIC');
943
+ },
944
+ },
945
+ fillSequenceWatcher: {
946
+ /**
947
+ * @param {[{ sequence: bigint }]} transferResponse
948
+ * @param {object} opts
949
+ * @param {ProgressTracker} opts.progressTracker
950
+ * @param {SliceDescriptor} opts.trafficSlice
951
+ */
952
+ onFulfilled([{ sequence }], { progressTracker, trafficSlice }) {
953
+ const priorReport = progressTracker.getCurrentProgressReport();
954
+ trace('fillSequenceWatcher', {
955
+ sequence,
956
+ priorReport,
957
+ trafficSlice,
958
+ });
959
+
960
+ const traffic = finishTrafficEntries(
961
+ priorReport.traffic,
962
+ trafficSlice,
963
+ entries => trafficTransforms.IbcTransfer.finish(entries, sequence),
964
+ );
965
+
966
+ /** @type {ProgressReport} */
967
+ const report = harden({
968
+ ...priorReport,
969
+ traffic,
970
+ });
971
+ progressTracker.update(report);
675
972
  },
676
973
  },
677
974
  invitationMakers: {
@@ -739,12 +1036,16 @@ export const prepareCosmosOrchestrationAccountKit = (
739
1036
  /**
740
1037
  * @type {OfferHandler<
741
1038
  * Vow<void>,
742
- * { toAccount: AccountIdArg; amount: AmountArg }
1039
+ * {
1040
+ * toAccount: AccountIdArg;
1041
+ * amount: AmountArg;
1042
+ * opts?: CosmosActionOptions;
1043
+ * }
743
1044
  * >}
744
1045
  */
745
- const offerHandler = (seat, { toAccount, amount }) => {
1046
+ const offerHandler = (seat, { toAccount, amount, opts }) => {
746
1047
  seat.exit();
747
- return watch(this.facets.holder.send(toAccount, amount));
1048
+ return watch(this.facets.holder.send(toAccount, amount, opts));
748
1049
  };
749
1050
  return zcf.makeInvitation(offerHandler, 'Send');
750
1051
  },
@@ -752,12 +1053,16 @@ export const prepareCosmosOrchestrationAccountKit = (
752
1053
  /**
753
1054
  * @type {OfferHandler<
754
1055
  * Vow<void>,
755
- * { toAccount: CosmosChainAddress; amounts: AmountArg[] }
1056
+ * {
1057
+ * toAccount: CosmosChainAddress;
1058
+ * amounts: AmountArg[];
1059
+ * opts?: CosmosActionOptions;
1060
+ * }
756
1061
  * >}
757
1062
  */
758
- const offerHandler = (seat, { toAccount, amounts }) => {
1063
+ const offerHandler = (seat, { toAccount, amounts, opts }) => {
759
1064
  seat.exit();
760
- return watch(this.facets.holder.sendAll(toAccount, amounts));
1065
+ return watch(this.facets.holder.sendAll(toAccount, amounts, opts));
761
1066
  };
762
1067
  return zcf.makeInvitation(offerHandler, 'SendAll');
763
1068
  },
@@ -772,7 +1077,7 @@ export const prepareCosmosOrchestrationAccountKit = (
772
1077
  Transfer() {
773
1078
  /**
774
1079
  * @type {OfferHandler<
775
- * Vow<void>,
1080
+ * Vow<any>,
776
1081
  * {
777
1082
  * amount: AmountArg;
778
1083
  * destination: AccountIdArg;
@@ -790,6 +1095,10 @@ export const prepareCosmosOrchestrationAccountKit = (
790
1095
  },
791
1096
  },
792
1097
  holder: {
1098
+ /** @type {OrchestrationAccountCommon['makeProgressTracker']} */
1099
+ makeProgressTracker() {
1100
+ return makeProgressTracker();
1101
+ },
793
1102
  /** @type {HostOf<OrchestrationAccountCommon['asContinuingOffer']>} */
794
1103
  asContinuingOffer() {
795
1104
  // @ts-expect-error XXX invitationMakers
@@ -835,70 +1144,72 @@ export const prepareCosmosOrchestrationAccountKit = (
835
1144
  return this.state.chainAddress;
836
1145
  },
837
1146
  /** @type {HostOf<StakingAccountActions['delegate']>} */
838
- delegate(validator, amount) {
1147
+ delegate(validator, amount, opts) {
839
1148
  return asVow(() => {
840
1149
  trace('delegate', validator, amount);
841
- const { helper } = this.facets;
1150
+ const { helper, holder } = this.facets;
842
1151
  const { chainAddress } = this.state;
843
1152
 
844
1153
  const amountAsCoin = helper.amountToCoin(amount);
845
1154
 
846
- const results = E(helper.owned()).executeEncodedTx([
847
- Any.toJSON(
848
- MsgDelegate.toProtoMsg({
849
- delegatorAddress: chainAddress.value,
850
- validatorAddress: validator.value,
851
- amount: amountAsCoin,
852
- }),
853
- ),
854
- ]);
855
- return watch(results, this.facets.returnVoidWatcher);
1155
+ const result = holder.executeTxProto3(
1156
+ [
1157
+ Any.toJSON(
1158
+ MsgDelegate.toProtoMsg({
1159
+ delegatorAddress: chainAddress.value,
1160
+ validatorAddress: validator.value,
1161
+ amount: amountAsCoin,
1162
+ }),
1163
+ ),
1164
+ ],
1165
+ opts,
1166
+ );
1167
+ return helper.pickVowIndex(result, 0);
856
1168
  });
857
1169
  },
858
1170
 
859
1171
  /** @type {HostOf<StakingAccountActions['redelegate']>} */
860
- redelegate(srcValidator, dstValidator, amount) {
1172
+ redelegate(srcValidator, dstValidator, amount, opts) {
861
1173
  return asVow(() => {
862
1174
  trace('redelegate', srcValidator, dstValidator, amount);
863
- const { helper } = this.facets;
1175
+ const { helper, holder } = this.facets;
864
1176
  const { chainAddress } = this.state;
865
1177
 
866
- const results = E(helper.owned()).executeEncodedTx([
867
- Any.toJSON(
868
- MsgBeginRedelegate.toProtoMsg({
869
- delegatorAddress: chainAddress.value,
870
- validatorSrcAddress: srcValidator.value,
871
- validatorDstAddress: dstValidator.value,
872
- amount: helper.amountToCoin(amount),
873
- }),
874
- ),
875
- ]);
876
-
877
- return watch(
878
- results,
879
- // NOTE: response, including completionTime, is currently discarded.
880
- this.facets.returnVoidWatcher,
1178
+ const results = holder.executeTxProto3(
1179
+ [
1180
+ Any.toJSON(
1181
+ MsgBeginRedelegate.toProtoMsg({
1182
+ delegatorAddress: chainAddress.value,
1183
+ validatorSrcAddress: srcValidator.value,
1184
+ validatorDstAddress: dstValidator.value,
1185
+ amount: helper.amountToCoin(amount),
1186
+ }),
1187
+ ),
1188
+ ],
1189
+ opts,
881
1190
  );
1191
+
1192
+ return helper.pickVowIndex(results, 0);
882
1193
  });
883
1194
  },
884
1195
  /** @type {HostOf<StakingAccountActions['withdrawReward']>} */
885
- withdrawReward(validator) {
1196
+ withdrawReward(validator, opts) {
886
1197
  return asVow(() => {
887
1198
  trace('withdrawReward', validator);
888
- const { helper } = this.facets;
1199
+ const { helper, holder } = this.facets;
889
1200
  const { chainAddress } = this.state;
890
1201
  const msg = MsgWithdrawDelegatorReward.toProtoMsg({
891
1202
  delegatorAddress: chainAddress.value,
892
1203
  validatorAddress: validator.value,
893
1204
  });
894
- const account = helper.owned();
895
1205
 
896
- const results = E(account).executeEncodedTx([Any.toJSON(msg)]);
897
- return watch(results, this.facets.withdrawRewardWatcher);
1206
+ const result = holder.executeTxProto3([Any.toJSON(msg)], opts);
1207
+ const reward = helper.pickVowIndex(result, 0);
1208
+ return watch(reward, this.facets.decodedWithdrawRewardWatcher);
898
1209
  });
899
1210
  },
900
1211
  /** @type {HostOf<OrchestrationAccountCommon['getBalance']>} */
901
- getBalance(denom) {
1212
+ getBalance(denom, opts) {
902
1213
  return asVow(() => {
903
1214
  const { chainAddress, icqConnection } = this.state;
904
1215
  if (!icqConnection) {
@@ -910,6 +1221,7 @@ export const prepareCosmosOrchestrationAccountKit = (
910
1221
  address: chainAddress.value,
911
1222
  denom: coerceDenom(chainHub, denom),
912
1223
  }),
1224
+ opts?.queryOpts,
913
1225
  ),
914
1226
  ]);
915
1227
  return watch(results, this.facets.balanceQueryWatcher);
@@ -917,7 +1229,7 @@ export const prepareCosmosOrchestrationAccountKit = (
917
1229
  },
918
1230
 
919
1231
  /** @type {HostOf<OrchestrationAccountCommon['getBalances']>} */
920
- getBalances() {
1232
+ getBalances(opts) {
921
1233
  return asVow(() => {
922
1234
  const { chainAddress, icqConnection } = this.state;
923
1235
  if (!icqConnection) {
@@ -928,6 +1240,7 @@ export const prepareCosmosOrchestrationAccountKit = (
928
1240
  QueryAllBalancesRequest.toProtoMsg({
929
1241
  address: chainAddress.value,
930
1242
  }),
1243
+ opts?.queryOpts,
931
1244
  ),
932
1245
  ]);
933
1246
  return watch(results, this.facets.allBalancesQueryWatcher);
@@ -935,16 +1248,16 @@ export const prepareCosmosOrchestrationAccountKit = (
935
1248
  },
936
1249
 
937
1250
  /** @type {HostOf<OrchestrationAccountCommon['send']>} */
938
- send(toAccount, amount) {
1251
+ send(toAccount, amount, opts) {
939
1252
  return asVow(() => {
940
- trace('send', toAccount, amount);
1253
+ trace('send', toAccount, amount, opts);
941
1254
  const cosmosDest = chainHub.coerceCosmosAddress(toAccount);
942
1255
  const { chainAddress } = this.state;
943
1256
  cosmosDest.chainId === chainAddress.chainId ||
944
1257
  Fail`bank/send cannot send to a different chain ${q(cosmosDest.chainId)}`;
945
- const { helper } = this.facets;
946
- return watch(
947
- E(helper.owned()).executeEncodedTx([
1258
+ const { helper, holder } = this.facets;
1259
+ const result = holder.executeTxProto3(
1260
+ [
948
1261
  Any.toJSON(
949
1262
  MsgSend.toProtoMsg({
950
1263
  fromAddress: chainAddress.value,
@@ -952,20 +1265,21 @@ export const prepareCosmosOrchestrationAccountKit = (
952
1265
  amount: [helper.amountToCoin(amount)],
953
1266
  }),
954
1267
  ),
955
- ]),
956
- this.facets.returnVoidWatcher,
1268
+ ],
1269
+ opts,
957
1270
  );
1271
+ return helper.pickVowIndex(result, 0);
958
1272
  });
959
1273
  },
960
1274
 
961
1275
  /** @type {HostOf<OrchestrationAccountCommon['sendAll']>} */
962
- sendAll(toAccount, amounts) {
1276
+ sendAll(toAccount, amounts, opts) {
963
1277
  return asVow(() => {
964
1278
  trace('sendAll', toAccount, amounts);
965
- const { helper } = this.facets;
1279
+ const { helper, holder } = this.facets;
966
1280
  const { chainAddress } = this.state;
967
- return watch(
968
- E(helper.owned()).executeEncodedTx([
1281
+ const result = holder.executeTxProto3(
1282
+ [
969
1283
  Any.toJSON(
970
1284
  MsgSend.toProtoMsg({
971
1285
  fromAddress: chainAddress.value,
@@ -973,9 +1287,10 @@ export const prepareCosmosOrchestrationAccountKit = (
973
1287
  amount: amounts.map(x => helper.amountToCoin(x)),
974
1288
  }),
975
1289
  ),
976
- ]),
977
- this.facets.returnVoidWatcher,
1290
+ ],
1291
+ opts,
978
1292
  );
1293
+ return helper.pickVowIndex(result, 0);
979
1294
  });
980
1295
  },
981
1296
 
@@ -983,32 +1298,22 @@ export const prepareCosmosOrchestrationAccountKit = (
983
1298
  transfer(destination, amount, opts) {
984
1299
  trace('transfer', destination, amount, opts);
985
1300
  return asVow(() => {
986
- // `destination` arg can be non-Cosmos per the common `.transfer` method signature
987
- // but this implementation only supports transferring to another Cosmos chain.
988
- // It relies on `coerceCosmosChainAddress` to throw if `destination` has another namespace.
989
-
990
1301
  const cosmosDest = chainHub.coerceCosmosAddress(destination);
991
-
992
1302
  const { helper } = this.facets;
993
1303
  const token = helper.amountToCoin(amount);
994
1304
 
995
1305
  const connectionInfoV = watch(
996
- chainHub.getConnectionInfo(
997
- this.state.chainAddress.chainId,
998
- cosmosDest.chainId,
999
- ),
1306
+ chainHub.getConnectionInfo(this.state.chainAddress, cosmosDest),
1000
1307
  );
1001
1308
 
1002
- // Resolves when host chain successfully submits, but not when
1003
- // the receiving chain acknowledges.
1004
- // See https://github.com/Agoric/agoric-sdk/issues/9784 for a
1005
- // solution that tracks the acknowledgement on the receiving chain.
1006
1309
  return watch(
1007
- allVows([
1008
- connectionInfoV,
1009
- timestampHelper.vowOrValueFromOpts(opts),
1010
- ]),
1011
- this.facets.transferWatcher,
1310
+ allVows(
1311
+ /** @type {const} */ ([
1312
+ connectionInfoV,
1313
+ timestampHelper.vowOrValueFromOpts(opts),
1314
+ ]),
1315
+ ),
1316
+ this.facets.beginTransferWatcher,
1012
1317
  { opts, token, destination: cosmosDest },
1013
1318
  );
1014
1319
  });
@@ -1026,10 +1331,10 @@ export const prepareCosmosOrchestrationAccountKit = (
1026
1331
  },
1027
1332
 
1028
1333
  /** @type {HostOf<StakingAccountActions['undelegate']>} */
1029
- undelegate(delegations) {
1334
+ undelegate(delegations, opts) {
1030
1335
  return asVow(() => {
1031
1336
  trace('undelegate', delegations);
1032
- const { helper } = this.facets;
1337
+ const { holder } = this.facets;
1033
1338
  const { chainAddress } = this.state;
1034
1339
 
1035
1340
  delegations.every(d =>
@@ -1037,7 +1342,7 @@ export const prepareCosmosOrchestrationAccountKit = (
1037
1342
  ) || Fail`Some delegation record is for another delegator`;
1038
1343
 
1039
1344
  const undelegateV = watch(
1040
- E(helper.owned()).executeEncodedTx(
1345
+ holder.executeTxProto3(
1041
1346
  delegations.map(({ validator, amount }) =>
1042
1347
  Any.toJSON(
1043
1348
  MsgUndelegate.toProtoMsg({
@@ -1047,23 +1352,23 @@ export const prepareCosmosOrchestrationAccountKit = (
1047
1352
  }),
1048
1353
  ),
1049
1354
  ),
1355
+ opts,
1050
1356
  ),
1051
- this.facets.undelegateWatcher,
1357
+ this.facets.decodedUndelegateWatcher,
1052
1358
  );
1053
1359
  return watch(undelegateV, this.facets.returnVoidWatcher);
1054
1360
  });
1055
1361
  },
1056
- /** @type {HostOf<IcaAccount['deactivate']>} */
1362
+ /** @type {HostOf<IcaAccountMethods['deactivate']>} */
1057
1363
  deactivate() {
1058
1364
  return asVow(() => watch(E(this.facets.helper.owned()).deactivate()));
1059
1365
  },
1060
- /** @type {HostOf<IcaAccount['reactivate']>} */
1366
+ /** @type {HostOf<IcaAccountMethods['reactivate']>} */
1061
1367
  reactivate() {
1062
1368
  return asVow(() => watch(E(this.facets.helper.owned()).reactivate()));
1063
1369
  },
1064
1370
  /** @type {HostOf<StakingAccountQueries['getDelegation']>} */
1065
- getDelegation(validator) {
1066
- // @ts-expect-error XXX string template with generics
1371
+ getDelegation(validator, opts) {
1067
1372
  return asVow(() => {
1068
1373
  trace('getDelegation', validator);
1069
1374
  const { chainAddress, icqConnection } = this.state;
@@ -1076,14 +1381,14 @@ export const prepareCosmosOrchestrationAccountKit = (
1076
1381
  delegatorAddr: chainAddress.value,
1077
1382
  validatorAddr: validator.value,
1078
1383
  }),
1384
+ opts?.queryOpts,
1079
1385
  ),
1080
1386
  ]);
1081
1387
  return watch(results, this.facets.delegationQueryWatcher);
1082
1388
  });
1083
1389
  },
1084
1390
  /** @type {HostOf<StakingAccountQueries['getDelegations']>} */
1085
- getDelegations() {
1086
- // @ts-expect-error XXX string template with generics
1391
+ getDelegations(opts) {
1087
1392
  return asVow(() => {
1088
1393
  trace('getDelegations');
1089
1394
  const { chainAddress, icqConnection } = this.state;
@@ -1095,13 +1400,14 @@ export const prepareCosmosOrchestrationAccountKit = (
1095
1400
  QueryDelegatorDelegationsRequest.toProtoMsg({
1096
1401
  delegatorAddr: chainAddress.value,
1097
1402
  }),
1403
+ opts?.queryOpts,
1098
1404
  ),
1099
1405
  ]);
1100
1406
  return watch(results, this.facets.delegationsQueryWatcher);
1101
1407
  });
1102
1408
  },
1103
1409
  /** @type {HostOf<StakingAccountQueries['getUnbondingDelegation']>} */
1104
- getUnbondingDelegation(validator) {
1410
+ getUnbondingDelegation(validator, opts) {
1105
1411
  return asVow(() => {
1106
1412
  trace('getUnbondingDelegation', validator);
1107
1413
  const { chainAddress, icqConnection } = this.state;
@@ -1114,13 +1420,14 @@ export const prepareCosmosOrchestrationAccountKit = (
1114
1420
  delegatorAddr: chainAddress.value,
1115
1421
  validatorAddr: validator.value,
1116
1422
  }),
1423
+ opts?.queryOpts,
1117
1424
  ),
1118
1425
  ]);
1119
1426
  return watch(results, this.facets.unbondingDelegationQueryWatcher);
1120
1427
  });
1121
1428
  },
1122
1429
  /** @type {HostOf<StakingAccountQueries['getUnbondingDelegations']>} */
1123
- getUnbondingDelegations() {
1430
+ getUnbondingDelegations(opts) {
1124
1431
  return asVow(() => {
1125
1432
  trace('getUnbondingDelegations');
1126
1433
  const { chainAddress, icqConnection } = this.state;
@@ -1132,13 +1439,14 @@ export const prepareCosmosOrchestrationAccountKit = (
1132
1439
  QueryDelegatorUnbondingDelegationsRequest.toProtoMsg({
1133
1440
  delegatorAddr: chainAddress.value,
1134
1441
  }),
1442
+ opts?.queryOpts,
1135
1443
  ),
1136
1444
  ]);
1137
1445
  return watch(results, this.facets.unbondingDelegationsQueryWatcher);
1138
1446
  });
1139
1447
  },
1140
1448
  /** @type {HostOf<StakingAccountQueries['getRedelegations']>} */
1141
- getRedelegations() {
1449
+ getRedelegations(opts) {
1142
1450
  return asVow(() => {
1143
1451
  trace('getRedelegations');
1144
1452
  const { chainAddress, icqConnection } = this.state;
@@ -1153,13 +1461,14 @@ export const prepareCosmosOrchestrationAccountKit = (
1153
1461
  dstValidatorAddr: '',
1154
1462
  srcValidatorAddr: '',
1155
1463
  }),
1464
+ opts?.queryOpts,
1156
1465
  ),
1157
1466
  ]);
1158
1467
  return watch(results, this.facets.redelegationsQueryWatcher);
1159
1468
  });
1160
1469
  },
1161
1470
  /** @type {HostOf<StakingAccountQueries['getReward']>} */
1162
- getReward(validator) {
1471
+ getReward(validator, opts) {
1163
1472
  return asVow(() => {
1164
1473
  trace('getReward', validator);
1165
1474
  const { chainAddress, icqConnection } = this.state;
@@ -1172,14 +1481,14 @@ export const prepareCosmosOrchestrationAccountKit = (
1172
1481
  delegatorAddress: chainAddress.value,
1173
1482
  validatorAddress: validator.value,
1174
1483
  }),
1484
+ opts?.queryOpts,
1175
1485
  ),
1176
1486
  ]);
1177
1487
  return watch(results, this.facets.rewardQueryWatcher);
1178
1488
  });
1179
1489
  },
1180
1490
  /** @type {HostOf<StakingAccountQueries['getRewards']>} */
1181
- getRewards() {
1182
- // @ts-expect-error XXX string template with generics
1491
+ getRewards(opts) {
1183
1492
  return asVow(() => {
1184
1493
  trace('getRewards');
1185
1494
  const { chainAddress, icqConnection } = this.state;
@@ -1191,24 +1500,94 @@ export const prepareCosmosOrchestrationAccountKit = (
1191
1500
  QueryDelegationTotalRewardsRequest.toProtoMsg({
1192
1501
  delegatorAddress: chainAddress.value,
1193
1502
  }),
1503
+ opts?.queryOpts,
1194
1504
  ),
1195
1505
  ]);
1196
1506
  return watch(results, this.facets.rewardsQueryWatcher);
1197
1507
  });
1198
1508
  },
1199
- /** @type {HostOf<IcaAccount['executeEncodedTx']>} */
1200
- executeEncodedTx(msgs, opts) {
1201
- return asVow(() =>
1202
- watch(E(this.facets.helper.owned()).executeEncodedTx(msgs, opts)),
1509
+ /** @type {HostOf<IcaAccountMethods['executeEncodedTx']>} */
1510
+ executeEncodedTx(msgs, opts = {}) {
1511
+ return asVow(() => {
1512
+ const { progressTracker } = opts;
1513
+ const { helper } = this.facets;
1514
+ const acct = helper.owned();
1515
+
1516
+ if (progressTracker) {
1517
+ const { chainAddress } = this.state;
1518
+ const agoric = chainHub.getChainInfo('agoric');
1519
+ const la = E(acct).getLocalAddress();
1520
+ /** @type {CaipChainId} */
1521
+ const dstChain = `cosmos:${chainAddress.chainId}`;
1522
+ const ra = E(acct).getRemoteAddress();
1523
+ // Identify this as an ICA operation.
1524
+ const priorReport = progressTracker.getCurrentProgressReport();
1525
+ const { traffic, slice: trafficSlice } = addTrafficEntries(
1526
+ priorReport.traffic,
1527
+ trafficTransforms.IbcICA.start(dstChain),
1528
+ );
1529
+ const report = {
1530
+ ...priorReport,
1531
+ traffic,
1532
+ };
1533
+
1534
+ progressTracker.update(harden(report));
1535
+ // Update the report when we can.
1536
+ void watch(
1537
+ allVows(/** @type {const} */ ([agoric, la, ra])),
1538
+ this.facets.updateTxProgressWatcher,
1539
+ { progressTracker, protocol: 'ibc', trafficSlice },
1540
+ );
1541
+ }
1542
+ return E(acct).executeEncodedTx(msgs, opts);
1543
+ });
1544
+ },
1545
+ /** @type {HostOf<IcaAccountMethods['executeTxProto3Undecoded']>} */
1546
+ executeTxProto3Undecoded(msgs, opts = {}) {
1547
+ const { holder } = this.facets;
1548
+ const { txOpts, ...restOpts } = opts;
1549
+ return holder.executeEncodedTx(msgs, {
1550
+ ...restOpts,
1551
+ ...txOpts,
1552
+ });
1553
+ },
1554
+ /**
1555
+ * @template {readonly (keyof TypeFromUrl | unknown)[]} TUS
1556
+ * @param {{
1557
+ * readonly [K in keyof TUS]: AnyJson<TUS[K]>;
1558
+ * }} msgs
1559
+ * @param {CosmosActionOptions} [opts]
1560
+ * @returns {Vow<{
1561
+ * [K in keyof TUS]: MessageBody<ResponseTypeUrl<TUS[K]>>;
1562
+ * }>}
1563
+ */
1564
+ executeTxProto3(msgs, opts = {}) {
1565
+ const { holder } = this.facets;
1566
+
1567
+ const typeUrls = /** @type {{ [K in keyof TUS]: TUS[K] }} */ (
1568
+ msgs.map(m => m.typeUrl)
1569
+ );
1570
+
1571
+ const decodedResult = watch(
1572
+ holder.executeTxProto3Undecoded(msgs, opts),
1573
+ this.facets.decodeResponsesWatcher,
1574
+ typeUrls,
1203
1575
  );
1576
+
1577
+ /**
1578
+ * @typedef {Vow<{
1579
+ * [K in keyof TUS]: MessageBody<ResponseTypeUrl<TUS[K]>>;
1580
+ * }>} Result
1581
+ */
1582
+ return /** @type {Result} */ (decodedResult);
1204
1583
  },
1205
1584
  /**
1206
1585
  * @type {HostOf<NobleMethods['depositForBurn']>}
1207
1586
  */
1208
- depositForBurn(destination, amount, caller) {
1587
+ depositForBurn(destination, amount, caller, opts = {}) {
1588
+ trace('depositForBurn', { destination, amount });
1209
1589
  return asVow(() => {
1210
- trace('depositForBurn', { destination, amount });
1211
- const { helper } = this.facets;
1590
+ const { helper, holder } = this.facets;
1212
1591
  const { chainAddress } = this.state;
1213
1592
 
1214
1593
  const destParts = parseAccountId(destination);
@@ -1221,7 +1600,7 @@ export const prepareCosmosOrchestrationAccountKit = (
1221
1600
  throw Fail`${q(chainId)} does not have "cctpDestinationDomain" set in ChainInfo`;
1222
1601
  }
1223
1602
 
1224
- /** @satisfies {MsgDepositForBurnType} */
1603
+ /** @satisfies {Partial<MsgDepositForBurnType>} */
1225
1604
  const depositForBurn = {
1226
1605
  amount: helper.amountToCoin(amount)?.amount,
1227
1606
  from: chainAddress.value,
@@ -1239,8 +1618,8 @@ export const prepareCosmosOrchestrationAccountKit = (
1239
1618
  return accountIdTo32Bytes(caller);
1240
1619
  })();
1241
1620
 
1242
- return watch(
1243
- E(helper.owned()).executeEncodedTx([
1621
+ const result = holder.executeTxProto3(
1622
+ [
1244
1623
  Any.toJSON(
1245
1624
  destinationCaller
1246
1625
  ? MsgDepositForBurnWithCaller.toProtoMsg({
@@ -1249,9 +1628,10 @@ export const prepareCosmosOrchestrationAccountKit = (
1249
1628
  })
1250
1629
  : MsgDepositForBurn.toProtoMsg(depositForBurn),
1251
1630
  ),
1252
- ]),
1253
- this.facets.returnVoidWatcher,
1631
+ ],
1632
+ opts,
1254
1633
  );
1634
+ return helper.pickVowIndex(result, 0);
1255
1635
  });
1256
1636
  },
1257
1637
  },
@@ -1271,6 +1651,7 @@ export const prepareCosmosOrchestrationAccountKit = (
1271
1651
  * @param {Zone} zone
1272
1652
  * @param {object} powers
1273
1653
  * @param {ChainHub} powers.chainHub
1654
+ * @param {MakeProgressTracker} powers.makeProgressTracker
1274
1655
  * @param {MakeRecorderKit} powers.makeRecorderKit
1275
1656
  * @param {Remote<TimerService>} powers.timerService
1276
1657
  * @param {VowTools} powers.vowTools
@@ -1283,10 +1664,18 @@ export const prepareCosmosOrchestrationAccountKit = (
1283
1664
  */
1284
1665
  export const prepareCosmosOrchestrationAccount = (
1285
1666
  zone,
1286
- { chainHub, makeRecorderKit, timerService, vowTools, zcf },
1667
+ {
1668
+ chainHub,
1669
+ makeProgressTracker,
1670
+ makeRecorderKit,
1671
+ timerService,
1672
+ vowTools,
1673
+ zcf,
1674
+ },
1287
1675
  ) => {
1288
1676
  const makeKit = prepareCosmosOrchestrationAccountKit(zone, {
1289
1677
  chainHub,
1678
+ makeProgressTracker,
1290
1679
  makeRecorderKit,
1291
1680
  timerService,
1292
1681
  vowTools,