-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Router Hook for the Xahau Ledger | ||
|
||
## Overview | ||
|
||
The router hook is designed to manage the execution of hooks on the Xahau Ledger. It allows for the conditional skipping of hooks based on their position in the execution sequence. | ||
|
||
## Features | ||
|
||
- **Conditional Execution**: The router hook can determine whether to execute or skip a hook based on its position. | ||
- **Dynamic Hook Management**: Hooks can be dynamically managed without altering the core logic of the router hook. | ||
|
||
## Usage | ||
|
||
To use the router hook, you need to set up the hook with the appropriate parameters and deploy it on an account on the Xahau Ledger. | ||
|
||
### Setting Up the Hook | ||
|
||
1. Create a hook payload with the desired flags and parameters. | ||
2. Use the `setHooksV3` function to attach the hook to your account. | ||
3. Define the hook positions using the `HookPosModel` and encode them into a `HookPosArray`. | ||
|
||
### Transaction Example | ||
|
||
Here is an example of how to invoke a transaction with the router hook: | ||
|
||
```typescript | ||
const builtTx1: Invoke = { | ||
TransactionType: 'Invoke', | ||
Account: aliceWallet.classicAddress, | ||
Destination: hookWallet.classicAddress, | ||
HookParameters: [otxn1param1.toXrpl()], | ||
}; | ||
|
||
const result1 = await Xrpld.submit(testContext.client, { | ||
wallet: aliceWallet, | ||
tx: builtTx1, | ||
}); | ||
``` | ||
|
||
### Hook Logic | ||
|
||
The router hook logic is implemented in `router_base.c`. It reads the hook positions from the transaction parameters and decides whether to skip or execute each hook based on its position. | ||
|
||
### Debugging | ||
|
||
To debug the router hook, you can monitor the `xrpld` logs for `HookTrace` entries: | ||
|
||
```shell | ||
tail -f xrpld/log/debug.log | grep HookTrace | ||
``` | ||
|
||
## Contributing | ||
|
||
Contributions to the router hook are welcome. Please ensure that you test your changes thoroughly before submitting a pull request. | ||
|
||
## License | ||
|
||
The router hook is released under [license name], which can be found in the LICENSE file. | ||
|
||
## Disclaimer | ||
|
||
This hook is provided "as is", without warranty of any kind. Use at your own risk. | ||
``` | ||
Please replace `[license name]` with the actual license name under which the router hook is released. The disclaimer is a standard warning, but you should adjust it according to the actual terms of use for the router hook. |