UNPKG

@reservoir0x/relay-kit-ui

Version:

Relay is the Fastest and Cheapest Way to Bridge and Transact Across Chains.

23 lines 868 B
/** * Ensure that an Ethereum address does not overflow * by removing the middle characters * @param address An Ethereum address * @param shrinkInidicator Visual indicator to show address is only * partially displayed * @returns A shrinked version of the Ethereum address * with the middle characters removed. */ function truncateAddress(address, shrinkInidicator, firstSectionLength, lastSectionLength) { return address ? address.slice(0, firstSectionLength ?? 4) + (shrinkInidicator || '…') + address.slice(-(lastSectionLength ?? 4)) : address; } function truncateEns(ensName, shrinkInidicator) { if (ensName.length < 24) return ensName; return ensName.slice(0, 20) + (shrinkInidicator || '…') + ensName.slice(-3); } export { truncateAddress, truncateEns }; //# sourceMappingURL=truncate.js.map