How to use the @walletconnect/utils.convertNumberToHex 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 WalletConnect / walletconnect-monorepo / packages / web3-subprovider / src / connection.ts View on Github external
async handleStateMethods (payload: any) {
    let result: any = null
    switch (payload.method) {
      case 'eth_accounts':
        result = this.accounts
        break
      case 'eth_chainId':
        result = convertNumberToHex(this.chainId)
        break

      case 'net_version':
        result = this.networkId
        break
      default:
        break
    }
    return {
      id: payload.id,
      jsonrpc: payload.jsonrpc,
      result
    }
  }
github WalletConnect / walletconnect-monorepo / packages / channel-provider / src / connection.ts View on Github external
public async handleStateMethods (payload: any) {
    let result: any = null
    switch (payload.method) {
      case 'eth_accounts':
        result = this.accounts
        break
      case 'eth_chainId':
        result = convertNumberToHex(this.chainId)
        break

      case 'net_version':
        result = this.networkId
        break
      default:
        break
    }
    return {
      id: payload.id,
      jsonrpc: payload.jsonrpc,
      result
    }
  }
github WalletConnect / walletconnect-monorepo / packages / eth-provider / src / connection.ts View on Github external
public async handleStateMethods (payload: any) {
    let result: any = null
    switch (payload.method) {
      case 'eth_accounts':
        result = this.accounts
        break
      case 'eth_chainId':
        result = convertNumberToHex(this.chainId)
        break

      case 'net_version':
        result = this.networkId
        break
      default:
        break
    }
    return {
      id: payload.id,
      jsonrpc: payload.jsonrpc,
      result
    }
  }
github WalletConnect / walletconnect-monorepo / packages / core / src / index.ts View on Github external
public async sendCustomRequest (request: Partial) {
    if (!this._connected) {
      throw new Error(ERROR_SESSION_DISCONNECTED)
    }

    switch (request.method) {
      case 'eth_accounts':
        return this.accounts
      case 'eth_chainId':
        return convertNumberToHex(this.chainId)
      case 'eth_sendTransaction':
      case 'eth_signTransaction':
        if (request.params) {
          request.params[0] = parseTransactionData(request.params[0])
        }
        break
      case 'personal_sign':
        if (request.params) {
          request.params = parsePersonalSign(request.params)
        }
        break
      default:
        break
    }

    const formattedRequest = this._formatRequest(request)