You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuweni.apache.org by to...@apache.org on 2020/12/17 06:46:16 UTC
[incubator-tuweni] branch master updated: Improve faucet: make the
org check optional,
and allow to configure the faucet transaction gas and gas price (#187)
This is an automated email from the ASF dual-hosted git repository.
toulmean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git
The following commit(s) were added to refs/heads/master by this push:
new 2cbcac5 Improve faucet: make the org check optional, and allow to configure the faucet transaction gas and gas price (#187)
2cbcac5 is described below
commit 2cbcac5d417cd660e648600b3e907fd7d319516f
Author: Antoine Toulme <at...@users.noreply.github.com>
AuthorDate: Wed Dec 16 22:46:08 2020 -0800
Improve faucet: make the org check optional, and allow to configure the faucet transaction gas and gas price (#187)
---
.../org/apache/tuweni/faucet/FaucetApplication.kt | 28 ++++++++++++----------
.../tuweni/faucet/controller/FaucetController.kt | 10 ++++++--
eth-faucet/src/main/resources/application.yml | 2 ++
3 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/eth-faucet/src/main/kotlin/org/apache/tuweni/faucet/FaucetApplication.kt b/eth-faucet/src/main/kotlin/org/apache/tuweni/faucet/FaucetApplication.kt
index 74e29b8..bcdf72d 100644
--- a/eth-faucet/src/main/kotlin/org/apache/tuweni/faucet/FaucetApplication.kt
+++ b/eth-faucet/src/main/kotlin/org/apache/tuweni/faucet/FaucetApplication.kt
@@ -74,19 +74,21 @@ class FaucetApplication {
val delegate = DefaultOAuth2UserService()
return OAuth2UserService { request: OAuth2UserRequest ->
val user = delegate.loadUser(request)
- val client = OAuth2AuthorizedClient(request.clientRegistration, user.name, request.accessToken)
- val url = user.getAttribute<String>("organizations_url")
- val orgs = rest
- .get().uri(url ?: "")
- .attributes(oauth2AuthorizedClient(client))
- .retrieve()
- .bodyToMono(MutableList::class.java)
- .block()
- val found = orgs?.stream()?.anyMatch { org ->
- authorizedOrg == (org as Map<*, *>)["login"]
- } ?: false
- if (!found) {
- throw OAuth2AuthenticationException(OAuth2Error("invalid_token", "Not in authorized team", ""))
+ authorizedOrg?.let {
+ val client = OAuth2AuthorizedClient(request.clientRegistration, user.name, request.accessToken)
+ val url = user.getAttribute<String>("organizations_url")
+ val orgs = rest
+ .get().uri(url ?: "")
+ .attributes(oauth2AuthorizedClient(client))
+ .retrieve()
+ .bodyToMono(MutableList::class.java)
+ .block()
+ val found = orgs?.stream()?.anyMatch { org ->
+ authorizedOrg == (org as Map<*, *>)["login"]
+ } ?: false
+ if (!found) {
+ throw OAuth2AuthenticationException(OAuth2Error("invalid_token", "Not in authorized team", ""))
+ }
}
user
}
diff --git a/eth-faucet/src/main/kotlin/org/apache/tuweni/faucet/controller/FaucetController.kt b/eth-faucet/src/main/kotlin/org/apache/tuweni/faucet/controller/FaucetController.kt
index f5b783e..ff533ef 100644
--- a/eth-faucet/src/main/kotlin/org/apache/tuweni/faucet/controller/FaucetController.kt
+++ b/eth-faucet/src/main/kotlin/org/apache/tuweni/faucet/controller/FaucetController.kt
@@ -51,6 +51,12 @@ class FaucetController {
@Autowired
var wallet: Wallet? = null
+ @Value("\${faucet.gasPrice}")
+ var gasPrice: Long? = null
+
+ @Value("\${faucet.gas}")
+ var gas: Long? = null
+
@Value("\${faucet.maxETH}")
var maxETH: Long? = null
@@ -97,8 +103,8 @@ class FaucetController {
val tx =
wallet!!.sign(
nonce,
- Wei.valueOf(30000),
- Gas.valueOf(3000000),
+ Wei.valueOf(gasPrice!!),
+ Gas.valueOf(gas!!),
addr,
missing,
Bytes.EMPTY,
diff --git a/eth-faucet/src/main/resources/application.yml b/eth-faucet/src/main/resources/application.yml
index 884d0f2..6e18518 100644
--- a/eth-faucet/src/main/resources/application.yml
+++ b/eth-faucet/src/main/resources/application.yml
@@ -34,6 +34,8 @@ faucet:
chainId: 2018
rpcPort: 8545
rpcHost: localhost
+ gas: 21000
+ gasPrice: 0
wallet:
path: wallet.key
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tuweni.apache.org
For additional commands, e-mail: commits-help@tuweni.apache.org