Skip to content

Commit

Permalink
whitelist checker script
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Gonzalez committed Jan 30, 2018
1 parent 2673e0c commit 01c97e8
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions check_whitelisted.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const contract = require("truffle-contract");
const ContributionABI = require("./build/contracts/Contribution.json");
const Contribution = contract(ContributionABI);
const Web3 = require("web3");
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8180"));

const fs = require("fs");
var sleep = require("sleep");

Contribution.setProvider(web3.currentProvider);

// KOVAN
// const CONTRIBUTION_ADDRESS = "0x379927202bBD6cCFdfC4d4397b65d8860fb9978e";
// const CONTRIBUTION_OWNER = "0x0019810eAceA494E393daf6D2340092b89c97eBB";

// DEV
const CONTRIBUTION_ADDRESS = "0x2ceFD8FfD8d8A1c3d7f40BaaF1C070BCeF81A907";
const CONTRIBUTION_OWNER = "0x0047F35735525f049e2103e3F654CCb589bF2b98";

let txConfirmation;
let isWhitelisted;

var lineReader = require("readline").createInterface({
input: fs.createReadStream("whitelisted.csv", { encoding: "utf8" })
});

// https://stackoverflow.com/a/32599033
let counter = 0;
lineReader.on("line", async line => {
counter++;
if (counter < 300) {
await checkWhitelisted(line);
} else {
return false;
}
});

const checkWhitelisted = async address => {
let instance = await Contribution.at(CONTRIBUTION_ADDRESS);

try {
isWhitelisted = await instance.canPurchase.call(address);
if (isWhitelisted == true) {
console.log("ADDRESS ALREADY WHITELISTED", address);
} else {
console.log("ADDRESS NOT WHITELISTED", address);
}
} catch (err) {
console.log(err);
}
};

0 comments on commit 01c97e8

Please sign in to comment.