From 5acc26fd9bae823920862eff65f5f5f2845cdc64 Mon Sep 17 00:00:00 2001 From: samuelea Date: Thu, 2 May 2024 11:15:28 -0400 Subject: [PATCH] added sardine integration --- examples/react/src/components/Homepage.tsx | 103 +++++++- examples/react/src/utils/helpers.ts | 36 +++ examples/react/src/utils/index.ts | 1 - examples/react/src/utils/settings.ts | 30 --- packages/checkout/src/api/data.ts | 227 +++++++++++++----- .../checkout/src/contexts/CheckoutModal.tsx | 31 +-- packages/checkout/src/contexts/Navigation.tsx | 3 +- .../shared/components/KitCheckoutProvider.tsx | 30 +-- .../shared/components/NavigationHeader.tsx | 2 +- .../shared/components/PaperTransaction.tsx | 190 --------------- .../component/OrderSummaryItem.tsx | 2 +- .../src/views/CheckoutSelection/index.tsx | 79 ++++-- .../src/views/PaperTransactionForm.tsx | 23 -- .../checkout/src/views/PendingTransaction.tsx | 65 +++-- .../checkout/src/views/TransactionError.tsx | 2 +- .../checkout/src/views/TransactionSuccess.tsx | 26 +- packages/checkout/src/views/index.ts | 1 - 17 files changed, 443 insertions(+), 408 deletions(-) delete mode 100644 examples/react/src/utils/settings.ts delete mode 100644 packages/checkout/src/shared/components/PaperTransaction.tsx delete mode 100644 packages/checkout/src/views/PaperTransactionForm.tsx diff --git a/examples/react/src/components/Homepage.tsx b/examples/react/src/components/Homepage.tsx index c1343b43..d588e793 100644 --- a/examples/react/src/components/Homepage.tsx +++ b/examples/react/src/components/Homepage.tsx @@ -5,7 +5,8 @@ import { validateEthProof, useTheme as useKitTheme, useWaasFeeOptions, - useIndexerClient + useIndexerClient, + getModalPositionCss } from '@0xsequence/kit' import { useOpenWalletModal } from '@0xsequence/kit-wallet' import { useCheckoutModal } from '@0xsequence/kit-checkout' @@ -36,9 +37,12 @@ import { Switch, Select, IconButton, - CheckmarkIcon + CheckmarkIcon, + Modal, + TextInput } from '@0xsequence/design-system' import { allNetworks } from '@0xsequence/network' +import { AnimatePresence } from 'framer-motion' import { Footer } from './Footer' import { messageToSign } from '../constants' import { delay, formatAddress, getCheckoutSettings } from '../utils' @@ -63,6 +67,12 @@ export const Homepage = () => { const { data: walletClient } = useWalletClient() const { switchChain } = useSwitchChain() + const [isCheckoutInfoModalOpen, setIsCheckoutInfoModalOpen] = React.useState(false) + + const [checkoutOrderId, setCheckoutOrderId] = React.useState('') + const [checkoutTokenContractAddress, setCheckoutTokenContractAddress] = React.useState('') + const [checkoutTokenId, setCheckoutTokenId] = React.useState('') + const connections = useConnections() const isWaasConnection = connections.find(c => c.connector.id.includes('waas')) !== undefined @@ -324,7 +334,23 @@ export const Homepage = () => { } const onClickCheckout = () => { - triggerCheckout(getCheckoutSettings(address)) + setIsCheckoutInfoModalOpen(true) + } + + const onCheckoutInfoConfirm = () => { + setIsCheckoutInfoModalOpen(false) + if (checkoutOrderId !== '' && checkoutTokenContractAddress !== '' && checkoutTokenId !== '') { + const checkoutSettings = getCheckoutSettings( + checkoutOrderId, + address || '', + checkoutTokenContractAddress, + checkoutTokenId, + 137, + 1, + true + ) + triggerCheckout(checkoutSettings) + } } const SwitchThemeButton = () => { @@ -370,11 +396,11 @@ export const Homepage = () => { description="Connect a Sequence wallet to view, swap, send, and receive collections" onClick={() => setOpenWalletModal(true)} /> - {/* */} + /> { {!isMobile &&