Skip to content

Commit

Permalink
Upgrade to dojo 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wraitii committed Sep 6, 2023
1 parent 60dc1b6 commit 315efe6
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "briq_protocol"
version = "2.0.0"
cairo-version = "2.1.1"
cairo-version = "2.2.0"

[cairo]
sierra-replace-ids = true
Expand Down
39 changes: 26 additions & 13 deletions src/attributes/attribute_group.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ impl AttributeGroupImpl of AttributeGroupTrait {
}
}

#[derive(Drop, PartialEq, starknet::Event)]
struct AttributeGroupCreated {
attribute_group_id: u64,
owner: ContractAddress,
system: felt252,
}

#[derive(Drop, PartialEq, starknet::Event)]
struct AttributeGroupUpdated {
attribute_group_id: u64,
owner: ContractAddress,
system: felt252,
}

#[event]
#[derive(Drop, PartialEq, starknet::Event)]
enum Event {
AttributeGroupCreated: AttributeGroupCreated,
AttributeGroupUpdated: AttributeGroupUpdated,
}

#[derive(Clone, Drop, Serde)]
struct CreateAttributeGroupParams {
Expand Down Expand Up @@ -122,13 +142,9 @@ mod create_attribute_group {
CreateAttributeGroupParams, AttributeGroupOwner, AttributeGroupTrait, AttributeGroup
};

#[derive(Drop, starknet::Event)]
struct AttributeGroupCreated {
attribute_group_id: u64,
owner: ContractAddress,
system: felt252,

}
use super::{AttributeGroupCreated};
#[event]
use super::Event;

fn execute(ctx: Context, data: CreateAttributeGroupParams) {
// TODO: check ctx.origin is actually the origin
Expand Down Expand Up @@ -204,12 +220,9 @@ mod update_attribute_group {
UpdateAttributeGroupParams, AttributeGroupOwner, AttributeGroupTrait, AttributeGroup
};

#[derive(Drop, starknet::Event)]
struct AttributeGroupUpdated {
attribute_group_id: u64,
owner: ContractAddress,
system: felt252,
}
use super::{AttributeGroupUpdated};
#[event]
use super::Event;

fn execute(ctx: Context, data: UpdateAttributeGroupParams) {
// TODO: check ctx.origin is actually the origin
Expand Down
11 changes: 9 additions & 2 deletions src/attributes/attributes.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,27 @@ use briq_protocol::attributes::attribute_group::{

use debug::PrintTrait;

#[derive(Drop, starknet::Event)]
#[derive(Drop, PartialEq, starknet::Event)]
struct AttributeAssigned {
set_token_id: ContractAddress,
attribute_group_id: u64,
attribute_id: u64
}

#[derive(Drop, starknet::Event)]
#[derive(Drop, PartialEq, starknet::Event)]
struct AttributeRemoved {
set_token_id: ContractAddress,
attribute_group_id: u64,
attribute_id: u64
}

#[event]
#[derive(Drop, PartialEq, starknet::Event)]
enum Event {
AttributeAssigned: AttributeAssigned,
AttributeRemoved: AttributeRemoved,
}

#[derive(Drop, Serde)]
struct AttributeAssignData {
set_owner: ContractAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/briq_booklet.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod briq_booklet {
ERC1155SafeBatchTransferFromParams, ERC1155MintParams, ERC1155BurnParams
};
use dojo_erc::erc_common::utils::{
to_calldata, ToCallDataTrait, system_calldata, PartialEqArray
to_calldata, ToCallDataTrait, system_calldata
};

use briq_protocol::world_config::AdminTrait;
Expand Down
10 changes: 9 additions & 1 deletion src/briq_factory/systems.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ use briq_protocol::briq_factory::constants::{

use briq_protocol::briq_factory::components::{BriqFactoryStore, BriqFactoryTrait};

#[derive(Drop, starknet::Event)]
#[derive(Drop, PartialEq, starknet::Event)]
struct BriqsBought {
buyer: ContractAddress,
amount: u32,
price: u128
}

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
BriqsBought: BriqsBought,
}

#[derive(Drop, Serde)]
struct BriqFactoryBuyParams {
material: u64,
Expand All @@ -43,6 +49,8 @@ mod BriqFactoryMint {
use super::{
BriqsBought, BriqFactoryTrait, BriqFactoryBuyParams, DECIMALS, MIN_PURCHASE, BRIQ_MATERIAL
};
#[event]
use super::Event;
use briq_protocol::world_config::AdminTrait;


Expand Down
1 change: 0 additions & 1 deletion src/briq_token.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ mod BriqToken {
use starknet::{ContractAddress, ClassHash, get_caller_address, get_contract_address};
use traits::{Into, TryInto};
use zeroable::Zeroable;
use briq_protocol::utils::PartialEqArray;
use briq_protocol::world_config::AdminTrait;

use serde::Serde;
Expand Down
2 changes: 1 addition & 1 deletion src/migrate.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod migrate_assets {
use dojo::world::Context;
use super::MigrateAssetsParams;

use core::pedersen;
use core::pedersen::pedersen;
use core::ecdsa::check_ecdsa_signature;
use traits::Into;
use starknet::ContractAddress;
Expand Down
1 change: 1 addition & 0 deletions src/set_nft/systems.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use array::SpanTrait;
use option::{Option, OptionTrait};
use zeroable::Zeroable;

use core::pedersen::pedersen;
use dojo::world::{Context, IWorldDispatcher, IWorldDispatcherTrait};

use dojo_erc::erc1155::components::{OperatorApproval, ERC1155Balance, ERC1155BalanceTrait};
Expand Down
6 changes: 0 additions & 6 deletions src/tests/test_migrate.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@ use dojo_erc::erc721::interface::IERC721DispatcherTrait;
use dojo_erc::erc1155::interface::{IERC1155DispatcherTrait};
use dojo_erc::erc1155::components::ERC1155BalanceTrait;


use briq_protocol::tests::test_utils::{
WORLD_ADMIN, DEFAULT_OWNER, ZERO, DefaultWorld, deploy_default_world, mint_briqs, impersonate
};
use briq_protocol::attributes::attribute_group::{CreateAttributeGroupData, AttributeGroupOwner};
use briq_protocol::shape_verifier::RegisterShapeVerifierData;
use briq_protocol::types::{FTSpec, ShapeItem, ShapePacking, PackedShapeItem, AttributeItem};
use briq_protocol::world_config::get_world_config;
use briq_protocol::utils::IntoContractAddressU256;
use briq_protocol::cumulative_balance::{CUM_BALANCE_TOKEN, CB_ATTRIBUTES, CB_BRIQ};

use debug::PrintTrait;

Expand Down
31 changes: 0 additions & 31 deletions src/utils.cairo
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
use traits::{Into, TryInto, Default, PartialEq};
use array::ArrayTrait;
use starknet::ContractAddress;
// TODO : remove when included in corelib

impl PartialEqArray<T, impl TPEq: PartialEq<T>> of PartialEq<Array<T>> {
fn eq(lhs: @Array<T>, rhs: @Array<T>) -> bool {
if lhs.len() != rhs.len() {
return false;
};

let mut is_eq = true;
let mut i = 0;
loop {
if lhs.len() == i {
break;
};
if lhs.at(i) != rhs.at(i) {
is_eq = false;
break;
};

i += 1;
};

is_eq
}

fn ne(lhs: @Array<T>, rhs: @Array<T>) -> bool {
!PartialEqArray::eq(lhs, rhs)
}
}



impl IntoContractAddressU256 of Into::<ContractAddress, u256> {
fn into(self: ContractAddress) -> u256 {
Expand Down

0 comments on commit 315efe6

Please sign in to comment.