-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Init Staking API GraphQL Plugin, discontinue Binance Spot (#2332)
- Loading branch information
Showing
26 changed files
with
598 additions
and
673 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 was deleted.
Oops, something went wrong.
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,58 @@ | ||
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
import { useEffectIgnoreInitial } from '@w3ux/hooks'; | ||
import { useNetwork } from 'contexts/Network'; | ||
import { | ||
ApolloProvider, | ||
client, | ||
useTokenPrice, | ||
formatResult, | ||
} from 'plugin-staking-api'; | ||
|
||
export const TokenPriceInner = () => { | ||
const { | ||
networkData: { | ||
api: { unit }, | ||
}, | ||
} = useNetwork(); | ||
const { loading, error, data, refetch } = useTokenPrice({ | ||
ticker: `${unit}USDT`, | ||
}); | ||
const { price, change } = formatResult(loading, error, data); | ||
|
||
const usdFormatter = new Intl.NumberFormat('en-US', { | ||
style: 'currency', | ||
currency: 'USD', | ||
}); | ||
|
||
// Initiate interval to refetch token price every 30 seconds. | ||
useEffectIgnoreInitial(() => { | ||
const interval = setInterval(() => { | ||
refetch(); | ||
}, 30 * 1000); | ||
return () => clearInterval(interval); | ||
}, [refetch]); | ||
|
||
return ( | ||
<> | ||
<div className="stat"> | ||
<span | ||
className={`change${change < 0 ? ' neg' : change > 0 ? ' pos' : ''}`} | ||
> | ||
{change < 0 ? '' : change > 0 ? '+' : ''} | ||
{change}% | ||
</span> | ||
</div> | ||
<div className="stat"> | ||
1 {unit} / {usdFormatter.format(price)} | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export const TokenPrice = () => ( | ||
<ApolloProvider client={client}> | ||
<TokenPriceInner /> | ||
</ApolloProvider> | ||
); |
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
Oops, something went wrong.