@alexkeating/common-utilities
Version:
Our **Common Utilities** package is a set of helper tools and utilities that are used throughout our libraries and apps. This includes things like our constants, types that are commonly shared across packages, and various utilities and helper functions.
112 lines (111 loc) • 3.5 kB
TypeScript
import { JSXElementConstructor } from 'react';
import { ValidateField } from '../utils';
import { ABI, ArgType } from './contract';
import { EthAddress, RequireOnlyOne } from './general';
import { Keychain } from './keychains';
export declare type LookupType = Record<string, keyof JSX.IntrinsicElements | JSXElementConstructor<any>>;
export declare type FieldValidationType = keyof typeof ValidateField;
export declare type FieldLegoBase<Lookup extends LookupType> = {
[FieldType in keyof Lookup]: React.ComponentProps<Lookup[FieldType]> & {
type: FieldType;
expectType?: FieldValidationType;
};
}[keyof Lookup];
export declare type FormLegoBase<Lookup extends LookupType = LookupType> = {
id: string;
title: string;
subtitle?: string;
description?: string;
tx?: TXLego;
fields: FieldLegoBase<Lookup>[];
requiredFields?: Record<string, boolean>;
log?: boolean;
devtool?: boolean;
submitButtonText?: string;
};
export declare type RequiredFields = Record<string, boolean>;
export declare type StringSearch = `.${string}`;
declare type DetailsSchema = Record<string, ValidArgType>;
export declare type JSONDetailsSearch = {
type: 'JSONDetails';
jsonSchema: DetailsSchema;
};
export declare type MulticallAction = {
contract: ContractLego;
method: string;
value?: ValidArgType;
operations?: ValidArgType;
args: ValidArgType[];
data?: string;
};
export declare type MulticallArg = {
type: 'multicall';
actions: MulticallAction[];
};
export declare type EstmimateGas = {
type: 'estimateGas';
actions: MulticallAction[];
bufferPercentage?: number;
};
declare type ProposalExpiry = {
type: 'proposalExpiry';
search?: StringSearch;
fallback: number;
};
declare type StaticArg = {
type: 'static';
value: ArgType;
};
declare type SingletonSearch = {
type: 'singleton';
keychain: Keychain;
};
export declare type ArgEncode = {
type: 'argEncode';
args: ValidArgType[];
solidityTypes: string[];
};
export declare type NestedArray = {
type: 'nestedArray';
args: ValidArgType[];
};
export declare type IPFSPinata = {
type: 'ipfsPinata';
content: ValidArgType;
};
export declare type ValidArgType = StringSearch | JSONDetailsSearch | EstmimateGas | SingletonSearch | NestedArray | MulticallArg | ProposalExpiry | StaticArg | IPFSPinata | ArgEncode;
export declare type TxStates = 'idle' | 'submitting' | 'polling' | 'pollFailed' | 'failed' | 'success';
export declare type TXLegoBase = {
id: string;
contract: ContractLego;
method: string;
customPoll?: string;
args?: ValidArgType[];
argCallback?: string;
staticArgs?: ArgType[];
};
export declare type TXLego = RequireOnlyOne<TXLegoBase, 'args' | 'argCallback' | 'staticArgs'>;
export declare type StaticContract = {
contractName: string;
type: 'static';
abi: ABI;
targetAddress: Keychain | StringSearch | EthAddress;
};
export declare type LocalContract = {
contractName: string;
type: 'local';
targetAddress: Keychain | StringSearch | EthAddress;
};
export declare type RemoteContract = {
contractName: string;
type: 'remote';
targetAddress: Keychain | StringSearch | EthAddress;
};
export declare type ProcessedContract = {
type: 'processed';
contractName: string;
abi: ABI;
address: string;
};
export declare type ContractLego = StaticContract | RemoteContract | LocalContract | ProcessedContract;
export {};