Skip to content

Commit 5a99dd5

Browse files
hthieu1110hieu.haWaDadidou
authored
feat: setup cairo / starknet (#1490)
Co-authored-by: hieu.ha <hieu.ha@hsc.com.vn> Co-authored-by: ๖ۣۜDadidou <50441633+WaDadidou@users.noreply.github.com>
1 parent 30e9edd commit 5a99dd5

File tree

45 files changed

+4455
-86
lines changed

Some content is hidden

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

45 files changed

+4455
-86
lines changed

.github/workflows/cairo.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Cairo
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
merge_group:
9+
10+
jobs:
11+
check-cairo:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: foundry-rs/setup-snfoundry@v4
16+
- uses: software-mansion/setup-scarb@v1
17+
with:
18+
scarb-version: "2.9.2"
19+
20+
- uses: dtolnay/rust-toolchain@stable
21+
with:
22+
targets: wasm32-unknown-unknown
23+
24+
- name: Install cairo-lint
25+
run: cargo install scarb-cairo-lint --git https://github.com/software-mansion/cairo-lint
26+
27+
- name: Format
28+
run: make fmt.cairo
29+
30+
- name: Lint
31+
run: make lint.cairo
32+
33+
- name: Test
34+
run: make test.cairo
35+
36+
- name: Build
37+
run: make build.cairo
38+
39+
- name: Check diff
40+
run: git diff --exit-code

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,7 @@ cypress/screenshots
112112
# multi-app
113113
/app-selector.js
114114
/app.config.js
115+
116+
# starknet / cairo
117+
cairo/keystore.json
118+
.cairo

Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ GO?=go
44
GOFMT?=$(shell $(GO) env GOROOT)/bin/gofmt
55
CAT := $(if $(filter $(OS),Windows_NT),type,cat)
66

7+
PROJECT_ROOT=$(shell pwd)
8+
79
COSMWASM_CONTRACTS_DIR=rust/cw-contracts
810
INTERNAL_COSMWASM_CONTRACTS=$(wildcard $(COSMWASM_CONTRACTS_DIR)/*)
911

12+
STARKNET_CONTRACTS=$(wildcard cairo/contracts/*)
13+
STARKNET_CONTRACT_CLIENTS=packages/starknet-contract-clients
14+
1015
TOKEN_REPO=teritori-nfts
1116
TOKEN_PACKAGE=teritori-nft
1217
SQUAD_STAKING_PACKAGE=teritori-squad-staking
@@ -385,6 +390,58 @@ init-weshd-go:
385390
bump-app-build-number:
386391
npx tsx packages/scripts/app-build/bumpBuildNumber.ts $(shell echo $$(($$(git rev-list HEAD --count) + 10)))
387392

393+
.PHONY: test.cairo
394+
test.cairo:
395+
set -e ; \
396+
for file in $(STARKNET_CONTRACTS); do \
397+
echo "> Testing $${file}" ; \
398+
cd $${file} ; \
399+
snforge test ; \
400+
cd - ; \
401+
done
402+
403+
.PHONY: build.cairo
404+
build.cairo:
405+
set -e ; \
406+
for file in $(STARKNET_CONTRACTS); do \
407+
echo "> Building $${file}" ; \
408+
cd $${file} ; \
409+
scarb build ; \
410+
cd - ; \
411+
done
412+
413+
.PHONY: fmt.cairo
414+
fmt.cairo:
415+
set -e ; \
416+
for file in $(STARKNET_CONTRACTS); do \
417+
echo "> Building $${file}" ; \
418+
cd $${file} ; \
419+
scarb fmt --check; \
420+
cd - ; \
421+
done
422+
423+
.PHONY: lint.cairo
424+
lint.cairo:
425+
set -e ; \
426+
for file in $(STARKNET_CONTRACTS); do \
427+
echo "> Building $${file}" ; \
428+
cd $${file} ; \
429+
scarb cairo-lint ; \
430+
cd - ; \
431+
done
432+
433+
.PHONY: gen.starknet-clients
434+
gen.starknet-clients:
435+
set -e ; \
436+
for file in $(STARKNET_CONTRACTS); do \
437+
echo "> Generating client for $${file}" ; \
438+
cd $${file} ; \
439+
output=$(PROJECT_ROOT)/$(STARKNET_CONTRACT_CLIENTS)/$$(basename $${file}) ; \
440+
mkdir -p $${output} ; \
441+
starknet-compile --single-file src/lib.cairo $${output}/abi.json ; \
442+
cd - ; \
443+
done
444+
388445
.PHONY: test.rust
389446
test.rust:
390447
set -e ; \

assets/icons/argent-x.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/icons/networks/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import solana from "./solana.svg";
1313
import teritoriCircle from "./teritori-circle.svg";
1414
import teritori from "./teritori.svg";
1515
import polygon from "./polygon.svg";
16+
import starknet from "./starknet.svg";
17+
import starknetCircle from "./starknet-circle.svg";
1618

1719
export const networks = {
1820
teritori,
@@ -30,4 +32,6 @@ export const networks = {
3032
solanaCircle,
3133
gno,
3234
polygon,
35+
starknet,
36+
starknetCircle,
3337
};
Lines changed: 30 additions & 0 deletions
Loading

assets/icons/networks/starknet.svg

Lines changed: 30 additions & 0 deletions
Loading

cairo/account.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": 1,
3+
"variant": {
4+
"type": "open_zeppelin",
5+
"version": 1,
6+
"public_key": "0x5865f50c819ded17adf5e75af231419c458987526583d0e7d03fa22b577bd3f",
7+
"legacy": false
8+
},
9+
"deployment": {
10+
"status": "deployed",
11+
"class_hash": "0x4a444ef8caf8fa0db05da60bf0ad9bae264c73fa7e32c61d245406f5523174b",
12+
"address": "0x5592f41259100b2e67112545aa55f1c93007ea2a7fab02132d75fa69f268b5d"
13+
}
14+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
.snfoundry_cache/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Code generated by scarb DO NOT EDIT.
2+
version = 1
3+
4+
[[package]]
5+
name = "snforge_scarb_plugin"
6+
version = "0.35.1"
7+
source = "registry+https://scarbs.xyz/"
8+
checksum = "sha256:1b6d50abc7f306a06abf90649bcd60a3bc1cdf6d0dc21a9725c71b014a334bab"
9+
10+
[[package]]
11+
name = "snforge_std"
12+
version = "0.35.1"
13+
source = "registry+https://scarbs.xyz/"
14+
checksum = "sha256:e25cbeb9cbed6da8e14ab19ad0e7c1d888055dfee62978a845ce669cfaba5d93"
15+
dependencies = [
16+
"snforge_scarb_plugin",
17+
]
18+
19+
[[package]]
20+
name = "todo_list"
21+
version = "0.1.0"
22+
dependencies = [
23+
"snforge_std",
24+
]

0 commit comments

Comments
 (0)