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

Use backend-agnostic Rust types in fuel-client-core instead of GraphQL types #1121

Closed
5 tasks done
Voxelot opened this issue Apr 12, 2023 · 0 comments · Fixed by #1191
Closed
5 tasks done

Use backend-agnostic Rust types in fuel-client-core instead of GraphQL types #1121

Voxelot opened this issue Apr 12, 2023 · 0 comments · Fixed by #1191
Assignees

Comments

@Voxelot
Copy link
Member

Voxelot commented Apr 12, 2023

The fuel-core-client currently exposes graphql specific types on its public api.

In order to make fuel-core graphql agnostic, all public types in fuel-core-client should be plain rust types that aren't specific to any backend server implementation or transport mechanism (i.e. grpc vs graphql).

Create a module in fuel-core-client containing all the plain Rust types, similar to fuel-core-types. These types should be optimized for user friendliness and SDK experience. This task will be considered as complete when there are no public types exposed by fuel-core-client that depend on cynic.

Acceptance Criteria:

  • fuel-client-core contains a types module for agnostic Rust types
  • The new types module is self-contained and does not depend on or reuse existing Fuel types, such as fuel-core-types
  • All Rust types are compliant with the needs of fuel-client-core consumers
    • CLI
    • SDK
    • GraphQL proxy (future)
  • No public types exposed by fuel-core-client depend on cynic
  • Client API uses ID types rather than strings for IDs
    • Transaction IDs
    • Block IDs
    • Coin IDs
    • Asset IDs
    • Contract IDs
    • Message IDs
@Voxelot Voxelot changed the title Instead of GraphQL types use Rust types(Move them to a module - preparation for the GraphQL backend) Instead of GraphQL types use backend agnostic Rust types Apr 12, 2023
@bvrooman bvrooman self-assigned this Apr 16, 2023
@bvrooman bvrooman changed the title Instead of GraphQL types use backend agnostic Rust types Use backend-agnostic Rust types in fuel-client-core instead of GraphQL types Apr 16, 2023
This was referenced Apr 21, 2023
xgreenx added a commit that referenced this issue May 22, 2023
Related issues:
- #1121 

This PR introduces a module of Rust types used by the `Client` in the
`fuel-core-client` crate. These types are referred to as client types
and they are used to compose the `Client` interface. All function
signatures in the Client interface now use only client types and Rust
primitives. All references to GraphQL schema types are removed from the
interface's function signatures.

Specifically, this PR introduces the following client types:
- `Balance`
- `Block` (as well as its constituent parts `Header`, `Consensus`,
`Genesis`, and `PoAConsensus`)
- `ChainInfo`
- `Coin`, `MessageCoin`, and `CoinType`
- `ConsensusParameters`
- `Contract` and `ContractBalance`
- `MerkleProof`
- `Message` and `MessageProof`
- `NodeInfo` 

While GraphQL types are used inside the client methods, all types
returned by the GraphQL server are transformed back into client types so
that the `Client` returns only these client types. This is enabled by
defining a number of `From` traits, that transform the GraphQL schema
type into the client type.

---------

Co-authored-by: green <xgreenx9999@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants