import { toChecksumAddress as toETHChecksumAddress } from 'ethereumjs-util' ; import { toChecksumAddress as toRSKChecksumAddress } from 'rskjs-util' ; import { toTokenBase } from './units' ; export const buildEIP681EtherRequest = ( recipientAddr , chainId , etherValue ) => `ethereum:${ recipientAddr }${ chainId !== 1 ? `@${ chainId }` : '' }?value=${ etherValue }e18` ; export const buildEIP681TokenRequest = ( recipientAddr , contractAddr , chainId , tokenValue , decimal ) => `ethereum:${ contractAddr }${ chainId !== 1 ? `@${ chainId }` : '' }/transfer?address=${ recipientAddr }&uint256=${ toTokenBase ( tokenValue , decimal ) }` ; export function formatMnemonic ( phrase ) { return phrase . replace ( /(\r\n|\n|\r|\s+|,)/gm , ' ' ) . trim ( ) ; } function getChecksumAddressFunction ( chainId ) { if ( chainId === 30 || chainId === 31 ) { return ( addr ) => toRSKChecksumAddress ( addr , chainId ) ; } return toETHChecksumAddress ; } export function toChecksumAddressByChainId ( address , chainId ) { return getChecksumAddressFunction ( chainId ) ( address ) ; }