keep-starknet-strange / satoru

Synthetics platform for Starknet, inspired by GMX v2 design.
https://book.satoru.run/
MIT License
110 stars 73 forks source link

Feat: Completed Implementation of `role_store` contract. #443

Closed ametel01 closed 1 year ago

ametel01 commented 1 year ago

Summary

Implemented role_store and added corresponding tests.

Labels

Issue Resolved

Resolves: #432

New Behavior

The new implementation mimics the behavior of the Solidity version but avoids using arrays in storage. Instead, role_members_count and roles_count track the total number of writes rather than the actual instance count. This is because deleting a <key, value> pair sets the value to zero() rather than removing it. To manage storage efficiently, the algorithm checks existing keys from 0 to the current storage count during insertion. If a zero() value is found, that key is reused; otherwise, a new key-value pair is created and the key count is incremented.

Breaking Changes

None.

Additional Info

N/A

ametel01 commented 1 year ago

Nice, could you just rename some test to follow our test naming rules

Like in the first test -> given_normal_conditions_when_revoke_role_then_works

renamed tests

zarboq commented 1 year ago

Sorry I wasn't clear but the test you renamed was the one with good naming :)

Rename other tests following the same pattern (given_...)

ametel01 commented 1 year ago

Sorry I wasn't clear but the test you renamed was the one with good naming :)

Rename other tests following the same pattern (given_...)

done