Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,294 changes: 118 additions & 1,176 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ version = "1.0.9"
crate-type = ["cdylib", "rlib", "staticlib"]

[dependencies]
dojo-world = { git = "https://github.com/dojoengine/dojo", rev = "02557aee098cb5abf6431665c6af8d0588b64128" }
dojo-types = { git = "https://github.com/dojoengine/dojo", rev = "02557aee098cb5abf6431665c6af8d0588b64128"}
torii-client = { git = "https://github.com/dojoengine/dojo", rev = "02557aee098cb5abf6431665c6af8d0588b64128" }
dojo-world = { git = "https://github.com/dojoengine/dojo", rev = "d11a7ec" }
dojo-types = { git = "https://github.com/dojoengine/dojo", rev = "d11a7ec"}
torii-client = { git = "https://github.com/dojoengine/dojo", rev = "d11a7ec" }
torii-grpc = { git = "https://github.com/dojoengine/dojo", features = [
"client",
], rev = "02557aee098cb5abf6431665c6af8d0588b64128" }
torii-relay = { git = "https://github.com/dojoengine/dojo", rev = "02557aee098cb5abf6431665c6af8d0588b64128" }
], rev = "d11a7ec" }
torii-typed-data = { git = "https://github.com/dojoengine/dojo", rev = "d11a7ec" }
torii-relay = { git = "https://github.com/dojoengine/dojo", rev = "d11a7ec" }

starknet = "0.12.0"
starknet-crypto = "0.7.2"
Expand Down
8 changes: 4 additions & 4 deletions dojo.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@ typedef enum Primitive_Tag {
#if defined(TARGET_POINTER_WIDTH_32)
U256,
#endif
USize,
Bool,
Felt252,
ClassHash,
ContractAddress,
EthAddress,
} Primitive_Tag;

typedef struct Primitive {
Expand Down Expand Up @@ -499,9 +499,6 @@ typedef struct Primitive {
uint32_t u256[8];
};
#endif
struct {
uint32_t u_size;
};
struct {
bool bool_;
};
Expand All @@ -514,6 +511,9 @@ typedef struct Primitive {
struct {
struct FieldElement contract_address;
};
struct {
struct FieldElement eth_address;
};
};
} Primitive;

Expand Down
34 changes: 17 additions & 17 deletions dojo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ struct Primitive {
#if defined(TARGET_POINTER_WIDTH_32)
U256,
#endif
USize,
Bool,
Felt252,
ClassHash,
ContractAddress,
EthAddress,
};

