How to use the @liquality/ethereum-utils.remove0x function in @liquality/ethereum-utils

To help you get started, we’ve selected a few @liquality/ethereum-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 liquality / chainabstractionlayer / packages / ethereum-swap-provider / lib / EthereumSwapProvider.js View on Github external
createSwapScript (recipientAddress, refundAddress, secretHash, expiration) {
    recipientAddress = remove0x(addressToString(recipientAddress))
    refundAddress = remove0x(addressToString(refundAddress))

    const dataSizeBase = 112
    const redeemDestinationBase = 66
    const refundDestinationBase = 89
    const expirationHex = expiration.toString(16)
    const expirationEncoded = padHexStart(expirationHex) // Pad with 0
    const expirationSize = expirationEncoded.length / 2
    const expirationPushOpcode = (0x60 - 1 + expirationSize).toString(16)
    const redeemDestinationEncoded = (redeemDestinationBase + expirationSize).toString(16)
    const refundDestinationEncoded = (refundDestinationBase + expirationSize).toString(16)
    const dataSizeEncoded = (dataSizeBase + expirationSize).toString(16)

    return [
      // Constructor
      '60', dataSizeEncoded, // PUSH1 {dataSizeEncoded}
github liquality / chainabstractionlayer / packages / ethereum-swap-provider / lib / EthereumSwapProvider.js View on Github external
createSwapScript (recipientAddress, refundAddress, secretHash, expiration) {
    recipientAddress = remove0x(addressToString(recipientAddress))
    refundAddress = remove0x(addressToString(refundAddress))

    const dataSizeBase = 112
    const redeemDestinationBase = 66
    const refundDestinationBase = 89
    const expirationHex = expiration.toString(16)
    const expirationEncoded = padHexStart(expirationHex) // Pad with 0
    const expirationSize = expirationEncoded.length / 2
    const expirationPushOpcode = (0x60 - 1 + expirationSize).toString(16)
    const redeemDestinationEncoded = (redeemDestinationBase + expirationSize).toString(16)
    const refundDestinationEncoded = (refundDestinationBase + expirationSize).toString(16)
    const dataSizeEncoded = (dataSizeBase + expirationSize).toString(16)

    return [
      // Constructor
      '60', dataSizeEncoded, // PUSH1 {dataSizeEncoded}
      '80', // DUP1
github liquality / chainabstractionlayer / packages / ethereum-erc20-swap-provider / lib / EthereumErc20SwapProvider.js View on Github external
const refundSwapTransaction = block.transactions.find(transaction =>
      transaction.to === initiationTransaction.contractAddress &&
      transaction.input === remove0x(SOL_REFUND_FUNCTION) && // eslint-disable-line
      block.timestamp >= expiration
    )
github liquality / chainabstractionlayer / packages / ethereum-erc20-swap-provider / lib / EthereumErc20SwapProvider.js View on Github external
createSwapScript (recipientAddress, refundAddress, secretHash, expiration) {
    recipientAddress = remove0x(addressToString(recipientAddress))
    refundAddress = remove0x(addressToString(refundAddress))

    const tokenAddress = remove0x(this.getMethod('getContractAddress')())
    const expirationEncoded = padHexStart(expiration.toString(16), 64)
    const bytecode = [
      '608060405260008054600160a060020a031990811673',
      recipientAddress,
      '1790915560018054821673',
      refundAddress,
      '1790556002805490911673',
      tokenAddress,
      '1790557f',
      secretHash,
      '60035534801561009a57600080fd5b50610414806100aa6000396000f3fe60806040526004361061002c5760e060020a6000350463590e1ae38114610031578063bd66528a14610048575b600080fd5b34801561003d57600080fd5b50610046610072565b005b34801561005457600080fd5b506100466004803603602081101561006b57600080fd5b50356101e9565b7f',
      expirationEncoded,
      '421161009e57600080fd5b600254600154604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9384169363a9059cbb93169184916370a0823191602480820192602092909190829003018186803b15801561011c57600080fd5b505afa158015610130573d6000803e3d6000fd5b505050506040513d602081101561014657600080fd5b50516040805160e060020a63ffffffff861602815273ffffffffffffffffffffffffffffffffffffffff909316600484015260248301919091525160448083019260209291908290030181600087803b1580156101a257600080fd5b505af11580156101b6573d6000803e3d6000fd5b505050506040513d60208110156101cc57600080fd5b505060015473ffffffffffffffffffffffffffffffffffffffff16ff5b600354600282604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b6020831061023d5780518252601f19909201916020918201910161021e565b51815160209384036101000a60001901801990921691161790526040519190930194509192505080830381855afa15801561027c573d6000803e3d6000fd5b5050506040513d602081101561029157600080fd5b50511461029d57600080fd5b600254600054604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9384169363a9059cbb93169184916370a0823191602480820192602092909190829003018186803b15801561031b57600080fd5b505afa15801561032f573d6000803e3d6000fd5b505050506040513d602081101561034557600080fd5b50516040805160e060020a63ffffffff861602815273ffffffffffffffffffffffffffffffffffffffff909316600484015260248301919091525160448083019260209291908290030181600087803b1580156103a157600080fd5b505af11580156103b5573d6000803e3d6000fd5b505050506040513d60208110156103cb57600080fd5b505060005473ffffffffffffffffffffffffffffffffffffffff16fffea165627a7a72305820b4278861f73b5e043b52d6669b023d772371e3ae909ecd4e617dd82afb7d1ffd0029'
github liquality / chainabstractionlayer / packages / ethereum-erc20-swap-provider / lib / EthereumErc20SwapProvider.js View on Github external
createSwapScript (recipientAddress, refundAddress, secretHash, expiration) {
    recipientAddress = remove0x(addressToString(recipientAddress))
    refundAddress = remove0x(addressToString(refundAddress))

    const tokenAddress = remove0x(this.getMethod('getContractAddress')())
    const expirationEncoded = padHexStart(expiration.toString(16), 64)
    const bytecode = [
      '608060405260008054600160a060020a031990811673',
      recipientAddress,
      '1790915560018054821673',
      refundAddress,
      '1790556002805490911673',
      tokenAddress,
      '1790557f',
      secretHash,
      '60035534801561009a57600080fd5b50610414806100aa6000396000f3fe60806040526004361061002c5760e060020a6000350463590e1ae38114610031578063bd66528a14610048575b600080fd5b34801561003d57600080fd5b50610046610072565b005b34801561005457600080fd5b506100466004803603602081101561006b57600080fd5b50356101e9565b7f',
      expirationEncoded,
      '421161009e57600080fd5b600254600154604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9384169363a9059cbb93169184916370a0823191602480820192602092909190829003018186803b15801561011c57600080fd5b505afa158015610130573d6000803e3d6000fd5b505050506040513d602081101561014657600080fd5b50516040805160e060020a63ffffffff861602815273ffffffffffffffffffffffffffffffffffffffff909316600484015260248301919091525160448083019260209291908290030181600087803b1580156101a257600080fd5b505af11580156101b6573d6000803e3d6000fd5b505050506040513d60208110156101cc57600080fd5b505060015473ffffffffffffffffffffffffffffffffffffffff16ff5b600354600282604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b6020831061023d5780518252601f19909201916020918201910161021e565b51815160209384036101000a60001901801990921691161790526040519190930194509192505080830381855afa15801561027c573d6000803e3d6000fd5b5050506040513d602081101561029157600080fd5b50511461029d57600080fd5b600254600054604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9384169363a9059cbb93169184916370a0823191602480820192602092909190829003018186803b15801561031b57600080fd5b505afa15801561032f573d6000803e3d6000fd5b505050506040513d602081101561034557600080fd5b50516040805160e060020a63ffffffff861602815273ffffffffffffffffffffffffffffffffffffffff909316600484015260248301919091525160448083019260209291908290030181600087803b1580156103a157600080fd5b505af11580156103b5573d6000803e3d6000fd5b505050506040513d60208110156103cb57600080fd5b505060005473ffffffffffffffffffffffffffffffffffffffff16fffea165627a7a72305820b4278861f73b5e043b52d6669b023d772371e3ae909ecd4e617dd82afb7d1ffd0029'
    ].join('').toLowerCase()

    return bytecode
github liquality / chainabstractionlayer / packages / ethereum-erc20-swap-provider / lib / EthereumErc20SwapProvider.js View on Github external
createSwapScript (recipientAddress, refundAddress, secretHash, expiration) {
    recipientAddress = remove0x(addressToString(recipientAddress))
    refundAddress = remove0x(addressToString(refundAddress))

    const tokenAddress = remove0x(this.getMethod('getContractAddress')())
    const expirationEncoded = padHexStart(expiration.toString(16), 64)
    const bytecode = [
      '608060405260008054600160a060020a031990811673',
      recipientAddress,
      '1790915560018054821673',
      refundAddress,
      '1790556002805490911673',
      tokenAddress,
      '1790557f',
      secretHash,
      '60035534801561009a57600080fd5b50610414806100aa6000396000f3fe60806040526004361061002c5760e060020a6000350463590e1ae38114610031578063bd66528a14610048575b600080fd5b34801561003d57600080fd5b50610046610072565b005b34801561005457600080fd5b506100466004803603602081101561006b57600080fd5b50356101e9565b7f',
      expirationEncoded,
      '421161009e57600080fd5b600254600154604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9384169363a9059cbb93169184916370a0823191602480820192602092909190829003018186803b15801561011c57600080fd5b505afa158015610130573d6000803e3d6000fd5b505050506040513d602081101561014657600080fd5b50516040805160e060020a63ffffffff861602815273ffffffffffffffffffffffffffffffffffffffff909316600484015260248301919091525160448083019260209291908290030181600087803b1580156101a257600080fd5b505af11580156101b6573d6000803e3d6000fd5b505050506040513d60208110156101cc57600080fd5b505060015473ffffffffffffffffffffffffffffffffffffffff16ff5b600354600282604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b6020831061023d5780518252601f19909201916020918201910161021e565b51815160209384036101000a60001901801990921691161790526040519190930194509192505080830381855afa15801561027c573d6000803e3d6000fd5b5050506040513d602081101561029157600080fd5b50511461029d57600080fd5b600254600054604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9384169363a9059cbb93169184916370a0823191602480820192602092909190829003018186803b15801561031b57600080fd5b505afa15801561032f573d6000803e3d6000fd5b505050506040513d602081101561034557600080fd5b50516040805160e060020a63ffffffff861602815273ffffffffffffffffffffffffffffffffffffffff909316600484015260248301919091525160448083019260209291908290030181600087803b1580156103a157600080fd5b505af11580156103b5573d6000803e3d6000fd5b505050506040513d60208110156103cb57600080fd5b505060005473ffffffffffffffffffffffffffffffffffffffff16fffea165627a7a72305820b4278861f73b5e043b52d6669b023d772371e3ae909ecd4e617dd82afb7d1ffd0029'
    ].join('').toLowerCase()
github liquality / chainabstractionlayer / packages / ethereum-metamask-provider / lib / EthereumMetaMaskProvider.js View on Github external
if (!from) {
      const addresses = await this.getAddresses()
      from = addressToString(addresses[0])
    }

    const tx = {
      from: ensure0x(from),
      value: ensure0x(BigNumber(value).toString(16))
    }

    if (to) tx.to = ensure0x(addressToString(to))
    if (data) tx.data = ensure0x(data)

    const txHash = await this.metamask('eth_sendTransaction', tx)

    return remove0x(txHash)
  }
github liquality / chainabstractionlayer / packages / ethereum-erc20-provider / lib / EthereumErc20Provider.js View on Github external
constructor (contractAddress) {
    super()
    this._contractAddress = remove0x(contractAddress)
  }

@liquality/ethereum-utils

[![Build Status](https://travis-ci.com/liquality/chainabstractionlayer.svg?branch=master)](https://travis-ci.com/liquality/chainabstractionlayer) [![Coverage Status](https://coveralls.io/repos/github/liquality/chainabstractionlayer/badge.svg?branch=master

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis

Similar packages