@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.
- package/index.js +0 -4
- package/package.json +27 -27
- package/src/axelar-types.d.ts +2 -0
- package/src/axelar-types.d.ts.map +1 -1
- package/src/axelar-types.js +2 -0
- package/src/cctp-chain-info.js +4 -1
- package/src/chain-info.d.ts +21 -6
- package/src/chain-info.d.ts.map +1 -1
- package/src/chain-info.js +9 -8
- package/src/cosmos-api.d.ts +102 -29
- package/src/cosmos-api.d.ts.map +1 -1
- package/src/cosmos-api.js +585 -0
- package/src/{ethereum-api.ts → ethereum-api.js} +1 -1
- package/src/examples/auto-stake-it-tap-kit.d.ts +4 -3
- package/src/examples/auto-stake-it-tap-kit.d.ts.map +1 -1
- package/src/examples/auto-stake-it-tap-kit.js +3 -4
- package/src/examples/auto-stake-it.contract.d.ts +6 -4
- package/src/examples/auto-stake-it.contract.d.ts.map +1 -1
- package/src/examples/auto-stake-it.contract.js +3 -1
- package/src/examples/auto-stake-it.flows.d.ts +2 -1
- package/src/examples/auto-stake-it.flows.d.ts.map +1 -1
- package/src/examples/auto-stake-it.flows.js +1 -0
- package/src/examples/axelar-gmp-account-kit.d.ts +6 -4
- package/src/examples/axelar-gmp-account-kit.d.ts.map +1 -1
- package/src/examples/axelar-gmp-account-kit.js +4 -2
- package/src/examples/axelar-gmp.contract.d.ts +8 -8
- package/src/examples/axelar-gmp.contract.d.ts.map +1 -1
- package/src/examples/axelar-gmp.contract.js +2 -2
- package/src/examples/axelar-gmp.flows.d.ts +1 -1
- package/src/examples/basic-flows.contract.d.ts +7 -5
- package/src/examples/basic-flows.contract.d.ts.map +1 -1
- package/src/examples/basic-flows.contract.js +3 -1
- package/src/examples/basic-flows.flows.d.ts +2 -1
- package/src/examples/basic-flows.flows.d.ts.map +1 -1
- package/src/examples/basic-flows.flows.js +1 -0
- package/src/examples/send-anywhere.contract.d.ts +12 -6
- package/src/examples/send-anywhere.contract.d.ts.map +1 -1
- package/src/examples/send-anywhere.contract.js +4 -1
- package/src/examples/send-anywhere.flows.d.ts +3 -2
- package/src/examples/send-anywhere.flows.d.ts.map +1 -1
- package/src/examples/send-anywhere.flows.js +3 -6
- package/src/examples/stake-bld.contract.d.ts +206 -25
- package/src/examples/stake-bld.contract.d.ts.map +1 -1
- package/src/examples/stake-bld.contract.js +19 -4
- package/src/examples/stake-ica.contract.d.ts +434 -71
- package/src/examples/stake-ica.contract.d.ts.map +1 -1
- package/src/examples/stake-ica.contract.js +28 -6
- package/src/examples/staking-combinations.contract.d.ts +4 -2
- package/src/examples/staking-combinations.contract.d.ts.map +1 -1
- package/src/examples/staking-combinations.contract.js +5 -3
- package/src/examples/staking-combinations.flows.d.ts +3 -2
- package/src/examples/staking-combinations.flows.d.ts.map +1 -1
- package/src/examples/staking-combinations.flows.js +7 -6
- package/src/examples/swap-anything.contract.d.ts +14 -7
- package/src/examples/swap-anything.contract.d.ts.map +1 -1
- package/src/examples/swap-anything.contract.js +12 -8
- package/src/examples/swap.contract.d.ts +18 -6
- package/src/examples/swap.contract.d.ts.map +1 -1
- package/src/examples/swap.contract.js +9 -3
- package/src/examples/swap.flows.d.ts +2 -0
- package/src/examples/swap.flows.d.ts.map +1 -1
- package/src/examples/swap.flows.js +2 -0
- package/src/examples/unbond.contract.d.ts +7 -4
- package/src/examples/unbond.contract.d.ts.map +1 -1
- package/src/examples/unbond.contract.js +6 -3
- package/src/exos/chain-hub-admin.d.ts +1 -19
- package/src/exos/chain-hub-admin.d.ts.map +1 -1
- package/src/exos/chain-hub-admin.js +1 -1
- package/src/exos/chain-hub.d.ts +4 -2
- package/src/exos/chain-hub.d.ts.map +1 -1
- package/src/exos/chain-hub.js +2 -1
- package/src/exos/combine-invitation-makers.d.ts +2 -1
- package/src/exos/combine-invitation-makers.d.ts.map +1 -1
- package/src/exos/combine-invitation-makers.js +2 -1
- package/src/exos/cosmos-orchestration-account.d.ts +615 -98
- package/src/exos/cosmos-orchestration-account.d.ts.map +1 -1
- package/src/exos/cosmos-orchestration-account.js +695 -306
- package/src/exos/exo-interfaces.js +35 -0
- package/src/exos/ibc-packet.d.ts +11 -9
- package/src/exos/ibc-packet.d.ts.map +1 -1
- package/src/exos/ibc-packet.js +33 -8
- package/src/exos/ica-account-kit.d.ts +4 -9
- package/src/exos/ica-account-kit.d.ts.map +1 -1
- package/src/exos/ica-account-kit.js +10 -7
- package/src/exos/icq-connection-kit.d.ts +1 -1
- package/src/exos/local-chain-facade.d.ts +1542 -5
- package/src/exos/local-chain-facade.d.ts.map +1 -1
- package/src/exos/local-chain-facade.js +4 -2
- package/src/exos/local-orchestration-account.d.ts +201 -56
- package/src/exos/local-orchestration-account.d.ts.map +1 -1
- package/src/exos/local-orchestration-account.js +260 -51
- package/src/exos/orchestrator.d.ts +35813 -73
- package/src/exos/orchestrator.d.ts.map +1 -1
- package/src/exos/orchestrator.js +7 -10
- package/src/exos/packet-tools.d.ts +19 -8
- package/src/exos/packet-tools.d.ts.map +1 -1
- package/src/exos/packet-tools.js +92 -9
- package/src/exos/portfolio-holder-kit.d.ts +90 -2
- package/src/exos/portfolio-holder-kit.d.ts.map +1 -1
- package/src/exos/remote-chain-facade.d.ts +1499 -1
- package/src/exos/remote-chain-facade.d.ts.map +1 -1
- package/src/exos/remote-chain-facade.js +8 -3
- package/src/facade.d.ts +1 -0
- package/src/facade.d.ts.map +1 -1
- package/src/facade.js +4 -6
- package/src/fixtures/query-flows.contract.d.ts +8 -6
- package/src/fixtures/query-flows.contract.d.ts.map +1 -1
- package/src/fixtures/query-flows.contract.js +3 -1
- package/src/fixtures/query-flows.flows.d.ts +1 -0
- package/src/fixtures/query-flows.flows.d.ts.map +1 -1
- package/src/fixtures/query-flows.flows.js +1 -0
- package/src/orchestration-api.d.ts +46 -16
- package/src/orchestration-api.d.ts.map +1 -1
- package/src/orchestration-api.js +410 -0
- package/src/proposals/init-chain-info.js +10 -2
- package/src/proposals/orchestration-proposal.js +3 -0
- package/src/proposals/revise-chain-info.js +4 -1
- package/src/proposals/start-auto-stake-it.js +1 -0
- package/src/proposals/start-axelar-gmp.js +2 -2
- package/src/proposals/start-basic-flows.js +5 -0
- package/src/proposals/start-send-anywhere.js +4 -2
- package/src/proposals/start-stakeAtom.js +5 -4
- package/src/proposals/start-stakeBld.js +8 -6
- package/src/proposals/start-stakeOsmo.js +5 -4
- package/src/proposals/start-swap-anything.js +4 -2
- package/src/stubs/{viem-abi.d.ts → viem-typedData.js} +10 -4
- package/src/typeGuards.d.ts +38 -5
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +92 -22
- package/src/types.d.ts +1 -0
- package/src/types.d.ts.map +1 -1
- package/src/types.js +27 -0
- package/src/utils/abitype.d.ts +6 -0
- package/src/utils/abitype.d.ts.map +1 -0
- package/src/utils/abitype.js +13 -0
- package/src/utils/address.d.ts +3 -1
- package/src/utils/address.d.ts.map +1 -1
- package/src/utils/address.js +24 -2
- package/src/utils/agd-lib.d.ts +1 -51
- package/src/utils/agd-lib.d.ts.map +1 -1
- package/src/utils/agd-lib.js +1 -1
- package/src/utils/amounts.d.ts +1 -0
- package/src/utils/amounts.d.ts.map +1 -1
- package/src/utils/amounts.js +1 -0
- package/src/utils/asset.d.ts +1 -0
- package/src/utils/asset.d.ts.map +1 -1
- package/src/utils/asset.js +1 -0
- package/src/utils/chain-hub-helper.d.ts +1 -0
- package/src/utils/chain-hub-helper.d.ts.map +1 -1
- package/src/utils/chain-hub-helper.js +1 -0
- package/src/utils/codecs.d.ts +145 -0
- package/src/utils/codecs.d.ts.map +1 -0
- package/src/utils/codecs.js +206 -0
- package/src/utils/cosmos.d.ts +5 -4
- package/src/utils/cosmos.d.ts.map +1 -1
- package/src/utils/cosmos.js +29 -9
- package/src/utils/exo-helpers.d.ts +156 -0
- package/src/utils/exo-helpers.d.ts.map +1 -0
- package/src/utils/exo-helpers.js +241 -0
- package/src/utils/gmp.d.ts +2 -2
- package/src/utils/gmp.d.ts.map +1 -1
- package/src/utils/gmp.js +31 -15
- package/src/utils/orchestrationAccount.d.ts +79 -0
- package/src/utils/orchestrationAccount.d.ts.map +1 -1
- package/src/utils/orchestrationAccount.js +210 -6
- package/src/utils/packet.d.ts.map +1 -1
- package/src/utils/packet.js +5 -0
- package/src/utils/permit2/signatureTransfer.d.ts +221 -0
- package/src/utils/permit2/signatureTransfer.d.ts.map +1 -0
- package/src/utils/permit2/signatureTransfer.js +265 -0
- package/src/utils/permit2/signatureTransferHelpers.d.ts +334 -0
- package/src/utils/permit2/signatureTransferHelpers.d.ts.map +1 -0
- package/src/utils/permit2/signatureTransferHelpers.js +270 -0
- package/src/utils/permit2.d.ts +11 -0
- package/src/utils/permit2.d.ts.map +1 -0
- package/src/utils/permit2.js +11 -0
- package/src/utils/progress.d.ts +41 -0
- package/src/utils/progress.d.ts.map +1 -0
- package/src/utils/progress.js +180 -0
- package/src/utils/start-helper.d.ts +28 -10
- package/src/utils/start-helper.d.ts.map +1 -1
- package/src/utils/start-helper.js +30 -7
- package/src/utils/time.d.ts +2 -2
- package/src/utils/time.d.ts.map +1 -1
- package/src/utils/time.js +1 -1
- package/src/utils/viem-utils/hashTypedData.d.ts +21 -0
- package/src/utils/viem-utils/hashTypedData.d.ts.map +1 -0
- package/src/utils/viem-utils/hashTypedData.js +61 -0
- package/src/utils/viem-utils/types.d.ts +6 -0
- package/src/utils/viem-utils/types.d.ts.map +1 -0
- package/src/utils/viem-utils/types.js +18 -0
- package/src/utils/viem.d.ts +11 -0
- package/src/utils/viem.d.ts.map +1 -0
- package/src/utils/viem.js +11 -0
- package/src/utils/zcf-tools.d.ts +15 -1
- package/src/utils/zcf-tools.d.ts.map +1 -1
- package/src/utils/zcf-tools.js +19 -3
- package/src/utils/zoe-tools.d.ts +5 -2
- package/src/utils/zoe-tools.d.ts.map +1 -1
- package/src/utils/zoe-tools.js +8 -2
- package/src/vat-orchestration.d.ts +5 -3
- package/src/vat-orchestration.d.ts.map +1 -1
- package/src/vat-orchestration.js +4 -3
- package/src/vendor/viem/{_esm-YOAV66U4.js → _esm-OKAICHVC.js} +2 -2
- package/src/vendor/viem/{ccip-AAQDZF3N.js → ccip-34BSSMV5.js} +1 -2
- package/src/vendor/viem/{chunk-4EF4K2MH.js → chunk-GCI53Z2G.js} +35 -1
- package/src/vendor/viem/chunk-ZKSIP2AM.js +326 -0
- package/src/vendor/viem/viem-abi.js +2 -2
- package/src/vendor/viem/viem-typedData.d.ts +19 -0
- package/src/vendor/viem/viem-typedData.js +59 -0
- package/tools/contract-tests.d.ts +34 -19
- package/tools/contract-tests.d.ts.map +1 -1
- package/tools/contract-tests.ts +15 -3
- package/tools/ibc-mock-fixtures.d.ts +49 -0
- package/tools/ibc-mock-fixtures.d.ts.map +1 -0
- package/tools/ibc-mock-fixtures.ts +161 -0
- package/tools/ibc-mocks.d.ts +2 -3
- package/tools/ibc-mocks.d.ts.map +1 -1
- package/tools/ibc-mocks.ts +2 -1
- package/tools/make-test-address.d.ts +1 -1
- package/tools/make-test-address.d.ts.map +1 -1
- package/tools/make-test-address.js +1 -2
- package/tools/network-fakes.d.ts +142 -0
- package/tools/network-fakes.d.ts.map +1 -0
- package/tools/network-fakes.ts +388 -0
- package/tsup.config.ts +3 -1
- package/src/cosmos-api.ts +0 -469
- package/src/exos/exo-interfaces.ts +0 -35
- package/src/orchestration-api.ts +0 -365
- package/src/stubs/viem-abi.d.ts.map +0 -1
- package/src/types.ts +0 -26
- package/src/vendor/viem/chunk-XN4LUOIH.js +0 -253
- package/src/vendor/viem/secp256k1-WHBDSQB2.js +0 -1914
- /package/src/stubs/{viem-abi.ts → viem-abi.js} +0 -0
|
@@ -9,7 +9,10 @@ import { E } from '@endo/far';
|
|
|
9
9
|
import { Fail, q } from '@endo/errors';
|
|
10
10
|
|
|
11
11
|
import { MsgTransfer as MsgTransferType } from '@agoric/cosmic-proto/ibc/applications/transfer/v1/tx.js';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
QueryDenomHashRequest as QueryDenomHashRequestType,
|
|
14
|
+
QueryDenomHashResponse as QueryDenomHashResponseType,
|
|
15
|
+
} from '@agoric/cosmic-proto/ibc/applications/transfer/v1/query.js';
|
|
13
16
|
import {
|
|
14
17
|
QueryAllBalancesRequest as QueryAllBalancesRequestType,
|
|
15
18
|
QueryBalanceRequest as QueryBalanceRequestType,
|
|
@@ -29,15 +32,24 @@ import {
|
|
|
29
32
|
TypedJsonShape,
|
|
30
33
|
} from '../typeGuards.js';
|
|
31
34
|
import { maxClockSkew, toDenomAmount } from '../utils/cosmos.js';
|
|
32
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
addTrafficEntries,
|
|
37
|
+
orchestrationAccountMethods,
|
|
38
|
+
trafficTransforms,
|
|
39
|
+
} from '../utils/orchestrationAccount.js';
|
|
40
|
+
import { makeVowExoHelpers } from '../utils/exo-helpers.js';
|
|
33
41
|
import { makeTimestampHelper } from '../utils/time.js';
|
|
34
42
|
import { preparePacketTools } from './packet-tools.js';
|
|
35
43
|
import { prepareIBCTools } from './ibc-packet.js';
|
|
36
44
|
import { coerceCoin, coerceDenomAmount } from '../utils/amounts.js';
|
|
37
45
|
import { TransferRouteShape } from './chain-hub.js';
|
|
46
|
+
import { chainOfAccount } from '../utils/address.js';
|
|
47
|
+
|
|
48
|
+
const { details: X } = assert;
|
|
38
49
|
|
|
39
50
|
const MsgTransfer = CodecHelper(MsgTransferType);
|
|
40
51
|
const QueryDenomHashRequest = CodecHelper(QueryDenomHashRequestType);
|
|
52
|
+
const QueryDenomHashResponse = CodecHelper(QueryDenomHashResponseType);
|
|
41
53
|
const QueryAllBalancesRequest = CodecHelper(QueryAllBalancesRequestType);
|
|
42
54
|
const QueryBalanceRequest = CodecHelper(QueryBalanceRequestType);
|
|
43
55
|
const MsgDelegate = CodecHelper(MsgDelegateType);
|
|
@@ -45,9 +57,11 @@ const MsgUndelegate = CodecHelper(MsgUndelegateType);
|
|
|
45
57
|
const MsgSend = CodecHelper(MsgSendType);
|
|
46
58
|
|
|
47
59
|
/**
|
|
48
|
-
* @import {HostOf} from '@agoric/async-flow';
|
|
60
|
+
* @import {HostInterface, HostOf} from '@agoric/async-flow';
|
|
49
61
|
* @import {LocalChain, LocalChainAccount} from '@agoric/vats/src/localchain.js';
|
|
50
|
-
* @import {AmountArg, CosmosChainAddress, DenomAmount, IBCMsgTransferOptions,
|
|
62
|
+
* @import {AmountArg, CosmosChainAddress, DenomAmount, IBCMsgTransferOptions,
|
|
63
|
+
* OrchestrationAccountCommon, LocalAccountMethods, TransferRoute,
|
|
64
|
+
* AccountIdArg, Denom, IBCConnectionInfo, ChainInfo, CosmosChainInfo} from '@agoric/orchestration';
|
|
51
65
|
* @import {OfferHandler, ZCF, ZCFSeat} from '@agoric/zoe';
|
|
52
66
|
* @import {IBCEvent} from '@agoric/vats';
|
|
53
67
|
* @import {QueryDenomHashResponse} from '@agoric/cosmic-proto/ibc/applications/transfer/v1/query.js';
|
|
@@ -63,8 +77,26 @@ const MsgSend = CodecHelper(MsgSendType);
|
|
|
63
77
|
* @import {Matcher} from '@endo/patterns';
|
|
64
78
|
* @import {ChainHub} from './chain-hub.js';
|
|
65
79
|
* @import {PacketTools} from './packet-tools.js';
|
|
80
|
+
* @import {SliceDescriptor} from '../utils/orchestrationAccount.js';
|
|
66
81
|
* @import {ZoeTools} from '../utils/zoe-tools.js';
|
|
82
|
+
* @import {MakeProgressTracker} from '../utils/progress.js';
|
|
83
|
+
* @import {Amount} from '@agoric/ertp';
|
|
84
|
+
* @import {StorageNode} from '@agoric/internal/src/lib-chainStorage.js';
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Watcher facets of the exoClassKit that have been removed from service, but
|
|
89
|
+
* need to leave behind a dummy facet to allow older contracts that use
|
|
90
|
+
* orchestration to be upgraded.
|
|
91
|
+
*
|
|
92
|
+
* Add new watchers here as they are removed from service. Maybe someday
|
|
93
|
+
* contract upgrade will allow us to prune this list.
|
|
67
94
|
*/
|
|
95
|
+
const TOMBSTONED_WATCHERS = /** @type {const} */ (
|
|
96
|
+
[
|
|
97
|
+
// 'transferWithMetaWatcher', // deprecated but not yet tombstoned
|
|
98
|
+
]
|
|
99
|
+
);
|
|
68
100
|
|
|
69
101
|
const trace = makeTracer('LocalOrchAccount');
|
|
70
102
|
|
|
@@ -72,6 +104,22 @@ const { Vow$ } = NetworkShape; // TODO #9611
|
|
|
72
104
|
|
|
73
105
|
const EVow$ = shape => M.or(Vow$(shape), M.promise(/* shape */));
|
|
74
106
|
|
|
107
|
+
/**
|
|
108
|
+
* @template {string} TU
|
|
109
|
+
* @param {{ error?: string; reply: TypedJson<TU> }[] | TypedJson<TU>} result
|
|
110
|
+
* @returns {{ error?: string; reply: TypedJson<TU> }}
|
|
111
|
+
*/
|
|
112
|
+
const extractFirstQueryResult = result => {
|
|
113
|
+
if (Array.isArray(result)) {
|
|
114
|
+
assert(
|
|
115
|
+
result.length > 0,
|
|
116
|
+
X`Expected result to be a nonempty array, got ${result}`,
|
|
117
|
+
);
|
|
118
|
+
return result[0];
|
|
119
|
+
}
|
|
120
|
+
return { reply: result };
|
|
121
|
+
};
|
|
122
|
+
|
|
75
123
|
/**
|
|
76
124
|
* @typedef {object} LocalChainAccountNotification
|
|
77
125
|
* @property {string} address
|
|
@@ -97,7 +145,7 @@ const HolderI = M.interface('holder', {
|
|
|
97
145
|
executeTx: M.call(M.arrayOf(M.record())).returns(Vow$(M.record())),
|
|
98
146
|
sendThenWaitForAck: M.call(EVow$(M.remotable('PacketSender')))
|
|
99
147
|
.optional(M.any())
|
|
100
|
-
.returns(EVow$(M.
|
|
148
|
+
.returns(EVow$(M.any())),
|
|
101
149
|
matchFirstPacket: M.call(M.any()).returns(EVow$(M.any())),
|
|
102
150
|
monitorTransfers: M.call(M.remotable('TargetApp')).returns(EVow$(M.any())),
|
|
103
151
|
parseInboundTransfer: M.call(M.recordOf(M.string(), M.any())).returns(
|
|
@@ -115,6 +163,12 @@ const PUBLIC_TOPICS = {
|
|
|
115
163
|
account: ['Account holder status', M.any()],
|
|
116
164
|
};
|
|
117
165
|
|
|
166
|
+
/**
|
|
167
|
+
* @see {@link https://github.com/cosmos/ibc-go/blob/a24a6c6/modules/apps/transfer/types/errors.go#L13}
|
|
168
|
+
* a24a6c6 Feb 27, 2023
|
|
169
|
+
*/
|
|
170
|
+
const ErrTraceNotFound = 'denomination trace not found';
|
|
171
|
+
|
|
118
172
|
/**
|
|
119
173
|
* @param {Zone} zone
|
|
120
174
|
* @param {object} powers
|
|
@@ -125,11 +179,13 @@ const PUBLIC_TOPICS = {
|
|
|
125
179
|
* @param {ChainHub} powers.chainHub
|
|
126
180
|
* @param {Remote<LocalChain>} powers.localchain
|
|
127
181
|
* @param {ZoeTools} powers.zoeTools
|
|
182
|
+
* @param {MakeProgressTracker} powers.makeProgressTracker
|
|
128
183
|
*/
|
|
129
184
|
export const prepareLocalOrchestrationAccountKit = (
|
|
130
185
|
zone,
|
|
131
186
|
{
|
|
132
187
|
makeRecorderKit,
|
|
188
|
+
makeProgressTracker,
|
|
133
189
|
zcf,
|
|
134
190
|
timerService,
|
|
135
191
|
vowTools,
|
|
@@ -139,6 +195,7 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
139
195
|
},
|
|
140
196
|
) => {
|
|
141
197
|
const { watch, asVow, when } = vowTools;
|
|
198
|
+
const vowExo = makeVowExoHelpers({ watch });
|
|
142
199
|
const { makeIBCTransferSender } = prepareIBCTools(
|
|
143
200
|
zone.subZone('ibcTools'),
|
|
144
201
|
vowTools,
|
|
@@ -153,7 +210,20 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
153
210
|
const makeLocalOrchestrationAccountKit = zone.exoClassKit(
|
|
154
211
|
'Local Orchestration Account Kit',
|
|
155
212
|
{
|
|
213
|
+
/** @deprecated replaced by transferWatcher */
|
|
214
|
+
transferWithMetaWatcher: M.interface('transferWatcher', {
|
|
215
|
+
onFulfilled: M.call([M.record(), M.record(), M.record(), M.nat()])
|
|
216
|
+
.optional({
|
|
217
|
+
opts: M.opt(IBCTransferOptionsShape),
|
|
218
|
+
route: TransferRouteShape,
|
|
219
|
+
})
|
|
220
|
+
.returns(Vow$(M.record())),
|
|
221
|
+
}),
|
|
222
|
+
/** Facets above this line are deprecated. */
|
|
223
|
+
...vowExo.makeTombstonedWatcherShapes(TOMBSTONED_WATCHERS),
|
|
224
|
+
...vowExo.watcherShapes,
|
|
156
225
|
helper: M.interface('helper', {
|
|
226
|
+
...vowExo.helperShapes,
|
|
157
227
|
amountToCoin: M.call(AmountArgShape).returns(M.record()),
|
|
158
228
|
}),
|
|
159
229
|
holder: HolderI,
|
|
@@ -165,9 +235,17 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
165
235
|
.returns(VowShape),
|
|
166
236
|
}),
|
|
167
237
|
transferWatcher: M.interface('transferWatcher', {
|
|
168
|
-
onFulfilled: M.call(M.
|
|
238
|
+
onFulfilled: M.call(M.array())
|
|
169
239
|
.optional({
|
|
170
|
-
opts: M.
|
|
240
|
+
opts: M.opt(IBCTransferOptionsShape),
|
|
241
|
+
route: TransferRouteShape,
|
|
242
|
+
})
|
|
243
|
+
.returns(Vow$(M.record())),
|
|
244
|
+
}),
|
|
245
|
+
transferConnectionWatcher: M.interface('transferConnectionWatcher', {
|
|
246
|
+
onFulfilled: M.call([M.record(), M.record(), M.nat()])
|
|
247
|
+
.optional({
|
|
248
|
+
opts: M.opt(IBCTransferOptionsShape),
|
|
171
249
|
route: TransferRouteShape,
|
|
172
250
|
})
|
|
173
251
|
.returns(Vow$(M.record())),
|
|
@@ -198,7 +276,7 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
198
276
|
),
|
|
199
277
|
}),
|
|
200
278
|
parseInboundTransferWatcher: M.interface('parseInboundTransferWatcher', {
|
|
201
|
-
onFulfilled: M.call(M.
|
|
279
|
+
onFulfilled: M.call(M.any(), M.record()).returns(M.record()),
|
|
202
280
|
onRejected: M.call(M.any(), M.record()).returns(M.record()),
|
|
203
281
|
}),
|
|
204
282
|
invitationMakers: M.interface('invitationMakers', {
|
|
@@ -234,7 +312,30 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
234
312
|
return { account, address, packetTools, topicKit };
|
|
235
313
|
},
|
|
236
314
|
{
|
|
315
|
+
/** @deprecated replaced by transferWatcher */
|
|
316
|
+
transferWithMetaWatcher: {
|
|
317
|
+
/**
|
|
318
|
+
* @param {readonly [
|
|
319
|
+
* ChainInfo,
|
|
320
|
+
* ChainInfo,
|
|
321
|
+
* Pick<IBCConnectionInfo, 'transferChannel'>,
|
|
322
|
+
* bigint,
|
|
323
|
+
* ]} details
|
|
324
|
+
* @param {{
|
|
325
|
+
* opts?: Omit<IBCMsgTransferOptions, 'forwardOpts'>;
|
|
326
|
+
* route: TransferRoute;
|
|
327
|
+
* }} ctx
|
|
328
|
+
*/
|
|
329
|
+
onFulfilled(details, ctx) {
|
|
330
|
+
const result = this.facets.transferWatcher.onFulfilled(details, ctx);
|
|
331
|
+
return harden({ result, meta: {} });
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
/** Facets above this line are deprecated. */
|
|
335
|
+
...vowExo.makeTombstonedWatcherShapes(TOMBSTONED_WATCHERS),
|
|
336
|
+
...vowExo.watchers,
|
|
237
337
|
helper: {
|
|
338
|
+
...vowExo.helper,
|
|
238
339
|
/**
|
|
239
340
|
* @param {AmountArg} amount
|
|
240
341
|
* @returns {Coin}
|
|
@@ -382,34 +483,83 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
382
483
|
);
|
|
383
484
|
},
|
|
384
485
|
},
|
|
486
|
+
transferConnectionWatcher: {
|
|
487
|
+
/**
|
|
488
|
+
* @param {readonly [CosmosChainInfo, CosmosChainInfo, bigint]} all
|
|
489
|
+
* @param {Record<string, any>} ctx
|
|
490
|
+
*/
|
|
491
|
+
onFulfilled([srcChainInfo, nextChainInfo, timeout], ctx) {
|
|
492
|
+
return watch(
|
|
493
|
+
vowTools.allVows(
|
|
494
|
+
/** @type {const} */ ([
|
|
495
|
+
srcChainInfo,
|
|
496
|
+
nextChainInfo,
|
|
497
|
+
chainHub.getConnectionInfo(srcChainInfo, nextChainInfo),
|
|
498
|
+
timeout,
|
|
499
|
+
]),
|
|
500
|
+
),
|
|
501
|
+
this.facets.transferWatcher,
|
|
502
|
+
ctx,
|
|
503
|
+
);
|
|
504
|
+
},
|
|
505
|
+
},
|
|
385
506
|
transferWatcher: {
|
|
386
507
|
/**
|
|
387
|
-
* @param {
|
|
508
|
+
* @param {readonly [
|
|
509
|
+
* ChainInfo,
|
|
510
|
+
* ChainInfo,
|
|
511
|
+
* Pick<IBCConnectionInfo, 'transferChannel'>,
|
|
512
|
+
* bigint,
|
|
513
|
+
* ]} details
|
|
388
514
|
* @param {{
|
|
389
515
|
* opts?: Omit<IBCMsgTransferOptions, 'forwardOpts'>;
|
|
390
516
|
* route: TransferRoute;
|
|
391
517
|
* }} ctx
|
|
392
518
|
*/
|
|
393
|
-
onFulfilled(
|
|
519
|
+
onFulfilled(
|
|
520
|
+
[srcChainInfo, dstChainInfo, { transferChannel }, timeoutTimestamp],
|
|
521
|
+
{ opts, route },
|
|
522
|
+
) {
|
|
394
523
|
const { forwardInfo, ...transferDetails } = route;
|
|
524
|
+
|
|
525
|
+
assert.equal(
|
|
526
|
+
transferDetails.sourcePort,
|
|
527
|
+
transferChannel.portId,
|
|
528
|
+
X`sourcePort ${q(
|
|
529
|
+
transferDetails.sourcePort,
|
|
530
|
+
)} must match the portId ${q(transferChannel.portId)}`,
|
|
531
|
+
);
|
|
532
|
+
assert.equal(
|
|
533
|
+
transferDetails.sourceChannel,
|
|
534
|
+
transferChannel.channelId,
|
|
535
|
+
X`sourceChannel ${q(
|
|
536
|
+
transferDetails.sourceChannel,
|
|
537
|
+
)} must match the channelId ${q(transferChannel.channelId)}`,
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
const {
|
|
541
|
+
// Strip out the fields that are already included in MsgTransfer.ß
|
|
542
|
+
timeoutHeight,
|
|
543
|
+
timeoutTimestamp: _,
|
|
544
|
+
memo: optsMemo,
|
|
545
|
+
...packetOpts
|
|
546
|
+
} = opts || {};
|
|
547
|
+
|
|
395
548
|
/** @type {string | undefined} */
|
|
396
|
-
let memo;
|
|
397
|
-
if (opts && 'memo' in opts) {
|
|
398
|
-
memo = opts.memo;
|
|
399
|
-
}
|
|
549
|
+
let memo = optsMemo;
|
|
400
550
|
if (forwardInfo) {
|
|
401
551
|
// pass opts.memo as forward.next, if present
|
|
402
552
|
memo = JSON.stringify({
|
|
403
553
|
forward: {
|
|
404
554
|
...forwardInfo.forward,
|
|
405
|
-
next: memo,
|
|
555
|
+
...(memo === undefined ? {} : { next: memo }),
|
|
406
556
|
},
|
|
407
557
|
});
|
|
408
558
|
}
|
|
409
559
|
const transferMsg = MsgTransfer.typedJson({
|
|
410
560
|
...transferDetails,
|
|
411
561
|
sender: this.state.address.value,
|
|
412
|
-
timeoutHeight
|
|
562
|
+
timeoutHeight,
|
|
413
563
|
timeoutTimestamp,
|
|
414
564
|
memo,
|
|
415
565
|
});
|
|
@@ -419,18 +569,51 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
419
569
|
/** @type {any} */ (holder),
|
|
420
570
|
transferMsg,
|
|
421
571
|
);
|
|
572
|
+
|
|
573
|
+
/** @type {SliceDescriptor | undefined} */
|
|
574
|
+
let trafficSlice;
|
|
575
|
+
const progressTracker = opts?.progressTracker;
|
|
576
|
+
if (progressTracker) {
|
|
577
|
+
const priorReport = progressTracker.getCurrentProgressReport();
|
|
578
|
+
|
|
579
|
+
const { traffic, slice } = addTrafficEntries(
|
|
580
|
+
priorReport.traffic,
|
|
581
|
+
// Sequence number is not known at this stage; it will be
|
|
582
|
+
// populated by IBCTransferSenderKit['responseWatcher'] once the
|
|
583
|
+
// transfer packet is sent and the sequence number is assigned.
|
|
584
|
+
trafficTransforms.IbcTransfer.start(
|
|
585
|
+
`${srcChainInfo.namespace}:${srcChainInfo.reference}`,
|
|
586
|
+
`${dstChainInfo.namespace}:${dstChainInfo.reference}`,
|
|
587
|
+
transferChannel,
|
|
588
|
+
),
|
|
589
|
+
);
|
|
590
|
+
trafficSlice = slice;
|
|
591
|
+
|
|
592
|
+
const newMeta = {
|
|
593
|
+
...priorReport,
|
|
594
|
+
traffic,
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
progressTracker.update(newMeta);
|
|
598
|
+
}
|
|
599
|
+
|
|
422
600
|
// Begin capturing packets, send the transfer packet, then return a
|
|
423
601
|
// vow that rejects unless the packet acknowledgment comes back and is
|
|
424
602
|
// verified.
|
|
425
|
-
return holder.sendThenWaitForAck(sender
|
|
603
|
+
return holder.sendThenWaitForAck(sender, {
|
|
604
|
+
...packetOpts,
|
|
605
|
+
trafficSlice,
|
|
606
|
+
});
|
|
426
607
|
},
|
|
427
608
|
},
|
|
428
|
-
/**
|
|
429
|
-
* takes an array of results (from `executeEncodedTx`) and returns the
|
|
430
|
-
* first result
|
|
431
|
-
*/
|
|
432
609
|
extractFirstResultWatcher: {
|
|
433
|
-
/**
|
|
610
|
+
/**
|
|
611
|
+
* Takes an array of results (from `executeTx`) and returns the first
|
|
612
|
+
* result element.
|
|
613
|
+
*
|
|
614
|
+
* @param {Record<PropertyKey, unknown>[]} results
|
|
615
|
+
* @returns {Record<PropertyKey, unknown>}
|
|
616
|
+
*/
|
|
434
617
|
onFulfilled(results) {
|
|
435
618
|
results.length === 1 ||
|
|
436
619
|
Fail`expected exactly one result; got ${results}`;
|
|
@@ -516,12 +699,25 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
516
699
|
},
|
|
517
700
|
parseInboundTransferWatcher: {
|
|
518
701
|
/**
|
|
519
|
-
* @param {
|
|
702
|
+
* @param {{ error?: string; reply: TypedJson<string> }[]
|
|
703
|
+
* | TypedJson<string>} result
|
|
520
704
|
* @param {Awaited<
|
|
521
705
|
* ReturnType<LocalAccountMethods['parseInboundTransfer']>
|
|
522
706
|
* >} naiveResult
|
|
523
707
|
*/
|
|
524
|
-
onFulfilled(
|
|
708
|
+
onFulfilled(result, naiveResult) {
|
|
709
|
+
const { error, reply } = extractFirstQueryResult(result);
|
|
710
|
+
|
|
711
|
+
// For the success case, error could be undefined or ''.
|
|
712
|
+
if (error) {
|
|
713
|
+
if (error.includes(ErrTraceNotFound)) {
|
|
714
|
+
// Looks like the trace was not found; The naive result is good enough.
|
|
715
|
+
return naiveResult;
|
|
716
|
+
}
|
|
717
|
+
throw Error(`IBC denom trace query failed: ${error}`);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const localDenomHash = QueryDenomHashResponse.fromTyped(reply);
|
|
525
721
|
const localDenom = `ibc/${localDenomHash.hash}`;
|
|
526
722
|
const { amount, ...rest } = naiveResult;
|
|
527
723
|
const { denom: _, ...amountRest } = amount;
|
|
@@ -539,7 +735,7 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
539
735
|
onRejected(reason, naiveResult) {
|
|
540
736
|
if (
|
|
541
737
|
reason instanceof Error &&
|
|
542
|
-
String(reason.message).includes(
|
|
738
|
+
String(reason.message).includes(ErrTraceNotFound)
|
|
543
739
|
) {
|
|
544
740
|
// Looks like the trace was not found; The naive result is good enough.
|
|
545
741
|
return naiveResult;
|
|
@@ -549,18 +745,21 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
549
745
|
},
|
|
550
746
|
},
|
|
551
747
|
holder: {
|
|
748
|
+
/** @type {OrchestrationAccountCommon['makeProgressTracker']} */
|
|
749
|
+
makeProgressTracker() {
|
|
750
|
+
return makeProgressTracker();
|
|
751
|
+
},
|
|
752
|
+
|
|
552
753
|
/** @type {HostOf<OrchestrationAccountCommon['asContinuingOffer']>} */
|
|
553
754
|
asContinuingOffer() {
|
|
554
|
-
// @ts-expect-error XXX invitationMakers
|
|
555
755
|
// getPublicTopics resolves promptly (same run), so we don't need a watcher
|
|
556
756
|
// eslint-disable-next-line no-restricted-syntax
|
|
557
757
|
return asVow(async () => {
|
|
558
758
|
await null;
|
|
559
759
|
const { holder, invitationMakers: im } = this.facets;
|
|
560
760
|
// XXX cast to a type that has string index signature
|
|
561
|
-
const invitationMakers =
|
|
562
|
-
/** @type {
|
|
563
|
-
);
|
|
761
|
+
const invitationMakers =
|
|
762
|
+
/** @type {HostInterface<InvitationMakers> & typeof im} */ (im);
|
|
564
763
|
|
|
565
764
|
return harden({
|
|
566
765
|
// getPublicTopics returns a vow, for membrane compatibility.
|
|
@@ -679,10 +878,7 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
679
878
|
*/
|
|
680
879
|
/** @type {HostOf<LocalAccountMethods['deposit']>} */
|
|
681
880
|
deposit(payment) {
|
|
682
|
-
return watch(
|
|
683
|
-
E(this.state.account).deposit(payment),
|
|
684
|
-
this.facets.returnVoidWatcher,
|
|
685
|
-
);
|
|
881
|
+
return watch(E(this.state.account).deposit(payment));
|
|
686
882
|
},
|
|
687
883
|
/** @type {HostOf<LocalAccountMethods['withdraw']>} */
|
|
688
884
|
withdraw(amount) {
|
|
@@ -701,7 +897,7 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
701
897
|
*
|
|
702
898
|
* @type {HostOf<OrchestrationAccountCommon['send']>}
|
|
703
899
|
*/
|
|
704
|
-
send(toAccount, amount) {
|
|
900
|
+
send(toAccount, amount, _opts = {}) {
|
|
705
901
|
return asVow(() => {
|
|
706
902
|
trace('send', toAccount, amount);
|
|
707
903
|
const cosmosDest = chainHub.coerceCosmosAddress(toAccount);
|
|
@@ -741,18 +937,7 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
741
937
|
);
|
|
742
938
|
});
|
|
743
939
|
},
|
|
744
|
-
/**
|
|
745
|
-
* @param {AccountIdArg} destination
|
|
746
|
-
* @param {AmountArg} amount an ERTP {@link Amount} or a
|
|
747
|
-
* {@link DenomAmount}
|
|
748
|
-
* @param {IBCMsgTransferOptions} [opts] if either timeoutHeight or
|
|
749
|
-
* timeoutTimestamp are not supplied, a default timeoutTimestamp will
|
|
750
|
-
* be set for 5 minutes in the future
|
|
751
|
-
* @returns {Vow<any>}
|
|
752
|
-
* @throws {Error} if route is not determinable, asset is not
|
|
753
|
-
* recognized, or the transfer is rejected (insufficient funds,
|
|
754
|
-
* timeout)
|
|
755
|
-
*/
|
|
940
|
+
/** @type {HostOf<OrchestrationAccountCommon['transfer']>} */
|
|
756
941
|
transfer(destination, amount, opts) {
|
|
757
942
|
return asVow(() => {
|
|
758
943
|
trace('Transferring funds over IBC');
|
|
@@ -762,19 +947,43 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
762
947
|
const { forwardOpts, ...rest } = opts ?? {};
|
|
763
948
|
|
|
764
949
|
// throws if route is not determinable
|
|
950
|
+
const srcChainName = 'agoric';
|
|
765
951
|
const route = chainHub.makeTransferRoute(
|
|
766
952
|
destination,
|
|
767
953
|
denomAmount,
|
|
768
|
-
|
|
954
|
+
srcChainName,
|
|
769
955
|
forwardOpts,
|
|
770
956
|
);
|
|
771
957
|
trace('got transfer route', route);
|
|
772
958
|
|
|
959
|
+
const denomDetail = chainHub.getAsset(
|
|
960
|
+
denomAmount.denom,
|
|
961
|
+
srcChainName,
|
|
962
|
+
);
|
|
963
|
+
assert(denomDetail);
|
|
964
|
+
|
|
965
|
+
const { baseName: denomBaseName } = denomDetail;
|
|
966
|
+
|
|
967
|
+
const srcChainInfo = chainHub.getChainInfoByChainId(
|
|
968
|
+
chainOfAccount(this.state.address),
|
|
969
|
+
);
|
|
970
|
+
|
|
971
|
+
const nextChainInfo =
|
|
972
|
+
srcChainName === denomBaseName
|
|
973
|
+
? chainHub.getChainInfoByChainId(chainOfAccount(destination))
|
|
974
|
+
: chainHub.getChainInfo(denomBaseName);
|
|
975
|
+
|
|
773
976
|
// don't resolve the vow until the transfer is confirmed on remote
|
|
774
977
|
// and reject vow if the transfer fails for any reason
|
|
775
978
|
const resultV = watch(
|
|
776
|
-
|
|
777
|
-
|
|
979
|
+
vowTools.allVows(
|
|
980
|
+
/** @type {const} */ ([
|
|
981
|
+
srcChainInfo,
|
|
982
|
+
nextChainInfo,
|
|
983
|
+
timestampHelper.vowOrValueFromOpts(opts),
|
|
984
|
+
]),
|
|
985
|
+
),
|
|
986
|
+
this.facets.transferConnectionWatcher,
|
|
778
987
|
{
|
|
779
988
|
opts: rest,
|
|
780
989
|
route,
|
|
@@ -836,11 +1045,11 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
836
1045
|
|
|
837
1046
|
// Find the local denom hash for the transferDenom, if there is one.
|
|
838
1047
|
return watch(
|
|
839
|
-
E(localchain).
|
|
1048
|
+
E(localchain).queryMany([
|
|
840
1049
|
QueryDenomHashRequest.typedJson({
|
|
841
1050
|
trace: denomOrTrace,
|
|
842
1051
|
}),
|
|
843
|
-
),
|
|
1052
|
+
]),
|
|
844
1053
|
this.facets.parseInboundTransferWatcher,
|
|
845
1054
|
buildReturnValue(denomOrTrace),
|
|
846
1055
|
);
|