Skip to content

Commit

Permalink
Localize file deps (#97)
Browse files Browse the repository at this point in the history
* eliminate file deps external to fuel-client folder
  • Loading branch information
Voxelot committed Dec 24, 2021
1 parent 7521c7c commit 07f1a3f
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion fuel-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fuel-gql-client"
version = "0.1.1"
version = "0.1.2"
authors = ["Fuel Labs <contact@fuel.sh>"]
categories = ["concurrency", "cryptography::cryptocurrencies", "emulators"]
edition = "2021"
Expand Down
File renamed without changes.
8 changes: 2 additions & 6 deletions fuel-client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ use std::io::prelude::*;
use std::path::PathBuf;

fn main() {
println!("cargo:rerun-if-changed=../fuel-core/src/schema");
println!("cargo:rerun-if-changed=./assets/debugAdapterProtocol.json");

let path = env::var("CARGO_MANIFEST_DIR")
.map(PathBuf::from)
.map(|p| {
p.parent()
.expect("Failed to uproot")
.join("fuel-client/assets/debugAdapterProtocol.json")
})
.map(|p| p.join("assets/debugAdapterProtocol.json"))
.expect("Failed to fetch JSON schema");

let json = fs::read_to_string(&path).expect("Failed to parse JSON from schema");
Expand Down
18 changes: 9 additions & 9 deletions fuel-client/src/client/schema.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// this is the format cynic expects
#[allow(clippy::module_inception)]
pub mod schema {
cynic::use_schema!("../assets/schema.sdl");
cynic::use_schema!("./assets/schema.sdl");
}

use hex::FromHexError;
Expand All @@ -19,13 +19,13 @@ pub mod primitives;
pub mod tx;

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl", graphql_type = "Query")]
#[cynic(schema_path = "./assets/schema.sdl", graphql_type = "Query")]
pub struct Health {
pub health: bool,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl", graphql_type = "Mutation")]
#[cynic(schema_path = "./assets/schema.sdl", graphql_type = "Mutation")]
pub struct StartSession {
pub start_session: cynic::Id,
}
Expand All @@ -37,7 +37,7 @@ pub struct IdArg {

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Mutation",
argument_struct = "IdArg"
)]
Expand All @@ -48,7 +48,7 @@ pub struct EndSession {

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Mutation",
argument_struct = "IdArg"
)]
Expand All @@ -65,7 +65,7 @@ pub struct ExecuteArgs {

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Mutation",
argument_struct = "ExecuteArgs"
)]
Expand All @@ -82,7 +82,7 @@ pub struct RegisterArgs {

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Query",
argument_struct = "RegisterArgs"
)]
Expand All @@ -100,7 +100,7 @@ pub struct MemoryArgs {

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Query",
argument_struct = "MemoryArgs"
)]
Expand All @@ -124,7 +124,7 @@ pub struct ConnectionArgs {
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct PageInfo {
pub end_cursor: Option<String>,
pub has_next_page: bool,
Expand Down
10 changes: 5 additions & 5 deletions fuel-client/src/client/schema/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct BlockByIdArgs {

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Query",
argument_struct = "BlockByIdArgs"
)]
Expand All @@ -22,7 +22,7 @@ pub struct BlockByIdQuery {

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Query",
argument_struct = "ConnectionArgs"
)]
Expand All @@ -32,7 +32,7 @@ pub struct BlocksQuery {
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct BlockConnection {
pub edges: Option<Vec<Option<BlockEdge>>>,
pub page_info: PageInfo,
Expand All @@ -53,14 +53,14 @@ impl From<BlockConnection> for PaginatedResult<Block, String> {
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct BlockEdge {
pub cursor: String,
pub node: Block,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct Block {
pub height: U64,
pub id: HexString256,
Expand Down
4 changes: 2 additions & 2 deletions fuel-client/src/client/schema/chain.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::client::schema::{block::Block, schema, U64};

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl", graphql_type = "Query")]
#[cynic(schema_path = "./assets/schema.sdl", graphql_type = "Query")]
pub struct ChainQuery {
pub chain: ChainInfo,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct ChainInfo {
pub base_chain_height: U64,
pub name: String,
Expand Down
12 changes: 6 additions & 6 deletions fuel-client/src/client/schema/coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct CoinByIdArgs {

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Query",
argument_struct = "CoinByIdArgs"
)]
Expand Down Expand Up @@ -55,7 +55,7 @@ impl From<(HexString256, PaginationRequest<String>)> for CoinsByOwnerConnectionA

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Query",
argument_struct = "CoinsByOwnerConnectionArgs"
)]
Expand All @@ -65,7 +65,7 @@ pub struct CoinsQuery {
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct CoinConnection {
pub edges: Option<Vec<Option<CoinEdge>>>,
pub page_info: PageInfo,
Expand All @@ -86,14 +86,14 @@ impl From<CoinConnection> for PaginatedResult<Coin, String> {
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct CoinEdge {
pub cursor: String,
pub node: Coin,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct Coin {
pub amount: U64,
pub block_created: U64,
Expand All @@ -105,7 +105,7 @@ pub struct Coin {
}

#[derive(cynic::Enum, Clone, Copy, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum CoinStatus {
Unspent,
Spent,
Expand Down
26 changes: 13 additions & 13 deletions fuel-client/src/client/schema/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct TxIdArgs {
/// Retrieves the transaction in opaque form
#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Query",
argument_struct = "TxIdArgs"
)]
Expand All @@ -24,7 +24,7 @@ pub struct TransactionQuery {

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Query",
argument_struct = "ConnectionArgs"
)]
Expand All @@ -34,7 +34,7 @@ pub struct TransactionsQuery {
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct TransactionConnection {
pub edges: Option<Vec<Option<TransactionEdge>>>,
pub page_info: PageInfo,
Expand All @@ -59,14 +59,14 @@ impl TryFrom<TransactionConnection> for PaginatedResult<fuel_tx::Transaction, St
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct TransactionEdge {
pub cursor: String,
pub node: OpaqueTransaction,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Transaction", schema_path = "../assets/schema.sdl")]
#[cynic(graphql_type = "Transaction", schema_path = "./assets/schema.sdl")]
pub struct OpaqueTransaction {
pub raw_payload: HexString,
pub receipts: Option<Vec<OpaqueReceipt>>,
Expand All @@ -83,7 +83,7 @@ impl TryFrom<OpaqueTransaction> for fuel_tx::Transaction {
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Receipt", schema_path = "../assets/schema.sdl")]
#[cynic(graphql_type = "Receipt", schema_path = "./assets/schema.sdl")]
pub struct OpaqueReceipt {
pub raw_payload: HexString,
}
Expand All @@ -100,29 +100,29 @@ impl TryFrom<OpaqueReceipt> for fuel_tx::Receipt {

#[allow(clippy::enum_variant_names)]
#[derive(cynic::InlineFragments, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum TransactionStatus {
SubmittedStatus(SubmittedStatus),
SuccessStatus(SuccessStatus),
FailureStatus(FailureStatus),
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct SubmittedStatus {
pub time: super::DateTime,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct SuccessStatus {
pub block_id: HexString256,
pub time: super::DateTime,
pub program_state: HexString,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct FailureStatus {
pub block_id: HexString256,
pub time: super::DateTime,
Expand Down Expand Up @@ -167,7 +167,7 @@ impl From<(HexString256, PaginationRequest<String>)> for TransactionsByOwnerConn

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Query",
argument_struct = "TransactionsByOwnerConnectionArgs"
)]
Expand All @@ -185,7 +185,7 @@ pub struct TxArg {

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Mutation",
argument_struct = "TxArg"
)]
Expand All @@ -196,7 +196,7 @@ pub struct DryRun {

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
schema_path = "../assets/schema.sdl",
schema_path = "./assets/schema.sdl",
graphql_type = "Mutation",
argument_struct = "TxArg"
)]
Expand Down
4 changes: 2 additions & 2 deletions fuel-client/src/client/schema/tx/tests/transparent_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::client::schema::{
use fuel_types::Word;

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct Receipt {
pub a: Option<U64>,
pub b: Option<U64>,
Expand Down Expand Up @@ -32,7 +32,7 @@ pub struct Receipt {
}

#[derive(cynic::Enum, Clone, Copy, Debug)]
#[cynic(schema_path = "../assets/schema.sdl")]
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum ReceiptType {
Call,
Return,
Expand Down

0 comments on commit 07f1a3f

Please sign in to comment.