-
Notifications
You must be signed in to change notification settings - Fork 12
CP-13005: Basic Fusion SDK Integration #3574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f603b50
c088cc9
2c63185
9231264
42def8a
cf4a18b
cdbb5a3
cf6b983
f1a0cc4
9e7cc73
0c476c8
3dc1c41
9717b76
3916b8f
848d8ba
5d28c18
80e2048
d6663c6
b777673
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,10 @@ export const useNetworks = () => { | |
| const chainId = parseInt(key) | ||
| const network = rawNetworks[chainId] | ||
| if (network && network.isTestnet === isDeveloperMode) { | ||
| reducedNetworks[chainId] = network | ||
| reducedNetworks[chainId] = { | ||
| ...network, | ||
| caip2ChainId: getCaip2ChainId(chainId) | ||
| } | ||
| } | ||
| return reducedNetworks | ||
| }, | ||
|
|
@@ -61,7 +64,10 @@ export const useNetworks = () => { | |
| const network = _customNetworks[chainId] | ||
|
|
||
| if (network && network.isTestnet === isDeveloperMode) { | ||
| reducedNetworks[chainId] = network | ||
| reducedNetworks[chainId] = { | ||
| ...network, | ||
| caip2ChainId: getCaip2ChainId(chainId) | ||
| } | ||
atn4z7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return reducedNetworks | ||
| }, | ||
|
|
@@ -70,7 +76,7 @@ export const useNetworks = () => { | |
| return { ...populatedNetworks, ...populatedCustomNetworks } | ||
| }, [rawNetworks, _customNetworks, isDeveloperMode]) | ||
|
|
||
| const customNetworks = useMemo(() => { | ||
| const customNetworks: NetworkWithCaip2ChainId[] = useMemo(() => { | ||
| if (networks === undefined) return [] | ||
|
|
||
| const customNetworkChainIds = Object.values(_customNetworks).map( | ||
|
|
@@ -81,7 +87,7 @@ export const useNetworks = () => { | |
| ) | ||
| }, [networks, _customNetworks]) | ||
|
|
||
| const enabledNetworks = useMemo(() => { | ||
| const enabledNetworks: NetworkWithCaip2ChainId[] = useMemo(() => { | ||
| if (networks === undefined) return [] | ||
|
|
||
| const lastTransactedChainIds = lastTransactedChains | ||
|
|
@@ -93,10 +99,10 @@ export const useNetworks = () => { | |
| const enabled = allChainIds.reduce((acc, chainId) => { | ||
| const network = networks[chainId] | ||
| if (network && network.isTestnet === isDeveloperMode) { | ||
| acc.push(network) | ||
| acc.push({ ...network, caip2ChainId: getCaip2ChainId(network.chainId) }) | ||
atn4z7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return acc | ||
| }, [] as Network[]) | ||
| }, [] as NetworkWithCaip2ChainId[]) | ||
|
|
||
| // sort all C/X/P networks to the top | ||
| return enabled.sort((a, b) => { | ||
|
|
@@ -162,6 +168,13 @@ export const useNetworks = () => { | |
| [allNetworks] | ||
| ) | ||
|
|
||
| const getEnabledNetworkByCaip2ChainId = useCallback( | ||
| (caip2ChainId: string) => { | ||
| return enabledNetworks.find(n => n.caip2ChainId === caip2ChainId) | ||
| }, | ||
| [enabledNetworks] | ||
| ) | ||
|
Comment on lines
+171
to
+176
|
||
|
|
||
| const getFromPopulatedNetwork = useCallback( | ||
| (chainId?: number) => { | ||
| if (chainId === undefined || networks === undefined) return | ||
|
|
@@ -180,6 +193,7 @@ export const useNetworks = () => { | |
| getSomeNetworks, | ||
| getNetwork, | ||
| getNetworkByCaip2ChainId, | ||
| getEnabledNetworkByCaip2ChainId, | ||
| getFromPopulatedNetwork, | ||
| toggleNetwork | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.