Skip to content

Commit

Permalink
chore: 🤖 eTransfer hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Portkey-David committed Feb 8, 2025
1 parent 14a1af1 commit 27806fc
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packages/hooks/hooks-eoa/useWithdrawByETransfer.ts
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,
}),
[],
);
};

0 comments on commit 27806fc

Please sign in to comment.