UNPKG

@bcpros/crypto-wallet-core

Version:

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

73 lines 2.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeriverProxy = void 0; var arb_1 = require("./arb"); var base_1 = require("./base"); var bch_1 = require("./bch"); var btc_1 = require("./btc"); var doge_1 = require("./doge"); var eth_1 = require("./eth"); var ltc_1 = require("./ltc"); var matic_1 = require("./matic"); var op_1 = require("./op"); var paths_1 = require("./paths"); var xec_1 = require("./xec"); var xpi_1 = require("./xpi"); var xrp_1 = require("./xrp"); var 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(), XEC: new xec_1.XecDeriver(), XPI: new xpi_1.XpiDeriver(), 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(), }; var DeriverProxy = (function () { function DeriverProxy() { } DeriverProxy.prototype.get = function (chain) { return derivers[chain]; }; DeriverProxy.prototype.deriveAddress = function (chain, network, xpubKey, addressIndex, isChange, addressType) { return this.get(chain).deriveAddress(network, xpubKey, addressIndex, isChange, addressType); }; DeriverProxy.prototype.derivePrivateKey = function (chain, network, privKey, addressIndex, isChange, addressType) { return this.get(chain).derivePrivateKey(network, privKey, addressIndex, isChange, addressType); }; DeriverProxy.prototype.deriveAddressWithPath = function (chain, network, xpubKey, path, addressType) { return this.get(chain).deriveAddressWithPath(network, xpubKey, path, addressType); }; DeriverProxy.prototype.derivePrivateKeyWithPath = function (chain, network, xprivKey, path, addressType) { return this.get(chain).derivePrivateKeyWithPath(network, xprivKey, path, addressType); }; DeriverProxy.prototype.getAddress = function (chain, network, pubKey, addressType) { return this.get(chain).getAddress(network, pubKey, addressType); }; DeriverProxy.prototype.pathFor = function (chain, network, account) { if (account === void 0) { account = 0; } var normalizedChain = chain.toUpperCase(); var accountStr = "".concat(account, "'"); var 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; } }; return DeriverProxy; }()); exports.DeriverProxy = DeriverProxy; exports.default = new DeriverProxy(); //# sourceMappingURL=index.js.map