Skip to content

Commit e482bc5

Browse files
committed
clean up wallet-widget
1 parent 70213b9 commit e482bc5

File tree

18 files changed

+37
-862
lines changed

18 files changed

+37
-862
lines changed

examples/react/src/components/Connected.tsx

Lines changed: 25 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCheckoutModal, useSelectPaymentModal, useSwapModal, useTransactionStatusModal } from '@0xsequence/checkout'
1+
import { useCheckoutModal, useTransactionStatusModal } from '@0xsequence/checkout'
22
import {
33
getModalPositionCss,
44
signEthAuthProof,
@@ -25,7 +25,6 @@ import { abi } from '../constants/nft-abi'
2525
import { delay, getCheckoutSettings, getOrderbookCalldata } from '../utils'
2626
import { checkoutPresets } from '../utils/checkout'
2727

28-
import { CustomCheckout } from './CustomCheckout'
2928
import { Select } from './Select'
3029

3130
// append ?debug to url to enable debug mode
@@ -40,11 +39,8 @@ export const Connected = () => {
4039
const [isOpenCustomCheckout, setIsOpenCustomCheckout] = React.useState(false)
4140
const { setOpenConnectModal } = useOpenConnectModal()
4241
const { address } = useAccount()
43-
const { openSwapModal } = useSwapModal()
4442
const { setOpenWalletModal } = useOpenWalletModal()
4543
const { triggerCheckout } = useCheckoutModal()
46-
const { triggerAddFunds } = useAddFundsModal()
47-
const { openSelectPaymentModal } = useSelectPaymentModal()
4844
const { setIsSocialLinkOpen } = useSocialLink()
4945
const { data: walletClient } = useWalletClient()
5046
const storage = useStorage()
@@ -74,17 +70,6 @@ export const Connected = () => {
7470
reset: resetSendUnsponsoredTransaction
7571
} = useSendTransaction()
7672

77-
const { openCheckoutModal, isLoading: erc1155CheckoutLoading } = useERC1155SaleContractCheckout({
78-
chain: 137,
79-
contractAddress: '0xf0056139095224f4eec53c578ab4de1e227b9597',
80-
wallet: address || '',
81-
collectionAddress: '0x92473261f2c26f2264429c451f70b0192f858795',
82-
items: [{ tokenId: '1', quantity: '1' }],
83-
onSuccess: txnHash => {
84-
console.log('txnHash', txnHash)
85-
}
86-
})
87-
8873
const [isSigningMessage, setIsSigningMessage] = React.useState(false)
8974
const [isMessageValid, setIsMessageValid] = React.useState<boolean | undefined>()
9075
const [messageSig, setMessageSig] = React.useState<string | undefined>()
@@ -375,55 +360,30 @@ export const Connected = () => {
375360
setIsCheckoutInfoModalOpen(true)
376361
}
377362

378-
const onClickSwap = () => {
379-
const chainId = 137
380-
const toTokenAddress = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359'
381-
const toTokenAmount = '200000'
382-
const data = encodeFunctionData({ abi: parseAbi(['function demo()']), functionName: 'demo', args: [] })
383-
384-
const swapModalSettings: SwapModalSettings = {
385-
onSuccess: () => {
386-
console.log('swap successful!')
387-
},
388-
chainId,
389-
toTokenAddress,
390-
toTokenAmount,
391-
postSwapTransactions: [
392-
{
393-
to: '0x37470dac8a0255141745906c972e414b1409b470',
394-
data
395-
}
396-
],
397-
title: 'Swap and Pay',
398-
description: 'Select a token in your wallet to swap to 0.2 USDC.'
399-
}
400-
401-
openSwapModal(swapModalSettings)
402-
}
403-
404-
const onClickSelectPayment = () => {
405-
if (!address) {
406-
return
407-
}
408-
409-
const creditCardProvider = checkoutProvider || 'forte'
410-
411-
openSelectPaymentModal({
412-
recipientAddress: address,
413-
creditCardProviders: [creditCardProvider],
414-
onRampProvider: onRampProvider ? (onRampProvider as TransactionOnRampProvider) : TransactionOnRampProvider.transak,
415-
onSuccess: (txnHash?: string) => {
416-
console.log('success!', txnHash)
417-
},
418-
onError: (error: Error) => {
419-
console.error(error)
420-
},
421-
onClose: () => {
422-
console.log('modal closed!')
423-
},
424-
...checkoutPresets[checkoutPreset as keyof typeof checkoutPresets](address || '')
425-
})
426-
}
363+
// Convert to credit card flow
364+
// const onClickSelectPayment = () => {
365+
// if (!address) {
366+
// return
367+
// }
368+
369+
// const creditCardProvider = checkoutProvider || 'forte'
370+
371+
// openSelectPaymentModal({
372+
// recipientAddress: address,
373+
// creditCardProviders: [creditCardProvider],
374+
// onRampProvider: onRampProvider ? (onRampProvider as TransactionOnRampProvider) : TransactionOnRampProvider.transak,
375+
// onSuccess: (txnHash?: string) => {
376+
// console.log('success!', txnHash)
377+
// },
378+
// onError: (error: Error) => {
379+
// console.error(error)
380+
// },
381+
// onClose: () => {
382+
// console.log('modal closed!')
383+
// },
384+
// ...checkoutPresets[checkoutPreset as keyof typeof checkoutPresets](address || '')
385+
// })
386+
// }
427387

428388
const onCheckoutInfoConfirm = () => {
429389
setIsCheckoutInfoModalOpen(false)
@@ -455,14 +415,6 @@ export const Connected = () => {
455415
}
456416
}
457417

458-
const onClickAddFunds = () => {
459-
triggerAddFunds({
460-
walletAddress: address || '',
461-
provider: onRampProvider ? (onRampProvider as TransactionOnRampProvider) : TransactionOnRampProvider.transak,
462-
transakOnRampKind: 'default'
463-
})
464-
}
465-
466418
const onClickConnect = () => {
467419
setOpenConnectModal(true)
468420
}
@@ -777,8 +729,6 @@ export const Connected = () => {
777729
Web SDK Checkout
778730
</Text>
779731

780-
<CardButton title="Add Funds" description="Buy Cryptocurrency with a Credit Card" onClick={() => onClickAddFunds()} />
781-
782732
{isDebugMode && (
783733
<>
784734
<CardButton title="Generate EthAuth proof" description="Generate EthAuth proof" onClick={generateEthAuthProof} />
@@ -794,13 +744,6 @@ export const Connected = () => {
794744
onClick={() => setIsOpenCustomCheckout(true)}
795745
/>
796746

797-
<CardButton
798-
title="ERC1155 Checkout"
799-
description="Purchase with useERC1155SaleContractCheckout hook"
800-
onClick={openCheckoutModal}
801-
isPending={erc1155CheckoutLoading}
802-
/>
803-
804747
<CardButton
805748
title="Transaction Status Modal"
806749
description="Transaction status modal"
@@ -809,18 +752,6 @@ export const Connected = () => {
809752
</>
810753
)}
811754

812-
<CardButton
813-
title="Swap"
814-
description="Seamlessly swap eligible currencies in your wallet to a target currency"
815-
onClick={onClickSwap}
816-
/>
817-
818-
<CardButton
819-
title="Checkout"
820-
description="Purchase an NFT through various purchase methods"
821-
onClick={onClickSelectPayment}
822-
/>
823-
824755
{(chainId === ChainId.ARBITRUM_NOVA || chainId === ChainId.ARBITRUM_SEPOLIA || isWaasConnectionActive) && (
825756
<Text className="mt-4" variant="small-bold" color="muted">
826757
Misc
@@ -945,25 +876,6 @@ export const Connected = () => {
945876
</Modal>
946877
)}
947878
</AnimatePresence>
948-
<AnimatePresence>
949-
{isOpenCustomCheckout && (
950-
<Modal
951-
contentProps={{
952-
style: {
953-
maxWidth: '400px',
954-
height: 'auto',
955-
...getModalPositionCss('center')
956-
}
957-
}}
958-
scroll={false}
959-
onClose={() => setIsOpenCustomCheckout(false)}
960-
>
961-
<Scroll style={{ height: '600px' }}>
962-
<CustomCheckout />
963-
</Scroll>
964-
</Modal>
965-
)}
966-
</AnimatePresence>
967879
</>
968880
)
969881
}

0 commit comments

Comments
 (0)