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
36 lines (35 loc) • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChainDetails = void 0;
let chainDict = false;
// This funcion calls fetch only once
// once fetched, it stores the chainDict in a variable
async function getChainDict() {
if (chainDict) {
return chainDict;
}
// Make a await call to fetch
let chainList = await fetch('https://chainid.network/chains_mini.json');
// Convert to json
let chainListJSON = await chainList.json();
// Create a dict
chainDict = {};
// convert chainList to dict with key chainId
chainListJSON.forEach((chain) => {
chainDict[chain.chainId] = chain;
});
return chainDict;
}
// Call getChainDict() to get the chainDict
// Then return the chain with chainId
async function getChainDetails(chainId) {
let chainValue;
try {
chainValue = (await getChainDict())[chainId];
}
catch (e) {
return false;
}
return chainValue;
}
exports.getChainDetails = getChainDetails;