From 2b475b25313185869c9ed9026c5c9f2a4e12cb53 Mon Sep 17 00:00:00 2001 From: CJ42 Date: Tue, 10 Oct 2023 09:36:00 +0100 Subject: [PATCH] docs: update tokens docs for `_afterTokenTransfer` hook --- .../LSP7DigitalAsset/LSP7DigitalAsset.md | 55 +++++++++++++++++- .../extensions/LSP7Burnable.md | 55 +++++++++++++++++- .../extensions/LSP7CappedSupply.md | 45 ++++++++++++++- .../extensions/LSP7CompatibleERC20.md | 23 ++++++++ .../presets/LSP7CompatibleERC20Mintable.md | 23 ++++++++ .../LSP7DigitalAsset/presets/LSP7Mintable.md | 55 +++++++++++++++++- .../LSP8IdentifiableDigitalAsset.md | 56 ++++++++++++++++++- .../extensions/LSP8Burnable.md | 56 ++++++++++++++++++- .../extensions/LSP8CappedSupply.md | 46 ++++++++++++++- .../extensions/LSP8CompatibleERC721.md | 24 +++++++- .../extensions/LSP8Enumerable.md | 55 +++++++++++++++++- .../presets/LSP8CompatibleERC721Mintable.md | 24 +++++++- .../presets/LSP8Mintable.md | 56 ++++++++++++++++++- 13 files changed, 549 insertions(+), 24 deletions(-) diff --git a/docs/contracts/LSP7DigitalAsset/LSP7DigitalAsset.md b/docs/contracts/LSP7DigitalAsset/LSP7DigitalAsset.md index 101dc5629..1f5e332c7 100644 --- a/docs/contracts/LSP7DigitalAsset/LSP7DigitalAsset.md +++ b/docs/contracts/LSP7DigitalAsset/LSP7DigitalAsset.md @@ -833,6 +833,16 @@ If the amount is zero then the operator is being revoked, otherwise the operator ### \_mint +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances. + +- {\_afterTokenTransfer} function will run after updating the balances, **but before notifying the recipient via LSP1**. + +::: + ```solidity function _mint( address to, @@ -865,6 +875,16 @@ Mints `amount` of tokens and transfers it to `to`. ### \_burn +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances. + +- {\_afterTokenTransfer} function will run after updating the balances, **but before notifying the sender via LSP1**. + +::: + :::tip Hint In dApps, you can know which address is burning tokens by listening for the `Transfer` event and filter with the zero address as `to`. @@ -879,7 +899,6 @@ Burns (= destroys) `amount` of tokens, decrease the `from` balance. This is done Both the sender and recipient will be notified of the token transfer through the LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before updating the balances.
@@ -923,6 +942,16 @@ Spend `amountToSpend` from the `operator`'s authorized on behalf of the `tokenOw ### \_transfer +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances. + +- {\_afterTokenTransfer} function will run after updating the balances, **but before notifying the sender/recipient via LSP1**. + +::: + ```solidity function _transfer( address from, @@ -938,7 +967,6 @@ of `to` by `+amount`. Both the sender and recipient will be notified of the token transfer through the LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before updating the balances.
@@ -983,6 +1011,29 @@ Allows to run custom logic before updating balances and notifiying sender/recipi
+### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + uint256 amount +) internal nonpayable; +``` + +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient** by overriding this function. + +#### Parameters + +| Name | Type | Description | +| -------- | :-------: | ------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | The recipient address | +| `amount` | `uint256` | The amount of token to transfer | + +
+ ### \_notifyTokenOperator ```solidity diff --git a/docs/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.md b/docs/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.md index 2a2652731..34098c44b 100644 --- a/docs/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.md +++ b/docs/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.md @@ -858,6 +858,16 @@ If the amount is zero then the operator is being revoked, otherwise the operator ### \_mint +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances. + +- {\_afterTokenTransfer} function will run after updating the balances, **but before notifying the recipient via LSP1**. + +::: + ```solidity function _mint( address to, @@ -890,6 +900,16 @@ Mints `amount` of tokens and transfers it to `to`. ### \_burn +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances. + +- {\_afterTokenTransfer} function will run after updating the balances, **but before notifying the sender via LSP1**. + +::: + :::tip Hint In dApps, you can know which address is burning tokens by listening for the `Transfer` event and filter with the zero address as `to`. @@ -904,7 +924,6 @@ Burns (= destroys) `amount` of tokens, decrease the `from` balance. This is done Both the sender and recipient will be notified of the token transfer through the LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before updating the balances.
@@ -948,6 +967,16 @@ Spend `amountToSpend` from the `operator`'s authorized on behalf of the `tokenOw ### \_transfer +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances. + +- {\_afterTokenTransfer} function will run after updating the balances, **but before notifying the sender/recipient via LSP1**. + +::: + ```solidity function _transfer( address from, @@ -963,7 +992,6 @@ of `to` by `+amount`. Both the sender and recipient will be notified of the token transfer through the LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before updating the balances.
@@ -1008,6 +1036,29 @@ Allows to run custom logic before updating balances and notifiying sender/recipi
+### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + uint256 amount +) internal nonpayable; +``` + +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient** by overriding this function. + +#### Parameters + +| Name | Type | Description | +| -------- | :-------: | ------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | The recipient address | +| `amount` | `uint256` | The amount of token to transfer | + +
+ ### \_notifyTokenOperator ```solidity diff --git a/docs/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.md b/docs/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.md index cc2501eae..9ed5575a0 100644 --- a/docs/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.md +++ b/docs/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.md @@ -874,6 +874,16 @@ after `amount` of tokens have been minted. ### \_burn +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances. + +- {\_afterTokenTransfer} function will run after updating the balances, **but before notifying the sender via LSP1**. + +::: + :::tip Hint In dApps, you can know which address is burning tokens by listening for the `Transfer` event and filter with the zero address as `to`. @@ -888,7 +898,6 @@ Burns (= destroys) `amount` of tokens, decrease the `from` balance. This is done Both the sender and recipient will be notified of the token transfer through the LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before updating the balances.
@@ -932,6 +941,16 @@ Spend `amountToSpend` from the `operator`'s authorized on behalf of the `tokenOw ### \_transfer +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances. + +- {\_afterTokenTransfer} function will run after updating the balances, **but before notifying the sender/recipient via LSP1**. + +::: + ```solidity function _transfer( address from, @@ -947,7 +966,6 @@ of `to` by `+amount`. Both the sender and recipient will be notified of the token transfer through the LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before updating the balances.
@@ -992,6 +1010,29 @@ Allows to run custom logic before updating balances and notifiying sender/recipi
+### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + uint256 amount +) internal nonpayable; +``` + +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient** by overriding this function. + +#### Parameters + +| Name | Type | Description | +| -------- | :-------: | ------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | The recipient address | +| `amount` | `uint256` | The amount of token to transfer | + +
+ ### \_notifyTokenOperator ```solidity diff --git a/docs/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.md b/docs/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.md index b5892952b..135705795 100644 --- a/docs/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.md +++ b/docs/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.md @@ -1090,6 +1090,29 @@ Allows to run custom logic before updating balances and notifiying sender/recipi
+### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + uint256 amount +) internal nonpayable; +``` + +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient** by overriding this function. + +#### Parameters + +| Name | Type | Description | +| -------- | :-------: | ------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | The recipient address | +| `amount` | `uint256` | The amount of token to transfer | + +
+ ### \_notifyTokenOperator ```solidity diff --git a/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md b/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md index 8a5d97d56..95238d92f 100644 --- a/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md +++ b/docs/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md @@ -1124,6 +1124,29 @@ Allows to run custom logic before updating balances and notifiying sender/recipi
+### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + uint256 amount +) internal nonpayable; +``` + +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient** by overriding this function. + +#### Parameters + +| Name | Type | Description | +| -------- | :-------: | ------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | The recipient address | +| `amount` | `uint256` | The amount of token to transfer | + +
+ ### \_notifyTokenOperator ```solidity diff --git a/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md b/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md index b9de110e4..eace4408b 100644 --- a/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md +++ b/docs/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md @@ -895,6 +895,16 @@ If the amount is zero then the operator is being revoked, otherwise the operator ### \_mint +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances. + +- {\_afterTokenTransfer} function will run after updating the balances, **but before notifying the recipient via LSP1**. + +::: + ```solidity function _mint( address to, @@ -927,6 +937,16 @@ Mints `amount` of tokens and transfers it to `to`. ### \_burn +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances. + +- {\_afterTokenTransfer} function will run after updating the balances, **but before notifying the sender via LSP1**. + +::: + :::tip Hint In dApps, you can know which address is burning tokens by listening for the `Transfer` event and filter with the zero address as `to`. @@ -941,7 +961,6 @@ Burns (= destroys) `amount` of tokens, decrease the `from` balance. This is done Both the sender and recipient will be notified of the token transfer through the LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before updating the balances.
@@ -985,6 +1004,16 @@ Spend `amountToSpend` from the `operator`'s authorized on behalf of the `tokenOw ### \_transfer +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances. + +- {\_afterTokenTransfer} function will run after updating the balances, **but before notifying the sender/recipient via LSP1**. + +::: + ```solidity function _transfer( address from, @@ -1000,7 +1029,6 @@ of `to` by `+amount`. Both the sender and recipient will be notified of the token transfer through the LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before updating the balances.
@@ -1045,6 +1073,29 @@ Allows to run custom logic before updating balances and notifiying sender/recipi
+### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + uint256 amount +) internal nonpayable; +``` + +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient** by overriding this function. + +#### Parameters + +| Name | Type | Description | +| -------- | :-------: | ------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | The recipient address | +| `amount` | `uint256` | The amount of token to transfer | + +
+ ### \_notifyTokenOperator ```solidity diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md b/docs/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md index 64eb7b0b8..c72dd01d3 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md @@ -803,6 +803,16 @@ When `tokenId` does not exist then revert with an error. ### \_mint +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the recipient via LSP1**. + +::: + ```solidity function _mint( address to, @@ -835,6 +845,16 @@ Create `tokenId` by minting it and transfers it to `to`. ### \_burn +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender via LSP1**. + +::: + :::tip Hint In dApps, you can know which addresses are burning tokens by listening for the `Transfer` event and filter with the zero address as `to`. @@ -850,7 +870,6 @@ This will also clear all the operators allowed to transfer the `tokenId`. The owner of the `tokenId` will be notified about the `tokenId` being transferred through its LSP1 [`universalReceiver`](#universalreceiver) function, if it is a contract that supports the LSP1 interface. Its [`universalReceiver`](#universalreceiver) function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before burning `tokenId` and updating the balances.
@@ -871,6 +890,16 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r ### \_transfer +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender/recipient via LSP1**. + +::: + :::danger This internal function does not check if the sender is authorized or not to operate on the `tokenId`. @@ -891,7 +920,6 @@ Change the owner of the `tokenId` from `from` to `to`. Both the sender and recipient will be notified of the `tokenId` being transferred through their LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before changing the owner of `tokenId`.
@@ -924,8 +952,30 @@ function _beforeTokenTransfer( ``` Hook that is called before any token transfer, including minting and burning. +Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | -------------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | @param tokenId The tokenId to transfer | +| `tokenId` | `bytes32` | The tokenId to transfer | + +
+ +### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + bytes32 tokenId +) internal nonpayable; +``` -- Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient via LSP1** by overriding this function. #### Parameters diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md index acfdb68cd..4f68d4008 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md @@ -829,6 +829,16 @@ When `tokenId` does not exist then revert with an error. ### \_mint +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the recipient via LSP1**. + +::: + ```solidity function _mint( address to, @@ -861,6 +871,16 @@ Create `tokenId` by minting it and transfers it to `to`. ### \_burn +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender via LSP1**. + +::: + :::tip Hint In dApps, you can know which addresses are burning tokens by listening for the `Transfer` event and filter with the zero address as `to`. @@ -876,7 +896,6 @@ This will also clear all the operators allowed to transfer the `tokenId`. The owner of the `tokenId` will be notified about the `tokenId` being transferred through its LSP1 [`universalReceiver`](#universalreceiver) function, if it is a contract that supports the LSP1 interface. Its [`universalReceiver`](#universalreceiver) function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before burning `tokenId` and updating the balances.
@@ -897,6 +916,16 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r ### \_transfer +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender/recipient via LSP1**. + +::: + :::danger This internal function does not check if the sender is authorized or not to operate on the `tokenId`. @@ -917,7 +946,6 @@ Change the owner of the `tokenId` from `from` to `to`. Both the sender and recipient will be notified of the `tokenId` being transferred through their LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before changing the owner of `tokenId`.
@@ -950,8 +978,30 @@ function _beforeTokenTransfer( ``` Hook that is called before any token transfer, including minting and burning. +Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | -------------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | @param tokenId The tokenId to transfer | +| `tokenId` | `bytes32` | The tokenId to transfer | + +
+ +### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + bytes32 tokenId +) internal nonpayable; +``` -- Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient via LSP1** by overriding this function. #### Parameters diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md index 5946dd474..62310f99c 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md @@ -845,6 +845,16 @@ after a new `tokenId` has of tokens have been minted. ### \_burn +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender via LSP1**. + +::: + :::tip Hint In dApps, you can know which addresses are burning tokens by listening for the `Transfer` event and filter with the zero address as `to`. @@ -860,7 +870,6 @@ This will also clear all the operators allowed to transfer the `tokenId`. The owner of the `tokenId` will be notified about the `tokenId` being transferred through its LSP1 [`universalReceiver`](#universalreceiver) function, if it is a contract that supports the LSP1 interface. Its [`universalReceiver`](#universalreceiver) function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before burning `tokenId` and updating the balances.
@@ -881,6 +890,16 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r ### \_transfer +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender/recipient via LSP1**. + +::: + :::danger This internal function does not check if the sender is authorized or not to operate on the `tokenId`. @@ -901,7 +920,6 @@ Change the owner of the `tokenId` from `from` to `to`. Both the sender and recipient will be notified of the `tokenId` being transferred through their LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before changing the owner of `tokenId`.
@@ -934,8 +952,30 @@ function _beforeTokenTransfer( ``` Hook that is called before any token transfer, including minting and burning. +Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | -------------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | @param tokenId The tokenId to transfer | +| `tokenId` | `bytes32` | The tokenId to transfer | + +
+ +### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + bytes32 tokenId +) internal nonpayable; +``` -- Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient via LSP1** by overriding this function. #### Parameters diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md index d1693dda6..e815cc233 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md @@ -1202,8 +1202,30 @@ function _beforeTokenTransfer( ``` Hook that is called before any token transfer, including minting and burning. +Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. -- Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | -------------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | @param tokenId The tokenId to transfer | +| `tokenId` | `bytes32` | The tokenId to transfer | + +
+ +### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + bytes32 tokenId +) internal nonpayable; +``` + +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient via LSP1** by overriding this function. #### Parameters diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md index 36bc2804e..5bba28705 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md @@ -834,6 +834,16 @@ When `tokenId` does not exist then revert with an error. ### \_mint +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the recipient via LSP1**. + +::: + ```solidity function _mint( address to, @@ -866,6 +876,16 @@ Create `tokenId` by minting it and transfers it to `to`. ### \_burn +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender via LSP1**. + +::: + :::tip Hint In dApps, you can know which addresses are burning tokens by listening for the `Transfer` event and filter with the zero address as `to`. @@ -881,7 +901,6 @@ This will also clear all the operators allowed to transfer the `tokenId`. The owner of the `tokenId` will be notified about the `tokenId` being transferred through its LSP1 [`universalReceiver`](#universalreceiver) function, if it is a contract that supports the LSP1 interface. Its [`universalReceiver`](#universalreceiver) function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before burning `tokenId` and updating the balances.
@@ -902,6 +921,16 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r ### \_transfer +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender/recipient via LSP1**. + +::: + :::danger This internal function does not check if the sender is authorized or not to operate on the `tokenId`. @@ -922,7 +951,6 @@ Change the owner of the `tokenId` from `from` to `to`. Both the sender and recipient will be notified of the `tokenId` being transferred through their LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before changing the owner of `tokenId`.
@@ -964,6 +992,29 @@ function _beforeTokenTransfer(
+### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + bytes32 tokenId +) internal nonpayable; +``` + +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient via LSP1** by overriding this function. + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | -------------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | @param tokenId The tokenId to transfer | +| `tokenId` | `bytes32` | The tokenId to transfer | + +
+ ### \_notifyTokenOperator ```solidity diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md index 33d19c009..6984f85dc 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md @@ -1244,8 +1244,30 @@ function _beforeTokenTransfer( ``` Hook that is called before any token transfer, including minting and burning. +Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. -- Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | -------------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | @param tokenId The tokenId to transfer | +| `tokenId` | `bytes32` | The tokenId to transfer | + +
+ +### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + bytes32 tokenId +) internal nonpayable; +``` + +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient via LSP1** by overriding this function. #### Parameters diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md index e71fb2a68..c82402175 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md @@ -867,6 +867,16 @@ When `tokenId` does not exist then revert with an error. ### \_mint +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the recipient via LSP1**. + +::: + ```solidity function _mint( address to, @@ -899,6 +909,16 @@ Create `tokenId` by minting it and transfers it to `to`. ### \_burn +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender via LSP1**. + +::: + :::tip Hint In dApps, you can know which addresses are burning tokens by listening for the `Transfer` event and filter with the zero address as `to`. @@ -914,7 +934,6 @@ This will also clear all the operators allowed to transfer the `tokenId`. The owner of the `tokenId` will be notified about the `tokenId` being transferred through its LSP1 [`universalReceiver`](#universalreceiver) function, if it is a contract that supports the LSP1 interface. Its [`universalReceiver`](#universalreceiver) function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before burning `tokenId` and updating the balances.
@@ -935,6 +954,16 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r ### \_transfer +:::info + +Any logic in the: + +- {\_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s. + +- {\_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender/recipient via LSP1**. + +::: + :::danger This internal function does not check if the sender is authorized or not to operate on the `tokenId`. @@ -955,7 +984,6 @@ Change the owner of the `tokenId` from `from` to `to`. Both the sender and recipient will be notified of the `tokenId` being transferred through their LSP1 [`universalReceiver`](#universalreceiver) function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive all the parameters in the calldata packed encoded. -Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will run before changing the owner of `tokenId`.
@@ -988,8 +1016,30 @@ function _beforeTokenTransfer( ``` Hook that is called before any token transfer, including minting and burning. +Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. + +#### Parameters + +| Name | Type | Description | +| --------- | :-------: | -------------------------------------- | +| `from` | `address` | The sender address | +| `to` | `address` | @param tokenId The tokenId to transfer | +| `tokenId` | `bytes32` | The tokenId to transfer | + +
+ +### \_afterTokenTransfer + +```solidity +function _afterTokenTransfer( + address from, + address to, + bytes32 tokenId +) internal nonpayable; +``` -- Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function. +Hook that is called after any token transfer, including minting and burning. +Allows to run custom logic after updating balances, but **before notifiying sender/recipient via LSP1** by overriding this function. #### Parameters