Skip to content

Commit

Permalink
payment-driver: rename erc20next to erc20
Browse files Browse the repository at this point in the history
  • Loading branch information
kamirr committed Jan 22, 2024
1 parent 98c4d18 commit ae34f77
Show file tree
Hide file tree
Showing 33 changed files with 81 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ workdir/*
core/market/decentralized/tests/test-workdir/*
releases/

# erc20next
# erc20
db.sqlite
db.sqlite-shm
db.sqlite-wal
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ license = "GPL-3.0"
edition = "2018"

[features]
default = ['erc20next-driver', 'gftp/bin']
default = ['erc20-driver', 'gftp/bin']
static-openssl = ["openssl/vendored", "openssl-probe"]
dummy-driver = ['ya-dummy-driver']
erc20next-driver = ['ya-erc20next-driver']
erc20-driver = ['ya-erc20-driver']
tos = []
framework-test = []
# Temporary to make goth integration tests work
Expand All @@ -36,7 +36,7 @@ ya-core-model = { version = "^0.9" }
ya-dummy-driver = { version = "0.3", optional = true }
ya-file-logging = "0.1"
ya-gsb-api = "0.1"
ya-erc20next-driver = { version = "0.4", optional = true }
ya-erc20-driver = { version = "0.4", optional = true }
ya-identity = "0.3"
ya-market = "0.4"
ya-metrics = "0.2"
Expand Down Expand Up @@ -188,7 +188,7 @@ members = [
"core/payment",
"core/payment-driver/base",
"core/payment-driver/dummy",
"core/payment-driver/erc20next",
"core/payment-driver/erc20",
"core/persistence",
"core/serv-api",
"core/serv-api/derive",
Expand Down Expand Up @@ -251,7 +251,7 @@ ya-sgx = { path = "core/sgx" }
ya-payment = { path = "core/payment" }
ya-payment-driver = { path = "core/payment-driver/base" }
ya-dummy-driver = { path = "core/payment-driver/dummy" }
ya-erc20next-driver = { path = "core/payment-driver/erc20next" }
ya-erc20-driver = { path = "core/payment-driver/erc20" }
ya-version = { path = "core/version" }
ya-vpn = { path = "core/vpn" }
ya-gsb-api = { path = "core/gsb-api" }
Expand Down
8 changes: 4 additions & 4 deletions core/model/src/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub mod local {
use ya_client_model::NodeId;

pub const BUS_ID: &str = "/local/payment";
pub const DEFAULT_PAYMENT_DRIVER: &str = "erc20next";
pub const DEFAULT_PAYMENT_DRIVER: &str = "erc20";

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct DebitNotePayment {
Expand Down Expand Up @@ -525,7 +525,7 @@ pub mod local {
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum DriverName {
Erc20Next,
Erc20,
Erc20,

Check failure on line 529 in core/model/src/payment.rs

View workflow job for this annotation

GitHub Actions / Unit Tests (ubuntu-latest)

the name `Erc20` is defined multiple times

Check failure on line 529 in core/model/src/payment.rs

View workflow job for this annotation

GitHub Actions / Check formatting

the name `Erc20` is defined multiple times

Check failure on line 529 in core/model/src/payment.rs

View workflow job for this annotation

GitHub Actions / System Tests (ubuntu-latest)

the name `Erc20` is defined multiple times

Check failure on line 529 in core/model/src/payment.rs

View workflow job for this annotation

GitHub Actions / Market Test Suite (ubuntu-latest)

the name `Erc20` is defined multiple times

Check failure on line 529 in core/model/src/payment.rs

View workflow job for this annotation

GitHub Actions / Build binaries (aarch64)

the name `Erc20` is defined multiple times
}

Expand All @@ -535,7 +535,7 @@ pub mod local {
#[structopt(long, env = "YA_ACCOUNT")]
pub account: Option<NodeId>,
/// Payment driver
#[structopt(long, possible_values = DriverName::VARIANTS, default_value = DriverName::Erc20Next.into())]
#[structopt(long, possible_values = DriverName::VARIANTS, default_value = DriverName::Erc20.into())]
pub driver: DriverName,
/// Payment network
#[structopt(long, possible_values = NetworkName::VARIANTS, default_value = NetworkName::Holesky.into())]
Expand Down Expand Up @@ -568,7 +568,7 @@ pub mod local {
fn test_cli_defaults() {
let a = AccountCli::from_iter(&[""]);
assert_eq!(None, a.address());
assert_eq!("erc20next", a.driver());
assert_eq!("erc20", a.driver());
assert_eq!("holesky", a.network());
assert_eq!("tGLM", a.token());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ya-erc20next-driver"
name = "ya-erc20-driver"
version = "0.4.0"
authors = ["Golem Factory <[email protected]>"]
edition = "2021"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Erc20Next Payment driver
# Erc20 Payment driver
## Functionality
A payment driver is an abstraction over any operations relating to funds, which includes:
* Scheduling transfers to run at any point in the future.
* Verifying transfers done by other parties.
* Checking account balance.
* Reporting status of scheduled transactions and the account.

The Erc20Next driver is such an abstraction built on top of the [ERC20 standard](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/).
The Erc20 driver is such an abstraction built on top of the [ERC20 standard](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/).

## Implementation
The core implementation is in [erc20_payment_lib](https://github.com/golemfactory/erc20_payment_lib), this crate only serves as an interface connecting
Expand Down Expand Up @@ -35,7 +35,7 @@ Be aware that options not prefixed with `ERC20NEXT` are also applicable to the o
* It can be overriden by placing a `config-payments.toml` file in yagna data directory. This is not recommended and is not guaranteed to work across versions.

## Statuses
The Erc20Next driver can report a selection of statuses which indicate possible issues.
The Erc20 driver can report a selection of statuses which indicate possible issues.
* `InsufficientGas`:
* An account does not have sufficient gas to execute further transactions.
* Contains: `driver`, `network`, `address`, `neededGasEst`.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use chrono::{DateTime, Duration, Utc};
/*
Erc20Driver to handle payments on the erc20next network.
Erc20Driver to handle payments on the erc20 network.
Please limit the logic in this file, use local mods to handle the calls.
*/
Expand Down Expand Up @@ -43,12 +43,12 @@ use crate::{network::SUPPORTED_NETWORKS, DRIVER_NAME};

mod cli;

pub struct Erc20NextDriver {
pub struct Erc20Driver {
active_accounts: AccountsArc,
payment_runtime: PaymentRuntime,
}

impl Erc20NextDriver {
impl Erc20Driver {
pub fn new(payment_runtime: PaymentRuntime, recv: Receiver<DriverEvent>) -> Arc<Self> {
let this = Arc::new(Self {
active_accounts: Accounts::new_rc(),
Expand Down Expand Up @@ -272,7 +272,7 @@ impl Erc20NextDriver {

let networks = self.get_networks();
let network = networks.get(network_name).ok_or(GenericError::new(format!(
"Network {network_name} not supported by Erc20NextDriver"
"Network {network_name} not supported by Erc20Driver"
)))?;
let platform = network
.tokens
Expand Down Expand Up @@ -337,7 +337,7 @@ impl Erc20NextDriver {
}

#[async_trait(?Send)]
impl PaymentDriver for Erc20NextDriver {
impl PaymentDriver for Erc20Driver {
async fn account_event(
&self,
_caller: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use ya_payment_driver::{
};

// Local uses
use crate::{driver::Erc20NextDriver, network, DRIVER_NAME};
use crate::{driver::Erc20Driver, network, DRIVER_NAME};

pub async fn init(driver: &Erc20NextDriver, msg: Init) -> Result<(), GenericError> {
pub async fn init(driver: &Erc20Driver, msg: Init) -> Result<(), GenericError> {
log::debug!("init: {:?}", msg);
let mode = msg.mode();
let address = msg.address();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Private mod to encapsulate all erc20next logic, revealed from the `wallet`.
Private mod to encapsulate all erc20 logic, revealed from the `wallet`.
*/

pub mod ethereum;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Wallet functions on erc20next.
Wallet functions on erc20.
*/

// External crates
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
/*
Payment driver for yagna using erc20next.
Payment driver for yagna using erc20.
This file only contains constants and imports.
*/

// Public
pub const DRIVER_NAME: &str = "erc20next";
pub const DRIVER_NAME: &str = "erc20";

pub const RINKEBY_NETWORK: &str = "rinkeby";
pub const RINKEBY_TOKEN: &str = "tGLM";
pub const RINKEBY_PLATFORM: &str = "erc20next-rinkeby-tglm";
pub const RINKEBY_PLATFORM: &str = "erc20-rinkeby-tglm";
pub const RINKEBY_CURRENCY_SHORT: &str = "tETH";
pub const RINKEBY_CURRENCY_LONG: &str = "Rinkeby Ether";

pub const GOERLI_NETWORK: &str = "goerli";
pub const GOERLI_TOKEN: &str = "tGLM";
pub const GOERLI_PLATFORM: &str = "erc20next-goerli-tglm";
pub const GOERLI_PLATFORM: &str = "erc20-goerli-tglm";
pub const GOERLI_CURRENCY_SHORT: &str = "tETH";
pub const GOERLI_CURRENCY_LONG: &str = "Goerli Ether";

pub const HOLESKY_NETWORK: &str = "holesky";
pub const HOLESKY_TOKEN: &str = "tGLM";
pub const HOLESKY_PLATFORM: &str = "erc20next-holesky-tglm";
pub const HOLESKY_PLATFORM: &str = "erc20-holesky-tglm";
pub const HOLESKY_CURRENCY_SHORT: &str = "tETH";
pub const HOLESKY_CURRENCY_LONG: &str = "Holesky Ether";

pub const MUMBAI_NETWORK: &str = "mumbai";
pub const MUMBAI_TOKEN: &str = "tGLM";
pub const MUMBAI_PLATFORM: &str = "erc20next-mumbai-tglm";
pub const MUMBAI_PLATFORM: &str = "erc20-mumbai-tglm";
pub const MUMBAI_CURRENCY_SHORT: &str = "tMATIC";
pub const MUMBAI_CURRENCY_LONG: &str = "Test MATIC";

pub const MAINNET_NETWORK: &str = "mainnet";
pub const MAINNET_TOKEN: &str = "GLM";
pub const MAINNET_PLATFORM: &str = "erc20next-mainnet-glm";
pub const MAINNET_PLATFORM: &str = "erc20-mainnet-glm";
pub const MAINNET_CURRENCY_SHORT: &str = "ETH";
pub const MAINNET_CURRENCY_LONG: &str = "Ether";

pub const POLYGON_MAINNET_NETWORK: &str = "polygon";
pub const POLYGON_MAINNET_TOKEN: &str = "GLM";
pub const POLYGON_MAINNET_PLATFORM: &str = "erc20next-polygon-glm";
pub const POLYGON_MAINNET_PLATFORM: &str = "erc20-polygon-glm";
pub const POLYGON_MAINNET_CURRENCY_SHORT: &str = "MATIC";
pub const POLYGON_MAINNET_CURRENCY_LONG: &str = "Polygon";

pub use service::Erc20NextService as PaymentDriverService;
pub use service::Erc20Service as PaymentDriverService;

// Private
#[macro_use]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ use ya_payment_driver::bus;

// Local uses
use crate::{
driver::Erc20NextDriver,
driver::Erc20Driver,
signer::{IdentitySigner, IdentitySignerActor},
};

pub struct Erc20NextService;
pub struct Erc20Service;

impl Erc20NextService {
impl Erc20Service {
pub async fn gsb(path: PathBuf) -> anyhow::Result<()> {
log::debug!("Connecting Erc20NextService to gsb...");
log::debug!("Connecting Erc20Service to gsb...");

// TODO: Read and validate env
log::debug!("Environment variables validated");
Expand All @@ -46,7 +46,7 @@ impl Erc20NextService {
};

let mut config = config::Config::load_from_str(include_str!("../config-payments.toml"))
.expect("Default erc20next config doesn't parse");
.expect("Default erc20 config doesn't parse");

// Load config from file if it exists giving the possibility of overwriting the default config
if tokio::fs::try_exists(&path.join("config-payments.toml"))
Expand Down Expand Up @@ -81,7 +81,7 @@ impl Erc20NextService {
if let Ok(sendout_interval) = env::var(sendout_interval_env) {
match sendout_interval.parse::<u64>() {
Ok(sendout_interval_secs) => {
log::info!("erc20next gather interval set to {sendout_interval_secs}s");
log::info!("erc20 gather interval set to {sendout_interval_secs}s");
config.engine.gather_interval = sendout_interval_secs;
},
Err(e) => log::warn!("Value {sendout_interval} for {sendout_interval_env} is not a valid integer: {e}"),
Expand Down Expand Up @@ -198,7 +198,7 @@ impl Erc20NextService {
let pr = PaymentRuntime::new(
PaymentRuntimeArgs {
secret_keys: private_keys,
db_filename: path.join("erc20next.sqlite"),
db_filename: path.join("erc20.sqlite"),
config,
conn: None,
options: Some(additional_options),
Expand All @@ -210,12 +210,12 @@ impl Erc20NextService {
)
.await?;

log::debug!("Bind erc20next driver");
let driver = Erc20NextDriver::new(pr, recv);
log::debug!("Bind erc20 driver");
let driver = Erc20Driver::new(pr, recv);
driver.load_active_accounts().await;
bus::bind_service(driver).await?;

log::info!("Successfully connected Erc20NextService to gsb.");
log::info!("Successfully connected Erc20Service to gsb.");
Ok(())
}
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion core/payment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ erc20_payment_lib = { workspace = true }
[dev-dependencies]
ya-client = "0.8"
ya-dummy-driver = "0.3"
ya-erc20next-driver = "0.4"
ya-erc20-driver = "0.4"
ya-net = { version = "0.3", features = ["service"] }
ya-sb-router = "0.6.1"

Expand Down
6 changes: 3 additions & 3 deletions core/payment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ The payments are made by drivers loaded in the service.
### Drivers

Currently these drivers are available to use:
- Erc20Next
- Erc20
- Erc20
- Dummy

By default only the Erc20 & Erc20Next drivers are enabled, extra drivers need to be specifically loaded with a feature flag.
By default only the Erc20 & Erc20 drivers are enabled, extra drivers need to be specifically loaded with a feature flag.

## DO NOT USE DUMMY DRIVER FOR BUILDS THAT WILL BE DISTRIBUTED!!!

Expand All @@ -25,7 +25,7 @@ You can enable multiple drivers at the same time, use this table for the require

### Examples:

Build with erc20next and erc20 drivers:
Build with erc20 and erc20 drivers:
```
cargo build --release
```
Loading

0 comments on commit ae34f77

Please sign in to comment.