-
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.
feat: add explorer url config to networks (#1508)
- Loading branch information
1 parent
67a14d8
commit a5b8007
Showing
32 changed files
with
308 additions
and
499 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,6 @@ | ||
--- | ||
"@fuel-wallet/types": minor | ||
"fuels-wallet": minor | ||
--- | ||
|
||
Add explorer, bridge and faucet url configuration to networks. |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import type { NetworkData } from '@fuel-wallet/types'; | ||
import { CHAIN_IDS } from 'fuels'; | ||
import { | ||
IS_DEVELOPMENT, | ||
IS_RELEASE, | ||
IS_TEST, | ||
VITE_EXPLORER_URL, | ||
VITE_FUEL_FAUCET_URL, | ||
VITE_FUEL_PROVIDER_URL, | ||
} from './config'; | ||
|
||
export const DEFAULT_NETWORKS: Array< | ||
NetworkData & { faucetUrl?: string; bridgeUrl?: string } | ||
> = [ | ||
{ | ||
name: 'Ignition', | ||
url: 'https://mainnet.fuel.network/v1/graphql', | ||
chainId: CHAIN_IDS.fuel.mainnet, | ||
explorerUrl: 'https://app.fuel.network', | ||
bridgeUrl: 'https://app.fuel.network/bridge', | ||
isSelected: IS_RELEASE, | ||
}, | ||
{ | ||
name: 'Fuel Sepolia Testnet', | ||
url: 'https://testnet.fuel.network/v1/graphql', | ||
chainId: CHAIN_IDS.fuel.testnet, | ||
explorerUrl: 'https://app-testnet.fuel.network', | ||
faucetUrl: 'https://faucet-testnet.fuel.network/', | ||
isSelected: !IS_RELEASE, | ||
}, | ||
{ | ||
name: 'Fuel Sepolia Devnet', | ||
url: 'https://devnet.fuel.network/v1/graphql', | ||
chainId: CHAIN_IDS.fuel.devnet, | ||
explorerUrl: 'https://app-devnet.fuel.network', | ||
faucetUrl: 'https://faucet-devnet.fuel.network/', | ||
isSelected: false, | ||
}, | ||
]; | ||
|
||
if ( | ||
(IS_DEVELOPMENT || IS_TEST) && | ||
!DEFAULT_NETWORKS.find((n) => n.url === VITE_FUEL_PROVIDER_URL) | ||
) { | ||
DEFAULT_NETWORKS.push({ | ||
name: 'Local network', | ||
url: VITE_FUEL_PROVIDER_URL, | ||
chainId: CHAIN_IDS.fuel.testnet, | ||
explorerUrl: VITE_EXPLORER_URL, | ||
faucetUrl: VITE_FUEL_FAUCET_URL, | ||
isSelected: false, | ||
}); | ||
} |
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
15 changes: 7 additions & 8 deletions
15
packages/app/src/systems/Asset/components/AssetList/AssetListEmpty.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
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 @@ | ||
export * from './useFundWallet'; |
50 changes: 50 additions & 0 deletions
50
packages/app/src/systems/FundWallet/hooks/useFundWallet.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,50 @@ | ||
import { Address } from 'fuels'; | ||
import { useCallback, useMemo } from 'react'; | ||
import { IS_CRX } from '~/config'; | ||
import { DEFAULT_NETWORKS } from '~/networks'; | ||
import { useAccounts } from '~/systems/Account'; | ||
import { openTab } from '~/systems/CRX/utils'; | ||
import { useNetworks } from '~/systems/Network'; | ||
|
||
export function useFundWallet() { | ||
const { selectedNetwork } = useNetworks(); | ||
const { account } = useAccounts(); | ||
|
||
const { faucetUrl, bridgeUrl } = useMemo(() => { | ||
const network = DEFAULT_NETWORKS.find( | ||
(n) => n.url === selectedNetwork?.url | ||
); | ||
return { | ||
bridgeUrl: network?.bridgeUrl ?? null, | ||
faucetUrl: network?.faucetUrl ?? null, | ||
}; | ||
}, [selectedNetwork]); | ||
|
||
const open = useCallback(() => { | ||
let url: URL | null = null; | ||
if (faucetUrl) { | ||
if (!account || !account.address) return faucetUrl; | ||
const address = Address.fromDynamicInput(account.address).toB256(); | ||
url = new URL(faucetUrl); | ||
url.searchParams.set('address', address); | ||
} else if (bridgeUrl) { | ||
url = new URL(bridgeUrl); | ||
} | ||
|
||
if (!url) return; | ||
if (IS_CRX) { | ||
openTab(url.toString()); | ||
return; | ||
} | ||
window.open(url, '_blank'); | ||
}, [account, bridgeUrl, faucetUrl]); | ||
|
||
return { | ||
open, | ||
faucetUrl, | ||
bridgeUrl, | ||
hasFaucet: !!faucetUrl, | ||
hasBridge: !!bridgeUrl, | ||
showFund: !!faucetUrl || !!bridgeUrl, | ||
}; | ||
} |
File renamed without changes.
Oops, something went wrong.