UNPKG

airgap-coin-lib

Version:

The airgap-coin-lib is a protocol agnostic library to prepare, sign and broadcast cryptocurrency transactions.

27 lines 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Network_1 = require("./Network"); var protocols = []; var supportedProtocols = function () { return protocols; }; exports.supportedProtocols = supportedProtocols; var addSupportedProtocol = function (newProtocol) { if (supportedProtocols().find(function (protocol) { return protocol.identifier === newProtocol.identifier && Network_1.isNetworkEqual(protocol.options.network, newProtocol.options.network); })) { throw new Error("protocol " + newProtocol.name + " on network " + newProtocol.options.network.type + "(" + newProtocol.options.network.rpcUrl + ") already exists"); } protocols.push(newProtocol); }; exports.addSupportedProtocol = addSupportedProtocol; var removeSupportedProtocol = function (protocolToRemove) { for (var index = 0; index < protocols.length; index++) { if (protocols[index].identifier === protocolToRemove.identifier && Network_1.isNetworkEqual(protocols[index].options.network, protocolToRemove.options.network)) { protocols.splice(index, 1); } } }; // TODO: Add tests exports.removeSupportedProtocol = removeSupportedProtocol; //# sourceMappingURL=supportedProtocols.js.map