Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contract API docs generated from @unlock-protocol/contracts@0-0-30 #14831

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1,384 changes: 572 additions & 812 deletions docs/docs/core-protocol/smart-contracts-api/PublicLock.md

Large diffs are not rendered by default.

661 changes: 235 additions & 426 deletions docs/docs/core-protocol/smart-contracts-api/Unlock.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
# ILockKeyCancelHook



# Solidity API

## ILockKeyCancelHook

Functions to be implemented by a keyCancelHook.

*Lock hooks are configured by calling `setEventHooks` on the lock.*

## Methods
_Lock hooks are configured by calling `setEventHooks` on the lock._

### onKeyCancel

```solidity
function onKeyCancel(address operator, address to, uint256 refund) external nonpayable
function onKeyCancel(address operator, address to, uint256 refund) external
```

If the lock owner has registered an implementer then this hook is called with every key cancel.


If the lock owner has registered an implementer
then this hook is called with every key cancel.

#### Parameters

| Name | Type | Description |
|---|---|---|
| operator | address | the msg.sender issuing the cancel |
| to | address | the account which had the key canceled |
| refund | uint256 | the amount sent to the `to` account (ETH or a ERC-20 token) |




| Name | Type | Description |
| -------- | ------- | ----------------------------------------------------------- |
| operator | address | the msg.sender issuing the cancel |
| to | address | the account which had the key canceled |
| refund | uint256 | the amount sent to the `to` account (ETH or a ERC-20 token) |
Original file line number Diff line number Diff line change
@@ -1,61 +1,57 @@
# ILockKeyPurchaseHook



# Solidity API

## ILockKeyPurchaseHook

Functions to be implemented by a keyPurchaseHook.

*Lock hooks are configured by calling `setEventHooks` on the lock.*

## Methods
_Lock hooks are configured by calling `setEventHooks` on the lock._

### keyPurchasePrice

```solidity
function keyPurchasePrice(address from, address recipient, address referrer, bytes data) external view returns (uint256 minKeyPrice)
```

Used to determine the purchase price before issueing a transaction. This allows the hook to offer a discount on purchases. This may revert to prevent a purchase.
Used to determine the purchase price before issueing a transaction.
This allows the hook to offer a discount on purchases.
This may revert to prevent a purchase.

*the lock's address is the `msg.sender` when this function is called via the lock's `purchasePriceFor` function*
_the lock's address is the `msg.sender` when this function is called via
the lock's `purchasePriceFor` function_

#### Parameters

| Name | Type | Description |
|---|---|---|
| from | address | the msg.sender making the purchase |
| recipient | address | the account which will be granted a key |
| referrer | address | the account which referred this key sale |
| data | bytes | arbitrary data populated by the front-end which initiated the sale |
| Name | Type | Description |
| --------- | ------- | ------------------------------------------------------------------ |
| from | address | the msg.sender making the purchase |
| recipient | address | the account which will be granted a key |
| referrer | address | the account which referred this key sale |
| data | bytes | arbitrary data populated by the front-end which initiated the sale |

#### Returns
#### Return Values

| Name | Type | Description |
|---|---|---|
| Name | Type | Description |
| ----------- | ------- | ---------------------------------------------------------------------- |
| minKeyPrice | uint256 | the minimum value/price required to purchase a key with these settings |

### onKeyPurchase

```solidity
function onKeyPurchase(address from, address recipient, address referrer, bytes data, uint256 minKeyPrice, uint256 pricePaid) external nonpayable
function onKeyPurchase(address from, address recipient, address referrer, bytes data, uint256 minKeyPrice, uint256 pricePaid) external
```

If the lock owner has registered an implementer then this hook is called with every key sold.
If the lock owner has registered an implementer then this hook
is called with every key sold.

*the lock's address is the `msg.sender` when this function is called*
_the lock's address is the `msg.sender` when this function is called_

#### Parameters

| Name | Type | Description |
|---|---|---|
| from | address | the msg.sender making the purchase |
| recipient | address | the account which will be granted a key |
| referrer | address | the account which referred this key sale |
| data | bytes | arbitrary data populated by the front-end which initiated the sale |
| minKeyPrice | uint256 | the price including any discount granted from calling this hook's `keyPurchasePrice` function |
| pricePaid | uint256 | the value/pricePaid included with the purchase transaction |




| Name | Type | Description |
| ----------- | ------- | --------------------------------------------------------------------------------------------- |
| from | address | the msg.sender making the purchase |
| recipient | address | the account which will be granted a key |
| referrer | address | the account which referred this key sale |
| data | bytes | arbitrary data populated by the front-end which initiated the sale |
| minKeyPrice | uint256 | the price including any discount granted from calling this hook's `keyPurchasePrice` function |
| pricePaid | uint256 | the value/pricePaid included with the purchase transaction |
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# ILockKeyTransferHook
# Solidity API

## ILockKeyTransferHook

Functions to be implemented by a hasValidKey Hook.

_Lock hooks are configured by calling `setEventHooks` on the lock._

## Methods

### onKeyTransfer

```solidity
function onKeyTransfer(address lockAddress, uint256 tokenId, address operator, address from, address to, uint256 expirationTimestamp) external nonpayable
function onKeyTransfer(address lockAddress, uint256 tokenId, address operator, address from, address to, uint256 expirationTimestamp) external
```

If the lock owner has registered an implementer then this hook is called every time balanceOf is called
If the lock owner has registered an implementer then this hook
is called every time balanceOf is called

