How to use airswap - 10 common examples

To help you get started, we’ve selected a few airswap 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 perich / ethereum-dex-prices-service / exchanges / airswapWorker.js View on Github external
const Indexer = require('airswap.js/src/indexer/index')
const Router = require('airswap.js/src/protocolMessaging/index.js')
const ethers = require('ethers')

const indexer = new Indexer()

let message

process.on('message', msg => {
  message = msg
})

indexer.ready.then(async () => {
  const router = new Router({ requireAuthentication: false, address: ethers.Wallet.createRandom().address })
  try {
    const intents = await indexer.getIntents()
    const { method, senderToken, signerToken, senderParam, signerParam } = message
    const filteredIntents = intents.filter(intent => {
      if (
        intent.signerToken === signerToken.toLowerCase() && // eslint-disable-line
        intent.senderToken === senderToken.toLowerCase() && // eslint-disable-line
github perich / ethereum-dex-prices-service / exchanges / airswapWorker.js View on Github external
indexer.ready.then(async () => {
  const router = new Router({ requireAuthentication: false, address: ethers.Wallet.createRandom().address })
  try {
    const intents = await indexer.getIntents()
    const { method, senderToken, signerToken, senderParam, signerParam } = message
    const filteredIntents = intents.filter(intent => {
      if (
        intent.signerToken === signerToken.toLowerCase() && // eslint-disable-line
        intent.senderToken === senderToken.toLowerCase() && // eslint-disable-line
        intent.locatorType === 'https'
      ) {
        return true
      }
      return false
    })

    if (method === 'getSenderSideQuotes') {
      const quotePromises = filteredIntents.map(intent => {