Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import { useCreateLedgerContractCallTx } from './use-create-ledger-contract-call-tx'; import { useCreateSoftwareContractCallTx } from './use-create-software-contract-call-tx'; import { useWalletType } from './use-wallet-type'; import { ContractCallOptions } from '@stacks/transactions'; import { useCallback } from 'react'; export function useCreateContractCallTx() { const { whenWallet } = useWalletType(); const { createSoftwareContractCallTx } = useCreateSoftwareContractCallTx(); const { createLedgerContractCallTx } = useCreateLedgerContractCallTx(); return useCallback( async (txOptions: ContractCallOptions, privateKey?: string) => whenWallet({ async software() { Iif (!privateKey) throw new Error('Software wallet txs require private key'); return createSoftwareContractCallTx({ txOptions, privateKey }); }, async ledger() { return createLedgerContractCallTx({ ...txOptions }); }, })(), [createLedgerContractCallTx, createSoftwareContractCallTx, whenWallet] ); } |