Fix ByteArray handling in ERC20 predeployment#744
Conversation
WalkthroughThe pull request introduces a new utility function to handle the conversion and storage of short strings as byte arrays within a Starknet contract’s state. The function encapsulates the conversion of strings to felt values using a utility function and a Poseidon hash for determining storage addresses. The ERC20 contract initialization code has been modified to leverage this function for setting name and symbol values. Additionally, the integration tests have been updated to reflect new storage expectations and include a new test for validating property retrieval. Changes
Sequence Diagram(s)sequenceDiagram
participant ERC20Init as initialize_erc20_at_address
participant StorageFunc as store_short_string_as_byte_array
participant CairoUtil as cairo_short_string_to_felt
participant Poseidon as PoseidonHash
participant State as StarknetState
ERC20Init->>StorageFunc: Call(state, contract_addr, storage_var, short_str)
StorageFunc->>CairoUtil: Convert short string to felt
CairoUtil-->>StorageFunc: Return felt value
StorageFunc->>Poseidon: Compute capacity & chunk base hash
Poseidon-->>StorageFunc: Return chunk base
StorageFunc->>State: Write felt value to storage at chunk base
StorageFunc-->>ERC20Init: Return success
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code Definitions (1)tests/integration/general_integration_tests.rs (6)
🔇 Additional comments (6)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Usage related changes
nameandsymbol#739Development related changes
ByteArrayChecklist:
./scripts/format.sh./scripts/clippy_check.sh./scripts/check_unused_deps.sh./scripts/check_spelling.sh./website/README.mdSummary by CodeRabbit