Skip to content

Commit d1e6a13

Browse files
committed
refactor
1 parent 5d66e6d commit d1e6a13

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

src/BorshSchema.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Schema } from 'borsh';
2-
import { EnumVariants, StructFields } from './types';
32
import { EnumType, StructType } from 'borsh/lib/types/types';
43

54
export class BorshSchema {
@@ -326,3 +325,9 @@ function toStructTypeStruct(fields: StructFields): StructType['struct'] {
326325
function toEnumTypeEnum(variants: EnumVariants): EnumType['enum'] {
327326
return Object.entries(variants).map<StructType>(([key, value]) => ({ struct: { [key]: value.toSchema() } }));
328327
}
328+
329+
export type Unit = Record<string, never>;
330+
331+
export type StructFields = Record<string, BorshSchema>;
332+
333+
export type EnumVariants = Record<string, BorshSchema>;

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Buffer } from 'buffer';
2-
import { BorshSchema } from './BorshSchema';
3-
import { EnumVariants, StructFields, Unit } from './types';
2+
import { BorshSchema, EnumVariants, StructFields, Unit } from './BorshSchema';
43
import { serialize, deserialize } from 'borsh';
54

65
function borshSerialize<T>(schema: BorshSchema, data: T): Buffer {

src/types.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"target": "ESNext",
44
"module": "CommonJS",
55
"outDir": "dist",
6-
"importHelpers": true,
6+
"importHelpers": false,
77
// output .d.ts declaration files for consumers
88
"declaration": true,
99
// output .js.map sourcemap files for consumers

0 commit comments

Comments
 (0)