From 13e4d1e5b5c927e6a8338b8e542c008a6cd33922 Mon Sep 17 00:00:00 2001 From: tequ Date: Wed, 7 May 2025 23:31:57 +0900 Subject: [PATCH] Functional Hook --- src/setHooks.ts | 12 +++++++++--- src/types.ts | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/setHooks.ts b/src/setHooks.ts index da5590c..97d0a45 100644 --- a/src/setHooks.ts +++ b/src/setHooks.ts @@ -5,7 +5,11 @@ import { SetHookFlags, } from 'xahau' import { SetHookParams, iHook } from './types' -import { HookGrant, HookParameter } from 'xahau/dist/npm/models/common/xahau' +import { + HookFunction, + HookGrant, + HookParameter, +} from 'xahau/dist/npm/models/common/xahau' import { readHookBinaryHexFromNS, hexNamespace } from './utils' import { appTransaction } from './libs/xrpl-helpers/transaction' import { appLogger } from './libs/logger' @@ -19,6 +23,7 @@ export interface SetHookPayload { hookOnArray?: string[] | null hookParams?: HookParameter[] | null hookGrants?: HookGrant[] | null + hookFunctions?: HookFunction[] | null fee?: string | null } @@ -62,11 +67,13 @@ export function createHookPayload(payload: SetHookPayload): iHook { if (payload.hookGrants) { hook.HookGrants = payload.hookGrants } + if (payload.hookFunctions) { + hook.HookFunctions = payload.hookFunctions + } // DA: validate return hook } - export async function setHooksV3({ client, wallet, hooks }: SetHookParams) { const tx: SetHook = { TransactionType: `SetHook`, @@ -87,7 +94,6 @@ export async function setHooksV3({ client, wallet, hooks }: SetHookParams) { appLogger.debug(`\n3. SetHook Success...`) } - export async function clearAllHooksV3({ client, wallet }: SetHookParams) { const hook = { CreateCode: '', diff --git a/src/types.ts b/src/types.ts index 723b0c0..8e2d965 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,6 @@ import { Hook, + HookFunction, HookGrant, HookParameter, } from 'xahau/dist/npm/models/common/xahau' @@ -14,6 +15,7 @@ export type iHook = { HookApiVersion?: number HookParameters?: HookParameter[] HookGrants?: HookGrant[] + HookFunctions?: HookFunction[] Fee?: string }