Skip to content

Commit

Permalink
erc20next: add support for token addr overrides & bump goth
Browse files Browse the repository at this point in the history
  • Loading branch information
kamirr committed Aug 30, 2023
1 parent 784fe13 commit df25e47
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion core/payment-driver/erc20next/config-payments.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ max-fee-per-gas = 10.0
gas-left-warning-limit = 1000000
transaction-timeout = 100
token = { address = "0x33af15c79d64b85ba14aaffaa4577949104b22e8", symbol = "tGLM" }
multi-contract = { address = "0x7777784f803a7bf1d7f115f849d29ce5706da64a", max-at-once = 10 }
# multi-contract = { address = "0x7777784f803a7bf1d7f115f849d29ce5706da64a", max-at-once = 10 }
confirmation-blocks = 1
block-explorer-url = "https://goerli.etherscan.io"

Expand Down
26 changes: 19 additions & 7 deletions core/payment-driver/erc20next/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
The service that binds this payment driver into yagna via GSB.
*/

use std::env;
use std::{env, str::FromStr};
// External crates
use erc20_payment_lib::config;
use erc20_payment_lib::config::AdditionalOptions;
use erc20_payment_lib::misc::load_private_keys;
use erc20_payment_lib::runtime::start_payment_engine;
use ethereum_types::H160;
use std::sync::Arc;

// Workspace uses
Expand Down Expand Up @@ -62,17 +63,28 @@ impl Erc20NextService {
};

let env_overrides = [
("goerli", "GOERLI_GETH_ADDR"),
("polygon", "POLYGON_GETH_ADDR"),
("mumbai", "MUMBAI_GETH_ADDR"),
("goerli", "GOERLI_GETH_ADDR", "GOERLI_TGLM_CONTRACT_ADDRESS"),
(
"polygon",
"POLYGON_GETH_ADDR",
"POLYGON_GLM_CONTRACT_ADDRESS",
),
];

for env_override in env_overrides {
if let Ok(addr) = env::var(env_override.1) {
log::info!("Geth addr override: {addr}");
if let Some(goerli_conf) = config.chain.get_mut(env_override.0) {
log::info!("Checking overrides for {}", env_override.0);
if let Some(goerli_conf) = config.chain.get_mut(env_override.0) {
if let Ok(addr) = env::var(env_override.1) {
log::info!("Geth addr: {addr}");

goerli_conf.rpc_endpoints = vec![addr];
}
if let Ok(addr) = env::var(env_override.2) {
log::info!("Token addr: {addr}");

goerli_conf.token.as_mut().unwrap().address =
H160::from_str(&addr).unwrap();
}
}
}

Expand Down
9 changes: 3 additions & 6 deletions goth_tests/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ version = "0.1.1"
description = "Integration tests for yagna"
authors = ["GolemFactory <[email protected]>"]
license = "LGPL-3.0-or-later"
classifiers = [
"Development Status :: 3 - Alpha",
"Framework :: AsyncIO",
]
classifiers = ["Development Status :: 3 - Alpha", "Framework :: AsyncIO"]
repository = "https://github.com/golemfactory/yagna"
documentation = "https://handbook.golem.network"
readme = "README.md"
Expand All @@ -22,9 +19,9 @@ pytest = "^6.2"
pytest-asyncio = "^0.20.2"
pytest-rerunfailures = "^10.3"
pytest-split = "^0.8.1"
goth = "^0.15.0"
# goth = "^0.15.0"
# to use development goth version uncomment below
# goth = { git = "https://github.com/golemfactory/goth.git", rev = "d2951a62e2a7cf0712f7f4a66c4a080777841611" }
goth = { git = "https://github.com/golemfactory/goth.git", rev = "664c85965cee5fed14c5b42e81ff2ca343184e08" }

[tool.poetry.dev-dependencies]
black = "^20.8b1"
Expand Down

0 comments on commit df25e47

Please sign in to comment.