>;
}
/**
* When displaying a {@link PCD} in Zupass, the PCDUI methods will be used to generate a
* card and, optionally, a header (used only when {@link PCDPackage.getDisplayOptions} does
* not return a header).
*
* @typeParam {@link P} the type of {@link PCD} rendered by this {@link PCDUI}
* @typeParam {@link E} any extended props required to render the {@link PCD} card
*/
export interface PCDUI {
/**
* Intended to be used by Zupass. Given a {@link PCD}, renders the body of a card
* that appears in Zupass representing this {@link PCD}.
*/
renderCardBody({ pcd }: {
pcd: P;
} & E): React.ReactElement;
/**
* If the {@link DisplayOptions#header} returned by {@link PCDPackage#getDisplayOptions}
* is undefined, Zupass will call this function and use the result as the header of the
* card.
*/
getHeader?({ pcd }: {
pcd: P;
}): React.ReactElement;
}
/**
* The input and output of a {@link PCDPackage}'s {@link PCDPackage.serialize} and
* {@link PCDPackage.deserialize} methods.
*/
export interface SerializedPCD<_T extends PCD = PCD> {
type: string;
pcd: string;
}
/**
* Given a type extending {@link PCDPackage}, extracts the type of the parameter of its
* {@link PCDPackage.prove} function.
*/
export type ArgsOf = T extends PCDPackage ? U : T;
/**
* Given a type extending {@link PCDPackage}, extracts the type of {@link PCD} it
* encapsulates.
*/
export type PCDOf = T extends PCDPackage ? PCD : T;
/**
* This interface can be optionally returned by the package for any given
* PCD, which allows the package some degree of control over how the PCD
* is displayed in Zupass.
*/
export interface DisplayOptions {
/**
* Shown to the user in the main page of Zupass, where they can
* see all of their cards. If `header` is undefined, the Zupass will use
* `getHeader` on {@link PCDUI}.
*/
header?: string;
/**
* Shown to the user in the `GenericProveScreen`, allowing them to
* disambiguate between different pcds of the same type. In the future,
* we'll have a better way to disambiguate between them.
*/
displayName?: string;
}
export type PCDTypeNameOf = T extends PCDPackage ? T["name"] : T;
export interface ArgumentType {
type: T;
specificType: U;
}
export interface Argument> {
argumentType: TypeName;
value?: ValueType;
userProvided?: boolean;
/**
* Display name for the argument. If not provided, the {@link Argument} key is displayed in title case.
*/
displayName?: string;
/**
* Tooltip text for the argument. If {@link displayName} is set to empty string, the tooltip text is displayed in line.
*/
description?: string;
/**
* Can be used to hide certain advanced arguments from the UI by default.
* Users can still reveal them by clicking the "show more" button. Defaults
* to true.
*/
defaultVisible?: boolean;
/**
* Whether to hide the icon left to the argument. Defaults to false.
*/
hideIcon?: boolean;
/**
* Can be used to validate user input before proof generation as well as
* proactive filtering of options, such as PCDs, in the UI.
*/
validatorParams?: ValidatorParams;
}
/**
* Fields of the object passed into {@link PCDPackage.prove} can only represent
* one of the following types. {@link Unknown} is included to be used in a similar
* way as {@code unknown} is used in TypeScript.
*/
export declare enum ArgumentTypeName {
String = "String",
Number = "Number",
BigInt = "BigInt",
Boolean = "Boolean",
Object = "Object",
StringArray = "StringArray",
PCD = "PCD",
RecordContainer = "RecordContainer",
ToggleList = "ToggleList",
Unknown = "Unknown"
}
/**
* Primitive argument type names, i.e. names for argument types other than the record container type.
*/
export type PrimitiveArgumentTypeName = Exclude;
/**
* Non-recursive record container argument type. This should be thought of as a
* container of named arguments of a single primitive type.
*/
export type RecordContainerArgument, ValidatorParams = Record> = Argument, ValidatorParams>;
export declare function isRecordContainerArgument>(arg: Argument): arg is RecordContainerArgument;
export type StringArgument = Argument;
export declare function isStringArgument(arg: Argument): arg is StringArgument;
export type NumberArgument = Argument;
export declare function isNumberArgument(arg: Argument): arg is NumberArgument;
export type BigIntArgument = Argument;
export declare function isBigIntArgument(arg: Argument): arg is BigIntArgument;
export type BooleanArgument = Argument;
export declare function isBooleanArgument(arg: Argument): arg is BooleanArgument;
export type ObjectArgument = Argument & {
remoteUrl?: string;
};
export declare function isObjectArgument(arg: Argument): arg is ObjectArgument;
export type StringArrayArgument = Argument;
export declare function isStringArrayArgument(arg: Argument): arg is StringArrayArgument;
export type PCDArgument = Argument, ValidatorParams> & {
pcdType?: string;
};
export declare function isPCDArgument(arg: Argument): arg is PCDArgument;
export type ToggleList = Record;
export type ToogleListArgument = Argument;
export declare function isToggleListArgument(arg: Argument): arg is ToogleListArgument;
export type RevealList = Record<`reveal${string}`, boolean>;
export type RevealListArgument = Argument;
export declare function isRevealListArgument(arg: ToogleListArgument): arg is RevealListArgument;
export interface ProveDisplayOptions>> {
defaultArgs?: ArgsDisplayOptions;
}
export type ArgsDisplayOptions>> = {
[Property in keyof Args]: DisplayArg;
};
export type RawValueType> = T extends PCDArgument ? U : T extends Argument ? U : T;
/**
* Argument validator as a predicate taking both the argument's value and its
* validator parameters as inputs. In the case of a record argument, this is a
* mapping from record keys to such predicates for the record value type.
*/
export type ArgumentValidator> = T extends RecordContainerArgument ? (s: S, value: RawValueType, params: T["validatorParams"] & U["validatorParams"]) => boolean : (value: RawValueType, params: T["validatorParams"]) => boolean;
/**
* Enriched Argument for display purposes
*/
export type DisplayArg> = Arg & {
validate?: ArgumentValidator;
};
//# sourceMappingURL=pcd.d.ts.map