From 9124648719be39ade9aec406200f02dbd4cbb41c Mon Sep 17 00:00:00 2001 From: boneyard93501 <4523011+boneyard93501@users.noreply.github.com> Date: Mon, 8 Mar 2021 17:38:52 -0600 Subject: [PATCH] rmm paywall --- multi-service/air-scripts/ethqlite_init.clj | 2 +- multi-service/ethqlite/src/crud.rs | 2 +- multi-service/ethqlite/src/main.rs | 27 ------- multi-service/ethqlite/src/paywall.rs | 80 --------------------- 4 files changed, 2 insertions(+), 109 deletions(-) delete mode 100644 multi-service/ethqlite/src/paywall.rs diff --git a/multi-service/air-scripts/ethqlite_init.clj b/multi-service/air-scripts/ethqlite_init.clj index 992f7d2..78a9b80 100644 --- a/multi-service/air-scripts/ethqlite_init.clj +++ b/multi-service/air-scripts/ethqlite_init.clj @@ -2,7 +2,7 @@ (seq (seq (call relay ("op" "identity") []) - (call node_1 (service "init_service") [use_owner use_paywall api_key] result) + (call node_1 (service "init_service") [use_owner api_key] result) ) (seq (call relay ("op" "identity") []) diff --git a/multi-service/ethqlite/src/crud.rs b/multi-service/ethqlite/src/crud.rs index 4e22205..292d33a 100644 --- a/multi-service/ethqlite/src/crud.rs +++ b/multi-service/ethqlite/src/crud.rs @@ -19,7 +19,7 @@ use fce_sqlite_connector::{Connection, State, Value}; use std::sync::atomic::{AtomicBool, Ordering}; -use crate::{AUTH, PAYWALL}; +use crate::AUTH; use crate::get_connection; use crate::auth::is_owner; diff --git a/multi-service/ethqlite/src/main.rs b/multi-service/ethqlite/src/main.rs index 76fbb25..3f3f248 100644 --- a/multi-service/ethqlite/src/main.rs +++ b/multi-service/ethqlite/src/main.rs @@ -20,7 +20,6 @@ use fluence::WasmLoggerBuilder; use fce_sqlite_connector; use fce_sqlite_connector::{Connection, State, Value}; -use uuid::Uuid; use std::path::{Path, PathBuf}; use serde::Deserialize; @@ -36,7 +35,6 @@ const DB_PATH: &str = "/tmp/fluence_service_db.sqlite"; mod crud; mod auth; -// mod paywall; fn main() { @@ -46,7 +44,6 @@ fn main() { const KOVAN_ACCT: &str = ""; pub static AUTH: AtomicBool = AtomicBool::new(false); -pub static PAYWALL: AtomicBool = AtomicBool::new(false); pub static INIT: AtomicBool = AtomicBool::new(false); @@ -87,7 +84,6 @@ pub fn init_service(is_auth:bool, is_paywall: bool, api_data: String) -> InitRes } AUTH.store(is_auth, Ordering::Relaxed); - PAYWALL.store(is_paywall, Ordering::Relaxed); if api_data.len() > 0 { @@ -124,7 +120,6 @@ pub fn owner_nuclear_reset() -> bool { } AUTH.store(false, Ordering::Relaxed); - PAYWALL.store(false, Ordering::Relaxed); INIT.store(false, Ordering::Relaxed); let conn = get_connection(); @@ -137,25 +132,3 @@ pub fn owner_nuclear_reset() -> bool { true } - -/* -#[fce] -fn get_balance(reference_id: String, ) { - let conn = fce_sqlite_connector::open(DB_PATH).unwrap(); - - let stmt = "select balance from payments where block_miner = ?"; - let select = conn.prepare(stmt); - let mut miner_rewards = MinerRewards::new(miner_address.clone()); - -} -*/ - -/* -fn check_funding(compute_units: u32, unit_cost: u32) -> bool { - let conn = get_connection(); - - let req_balance:i64 = (compute_units * unit_cost).into(); - get_balance(user_id) - true -} -*/ \ No newline at end of file diff --git a/multi-service/ethqlite/src/paywall.rs b/multi-service/ethqlite/src/paywall.rs deleted file mode 100644 index 05df5ac..0000000 --- a/multi-service/ethqlite/src/paywall.rs +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2021 Fluence Labs Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -use uuid::Uuid; -use ed25519_dalek::{Signature, Verifier, PublicKey}; - - -use crate::get_connection; - - -pub enum EthereumChains { - MAINNET = 1, - ROPSTEN = 3, - RINKEBY = 4, - GOERLI = 5, - KOVAN = 42, - -} - - -fn sig_check(pub_key: &[u8], message: &[u8], signature: [u8;64]) -> bool { - let pk = PublicKey::from_bytes(pub_key).unwrap(); - let signature = Signature::new(signature); - match pk.verify(message, &signature) { - Ok(_) => true, - Err(_) => false - } -} - - -#[fce] -#[derive(Debug)] -pub struct DepositResult { - success: bool, - balance: String, - err_msg: String, -} - -impl DepositResult { - fn success(balance: String) -> Self { - DepositResult { - success: true, - balance, - err_msg: String::from(""), - } - } - - fn failure(err_msg: String, balance: String) -> Self { - DepositResult { - success: false, - balance, - err_msg, - } - } -} - -pub fn deposit(user_id:String, tx_id: String, chain_id: u32, pub_key: &[u8], signature: &[u8]) -> DepositResult { - let mut user_id:String = user_id; - if user_id.len() == 0 { - let user_id = Uuid::new_v4(); - } - - let stmt = "insert into table ??? where user_id = ? on conflict (user_id) do update set balance += ?"; - - DepositResult::failure("no_good".into(), "0".into()) -} -