-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
166 faucet (outdated) #179
Closed
Closed
Changes from 114 commits
Commits
Show all changes
116 commits
Select commit
Hold shift + click to select a range
5976adf
Add project faucet (166-faucet)
vakond 4dd17ee
Eth side wip (166-faucet)
vakond 06a570c
Http server side wip (166-faucet)
vakond 8af49c8
WIP (166-faucet)
vakond bf2d790
WIP (166-faucet)
vakond 1fcb504
Merge branch 'develop' into 166-faucet
vakond 6281f15
Refactoring (166-faucet)
vakond 9333e36
Wrap into docker image (166-faucet)
vakond e04278b
Add readme file (166-faucet)
vakond 9989491
Set Access-Control-Allow-Origin header of responses (166-faucet)
vakond 19d81e4
Set Access-Control-Allow-Methods header of responses (166-faucet)
vakond b46f959
Set Access-Control-Allow-Headers header of responses (166-faucet)
vakond a147305
Input request as plain text (166-faucet)
vakond 68e331f
Merge branch 'develop' into 166-faucet
vakond b8e6ebc
Explicit sender of transactions (166-faucet)
vakond 438be07
Config keeps both admin key and address (166-faucet)
vakond 7957fda
Use actix-web for incoming rpc (166-faucet)
vakond 2743387
Refactoring (166-faucet)
vakond ced9cea
Remove explicit admin address (can be derived from privkey) (166-faucet)
vakond becd086
Improve error handling (166-faucet)
vakond d3efa29
Add logs (166-faucet)
vakond 8475503
Add logs (166-faucet)
vakond 78fefdb
Use ethers.rs version 0.2 (166-faucet)
vakond dbf6f4f
Refactoring (166-faucet)
vakond cb186b9
Refactoring (166-faucet)
vakond 27d8cba
Use rust-web3 version 0.17 (166-faucet)
vakond cee8f80
eth_sendRawTransaction (166-faucet)
vakond b6b34b0
Pass recipient address as string not H160 (166-faucet)
vakond 03518bd
Pass amount as U256 not u64 (166-faucet)
vakond 60625f9
Pass wallet as Address (166-faucet)
vakond cc7732d
Refactoring (166-faucet)
vakond 399b17c
Include crate web3 into the project (166-faucet)
vakond d2494f6
Improve error handling (166-faucet)
vakond 4fb0c8d
Improve error handling (166-faucet)
vakond f1f18ce
Improve error handling (166-faucet)
vakond 5cd48ec
Improve error handling (166-faucet)
vakond 2a75e80
Improve error handling (166-faucet)
vakond 9630a04
Log all eth_* requests (166-faucet)
vakond 17f7110
Improve error handling (166-faucet)
vakond 76daef5
Improve error handling (166-faucet)
vakond 1b16af5
Add parameter --workers (166-faucet)
vakond 8457526
Refactoring (166-faucet)
vakond 6db96c7
Temporarily off Eth (166-faucet)
vakond 1da072c
Setup CORS (166-faucet)
vakond e8f6b1b
Add logging (166-faucet)
vakond 9fc1445
Adjust CORS settings (166-faucet)
vakond e0957bb
Show version in log (166-faucet)
vakond f348ec0
Show revision in log (166-faucet)
vakond da0c103
CORS in config file (166-faucet)
vakond 4051061
Refactoring (166-faucet)
vakond 486ebc2
Merge branch 'develop' into 166-faucet
vakond 10e1ad1
Add module tokens (166-faucet)
vakond b029c93
Use default decimals=18 (166-faucet)
vakond 0e2511f
Refactoring (166-faucet)
vakond 97f8abc
Implement getting decimals from contracts (166-faucet)
vakond 4ecd195
Use env vars for config (166-faucet)
vakond e00af6c
Refactoring (166-faucet)
vakond 135b7d6
Add build of faucet (166-faucet)
vakond bf8d816
Debugging CI (166-faucet)
vakond b1972c5
Remove general settings (166-faucet)
vakond f54f2cc
Env vars for all settings (166-faucet)
vakond f8f4d3f
Delete docker directory (166-faucet)
vakond 4a94a41
Show revision as unknown if no git metadata (166-faucet)
vakond ba074ae
Refactoring (166-faucet)
vakond 2f3082a
Add unit test (166-faucet)
vakond c46febd
Refactoring (166-faucet)
vakond 3e7b5b8
Add handler for eth token (166-faucet)
vakond af0f2f9
Add settings for eth token (166-faucet)
vakond 10e1e4a
Merge branch 'develop' into 166-faucet
vakond 70441d6
Refactoring (166-faucet)
vakond 72dc802
Add max_limit (166-faucet)
vakond d31a7ae
Add connection to Solana (166-faucet)
vakond 504196b
Try get_token_account (166-faucet)
vakond 9604dff
Try create_associated_token_account (166-faucet)
vakond fb47f39
Add spl_token::instruction::transfer_checked (166-faucet)
vakond 3533089
Bump version to 0.2.0 (166-faucet)
vakond 3999a2a
Merge branch 'develop' into 166-faucet
vakond 92b6b67
Use make_solana_program_address from cli (166-faucet)
vakond 9e3b790
Add operator_key (166-faucet)
vakond dc3d7a3
Use operator_key (166-faucet)
vakond a49b92e
No need for private key of token owner (166-faucet)
vakond b4ca6b5
Refactoring (166-faucet)
vakond f3f413e
Get back standard gasPrice -> '0x...' (166-faucet)
vakond 49a5e9c
Refactoring (166-faucet)
vakond 612a6ab
Refactoring (166-faucet)
vakond 24a43e3
Obfuscate private keys (166-faucet)
vakond b36d28a
Transfer checked (166-faucet)
vakond aac5b84
Create ether account if needed (166-faucet)
vakond 81639e6
Refactoring (166-faucet)
vakond f8b21d8
Take decimals into consideration (166-faucet)
vakond a23c76a
Take decimals into consideration (166-faucet)
vakond 28d08c8
Refactoring (166-faucet)
vakond 5ecb5f4
Refactoring (166-faucet)
vakond 60f8569
Use serde(deny_unknown_fields) (166-faucet)
vakond dd74dd4
Obfuscate also public addresses (166-faucet)
vakond d1c76bf
Refactoring (166-faucet)
vakond c0a6c28
Use tokio spawn_blocking instead of std thread spawn (166-faucet)
vakond e4d6b77
Fix amount scaling calculation (166-faucet)
vakond 1092d92
Refactoring (166-faucet)
vakond eef35a1
Merge branch 'develop' into 166-faucet
vakond cdd3282
Can disable subservices (166-faucet)
vakond 90607a5
Read keypair from another file (166-faucet)
vakond 17e7d4a
Refactoring (166-faucet)
vakond 82d208b
Refactoring (166-faucet)
vakond 9a200af
Refactoring (166-faucet)
vakond e54bc23
Introduce config option token_mint (166-faucet)
vakond 1cb6458
Introduce config option token_mint_decimals (166-faucet)
vakond ee0fc81
Use config option token_mint (166-faucet)
vakond 0892648
Adjust comments (166-faucet)
vakond cb3d255
Refactoring (166-faucet)
vakond 8f9ab39
Handle request stop (166-faucet)
vakond 3e44ee2
Improve error handling (166-faucet)
vakond e415f15
Check tokens lazily (166-faucet)
vakond 6f41ad2
Refactoring (166-faucet)
vakond f7242e6
Refactoring (166-faucet)
vakond 78e272c
Use public version web3 0.17 (166-faucet)
vakond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ node_modules | |
hfuzz_target | ||
hfuzz_workspace | ||
**/*.so | ||
**/*.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[package] | ||
name = "faucet" | ||
description = "Ethereum ERC20 Token Faucet Service" | ||
authors = ["NeonLabs Maintainers <[email protected]>"] | ||
repository = "https://github.com/neonlabsorg/neon-evm/evm_loader/faucet" | ||
version = "0.2.2" | ||
build = "build.rs" | ||
edition = "2018" | ||
|
||
[dependencies] | ||
actix-cors = { version = "0.6.0-beta.2", default-features = false } | ||
actix-web = { version = "4.0.0-beta.9", default-features = false } | ||
color-eyre = "0.5" | ||
derive-new = "0.5" | ||
ed25519-dalek = "1.0" | ||
evm-loader = { path = "../program", default_features = false, features = ["no-entrypoint"] } | ||
hex = "0.4" | ||
lazy_static = "1.4" | ||
nix = "0.22" | ||
num_cpus = "1.13" | ||
secp256k1 = "0.20" | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" | ||
solana-client = "=1.7.10" | ||
solana-sdk = "=1.7.10" | ||
spl-associated-token-account = { version = "1.0", default_features = false, features = ["no-entrypoint"] } | ||
spl-token = { version = "3.2", default_features = false, features = ["no-entrypoint"] } | ||
structopt = "0.3" | ||
thiserror = "1.0" | ||
tokio = { version = "1.10", default_features = false, features = ["rt"] } | ||
toml = "0.5" | ||
tracing = "0.1" | ||
tracing-subscriber = "0.2" | ||
web3 = { path = "web3" } | ||
|
||
[build-dependencies] | ||
vergen = { version = "5.1", default-features = false, features = ["git"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ERC20 Token Faucet (Airdrop) | ||
|
||
ERC20 Token Faucet is a service which performs airdrop of tokens on user request. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use vergen::{vergen, Config}; | ||
|
||
fn main() { | ||
vergen(Config::default()).ok(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenOwner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"_totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"remaining","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"}],"name":"safeAdd","outputs":[{"internalType":"uint256","name":"c","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"}],"name":"safeSub","outputs":[{"internalType":"uint256","name":"c","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0; | ||
// ---------------------------------------------------------------------------- | ||
// Safe maths | ||
// ---------------------------------------------------------------------------- | ||
contract SafeMath { | ||
function safeAdd(uint a, uint b) public pure returns (uint c) { | ||
c = a + b; | ||
require(c >= a); | ||
} | ||
function safeSub(uint a, uint b) public pure returns (uint c) { | ||
require(b <= a); | ||
c = a - b; | ||
} | ||
} | ||
// ---------------------------------------------------------------------------- | ||
// ERC Token Standard #20 Interface | ||
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md | ||
// ---------------------------------------------------------------------------- | ||
abstract contract ERC20Interface { | ||
function totalSupply() virtual public view returns (uint); | ||
function balanceOf(address tokenOwner) virtual public view returns (uint balance); | ||
function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining); | ||
function transfer(address to, uint tokens) virtual public returns (bool success); | ||
function approve(address spender, uint tokens) virtual public returns (bool success); | ||
function transferFrom(address from, address to, uint tokens) virtual public returns (bool success); | ||
event Transfer(address indexed from, address indexed to, uint tokens); | ||
event Approval(address indexed tokenOwner, address indexed spender, uint tokens); | ||
} | ||
// ---------------------------------------------------------------------------- | ||
// ERC20 Token, with the addition of symbol, name and decimals | ||
// assisted token transfers | ||
// ---------------------------------------------------------------------------- | ||
contract TestToken is ERC20Interface, SafeMath { | ||
string public symbol; | ||
string public name; | ||
uint8 public decimals; | ||
uint public _totalSupply; | ||
mapping(address => uint) balances; | ||
mapping(address => mapping(address => uint)) allowed; | ||
// ------------------------------------------------------------------------ | ||
// Constructor | ||
// ------------------------------------------------------------------------ | ||
constructor() { | ||
symbol = "TST"; | ||
name = "TestToken"; | ||
decimals = 18; | ||
_totalSupply = 10000000000000000000000000000; | ||
balances[msg.sender] = _totalSupply; | ||
emit Transfer(address(0), msg.sender, _totalSupply); | ||
} | ||
// ------------------------------------------------------------------------ | ||
// Total supply | ||
// ------------------------------------------------------------------------ | ||
function totalSupply() public override view returns (uint) { | ||
return _totalSupply - balances[address(0)]; | ||
} | ||
// ------------------------------------------------------------------------ | ||
// Get the token balance for account tokenOwner | ||
// ------------------------------------------------------------------------ | ||
function balanceOf(address tokenOwner) public override view returns (uint balance) { | ||
return balances[tokenOwner]; | ||
} | ||
// ------------------------------------------------------------------------ | ||
// Transfer the balance from token owner's account to receiver account | ||
// - Owner's account must have sufficient balance to transfer | ||
// - 0 value transfers are allowed | ||
// ------------------------------------------------------------------------ | ||
function transfer(address receiver, uint tokens) public override returns (bool success) { | ||
balances[msg.sender] = safeSub(balances[msg.sender], tokens); | ||
balances[receiver] = safeAdd(balances[receiver], tokens); | ||
emit Transfer(msg.sender, receiver, tokens); | ||
return true; | ||
} | ||
// ------------------------------------------------------------------------ | ||
// Token owner can approve for spender to transferFrom(...) tokens | ||
// from the token owner's account | ||
// | ||
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md | ||
// recommends that there are no checks for the approval double-spend attack | ||
// as this should be implemented in user interfaces | ||
// ------------------------------------------------------------------------ | ||
function approve(address spender, uint tokens) public override returns (bool success) { | ||
allowed[msg.sender][spender] = tokens; | ||
emit Approval(msg.sender, spender, tokens); | ||
return true; | ||
} | ||
// ------------------------------------------------------------------------ | ||
// Transfer tokens from sender account to receiver account | ||
// | ||
// The calling account must already have sufficient tokens approve(...)-d | ||
// for spending from sender account and | ||
// - From account must have sufficient balance to transfer | ||
// - Spender must have sufficient allowance to transfer | ||
// - 0 value transfers are allowed | ||
// ------------------------------------------------------------------------ | ||
function transferFrom(address sender, address receiver, uint tokens) public override returns (bool success) { | ||
balances[sender] = safeSub(balances[sender], tokens); | ||
allowed[sender][msg.sender] = safeSub(allowed[sender][msg.sender], tokens); | ||
balances[receiver] = safeAdd(balances[receiver], tokens); | ||
emit Transfer(sender, receiver, tokens); | ||
return true; | ||
} | ||
// ------------------------------------------------------------------------ | ||
// Returns the amount of tokens approved by the owner that can be | ||
// transferred to the spender's account | ||
// ------------------------------------------------------------------------ | ||
function allowance(address tokenOwner, address spender) public override view returns (uint remaining) { | ||
return allowed[tokenOwner][spender]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Neon Token Faucet Service Config | ||
|
||
[rpc] | ||
port = 3333 | ||
allowed_origins = ["http://localhost"] | ||
|
||
[web3] | ||
enable = true | ||
rpc_url = "http://localhost:9090/solana" | ||
private_key = "0x0000000000000000000000000000000000000000000000000000000000000Ace" | ||
tokens = ["0x00000000000000000000000000000000CafeBabe", | ||
"0x00000000000000000000000000000000DeadBeef"] | ||
max_amount = 1000 | ||
|
||
[solana] | ||
enable = true | ||
url = "http://localhost:8899" | ||
operator_keyfile = "operator_id.json" | ||
evm_loader = "EvmLoaderId11111111111111111111111111111111" | ||
token_mint = "TokenMintId11111111111111111111111111111111" | ||
token_mint_decimals = 9 | ||
max_amount = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//! Faucet options parser. | ||
|
||
use crate::config; | ||
use std::path::PathBuf; | ||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt)] | ||
#[structopt(about = "NeonLabs Token Faucet Service")] | ||
pub struct Application { | ||
#[structopt( | ||
parse(from_os_str), | ||
short, | ||
long, | ||
default_value = &config::DEFAULT_CONFIG, | ||
help = "Path to the config file" | ||
)] | ||
pub config: PathBuf, | ||
|
||
#[structopt(subcommand)] | ||
pub cmd: Command, | ||
} | ||
|
||
#[derive(StructOpt)] | ||
pub enum Command { | ||
#[structopt(about = "Shows config")] | ||
Config { | ||
#[structopt( | ||
parse(from_os_str), | ||
short, | ||
long, | ||
default_value = &config::DEFAULT_CONFIG, | ||
help = "Path to the config file" | ||
)] | ||
file: PathBuf, | ||
}, | ||
|
||
#[structopt(about = "Shows environment variables")] | ||
Env {}, | ||
|
||
#[structopt(about = "Starts listening for requests")] | ||
Run { | ||
#[structopt( | ||
long, | ||
default_value = &config::AUTO, | ||
help = "Number of listening workers" | ||
)] | ||
workers: String, | ||
}, | ||
} | ||
|
||
/// Constructs instance of Application. | ||
pub fn application() -> Application { | ||
Application::from_args() | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we can't use
web3
package from the rust repository?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was because of gasPrice. I started with the public version of web3, of course, but had to modify it to support non-standard result of the proxy's gasPrice at that time. Probably we should try to return to the public version of web3 crate.