def test_reclaim_twice(csv_stream, customer, aml_token: Contract, team_multisig): """If we have tokens alreadhy reclaimed in the input, entries are skipped.""" rows = prepare_csv(csv_stream, "address", "label") # First run performed_op_count = reclaim_all(aml_token, rows, {"from": team_multisig}) assert performed_op_count == 1 # Attempt to continue performed_op_count = reclaim_all(aml_token, rows, {"from": team_multisig}) assert performed_op_count == 0
def test_reclaim_csv(csv_stream, customer, customer_2, aml_token: Contract, team_multisig): """Tokens are reclaimed correctly from CSV input..""" start_owner_balance = aml_token.functions.balanceOf(team_multisig).call() rows = prepare_csv(csv_stream, "address", "label") performed_op_count = reclaim_all(aml_token, rows, {"from": team_multisig}) assert performed_op_count == 1 assert aml_token.functions.balanceOf(customer).call() == 0 assert aml_token.functions.balanceOf(customer_2).call() == 2000000 assert aml_token.functions.balanceOf( team_multisig).call() == start_owner_balance + 1000000
def main(chain, owner_address, token, csv_file, address_column, label_column, gas_price): """Reclaim tokens that failed AML check. Before the token release, after AML/post sale KYC data has been assembled, go through the addresses that failed the checks and get back tokens from those buyers. Owner account must have balance to perform the the reclaim transactions. Example: aml-reclaim \ --token=0x... \ --owner-address=0x... \ --address-column="address" \ --label-column="label" \ --csv-file=test.csv """ setup_console_logging() logger = logging.getLogger(__name__) project = Project() with project.get_chain(chain) as c: web3 = c.web3 logger.info("Web3 provider is %s", web3.currentProvider) logger.info("Owner account address is %s", owner_address) logger.info("Owner account balance is %s ETH", from_wei(web3.eth.getBalance(owner_address), "ether")) # Goes through geth account unlock process if needed if is_account_locked(web3, owner_address): request_account_unlock(c, owner_address, timeout=3600 * 6) assert not is_account_locked(web3, owner_address) Token = c.provider.get_base_contract_factory('AMLToken') token = Token(address=token) logger.info("Token address is %s", token.address) decimals = token.call().decimals() logger.info("Total supply is %s", token.call().totalSupply() / (10**decimals)) logger.info("Owner account token balance is %s", token.call().balanceOf(owner_address) / (10**decimals)) if gas_price: gas_price = int(gas_price) * 10**9 else: # Use default gas price with little multiplies to cut us at the front of the queue gas_price = web3.eth.gasPrice * 1.2 tx_params = { "from": owner_address, "gasPrice": gas_price, } logger.info("Using gas price of %f GWei", gas_price / 10**9) logger.info("Reading data from %s", csv_file) with open(csv_file, "rt") as inp: rows = prepare_csv(inp, address_column, label_column) logger.info("Total %s rows", len(rows)) amount = count_tokens_to_reclaim(token, rows) / 10**decimals logger.info("Claiming total %f tokens", amount) start_balance = from_wei(web3.eth.getBalance(owner_address), "ether") reclaim_all(token, rows, tx_params) end_balance = from_wei(web3.eth.getBalance(owner_address), "ether") logger.info("Deployment cost is %f ETH", start_balance - end_balance) logger.info("All done! Enjoy your decentralized future.")