1.0.14 • Published 2 months ago

@transia/hooks-toolkit v1.0.14

Weekly downloads
-
License
GPL-3.0-or-later
Repository
-
Last release
2 months ago

The Hooks Toolkit (Typescript)

Global Prerequsits

$ npm i -g c2wasm-cli

Compile Hooks

Run this command to locally compile an XRPL Hook source file (inside ./contracts) from .c to .wasm code:

$ yarn run build:hooks

Here is what each command does in the background: 1. wasmcc - compiles a Hook source file (C code) to WebAssembly (WASM) code. For example, ./contracts/base.c compiles to ./build/base.wasm 2. wasm-opt - optimizes the WASM code ./build/base.wasm 3. hook-cleaner - cleans it by removing unnecessary additional exports 4. guard_checker - this checks if any guard violation has occurred in the Hooks code before submitting it in SetHook transaction. For more information, visit this link 5. Converts the compiled WASM to hexadecimal characters then submits it as payload in a SetHook transaction

You can also build a single hook with;

$ yarn run build:hook contracts/toolbox/base.c build

Debug the test env

tail -f xahau/log/debug.log | grep HookTrace

Test the Hook Library

Run Unit tests

$ yarn run test:unit

Before you can run the integration tests you must have a standalone rippled server running.

  • Full env with explorer:

    • $ xrpld-netgen up:standalone
  • Docker standalone only:

    • $ docker run -p 5005:5005 -p 6006:6006 -it transia/xahaud:latest

Run Integration tests

$ yarn run test:integration

Run single Integration test

$ yarn run test:integration test/integration/toolbox/base.test.ts

Adding a new Hook

  1. Add the hook.c file into the contracts directory
  2. Build the hooks $ yarn run build:hooks
  3. Copy the hook base.test.ts template into the correct folder. (audited/toolbox)
  4. Test the hook using: $ yarn run test:integration test/integration/audited/myHook.test.ts
1.0.14

2 months ago

1.0.13

2 months ago

1.0.12

3 months ago

1.0.11

5 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

7 months ago

1.0.5

9 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

11 months ago

0.0.1

11 months ago