Skip to content

Rain orderbook libraries, subgraph and contract implementation.

Notifications You must be signed in to change notification settings

rainlanguage/rain.orderbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rain.orderbook

Docs at https://rainprotocol.github.io/foundry.template

Run Tauri App for local development

  • Prepare the tauri build: ./prep-tauri.sh
  • Copy tauri-app/.env.example to tauri-ap/.env and fill in values
  • Run tauri for develoment: nix develop .#tauri-shell --command cargo tauri dev

Use as template

forge init -t rainprotocol/foundry.template <projectname>
cd <projectname>
forge install foundry-rs/forge-std

Then update the readme, set the docs url and configure github pages on github repo settings.

For CI deployments, setup all the environment variables and define contracts to deploy in the matrix.

Generating Rust Types from Graphql

NOTICE The crates and tauri app are currently expecting a subgraph compatible with the schema in crates/subgraph/schema/orderbook.graphql. When this project is migrated to use the subgraph schema defined in subgraph/schema/graphql, the command below will change.

  1. Run the following commands to generate Rust types from GraphQL Queries
cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/subgraph/queries/vaultDetail.graphql  > crates/subgraph/src/types/vault_detail.rs
cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/subgraph/queries/vaultsList.graphql  > crates/subgraph/src/types/vaults_list.rs
cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/subgraph/queries/orderDetail.graphql  > crates/subgraph/src/types/order_detail.rs
cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/subgraph/queries/ordersList.graphql  > crates/subgraph/src/types/orders_list.rs
cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/subgraph/queries/vaultBalanceChangesList.graphql  > crates/subgraph/src/types/vault_balance_changes_list.rs
cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/subgraph/queries/orderTakesList.graphql  > crates/subgraph/src/types/order_takes_list.rs
cynic querygen --schema crates/subgraph/schema/orderbook.graphql --query crates/subgraph/queries/orderTakeDetail.graphql  > crates/subgraph/src/types/order_take_detail.rs
  1. Prepend each generated types file with the following:
use crate::schema;
use typeshare::typeshare;
  1. Add the following derives for all generated Rust types:
#[derive(Clone)]
  1. Add the following derives for all generated Rust types that also derive cynic::QueryFragment:
#[derive(Serialize)]
  1. Add the following macros to all generated Rust types
#[typeshare]
  1. Rename the conflicting enum TokenVaultOrderBy::VaultId to TokenVaultOrderBy::VaultId2 in crates/subgraphs/src/types/vaults.rs

Generating Typescript Types from Rust Types

Run the following from the repo root, outside the nix shell, to generate Typescript types from Rust types in crates/subgraph/src/types.

nix run .#ob-tauri-prelude