-
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 #280 from bnb-chain/feat/upperLimit0107
feat: Upper limit validation
- Loading branch information
Showing
11 changed files
with
118 additions
and
22 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@bnb-chain/canonical-bridge-widget": patch | ||
--- | ||
|
||
chore: Update confirmation popup amount styling |
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,11 @@ | ||
{ | ||
"mode": "pre", | ||
"tag": "alpha", | ||
"initialVersions": { | ||
"@bnb-chain/canonical-bridge-sdk": "0.4.7", | ||
"@bnb-chain/canonical-bridge-widget": "0.5.18" | ||
}, | ||
"changesets": [ | ||
"blue-goats-shave" | ||
] | ||
} |
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
33 changes: 33 additions & 0 deletions
33
packages/canonical-bridge-widget/src/modules/transfer/hooks/usePriceValidation.ts
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,33 @@ | ||
import { useCallback } from 'react'; | ||
|
||
import { useBridgeConfig } from '@/index'; | ||
import { useTokenPrice } from '@/modules/aggregator/providers/TokenPricesProvider'; | ||
|
||
export const usePriceValidation = () => { | ||
const { fetchApiTokenPrices } = useTokenPrice(); | ||
const bridgeConfig = useBridgeConfig(); | ||
|
||
const validateTokenPrice = useCallback( | ||
async ({ tokenSymbol, tokenAddress }: { tokenSymbol: string; tokenAddress: string }) => { | ||
const { cmcPrices, llamaPrices } = await fetchApiTokenPrices(bridgeConfig); | ||
|
||
const key1 = `${tokenSymbol?.toLowerCase()}:${tokenAddress?.toLowerCase()}`; | ||
const key3 = tokenSymbol?.toLowerCase(); | ||
const key2 = `ethereum:${key3}`; | ||
let price = | ||
cmcPrices?.[key1]?.price ?? | ||
llamaPrices?.[key1]?.price ?? | ||
cmcPrices?.[key2]?.price ?? | ||
llamaPrices?.[key2]?.price ?? | ||
cmcPrices?.[key3]?.price ?? | ||
llamaPrices?.[key3]?.price; | ||
if (price !== undefined) { | ||
price = Number(price); | ||
} | ||
return price; | ||
}, | ||
[bridgeConfig, fetchApiTokenPrices], | ||
); | ||
|
||
return { validateTokenPrice }; | ||
}; |