types APIs
- SimpleOptions
- RootState
- User
- ChainType
- FeedbackCategoryAPI
- FeedbackStatusAPI
- FeedbackUserProfileAPI
- NavItems
- SingleNavItem
- NonNullableChildrenDeep
- SingleArticle
- ColumnType
- DataType
- Hub
- PluginConfig
- RawEventMessage
- DualStakingInfo
- StakingInfo
- SyrupInfo
- CommonStakingInfo
- LairInfo
- StakingBasic
- DualStakingBasic
- SyrupBasic
- Questionnaire
- TaskStatuses
- LoginPayload
- SignupPayload
- MutationType
- ProteinSize
- Config
- Themes
- defaults
- CoordinateSpaceInitial
- Background
- Metric
- Metadata
- TManageValue
- Domain
- Organization
- OrganizationTag
- Scan
- ScanSchema
- Query
- SavedSearch
- Role
- ScanTask
- Vulnerability
- GenericObject
- Annotation
- AnnotationList
- VideoAnnotation
- IconName
- IllustrationName
- INotification
- BottomTabScreens
- KYCScreens
- CCVPScreens
- LoginScreens
- PreAuthScreens
- SignUpScreens
- TFAScreens
- PNVScreens
- ProfileScreens
- SecurityScreens
- SMTYFScreens
- WalletScreens
- WithdrawalScreens
- StackNavigationProps
- Coin
- Country
- TransactionStatus
- SetApiActionPayloadInterface
- LoadingStateInterface
- MessageStateInterface
- UiOptionType
- ApiDiffInterface
- ApiStateInterface
- Account
- NFT
- NFTDetails
- AlertType
- DefaultTemplateOptions
- ProviderProps
- AlertTimer
- AlertInstance
- AlertOptions
- TemplateAlertOptions
- AlertContainerFactory
- ChainBase
- ChainNetwork
- WalletId
- ProposalType
- ChainEventNotification
- WebsocketMessageNames
- WebsocketNamespaces
- NotificationCategories
- InviteCodeAttributes
- IPostNotificationData
- ChainCategoryType
- Screens
- NavigationProperty
- IP
- Maybe
- Tuple
- ChainProperties
- ApiPromise
- ApiAction
- BlueprintOptions
- ContractQuery
- ContractOptions
- ContractTx
- KeyringPair
- ContractDryRunParams
- InstantiateData
- SubmittableExtrinsic
- DbState
- OnInstantiateSuccess$Code
- OnInstantiateSuccess$Hash
- InstantiateState
- ApiState
- OrFalsy
- Bytes
- AbiParam
- Registry
- Weight
- SubmittableResult
- Hash
- CodeBundleDocument
- MyCodeBundles
- ContractDocument
- MyContracts
- Database
- DbStatistics
- UserDocument
- QueuedTxOptions
- TransactionsState
- DropdownOption
- DropdownProps
- ValidFormField
- SetState
- BN
- CallResult
- ContractPromise
- RegistryError
- Abi
- TypeDef
- Validation
- FileState
- UseWeight
- ArgComponentProps
- TypeDefInfo
- UseMetadata
- AbiMessage
- AbiConstructor
- InstantiateProps
- CodeSubmittableResult
- BlueprintSubmittableResult
- BlueprintPromise
- Step2FormData
- TxOptions
- TransactionsQueue
- Keyring
- DbQuery
- UseBalance
- CodeBundle
- ValidateFn
- MetadataState
- UseStepper
- UseToggle
- Party
- Restaurant
- BoardMember
- Id
- Label
- Priority
- Avatar
- PriorityValue
- AuthSetup
- IColumn
- Board
- ITask
- TaskComment
- NewTaskComment
- WithTheme
- UserDetail
- TasksByColumn
- NewTask
- ValueOf
- APIResponse
- Nullable
- Currency
- Route
- Author
- Post
- Category
- Watch
- ComputeCallback
Other Related APIs
- react#useState
- react#useEffect
- react#useCallback
- react#useMemo
- types#ChainType
- types#ApiPromise
- types#OrFalsy
- types#Bytes
- types#AbiParam
- types#Weight
- types#SubmittableResult
- types#Hash
- types#CodeBundleDocument
- types#ValidFormField
- types#SetState
- types#TypeDef
- @polkadot/util-crypto#randomAsU8a
- @polkadot/util#u8aToU8a
- @polkadot/util#BN_TEN
- @polkadot/util#compactAddLength
- @polkadot/util#isNumber
types#Registry TypeScript Examples
The following examples show how to use
types#Registry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts From contracts-ui with GNU General Public License v3.0 | 6 votes |
export function transformUserInput(
registry: Registry,
messageArgs: AbiParam[],
values?: Record<string, unknown>
) {
return messageArgs.map(({ name, type: { type } }) => {
const value = values ? values[name] : null;
if (type === 'Balance') {
return registry.createType('Balance', value);
}
return value || null;
});
}
Example #2
Source File: findComponent.tsx From contracts-ui with GNU General Public License v3.0 | 4 votes |
// nestingNumber counts the depth of nested components
export function findComponent(
registry: Registry,
type: TypeDef,
nestingNumber = 0
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): React.ComponentType<ArgComponentProps<any>> {
if (type.info === TypeDefInfo.Si) {
return findComponent(registry, registry.lookup.getTypeDef(type.type));
}
if (type.info === TypeDefInfo.Option) {
return (props: React.PropsWithChildren<ValidFormField<unknown>>) => (
<Option
component={findComponent(registry, type.sub as TypeDef)}
registry={registry}
typeDef={type}
{...props}
/>
);
}
if (type.info === TypeDefInfo.Enum) {
return (props: React.PropsWithChildren<ValidFormField<Record<string, unknown>>>) => (
<Enum
components={(type.sub as TypeDef[]).map(enumVariant =>
findComponent(registry, enumVariant)
)}
registry={registry}
typeDef={type}
{...props}
/>
);
}
if (type.info === TypeDefInfo.Struct) {
if (Array.isArray(type.sub)) {
const components = type.sub.map(
subtype =>
({
Component: findComponent(registry, subtype, nestingNumber + 1),
name: subtype.name,
} as SubComponent)
);
return (props: ArgComponentProps<Record<string, unknown>>) =>
SubForm({ ...props, components, nestingNumber, type });
}
}
if (type.info === TypeDefInfo.Vec) {
if (type.sub && !Array.isArray(type.sub)) {
const Component = findComponent(registry, type.sub, nestingNumber + 1);
return (props: ArgComponentProps<unknown[]>) =>
Vector({ ...props, Component, nestingNumber, type });
}
}
if (type.info === TypeDefInfo.Compact) {
return findComponent(registry, type.sub as TypeDef);
}
switch (type.type) {
case 'AccountId':
case 'Address':
return AddressSelect;
case 'Balance':
return InputBalance;
case 'bool':
return Bool;
case 'u8':
case 'i8':
case 'i32':
case 'u32':
case 'i64':
case 'u64':
case 'BN':
return InputNumber;
default:
return Input;
}
}