-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1037 from rainlanguage/2024-12-02-prep-script
new prep script and readme
- Loading branch information
Showing
12 changed files
with
102 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
COMMIT_SHA=test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,28 @@ | ||
# rain.orderbook | ||
|
||
Docs at https://rainprotocol.github.io/foundry.template | ||
## Setup for local development | ||
|
||
## 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` | ||
### Environment Setup | ||
|
||
## Use as template | ||
1. Copy `.env.example` to `.env` | ||
2. Copy `tauri-app/.env.example` to `tauri-app/.env` and fill out `VITE_WALLETCONNECT_PROJECT_ID` with a test project ID from [Reown (FKA WalletConnect)](https://cloud.reown.com/sign-in) | ||
|
||
``` | ||
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 | ||
Then run the following to install dependencies and build the project: | ||
```bash | ||
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 | ||
./prep-all.sh | ||
``` | ||
|
||
2. Prepend each generated types file with the following: | ||
```rust | ||
use crate::schema; | ||
use typeshare::typeshare; | ||
You may need to make the shell script executable: | ||
```bash | ||
chmod +x prep-all.sh | ||
``` | ||
|
||
3. Add the following derives for all generated Rust types: | ||
```rust | ||
#[derive(Clone)] | ||
### Run Webapp for local development | ||
``` | ||
|
||
4. Add the following derives for all generated Rust types that also derive `cynic::QueryFragment`: | ||
```rust | ||
#[derive(Serialize)] | ||
cd packages/webapp && nix develop -c npm run dev | ||
``` | ||
|
||
5. Add the following macros to all generated Rust types | ||
```rust | ||
#[typeshare] | ||
### Run Tauri App for local development | ||
``` | ||
|
||
6. 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`. | ||
```bash | ||
nix run .#ob-tauri-prelude | ||
nix develop .#tauri-shell --command cargo tauri dev | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/bash | ||
|
||
# Set strict error handling | ||
set -euxo pipefail | ||
|
||
echo "Starting project setup..." | ||
|
||
# Environment variables that need to be set (commented out as reference) | ||
# export CI_DEPLOY_SEPOLIA_RPC_URL="" | ||
# export CI_FORK_SEPOLIA_DEPLOYER_ADDRESS="" | ||
# export CI_FORK_SEPOLIA_BLOCK_NUMBER="" | ||
# export CI_DEPLOY_POLYGON_RPC_URL="" | ||
# export CI_SEPOLIA_METABOARD_URL="" | ||
# export RPC_URL_ETHEREUM_FORK="" | ||
# export COMMIT_SHA="" | ||
|
||
# Keep environment variables when using nix-develop | ||
keep=( | ||
-k CI_DEPLOY_SEPOLIA_RPC_URL | ||
-k CI_FORK_SEPOLIA_DEPLOYER_ADDRESS | ||
-k CI_FORK_SEPOLIA_BLOCK_NUMBER | ||
-k CI_DEPLOY_POLYGON_RPC_URL | ||
-k CI_SEPOLIA_METABOARD_URL | ||
-k RPC_URL_ETHEREUM_FORK | ||
-k COMMIT_SHA | ||
) | ||
|
||
echo "Installing Forge dependencies..." | ||
nix develop -c forge install | ||
|
||
echo "Setting up rain.interpreter..." | ||
nix develop -i ${keep[@]} -c bash -c '(cd lib/rain.interpreter && rainix-sol-prelude)' | ||
nix develop -i ${keep[@]} -c bash -c '(cd lib/rain.interpreter && rainix-rs-prelude)' | ||
(cd lib/rain.interpreter && nix develop -i ${keep[@]} -c bash -c i9r-prelude) | ||
|
||
echo "Setting up rain.metadata..." | ||
nix develop -i ${keep[@]} -c bash -c '(cd lib/rain.interpreter/lib/rain.metadata && rainix-sol-prelude)' | ||
nix develop -i ${keep[@]} -c bash -c '(cd lib/rain.interpreter/lib/rain.metadata && rainix-rs-prelude)' | ||
|
||
echo "Setting up main project dependencies..." | ||
nix develop -i ${keep[@]} -c rainix-sol-prelude | ||
nix develop -i ${keep[@]} -c rainix-rs-prelude | ||
nix develop -i ${keep[@]} -c raindex-prelude | ||
|
||
echo "Setting up UI components..." | ||
nix develop -i ${keep[@]} .#tauri-shell -c ob-tauri-prelude | ||
nix develop -i ${keep[@]} .#tauri-shell -c ob-ui-components-prelude | ||
|
||
echo "Building packages..." | ||
nix develop -i ${keep[@]} -c bash -c '(npm run build -w @rainlanguage/orderbook)' | ||
nix develop -i ${keep[@]} -c bash -c '(npm run build -w @rainlanguage/ui-components && npm run build -w @rainlanguage/webapp)' | ||
|
||
# Temporarily disable command echoing | ||
set +x | ||
|
||
export LANG=en_US.UTF-8 | ||
export LC_ALL=en_US.UTF-8 | ||
|
||
GREEN='\033[0;32m' | ||
NC='\033[0m' # No Color | ||
|
||
# Print the completion message | ||
printf "\033[0;32m" # Set text to green | ||
printf "╔════════════════════════════════════════════════════════════════════════╗\n" | ||
printf "║ Setup Complete! ║\n" | ||
printf "╠════════════════════════════════════════════════════════════════════════╣\n" | ||
printf "║ How to run the apps: ║\n" | ||
printf "║ ║\n" | ||
printf "║ To run webapp: cd packages/webapp && nix develop -c npm run dev ║\n" | ||
printf "║ To run tauri app: nix develop .#tauri-shell -c cargo tauri dev ║\n" | ||
printf "╚════════════════════════════════════════════════════════════════════════╝\n" | ||
printf "\033[0m" # Reset text color | ||
|
||
# Re-enable command echoing | ||
set -x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
COMMIT_SHA= | ||
|
||
VITE_WALLETCONNECT_PROJECT_ID= | ||
|
||
# The long url provided by sentry for your project configuration | ||
|