@agoric/orchestration 0.1.1-dev-4687f0d.0 → 0.1.1-dev-0282e58.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 +15 -15
- package/src/chain-info.d.ts +334 -74
- package/src/chain-info.d.ts.map +1 -1
- package/src/chain-info.js +3 -1
- package/src/examples/sendAnywhere.contract.d.ts +1 -1
- package/src/examples/stakeIca.contract.d.ts +3 -1
- package/src/examples/stakeIca.contract.d.ts.map +1 -1
- package/src/examples/stakeIca.contract.js +4 -2
- package/src/examples/swapExample.contract.d.ts +1 -1
- package/src/examples/swapExample.contract.d.ts.map +1 -1
- package/src/examples/swapExample.contract.js +7 -7
- package/src/examples/unbondExample.contract.d.ts +2 -3
- package/src/examples/unbondExample.contract.d.ts.map +1 -1
- package/src/examples/unbondExample.contract.js +3 -3
- package/src/exos/chainAccountKit.d.ts +2 -1
- package/src/exos/chainAccountKit.d.ts.map +1 -1
- package/src/exos/chainAccountKit.js +5 -4
- package/src/exos/local-chain-account-kit.d.ts +346 -85
- package/src/exos/local-chain-account-kit.d.ts.map +1 -1
- package/src/facade.d.ts +1 -1
- package/src/facade.d.ts.map +1 -1
- package/src/facade.js +20 -14
- package/src/fetched-chain-info.d.ts +1935 -2984
- package/src/fetched-chain-info.js +335 -73
- package/src/proposals/orchestration-proposal.d.ts +10 -6
- package/src/proposals/orchestration-proposal.d.ts.map +1 -1
- package/src/proposals/orchestration-proposal.js +43 -24
- package/src/proposals/start-stakeAtom.d.ts +1 -1
- package/src/proposals/start-stakeAtom.d.ts.map +1 -1
- package/src/proposals/start-stakeAtom.js +4 -2
- package/src/service.d.ts +2 -1
- package/src/service.d.ts.map +1 -1
- package/src/service.js +8 -3
- package/src/utils/chainHub.d.ts +378 -88
- package/src/utils/chainHub.d.ts.map +1 -1
- package/src/utils/chainHub.js +47 -19
- package/src/vat-orchestration.d.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgBH;;;;OAIG;iCAHQ,MAAM,YACN,MAAM;IAQjB;;;;OAIG;gCAHQ,MAAM,YACN,MAAM;EAoBpB;AASM,gDALI,IAAI,CAAC,OAAO,cAAc,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC,QACpD,MAAM,oCAEN,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,iBAgCzC;uBAtCa,UAAU,CAAC,OAAO,YAAY,CAAC;6BAlInB,cAAc;4BAGf,kBAAkB;0BACpB,cAAc;qCAHgB,kBAAkB;+BAC9B,kBAAkB;uCADN,kBAAkB"}
|
package/src/utils/chainHub.js
CHANGED
|
@@ -3,6 +3,8 @@ import { M, mustMatch } from '@endo/patterns';
|
|
|
3
3
|
import { makeHeapZone } from '@agoric/zone';
|
|
4
4
|
import { CosmosChainInfoShape, IBCConnectionInfoShape } from '../typeGuards.js';
|
|
5
5
|
|
|
6
|
+
const { Fail } = assert;
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* @import {NameHub} from '@agoric/vats';
|
|
8
10
|
* @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api.js';
|
|
@@ -16,6 +18,17 @@ export const CHAIN_KEY = 'chain';
|
|
|
16
18
|
/** namehub for connection info */
|
|
17
19
|
export const CONNECTIONS_KEY = 'chainConnection';
|
|
18
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Character used in a connection tuple key to separate the two chain ids. Valid
|
|
23
|
+
* because a chainId can contain only alphanumerics and dash.
|
|
24
|
+
*
|
|
25
|
+
* Vstorage keys can be only alphanumerics, dash or underscore. That leaves
|
|
26
|
+
* underscore as the only valid separator.
|
|
27
|
+
*
|
|
28
|
+
* @see {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md}
|
|
29
|
+
*/
|
|
30
|
+
const CHAIN_ID_SEPARATOR = '_';
|
|
31
|
+
|
|
19
32
|
/**
|
|
20
33
|
* The entries of the top-level namehubs in agoricNames are reflected to
|
|
21
34
|
* vstorage. But only the top level. So we combine the 2 chain ids into 1 key.
|
|
@@ -24,8 +37,15 @@ export const CONNECTIONS_KEY = 'chainConnection';
|
|
|
24
37
|
* @param {string} chainId1
|
|
25
38
|
* @param {string} chainId2
|
|
26
39
|
*/
|
|
27
|
-
export const connectionKey = (chainId1, chainId2) =>
|
|
28
|
-
|
|
40
|
+
export const connectionKey = (chainId1, chainId2) => {
|
|
41
|
+
if (
|
|
42
|
+
chainId1.includes(CHAIN_ID_SEPARATOR) ||
|
|
43
|
+
chainId2.includes(CHAIN_ID_SEPARATOR)
|
|
44
|
+
) {
|
|
45
|
+
Fail`invalid chain id ${chainId1} or ${chainId2}`;
|
|
46
|
+
}
|
|
47
|
+
return [chainId1, chainId2].sort().join(CHAIN_ID_SEPARATOR);
|
|
48
|
+
};
|
|
29
49
|
|
|
30
50
|
/**
|
|
31
51
|
* @param {Remote<NameHub>} agoricNames
|
|
@@ -84,22 +104,22 @@ export const makeChainHub = (agoricNames, zone = makeHeapZone()) => {
|
|
|
84
104
|
return chainInfo;
|
|
85
105
|
},
|
|
86
106
|
/**
|
|
87
|
-
* @param {string}
|
|
88
|
-
* @param {string}
|
|
107
|
+
* @param {string} chainId1
|
|
108
|
+
* @param {string} chainId2
|
|
89
109
|
* @param {IBCConnectionInfo} connectionInfo
|
|
90
110
|
*/
|
|
91
|
-
registerConnection(
|
|
92
|
-
const key = connectionKey(
|
|
111
|
+
registerConnection(chainId1, chainId2, connectionInfo) {
|
|
112
|
+
const key = connectionKey(chainId1, chainId2);
|
|
93
113
|
connectionInfos.init(key, connectionInfo);
|
|
94
114
|
},
|
|
95
115
|
|
|
96
116
|
/**
|
|
97
|
-
* @param {string}
|
|
98
|
-
* @param {string}
|
|
117
|
+
* @param {string} chainId1
|
|
118
|
+
* @param {string} chainId2
|
|
99
119
|
* @returns {Promise<IBCConnectionInfo>}
|
|
100
120
|
*/
|
|
101
|
-
async getConnectionInfo(
|
|
102
|
-
const key = connectionKey(
|
|
121
|
+
async getConnectionInfo(chainId1, chainId2) {
|
|
122
|
+
const key = connectionKey(chainId1, chainId2);
|
|
103
123
|
if (connectionInfos.has(key)) {
|
|
104
124
|
return connectionInfos.get(key);
|
|
105
125
|
}
|
|
@@ -107,9 +127,7 @@ export const makeChainHub = (agoricNames, zone = makeHeapZone()) => {
|
|
|
107
127
|
const connectionInfo = await E(agoricNames)
|
|
108
128
|
.lookup(CONNECTIONS_KEY, key)
|
|
109
129
|
.catch(_cause => {
|
|
110
|
-
throw assert.error(
|
|
111
|
-
`connection not found: ${srcChainId}<->${destChainId}`,
|
|
112
|
-
);
|
|
130
|
+
throw assert.error(`connection not found: ${chainId1}<->${chainId2}`);
|
|
113
131
|
});
|
|
114
132
|
connectionInfos.init(key, connectionInfo);
|
|
115
133
|
return connectionInfo;
|
|
@@ -138,12 +156,22 @@ export const registerChain = async (
|
|
|
138
156
|
|
|
139
157
|
mustMatch(chainInfo, CosmosChainInfoShape);
|
|
140
158
|
const { connections = {}, ...vertex } = chainInfo;
|
|
141
|
-
log(`registering agoricNames chain.${name}`);
|
|
142
|
-
await E(nameAdmin).update(name, vertex);
|
|
143
159
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
160
|
+
const promises = [
|
|
161
|
+
E(nameAdmin)
|
|
162
|
+
.update(name, vertex)
|
|
163
|
+
.then(() => log(`registered agoricNames chain.${name}`)),
|
|
164
|
+
];
|
|
165
|
+
|
|
166
|
+
// XXX updates redundantly, twice per edge
|
|
167
|
+
for await (const [counterChainId, connInfo] of Object.entries(connections)) {
|
|
168
|
+
const key = connectionKey(chainInfo.chainId, counterChainId);
|
|
169
|
+
promises.push(
|
|
170
|
+
E(connAdmin)
|
|
171
|
+
.update(key, connInfo)
|
|
172
|
+
.then(() => log(`registering agoricNames chainConnection.${key}`)),
|
|
173
|
+
);
|
|
148
174
|
}
|
|
175
|
+
// Bundle to pipeline IO
|
|
176
|
+
await Promise.all(promises);
|
|
149
177
|
};
|
|
@@ -6,7 +6,7 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
|
|
|
6
6
|
allocateICQControllerPort(): Promise<import("@agoric/network").Port>;
|
|
7
7
|
};
|
|
8
8
|
public: {
|
|
9
|
-
makeAccount(hostConnectionId: `connection-${number}`, controllerConnectionId: `connection-${number}`): Promise<import("./cosmos-api.js").IcaAccount>;
|
|
9
|
+
makeAccount(chainId: string, hostConnectionId: `connection-${number}`, controllerConnectionId: `connection-${number}`): Promise<import("./cosmos-api.js").IcaAccount>;
|
|
10
10
|
provideICQConnection(controllerConnectionId: `connection-${number}`): Promise<import("@endo/exo").Guarded<{
|
|
11
11
|
getLocalAddress(): `/ibc-port/${string}`;
|
|
12
12
|
getRemoteAddress(): `/${string}ibc-port/${string}/ordered/${string}` | `/${string}ibc-port/${string}/unordered/${string}`;
|
|
@@ -22,7 +22,7 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
|
|
|
22
22
|
allocateICQControllerPort(): Promise<import("@agoric/network").Port>;
|
|
23
23
|
};
|
|
24
24
|
public: {
|
|
25
|
-
makeAccount(hostConnectionId: `connection-${number}`, controllerConnectionId: `connection-${number}`): Promise<import("./cosmos-api.js").IcaAccount>;
|
|
25
|
+
makeAccount(chainId: string, hostConnectionId: `connection-${number}`, controllerConnectionId: `connection-${number}`): Promise<import("./cosmos-api.js").IcaAccount>;
|
|
26
26
|
provideICQConnection(controllerConnectionId: `connection-${number}`): Promise<import("@endo/exo").Guarded<{
|
|
27
27
|
getLocalAddress(): `/ibc-port/${string}`;
|
|
28
28
|
getRemoteAddress(): `/${string}ibc-port/${string}/ordered/${string}` | `/${string}ibc-port/${string}/unordered/${string}`;
|