Skip to content

Commit

Permalink
fix erc1155 test
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Feb 14, 2025
1 parent 92ffe4b commit c71634d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 8 additions & 6 deletions crates/torii/indexer/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ async fn test_load_from_remote_erc721(sequencer: &RunnerCtx) {
format!(
"SELECT balance FROM token_balances WHERE account_address = '{:#x}' AND \
contract_address = '{:#x}' AND token_id = '{:#x}:{}'",
account.address(),
Felt::ONE,
badge_address,
badge_address,
u256_to_sql_string(&U256::from(token_id as u32))
Expand All @@ -457,8 +457,8 @@ async fn test_load_from_remote_erc721(sequencer: &RunnerCtx) {
let balance = crypto_bigint::U256::from_be_hex(balance.trim_start_matches("0x"));
assert_eq!(
U256::from(balance),
U256::from(0u8),
"Sender should have balance of 0 for transferred tokens"
U256::from(1u8),
"Sender should have balance of 1 for transferred tokens"
);
}

Expand Down Expand Up @@ -497,6 +497,7 @@ async fn test_load_from_remote_erc1155(sequencer: &RunnerCtx) {
let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap();

let account = sequencer.account(0);
let other_account = sequencer.account(1);
let provider = Arc::new(JsonRpcClient::new(HttpTransport::new(sequencer.url())));

let world_local = ws.load_world_local().unwrap();
Expand Down Expand Up @@ -533,7 +534,7 @@ async fn test_load_from_remote_erc1155(sequencer: &RunnerCtx) {
.execute_v1(vec![Call {
to: rewards_address,
selector: get_selector_from_name("mint").unwrap(),
calldata: vec![Felt::ZERO, Felt::from(*token_id), Felt::ZERO, Felt::from(*amount)],
calldata: vec![Felt::from(*token_id), Felt::ZERO, Felt::from(*amount), Felt::ZERO],
}])
.send()
.await
Expand All @@ -550,11 +551,12 @@ async fn test_load_from_remote_erc1155(sequencer: &RunnerCtx) {
selector: get_selector_from_name("transfer_from").unwrap(),
calldata: vec![
account.address(),
Felt::ONE,
other_account.address(),
Felt::from(*token_id),
Felt::ZERO,
Felt::from(amount / 2),
Felt::ZERO,
Felt::ZERO,
],
}])
.send()
Expand Down Expand Up @@ -619,7 +621,7 @@ async fn test_load_from_remote_erc1155(sequencer: &RunnerCtx) {
format!(
"SELECT balance FROM token_balances WHERE account_address = '{:#x}' AND \
contract_address = '{:#x}' AND token_id = '{:#x}:{}'",
Felt::ONE,
other_account.address(),
rewards_address,
rewards_address,
u256_to_sql_string(&U256::from(token_id as u32))
Expand Down
6 changes: 6 additions & 0 deletions examples/spawn-and-move/src/externals/erc1155.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ mod ERC1155Token {
// self.erc1155.mint_with_acceptance_check(account, token_id, value, data);
}

#[external(v0)]
fn transfer_from(ref self: ContractState, from: ContractAddress, to: ContractAddress, token_id: u256, value: u256) {
self.erc1155.update(from, to, array![token_id].span(), array![value].span());
// safe transfer from does not support default account since they dont implement receiver.
}

#[external(v0)]
fn batch_mint(ref self: ContractState, token_ids: Span<u256>, values: Span<u256>) {
self
Expand Down

0 comments on commit c71634d

Please sign in to comment.