@goldsb/wc-utils
Version:
Utility Library for WalletConnect
59 lines • 2.25 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRpcUrl = exports.getInfuraRpcUrl = exports.logDeprecationWarning = exports.uuid = exports.payloadId = exports.removeHexLeadingZeros = exports.removeHexPrefix = exports.addHexPrefix = exports.sanitizeHex = void 0;
const tslib_1 = require("tslib");
const encoding = tslib_1.__importStar(require("@walletconnect/encoding"));
const jsonRpcUtils = tslib_1.__importStar(require("@walletconnect/jsonrpc-utils"));
const constants_1 = require("./constants");
function sanitizeHex(hex) {
return encoding.sanitizeHex(hex);
}
exports.sanitizeHex = sanitizeHex;
function addHexPrefix(hex) {
return encoding.addHexPrefix(hex);
}
exports.addHexPrefix = addHexPrefix;
function removeHexPrefix(hex) {
return encoding.removeHexPrefix(hex);
}
exports.removeHexPrefix = removeHexPrefix;
function removeHexLeadingZeros(hex) {
return encoding.removeHexLeadingZeros(encoding.addHexPrefix(hex));
}
exports.removeHexLeadingZeros = removeHexLeadingZeros;
exports.payloadId = jsonRpcUtils.payloadId;
function uuid() {
const result = ((a, b) => {
for (b = a = ""; a++ < 36; b += (a * 51) & 52 ? (a ^ 15 ? 8 ^ (Math.random() * (a ^ 20 ? 16 : 4)) : 4).toString(16) : "-") {
}
return b;
})();
return result;
}
exports.uuid = uuid;
function logDeprecationWarning() {
console.warn("DEPRECATION WARNING: This WalletConnect client library will be deprecated in favor of @walletconnect/client. Please check docs.walletconnect.org to learn more about this migration!");
}
exports.logDeprecationWarning = logDeprecationWarning;
function getInfuraRpcUrl(chainId, infuraId) {
let rpcUrl;
const network = constants_1.infuraNetworks[chainId];
if (network) {
rpcUrl = `https://${network}.infura.io/v3/${infuraId}`;
}
return rpcUrl;
}
exports.getInfuraRpcUrl = getInfuraRpcUrl;
function getRpcUrl(chainId, rpc) {
let rpcUrl;
const infuraUrl = getInfuraRpcUrl(chainId, rpc.infuraId);
if (rpc.custom && rpc.custom[chainId]) {
rpcUrl = rpc.custom[chainId];
}
else if (infuraUrl) {
rpcUrl = infuraUrl;
}
return rpcUrl;
}
exports.getRpcUrl = getRpcUrl;
//# sourceMappingURL=misc.js.map
;