Skip to content

Commit

Permalink
fix: approve maximum
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveVodrazka committed Jun 27, 2024
1 parent 933489a commit 1ef186e
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions src/components/CarmineStaking/StakeCRM.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ const stake = async (
account: AccountInterface,
amount: bigint,
length: number,
setTxState: TxTracking
setTxState: TxTracking,
max: bigint
) => {
setTxState(TransactionState.Processing);

const approveCall = {
contractAddress: VE_CRM_ADDRESS,
entrypoint: "approve",
calldata: [GOVERNANCE_ADDRESS, amount.toString(10), 0],
calldata: [GOVERNANCE_ADDRESS, max.toString(10), 0],
};

const stakeCall = {
Expand Down Expand Up @@ -97,25 +98,41 @@ export const StakeCrm = ({ account, carmBalance }: Props) => {
const handle1month = () => {
setSixMonthsState(TransactionState.Processing);
setYearState(TransactionState.Processing);
stake(account, amount, CARMINE_STAKING_MONTH, setMonthState).then(() => {
stake(
account,
amount,
CARMINE_STAKING_MONTH,
setMonthState,
carmBalance
).then(() => {
setSixMonthsState(TransactionState.Initial);
setYearState(TransactionState.Initial);
});
};
const handle6months = () => {
setMonthState(TransactionState.Processing);
setYearState(TransactionState.Processing);
stake(account, amount, 6 * CARMINE_STAKING_MONTH, setSixMonthsState).then(
() => {
setMonthState(TransactionState.Initial);
setYearState(TransactionState.Initial);
}
);
stake(
account,
amount,
6 * CARMINE_STAKING_MONTH,
setSixMonthsState,
carmBalance
).then(() => {
setMonthState(TransactionState.Initial);
setYearState(TransactionState.Initial);
});
};
const handleYear = () => {
setMonthState(TransactionState.Processing);
setSixMonthsState(TransactionState.Processing);
stake(account, amount, CARMINE_STAKING_YEAR, setYearState).then(() => {
stake(
account,
amount,
CARMINE_STAKING_YEAR,
setYearState,
carmBalance
).then(() => {
setMonthState(TransactionState.Initial);
setSixMonthsState(TransactionState.Initial);
});
Expand Down

0 comments on commit 1ef186e

Please sign in to comment.