feat: base for USDT support

This commit is contained in:
Sérgio Salgado 2021-02-04 16:24:38 +00:00 committed by Josh Harvey
parent c94d043506
commit 1dd16c2220
5 changed files with 14 additions and 5 deletions

View file

@ -3,7 +3,7 @@ const _ = require('lodash/fp')
const { ALL } = require('../../plugins/common/ccxt')
const { BTC, BCH, DASH, ETH, LTC, ZEC } = COINS
const { BTC, BCH, DASH, ETH, LTC, ZEC, USDT } = COINS
const { bitpay, coinbase, itbit, bitstamp, kraken } = ALL
const TICKER = 'ticker'
@ -24,7 +24,7 @@ const ALL_ACCOUNTS = [
{ code: 'mock-ticker', display: 'Mock (Caution!)', class: TICKER, cryptos: ALL_CRYPTOS, dev: true },
{ code: 'bitcoind', display: 'bitcoind', class: WALLET, cryptos: [BTC] },
{ code: 'no-layer2', display: 'No Layer 2', class: LAYER_2, cryptos: ALL_CRYPTOS },
{ code: 'infura', display: 'Infura', class: WALLET, cryptos: [ETH] },
{ code: 'infura', display: 'Infura', class: WALLET, cryptos: [ETH, USDT] },
{ code: 'geth', display: 'geth (DEPRECATED)', class: WALLET, cryptos: [ETH], deprecated: true },
{ code: 'zcashd', display: 'zcashd', class: WALLET, cryptos: [ZEC] },
{ code: 'litecoind', display: 'litecoind', class: WALLET, cryptos: [LTC] },
@ -43,7 +43,7 @@ const ALL_ACCOUNTS = [
{ code: 'mailgun', display: 'Mailgun', class: EMAIL },
{ code: 'none', display: 'None', class: ZERO_CONF, cryptos: [BTC, ZEC, LTC, DASH, BCH, ETH] },
{ code: 'blockcypher', display: 'Blockcypher', class: ZERO_CONF, cryptos: [BTC] },
{ code: 'mock-zero-conf', display: 'Mock 0-conf', class: ZERO_CONF, cryptos: [BTC, ZEC, LTC, DASH, BCH, ETH], dev: true }
{ code: 'mock-zero-conf', display: 'Mock 0-conf', class: ZERO_CONF, cryptos: ALL_CRYPTOS, dev: true }
]
const devMode = require('minimist')(process.argv.slice(2)).dev

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,3 @@
const usdt = require('./abi/usdt.json')
module.exports = { usdt }

View file

@ -5,8 +5,10 @@ const web3 = new Web3()
const hdkey = require('ethereumjs-wallet/hdkey')
const Tx = require('ethereumjs-tx')
const util = require('ethereumjs-util')
const coins = require('lamassu-coins')
const pify = require('pify')
const BN = require('../../../bn')
const erc20ABIs = require('../../erc20')
const NAME = 'geth'
exports.SUPPORTED_MODULES = ['wallet']
@ -15,6 +17,9 @@ const paymentPrefixPath = "m/44'/60'/0'/0'"
const defaultPrefixPath = "m/44'/60'/1'/0'"
let lastUsedNonces = {}
const contract = web3.eth.contract(erc20ABIs.usdt, coins.utils.getErc20Token('USDT').contractAddress)
// console.log(contract)
module.exports = {
NAME,
balance,
@ -63,7 +68,7 @@ function sendCoins (account, tx, settings, operatorId) {
}
function checkCryptoCode (cryptoCode) {
if (cryptoCode === 'ETH') return Promise.resolve()
if (cryptoCode === 'ETH' || coins.utils.isErc20Token(cryptoCode)) return Promise.resolve()
return Promise.reject(new Error('cryptoCode must be ETH'))
}

View file

@ -51,7 +51,7 @@ const getLogo = code => {
case 'ZEC':
return ZCashLogo
default:
return null
return EthereumLogo
}
}