Files
pwap/scripts/register_parachain.js
T
pezkuwichain 11678fe7cd feat(web): add network subpages and subdomains listing page
- Add /subdomains page listing all 20 PezkuwiChain subdomains
- Add Back to Home button to Subdomains page
- Create NetworkPage reusable component for network details
- Add 7 network subpages: /mainnet, /staging, /testnet, /beta, /alfa, /development, /local
- Update ChainSpecs network cards to navigate to network subpages
- Add i18n translations for chainSpecs section in en.ts
- Add SDK docs with rebranding support (rebrand-rustdoc.cjs)
- Add generate-docs-structure.cjs for automatic docs generation
- Update shared libs: endpoints, polkadot, wallet, xcm-bridge
- Add new token logos: TYR, ZGR, pezkuwi_icon
- Add new pages: Explorer, Docs, Wallet, Api, Faucet, Developers, Grants, Wiki, Forum, Telemetry
2025-12-11 00:33:47 +03:00

75 lines
2.3 KiB
JavaScript

#!/usr/bin/env node
const { ApiPromise, WsProvider, Keyring } = require('@polkadot/api');
const fs = require('fs');
async function main() {
const provider = new WsProvider('ws://127.0.0.1:9944');
const api = await ApiPromise.create({ provider });
// Read genesis files as hex strings
const genesisHead = '0x' + fs.readFileSync('/tmp/teyrchain-genesis-head', 'utf8').trim();
const genesisWasm = '0x' + fs.readFileSync('/tmp/teyrchain-genesis-wasm', 'utf8').trim();
console.log(`Genesis head length: ${genesisHead.length} chars`);
console.log(`Genesis WASM length: ${genesisWasm.length} chars`);
// Create keyring and add Alice
const keyring = new Keyring({ type: 'sr25519' });
const alice = keyring.addFromUri('//Alice');
console.log('Registering parachain 2000...');
// Para ID 2000
const paraId = 2000;
// Register parachain using sudo
const tx = api.tx.sudo.sudo(
api.tx.parasSudoWrapper.sudoScheduleParaInitialize(
paraId,
{
genesisHead,
validationCode: genesisWasm,
paraKind: true, // true for parachain, false for parathread
}
)
);
// Sign and send transaction
await new Promise(async (resolve, reject) => {
const unsub = await tx.signAndSend(alice, ({ status, events, dispatchError }) => {
console.log(`Transaction status: ${status.type}`);
if (status.isInBlock) {
console.log(`Included in block ${status.asInBlock.toHex()}`);
// Check for errors
if (dispatchError) {
if (dispatchError.isModule) {
const decoded = api.registry.findMetaError(dispatchError.asModule);
const { docs, name, section } = decoded;
console.error(`Error: ${section}.${name}: ${docs.join(' ')}`);
} else {
console.error(`Error: ${dispatchError.toString()}`);
}
reject(dispatchError);
}
events.forEach(({ event }) => {
const { section, method, data } = event;
console.log(`Event: ${section}.${method}`, data.toString());
});
} else if (status.isFinalized) {
console.log(`Finalized in block ${status.asFinalized.toHex()}`);
unsub();
resolve();
}
});
});
console.log('Parachain 2000 registered successfully!');
await api.disconnect();
}
main().catch(console.error).finally(() => process.exit());