-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
7,111 additions
and
12 deletions.
There are no files selected for viewing
File renamed without changes.
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,53 @@ | ||
name: Test | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
DOJO_VERSION: v0.3.3 | ||
WORKING-DIRECTORY: examples | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
name: Check format | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: software-mansion/setup-scarb@v1 | ||
- name: Format | ||
working-directory: ${{ env.WORKING-DIRECTORY }} | ||
run: scarb fmt --package random --check | ||
shell: bash | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
name: Build package | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
- name: Build | ||
working-directory: ${{ env.WORKING-DIRECTORY }} | ||
run: sozo build | ||
shell: bash | ||
|
||
market: | ||
runs-on: ubuntu-latest | ||
name: Test market example | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
- name: Test | ||
working-directory: ${{ env.WORKING-DIRECTORY }} | ||
run: sozo test | ||
shell: bash | ||
|
||
projectile: | ||
runs-on: ubuntu-latest | ||
name: Test projectile example | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
- name: Test | ||
working-directory: ${{ env.WORKING-DIRECTORY }} | ||
run: sozo test | ||
shell: bash | ||
|
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,3 +1,3 @@ | ||
mod vec2; | ||
mod vector; | ||
mod matrix; | ||
mod matrix; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
target |
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,27 @@ | ||
# Code generated by scarb DO NOT EDIT. | ||
version = 1 | ||
|
||
[[package]] | ||
name = "cubit" | ||
version = "1.2.0" | ||
source = "git+/~https://github.com/influenceth/cubit?rev=b459053#b4590530d5aeae9aabd36740cc2a3d9e6adc5fde" | ||
|
||
[[package]] | ||
name = "dojo" | ||
version = "0.3.3" | ||
source = "git+/~https://github.com/dojoengine/dojo.git?tag=v0.3.3#3c9f109e667ca5d12739e6553fdb8261378f4ecf" | ||
dependencies = [ | ||
"dojo_plugin", | ||
] | ||
|
||
[[package]] | ||
name = "dojo_plugin" | ||
version = "0.3.3" | ||
|
||
[[package]] | ||
name = "market" | ||
version = "0.0.0" | ||
dependencies = [ | ||
"cubit", | ||
"dojo", | ||
] |
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,9 @@ | ||
[package] | ||
name = "market" | ||
version = "0.0.0" | ||
description = "Example of defi crate usage." | ||
homepage = "/~https://github.com/dojoengine/origami/tree/examples/market" | ||
|
||
[dependencies] | ||
cubit = { git = "/~https://github.com/influenceth/cubit", rev = "b459053" } | ||
dojo = { git = "/~https://github.com/dojoengine/dojo.git", tag = "v0.3.3" } |
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,17 @@ | ||
mod models { | ||
mod cash; | ||
mod item; | ||
mod liquidity; | ||
mod market; | ||
} | ||
|
||
mod systems { | ||
mod liquidity; | ||
mod trade; | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
mod setup; | ||
mod trade; | ||
} |
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,10 @@ | ||
// Starknet imports | ||
|
||
use starknet::ContractAddress; | ||
|
||
#[derive(Model, Copy, Drop, Serde)] | ||
struct Cash { | ||
#[key] | ||
player: ContractAddress, | ||
amount: u128, | ||
} |
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,12 @@ | ||
// Starknet imports | ||
|
||
use starknet::ContractAddress; | ||
|
||
#[derive(Model, Copy, Drop, Serde)] | ||
struct Item { | ||
#[key] | ||
player: ContractAddress, | ||
#[key] | ||
item_id: u32, | ||
quantity: u128, | ||
} |
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,56 @@ | ||
// Starknet imports | ||
|
||
use starknet::ContractAddress; | ||
|
||
// Dojo imports | ||
|
||
use dojo::database::schema::{Struct, Ty, SchemaIntrospection, Member, serialize_member}; | ||
|
||
// External imports | ||
|
||
use cubit::f128::types::fixed::Fixed; | ||
|
||
// Constants | ||
|
||
const SCALING_FACTOR: u128 = 10000; | ||
|
||
impl SchemaIntrospectionFixed of SchemaIntrospection<Fixed> { | ||
#[inline(always)] | ||
fn size() -> usize { | ||
2 | ||
} | ||
|
||
#[inline(always)] | ||
fn layout(ref layout: Array<u8>) { | ||
layout.append(128); | ||
layout.append(1); | ||
} | ||
|
||
#[inline(always)] | ||
fn ty() -> Ty { | ||
Ty::Struct( | ||
Struct { | ||
name: 'Fixed', | ||
attrs: array![].span(), | ||
children: array![ | ||
serialize_member( | ||
@Member { name: 'mag', ty: Ty::Primitive('u128'), attrs: array![].span() } | ||
), | ||
serialize_member( | ||
@Member { name: 'sign', ty: Ty::Primitive('bool'), attrs: array![].span() } | ||
) | ||
] | ||
.span() | ||
} | ||
) | ||
} | ||
} | ||
|
||
#[derive(Model, Copy, Drop, Serde)] | ||
struct Liquidity { | ||
#[key] | ||
player: ContractAddress, | ||
#[key] | ||
item_id: u32, | ||
shares: Fixed, | ||
} |
Oops, something went wrong.