@dotdm/env 1.0.0-dev.1778274929 → 1.0.1-dev.1778555844
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 +79 -29
- package/dist/index.js +82 -16
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,68 +1,118 @@
|
|
|
1
1
|
export { DEFAULT_NODE_URL, REGISTRY_ADDRESS } from '@dotdm/utils';
|
|
2
2
|
import * as polkadot_api from 'polkadot-api';
|
|
3
|
-
import { PolkadotClient, TypedApi
|
|
3
|
+
import { PolkadotClient, TypedApi } from 'polkadot-api';
|
|
4
|
+
import { polkadot_asset_hub } from '@parity/product-sdk-descriptors/polkadot-asset-hub';
|
|
4
5
|
import { paseo_asset_hub } from '@parity/product-sdk-descriptors/paseo-asset-hub';
|
|
5
|
-
import {
|
|
6
|
+
import { previewnet_asset_hub } from '@parity/product-sdk-descriptors/previewnet-asset-hub';
|
|
7
|
+
import { paseo_bulletin } from '@parity/product-sdk-descriptors/paseo-bulletin';
|
|
8
|
+
import { previewnet_bulletin } from '@parity/product-sdk-descriptors/previewnet-bulletin';
|
|
6
9
|
export { ss58Address } from '@polkadot-labs/hdkd-helpers';
|
|
7
10
|
|
|
8
11
|
interface ChainFaucet {
|
|
9
12
|
label: string;
|
|
10
13
|
url: string;
|
|
11
14
|
}
|
|
15
|
+
type ProductSdkEnvironment = "paseo" | "previewnet";
|
|
12
16
|
interface ChainPreset {
|
|
13
17
|
assethubUrl: string;
|
|
14
18
|
bulletinUrl: string;
|
|
15
19
|
ipfsGatewayUrl: string;
|
|
16
|
-
|
|
20
|
+
registryAddress?: string;
|
|
21
|
+
productSdkEnvironment?: ProductSdkEnvironment;
|
|
22
|
+
faucets?: readonly ChainFaucet[];
|
|
17
23
|
}
|
|
18
|
-
declare const KNOWN_CHAINS:
|
|
24
|
+
declare const KNOWN_CHAINS: {
|
|
25
|
+
readonly polkadot: {
|
|
26
|
+
readonly assethubUrl: "wss://polkadot-asset-hub-rpc.polkadot.io";
|
|
27
|
+
readonly bulletinUrl: "wss://polkadot-bulletin-rpc.polkadot.io";
|
|
28
|
+
readonly ipfsGatewayUrl: "https://polkadot-bulletin-rpc.polkadot.io/ipfs";
|
|
29
|
+
readonly registryAddress: "0xae344f7f0f91d3a2176032af2990abcc7606c7d4";
|
|
30
|
+
};
|
|
31
|
+
readonly paseo: {
|
|
32
|
+
readonly assethubUrl: "wss://asset-hub-paseo-rpc.n.dwellir.com";
|
|
33
|
+
readonly bulletinUrl: "wss://paseo-bulletin-rpc.polkadot.io";
|
|
34
|
+
readonly ipfsGatewayUrl: "https://paseo-ipfs.polkadot.io/ipfs";
|
|
35
|
+
readonly registryAddress: "0xae344f7f0f91d3a2176032af2990abcc7606c7d4";
|
|
36
|
+
readonly productSdkEnvironment: "paseo";
|
|
37
|
+
readonly faucets: readonly [{
|
|
38
|
+
readonly label: "Asset Hub";
|
|
39
|
+
readonly url: "https://faucet.polkadot.io/";
|
|
40
|
+
}, {
|
|
41
|
+
readonly label: "Bulletin";
|
|
42
|
+
readonly url: "https://paritytech.github.io/polkadot-bulletin-chain/authorizations?tab=faucet";
|
|
43
|
+
}];
|
|
44
|
+
};
|
|
45
|
+
readonly "preview-net": {
|
|
46
|
+
readonly assethubUrl: "wss://previewnet.substrate.dev/asset-hub";
|
|
47
|
+
readonly bulletinUrl: "wss://paseo-bulletin-rpc.polkadot.io";
|
|
48
|
+
readonly ipfsGatewayUrl: "https://paseo-ipfs.polkadot.io/ipfs";
|
|
49
|
+
readonly registryAddress: "0x5c7b23d386ff622c7f7a4e7a95d5c7a67b10a00d";
|
|
50
|
+
readonly productSdkEnvironment: "previewnet";
|
|
51
|
+
};
|
|
52
|
+
readonly local: {
|
|
53
|
+
readonly assethubUrl: "ws://127.0.0.1:10020";
|
|
54
|
+
readonly bulletinUrl: "ws://127.0.0.1:10030";
|
|
55
|
+
readonly ipfsGatewayUrl: "http://127.0.0.1:8283/ipfs";
|
|
56
|
+
readonly registryAddress: "0xae344f7f0f91d3a2176032af2990abcc7606c7d4";
|
|
57
|
+
};
|
|
58
|
+
};
|
|
19
59
|
type KnownChainName = keyof typeof KNOWN_CHAINS;
|
|
60
|
+
declare function isKnownChainPreset(name: string): boolean;
|
|
20
61
|
declare function getChainPreset(name: string): ChainPreset;
|
|
21
62
|
|
|
22
|
-
type
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
destroy: () => void;
|
|
29
|
-
};
|
|
63
|
+
type CdmDeployAssetHubDescriptor = typeof paseo_asset_hub | typeof previewnet_asset_hub;
|
|
64
|
+
type CdmAssetHubDescriptor = CdmDeployAssetHubDescriptor | typeof polkadot_asset_hub;
|
|
65
|
+
type CdmBulletinDescriptor = typeof paseo_bulletin | typeof previewnet_bulletin;
|
|
66
|
+
type CdmDeployAssetHubApi = TypedApi<CdmDeployAssetHubDescriptor>;
|
|
67
|
+
type CdmAssetHubApi = TypedApi<CdmAssetHubDescriptor>;
|
|
68
|
+
type CdmBulletinApi = TypedApi<CdmBulletinDescriptor>;
|
|
30
69
|
/**
|
|
31
70
|
* Shape of a CDM chain client — both Asset Hub and Bulletin connected
|
|
32
71
|
* under one chain-client-shaped object.
|
|
33
72
|
*
|
|
34
73
|
* Uses `@parity/product-sdk-descriptors` for the chain descriptors so the
|
|
35
74
|
* resulting `TypedApi` types line up natively with `ContractDeployer`,
|
|
36
|
-
* `MetadataPublisher`, and the product-sdk batch/bulletin helpers
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* AssetHub at the queries/txs we use.
|
|
75
|
+
* `MetadataPublisher`, and the product-sdk batch/bulletin helpers. TEMPORARY_PATCH! Preview-net
|
|
76
|
+
* currently uses its own Asset Hub descriptor and Paseo's Bulletin descriptor
|
|
77
|
+
* because CDM stores preview-net metadata on Paseo Bulletin.
|
|
40
78
|
*/
|
|
41
|
-
type CdmChainClient =
|
|
42
|
-
assetHub:
|
|
43
|
-
bulletin:
|
|
44
|
-
|
|
79
|
+
type CdmChainClient = {
|
|
80
|
+
assetHub: CdmDeployAssetHubApi;
|
|
81
|
+
bulletin: CdmBulletinApi;
|
|
82
|
+
raw: {
|
|
83
|
+
assetHub: PolkadotClient;
|
|
84
|
+
bulletin: PolkadotClient;
|
|
85
|
+
};
|
|
86
|
+
destroy: () => void;
|
|
87
|
+
};
|
|
45
88
|
/** Asset-Hub-only variant for callers that don't need Bulletin (e.g., `install`). */
|
|
46
|
-
type CdmAssetHubClient =
|
|
47
|
-
assetHub:
|
|
48
|
-
|
|
89
|
+
type CdmAssetHubClient = {
|
|
90
|
+
assetHub: CdmAssetHubApi;
|
|
91
|
+
raw: {
|
|
92
|
+
assetHub: PolkadotClient;
|
|
93
|
+
};
|
|
94
|
+
destroy: () => void;
|
|
95
|
+
};
|
|
49
96
|
interface AssetHubConnection {
|
|
50
97
|
client: PolkadotClient;
|
|
51
|
-
api:
|
|
98
|
+
api: CdmAssetHubApi;
|
|
52
99
|
}
|
|
53
100
|
interface BulletinConnection {
|
|
54
101
|
client: PolkadotClient;
|
|
55
|
-
api:
|
|
102
|
+
api: CdmBulletinApi;
|
|
56
103
|
}
|
|
57
104
|
interface CdmChainEndpoints {
|
|
58
105
|
assethubUrl: string;
|
|
59
106
|
bulletinUrl: string;
|
|
107
|
+
chainName?: string;
|
|
60
108
|
}
|
|
61
109
|
/**
|
|
62
110
|
* Connect to both Asset Hub and Bulletin over direct WebSocket RPC.
|
|
63
111
|
*
|
|
64
|
-
* Accepts either a
|
|
65
|
-
* `"
|
|
112
|
+
* Accepts either a supported deploy chain name (`"paseo"`, `"preview-net"`,
|
|
113
|
+
* `"local"`) resolved through `getChainPreset`, or explicit URLs. Polkadot
|
|
114
|
+
* remains available for Asset-Hub-only install reads, but product-sdk does
|
|
115
|
+
* not publish a Polkadot Bulletin descriptor yet.
|
|
66
116
|
*
|
|
67
117
|
* The returned object matches product-sdk's `ChainClient` shape closely enough
|
|
68
118
|
* for callers to pass either one into CDM APIs. CDM builds this locally because
|
|
@@ -74,7 +124,7 @@ declare function createCdmChainClient(arg: string | CdmChainEndpoints): Promise<
|
|
|
74
124
|
* Connect to Asset Hub only (no Bulletin). Used by commands that don't
|
|
75
125
|
* publish metadata — e.g., `install`, `account map`, `deploy-registry`.
|
|
76
126
|
*/
|
|
77
|
-
declare function createCdmAssetHubClient(assethubUrl: string): Promise<CdmAssetHubClient>;
|
|
127
|
+
declare function createCdmAssetHubClient(assethubUrl: string, chainName?: string): Promise<CdmAssetHubClient>;
|
|
78
128
|
interface IpfsGateway {
|
|
79
129
|
fetch: (cid: string) => Promise<Response>;
|
|
80
130
|
}
|
|
@@ -105,4 +155,4 @@ declare function prepareSignerFromMnemonic(mnemonic: string): polkadot_api.Polka
|
|
|
105
155
|
*/
|
|
106
156
|
declare function prepareSignerFromSuri(suri: string): polkadot_api.PolkadotSigner;
|
|
107
157
|
|
|
108
|
-
export { type AssetHubConnection, type BulletinConnection, type CdmAssetHubClient, type CdmChainClient, type CdmChainEndpoints, type ChainFaucet, type ChainPreset, type IpfsGateway,
|
|
158
|
+
export { type AssetHubConnection, type BulletinConnection, type CdmAssetHubApi, type CdmAssetHubClient, type CdmBulletinApi, type CdmChainClient, type CdmChainEndpoints, type CdmDeployAssetHubApi, type ChainFaucet, type ChainPreset, type IpfsGateway, type KnownChainName, type ProductSdkEnvironment, connectIpfsGateway, createCdmAssetHubClient, createCdmChainClient, getChainPreset, isKnownChainPreset, prepareSigner, prepareSignerFromMnemonic, prepareSignerFromSuri };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
// src/known_chains.ts
|
|
2
|
+
import { BULLETIN_RPCS } from "@parity/product-sdk-host";
|
|
3
|
+
import { REGISTRY_ADDRESS } from "@dotdm/utils";
|
|
4
|
+
var PREVIEW_NET_REGISTRY_ADDRESS = "0x5c7b23d386ff622c7f7a4e7a95d5c7a67b10a00d";
|
|
2
5
|
var KNOWN_CHAINS = {
|
|
3
6
|
polkadot: {
|
|
4
7
|
assethubUrl: "wss://polkadot-asset-hub-rpc.polkadot.io",
|
|
5
8
|
bulletinUrl: "wss://polkadot-bulletin-rpc.polkadot.io",
|
|
6
|
-
ipfsGatewayUrl: "https://polkadot-bulletin-rpc.polkadot.io/ipfs"
|
|
9
|
+
ipfsGatewayUrl: "https://polkadot-bulletin-rpc.polkadot.io/ipfs",
|
|
10
|
+
registryAddress: REGISTRY_ADDRESS
|
|
7
11
|
},
|
|
8
12
|
paseo: {
|
|
9
13
|
assethubUrl: "wss://asset-hub-paseo-rpc.n.dwellir.com",
|
|
10
|
-
bulletinUrl:
|
|
14
|
+
bulletinUrl: BULLETIN_RPCS.paseo[0],
|
|
11
15
|
ipfsGatewayUrl: "https://paseo-ipfs.polkadot.io/ipfs",
|
|
16
|
+
registryAddress: REGISTRY_ADDRESS,
|
|
17
|
+
productSdkEnvironment: "paseo",
|
|
12
18
|
faucets: [
|
|
13
19
|
{ label: "Asset Hub", url: "https://faucet.polkadot.io/" },
|
|
14
20
|
{
|
|
@@ -19,17 +25,34 @@ var KNOWN_CHAINS = {
|
|
|
19
25
|
},
|
|
20
26
|
"preview-net": {
|
|
21
27
|
assethubUrl: "wss://previewnet.substrate.dev/asset-hub",
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
// TEMPORARY_PATCH! Preview-net's IPFS gateway does not currently serve Bulletin CIDs,
|
|
29
|
+
// so CDM stores preview-net metadata on Paseo Bulletin for now.
|
|
30
|
+
bulletinUrl: BULLETIN_RPCS.paseo[0],
|
|
31
|
+
ipfsGatewayUrl: "https://paseo-ipfs.polkadot.io/ipfs",
|
|
32
|
+
registryAddress: PREVIEW_NET_REGISTRY_ADDRESS,
|
|
33
|
+
productSdkEnvironment: "previewnet"
|
|
24
34
|
},
|
|
25
35
|
local: {
|
|
26
36
|
assethubUrl: "ws://127.0.0.1:10020",
|
|
27
37
|
bulletinUrl: "ws://127.0.0.1:10030",
|
|
28
|
-
ipfsGatewayUrl: "http://127.0.0.1:8283/ipfs"
|
|
38
|
+
ipfsGatewayUrl: "http://127.0.0.1:8283/ipfs",
|
|
39
|
+
registryAddress: REGISTRY_ADDRESS
|
|
29
40
|
}
|
|
30
41
|
};
|
|
42
|
+
function normalizeChainName(name) {
|
|
43
|
+
if (name === "previewnet") return "preview-net";
|
|
44
|
+
if (name === "preview-net" || name === "paseo" || name === "polkadot" || name === "local") {
|
|
45
|
+
return name;
|
|
46
|
+
}
|
|
47
|
+
if (name === "custom") return "custom";
|
|
48
|
+
}
|
|
49
|
+
function isKnownChainPreset(name) {
|
|
50
|
+
const normalized = normalizeChainName(name);
|
|
51
|
+
return normalized !== void 0 && normalized !== "custom";
|
|
52
|
+
}
|
|
31
53
|
function getChainPreset(name) {
|
|
32
|
-
const
|
|
54
|
+
const normalized = normalizeChainName(name);
|
|
55
|
+
const preset = normalized && normalized !== "custom" ? KNOWN_CHAINS[normalized] : void 0;
|
|
33
56
|
if (!preset) {
|
|
34
57
|
const valid = Object.keys(KNOWN_CHAINS).join(", ");
|
|
35
58
|
throw new Error(`Unknown chain "${name}". Valid names: ${valid}`);
|
|
@@ -38,31 +61,74 @@ function getChainPreset(name) {
|
|
|
38
61
|
}
|
|
39
62
|
|
|
40
63
|
// src/index.ts
|
|
41
|
-
import { DEFAULT_NODE_URL, REGISTRY_ADDRESS } from "@dotdm/utils";
|
|
64
|
+
import { DEFAULT_NODE_URL, REGISTRY_ADDRESS as REGISTRY_ADDRESS2 } from "@dotdm/utils";
|
|
42
65
|
|
|
43
66
|
// src/connection.ts
|
|
44
67
|
import {
|
|
45
68
|
createClient
|
|
46
69
|
} from "polkadot-api";
|
|
47
70
|
import { getWsProvider } from "polkadot-api/ws";
|
|
71
|
+
import { polkadot_asset_hub } from "@parity/product-sdk-descriptors/polkadot-asset-hub";
|
|
48
72
|
import { paseo_asset_hub } from "@parity/product-sdk-descriptors/paseo-asset-hub";
|
|
49
|
-
import {
|
|
73
|
+
import { previewnet_asset_hub } from "@parity/product-sdk-descriptors/previewnet-asset-hub";
|
|
74
|
+
import { paseo_bulletin } from "@parity/product-sdk-descriptors/paseo-bulletin";
|
|
75
|
+
var DEPLOY_CHAIN_DESCRIPTORS = {
|
|
76
|
+
paseo: { assetHub: paseo_asset_hub, bulletin: paseo_bulletin },
|
|
77
|
+
"preview-net": { assetHub: previewnet_asset_hub, bulletin: paseo_bulletin },
|
|
78
|
+
local: { assetHub: paseo_asset_hub, bulletin: paseo_bulletin }
|
|
79
|
+
};
|
|
80
|
+
var ASSET_HUB_DESCRIPTORS = {
|
|
81
|
+
polkadot: polkadot_asset_hub,
|
|
82
|
+
paseo: paseo_asset_hub,
|
|
83
|
+
"preview-net": previewnet_asset_hub,
|
|
84
|
+
local: paseo_asset_hub
|
|
85
|
+
};
|
|
86
|
+
function resolveExplicitChainName(chainName) {
|
|
87
|
+
const normalized = normalizeChainName(chainName);
|
|
88
|
+
if (!normalized) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`Unknown chain "${chainName}". Valid names: polkadot, paseo, preview-net, local, custom`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
return normalized;
|
|
94
|
+
}
|
|
95
|
+
function resolveAssetHubDescriptors(chainName) {
|
|
96
|
+
const normalized = chainName ? resolveExplicitChainName(chainName) : void 0;
|
|
97
|
+
return ASSET_HUB_DESCRIPTORS[normalized && normalized !== "custom" ? normalized : "paseo"];
|
|
98
|
+
}
|
|
99
|
+
function resolveDeployDescriptors(chainName) {
|
|
100
|
+
const normalized = chainName ? resolveExplicitChainName(chainName) : void 0;
|
|
101
|
+
const descriptorChain = normalized && normalized !== "custom" ? normalized : "paseo";
|
|
102
|
+
if (descriptorChain === "polkadot") {
|
|
103
|
+
throw new Error(
|
|
104
|
+
'CDM deploy connections are only available for "paseo", "preview-net", and "local"; product-sdk does not publish a Polkadot Bulletin descriptor yet.'
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return DEPLOY_CHAIN_DESCRIPTORS[descriptorChain];
|
|
108
|
+
}
|
|
50
109
|
async function createCdmChainClient(arg) {
|
|
51
110
|
const endpoints = typeof arg === "string" ? {
|
|
52
111
|
assethubUrl: getChainPreset(arg).assethubUrl,
|
|
53
|
-
bulletinUrl: getChainPreset(arg).bulletinUrl
|
|
112
|
+
bulletinUrl: getChainPreset(arg).bulletinUrl,
|
|
113
|
+
chainName: arg
|
|
54
114
|
} : arg;
|
|
115
|
+
return createDirectChainClient(resolveDeployDescriptors(endpoints.chainName), {
|
|
116
|
+
assetHub: endpoints.assethubUrl,
|
|
117
|
+
bulletin: endpoints.bulletinUrl
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async function createCdmAssetHubClient(assethubUrl, chainName) {
|
|
55
121
|
return createDirectChainClient(
|
|
56
|
-
{ assetHub:
|
|
57
|
-
{ assetHub:
|
|
122
|
+
{ assetHub: resolveAssetHubDescriptors(chainName) },
|
|
123
|
+
{ assetHub: assethubUrl }
|
|
58
124
|
);
|
|
59
125
|
}
|
|
60
|
-
|
|
61
|
-
return
|
|
126
|
+
function joinGatewayUrl(url, cid) {
|
|
127
|
+
return `${url.replace(/\/+$/, "")}/${cid.replace(/^\/+/, "")}`;
|
|
62
128
|
}
|
|
63
129
|
function connectIpfsGateway(url) {
|
|
64
130
|
return {
|
|
65
|
-
fetch: (cid) => globalThis.fetch(
|
|
131
|
+
fetch: (cid) => globalThis.fetch(joinGatewayUrl(url, cid), { signal: AbortSignal.timeout(15e3) }).then((r) => {
|
|
66
132
|
if (!r.ok) throw new Error(`IPFS fetch failed: ${r.statusText}`);
|
|
67
133
|
return r;
|
|
68
134
|
})
|
|
@@ -118,12 +184,12 @@ function prepareSignerFromSuri(suri) {
|
|
|
118
184
|
}
|
|
119
185
|
export {
|
|
120
186
|
DEFAULT_NODE_URL,
|
|
121
|
-
|
|
122
|
-
REGISTRY_ADDRESS,
|
|
187
|
+
REGISTRY_ADDRESS2 as REGISTRY_ADDRESS,
|
|
123
188
|
connectIpfsGateway,
|
|
124
189
|
createCdmAssetHubClient,
|
|
125
190
|
createCdmChainClient,
|
|
126
191
|
getChainPreset,
|
|
192
|
+
isKnownChainPreset,
|
|
127
193
|
prepareSigner,
|
|
128
194
|
prepareSignerFromMnemonic,
|
|
129
195
|
prepareSignerFromSuri,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotdm/env",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-dev.1778555844",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@parity/product-sdk-descriptors": "^0.
|
|
20
|
+
"@parity/product-sdk-descriptors": "^0.3.0",
|
|
21
|
+
"@parity/product-sdk-host": "^0.2.1",
|
|
21
22
|
"@polkadot-labs/hdkd": "^0.0.26",
|
|
22
23
|
"@polkadot-labs/hdkd-helpers": "^0.0.27",
|
|
23
24
|
"polkadot-api": "^2.1.2",
|