@dotdm/env 0.3.2 → 1.0.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/dist/index.d.ts +53 -21
- package/dist/index.js +21 -34
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { DEFAULT_NODE_URL, REGISTRY_ADDRESS } from '@dotdm/utils';
|
|
2
2
|
import * as polkadot_api from 'polkadot-api';
|
|
3
3
|
import { PolkadotClient, TypedApi } from 'polkadot-api';
|
|
4
|
-
import {
|
|
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';
|
|
5
7
|
export { ss58Address } from '@polkadot-labs/hdkd-helpers';
|
|
6
8
|
|
|
7
9
|
interface ChainFaucet {
|
|
@@ -18,38 +20,68 @@ declare const KNOWN_CHAINS: Record<string, ChainPreset>;
|
|
|
18
20
|
type KnownChainName = keyof typeof KNOWN_CHAINS;
|
|
19
21
|
declare function getChainPreset(name: string): ChainPreset;
|
|
20
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Shape of a CDM chain client — both Asset Hub and Bulletin connected
|
|
25
|
+
* under one `ChainClient` managed by `@polkadot-apps/chain-client`.
|
|
26
|
+
*
|
|
27
|
+
* Uses `@polkadot-apps/descriptors` for the chain descriptors so the
|
|
28
|
+
* resulting `TypedApi` types line up natively with `ContractDeployer`,
|
|
29
|
+
* `MetadataPublisher`, and the @polkadot-apps batch/bulletin helpers
|
|
30
|
+
* (no casts required). We pin AssetHub to the Paseo flavor — it's the
|
|
31
|
+
* primary test target, and the pallet surface matches Polkadot/Kusama
|
|
32
|
+
* AssetHub at the queries/txs we use.
|
|
33
|
+
*/
|
|
34
|
+
type CdmChainClient = ChainClient<{
|
|
35
|
+
assetHub: typeof paseo_asset_hub;
|
|
36
|
+
bulletin: typeof bulletin;
|
|
37
|
+
}>;
|
|
38
|
+
/** Asset-Hub-only variant for callers that don't need Bulletin (e.g., `install`). */
|
|
39
|
+
type CdmAssetHubClient = ChainClient<{
|
|
40
|
+
assetHub: typeof paseo_asset_hub;
|
|
41
|
+
}>;
|
|
21
42
|
interface AssetHubConnection {
|
|
22
43
|
client: PolkadotClient;
|
|
23
|
-
api: TypedApi<
|
|
44
|
+
api: TypedApi<typeof paseo_asset_hub>;
|
|
24
45
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Detect connection type from URL.
|
|
27
|
-
* - ws:// or wss:// -> WebSocket
|
|
28
|
-
* - file path -> smoldot with chainspec
|
|
29
|
-
*/
|
|
30
|
-
declare function detectConnectionType(url: string): "websocket" | "smoldot";
|
|
31
|
-
/**
|
|
32
|
-
* Connect to a chain via WebSocket.
|
|
33
|
-
*/
|
|
34
|
-
declare function connectAssetHubWebSocket(url: string): AssetHubConnection;
|
|
35
46
|
interface BulletinConnection {
|
|
36
47
|
client: PolkadotClient;
|
|
37
|
-
api: TypedApi<
|
|
48
|
+
api: TypedApi<typeof bulletin>;
|
|
49
|
+
}
|
|
50
|
+
interface CdmChainEndpoints {
|
|
51
|
+
assethubUrl: string;
|
|
52
|
+
bulletinUrl: string;
|
|
38
53
|
}
|
|
39
54
|
/**
|
|
40
|
-
* Connect to
|
|
55
|
+
* Connect to both Asset Hub and Bulletin using `@polkadot-apps/chain-client`.
|
|
56
|
+
*
|
|
57
|
+
* Accepts either a known chain name (`"polkadot"`, `"paseo"`, `"local"`,
|
|
58
|
+
* `"preview-net"`) resolved through `getChainPreset`, or explicit URLs.
|
|
59
|
+
*
|
|
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.
|
|
41
64
|
*/
|
|
42
|
-
declare function
|
|
65
|
+
declare function createCdmChainClient(arg: string | CdmChainEndpoints): Promise<CdmChainClient>;
|
|
43
66
|
/**
|
|
44
|
-
* Connect to
|
|
45
|
-
*
|
|
46
|
-
* @param parachainChainspec - Path to the parachain chainspec JSON file
|
|
47
|
-
* @param relayChainspec - Path to the relay chain chainspec JSON file
|
|
67
|
+
* Connect to Asset Hub only (no Bulletin). Used by commands that don't
|
|
68
|
+
* publish metadata — e.g., `install`, `account map`, `deploy-registry`.
|
|
48
69
|
*/
|
|
49
|
-
declare function
|
|
70
|
+
declare function createCdmAssetHubClient(assethubUrl: string): Promise<CdmAssetHubClient>;
|
|
50
71
|
interface IpfsGateway {
|
|
51
72
|
fetch: (cid: string) => Promise<Response>;
|
|
52
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Minimal IPFS gateway HTTP client used by `install` to fetch metadata JSON
|
|
76
|
+
* by CID. Unrelated to chain-client; kept here alongside the chain-connection
|
|
77
|
+
* factory for convenience.
|
|
78
|
+
*
|
|
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.
|
|
84
|
+
*/
|
|
53
85
|
declare function connectIpfsGateway(url: string): IpfsGateway;
|
|
54
86
|
|
|
55
87
|
/**
|
|
@@ -68,4 +100,4 @@ declare function prepareSignerFromMnemonic(mnemonic: string): polkadot_api.Polka
|
|
|
68
100
|
*/
|
|
69
101
|
declare function prepareSignerFromSuri(suri: string): polkadot_api.PolkadotSigner;
|
|
70
102
|
|
|
71
|
-
export { type AssetHubConnection, type BulletinConnection, type ChainFaucet, type ChainPreset, type IpfsGateway, KNOWN_CHAINS, type KnownChainName,
|
|
103
|
+
export { type AssetHubConnection, type BulletinConnection, type CdmAssetHubClient, type CdmChainClient, type CdmChainEndpoints, type ChainFaucet, type ChainPreset, type IpfsGateway, KNOWN_CHAINS, type KnownChainName, connectIpfsGateway, createCdmAssetHubClient, createCdmChainClient, getChainPreset, prepareSigner, prepareSignerFromMnemonic, prepareSignerFromSuri };
|
package/dist/index.js
CHANGED
|
@@ -41,38 +41,27 @@ function getChainPreset(name) {
|
|
|
41
41
|
import { DEFAULT_NODE_URL, REGISTRY_ADDRESS } from "@dotdm/utils";
|
|
42
42
|
|
|
43
43
|
// src/connection.ts
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
function connectBulletinWebSocket(url) {
|
|
61
|
-
const client = createClient(withPolkadotSdkCompat(getWsProvider(url)));
|
|
62
|
-
return { client, api: client.getTypedApi(bulletin) };
|
|
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";
|
|
47
|
+
async function createCdmChainClient(arg) {
|
|
48
|
+
const endpoints = typeof arg === "string" ? {
|
|
49
|
+
assethubUrl: getChainPreset(arg).assethubUrl,
|
|
50
|
+
bulletinUrl: getChainPreset(arg).bulletinUrl
|
|
51
|
+
} : arg;
|
|
52
|
+
return createChainClient({
|
|
53
|
+
chains: { assetHub: paseo_asset_hub, bulletin },
|
|
54
|
+
rpcs: {
|
|
55
|
+
assetHub: [endpoints.assethubUrl],
|
|
56
|
+
bulletin: [endpoints.bulletinUrl]
|
|
57
|
+
}
|
|
58
|
+
});
|
|
63
59
|
}
|
|
64
|
-
async function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const parachainSpec = readFileSync(parachainChainspec, "utf-8");
|
|
69
|
-
const relayChain = await smoldot.addChain({ chainSpec: relaySpec });
|
|
70
|
-
const parachain = await smoldot.addChain({
|
|
71
|
-
chainSpec: parachainSpec,
|
|
72
|
-
potentialRelayChains: [relayChain]
|
|
60
|
+
async function createCdmAssetHubClient(assethubUrl) {
|
|
61
|
+
return createChainClient({
|
|
62
|
+
chains: { assetHub: paseo_asset_hub },
|
|
63
|
+
rpcs: { assetHub: [assethubUrl] }
|
|
73
64
|
});
|
|
74
|
-
const client = createClient(getSmProvider(parachain));
|
|
75
|
-
return { client, api: client.getTypedApi(assetHub) };
|
|
76
65
|
}
|
|
77
66
|
function connectIpfsGateway(url) {
|
|
78
67
|
return {
|
|
@@ -116,11 +105,9 @@ export {
|
|
|
116
105
|
DEFAULT_NODE_URL,
|
|
117
106
|
KNOWN_CHAINS,
|
|
118
107
|
REGISTRY_ADDRESS,
|
|
119
|
-
connectAssetHubWebSocket,
|
|
120
|
-
connectBulletinWebSocket,
|
|
121
108
|
connectIpfsGateway,
|
|
122
|
-
|
|
123
|
-
|
|
109
|
+
createCdmAssetHubClient,
|
|
110
|
+
createCdmChainClient,
|
|
124
111
|
getChainPreset,
|
|
125
112
|
prepareSigner,
|
|
126
113
|
prepareSignerFromMnemonic,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotdm/env",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -17,11 +17,12 @@
|
|
|
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
22
|
"@polkadot-labs/hdkd": "^0.0.26",
|
|
21
23
|
"@polkadot-labs/hdkd-helpers": "^0.0.27",
|
|
22
24
|
"polkadot-api": "^1.23.3",
|
|
23
25
|
"smoldot": "^2.0.40",
|
|
24
|
-
"@dotdm/descriptors": "0.1.9",
|
|
25
26
|
"@dotdm/utils": "0.3.1"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|