-
Notifications
You must be signed in to change notification settings - Fork 33
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
feat: add an example to deploy an ArgentX 0.4.0 account on devnet #471
feat: add an example to deploy an ArgentX 0.4.0 account on devnet #471
Conversation
To view this pull requests documentation preview, visit the following URL: docs.page/focustree/starknet.dart~471 Documentation is deployed and generated using docs.page. |
WalkthroughA new Dart file has been added that implements a script to deploy an ArgentX account on the StarkNet blockchain. The script initializes the necessary signers, establishes a connection to a JSON-RPC provider, computes the account address using calldata and public keys, and handles minting and deployment transactions. It also verifies the account balance and sends a transfer, printing transaction details and handling potential errors during deployment. Changes
Sequence Diagram(s)sequenceDiagram
participant Main
participant RPC
participant Contract
Main ->> RPC: Connect (using node URI)
Main ->> RPC: Request Chain ID
RPC -->> Main: Return Chain ID
Main ->> Main: Initialize Guardian & Owner signers
Main ->> Main: Compute Account Address (calldata + public key)
Main ->> RPC: Mint funds (initiate mint transaction)
Main ->> RPC: Check account balance (balanceOf call)
alt Account not deployed
Main ->> Contract: Deploy account via Account.deployAccount
Contract -->> Main: Return Transaction Hash
Main ->> RPC: Await transaction confirmation
end
Main ->> Contract: Send funds to recipient
Contract -->> Main: Return Transaction Hash
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (4)
packages/starknet/example/examples/deploy_argent_account.dart (4)
8-10
: Consider making the ArgentX class hash configurable.The hardcoded class hash might need updates when ArgentX releases new versions. Consider making it configurable through environment variables or constructor parameters.
-final argentClassHash = Felt.fromHexString( - '0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f', -); +// Read from environment variable or configuration +final argentClassHash = Felt.fromHexString( + Platform.environment['ARGENT_CLASS_HASH'] ?? + '0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f', +);
36-43
: Make the devnet URL configurable and improve WEI calculation.The hardcoded localhost URL should be configurable, and the WEI calculation can be improved for clarity.
+const oneEther = BigInt.from(10).pow(18); +final devnetUrl = Platform.environment['DEVNET_URL'] ?? 'http://localhost:5050'; await Devnet.mintTransaction( - Uri.parse('http://localhost:5050'), + Uri.parse(devnetUrl), MintRequest( address: accountAddress.toHexString(), - amount: pow(10, 18) as int, + amount: oneEther.toInt(), unit: 'WEI', ), );
69-70
: Document the commented fee configuration options.The commented fee configuration options might be useful for users. Consider adding documentation about when and why to use these options.
Add a comment explaining the fee configuration:
+ // Optional: Use STRK for fee payment instead of ETH // useSTRKFee: true, + // Optional: Set maximum fee for deployment (in WEI) // max_fee: Felt.fromInt(20000000000000),
96-99
: Make transfer parameters configurable.The recipient address and transfer amount are hardcoded. Consider making these configurable to make the example more flexible.
+ final recipient = Platform.environment['RECIPIENT_ADDRESS'] ?? + '0x44554d4d59'; // Example recipient + final amount = BigInt.parse( + Platform.environment['TRANSFER_AMOUNT'] ?? '10' + ); final txHash = await account.send( - recipient: Felt.fromHexString('0x44554d4d59'), + recipient: Felt.fromHexString(recipient), amount: Uint256( - low: Felt.fromInt(10), + low: Felt.fromInt(amount.toInt()), high: Felt.zero ), );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/starknet/example/examples/deploy_argent_account.dart
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: lint
- GitHub Check: analyze
- GitHub Check: test-integration
🔇 Additional comments (1)
packages/starknet/example/examples/deploy_argent_account.dart (1)
28-34
: LGTM! Clean implementation of account address computation.The code correctly follows StarkNet's account deployment pattern by computing the account address using the class hash, constructor calldata, and signer's public key.
Add an example to deply an ArgentX 0.4.0 with a local cosigner on devnet
Summary by CodeRabbit