diff --git a/src/types/contract.test-d.ts b/src/types/contract.test-d.ts index 25e269d98b..bb9fd0a03a 100644 --- a/src/types/contract.test-d.ts +++ b/src/types/contract.test-d.ts @@ -215,10 +215,10 @@ test('GetEventArgs', () => { 'Transfer' > expectTypeOf().toEqualTypeOf< - `0x${string}` | `0x${string}`[] | null | undefined + `0x${string}` | readonly `0x${string}`[] | null | undefined >() expectTypeOf().toEqualTypeOf< - `0x${string}` | `0x${string}`[] | null | undefined + `0x${string}` | readonly `0x${string}`[] | null | undefined >() }) @@ -260,7 +260,7 @@ test('GetValue', () => { test('LogTopicType', () => { expectTypeOf>().toEqualTypeOf() - expectTypeOf>().toEqualTypeOf() + expectTypeOf>().toEqualTypeOf() expectTypeOf>().toEqualTypeOf() expectTypeOf>().toEqualTypeOf< @@ -271,7 +271,7 @@ test('LogTopicType', () => { test('AbiEventParameterToPrimitiveType', () => { expectTypeOf< AbiEventParameterToPrimitiveType<{ name: 'foo'; type: 'string' }> - >().toEqualTypeOf() + >().toEqualTypeOf() expectTypeOf< AbiEventParameterToPrimitiveType< { name: 'foo'; type: 'string' }, @@ -286,7 +286,7 @@ test('AbiEventTopicToPrimitiveType', () => { >().toEqualTypeOf<`0x${string}`>() expectTypeOf< AbiEventTopicToPrimitiveType<{ name: 'foo'; type: 'string' }, Hex[]> - >().toEqualTypeOf<`0x${string}`[][]>() // TODO: Is this correct? + >().toEqualTypeOf() // TODO: Is this correct? expectTypeOf< AbiEventTopicToPrimitiveType<{ name: 'foo'; type: 'string' }, null> >().toEqualTypeOf() @@ -300,7 +300,7 @@ test('AbiEventTopicToPrimitiveType', () => { >().toEqualTypeOf() expectTypeOf< AbiEventTopicToPrimitiveType<{ name: 'foo'; type: 'bool' }, Hex[]> - >().toEqualTypeOf() + >().toEqualTypeOf() }) test('AbiEventParametersToPrimitiveTypes', () => { @@ -310,7 +310,7 @@ test('AbiEventParametersToPrimitiveTypes', () => { [{ name: 'foo'; type: 'string'; indexed: true }] > >().toEqualTypeOf<{ - foo?: string | string[] | null | undefined + foo?: string | readonly string[] | null | undefined }>() expectTypeOf< AbiEventParametersToPrimitiveTypes< @@ -321,8 +321,8 @@ test('AbiEventParametersToPrimitiveTypes', () => { ] > >().toEqualTypeOf<{ - foo?: string | string[] | null | undefined - bar?: number | number[] | null | undefined + foo?: string | readonly string[] | null | undefined + bar?: number | readonly number[] | null | undefined }>() type Named_AllowNonIndexed = AbiEventParametersToPrimitiveTypes< @@ -338,9 +338,9 @@ test('AbiEventParametersToPrimitiveTypes', () => { } > expectTypeOf().toEqualTypeOf<{ - foo?: string | string[] | null | undefined - bar?: number | number[] | null | undefined - baz?: `0x${string}` | `0x${string}`[] | null | undefined + foo?: string | readonly string[] | null | undefined + bar?: number | readonly number[] | null | undefined + baz?: `0x${string}` | readonly `0x${string}`[] | null | undefined }>() type Named_DisableUnion = AbiEventParametersToPrimitiveTypes< [ @@ -373,8 +373,8 @@ test('AbiEventParametersToPrimitiveTypes', () => { > >().toEqualTypeOf< | readonly [] - | readonly [string | string[] | null] - | readonly [string | string[] | null, number | number[] | null] + | readonly [string | readonly string[] | null] + | readonly [string | readonly string[] | null, number | readonly number[] | null] >() type Unnamed_AllowNonIndexed = AbiEventParametersToPrimitiveTypes< @@ -391,12 +391,12 @@ test('AbiEventParametersToPrimitiveTypes', () => { > expectTypeOf().toEqualTypeOf< | readonly [] - | readonly [string | string[] | null] - | readonly [string | string[] | null, number | number[] | null] + | readonly [string | readonly string[] | null] + | readonly [string | readonly string[] | null, number | readonly number[] | null] | readonly [ - string | string[] | null, - number | number[] | null, - `0x${string}` | `0x${string}`[] | null, + string | readonly string[] | null, + number | readonly number[] | null, + `0x${string}` | readonly `0x${string}`[] | null, ] >() @@ -426,7 +426,7 @@ test('AbiEventParametersToPrimitiveTypes', () => { > >().toEqualTypeOf< | readonly [] - | readonly [string | string[] | null] - | readonly [string | string[] | null, number | number[] | null] + | readonly [string | readonly string[] | null] + | readonly [string | readonly string[] | null, number | readonly number[] | null] >() }) diff --git a/src/types/contract.ts b/src/types/contract.ts index 4cbbf9a854..0f95e42c6f 100644 --- a/src/types/contract.ts +++ b/src/types/contract.ts @@ -466,8 +466,8 @@ export type LogTopicType< topic extends LogTopic = LogTopic, > = topic extends Hex ? primitiveType - : topic extends Hex[] - ? primitiveType[] + : topic extends readonly Hex[] + ? readonly primitiveType[] : topic extends null ? null : never diff --git a/src/types/misc.ts b/src/types/misc.ts index 625ba085cc..fdffe13618 100644 --- a/src/types/misc.ts +++ b/src/types/misc.ts @@ -3,7 +3,7 @@ import type { OneOf } from './utils.js' export type ByteArray = Uint8Array export type Hex = `0x${string}` export type Hash = `0x${string}` -export type LogTopic = Hex | Hex[] | null +export type LogTopic = Hex | readonly Hex[] | null export type SignableMessage = | string | {