@agoric/orchestration 0.1.1-dev-31a57fc.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 +2 -2
- package/src/chain-info.d.ts.map +1 -1
- package/src/chain-info.js +20 -37
- 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/proposals/orchestration-proposal.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/start-helper.d.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/orchestration",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-76f3e6f.0+76f3e6f",
|
|
4
4
|
"description": "Chain abstraction for Agoric's orchestration clients",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@agoric/async-flow": "0.1.1-dev-
|
|
37
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
38
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
39
|
-
"@agoric/internal": "0.3.3-dev-
|
|
40
|
-
"@agoric/network": "0.1.1-dev-
|
|
41
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
42
|
-
"@agoric/store": "0.9.3-dev-
|
|
43
|
-
"@agoric/time": "0.3.3-dev-
|
|
44
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
45
|
-
"@agoric/vats": "0.15.2-dev-
|
|
46
|
-
"@agoric/vow": "0.1.1-dev-
|
|
47
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
48
|
-
"@agoric/zone": "0.2.3-dev-
|
|
36
|
+
"@agoric/async-flow": "0.1.1-dev-76f3e6f.0+76f3e6f",
|
|
37
|
+
"@agoric/cosmic-proto": "0.4.1-dev-76f3e6f.0+76f3e6f",
|
|
38
|
+
"@agoric/ertp": "0.16.3-dev-76f3e6f.0+76f3e6f",
|
|
39
|
+
"@agoric/internal": "0.3.3-dev-76f3e6f.0+76f3e6f",
|
|
40
|
+
"@agoric/network": "0.1.1-dev-76f3e6f.0+76f3e6f",
|
|
41
|
+
"@agoric/notifier": "0.6.3-dev-76f3e6f.0+76f3e6f",
|
|
42
|
+
"@agoric/store": "0.9.3-dev-76f3e6f.0+76f3e6f",
|
|
43
|
+
"@agoric/time": "0.3.3-dev-76f3e6f.0+76f3e6f",
|
|
44
|
+
"@agoric/vat-data": "0.5.3-dev-76f3e6f.0+76f3e6f",
|
|
45
|
+
"@agoric/vats": "0.15.2-dev-76f3e6f.0+76f3e6f",
|
|
46
|
+
"@agoric/vow": "0.1.1-dev-76f3e6f.0+76f3e6f",
|
|
47
|
+
"@agoric/zoe": "0.26.3-dev-76f3e6f.0+76f3e6f",
|
|
48
|
+
"@agoric/zone": "0.2.3-dev-76f3e6f.0+76f3e6f",
|
|
49
49
|
"@endo/base64": "^1.0.5",
|
|
50
50
|
"@endo/errors": "^1.2.2",
|
|
51
51
|
"@endo/far": "^1.1.2",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@noble/hashes": "github:paulmillr/noble-hashes#ae060da"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
57
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-76f3e6f.0+76f3e6f",
|
|
58
58
|
"@chain-registry/client": "^1.47.4",
|
|
59
59
|
"@cosmjs/amino": "^0.32.3",
|
|
60
60
|
"@cosmjs/proto-signing": "^0.32.3",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"typeCoverage": {
|
|
95
95
|
"atLeast": 97.99
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "76f3e6f282aff177b906d23b036c7ca9d22e0ed1"
|
|
98
98
|
}
|
package/src/chain-info.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function registerChain(agoricNamesAdmin: ERef<import("@agoric/vats").NameHubKit["nameAdmin"]>, name: string, chainInfo: CosmosChainInfo, log?: ((...messages: string[]) => void) | undefined): Promise<void>;
|
|
2
|
-
export function
|
|
1
|
+
export function registerChain(agoricNamesAdmin: ERef<import("@agoric/vats").NameHubKit["nameAdmin"]>, name: string, chainInfo: CosmosChainInfo, log?: ((...messages: string[]) => void) | undefined, handledConnections?: Set<string> | undefined): Promise<void>;
|
|
2
|
+
export function registerKnownChains(agoricNamesAdmin: ERef<import("@agoric/vats").NameHubKit["nameAdmin"]>, log?: ((...messages: string[]) => void) | undefined): Promise<void>;
|
|
3
3
|
export type ChainInfo = CosmosChainInfo | EthChainInfo;
|
|
4
4
|
export type KnownChains = typeof knownChains;
|
|
5
5
|
import type { CosmosChainInfo } from './types.js';
|
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,YA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqDE"}
|
package/src/chain-info.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
|
|
|
@@ -65,46 +65,20 @@ const knownChains = /** @satisfies {Record<string, ChainInfo>} */ (
|
|
|
65
65
|
|
|
66
66
|
/** @typedef {typeof knownChains} KnownChains */
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
* Utility to reverse connection info perspective.
|
|
70
|
-
*
|
|
71
|
-
* @param {IBCConnectionInfo} connInfo
|
|
72
|
-
* @returns {IBCConnectionInfo}
|
|
73
|
-
*/
|
|
74
|
-
const reverseConnInfo = connInfo => {
|
|
75
|
-
const { transferChannel } = connInfo;
|
|
76
|
-
return {
|
|
77
|
-
id: connInfo.counterparty.connection_id,
|
|
78
|
-
client_id: connInfo.counterparty.client_id,
|
|
79
|
-
counterparty: {
|
|
80
|
-
client_id: connInfo.client_id,
|
|
81
|
-
connection_id: connInfo.id,
|
|
82
|
-
prefix: {
|
|
83
|
-
key_prefix: '',
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
state: connInfo.state,
|
|
87
|
-
transferChannel: {
|
|
88
|
-
...transferChannel,
|
|
89
|
-
channelId: transferChannel.counterPartyChannelId,
|
|
90
|
-
counterPartyChannelId: transferChannel.channelId,
|
|
91
|
-
portId: transferChannel.counterPartyPortId,
|
|
92
|
-
counterPartyPortId: transferChannel.portId,
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
|
|
97
68
|
/**
|
|
98
69
|
* @param {ERef<import('@agoric/vats').NameHubKit['nameAdmin']>} agoricNamesAdmin
|
|
99
70
|
* @param {string} name
|
|
100
71
|
* @param {CosmosChainInfo} chainInfo
|
|
101
72
|
* @param {(...messages: string[]) => void} [log]
|
|
73
|
+
* @param {Set<string>} [handledConnections] connection keys that need not be
|
|
74
|
+
* updated
|
|
102
75
|
*/
|
|
103
76
|
export const registerChain = async (
|
|
104
77
|
agoricNamesAdmin,
|
|
105
78
|
name,
|
|
106
79
|
chainInfo,
|
|
107
80
|
log = () => {},
|
|
81
|
+
handledConnections = new Set(),
|
|
108
82
|
) => {
|
|
109
83
|
const { nameAdmin } = await E(agoricNamesAdmin).provideChild('chain');
|
|
110
84
|
const { nameAdmin: connAdmin } =
|
|
@@ -120,28 +94,37 @@ export const registerChain = async (
|
|
|
120
94
|
];
|
|
121
95
|
|
|
122
96
|
const { chainId } = chainInfo;
|
|
123
|
-
// FIXME updates redundantly, twice per edge
|
|
124
97
|
for (const [counterChainId, connInfo] of Object.entries(connections)) {
|
|
125
|
-
const key =
|
|
126
|
-
|
|
127
|
-
|
|
98
|
+
const [key, connectionInfo] = normalizeConnectionInfo(
|
|
99
|
+
chainId,
|
|
100
|
+
counterChainId,
|
|
101
|
+
connInfo,
|
|
102
|
+
);
|
|
103
|
+
if (handledConnections.has(key)) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
128
106
|
|
|
129
107
|
promises.push(
|
|
130
108
|
E(connAdmin)
|
|
131
|
-
.update(key,
|
|
109
|
+
.update(key, connectionInfo)
|
|
132
110
|
.then(() => log(`registering agoricNames chainConnection.${key}`)),
|
|
133
111
|
);
|
|
112
|
+
|
|
113
|
+
handledConnections.add(key);
|
|
134
114
|
}
|
|
135
115
|
// Bundle to pipeline IO
|
|
136
116
|
await Promise.all(promises);
|
|
137
117
|
};
|
|
138
118
|
|
|
139
119
|
/**
|
|
120
|
+
* Register all the chains that are known statically.
|
|
121
|
+
*
|
|
140
122
|
* @param {ERef<import('@agoric/vats').NameHubKit['nameAdmin']>} agoricNamesAdmin
|
|
141
123
|
* @param {(...messages: string[]) => void} [log]
|
|
142
124
|
*/
|
|
143
|
-
export const
|
|
125
|
+
export const registerKnownChains = async (agoricNamesAdmin, log) => {
|
|
126
|
+
const handledConnections = new Set();
|
|
144
127
|
for await (const [name, info] of Object.entries(knownChains)) {
|
|
145
|
-
await registerChain(agoricNamesAdmin, name, info, log);
|
|
128
|
+
await registerChain(agoricNamesAdmin, name, info, log, handledConnections);
|
|
146
129
|
}
|
|
147
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;AAEH,wCAAwC;AACxC,gCAAiC;AACjC,kCAAkC;AAClC,gDAAiD;AAqB1C,wCAHI,MAAM,YACN,MAAM,UAUhB;AAQM,0CAHI,iBAAiB,GACf,iBAAiB,CAuB7B;AAUM,wDALI,MAAM,kBACN,MAAM,YACN,iBAAiB,GACf,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAavC;AAuDM,0CAHI,OAAO,OAAO,CAAC,YACf,QAAQ;IAoGf;;;;;;;;;;;OAWG;wBAFQ,MAAM,aACN,eAAe;IAK1B;;;;OAIG;iBAHmB,CAAC,SAAV,MAAQ,aACV,CAAC,GACC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC;IAYpC;;;;OAIG;uCAHQ,MAAM,uBACN,MAAM,kBACN,iBAAiB;IAW5B;;;;OAIG;+BAHQ,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,WAC5B,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAC1B,IAAI,iBAAiB,CAAC;IAmBnC;;;;;;;;OAQG;2BAPmB,EAAE,SAAX,MAAQ,EACC,EAAE,SAAX,MAAQ,eACV,EAAE,eACF,EAAE,GACA,IACZ,CAAK,eAAe,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,EAAE,CAAC,EAAE,iBAAiB,CAAC,CAC9D;GASP;4BAnUqB,CAAC,SAAV,MAAQ,IACR,CAAC,SAAS,MAAM,WAAW,GACjC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,GACnC,SAAS;uBAiUF,UAAU,CAAC,OAAO,YAAY,CAAC;uCA3UQ,kBAAkB;6BAF7C,cAAc;4BAIf,kBAAkB;8BAHX,aAAa;qCACQ,kBAAkB;yBADvC,aAAa;iCAEJ,kBAAkB;+BAAlB,kBAAkB"}
|
package/src/exos/chain-hub.js
CHANGED
|
@@ -56,6 +56,75 @@ export const connectionKey = (chainId1, chainId2) => {
|
|
|
56
56
|
return [chainId1, chainId2].sort().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
|
|
|
@@ -2,7 +2,7 @@ import { Fail } from '@endo/errors';
|
|
|
2
2
|
import { E, Far } from '@endo/far';
|
|
3
3
|
import { makeMarshal } from '@endo/marshal';
|
|
4
4
|
import { makeTracer } from '@agoric/internal';
|
|
5
|
-
import {
|
|
5
|
+
import { registerKnownChains } from '../chain-info.js';
|
|
6
6
|
import { CHAIN_KEY, CONNECTIONS_KEY } from '../exos/chain-hub.js';
|
|
7
7
|
|
|
8
8
|
const trace = makeTracer('CoreEvalOrchestration', true);
|
|
@@ -127,7 +127,7 @@ export const initChainInfo = async ({
|
|
|
127
127
|
await publishChainInfoToChainStorage(agoricNamesAdmin, chainStorageP);
|
|
128
128
|
|
|
129
129
|
// Now register the names
|
|
130
|
-
await
|
|
130
|
+
await registerKnownChains(agoricNamesAdmin, trace);
|
|
131
131
|
};
|
|
132
132
|
harden(initChainInfo);
|
|
133
133
|
|
package/src/typeGuards.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @import {TypedPattern} from '@agoric/internal';
|
|
3
|
-
* @import {CosmosChainInfo} from './
|
|
3
|
+
* @import {ChainInfo, CosmosChainInfo} from './types.js';
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Used for IBC Channel Connections that only send outgoing transactions. If
|
|
@@ -42,11 +42,10 @@ export const IBCChannelIDShape: import("@endo/patterns").Matcher;
|
|
|
42
42
|
export const IBCChannelInfoShape: import("@endo/patterns").Matcher;
|
|
43
43
|
export const IBCConnectionIDShape: import("@endo/patterns").Matcher;
|
|
44
44
|
export const IBCConnectionInfoShape: import("@endo/patterns").Matcher;
|
|
45
|
-
/**
|
|
46
|
-
* @type {TypedPattern<CosmosChainInfo>}
|
|
47
|
-
*/
|
|
45
|
+
/** @type {TypedPattern<CosmosChainInfo>} */
|
|
48
46
|
export const CosmosChainInfoShape: TypedPattern<CosmosChainInfo>;
|
|
49
|
-
|
|
47
|
+
/** @type {TypedPattern<ChainInfo>} */
|
|
48
|
+
export const ChainInfoShape: TypedPattern<ChainInfo>;
|
|
50
49
|
export const LocalChainAccountShape: import("@endo/patterns").Matcher;
|
|
51
50
|
export const DenomShape: import("@endo/patterns").Matcher;
|
|
52
51
|
export const BrandInfoShape: import("@endo/patterns").Matcher;
|
|
@@ -64,6 +63,7 @@ export namespace TimestampProtoShape {
|
|
|
64
63
|
let seconds: import("@endo/patterns").Matcher;
|
|
65
64
|
let nanos: import("@endo/patterns").Matcher;
|
|
66
65
|
}
|
|
67
|
-
import type { CosmosChainInfo } from './
|
|
66
|
+
import type { CosmosChainInfo } from './types.js';
|
|
68
67
|
import type { TypedPattern } from '@agoric/internal';
|
|
68
|
+
import type { ChainInfo } from './types.js';
|
|
69
69
|
//# sourceMappingURL=typeGuards.d.ts.map
|
package/src/typeGuards.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA;;;GAGG;AAEH;;;;GAIG;AACH;;;GAQE;;;;;;;;;;;;;;;;;;;;;;AAiBF,8DAAkE;;;;;AAOlE,uEAUE;AAEF,iEAA4C;AAC5C,mEAQG;AACH,oEAA+C;AAC/C,sEAYG;AAEH
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA;;;GAGG;AAEH;;;;GAIG;AACH;;;GAQE;;;;;;;;;;;;;;;;;;;;;;AAiBF,8DAAkE;;;;;AAOlE,uEAUE;AAEF,iEAA4C;AAC5C,mEAQG;AACH,oEAA+C;AAC/C,sEAYG;AAEH,4CAA4C;AAC5C,mCADW,aAAa,eAAe,CAAC,CAWtC;AAEF,sCAAsC;AACtC,6BADW,aAAa,SAAS,CAAC,CAG/B;AACH,sEAAuE;AACvE,0DAAqC;AAErC,8DAAsC;;;;;;AAItC,mBAAmB;AACnB;;;GAGG;;;;;qCAzG0C,YAAY;kCAD1B,kBAAkB;+BACJ,YAAY"}
|
package/src/typeGuards.js
CHANGED
|
@@ -4,7 +4,7 @@ import { M } from '@endo/patterns';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @import {TypedPattern} from '@agoric/internal';
|
|
7
|
-
* @import {CosmosChainInfo} from './
|
|
7
|
+
* @import {ChainInfo, CosmosChainInfo} from './types.js';
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -81,9 +81,7 @@ export const IBCConnectionInfoShape = M.splitRecord({
|
|
|
81
81
|
transferChannel: IBCChannelInfoShape,
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
/**
|
|
85
|
-
* @type {TypedPattern<CosmosChainInfo>}
|
|
86
|
-
*/
|
|
84
|
+
/** @type {TypedPattern<CosmosChainInfo>} */
|
|
87
85
|
export const CosmosChainInfoShape = M.splitRecord(
|
|
88
86
|
{
|
|
89
87
|
chainId: M.string(),
|
|
@@ -96,11 +94,13 @@ export const CosmosChainInfoShape = M.splitRecord(
|
|
|
96
94
|
},
|
|
97
95
|
);
|
|
98
96
|
|
|
99
|
-
|
|
100
|
-
export const ChainInfoShape = M.
|
|
97
|
+
/** @type {TypedPattern<ChainInfo>} */
|
|
98
|
+
export const ChainInfoShape = M.splitRecord({
|
|
99
|
+
chainId: M.string(),
|
|
100
|
+
});
|
|
101
101
|
export const LocalChainAccountShape = M.remotable('LocalChainAccount');
|
|
102
102
|
export const DenomShape = M.string();
|
|
103
|
-
//
|
|
103
|
+
// TODO define for #9211
|
|
104
104
|
export const BrandInfoShape = M.any();
|
|
105
105
|
|
|
106
106
|
export const DenomAmountShape = { denom: DenomShape, value: M.bigint() };
|
|
@@ -2,13 +2,13 @@ export function provideOrchestration(zcf: ZCF, baggage: Baggage, remotePowers: O
|
|
|
2
2
|
chainHub: import("@endo/exo").Guarded<{
|
|
3
3
|
registerChain(name: string, chainInfo: import("../cosmos-api.js").CosmosChainInfo): void;
|
|
4
4
|
getChainInfo<K extends string>(chainName: K): import("@agoric/vow").Vow<ActualChainInfo<K>>;
|
|
5
|
-
registerConnection(
|
|
6
|
-
getConnectionInfo(
|
|
5
|
+
registerConnection(primaryChainId: string, counterpartyChainId: string, connectionInfo: import("../cosmos-api.js").IBCConnectionInfo): void;
|
|
6
|
+
getConnectionInfo(primary: string | {
|
|
7
7
|
chainId: string;
|
|
8
|
-
},
|
|
8
|
+
}, counter: string | {
|
|
9
9
|
chainId: string;
|
|
10
10
|
}): import("@agoric/vow").Vow<import("../cosmos-api.js").IBCConnectionInfo>;
|
|
11
|
-
getChainsAndConnection<C1 extends string, C2 extends string>(
|
|
11
|
+
getChainsAndConnection<C1 extends string, C2 extends string>(primaryName: C1, counterName: C2): import("@agoric/vow").Vow<[ActualChainInfo<C1>, ActualChainInfo<C2>, import("../cosmos-api.js").IBCConnectionInfo]>;
|
|
12
12
|
}>;
|
|
13
13
|
vowTools: {
|
|
14
14
|
when: <T, TResult1 = import("@agoric/vow").EUnwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("@agoric/vow").EUnwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
|