@agoric/client-utils 0.1.1-dev-59107c0.0.59107c0 → 0.1.1-dev-3f5d355.0.3f5d355

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.
@@ -1,15 +1,25 @@
1
1
  export function toNetworkConfigUrl(agoricNetSubdomain: any): string;
2
2
  export function toRpcUrl(agoricNetSubdomain: any): string;
3
3
  export namespace LOCAL_CONFIG {
4
- let rpcAddrs: string[];
5
4
  let chainName: string;
5
+ let rpcAddrs: string[];
6
6
  }
7
7
  export const LOCAL_CONFIG_KEY: "local";
8
+ export function parseNetworkSpec(spec: string): {
9
+ subdomain: string;
10
+ chainId?: string;
11
+ };
8
12
  export function fetchNetworkConfig(spec: string, { fetch }: {
9
13
  fetch: typeof globalThis.fetch;
10
14
  }): Promise<MinimalNetworkConfig>;
11
15
  export type MinimalNetworkConfig = {
12
- rpcAddrs: string[];
16
+ /**
17
+ * a Cosmos Chain ID (cf. https://evm.cosmos.network/docs/next/documentation/concepts/chain-id and https://github.com/cosmos/chain-registry )
18
+ */
13
19
  chainName: string;
20
+ /**
21
+ * endpoints that are expected to respond to cosmos-sdk RPC requests
22
+ */
23
+ rpcAddrs: string[];
14
24
  };
15
25
  //# sourceMappingURL=network-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"network-config.d.ts","sourceRoot":"","sources":["../src/network-config.js"],"names":[],"mappings":"AAIO,oEACoD;AAEpD,0DAC6C;;;;;AAQpD,+BAAgC,OAAO,CAAC;AASjC,yCAJI,MAAM,aACN;IAAE,KAAK,EAAE,uBAAY,CAAA;CAAE,GACrB,OAAO,CAAC,oBAAoB,CAAC,CAkBzC;mCAxCY;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE"}
1
+ {"version":3,"file":"network-config.d.ts","sourceRoot":"","sources":["../src/network-config.js"],"names":[],"mappings":"AAMO,oEACoD;AAEpD,0DAC6C;;;;;AAQpD,+BAAgC,OAAO,CAAC;AAejC,uCAHI,MAAM,GACJ;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAKnD;AASM,yCAJI,MAAM,aACN;IAAE,KAAK,EAAE,uBAAY,CAAA;CAAE,GACrB,OAAO,CAAC,oBAAoB,CAAC,CAoBzC;;;;;eA7Da,MAAM;;;;cACN,MAAM,EAAE"}
@@ -1,14 +1,33 @@
1
1
  /**
2
- * @typedef {{ rpcAddrs: string[], chainName: string }} MinimalNetworkConfig
2
+ * @typedef {object} MinimalNetworkConfig
3
+ * @property {string} chainName a Cosmos Chain ID (cf. https://evm.cosmos.network/docs/next/documentation/concepts/chain-id and https://github.com/cosmos/chain-registry )
4
+ * @property {string[]} rpcAddrs endpoints that are expected to respond to cosmos-sdk RPC requests
3
5
  */
4
6
  export const toNetworkConfigUrl = agoricNetSubdomain => `https://${agoricNetSubdomain}.agoric.net/network-config`;
5
7
  export const toRpcUrl = agoricNetSubdomain => `https://${agoricNetSubdomain}.rpc.agoric.net:443`;
6
8
  /** @satisfies {MinimalNetworkConfig} */
7
9
  export const LOCAL_CONFIG = {
8
- rpcAddrs: ['http://0.0.0.0:26657'],
9
10
  chainName: 'agoriclocal',
11
+ rpcAddrs: ['http://0.0.0.0:26657'],
10
12
  };
11
13
  export const LOCAL_CONFIG_KEY = 'local';
14
+ /**
15
+ * Parse a network specifier, which must use one of the following formats:
16
+ * - "$subdomain": a subdomain of agoric.net that is expected to respond to an
17
+ * HTTP request for `/network-config` (e.g., "local" or "main" or a network
18
+ * listed at https://all.agoric.net/ ) with a {@link MinimalNetworkConfig}
19
+ * - "$subdomain,$chainId": a subdomain of rpc.agoric.net that is expected to
20
+ * respond to cosmos-sdk RPC requests, and a Cosmos Chain ID (cf.
21
+ * https://evm.cosmos.network/docs/next/documentation/concepts/chain-id and
22
+ * https://github.com/cosmos/chain-registry ) to associate with it
23
+ *
24
+ * @param {string} spec
25
+ * @returns {{ subdomain: string, chainId?: string }}
26
+ */
27
+ export const parseNetworkSpec = spec => {
28
+ const [subdomain, chainId] = spec.split(',');
29
+ return { subdomain, chainId };
30
+ };
12
31
  /**
13
32
  * Fetches the network config for the given network specifier.
14
33
  *
@@ -17,14 +36,17 @@ export const LOCAL_CONFIG_KEY = 'local';
17
36
  * @returns {Promise<MinimalNetworkConfig>}
18
37
  */