struct I8_Body {
Expand Down Expand Up @@ -195,10 +195,6 @@ struct Primitive {
};
#endif

struct USize_Body {
uint32_t _0;
};

struct Bool_Body {
bool _0;
};
Expand All @@ -215,6 +211,10 @@ struct Primitive {
FieldElement _0;
};

struct EthAddress_Body {
FieldElement _0;
};

Tag tag;
union {
I8_Body i8;
Expand All @@ -231,11 +231,11 @@ struct Primitive {
#if defined(TARGET_POINTER_WIDTH_32)
U256_Body u256;
#endif
USize_Body u_size;
Bool_Body bool_;
Felt252_Body felt252;
ClassHash_Body class_hash;
ContractAddress_Body contract_address;
EthAddress_Body eth_address;
};

static Primitive I8(const int8_t &_0) {
Expand Down Expand Up @@ -380,17 +380,6 @@ struct Primitive {
}
#endif

static Primitive USize(const uint32_t &_0) {
Primitive result;
::new (&result.u_size._0) (uint32_t)(_0);
result.tag = Tag::USize;
return result;
}

bool IsUSize() const {
return tag == Tag::USize;
}

static Primitive Bool(const bool &_0) {
Primitive result;
::new (&result.bool_._0) (bool)(_0);
Expand Down Expand Up @@ -434,6 +423,17 @@ struct Primitive {
bool IsContractAddress() const {
return tag == Tag::ContractAddress;
}

static Primitive EthAddress(const FieldElement &_0) {
Primitive result;
::new (&result.eth_address._0) (FieldElement)(_0);
result.tag = Tag::EthAddress;
return result;
}

bool IsEthAddress() const {
return tag == Tag::EthAddress;
}
};

struct EnumOption {
Expand Down
4 changes: 2 additions & 2 deletions dojo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,11 @@ cdef extern from *:
U128,
U256,
U256,
USize,
Bool,
Felt252,
ClassHash,
ContractAddress,
EthAddress,

cdef struct Primitive:
Primitive_Tag tag;
Expand All @@ -307,11 +307,11 @@ cdef extern from *:
uint8_t u128[16];
uint64_t u256[4];
uint32_t u256[8];
uint32_t u_size;
bool bool_;
FieldElement felt252;
FieldElement class_hash;
FieldElement contract_address;
FieldElement eth_address;

cdef struct CArrayMemberValue:
MemberValue *data;
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.80.0"
channel = "1.81.0"
2 changes: 1 addition & 1 deletion src/c/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ use tokio::runtime::Runtime;
use tokio::time::sleep;
use tokio_stream::StreamExt;
use torii_client::client::Client as TClient;
use torii_relay::typed_data::TypedData;
use torii_relay::types::Message;
use torii_typed_data::TypedData;
use tower_http::cors::{AllowOrigin, CorsLayer};
use types::{EntityKeysClause, Event, IndexerUpdate, Policy, Struct, Token, TokenBalance};
use url::Url;
Expand Down
14 changes: 11 additions & 3 deletions src/c/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,11 +822,11 @@ pub enum Primitive {
U256([u64; 4]),
#[cfg(target_pointer_width = "32")]
U256([u32; 8]),
USize(u32),
Bool(bool),
Felt252(FieldElement),
ClassHash(FieldElement),
ContractAddress(FieldElement),
EthAddress(FieldElement),
}

impl From<&Primitive> for dojo_types::primitive::Primitive {
Expand All @@ -847,7 +847,6 @@ impl From<&Primitive> for dojo_types::primitive::Primitive {
dojo_types::primitive::Primitive::U128(Some(u128::from_be_bytes(*v)))
}
Primitive::U256(v) => dojo_types::primitive::Primitive::U256(Some((*v).into())),
Primitive::USize(v) => dojo_types::primitive::Primitive::USize(Some(*v)),
Primitive::Bool(v) => dojo_types::primitive::Primitive::Bool(Some(*v)),
Primitive::Felt252(v) => {
dojo_types::primitive::Primitive::Felt252(Some((&v.clone()).into()))
Expand All @@ -858,6 +857,9 @@ impl From<&Primitive> for dojo_types::primitive::Primitive {
Primitive::ContractAddress(v) => {
dojo_types::primitive::Primitive::ContractAddress(Some((&v.clone()).into()))
}
Primitive::EthAddress(v) => {
dojo_types::primitive::Primitive::EthAddress(Some((&v.clone()).into()))
}
}
}
}
Expand Down Expand Up @@ -897,7 +899,6 @@ impl From<&dojo_types::primitive::Primitive> for Primitive {
return Primitive::U256([0; 8]);
}
}
dojo_types::primitive::Primitive::USize(v) => Primitive::USize(v.unwrap_or(0)),
dojo_types::primitive::Primitive::Bool(v) => Primitive::Bool(v.unwrap_or(false)),
dojo_types::primitive::Primitive::Felt252(v) => {
if let Some(v) = v {
Expand All @@ -920,6 +921,13 @@ impl From<&dojo_types::primitive::Primitive> for Primitive {
Primitive::Felt252(FieldElement { data: [0; 32] })
}
}
dojo_types::primitive::Primitive::EthAddress(v) => {
if let Some(v) = v {
Primitive::EthAddress((&v.clone()).into())
} else {
Primitive::EthAddress(FieldElement { data: [0; 32] })
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use starknet::providers::{JsonRpcClient, Provider as _};
use starknet::signers::{LocalWallet, SigningKey, VerifyingKey};
use starknet_crypto::poseidon_hash_many;
use stream_cancel::{StreamExt as _, Tripwire};
use torii_relay::typed_data::TypedData;
use torii_relay::types::Message;
use torii_typed_data::TypedData;
use tsify_next::Tsify;
use wasm_bindgen::prelude::*;

Expand Down
6 changes: 4 additions & 2 deletions src/wasm/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,11 @@ pub enum Primitive {
U64(Option<u64>),
U128(Option<String>),
U256(Option<String>),
USize(Option<u32>),
Bool(Option<bool>),
Felt252(Option<String>),
ClassHash(Option<String>),
ContractAddress(Option<String>),
EthAddress(Option<String>),
}

impl From<&Primitive> for dojo_types::primitive::Primitive {
Expand All @@ -626,7 +626,6 @@ impl From<&Primitive> for dojo_types::primitive::Primitive {
Primitive::U64(Some(value)) => Self::U64(Some(*value)),
Primitive::U128(Some(value)) => Self::U128(Some(u128::from_str(value).unwrap())),
Primitive::U256(Some(value)) => Self::U256(Some(U256::from_be_hex(value.as_str()))),
Primitive::USize(Some(value)) => Self::USize(Some(*value)),
Primitive::Bool(Some(value)) => Self::Bool(Some(*value)),
Primitive::Felt252(Some(value)) => Self::Felt252(Some(Felt::from_str(value).unwrap())),
Primitive::ClassHash(Some(value)) => {
Expand All @@ -635,6 +634,9 @@ impl From<&Primitive> for dojo_types::primitive::Primitive {
Primitive::ContractAddress(Some(value)) => {
Self::ContractAddress(Some(Felt::from_str(value).unwrap()))
}
Primitive::EthAddress(Some(value)) => {
Self::EthAddress(Some(Felt::from_str(value).unwrap()))
}
_ => unimplemented!(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ fn primitive_value_json(primitive: Primitive) -> JsValue {
Primitive::U8(Some(value)) => JsValue::from_f64(value.into()),
Primitive::U16(Some(value)) => JsValue::from_f64(value.into()),
Primitive::U32(Some(value)) => JsValue::from_f64(value.into()),
Primitive::USize(Some(value)) => JsValue::from_f64(value.into()),
Primitive::I64(Some(value)) => JsValue::from_str(&format!("0x{value:064x}")),
Primitive::U64(Some(value)) => JsValue::from_str(&format!("0x{value:064x}")),
Primitive::I128(Some(value)) => JsValue::from_str(&format!("0x{value:064x}")),
Expand All @@ -109,6 +108,7 @@ fn primitive_value_json(primitive: Primitive) -> JsValue {
Primitive::Felt252(Some(value)) => JsValue::from_str(&format!("0x{value:064x}")),
Primitive::ClassHash(Some(value)) => JsValue::from_str(&format!("0x{value:064x}")),
Primitive::ContractAddress(Some(value)) => JsValue::from_str(&format!("0x{value:064x}")),
Primitive::EthAddress(Some(value)) => JsValue::from_str(&format!("0x{value:064x}")),
_ => JsValue::NULL,
}
}
Expand Down