diff --git a/package.json b/package.json index fa92ac3..7a99ecf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.16.0-rc.23", + "version": "0.16.0-rc.24", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/utils/typeHelpers.ts b/src/utils/typeHelpers.ts index eb901b7..a65cbb8 100644 --- a/src/utils/typeHelpers.ts +++ b/src/utils/typeHelpers.ts @@ -3,7 +3,7 @@ type WithReason = { } type WithCodeError = Error & { - code: number; + code: number | string; } type WithMessage = { @@ -41,9 +41,9 @@ export function hasProp, K extends PropertyKey } export function isWithCode(candidate: unknown): candidate is WithCodeError { - if (!isUnknownObject(candidate)) return false; - const hasCodeProperty = hasProp(candidate, 'code') && typeof candidate.code === 'number'; - return hasCodeProperty; + if (!isUnknownObject(candidate) || !hasProp(candidate, 'code')) return false; + const type = typeof candidate.code; + return type === 'number' || type === 'string'; } export function isWithReason(candidate: unknown): candidate is WithReason {