diff --git a/examples/react/src/components/Connected.tsx b/examples/react/src/components/Connected.tsx index 6d445064..c4a061ca 100644 --- a/examples/react/src/components/Connected.tsx +++ b/examples/react/src/components/Connected.tsx @@ -5,7 +5,7 @@ import { useIndexerClient, signEthAuthProof, validateEthProof, - getModalPositionCss, + getModalPositionCss } from '@0xsequence/kit' import { useCheckoutModal, useAddFundsModal } from '@0xsequence/kit-checkout' import { CardButton, Header } from '@0xsequence/kit-example-shared-components' diff --git a/examples/react/src/constants/orderbook-abi.ts b/examples/react/src/constants/orderbook-abi.ts index 93409fe2..8aa74fd7 100644 --- a/examples/react/src/constants/orderbook-abi.ts +++ b/examples/react/src/constants/orderbook-abi.ts @@ -1 +1,15 @@ -export const orderbookAbi = [{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"additionalFees","type":"uint256[]"},{"internalType":"address[]","name":"additionalFeeRecipients","type":"address[]"}],"name":"acceptRequest","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file +export const orderbookAbi = [ + { + inputs: [ + { internalType: 'uint256', name: 'requestId', type: 'uint256' }, + { internalType: 'uint256', name: 'quantity', type: 'uint256' }, + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'uint256[]', name: 'additionalFees', type: 'uint256[]' }, + { internalType: 'address[]', name: 'additionalFeeRecipients', type: 'address[]' } + ], + name: 'acceptRequest', + outputs: [], + stateMutability: 'nonpayable', + type: 'function' + } +] diff --git a/examples/react/src/utils/helpers.ts b/examples/react/src/utils/helpers.ts index a464c939..1cf33e21 100644 --- a/examples/react/src/utils/helpers.ts +++ b/examples/react/src/utils/helpers.ts @@ -42,10 +42,14 @@ export const getCheckoutSettings = (args: GetCheckoutSettings) => { const checkoutSettings: CheckoutSettings = { creditCardCheckout: { defaultPaymentMethodType: 'us_debit', - onSuccess: (hash) => { console.log('credit card checkout success', hash) }, - onError: (e) => { console.log('credit card checkout error', e) }, + onSuccess: hash => { + console.log('credit card checkout success', hash) + }, + onError: e => { + console.log('credit card checkout error', e) + }, ...args - }, + } // orderSummaryItems: [ // { // chainId: args.chainId, @@ -60,27 +64,17 @@ export const getCheckoutSettings = (args: GetCheckoutSettings) => { } export interface GetOrderbookCalldata { - orderId: string, - quantity: string, - recipient: string, + orderId: string + quantity: string + recipient: string } -export const getOrderbookCalldata = ({ - orderId, - quantity, - recipient, -}: GetOrderbookCalldata) => { +export const getOrderbookCalldata = ({ orderId, quantity, recipient }: GetOrderbookCalldata) => { const calldata = encodeFunctionData({ abi: orderbookAbi, functionName: 'acceptRequest', - args: [ - BigInt(orderId), - BigInt(quantity), - recipient as Hex, - [], - [] - ] + args: [BigInt(orderId), BigInt(quantity), recipient as Hex, [], []] }) return calldata -} \ No newline at end of file +} diff --git a/package.json b/package.json index 29746806..d75beb04 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "reinstall": "rimraf -g ./**/node_modules && pnpm install", "test": "turbo run test", "lint": "eslint -c .eslintrc.js 'packages/**/src/**/*.{ts,tsx}'", - "lint:fix": "eslint -c .eslintrc.js --fix 'packages/**/src/**/*.{ts,tsx}'", + "lint:fix": "eslint -c .eslintrc.js --fix 'packages/**/src/**/*.{ts,tsx}' && pnpm run format", "format": "prettier --list-different --write './{packages,examples}/*/src/**/*.{ts,tsx}'", "audit:fix": "pnpm audit --fix", "typecheck": "tsc --noEmit", diff --git a/packages/checkout/src/api/data.ts b/packages/checkout/src/api/data.ts index 1a0a2da2..2faa6296 100644 --- a/packages/checkout/src/api/data.ts +++ b/packages/checkout/src/api/data.ts @@ -13,9 +13,9 @@ export interface MethodArguments { } export interface FetchSardineClientTokenArgs { - order: CreditCardCheckout, - isDev: boolean, - projectAccessKey: string, + order: CreditCardCheckout + isDev: boolean + projectAccessKey: string tokenMetadata?: TokenMetadata } @@ -24,7 +24,7 @@ export const fetchSardineClientToken = async ({ isDev, projectAccessKey, tokenMetadata - }: FetchSardineClientTokenArgs): Promise => { +}: FetchSardineClientTokenArgs): Promise => { // Test credentials: https://docs.sardine.ai/docs/integrate-payments/nft-checkout-testing-credentials const accessKey = isDev ? '17xhjK4yjRf1fr0am8kgKfICAAAAAAAAA' : projectAccessKey const url = isDev @@ -44,7 +44,7 @@ export const fetchSardineClientToken = async ({ network: networks[order.chainId as ChainId].name, recipientAddress: order.recipientAddress, contractAddress: order.contractAddress, - platform: "calldata_execution", + platform: 'calldata_execution', blockchainNftId: order.nftId, quantity: Number(order.nftQuantity), decimals: Number(order?.nftDecimals || 0), diff --git a/packages/checkout/src/contexts/AddFundsModal.ts b/packages/checkout/src/contexts/AddFundsModal.ts index 4c53d8c7..156be5a8 100644 --- a/packages/checkout/src/contexts/AddFundsModal.ts +++ b/packages/checkout/src/contexts/AddFundsModal.ts @@ -3,10 +3,10 @@ import { Hex } from 'viem' import { createGenericContext } from './genericContext' export interface AddFundsSettings { - walletAddress: string | Hex, - fiatCurrency?: string, - defaultFiatAmount?: string, - defaultCryptoCurrency?: string, + walletAddress: string | Hex + fiatCurrency?: string + defaultFiatAmount?: string + defaultCryptoCurrency?: string networks?: string } diff --git a/packages/checkout/src/hooks/index.ts b/packages/checkout/src/hooks/index.ts index 7db415d3..86aba645 100644 --- a/packages/checkout/src/hooks/index.ts +++ b/packages/checkout/src/hooks/index.ts @@ -3,4 +3,4 @@ export * from './useCheckoutModal' export * from './useNavigation' export * from './useModalTheme' export * from './useCheckoutWhitelistStatus' -export * from './useSardineClientToken' \ No newline at end of file +export * from './useSardineClientToken' diff --git a/packages/checkout/src/hooks/useCheckoutWhitelistStatus.ts b/packages/checkout/src/hooks/useCheckoutWhitelistStatus.ts index 123b37f0..e85e69ff 100644 --- a/packages/checkout/src/hooks/useCheckoutWhitelistStatus.ts +++ b/packages/checkout/src/hooks/useCheckoutWhitelistStatus.ts @@ -3,7 +3,6 @@ import { useQuery } from '@tanstack/react-query' import { checkSardineWhitelistStatus, CheckSardineWhitelistStatusArgs } from '../utils' - export const useCheckoutWhitelistStatus = (args: CheckSardineWhitelistStatusArgs, disabled?: boolean) => { const projectAccessKey = useProjectAccessKey() diff --git a/packages/checkout/src/hooks/useSardineClientToken.ts b/packages/checkout/src/hooks/useSardineClientToken.ts index 12365878..3811459a 100644 --- a/packages/checkout/src/hooks/useSardineClientToken.ts +++ b/packages/checkout/src/hooks/useSardineClientToken.ts @@ -13,6 +13,6 @@ export const useSardineClientToken = (args: FetchSardineClientTokenArgs, disable retry: false, staleTime: 0, enabled: !disabled, - refetchOnWindowFocus: false, + refetchOnWindowFocus: false }) } diff --git a/packages/checkout/src/index.ts b/packages/checkout/src/index.ts index 7104b7c6..3dc48ae2 100644 --- a/packages/checkout/src/index.ts +++ b/packages/checkout/src/index.ts @@ -10,4 +10,4 @@ export { type CheckoutSettings } from './contexts/CheckoutModal' export { type AddFundsSettings } from './contexts/AddFundsModal' // utils -export { fetchTransakSupportedCountries, getTransakLink } from './utils/transak' \ No newline at end of file +export { fetchTransakSupportedCountries, getTransakLink } from './utils/transak' diff --git a/packages/checkout/src/shared/components/KitCheckoutProvider.tsx b/packages/checkout/src/shared/components/KitCheckoutProvider.tsx index bd41f7e4..553cece1 100644 --- a/packages/checkout/src/shared/components/KitCheckoutProvider.tsx +++ b/packages/checkout/src/shared/components/KitCheckoutProvider.tsx @@ -13,16 +13,10 @@ import { CheckoutModalContextProvider, CheckoutSettings, AddFundsContextProvider, - AddFundsSettings, + AddFundsSettings } from '../../contexts' import { NavigationHeader } from '../../shared/components/NavigationHeader' -import { - PendingTransaction, - TransactionError, - TransactionSuccess, - CheckoutSelection, - AddFundsContent, -} from '../../views' +import { PendingTransaction, TransactionError, TransactionSuccess, CheckoutSelection, AddFundsContent } from '../../views' import '@0xsequence/design-system/styles.css' @@ -53,16 +47,16 @@ export const KitCheckoutContent = ({ children }: KitCheckoutProvider) => { const orderSummaryItems = settings?.orderSummaryItems || [] const creditCardSettings = settings?.creditCardCheckout if (orderSummaryItems.length === 0 && creditCardSettings) { - return({ + return { location: 'transaction-pending', params: { creditCardCheckout: creditCardSettings - } - }) + } + } } else { - return({ + return { location: 'select-method-checkout' - }) + } } } @@ -145,7 +139,7 @@ export const KitCheckoutContent = ({ children }: KitCheckoutProvider) => { value={{ triggerAddFunds, closeAddFunds, - addFundsSettings, + addFundsSettings }} > { triggerCheckout, closeCheckout, settings, - theme, + theme }} > diff --git a/packages/checkout/src/utils/index.ts b/packages/checkout/src/utils/index.ts index 975e9f39..a95dbb22 100644 --- a/packages/checkout/src/utils/index.ts +++ b/packages/checkout/src/utils/index.ts @@ -1,3 +1,3 @@ export * from './helpers' export * from './networks' -export * from './sardine' \ No newline at end of file +export * from './sardine' diff --git a/packages/checkout/src/utils/sardine.ts b/packages/checkout/src/utils/sardine.ts index c9fda4cc..44883be3 100644 --- a/packages/checkout/src/utils/sardine.ts +++ b/packages/checkout/src/utils/sardine.ts @@ -7,12 +7,10 @@ export interface CheckSardineWhitelistStatusArgs { marketplaceAddress: string } -export const checkSardineWhitelistStatus = async ({ - isDev, - chainId, - marketplaceAddress, -}: CheckSardineWhitelistStatusArgs, -projectAccessKey: string) => { +export const checkSardineWhitelistStatus = async ( + { isDev, chainId, marketplaceAddress }: CheckSardineWhitelistStatusArgs, + projectAccessKey: string +) => { const referenceId = `sequence-kit-sardine-whitelist-check` const accessKey = isDev ? '17xhjK4yjRf1fr0am8kgKfICAAAAAAAAA' : projectAccessKey @@ -40,7 +38,7 @@ projectAccessKey: string) => { network: networks[chainId as ChainId].name, recipientAddress: constants.AddressZero, contractAddress: marketplaceAddress, - platform: "calldata_execution", + platform: 'calldata_execution', executionType: 'smart_contract', blockchainNftId: '42', quantity: 1, @@ -49,19 +47,16 @@ projectAccessKey: string) => { tokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', tokenSymbol: 'USDC', tokenDecimals: 6, - callData: '0x1', + callData: '0x1' } }) }) const resJson = await res.json() - if ( - typeof resJson?.cause === 'string' && - resJson.cause.includes('It must me allow listed') - ) { + if (typeof resJson?.cause === 'string' && resJson.cause.includes('It must me allow listed')) { return false } - + return true -} \ No newline at end of file +} diff --git a/packages/checkout/src/utils/transak.ts b/packages/checkout/src/utils/transak.ts index ae872813..81b93cc4 100644 --- a/packages/checkout/src/utils/transak.ts +++ b/packages/checkout/src/utils/transak.ts @@ -1,9 +1,9 @@ -import { AddFundsSettings } from "../contexts" +import { AddFundsSettings } from '../contexts' export const TRANSAK_API_KEY = '5911d9ec-46b5-48fa-a755-d59a715ff0cf' export const getTransakLink = (addFundsSettings: AddFundsSettings) => { - const defaultNetworks = "ethereum,mainnet,arbitrum,optimism,polygon,polygonzkevm,zksync,base,bnb,oasys,astar,avaxcchain" + const defaultNetworks = 'ethereum,mainnet,arbitrum,optimism,polygon,polygonzkevm,zksync,base,bnb,oasys,astar,avaxcchain' interface Options { [index: string]: string | undefined @@ -37,4 +37,4 @@ export const fetchTransakSupportedCountries = async () => { // @ts-ignore-next-line return data.response.filter(x => x.isAllowed).map(x => x.alpha2) -} \ No newline at end of file +} diff --git a/packages/checkout/src/views/AddFunds.tsx b/packages/checkout/src/views/AddFunds.tsx index 57c87ca7..434e4421 100644 --- a/packages/checkout/src/views/AddFunds.tsx +++ b/packages/checkout/src/views/AddFunds.tsx @@ -1,7 +1,5 @@ +import { Box } from '@0xsequence/design-system' import React from 'react' -import { - Box, -} from '@0xsequence/design-system' import { useAddFundsModal } from '../hooks' import { getTransakLink } from '../utils/transak' diff --git a/packages/checkout/src/views/CheckoutSelection/index.tsx b/packages/checkout/src/views/CheckoutSelection/index.tsx index d6c94630..9d339a63 100644 --- a/packages/checkout/src/views/CheckoutSelection/index.tsx +++ b/packages/checkout/src/views/CheckoutSelection/index.tsx @@ -11,7 +11,7 @@ import { Skeleton, TokenImage } from '@0xsequence/design-system' -import { getNativeTokenInfoByChainId, useBalances, useContractInfo, useProjectAccessKey } from '@0xsequence/kit' +import { getNativeTokenInfoByChainId, useBalances, useContractInfo } from '@0xsequence/kit' import { ethers } from 'ethers' import React from 'react' import { useAccount, useConfig } from 'wagmi' @@ -27,7 +27,6 @@ export const CheckoutSelection = () => { const { setNavigation } = useNavigation() const { closeCheckout, settings } = useCheckoutModal() const { address: accountAddress } = useAccount() - const projectAccessKey = useProjectAccessKey() const cryptoCheckoutSettings = settings?.cryptoCheckout const creditCardCheckoutSettings = settings?.creditCardCheckout diff --git a/packages/checkout/src/views/PendingTransaction.tsx b/packages/checkout/src/views/PendingTransaction.tsx index 32f510bc..272ebbeb 100644 --- a/packages/checkout/src/views/PendingTransaction.tsx +++ b/packages/checkout/src/views/PendingTransaction.tsx @@ -1,11 +1,10 @@ import { Box, Spinner, Text } from '@0xsequence/design-system' -import { useProjectAccessKey } from '@0xsequence/kit' +import { useProjectAccessKey, useTokenMetadata } from '@0xsequence/kit' import React, { useEffect } from 'react' import { fetchSardineOrderStatus } from '../api' import { TransactionPendingNavigation } from '../contexts' import { useNavigation, useCheckoutModal, useSardineClientToken } from '../hooks' -import { useTokenMetadata } from '@0xsequence/kit' const POLLING_TIME = 10 * 1000 @@ -19,19 +18,26 @@ export const PendingTransaction = () => { const { setNavigation } = nav const projectAccessKey = useProjectAccessKey() - const { data: tokensMetadata, isLoading: isLoadingTokenMetadata } = useTokenMetadata(creditCardCheckout.chainId, creditCardCheckout.nftAddress, [creditCardCheckout.nftId]) + const { data: tokensMetadata, isLoading: isLoadingTokenMetadata } = useTokenMetadata( + creditCardCheckout.chainId, + creditCardCheckout.nftAddress, + [creditCardCheckout.nftId] + ) const tokenMetadata = tokensMetadata ? tokensMetadata[0] : undefined const isDev = settings?.creditCardCheckout?.isDev || false const disableSardineClientTokenFetch = isLoadingTokenMetadata - const { data, isLoading, isError } = useSardineClientToken({ - order: creditCardCheckout, - isDev, - projectAccessKey: projectAccessKey, - tokenMetadata: tokenMetadata - }, disableSardineClientTokenFetch) + const { data, isLoading, isError } = useSardineClientToken( + { + order: creditCardCheckout, + isDev, + projectAccessKey: projectAccessKey, + tokenMetadata: tokenMetadata + }, + disableSardineClientTokenFetch + ) const authToken = data?.token @@ -103,10 +109,16 @@ export const PendingTransaction = () => { if (isError) { return ( - + An error has occurred @@ -116,10 +128,16 @@ export const PendingTransaction = () => { if (isLoading || !authToken) { return ( - + diff --git a/packages/checkout/src/views/TransactionError.tsx b/packages/checkout/src/views/TransactionError.tsx index 39bb8f39..d800d0e6 100644 --- a/packages/checkout/src/views/TransactionError.tsx +++ b/packages/checkout/src/views/TransactionError.tsx @@ -12,7 +12,8 @@ export const TransactionError = () => { useEffect(() => { setTimeout(() => { closeCheckout() - settings?.creditCardCheckout?.onError && settings?.creditCardCheckout?.onError(navigation.params.error, settings?.creditCardCheckout) + settings?.creditCardCheckout?.onError && + settings?.creditCardCheckout?.onError(navigation.params.error, settings?.creditCardCheckout) }, 3000) }, []) diff --git a/packages/kit/src/connectors/walletConnect/walletConnect.ts b/packages/kit/src/connectors/walletConnect/walletConnect.ts index 585ec312..99b5d778 100644 --- a/packages/kit/src/connectors/walletConnect/walletConnect.ts +++ b/packages/kit/src/connectors/walletConnect/walletConnect.ts @@ -1,6 +1,7 @@ -import { Wallet } from '../../types' import { walletConnect as walletConnectbase, WalletConnectParameters } from 'wagmi/connectors' +import { Wallet } from '../../types' + import { WalletConnectLogo } from './WalletConnectLogo' export const walletConnect = (options: WalletConnectParameters): Wallet => ({ diff --git a/packages/kit/src/constants/localStorage.ts b/packages/kit/src/constants/localStorage.ts index f2a1c1b7..b2af9e9a 100644 --- a/packages/kit/src/constants/localStorage.ts +++ b/packages/kit/src/constants/localStorage.ts @@ -27,5 +27,5 @@ export enum LocalStorageKey { WaasSessionHash = `${PREFIX}.${WAAS_SESSION_HASH}`, WaasActiveLoginType = `${PREFIX}.${WAAS_ACTIVE_LOGIN_TYPE}`, WaasEmailIdToken = `${PREFIX}.${WAAS_EMAIL_ID_TOKEN}`, - WaasSignInEmail = `${PREFIX}.${WAAS_SIGN_IN_EMAIL}`, + WaasSignInEmail = `${PREFIX}.${WAAS_SIGN_IN_EMAIL}` } diff --git a/packages/kit/src/hooks/useWaasSignInEmail.ts b/packages/kit/src/hooks/useWaasSignInEmail.ts index b5fdd618..b53d03bc 100644 --- a/packages/kit/src/hooks/useWaasSignInEmail.ts +++ b/packages/kit/src/hooks/useWaasSignInEmail.ts @@ -8,13 +8,12 @@ import { LocalStorageKey } from '../constants/localStorage' export const useWaasSignInEmail = () => { const { storage } = useConfig() const { isConnected } = useAccount() - const [email, setEmail] = useState(null) - + const [email, setEmail] = useState(null) const storeEmail = async () => { const key = LocalStorageKey.WaasSignInEmail const storedEmail = await storage?.getItem(key as any) - + setEmail(storedEmail) } @@ -28,4 +27,3 @@ export const useWaasSignInEmail = () => { return email } - diff --git a/packages/kit/src/types.ts b/packages/kit/src/types.ts index 8c39d576..8a4d4fce 100644 --- a/packages/kit/src/types.ts +++ b/packages/kit/src/types.ts @@ -18,7 +18,7 @@ export interface WalletProperties { name: string iconBackground?: string hideConnectorId?: string | null - isSequenceBased?: boolean, + isSequenceBased?: boolean type?: 'social' | 'wallet' } @@ -72,7 +72,7 @@ export interface KitConfig { useMock?: boolean } displayedAssets?: DisplayedAsset[] - ethAuth?: EthAuthSettings, + ethAuth?: EthAuthSettings isDev?: boolean } diff --git a/packages/wallet/src/views/Home/components/AssetSummary/CoinTile/index.tsx b/packages/wallet/src/views/Home/components/AssetSummary/CoinTile/index.tsx index 85b4c3c0..a1abd9b9 100644 --- a/packages/wallet/src/views/Home/components/AssetSummary/CoinTile/index.tsx +++ b/packages/wallet/src/views/Home/components/AssetSummary/CoinTile/index.tsx @@ -5,7 +5,6 @@ import { ethers } from 'ethers' import React from 'react' import { useConfig } from 'wagmi' - import { useSettings } from '../../../../../hooks' import { computeBalanceFiat, formatDisplay, getPercentagePriceChange, compareAddress } from '../../../../../utils' diff --git a/packages/wallet/src/views/Receive.tsx b/packages/wallet/src/views/Receive.tsx index 143c0cb9..5acd3d75 100644 --- a/packages/wallet/src/views/Receive.tsx +++ b/packages/wallet/src/views/Receive.tsx @@ -7,7 +7,6 @@ import { useAccount, useConfig } from 'wagmi' import { HEADER_HEIGHT } from '../constants' - export const Receive = () => { const { address, chain } = useAccount() const { chains } = useConfig()