Skip to content

Commit c71634d

Browse files
committed
fix erc1155 test
1 parent 92ffe4b commit c71634d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

crates/torii/indexer/src/test.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ async fn test_load_from_remote_erc721(sequencer: &RunnerCtx) {
443443
format!(
444444
"SELECT balance FROM token_balances WHERE account_address = '{:#x}' AND \
445445
contract_address = '{:#x}' AND token_id = '{:#x}:{}'",
446-
account.address(),
446+
Felt::ONE,
447447
badge_address,
448448
badge_address,
449449
u256_to_sql_string(&U256::from(token_id as u32))
@@ -457,8 +457,8 @@ async fn test_load_from_remote_erc721(sequencer: &RunnerCtx) {
457457
let balance = crypto_bigint::U256::from_be_hex(balance.trim_start_matches("0x"));
458458
assert_eq!(
459459
U256::from(balance),
460-
U256::from(0u8),
461-
"Sender should have balance of 0 for transferred tokens"
460+
U256::from(1u8),
461+
"Sender should have balance of 1 for transferred tokens"
462462
);
463463
}
464464

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

499499
let account = sequencer.account(0);
500+
let other_account = sequencer.account(1);
500501
let provider = Arc::new(JsonRpcClient::new(HttpTransport::new(sequencer.url())));
501502

502503
let world_local = ws.load_world_local().unwrap();
@@ -533,7 +534,7 @@ async fn test_load_from_remote_erc1155(sequencer: &RunnerCtx) {
533534
.execute_v1(vec![Call {
534535
to: rewards_address,
535536
selector: get_selector_from_name("mint").unwrap(),
536-
calldata: vec![Felt::ZERO, Felt::from(*token_id), Felt::ZERO, Felt::from(*amount)],
537+
calldata: vec![Felt::from(*token_id), Felt::ZERO, Felt::from(*amount), Felt::ZERO],
537538
}])
538539
.send()
539540
.await
@@ -550,11 +551,12 @@ async fn test_load_from_remote_erc1155(sequencer: &RunnerCtx) {
550551
selector: get_selector_from_name("transfer_from").unwrap(),
551552
calldata: vec![
552553
account.address(),
553-
Felt::ONE,
554+
other_account.address(),
554555
Felt::from(*token_id),
555556
Felt::ZERO,
556557
Felt::from(amount / 2),
557558
Felt::ZERO,
559+
Felt::ZERO,
558560
],
559561
}])
560562
.send()
@@ -619,7 +621,7 @@ async fn test_load_from_remote_erc1155(sequencer: &RunnerCtx) {
619621
format!(
620622
"SELECT balance FROM token_balances WHERE account_address = '{:#x}' AND \
621623
contract_address = '{:#x}' AND token_id = '{:#x}:{}'",
622-
Felt::ONE,
624+
other_account.address(),
623625
rewards_address,
624626
rewards_address,
625627
u256_to_sql_string(&U256::from(token_id as u32))

examples/spawn-and-move/src/externals/erc1155.cairo

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ mod ERC1155Token {
6767
// self.erc1155.mint_with_acceptance_check(account, token_id, value, data);
6868
}
6969

70+
#[external(v0)]
71+
fn transfer_from(ref self: ContractState, from: ContractAddress, to: ContractAddress, token_id: u256, value: u256) {
72+
self.erc1155.update(from, to, array![token_id].span(), array![value].span());
73+
// safe transfer from does not support default account since they dont implement receiver.
74+
}
75+
7076
#[external(v0)]
7177
fn batch_mint(ref self: ContractState, token_ids: Span<u256>, values: Span<u256>) {
7278
self

0 commit comments

Comments
 (0)