make bond force redeem works
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
fcc3d341d9
commit
08bf24f90b
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ghost-dao-interface",
|
||||
"private": true,
|
||||
"version": "0.7.37",
|
||||
"version": "0.7.38",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -64,22 +64,22 @@ export const ClaimBonds = ({ chainId, address, secondsTo }) => {
|
||||
};
|
||||
|
||||
if (isNetworkLegacy(chainId)) {
|
||||
await defaultFunction();
|
||||
// const isFundsInWarmup = warmupInfo.deposit._value > 0n;
|
||||
// if (warmupExists && isFundsInWarmup && !isPreClaimConfirmed) {
|
||||
// setIsWapmup(true);
|
||||
// } else {
|
||||
// await defaultFunction();
|
||||
// }
|
||||
const isFundsInWarmup = warmupInfo.deposit._value > 0n;
|
||||
if (warmupExists && isFundsInWarmup && !isPreClaimConfirmed) {
|
||||
setIsWapmup(true);
|
||||
} else {
|
||||
await defaultFunction();
|
||||
}
|
||||
} else {
|
||||
const warmupLeft = warmupInfo.expiry - epoch.number;
|
||||
const amount = notes
|
||||
const amountRaw = notes
|
||||
.filter(note => indexes.includes(note.id))
|
||||
.reduce((sum, note) => sum.add(note.payout), new DecimalBigNumber(0, 0));
|
||||
.reduce((sum, note) => sum + note.payout._value, 0n);
|
||||
const amount = new DecimalBigNumber(amountRaw, 18);
|
||||
|
||||
const toExecute = (receiver) => {
|
||||
forceRedeem({ chainId, user: address, receiver, indexes });
|
||||
notesRefetch();
|
||||
const toExecute = async (receiver) => {
|
||||
const txHash = await forceRedeem({ chainId, user: address, receiver, indexes });
|
||||
return txHash;
|
||||
}
|
||||
|
||||
breakoutFromBonding({ defaultFunction, toExecute, amount, warmupLeft })
|
||||
|
||||
@ -378,6 +378,8 @@ const ConfirmStep = ({
|
||||
: 0);
|
||||
|
||||
const transaction = {
|
||||
receiverAddress: receiver,
|
||||
amount: estimatedAmount._value.toString(),
|
||||
sessionIndex: expectedSessionIndex,
|
||||
transactionHash: txHash,
|
||||
chainId: chainId,
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { useEffect, useState, useMemo, useCallback } from "react";
|
||||
import ReactGA from "react-ga4";
|
||||
import useSWR from "swr";
|
||||
|
||||
import {
|
||||
Box,
|
||||
@ -12,7 +11,7 @@ import {
|
||||
} from "@mui/material";
|
||||
import { decodeAddress } from "@polkadot/util-crypto";
|
||||
import { fromHex } from "@polkadot-api/utils";
|
||||
import { getBlockNumber, getTransaction } from "@wagmi/core";
|
||||
import { getBlockNumber } from "@wagmi/core";
|
||||
import { useTransaction } from "wagmi";
|
||||
import { keccak256, decodeFunctionData } from "viem";
|
||||
import { u32, u64, u128 } from "scale-ts";
|
||||
@ -102,25 +101,12 @@ const Bridge = ({ chainId, address, config, connect }) => {
|
||||
hash: watchTransaction?.transactionHash
|
||||
});
|
||||
|
||||
const watchTransactionArgs = useMemo(() => {
|
||||
if (watchTransactionInfo && watchTransactionInfo.input) {
|
||||
const { functionName, args } = decodeFunctionData({
|
||||
abi: StakingAbi,
|
||||
data: watchTransactionInfo.input,
|
||||
});
|
||||
return { receiver: args.at(0), amount: args.at(1) }
|
||||
}
|
||||
return { receiver: "", amount: 0n }
|
||||
}, [watchTransactionInfo]);
|
||||
|
||||
const hashedArguments = useMemo(() => {
|
||||
if (!watchTransaction || !watchTransactionArgs.receiver) {
|
||||
return undefined;
|
||||
}
|
||||
if (!watchTransaction) return undefined;
|
||||
|
||||
const networkIdEncoded = u64.enc(BigInt(chainId));
|
||||
const amountEncoded = u128.enc(BigInt(watchTransactionArgs.amount));
|
||||
const addressEncoded = decodeAddress(watchTransactionArgs.receiver, false, 1996);
|
||||
const amountEncoded = u128.enc(BigInt(watchTransaction.amount));
|
||||
const addressEncoded = decodeAddress(watchTransaction.receiverAddress, false, 1996);
|
||||
const transactionHashEncoded = fromHex(watchTransaction.transactionHash);
|
||||
const blockNumber = u64.enc(watchTransactionInfo?.blockNumber ?? 0n);
|
||||
|
||||
@ -132,7 +118,7 @@ const Bridge = ({ chainId, address, config, connect }) => {
|
||||
...networkIdEncoded
|
||||
]);
|
||||
return keccak256(clapArgsStr)
|
||||
}, [watchTransaction, watchTransactionInfo, watchTransactionArgs])
|
||||
}, [watchTransaction, watchTransactionInfo])
|
||||
|
||||
const latestBlockNumber = useLatestBlockNumber();
|
||||
const eraIndex = useEraIndex();
|
||||
@ -207,8 +193,6 @@ const Bridge = ({ chainId, address, config, connect }) => {
|
||||
|
||||
return {
|
||||
...watchTransaction,
|
||||
receiverAddress: watchTransactionArgs.receiver,
|
||||
amount: watchTransactionArgs.amount,
|
||||
finalization,
|
||||
applaused,
|
||||
numberOfClaps,
|
||||
@ -218,7 +202,6 @@ const Bridge = ({ chainId, address, config, connect }) => {
|
||||
}
|
||||
}, [
|
||||
watchTransaction,
|
||||
watchTransactionArgs,
|
||||
watchTransactionInfo,
|
||||
transactionApplaused,
|
||||
finalityDelay,
|
||||
@ -227,39 +210,10 @@ const Bridge = ({ chainId, address, config, connect }) => {
|
||||
authorities
|
||||
]);
|
||||
|
||||
const filteredStoredTransactionInfos = useMemo(() => {
|
||||
const filteredStoredTransactions = useMemo(() => {
|
||||
return storedTransactions.filter(obj => obj.chainId === chainId);
|
||||
}, [storedTransactions, chainId]);
|
||||
|
||||
const { data: filteredStoredTransactions } = useSWR(
|
||||
filteredStoredTransactionInfos.length > 0
|
||||
? ["filtered-tx", chainId, filteredStoredTransactionInfos.map(t => t.transactionHash)]
|
||||
: undefined,
|
||||
async ([,, hashes]) => {
|
||||
const results = await Promise.all(
|
||||
hashes.map(hash => getTransaction(config, { hash }).catch(() => undefined))
|
||||
);
|
||||
|
||||
return filteredStoredTransactionInfos.map((tx, index) => {
|
||||
const txInfo = results.at(index);
|
||||
let decodedData = { receiverAddress: "unknown", amount: 0n };
|
||||
|
||||
if (txInfo && txInfo.input) {
|
||||
const { args } = decodeFunctionData({
|
||||
abi: StakingAbi,
|
||||
data: txInfo.input,
|
||||
});
|
||||
if (args && args.at(0) && args.at(1)) {
|
||||
decodedData = { receiverAddress: args.at(0), amount: args.at(1) };
|
||||
}
|
||||
}
|
||||
|
||||
return { ...tx, ...decodedData };
|
||||
})
|
||||
},
|
||||
{ revalidateOnFocus: false }
|
||||
)
|
||||
|
||||
const latestCommits = useMemo(() => {
|
||||
return validators?.map((validator, index) => {
|
||||
const lastUpdatedNumber = Number(blockCommitments?.at(index)?.last_updated ?? 0);
|
||||
|
||||
@ -307,7 +307,7 @@ export const BridgeCardHistory = ({
|
||||
<Box display="flex" flexDirection="column" justifyContent="center">
|
||||
<Typography variant="caption">
|
||||
{formatCurrency(
|
||||
new DecimalBigNumber(obj.amount, 18).toString(),
|
||||
new DecimalBigNumber(BigInt(obj.amount ?? "0"), 18).toString(),
|
||||
isSemiSmallScreen ? 3 : 8,
|
||||
ghstSymbol
|
||||
)}
|
||||
|
||||
@ -369,7 +369,7 @@ export const BridgeModal = ({
|
||||
<Typography variant="body2">Bridged Amount:</Typography>
|
||||
<Typography variant="body2">{formatCurrency(
|
||||
new DecimalBigNumber(
|
||||
BigInt(currentRecord ? currentRecord.amount : "0"),
|
||||
BigInt(currentRecord && currentRecord.amount ? currentRecord.amount : "0"),
|
||||
18
|
||||
).toString(), 9, ghstSymbol)
|
||||
}</Typography>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user