From c0e5d7b361c9b0cff2df1e9ae11d86ee9d672ecb Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 16 Jul 2024 19:33:45 +0100 Subject: [PATCH] chore: simplify the `EnumCoder::isNativeEnum` check --- packages/abi-coder/src/encoding/coders/EnumCoder.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/abi-coder/src/encoding/coders/EnumCoder.ts b/packages/abi-coder/src/encoding/coders/EnumCoder.ts index 72f3b1e20e..0124042bfe 100644 --- a/packages/abi-coder/src/encoding/coders/EnumCoder.ts +++ b/packages/abi-coder/src/encoding/coders/EnumCoder.ts @@ -9,7 +9,6 @@ import { hasNestedOption } from '../../utils/utilities'; import type { TypesOfCoder } from './AbstractCoder'; import { Coder } from './AbstractCoder'; import { BigNumberCoder } from './BigNumberCoder'; -import type { TupleCoder } from './TupleCoder'; export type InputValueOf> = RequireExactlyOne<{ [P in keyof TCoders]: TypesOfCoder['Input']; @@ -42,14 +41,9 @@ export class EnumCoder> extends Coder< this.#shouldValidateLength = !(this.type === OPTION_CODER_TYPE || hasNestedOption(coders)); } - // We parse a native enum as an empty tuple, so we are looking for a tuple with no child coders. - // The '()' is enough but the child coders is a stricter check. + // Checks that we're handling a native enum that is of type void. #isNativeEnum(coder: Coder): boolean { - if (this.type !== OPTION_CODER_TYPE && coder.type === VOID_TYPE) { - const tupleCoder = coder as TupleCoder<[]>; - return tupleCoder.coders.length === 0; - } - return false; + return this.type !== OPTION_CODER_TYPE && coder.type === VOID_TYPE; } #encodeNativeEnum(value: string): Uint8Array {