Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cadaafd
Add getDelegatorState function to parachain staking precompile
Aug 11, 2025
a32bbc3
Enhance getDelegatorState with comprehensive paging and data verifica…
Aug 11, 2025
cf0ca0d
Format parachain-staking precompile code
Aug 11, 2025
c73553c
Refactor parachain-staking precompile for performance and maintainabi…
Aug 11, 2025
6989f85
Adjust collator pool gas cost from 150 to 64 collators
Aug 11, 2025
6186e0e
Enforce strict limit validation for getDelegatorState function
Aug 11, 2025
882f129
Fix clippy warnings in parachain-staking precompile
Aug 12, 2025
a73884d
Update precompiles/parachain-staking/src/lib.rs
sfffaaa Aug 12, 2025
448e47d
Update precompiles/parachain-staking/src/lib.rs
sfffaaa Aug 12, 2025
dd86122
Clarify sorting behavior in getDelegatorState documentation
Aug 12, 2025
a275540
Fix no_std compilation errors in parachain-staking precompile
Aug 13, 2025
fb964d2
Format documentation comments in parachain-staking precompile
Aug 13, 2025
507d8b8
Fix paging logic in single delegator query
Aug 13, 2025
088de04
Simplify iterator chain formatting in paging logic
Aug 13, 2025
63ef125
Remove redundant validations and single-parameter getDelegatorState
Aug 13, 2025
a9130ca
Change getDelegatorState parameter from bytes32 to address
Aug 15, 2025
1b5d02e
Add convertEthToSubstrateAccount utility function to parachain stakin…
Aug 15, 2025
1949f3c
Fix formatting and whitespace in parachain staking precompile
Aug 15, 2025
205c0ce
Merge branch 'dev' into feature/blk-129-precompile-for-the-delegate-s…
sfffaaa Aug 16, 2025
ba81e2b
Improve documentation for address format handling in parachain stakin…
Aug 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pallets/parachain-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ pub mod pallet {
/// It maps from an account to its delegation details.
#[pallet::storage]
#[pallet::getter(fn delegator_state)]
pub(crate) type DelegatorState<T: Config> = StorageMap<
pub type DelegatorState<T: Config> = StorageMap<
_,
Twox64Concat,
T::AccountId,
Expand Down
43 changes: 43 additions & 0 deletions precompiles/parachain-staking/ParachainStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ interface ParachainStaking {
uint256 commission;
}

struct DelegationInfo {
bytes32 collator;
uint256 amount;
}

struct CollatorDelegatorState {
bytes32 delegator;
DelegationInfo[] collators;
uint256 total;
}

/// Get all collator informations
// selector: 0xaaacb283
function getCollatorList() external view returns (CollatorInfo[] memory);
Expand Down Expand Up @@ -58,4 +69,36 @@ interface ParachainStaking {
/// elapsed.
/// selector: 0x0f615369
function unlockUnstaked(address target) external;


/// Get the delegations for a specific delegator or all delegators with paging support
/// If delegator is zero address (0x0), returns all delegators' states with paging
/// Otherwise returns the delegations for the specified delegator (paging applies to collators within delegator)
///
/// IMPORTANT - Sorting behavior (same as above):
/// - When querying ALL delegators (0x0): The order of delegators is NOT sorted
/// - Each individual delegator's delegations: ARE sorted by stake amount in DESCENDING order
///
/// INPUT/OUTPUT ADDRESS FORMAT:
/// - Input: Ethereum address (20 bytes) for the delegator parameter
/// - Output: All addresses in the returned structs are substrate account hashes (bytes32)
///
/// @param delegator The delegator Ethereum address to query (use 0x0 for all delegators)
/// @param offset The starting index for pagination (0-based)
/// @param limit The maximum number of items to return (must be 1-512)
///
/// selector: 0xbeae0df4
function getDelegatorState(address delegator, uint256 offset, uint256 limit) external view returns (CollatorDelegatorState[] memory);

/// Convert Ethereum address to substrate account hash (bytes32)
/// This shows how Ethereum addresses are mapped to substrate accounts internally
///
/// Input: Standard Ethereum address (20 bytes)
/// Output: Substrate account hash (32 bytes) - the derived substrate account representation
///
/// @param ethAddress The Ethereum address to convert
/// @return The substrate account hash (bytes32) derived from the Ethereum address
///
/// selector: 0xb76f87bf
function convertEthToSubstrateAccount(address ethAddress) external view returns (bytes32);
}
Loading
Loading