Skip to content

Commit

Permalink
Remove Faucet component (#25)
Browse files Browse the repository at this point in the history
* Remove Faucet component

Signed-off-by: Justin <[email protected]>

* LINTING!!!!!

Signed-off-by: Justin <[email protected]>

---------

Signed-off-by: Justin <[email protected]>
  • Loading branch information
justinbarry authored Dec 4, 2024
1 parent c612a04 commit cd496f8
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 165 deletions.
93 changes: 0 additions & 93 deletions src/features/staking/components/faucet.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/features/staking/components/main-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import { memo, useState } from "react";

import { IS_TESTNET } from "@/config";
import { Title } from "@/features/core/components/base";

import { useStaking } from "../context/hooks";
import DelegationDetails, {
DetailsTrigger,
getCanShowDetails,
} from "./delegation-details";
import Faucet from "./faucet";
import StakingModals from "./staking-modals";
import StakingOverview from "./staking-overview";
import ValidatorsTable from "./validators-table";
Expand All @@ -36,7 +34,6 @@ function StakingPage() {
/>
)}
</div>
{IS_TESTNET && <Faucet />}
<StakingOverview />
{isShowingDetails && canShowDetail && <DelegationDetails />}
<ValidatorsTable />
Expand Down
69 changes: 0 additions & 69 deletions src/features/staking/lib/core/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
MsgUndelegate,
} from "cosmjs-types/cosmos/staking/v1beta1/tx";

import { FAUCET_CONTRACT_ADDRESS } from "@/config";
import { MIN_CLAIMABLE_XION } from "@/constants";

import type { Unbonding } from "../../context/state";
Expand Down Expand Up @@ -215,74 +214,6 @@ export const cancelUnbonding = async (
.catch(handleTxError);
};

export interface AddressLastFaucetStatus {
canFaucet: boolean;

denom: string;
lastFaucetTimestamp: number;
maxBalance: number;
nextFaucetTimestamp: number;
}

interface GetAccountLastClaimTimestampResponse {
amount_to_faucet: number;
cooldown_period: number;
denom: string;
timestamp: string;
}

export const getAddressLastFaucetTimestamp = async (
address: string,
client: NonNullable<AbstraxionSigningClient>,
): Promise<AddressLastFaucetStatus> => {
const msg = {
get_address_last_faucet_timestamp: {
address,
},
};

return await client
.queryContractSmart(FAUCET_CONTRACT_ADDRESS, msg)
.then((res: GetAccountLastClaimTimestampResponse) => {
// Get the current timestamp in seconds
const currentTimestampInSeconds = Math.floor(Date.now() / 1000);
const timestamp = parseInt(res.timestamp);

// If the timestamp is 0, the user has never claimed.
if (timestamp === 0) {
return {
canFaucet: true,
denom: res.denom,
lastFaucetTimestamp: 0,
maxBalance: res.amount_to_faucet,
nextFaucetTimestamp: currentTimestampInSeconds,
};
}

return {
canFaucet: timestamp + res.cooldown_period < currentTimestampInSeconds,
denom: res.denom,
lastFaucetTimestamp: timestamp,
maxBalance: res.amount_to_faucet,
nextFaucetTimestamp: timestamp + res.cooldown_period,
};
})
.catch(handleTxError);
};

export const faucetFunds = async (
address: string,
client: NonNullable<AbstraxionSigningClient>,
) => {
const msg = {
faucet: {},
};

return await client
.execute(address, FAUCET_CONTRACT_ADDRESS, msg, "auto")
.catch(handleTxError);
};

type BatchClaimAddresses = {
delegator: string;
validators: string[];
Expand Down

0 comments on commit cd496f8

Please sign in to comment.