Skip to content

Commit

Permalink
fix metadata resource to take the first one in account explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Oct 11, 2023
1 parent 399e4c6 commit 45c5558
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
52 changes: 46 additions & 6 deletions crates/torii/client/abigen/world.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@
{
"type": "function",
"name": "metadata_uri",
"inputs": [],
"inputs": [
{
"name": "resource",
"type": "core::felt252"
}
],
"outputs": [
{
"type": "core::array::Span::<core::felt252>"
Expand All @@ -81,6 +86,10 @@
"type": "function",
"name": "set_metadata_uri",
"inputs": [
{
"name": "resource",
"type": "core::felt252"
},
{
"name": "uri",
"type": "core::array::Span::<core::felt252>"
Expand Down Expand Up @@ -315,7 +324,7 @@
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "target",
"name": "resource",
"type": "core::felt252"
}
],
Expand All @@ -335,7 +344,7 @@
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "target",
"name": "resource",
"type": "core::felt252"
}
],
Expand All @@ -351,7 +360,7 @@
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "target",
"name": "resource",
"type": "core::felt252"
}
],
Expand Down Expand Up @@ -412,6 +421,20 @@
}
]
},
{
"type": "constructor",
"name": "constructor",
"inputs": [
{
"name": "executor",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "contract_base",
"type": "core::starknet::class_hash::ClassHash"
}
]
},
{
"type": "event",
"name": "dojo::world::world::WorldSpawned",
Expand All @@ -423,12 +446,24 @@
"kind": "data"
},
{
"name": "caller",
"name": "creator",
"type": "core::starknet::contract_address::ContractAddress",
"kind": "data"
}
]
},
{
"type": "event",
"name": "dojo::world::world::MetadataUpdate",
"kind": "struct",
"members": [
{
"name": "resource",
"type": "core::felt252",
"kind": "data"
},
{
"name": "metadata_uri",
"name": "uri",
"type": "core::array::Span::<core::felt252>",
"kind": "data"
}
Expand Down Expand Up @@ -505,6 +540,11 @@
"type": "dojo::world::world::WorldSpawned",
"kind": "nested"
},
{
"name": "MetadataUpdate",
"type": "dojo::world::world::MetadataUpdate",
"kind": "nested"
},
{
"name": "ModelRegistered",
"type": "dojo::world::world::ModelRegistered",
Expand Down
5 changes: 2 additions & 3 deletions crates/torii/client/src/contract/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub enum WorldContractError<S, P> {
impl<'a, A: ConnectedAccount + Sync> WorldContract<'a, A> {
pub async fn set_metadata_uri_from_str(
&self,
resource: FieldElement,
resource: &FieldElement,
metadata_uri: String,
) -> Result<
InvokeTransactionResult,
Expand All @@ -57,9 +57,8 @@ impl<'a, A: ConnectedAccount + Sync> WorldContract<'a, A> {
.collect::<Vec<_>>();

encoded.insert(0, encoded.len().into());
encoded.insert(0, resource);

self.set_metadata_uri(&encoded).await.map_err(WorldContractError::AccountError)
self.set_metadata_uri(resource, &encoded).await.map_err(WorldContractError::AccountError)
}

pub async fn grant_writer_from_str(
Expand Down

0 comments on commit 45c5558

Please sign in to comment.