@dotdm/env 0.3.0 → 0.3.1
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 +71 -7
- package/dist/index.js +129 -5
- package/package.json +4 -3
- package/dist/connection.d.ts +0 -36
- package/dist/connection.d.ts.map +0 -1
- package/dist/connection.js +0 -60
- package/dist/connection.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/known_chains.d.ts +0 -14
- package/dist/known_chains.d.ts.map +0 -1
- package/dist/known_chains.js +0 -38
- package/dist/known_chains.js.map +0 -1
- package/dist/signer.d.ts +0 -18
- package/dist/signer.d.ts.map +0 -1
- package/dist/signer.js +0 -39
- package/dist/signer.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,71 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
|
|
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 { AssetHub, Bulletin } from '@dotdm/descriptors';
|
|
5
|
+
export { ss58Address } from '@polkadot-labs/hdkd-helpers';
|
|
6
|
+
|
|
7
|
+
interface ChainFaucet {
|
|
8
|
+
label: string;
|
|
9
|
+
url: string;
|
|
10
|
+
}
|
|
11
|
+
interface ChainPreset {
|
|
12
|
+
assethubUrl: string;
|
|
13
|
+
bulletinUrl: string;
|
|
14
|
+
ipfsGatewayUrl: string;
|
|
15
|
+
faucets?: ChainFaucet[];
|
|
16
|
+
}
|
|
17
|
+
declare const KNOWN_CHAINS: Record<string, ChainPreset>;
|
|
18
|
+
type KnownChainName = keyof typeof KNOWN_CHAINS;
|
|
19
|
+
declare function getChainPreset(name: string): ChainPreset;
|
|
20
|
+
|
|
21
|
+
interface AssetHubConnection {
|
|
22
|
+
client: PolkadotClient;
|
|
23
|
+
api: TypedApi<AssetHub>;
|
|
24
|
+
}
|
|
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
|
+
interface BulletinConnection {
|
|
36
|
+
client: PolkadotClient;
|
|
37
|
+
api: TypedApi<Bulletin>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Connect to the Bulletin chain via WebSocket.
|
|
41
|
+
*/
|
|
42
|
+
declare function connectBulletinWebSocket(url: string): BulletinConnection;
|
|
43
|
+
/**
|
|
44
|
+
* Connect to a parachain via smoldot light client.
|
|
45
|
+
*
|
|
46
|
+
* @param parachainChainspec - Path to the parachain chainspec JSON file
|
|
47
|
+
* @param relayChainspec - Path to the relay chain chainspec JSON file
|
|
48
|
+
*/
|
|
49
|
+
declare function connectSmoldot(parachainChainspec: string, relayChainspec: string): Promise<AssetHubConnection>;
|
|
50
|
+
interface IpfsGateway {
|
|
51
|
+
fetch: (cid: string) => Promise<Response>;
|
|
52
|
+
}
|
|
53
|
+
declare function connectIpfsGateway(url: string): IpfsGateway;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Prepares a signer from a dev account name (e.g., "Alice", "Bob").
|
|
57
|
+
* Uses sr25519 key derivation compatible with Substrate dev accounts.
|
|
58
|
+
*/
|
|
59
|
+
declare function prepareSigner(name: string): polkadot_api.PolkadotSigner;
|
|
60
|
+
/**
|
|
61
|
+
* Prepares a signer from a mnemonic phrase.
|
|
62
|
+
* Derives sr25519 keypair from the mnemonic with no derivation path.
|
|
63
|
+
*/
|
|
64
|
+
declare function prepareSignerFromMnemonic(mnemonic: string): polkadot_api.PolkadotSigner;
|
|
65
|
+
/**
|
|
66
|
+
* Prepares a signer from a secret URI (SURI).
|
|
67
|
+
* Format: "//Alice" for dev accounts or a full mnemonic.
|
|
68
|
+
*/
|
|
69
|
+
declare function prepareSignerFromSuri(suri: string): polkadot_api.PolkadotSigner;
|
|
70
|
+
|
|
71
|
+
export { type AssetHubConnection, type BulletinConnection, type ChainFaucet, type ChainPreset, type IpfsGateway, KNOWN_CHAINS, type KnownChainName, connectAssetHubWebSocket, connectBulletinWebSocket, connectIpfsGateway, connectSmoldot, detectConnectionType, getChainPreset, prepareSigner, prepareSignerFromMnemonic, prepareSignerFromSuri };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 { createClient } from "polkadot-api";
|
|
45
|
+
import { getSmProvider } from "polkadot-api/sm-provider";
|
|
46
|
+
import { start } from "polkadot-api/smoldot";
|
|
47
|
+
import { getWsProvider } from "polkadot-api/ws-provider";
|
|
48
|
+
import { withPolkadotSdkCompat } from "polkadot-api/polkadot-sdk-compat";
|
|
49
|
+
import { assetHub, bulletin } from "@dotdm/descriptors";
|
|
50
|
+
function detectConnectionType(url) {
|
|
51
|
+
if (url.startsWith("ws://") || url.startsWith("wss://")) {
|
|
52
|
+
return "websocket";
|
|
53
|
+
}
|
|
54
|
+
return "smoldot";
|
|
55
|
+
}
|
|
56
|
+
function connectAssetHubWebSocket(url) {
|
|
57
|
+
const client = createClient(withPolkadotSdkCompat(getWsProvider(url)));
|
|
58
|
+
return { client, api: client.getTypedApi(assetHub) };
|
|
59
|
+
}
|
|
60
|
+
function connectBulletinWebSocket(url) {
|
|
61
|
+
const client = createClient(withPolkadotSdkCompat(getWsProvider(url)));
|
|
62
|
+
return { client, api: client.getTypedApi(bulletin) };
|
|
63
|
+
}
|
|
64
|
+
async function connectSmoldot(parachainChainspec, relayChainspec) {
|
|
65
|
+
const smoldot = start();
|
|
66
|
+
const { readFileSync } = await import("fs");
|
|
67
|
+
const relaySpec = readFileSync(relayChainspec, "utf-8");
|
|
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]
|
|
73
|
+
});
|
|
74
|
+
const client = createClient(getSmProvider(parachain));
|
|
75
|
+
return { client, api: client.getTypedApi(assetHub) };
|
|
76
|
+
}
|
|
77
|
+
function connectIpfsGateway(url) {
|
|
78
|
+
return {
|
|
79
|
+
fetch: (cid) => globalThis.fetch(`${url}/${cid}`, { signal: AbortSignal.timeout(15e3) }).then((r) => {
|
|
80
|
+
if (!r.ok) throw new Error(`IPFS fetch failed: ${r.statusText}`);
|
|
81
|
+
return r;
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/signer.ts
|
|
87
|
+
import { getPolkadotSigner } from "polkadot-api/signer";
|
|
88
|
+
import { sr25519CreateDerive } from "@polkadot-labs/hdkd";
|
|
89
|
+
import {
|
|
90
|
+
DEV_PHRASE,
|
|
91
|
+
entropyToMiniSecret,
|
|
92
|
+
mnemonicToEntropy,
|
|
93
|
+
ss58Address
|
|
94
|
+
} from "@polkadot-labs/hdkd-helpers";
|
|
95
|
+
function prepareSigner(name) {
|
|
96
|
+
const entropy = mnemonicToEntropy(DEV_PHRASE);
|
|
97
|
+
const miniSecret = entropyToMiniSecret(entropy);
|
|
98
|
+
const derive = sr25519CreateDerive(miniSecret);
|
|
99
|
+
const hdkdKeyPair = derive(`//${name}`);
|
|
100
|
+
return getPolkadotSigner(hdkdKeyPair.publicKey, "Sr25519", hdkdKeyPair.sign);
|
|
101
|
+
}
|
|
102
|
+
function prepareSignerFromMnemonic(mnemonic) {
|
|
103
|
+
const entropy = mnemonicToEntropy(mnemonic);
|
|
104
|
+
const miniSecret = entropyToMiniSecret(entropy);
|
|
105
|
+
const derive = sr25519CreateDerive(miniSecret);
|
|
106
|
+
const hdkdKeyPair = derive("");
|
|
107
|
+
return getPolkadotSigner(hdkdKeyPair.publicKey, "Sr25519", hdkdKeyPair.sign);
|
|
108
|
+
}
|
|
109
|
+
function prepareSignerFromSuri(suri) {
|
|
110
|
+
if (suri.startsWith("//")) {
|
|
111
|
+
return prepareSigner(suri.slice(2));
|
|
112
|
+
}
|
|
113
|
+
return prepareSignerFromMnemonic(suri);
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
DEFAULT_NODE_URL,
|
|
117
|
+
KNOWN_CHAINS,
|
|
118
|
+
REGISTRY_ADDRESS,
|
|
119
|
+
connectAssetHubWebSocket,
|
|
120
|
+
connectBulletinWebSocket,
|
|
121
|
+
connectIpfsGateway,
|
|
122
|
+
connectSmoldot,
|
|
123
|
+
detectConnectionType,
|
|
124
|
+
getChainPreset,
|
|
125
|
+
prepareSigner,
|
|
126
|
+
prepareSignerFromMnemonic,
|
|
127
|
+
prepareSignerFromSuri,
|
|
128
|
+
ss58Address
|
|
129
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotdm/env",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
"polkadot-api": "^1.23.3",
|
|
23
23
|
"smoldot": "^2.0.40",
|
|
24
24
|
"@dotdm/descriptors": "0.1.8",
|
|
25
|
-
"@dotdm/utils": "0.3.
|
|
25
|
+
"@dotdm/utils": "0.3.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^24.10.1",
|
|
29
|
+
"tsup": "^8.5.0",
|
|
29
30
|
"typescript": "^5.9.3"
|
|
30
31
|
},
|
|
31
32
|
"scripts": {
|
|
32
|
-
"build": "
|
|
33
|
+
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
33
34
|
"clean": "rm -rf dist"
|
|
34
35
|
}
|
|
35
36
|
}
|
package/dist/connection.d.ts
DELETED
|
@@ -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
|
package/dist/connection.d.ts.map
DELETED
|
@@ -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"}
|
package/dist/connection.js
DELETED
|
@@ -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
|
package/dist/connection.js.map
DELETED
|
@@ -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,CAAC;AAOD;;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,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,kBAA0B,EAC1B,cAAsB;IAEtB,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;IAExB,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,SAAS,GAAG,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACxD,MAAM,aAAa,GAAG,YAAY,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAEhE,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;IACpE,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC;QACrC,SAAS,EAAE,aAAa;QACxB,oBAAoB,EAAE,CAAC,UAAU,CAAC;KACrC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,YAAY,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;AACzD,CAAC;AAMD,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC1C,OAAO;QACH,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE,CACnB,UAAU,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,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"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -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"}
|
package/dist/known_chains.d.ts
DELETED
|
@@ -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"}
|
package/dist/known_chains.js
DELETED
|
@@ -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
|
package/dist/known_chains.js.map
DELETED
|
@@ -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
|
package/dist/signer.d.ts.map
DELETED
|
@@ -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
|
package/dist/signer.js.map
DELETED
|
@@ -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,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,GACd,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACtC,MAAM,OAAO,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAExC,OAAO,iBAAiB,CAAC,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;AACjF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAgB;IACtD,MAAM,OAAO,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAE/B,OAAO,iBAAiB,CAAC,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;AACjF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAC9C,oDAAoD;IACpD,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,gBAAgB;IAChB,OAAO,yBAAyB,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC"}
|