Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Read the JSON file of compiled cairo contracts and the find return signatures of test functions that will be mocked #98

Open
Eikix opened this issue Jan 11, 2023 · 2 comments
Assignees
Labels
Context: intricated deep understanding of the codebase required Difficulty: hard require extensive knowledge Duration: 0.5 day will take about half a day
Milestone

Comments

@Eikix
Copy link
Collaborator

Eikix commented Jan 11, 2023

Tim: Lire le compiled.json pour trouver la struct et size de chacune des Cairo types.

@Eikix
Copy link
Collaborator Author

Eikix commented Jan 11, 2023

end goal:
mock_call(name_of_my_func, [42, “shortstring”, ids.myVarName, Uint256 {high: 42, low: 0x0}])

@ptisserand
Copy link
Contributor

Return payload in compiled JSON file is available with the following command:

$ cat balance.json | jq '.program.identifiers | to_entries | .[] | select(.key|test(".*Return"))'

which will output the following:

{
  "key": "__main__.get_balance.Return",
  "value": {
    "cairo_type": "(balance: felt)",
    "type": "type_definition"
  }
}
{
  "key": "__main__.increase_balance.Return",
  "value": {
    "cairo_type": "()",
    "type": "type_definition"
  }
}
{
  "key": "__main__.multiple_outputs.Return",
  "value": {
    "cairo_type": "(account: __main__.MyAccount, total: starkware.cairo.common.uint256.Uint256, ref: felt)",
    "type": "type_definition"
  }
}
{
  "key": "__main__.multiple_outputs_with_array.Return",
  "value": {
    "cairo_type": "(id: felt, b_len: felt, b: felt*, answer: felt)",
    "type": "type_definition"
  }
}
{
  "key": "__main__.sum.Return",
  "value": {
    "cairo_type": "(sum: felt)",
    "type": "type_definition"
  }
}

@tdelabro tdelabro added this to the Mock call milestone Jan 16, 2023
@tdelabro tdelabro changed the title [CHALET - MOCK CALL] Read the JSON file of compiled cairo contracts and the find return signatures of test functions that will be mocked Read the JSON file of compiled cairo contracts and the find return signatures of test functions that will be mocked Jan 16, 2023
ptisserand added a commit to ptisserand/cairo-foundry that referenced this issue Jan 26, 2023
…contract

`retrieve_return_signatures` will return an HashMap with the following content:
- key: String: function symbol
- value: Vec<String>: list of types of function return signature
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Context: intricated deep understanding of the codebase required Difficulty: hard require extensive knowledge Duration: 0.5 day will take about half a day
Projects
None yet
Development

No branches or pull requests

3 participants