#### Parameters

Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
# ILockTokenURIHook



# Solidity API

## ILockTokenURIHook

Functions to be implemented by a tokenURIHook.

*Lock hooks are configured by calling `setEventHooks` on the lock.*

## Methods
_Lock hooks are configured by calling `setEventHooks` on the lock._

### tokenURI

```solidity
function tokenURI(address lockAddress, address operator, address owner, uint256 keyId, uint256 expirationTimestamp) external view returns (string)
```

If the lock owner has registered an implementer then this hook is called every time `tokenURI()` is called


If the lock owner has registered an implementer
then this hook is called every time `tokenURI()` is called

#### Parameters

| Name | Type | Description |
|---|---|---|
| lockAddress | address | the address of the lock |
| operator | address | the msg.sender issuing the call |
| owner | address | the owner of the key for which we are retrieving the `tokenUri` |
| keyId | uint256 | the id (tokenId) of the key (if applicable) |
| expirationTimestamp | uint256 | the key expiration timestamp |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | string | the tokenURI |


| Name | Type | Description |
| ------------------- | ------- | --------------------------------------------------------------- |
| lockAddress | address | the address of the lock |
| operator | address | the msg.sender issuing the call |
| owner | address | the owner of the key for which we are retrieving the `tokenUri` |
| keyId | uint256 | the id (tokenId) of the key (if applicable) |
| expirationTimestamp | uint256 | the key expiration timestamp |

#### Return Values

| Name | Type | Description |
| ---- | ------ | ------------ |
| [0] | string | the tokenURI |
Original file line number Diff line number Diff line change
@@ -1,40 +1,25 @@
# ILockValidKeyHook



# Solidity API

## ILockValidKeyHook

Functions to be implemented by a hasValidKey Hook.

*Lock hooks are configured by calling `setEventHooks` on the lock.*

## Methods
_Lock hooks are configured by calling `setEventHooks` on the lock._

### hasValidKey

```solidity
function hasValidKey(address lockAddress, address keyOwner, uint256 expirationTimestamp, bool isValidKey) external view returns (bool)
```

If the lock owner has registered an implementer then this hook is called every time balanceOf is called


If the lock owner has registered an implementer then this hook
is called every time balanceOf is called

#### Parameters

| Name | Type | Description |
|---|---|---|
| lockAddress | address | the address of the current lock |
| keyOwner | address | the potential owner of the key for which we are retrieving the `balanceof` |
| expirationTimestamp | uint256 | the key expiration timestamp |
| isValidKey | bool | undefined |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | bool | undefined |




| Name | Type | Description |
| ------------------- | ------- | -------------------------------------------------------------------------- |
| lockAddress | address | the address of the current lock |
| keyOwner | address | the potential owner of the key for which we are retrieving the `balanceof` |
| expirationTimestamp | uint256 | the key expiration timestamp |
| isValidKey | bool | |
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
# ILockKeyCancelHook



# Solidity API

## ILockKeyCancelHook

Functions to be implemented by a keyCancelHook.

*Lock hooks are configured by calling `setEventHooks` on the lock.*

## Methods
_Lock hooks are configured by calling `setEventHooks` on the lock._

### onKeyCancel

```solidity
function onKeyCancel(address operator, address to, uint256 refund) external nonpayable
function onKeyCancel(address operator, address to, uint256 refund) external
```

If the lock owner has registered an implementer then this hook is called with every key cancel.


If the lock owner has registered an implementer
then this hook is called with every key cancel.

#### Parameters

| Name | Type | Description |
|---|---|---|
| operator | address | the msg.sender issuing the cancel |
| to | address | the account which had the key canceled |
| refund | uint256 | the amount sent to the `to` account (ETH or a ERC-20 token) |




| Name | Type | Description |
| -------- | ------- | ----------------------------------------------------------- |
| operator | address | the msg.sender issuing the cancel |
| to | address | the account which had the key canceled |
| refund | uint256 | the amount sent to the `to` account (ETH or a ERC-20 token) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Solidity API

## ILockKeyExtendHook

Functions to be implemented by a keyExtendHook.

_Lock hooks are configured by calling `setEventHooks` on the lock._

### onKeyExtend

```solidity
function onKeyExtend(uint256 tokenId, address from, uint256 newTimestamp, uint256 prevTimestamp) external
```

This hook every time a key is extended.

#### Parameters

| Name | Type | Description |
| ------------- | ------- | --------------------------------------------------------- |
| tokenId | uint256 | tje id of the key |
| from | address | the msg.sender making the purchase |
| newTimestamp | uint256 | the new expiration timestamp after the key extension |
| prevTimestamp | uint256 | the expiration timestamp of the key before being extended |
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Solidity API

## ILockKeyGrantHook

Functions to be implemented by a KeyGrantedHook.

_Lock hooks are configured by calling `setEventHooks` on the lock._

### onKeyGranted

```solidity
function onKeyGranted(uint256 tokenId, address from, address recipient, address keyManager, uint256 expiration) external
```

If the lock owner has registered an implementer then this hook
is called with every key granted.

_the lock's address is the `msg.sender` when this function is called_

#### Parameters

| Name | Type | Description |
| ---------- | ------- | --------------------------------------- |
| tokenId | uint256 | the id of the granted key |
| from | address | the msg.sender granting the key |
| recipient | address | the account which will be granted a key |
| keyManager | address | an additional keyManager for the key |
| expiration | uint256 | the expiration timestamp of the key |
Loading
Loading