From cf2cae9b39b116922271dbb4d3dcaf1002938102 Mon Sep 17 00:00:00 2001 From: kevin Heifner Date: Fri, 25 Sep 2026 15:13:18 -0500 Subject: [PATCH] fix(sdk-core): narrow the slug_name self-encoding guard for strict null checks ABISerializableObject declares toABI optional, so narrowing to it left the call possibly undefined under the strict-null typecheck and failed test:ci on master (and the v1.0.93 tag-release). Narrow to a type whose toABI is present. Change-Id: I6b4a61bcdf946c5b0ab2066fb65332cbd6d0c55c --- packages/sdk-core/src/serializer/Builtins.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/sdk-core/src/serializer/Builtins.ts b/packages/sdk-core/src/serializer/Builtins.ts index 3f3ad4e..2666334 100644 --- a/packages/sdk-core/src/serializer/Builtins.ts +++ b/packages/sdk-core/src/serializer/Builtins.ts @@ -81,12 +81,9 @@ const SlugNameType = { value === SLUG_NAME_ZERO ? SLUG_NAME_ZERO : SlugName.toString(slugValue(value, SlugNameType.abiName)), - toABI: ( - value: SlugNameValue | ABISerializableObject, - encoder: ABIEncoder - ) => { + toABI: (value: SlugNameValue | SelfEncodingValue, encoder: ABIEncoder) => { match(value) - .when(isSerializable, serializable => serializable.toABI(encoder)) + .when(isSelfEncoding, selfEncoding => selfEncoding.toABI(encoder)) .with(SLUG_NAME_ZERO, () => UInt64.from(0).toABI(encoder)) .otherwise(carrier => UInt64.from( @@ -96,8 +93,13 @@ const SlugNameType = { } } -/** True for an already-typed ABI value, e.g. a `ChainsSlugName` passed to the generic encoder. */ -function isSerializable(value: unknown): value is ABISerializableObject { +/** An already-typed ABI value that encodes itself, e.g. a `ChainsSlugName`. */ +interface SelfEncodingValue { + toABI(encoder: ABIEncoder): void +} + +/** True for a value whose `toABI` is present — `ABISerializableObject` declares it optional. */ +function isSelfEncoding(value: unknown): value is SelfEncodingValue { return ( typeof value === "object" && value !== null &&