Skip to content

Commit

Permalink
Fix BLS address byte size
Browse files Browse the repository at this point in the history
  • Loading branch information
pouya-eghbali committed Mar 9, 2024
1 parent 81adf95 commit a9a8d4a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions contracts/Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ contract UnchainedStaking is Ownable, IERC721Receiver, ReentrancyGuard {

mapping(address => Stake) private _stakes;
mapping(bytes32 => Slash) private _slashes;
mapping(bytes32 => address) private _blsToAddress;
mapping(address => bytes32) private _addressToBls;
mapping(bytes20 => address) private _blsToAddress;
mapping(address => bytes20) private _addressToBls;

bool private _acceptNft;

Expand Down Expand Up @@ -404,7 +404,7 @@ contract UnchainedStaking is Ownable, IERC721Receiver, ReentrancyGuard {
* @dev Allows a user to set or update their BLS (Boneh-Lynn-Shacham) address.
* @param blsAddress The new BLS address to be set for the user.
*/
function setBlsAddress(bytes32 blsAddress) external {
function setBlsAddress(bytes20 blsAddress) external {
bytes32 current = _addressToBls[_msgSender()];
_addressToBls[_msgSender()] = blsAddress;
_blsToAddress[blsAddress] = _msgSender();
Expand All @@ -416,7 +416,7 @@ contract UnchainedStaking is Ownable, IERC721Receiver, ReentrancyGuard {
* @param evm The EVM address to query the associated BLS address.
* @return The BLS address associated with the given EVM address.
*/
function blsAddressOf(address evm) public view returns (bytes32) {
function blsAddressOf(address evm) public view returns (bytes20) {
return _addressToBls[evm];
}

Expand All @@ -425,7 +425,7 @@ contract UnchainedStaking is Ownable, IERC721Receiver, ReentrancyGuard {
* @param bls The BLS address to query the associated EVM address.
* @return The EVM address associated with the given BLS address.
*/
function evmAddressOf(bytes32 bls) public view returns (address) {
function evmAddressOf(bytes20 bls) public view returns (address) {
return _blsToAddress[bls];
}

Expand All @@ -434,7 +434,7 @@ contract UnchainedStaking is Ownable, IERC721Receiver, ReentrancyGuard {
* @param bls The BLS address to query the stake information.
* @return The stake information associated with the given BLS address.
*/
function stakeOf(bytes32 bls) public view returns (Stake memory) {
function stakeOf(bytes20 bls) public view returns (Stake memory) {
return _stakes[evmAddressOf(bls)];
}

Expand Down
28 changes: 14 additions & 14 deletions docs/UnchainedStaking.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This contract allows users to stake ERC20 tokens and ERC721 NFTs, offering funct
### blsAddressOf

```solidity
function blsAddressOf(address evm) external view returns (bytes32)
function blsAddressOf(address evm) external view returns (bytes20)
```


Expand All @@ -30,12 +30,12 @@ function blsAddressOf(address evm) external view returns (bytes32)

| Name | Type | Description |
|---|---|---|
| _0 | bytes32 | The BLS address associated with the given EVM address. |
| _0 | bytes20 | The BLS address associated with the given EVM address. |

### evmAddressOf

```solidity
function evmAddressOf(bytes32 bls) external view returns (address)
function evmAddressOf(bytes20 bls) external view returns (address)
```


Expand All @@ -46,7 +46,7 @@ function evmAddressOf(bytes32 bls) external view returns (address)

| Name | Type | Description |
|---|---|---|
| bls | bytes32 | The BLS address to query the associated EVM address. |
| bls | bytes20 | The BLS address to query the associated EVM address. |

#### Returns

Expand Down Expand Up @@ -217,7 +217,7 @@ function renounceOwnership() external nonpayable
### setBlsAddress

```solidity
function setBlsAddress(bytes32 blsAddress) external nonpayable
function setBlsAddress(bytes20 blsAddress) external nonpayable
```


Expand All @@ -228,7 +228,7 @@ function setBlsAddress(bytes32 blsAddress) external nonpayable

| Name | Type | Description |
|---|---|---|
| blsAddress | bytes32 | The new BLS address to be set for the user. |
| blsAddress | bytes20 | The new BLS address to be set for the user. |

### setSlashThreshold

Expand Down Expand Up @@ -285,46 +285,46 @@ function stake(uint256 duration, uint256 amount, uint256[] nftIds, bool consumer
### stakeOf

```solidity
function stakeOf(bytes32 bls) external view returns (struct UnchainedStaking.Stake)
function stakeOf(address evm) external view returns (struct UnchainedStaking.Stake)
```



*Retrieves the stake information associated with a given BLS address.*
*Retrieves the stake information associated with a given EVM address.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| bls | bytes32 | The BLS address to query the stake information. |
| evm | address | The EVM address to query the stake information. |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | UnchainedStaking.Stake | The stake information associated with the given BLS address. |
| _0 | UnchainedStaking.Stake | The stake information associated with the given EVM address. |

### stakeOf

```solidity
function stakeOf(address evm) external view returns (struct UnchainedStaking.Stake)
function stakeOf(bytes20 bls) external view returns (struct UnchainedStaking.Stake)
```



*Retrieves the stake information associated with a given EVM address.*
*Retrieves the stake information associated with a given BLS address.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| evm | address | The EVM address to query the stake information. |
| bls | bytes20 | The BLS address to query the stake information. |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | UnchainedStaking.Stake | The stake information associated with the given EVM address. |
| _0 | UnchainedStaking.Stake | The stake information associated with the given BLS address. |

### transfer

Expand Down

0 comments on commit a9a8d4a

Please sign in to comment.