Skip to content

Commit

Permalink
fix type for buffer decode
Browse files Browse the repository at this point in the history
  • Loading branch information
vanruch committed Mar 27, 2024
1 parent f939758 commit dea4d85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions evm/evm-codec/src/codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import type { Pretty } from "./utils";

export const WORD_SIZE = 32;

export interface Codec<T> {
encode(sink: Sink, val: T): void;
decode(src: Src): T;
export interface Codec<TIn, TOut = TIn> {
encode(sink: Sink, val: TIn): void;
decode(src: Src): TOut;
isDynamic: boolean;
slotsCount?: number;
}
Expand All @@ -16,5 +16,5 @@ export type Struct = {
};

export type StructTypes<T extends Struct> = Pretty<{
[K in keyof T]: T[K] extends Codec<infer U> ? U : never;
[K in keyof T]: T[K] extends Codec<any, infer U> ? U : never;
}>;
4 changes: 2 additions & 2 deletions evm/evm-codec/src/codecs/primitives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const string = <const>{
isDynamic: true,
};

export const bytes = <const>{
export const bytes: Codec<Uint8Array | Hex, Hex> = <const>{
encode(sink: Sink, val: Uint8Array | Hex) {
sink.offset();
sink.bytes(val);
Expand All @@ -161,7 +161,7 @@ export const bytes = <const>{
isDynamic: true,
};

const bytesN = (size: number): Codec<Uint8Array | Hex> => ({
const bytesN = (size: number): Codec<Uint8Array | Hex, Hex> => ({
encode(sink: Sink, val: Uint8Array | Hex) {
sink.staticBytes(size, val);
},
Expand Down

0 comments on commit dea4d85

Please sign in to comment.