Skip to content

Instantly share code, notes, and snippets.

View valstu's full-sized avatar

Valtteri Karesto valstu

View GitHub Profile
@valstu
valstu / accept.ts
Last active April 13, 2022 11:06
AssemblyScript hook
@external("env", "_g")
declare function _g(id: i32, maxiter: i32): i32
@external("env", "accept")
declare function accept(read_ptr: string, read_len: i32, err: i64): i64
@external("env", "trace")
declare function trace(mread_ptr: string, mread_len: i32, dread_ptr: string, dread_len: i32, as_hex: i32): i64
export function cbak(reserved: i32): i64 {
/**
* Hook API include file
*
* Note to the reader:
* This include defines two types of things: external functions and macros
* Functions are used sparingly because a non-inlining compiler may produce
* undesirable output.
*
* Find documentation here: https://xrpl-hooks.readme.io/reference/
*/
#include <stdint.h>
#include "hookapi.h"
int64_t cbak(int64_t reserved)
{
return 0;
}
int64_t hook(int64_t reserved ) {
/**
* Peggy.c - An oracle based stable coin hook
*
* Author: Richard Holland
* Date: 1 Mar 2021
*
**/
#include <stdint.h>
#include "hookapi.h"
//Authors: NeilH, RichardAH
// (joke) test hook that doubles incoming XRP payments and sends it back
// April 1st 2021: Added (unfair) coin flip
#include <stdint.h>
#include "../hookapi.h"
int64_t cbak(uint32_t reserved)
{
return 0;
}
#include <stdint.h>
#include "hookapi.h"
int64_t cbak(uint32_t reserved)
{
TRACESTR("Carbon: callback called.");
return 0;
}
int64_t hook(uint32_t reserved)
/**
* Notary.c - An example hook for collecting signatures for multi-sign transactions without blocking sequence number
* on the account.
*
* Author: Richard Holland
* Date: 11 Feb 2021
*
**/
#include <stdint.h>
#include "hookapi.h"
// this hook has no emitted tx and therefore no callbacks
int64_t cbak(uint32_t reserved)
{
return 0;
}
int64_t hook(uint32_t reserved)
{
@valstu
valstu / starter.c
Last active June 10, 2022 10:11
This hook just accepts any transaction coming through it
/**
* This hook just accepts any transaction coming through it
*/
#include "hookapi.h"
int64_t cbak(uint32_t reserved) {
return 0;
}
# testing