import punycode from "punycode" ; import { TransactionInfo } from "../types/transactions" ; export const encodeObject = ( obj ) => btoa ( unescape ( encodeURIComponent ( JSON . stringify ( obj ) ) ) ) ; export const decodeString = ( str ) => decodeURIComponent ( escape ( atob ( str ) ) ) ; export const newTabHref = ( path = "" ) => `index.html#${ path }` ; export const removeQueryParam = ( url = "" ) => url . replace ( /\?(.*)/ , "" ) ; export const parsedSearchParam = ( param ) : TransactionInfo => { const decodedSearchParam = decodeString ( param . replace ( "?" , "" ) ) ; return decodedSearchParam ? JSON . parse ( decodedSearchParam ) : { } ; } ; export const getUrlHostname = ( url ) => { const u = new URL ( url ) ; return u . hostname ; } ; export const getPunycodedDomain = ( url ) => punycode . toASCII ( url ) ;