feat: add migration to clean blacklist table
fix: address reuse and blacklist check
This commit is contained in:
parent
f682a77eb5
commit
d7519d477e
4 changed files with 23 additions and 20 deletions
|
|
@ -3,11 +3,10 @@ const notifierQueries = require('./notifier/queries')
|
|||
|
||||
// Get all blacklist rows from the DB "blacklist" table that were manually inserted by the operator
|
||||
const getBlacklist = () => {
|
||||
return db.any(`SELECT * FROM blacklist WHERE created_by_operator = 't'`).then(res =>
|
||||
return db.any(`SELECT * FROM blacklist`).then(res =>
|
||||
res.map(item => ({
|
||||
cryptoCode: item.crypto_code,
|
||||
address: item.address,
|
||||
createdByOperator: item.created_by_operator
|
||||
address: item.address
|
||||
}))
|
||||
)
|
||||
}
|
||||
|
|
@ -22,13 +21,13 @@ const deleteFromBlacklist = (cryptoCode, address) => {
|
|||
const insertIntoBlacklist = (cryptoCode, address) => {
|
||||
return db
|
||||
.none(
|
||||
'insert into blacklist(crypto_code, address, created_by_operator) values($1, $2, $3);',
|
||||
[cryptoCode, address, true]
|
||||
'INSERT INTO blacklist (crypto_code, address) VALUES ($1, $2);',
|
||||
[cryptoCode, address]
|
||||
)
|
||||
}
|
||||
|
||||
function blocked (address, cryptoCode) {
|
||||
const sql = `select * from blacklist where address = $1 and crypto_code = $2`
|
||||
const sql = `SELECT * FROM blacklist WHERE address = $1 AND crypto_code = $2`
|
||||
return db.any(sql, [address, cryptoCode])
|
||||
}
|
||||
|
||||
|
|
@ -36,7 +35,7 @@ function addToUsedAddresses (address, cryptoCode) {
|
|||
// ETH reuses addresses
|
||||
if (cryptoCode === 'ETH') return Promise.resolve()
|
||||
|
||||
const sql = `insert into blacklist(crypto_code, address, created_by_operator) values ($1, $2, 'f')`
|
||||
const sql = `INSERT INTO blacklist (crypto_code, address) VALUES ($1, $2)`
|
||||
return db.oneOrNone(sql, [cryptoCode, address])
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue