Skip to content

Commit

Permalink
Merge pull request #2859 from golemfactory/kek/rename-drivers
Browse files Browse the repository at this point in the history
payment-driver: Rename erc20legacy->erc20, erc20->erc20next
  • Loading branch information
kamirr authored Oct 23, 2023
2 parents 42828e7 + 3c81b89 commit a60f414
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 71 deletions.
2 changes: 1 addition & 1 deletion core/model/src/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ pub mod local {
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum DriverName {
Erc20Next,
Erc20,
Erc20legacy,
}

#[derive(StructOpt, Debug, Clone)]
Expand Down
12 changes: 6 additions & 6 deletions core/payment-driver/erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
*/

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

pub const RINKEBY_NETWORK: &str = "rinkeby";
pub const RINKEBY_TOKEN: &str = "tGLM";
pub const RINKEBY_PLATFORM: &str = "erc20legacy-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 = "erc20legacy-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 MUMBAI_NETWORK: &str = "mumbai";
pub const MUMBAI_TOKEN: &str = "tGLM";
pub const MUMBAI_PLATFORM: &str = "erc20legacy-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 = "erc20legacy-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 = "erc20legacy-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";

Expand Down
4 changes: 2 additions & 2 deletions core/payment-driver/erc20next/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This command will send 0.0001 GLMs from internal wallet to address 0x89Ef977db64
Note that service have to be running otherwise you get no connection error.

```
yagna.exe payment transfer --amount 0.0001 --driver erc20 --network mumbai --to-address 0x89Ef977db64A2597bA57E3eb4b717D3bAAeBaeC3
yagna.exe payment transfer --amount 0.0001 --driver erc20next --network mumbai --to-address 0x89Ef977db64A2597bA57E3eb4b717D3bAAeBaeC3
```

You can specify extra options
Expand All @@ -17,7 +17,7 @@ You can specify extra options
* --gas-limit (limit of gas used in transaction). Better to leave default as it is not affecting cost of transaction. This is convenient for testing errors on blockchain.

```
yagna.exe payment transfer --amount 0.0001 --gas-price 1.1 --max-gas-price 60.4 --gas-limit 80000 --driver erc20 --network mumbai --to-address 0x89Ef977db64A2597bA57E3eb4b717D3bAAeBaeC3
yagna.exe payment transfer --amount 0.0001 --gas-price 1.1 --max-gas-price 60.4 --gas-limit 80000 --driver erc20next --network mumbai --to-address 0x89Ef977db64A2597bA57E3eb4b717D3bAAeBaeC3
```

Networks currently supported:
Expand Down
2 changes: 1 addition & 1 deletion core/payment-driver/erc20next/src/driver.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Erc20Driver to handle payments on the erc20 network.
Erc20Driver to handle payments on the erc20next network.
Please limit the logic in this file, use local mods to handle the calls.
*/
Expand Down
2 changes: 1 addition & 1 deletion core/payment-driver/erc20next/src/erc20/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Private mod to encapsulate all erc20 logic, revealed from the `wallet`.
Private mod to encapsulate all erc20next logic, revealed from the `wallet`.
*/

pub mod ethereum;
Expand Down
2 changes: 1 addition & 1 deletion core/payment-driver/erc20next/src/erc20/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Wallet functions on erc20.
Wallet functions on erc20next.
*/

// External crates
Expand Down
14 changes: 7 additions & 7 deletions core/payment-driver/erc20next/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
/*
Payment driver for yagna using erc20.
Payment driver for yagna using erc20next.
This file only contains constants and imports.
*/

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

pub const RINKEBY_NETWORK: &str = "rinkeby";
pub const RINKEBY_TOKEN: &str = "tGLM";
pub const RINKEBY_PLATFORM: &str = "erc20-rinkeby-tglm";
pub const RINKEBY_PLATFORM: &str = "erc20next-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 = "erc20-goerli-tglm";
pub const GOERLI_PLATFORM: &str = "erc20next-goerli-tglm";
pub const GOERLI_CURRENCY_SHORT: &str = "tETH";
pub const GOERLI_CURRENCY_LONG: &str = "Goerli Ether";

pub const MUMBAI_NETWORK: &str = "mumbai";
pub const MUMBAI_TOKEN: &str = "tGLM";
pub const MUMBAI_PLATFORM: &str = "erc20-mumbai-tglm";
pub const MUMBAI_PLATFORM: &str = "erc20next-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 = "erc20-mainnet-glm";
pub const MAINNET_PLATFORM: &str = "erc20next=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 = "erc20-polygon-glm";
pub const POLYGON_MAINNET_PLATFORM: &str = "erc20next-polygon-glm";
pub const POLYGON_MAINNET_CURRENCY_SHORT: &str = "MATIC";
pub const POLYGON_MAINNET_CURRENCY_LONG: &str = "Polygon";

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

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

By default only the Erc20 & Erc20Next drivers are enabled, extra drivers need to be specifically loaded with a feature flag.
Expand All @@ -25,7 +25,7 @@ You can enable multiple drivers at the same time, use this table for the require

### Examples:

Build with erc20 and erc20legacy drivers:
Build with erc20next and erc20 drivers:
```
cargo build --release
```
8 changes: 4 additions & 4 deletions core/payment/examples/payment_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ impl FromStr for Driver {
fn from_str(s: &str) -> anyhow::Result<Self> {
match s.to_lowercase().as_str() {
"dummy" => Ok(Driver::Dummy),
"erc20legacy" => Ok(Driver::Erc20),
"erc20" => Ok(Driver::Erc20next),
"erc20" => Ok(Driver::Erc20),
"erc20next" => Ok(Driver::Erc20next),
s => Err(anyhow::Error::msg(format!("Invalid driver: {}", s))),
}
}
Expand All @@ -57,8 +57,8 @@ impl std::fmt::Display for Driver {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Driver::Dummy => write!(f, "dummy"),
Driver::Erc20 => write!(f, "erc20legacy"),
Driver::Erc20next => write!(f, "erc20"),
Driver::Erc20 => write!(f, "erc20"),
Driver::Erc20next => write!(f, "erc20next"),
}
}
}
Expand Down
42 changes: 21 additions & 21 deletions golem_cli/src/command/yagna.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,40 @@ lazy_static! {
erc20.insert(
NetworkName::Mainnet.into(),
PaymentPlatform {
platform: "erc20legacy-mainnet-glm",
driver: "erc20legacy",
platform: "erc20-mainnet-glm",
driver: "erc20",
token: "GLM",
},
);
erc20.insert(
NetworkName::Rinkeby.into(),
PaymentPlatform {
platform: "erc20legacy-rinkeby-tglm",
driver: "erc20legacy",
platform: "erc20-rinkeby-tglm",
driver: "erc20",
token: "tGLM",
},
);
erc20.insert(
NetworkName::Goerli.into(),
PaymentPlatform {
platform: "erc20legacy-goerli-tglm",
driver: "erc20legacy",
platform: "erc20-goerli-tglm",
driver: "erc20",
token: "tGLM",
},
);
erc20.insert(
NetworkName::Mumbai.into(),
PaymentPlatform {
platform: "erc20legacy-mumbai-tglm",
driver: "erc20legacy",
platform: "erc20-mumbai-tglm",
driver: "erc20",
token: "tGLM",
},
);
erc20.insert(
NetworkName::Polygon.into(),
PaymentPlatform {
platform: "erc20legacy-polygon-glm",
driver: "erc20legacy",
platform: "erc20-polygon-glm",
driver: "erc20",
token: "GLM",
},
);
Expand All @@ -81,47 +81,47 @@ lazy_static! {
erc20next.insert(
NetworkName::Mainnet.into(),
PaymentPlatform {
platform: "erc20-mainnet-glm",
driver: "erc20",
platform: "erc20next-mainnet-glm",
driver: "erc20next",
token: "GLM",
},
);
erc20next.insert(
NetworkName::Rinkeby.into(),
PaymentPlatform {
platform: "erc20-rinkeby-tglm",
driver: "erc20",
platform: "erc20next-rinkeby-tglm",
driver: "erc20next",
token: "tGLM",
},
);
erc20next.insert(
NetworkName::Goerli.into(),
PaymentPlatform {
platform: "erc20-goerli-tglm",
driver: "erc20",
platform: "erc20next-goerli-tglm",
driver: "erc20next",
token: "tGLM",
},
);
erc20next.insert(
NetworkName::Mumbai.into(),
PaymentPlatform {
platform: "erc20-mumbai-tglm",
driver: "erc20",
platform: "erc20next-mumbai-tglm",
driver: "erc20next",
token: "tGLM",
},
);
erc20next.insert(
NetworkName::Polygon.into(),
PaymentPlatform {
platform: "erc20-polygon-glm",
driver: "erc20",
platform: "erc20next-polygon-glm",
driver: "erc20next",
token: "GLM",
},
);

PaymentDriver {
platforms: erc20next,
name: "erc20",
name: "erc20next",
}
};
pub static ref DRIVERS: Vec<&'static PaymentDriver> = vec![&ERC20_DRIVER];
Expand Down
Loading

0 comments on commit a60f414

Please sign in to comment.