Skip to content

Commit

Permalink
add readme for router hook
Browse files Browse the repository at this point in the history
  • Loading branch information
dangell7 committed Nov 17, 2023
1 parent 88eabb4 commit ca18a44
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions test/integration/router/README.md
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.

0 comments on commit ca18a44

Please sign in to comment.