@dotdm/env 0.3.0 → 0.3.2-dev.1776660158

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,7 +1,103 @@
1
- export type { ChainPreset, ChainFaucet, KnownChainName } from "./known_chains";
2
- export { KNOWN_CHAINS, getChainPreset } from "./known_chains";
3
- export { DEFAULT_NODE_URL, REGISTRY_ADDRESS } from "@dotdm/utils";
4
- export type { AssetHubConnection, BulletinConnection, IpfsGateway } from "./connection";
5
- export { detectConnectionType, connectAssetHubWebSocket, connectBulletinWebSocket, connectSmoldot, connectIpfsGateway, } from "./connection";
6
- export { prepareSigner, prepareSignerFromSuri, prepareSignerFromMnemonic, ss58Address, } from "./signer";
7
- //# sourceMappingURL=index.d.ts.map
1
+ export { DEFAULT_NODE_URL, REGISTRY_ADDRESS } from '@dotdm/utils';
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';
7
+ export { ss58Address } from '@polkadot-labs/hdkd-helpers';
8
+
9
+ interface ChainFaucet {
10
+ label: string;
11
+ url: string;
12
+ }
13
+ interface ChainPreset {
14
+ assethubUrl: string;
15
+ bulletinUrl: string;
16
+ ipfsGatewayUrl: string;
17
+ faucets?: ChainFaucet[];
18
+ }
19
+ declare const KNOWN_CHAINS: Record<string, ChainPreset>;
20
+ type KnownChainName = keyof typeof KNOWN_CHAINS;
21
+ declare function getChainPreset(name: string): ChainPreset;
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
+ }>;
42
+ interface AssetHubConnection {
43
+ client: PolkadotClient;
44
+ api: TypedApi<typeof paseo_asset_hub>;
45
+ }
46
+ interface BulletinConnection {
47
+ client: PolkadotClient;
48
+ api: TypedApi<typeof bulletin>;
49
+ }
50
+ interface CdmChainEndpoints {
51
+ assethubUrl: string;
52
+ bulletinUrl: string;
53
+ }
54
+ /**
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.
64
+ */
65
+ declare function createCdmChainClient(arg: string | CdmChainEndpoints): Promise<CdmChainClient>;
66
+ /**
67
+ * Connect to Asset Hub only (no Bulletin). Used by commands that don't
68
+ * publish metadata — e.g., `install`, `account map`, `deploy-registry`.
69
+ */
70
+ declare function createCdmAssetHubClient(assethubUrl: string): Promise<CdmAssetHubClient>;
71
+ interface IpfsGateway {
72
+ fetch: (cid: string) => Promise<Response>;
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
+ */
85
+ declare function connectIpfsGateway(url: string): IpfsGateway;
86
+
87
+ /**
88
+ * Prepares a signer from a dev account name (e.g., "Alice", "Bob").
89
+ * Uses sr25519 key derivation compatible with Substrate dev accounts.
90
+ */
91
+ declare function prepareSigner(name: string): polkadot_api.PolkadotSigner;
92
+ /**
93
+ * Prepares a signer from a mnemonic phrase.
94
+ * Derives sr25519 keypair from the mnemonic with no derivation path.
95
+ */
96
+ declare function prepareSignerFromMnemonic(mnemonic: string): polkadot_api.PolkadotSigner;
97
+ /**
98
+ * Prepares a signer from a secret URI (SURI).
99
+ * Format: "//Alice" for dev accounts or a full mnemonic.
100
+ */
101
+ declare function prepareSignerFromSuri(suri: string): polkadot_api.PolkadotSigner;
102
+
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
@@ -1,5 +1,116 @@
1
- export { KNOWN_CHAINS, getChainPreset } from "./known_chains";
2
- export { DEFAULT_NODE_URL, REGISTRY_ADDRESS } from "@dotdm/utils";
3
- export { detectConnectionType, connectAssetHubWebSocket, connectBulletinWebSocket, connectSmoldot, connectIpfsGateway, } from "./connection";
4
- export { prepareSigner, prepareSignerFromSuri, prepareSignerFromMnemonic, ss58Address, } from "./signer";
5
- //# sourceMappingURL=index.js.map
1
+ // src/known_chains.ts
2
+ var KNOWN_CHAINS = {
3
+ polkadot: {
4
+ assethubUrl: "wss://polkadot-asset-hub-rpc.polkadot.io",
5
+ bulletinUrl: "wss://polkadot-bulletin-rpc.polkadot.io",
6
+ ipfsGatewayUrl: "https://polkadot-bulletin-rpc.polkadot.io/ipfs"
7
+ },
8
+ paseo: {
9
+ assethubUrl: "wss://asset-hub-paseo-rpc.n.dwellir.com",
10
+ bulletinUrl: "wss://paseo-bulletin-rpc.polkadot.io",
11
+ ipfsGatewayUrl: "https://paseo-ipfs.polkadot.io/ipfs",
12
+ faucets: [
13
+ { label: "Asset Hub", url: "https://faucet.polkadot.io/" },
14
+ {
15
+ label: "Bulletin",
16
+ url: "https://paritytech.github.io/polkadot-bulletin-chain/authorizations?tab=faucet"
17
+ }
18
+ ]
19
+ },
20
+ "preview-net": {
21
+ assethubUrl: "wss://previewnet.substrate.dev/asset-hub",
22
+ bulletinUrl: "wss://previewnet.substrate.dev/bulletin",
23
+ ipfsGatewayUrl: "https://previewnet.substrate.dev/ipfs/"
24
+ },
25
+ local: {
26
+ assethubUrl: "ws://127.0.0.1:10020",
27
+ bulletinUrl: "ws://127.0.0.1:10030",
28
+ ipfsGatewayUrl: "http://127.0.0.1:8283/ipfs"
29
+ }
30
+ };
31
+ function getChainPreset(name) {
32
+ const preset = KNOWN_CHAINS[name];
33
+ if (!preset) {
34
+ const valid = Object.keys(KNOWN_CHAINS).join(", ");
35
+ throw new Error(`Unknown chain "${name}". Valid names: ${valid}`);
36
+ }
37
+ return preset;
38
+ }
39
+
40
+ // src/index.ts
41
+ import { DEFAULT_NODE_URL, REGISTRY_ADDRESS } from "@dotdm/utils";
42
+
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";
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
+ });
59
+ }
60
+ async function createCdmAssetHubClient(assethubUrl) {
61
+ return createChainClient({
62
+ chains: { assetHub: paseo_asset_hub },
63
+ rpcs: { assetHub: [assethubUrl] }
64
+ });
65
+ }
66
+ function connectIpfsGateway(url) {
67
+ return {
68
+ fetch: (cid) => globalThis.fetch(`${url}/${cid}`, { signal: AbortSignal.timeout(15e3) }).then((r) => {
69
+ if (!r.ok) throw new Error(`IPFS fetch failed: ${r.statusText}`);
70
+ return r;
71
+ })
72
+ };
73
+ }
74
+
75
+ // src/signer.ts
76
+ import { getPolkadotSigner } from "polkadot-api/signer";
77
+ import { sr25519CreateDerive } from "@polkadot-labs/hdkd";
78
+ import {
79
+ DEV_PHRASE,
80
+ entropyToMiniSecret,
81
+ mnemonicToEntropy,
82
+ ss58Address
83
+ } from "@polkadot-labs/hdkd-helpers";
84
+ function prepareSigner(name) {
85
+ const entropy = mnemonicToEntropy(DEV_PHRASE);
86
+ const miniSecret = entropyToMiniSecret(entropy);
87
+ const derive = sr25519CreateDerive(miniSecret);
88
+ const hdkdKeyPair = derive(`//${name}`);
89
+ return getPolkadotSigner(hdkdKeyPair.publicKey, "Sr25519", hdkdKeyPair.sign);
90
+ }
91
+ function prepareSignerFromMnemonic(mnemonic) {
92
+ const entropy = mnemonicToEntropy(mnemonic);
93
+ const miniSecret = entropyToMiniSecret(entropy);
94
+ const derive = sr25519CreateDerive(miniSecret);
95
+ const hdkdKeyPair = derive("");
96
+ return getPolkadotSigner(hdkdKeyPair.publicKey, "Sr25519", hdkdKeyPair.sign);
97
+ }
98
+ function prepareSignerFromSuri(suri) {
99
+ if (suri.startsWith("//")) {
100
+ return prepareSigner(suri.slice(2));
101
+ }
102
+ return prepareSignerFromMnemonic(suri);
103
+ }
104
+ export {
105
+ DEFAULT_NODE_URL,
106
+ KNOWN_CHAINS,
107
+ REGISTRY_ADDRESS,
108
+ connectIpfsGateway,
109
+ createCdmAssetHubClient,
110
+ createCdmChainClient,
111
+ getChainPreset,
112
+ prepareSigner,
113
+ prepareSignerFromMnemonic,
114
+ prepareSignerFromSuri,
115
+ ss58Address
116
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotdm/env",
3
- "version": "0.3.0",
3
+ "version": "0.3.2-dev.1776660158",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -17,19 +17,21 @@
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.8",
25
- "@dotdm/utils": "0.3.0"
26
+ "@dotdm/utils": "0.3.1"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@types/node": "^24.10.1",
30
+ "tsup": "^8.5.0",
29
31
  "typescript": "^5.9.3"
30
32
  },
