Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] storage vars abstraction for Cairo1 contracts #646

Open
tabaktoni opened this issue Jun 14, 2023 · 6 comments
Open

[Proposal] storage vars abstraction for Cairo1 contracts #646

tabaktoni opened this issue Jun 14, 2023 · 6 comments
Assignees
Labels

Comments

@tabaktoni
Copy link
Collaborator

tabaktoni commented Jun 14, 2023

How to retrieve storage for complex data types:
Complex mapping - https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-storage/

After resolving this, we could implement class for retreating complex storage vars, by using ABI,
and than on top of that implement it in Contract vars so that one can do:

// simple - can be implemented now
mycontract.status;
mycontract.balance;
// complex - need to decode retreaving part, create request from ABI structure
mycontract.users[0].name;
@tabaktoni tabaktoni changed the title How to retrieve storage for complex data types [Proposal] storage vars abstraction for Cairo1 contracts Jun 16, 2023
@ivpavici ivpavici added the OnlyDust Open for OnlyDust contributors label Jun 27, 2023
@PhilippeR26
Copy link
Collaborator

To calculate the storage addresses, we need the name of the elements in the storage, and their types.
Can we find these data in .sierra or in .casm?

@tabaktoni
Copy link
Collaborator Author

They are indirectly specified if used in methods. (We can check with SW about extending ABI)
But even if they are not part of the ABI, we can presume the user knows the storage vars and build queries for him.

@PhilippeR26
Copy link
Collaborator

PhilippeR26 commented Jul 14, 2023

I made some tests : it works for litterals (including u256), legacyMap, structs, if the user provides the name of the element. Array and enums not supported in Storage (cairo v2.0.0).
Remain one major problem : how the user will provide to Starknet.js the way to deserialize complex elements? It could be a type that is not described in the abi.

@PhilippeR26
Copy link
Collaborator

PhilippeR26 commented Jul 15, 2023

I think that we can have :

const content:AllowArray<string>=await myContract.getStorage(varName,nbFeltToRead);

nbFeltToRead is optional.
Then the user has to deserialize the output.

I think it will be difficult to have something more refined...

@WiseMrMusa
Copy link

Hi, is there anyone working on this?

@PhilippeR26
Copy link
Collaborator

Hi, is there anyone working on this?

Hello,
I have started to work on it, but it has not been yet decided the exact scope of this job.

@ivpavici ivpavici removed the OnlyDust Open for OnlyDust contributors label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants