diff --git a/packages/neon-dappkit-types/dist/TypeChecker.d.ts b/packages/neon-dappkit-types/dist/TypeChecker.d.ts new file mode 100644 index 0000000..cfc1b4b --- /dev/null +++ b/packages/neon-dappkit-types/dist/TypeChecker.d.ts @@ -0,0 +1,15 @@ +import { AnyArgType, BooleanArgType, IntegerArgType, ArrayResponseArgType, MapResponseArgType, ByteStringArgType, InteropInterfaceArgType, PointerArgType, BufferArgType, StructArgType, RpcResponseStackItem } from './Neo3Invoker'; +declare const TypeChecker: { + isStackTypeAny(item: any): item is AnyArgType; + isStackTypeBoolean(item: any): item is BooleanArgType; + isStackTypeInteger(item: any): item is IntegerArgType; + isStackTypeArray(item: any): item is ArrayResponseArgType; + isStackTypeMap(item: any): item is MapResponseArgType; + isStackTypeByteString(item: any): item is ByteStringArgType; + isStackTypeInteropInterface(item: any): item is InteropInterfaceArgType; + isStackTypePointer(item: any): item is PointerArgType; + isStackTypeBuffer(item: any): item is BufferArgType; + isStackTypeStruct(item: any): item is StructArgType; + isRpcResponseStackItem(item: any): item is RpcResponseStackItem; +}; +export { TypeChecker }; diff --git a/packages/neon-dappkit-types/dist/TypeChecker.js b/packages/neon-dappkit-types/dist/TypeChecker.js new file mode 100644 index 0000000..de7bc0b --- /dev/null +++ b/packages/neon-dappkit-types/dist/TypeChecker.js @@ -0,0 +1,60 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TypeChecker = void 0; +const TypeChecker = { + isStackTypeAny(item) { + return typeof item === 'object' && item.type === 'Any'; + }, + isStackTypeBoolean(item) { + return typeof item === 'object' && item.type === 'Boolean' && typeof item.value === 'boolean'; + }, + isStackTypeInteger(item) { + return typeof item === 'object' && item.type === 'Integer' && typeof item.value === 'string'; + }, + isStackTypeArray(item) { + return (typeof item === 'object' && + item.type === 'Array' && + Array.isArray(item.value) && + item.value.every((i) => TypeChecker.isRpcResponseStackItem(i))); + }, + isStackTypeMap(item) { + return (typeof item === 'object' && + item.type === 'Map' && + Array.isArray(item.value) && + item.value.every((i) => TypeChecker.isRpcResponseStackItem(i.key) && TypeChecker.isRpcResponseStackItem(i.value))); + }, + isStackTypeByteString(item) { + return typeof item === 'object' && item.type === 'ByteString' && typeof item.value === 'string'; + }, + isStackTypeInteropInterface(item) { + return (typeof item === 'object' && + item.type === 'InteropInterface' && + typeof item.interface === 'string' && + typeof item.id === 'string'); + }, + isStackTypePointer(item) { + return typeof item === 'object' && item.type === 'Pointer' && typeof item.value === 'string'; + }, + isStackTypeBuffer(item) { + return typeof item === 'object' && item.type === 'Buffer' && typeof item.value === 'string'; + }, + isStackTypeStruct(item) { + return (typeof item === 'object' && + item.type === 'Struct' && + Array.isArray(item.value) && + item.value.every((i) => TypeChecker.isRpcResponseStackItem(i))); + }, + isRpcResponseStackItem(item) { + return (TypeChecker.isStackTypeAny(item) || + TypeChecker.isStackTypeBoolean(item) || + TypeChecker.isStackTypeInteger(item) || + TypeChecker.isStackTypeArray(item) || + TypeChecker.isStackTypeMap(item) || + TypeChecker.isStackTypeByteString(item) || + TypeChecker.isStackTypeInteropInterface(item) || + TypeChecker.isStackTypePointer(item) || + TypeChecker.isStackTypeBuffer(item) || + TypeChecker.isStackTypeStruct(item)); + }, +}; +exports.TypeChecker = TypeChecker; diff --git a/packages/neon-dappkit-types/dist/index.d.ts b/packages/neon-dappkit-types/dist/index.d.ts index 8f90c7c..fcbd930 100644 --- a/packages/neon-dappkit-types/dist/index.d.ts +++ b/packages/neon-dappkit-types/dist/index.d.ts @@ -2,3 +2,4 @@ export * from './Neo3EventListener'; export * from './Neo3Invoker'; export * from './Neo3Parser'; export * from './Neo3Signer'; +export * from './TypeChecker'; diff --git a/packages/neon-dappkit-types/dist/index.js b/packages/neon-dappkit-types/dist/index.js index 41720f6..4ba1924 100644 --- a/packages/neon-dappkit-types/dist/index.js +++ b/packages/neon-dappkit-types/dist/index.js @@ -18,3 +18,4 @@ __exportStar(require("./Neo3EventListener"), exports); __exportStar(require("./Neo3Invoker"), exports); __exportStar(require("./Neo3Parser"), exports); __exportStar(require("./Neo3Signer"), exports); +__exportStar(require("./TypeChecker"), exports); diff --git a/packages/neon-dappkit-types/docs/index.html b/packages/neon-dappkit-types/docs/index.html index 5600693..123a7eb 100644 --- a/packages/neon-dappkit-types/docs/index.html +++ b/packages/neon-dappkit-types/docs/index.html @@ -143,7 +143,8 @@