31
33
  "scripts": {
32
- "build": "tsc -p tsconfig.json",
34
+ "build": "tsup src/index.ts --format esm --dts --clean",
33
35
  "clean": "rm -rf dist"
34
36
  }
35
37
  }
@@ -1,36 +0,0 @@
1
- import type { PolkadotClient, TypedApi } from "polkadot-api";
2
- import type { AssetHub, Bulletin } from "@dotdm/descriptors";
3
- export interface AssetHubConnection {
4
- client: PolkadotClient;
5
- api: TypedApi<AssetHub>;
6
- }
7
- /**
8
- * Detect connection type from URL.
9
- * - ws:// or wss:// -> WebSocket
10
- * - file path -> smoldot with chainspec
11
- */
12
- export declare function detectConnectionType(url: string): "websocket" | "smoldot";
13
- /**
14
- * Connect to a chain via WebSocket.
15
- */
16
- export declare function connectAssetHubWebSocket(url: string): AssetHubConnection;
17
- export interface BulletinConnection {
18
- client: PolkadotClient;
19
- api: TypedApi<Bulletin>;
20
- }
21
- /**
22
- * Connect to the Bulletin chain via WebSocket.
23
- */
24
- export declare function connectBulletinWebSocket(url: string): BulletinConnection;
25
- /**
26
- * Connect to a parachain via smoldot light client.
27
- *
28
- * @param parachainChainspec - Path to the parachain chainspec JSON file
29
- * @param relayChainspec - Path to the relay chain chainspec JSON file
30
- */
31
- export declare function connectSmoldot(parachainChainspec: string, relayChainspec: string): Promise<AssetHubConnection>;
32
- export interface IpfsGateway {
33
- fetch: (cid: string) => Promise<Response>;
34
- }
35
- export declare function connectIpfsGateway(url: string): IpfsGateway;
36
- //# sourceMappingURL=connection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAM7D,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAKzE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAGxE;AAED,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAGxE;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAChC,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,MAAM,GACvB,OAAO,CAAC,kBAAkB,CAAC,CAe7B;AAED,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC7C;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAQ3D"}
@@ -1,60 +0,0 @@
1
- import { createClient } from "polkadot-api";
2
- import { getSmProvider } from "polkadot-api/sm-provider";
3
- import { start } from "polkadot-api/smoldot";
4
- import { getWsProvider } from "polkadot-api/ws-provider";
5
- import { withPolkadotSdkCompat } from "polkadot-api/polkadot-sdk-compat";
6
- import { assetHub, bulletin } from "@dotdm/descriptors";
7
- /**
8
- * Detect connection type from URL.
9
- * - ws:// or wss:// -> WebSocket
10
- * - file path -> smoldot with chainspec
11
- */
12
- export function detectConnectionType(url) {
13
- if (url.startsWith("ws://") || url.startsWith("wss://")) {
14
- return "websocket";
15
- }
16
- return "smoldot";
17
- }
18
- /**
19
- * Connect to a chain via WebSocket.
20
- */
21
- export function connectAssetHubWebSocket(url) {
22
- const client = createClient(withPolkadotSdkCompat(getWsProvider(url)));
23
- return { client, api: client.getTypedApi(assetHub) };
24
- }
25
- /**
26
- * Connect to the Bulletin chain via WebSocket.
27
- */
28
- export function connectBulletinWebSocket(url) {
29
- const client = createClient(withPolkadotSdkCompat(getWsProvider(url)));
30
- return { client, api: client.getTypedApi(bulletin) };
31
- }
32
- /**
33
- * Connect to a parachain via smoldot light client.
34
- *
35
- * @param parachainChainspec - Path to the parachain chainspec JSON file
36
- * @param relayChainspec - Path to the relay chain chainspec JSON file
37
- */
38
- export async function connectSmoldot(parachainChainspec, relayChainspec) {
39
- const smoldot = start();
40
- const { readFileSync } = await import("fs");
41
- const relaySpec = readFileSync(relayChainspec, "utf-8");
42
- const parachainSpec = readFileSync(parachainChainspec, "utf-8");
43
- const relayChain = await smoldot.addChain({ chainSpec: relaySpec });
44
- const parachain = await smoldot.addChain({
45
- chainSpec: parachainSpec,
46
- potentialRelayChains: [relayChain],
47
- });
48
- const client = createClient(getSmProvider(parachain));
49
- return { client, api: client.getTypedApi(assetHub) };
50
- }
51
- export function connectIpfsGateway(url) {
52
- return {
53
- fetch: (cid) => globalThis.fetch(`${url}/${cid}`, { signal: AbortSignal.timeout(15_000) }).then((r) => {
54
- if (!r.ok)
55
- throw new Error(`IPFS fetch failed: ${r.statusText}`);
56
- return r;
57
- }),
58
- };
59
- }
60
- //# sourceMappingURL=connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAQxD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC5C,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtD,OAAO,WAAW,CAAC;IACvB,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAChD,MAAM,MAAM,GAAG,YAAY,CAAC,qBAAqB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACvE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;AACzD,CAA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,CAAC,CAAC,EAAE,EAAE;YAClF,IAAI,CAAC,CAAC,CAAC,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;YACjE,OAAO,CAAC,CAAC;QACb,CAAC,CAAC;KACT,CAAC;AACN,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAElE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,cAAc,EACd,kBAAkB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACH,aAAa,EACb,qBAAqB,EACrB,yBAAyB,EACzB,WAAW,GACd,MAAM,UAAU,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGlE,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,cAAc,EACd,kBAAkB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACH,aAAa,EACb,qBAAqB,EACrB,yBAAyB,EACzB,WAAW,GACd,MAAM,UAAU,CAAC"}
@@ -1,14 +0,0 @@
1
- export interface ChainFaucet {
2
- label: string;
3
- url: string;
4
- }
5
- export interface ChainPreset {
6
- assethubUrl: string;
7
- bulletinUrl: string;
8
- ipfsGatewayUrl: string;
9
- faucets?: ChainFaucet[];
10
- }
11
- export declare const KNOWN_CHAINS: Record<string, ChainPreset>;
12
- export type KnownChainName = keyof typeof KNOWN_CHAINS;
13
- export declare function getChainPreset(name: string): ChainPreset;
14
- //# sourceMappingURL=known_chains.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"known_chains.d.ts","sourceRoot":"","sources":["../src/known_chains.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;CAC3B;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CA4BpD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,YAAY,CAAC;AAEvD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAOxD"}
@@ -1,38 +0,0 @@
1
- export const KNOWN_CHAINS = {
2
- polkadot: {
3
- assethubUrl: "wss://polkadot-asset-hub-rpc.polkadot.io",
4
- bulletinUrl: "wss://polkadot-bulletin-rpc.polkadot.io",
5
- ipfsGatewayUrl: "https://polkadot-bulletin-rpc.polkadot.io/ipfs",
6
- },
7
- paseo: {
8
- assethubUrl: "wss://asset-hub-paseo-rpc.n.dwellir.com",
9
- bulletinUrl: "wss://paseo-bulletin-rpc.polkadot.io",
10
- ipfsGatewayUrl: "https://paseo-ipfs.polkadot.io/ipfs",
11
- faucets: [
12
- { label: "Asset Hub", url: "https://faucet.polkadot.io/" },
13
- {
14
- label: "Bulletin",
15
- url: "https://paritytech.github.io/polkadot-bulletin-chain/authorizations?tab=faucet",
16
- },
17
- ],
18
- },
19
- "preview-net": {
20
- assethubUrl: "wss://previewnet.substrate.dev/asset-hub",
21
- bulletinUrl: "wss://previewnet.substrate.dev/bulletin",
22
- ipfsGatewayUrl: "https://previewnet.substrate.dev/ipfs/",
23
- },
24
- local: {
25
- assethubUrl: "ws://127.0.0.1:10020",
26
- bulletinUrl: "ws://127.0.0.1:10030",
27
- ipfsGatewayUrl: "http://127.0.0.1:8283/ipfs",
28
- },
29
- };
30
- export function getChainPreset(name) {
31
- const preset = KNOWN_CHAINS[name];
32
- if (!preset) {
33
- const valid = Object.keys(KNOWN_CHAINS).join(", ");
34
- throw new Error(`Unknown chain "${name}". Valid names: ${valid}`);
35
- }
36
- return preset;
37
- }
38
- //# sourceMappingURL=known_chains.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"known_chains.js","sourceRoot":"","sources":["../src/known_chains.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,YAAY,GAAgC;IACrD,QAAQ,EAAE;QACN,WAAW,EAAE,0CAA0C;QACvD,WAAW,EAAE,yCAAyC;QACtD,cAAc,EAAE,gDAAgD;KACnE;IACD,KAAK,EAAE;QACH,WAAW,EAAE,yCAAyC;QACtD,WAAW,EAAE,sCAAsC;QACnD,cAAc,EAAE,qCAAqC;QACrD,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,6BAA6B,EAAE;YAC1D;gBACI,KAAK,EAAE,UAAU;gBACjB,GAAG,EAAE,gFAAgF;aACxF;SACJ;KACJ;IACD,aAAa,EAAE;QACX,WAAW,EAAE,0CAA0C;QACvD,WAAW,EAAE,yCAAyC;QACtD,cAAc,EAAE,wCAAwC;KAC3D;IACD,KAAK,EAAE;QACH,WAAW,EAAE,sBAAsB;QACnC,WAAW,EAAE,sBAAsB;QACnC,cAAc,EAAE,4BAA4B;KAC/C;CACJ,CAAC;AAIF,MAAM,UAAU,cAAc,CAAC,IAAY;IACvC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,mBAAmB,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
package/dist/signer.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import { ss58Address } from "@polkadot-labs/hdkd-helpers";
2
- export { ss58Address };
3
- /**
4
- * Prepares a signer from a dev account name (e.g., "Alice", "Bob").
5
- * Uses sr25519 key derivation compatible with Substrate dev accounts.
6
- */
7
- export declare function prepareSigner(name: string): import("polkadot-api").PolkadotSigner;
8
- /**
9
- * Prepares a signer from a mnemonic phrase.
10
- * Derives sr25519 keypair from the mnemonic with no derivation path.
11
- */
12
- export declare function prepareSignerFromMnemonic(mnemonic: string): import("polkadot-api").PolkadotSigner;
13
- /**
14
- * Prepares a signer from a secret URI (SURI).
15
- * Format: "//Alice" for dev accounts or a full mnemonic.
16
- */
17
- export declare function prepareSignerFromSuri(suri: string): import("polkadot-api").PolkadotSigner;
18
- //# sourceMappingURL=signer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAEA,OAAO,EAIH,WAAW,EACd,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,yCAOzC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,yCAOzD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,yCAQjD"}
package/dist/signer.js DELETED
@@ -1,39 +0,0 @@
1
- import { getPolkadotSigner } from "polkadot-api/signer";
2
- import { sr25519CreateDerive } from "@polkadot-labs/hdkd";
3
- import { DEV_PHRASE, entropyToMiniSecret, mnemonicToEntropy, ss58Address, } from "@polkadot-labs/hdkd-helpers";
4
- export { ss58Address };
5
- /**
6
- * Prepares a signer from a dev account name (e.g., "Alice", "Bob").
7
- * Uses sr25519 key derivation compatible with Substrate dev accounts.
8
- */
9
- export function prepareSigner(name) {
10
- const entropy = mnemonicToEntropy(DEV_PHRASE);
11
- const miniSecret = entropyToMiniSecret(entropy);
12
- const derive = sr25519CreateDerive(miniSecret);
13
- const hdkdKeyPair = derive(`//${name}`);
14
- return getPolkadotSigner(hdkdKeyPair.publicKey, "Sr25519", hdkdKeyPair.sign);
15
- }
16
- /**
17
- * Prepares a signer from a mnemonic phrase.
18
- * Derives sr25519 keypair from the mnemonic with no derivation path.
19
- */
20
- export function prepareSignerFromMnemonic(mnemonic) {
21
- const entropy = mnemonicToEntropy(mnemonic);
22
- const miniSecret = entropyToMiniSecret(entropy);
23
- const derive = sr25519CreateDerive(miniSecret);
24
- const hdkdKeyPair = derive("");
25
- return getPolkadotSigner(hdkdKeyPair.publicKey, "Sr25519", hdkdKeyPair.sign);
26
- }
27
- /**
28
- * Prepares a signer from a secret URI (SURI).
29
- * Format: "//Alice" for dev accounts or a full mnemonic.
30
- */
31
- export function prepareSignerFromSuri(suri) {
32
- // Simple case: dev account shorthand like "//Alice"
33
- if (suri.startsWith("//")) {
34
- return prepareSigner(suri.slice(2));
35
- }
36
- // Full mnemonic
37
- return prepareSignerFromMnemonic(suri);
38
- }
39
- //# sourceMappingURL=signer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACH,UAAU,EACV,mBA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