export type Constructor = new (...args: any[]) => T; export type AnyFunction = (...args: any) => any; export type UnionToIntersection = (Union extends any ? (argument: Union) => void : never ) extends (argument: infer Intersection) => void ? Intersection : never; export type Return = T extends AnyFunction ? ReturnType : T extends AnyFunction[] ? UnionToIntersection> : never export const MissingWalletError = new Error("wallet is required"); export function getStructure(template) { let structure = { fields: [] as Array} for (const [key, value] of Object.entries(template)) { let field: any = {} field.name = key field.type = typeof value structure.fields.push(field) } return structure }