28b4593a1d
Co-authored-by: bwallacee <ben@vega.xyz>
33 lines
823 B
TypeScript
33 lines
823 B
TypeScript
import {
|
|
type CreateReferralSet,
|
|
type UpdateReferralSet,
|
|
} from '@vegaprotocol/wallet';
|
|
import { useSimpleTransaction, type Options } from '@vegaprotocol/wallet-react';
|
|
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,
|
|
};
|
|
};
|