How to use the @walletconnect/utils.payloadId 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 / eth-provider / src / provider.ts View on Github external
public _send (method?: string, params: any[] = []) {
    if (!method || typeof method !== 'string') {
      throw new Error('Method is not a valid string.')
    }
    if (!(params instanceof Array)) {
      throw new Error('Params is not a valid array.')
    }
    const payload = { jsonrpc: '2.0', id: payloadId(), method, params }
    const promise: Promise = new Promise((resolve, reject) => {
      this.promises[payload.id] = { resolve, reject }
    })
    this.connection.send(payload)
    return promise
  }
  public send () {
github WalletConnect / walletconnect-monorepo / packages / channel-provider / src / provider.ts View on Github external
public _send (method?: string, params?: any) {
    if (!method || typeof method !== 'string') {
      throw new Error('Method is not a valid string.')
    }
    if (!(params instanceof Object)) {
      throw new Error('Params is not a valid object.')
    }
    const payload = { jsonrpc: '2.0', id: payloadId(), method, params }
    const promise: Promise = new Promise((resolve, reject) => {
      this.promises[payload.id] = { resolve, reject }
    })
    this.connection.send(payload)
    return promise
  }
  public send () {
github WalletConnect / walletconnect-monorepo / packages / core / src / index.ts View on Github external
protected _formatRequest (request: Partial): IJsonRpcRequest {
    if (typeof request.method === 'undefined') {
      throw new Error(ERROR_MISSING_METHOD)
    }
    const formattedRequest: IJsonRpcRequest = {
      id: typeof request.id === 'undefined' ? payloadId() : request.id,
      jsonrpc: '2.0',
      method: request.method,
      params: typeof request.params === 'undefined' ? [] : request.params
    }
    return formattedRequest
  }