Skip to content

Commit

Permalink
linting and prettier (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
bunnybones1 authored Jul 25, 2024
1 parent c704334 commit 6cfb2d3
Show file tree
Hide file tree
Showing 24 changed files with 110 additions and 101 deletions.
2 changes: 1 addition & 1 deletion examples/react/src/components/Connected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
16 changes: 15 additions & 1 deletion examples/react/src/constants/orderbook-abi.ts
Original file line number Diff line number Diff line change
@@ -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"}]
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'
}
]
32 changes: 13 additions & 19 deletions examples/react/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions packages/checkout/src/api/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export interface MethodArguments {
}

export interface FetchSardineClientTokenArgs {
order: CreditCardCheckout,
isDev: boolean,
projectAccessKey: string,
order: CreditCardCheckout
isDev: boolean
projectAccessKey: string
tokenMetadata?: TokenMetadata
}

Expand All @@ -24,7 +24,7 @@ export const fetchSardineClientToken = async ({
isDev,
projectAccessKey,
tokenMetadata
}: FetchSardineClientTokenArgs): Promise<FetchSardineClientTokenReturn> => {
}: FetchSardineClientTokenArgs): Promise<FetchSardineClientTokenReturn> => {
// Test credentials: https://docs.sardine.ai/docs/integrate-payments/nft-checkout-testing-credentials
const accessKey = isDev ? '17xhjK4yjRf1fr0am8kgKfICAAAAAAAAA' : projectAccessKey
const url = isDev
Expand All @@ -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),
Expand Down
8 changes: 4 additions & 4 deletions packages/checkout/src/contexts/AddFundsModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion packages/checkout/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export * from './useCheckoutModal'
export * from './useNavigation'
export * from './useModalTheme'
export * from './useCheckoutWhitelistStatus'
export * from './useSardineClientToken'
export * from './useSardineClientToken'
1 change: 0 additions & 1 deletion packages/checkout/src/hooks/useCheckoutWhitelistStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion packages/checkout/src/hooks/useSardineClientToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export const useSardineClientToken = (args: FetchSardineClientTokenArgs, disable
retry: false,
staleTime: 0,
enabled: !disabled,
refetchOnWindowFocus: false,
refetchOnWindowFocus: false
})
}
2 changes: 1 addition & 1 deletion packages/checkout/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export { type CheckoutSettings } from './contexts/CheckoutModal'
export { type AddFundsSettings } from './contexts/AddFundsModal'

// utils
export { fetchTransakSupportedCountries, getTransakLink } from './utils/transak'
export { fetchTransakSupportedCountries, getTransakLink } from './utils/transak'
24 changes: 9 additions & 15 deletions packages/checkout/src/shared/components/KitCheckoutProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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'
})
}
}
}

Expand Down Expand Up @@ -145,15 +139,15 @@ export const KitCheckoutContent = ({ children }: KitCheckoutProvider) => {
value={{
triggerAddFunds,
closeAddFunds,
addFundsSettings,
addFundsSettings
}}
>
<CheckoutModalContextProvider
value={{
triggerCheckout,
closeCheckout,
settings,
theme,
theme
}}
>
<NavigationContextProvider value={{ history, setHistory, defaultLocation: getDefaultLocation() }}>
Expand Down
2 changes: 1 addition & 1 deletion packages/checkout/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './helpers'
export * from './networks'
export * from './sardine'
export * from './sardine'
23 changes: 9 additions & 14 deletions packages/checkout/src/utils/sardine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
}
}
6 changes: 3 additions & 3 deletions packages/checkout/src/utils/transak.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -37,4 +37,4 @@ export const fetchTransakSupportedCountries = async () => {

// @ts-ignore-next-line
return data.response.filter(x => x.isAllowed).map(x => x.alpha2)
}
}
4 changes: 1 addition & 3 deletions packages/checkout/src/views/AddFunds.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 1 addition & 2 deletions packages/checkout/src/views/CheckoutSelection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
Loading

0 comments on commit 6cfb2d3

Please sign in to comment.