Skip to content

Commit

Permalink
Reorg (#19)
Browse files Browse the repository at this point in the history
* reorg

* move server

* update CI
  • Loading branch information
notV4l authored Oct 15, 2024
1 parent 284f498 commit e77640b
Show file tree
Hide file tree
Showing 25 changed files with 184 additions and 277 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,26 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Format
working-directory: ./server
run: cargo fmt --all -- --check

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clippy
working-directory: ./server
run: cargo clippy --fix
- name: Check for diff
working-directory: ./server
run: git diff --exit-code

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
working-directory: ./server
run: cargo build --verbose

test:
Expand All @@ -34,4 +38,5 @@ jobs:
- uses: Swatinem/rust-cache@v2

- name: Run tests
working-directory: ./server
run: cargo test --workspace --verbose
40 changes: 2 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
## Run server
## Documentation

`cargo run`

## Get server's public key

`GET http://0.0.0.0:3000/info`

## Get random numbers

```js
const response = await fetch("http://0.0.0.0:3000/stark_vrf", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ seed: ["0x5733e5c2c8030bc06888747525b1a1f0242ca770c9387b58a4529df0ca55499"] }),
});
const json = await response.json();
```

which will return:

```js
{
"result": {
"gamma_x": "0x6ac32f9b3c0bef88e4e1ba77d2f77fa603bbd4b42cca6405c5bdf7a16821d75",
"gamma_y": "0x50e3875635d84cb0038dbccb309b1134e101aee38c02001e456d5988b39fd43",
"c": "0x111fd321fb9b48c651a871fcfeea71a0f521ba04fe54f81caf2f407cba0979f",
"s": "0x437d280a8eb8e1e57c291af359738118c5b64b00ff5bd209d86ef83b051a2c6",
"sqrt_ratio": "0xa99242633a4f2a7b31c4c7d3bee93dad3bd946a68cfac753dbd4bbd837d8c0",
"rnd": "0x41c6b570b6720f205da6ef692021fe3625bbbab1ef5ea0ecea470e2d93b7982"
}
}
```

## Verify proof in Cairo

See https://github.com/dojoengine/stark-vrf
[Cartridge VRF Documentation](https://docs.cartridge.gg/vrf/overview)
22 changes: 11 additions & 11 deletions contracts/Scarb.lock → Scarb.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "cartridge_vrf"
version = "0.1.0"
dependencies = [
"openzeppelin",
"openzeppelin_testing",
"openzeppelin_utils",
"snforge_std",
"stark_vrf",
]

[[package]]
name = "openzeppelin"
version = "0.15.0-rc.0"
Expand Down Expand Up @@ -104,14 +115,3 @@ source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.26.0#50e
name = "stark_vrf"
version = "0.1.0"
source = "git+https://github.com/dojoengine/stark-vrf.git#96d6d2a88b1ef46c4a285d0ccc334237205edae3"

[[package]]
name = "vrf_contracts"
version = "0.1.0"
dependencies = [
"openzeppelin",
"openzeppelin_testing",
"openzeppelin_utils",
"snforge_std",
"stark_vrf",
]
22 changes: 16 additions & 6 deletions Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
[workspace]
members = ["contracts"]

[workspace.package]
[package]
name = "cartridge_vrf"
version = "0.1.0"
edition = "2023_10"

[workspace.dependencies]
[dependencies]
starknet = "2.7.0"
stark_vrf = { git = "https://github.com/dojoengine/stark-vrf.git" }
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", rev = "a13bae3" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.26.0" }
# Scripts are not supported for virtual workspaces.

[dev-dependencies]
openzeppelin_testing = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", rev = "a13bae3" }
openzeppelin_utils = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", rev = "a13bae3" }

[[target.starknet-contract]]
allowed-libfuncs-list.name = "experimental"

[lib]

[script]
test = "snforge test"
51 changes: 0 additions & 51 deletions contracts/README.md

This file was deleted.

24 changes: 0 additions & 24 deletions contracts/Scarb.toml

This file was deleted.

67 changes: 0 additions & 67 deletions contracts/dojo/buildVrfCalls.ts

This file was deleted.

52 changes: 0 additions & 52 deletions contracts/dojo/vrf_consumer_template.cairo

This file was deleted.

Loading

0 comments on commit e77640b

Please sign in to comment.