-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from ar-io/develop
Release v1.3.0 to production
- Loading branch information
Showing
19 changed files
with
1,704 additions
and
552 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ cache | |
dist-id.txt | ||
dist-manifest.csv | ||
dist-manifest.json | ||
package-lock.json |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { StreakDownArrowIcon, StreakUpArrowIcon } from './icons'; | ||
|
||
const Streak = ({ | ||
streak, | ||
fixedDigits = 0, | ||
rightLabel = '', | ||
}: { | ||
streak: number; | ||
fixedDigits?: number; | ||
rightLabel?: string; | ||
}) => { | ||
if (streak === 0) { | ||
return ''; | ||
} | ||
|
||
if (streak === Number.NEGATIVE_INFINITY) { | ||
return 'N/A'; | ||
} | ||
|
||
const colorClasses = | ||
streak > 0 | ||
? 'border-streak-up/[.56] bg-streak-up/[.1] text-streak-up' | ||
: 'border-text-red/[.56] bg-text-red/[.1] text-text-red'; | ||
const icon = | ||
streak > 0 ? ( | ||
<StreakUpArrowIcon className="size-3" /> | ||
) : ( | ||
<StreakDownArrowIcon className="size-3" /> | ||
); | ||
|
||
return ( | ||
<div | ||
className={`flex w-fit items-center gap-1 rounded-xl border py-0.5 pl-[.4375rem] pr-[.5625rem] ${colorClasses}`} | ||
> | ||
{icon} {Math.abs(streak).toFixed(fixedDigits)}{rightLabel} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Streak; |
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,32 @@ | ||
import { useGlobalState } from '@src/store'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export type ArNSStats = { | ||
namesPurchased: number; | ||
demandFactor: number; | ||
activeAuctions: number; | ||
}; | ||
|
||
const useArNSStats = () => { | ||
const arioReadSDK = useGlobalState((state) => state.arIOReadSDK); | ||
|
||
const res = useQuery<ArNSStats>({ | ||
queryKey: ['arNSStats', arioReadSDK], | ||
queryFn: async () => { | ||
if (!arioReadSDK) throw new Error('arIOReadSDK not initialized'); | ||
|
||
const demandFactor = await arioReadSDK.getDemandFactor(); | ||
|
||
const records = await arioReadSDK.getArNSRecords({ limit: 1}); | ||
|
||
return { | ||
demandFactor, | ||
namesPurchased: records.totalItems, | ||
activeAuctions: 0, | ||
}; | ||
}, | ||
}); | ||
return res; | ||
}; | ||
|
||
export default useArNSStats; |
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,37 @@ | ||
import { useGlobalState } from '@src/store'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import useEpochs from './useEpochs'; | ||
|
||
export type GatewayEpochCount = { | ||
epochIndex: number; | ||
totalEligibleGateways: number; | ||
}; | ||
|
||
const useGatewaysPerEpoch = () => { | ||
const arioReadSDK = useGlobalState((state) => state.arIOReadSDK); | ||
const { data: epochs } = useEpochs(); | ||
|
||
const res = useQuery<Array<GatewayEpochCount>>({ | ||
queryKey: ['gatewaysPerEpoch', epochs, arioReadSDK], | ||
queryFn: () => { | ||
if (!arioReadSDK || !epochs) { | ||
throw new Error('arIOReadSDK not initialized or epochs not available'); | ||
} | ||
|
||
return epochs | ||
.filter((epoch) => epoch !== undefined) | ||
.sort((a, b) => a!.epochIndex - b!.epochIndex) | ||
.map((epoch) => { | ||
if (!epoch) throw new Error('Epoch not available'); | ||
return { | ||
epochIndex: epoch.epochIndex, | ||
totalEligibleGateways: | ||
epoch.distributions.totalEligibleGateways || | ||
Object.keys(epoch.distributions.rewards.eligible).length, | ||
}; | ||
}); | ||
}, | ||
}); | ||
return res; | ||
}; | ||
export default useGatewaysPerEpoch; |
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,17 @@ | ||
import { useGlobalState } from '@src/store'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
const useTokenSupply = () => { | ||
const arioReadSDK = useGlobalState((state) => state.arIOReadSDK); | ||
|
||
const res = useQuery({ | ||
queryKey: ['tokenSupply'], | ||
queryFn: () => { | ||
if (!arioReadSDK) throw new Error('arIOReadSDK not initialized'); | ||
return arioReadSDK.getTokenSupply(); | ||
}, | ||
}); | ||
return res; | ||
}; | ||
|
||
export default useTokenSupply; |
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 was deleted.
Oops, something went wrong.
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,46 @@ | ||
import Placeholder from '@src/components/Placeholder'; | ||
import useArNSStats from '@src/hooks/useArNSStats'; | ||
import { formatWithCommas } from '@src/utils'; | ||
|
||
const ArNSStatsPanel = () => { | ||
const { data: arnsStats } = useArNSStats(); | ||
|
||
return ( | ||
<div className="flex min-w-[22rem] flex-col rounded-xl border border-grey-500 px-6 py-5"> | ||
<div className=" text-sm text-mid">ArNS Names Purchased</div> | ||
<div className="self-center px-24 py-6 text-center text-[2.625rem]"> | ||
{arnsStats ? ( | ||
formatWithCommas(arnsStats.namesPurchased) | ||
) : ( | ||
<Placeholder /> | ||
)} | ||
</div> | ||
<div className="flex h-full justify-between align-bottom font-bold text-high"> | ||
<div className="flex flex-col place-items-start text-left text-xs"> | ||
<div className="grow" /> | ||
{arnsStats ? ( | ||
<> | ||
<div>{arnsStats.demandFactor.toFixed(4)}</div> | ||
<div>Demand Factor</div> | ||
</> | ||
) : ( | ||
<Placeholder /> | ||
)} | ||
</div> | ||
<div className="flex flex-col place-items-end text-right text-xs"> | ||
<div className="grow" /> | ||
{arnsStats ? ( | ||
<> | ||
<div>0</div> | ||
<div>Active Auctions</div> | ||
</> | ||
) : ( | ||
<Placeholder /> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ArNSStatsPanel; |
Oops, something went wrong.