How to use the @walletconnect/utils.parseTransactionData 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 / 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)

    try {
      const result = await this._sendCallRequest(formattedRequest)
      return result
github WalletConnect / walletconnect-monorepo / packages / core / src / index.ts View on Github external
public async sendTransaction (tx: ITxData) {
    if (!this._connected) {
      throw new Error(ERROR_SESSION_DISCONNECTED)
    }

    const parsedTx = parseTransactionData(tx)

    const request = this._formatRequest({
      method: 'eth_sendTransaction',
      params: [parsedTx]
    })

    try {
      const result = await this._sendCallRequest(request)
      return result
    } catch (error) {
      throw error
    }
  }
github WalletConnect / walletconnect-monorepo / packages / core / src / index.ts View on Github external
public async signTransaction (tx: ITxData) {
    if (!this._connected) {
      throw new Error(ERROR_SESSION_DISCONNECTED)
    }

    const parsedTx = parseTransactionData(tx)

    const request = this._formatRequest({
      method: 'eth_signTransaction',
      params: [parsedTx]
    })

    try {
      const result = await this._sendCallRequest(request)
      return result
    } catch (error) {
      throw error
    }
  }