UNPKG

glip-wallet-sdk

Version:

Guide for installation and usage of Glip's Web3 Wallet.\ Glip Wallet through its SDK provides a signer using which a user's transaction can be signed.\ It also contains a iframe based UI element which can be embedded into any webpage.\ The UI contains

44 lines (43 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getChainDetails = exports.getInternalProvider = void 0; const ethers_1 = require("ethers"); const chainListService_1 = require("./chainListService"); Object.defineProperty(exports, "getChainDetails", { enumerable: true, get: function () { return chainListService_1.getChainDetails; } }); const API_KEY_INFURA = 'a0425606c7964da3a91be846c891fee7'; function getInfuraHttpRpcUrl(rpcValues) { console.log('rpcValues', rpcValues); for (let rpcValue of rpcValues) { // check if rpcvalue starts with https // and has infura in string if (rpcValue.startsWith('https') && rpcValue.includes('infura')) { // replace ${INFURA_API_KEY} with apikey return rpcValue.replace('${INFURA_API_KEY}', API_KEY_INFURA); } } return false; } function getHttpRpcUrl(rpcValues) { console.log('rpcValues', rpcValues); for (let rpcValue of rpcValues) { // check if rpcvalue starts with https if (rpcValue.startsWith('https')) { return rpcValue; } } return false; } async function getInternalProvider(chainId) { console.log('chainId', chainId); let chainValue = await (0, chainListService_1.getChainDetails)(chainId); if (!chainValue) { throw new Error(`ChainId not found ${chainId}`); } console.log('chainValue', chainValue); let infuraRPC = getInfuraHttpRpcUrl(chainValue.rpc); let httpRPC = getHttpRpcUrl(chainValue.rpc); let rpcUrl = infuraRPC || httpRPC; let jsonRpcProvider = new ethers_1.ethers.providers.JsonRpcProvider(rpcUrl); return jsonRpcProvider; } exports.getInternalProvider = getInternalProvider;