Skip to content

Commit f77f32f

Browse files
sai-trading: project scaffolding with script to deploy all Sai contracts (#2433)
* chore: changelog * sai-trading: add first set of artifacts * sai-trading: toml for build info * sai-trading: start a small program that uses a running nibid process for local testing * chore: add out.txt to gitignore; add justfile comment * sai-trading: project scaffolding with script to deploy all Sai contracts * sai-trading: get a simple test going that checks for the running network in the background * test(ci): need to install bun before running the script * use which instead of command -v * fix array concatenation * make pr title lint more flexible to account for sai-trading and revert changes to app, proto, api * test(.github): fix just install if statement * chore: linter * fix(linter): revert the build tag issue and disable that small piece of govet * Delete TODO_ANALYSIS.md
1 parent 68bb5ba commit f77f32f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+6109
-2
lines changed

.cursorignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ dist/
4141
# x/sudo/
4242
# x/tokenfactory/
4343

44+
# DON'T ignore out.txt
45+
!out.txt
4446

4547
# Boilerplate
4648
# *.pb.go

.github/workflows/e2e-evm.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,65 @@ jobs:
8888
env:
8989
JSON_RPC_ENDPOINT: http://127.0.0.1:8545
9090
MNEMONIC: guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host
91+
92+
sai-trading:
93+
runs-on: ubuntu-latest
94+
steps:
95+
- uses: actions/checkout@v4
96+
97+
- name: "Check for EVM-related changes"
98+
id: check_changes
99+
uses: dorny/paths-filter@v3
100+
with:
101+
filters: |
102+
check_changes:
103+
- "sai-trading/**/*.ts"
104+
- "sai-trading/artifacts/*"
105+
- "sai-trading/**/*.go"
106+
107+
- name: Set up Go
108+
if: steps.check_changes.outputs.check_changes == 'true'
109+
uses: actions/setup-go@v5
110+
with:
111+
go-version: 1.24
112+
# cache: "The action has a built-in functionality for caching and
113+
# restoring go modules and build outputs. It uses [actions/cache@v4]."
114+
# - Handles go module cache (go env GOMODCACHE).
115+
# - Handles go build cache (go env GOCACHE).
116+
cache: true
117+
118+
- name: "Install just"
119+
if: steps.check_changes.outputs.check_changes == 'true'
120+
# casey/just: https://just.systems/man/en/chapter_6.html
121+
# taiki-e/install-action: https://github.com/taiki-e/install-action
122+
uses: taiki-e/install-action@just
123+
124+
- name: "Build the nibid binary"
125+
if: steps.check_changes.outputs.check_changes == 'true'
126+
run: |
127+
just install
128+
129+
- if: steps.check_changes.outputs.check_changes == 'true'
130+
# For running things and for package management "
131+
uses: oven-sh/setup-bun@v1
132+
with:
133+
bun-version: 1.2.22 # Values: latest, <sha>, 1.2.3, canary
134+
# Outputs:
135+
# - cache-hit : Whether the executable was read from cache. Ex. "true"
136+
# - bun-version : The output from running `bun-version`. Ex. "1.0.0"
137+
# - bun-revision : The output from running `bun-revision`.
138+
139+
- if: steps.check_changes.outputs.check_changes == 'true'
140+
working-directory: "sai-trading"
141+
run: |
142+
bun install
143+
144+
- if: steps.check_changes.outputs.check_changes == 'true'
145+
run: |
146+
just localnet --no-build &
147+
sleep 10
148+
149+
- if: steps.check_changes.outputs.check_changes == 'true'
150+
working-directory: "sai-trading"
151+
run: |
152+
just test

.github/workflows/pr-title-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: seferov/[email protected]
1212
with:
1313
# V2: Includes Nibiru-specific qualifiers and allows for
14-
title-regex: '^(evm|build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.\/]+\))?(!)?: ([\w ])+([\s\S]*)'
14+
title-regex: '^(evm|sai-trading|build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.\/]+\))?(!)?: ([\w ])+([\s\S]*)'
1515
# V1: Old regex taken from Gist: https://gist.github.com/marcojahn/482410b728c31b221b70ea6d2c433f0c
1616
# title-regex: '^(evm|build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)'
1717
# title-regex-flags (Optional)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ sketch
347347

348348
public/js/
349349
.npmrc
350+
out.txt
350351

351352
playwright/test-results/
352353
playwright/playwright-report/

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ require (
258258
sigs.k8s.io/yaml v1.4.0 // indirect
259259
)
260260

261+
// Replace block for Nibiru
262+
// TODO: Remove rocksdb dep: https://github.com/NibiruChain/nibiru/issues/2432
261263
replace (
262264
cosmossdk.io/api => cosmossdk.io/api v0.3.1
263265

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ lint:
9999
golangci/golangci-lint:$image_version \
100100
golangci-lint run -v --fix 2>&1
101101

102-
# Runs a Nibiru local network. Ex: "just localnet", "just localnet --features featureA"
102+
# Runs a Nibiru local network. Ex: "just localnet", "just localnet --no-build", "just localnet --features featureA"
103103
localnet *PASS_FLAGS:
104104
make localnet FLAGS="{{PASS_FLAGS}}"
105105

sai-trading/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
artifacts/solidity/build-info
2+
*.dbg.json

sai-trading/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Nibiru/Sai-Trading
2+
3+
Rough notes (for now)
4+
5+
## Plan
6+
7+
- [ ] Use sai-perps version for both the EVM interface and Wasm contracts.
8+
9+
---
10+
11+
### Pulling in artifacts
12+
13+
Sketching out the flow from the "sai-perps" repo:
14+
15+
```bash
16+
root="$(pwd)" # Nibiru/sai-trading
17+
18+
# Assuming sai-perps is temporarily locally cloned:
19+
# npx degit ... OR downlaod from release assets
20+
sai_perps="$root/sai-perps"
21+
22+
cp "$sai_perps/artifacts/*" artifacts/
23+
(cd $sai_perps just evm-install && just evm-build)
24+
rm -rf artifacts/solidity
25+
cp -r "$sai_perps/evm-interface/artifacts" artifacts/solidity
26+
```
27+
28+
cp "
29+
30+
```bash
31+
cp "$sai_perps/evm-interface/artifacts/contracts/PerpVaultEvmInterface.sol/PerpVaultEvmInterface.json" artifacts/
32+
jq '{sourceName, contractName, abi, bytecode}' artifacts/PerpVaultEvmInterface.json > tmp.json
33+
mv tmp.json artifacts/PerpVaultEvmInterface.json
34+
```
35+
36+
### yq for artifacts build info:
37+
38+
The `yq` tool is written in Go as a dependency free binary.
39+
40+
```bash
41+
go install github.com/mikefarah/yq/v4@latest
42+
```
43+
https://github.com/mikefarah/yq?tab=readme-ov-file#github-action
44+

sai-trading/artifacts-lock.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[[artifacts]]
2+
# sai_trading_version: Version number for this tool (Nibiru/sai-trading)
3+
sai_trading_version = "0.0.1" # vX.Y.Z
4+
5+
# sai_perps_version: This is the version number for the Wasm bytecode files and
6+
# the sai-perps/evm-interface Solidity contract(s).
7+
sai_perps_version = "" # vX.Y.Z
8+
sai_perps_commit = "https://github.com/NibiruChain/sai-perps/tree/4a801ec7572e83597a88c11a9be9a48e26dfaf5e"

0 commit comments

Comments
 (0)