-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0afa9ce
commit d60d444
Showing
62 changed files
with
3,503 additions
and
4,401 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
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,42 @@ | ||
import { useMemo } from 'react'; | ||
|
||
import { type MarketData, createMarketData, createMarketPair } from '@leather.io/models'; | ||
import { | ||
useAlexCurrencyPriceAsMarketData, | ||
useCryptoCurrencyMarketDataMeanAverage, | ||
} from '@leather.io/query'; | ||
import { createMoney } from '@leather.io/utils'; | ||
|
||
import { useConfigSbtc } from '@app/query/common/remote-config/remote-config.query'; | ||
|
||
import { getPrincipalFromContractId } from '../utils'; | ||
|
||
function castBitcoinMarketDataToSbtcMarketData(bitcoinMarketData: MarketData) { | ||
return createMarketData( | ||
createMarketPair('sBTC', 'USD'), | ||
createMoney(bitcoinMarketData.price.amount.toNumber(), 'USD') | ||
); | ||
} | ||
|
||
export function useSip10FiatMarketData() { | ||
const priceAsMarketData = useAlexCurrencyPriceAsMarketData(); | ||
const bitcoinMarketData = useCryptoCurrencyMarketDataMeanAverage('BTC'); | ||
const { isSbtcContract } = useConfigSbtc(); | ||
|
||
return useMemo( | ||
() => ({ | ||
getTokenMarketData(principal: string, symbol: string) { | ||
const lookupIdentifier = principal.includes('::') | ||
? getPrincipalFromContractId(principal) | ||
: principal; | ||
|
||
if (isSbtcContract(lookupIdentifier)) { | ||
return castBitcoinMarketDataToSbtcMarketData(bitcoinMarketData); | ||
} | ||
|
||
return priceAsMarketData(lookupIdentifier, symbol); | ||
}, | ||
}), | ||
[bitcoinMarketData, isSbtcContract, priceAsMarketData] | ||
); | ||
} |
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
39 changes: 39 additions & 0 deletions
39
src/app/components/sbtc-deposit-status-item/sbtc-deposit-status-item.tsx
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,39 @@ | ||
import SbtcAvatarIconSrc from '@assets/avatars/sbtc-avatar-icon.png'; | ||
|
||
import { Avatar, Caption, Title } from '@leather.io/ui'; | ||
import { truncateMiddle } from '@leather.io/utils'; | ||
|
||
import { analytics } from '@shared/utils/analytics'; | ||
|
||
import { useBitcoinExplorerLink } from '@app/common/hooks/use-bitcoin-explorer-link'; | ||
import type { SbtcDepositInfo } from '@app/query/sbtc/sbtc-deposits.query'; | ||
|
||
import { TransactionItemLayout } from '../transaction-item/transaction-item.layout'; | ||
|
||
interface SbtcDepositTransactionItemProps { | ||
deposit: SbtcDepositInfo; | ||
} | ||
export function SbtcDepositTransactionItem({ deposit }: SbtcDepositTransactionItemProps) { | ||
const { handleOpenBitcoinTxLink: handleOpenTxLink } = useBitcoinExplorerLink(); | ||
|
||
const openTxLink = () => { | ||
void analytics.track('view_bitcoin_transaction'); | ||
handleOpenTxLink({ txid: deposit.bitcoinTxid }); | ||
}; | ||
|
||
return ( | ||
<TransactionItemLayout | ||
openTxLink={openTxLink} | ||
txCaption={truncateMiddle(deposit.bitcoinTxid, 4)} | ||
txIcon={ | ||
<Avatar.Root> | ||
<Avatar.Image alt="ST" src={SbtcAvatarIconSrc} /> | ||
</Avatar.Root> | ||
} | ||
txStatus={<Caption color="yellow.action-primary-default">Pending</Caption>} | ||
txTitle={<Title textStyle="label.02">BTC → sBTC</Title>} | ||
// Api is only returning 0 right now | ||
txValue={''} // deposit.amount.toString() | ||
/> | ||
); | ||
} |
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
Oops, something went wrong.