Skip to content

Commit

Permalink
polygon-amoy ccip
Browse files Browse the repository at this point in the history
  • Loading branch information
Vib-UX committed Jun 1, 2024
1 parent 78e6110 commit a7658e4
Show file tree
Hide file tree
Showing 3 changed files with 353 additions and 56 deletions.
33 changes: 8 additions & 25 deletions src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import toast from 'react-hot-toast';
import useWeb3auth, { chainConfig } from '@/hooks/useWeb3auth';
import {
PurchaseSubsAvaGasslessBundle,
PurchaseSubsPolygon,
PurchaseSubsAmoyGasslessBundle,
approveNSubscribe,
batchSubscribeFor,
chainLinkAutomationSubscription,
checkUserBalanceAvaWeb3Auth,
checkUserBalancePolygonWeb3Auth,
checkUserBalanceAmoyWeb3Auth,
checkUserBalanceWeb3Auth,
getPolygonFundsWeb3Auth,
getTestFundsWeb3Auth,
mintingNft,
} from '@/lib/func';
Expand Down Expand Up @@ -214,7 +213,7 @@ export default function MyModal({
}
} else if (walletChosen === 'Polygon') {
setProgress(10);
const resp = await PurchaseSubsPolygon(
const resp = await PurchaseSubsAmoyGasslessBundle(
smartAccount,
modelId,
subscriptionId,
Expand Down Expand Up @@ -253,8 +252,8 @@ export default function MyModal({
}
};

const insufficiantPolygonBalance = async () => {
const amount = await checkUserBalancePolygonWeb3Auth(smartAccount);
const insufficiantAmoyBalance = async () => {
const amount = await checkUserBalanceAmoyWeb3Auth(smartAccount);
if (parseInt(amount.signerBalance) < value) {
setLoadingState(
`Insufficient Funds need ${
Expand All @@ -270,7 +269,8 @@ export default function MyModal({
} else if (walletChosen === 'avalanche') {
insufficiantAvaBalance();
} else if (walletChosen === 'Polygon') {
insufficiantPolygonBalance();
console.log('there?');
insufficiantAmoyBalance();
}
}, [walletChosen]);
return (
Expand Down Expand Up @@ -509,6 +509,7 @@ export default function MyModal({
} else if (coin.name === 'Ethereum') {
login(1);
} else if (coin.name === 'Polygon') {
console.log('there?');
login(2);
}
setWalletChosen(coin.name);
Expand Down Expand Up @@ -583,24 +584,6 @@ export default function MyModal({
);
setTestTokensHash('');
}
} else if (walletChosen === 'Polygon') {
const resp = await getPolygonFundsWeb3Auth(
smartAccount
);
if (resp.trxhash) {
toast.success(
'Wooho your funds have arrived 🚀🎉💸',
toastStyles
);
setPolygonTokensHash(resp.trxhash);
setLoadingState('Confirm Payment');
} else {
toast.error(
'Something went wrong',
toastStyles
);
setPolygonTokensHash('');
}
} else {
window.open(
'https://faucet.circle.com/',
Expand Down
Loading

0 comments on commit a7658e4

Please sign in to comment.