-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14a1af1
commit 27806fc
Showing
1 changed file
with
36 additions
and
0 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,36 @@ | ||
import { useCurrentNetworkInfo } from './network'; | ||
import { useEffect, useMemo } from 'react'; | ||
import { useCurrentAccount } from './wallet'; | ||
import { useCurrentChainList } from './chainList'; | ||
import CrossTransfer from '@portkey-wallet/utils/withdrawEOA'; | ||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
|
||
const crossChainTransfer = new CrossTransfer(); | ||
|
||
export const CROSS_CHAIN_ETRANSFER_SUPPORT_SYMBOL = ['ELF', 'USDT']; | ||
|
||
export const useCrossTransferByEtransfer = (pin?: string) => { | ||
const { eTransferUrl, eTransferCA } = useCurrentNetworkInfo(); | ||
const currentChainList = useCurrentChainList(); | ||
const account = useCurrentAccount(); | ||
|
||
useEffect(() => { | ||
if (!eTransferUrl || !pin || !currentChainList || !eTransferCA || !account) return; | ||
crossChainTransfer.init({ | ||
eTransferUrl: eTransferUrl, | ||
account, | ||
pin, | ||
chainList: currentChainList, | ||
eTransferCA, | ||
storage: AsyncStorage, | ||
}); | ||
}, [account, currentChainList, eTransferCA, eTransferUrl, pin]); | ||
|
||
return useMemo( | ||
() => ({ | ||
withdraw: crossChainTransfer.withdraw, | ||
withdrawPreview: crossChainTransfer.withdrawPreview, | ||
}), | ||
[], | ||
); | ||
}; |