-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'tooling-epic/explorer-darkmode-support' into tooling-ex…
…plorer/improve-code-blocks
- Loading branch information
Showing
154 changed files
with
2,231 additions
and
1,332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
export enum Theme { | ||
Light = 'light', | ||
Dark = 'dark', | ||
System = 'system', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,5 @@ | |
export type TokenForm = { | ||
amount: string; | ||
to: string; | ||
isPayAllIota: boolean; | ||
gasBudgetEst: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { | ||
useGetTimeBeforeEpochNumber, | ||
useTimeAgo, | ||
TimeUnit, | ||
NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_REDEEMABLE, | ||
NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_STARTS, | ||
} from '../../'; | ||
|
||
export function useStakeTxnInfo(startEpoch?: string | number) { | ||
const startEarningRewardsEpoch = | ||
Number(startEpoch || 0) + NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_STARTS; | ||
|
||
const redeemableRewardsEpoch = | ||
Number(startEpoch || 0) + NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_REDEEMABLE; | ||
|
||
const { data: timeBeforeStakeRewardsStarts } = | ||
useGetTimeBeforeEpochNumber(startEarningRewardsEpoch); | ||
const timeBeforeStakeRewardsStartsAgo = useTimeAgo({ | ||
timeFrom: timeBeforeStakeRewardsStarts, | ||
shortedTimeLabel: false, | ||
shouldEnd: true, | ||
maxTimeUnit: TimeUnit.ONE_HOUR, | ||
}); | ||
const stakedRewardsStartEpoch = | ||
timeBeforeStakeRewardsStarts > 0 | ||
? `in ${timeBeforeStakeRewardsStartsAgo}` | ||
: startEpoch | ||
? `Epoch #${Number(startEarningRewardsEpoch)}` | ||
: '--'; | ||
|
||
const { data: timeBeforeStakeRewardsRedeemable } = | ||
useGetTimeBeforeEpochNumber(redeemableRewardsEpoch); | ||
const timeBeforeStakeRewardsRedeemableAgo = useTimeAgo({ | ||
timeFrom: timeBeforeStakeRewardsRedeemable, | ||
shortedTimeLabel: false, | ||
shouldEnd: true, | ||
maxTimeUnit: TimeUnit.ONE_HOUR, | ||
}); | ||
const timeBeforeStakeRewardsRedeemableAgoDisplay = | ||
timeBeforeStakeRewardsRedeemable > 0 | ||
? `in ${timeBeforeStakeRewardsRedeemableAgo}` | ||
: startEpoch | ||
? `Epoch #${Number(redeemableRewardsEpoch)}` | ||
: '--'; | ||
|
||
return { | ||
stakedRewardsStartEpoch, | ||
timeBeforeStakeRewardsRedeemableAgoDisplay, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { useIotaClientQuery } from '@iota/dapp-kit'; | ||
import { useGetValidatorsApy } from '../'; | ||
|
||
export function useValidatorInfo({ validatorAddress }: { validatorAddress: string }) { | ||
const { | ||
data: system, | ||
isPending: isPendingValidators, | ||
isError: errorValidators, | ||
} = useIotaClientQuery('getLatestIotaSystemState'); | ||
const { data: rollingAverageApys } = useGetValidatorsApy(); | ||
|
||
const validatorSummary = | ||
system?.activeValidators.find((validator) => validator.iotaAddress === validatorAddress) || | ||
null; | ||
|
||
const currentEpoch = Number(system?.epoch || 0); | ||
|
||
const stakingPoolActivationEpoch = Number(validatorSummary?.stakingPoolActivationEpoch || 0); | ||
|
||
// flag as new validator if the validator was activated in the last epoch | ||
// for genesis validators, this will be false | ||
const newValidator = currentEpoch - stakingPoolActivationEpoch <= 1 && currentEpoch !== 0; | ||
|
||
// flag if the validator is at risk of being removed from the active set | ||
const isAtRisk = system?.atRiskValidators.some((item) => item[0] === validatorAddress); | ||
|
||
const { apy, isApyApproxZero } = rollingAverageApys?.[validatorAddress] ?? { | ||
apy: null, | ||
}; | ||
|
||
const commission = validatorSummary ? Number(validatorSummary.commissionRate) / 100 : 0; | ||
|
||
return { | ||
system, | ||
isPendingValidators, | ||
errorValidators, | ||
|
||
currentEpoch, | ||
validatorSummary, | ||
name: validatorSummary?.name || '', | ||
stakingPoolActivationEpoch, | ||
commission, | ||
newValidator, | ||
isAtRisk, | ||
apy, | ||
isApyApproxZero, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.