forked from MattyIce/postpromoter
-
Notifications
You must be signed in to change notification settings - Fork 4
/
fixWhitelist.js
38 lines (31 loc) · 1.12 KB
/
fixWhitelist.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var fs = require("fs");
var firebase = require('firebase-admin');
var firebaseServiceAccount = require('./firebase-credentials.json');
var steem = require("steem")
const { Client } = require('dsteem')
config = JSON.parse(fs.readFileSync("config.json"));
firebase.initializeApp({
credential: firebase.credential.cert(firebaseServiceAccount),
databaseURL: 'https://steem-bid-bot.firebaseio.com/'
});
var rpc_node = config.rpc_nodes ? config.rpc_nodes[0] : (config.rpc_node ? config.rpc_node : 'https://api.steemit.com');
steem.api.setOptions({ transport: 'http', uri: rpc_node, url: rpc_node });
dsteem = new Client(rpc_node);
firebase.database().ref(config.account+'/whitelist').once('value')
.then(async function(data){
for(key in data.val()){
user = key.replace(/[,]/g,".");
try{
var accounts = await dsteem.database.getAccounts([user])
if(accounts.length == 0) {
console.log('the user @'+user+' does not exists')
}
}catch(error){
console.log('error with the user @'+user)
}
}
})
.catch(function(error){
console.log('Error reading firebase database')
console.log(error)
})