-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Closes #1474 - Closes #1462 # Summary Refactors all assets related code of application, aiming to have stable formatting and always correct asset address + decimal config depending on current network chainId. The previous implementation was made to work always with same chainId, thus needed to upgrade now to support multi chainId ### Changes - fixed formatting and decimals config all over the app - never use mocked chainId - Send screen: enable sending unknown tokens as well - improve logic of add/edit assets to change inside asset networks as well - include hooks and helpers to deal with assets - `useFuelAsset`, `getAssetFuelCurrentChain`, `getFuelAssetByAssetId` - fix bugs when formatting / creating values with zero units (unknown tokens) - make all unknown tokens / assets use default as zero units - upgrade database to remove assetId from primaryKey of assets table - fix flaky e2e ReportError test --------- Co-authored-by: Arthur Geron <[email protected]>
- Loading branch information
1 parent
f6a9772
commit 76c88c4
Showing
96 changed files
with
1,169 additions
and
1,109 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 @@ | ||
--- | ||
"fuels-wallet": patch | ||
--- | ||
|
||
fix bugs when formatting / creating values with zero units (unknown tokens) |
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 @@ | ||
--- | ||
"fuels-wallet": patch | ||
--- | ||
|
||
make all unknown tokens / assets use default as zero units |
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 @@ | ||
--- | ||
"fuels-wallet": patch | ||
--- | ||
|
||
include hooks and helpers to deal with assets, like `useFuelAsset`, `getAssetFuelCurrentChain`, `getFuelAssetByAssetId` |
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 @@ | ||
--- | ||
"fuels-wallet": minor | ||
--- | ||
|
||
refactor assets related code of application |
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 @@ | ||
--- | ||
"@fuels/playwright-utils": minor | ||
--- | ||
|
||
pump |
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 @@ | ||
--- | ||
"fuels-wallet": patch | ||
--- | ||
|
||
Send screen: enable sending unknown tokens as well |
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 @@ | ||
--- | ||
"fuels-wallet": patch | ||
--- | ||
|
||
upgrade database to remove assetId from primaryKey of assets table |
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 |
---|---|---|
|
@@ -3,4 +3,4 @@ channel = "testnet" | |
|
||
[components] | ||
fuel-core = "0.35.0" | ||
forc = "0.63.3" | ||
forc = "0.63.5" |
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
57 changes: 57 additions & 0 deletions
57
packages/app/src/systems/Account/components/BalanceAssets/BalanceAssets.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,57 @@ | ||
import { Button, CardList } from '@fuel-ui/react'; | ||
import type { CoinAsset } from '@fuel-wallet/types'; | ||
import { useMemo, useState } from 'react'; | ||
import { AssetItem, AssetList } from '~/systems/Asset/components'; | ||
import type { AssetListEmptyProps } from '~/systems/Asset/components/AssetList/AssetListEmpty'; | ||
|
||
export type BalanceAssetListProp = { | ||
balances?: CoinAsset[]; | ||
isLoading?: boolean; | ||
onRemove?: (assetId: string) => void; | ||
onEdit?: (assetId: string) => void; | ||
emptyProps?: AssetListEmptyProps; | ||
}; | ||
|
||
export const BalanceAssets = ({ | ||
balances, | ||
isLoading, | ||
emptyProps = {}, | ||
onRemove, | ||
onEdit, | ||
}: BalanceAssetListProp) => { | ||
const [showUnknown, setShowUnknown] = useState(false); | ||
const unknownLength = useMemo( | ||
() => balances?.filter((balance) => !balance.asset?.name).length, | ||
[balances] | ||
); | ||
|
||
if (isLoading) return <AssetList.Loading items={4} />; | ||
const isEmpty = !balances || !balances.length; | ||
if (isEmpty) return <AssetList.Empty {...emptyProps} />; | ||
const balancesToShow = balances.filter( | ||
(balance) => showUnknown || balance.asset?.name | ||
); | ||
|
||
function toggle() { | ||
setShowUnknown((s) => !s); | ||
} | ||
|
||
return ( | ||
<CardList> | ||
{balancesToShow.map((balance) => ( | ||
<AssetItem | ||
key={balance.asset?.name} | ||
fuelAsset={balance.asset} | ||
amount={balance.amount} | ||
onRemove={onRemove} | ||
onEdit={onEdit} | ||
/> | ||
))} | ||
{!!(!isLoading && unknownLength) && ( | ||
<Button size="xs" variant="link" onPress={toggle}> | ||
{showUnknown ? 'Hide' : 'Show'} unknown assets ({unknownLength}) | ||
</Button> | ||
)} | ||
</CardList> | ||
); | ||
}; |
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.