@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
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { Shape as NetworkShape } from '@agoric/network';
|
|
2
|
+
import { M } from '@endo/patterns';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @import {EVow, Vow, VowTools} from '@agoric/vow';
|
|
6
|
+
* @import {InterfaceGuard, MethodGuard} from '@endo/patterns';
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The utilities that are named like `Something$` and take a `subshape`
|
|
11
|
+
* parameter indicate that they return a Shape of `Something`, specialized for
|
|
12
|
+
* `subshape`.
|
|
13
|
+
*/
|
|
14
|
+
const { Vow$ } = NetworkShape; // TODO #9611
|
|
15
|
+
const EVow$ = shape => M.or(Vow$(shape), M.promise(/* shape */));
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {Pick<VowTools, 'watch'>} powers
|
|
19
|
+
*/
|
|
20
|
+
export const makeVowExoHelpers = ({ watch }) => {
|
|
21
|
+
const vowExoHelpers = {
|
|
22
|
+
/**
|
|
23
|
+
* These are functions that operate on vows, intended to be added to an
|
|
24
|
+
* internal `helper` facet of an exoClassKit.
|
|
25
|
+
*/
|
|
26
|
+
helper: {
|
|
27
|
+
/**
|
|
28
|
+
* Return a vow that fulfills with the property at `prop` of the
|
|
29
|
+
* fulfilment of `inputV`. If `inputV` rejects, the returned vow rejects
|
|
30
|
+
* with the same reason.
|
|
31
|
+
*
|
|
32
|
+
* @template {readonly Record<PropertyKey, any>} R
|
|
33
|
+
* @template {PropertyKey} K
|
|
34
|
+
* @param {EVow<R>} inputV
|
|
35
|
+
* @param {K} prop
|
|
36
|
+
* @returns {Vow<R[K]>}
|
|
37
|
+
*/
|
|
38
|
+
pickVowProp(inputV, prop) {
|
|
39
|
+
return watch(inputV, this.facets.pickDataWatcher, prop);
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* Return a vow that fulfills with the element at `index` of the
|
|
43
|
+
* fulfilment of `inputV`. If `inputV` rejects, the returned vow rejects
|
|
44
|
+
* with the same reason.
|
|
45
|
+
*
|
|
46
|
+
* @template {readonly unknown[]} T
|
|
47
|
+
* @template {number} I
|
|
48
|
+
* @param {EVow<T>} inputV
|
|
49
|
+
* @param {I} index
|
|
50
|
+
* @returns {Vow<T[I]>}
|
|
51
|
+
*/
|
|
52
|
+
pickVowIndex(inputV, index) {
|
|
53
|
+
return watch(inputV, this.facets.pickDataWatcher, index);
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Return a vow that fulfills with `newValue` after `inputV` fulfills. If
|
|
57
|
+
* `inputV` rejects, the returned vow rejects with the same reason.
|
|
58
|
+
*
|
|
59
|
+
* @template [T=undefined]
|
|
60
|
+
* @param {Vow<unknown>} inputV
|
|
61
|
+
* @param {T} [newValue]
|
|
62
|
+
* @returns {Vow<T>}
|
|
63
|
+
*/
|
|
64
|
+
overrideVow(inputV, newValue) {
|
|
65
|
+
return watch(inputV, this.facets.overrideVowWatcher, newValue);
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Return a vow typed as `Vow<void>` that fulfills with `undefined` after
|
|
69
|
+
* `inputV` fulfills. If `inputV` rejects, the returned vow rejects with
|
|
70
|
+
* the same reason.
|
|
71
|
+
*
|
|
72
|
+
* @param {Vow<unknown>} inputV
|
|
73
|
+
* @returns {Vow<void>}
|
|
74
|
+
*/
|
|
75
|
+
voidVow(inputV) {
|
|
76
|
+
return watch(inputV, this.facets.overrideVowWatcher);
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
/** These are shapes of the function provided by `helper`. */
|
|
80
|
+
helperShapes: {
|
|
81
|
+
pickVowIndex: M.call(Vow$(M.array()), M.number()).returns(EVow$(M.any())),
|
|
82
|
+
pickVowProp: M.call(
|
|
83
|
+
Vow$(M.record()),
|
|
84
|
+
M.or(M.string(), M.number()),
|
|
85
|
+
).returns(EVow$(M.any())),
|
|
86
|
+
voidVow: M.call(EVow$(M.any())).returns(EVow$(M.undefined())),
|
|
87
|
+
overrideVow: M.call(EVow$(M.any()))
|
|
88
|
+
.optional(M.any())
|
|
89
|
+
.returns(EVow$(M.any())),
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* These are the watcher facets used by the functions provided by `helper`.
|
|
93
|
+
*/
|
|
94
|
+
watchers: {
|
|
95
|
+
pickDataWatcher: {
|
|
96
|
+
/**
|
|
97
|
+
* Return `value[key]`.
|
|
98
|
+
*
|
|
99
|
+
* @template {{}} V
|
|
100
|
+
* @template {keyof V} K
|
|
101
|
+
* @param {V} value
|
|
102
|
+
* @param {K} key
|
|
103
|
+
* @returns {V[K]}
|
|
104
|
+
*/
|
|
105
|
+
onFulfilled(value, key) {
|
|
106
|
+
return harden(value[key]);
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
overrideVowWatcher: {
|
|
110
|
+
/**
|
|
111
|
+
* Always return `newValue`.
|
|
112
|
+
*
|
|
113
|
+
* @template V
|
|
114
|
+
* @param {unknown} _value
|
|
115
|
+
* @param {V} newValue
|
|
116
|
+
* @returns {V}
|
|
117
|
+
*/
|
|
118
|
+
onFulfilled(_value, newValue) {
|
|
119
|
+
return newValue;
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* These are the shapes of watcher facets used by the functions provided by
|
|
125
|
+
* `helper`.
|
|
126
|
+
*/
|
|
127
|
+
watcherShapes: {
|
|
128
|
+
pickDataWatcher: M.interface('pickArrayDataWatcher', {
|
|
129
|
+
onFulfilled: M.call(
|
|
130
|
+
M.or(M.array(), M.record()),
|
|
131
|
+
M.or(M.number(), M.string()),
|
|
132
|
+
).returns(M.any()),
|
|
133
|
+
}),
|
|
134
|
+
overrideVowWatcher: M.interface('overrideVowWatcher', {
|
|
135
|
+
onFulfilled: M.call(M.any()).optional(M.any()).returns(M.any()),
|
|
136
|
+
}),
|
|
137
|
+
},
|
|
138
|
+
/**
|
|
139
|
+
* Given a tuple of facet names and a tuple of method names, return a record
|
|
140
|
+
* mapping each facet name to a facet tombstone whose methods always throw.
|
|
141
|
+
*
|
|
142
|
+
* This is useful for retiring watchers while preserving their facets so
|
|
143
|
+
* that older exoClassKits can be upgraded without errors caused by missing
|
|
144
|
+
* facet definitions.
|
|
145
|
+
*
|
|
146
|
+
* @template {readonly string[]} F
|
|
147
|
+
* @template {readonly string[]} M
|
|
148
|
+
* @param {F} facets
|
|
149
|
+
* @param {M} methods
|
|
150
|
+
* @returns {{ [S in F[number]]: { [T in M[number]]: () => never } }}
|
|
151
|
+
*/
|
|
152
|
+
makeTombstonedFacets: (facets, methods) =>
|
|
153
|
+
/** @type {{ [S in F[number]]: { [T in M[number]]: () => never } }} */ (
|
|
154
|
+
Object.fromEntries(
|
|
155
|
+
facets.map(facet => [
|
|
156
|
+
facet,
|
|
157
|
+
/** @type {{ [T in M[number]]: () => never }} */ (
|
|
158
|
+
Object.fromEntries(
|
|
159
|
+
methods.map(meth => [
|
|
160
|
+
meth,
|
|
161
|
+
() => {
|
|
162
|
+
throw Error(
|
|
163
|
+
`${facet} is retired. Retry your request to switch to a supported code path.`,
|
|
164
|
+
);
|
|
165
|
+
},
|
|
166
|
+
]),
|
|
167
|
+
)
|
|
168
|
+
),
|
|
169
|
+
]),
|
|
170
|
+
)
|
|
171
|
+
),
|
|
172
|
+
/**
|
|
173
|
+
* Given a tuple of facet names and a tuple of method names, return a record
|
|
174
|
+
* mapping each name to a lax interface guard for a facet tombstone.
|
|
175
|
+
*
|
|
176
|
+
* @template {readonly string[]} F
|
|
177
|
+
* @template {readonly string[]} M
|
|
178
|
+
* @param {F} facets
|
|
179
|
+
* @param {M} methods
|
|
180
|
+
* @returns {{
|
|
181
|
+
* [S in F[number]]: InterfaceGuard<{ [T in M[number]]: MethodGuard }>;
|
|
182
|
+
* }}
|
|
183
|
+
*/
|
|
184
|
+
makeTombstonedFacetShapes: (facets, methods) =>
|
|
185
|
+
/**
|
|
186
|
+
* @type {{
|
|
187
|
+
* [S in F[number]]: InterfaceGuard<{
|
|
188
|
+
* [T in M[number]]: MethodGuard;
|
|
189
|
+
* }>;
|
|
190
|
+
* }}
|
|
191
|
+
*/
|
|
192
|
+
(
|
|
193
|
+
Object.fromEntries(
|
|
194
|
+
facets.map(name => [
|
|
195
|
+
name,
|
|
196
|
+
M.interface(
|
|
197
|
+
name,
|
|
198
|
+
/** @type {{ [T in M[number]]: MethodGuard }} */ (
|
|
199
|
+
Object.fromEntries(
|
|
200
|
+
methods.map(method => [
|
|
201
|
+
method,
|
|
202
|
+
M.call().rest(M.any()).returns(),
|
|
203
|
+
]),
|
|
204
|
+
)
|
|
205
|
+
),
|
|
206
|
+
),
|
|
207
|
+
]),
|
|
208
|
+
)
|
|
209
|
+
),
|
|
210
|
+
/**
|
|
211
|
+
* Given a tuple of watcher names, return a record mapping each watcher name
|
|
212
|
+
* to a watcher facet tombstone whose methods always throw.
|
|
213
|
+
*
|
|
214
|
+
* This is useful for retiring watchers while preserving their facets so
|
|
215
|
+
* that older exoClassKits can be upgraded without errors caused by missing
|
|
216
|
+
* facet definitions.
|
|
217
|
+
*
|
|
218
|
+
* @template {readonly string[]} W
|
|
219
|
+
* @param {W} watchers
|
|
220
|
+
*/
|
|
221
|
+
makeTombstonedWatchers: watchers =>
|
|
222
|
+
vowExoHelpers.makeTombstonedFacets(
|
|
223
|
+
watchers,
|
|
224
|
+
/** @type {const} */ (['onFulfilled']),
|
|
225
|
+
),
|
|
226
|
+
/**
|
|
227
|
+
* Given a tuple of watcher names, return a record mapping each name to a
|
|
228
|
+
* lax interface guard for a watcher facet tombstone.
|
|
229
|
+
*
|
|
230
|
+
* @template {readonly string[]} W
|
|
231
|
+
* @param {W} watchers
|
|
232
|
+
*/
|
|
233
|
+
makeTombstonedWatcherShapes: watchers =>
|
|
234
|
+
vowExoHelpers.makeTombstonedFacetShapes(
|
|
235
|
+
watchers,
|
|
236
|
+
/** @type {const} */ (['onFulfilled']),
|
|
237
|
+
),
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
return vowExoHelpers;
|
|
241
|
+
};
|
package/src/utils/gmp.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export const gmpAddresses: {
|
|
|
15
15
|
AXELAR_GAS: Bech32Address;
|
|
16
16
|
OSMOSIS_RECEIVER: Bech32Address;
|
|
17
17
|
};
|
|
18
|
-
export function constructContractCall({ target, functionSignature, args }: ContractCall): AbiEncodedContractCall;
|
|
19
|
-
export function buildGMPPayload(contractCalls: ContractCall[]): number[];
|
|
18
|
+
export function constructContractCall({ target, functionSignature, args, abi, }: ContractCall): AbiEncodedContractCall;
|
|
19
|
+
export function buildGMPPayload(contractCalls: ContractCall[], id?: string): number[];
|
|
20
20
|
export function buildNoncePayload(nonce: bigint): number[];
|
|
21
21
|
export function buildGasPayload(gasAmount: bigint): number[];
|
|
22
22
|
export namespace EVM_CHAINS {
|
package/src/utils/gmp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gmp.d.ts","sourceRoot":"","sources":["gmp.js"],"names":[],"mappings":";;;;;AAoBA;;;;;;GAMG;AACH,2BANU;IACL,UAAU,EAAE,aAAa,CAAC;IAC1B,UAAU,EAAE,aAAa,CAAC;IAC1B,gBAAgB,EAAE,aAAa,CAAC;CACjC,CAOF;AAQK,
|
|
1
|
+
{"version":3,"file":"gmp.d.ts","sourceRoot":"","sources":["gmp.js"],"names":[],"mappings":";;;;;AAoBA;;;;;;GAMG;AACH,2BANU;IACL,UAAU,EAAE,aAAa,CAAC;IAC1B,UAAU,EAAE,aAAa,CAAC;IAC1B,gBAAgB,EAAE,aAAa,CAAC;CACjC,CAOF;AAQK,iFAHI,YAAY,GACV,sBAAsB,CA0BlC;AASM,+CAJI,YAAY,EAAE,OACd,MAAM,GACJ,MAAM,EAAE,CAkCpB;AAMM,yCAHI,MAAM,GACJ,MAAM,EAAE,CAMpB;AAMM,2CAHI,MAAM,GACJ,MAAM,EAAE,CASpB;;;;;;mCArH+B,uBAAuB;kCADA,oBAAoB;4CAApB,oBAAoB"}
|
package/src/utils/gmp.js
CHANGED
|
@@ -38,20 +38,26 @@ export const gmpAddresses = {
|
|
|
38
38
|
* @param {ContractCall} data - The data for the contract call.
|
|
39
39
|
* @returns {AbiEncodedContractCall} The encoded contract call object.
|
|
40
40
|
*/
|
|
41
|
-
export const constructContractCall = ({
|
|
41
|
+
export const constructContractCall = ({
|
|
42
|
+
target,
|
|
43
|
+
functionSignature,
|
|
44
|
+
args,
|
|
45
|
+
abi,
|
|
46
|
+
}) => {
|
|
42
47
|
const [name, paramsRaw] = functionSignature.split('(');
|
|
43
48
|
const params = paramsRaw.replace(')', '').split(',').filter(Boolean);
|
|
49
|
+
const resolvedAbi = abi ?? [
|
|
50
|
+
{
|
|
51
|
+
type: 'function',
|
|
52
|
+
name,
|
|
53
|
+
inputs: params.map((type, i) => ({ type, name: `arg${i}` })),
|
|
54
|
+
},
|
|
55
|
+
];
|
|
44
56
|
|
|
45
57
|
return {
|
|
46
58
|
target,
|
|
47
59
|
data: encodeFunctionData({
|
|
48
|
-
abi:
|
|
49
|
-
{
|
|
50
|
-
type: 'function',
|
|
51
|
-
name,
|
|
52
|
-
inputs: params.map((type, i) => ({ type, name: `arg${i}` })),
|
|
53
|
-
},
|
|
54
|
-
],
|
|
60
|
+
abi: resolvedAbi,
|
|
55
61
|
functionName: name,
|
|
56
62
|
args,
|
|
57
63
|
}),
|
|
@@ -62,28 +68,38 @@ export const constructContractCall = ({ target, functionSignature, args }) => {
|
|
|
62
68
|
* Builds a GMP payload from an array of contract calls.
|
|
63
69
|
*
|
|
64
70
|
* @param {ContractCall[]} contractCalls - Array of contract call objects.
|
|
71
|
+
* @param {string} id - Optional message ID for tracing/debugging purposes
|
|
65
72
|
* @returns {number[]} The GMP payload array.
|
|
66
73
|
*/
|
|
67
|
-
export const buildGMPPayload = contractCalls => {
|
|
74
|
+
export const buildGMPPayload = (contractCalls, id = '') => {
|
|
68
75
|
const abiEncodedContractCalls = [];
|
|
69
76
|
for (const call of contractCalls) {
|
|
70
|
-
const { target, functionSignature, args } = call;
|
|
77
|
+
const { target, functionSignature, args, abi } = call;
|
|
78
|
+
|
|
71
79
|
abiEncodedContractCalls.push(
|
|
72
|
-
constructContractCall({ target, functionSignature, args }),
|
|
80
|
+
constructContractCall({ target, functionSignature, args, abi }),
|
|
73
81
|
);
|
|
74
82
|
}
|
|
75
83
|
|
|
76
84
|
const abiEncodedData = encodeAbiParameters(
|
|
77
85
|
[
|
|
78
86
|
{
|
|
79
|
-
type: 'tuple
|
|
87
|
+
type: 'tuple',
|
|
88
|
+
name: 'callMessage',
|
|
80
89
|
components: [
|
|
81
|
-
{ name: '
|
|
82
|
-
{
|
|
90
|
+
{ name: 'id', type: 'string' },
|
|
91
|
+
{
|
|
92
|
+
name: 'calls',
|
|
93
|
+
type: 'tuple[]',
|
|
94
|
+
components: [
|
|
95
|
+
{ name: 'target', type: 'address' },
|
|
96
|
+
{ name: 'data', type: 'bytes' },
|
|
97
|
+
],
|
|
98
|
+
},
|
|
83
99
|
],
|
|
84
100
|
},
|
|
85
101
|
],
|
|
86
|
-
[abiEncodedContractCalls],
|
|
102
|
+
[{ id, calls: abiEncodedContractCalls }],
|
|
87
103
|
);
|
|
88
104
|
|
|
89
105
|
return Array.from(hexToBytes(abiEncodedData));
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {TypedPattern} from '@agoric/internal';
|
|
3
|
+
* @import {IBCEndpoint} from '@agoric/vats/tools/ibc-utils.js';
|
|
4
|
+
* @import {CaipChainId, IBCConnectionInfo, TrafficEntry} from '../types.js';
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {object} SliceDescriptor
|
|
8
|
+
* @property {number} start beginning index of the range (inclusive)
|
|
9
|
+
* @property {number} end ending index of the range (exclusive)
|
|
10
|
+
*/
|
|
11
|
+
/** @type {TypedPattern<SliceDescriptor>} */
|
|
12
|
+
export const SliceDescriptorShape: TypedPattern<SliceDescriptor>;
|
|
1
13
|
export namespace orchestrationAccountMethods {
|
|
2
14
|
let getAddress: import("@endo/patterns").MethodGuard;
|
|
3
15
|
let getBalance: import("@endo/patterns").MethodGuard;
|
|
@@ -8,5 +20,72 @@ export namespace orchestrationAccountMethods {
|
|
|
8
20
|
let transferSteps: import("@endo/patterns").MethodGuard;
|
|
9
21
|
let asContinuingOffer: import("@endo/patterns").MethodGuard;
|
|
10
22
|
let getPublicTopics: import("@endo/patterns").MethodGuard;
|
|
23
|
+
let makeProgressTracker: import("@endo/patterns").MethodGuard;
|
|
11
24
|
}
|
|
25
|
+
export namespace trafficTransforms {
|
|
26
|
+
namespace IbcTransfer {
|
|
27
|
+
export { startIbcTransfer as start };
|
|
28
|
+
export { finishIbcTransfer as finish };
|
|
29
|
+
}
|
|
30
|
+
namespace IbcICA {
|
|
31
|
+
export { startIbcICA as start };
|
|
32
|
+
export { finishIbcICA as finish };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function addTrafficEntries(priorTraffic: TrafficEntry[] | undefined, newEntries: TrafficEntry[]): {
|
|
36
|
+
traffic: TrafficEntry[];
|
|
37
|
+
slice: SliceDescriptor;
|
|
38
|
+
};
|
|
39
|
+
export function finishTrafficEntries(priorTraffic: TrafficEntry[] | undefined, sliceDescriptor: SliceDescriptor | undefined, finisher: (entries: TrafficEntry[]) => TrafficEntry[]): TrafficEntry[];
|
|
40
|
+
export type SliceDescriptor = {
|
|
41
|
+
/**
|
|
42
|
+
* beginning index of the range (inclusive)
|
|
43
|
+
*/
|
|
44
|
+
start: number;
|
|
45
|
+
/**
|
|
46
|
+
* ending index of the range (exclusive)
|
|
47
|
+
*/
|
|
48
|
+
end: number;
|
|
49
|
+
};
|
|
50
|
+
import type { TypedPattern } from '@agoric/internal';
|
|
51
|
+
/**
|
|
52
|
+
* @param {CaipChainId} srcChain
|
|
53
|
+
* @param {CaipChainId} dstChain
|
|
54
|
+
* @param {IBCConnectionInfo['transferChannel']} ibcChannel
|
|
55
|
+
* @returns {(TrafficEntry<'ibc'> & { incomplete: true })[]}
|
|
56
|
+
*/
|
|
57
|
+
declare function startIbcTransfer(srcChain: CaipChainId, dstChain: CaipChainId, ibcChannel: IBCConnectionInfo["transferChannel"]): (TrafficEntry<"ibc"> & {
|
|
58
|
+
incomplete: true;
|
|
59
|
+
})[];
|
|
60
|
+
/**
|
|
61
|
+
* @param {(TrafficEntry<'ibc'> & { incomplete?: any })[]} entries
|
|
62
|
+
* @param {TrafficEntry<'ibc'>['seq']} sequence
|
|
63
|
+
* @returns {TrafficEntry<'ibc'>[]}
|
|
64
|
+
*/
|
|
65
|
+
declare function finishIbcTransfer(entries: (TrafficEntry<"ibc"> & {
|
|
66
|
+
incomplete?: any;
|
|
67
|
+
})[], sequence: TrafficEntry<"ibc">["seq"]): TrafficEntry<"ibc">[];
|
|
68
|
+
/**
|
|
69
|
+
* @param {CaipChainId} dstChain
|
|
70
|
+
* @returns {(TrafficEntry<'ibc'> & { incomplete: true })[]}
|
|
71
|
+
*/
|
|
72
|
+
declare function startIbcICA(dstChain: CaipChainId): (TrafficEntry<"ibc"> & {
|
|
73
|
+
incomplete: true;
|
|
74
|
+
})[];
|
|
75
|
+
/**
|
|
76
|
+
* @param {(TrafficEntry<'ibc'> & { incomplete?: any })[]} entries
|
|
77
|
+
* @param {CaipChainId} srcChain
|
|
78
|
+
* @param {Pick<IBCEndpoint, 'portID' | 'channelID'>} srcEndpoint
|
|
79
|
+
* @param {Pick<IBCEndpoint, 'portID' | 'channelID'>} dstEndpoint
|
|
80
|
+
* @param {TrafficEntry<'ibc'>['seq']} sequence
|
|
81
|
+
* @returns {TrafficEntry<'ibc'>[]}
|
|
82
|
+
*/
|
|
83
|
+
declare function finishIbcICA(entries: (TrafficEntry<"ibc"> & {
|
|
84
|
+
incomplete?: any;
|
|
85
|
+
})[], srcChain: CaipChainId, srcEndpoint: Pick<IBCEndpoint, "portID" | "channelID">, dstEndpoint: Pick<IBCEndpoint, "portID" | "channelID">, sequence: TrafficEntry<"ibc">["seq"]): TrafficEntry<"ibc">[];
|
|
86
|
+
import type { TrafficEntry } from '../types.js';
|
|
87
|
+
import type { CaipChainId } from '../types.js';
|
|
88
|
+
import type { IBCConnectionInfo } from '../types.js';
|
|
89
|
+
import type { IBCEndpoint } from '@agoric/vats/tools/ibc-utils.js';
|
|
90
|
+
export {};
|
|
12
91
|
//# sourceMappingURL=orchestrationAccount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrationAccount.d.ts","sourceRoot":"","sources":["orchestrationAccount.js"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"orchestrationAccount.d.ts","sourceRoot":"","sources":["orchestrationAccount.js"],"names":[],"mappings":"AAgBA;;;;GAIG;AAEH;;;;GAIG;AACH,4CAA4C;AAC5C,mCADW,aAAa,eAAe,CAAC,CAIrC;;;;;;;;;;;;;;;;;;;;;;;AA8KI,gDAJI,YAAY,EAAE,GAAG,SAAS,cAC1B,YAAY,EAAE,GACZ;IAAE,OAAO,EAAE,YAAY,EAAE,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE,CAa/D;AASM,mDALI,YAAY,EAAE,GAAG,SAAS,mBAC1B,eAAe,GAAG,SAAS,YAC3B,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,GACzC,YAAY,EAAE,CAoB1B;;;;;WA3Na,MAAM;;;;SACN,MAAM;;kCARW,kBAAkB;AA6CjD;;;;;GAKG;AACH,4CALW,WAAW,YACX,WAAW,cACX,iBAAiB,CAAC,iBAAiB,CAAC,GAClC,CAAC,aAAa,KAAK,CAAC,GAAG;IAAE,UAAU,EAAE,IAAI,CAAA;CAAE,CAAC,EAAE,CAqBvD;AAoBJ;;;;GAIG;AACH,4CAJW,CAAC,aAAa,KAAK,CAAC,GAAG;IAAE,UAAU,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC,EAAE,YAC9C,aAAa,KAAK,CAAN,CAAQ,KAAK,CAAC,GACxB,aAAa,KAAK,CAAC,EAAE,CAYjC;AAED;;;GAGG;AACH,uCAHW,WAAW,GACT,CAAC,aAAa,KAAK,CAAC,GAAG;IAAE,UAAU,EAAE,IAAI,CAAA;CAAE,CAAC,EAAE,CAYvD;AAEJ;;;;;;;GAOG;AACH,uCAPW,CAAC,aAAa,KAAK,CAAC,GAAG;IAAE,UAAU,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC,EAAE,YAC9C,WAAW,eACX,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,WAAW,CAAC,eACzC,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,WAAW,CAAC,YACzC,aAAa,KAAK,CAAN,CAAQ,KAAK,CAAC,GACxB,aAAa,KAAK,CAAC,EAAE,CAwCjC;kCAvK8D,aAAa;iCAAb,aAAa;uCAAb,aAAa;iCAD9C,iCAAiC"}
|
|
@@ -3,6 +3,7 @@ import { Shape as NetworkShape } from '@agoric/network';
|
|
|
3
3
|
import { VowShape } from '@agoric/vow';
|
|
4
4
|
import { TopicsRecordShape } from '@agoric/zoe/src/contractSupport/topics.js';
|
|
5
5
|
import { M } from '@endo/patterns';
|
|
6
|
+
import { Fail } from '@endo/errors';
|
|
6
7
|
import {
|
|
7
8
|
AccountIdArgShape,
|
|
8
9
|
AmountArgShape,
|
|
@@ -11,10 +12,26 @@ import {
|
|
|
11
12
|
IBCTransferOptionsShape,
|
|
12
13
|
} from '../typeGuards.js';
|
|
13
14
|
|
|
14
|
-
/** @import {OrchestrationAccountCommon} from '../orchestration-api.js'; */
|
|
15
|
-
|
|
16
15
|
const { Vow$ } = NetworkShape; // TODO #9611
|
|
17
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @import {TypedPattern} from '@agoric/internal';
|
|
19
|
+
* @import {IBCEndpoint} from '@agoric/vats/tools/ibc-utils.js';
|
|
20
|
+
* @import {CaipChainId, IBCConnectionInfo, TrafficEntry} from '../types.js';
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {object} SliceDescriptor
|
|
25
|
+
* @property {number} start beginning index of the range (inclusive)
|
|
26
|
+
* @property {number} end ending index of the range (exclusive)
|
|
27
|
+
*/
|
|
28
|
+
/** @type {TypedPattern<SliceDescriptor>} */
|
|
29
|
+
export const SliceDescriptorShape = M.splitRecord({
|
|
30
|
+
start: M.number(),
|
|
31
|
+
end: M.number(),
|
|
32
|
+
});
|
|
33
|
+
harden(SliceDescriptorShape);
|
|
34
|
+
|
|
18
35
|
/** @see {OrchestrationAccountCommon} */
|
|
19
36
|
export const orchestrationAccountMethods = {
|
|
20
37
|
getAddress: M.call().returns(CosmosChainAddressShape),
|
|
@@ -22,10 +39,12 @@ export const orchestrationAccountMethods = {
|
|
|
22
39
|
Vow$(DenomAmountShape),
|
|
23
40
|
),
|
|
24
41
|
getBalances: M.call().returns(Vow$(M.arrayOf(DenomAmountShape))),
|
|
25
|
-
send: M.call(AccountIdArgShape, AmountArgShape)
|
|
26
|
-
|
|
27
|
-
VowShape,
|
|
28
|
-
)
|
|
42
|
+
send: M.call(AccountIdArgShape, AmountArgShape)
|
|
43
|
+
.optional(M.record())
|
|
44
|
+
.returns(VowShape),
|
|
45
|
+
sendAll: M.call(CosmosChainAddressShape, M.arrayOf(AmountArgShape))
|
|
46
|
+
.optional(M.record())
|
|
47
|
+
.returns(VowShape),
|
|
29
48
|
transfer: M.call(AccountIdArgShape, AmountArgShape)
|
|
30
49
|
.optional(IBCTransferOptionsShape)
|
|
31
50
|
.returns(VowShape),
|
|
@@ -38,4 +57,189 @@ export const orchestrationAccountMethods = {
|
|
|
38
57
|
}),
|
|
39
58
|
),
|
|
40
59
|
getPublicTopics: M.call().returns(Vow$(TopicsRecordShape)),
|
|
60
|
+
makeProgressTracker: M.call().returns(M.remotable('ProgressTracker')),
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {CaipChainId} srcChain
|
|
65
|
+
* @param {CaipChainId} dstChain
|
|
66
|
+
* @param {IBCConnectionInfo['transferChannel']} ibcChannel
|
|
67
|
+
* @returns {(TrafficEntry<'ibc'> & { incomplete: true })[]}
|
|
68
|
+
*/
|
|
69
|
+
const startIbcTransfer = (srcChain, dstChain, ibcChannel) =>
|
|
70
|
+
harden([
|
|
71
|
+
{
|
|
72
|
+
op: 'transfer',
|
|
73
|
+
src: [
|
|
74
|
+
'ibc',
|
|
75
|
+
['chain', srcChain],
|
|
76
|
+
['port', ibcChannel.portId],
|
|
77
|
+
['channel', ibcChannel.channelId],
|
|
78
|
+
],
|
|
79
|
+
dst: [
|
|
80
|
+
'ibc',
|
|
81
|
+
['chain', dstChain],
|
|
82
|
+
['port', ibcChannel.counterPartyPortId],
|
|
83
|
+
['channel', ibcChannel.counterPartyChannelId],
|
|
84
|
+
],
|
|
85
|
+
seq: { status: 'pending' },
|
|
86
|
+
incomplete: true,
|
|
87
|
+
},
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @template {TrafficEntry} T
|
|
92
|
+
* @param {T} entry
|
|
93
|
+
* @param {TrafficEntry['seq']} sequence
|
|
94
|
+
* @returns {T}
|
|
95
|
+
*/
|
|
96
|
+
const attachGenericSequence = (entry, sequence) => {
|
|
97
|
+
const baseSequence = entry.seq;
|
|
98
|
+
Object(baseSequence)?.status === 'pending' ||
|
|
99
|
+
Fail`expected entry.seq ${baseSequence} to be pending`;
|
|
100
|
+
sequence != null || Fail`expected sequence ${sequence} to be non-nullish`;
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
...entry,
|
|
104
|
+
seq: sequence,
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param {(TrafficEntry<'ibc'> & { incomplete?: any })[]} entries
|
|
110
|
+
* @param {TrafficEntry<'ibc'>['seq']} sequence
|
|
111
|
+
* @returns {TrafficEntry<'ibc'>[]}
|
|
112
|
+
*/
|
|
113
|
+
const finishIbcTransfer = (entries, sequence) => {
|
|
114
|
+
entries.length === 1 || Fail`expected single traffic entry to finish`;
|
|
115
|
+
const [{ incomplete, ...entry }] = entries;
|
|
116
|
+
incomplete || Fail`expected incomplete traffic entry`;
|
|
117
|
+
entry.op === 'transfer' ||
|
|
118
|
+
Fail`expected transfer traffic entry, got ${entry.op}`;
|
|
119
|
+
entry.src[0] === 'ibc' || Fail`expected ibc source in transfer traffic entry`;
|
|
120
|
+
entry.dst[0] === 'ibc' || Fail`expected ibc dest in transfer traffic entry`;
|
|
121
|
+
|
|
122
|
+
return harden([attachGenericSequence(entry, sequence)]);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {CaipChainId} dstChain
|
|
127
|
+
* @returns {(TrafficEntry<'ibc'> & { incomplete: true })[]}
|
|
128
|
+
*/
|
|
129
|
+
const startIbcICA = dstChain =>
|
|
130
|
+
harden([
|
|
131
|
+
{
|
|
132
|
+
op: 'ICA',
|
|
133
|
+
src: ['ibc'],
|
|
134
|
+
dst: ['ibc', ['chain', dstChain]],
|
|
135
|
+
// the rest is filled in by ICA processing
|
|
136
|
+
seq: { status: 'pending' },
|
|
137
|
+
incomplete: true,
|
|
138
|
+
},
|
|
139
|
+
]);
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @param {(TrafficEntry<'ibc'> & { incomplete?: any })[]} entries
|
|
143
|
+
* @param {CaipChainId} srcChain
|
|
144
|
+
* @param {Pick<IBCEndpoint, 'portID' | 'channelID'>} srcEndpoint
|
|
145
|
+
* @param {Pick<IBCEndpoint, 'portID' | 'channelID'>} dstEndpoint
|
|
146
|
+
* @param {TrafficEntry<'ibc'>['seq']} sequence
|
|
147
|
+
* @returns {TrafficEntry<'ibc'>[]}
|
|
148
|
+
*/
|
|
149
|
+
const finishIbcICA = (
|
|
150
|
+
entries,
|
|
151
|
+
srcChain,
|
|
152
|
+
srcEndpoint,
|
|
153
|
+
dstEndpoint,
|
|
154
|
+
sequence,
|
|
155
|
+
) => {
|
|
156
|
+
entries.length === 1 || Fail`expected single traffic entry to finish`;
|
|
157
|
+
const [{ incomplete, ...entry }] = entries;
|
|
158
|
+
incomplete || Fail`expected incomplete traffic entry`;
|
|
159
|
+
entry.op === 'ICA' || Fail`expected ICA traffic entry`;
|
|
160
|
+
|
|
161
|
+
entry.src.length === 1 || Fail`expected source length 1 in ICA traffic entry`;
|
|
162
|
+
entry.src[0] === 'ibc' || Fail`expected ibc source in ICA traffic entry`;
|
|
163
|
+
const src = /** @type {const} */ ([
|
|
164
|
+
...entry.src,
|
|
165
|
+
['chain', srcChain],
|
|
166
|
+
['port', srcEndpoint.portID],
|
|
167
|
+
['channel', srcEndpoint.channelID],
|
|
168
|
+
]);
|
|
169
|
+
|
|
170
|
+
entry.dst.length === 2 || Fail`expected dest length 2 in ICA traffic entry`;
|
|
171
|
+
entry.dst[0] === 'ibc' || Fail`expected ibc dest in ICA traffic entry`;
|
|
172
|
+
const dst = /** @type {const} */ ([
|
|
173
|
+
...entry.dst,
|
|
174
|
+
['port', dstEndpoint.portID],
|
|
175
|
+
['channel', dstEndpoint.channelID],
|
|
176
|
+
]);
|
|
177
|
+
return [
|
|
178
|
+
attachGenericSequence(
|
|
179
|
+
/** @type {TrafficEntry<'ibc'>} */ ({
|
|
180
|
+
...entry,
|
|
181
|
+
src,
|
|
182
|
+
dst,
|
|
183
|
+
}),
|
|
184
|
+
sequence,
|
|
185
|
+
),
|
|
186
|
+
];
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export const trafficTransforms = /** @type {const} */ ({
|
|
190
|
+
IbcTransfer: {
|
|
191
|
+
start: startIbcTransfer,
|
|
192
|
+
finish: finishIbcTransfer,
|
|
193
|
+
},
|
|
194
|
+
IbcICA: {
|
|
195
|
+
start: startIbcICA,
|
|
196
|
+
finish: finishIbcICA,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
harden(trafficTransforms);
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @param {TrafficEntry[] | undefined} priorTraffic
|
|
203
|
+
* @param {TrafficEntry[]} newEntries
|
|
204
|
+
* @returns {{ traffic: TrafficEntry[]; slice: SliceDescriptor }}
|
|
205
|
+
*/
|
|
206
|
+
export const addTrafficEntries = (priorTraffic, newEntries) => {
|
|
207
|
+
const entries = priorTraffic ?? [];
|
|
208
|
+
const start = entries.length;
|
|
209
|
+
const end = start + newEntries.length;
|
|
210
|
+
return harden({
|
|
211
|
+
traffic: [...entries, ...newEntries],
|
|
212
|
+
slice: {
|
|
213
|
+
start,
|
|
214
|
+
end,
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
harden(addTrafficEntries);
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @param {TrafficEntry[] | undefined} priorTraffic
|
|
222
|
+
* @param {SliceDescriptor | undefined} sliceDescriptor
|
|
223
|
+
* @param {(entries: TrafficEntry[]) => TrafficEntry[]} finisher
|
|
224
|
+
* @returns {TrafficEntry[]}
|
|
225
|
+
*/
|
|
226
|
+
export const finishTrafficEntries = (
|
|
227
|
+
priorTraffic,
|
|
228
|
+
sliceDescriptor,
|
|
229
|
+
finisher,
|
|
230
|
+
) => {
|
|
231
|
+
const entries = priorTraffic ?? [];
|
|
232
|
+
const slice = sliceDescriptor ?? { start: 0, end: entries.length };
|
|
233
|
+
|
|
234
|
+
const toTransform = harden(entries.slice(slice.start, slice.end));
|
|
235
|
+
toTransform.length > 0 || Fail`no traffic entries to finish`;
|
|
236
|
+
|
|
237
|
+
const transformed = harden(finisher(toTransform));
|
|
238
|
+
transformed.length === toTransform.length ||
|
|
239
|
+
Fail`traffic entry transform must not change length; expected ${toTransform.length}, got ${transformed.length}`;
|
|
240
|
+
|
|
241
|
+
const pre = entries.slice(0, slice.start);
|
|
242
|
+
const post = entries.slice(slice.end);
|
|
243
|
+
return harden([...pre, ...transformed, ...post]);
|
|
41
244
|
};
|
|
245
|
+
harden(finishTrafficEntries);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packet.d.ts","sourceRoot":"","sources":["packet.js"],"names":[],"mappings":"AAsBA;;;;GAIG;AAEH;;;;;;;;;GASG;AACH,mCALW,OAAO,EAAE,SACT,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,GACnC,MAAM,
|
|
1
|
+
{"version":3,"file":"packet.d.ts","sourceRoot":"","sources":["packet.js"],"names":[],"mappings":"AAsBA;;;;GAIG;AAEH;;;;;;;;;GASG;AACH,mCALW,OAAO,EAAE,SACT,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,GACnC,MAAM,CAsBlB;AAGD;;;;;;;;GAQG;AACH,sCAJW,SAAS,gBAAgB,CAAC,EAAE,GAC1B,MAAM,CAgBlB;AAGD;;;;;;;;;;GAUG;AACH,wCALW,MAAM,GACJ,MAAM,CASlB;AAGD;;;;;;;;;;;GAWG;AACH,2CALW,MAAM,GACJ,SAAS,iBAAiB,CAAC,EAAE,CASzC;6BAlGmC,sBAAsB;qCAtBrB,8CAA8C;iDAK5E,+CAA+C;8BAiBlB,sBAAsB;mDAjBnD,+CAA+C"}
|
package/src/utils/packet.js
CHANGED
|
@@ -38,6 +38,11 @@ const CosmosResponse = CodecHelper(CosmosResponseType);
|
|
|
38
38
|
*/
|
|
39
39
|
export function makeTxPacket(msgs, opts) {
|
|
40
40
|
const messages = msgs.map(Any.fromJSON);
|
|
41
|
+
if (opts?.unordered) {
|
|
42
|
+
opts?.timeoutTimestamp ||
|
|
43
|
+
Fail`unordered packets must have a timeout timestamp`;
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
const bytes = TxBody.toProto({
|
|
42
47
|
messages,
|
|
43
48
|
...opts,
|