fix: Clean up dead code and stale domain references across landing + web-app (#189)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5ee2238604
commit
878d1337df
21 changed files with 2 additions and 263 deletions
|
|
@ -51,8 +51,6 @@ export function useAdjustTaxRate() {
|
|||
|
||||
async function changeTax(positionId: bigint, taxRateIndex: number) {
|
||||
try {
|
||||
// console.log("changeTax", { positionId, taxRate });
|
||||
|
||||
loading.value = true;
|
||||
const option = getTaxRateOptionByIndex(taxRateIndex);
|
||||
if (!option) {
|
||||
|
|
@ -60,7 +58,6 @@ export function useAdjustTaxRate() {
|
|||
}
|
||||
|
||||
const hash = await StakeContract.changeTax(positionId, option.index);
|
||||
// console.log("hash", hash);
|
||||
loading.value = false;
|
||||
waiting.value = true;
|
||||
await waitForTransactionReceipt(config as Config, {
|
||||
|
|
@ -70,9 +67,6 @@ export function useAdjustTaxRate() {
|
|||
contractToast.showSuccessToast(option.year.toString(), 'Success!', 'You adjusted your position tax to', '', '%');
|
||||
waiting.value = false;
|
||||
} catch (error: unknown) {
|
||||
// console.error("error", error);
|
||||
// console.log(JSON.stringify(error, (_, v) => (typeof v === "bigint" ? v.toString() : v)));
|
||||
|
||||
contractToast.showFailToast((error as { shortMessage?: string })?.shortMessage ?? 'Transaction failed');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
|
|
|
|||
|
|
@ -43,14 +43,12 @@ export function useClaim() {
|
|||
|
||||
loading.value = true;
|
||||
const hash = await HarbContract.claimUbi(address);
|
||||
// console.log("hash", hash);
|
||||
loading.value = false;
|
||||
waiting.value = true;
|
||||
await waitForTransactionReceipt(config as Config, {
|
||||
hash: hash,
|
||||
});
|
||||
} catch (_error) {
|
||||
// console.error("error", error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
waiting.value = false;
|
||||
|
|
@ -58,12 +56,8 @@ export function useClaim() {
|
|||
}
|
||||
|
||||
if (!unwatch) {
|
||||
// console.log("useClaim function");
|
||||
|
||||
unwatch = watchAccount(config as Config, {
|
||||
async onChange(data) {
|
||||
// console.log("watchAccount", data);
|
||||
|
||||
if (data.address) {
|
||||
await HarbContract.setHarbContract();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ const toast = useToast();
|
|||
|
||||
export function useContractToast() {
|
||||
function showFailToast(name?: string) {
|
||||
// console.log("name", name);
|
||||
if (name === 'UserRejectedRequestError') {
|
||||
//
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -87,10 +87,6 @@ const myClosedPositions: ComputedRef<Position[]> = computed(() => {
|
|||
const account = getAccount(config as Config);
|
||||
|
||||
return rawClosedPositoins.value.map(obj => {
|
||||
// console.log("taxRatePosition", taxRatePosition);
|
||||
|
||||
// console.log("taxRates[taxRatePosition]", taxRates[taxRatePosition]);
|
||||
|
||||
const taxRateDecimal = Number(obj.taxRate);
|
||||
const taxRateIndex =
|
||||
Number.isFinite(taxRateDecimal) && !Number.isNaN(taxRateDecimal) ? getTaxRateIndexByDecimal(taxRateDecimal) : undefined;
|
||||
|
|
@ -139,9 +135,6 @@ interface ActivePositionsResult {
|
|||
export async function loadActivePositions(chainId: number, endpointOverride?: string): Promise<ActivePositionsResult> {
|
||||
const targetEndpoint = resolveGraphqlEndpoint(chainId, endpointOverride);
|
||||
logger.info(`loadActivePositions for chainId: ${chainId}`);
|
||||
|
||||
// console.log("graphql endpoint", targetEndpoint);
|
||||
|
||||
const res = await axios.post(
|
||||
targetEndpoint,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,9 +44,6 @@ export function useStake() {
|
|||
|
||||
const state: ComputedRef<StakeState> = computed(() => {
|
||||
const balance = wallet.balance.value;
|
||||
// console.log("balance123", balance);
|
||||
// console.log("wallet", wallet);
|
||||
|
||||
if (loading.value) {
|
||||
return StakeState.SignTransaction;
|
||||
} else if (minStake.value > balance || stakingAmount.value > balance) {
|
||||
|
|
@ -83,7 +80,6 @@ export function useStake() {
|
|||
// const stakingAmountNumber = computed(() => return staking)
|
||||
|
||||
async function snatch(stakingAmount: bigint, taxRateIndex: number, positions: Array<bigint> = []) {
|
||||
// console.log("snatch", { stakingAmount, taxRateIndex, positions });
|
||||
const account = getAccount(wagmiConfig);
|
||||
const taxRateOption = getTaxRateOptionByIndex(taxRateIndex);
|
||||
if (!taxRateOption) {
|
||||
|
|
@ -92,8 +88,6 @@ export function useStake() {
|
|||
|
||||
try {
|
||||
const assets: bigint = stakingAmount;
|
||||
// console.log("receiver", receiver);
|
||||
|
||||
// await snatchService(assets, receiver, taxRate, []);
|
||||
// assets: BigInt, receiver: Address, taxRate: Number, positionsToSnatch: Array<BigInt>
|
||||
const deadline = BigInt(Date.now()) / 1000n + 1200n;
|
||||
|
|
@ -110,8 +104,6 @@ export function useStake() {
|
|||
account.chainId!,
|
||||
name
|
||||
);
|
||||
// console.log("resultPermitObject", { types, message, domain, primaryType });
|
||||
|
||||
const typedData: TypedDataDefinition = {
|
||||
domain,
|
||||
message,
|
||||
|
|
@ -120,20 +112,9 @@ export function useStake() {
|
|||
};
|
||||
|
||||
const signature = await signTypedData(wagmiConfig, typedData);
|
||||
|
||||
// console.log("signature", {
|
||||
// domain,
|
||||
// message,
|
||||
// primaryType,
|
||||
// types,
|
||||
// });
|
||||
|
||||
const { r, s, v } = getSignatureRSV(signature);
|
||||
loading.value = true;
|
||||
// console.log("permitAndSnatch", assets, account.address!, taxRateOption.index, positions, deadline, v, r, s);
|
||||
|
||||
const hash = await permitAndSnatch(assets, account.address!, taxRateOption.index, positions, deadline, v, r, s);
|
||||
// console.log("hash", hash);
|
||||
loading.value = false;
|
||||
waiting.value = true;
|
||||
const data = await waitForTransactionReceipt(wagmiConfig, {
|
||||
|
|
@ -154,8 +135,6 @@ export function useStake() {
|
|||
waiting.value = false;
|
||||
await getNonce();
|
||||
} catch (error) {
|
||||
// console.error("error", error);
|
||||
// console.log(JSON.parse(JSON.stringify(error)));
|
||||
const message = error instanceof Error ? error.name : 'Transaction failed';
|
||||
contractToast.showFailToast(message);
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -165,8 +165,6 @@ const inflation7d = computed(() => {
|
|||
|
||||
const stakeableSupply = computed(() => {
|
||||
if (rawStatsCollections.value?.length > 0 && BigInt(rawStatsCollections.value[0].kraikenTotalSupply) > 0n) {
|
||||
// console.log("rawStatsCollections.value[0]", rawStatsCollections.value[0]);
|
||||
|
||||
return stakeTotalSupply.value / 5n;
|
||||
} else {
|
||||
return 0n;
|
||||
|
|
@ -176,8 +174,6 @@ const stakeableSupply = computed(() => {
|
|||
//maxSlots
|
||||
const maxSlots = computed(() => {
|
||||
if (rawStatsCollections.value?.length > 0 && BigInt(rawStatsCollections.value[0].kraikenTotalSupply) > 0n) {
|
||||
// console.log("rawStatsCollections.value[0]", rawStatsCollections.value[0]);
|
||||
|
||||
return (bigInt2Number(stakeTotalSupply.value, 18) * 0.2) / 100;
|
||||
} else {
|
||||
return 0;
|
||||
|
|
@ -243,8 +239,6 @@ export function useStatCollection(chainId: number = DEFAULT_CHAIN_ID) {
|
|||
}
|
||||
});
|
||||
if (!unwatch) {
|
||||
// console.log("watchChain");
|
||||
|
||||
//chain Switch reload stats for other chain
|
||||
unwatch = watchChainId(config as Config, {
|
||||
async onChange(nextChainId) {
|
||||
|
|
@ -253,13 +247,6 @@ export function useStatCollection(chainId: number = DEFAULT_CHAIN_ID) {
|
|||
await loadStats(resolvedChainId);
|
||||
},
|
||||
});
|
||||
|
||||
// const unwatchBlock = watchBlocks(config as Config, {
|
||||
// async onBlock(block) {
|
||||
// console.log('Block changed!', block)
|
||||
// await loadStats();
|
||||
// },
|
||||
// })
|
||||
}
|
||||
onUnmounted(() => {
|
||||
retryManager.clear();
|
||||
|
|
|
|||
|
|
@ -39,11 +39,8 @@ export function useUnstake() {
|
|||
|
||||
async function exitPosition(positionId: bigint) {
|
||||
try {
|
||||
// console.log("positionId", positionId);
|
||||
|
||||
loading.value = true;
|
||||
const hash = await StakeContract.exitPosition(positionId);
|
||||
// console.log("hash", hash);
|
||||
loading.value = false;
|
||||
waiting.value = true;
|
||||
const data = await waitForTransactionReceipt(config as Config, {
|
||||
|
|
@ -64,7 +61,6 @@ export function useUnstake() {
|
|||
waiting.value = false;
|
||||
wallet.loadBalance();
|
||||
} catch (error) {
|
||||
// console.error("error", error);
|
||||
contractToast.showFailToast((error as Error).name);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
|
|
|
|||
|
|
@ -105,12 +105,8 @@ export function useWallet() {
|
|||
}
|
||||
|
||||
if (!unwatch) {
|
||||
// console.log("useWallet function");
|
||||
|
||||
unwatch = watchAccount(config as Config, {
|
||||
async onChange(data) {
|
||||
// console.log("watchaccount-useWallet", data);
|
||||
|
||||
if (!data.address) {
|
||||
logger.info(`disconnected`);
|
||||
setWalletPublicClient(null);
|
||||
|
|
@ -141,8 +137,6 @@ export function useWallet() {
|
|||
}
|
||||
|
||||
if (!unwatchChain) {
|
||||
// console.log("unwatchChain");
|
||||
|
||||
unwatchChain = watchChainId(config as Config, {
|
||||
async onChange(_chainId) {
|
||||
await syncWalletPublicClient(account.value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue