@agoric/orchestration 0.1.1-dev-788647d.0 → 0.1.1-dev-01a1123.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/orchestration",
3
- "version": "0.1.1-dev-788647d.0+788647d",
3
+ "version": "0.1.1-dev-01a1123.0+01a1123",
4
4
  "description": "Chain abstraction for Agoric's orchestration clients",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -33,20 +33,20 @@
33
33
  },
34
34
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
35
35
  "dependencies": {
36
- "@agoric/assert": "0.6.1-dev-788647d.0+788647d",
37
- "@agoric/async-flow": "0.1.1-dev-788647d.0+788647d",
38
- "@agoric/cosmic-proto": "0.4.1-dev-788647d.0+788647d",
39
- "@agoric/ertp": "0.16.3-dev-788647d.0+788647d",
40
- "@agoric/internal": "0.3.3-dev-788647d.0+788647d",
41
- "@agoric/network": "0.1.1-dev-788647d.0+788647d",
42
- "@agoric/notifier": "0.6.3-dev-788647d.0+788647d",
43
- "@agoric/store": "0.9.3-dev-788647d.0+788647d",
44
- "@agoric/time": "0.3.3-dev-788647d.0+788647d",
45
- "@agoric/vat-data": "0.5.3-dev-788647d.0+788647d",
46
- "@agoric/vats": "0.15.2-dev-788647d.0+788647d",
47
- "@agoric/vow": "0.1.1-dev-788647d.0+788647d",
48
- "@agoric/zoe": "0.26.3-dev-788647d.0+788647d",
49
- "@agoric/zone": "0.2.3-dev-788647d.0+788647d",
36
+ "@agoric/assert": "0.6.1-dev-01a1123.0+01a1123",
37
+ "@agoric/async-flow": "0.1.1-dev-01a1123.0+01a1123",
38
+ "@agoric/cosmic-proto": "0.4.1-dev-01a1123.0+01a1123",
39
+ "@agoric/ertp": "0.16.3-dev-01a1123.0+01a1123",
40
+ "@agoric/internal": "0.3.3-dev-01a1123.0+01a1123",
41
+ "@agoric/network": "0.1.1-dev-01a1123.0+01a1123",
42
+ "@agoric/notifier": "0.6.3-dev-01a1123.0+01a1123",
43
+ "@agoric/store": "0.9.3-dev-01a1123.0+01a1123",
44
+ "@agoric/time": "0.3.3-dev-01a1123.0+01a1123",
45
+ "@agoric/vat-data": "0.5.3-dev-01a1123.0+01a1123",
46
+ "@agoric/vats": "0.15.2-dev-01a1123.0+01a1123",
47
+ "@agoric/vow": "0.1.1-dev-01a1123.0+01a1123",
48
+ "@agoric/zoe": "0.26.3-dev-01a1123.0+01a1123",
49
+ "@agoric/zone": "0.2.3-dev-01a1123.0+01a1123",
50
50
  "@endo/base64": "^1.0.5",
51
51
  "@endo/far": "^1.1.2",
52
52
  "@endo/marshal": "^1.5.0",
@@ -90,5 +90,5 @@
90
90
  "typeCoverage": {
91
91
  "atLeast": 97.1
92
92
  },
93
- "gitHead": "788647d162386a8ab80ce1928645dc3712d7c0f6"
93
+ "gitHead": "01a1123a526b11e11fa1ef80e0c532a616cd29b9"
94
94
  }
