Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions proxy/plugin/solana_rest_api_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
89 changes: 84 additions & 5 deletions proxy/test_eth_sendRawTransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -61,7 +61,7 @@
}

bytes32 public value = "";

function initValue(string memory s) public {
value = keccak256(bytes(s));
}
Expand All @@ -71,11 +71,11 @@
value = keccak256(abi.encodePacked(value));
}
}

function getValue() public view returns (bytes32) {
return value;
}

}
'''

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down