diff --git a/packages/neon-core/src/rpc/Query.ts b/packages/neon-core/src/rpc/Query.ts index da08f291..e882e70f 100644 --- a/packages/neon-core/src/rpc/Query.ts +++ b/packages/neon-core/src/rpc/Query.ts @@ -5,6 +5,7 @@ import { ContractParam, StackItemJson, NEFJson, + isContractParam, } from "../sc"; import { BlockJson, Validator, BlockHeaderJson } from "../types"; import { HexString } from "../u"; @@ -573,7 +574,7 @@ export class Query { params: [ scriptHash, operation, - params.map((p) => (p instanceof ContractParam ? p.toJson() : p)), + params.map((p) => (isContractParam(p) ? p.toJson() : p)), signers.map((s) => (s instanceof Signer ? s.toJson() : s)), ], }); diff --git a/packages/neon-core/src/sc/ContractParam.ts b/packages/neon-core/src/sc/ContractParam.ts index df84de45..a717aedf 100644 --- a/packages/neon-core/src/sc/ContractParam.ts +++ b/packages/neon-core/src/sc/ContractParam.ts @@ -502,3 +502,18 @@ export function likeContractParam( cp.value !== undefined ); } + +// eslint-disable-next-line +export function isContractParam(value: any): value is ContractParam { + if (value instanceof ContractParam) { + return true; + } + + return ( + value.type !== undefined && + value.type in ContractParamType && + value.value !== null && + value.value !== undefined && + typeof value.toJson === "function" + ); +}