Skip to content

Commit 38d712c

Browse files
chore: fix specification of hook execution order (#1338)
Signed-off-by: Michael Tinker <michael.tinker@swirldslabs.com>
1 parent c6a6038 commit 38d712c

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

HIP/hip-1195.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,23 +1004,24 @@ records for a single transaction,
10041004
consensus.handle.maxFollowingRecords=50
10051005
```
10061006
The `CryptoTransfer` handler will execute hook calls in the following order:
1007-
1. All `pre_tx_allowance_hook` calls in the HBAR `TransferList`, in the order they appear in the `CryptoTransferTransactionBody`.
1008-
2. All `pre_tx_allowance_hook` calls in the fungible `transfers` of the `tokenTransfers`
1009-
list, in the order they appear in the `CryptoTransferTransactionBody`.
1010-
3. All `pre_tx_sender_allowance_hook`, `pre_tx_receiver_allowance_hook`, calls in the non-fungible `nftTransfers` of
1011-
the `tokenTransfers` list, in the order they appear in the `CryptoTransferTransactionBody`.
1012-
(_Note:_ if both sender and receiver hooks are present, then the sender hook is executed first.)
1013-
4. All `pre_post_tx_allowance_hook` calls in the HBAR `TransferList`, in the order they appear in the `CryptoTransferTransactionBody`.
1014-
5. All `pre_post_tx_allowance_hook` calls in the fungible `transfers` of the `tokenTransfers`
1015-
list, in the order they appear in the `CryptoTransferTransactionBody`.
1016-
6. All `pre_post_sender_tx_allowance_hook`, `pre_post_tx_receiver_allowance_hook`, calls in the non-fungible `nftTransfers` of
1017-
the `tokenTransfers` list, in the order they appear in the `CryptoTransferTransactionBody`.
1018-
7. All `pre_post` hooks previously executed in steps (4) to (6), _in the same order they were previously executed_;
1007+
1. All `pre_tx_allowance_hook` calls in the HBAR `TransferList`, in the order they appear.
1008+
2. For each `TokenTransferList`,
1009+
- If for a fungible token, all `pre_tx_allowance_hook` calls in the `transfers` list, in the order they appear.
1010+
- If for a non-fungible token, all `pre_tx_sender_allowance_hook` and `pre_tx_receiver_allowance_hook` calls in the
1011+
`nftTransfers` list, in the order they appear. (_Note:_ given both sender and receiver hooks in the same
1012+
`NftTransfer`, the sender hook executes first.)
1013+
3. All `pre_post_tx_allowance_hook` calls in the HBAR `TransferList`, in the order they appear.
1014+
4. For each `TokenTransferList`,
1015+
- If for a fungible token, all `pre_post_tx_allowance_hook` calls in the `transfers` list, in the order they appear.
1016+
- If for a non-fungible token, all `pre_post_sender_tx_allowance_hook` and `pre_post_tx_receiver_allowance_hook` calls
1017+
in the `nftTransfers` list, in the order they appear. (_Note:_ given both sender and receiver hooks in the same
1018+
`NftTransfer`, the sender hook executes first.)
1019+
5. All `pre_post` hooks previously executed in steps (3) and (4), _in the same order they were previously executed_;
10191020
while the first call will be to the `allowPre(HookContext, ProposedTransfers)` method signature, the second call will
10201021
be to the `allowPost(HookContext, ProposedTransfers)` signature.
10211022

1022-
A block stream or legacy record stream client can use this well-known ordering to identify which child `ContractCall`
1023-
to `0x16d` corresponds to which `HookCall` in a `CryptoTransferTransactionBody`.
1023+
A block stream or legacy record stream client can use this ordering to identify which child `ContractCall` to `0x16d`
1024+
corresponds to which `HookCall` in a `CryptoTransferTransactionBody`.
10241025

10251026
### Examples
10261027

0 commit comments

Comments
 (0)