From 57a32340a8ba890c8badb4e2c64b8a6b64b9b0d5 Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 5 Oct 2023 15:05:40 +0200 Subject: [PATCH] chore: adapt script to the csv file --- contracts/mocks/MultiSend.sol | 6 ++- scripts/deploy_tokenVestings.py | 79 ++++++++++++++++++++++----------- 2 files changed, 58 insertions(+), 27 deletions(-) diff --git a/contracts/mocks/MultiSend.sol b/contracts/mocks/MultiSend.sol index f920d9b9..647b8fe7 100644 --- a/contracts/mocks/MultiSend.sol +++ b/contracts/mocks/MultiSend.sol @@ -17,6 +17,8 @@ contract MultiSend { function multiSendToken(IERC20 token, TransferParams[] calldata transferParamsArray, uint256 totalAmount) external { require(msg.sender == owner, "Not owner"); + uint256 initialBalance = token.balanceOf(address(this)); + require(token.transferFrom(msg.sender, address(this), totalAmount)); uint256 length = transferParamsArray.length; @@ -27,8 +29,8 @@ contract MultiSend { } } - // Return remainding tokens to msg.sender. If totalAmount < actualAmount, it will revert before - require(token.balanceOf(address(this)) == 0, "MultiSend: TotalAmount != amountSent"); + // Assumed that this contract won't be in the recipientAddress + require(token.balanceOf(address(this)) == initialBalance, "MultiSend: TotalAmount != amountSent"); } function recoverTokens(IERC20 token) external { diff --git a/scripts/deploy_tokenVestings.py b/scripts/deploy_tokenVestings.py index 9839f3b4..bd6b8dda 100644 --- a/scripts/deploy_tokenVestings.py +++ b/scripts/deploy_tokenVestings.py @@ -18,15 +18,26 @@ TokenVestingStaking, TokenVestingNoStaking, network, + web3, ) # File should be formatted as a list of parameters. First line should be the headers with names of the # parameters. The rest of the lines should be the values for each parameter. It should contain the # parameters described in the order dictionary below but it can have others, which will be ignored. VESTING_INFO_FILE = os.environ["VESTING_INFO_FILE"] -order = {"eth_address": 0, "amount": 1, "lockup_type": 2, "transferable_beneficiary": 3} -options_lockup_type = ["A", "B"] -options_transferable_beneficiary = ["Y", "N"] +columns = [ + "Full name/Company Name", + "Email Address", + "Final Choice Lock up Schedule", + "Investor Label", + "# tokens", + "Beneficiary Wallet Address", + "Address transfer enabled in smart contract?", + "Sanity checked?", +] +# order = {"eth_address": 0, "amount": 1, "lockup_type": 2, "transferable_beneficiary": 3} +options_lockup_type = ["Option A", "Option B", "Airdrop"] +# options_transferable_beneficiary = ["Y", "N"] # NOTE: Ensure vesting schedule is correct vesting_time_cliff = QUARTER_YEAR @@ -63,34 +74,52 @@ def main(): # Check the first row - parameter names first_row = next(reader) - for parameter_name, position in order.items(): - assert first_row[position] == parameter_name, "Incorrect parameter name" + for position, parameter_name in enumerate(columns): + assert ( + first_row[position] == parameter_name + ), f"Incorrect parameter name: expected {parameter_name}, but got {first_row[position]}" # Read the rest of the rows for row in reader: - assert len(row) == 4, "Incorrect number of parameters" - - beneficiary = row[order["eth_address"]] - amount = int(row[order["amount"]]) - lockup_type = row[order["lockup_type"]] - transferable = row[order["transferable_beneficiary"]] - - # Check that the row are valid - assert ( - transferable in options_transferable_beneficiary - ), "Incorrect transferability parameter" - assert lockup_type in options_lockup_type, "Incorrect lockup type parameter" - - transferable = ( - True if row[order["transferable_beneficiary"]] == "Y" else False - ) + assert len(row) == len( + columns + ), f"Incorrect number of parameters: expected {len(columns)}, but got {len(row)}" - vesting_list.append([beneficiary, amount, lockup_type, transferable]) + # Check that all rows are valid + lockup_type = row[columns.index("Final Choice Lock up Schedule")] - if lockup_type == "A": + if lockup_type == options_lockup_type[0]: number_staking += 1 - else: + elif lockup_type == options_lockup_type[1]: number_noStaking += 1 + elif lockup_type == options_lockup_type[2]: + continue + else: + continue + # raise Exception(f"Incorrect lockup type parameter {lockup_type}") + + beneficiary = row[columns.index("Beneficiary Wallet Address")] + amount = int(row[columns.index("# tokens")].replace(",", "")) + transferable = row[ + columns.index("Address transfer enabled in smart contract?") + ] + + # assert web3.isAddress(beneficiary), f"Incorrect beneficiary address {beneficiary}" + + # To remove + validAddress = web3.isAddress(beneficiary) + if not validAddress: + continue + + if transferable in ["yes", "Yes"]: + transferable = True + elif transferable in ["no", "No"]: + transferable = False + else: + continue + # raise Exception(f"Incorrect transferability parameter {transferable}") + + vesting_list.append([beneficiary, amount, lockup_type, transferable]) flip_total += amount @@ -149,7 +178,7 @@ def main(): beneficiary, amount, lockup_type, transferable_beneficiary = vesting amount_E18 = amount * E_18 - if lockup_type == "A": + if lockup_type == options_lockup_type[0]: tv = deploy_tokenVestingStaking( DEPLOYER,