UNPKG

crypto-wallet-core

Version:

A multi-currency support library for address derivation, private key creation, and transaction creation

68 lines 2.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeriverProxy = void 0; const arb_1 = require("./arb"); const base_1 = require("./base"); const bch_1 = require("./bch"); const btc_1 = require("./btc"); const doge_1 = require("./doge"); const eth_1 = require("./eth"); const ltc_1 = require("./ltc"); const matic_1 = require("./matic"); const op_1 = require("./op"); const paths_1 = require("./paths"); const sol_1 = require("./sol"); const xrp_1 = require("./xrp"); const derivers = { BTC: new btc_1.BtcDeriver(), BCH: new bch_1.BchDeriver(), ETH: new eth_1.EthDeriver(), XRP: new xrp_1.XrpDeriver(), DOGE: new doge_1.DogeDeriver(), LTC: new ltc_1.LtcDeriver(), MATIC: new matic_1.MaticDeriver(), ARB: new arb_1.ArbDeriver(), BASE: new base_1.BaseDeriver(), OP: new op_1.OpDeriver(), SOL: new sol_1.SolDeriver() }; class DeriverProxy { get(chain) { const normalizedChain = chain.toUpperCase(); return derivers[normalizedChain]; } deriveAddress(chain, network, xpubKey, addressIndex, isChange, addressType) { return this.get(chain).deriveAddress(network, xpubKey, addressIndex, isChange, addressType); } derivePrivateKey(chain, network, privKey, addressIndex, isChange, addressType) { return this.get(chain).derivePrivateKey(network, privKey, addressIndex, isChange, addressType); } deriveAddressWithPath(chain, network, xpubKey, path, addressType) { return this.get(chain).deriveAddressWithPath(network, xpubKey, path, addressType); } derivePrivateKeyWithPath(chain, network, xprivKey, path, addressType) { return this.get(chain).derivePrivateKeyWithPath(network, xprivKey, path, addressType); } getAddress(chain, network, pubKey, addressType) { return this.get(chain).getAddress(network, pubKey, addressType); } pathFor(chain, network, account = 0) { const normalizedChain = chain.toUpperCase(); const accountStr = `${account}'`; const chainConfig = paths_1.Paths[normalizedChain]; if (chainConfig) { if (chainConfig[network]) { return chainConfig[network] + accountStr; } else { return chainConfig.default + accountStr; } } else { return paths_1.Paths.BTC.default + accountStr; } } } exports.DeriverProxy = DeriverProxy; exports.default = new DeriverProxy(); //# sourceMappingURL=index.js.map