Create functionality for delegating account permissions#27
Closed
kadoso-noni wants to merge 2 commits intoChain-Library:mainfrom
Closed
Create functionality for delegating account permissions#27kadoso-noni wants to merge 2 commits intoChain-Library:mainfrom
kadoso-noni wants to merge 2 commits intoChain-Library:mainfrom
Conversation
Contributor
|
@kadoso-noni please resolve the conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Account Delegation Smart Contract
Overview
This PR introduces the AccountDelegation smart contract, a comprehensive solution for managing permissions delegation on StarkNet. The contract enables account owners to delegate specific permissions to other addresses with fine-grained control over delegation lifetimes and usage limits.
Features
Permission Types
The contract supports multiple delegation scopes:
Transfer: Permission to transfer tokens
Sign: Permission to sign messages
Call: Permission to call specific contracts
Admin: Full administrative access
Delegation Controls
Each delegation can be configured with:
Expiration Time: Delegations automatically expire after a specified timestamp
Action Limits: Delegations can be limited to a specific number of uses
Active Status: Delegations can be revoked at any time
Flexible Ownership
Multiple owners can be registered
Only owners can create delegations
Each owner manages their own delegations independently
Technical Details
Storage Structure
delegations: Maps from owner address and permission type to delegation details
owners: Maps an address to a boolean indicating ownership status
Events
DelegationCreated: Emitted when a new delegation is created
DelegationRevoked: Emitted when a delegation is explicitly revoked
DelegationUsed: Emitted each time a delegation is used
DelegationExpired: Emitted when a delegation expires during use
Error Handling
Comprehensive error handling for all operations:
NotAuthorized: Caller lacks required permissions
DelegationExpired: Attempted to use an expired delegation
ActionLimitReached: Maximum number of actions already performed
DelegationNotActive: Delegation has been deactivated
InvalidDelegate: Invalid delegate address provided
InvalidExpiry: Invalid expiration time provided
Core Functionality Tests
Contract initialization
Owner management
Delegation creation with various parameters
Delegation revocation
Permission checking
Delegation usage tracking
Edge Cases
Unlimited delegations (no expiry, no action limit)
Multiple delegation types for the same delegate
Multiple owners creating independent delegations
Security Testing
Unauthorized access attempts
Zero address validation
Past expiry validation
Action limit enforcement
Expiration handling
Delegation status verification
Security Considerations
All ownership and delegation operations check caller permissions
Time-based expirations are enforced on delegation usage
Action limits are strictly enforced
Delegations are automatically deactivated when limits are reached
All state changes emit appropriate events