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#useCallback
- react#createContext
- react#useContext
- react-router#useParams
- react-router#useNavigate
- types#ApiPromise
- types#InstantiateData
- types#OnInstantiateSuccess$Code
- types#OnInstantiateSuccess$Hash
- types#InstantiateState
- types#ContractPromise
- types#InstantiateProps
- types#CodeSubmittableResult
- types#BlueprintSubmittableResult
- types#BlueprintPromise
- types#Step2FormData
- @polkadot/api#SubmittableResult
- @polkadot/types/interfaces#ContractInstantiateResult
- @polkadot/util#isNumber
- @polkadot/util#BN_THOUSAND
types#SubmittableExtrinsic TypeScript Examples
The following examples show how to use
types#SubmittableExtrinsic.
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: createInstantiateTx.ts From contracts-ui with GNU General Public License v3.0 | 6 votes |
export function createInstantiateTx(
api: ApiPromise,
{
argValues,
codeHash,
constructorIndex,
weight: gasLimit,
value,
metadata,
salt,
storageDepositLimit,
}: InstantiateData
): SubmittableExtrinsic<'promise'> | null {
const wasm = metadata?.info.source.wasm;
const isValid = codeHash || !!wasm;
if (isValid && metadata && isNumber(constructorIndex) && metadata && argValues) {
const constructor = metadata.findConstructor(constructorIndex);
const options = {
gasLimit,
salt: salt ? encodeSalt(salt) : null,
storageDepositLimit: storageDepositLimit || undefined,
value: value && constructor.isPayable ? api.registry.createType('Balance', value) : undefined,
};
const codeOrBlueprint = codeHash
? new BlueprintPromise(api, metadata, codeHash)
: new CodePromise(api, metadata, wasm && wasm.toU8a());
const transformed = transformUserInput(api.registry, constructor.args, argValues);
return constructor.args.length > 0
? codeOrBlueprint.tx[constructor.method](options, ...transformed)
: codeOrBlueprint.tx[constructor.method](options);
} else {
throw new Error('Unknown error');
}
}
Example #2
Source File: useQueueTx.ts From contracts-ui with GNU General Public License v3.0 | 6 votes |
export function useQueueTx(
extrinsic: SubmittableExtrinsic<'promise'> | null,
accountId: string | null | undefined,
onSuccess: (_: SubmittableResult) => Promise<void>,
onError: VoidFn,
isValid: (_: SubmittableResult) => boolean
): [VoidFn, VoidFn, boolean, boolean] {
const { queue, dismiss, process, txs } = useTransactions();
const [txId, setTxId] = useState<number>(0);
const txIdRef = useRef(txId);
const isProcessing = useMemo(
(): boolean => !!(txs[txId] && txs[txId]?.status === 'processing'),
[txs, txId]
);
const onSubmit = useCallback((): void => {
txId && process(txId);
}, [process, txId]);
const onCancel = useCallback((): void => {
txId && dismiss(txId);
setTxId(0);
}, [dismiss, txId]);
useEffect((): void => {
if (extrinsic && accountId && txId === 0) {
const newId = queue({ extrinsic, accountId, onSuccess, onError, isValid });
setTxId(newId);
txIdRef.current = newId;
}
}, [accountId, extrinsic, isValid, onError, onSuccess, queue, txId]);
return [onSubmit, onCancel, !isNull(txId), isProcessing];
}