@dotdm/env 0.3.2-dev.1776660158 → 1.0.0-dev.1778274929

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/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  export { DEFAULT_NODE_URL, REGISTRY_ADDRESS } from '@dotdm/utils';
2
2
  import * as polkadot_api from 'polkadot-api';
3
- import { PolkadotClient, TypedApi } from 'polkadot-api';
4
- import { ChainClient } from '@polkadot-apps/chain-client';
5
- import { paseo_asset_hub } from '@polkadot-apps/descriptors/paseo-asset-hub';
6
- import { bulletin } from '@polkadot-apps/descriptors/bulletin';
3
+ import { PolkadotClient, TypedApi, ChainDefinition } from 'polkadot-api';
4
+ import { paseo_asset_hub } from '@parity/product-sdk-descriptors/paseo-asset-hub';
5
+ import { bulletin } from '@parity/product-sdk-descriptors/bulletin';
7
6
  export { ss58Address } from '@polkadot-labs/hdkd-helpers';
8
7
 
9
8
  interface ChainFaucet {
@@ -20,23 +19,31 @@ declare const KNOWN_CHAINS: Record<string, ChainPreset>;
20
19
  type KnownChainName = keyof typeof KNOWN_CHAINS;
21
20
  declare function getChainPreset(name: string): ChainPreset;
22
21
 
22
+ type CdmDirectChainClient<TChains extends Record<string, ChainDefinition>> = {
23
+ [K in keyof TChains]: TypedApi<TChains[K]>;
24
+ } & {
25
+ raw: {
26
+ [K in keyof TChains]: PolkadotClient;
27
+ };
28
+ destroy: () => void;
29
+ };
23
30
  /**
24
31
  * Shape of a CDM chain client — both Asset Hub and Bulletin connected
25
- * under one `ChainClient` managed by `@polkadot-apps/chain-client`.
32
+ * under one chain-client-shaped object.
26
33
  *
27
- * Uses `@polkadot-apps/descriptors` for the chain descriptors so the
34
+ * Uses `@parity/product-sdk-descriptors` for the chain descriptors so the
28
35
  * resulting `TypedApi` types line up natively with `ContractDeployer`,
29
- * `MetadataPublisher`, and the @polkadot-apps batch/bulletin helpers
36
+ * `MetadataPublisher`, and the product-sdk batch/bulletin helpers
30
37
  * (no casts required). We pin AssetHub to the Paseo flavor — it's the
31
38
  * primary test target, and the pallet surface matches Polkadot/Kusama
32
39
  * AssetHub at the queries/txs we use.
33
40
  */
34
- type CdmChainClient = ChainClient<{
41
+ type CdmChainClient = CdmDirectChainClient<{
35
42
  assetHub: typeof paseo_asset_hub;
36
43
  bulletin: typeof bulletin;
37
44
  }>;
38
45
  /** Asset-Hub-only variant for callers that don't need Bulletin (e.g., `install`). */
39
- type CdmAssetHubClient = ChainClient<{
46
+ type CdmAssetHubClient = CdmDirectChainClient<{
40
47
  assetHub: typeof paseo_asset_hub;
41
48
  }>;
42
49
  interface AssetHubConnection {
@@ -52,15 +59,15 @@ interface CdmChainEndpoints {
52
59
  bulletinUrl: string;
53
60
  }
54
61
  /**
55
- * Connect to both Asset Hub and Bulletin using `@polkadot-apps/chain-client`.
62
+ * Connect to both Asset Hub and Bulletin over direct WebSocket RPC.
56
63
  *
57
64
  * Accepts either a known chain name (`"polkadot"`, `"paseo"`, `"local"`,
58
65
  * `"preview-net"`) resolved through `getChainPreset`, or explicit URLs.
59
66
  *
60
- * The returned `ChainClient` manages both connections — one `.destroy()`
61
- * call tears everything down. `chain-client` caches by genesis-hash
62
- * fingerprint, so repeated calls with the same descriptor set share a
63
- * single instance.
67
+ * The returned object matches product-sdk's `ChainClient` shape closely enough
68
+ * for callers to pass either one into CDM APIs. CDM builds this locally because
69
+ * product-sdk's published chain-client is host-provider-only and ignores RPC
70
+ * URLs, while the CLI must keep working as a standalone process.
64
71
  */
65
72
  declare function createCdmChainClient(arg: string | CdmChainEndpoints): Promise<CdmChainClient>;
66
73
  /**
@@ -76,11 +83,9 @@ interface IpfsGateway {
76
83
  * by CID. Unrelated to chain-client; kept here alongside the chain-connection
77
84
  * factory for convenience.
78
85
  *
79
- * `@polkadot-apps/bulletin` offers gateway helpers (`getGateway`, `fetchBytes`,
80
- * `fetchJson`), but those key off a fixed `Environment` enum
81
- * (polkadot/kusama/paseo) and don't yet cover CDM's custom networks
82
- * (local, preview-net). Keep this thin wrapper until CDM can map its
83
- * `KNOWN_CHAINS` onto that enum.
86
+ * Product SDK's Bulletin read helpers go through the host preimage
87
+ * subscription and do not cover CDM's custom gateway URLs (local,
88
+ * preview-net). Keep this thin wrapper for install flows.
84
89
  */
85
90
  declare function connectIpfsGateway(url: string): IpfsGateway;
86
91
 
package/dist/index.js CHANGED
@@ -41,27 +41,24 @@ function getChainPreset(name) {
41
41
  import { DEFAULT_NODE_URL, REGISTRY_ADDRESS } from "@dotdm/utils";
42
42
 
43
43
  // src/connection.ts
44
- import { createChainClient } from "@polkadot-apps/chain-client";
45
- import { paseo_asset_hub } from "@polkadot-apps/descriptors/paseo-asset-hub";
46
- import { bulletin } from "@polkadot-apps/descriptors/bulletin";
44
+ import {
45
+ createClient
46
+ } from "polkadot-api";
47
+ import { getWsProvider } from "polkadot-api/ws";
48
+ import { paseo_asset_hub } from "@parity/product-sdk-descriptors/paseo-asset-hub";
49
+ import { bulletin } from "@parity/product-sdk-descriptors/bulletin";
47
50
  async function createCdmChainClient(arg) {
48
51
  const endpoints = typeof arg === "string" ? {
49
52
  assethubUrl: getChainPreset(arg).assethubUrl,
50
53
  bulletinUrl: getChainPreset(arg).bulletinUrl
51
54
  } : arg;
52
- return createChainClient({
53
- chains: { assetHub: paseo_asset_hub, bulletin },
54
- rpcs: {
55
- assetHub: [endpoints.assethubUrl],
56
- bulletin: [endpoints.bulletinUrl]
57
- }
58
- });
55
+ return createDirectChainClient(
56
+ { assetHub: paseo_asset_hub, bulletin },
57
+ { assetHub: endpoints.assethubUrl, bulletin: endpoints.bulletinUrl }
58
+ );
59
59
  }
60
60
  async function createCdmAssetHubClient(assethubUrl) {
61
- return createChainClient({
62
- chains: { assetHub: paseo_asset_hub },
63
- rpcs: { assetHub: [assethubUrl] }
64
- });
61
+ return createDirectChainClient({ assetHub: paseo_asset_hub }, { assetHub: assethubUrl });
65
62
  }
66
63
  function connectIpfsGateway(url) {
67
64
  return {
@@ -71,6 +68,24 @@ function connectIpfsGateway(url) {
71
68
  })
72
69
  };
73
70
  }
71
+ function createDirectChainClient(chains, rpcs) {
72
+ const apis = {};
73
+ const raw = {};
74
+ for (const name of Object.keys(chains)) {
75
+ const client = createClient(getWsProvider(rpcs[name]));
76
+ raw[name] = client;
77
+ apis[name] = client.getTypedApi(chains[name]);
78
+ }
79
+ return {
80
+ ...apis,
81
+ raw,
82
+ destroy() {
83
+ for (const client of Object.values(raw)) {
84
+ client.destroy();
85
+ }
86
+ }
87
+ };
88
+ }
74
89
 
75
90
  // src/signer.ts
76
91
  import { getPolkadotSigner } from "polkadot-api/signer";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotdm/env",
3
- "version": "0.3.2-dev.1776660158",
3
+ "version": "1.0.0-dev.1778274929",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -17,11 +17,10 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@polkadot-apps/chain-client": "^2.0.4",
21
- "@polkadot-apps/descriptors": "^1.0.1",
20
+ "@parity/product-sdk-descriptors": "^0.2.1",
22
21
  "@polkadot-labs/hdkd": "^0.0.26",
23
22
  "@polkadot-labs/hdkd-helpers": "^0.0.27",
24
- "polkadot-api": "^1.23.3",
23
+ "polkadot-api": "^2.1.2",
25
24
  "smoldot": "^2.0.40",
26
25
  "@dotdm/utils": "0.3.1"
27
26
  },