Skip to content
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

GNT to GLM user facing refactor #1013

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Other ExeUnit types are to come (see below).
## MVP Requirements

* Clean and easy UX, most specifically during onboarding.
* NGNT-centric.
* GLM-centric.
* Production-ready, modular and easy to maintain architecture and code base.
_Modular_ means that all the building blocks can be easily replaceable.
* Documentation and SDK for developers.
Expand All @@ -51,7 +51,7 @@ _Modular_ means that all the building blocks can be easily replaceable.
* [ ] Docker on Linux _(optional)_
* [ ] SGX on Graphene _(optional)_
1. Payment platform
* [x] **Payments with NGNT**
pnowosie marked this conversation as resolved.
Show resolved Hide resolved
* [x] **Payments with GLM**
* [x] **Gasless transactions**
* [x] **ERC20 token**
* [ ] payment matching _(optional)_
Expand All @@ -68,4 +68,3 @@ _Modular_ means that all the building blocks can be easily replaceable.
* [ ] Verification by humans _(optional)_
1. Back compatibility
* [ ] Golem Brass/Clay interoperability _(optional)_

4 changes: 2 additions & 2 deletions accounts-example.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[
{
"driver": "ngnt",
"driver": "zksync",
"address": "0xdde2ccd1566294aa77db314501385ea50f1059c3",
"send": true,
"receive": false
}, {
"driver": "ngnt",
"driver": "zksync",
"address": "0x96af8f53f7f135824273105f94716f36970cfe75",
"send": false,
"receive": true
Expand Down
2 changes: 1 addition & 1 deletion core/payment-driver/gnt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl GntDriver {
async move {
let balance = common::get_gnt_balance(&contract, address).await?;
if balance < max_testnet_balance {
log::info!("Requesting NGNT from Faucet...");
log::info!("Requesting tGLM from Faucet...");
let gas_price = client.get_gas_price().await?;
let mut b =
sender::Builder::new(address, gas_price, chain_id).with_tx_type(TxType::Faucet);
Expand Down
12 changes: 6 additions & 6 deletions core/payment-driver/zksync/src/zksync/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub async fn request_ngnt(address: &str, network: Network) -> Result<(), Generic
}

log::info!(
"Requesting NGNT from zkSync faucet... address = {}",
"Requesting tGLM from zkSync faucet... address = {}",
address
);

Expand All @@ -43,14 +43,14 @@ pub async fn request_ngnt(address: &str, network: Network) -> Result<(), Generic
// Do not warn nor sleep at the last try.
if i >= MAX_FAUCET_REQUESTS - 1 {
log::error!(
"Failed to request NGNT from Faucet, tried {} times.: {:?}",
"Failed to request tGLM from Faucet, tried {} times.: {:?}",
MAX_FAUCET_REQUESTS,
e
);
return Err(e);
} else {
log::warn!(
"Retrying ({}/{}) to request NGNT from Faucet after failure: {:?}",
"Retrying ({}/{}) to request tGLM from Faucet after failure: {:?}",
i + 1,
MAX_FAUCET_REQUESTS,
e
Expand All @@ -65,16 +65,16 @@ pub async fn request_ngnt(address: &str, network: Network) -> Result<(), Generic
}

async fn wait_for_ngnt(address: &str, network: Network) -> Result<(), GenericError> {
log::info!("Waiting for NGNT from faucet...");
log::info!("Waiting for tGLM from faucet...");
let wait_until = Utc::now() + *MAX_WAIT;
while Utc::now() < wait_until {
if account_balance(address, network).await? >= *MIN_BALANCE {
log::info!("Received NGNT from faucet.");
log::info!("Received tGLM from faucet.");
return Ok(());
}
delay_for(time::Duration::from_secs(3)).await;
}
let msg = "Waiting for NGNT timed out.";
let msg = "Waiting for tGLM timed out.";
log::error!("{}", msg);
Err(GenericError::new(msg))
}
Expand Down
8 changes: 4 additions & 4 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:
- NGNT
- Erc20
- Dummy
- ZK-NGNT
- ZkSync

By default the NGNT driver is selected, extra drivers need to be specifically loaded with a feature flag.
By default the Erc20 and ZkSync drivers are selected, 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 zksync + ngnt driver:
Build with zksync + erc20 driver:
```
cargo build --release
```
Expand Down
6 changes: 5 additions & 1 deletion core/payment/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cd core/payment
cp ../../.env-template .env
cargo run --example payment_api
```
To use GNT instead of dummy driver us `cargo run --example payment_api -- --driver=gnt` instead.
To use Erc-20 instead of ZkSync driver us `cargo run --example payment_api -- --driver=erc20 --platform=erc20-rinkeby-tglm` instead.

### Debit note flow

Expand All @@ -21,6 +21,8 @@ cargo run --example debit_note_flow
(**NOTE:** The example expects a clean database so might need to remove `payment.db`
and restart the API server.)

Running examples with erc-20 payment driver, please wait until `payment_api` get funded and then run `debit_note_flow` with `--driver=erc20` parameter.
pnowosie marked this conversation as resolved.
Show resolved Hide resolved

##### Issue a debit node:
`POST` `http://127.0.0.1:7465/payment-api/v1/provider/debitNotes`

Expand Down Expand Up @@ -74,6 +76,8 @@ cargo run --example invoice_flow
(**NOTE:** The example expects a clean database so might need to remove `payment.db`
and restart the API server.)

Running examples with erc-20 payment driver, please wait until `payment_api` get funded and then run `invoice_flow` with `--driver=erc20` parameter.
pnowosie marked this conversation as resolved.
Show resolved Hide resolved

##### Issue an invoice:
`POST` `http://127.0.0.1:7465/payment-api/v1/provider/invoices`

Expand Down
2 changes: 1 addition & 1 deletion core/payment/examples/get_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ya_client::web::{rest_api_url, WebClient};

#[derive(Clone, Debug, StructOpt)]
struct Args {
#[structopt(short, long, default_value = "NGNT")]
#[structopt(short, long, default_value = "zksync-rinkeby-tglm")]
platform: String,
#[structopt()]
provider_addr: String,
Expand Down
15 changes: 11 additions & 4 deletions core/payment/examples/payment_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use structopt::StructOpt;
use ya_client_model::market;
use ya_client_model::payment::PAYMENT_API_PATH;
use ya_client_model::NodeId;
use ya_core_model::driver::{driver_bus_id, AccountMode, Init};
use ya_core_model::driver::{driver_bus_id, AccountMode, Init, Fund};
use ya_core_model::identity;
use ya_dummy_driver as dummy;
use ya_gnt_driver as gnt;
Expand Down Expand Up @@ -227,18 +227,25 @@ async fn main() -> anyhow::Result<()> {
zksync::DRIVER_NAME
}
};

bus::service(driver_bus_id(driver_name))
.call(Init::new(
provider_id.clone(),
provider_addr.clone(),
args.network.clone(),
None,
AccountMode::RECV,
))
.await??;

bus::service(driver_bus_id(driver_name))
.call(Fund::new(
requestor_addr.clone(),
args.network.clone(),
None
))
.await??;
bus::service(driver_bus_id(driver_name))
.call(Init::new(
requestor_id.clone(),
requestor_addr.clone(),
args.network.clone(),
None,
AccountMode::SEND,
Expand Down
8 changes: 4 additions & 4 deletions core/payment/examples/validate_allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,21 @@ async fn main() -> anyhow::Result<()> {
};

log::info!(
"Creating allocation for {} NGNT...",
"Creating allocation for {} tGLM...",
&new_allocation.total_amount
);
requestor.create_allocation(&new_allocation).await?;
log::info!("Allocation created.");

log::info!(
"Creating another allocation for {} NGNT...",
"Creating another allocation for {} tGLM...",
&new_allocation.total_amount
);
let allocation = requestor.create_allocation(&new_allocation).await?;
log::info!("Allocation created.");

log::info!(
"Attempting to create another allocation for {} NGNT...",
"Attempting to create another allocation for {} tGLM...",
&new_allocation.total_amount
);
let result = requestor.create_allocation(&new_allocation).await;
Expand All @@ -93,7 +93,7 @@ async fn main() -> anyhow::Result<()> {
log::info!("Allocation released.");

log::info!(
"Creating another allocation for {} NGNT...",
"Creating another allocation for {} tGLM...",
&new_allocation.total_amount
);
requestor.create_allocation(&new_allocation).await?;
Expand Down
4 changes: 2 additions & 2 deletions docs/logging-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ The log entries should record following aspects/attributes:
### Generic guidelines
- Use descriptive messages and proper casing/punctuation, ie. instead of:
```
[2020-08-27T07:56:22Z DEBUG yagna] init gnt drv
[2020-08-27T07:56:22Z DEBUG yagna] init glm drv
```
do this:
```
[2020-08-27T07:56:22Z DEBUG yagna] Initializing GNT payment driver
[2020-08-27T07:56:22Z DEBUG yagna] Initializing GLM payment driver
```

### Data confidentiality
Expand Down