Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Import the dependencies from the `@biomapper-sdk` like this:
import {IBiomapperLogRead} from "@biomapper-sdk/core/IBiomapperLogRead.sol";
import {IBridgedBiomapperRead} from "@biomapper-sdk/core/IBridgedBiomapperRead.sol";
import {BiomapperLogLib} from "@biomapper-sdk/libraries/BiomapperLogLib.sol";
import {BridgedBiomapperReadLib} from "@biomapper-sdk/libraries/BridgedBiomapperReadLib.sol";
import {BridgedBiomapperLib} from "@biomapper-sdk/libraries/BridgedBiomapperLib.sol";
```

### With Foundry
Expand All @@ -66,7 +66,7 @@ Import the dependencies from `biomapper-sdk` like this:
import {IBiomapperLogRead} from "biomapper-sdk/core/IBiomapperLogRead.sol";
import {IBridgedBiomapperRead} from "biomapper-sdk/core/IBridgedBiomapperRead.sol";
import {BiomapperLogLib} from "biomapper-sdk/libraries/BiomapperLogLib.sol";
import {BridgedBiomapperReadLib} from "biomapper-sdk/libraries/BridgedBiomapperReadLib.sol";
import {BridgedBiomapperLib} from "biomapper-sdk/libraries/BridgedBiomapperLib.sol";
```

## Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ contract SybilResistantAirdrop {
event Claimed(address who);

/**
* @dev Allows a user to claim their tokens if they haven't already claimed and are unique.
* @dev Allows a user to claim their tokens if they haven't already claimed
* and are unique in the last generation.
*/
function claim() public {
require(!isAlreadyClaimed[msg.sender], "User has already claimed");
require(BIOMAPPER_LOG.isUnique(msg.sender), "User is not unique");
require(
BIOMAPPER_LOG.isUniqueInLastGeneration(msg.sender),
"User is not unique"
);

ERC20_TOKEN.safeTransferFrom(TOKEN_VAULT, msg.sender, AMOUNT_PER_USER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ contract SybilResistantStaking {
}

modifier mustBeUnique() {
require(BIOMAPPER_LOG.isUnique(msg.sender), "User is not unique");
require(
BIOMAPPER_LOG.isUniqueInLastGeneration(msg.sender),
"User is not unique"
);
_;
}

Expand Down
10 changes: 8 additions & 2 deletions libraries/BiomapperLogLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import {IBiomapperLogRead} from "@biomapper-sdk/core/IBiomapperLogRead.sol";
/// @notice A utility library for the `BiomapperLog` contract.
library BiomapperLogLib {
/// @notice Determines the uniqueness status of a given address in the current biomapper generation.
/// The alternative way of using the `Biomapper` contract.
///
/// @notice This call does not guarantee uniqueness across generations,
/// meaning the same person can pass this check more than once (perform a Sybil-attack):
/// with same biometrics but different account after each generation change.
/// Ensure you are fully understand the implications of generations and the security guarantees they provide,
/// and consider explicitly scoping your uniqueness check by a particular generation.
///
/// @param biomapperLog The `BiomapperLog` contract.
/// @param who The address to check for uniqueness.
/// @return A boolean value indicating whether the address is biomapped (true) or not (false).
function isUnique(
function isUniqueInLastGeneration(
IBiomapperLogRead biomapperLog,
address who
) external view returns (bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.20;
import {IBridgedBiomapperRead} from "@biomapper-sdk/core/IBridgedBiomapperRead.sol";

/// @notice A utility library for the `BridgedBiomapper` contract.
library BridgedBiomapperReadLib {
library BridgedBiomapperLib {
/// @notice Determines the uniqueness status of a given address in the last known biomapper generation.
///
/// @notice This call does not guarantee uniqueness across generations,
Expand Down
2 changes: 1 addition & 1 deletion tests/hardhat/contracts/CanImport.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.24;

import {IBiomapperLogRead} from "@biomapper-sdk/core/IBiomapperLogRead.sol";
import {BiomapperLogLib} from "@biomapper-sdk/libraries/BiomapperLogLib.sol";
import {BridgedBiomapperReadLib} from "@biomapper-sdk/libraries/BridgedBiomapperReadLib.sol";
import {BridgedBiomapperLib} from "@biomapper-sdk/libraries/BridgedBiomapperLib.sol";
import {IGenerationChangeEvents} from "@biomapper-sdk/events/IGenerationChangeEvents.sol";
import {IProveUniquenessEvents} from "@biomapper-sdk/events/IProveUniquenessEvents.sol";
import {IBridgeBiomappingEvents} from "@biomapper-sdk/events/IBridgeBiomappingEvents.sol";
Expand Down