Skip to content
Merged
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
29 changes: 29 additions & 0 deletions packages/state-transition/src/stateView/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,35 @@ export type IBeaconStateViewLatestFork = Omit<
latestExecutionPayloadHeader: ExecutionPayloadHeader;
payloadBlockNumber: number;
};

/**
* Contract a BeaconStateView backing implementation must satisfy.
*
* Differs from `IBeaconStateViewLatestFork` in two ways:
* - `executionPayloadAvailability` is a raw `{uint8Array, bitLen}` POJO — a
* native (`.node`) binding cannot construct a `BitArray` across FFI.
* `NativeBeaconStateView` lifts it back to `BitArray` for beacon-node.
* - Methods that produce another view (`stateTransition`, `processSlots`,
* `loadOtherState`, `withParentPayloadApplied`) return `IBeaconStateViewNative`
* so callers can re-wrap without an `as unknown` cast. Param lists are reused
* via `Parameters<...>` to avoid duplicating signatures.
*
* The TS-side `BeaconStateView` also structurally satisfies this contract since
* `BitArray` exposes `uint8Array` and `bitLen`.
*/
export type IBeaconStateViewNative = Omit<
IBeaconStateViewLatestFork,
"executionPayloadAvailability" | "loadOtherState" | "stateTransition" | "processSlots" | "withParentPayloadApplied"
> & {
executionPayloadAvailability: {uint8Array: Uint8Array; bitLen: number};
loadOtherState(...args: Parameters<IBeaconStateViewLatestFork["loadOtherState"]>): IBeaconStateViewNative;
stateTransition(...args: Parameters<IBeaconStateViewLatestFork["stateTransition"]>): IBeaconStateViewNative;
processSlots(...args: Parameters<IBeaconStateViewLatestFork["processSlots"]>): IBeaconStateViewNative;
withParentPayloadApplied(
...args: Parameters<IBeaconStateViewLatestFork["withParentPayloadApplied"]>
): IBeaconStateViewNative;
};

export function isStatePostAltair(state: IBeaconStateView): state is IBeaconStateViewAltair {
return isForkPostAltair(state.forkName);
}
Expand Down
Loading
Loading