|
1 | 1 | package org.hiero.base.data; |
2 | 2 |
|
3 | | -import com.hedera.hashgraph.sdk.ContractId; |
4 | | -import com.hedera.hashgraph.sdk.EvmHookStorageUpdate; |
| 3 | +import com.hedera.hashgraph.sdk.EvmHook; |
| 4 | +import com.hedera.hashgraph.sdk.HookCreationDetails; |
5 | 5 | import com.hedera.hashgraph.sdk.HookExtensionPoint; |
6 | 6 | import com.hedera.hashgraph.sdk.Key; |
7 | | -import java.util.List; |
8 | 7 | import java.util.Objects; |
9 | 8 | import org.jspecify.annotations.NonNull; |
10 | 9 | import org.jspecify.annotations.Nullable; |
11 | 10 |
|
12 | | -/** |
13 | | - * High-level representation of a hook to attach to an account. |
14 | | - * |
15 | | - * @param extensionPoint the extension point where the hook should be attached |
16 | | - * @param hookId unique identifier of the hook on the owning entity |
17 | | - * @param evmHookContractId contract implementing the hook logic |
18 | | - * @param initialStorageUpdates initial EVM storage updates to apply on hook creation |
19 | | - * @param adminKey optional key used to authorize management operations for this hook |
20 | | - */ |
| 11 | +/** Data model describing a hook to be created on an account update transaction. */ |
21 | 12 | public record HookDetails( |
22 | 13 | @NonNull HookExtensionPoint extensionPoint, |
23 | 14 | long hookId, |
24 | | - @NonNull ContractId evmHookContractId, |
25 | | - @NonNull List<EvmHookStorageUpdate> initialStorageUpdates, |
| 15 | + @NonNull EvmHook hook, |
26 | 16 | @Nullable Key adminKey) { |
27 | 17 |
|
28 | 18 | public HookDetails { |
29 | | - Objects.requireNonNull(extensionPoint, "extensionPoint must not be null"); |
30 | | - Objects.requireNonNull(evmHookContractId, "evmHookContractId must not be null"); |
31 | | - Objects.requireNonNull(initialStorageUpdates, "initialStorageUpdates must not be null"); |
32 | | - initialStorageUpdates.forEach( |
33 | | - update -> Objects.requireNonNull(update, "initialStorageUpdates must not contain null")); |
34 | | - initialStorageUpdates = List.copyOf(initialStorageUpdates); |
| 19 | + Objects.requireNonNull(extensionPoint, "extensionPoint is required"); |
| 20 | + Objects.requireNonNull(hook, "hook is required"); |
35 | 21 | if (hookId < 0) { |
36 | 22 | throw new IllegalArgumentException("hookId must be non-negative"); |
37 | 23 | } |
38 | 24 | } |
| 25 | + |
| 26 | + @NonNull |
| 27 | + public HookCreationDetails toHederaSdkType() { |
| 28 | + if (adminKey != null) { |
| 29 | + return new HookCreationDetails(extensionPoint, hookId, hook, adminKey); |
| 30 | + } |
| 31 | + return new HookCreationDetails(extensionPoint, hookId, hook); |
| 32 | + } |
39 | 33 | } |
0 commit comments