Skip to content

Commit

Permalink
CU-86a0uktwy - Move typeChecker to neon-dappkit-types
Browse files Browse the repository at this point in the history
  • Loading branch information
luc10921 authored and melanke committed Sep 27, 2023
1 parent de0048d commit de9a859
Show file tree
Hide file tree
Showing 15 changed files with 463 additions and 144 deletions.
15 changes: 15 additions & 0 deletions packages/neon-dappkit-types/dist/TypeChecker.d.ts
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 };
60 changes: 60 additions & 0 deletions packages/neon-dappkit-types/dist/TypeChecker.js
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;
1 change: 1 addition & 0 deletions packages/neon-dappkit-types/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './Neo3EventListener';
export * from './Neo3Invoker';
export * from './Neo3Parser';
export * from './Neo3Signer';
export * from './TypeChecker';
1 change: 1 addition & 0 deletions packages/neon-dappkit-types/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ __exportStar(require("./Neo3EventListener"), exports);
__exportStar(require("./Neo3Invoker"), exports);
__exportStar(require("./Neo3Parser"), exports);
__exportStar(require("./Neo3Signer"), exports);
__exportStar(require("./TypeChecker"), exports);
3 changes: 2 additions & 1 deletion packages/neon-dappkit-types/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.9389
<li class="tsd-kind-type-alias"><a href="types/WitnessCondition.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Witness<wbr/>Condition</a></li>
<li class="tsd-kind-variable"><a href="variables/ABI_TYPES.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-32-path"></rect><path d="M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z" fill="var(--color-text)" id="icon-32-text"></path></svg>ABI_<wbr/>TYPES</a></li>
<li class="tsd-kind-variable"><a href="variables/HINT_TYPES.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>HINT_<wbr/>TYPES</a></li>
<li class="tsd-kind-variable"><a href="variables/INTERNAL_TYPES.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>INTERNAL_<wbr/>TYPES</a></li></ul></nav></div></div>
<li class="tsd-kind-variable"><a href="variables/INTERNAL_TYPES.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>INTERNAL_<wbr/>TYPES</a></li>
<li class="tsd-kind-variable"><a href="variables/TypeChecker.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>Type<wbr/>Checker</a></li></ul></nav></div></div>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
<div class="overlay"></div><script src="assets/main.js"></script></body></html>
4 changes: 3 additions & 1 deletion packages/neon-dappkit-types/docs/modules.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ <h3 class="tsd-index-heading">Variables</h3>
<div class="tsd-index-list"><a href="variables/ABI_TYPES.html" class="tsd-index-link tsd-kind-variable"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-32-path"></rect><path d="M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z" fill="var(--color-text)" id="icon-32-text"></path></svg><span>ABI_<wbr/>TYPES</span></a>
<a href="variables/HINT_TYPES.html" class="tsd-index-link tsd-kind-variable"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg><span>HINT_<wbr/>TYPES</span></a>
<a href="variables/INTERNAL_TYPES.html" class="tsd-index-link tsd-kind-variable"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg><span>INTERNAL_<wbr/>TYPES</span></a>
<a href="variables/TypeChecker.html" class="tsd-index-link tsd-kind-variable"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg><span>Type<wbr/>Checker</span></a>
</div></section></section></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<div class="tsd-navigation settings">
Expand Down Expand Up @@ -175,7 +176,8 @@ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.9389
<li class="tsd-kind-type-alias"><a href="types/WitnessCondition.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Witness<wbr/>Condition</a></li>
<li class="tsd-kind-variable"><a href="variables/ABI_TYPES.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>ABI_<wbr/>TYPES</a></li>
<li class="tsd-kind-variable"><a href="variables/HINT_TYPES.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>HINT_<wbr/>TYPES</a></li>
<li class="tsd-kind-variable"><a href="variables/INTERNAL_TYPES.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>INTERNAL_<wbr/>TYPES</a></li></ul></nav></div></div>
<li class="tsd-kind-variable"><a href="variables/INTERNAL_TYPES.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>INTERNAL_<wbr/>TYPES</a></li>
<li class="tsd-kind-variable"><a href="variables/TypeChecker.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>Type<wbr/>Checker</a></li></ul></nav></div></div>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
<div class="overlay"></div><script src="assets/main.js"></script></body></html>
Loading

0 comments on commit de9a859

Please sign in to comment.