mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-10-20 18:56:29 +00:00
Remove root transfer test scripts
test-compare.mjs, test-extrinsic-hex.mjs, test-transfer.mjs and test-transfer-e2e.mjs were ad-hoc scripts run by hand against a node. They are not part of any package or test suite, and they embed the mnemonic of a test wallet in plain text. That wallet is retired.
This commit is contained in:
1 parent
25f98dd613
commit
87a099af2b
4 files changed
-313
No files matched your search
@@ -1,45 +0,0 @@
|
||||
import { ApiPromise, WsProvider, Keyring } from './packages/api/build/index.js';
|
||||
|
||||
const SENDER_SEED = 'crucial surge north silly divert throw habit fury zebra fabric tank output';
|
||||
const RECEIVER = '5HdY6U2UQF8wPwczP3SoQz28kQu1WJSBqxKGePUKG4M5QYdV';
|
||||
const RPC_ENDPOINT = 'wss://rpc.pezkuwichain.io';
|
||||
|
||||
const main = async () => {
|
||||
console.log('Connecting to Pezkuwi...');
|
||||
|
||||
const provider = new WsProvider(RPC_ENDPOINT);
|
||||
const api = await ApiPromise.create({
|
||||
provider,
|
||||
signedExtensions: {
|
||||
AuthorizeCall: {
|
||||
extrinsic: {},
|
||||
payload: {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Connected!');
|
||||
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
const sender = keyring.addFromUri(SENDER_SEED);
|
||||
|
||||
console.log('Sender:', sender.address);
|
||||
console.log('Receiver:', RECEIVER);
|
||||
|
||||
// Small amount: 0.0001 HEZ = 100000000 planks (10^8)
|
||||
const amount = 100000000n;
|
||||
|
||||
const tx = api.tx.balances.transferAllowDeath(RECEIVER, amount);
|
||||
|
||||
// Sign but don't send
|
||||
const signedTx = await tx.signAsync(sender);
|
||||
|
||||
console.log('\n=== SIGNED EXTRINSIC ===');
|
||||
console.log('Hex:', signedTx.toHex());
|
||||
console.log('\nMethod:', signedTx.method.toHex());
|
||||
console.log('Signature:', signedTx.signature.toHex());
|
||||
|
||||
await api.disconnect();
|
||||
};
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -1,68 +0,0 @@
|
||||
// Test: Generate extrinsic hex without sending
|
||||
import { ApiPromise, WsProvider, Keyring } from './packages/api/build/index.js';
|
||||
|
||||
const SENDER_SEED = 'crucial surge north silly divert throw habit fury zebra fabric tank output';
|
||||
const RECEIVER = '5FbRAFqo3WPNc1msSFy1cwr3oMNCwma5e4TcJjoX5uPUUqob';
|
||||
const RPC_ENDPOINT = 'wss://rpc.pezkuwichain.io';
|
||||
|
||||
const main = async () => {
|
||||
console.log('Connecting to PezkuwiChain Mainnet...');
|
||||
|
||||
const provider = new WsProvider(RPC_ENDPOINT);
|
||||
const api = await ApiPromise.create({
|
||||
provider,
|
||||
signedExtensions: {
|
||||
AuthorizeCall: {
|
||||
extrinsic: {},
|
||||
payload: {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Connected! Chain:', (await api.rpc.system.chain()).toString());
|
||||
|
||||
// Setup keyring and sender
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
const sender = keyring.addFromUri(SENDER_SEED);
|
||||
|
||||
console.log('\nSender address:', sender.address);
|
||||
console.log('Sender publicKey:', Buffer.from(sender.publicKey).toString('hex'));
|
||||
console.log('Receiver address:', RECEIVER);
|
||||
|
||||
// 0.01 HEZ = 0.01 * 10^12 (12 decimals)
|
||||
const amount = BigInt(Math.floor(0.01 * 1e12));
|
||||
console.log('\nAmount in planks:', amount.toString());
|
||||
|
||||
// Get current nonce
|
||||
const nonce = await api.rpc.system.accountNextIndex(sender.address);
|
||||
console.log('Current nonce:', nonce.toString());
|
||||
|
||||
// Create transaction
|
||||
const tx = api.tx.balances.transferAllowDeath(RECEIVER, amount);
|
||||
|
||||
// Sign the transaction
|
||||
const signedTx = await tx.signAsync(sender, { nonce });
|
||||
|
||||
// Get the hex
|
||||
const hex = signedTx.toHex();
|
||||
console.log('\n=== SIGNED EXTRINSIC HEX ===');
|
||||
console.log(hex);
|
||||
console.log('\n=== HEX LENGTH ===');
|
||||
console.log(hex.length, 'chars =', (hex.length - 2) / 2, 'bytes');
|
||||
|
||||
// Parse the extrinsic structure
|
||||
console.log('\n=== EXTRINSIC BREAKDOWN ===');
|
||||
const bytes = hex.slice(2); // remove 0x
|
||||
let pos = 0;
|
||||
|
||||
// Length (compact encoded)
|
||||
console.log('First bytes:', bytes.slice(0, 10));
|
||||
|
||||
await api.disconnect();
|
||||
console.log('\nDone!');
|
||||
};
|
||||
|
||||
main().catch((err) => {
|
||||
console.error('Error:', err.message || err);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -1,117 +0,0 @@
|
||||
// End-to-end HEZ transfer test
|
||||
import { ApiPromise, WsProvider, Keyring } from './packages/api/build/index.js';
|
||||
|
||||
const SENDER_SEED = 'crucial surge north silly divert throw habit fury zebra fabric tank output';
|
||||
const RECEIVER = '5FbRAFqo3WPNc1msSFy1cwr3oMNCwma5e4TcJjoX5uPUUqob';
|
||||
const RPC_ENDPOINT = 'wss://rpc.pezkuwichain.io';
|
||||
const AMOUNT_HEZ = 0.001; // Very small amount for testing
|
||||
|
||||
const main = async () => {
|
||||
console.log('=== PEZKUWI HEZ TRANSFER E2E TEST ===\n');
|
||||
console.log('Connecting to', RPC_ENDPOINT);
|
||||
|
||||
const provider = new WsProvider(RPC_ENDPOINT);
|
||||
const api = await ApiPromise.create({
|
||||
provider,
|
||||
signedExtensions: {
|
||||
AuthorizeCall: {
|
||||
extrinsic: {},
|
||||
payload: {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Connected! Chain:', (await api.rpc.system.chain()).toString());
|
||||
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
const sender = keyring.addFromUri(SENDER_SEED);
|
||||
|
||||
console.log('\nSender:', sender.address);
|
||||
console.log('Receiver:', RECEIVER);
|
||||
|
||||
// Get balances before
|
||||
const senderBalanceBefore = await api.query.system.account(sender.address);
|
||||
const receiverBalanceBefore = await api.query.system.account(RECEIVER);
|
||||
|
||||
console.log('\n--- BEFORE TRANSFER ---');
|
||||
console.log('Sender balance:', (BigInt(senderBalanceBefore.data.free) / BigInt(1e12)).toString(), 'HEZ');
|
||||
console.log('Receiver balance:', (BigInt(receiverBalanceBefore.data.free) / BigInt(1e12)).toString(), 'HEZ');
|
||||
|
||||
// Amount in planks (12 decimals)
|
||||
const amount = BigInt(Math.floor(AMOUNT_HEZ * 1e12));
|
||||
console.log('\nTransferring:', AMOUNT_HEZ, 'HEZ (', amount.toString(), 'planks)');
|
||||
|
||||
// Create and send transaction
|
||||
const tx = api.tx.balances.transferKeepAlive(RECEIVER, amount);
|
||||
|
||||
console.log('\nSending transaction...');
|
||||
|
||||
try {
|
||||
const hash = await new Promise((resolve, reject) => {
|
||||
tx.signAndSend(sender, ({ status, events, dispatchError }) => {
|
||||
console.log('Status:', status.type);
|
||||
|
||||
if (dispatchError) {
|
||||
if (dispatchError.isModule) {
|
||||
const decoded = api.registry.findMetaError(dispatchError.asModule);
|
||||
reject(new Error(`${decoded.section}.${decoded.name}: ${decoded.docs.join(' ')}`));
|
||||
} else {
|
||||
reject(new Error(dispatchError.toString()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (status.isInBlock) {
|
||||
console.log('Included in block:', status.asInBlock.toHex());
|
||||
}
|
||||
|
||||
if (status.isFinalized) {
|
||||
console.log('Finalized in block:', status.asFinalized.toHex());
|
||||
|
||||
// Check for success event
|
||||
const success = events.find(({ event }) =>
|
||||
api.events.system.ExtrinsicSuccess.is(event)
|
||||
);
|
||||
|
||||
if (success) {
|
||||
resolve(status.asFinalized.toHex());
|
||||
} else {
|
||||
reject(new Error('Transaction failed - no success event'));
|
||||
}
|
||||
}
|
||||
}).catch(reject);
|
||||
});
|
||||
|
||||
console.log('\n=== TRANSFER SUCCESSFUL ===');
|
||||
console.log('Block hash:', hash);
|
||||
|
||||
// Get balances after
|
||||
const senderBalanceAfter = await api.query.system.account(sender.address);
|
||||
const receiverBalanceAfter = await api.query.system.account(RECEIVER);
|
||||
|
||||
console.log('\n--- AFTER TRANSFER ---');
|
||||
console.log('Sender balance:', (BigInt(senderBalanceAfter.data.free) / BigInt(1e12)).toString(), 'HEZ');
|
||||
console.log('Receiver balance:', (BigInt(receiverBalanceAfter.data.free) / BigInt(1e12)).toString(), 'HEZ');
|
||||
|
||||
const receiverDiff = BigInt(receiverBalanceAfter.data.free) - BigInt(receiverBalanceBefore.data.free);
|
||||
console.log('\nReceiver balance change:', (receiverDiff / BigInt(1e12)).toString(), 'HEZ');
|
||||
|
||||
if (receiverDiff === amount) {
|
||||
console.log('\n✅ TEST PASSED: Transfer completed correctly!');
|
||||
} else {
|
||||
console.log('\n⚠️ Balance change does not match expected amount');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('\n❌ TRANSFER FAILED:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
await api.disconnect();
|
||||
console.log('\nDone!');
|
||||
};
|
||||
|
||||
main().catch((err) => {
|
||||
console.error('Fatal error:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -1,83 +0,0 @@
|
||||
// Test: 10 HEZ transfer using @pezkuwi/api
|
||||
import { ApiPromise, WsProvider, Keyring } from './packages/api/build/index.js';
|
||||
|
||||
const SENDER_SEED = 'crucial surge north silly divert throw habit fury zebra fabric tank output';
|
||||
const RECEIVER = '5D26fJAsbFnaarz85Kv51Eau52nsTBs3L4sYQDbLMtWHhuLU';
|
||||
const RPC_ENDPOINT = 'ws://62.146.235.186:9944'; // VPS2
|
||||
|
||||
const main = async () => {
|
||||
console.log('Connecting to PezkuwiChain Mainnet...');
|
||||
|
||||
const provider = new WsProvider(RPC_ENDPOINT);
|
||||
const api = await ApiPromise.create({
|
||||
provider,
|
||||
signedExtensions: {
|
||||
AuthorizeCall: {
|
||||
extrinsic: {},
|
||||
payload: {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Connected! Chain:', (await api.rpc.system.chain()).toString());
|
||||
console.log('Block:', (await api.rpc.chain.getHeader()).number.toString());
|
||||
|
||||
// Setup keyring and sender
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
const sender = keyring.addFromUri(SENDER_SEED);
|
||||
|
||||
console.log('\nSender address:', sender.address);
|
||||
console.log('Receiver address:', RECEIVER);
|
||||
|
||||
// Check sender balance before
|
||||
const balanceBefore = await api.query.balances.account(sender.address);
|
||||
console.log('\nSender balance before:', (BigInt(balanceBefore.free.toString()) / 10n**18n).toString(), 'HEZ');
|
||||
|
||||
// 10 HEZ = 10 * 10^18 TYR (smallest unit)
|
||||
const amount = 10n * 10n**18n;
|
||||
console.log('\nTransferring 10 HEZ...');
|
||||
|
||||
// Create and send transaction
|
||||
const tx = api.tx.balances.transferAllowDeath(RECEIVER, amount);
|
||||
|
||||
const hash = await new Promise((resolve, reject) => {
|
||||
tx.signAndSend(sender, ({ status, dispatchError }) => {
|
||||
console.log('Status:', status.type);
|
||||
|
||||
if (status.isInBlock) {
|
||||
console.log('Included in block:', status.asInBlock.toHex());
|
||||
}
|
||||
|
||||
if (status.isFinalized) {
|
||||
if (dispatchError) {
|
||||
if (dispatchError.isModule) {
|
||||
const decoded = api.registry.findMetaError(dispatchError.asModule);
|
||||
reject(new Error(`${decoded.section}.${decoded.name}: ${decoded.docs.join(' ')}`));
|
||||
} else {
|
||||
reject(new Error(dispatchError.toString()));
|
||||
}
|
||||
} else {
|
||||
console.log('Finalized in block:', status.asFinalized.toHex());
|
||||
resolve(status.asFinalized.toHex());
|
||||
}
|
||||
}
|
||||
}).catch(reject);
|
||||
});
|
||||
|
||||
// Check balances after
|
||||
const senderBalanceAfter = await api.query.balances.account(sender.address);
|
||||
const receiverBalanceAfter = await api.query.balances.account(RECEIVER);
|
||||
|
||||
console.log('\n--- RESULT ---');
|
||||
console.log('Transaction hash:', hash);
|
||||
console.log('Sender balance after:', (BigInt(senderBalanceAfter.free.toString()) / 10n**18n).toString(), 'HEZ');
|
||||
console.log('Receiver balance after:', (BigInt(receiverBalanceAfter.free.toString()) / 10n**18n).toString(), 'HEZ');
|
||||
|
||||
await api.disconnect();
|
||||
console.log('\nTest completed successfully!');
|
||||
};
|
||||
|
||||
main().catch((err) => {
|
||||
console.error('Error:', err.message || err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in new issue
Block a user