UNPKG

@pushchain/ui-kit

Version:
47 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getChainId = exports.getWalletDataFromAccount = void 0; exports.centerMaskString = centerMaskString; const getWalletDataFromAccount = (account) => { const addressComponent = account.split(':'); // Handle cases where there are exactly three components (chain, chainId, address) if (addressComponent.length === 3) { return { chain: addressComponent[0], chainId: addressComponent[1], address: addressComponent[2], }; } // Handle cases where there are exactly two components (chain, address) else if (addressComponent.length === 2) { return { chain: addressComponent[0], chainId: '', address: addressComponent[1], }; } // If the input doesn't match the expected format, return the address only else { return { chain: '', chainId: '', address: account, }; } }; exports.getWalletDataFromAccount = getWalletDataFromAccount; function centerMaskString(str, len = 6) { if (str && str.length > 15) { const start = str.substring(0, len); const end = str.substring(str.length - len); return start + '...' + end; } // If the string is too short, return it as is return str; } const getChainId = (chain) => { const parts = chain.split(':'); return parts[1]; }; exports.getChainId = getChainId; //# sourceMappingURL=wallet.helpers.js.map