19
38
  export const fetchNetworkConfig = async (spec, { fetch }) => {
20
- const [netName, chainName] = spec.split(',');
21
- if (netName === LOCAL_CONFIG_KEY) {
22
- return LOCAL_CONFIG;
39
+ const { subdomain, chainId } = parseNetworkSpec(spec);
40
+ if (subdomain === LOCAL_CONFIG_KEY) {
41
+ const config = { ...LOCAL_CONFIG };
42
+ if (chainId)
43
+ config.chainName = chainId;
44
+ return config;
23
45
  }
24
- if (chainName) {
25
- return { chainName, rpcAddrs: [toRpcUrl(netName)] };
46
+ if (chainId) {
47
+ return { chainName: chainId, rpcAddrs: [toRpcUrl(subdomain)] };
26
48
  }
27
- return fetch(toNetworkConfigUrl(netName))
49
+ return fetch(toNetworkConfigUrl(subdomain))
28
50
  .then(res => res.json())
29
51
  .catch(err => {
30
52
  throw Error(`cannot get network config (${spec}): ${err.message}`);
@@ -1 +1 @@
1
- {"version":3,"file":"network-config.js","sourceRoot":"","sources":["../src/network-config.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,EAAE,CACrD,WAAW,kBAAkB,4BAA4B,CAAC;AAE5D,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,EAAE,CAC3C,WAAW,kBAAkB,qBAAqB,CAAC;AAErD,wCAAwC;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,CAAC,sBAAsB,CAAC;IAClC,SAAS,EAAE,aAAa;CACzB,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAExC;;;;;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AAC,SAAS,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAChC,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;IAC1D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEtD,IAAI,SAAS,KAAK,gBAAgB,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC;QACnC,IAAI,OAAO;YAAE,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC;QACxC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;IACjE,CAAC;IAED,OAAO,KAAK,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;SACxC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACvB,KAAK,CAAC,GAAG,CAAC,EAAE;QACX,MAAM,KAAK,CAAC,8BAA8B,IAAI,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/client-utils",
3
- "version": "0.1.1-dev-59107c0.0.59107c0",
3
+ "version": "0.1.1-dev-3f5d355.0.3f5d355",
4
4
  "description": "Utilities for building Agoric clients",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
@@ -32,12 +32,12 @@
32
32
  "ts-blank-space": "^0.6.2"
33
33
  },
34
34
  "dependencies": {
35
- "@agoric/casting": "0.4.3-dev-59107c0.0.59107c0",
36
- "@agoric/cosmic-proto": "0.4.1-dev-59107c0.0.59107c0",
37
- "@agoric/ertp": "0.16.3-dev-59107c0.0.59107c0",
38
- "@agoric/internal": "0.3.3-dev-59107c0.0.59107c0",
39
- "@agoric/smart-wallet": "0.5.4-dev-59107c0.0.59107c0",
40
- "@agoric/vats": "0.15.2-dev-59107c0.0.59107c0",
35
+ "@agoric/casting": "0.4.3-dev-3f5d355.0.3f5d355",
36
+ "@agoric/cosmic-proto": "0.4.1-dev-3f5d355.0.3f5d355",
37
+ "@agoric/ertp": "0.16.3-dev-3f5d355.0.3f5d355",
38
+ "@agoric/internal": "0.3.3-dev-3f5d355.0.3f5d355",
39
+ "@agoric/smart-wallet": "0.5.4-dev-3f5d355.0.3f5d355",
40
+ "@agoric/vats": "0.15.2-dev-3f5d355.0.3f5d355",
41
41
  "@cosmjs/crypto": "^0.36.0",
42
42
  "@cosmjs/proto-signing": "^0.36.0",
43
43
  "@cosmjs/stargate": "^0.36.0",
@@ -73,5 +73,5 @@
73
73
  "engines": {
74
74
  "node": "^20.9 || ^22.11"
75
75
  },
76
- "gitHead": "59107c01ca482ce7dc562ea912a7cb639b0ca1ce"
76
+ "gitHead": "3f5d355f9a3f4355d9d449da43d043720b74f8e8"
77
77
  }