How to use the @audius/libs.AudiusABIDecoder.decodeMethod function in @audius/libs

To help you get started, we’ve selected a few @audius/libs 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 AudiusProject / audius-protocol / identity-service / src / txRelay.js View on Github external
// contracts (eg. storage contracts, discovery service contract, should not be allowed
  // to relay TXes from here but can today).

  const existingTx = await models.Transaction.findOne({
    where: {
      encodedABI: encodedABI // this should always be unique because of the nonce / sig
    }
  })

  // if this transaction has already been submitted before and succeeded, send this receipt
  if (existingTx) {
    return existingTx.receipt
  }

  const contractName = contractRegistryKey.charAt(0).toUpperCase() + contractRegistryKey.slice(1) // uppercase the first letter
  const decodedABI = AudiusABIDecoder.decodeMethod(contractName, encodedABI)

  const privateKeyBuffer = Buffer.from(config.get('relayerPrivateKey'), 'hex')
  const wallet = EthereumWallet.fromPrivateKey(privateKeyBuffer)
  const address = wallet.getAddressString()
  if (address !== config.get('relayerPublicKey').toLowerCase()) {
    throw new Error('Invalid relayerPublicKey')
  }

  let gasPrice = parseInt(await web3.eth.getGasPrice())
  if (isNaN(gasPrice) || gasPrice > HIGH_GAS_PRICE) {
    gasPrice = GANACHE_GAS_PRICE
  } else if (gasPrice === 0) {
    // If the gas is zero, the txn will likely never get mined.
    gasPrice = MIN_GAS_PRICE
  } else if (gasPrice < MIN_GAS_PRICE) {
    gasPrice = MIN_GAS_PRICE

@audius/libs

This is an npm module which contains the common javascript functionality for consuming Audius services and communicating with ETH-compatible blockchains

Apache-2.0
Latest version published 2 years ago

Package Health Score

55 / 100
Full package analysis

Similar packages