Skip to content

Commit

Permalink
⬆️ Upgrade dojo to v0.7.2 (#77)
Browse files Browse the repository at this point in the history
* ⬆️ Upgrade dojo to v0.7.2

* 💄 Code format

* remove allow_ref_self

* remove useless code

---------

Co-authored-by: notV4l <[email protected]>
  • Loading branch information
bal7hazar and notV4l authored Jun 20, 2024
1 parent ab4fde3 commit c537966
Show file tree
Hide file tree
Showing 24 changed files with 38 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Origami CI
on: [push, pull_request]

env:
DOJO_VERSION: v0.7.1
SCARB_VERSION: v2.6.4
DOJO_VERSION: v0.7.2
SCARB_VERSION: nightly-2024-06-08

jobs:
check:
Expand Down
6 changes: 3 additions & 3 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ source = "git+https://github.com/notV4l/cubit.git?branch=cairo_2.7#cadb27aa62509

[[package]]
name = "dojo"
version = "0.7.1"
source = "git+https://github.com/dojoengine/dojo?tag=v0.7.1#c4a1feadf1d5c5ecf9593b50c1a2ca2856ae2313"
version = "0.7.2"
source = "git+https://github.com/dojoengine/dojo?tag=v0.7.2#3da5cad9fdd39b81551e0668015d88262e6c5fc4"
dependencies = [
"dojo_plugin",
]
Expand Down Expand Up @@ -60,7 +60,7 @@ dependencies = [

[[package]]
name = "origami"
version = "0.7.0"
version = "0.7.2"
dependencies = [
"cubit",
"dojo",
Expand Down
4 changes: 2 additions & 2 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ members = [
]

[workspace.package]
version = "0.7.1"
version = "0.7.2"
description = "Community-maintained libraries for Cairo"
homepage = "https://github.com/dojoengine/origami"
authors = ["[email protected]"]

[workspace.dependencies]
# cubit = { git = "https://github.com/influenceth/cubit.git" }
cubit = { git = "https://github.com/notV4l/cubit.git", branch = "cairo_2.7" }
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v0.7.1" }
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v0.7.2" }
origami = { path = "crates" }
token = { path = "token" }
7 changes: 1 addition & 6 deletions examples/hex_map/src/actions.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,11 @@ mod actions {
#[abi(embed_v0)]
impl ActionsImpl of IActions<ContractState> {
// ContractState is defined by system decorator expansion
fn spawn(ref world: IWorldDispatcher) { // Access the world dispatcher for reading.
let world = self.world_dispatcher.read();

fn spawn(ref world: IWorldDispatcher) {
set!(world, (Position { player: get_caller_address(), vec: Vec2 { x: 10, y: 10 } }));
}
// Moves player in the provided direction.
fn move(ref world: IWorldDispatcher, direction: Direction) {
// Access the world dispatcher for reading.
let world = self.world_dispatcher.read();

// Get the address of the current caller, possibly the player's address.
let player = get_caller_address();

Expand Down
8 changes: 0 additions & 8 deletions examples/matchmaker/src/helpers/bitmap.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ impl Bitmap of BitmapTrait {

/// The index of the most significant bit of the number,
/// where the least significant bit is at index 0 and the most significant bit is at index 255
/// Source:
///
///
/// https://github.com/lambdaclass/yet-another-swap/blob/main/crates/yas_core/src/libraries/bit_math.cairo
/// # Arguments * `x` - The value for which to compute the most significant bit, must be greater
/// than 0.
/// # Returns
Expand Down Expand Up @@ -111,10 +107,6 @@ impl Bitmap of BitmapTrait {

/// The index of the least significant bit of the number,
/// where the least significant bit is at index 0 and the most significant bit is at index 255
/// Source:
///
///
/// https://github.com/lambdaclass/yet-another-swap/blob/main/crates/yas_core/src/libraries/bit_math.cairo
/// # Arguments * `x` - The value for which to compute the least significant bit, must be
/// greater than 0.
/// # Returns
Expand Down
2 changes: 1 addition & 1 deletion governance/src/systems/timelock/contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod timelock {
assert!(
delay <= MAXIMUM_DELAY, "Timelock::initialize: Delay must not exceed maximum delay."
);
let world = self.world_dispatcher.read();

let contract = get_contract_address();
let curr_params = get!(world, contract, TimelockParams);
assert!(
Expand Down
3 changes: 2 additions & 1 deletion token/src/components/introspection/src5.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// adaptation of https://github.com/OpenZeppelin/cairo-contracts/blob/main/src/introspection/src5.cairo for dojo
/// adaptation of
/// https://github.com/OpenZeppelin/cairo-contracts/blob/main/src/introspection/src5.cairo for dojo

use starknet::ContractAddress;

Expand Down
4 changes: 3 additions & 1 deletion token/src/components/security/initializable.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// adaptation of https://github.com/OpenZeppelin/cairo-contracts/blob/main/src/security/initializable.cairo for dojo
/// adaptation of
/// https://github.com/OpenZeppelin/cairo-contracts/blob/main/src/security/initializable.cairo for
/// dojo

use starknet::ContractAddress;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait IERC20BalanceMockInit<TState> {
fn initializer(ref self: TState, initial_supply: u256, recipient: ContractAddress,);
}

#[dojo::contract(allow_ref_self)]
#[dojo::contract]
mod erc20_balance_mock {
use starknet::ContractAddress;
use token::components::token::erc20::erc20_allowance::erc20_allowance_component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait IERC20BridgeableMockInit<TState> {
);
}

#[dojo::contract(allow_ref_self)]
#[dojo::contract]
mod erc20_bridgeable_mock {
use starknet::ContractAddress;
use starknet::{get_caller_address, get_contract_address};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ trait IERC721BalanceMockInit<TState> {
fn initializer(ref self: TState, recipient: ContractAddress, token_id: u256);
}

#[dojo::contract(allow_ref_self)]
#[dojo::contract]
mod erc721_balance_mock {
use starknet::ContractAddress;
use token::components::token::erc721::erc721_approval::erc721_approval_component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait IERC721ReceiverMockInit<TState> {
fn initializer(ref self: TState);
}

#[dojo::contract(allow_ref_self)]
#[dojo::contract]
mod erc721_receiver_mock {
use token::components::introspection::src5::src5_component;
use token::components::token::erc721::erc721_receiver::erc721_receiver_component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn test_erc20_allowance_approve_to_zero() {
}

//
// spend_allowance
// spend_allowance
//

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ fn test_transfer_from() {
assert_event_approval(erc20_balance_mock.contract_address, OWNER(), SPENDER(), 0);
assert_only_event_transfer(erc20_balance_mock.contract_address, OWNER(), RECIPIENT(), VALUE);

// drop StoreSetRecord ERC20AllowanceModel
// drop StoreSetRecord ERC20AllowanceModel
utils::drop_event(world.contract_address);
assert_event_approval(world.contract_address, OWNER(), SPENDER(), 0);
// drop StoreSetRecord ERC20BalanceModel x2
Expand Down Expand Up @@ -258,7 +258,7 @@ fn test_transfer_from_from_zero_address() {


//
// transferFrom
// transferFrom
//

#[test]
Expand All @@ -277,7 +277,7 @@ fn test_transferFrom() {
assert_event_approval(erc20_balance_mock.contract_address, OWNER(), SPENDER(), 0);
assert_only_event_transfer(erc20_balance_mock.contract_address, OWNER(), RECIPIENT(), VALUE);

// drop StoreSetRecord ERC20AllowanceModel
// drop StoreSetRecord ERC20AllowanceModel
utils::drop_event(world.contract_address);
assert_event_approval(world.contract_address, OWNER(), SPENDER(), 0);
// drop StoreSetRecord ERC20BalanceModel x2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn setup() -> erc20_bridgeable_mock::ContractState {
}

//
// initializer
// initializer
//

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fn test_transfer_from() {
erc721_balance_mock.contract_address, OWNER(), RECIPIENT(), TOKEN_ID
);

// // drop StoreSetRecord ERC721TokenApprovalModel
// // drop StoreSetRecord ERC721TokenApprovalModel
utils::drop_event(world.contract_address);
// // drop StoreSetRecord ERC721BalanceModel x3 - incl mint
utils::drop_event(world.contract_address);
Expand Down Expand Up @@ -289,7 +289,7 @@ fn test_safe_transfer_from() {
TOKEN_ID
);

// // drop StoreSetRecord ERC721TokenApprovalModel
// // drop StoreSetRecord ERC721TokenApprovalModel
utils::drop_event(world.contract_address);
// // drop StoreSetRecord ERC721BalanceModel x3 - incl mint
utils::drop_event(world.contract_address);
Expand All @@ -307,7 +307,7 @@ fn test_safe_transfer_from() {
}

//
// transferFrom
// transferFrom
//

#[test]
Expand All @@ -328,7 +328,7 @@ fn test_transferFrom() {
erc721_balance_mock.contract_address, OWNER(), RECIPIENT(), TOKEN_ID
);

// // drop StoreSetRecord ERC721TokenApprovalModel
// // drop StoreSetRecord ERC721TokenApprovalModel
utils::drop_event(world.contract_address);
// // drop StoreSetRecord ERC721BalanceModel x3 - incl mint
utils::drop_event(world.contract_address);
Expand Down Expand Up @@ -364,7 +364,7 @@ fn test_safeTransferFrom() {
TOKEN_ID
);

// // drop StoreSetRecord ERC721TokenApprovalModel
// // drop StoreSetRecord ERC721TokenApprovalModel
utils::drop_event(world.contract_address);
// // drop StoreSetRecord ERC721BalanceModel x3 - incl mint
utils::drop_event(world.contract_address);
Expand Down
2 changes: 1 addition & 1 deletion token/src/components/token/erc721/erc721_enumerable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use starknet::ContractAddress;
///
/// Model
///
///
///

#[dojo::model]
#[derive(Copy, Drop, Serde)]
Expand Down
2 changes: 1 addition & 1 deletion token/src/erc1155/tests.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ fn test__burn_more_than_balance() {


//
// Helpers
// Helpers
//

fn assert_state_before_transfer(
Expand Down
2 changes: 1 addition & 1 deletion token/src/presets/erc20/bridgeable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ trait IERC20BridgeableInitializer<TState> {
);
}

#[dojo::contract(allow_ref_self)]
#[dojo::contract]
mod ERC20Bridgeable {
use integer::BoundedInt;
use starknet::ContractAddress;
Expand Down
6 changes: 3 additions & 3 deletions token/src/presets/erc20/tests_bridgeable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn setup() -> (IWorldDispatcher, IERC20BridgeablePresetDispatcher) {


//
// initializer
// initializer
//

#[test]
Expand Down Expand Up @@ -141,7 +141,7 @@ fn test_approve() {


//
// transfer
// transfer
//

#[test]
Expand Down Expand Up @@ -186,7 +186,7 @@ fn test_transfer_from() {
assert_event_approval(erc20_bridgeable.contract_address, OWNER(), SPENDER(), 0);
assert_only_event_transfer(erc20_bridgeable.contract_address, OWNER(), RECIPIENT(), VALUE);

// drop StoreSetRecord ERC20AllowanceModel
// drop StoreSetRecord ERC20AllowanceModel
utils::drop_event(world.contract_address);
assert_event_approval(world.contract_address, OWNER(), SPENDER(), 0);
// drop StoreSetRecord ERC20BalanceModel x2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ trait IERC721EnumMintBurn<TState> {
fn burn(ref self: TState, token_id: u256);
}

#[dojo::contract(allow_ref_self)]
#[dojo::contract]
mod ERC721EnumMintBurn {
use starknet::ContractAddress;
use starknet::{get_contract_address, get_caller_address};
Expand Down
2 changes: 1 addition & 1 deletion token/src/presets/erc721/mintable_burnable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ trait IERC721MintableBurnableMintBurn<TState> {
fn burn(ref self: TState, token_id: u256);
}

#[dojo::contract(allow_ref_self)]
#[dojo::contract]
mod ERC721MintableBurnable {
use starknet::ContractAddress;
use starknet::{get_caller_address, get_contract_address};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn setup() -> (IWorldDispatcher, IERC721EnumMintBurnPresetDispatcher) {
}

//
// initializer
// initializer
//

#[test]
Expand Down
2 changes: 1 addition & 1 deletion token/src/presets/erc721/tests_mintable_burnable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn setup() -> (IWorldDispatcher, IERC721MintableBurnablePresetDispatcher) {
}

//
// initializer
// initializer
//

#[test]
Expand Down

0 comments on commit c537966

Please sign in to comment.