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",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.7.37",
|
"version": "0.7.38",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"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)) {
|
if (isNetworkLegacy(chainId)) {
|
||||||
|
const isFundsInWarmup = warmupInfo.deposit._value > 0n;
|
||||||
|
if (warmupExists && isFundsInWarmup && !isPreClaimConfirmed) {
|
||||||
|
setIsWapmup(true);
|
||||||
|
} else {
|
||||||
await defaultFunction();
|
await defaultFunction();
|
||||||
// const isFundsInWarmup = warmupInfo.deposit._value > 0n;
|
}
|
||||||
// if (warmupExists && isFundsInWarmup && !isPreClaimConfirmed) {
|
|
||||||
// setIsWapmup(true);
|
|
||||||
// } else {
|
|
||||||
// await defaultFunction();
|
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
const warmupLeft = warmupInfo.expiry - epoch.number;
|
const warmupLeft = warmupInfo.expiry - epoch.number;
|
||||||
const amount = notes
|
const amountRaw = notes
|
||||||
.filter(note => indexes.includes(note.id))
|
.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) => {
|
const toExecute = async (receiver) => {
|
||||||
forceRedeem({ chainId, user: address, receiver, indexes });
|
const txHash = await forceRedeem({ chainId, user: address, receiver, indexes });
|
||||||
notesRefetch();
|
return txHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
breakoutFromBonding({ defaultFunction, toExecute, amount, warmupLeft })
|
breakoutFromBonding({ defaultFunction, toExecute, amount, warmupLeft })
|
||||||
|
|||||||
@ -378,6 +378,8 @@ const ConfirmStep = ({
|
|||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
const transaction = {
|
const transaction = {
|
||||||
|
receiverAddress: receiver,
|
||||||
|
amount: estimatedAmount._value.toString(),
|
||||||
sessionIndex: expectedSessionIndex,
|
sessionIndex: expectedSessionIndex,
|
||||||
transactionHash: txHash,
|
transactionHash: txHash,
|
||||||
chainId: chainId,
|
chainId: chainId,
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { useEffect, useState, useMemo, useCallback } from "react";
|
import { useEffect, useState, useMemo, useCallback } from "react";
|
||||||
import ReactGA from "react-ga4";
|
import ReactGA from "react-ga4";
|
||||||
import useSWR from "swr";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
@ -12,7 +11,7 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { decodeAddress } from "@polkadot/util-crypto";
|
import { decodeAddress } from "@polkadot/util-crypto";
|
||||||
import { fromHex } from "@polkadot-api/utils";
|
import { fromHex } from "@polkadot-api/utils";
|
||||||
import { getBlockNumber, getTransaction } from "@wagmi/core";
|
import { getBlockNumber } from "@wagmi/core";
|
||||||
import { useTransaction } from "wagmi";
|
import { useTransaction } from "wagmi";
|
||||||
import { keccak256, decodeFunctionData } from "viem";
|
import { keccak256, decodeFunctionData } from "viem";
|
||||||
import { u32, u64, u128 } from "scale-ts";
|
import { u32, u64, u128 } from "scale-ts";
|
||||||
@ -102,25 +101,12 @@ const Bridge = ({ chainId, address, config, connect }) => {
|
|||||||
hash: watchTransaction?.transactionHash
|
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(() => {
|
const hashedArguments = useMemo(() => {
|
||||||
if (!watchTransaction || !watchTransactionArgs.receiver) {
|
if (!watchTransaction) return undefined;
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const networkIdEncoded = u64.enc(BigInt(chainId));
|
const networkIdEncoded = u64.enc(BigInt(chainId));
|
||||||
const amountEncoded = u128.enc(BigInt(watchTransactionArgs.amount));
|
const amountEncoded = u128.enc(BigInt(watchTransaction.amount));
|
||||||
const addressEncoded = decodeAddress(watchTransactionArgs.receiver, false, 1996);
|
const addressEncoded = decodeAddress(watchTransaction.receiverAddress, false, 1996);
|
||||||
const transactionHashEncoded = fromHex(watchTransaction.transactionHash);
|
const transactionHashEncoded = fromHex(watchTransaction.transactionHash);
|
||||||
const blockNumber = u64.enc(watchTransactionInfo?.blockNumber ?? 0n);
|
const blockNumber = u64.enc(watchTransactionInfo?.blockNumber ?? 0n);
|
||||||
|
|
||||||
@ -132,7 +118,7 @@ const Bridge = ({ chainId, address, config, connect }) => {
|
|||||||
...networkIdEncoded
|
...networkIdEncoded
|
||||||
]);
|
]);
|
||||||
return keccak256(clapArgsStr)
|
return keccak256(clapArgsStr)
|
||||||
}, [watchTransaction, watchTransactionInfo, watchTransactionArgs])
|
}, [watchTransaction, watchTransactionInfo])
|
||||||
|
|
||||||
const latestBlockNumber = useLatestBlockNumber();
|
const latestBlockNumber = useLatestBlockNumber();
|
||||||
const eraIndex = useEraIndex();
|
const eraIndex = useEraIndex();
|
||||||
@ -207,8 +193,6 @@ const Bridge = ({ chainId, address, config, connect }) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...watchTransaction,
|
...watchTransaction,
|
||||||
receiverAddress: watchTransactionArgs.receiver,
|
|
||||||
amount: watchTransactionArgs.amount,
|
|
||||||
finalization,
|
finalization,
|
||||||
applaused,
|
applaused,
|
||||||
numberOfClaps,
|
numberOfClaps,
|
||||||
@ -218,7 +202,6 @@ const Bridge = ({ chainId, address, config, connect }) => {
|
|||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
watchTransaction,
|
watchTransaction,
|
||||||
watchTransactionArgs,
|
|
||||||
watchTransactionInfo,
|
watchTransactionInfo,
|
||||||
transactionApplaused,
|
transactionApplaused,
|
||||||
finalityDelay,
|
finalityDelay,
|
||||||
@ -227,39 +210,10 @@ const Bridge = ({ chainId, address, config, connect }) => {
|
|||||||
authorities
|
authorities
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const filteredStoredTransactionInfos = useMemo(() => {
|
const filteredStoredTransactions = useMemo(() => {
|
||||||
return storedTransactions.filter(obj => obj.chainId === chainId);
|
return storedTransactions.filter(obj => obj.chainId === chainId);
|
||||||
}, [storedTransactions, 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(() => {
|
const latestCommits = useMemo(() => {
|
||||||
return validators?.map((validator, index) => {
|
return validators?.map((validator, index) => {
|
||||||
const lastUpdatedNumber = Number(blockCommitments?.at(index)?.last_updated ?? 0);
|
const lastUpdatedNumber = Number(blockCommitments?.at(index)?.last_updated ?? 0);
|
||||||
|
|||||||
@ -307,7 +307,7 @@ export const BridgeCardHistory = ({
|
|||||||
<Box display="flex" flexDirection="column" justifyContent="center">
|
<Box display="flex" flexDirection="column" justifyContent="center">
|
||||||
<Typography variant="caption">
|
<Typography variant="caption">
|
||||||
{formatCurrency(
|
{formatCurrency(
|
||||||
new DecimalBigNumber(obj.amount, 18).toString(),
|
new DecimalBigNumber(BigInt(obj.amount ?? "0"), 18).toString(),
|
||||||
isSemiSmallScreen ? 3 : 8,
|
isSemiSmallScreen ? 3 : 8,
|
||||||
ghstSymbol
|
ghstSymbol
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -369,7 +369,7 @@ export const BridgeModal = ({
|
|||||||
<Typography variant="body2">Bridged Amount:</Typography>
|
<Typography variant="body2">Bridged Amount:</Typography>
|
||||||
<Typography variant="body2">{formatCurrency(
|
<Typography variant="body2">{formatCurrency(
|
||||||
new DecimalBigNumber(
|
new DecimalBigNumber(
|
||||||
BigInt(currentRecord ? currentRecord.amount : "0"),
|
BigInt(currentRecord && currentRecord.amount ? currentRecord.amount : "0"),
|
||||||
18
|
18
|
||||||
).toString(), 9, ghstSymbol)
|
).toString(), 9, ghstSymbol)
|
||||||
}</Typography>
|
}</Typography>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user