UNPKG

@xpla/xpla

Version:

<p align="center"> <img src="https://user-images.githubusercontent.com/545047/188804067-28e67e5e-0214-4449-ab04-2e0c564a6885.svg" width="80"> </p>

42 lines (40 loc) 2.42 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const require_runtime = require('../_virtual/_rolldown/runtime.cjs'); const require_auth_strategy = require('../auth/strategy.cjs'); const require_auth_config = require('../auth/config.cjs'); let _interchainjs_types = require("@interchainjs/types"); let _interchainjs_cosmos_wallets_secp256k1hd = require("@interchainjs/cosmos/wallets/secp256k1hd"); let bip39 = require("bip39"); bip39 = require_runtime.__toESM(bip39); let _interchainjs_auth = require("@interchainjs/auth"); let deepmerge = require("deepmerge"); deepmerge = require_runtime.__toESM(deepmerge); //#region src/wallets/ethSecp256k1hd.ts (0, _interchainjs_auth.registerAddressStrategy)(require_auth_strategy.COSMOS_EVM_ADDRESS_STRATEGY); /** * HD Wallet implementation for secp256k1 with Ethereum-style address derivation for CosmosEvm * Extends Secp256k1HDWallet from Cosmos for consistent wallet behavior * Uses proper HD derivation with configurable derivation paths * Uses keccak256 hashing for address generation instead of standard Cosmos approach */ var EthSecp256k1HDWallet = class EthSecp256k1HDWallet extends _interchainjs_cosmos_wallets_secp256k1hd.Secp256k1HDWallet { constructor(privateKeys, config) { const mergedConfig = (0, deepmerge.default)(require_auth_config.createCosmosEvmConfig(config?.derivations, config?.privateKeyConfig?.passphrase), config || {}); super(privateKeys, mergedConfig); } /** * Create wallet from mnemonic with derivation paths from config * @param mnemonic BIP39 mnemonic phrase * @param config Wallet configuration including derivation paths and address prefix * @returns Promise<EthSecp256k1HDWallet> instance */ static async fromMnemonic(mnemonic, config) { if (!bip39.validateMnemonic(mnemonic)) throw new Error("Invalid mnemonic"); const walletConfig = (0, deepmerge.default)(require_auth_config.createCosmosEvmConfig(config?.derivations, config?.privateKeyConfig?.passphrase), config || {}); const privateKeyConfig = walletConfig.privateKeyConfig; const hdPaths = config?.derivations?.map((derivation) => _interchainjs_types.HDPath.fromString(derivation.hdPath)) || [_interchainjs_types.HDPath.eth(0, 0, 0)]; return new EthSecp256k1HDWallet(await _interchainjs_auth.PrivateKey.fromMnemonic(mnemonic, hdPaths, privateKeyConfig), walletConfig); } }; //#endregion exports.EthSecp256k1HDWallet = EthSecp256k1HDWallet;