Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Skeleton #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ index.html

# Test data
test-data

Cargo.lock
15 changes: 4 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
[package]
authors = ["Xavier Lau <[email protected]>"]
build = "build.rs"
description = "<DESCRIPTION>"
edition = "2021"
homepage = "https://<NAME>.hack.ink"
license = "GPL-3.0"
name = "<NAME>"
readme = "README.md"
repository = "https://github.com/hack-ink/<NAME>"
version = "0.1.0"
[workspace]
members = [
"subapeye"
]
17 changes: 0 additions & 17 deletions build.rs

This file was deleted.

31 changes: 31 additions & 0 deletions subapeye/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
authors = ["Xavier Lau <[email protected]>"]
description = "subapeye"
edition = "2021"
homepage = "https://github.com/darwinia-network/subxt"
license = "GPL-3.0"
name = "subapeye"
readme = "README.md"
repository = "https://github.com/darwinia-network/subxt"
version = "0.1.0"

[dependencies]

thiserror = "1"
async-trait = "0.1"
tokio-tungstenite = { optional = true, version = "0.18" }
reqwest = { optional = true, version = "0.11" }

subcryptor = { branch = "main", git = "https://github.com/hack-ink/subalfred" }
subgrandpa = { branch = "main", git = "https://github.com/hack-ink/subalfred" }
subhasher = { branch = "main", git = "https://github.com/hack-ink/subalfred" }
subrpcer = { branch = "main", git = "https://github.com/hack-ink/subalfred" }
subruntimer = { branch = "main", git = "https://github.com/hack-ink/subalfred" }
subspector = { branch = "main", git = "https://github.com/hack-ink/subalfred" }
substorager = { branch = "main", git = "https://github.com/hack-ink/subalfred" }
subversioner = { branch = "main", git = "https://github.com/hack-ink/subalfred" }

[features]
default = ["provider-http", "provider-ws"]
provider-http = ["reqwest"]
provider-ws = ["tokio-tungstenite"]
11 changes: 11 additions & 0 deletions subapeye/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use thiserror::Error as ThisError;

pub type SubapeyeResult<T> = Result<T, SubapeyeError>;


/// Subapeye error
#[derive(ThisError, Debug)]
pub enum SubapeyeError {
#[error("Unsupported: {0}")]
Unsupported(String),
}
5 changes: 5 additions & 0 deletions subapeye/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub use self::subapeye::*;

pub mod provider;

mod subapeye;
23 changes: 23 additions & 0 deletions subapeye/src/provider/common.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

/// provider config
#[derive(Clone, Debug)]
pub struct Config {
pub endpoint: String,
pub timeout: Option<u64>,
}

impl Config {
pub fn simple(endpoint: impl AsRef<str>) -> Self {
Self {
endpoint: endpoint.as_ref().to_string(),
timeout: None,
}
}
}

#[async_trait::async_trait]
pub trait ApeyeProvider: Clone + std::fmt::Debug {

}


15 changes: 15 additions & 0 deletions subapeye/src/provider/http.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::provider::{ApeyeProvider, Config};

#[derive(Clone, Debug)]
pub struct HttpProvider {
config: Config,
}

impl HttpProvider {
pub fn new(config: Config) -> Self {
Self { config }
}
}

#[async_trait::async_trait]
impl ApeyeProvider for HttpProvider {}
15 changes: 15 additions & 0 deletions subapeye/src/provider/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

#[cfg(any(feature = "provider-http", feature = "provider-ws"))]
pub use self::common::*;
#[cfg(feature = "provider-http")]
pub use self::http::*;
#[cfg(feature = "provider-ws")]
pub use self::websocket::*;

#[cfg(feature = "provider-http")]
mod http;
#[cfg(feature = "provider-ws")]
mod websocket;

#[cfg(any(feature = "provider-http", feature = "provider-ws"))]
mod common;
15 changes: 15 additions & 0 deletions subapeye/src/provider/websocket.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::provider::{ApeyeProvider, Config};

#[derive(Clone, Debug)]
pub struct WsProvider {
config: Config,
}

impl WsProvider {
pub fn new(config: Config) -> Self {
Self { config }
}
}

#[async_trait::async_trait]
impl ApeyeProvider for WsProvider {}
15 changes: 15 additions & 0 deletions subapeye/src/subapeye.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::provider::ApeyeProvider;

/// Subapeye
#[derive(Clone, Debug)]
pub struct Subapeye<P: ApeyeProvider> {
provider: P,
}

impl<P: ApeyeProvider> Subapeye<P> {
/// New subapeye instance
pub fn new(provider: P) -> Self {
Self { provider }
}
}

File renamed without changes.