How to use the @walletconnect/utils.convertHexToUtf8 function in @walletconnect/utils

To help you get started, we’ve selected a few @walletconnect/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rainbow-me / rainbow / src / parsers / requests.js View on Github external
transaction,
      assets,
      nativeCurrency,
      timestampInMs
    );
  }
  if (payload.method === SIGN) {
    const message = get(payload, 'params[1]');
    const result = getMessageDisplayDetails(message, timestampInMs);
    return result;
  }
  if (payload.method === PERSONAL_SIGN) {
    let message = get(payload, 'params[0]');
    try {
      if (isHexString(message)) {
        message = convertHexToUtf8(message);
      }
    } catch (error) {
      // TODO error handling
    }
    return getMessageDisplayDetails(message, timestampInMs);
  }
  if (payload.method === SIGN_TYPED || payload.method === SIGN_TYPED_V3) {
    const request = get(payload, 'params[1]', null);
    const jsonRequest = JSON.stringify(request.message);
    return getMessageDisplayDetails(jsonRequest, timestampInMs);
  }
  return {};
};
github WalletConnect / walletconnect-test-wallet / src / helpers / utilities.ts View on Github external
export function convertHexToUtf8IfPossible(hex: string) {
  try {
    return convertHexToUtf8(hex);
  } catch(e) {
    return hex;
  }
}
github rainbow-me / rainbow / src / redux / transactionsToApprove.js View on Github external
return getTransactionDisplayDetails(
      transaction,
      assets,
      prices,
      nativeCurrency,
      timestampInMs,
    );
  }
  if (payload.method === 'eth_sign') {
    const message = get(payload, 'params[1]');
    return getMessageDisplayDetails(message, timestampInMs);
  }
  if (payload.method === 'personal_sign') {
    let message = '';
    try {
      message = convertHexToUtf8(get(payload, 'params[0]'));
    } catch (error) {
      message = get(payload, 'params[0]');
    }
    return getMessageDisplayDetails(message, timestampInMs, 'messagePersonal');
  }
  if (payload.method === 'eth_signTypedData'
    || payload.method === 'eth_signTypedData_v3') {
    const request = get(payload, 'params[1]', null);
    const jsonRequest = JSON.stringify(request.message);
    return getMessageDisplayDetails(jsonRequest, timestampInMs);
  }
  return {};
};