-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CU-86a0uktwy - Move typeChecker to neon-dappkit-types
- Loading branch information
Showing
15 changed files
with
463 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.