Skip to content

Commit

Permalink
remove queryLink() function
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcabot committed Jan 3, 2023
1 parent ef7ad2a commit 0134285
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 180 deletions.
107 changes: 0 additions & 107 deletions contracts/SoulLinker.sol
Expand Up @@ -163,70 +163,6 @@ contract SoulLinker is PaymentGateway, EIP712, Pausable {
);
}

/// @notice Validates a link signature, of a given read link request, without storing it
/// @dev The token must be linked to this soul linker
/// @param readerIdentityId Id of the identity of the reader
/// @param ownerIdentityId Id of the identity of the owner of the SBT
/// @param token Address of the SBT contract
/// @param tokenId Id of the token
/// @param signatureDate Signature date of the signature
/// @param expirationDate Expiration date of the signature
/// @param signature Signature of the read link request made by the owner
/// @return True if the link is valid
function queryLink(
address paymentMethod,
uint256 readerIdentityId,
uint256 ownerIdentityId,
address token,
uint256 tokenId,
uint256 signatureDate,
uint256 expirationDate,
bytes calldata signature
) external payable whenNotPaused returns (bool) {
address ownerAddress = soulboundIdentity.ownerOf(ownerIdentityId);
address readerAddress = soulboundIdentity.ownerOf(readerIdentityId);
address tokenOwner = IERC721Enumerable(token).ownerOf(tokenId);

if (ownerAddress != tokenOwner)
revert IdentityOwnerNotTokenOwner(tokenId, ownerIdentityId);
if (readerAddress != _msgSender()) revert CallerNotReader(_msgSender());
if (ownerIdentityId == readerIdentityId)
revert IdentityOwnerIsReader(readerIdentityId);
if (expirationDate < block.timestamp)
revert ValidPeriodExpired(expirationDate);
// check if the link is revoked
if (_links[token][tokenId][readerIdentityId][signatureDate].isRevoked)
revert LinkAlreadyRevoked();

if (
!_verify(
_hash(
readerIdentityId,
ownerIdentityId,
token,
tokenId,
signatureDate,
expirationDate
),
signature,
ownerAddress
)
) revert InvalidSignature();

_pay(paymentMethod, getPriceForQueryLink(paymentMethod, token));

emit LinkQuery(
readerIdentityId,
ownerIdentityId,
token,
tokenId,
signatureDate,
expirationDate
);

return true;
}

/// @notice Revokes the link
/// @dev The token must be linked to this soul linker
/// @param readerIdentityId Id of the identity of the reader
Expand Down Expand Up @@ -486,40 +422,6 @@ contract SoulLinker is PaymentGateway, EIP712, Pausable {
}
}

/// @notice Returns the price for querying a link
/// @dev Returns the current pricing for querying a link
/// @param paymentMethod Address of token that user want to pay
/// @param token Token that user want to query link
/// @return Current price for querying a link
function getPriceForQueryLink(address paymentMethod, address token)
public
view
returns (uint256)
{
uint256 queryLinkPrice = ILinkableSBT(token).queryLinkPrice();
uint256 queryLinkPriceMASA = ILinkableSBT(token).queryLinkPriceMASA();
if (queryLinkPrice == 0 && queryLinkPriceMASA == 0) {
return 0;
} else if (
paymentMethod == masaToken &&
enabledPaymentMethod[paymentMethod] &&
queryLinkPriceMASA > 0
) {
// price in MASA without conversion rate
return queryLinkPriceMASA;
} else if (
paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]
) {
// stable coin
return queryLinkPrice;
} else if (enabledPaymentMethod[paymentMethod]) {
// ETH and ERC 20 token
return _convertFromStableCoin(paymentMethod, queryLinkPrice);
} else {
revert InvalidPaymentMethod(paymentMethod);
}
}

/* ========== PRIVATE FUNCTIONS ========================================= */

function _hash(
Expand Down Expand Up @@ -569,15 +471,6 @@ contract SoulLinker is PaymentGateway, EIP712, Pausable {
uint256 expirationDate
);

event LinkQuery(
uint256 readerIdentityId,
uint256 ownerIdentityId,
address token,
uint256 tokenId,
uint256 signatureDate,
uint256 expirationDate
);

event LinkRevoked(
uint256 readerIdentityId,
uint256 ownerIdentityId,
Expand Down
73 changes: 0 additions & 73 deletions docs/SoulLinker.md
Expand Up @@ -244,29 +244,6 @@ Returns the price for storing a link
|---|---|---|
| _0 | uint256 | Current price for storing a link |

### getPriceForQueryLink

```solidity
function getPriceForQueryLink(address paymentMethod, address token) external view returns (uint256)
```

Returns the price for querying a link

*Returns the current pricing for querying a link*

#### Parameters

| Name | Type | Description |
|---|---|---|
| paymentMethod | address | Address of token that user want to pay |
| token | address | Token that user want to query link |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | uint256 | Current price for querying a link |

### getSBTConnections

```solidity
Expand Down Expand Up @@ -375,35 +352,6 @@ function paused() external view returns (bool)
|---|---|---|
| _0 | bool | undefined |

### queryLink

```solidity
function queryLink(address paymentMethod, uint256 readerIdentityId, uint256 ownerIdentityId, address token, uint256 tokenId, uint256 signatureDate, uint256 expirationDate, bytes signature) external payable returns (bool)
```

Validates a link signature, of a given read link request, without storing it

*The token must be linked to this soul linker*

#### Parameters

| Name | Type | Description |
|---|---|---|
| paymentMethod | address | undefined |
| readerIdentityId | uint256 | Id of the identity of the reader |
| ownerIdentityId | uint256 | Id of the identity of the owner of the SBT |
| token | address | Address of the SBT contract |
| tokenId | uint256 | Id of the token |
| signatureDate | uint256 | Signature date of the signature |
| expirationDate | uint256 | Expiration date of the signature |
| signature | bytes | Signature of the read link request made by the owner |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | bool | True if the link is valid |

### renounceOwnership

```solidity
Expand Down Expand Up @@ -683,27 +631,6 @@ event LinkAdded(uint256 readerIdentityId, uint256 ownerIdentityId, address token



#### Parameters

| Name | Type | Description |
|---|---|---|
| readerIdentityId | uint256 | undefined |
| ownerIdentityId | uint256 | undefined |
| token | address | undefined |
| tokenId | uint256 | undefined |
| signatureDate | uint256 | undefined |
| expirationDate | uint256 | undefined |

### LinkQuery

```solidity
event LinkQuery(uint256 readerIdentityId, uint256 ownerIdentityId, address token, uint256 tokenId, uint256 signatureDate, uint256 expirationDate)
```





#### Parameters

| Name | Type | Description |
Expand Down
12 changes: 12 additions & 0 deletions docs/elin/contracts/security/ReentrancyGuard.md
@@ -0,0 +1,12 @@
# ReentrancyGuard







*Contract module that helps prevent reentrant calls to a function. Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier available, which can be applied to functions to make sure there are no nested (reentrant) calls to them. Note that because there is a single `nonReentrant` guard, functions marked as `nonReentrant` may not call one another. This can be worked around by making those functions `private`, and then adding `external` `nonReentrant` entry points to them. TIP: If you would like to learn more about reentrancy and alternative ways to protect against it, check out our blog post https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].*



0 comments on commit 0134285

Please sign in to comment.