From 68a2c2d51d0c87774dbc6be2511e31d23abbbd20 Mon Sep 17 00:00:00 2001 From: Dmitriy Borisenko Date: Wed, 22 Sep 2021 23:15:34 +0300 Subject: [PATCH 1/2] remove account creation #202 --- proxy/plugin/solana_rest_api_tools.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/proxy/plugin/solana_rest_api_tools.py b/proxy/plugin/solana_rest_api_tools.py index cca640fa4..7aa56f731 100644 --- a/proxy/plugin/solana_rest_api_tools.py +++ b/proxy/plugin/solana_rest_api_tools.py @@ -1099,23 +1099,7 @@ def getTokens(client, signer, evm_loader, eth_acc, base_account): balance = client.get_token_account_balance(token_account, commitment=Confirmed) if 'error' in balance: if NEW_USER_AIRDROP_AMOUNT > 0: - trx = Transaction() - sender_sol_info = client.get_account_info(account, commitment=Confirmed) - if sender_sol_info['result']['value'] is None: - trx.add(createEtherAccountTrx(client, bytes(eth_acc).hex(), evm_loader_id, signer)[0]) - trx.add(transfer2(Transfer2Params( - source=getTokenAddr(signer.public_key()), - owner=signer.public_key(), - dest=token_account, - amount=NEW_USER_AIRDROP_AMOUNT*1_000_000_000, - decimals=9, - mint=ETH_TOKEN_MINT_ID, - program_id=TOKEN_PROGRAM_ID, - ))) - logger.debug("Token transfer to %s as ethereum 0x%s amount %s", token_account, bytes(eth_acc).hex(), str(NEW_USER_AIRDROP_AMOUNT)) - send_transaction(client, trx, signer) - - return getTokens(client, signer, evm_loader, eth_acc, base_account) + return NEW_USER_AIRDROP_AMOUNT * 1_000_000_000 else: logger.debug("'error' in balance:") return 0 From 1a9a57ad8a0a1a982af7e5fadbf20868ce156950 Mon Sep 17 00:00:00 2001 From: Dmitriy Borisenko Date: Thu, 23 Sep 2021 00:06:32 +0300 Subject: [PATCH 2/2] fix tests --- proxy/test_eth_sendRawTransaction.py | 89 ++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/proxy/test_eth_sendRawTransaction.py b/proxy/test_eth_sendRawTransaction.py index f81a92910..45307f84d 100644 --- a/proxy/test_eth_sendRawTransaction.py +++ b/proxy/test_eth_sendRawTransaction.py @@ -49,7 +49,7 @@ function getKeccakOfEmptyString() public view returns (bytes32 variant) { variant = keccak256(emprty_string); } - + bytes32 constant neonlabsHash = keccak256("neonlabs"); function endlessCycle() public view returns (bytes32 variant) { @@ -61,7 +61,7 @@ } bytes32 public value = ""; - + function initValue(string memory s) public { value = keccak256(bytes(s)); } @@ -71,11 +71,11 @@ value = keccak256(abi.encodePacked(value)); } } - + function getValue() public view returns (bytes32) { return value; } - + } ''' @@ -210,16 +210,55 @@ def test_04_execute_with_bad_nonce(self): # @unittest.skip("a.i.") def test_05_transfer_one_gwei(self): print("\ntest_05_transfer_one_gwei") + + one_gwei = 1_000_000_000 + eth_account_alice = proxy.eth.account.create('alice') eth_account_bob = proxy.eth.account.create('bob') print('eth_account_alice.address:', eth_account_alice.address) print('eth_account_bob.address:', eth_account_bob.address) + if True: + print("add funds to alice and bob") + + print("alice") + trx_transfer = proxy.eth.account.sign_transaction(dict( + nonce=proxy.eth.get_transaction_count(proxy.eth.default_account), + chainId=proxy.eth.chain_id, + gas=987654321, + gasPrice=0, + to=eth_account_alice.address, + value=one_gwei), + eth_account.key + ) + + print('trx_transfer:', trx_transfer) + trx_transfer_hash = proxy.eth.send_raw_transaction(trx_transfer.rawTransaction) + print('trx_transfer_hash:', trx_transfer_hash.hex()) + trx_transfer_receipt = proxy.eth.wait_for_transaction_receipt(trx_transfer_hash) + print('trx_transfer_receipt:', trx_transfer_receipt) + + print("bob") + trx_transfer = proxy.eth.account.sign_transaction(dict( + nonce=proxy.eth.get_transaction_count(proxy.eth.default_account), + chainId=proxy.eth.chain_id, + gas=987654321, + gasPrice=0, + to=eth_account_bob.address, + value=one_gwei), + eth_account.key + ) + + print('trx_transfer:', trx_transfer) + trx_transfer_hash = proxy.eth.send_raw_transaction(trx_transfer.rawTransaction) + print('trx_transfer_hash:', trx_transfer_hash.hex()) + trx_transfer_receipt = proxy.eth.wait_for_transaction_receipt(trx_transfer_hash) + print('trx_transfer_receipt:', trx_transfer_receipt) + alice_balance_before_transfer = proxy.eth.get_balance(eth_account_alice.address) bob_balance_before_transfer = proxy.eth.get_balance(eth_account_bob.address) print('alice_balance_before_transfer:', alice_balance_before_transfer) print('bob_balance_before_transfer:', bob_balance_before_transfer) - one_gwei = 1_000_000_000 print('one_gwei:', one_gwei) trx_transfer = proxy.eth.account.sign_transaction(dict( @@ -248,11 +287,51 @@ def test_05_transfer_one_gwei(self): # @unittest.skip("a.i.") def test_06_transfer_one_and_a_half_gweis(self): print("\ntest_06_transfer_one_and_a_half_gweis") + eth_account_alice = proxy.eth.account.create('alice') eth_account_bob = proxy.eth.account.create('bob') print('eth_account_alice.address:', eth_account_alice.address) print('eth_account_bob.address:', eth_account_bob.address) + one_gwei = 1_000_000_000 + + if True: + print("add funds to alice and bob") + + print("alice") + trx_transfer = proxy.eth.account.sign_transaction(dict( + nonce=proxy.eth.get_transaction_count(proxy.eth.default_account), + chainId=proxy.eth.chain_id, + gas=987654321, + gasPrice=0, + to=eth_account_alice.address, + value=one_gwei), + eth_account.key + ) + + print('trx_transfer:', trx_transfer) + trx_transfer_hash = proxy.eth.send_raw_transaction(trx_transfer.rawTransaction) + print('trx_transfer_hash:', trx_transfer_hash.hex()) + trx_transfer_receipt = proxy.eth.wait_for_transaction_receipt(trx_transfer_hash) + print('trx_transfer_receipt:', trx_transfer_receipt) + + print("bob") + trx_transfer = proxy.eth.account.sign_transaction(dict( + nonce=proxy.eth.get_transaction_count(proxy.eth.default_account), + chainId=proxy.eth.chain_id, + gas=987654321, + gasPrice=0, + to=eth_account_bob.address, + value=one_gwei), + eth_account.key + ) + + print('trx_transfer:', trx_transfer) + trx_transfer_hash = proxy.eth.send_raw_transaction(trx_transfer.rawTransaction) + print('trx_transfer_hash:', trx_transfer_hash.hex()) + trx_transfer_receipt = proxy.eth.wait_for_transaction_receipt(trx_transfer_hash) + print('trx_transfer_receipt:', trx_transfer_receipt) + alice_balance_before_transfer = proxy.eth.get_balance(eth_account_alice.address) bob_balance_before_transfer = proxy.eth.get_balance(eth_account_bob.address) print('alice_balance_before_transfer:', alice_balance_before_transfer)