@reservoir0x/relay-kit-ui
Version:
Relay is the Fastest and Cheapest Way to Bridge and Transact Across Chains.
28 lines • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTxBlockExplorerUrl = void 0;
const tslib_1 = require("tslib");
const getChainBlockExplorerUrl_js_1 = tslib_1.__importDefault(require("./getChainBlockExplorerUrl.js"));
const appendQueryParams = (url, params) => {
if (params) {
const queryParams = new URLSearchParams(params);
return `${url}?${queryParams.toString()}`;
}
return url;
};
const getTxBlockExplorerUrl = (chainId, chains, txHash) => {
const chain = chains?.find((chain) => chain.id === chainId);
let blockExplorerUrl = (0, getChainBlockExplorerUrl_js_1.default)(chainId, chains);
if (txHash) {
if (chain?.explorerPaths?.transaction) {
blockExplorerUrl = `${blockExplorerUrl}${chain.explorerPaths.transaction.replace('{TX_HASH}', txHash)}`;
}
else {
blockExplorerUrl = `${blockExplorerUrl}/tx/${txHash}`;
}
}
blockExplorerUrl = appendQueryParams(blockExplorerUrl, chain?.explorerQueryParams);
return blockExplorerUrl;
};
exports.getTxBlockExplorerUrl = getTxBlockExplorerUrl;
//# sourceMappingURL=getTxBlockExplorerUrl.js.map