-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bump ajs and avalanche-sdks to latest version (#2054)
- Loading branch information
1 parent
f5528e1
commit ea1aaed
Showing
39 changed files
with
1,292 additions
and
417 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
68 changes: 52 additions & 16 deletions
68
packages/core-mobile/app/hooks/networks/networkProviderHooks.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 |
---|---|---|
@@ -1,38 +1,74 @@ | ||
import { | ||
Avalanche, | ||
BitcoinProvider, | ||
JsonRpcBatchInternal | ||
} from '@avalabs/core-wallets-sdk' | ||
import { useMemo } from 'react' | ||
import { useEffect, useState } from 'react' | ||
import { | ||
getAvalancheEvmProvider, | ||
getAvalancheXpProvider, | ||
getBitcoinProvider, | ||
getEthereumProvider | ||
} from 'services/network/utils/providerUtils' | ||
import Logger from 'utils/Logger' | ||
import { useNetworks } from './useNetworks' | ||
|
||
export function useEthereumProvider(): JsonRpcBatchInternal | undefined { | ||
export function useEthereumProvider( | ||
isTestnet?: boolean | ||
): JsonRpcBatchInternal | undefined { | ||
const { activeNetwork, networks } = useNetworks() | ||
const _isTestnet = isTestnet ?? activeNetwork.isTestnet | ||
|
||
return useMemo( | ||
() => getEthereumProvider(networks, activeNetwork.isTestnet), | ||
[networks, activeNetwork] | ||
) | ||
const [ethereumProvider, setEthereumProvider] = | ||
useState<JsonRpcBatchInternal>() | ||
useEffect(() => { | ||
getEthereumProvider(networks, _isTestnet) | ||
.then(setEthereumProvider) | ||
.catch(Logger.error) | ||
}, [networks, activeNetwork, _isTestnet]) | ||
|
||
return ethereumProvider | ||
} | ||
|
||
export function useBitcoinProvider(): BitcoinProvider { | ||
export function useBitcoinProvider( | ||
isTestnet?: boolean | ||
): BitcoinProvider | undefined { | ||
const { activeNetwork } = useNetworks() | ||
const _isTestnet = isTestnet ?? activeNetwork.isTestnet | ||
const [bitcoinProvider, setBitcoinProvider] = useState<BitcoinProvider>() | ||
useEffect(() => { | ||
getBitcoinProvider(_isTestnet).then(setBitcoinProvider).catch(Logger.error) | ||
}, [activeNetwork, _isTestnet]) | ||
|
||
return useMemo( | ||
() => getBitcoinProvider(activeNetwork.isTestnet), | ||
[activeNetwork] | ||
) | ||
return bitcoinProvider | ||
} | ||
|
||
export function useAvalancheProvider(): JsonRpcBatchInternal | undefined { | ||
export function useAvalancheProvider( | ||
isTestnet?: boolean | ||
): JsonRpcBatchInternal | undefined { | ||
const { activeNetwork, networks } = useNetworks() | ||
const _isTestnet = isTestnet ?? activeNetwork.isTestnet | ||
const [avalancheProvider, setAvalancheProvider] = | ||
useState<JsonRpcBatchInternal>() | ||
useEffect(() => { | ||
getAvalancheEvmProvider(networks, _isTestnet) | ||
.then(setAvalancheProvider) | ||
.catch(Logger.error) | ||
}, [networks, activeNetwork, _isTestnet]) | ||
return avalancheProvider | ||
} | ||
|
||
return useMemo( | ||
() => getAvalancheEvmProvider(networks, activeNetwork.isTestnet), | ||
[networks, activeNetwork] | ||
) | ||
export function useAvalancheXpProvider( | ||
isTestnet?: boolean | ||
): Avalanche.JsonRpcProvider | undefined { | ||
const { activeNetwork } = useNetworks() | ||
const _isTestnet = isTestnet ?? activeNetwork.isTestnet | ||
const [avalancheXpProvider, setAvalancheXpProvider] = | ||
useState<Avalanche.JsonRpcProvider>() | ||
useEffect(() => { | ||
getAvalancheXpProvider(!!_isTestnet) | ||
.then(setAvalancheXpProvider) | ||
.catch(Logger.error) | ||
}, [activeNetwork, _isTestnet]) | ||
return avalancheXpProvider | ||
} |
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
Oops, something went wrong.