Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
32 lines
No EOL
791 B
TypeScript
Executable file
32 lines
No EOL
791 B
TypeScript
Executable file
export type Constructor<T> = new (...args: any[]) => T;
|
|
|
|
export type AnyFunction = (...args: any) => any;
|
|
|
|
export type UnionToIntersection<Union> =
|
|
(Union extends any
|
|
? (argument: Union) => void
|
|
: never
|
|
) extends (argument: infer Intersection) => void
|
|
? Intersection
|
|
: never;
|
|
|
|
export type Return<T> =
|
|
T extends AnyFunction
|
|
? ReturnType<T>
|
|
: T extends AnyFunction[]
|
|
? UnionToIntersection<ReturnType<T[number]>>
|
|
: never
|
|
|
|
|
|
export const MissingWalletError = new Error("wallet is required");
|
|
|
|
export function getStructure(template) {
|
|
let structure = { fields: [] as Array<unknown>}
|
|
for (const [key, value] of Object.entries(template)) {
|
|
let field: any = {}
|
|
field.name = key
|
|
field.type = typeof value
|
|
structure.fields.push(field)
|
|
}
|
|
return structure
|
|
} |