Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
HOOKS_COMPILE_HOST=https://hook-buildbox.xrpl.org
HOOKS_COMPILE_HOST=http://0.0.0.0:9000
# HOOKS_COMPILE_HOST=https://hook-buildbox.xrpl.org
HOOKS_DEBUG_HOST=wss://xahau-test.net/debugstream
XAHAU_ENV=standalone
34 changes: 31 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ You can also build a single hook with;

## Compile JS Hooks

You can ONLY build a single js hook at a time;
## Compile C FHooks

`$ hooks-cli compile-js contracts-js/toolbox/base.ts build`
Run this command to locally compile an XAHL Hook source file (inside ./contracts) from .c to .wasm code:

`$ hooks-cli compile-c contracts-cf build`

You can also build a single hook with;

`$ hooks-cli compile-c contracts-c/toolbox/base.c build`

## Test the Hook Library

Expand Down Expand Up @@ -46,4 +52,26 @@ Run JS Hooks Integration tests

Run single JS Hooks Integration test

`$ yarn run test:integration-js test/integration-js/toolbox/base.test.ts`
`$ yarn run test:integration-js test/integration-js/toolbox/base.test.ts`

## JS Hooks

### Standalone

`$ xrpld-netgen up:standalone --version=2025.2.24-HEAD+1366`

### Compile

You can ONLY build a single js hook at a time;

`$ hooks-cli compile-js contracts-js/toolbox/base.ts build`

## Functional Hooks

### Standalone

`$ xrpld-netgen up:standalone --version=2025.5.4-HEAD+1765`

### Compile

`$ hooks-cli compile-c contracts-func/toolbox/base.c build`
13 changes: 13 additions & 0 deletions contracts-func/toolbox/base.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "hookapi.h"

int64_t func_one(uint32_t reserved) {
TRACESTR("func_one.c: Called.");
_g(1,1);
return accept(SBUF("func_one: Finished."), __LINE__);
}

int64_t func_two(uint32_t reserved) {
TRACESTR("func_two.c: Called.");
_g(1,1);
return accept(SBUF("func_two: Finished."), __LINE__);
}
51 changes: 51 additions & 0 deletions contracts-func/utils/hook/error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// For documentation please see: https://xrpl-hooks.readme.io/reference/
// Generated using generate_error.sh
#ifndef HOOK_ERROR_CODES
#define SUCCESS 0
#define OUT_OF_BOUNDS -1
#define INTERNAL_ERROR -2
#define TOO_BIG -3
#define TOO_SMALL -4
#define DOESNT_EXIST -5
#define NO_FREE_SLOTS -6
#define INVALID_ARGUMENT -7
#define ALREADY_SET -8
#define PREREQUISITE_NOT_MET -9
#define FEE_TOO_LARGE -10
#define EMISSION_FAILURE -11
#define TOO_MANY_NONCES -12
#define TOO_MANY_EMITTED_TXN -13
#define NOT_IMPLEMENTED -14
#define INVALID_ACCOUNT -15
#define GUARD_VIOLATION -16
#define INVALID_FIELD -17
#define PARSE_ERROR -18
#define RC_ROLLBACK -19
#define RC_ACCEPT -20
#define NO_SUCH_KEYLET -21
#define NOT_AN_ARRAY -22
#define NOT_AN_OBJECT -23
#define INVALID_FLOAT -10024
#define DIVISION_BY_ZERO -25
#define MANTISSA_OVERSIZED -26
#define MANTISSA_UNDERSIZED -27
#define EXPONENT_OVERSIZED -28
#define EXPONENT_UNDERSIZED -29
#define XFL_OVERFLOW -30
#define NOT_IOU_AMOUNT -31
#define NOT_AN_AMOUNT -32
#define CANT_RETURN_NEGATIVE -33
#define NOT_AUTHORIZED -34
#define PREVIOUS_FAILURE_PREVENTS_RETRY -35
#define TOO_MANY_PARAMS -36
#define INVALID_TXN -37
#define RESERVE_INSUFFICIENT -38
#define COMPLEX_NOT_SUPPORTED -39
#define DOES_NOT_MATCH -40
#define INVALID_KEY -41
#define NOT_A_STRING -42
#define MEM_OVERLAP -43
#define TOO_MANY_STATE_MODIFICATIONS -44
#define TOO_MANY_NAMESPACES -45
#define HOOK_ERROR_CODES
#endif //HOOK_ERROR_CODES
Loading