@agoric/orchestration 0.1.1-dev-66bf702.0 → 0.1.1-dev-76f3e6f.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +16 -16
- package/src/chain-info.d.ts +207 -207
- package/src/chain-info.d.ts.map +1 -1
- package/src/chain-info.js +23 -7
- package/src/exos/chain-hub.d.ts +14 -12
- package/src/exos/chain-hub.d.ts.map +1 -1
- package/src/exos/chain-hub.js +108 -28
- package/src/exos/remote-chain-facade.js +1 -1
- package/src/fetched-chain-info.d.ts +204 -204
- package/src/fetched-chain-info.js +204 -204
- package/src/proposals/orchestration-proposal.js +2 -2
- package/src/proposals/start-stakeAtom.js +2 -2
- package/src/proposals/start-stakeOsmo.js +2 -2
- package/src/typeGuards.d.ts +6 -6
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +7 -7
- package/src/utils/address.js +1 -1
- package/src/utils/registry.js +2 -2
- package/src/utils/start-helper.d.ts +4 -4
package/src/chain-info.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-info.d.ts","sourceRoot":"","sources":["chain-info.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chain-info.d.ts","sourceRoot":"","sources":["chain-info.js"],"names":[],"mappings":"AA2EO,gDAPI,IAAI,CAAC,OAAO,cAAc,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC,QACpD,MAAM,aACN,eAAe,uBACD,MAAM,EAAE,KAAK,IAAI,4EA6CzC;AAQM,sDAHI,IAAI,CAAC,OAAO,cAAc,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC,uBACtC,MAAM,EAAE,KAAK,IAAI,8BAOzC;wBAzHa,eAAe,GAAG,YAAY;0BAyD9B,OAAO,WAAW;qCA3DoC,YAAY;kCAAZ,YAAY;AAAhF,oFAAoF;AAEpF,0DAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqDE"}
|
package/src/chain-info.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { E } from '@endo/far';
|
|
2
2
|
import { mustMatch } from '@endo/patterns';
|
|
3
|
-
import {
|
|
3
|
+
import { normalizeConnectionInfo } from './exos/chain-hub.js';
|
|
4
4
|
import fetchedChainInfo from './fetched-chain-info.js'; // Refresh with scripts/refresh-chain-info.ts
|
|
5
5
|
import { CosmosChainInfoShape } from './typeGuards.js';
|
|
6
6
|
|
|
7
|
-
/** @import {CosmosChainInfo, EthChainInfo} from './types.js'; */
|
|
7
|
+
/** @import {CosmosChainInfo, EthChainInfo, IBCConnectionInfo} from './types.js'; */
|
|
8
8
|
|
|
9
9
|
/** @typedef {CosmosChainInfo | EthChainInfo} ChainInfo */
|
|
10
10
|
|
|
@@ -70,12 +70,15 @@ const knownChains = /** @satisfies {Record<string, ChainInfo>} */ (
|
|
|
70
70
|
* @param {string} name
|
|
71
71
|
* @param {CosmosChainInfo} chainInfo
|
|
72
72
|
* @param {(...messages: string[]) => void} [log]
|
|
73
|
+
* @param {Set<string>} [handledConnections] connection keys that need not be
|
|
74
|
+
* updated
|
|
73
75
|
*/
|
|
74
76
|
export const registerChain = async (
|
|
75
77
|
agoricNamesAdmin,
|
|
76
78
|
name,
|
|
77
79
|
chainInfo,
|
|
78
80
|
log = () => {},
|
|
81
|
+
handledConnections = new Set(),
|
|
79
82
|
) => {
|
|
80
83
|
const { nameAdmin } = await E(agoricNamesAdmin).provideChild('chain');
|
|
81
84
|
const { nameAdmin: connAdmin } =
|
|
@@ -90,25 +93,38 @@ export const registerChain = async (
|
|
|
90
93
|
.then(() => log(`registered agoricNames chain.${name}`)),
|
|
91
94
|
];
|
|
92
95
|
|
|
93
|
-
|
|
96
|
+
const { chainId } = chainInfo;
|
|
94
97
|
for (const [counterChainId, connInfo] of Object.entries(connections)) {
|
|
95
|
-
const key =
|
|
98
|
+
const [key, connectionInfo] = normalizeConnectionInfo(
|
|
99
|
+
chainId,
|
|
100
|
+
counterChainId,
|
|
101
|
+
connInfo,
|
|
102
|
+
);
|
|
103
|
+
if (handledConnections.has(key)) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
|
|
96
107
|
promises.push(
|
|
97
108
|
E(connAdmin)
|
|
98
|
-
.update(key,
|
|
109
|
+
.update(key, connectionInfo)
|
|
99
110
|
.then(() => log(`registering agoricNames chainConnection.${key}`)),
|
|
100
111
|
);
|
|
112
|
+
|
|
113
|
+
handledConnections.add(key);
|
|
101
114
|
}
|
|
102
115
|
// Bundle to pipeline IO
|
|
103
116
|
await Promise.all(promises);
|
|
104
117
|
};
|
|
105
118
|
|
|
106
119
|
/**
|
|
120
|
+
* Register all the chains that are known statically.
|
|
121
|
+
*
|
|
107
122
|
* @param {ERef<import('@agoric/vats').NameHubKit['nameAdmin']>} agoricNamesAdmin
|
|
108
123
|
* @param {(...messages: string[]) => void} [log]
|
|
109
124
|
*/
|
|
110
|
-
export const
|
|
125
|
+
export const registerKnownChains = async (agoricNamesAdmin, log) => {
|
|
126
|
+
const handledConnections = new Set();
|
|
111
127
|
for await (const [name, info] of Object.entries(knownChains)) {
|
|
112
|
-
await registerChain(agoricNamesAdmin, name, info, log);
|
|
128
|
+
await registerChain(agoricNamesAdmin, name, info, log, handledConnections);
|
|
113
129
|
}
|
|
114
130
|
};
|
package/src/exos/chain-hub.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export const CHAIN_KEY: "chain";
|
|
|
17
17
|
/** namehub for connection info */
|
|
18
18
|
export const CONNECTIONS_KEY: "chainConnection";
|
|
19
19
|
export function connectionKey(chainId1: string, chainId2: string): string;
|
|
20
|
+
export function reverseConnInfo(connInfo: IBCConnectionInfo): IBCConnectionInfo;
|
|
21
|
+
export function normalizeConnectionInfo(primaryChainId: string, counterChainId: string, directed: IBCConnectionInfo): [string, IBCConnectionInfo];
|
|
20
22
|
export function makeChainHub(agoricNames: Remote<NameHub>, vowTools: VowTools): import("@endo/exo").Guarded<{
|
|
21
23
|
/**
|
|
22
24
|
* Register a new chain. The name will override a name in well known chain
|
|
@@ -38,40 +40,40 @@ export function makeChainHub(agoricNames: Remote<NameHub>, vowTools: VowTools):
|
|
|
38
40
|
*/
|
|
39
41
|
getChainInfo<K extends string>(chainName: K): Vow<ActualChainInfo<K>>;
|
|
40
42
|
/**
|
|
41
|
-
* @param {string}
|
|
42
|
-
* @param {string}
|
|
43
|
-
* @param {IBCConnectionInfo} connectionInfo
|
|
43
|
+
* @param {string} primaryChainId
|
|
44
|
+
* @param {string} counterpartyChainId
|
|
45
|
+
* @param {IBCConnectionInfo} connectionInfo from primary to counterparty
|
|
44
46
|
*/
|
|
45
|
-
registerConnection(
|
|
47
|
+
registerConnection(primaryChainId: string, counterpartyChainId: string, connectionInfo: IBCConnectionInfo): void;
|
|
46
48
|
/**
|
|
47
|
-
* @param {string | { chainId: string }}
|
|
48
|
-
* @param {string | { chainId: string }}
|
|
49
|
+
* @param {string | { chainId: string }} primary the primary chain
|
|
50
|
+
* @param {string | { chainId: string }} counter the counterparty chain
|
|
49
51
|
* @returns {Vow<IBCConnectionInfo>}
|
|
50
52
|
*/
|
|
51
|
-
getConnectionInfo(
|
|
53
|
+
getConnectionInfo(primary: string | {
|
|
52
54
|
chainId: string;
|
|
53
|
-
},
|
|
55
|
+
}, counter: string | {
|
|
54
56
|
chainId: string;
|
|
55
57
|
}): Vow<IBCConnectionInfo>;
|
|
56
58
|
/**
|
|
57
59
|
* @template {string} C1
|
|
58
60
|
* @template {string} C2
|
|
59
|
-
* @param {C1}
|
|
60
|
-
* @param {C2}
|
|
61
|
+
* @param {C1} primaryName the primary chain name
|
|
62
|
+
* @param {C2} counterName the counterparty chain name
|
|
61
63
|
* @returns {Vow<
|
|
62
64
|
* [ActualChainInfo<C1>, ActualChainInfo<C2>, IBCConnectionInfo]
|
|
63
65
|
* >}
|
|
64
66
|
*/
|
|
65
|
-
getChainsAndConnection<C1 extends string, C2 extends string>(
|
|
67
|
+
getChainsAndConnection<C1 extends string, C2 extends string>(primaryName: C1, counterName: C2): Vow<[ActualChainInfo<C1>, ActualChainInfo<C2>, IBCConnectionInfo]>;
|
|
66
68
|
}>;
|
|
67
69
|
export type ActualChainInfo<K extends string> = K extends keyof KnownChains ? Omit<KnownChains[K], "connections"> : ChainInfo;
|
|
68
70
|
export type ChainHub = ReturnType<typeof makeChainHub>;
|
|
71
|
+
import type { IBCConnectionInfo } from '../cosmos-api.js';
|
|
69
72
|
import type { NameHub } from '@agoric/vats';
|
|
70
73
|
import type { Remote } from '@agoric/internal';
|
|
71
74
|
import type { VowTools } from '@agoric/vow';
|
|
72
75
|
import type { CosmosChainInfo } from '../cosmos-api.js';
|
|
73
76
|
import type { Vow } from '@agoric/vow';
|
|
74
|
-
import type { IBCConnectionInfo } from '../cosmos-api.js';
|
|
75
77
|
import type { KnownChains } from '../chain-info.js';
|
|
76
78
|
import type { ChainInfo } from '../chain-info.js';
|
|
77
79
|
//# sourceMappingURL=chain-hub.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-hub.d.ts","sourceRoot":"","sources":["chain-hub.js"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AAEH;;;;;GAKG;AAEH,wCAAwC;AACxC,gCAAiC;AACjC,kCAAkC;AAClC,gDAAiD;AAqB1C,wCAHI,MAAM,YACN,MAAM,UAUhB;
|
|
1
|
+
{"version":3,"file":"chain-hub.d.ts","sourceRoot":"","sources":["chain-hub.js"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AAEH;;;;;GAKG;AA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().join(CHAIN_ID_SEPARATOR);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Utility to reverse connection info perspective.
|
|
61
|
+
*
|
|
62
|
+
* @param {IBCConnectionInfo} connInfo
|
|
63
|
+
* @returns {IBCConnectionInfo}
|
|
64
|
+
*/
|
|
65
|
+
export const reverseConnInfo = connInfo => {
|
|
66
|
+
const { transferChannel } = connInfo;
|
|
67
|
+
return {
|
|
68
|
+
id: connInfo.counterparty.connection_id,
|
|
69
|
+
client_id: connInfo.counterparty.client_id,
|
|
70
|
+
counterparty: {
|
|
71
|
+
client_id: connInfo.client_id,
|
|
72
|
+
connection_id: connInfo.id,
|
|
73
|
+
prefix: {
|
|
74
|
+
key_prefix: 'FIXME',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
state: connInfo.state,
|
|
78
|
+
transferChannel: {
|
|
79
|
+
...transferChannel,
|
|
80
|
+
channelId: transferChannel.counterPartyChannelId,
|
|
81
|
+
counterPartyChannelId: transferChannel.channelId,
|
|
82
|
+
portId: transferChannel.counterPartyPortId,
|
|
83
|
+
counterPartyPortId: transferChannel.portId,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Convert the info to an undirected form.
|
|
90
|
+
*
|
|
91
|
+
* @param {string} primaryChainId
|
|
92
|
+
* @param {string} counterChainId
|
|
93
|
+
* @param {IBCConnectionInfo} directed
|
|
94
|
+
* @returns {[string, IBCConnectionInfo]}
|
|
95
|
+
*/
|
|
96
|
+
export const normalizeConnectionInfo = (
|
|
97
|
+
primaryChainId,
|
|
98
|
+
counterChainId,
|
|
99
|
+
directed,
|
|
100
|
+
) => {
|
|
101
|
+
const key = connectionKey(primaryChainId, counterChainId);
|
|
102
|
+
if (primaryChainId < counterChainId) {
|
|
103
|
+
return [key, directed];
|
|
104
|
+
} else {
|
|
105
|
+
return [key, reverseConnInfo(directed)];
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Provide a view on the connection from the primary chain's perspective.
|
|
111
|
+
*
|
|
112
|
+
* @param {string} primaryChainId
|
|
113
|
+
* @param {string} counterChainId
|
|
114
|
+
* @param {IBCConnectionInfo} normalized
|
|
115
|
+
*/
|
|
116
|
+
const denormalizeConnectionInfo = (
|
|
117
|
+
primaryChainId,
|
|
118
|
+
counterChainId,
|
|
119
|
+
normalized,
|
|
120
|
+
) => {
|
|
121
|
+
if (primaryChainId < counterChainId) {
|
|
122
|
+
return normalized;
|
|
123
|
+
} else {
|
|
124
|
+
return reverseConnInfo(normalized);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
59
128
|
const ChainIdArgShape = M.or(
|
|
60
129
|
M.string(),
|
|
61
130
|
M.splitRecord(
|
|
@@ -146,7 +215,8 @@ export const makeChainHub = (agoricNames, vowTools) => {
|
|
|
146
215
|
if (!connectionInfos.has(key)) {
|
|
147
216
|
connectionInfos.init(key, connectionInfo);
|
|
148
217
|
}
|
|
149
|
-
|
|
218
|
+
|
|
219
|
+
return denormalizeConnectionInfo(chainId1, chainId2, connectionInfo);
|
|
150
220
|
} catch (e) {
|
|
151
221
|
console.error('lookupConnectionInfo', chainId1, chainId2, 'error', e);
|
|
152
222
|
throw makeError(`connection not found: ${chainId1}<->${chainId2}`);
|
|
@@ -161,26 +231,26 @@ export const makeChainHub = (agoricNames, vowTools) => {
|
|
|
161
231
|
/**
|
|
162
232
|
* @template {string} C1
|
|
163
233
|
* @template {string} C2
|
|
164
|
-
* @param {C1}
|
|
165
|
-
* @param {C2}
|
|
234
|
+
* @param {C1} primaryName
|
|
235
|
+
* @param {C2} counterName
|
|
166
236
|
* @returns {Promise<
|
|
167
237
|
* [ActualChainInfo<C1>, ActualChainInfo<C2>, IBCConnectionInfo]
|
|
168
238
|
* >}
|
|
169
239
|
*/
|
|
170
240
|
// eslint-disable-next-line no-restricted-syntax -- TODO more exact rules for vow best practices
|
|
171
|
-
async (
|
|
172
|
-
const [
|
|
241
|
+
async (primaryName, counterName) => {
|
|
242
|
+
const [primary, counter] = await vowTools.asPromise(
|
|
173
243
|
vowTools.allVows([
|
|
174
|
-
chainHub.getChainInfo(
|
|
175
|
-
chainHub.getChainInfo(
|
|
244
|
+
chainHub.getChainInfo(primaryName),
|
|
245
|
+
chainHub.getChainInfo(counterName),
|
|
176
246
|
]),
|
|
177
247
|
);
|
|
178
248
|
const connectionInfo = await vowTools.asPromise(
|
|
179
|
-
chainHub.getConnectionInfo(
|
|
249
|
+
chainHub.getConnectionInfo(primary, counter),
|
|
180
250
|
);
|
|
181
251
|
return /** @type {[ActualChainInfo<C1>, ActualChainInfo<C2>, IBCConnectionInfo]} */ ([
|
|
182
|
-
|
|
183
|
-
|
|
252
|
+
primary,
|
|
253
|
+
counter,
|
|
184
254
|
connectionInfo,
|
|
185
255
|
]);
|
|
186
256
|
},
|
|
@@ -218,43 +288,53 @@ export const makeChainHub = (agoricNames, vowTools) => {
|
|
|
218
288
|
return lookupChainInfo(chainName);
|
|
219
289
|
},
|
|
220
290
|
/**
|
|
221
|
-
* @param {string}
|
|
222
|
-
* @param {string}
|
|
223
|
-
* @param {IBCConnectionInfo} connectionInfo
|
|
291
|
+
* @param {string} primaryChainId
|
|
292
|
+
* @param {string} counterpartyChainId
|
|
293
|
+
* @param {IBCConnectionInfo} connectionInfo from primary to counterparty
|
|
224
294
|
*/
|
|
225
|
-
registerConnection(
|
|
226
|
-
const key =
|
|
227
|
-
|
|
295
|
+
registerConnection(primaryChainId, counterpartyChainId, connectionInfo) {
|
|
296
|
+
const [key, normalized] = normalizeConnectionInfo(
|
|
297
|
+
primaryChainId,
|
|
298
|
+
counterpartyChainId,
|
|
299
|
+
connectionInfo,
|
|
300
|
+
);
|
|
301
|
+
connectionInfos.init(key, normalized);
|
|
228
302
|
},
|
|
229
303
|
|
|
230
304
|
/**
|
|
231
|
-
* @param {string | { chainId: string }}
|
|
232
|
-
* @param {string | { chainId: string }}
|
|
305
|
+
* @param {string | { chainId: string }} primary the primary chain
|
|
306
|
+
* @param {string | { chainId: string }} counter the counterparty chain
|
|
233
307
|
* @returns {Vow<IBCConnectionInfo>}
|
|
234
308
|
*/
|
|
235
|
-
getConnectionInfo(
|
|
236
|
-
const
|
|
237
|
-
const
|
|
238
|
-
const key = connectionKey(
|
|
309
|
+
getConnectionInfo(primary, counter) {
|
|
310
|
+
const primaryId = typeof primary === 'string' ? primary : primary.chainId;
|
|
311
|
+
const counterId = typeof counter === 'string' ? counter : counter.chainId;
|
|
312
|
+
const key = connectionKey(primaryId, counterId);
|
|
239
313
|
if (connectionInfos.has(key)) {
|
|
240
|
-
return vowTools.asVow(() =>
|
|
314
|
+
return vowTools.asVow(() =>
|
|
315
|
+
denormalizeConnectionInfo(
|
|
316
|
+
primaryId,
|
|
317
|
+
counterId,
|
|
318
|
+
connectionInfos.get(key),
|
|
319
|
+
),
|
|
320
|
+
);
|
|
241
321
|
}
|
|
242
322
|
|
|
243
|
-
return lookupConnectionInfo(
|
|
323
|
+
return lookupConnectionInfo(primaryId, counterId);
|
|
244
324
|
},
|
|
245
325
|
|
|
246
326
|
/**
|
|
247
327
|
* @template {string} C1
|
|
248
328
|
* @template {string} C2
|
|
249
|
-
* @param {C1}
|
|
250
|
-
* @param {C2}
|
|
329
|
+
* @param {C1} primaryName the primary chain name
|
|
330
|
+
* @param {C2} counterName the counterparty chain name
|
|
251
331
|
* @returns {Vow<
|
|
252
332
|
* [ActualChainInfo<C1>, ActualChainInfo<C2>, IBCConnectionInfo]
|
|
253
333
|
* >}
|
|
254
334
|
*/
|
|
255
|
-
getChainsAndConnection(
|
|
335
|
+
getChainsAndConnection(primaryName, counterName) {
|
|
256
336
|
// @ts-expect-error XXX generic parameter propagation
|
|
257
|
-
return lookupChainsAndConnection(
|
|
337
|
+
return lookupChainsAndConnection(primaryName, counterName);
|
|
258
338
|
},
|
|
259
339
|
});
|
|
260
340
|
|
|
@@ -101,8 +101,8 @@ const prepareRemoteChainFacadeKit = (
|
|
|
101
101
|
return watch(
|
|
102
102
|
E(orchestration).makeAccount(
|
|
103
103
|
remoteChainInfo.chainId,
|
|
104
|
-
connectionInfo.id,
|
|
105
104
|
connectionInfo.counterparty.connection_id,
|
|
105
|
+
connectionInfo.id,
|
|
106
106
|
),
|
|
107
107
|
this.facets.makeAccountWatcher,
|
|
108
108
|
);
|