Skip to content

Commit fb5dc62

Browse files
authored
⬆️ Upgrade cairo and dojo versions (#120)
1 parent 8e9a2bd commit fb5dc62

File tree

27 files changed

+190
-329
lines changed

27 files changed

+190
-329
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
pull_request:
88

99
env:
10-
DOJO_VERSION: v1.0.1
11-
SCARB_VERSION: 2.8.4
10+
DOJO_VERSION: v1.1.2
11+
SCARB_VERSION: 2.9.2
1212

1313
jobs:
1414
check:
@@ -40,6 +40,9 @@ jobs:
4040
name: Test origami_algebra
4141
steps:
4242
- uses: actions/checkout@v4
43+
- uses: software-mansion/setup-scarb@v1
44+
with:
45+
scarb-version: ${{ env.SCARB_VERSION }}
4346
- uses: ./.github/actions/setup
4447
- name: Test
4548
run: sozo test --package origami_algebra
@@ -51,6 +54,9 @@ jobs:
5154
name: Test origami_defi
5255
steps:
5356
- uses: actions/checkout@v4
57+
- uses: software-mansion/setup-scarb@v1
58+
with:
59+
scarb-version: ${{ env.SCARB_VERSION }}
5460
- uses: ./.github/actions/setup
5561
- name: Test
5662
run: sozo test --package origami_defi
@@ -62,6 +68,9 @@ jobs:
6268
name: Test origami_map
6369
steps:
6470
- uses: actions/checkout@v4
71+
- uses: software-mansion/setup-scarb@v1
72+
with:
73+
scarb-version: ${{ env.SCARB_VERSION }}
6574
- uses: ./.github/actions/setup
6675
- name: Test
6776
run: sozo test --package origami_map
@@ -73,6 +82,9 @@ jobs:
7382
name: Test origami_random
7483
steps:
7584
- uses: actions/checkout@v4
85+
- uses: software-mansion/setup-scarb@v1
86+
with:
87+
scarb-version: ${{ env.SCARB_VERSION }}
7688
- uses: ./.github/actions/setup
7789
- name: Test
7890
run: sozo test --package origami_random
@@ -84,6 +96,9 @@ jobs:
8496
name: Test origami_rating
8597
steps:
8698
- uses: actions/checkout@v4
99+
- uses: software-mansion/setup-scarb@v1
100+
with:
101+
scarb-version: ${{ env.SCARB_VERSION }}
87102
- uses: ./.github/actions/setup
88103
- name: Test
89104
run: sozo test --package origami_rating
@@ -95,6 +110,9 @@ jobs:
95110
name: Test origami_security
96111
steps:
97112
- uses: actions/checkout@v4
113+
- uses: software-mansion/setup-scarb@v1
114+
with:
115+
scarb-version: ${{ env.SCARB_VERSION }}
98116
- uses: ./.github/actions/setup
99117
- name: Test
100118
run: sozo test --package origami_security

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
scarb 2.8.4
1+
scarb 2.9.2

Scarb.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,34 @@ version = 1
44
[[package]]
55
name = "cubit"
66
version = "1.3.0"
7-
source = "git+https://github.com/bal7hazar/cubit?branch=cairo-2.8.4#6bce623d5c735c097be47a4045c0e0432bad38e7"
7+
source = "git+https://github.com/bengineer42/cubit?branch=bump-cairo-gt-2.8#32a20af893b3e26e6f5cf436c509457d6500ca5c"
88

99
[[package]]
1010
name = "origami_algebra"
11-
version = "1.0.0-rc.2"
11+
version = "1.1.2"
1212
dependencies = [
1313
"cubit",
1414
]
1515

1616
[[package]]
1717
name = "origami_defi"
18-
version = "1.0.0-rc.2"
18+
version = "1.1.2"
1919
dependencies = [
2020
"cubit",
2121
]
2222

2323
[[package]]
2424
name = "origami_map"
25-
version = "1.0.0-rc.2"
25+
version = "1.1.2"
2626

2727
[[package]]
2828
name = "origami_random"
29-
version = "1.0.0-rc.2"
29+
version = "1.1.2"
3030

3131
[[package]]
3232
name = "origami_rating"
33-
version = "1.0.0-rc.2"
33+
version = "1.1.2"
3434

3535
[[package]]
3636
name = "origami_security"
37-
version = "1.0.0-rc.2"
37+
version = "1.1.2"

Scarb.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ members = [
99
]
1010

1111
[workspace.package]
12-
version = "1.0.0-rc.2"
12+
version = "1.1.2"
13+
edition = "2024_07"
1314

1415
[workspace.dependencies]
15-
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.1" }
16+
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.1.2" }
1617
# dojo = { path = "../dojo/crates/dojo-core" }
17-
cubit = { git = "https://github.com/bal7hazar/cubit", branch = "cairo-2.8.4" }
18-
starknet = "^2.8.4"
19-
cairo_test = "^2.8.4"
20-
# Scripts are not supported for virtual workspaces.
18+
cubit = { git = "https://github.com/bengineer42/cubit", branch = "bump-cairo-gt-2.8" }
19+
starknet = "^2.9.2"
20+
cairo_test = "^2.9.2"

crates/Scarb.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
[package]
22
name = "origami"
33
version.workspace = true
4+
edition.workspace = true
45
authors.workspace = true
56
description.workspace = true
67
homepage = "https://github.com/dojoengine/origami/tree/main/crates"
78

89
[dependencies]
910
cubit.workspace = true
1011
dojo.workspace = true
12+
cairo_test.workspace = true

crates/algebra/Scarb.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[package]
22
name = "origami_algebra"
33
version.workspace = true
4+
edition.workspace = true
45
description = "Algebra library for Dojo based games."
56
homepage = "https://github.com/dojoengine/origami/tree/main/crates/algebra"
67

@@ -9,3 +10,4 @@ homepage = "https://github.com/dojoengine/origami/tree/main/crates/algebra"
910

1011
[dependencies]
1112
cubit.workspace = true
13+
cairo_test.workspace = true

crates/algebra/src/matrix.cairo

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use zeroable::Zeroable;
1+
use core::num::traits::Zero;
22
use core::ops::{AddAssign, SubAssign};
33

44

@@ -10,9 +10,9 @@ struct Matrix<T> {
1010
}
1111

1212
mod errors {
13-
const INVALID_INDEX: felt252 = 'Matrix: index out of bounds';
14-
const INVALID_DIMENSION: felt252 = 'Matrix: invalid dimension';
15-
const INVALID_MATRIX_INVERSION: felt252 = 'Matrix: matrix not invertible';
13+
pub const INVALID_INDEX: felt252 = 'Matrix: index out of bounds';
14+
pub const INVALID_DIMENSION: felt252 = 'Matrix: invalid dimension';
15+
pub const INVALID_MATRIX_INVERSION: felt252 = 'Matrix: matrix not invertible';
1616
}
1717

1818
trait MatrixTrait<T> {
@@ -38,7 +38,7 @@ impl MatrixImpl<
3838
+Sub<T>,
3939
+SubAssign<T, T>,
4040
+Neg<T>,
41-
+Zeroable<T>,
41+
+Zero<T>,
4242
+Copy<T>,
4343
+Drop<T>,
4444
> of MatrixTrait<T> {
@@ -102,7 +102,7 @@ impl MatrixImpl<
102102
return (self.get(0, 0) * self.get(1, 1)) - (self.get(0, 1) * self.get(1, 0));
103103
}
104104

105-
let mut det: T = Zeroable::zero();
105+
let mut det: T = Zero::zero();
106106
let mut col: u8 = 0;
107107
loop {
108108
if col >= self.cols {
@@ -166,7 +166,7 @@ impl MatrixAdd<
166166
+Sub<T>,
167167
+SubAssign<T, T>,
168168
+Neg<T>,
169-
+Zeroable<T>,
169+
+Zero<T>,
170170
+Copy<T>,
171171
+Drop<T>,
172172
> of Add<Matrix<T>> {
@@ -198,7 +198,7 @@ impl MatrixSub<
198198
+Sub<T>,
199199
+SubAssign<T, T>,
200200
+Neg<T>,
201-
+Zeroable<T>,
201+
+Zero<T>,
202202
+Copy<T>,
203203
+Drop<T>,
204204
> of Sub<Matrix<T>> {
@@ -230,7 +230,7 @@ impl MatrixMul<
230230
+Sub<T>,
231231
+SubAssign<T, T>,
232232
+Neg<T>,
233-
+Zeroable<T>,
233+
+Zero<T>,
234234
+Copy<T>,
235235
+Drop<T>,
236236
> of Mul<Matrix<T>> {
@@ -248,7 +248,7 @@ impl MatrixMul<
248248
let row = index / rhs.cols;
249249
let col = index % rhs.cols;
250250

251-
let mut sum: T = Zeroable::zero();
251+
let mut sum: T = Zero::zero();
252252
let mut k: u8 = 0;
253253
loop {
254254
if k == lhs.cols {
@@ -268,30 +268,7 @@ impl MatrixMul<
268268

269269
#[cfg(test)]
270270
mod tests {
271-
use core::traits::TryInto;
272271
use super::{Matrix, MatrixTrait};
273-
use debug::PrintTrait;
274-
275-
impl I128Zeroable of Zeroable<i128> {
276-
fn zero() -> i128 {
277-
0
278-
}
279-
fn is_zero(self: i128) -> bool {
280-
self == 0
281-
}
282-
fn is_non_zero(self: i128) -> bool {
283-
self != 0
284-
}
285-
}
286-
287-
// impl I128Div of Div<i128> {
288-
// fn div(lhs: i128, rhs: i128) -> i128 {
289-
// let lhs_u256: u256 = Into::<felt252, u256>::into(lhs.into());
290-
// let rhs_u256: u256 = Into::<felt252, u256>::into(rhs.into());
291-
// let div: felt252 = (lhs_u256 / rhs_u256).try_into().unwrap();
292-
// div.try_into().unwrap()
293-
// }
294-
// }
295272

296273
#[test]
297274
fn test_matrix_get() {

crates/algebra/src/vec2.cairo

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use cubit::f128::types::fixed::{Fixed, FixedTrait, ONE_u128};
1+
use cubit::f128::types::fixed::{FixedTrait, ONE_u128};
22

33
struct Vec2<T> {
44
x: T,
5-
y: T
5+
y: T,
66
}
77

88
impl Vec2Copy<T, impl TCopy: Copy<T>> of Copy<Vec2<T>>;
@@ -78,22 +78,22 @@ impl Vec2Impl<T, impl TCopy: Copy<T>, impl TDrop: Drop<T>> of Vec2Trait<T> {
7878
/// Vec2<T> -> Vec2<T>
7979
#[inline(always)]
8080
fn xx(self: Vec2<T>) -> Vec2<T> {
81-
Vec2 { x: self.x, y: self.x, }
81+
Vec2 { x: self.x, y: self.x }
8282
}
8383

8484
#[inline(always)]
8585
fn xy(self: Vec2<T>) -> Vec2<T> {
86-
Vec2 { x: self.x, y: self.y, }
86+
Vec2 { x: self.x, y: self.y }
8787
}
8888

8989
#[inline(always)]
9090
fn yx(self: Vec2<T>) -> Vec2<T> {
91-
Vec2 { x: self.y, y: self.x, }
91+
Vec2 { x: self.y, y: self.x }
9292
}
9393

9494
#[inline(always)]
9595
fn yy(self: Vec2<T>) -> Vec2<T> {
96-
Vec2 { x: self.y, y: self.y, }
96+
Vec2 { x: self.y, y: self.y }
9797
}
9898
}
9999

crates/algebra/src/vector.cairo

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
use core::ops::AddAssign;
2+
use core::num::traits::Zero;
23

34
#[derive(Copy, Drop)]
45
struct Vector<T> {
56
data: Span<T>,
67
}
78

89
mod errors {
9-
const INVALID_INDEX: felt252 = 'Vector: index out of bounds';
10-
const INVALID_SIZE: felt252 = 'Vector: invalid size';
10+
pub const INVALID_INDEX: felt252 = 'Vector: index out of bounds';
11+
pub const INVALID_SIZE: felt252 = 'Vector: invalid size';
1112
}
1213

1314
trait VectorTrait<T> {
@@ -20,7 +21,7 @@ trait VectorTrait<T> {
2021
fn dot(self: Vector<T>, vector: Vector<T>) -> T;
2122
}
2223

23-
impl VectorImpl<T, +Mul<T>, +AddAssign<T, T>, +Zeroable<T>, +Copy<T>, +Drop<T>,> of VectorTrait<T> {
24+
impl VectorImpl<T, +Mul<T>, +AddAssign<T, T>, +Zero<T>, +Copy<T>, +Drop<T>> of VectorTrait<T> {
2425
fn new(data: Span<T>) -> Vector<T> {
2526
Vector { data }
2627
}
@@ -37,7 +38,7 @@ impl VectorImpl<T, +Mul<T>, +AddAssign<T, T>, +Zeroable<T>, +Copy<T>, +Drop<T>,>
3738
// [Check] Dimesions are compatible
3839
assert(self.size() == vector.size(), errors::INVALID_SIZE);
3940
// [Compute] Dot product in a loop
40-
let mut value = Zeroable::zero();
41+
let mut value = Zero::zero();
4142
loop {
4243
match self.data.pop_front() {
4344
Option::Some(x_value) => {
@@ -51,7 +52,7 @@ impl VectorImpl<T, +Mul<T>, +AddAssign<T, T>, +Zeroable<T>, +Copy<T>, +Drop<T>,>
5152
}
5253

5354
impl VectorAdd<
54-
T, +Mul<T>, +AddAssign<T, T>, +Add<T>, +Zeroable<T>, +Copy<T>, +Drop<T>,
55+
T, +Mul<T>, +AddAssign<T, T>, +Add<T>, +Zero<T>, +Copy<T>, +Drop<T>,
5556
> of Add<Vector<T>> {
5657
fn add(mut lhs: Vector<T>, mut rhs: Vector<T>) -> Vector<T> {
5758
// [Check] Dimesions are compatible
@@ -71,7 +72,7 @@ impl VectorAdd<
7172
}
7273

7374
impl VectorSub<
74-
T, +Mul<T>, +AddAssign<T, T>, +Sub<T>, +Zeroable<T>, +Copy<T>, +Drop<T>,
75+
T, +Mul<T>, +AddAssign<T, T>, +Sub<T>, +Zero<T>, +Copy<T>, +Drop<T>,
7576
> of Sub<Vector<T>> {
7677
fn sub(mut lhs: Vector<T>, mut rhs: Vector<T>) -> Vector<T> {
7778
// [Check] Dimesions are compatible
@@ -92,26 +93,8 @@ impl VectorSub<
9293

9394
#[cfg(test)]
9495
mod tests {
95-
// Core imports
96-
97-
use debug::PrintTrait;
98-
99-
// Local imports
100-
10196
use super::{Vector, VectorTrait};
10297

103-
impl I128Zeroable of Zeroable<i128> {
104-
fn zero() -> i128 {
105-
0
106-
}
107-
fn is_zero(self: i128) -> bool {
108-
self == 0
109-
}
110-
fn is_non_zero(self: i128) -> bool {
111-
self != 0
112-
}
113-
}
114-
11598
#[test]
11699
fn test_vector_get() {
117100
let mut vector: Vector = VectorTrait::new(array![1, 2, 3, 4].span());

crates/defi/Scarb.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[package]
22
name = "origami_defi"
33
version.workspace = true
4+
edition.workspace = true
45
description = "DeFi library for Dojo based games."
56
homepage = "https://github.com/dojoengine/origami/tree/main/crates/defi"
6-
edition = "2024_07"
77

88
[dependencies]
99
cubit.workspace = true
1010
starknet.workspace = true
11+
cairo_test.workspace = true

0 commit comments

Comments
 (0)