OpenZeppelin / cairo-contracts

OpenZeppelin Contracts written in Cairo for Starknet, a decentralized ZK Rollup
https://docs.openzeppelin.com/contracts-cairo
MIT License
800 stars 322 forks source link

fix: bug in account.cairo #870

Closed kongtaoxing closed 5 months ago

kongtaoxing commented 5 months ago

Fixes bug in src/account/account.cairo

Scarb version: scarb 2.5.0 (c531a6e50 2024-01-22) I'm trying to build a NFT, so I use Wizzard for Cairo to get start. When I tried to compile the contract with scarb build. I got a error below:

error: Method `span` could not be called on type `core::array::Span::<core::felt252>`.
Candidate `ArrayTrait::span` inference failed with: Type mismatch: `core::array::Span::<core::felt252>` and `@core::array::Array::<?0>`
 --> C:\Users\username\AppData\Local\swmansion\scarb\cache\registry\git\checkouts\cairo-contracts-9cboa8jg3jldq\5c7a022\src\account\account.cairo:272:64
        starknet::call_contract_syscall(to, selector, calldata.span()).unwrap()
                                                               ^**^

After I change calldata.span() into calldata.into(), the error was gone. The NFT's class hash is https://testnet.starkscan.co/class/0x07a029bdd6727af993c9d2432a5c353ffa8a08a2ef33249bd6dd33bf12ffe7ed

PR Checklist

martriay commented 5 months ago

Hello! Thanks for opening this PR, but this is not really a bug in the contract but a communication problem. Wizard for Cairo is not compatible with Cairo 2.5.0, which introduced a breaking change in the language that results in this error. Wizard should be used with Cairo 2.4.4 or lower.

I created an issue to tackle the wider task of bumping the compiler throughout the repo not just this file, so I'll close this PR in favor of that.

Once again, thanks for doing this! If you're interested in contributing to the project please check out this list of issues open to tackle.