web3-domain-resolver
Version:
Web3 Library that enable with just one function to resolve domains on multiple web3 providers such as ENS, UnstoppableDomains and Freename
38 lines (37 loc) • 1.22 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionLibrary = void 0;
class ConnectionLibrary {
constructor(connections) {
this._connections = connections || [];
}
get connections() {
return this._connections;
}
set connections(value) {
this._connections = value;
}
getConnection(network) {
if (this._connections && network) {
const connection = this._connections.find(x => x.networkName == network);
return connection;
}
return undefined;
}
setConnection(connection) {
if (this._connections && connection.networkName && connection.rpcUrl) {
const indexFound = this._connections.findIndex(x => x.networkName == connection.networkName);
const newConnection = {
networkName: connection.networkName,
rpcUrl: connection.rpcUrl,
};
if (indexFound !== -1) {
this._connections[indexFound] = newConnection;
}
else {
this._connections.push(newConnection);
}
}
}
}
exports.ConnectionLibrary = ConnectionLibrary;
;