"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_assert_1 = __importDefault(require("node:assert"));
const node_test_1 = require("node:test");
const ethers_1 = require("ethers");
const tronweb_1 = require("tronweb");
const MnemonicWallet_js_1 = require("./MnemonicWallet.js");
(0, node_test_1.describe)("MnemonicWallet", () => {
    (0, node_test_1.it)("generates a valid EVM address from the seed phrase", () => {
        const wallet = (0, MnemonicWallet_js_1.generateVaultWallet)();
        node_assert_1.default.ok(wallet.seedPhrase.split(" ").length >= 12, "seed phrase should have at least 12 words");
        node_assert_1.default.ok(ethers_1.ethers.isAddress(wallet.evmAddress), "EVM address should be valid");
        const evmHdWallet = ethers_1.ethers.HDNodeWallet.fromPhrase(wallet.seedPhrase, "", MnemonicWallet_js_1.EVM_DERIVATION_PATH);
        node_assert_1.default.strictEqual(evmHdWallet.address, wallet.evmAddress, "EVM address should match the EVM derivation path");
        node_assert_1.default.strictEqual(evmHdWallet.privateKey, wallet.privateKey, "privateKey should be the EVM path private key");
    });
    (0, node_test_1.it)("generates a valid Tron address from the Tron derivation path", () => {
        const wallet = (0, MnemonicWallet_js_1.generateVaultWallet)();
        node_assert_1.default.ok(tronweb_1.TronWeb.isAddress(wallet.tronAddress), "Tron address should be valid");
        const tronHdWallet = ethers_1.ethers.HDNodeWallet.fromPhrase(wallet.seedPhrase, "", MnemonicWallet_js_1.TRON_DERIVATION_PATH);
        const tronPrivateKey = tronHdWallet.privateKey.startsWith("0x")
            ? tronHdWallet.privateKey.slice(2)
            : tronHdWallet.privateKey;
        const derivedTronAddress = tronweb_1.TronWeb.address.fromPrivateKey(tronPrivateKey);
        node_assert_1.default.strictEqual(derivedTronAddress, wallet.tronAddress, "Tron address should match the Tron derivation path");
    });
    (0, node_test_1.it)("derives network-specific wallets from a seed phrase", () => {
        const wallet = (0, MnemonicWallet_js_1.generateVaultWallet)();
        const evmWallet = (0, MnemonicWallet_js_1.deriveVaultWallet)(wallet.seedPhrase, "bsc");
        node_assert_1.default.strictEqual(evmWallet.address, wallet.evmAddress, "derived EVM address should match vault EVM address");
        const tronWallet = (0, MnemonicWallet_js_1.deriveVaultWallet)(wallet.seedPhrase, "tron");
        node_assert_1.default.strictEqual(tronWallet.address, wallet.tronAddress, "derived Tron address should match vault Tron address");
    });
    (0, node_test_1.it)("generates unique wallets each time", () => {
        const wallet1 = (0, MnemonicWallet_js_1.generateVaultWallet)();
        const wallet2 = (0, MnemonicWallet_js_1.generateVaultWallet)();
        node_assert_1.default.notStrictEqual(wallet1.evmAddress, wallet2.evmAddress);
        node_assert_1.default.notStrictEqual(wallet1.tronAddress, wallet2.tronAddress);
        node_assert_1.default.notStrictEqual(wallet1.seedPhrase, wallet2.seedPhrase);
    });
});