@@ -0,0 +1,21 @@
1
+ export function reviseChainInfo({ consume: { agoricNamesAdmin } }: BootstrapPowers, { options: { chainInfo } }: {
2
+ options: {
3
+ chainInfo: Record<string, CosmosChainInfo>;
4
+ };
5
+ }): Promise<void>;
6
+ export function getManifestForReviseChains(_powers: any, { chainInfo }: {
7
+ chainInfo: any;
8
+ }): {
9
+ manifest: {
10
+ [x: string]: {
11
+ consume: {
12
+ agoricNamesAdmin: boolean;
13
+ };
14
+ };
15
+ };
16
+ options: {
17
+ chainInfo: any;
18
+ };
19
+ };
20
+ import type { CosmosChainInfo } from '../types.js';
21
+ //# sourceMappingURL=revise-chain-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revise-chain-info.d.ts","sourceRoot":"","sources":["revise-chain-info.js"],"names":[],"mappings":"AAeO,mEAHI,eAAe,8BACf;IAAE,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;KAAE,CAAA;CAAE,iBAgBrE;AAGM;;;;;;;;;;;;;EAWL;qCAtCiC,aAAa"}
@@ -0,0 +1,44 @@
1
+ import { makeTracer } from '@agoric/internal';
2
+ import { registerChain } from '../chain-info.js';
3
+
4
+ const trace = makeTracer('ReviseChainInfo', true);
5
+
6
+ /** @import {CosmosChainInfo} from '../types.js'; */
7
+
8
+ /**
9
+ * This will add news values AND overwrite any existing values. Voters on a
10
+ * proposal of core-eval must be careful not to overwrite any values operating
11
+ * in production.
12
+ *
13
+ * @param {BootstrapPowers} powers
14
+ * @param {{ options: { chainInfo: Record<string, CosmosChainInfo> } }} opt
15
+ */
16
+ export const reviseChainInfo = async (
17
+ { consume: { agoricNamesAdmin } },
18
+ { options: { chainInfo } },
19
+ ) => {
20
+ trace('init-chainInfo');
21
+
22
+ assert(chainInfo, 'chainInfo is required');
23
+
24
+ trace(chainInfo);
25
+
26
+ // Now register the names
27
+ for await (const [name, info] of Object.entries(chainInfo)) {
28
+ await registerChain(agoricNamesAdmin, name, info, trace);
29
+ }
30
+ };
31
+ harden(reviseChainInfo);
32
+
33
+ export const getManifestForReviseChains = (_powers, { chainInfo }) => ({
34
+ manifest: {
35
+ [reviseChainInfo.name]: {
36
+ consume: {
37
+ agoricNamesAdmin: true,
38
+ },
39
+ },
40
+ },
41
+ options: {
42
+ chainInfo,
43
+ },
44
+ });
@@ -0,0 +1,13 @@
1
+ export function convertChainInfo(registry: Pick<ChainRegistryClient, "chains" | "ibcData">): Promise<{
2
+ [k: string]: Readonly<{
3
+ chainId: string;
4
+ connections?: Record<string, IBCConnectionInfo>;
5
+ icqEnabled?: boolean;
6
+ stakingTokens?: Readonly<Array<{
7
+ denom: string;
8
+ }>>;
9
+ }>;
10
+ }>;
11
+ import type { ChainRegistryClient } from '@chain-registry/client';
12
+ import type { IBCConnectionInfo } from '../cosmos-api.js';
13
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["registry.js"],"names":[],"mappings":"AAwFO,2CAFI,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,SAAS,CAAC;;;;;;;;;GA4CzD;yCAxHqC,wBAAwB;uCACT,kBAAkB"}
@@ -0,0 +1,131 @@
1
+ import {
2
+ State as IBCChannelState,
3
+ Order,
4
+ } from '@agoric/cosmic-proto/ibc/core/channel/v1/channel.js';
5
+ import { State as IBCConnectionState } from '@agoric/cosmic-proto/ibc/core/connection/v1/connection.js';
6
+ import assert from 'node:assert';
7
+
8
+ /**
9
+ * @import {IBCChannelID, IBCConnectionID} from '@agoric/vats';
10
+ * @import {Chain, IBCInfo} from '@chain-registry/types';
11
+ * @import {ChainRegistryClient} from '@chain-registry/client';
12
+ * @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api.js';
13
+ */
14
+
15
+ /**
16
+ * @param {IBCInfo} ibcInfo
17
+ * @param {string} name
18
+ * @param {Record<string, CosmosChainInfo>} chainInfo
19
+ * @returns {[string, IBCConnectionInfo] | []}
20
+ */
21
+ function toConnectionEntry(ibcInfo, name, chainInfo) {
22
+ // IbcInfo encodes the undirected edge as a tuple of (chain_1, chain_2) in alphabetical order
23
+ const fromChain1 = ibcInfo.chain_1.chain_name === name;
24
+ const [from, to] = fromChain1
25
+ ? [ibcInfo.chain_1, ibcInfo.chain_2]
26
+ : [ibcInfo.chain_2, ibcInfo.chain_1];
27
+ assert.equal(from.chain_name, name);
28
+ const transferChannels = ibcInfo.channels.filter(
29
+ c =>
30
+ c.chain_1.port_id === 'transfer' &&
31
+ // @ts-expect-error tags does not specify keys
32
+ c.tags?.preferred,
33
+ );
34
+ if (transferChannels.length === 0) {
35
+ console.warn(
36
+ 'no transfer channel for [',
37
+ from.chain_name,
38
+ to.chain_name,
39
+ ']',
40
+ '(skipping)',
41
+ );
42
+ return [];
43
+ }
44
+ if (transferChannels.length > 1) {
45
+ console.warn(
46
+ 'multiple preferred transfer channels [',
47
+ from.chain_name,
48
+ to.chain_name,
49
+ ']:',
50
+ transferChannels,
51
+ '(choosing first)',
52
+ );
53
+ }
54
+ const [channel] = transferChannels;
55
+ const [channelFrom, channelTo] = fromChain1
56
+ ? [channel.chain_2, channel.chain_1]
57
+ : [channel.chain_1, channel.chain_2];
58
+ const record = {
59
+ id: /** @type {IBCConnectionID} */ (from.connection_id),
60
+ client_id: from.client_id,
61
+ counterparty: {
62
+ client_id: to.client_id,
63
+ connection_id: /** @type {IBCConnectionID} */ (to.connection_id),
64
+ prefix: {
65
+ key_prefix: 'FIXME',
66
+ },
67
+ },
68
+ state: IBCConnectionState.STATE_OPEN, // XXX presumably
69
+ transferChannel: {
70
+ channelId: /** @type {IBCChannelID} */ (channelFrom.channel_id),
71
+ portId: channelFrom.port_id,
72
+ counterPartyChannelId: /** @type {IBCChannelID} */ (channelTo.channel_id),
73
+ counterPartyPortId: channelTo.port_id,
74
+ // FIXME mapping, our guard expects a numerical enum
75
+ ordering: Order.ORDER_NONE_UNSPECIFIED,
76
+ state: IBCChannelState.STATE_OPEN, // XXX presumably
77
+ version: channel.version,
78
+ },
79
+ };
80
+ const destChainId = chainInfo[to.chain_name].chainId;
81
+ return [destChainId, record];
82
+ }
83
+
84
+ /**
85
+ * Converts the given chain info to our local config format
86
+ *
87
+ * @param {Pick<ChainRegistryClient, 'chains' | 'ibcData'>} registry
88
+ */
89
+ export const convertChainInfo = async registry => {
90
+ /** @type {Record<string, CosmosChainInfo>} */
91
+ const chainInfo = {};
92
+
93
+ for (const chain of registry.chains) {
94
+ console.log('processing info', chain.chain_name);
95
+ chainInfo[chain.chain_name] = {
96
+ chainId: chain.chain_id,
97
+ stakingTokens: chain.staking?.staking_tokens,
98
+ // UNTIL https://github.com/Agoric/agoric-sdk/issues/9326
99
+ icqEnabled: chain.chain_name === 'osmosis',
100
+ };
101
+ }
102
+
103
+ // XXX probably easier to keep ibc separate
104
+ const ibcLookup = {};
105
+ for (const ibc of registry.ibcData) {
106
+ ibcLookup[ibc.chain_1.chain_name] ||= [];
107
+ ibcLookup[ibc.chain_2.chain_name] ||= [];
108
+
109
+ ibcLookup[ibc.chain_1.chain_name].push(ibc);
110
+ ibcLookup[ibc.chain_2.chain_name].push(ibc);
111
+ }
112
+
113
+ const chainNames = registry.chains.map(c => c.chain_name).sort();
114
+
115
+ // iterate this after chainInfo is filled out
116
+ for (const name of chainNames) {
117
+ console.log('processing connections', name);
118
+
119
+ const ibcData = ibcLookup[name];
120
+ const connections = Object.fromEntries(
121
+ ibcData
122
+ .map(datum => toConnectionEntry(datum, name, chainInfo))
123
+ // sort alphabetically for consistency
124
+ .sort(([a], [b]) => (a && b ? a.localeCompare(b) : 0)),
125
+ );
126
+ chainInfo[name] = { ...chainInfo[name], connections };
127
+ }
128
+
129
+ // return object with insertion in alphabetical order of chain name
130
+ return Object.fromEntries(chainNames.map(name => [name, chainInfo[name]]));
131
+ };