vega-frontend-monorepo/apps/trading/lib/hooks/use-referral-set-transaction.ts
Matthew Russell e52ae97233
feat(trading): competitions (#5621)
Co-authored-by: asiaznik <artur@vegaprotocol.io>
Co-authored-by: Ben <ben@vega.xyz>
2024-01-31 14:21:29 +00:00

34 lines
782 B
TypeScript

import {
useSimpleTransaction,
type Options,
type CreateReferralSet,
type UpdateReferralSet,
} from '@vegaprotocol/wallet';
import { useStakeAvailable } from './use-stake-available';
/**
* Manages state for creating a referral set or team
*/
export const useReferralSetTransaction = (opts?: Options) => {
const { stakeAvailable, requiredStake, isEligible } = useStakeAvailable();
const { status, result, error, send } = useSimpleTransaction({
onSuccess: opts?.onSuccess,
onError: opts?.onError,
});
const onSubmit = (tx: CreateReferralSet | UpdateReferralSet) => {
send(tx);
};
return {
err: error ? error : null,
code: result ? result.id : null,
status,
stakeAvailable,
requiredStake,
onSubmit,
isEligible,
};
};