NonceManager
S_userSequentialNonceTrackers
mapping(address => uint256) S_userSequentialNonceTrackers
S_dAppSequentialNonceTrackers
mapping(address => uint256) S_dAppSequentialNonceTrackers
S_userNonSequentialNonceTrackers
mapping(address => mapping(uint248 => uint256)) S_userNonSequentialNonceTrackers
_handleUserNonces
function _handleUserNonces(address user, uint256 nonce, bool sequential, bool isSimulation) internal returns (bool validNonce)
The _handleUserNonces internal function handles the verification of user nonces for both sequential and
non-sequential nonce systems.
Parameters
| Name | Type | Description |
|---|
| user | address | The address of the user to verify the nonce for. |
| nonce | uint256 | The nonce to verify. |
| sequential | bool | A boolean indicating if the nonce mode is sequential (true) or not (false) |
| isSimulation | bool | A boolean indicating if the execution is a simulation. |
Return Values
| Name | Type | Description |
|---|
| validNonce | bool | A boolean indicating if the nonce is valid. |
_handleDAppNonces
function _handleDAppNonces(address dAppSignatory, uint256 nonce, bool isSimulation) internal returns (bool validNonce)
The _handleDAppNonces internal function handles the verification of dApp signatory nonces for sequential
nonce systems.
DApps nonces are only handled in sequential mode.
Parameters
| Name | Type | Description |
|---|
| dAppSignatory | address | The address of the dApp to verify the nonce for. |
| nonce | uint256 | The nonce to verify. |
| isSimulation | bool | A boolean indicating if the execution is a simulation. |
Return Values
| Name | Type | Description |
|---|
| validNonce | bool | A boolean indicating if the nonce is valid. |
_handleSequentialNonces
function _handleSequentialNonces(uint256 lastUsedNonce, uint256 nonce) internal pure returns (bool, uint256)
The _handleSequentialNonces internal function handles the verification of sequential nonces.
Parameters
| Name | Type | Description |
|---|
| lastUsedNonce | uint256 | The last used nonce. |
| nonce | uint256 | The nonce to verify. |
Return Values
| Name | Type | Description |
|---|
| [0] | bool | A boolean indicating if the nonce is valid. |
| [1] | uint256 | The updated last used nonce. |
_handleNonSequentialNonces
function _handleNonSequentialNonces(uint256 bitmap, uint8 bitPos) internal pure returns (bool, uint256)
The _handleNonSequentialNonces internal function handles the verification of non-sequential nonces.
Parameters
| Name | Type | Description |
|---|
| bitmap | uint256 | The bitmap to verify the nonce bit position against. |
| bitPos | uint8 | The bit position of the nonce to verify. |
Return Values
| Name | Type | Description |
|---|
| [0] | bool | A boolean indicating if the nonce is valid. |
| [1] | uint256 | The updated bitmap. |
getUserNextNonce
function getUserNextNonce(address user, bool sequential) external view returns (uint256 nextNonce)
Returns the next nonce for the given user, in sequential or non-sequential mode.
Parameters
| Name | Type | Description |
|---|
| user | address | The address of the user for which to retrieve the next nonce. |
| sequential | bool | A boolean indicating if the nonce should be sequential (true) or non-sequential (false). |
Return Values
| Name | Type | Description |
|---|
| nextNonce | uint256 | The next nonce for the given user. |
getUserNextNonSeqNonceAfter
function getUserNextNonSeqNonceAfter(address user, uint256 refNonce) external view returns (uint256)
Returns the next valid nonce after refNonce for the given user, in non-sequential mode.
Parameters
| Name | Type | Description |
|---|
| user | address | The address of the user for which to retrieve the next nonce. |
| refNonce | uint256 | The nonce to start the search from. |
Return Values
| Name | Type | Description |
|---|
| [0] | uint256 | The next nonce for the given user. |
getDAppNextNonce
function getDAppNextNonce(address dApp) external view returns (uint256 nextNonce)
Returns the next nonce for the given dApp signatory, in sequential mode.
DApps nonces are only handled in sequential mode.
Parameters
| Name | Type | Description |
|---|
| dApp | address | The address of the dApp signatory for which to retrieve the next nonce. |
Return Values
| Name | Type | Description |
|---|
| nextNonce | uint256 | The next nonce for the given dApp. |
_getNextNonSequentialNonce
function _getNextNonSequentialNonce(address user, uint248 wordIndex, uint8 bitPos) internal view returns (uint256 nextNonce)
Returns the next nonce for the given account, in non-sequential mode.
Non-sequential nonces are only enabled for users.
Parameters
| Name | Type | Description |
|---|
| user | address | The user to get the next nonce for. |
| wordIndex | uint248 | The word index to start the search from. |
| bitPos | uint8 | The bit position to start the search from. |
Return Values
| Name | Type | Description |
|---|
| nextNonce | uint256 | The next nonce for the given account. |
_nextNonceBitmapPositions
function _nextNonceBitmapPositions(uint256 refNonce) internal pure returns (uint248 wordIndex, uint8 bitPos)
Returns the index of the bitmap and the bit position within the bitmap for the next nonce.
Parameters
| Name | Type | Description |
|---|
| refNonce | uint256 | The nonce to get the next nonce positions from. |
Return Values
| Name | Type | Description |
|---|
| wordIndex | uint248 | The word position or index into the bitmap of the next nonce. |
| bitPos | uint8 | The bit position of the next nonce. |
_bitmapPositions
function _bitmapPositions(uint256 nonce) internal pure returns (uint248 wordIndex, uint8 bitPos)
Returns the index of the bitmap and the bit position within the bitmap. Used for non-sequenced nonces.
The first 248 bits of the nonce value is the index of the desired bitmap.
The last 8 bits of the nonce value is the position of the bit in the bitmap.
Parameters
| Name | Type | Description |
|---|
| nonce | uint256 | The nonce to get the associated word and bit positions. |
Return Values
| Name | Type | Description |
|---|
| wordIndex | uint248 | The word position or index into the bitmap. |
| bitPos | uint8 | The bit position. |
_nonceFromWordAndPos
function _nonceFromWordAndPos(uint248 wordIndex, uint8 bitPos) internal pure returns (uint256 nonce)
Constructs a nonce from a word and a position inside the word.
The first 248 bits of the nonce value is the index of the desired bitmap.
The last 8 bits of the nonce value is the position of the bit in the bitmap.
Parameters
| Name | Type | Description |
|---|
| wordIndex | uint248 | The word position or index into the bitmap. |
| bitPos | uint8 | The bit position. |
Return Values
| Name | Type | Description |
|---|
| nonce | uint256 | The nonce constructed from the word and position. |
userSequentialNonceTrackers
function userSequentialNonceTrackers(address account) external view returns (uint256 lastUsedSeqNonce)
Returns the last used sequential nonce for a user.
Parameters
| Name | Type | Description |
|---|
| account | address | The address of the account to get the last used sequential nonce for. |
Return Values
| Name | Type | Description |
|---|
| lastUsedSeqNonce | uint256 | The last used sequential nonce for the account. |
dAppSequentialNonceTrackers
function dAppSequentialNonceTrackers(address account) external view returns (uint256 lastUsedSeqNonce)
Returns the last used sequential nonce for a dApp signatory.
Parameters
| Name | Type | Description |
|---|
| account | address | The address of the account to get the last used sequential nonce for. |
Return Values
| Name | Type | Description |
|---|
| lastUsedSeqNonce | uint256 | The last used sequential nonce for the account. |
userNonSequentialNonceTrackers
function userNonSequentialNonceTrackers(address account, uint248 wordIndex) external view returns (uint256 bitmap)
Returns the non-sequential nonce bitmap for a user.
Parameters
| Name | Type | Description |
|---|
| account | address | The address of the account to get the non-sequential nonce bitmap for. |
| wordIndex | uint248 | The word index to get the bitmap from. |
Return Values
| Name | Type | Description |
|---|
| bitmap | uint256 | The non-sequential nonce bitmap for the account. |