@funkit/connect
Version:
Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.
50 lines (49 loc) • 1.59 kB
TypeScript
/**
* These are the data types that a feature flag can return.
* Note: they need to be values that can be expressed in JSON
*/
export type FlagConfig = BooleanFlagConfig | NumberFlagConfig | StringFlagConfig;
export interface BooleanFlagConfig {
type: 'boolean';
default_value: boolean;
overrides?: Override<boolean>[];
}
export interface NumberFlagConfig {
type: 'number';
default_value: number;
overrides?: Override<number>[];
}
export interface StringFlagConfig {
type: 'string';
default_value: string;
overrides?: Override<string>[];
}
export type InferFlagType<F extends FlagConfig> = F['type'] extends 'number' ? number : F['type'] extends 'string' ? string : F['type'] extends 'boolean' ? boolean : never;
export type Override<T> = {
/** non-empty list of conditions, any condition will cause the value to match */
if_any: Condition[];
/** non-empty list of conditions, all condition will cause the value to match */
if_all?: Condition[];
value: T;
};
type ConditionKey = 'userId' | 'apiKey' | 'ipCountry';
export type Condition = {
type: 'pctRollout';
key: ConditionKey;
/** whole number from 0 - 100 inclusive */
pct: number;
} | {
type: 'isAnyOf';
key: ConditionKey;
/** non-empty list of API keys */
values: string[];
};
export type AbstractFlags = Record<string, FlagConfig>;
export type AssetSelectionBannerConfig = {
chainId: number;
symbol: string;
name: string;
isChainNew?: boolean;
};
export type TokenTransferNewBadgeConfig = Record<number, string[]>;
export {};