Developer Questions
getting this error var Keypair = ripple_keypairs_1.default.deriveKeypair(familyseed); ^ TypeError: Cannot read properties of undefined (reading 'deriveKeypair')
about 1 year ago by Zia Ullah khan
if (process.argv.length < 3) {
console.log('usage: node dist/index <secret_type> <secret> <destination> <amount>');
console.log ("secret type\n1. family\n2. Mnemonic\n\n")
process.exit(1);
}
import { XrplClient } from "xrpl-client";
import { utils, derive, sign } from "xrpl-accountlib";
const cilent = new XrplClient('wss://s.altnet.rippletest.net:51233');
const main = async () => {
let account: any;
if (isNaN(Number(process.argv[5]))){
console.log('Invalid amount');
process.exit(1);
}
if (process.argv[2] !== "1" && process.argv[2] !== "2") {
console.log('\nPlease enter appropriate secret type from the selection\n');
process.exit(1);
}
if (!utils.isValidAddress(process.argv[4])) {
console.log('Invalid destination address');
process.exit(1);
}
if (process.argv[2] === "1"){
if (!utils.isValidSeed(process.argv[3])) {
console.log('Invalid family seed');
process.exit(1);
}
account = derive.familySeed(process.argv[3]);
}
if (process.argv[2] === "2" ) {
if (!utils.isValidMnemnic(process.argv[3])) {
console.log('Invalid Mnemonic');
process.exit(1);
}
account = derive.mnemonic(process.argv[3]);
}
console.log(process.argv[3])
const data = await cilent.send({
id :1,
command: 'account_info',
account: account.address,
strict: true,
});
/*console.log(data);*/
if (data.error){
console.log ("Error: ", data.error_message);
process.exit(1);
}
console.log("Balance: ", Number(data.account_data.Balance) / 1000000);
if (
Number(data.account_data.Balance) / 1000000 <=
Number(process.argv[5]) +10
) {
console.log("Not enough balance");
process.exit(1);
}
const { id, signedTransaction } = sign(
{
TransactionType: 'Payment',
account: account.address,
Destination: process.argv[4],
Amount: String(Number(process.argv[5]) * 1000000),
Sequence: data.account_data.Sequence,
Fee: String(12),
},
account);
console.log(id);
console.log(signedTransaction);
/*
if (data.error){
console.log ("Error: ", data.error_message);
process.exit(1);
}
console.log("LedgerEntryType: ", data.result.account_data?.LedgerEntryType);
console.log("Balance: ", data.result.account_data.Balance / 1000000, "XRP");
console.log("OwnerCount: ", data.result.account_data?.OwnerCount);
console.log("Sequence: ", data.result.account_data?.Sequence);
console.log("Current Ledger Index: ", data?.ledger_current_index);
*/
};
main();
this is the full script