starknet-io / starknet.js

JavaScript library for StarkNet
https://www.starknetjs.com
MIT License
1.21k stars 706 forks source link

Cairo Zeroable type not supported #1144

Closed PhilippeR26 closed 2 weeks ago

PhilippeR26 commented 1 month ago

Describe the bug Try to interact with a Cairo function that use the type NonZero generates an Error.

To Reproduce The contract 0x07be990e59999c2e4210d2e42f99c5701bb641da25ccccad14b206c2f0acb2c2 deployed in Sepolia Testnet has a pause function using NonZero :

{
    "name": "pause",
    "type": "function",
    "inputs": [
      {
        "name": "some_param",
        "type": "core::zeroable::NonZero::<core::integer::u128>"
      }
    ],
    "outputs": [],
    "state_mutability": "external"
  }

code :

const testAddress= "0x07be990e59999c2e4210d2e42f99c5701bb641da25ccccad14b206c2f0acb2c2";
const testContract = await myProvider.getClassAt(testAddress);
const myContract=new Contract( testContract.abi,testAddress,account0);
const res=await myContract.invoke("pause",[200]);

Error :

Error: Validate Unhandled: argument some_param, type core::zeroable::NonZero::<core::integer::u128>, value 200
    at /D/starknetFork/starknet.js/src/utils/calldata/validate.ts:320:15

Expected behavior Full compatibility with core::zerable.

Screenshots N/A Desktop (please complete the following information):

Additional context I will investigate is there are other types in core::zeroable that fails also.

Jemiiah commented 1 month ago

@PhilippeR26 i would love to work on this issue