@saberhq/anchor-contrib
Advanced tools
Comparing version 1.2.4 to 1.2.5
@@ -40,3 +40,3 @@ /// <reference types="node" /> | ||
declare type AccountsNamespace<A> = { | ||
[K in keyof A]: AccountClient & { | ||
[K in keyof A]: Omit<AccountClient, "fetch" | "all" | "associated"> & { | ||
/** | ||
@@ -108,20 +108,24 @@ * Returns a deserialized account. | ||
export declare type AnchorError<T extends Idl> = NonNullable<T["errors"]>[number]; | ||
declare type FieldsOfType<I extends IdlTypeDef & { | ||
declare type FieldsOfType<I extends { | ||
type: IdlTypeDefTyStruct; | ||
}> = I["type"]["fields"][number]; | ||
declare type AnchorTypeDef<I extends IdlTypeDef, Defined> = I extends { | ||
declare type AnchorTypeDef<I extends { | ||
type: IdlTypeDefTyStruct; | ||
} ? { | ||
}, Defined> = { | ||
[F in FieldsOfType<I>["name"]]: DecodeType<(FieldsOfType<I> & { | ||
name: F; | ||
})["type"], Defined>; | ||
} : string; | ||
}; | ||
declare type AnchorTypeDefs<T extends IdlTypeDef[], Defined> = { | ||
[K in T[number]["name"]]: AnchorTypeDef<T[number] & { | ||
[K in T[number]["name"]]: T[number] extends { | ||
type: IdlTypeDefTyStruct; | ||
} ? AnchorTypeDef<T[number] & { | ||
name: K; | ||
}, Defined>; | ||
}, Defined> : string; | ||
}; | ||
export declare type AnchorDefined<T extends Idl, D = Record<string, never>> = AnchorTypeDefs<NonNullable<T["types"]>, D>; | ||
export declare type AnchorAccounts<T extends Idl, Defined> = AnchorTypeDefs<NonNullable<T["accounts"]>, Defined>; | ||
export declare type AnchorState<T extends Idl, Defined> = AnchorTypeDef<NonNullable<T["state"]>["struct"], Defined>; | ||
export declare type AnchorState<T extends Idl, Defined> = NonNullable<T["state"]>["struct"] extends { | ||
type: IdlTypeDefTyStruct; | ||
} ? AnchorTypeDef<NonNullable<T["state"]>["struct"], Defined> : never; | ||
export declare type AnchorTypes<T extends Idl, AccountMap = Record<string, never>, D = Record<string, never>, DEF = AnchorDefined<T, D>> = { | ||
@@ -128,0 +132,0 @@ Defined: DEF; |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"main": "dist/index.js", | ||
@@ -29,3 +29,3 @@ "author": "Ian Macalinao <ian@saber.so>", | ||
}, | ||
"gitHead": "d9a566b79c996cd3b334f45bf7d1fe44c17f0477" | ||
"gitHead": "2450dd843ab6aabc9a927ebf6b5d2e87cf6e420c" | ||
} |
@@ -92,3 +92,3 @@ import type { | ||
type AccountsNamespace<A> = { | ||
[K in keyof A]: AccountClient & { | ||
[K in keyof A]: Omit<AccountClient, "fetch" | "all" | "associated"> & { | ||
/** | ||
@@ -179,3 +179,3 @@ * Returns a deserialized account. | ||
type FieldsOfType< | ||
I extends IdlTypeDef & { | ||
I extends { | ||
type: IdlTypeDefTyStruct; | ||
@@ -185,15 +185,13 @@ } | ||
type AnchorTypeDef<I extends IdlTypeDef, Defined> = I extends { | ||
type: IdlTypeDefTyStruct; | ||
} | ||
? { | ||
[F in FieldsOfType<I>["name"]]: DecodeType< | ||
(FieldsOfType<I> & { name: F })["type"], | ||
Defined | ||
>; | ||
} | ||
: string; | ||
type AnchorTypeDef<I extends { type: IdlTypeDefTyStruct }, Defined> = { | ||
[F in FieldsOfType<I>["name"]]: DecodeType< | ||
(FieldsOfType<I> & { name: F })["type"], | ||
Defined | ||
>; | ||
}; | ||
type AnchorTypeDefs<T extends IdlTypeDef[], Defined> = { | ||
[K in T[number]["name"]]: AnchorTypeDef<T[number] & { name: K }, Defined>; | ||
[K in T[number]["name"]]: T[number] extends { type: IdlTypeDefTyStruct } | ||
? AnchorTypeDef<T[number] & { name: K }, Defined> | ||
: string; | ||
}; | ||
@@ -211,6 +209,7 @@ | ||
export type AnchorState<T extends Idl, Defined> = AnchorTypeDef< | ||
NonNullable<T["state"]>["struct"], | ||
Defined | ||
>; | ||
export type AnchorState<T extends Idl, Defined> = NonNullable< | ||
T["state"] | ||
>["struct"] extends { type: IdlTypeDefTyStruct } | ||
? AnchorTypeDef<NonNullable<T["state"]>["struct"], Defined> | ||
: never; | ||
@@ -217,0 +216,0 @@ export type AnchorTypes< |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33993
408