diff --git a/.env.example b/.env.example deleted file mode 100644 index 32135bab..00000000 --- a/.env.example +++ /dev/null @@ -1 +0,0 @@ -DEVMODE=false \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7f400b41..2101d5ae 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,4 @@ dist/ *.iml .cache package-lock.json -coverage - -.env -packages/kit/src/env.ts +coverage \ No newline at end of file diff --git a/README.md b/README.md index 5f12627a..00460f44 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,6 @@ interface CreateConfigOptions { chainId: number }> ethAuth?: EthAuthSettings - isDev?: boolean wagmiConfig?: WagmiConfig // optional wagmiConfig overrides diff --git a/examples/react/src/components/Connected.tsx b/examples/react/src/components/Connected.tsx index 89903ae3..011ac5ec 100644 --- a/examples/react/src/components/Connected.tsx +++ b/examples/react/src/components/Connected.tsx @@ -352,7 +352,6 @@ export const Connected = () => { currencyAddress, collectionAddress, creditCardProviders: ['sardine'], - isDev: true, copyrightText: 'ⓒ2024 Sequence', onSuccess: (txnHash: string) => { console.log('success!', txnHash) @@ -382,7 +381,6 @@ export const Connected = () => { nftId: checkoutTokenId, nftAddress: checkoutTokenContractAddress, nftQuantity, - isDev: true, approvedSpenderAddress: orderbookAddress, calldata: getOrderbookCalldata({ orderId: checkoutOrderId, diff --git a/examples/react/src/config.ts b/examples/react/src/config.ts index 571e70b8..6c45af82 100644 --- a/examples/react/src/config.ts +++ b/examples/react/src/config.ts @@ -23,7 +23,6 @@ export const kitConfig: KitConfig = { projectName: 'Kit Demo', useMock: isDebugMode }, - isDev: isDebugMode, displayedAssets: [ // Native token { diff --git a/examples/react/src/utils/helpers.ts b/examples/react/src/utils/helpers.ts index 1cf33e21..3c34994f 100644 --- a/examples/react/src/utils/helpers.ts +++ b/examples/react/src/utils/helpers.ts @@ -35,7 +35,6 @@ export interface GetCheckoutSettings { calldata: string approvedSpenderAddress?: string nftDecimals?: string - isDev?: boolean } export const getCheckoutSettings = (args: GetCheckoutSettings) => { diff --git a/package.json b/package.json index f48a8c05..ba2fe48d 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,6 @@ "license": "Apache-2.0", "sideEffects": false, "scripts": { - "copy-env": "((cp -n .env.example .env) || echo already exists)", - "generate-env": "node scripts/generate-env.js", - "postinstall": "pnpm run copy-env && pnpm run generate-env", "build": "turbo run build --filter={packages/*}", "build:clean": "turbo run build:clean", "dev": "turbo run dev --filter={packages/*}", @@ -42,7 +39,6 @@ "@typescript-eslint/parser": "^7.10.0", "@vanilla-extract/css": "^1.15.2", "@vanilla-extract/recipes": "^0.5.3", - "dotenv": "^16.4.5", "eslint": "^8.27.0", "eslint-config-prettier": "^8.10.0", "eslint-plugin-import": "^2.29.1", diff --git a/packages/checkout/README.md b/packages/checkout/README.md index 5b6f587f..9d7874a4 100644 --- a/packages/checkout/README.md +++ b/packages/checkout/README.md @@ -116,7 +116,6 @@ const creditCardCheckout = { nftId: checkoutTokenId, nftAddress: checkoutTokenContractAddress, nftQuantity, - isDev: true, calldata: getOrderbookCalldata({ orderId: checkoutOrderId, quantity: nftQuantity, diff --git a/packages/checkout/src/api/data.ts b/packages/checkout/src/api/data.ts index 2bf56b55..da89c6c0 100644 --- a/packages/checkout/src/api/data.ts +++ b/packages/checkout/src/api/data.ts @@ -16,20 +16,18 @@ export interface MethodArguments { export interface FetchSardineClientTokenArgs { order: CreditCardCheckout - isDev: boolean projectAccessKey: string tokenMetadata?: TokenMetadata } export const fetchSardineClientToken = async ({ order, - isDev, projectAccessKey, tokenMetadata }: FetchSardineClientTokenArgs): Promise => { // Test credentials: https://docs.sardine.ai/docs/integrate-payments/nft-checkout-testing-credentials - const accessKey = isDev ? '17xhjK4yjRf1fr0am8kgKfICAAAAAAAAA' : projectAccessKey - const url = isDev + const accessKey = DEVMODE ? '17xhjK4yjRf1fr0am8kgKfICAAAAAAAAA' : projectAccessKey + const url = DEVMODE ? 'https://dev-api.sequence.app/rpc/API/SardineGetNFTCheckoutToken' : 'https://api.sequence.app/rpc/API/SardineGetNFTCheckoutToken' @@ -70,10 +68,10 @@ export const fetchSardineClientToken = async ({ } } -export const fetchSardineOrderStatus = async (orderId: string, isDev: boolean, projectAccessKey: string) => { +export const fetchSardineOrderStatus = async (orderId: string, projectAccessKey: string) => { // Test credentials: https://docs.sardine.ai/docs/integrate-payments/nft-checkout-testing-credentials - const accessKey = isDev ? '17xhjK4yjRf1fr0am8kgKfICAAAAAAAAA' : projectAccessKey - const url = isDev + const accessKey = DEVMODE ? '17xhjK4yjRf1fr0am8kgKfICAAAAAAAAA' : projectAccessKey + const url = DEVMODE ? 'https://dev-api.sequence.app/rpc/API/SardineGetNFTCheckoutOrderStatus' : 'https://api.sequence.app/rpc/API/SardineGetNFTCheckoutOrderStatus' const response = await fetch(url, { diff --git a/packages/checkout/src/contexts/CheckoutModal.ts b/packages/checkout/src/contexts/CheckoutModal.ts index 1956bc94..ff6fb59d 100644 --- a/packages/checkout/src/contexts/CheckoutModal.ts +++ b/packages/checkout/src/contexts/CheckoutModal.ts @@ -31,7 +31,6 @@ export interface CreditCardCheckout { calldata: string onSuccess?: (transactionHash: string, settings: CreditCardCheckout) => void onError?: (error: Error, settings: CreditCardCheckout) => void - isDev?: boolean approvedSpenderAddress?: string } diff --git a/packages/checkout/src/contexts/SelectPaymentModal.ts b/packages/checkout/src/contexts/SelectPaymentModal.ts index 9f477637..8324aec4 100644 --- a/packages/checkout/src/contexts/SelectPaymentModal.ts +++ b/packages/checkout/src/contexts/SelectPaymentModal.ts @@ -9,7 +9,7 @@ export interface Collectible { quantity: string decimals?: number price?: string - } +} export interface SelectPaymentSettings { collectibles: Collectible[] @@ -21,7 +21,6 @@ export interface SelectPaymentSettings { collectionAddress: string | Hex recipientAddress: string | Hex approvedSpenderAddress?: string - isDev?: boolean transactionConfirmations?: number onSuccess?: (txHash: string) => void onError?: (error: Error) => void diff --git a/packages/checkout/src/hooks/useSelectPaymentModal.ts b/packages/checkout/src/hooks/useSelectPaymentModal.ts index 0da8a8e0..8fb699b2 100644 --- a/packages/checkout/src/hooks/useSelectPaymentModal.ts +++ b/packages/checkout/src/hooks/useSelectPaymentModal.ts @@ -19,7 +19,6 @@ export const getERC1155SaleContractConfig = ({ recipientAddress, collectibles, collectionAddress, - isDev = false, ...restProps }: ERC1155SaleContractSettings): SelectPaymentSettings => { const erc1155SalesContractAbi = [ @@ -43,7 +42,15 @@ export const getERC1155SaleContractConfig = ({ const purchaseTransactionData = encodeFunctionData({ abi: erc1155SalesContractAbi, functionName: 'mint', - args: [recipientAddress, collectibles.map(c => BigInt(c.tokenId)), collectibles.map(c => BigInt(c.quantity)), toHex(0), currencyAddress, price, [toHex(0, { size: 32 })]] + args: [ + recipientAddress, + collectibles.map(c => BigInt(c.tokenId)), + collectibles.map(c => BigInt(c.quantity)), + toHex(0), + currencyAddress, + price, + [toHex(0, { size: 32 })] + ] }) return { @@ -53,7 +60,6 @@ export const getERC1155SaleContractConfig = ({ recipientAddress, collectibles, collectionAddress, - isDev, txData: purchaseTransactionData, ...restProps } diff --git a/packages/checkout/src/utils/sardine.ts b/packages/checkout/src/utils/sardine.ts index 5ae23bdf..40ea22cc 100644 --- a/packages/checkout/src/utils/sardine.ts +++ b/packages/checkout/src/utils/sardine.ts @@ -4,20 +4,19 @@ import { ethers } from 'ethers' import { DEVMODE } from '@0xsequence/kit' export interface CheckSardineWhitelistStatusArgs { - isDev: boolean chainId: number marketplaceAddress: string } export const checkSardineWhitelistStatus = async ( - { isDev, chainId, marketplaceAddress }: CheckSardineWhitelistStatusArgs, + { chainId, marketplaceAddress }: CheckSardineWhitelistStatusArgs, projectAccessKey: string ) => { const referenceId = `sequence-kit-sardine-whitelist-check` - const accessKey = isDev ? '17xhjK4yjRf1fr0am8kgKfICAAAAAAAAA' : projectAccessKey + const accessKey = DEVMODE ? '17xhjK4yjRf1fr0am8kgKfICAAAAAAAAA' : projectAccessKey - const url = isDev + const url = DEVMODE ? 'https://dev-api.sequence.app/rpc/API/SardineGetNFTCheckoutToken' : 'https://api.sequence.app/rpc/API/SardineGetNFTCheckoutToken' diff --git a/packages/checkout/src/views/PaymentSelection/PayWithCreditCard/index.tsx b/packages/checkout/src/views/PaymentSelection/PayWithCreditCard/index.tsx index ceb7a4b3..82035c8f 100644 --- a/packages/checkout/src/views/PaymentSelection/PayWithCreditCard/index.tsx +++ b/packages/checkout/src/views/PaymentSelection/PayWithCreditCard/index.tsx @@ -36,7 +36,6 @@ export const PayWithCreditCard = ({ settings, disableButtons }: PayWithCreditCar collectibles, collectionAddress, approvedSpenderAddress, - isDev = false, onSuccess = () => {}, onError = () => {}, creditCardProviders = [] @@ -93,7 +92,6 @@ export const PayWithCreditCard = ({ settings, disableButtons }: PayWithCreditCar nftAddress: collectionAddress, nftQuantity: collectible.quantity, nftDecimals: collectible.decimals === undefined ? undefined : String(collectible.decimals), - isDev, calldata: txData, approvedSpenderAddress: approvedSpenderAddress || targetContractAddress } diff --git a/packages/checkout/src/views/PendingTransaction.tsx b/packages/checkout/src/views/PendingTransaction.tsx index 4567325e..df8920a0 100644 --- a/packages/checkout/src/views/PendingTransaction.tsx +++ b/packages/checkout/src/views/PendingTransaction.tsx @@ -28,14 +28,11 @@ export const PendingTransaction = () => { ) 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 }, @@ -44,7 +41,7 @@ export const PendingTransaction = () => { const authToken = data?.token - const url = isDev + const url = DEVMODE ? `https://sardine-checkout-sandbox.sequence.info?api_url=https://sardine-api-sandbox.sequence.info&client_token=${authToken}&show_features=true` : `https://sardine-checkout.sequence.info?api_url=https://sardine-api.sequence.info&client_token=${authToken}&show_features=true` @@ -57,9 +54,8 @@ export const PendingTransaction = () => { const { orderId } = data console.log('Polling for transaction status') - const isDev = creditCardCheckout?.isDev || false - const pollResponse = await fetchSardineOrderStatus(orderId, isDev, projectAccessKey) + const pollResponse = await fetchSardineOrderStatus(orderId, projectAccessKey) const status = pollResponse.resp.status const transactionHash = pollResponse.resp?.transactionHash diff --git a/packages/kit/README.md b/packages/kit/README.md index 9bab04e2..24ecda62 100644 --- a/packages/kit/README.md +++ b/packages/kit/README.md @@ -55,7 +55,6 @@ interface CreateConfigOptions { chainId: number }> ethAuth?: EthAuthSettings - isDev?: boolean wagmiConfig?: WagmiConfig // optional wagmiConfig overrides diff --git a/packages/kit/src/config/defaultConnectors.ts b/packages/kit/src/config/defaultConnectors.ts index a4fddb3c..178d1404 100644 --- a/packages/kit/src/config/defaultConnectors.ts +++ b/packages/kit/src/config/defaultConnectors.ts @@ -23,7 +23,6 @@ export interface CommonConnectorOptions { export interface DefaultWaasConnectorOptions extends CommonConnectorOptions { waasConfigKey: string enableConfirmationModal?: boolean - isDev?: boolean email?: boolean @@ -98,7 +97,7 @@ export const getDefaultConnectors = (walletType: T, option } export const getDefaultWaasConnectors = (options: DefaultWaasConnectorOptions): CreateConnectorFn[] => { - const { projectAccessKey, waasConfigKey, appName, enableConfirmationModal, defaultChainId, isDev } = options + const { projectAccessKey, waasConfigKey, appName, enableConfirmationModal, defaultChainId } = options const wallets: Wallet[] = [] @@ -108,8 +107,7 @@ export const getDefaultWaasConnectors = (options: DefaultWaasConnectorOptions): projectAccessKey, waasConfigKey, enableConfirmationModal, - network: defaultChainId, - isDev + network: defaultChainId }) ) } @@ -123,8 +121,7 @@ export const getDefaultWaasConnectors = (options: DefaultWaasConnectorOptions): waasConfigKey, googleClientId, enableConfirmationModal, - network: defaultChainId, - isDev + network: defaultChainId }) ) } @@ -140,8 +137,7 @@ export const getDefaultWaasConnectors = (options: DefaultWaasConnectorOptions): appleClientId, appleRedirectURI, enableConfirmationModal, - network: defaultChainId, - isDev + network: defaultChainId }) ) } diff --git a/packages/kit/src/connectors/wagmiConnectors/sequenceWaasConnector.ts b/packages/kit/src/connectors/wagmiConnectors/sequenceWaasConnector.ts index 317f0d2a..26cb1cec 100644 --- a/packages/kit/src/connectors/wagmiConnectors/sequenceWaasConnector.ts +++ b/packages/kit/src/connectors/wagmiConnectors/sequenceWaasConnector.ts @@ -28,7 +28,6 @@ export interface SequenceWaasConnectConfig { appleRedirectURI?: string enableConfirmationModal?: boolean loginType: 'email' | 'google' | 'apple' - isDev?: boolean } export type BaseSequenceWaasConnectorOptions = SequenceConfig & SequenceWaasConnectConfig & Partial @@ -53,8 +52,7 @@ export function sequenceWaasWallet(params: BaseSequenceWaasConnectorOptions) { [LocalStorageKey.WaasSignInEmail]: string } - const isDev = !!params?.isDev - const nodesUrl = isDev ? 'https://dev-nodes.sequence.app' : 'https://nodes.sequence.app' + const nodesUrl = DEVMODE ? 'https://dev-nodes.sequence.app' : 'https://nodes.sequence.app' const showConfirmationModal = params.enableConfirmationModal ?? false diff --git a/packages/kit/src/env.ts b/packages/kit/src/env.ts new file mode 100644 index 00000000..24254c1b --- /dev/null +++ b/packages/kit/src/env.ts @@ -0,0 +1 @@ +export const DEVMODE = false diff --git a/packages/kit/src/hooks/useAPIClient.ts b/packages/kit/src/hooks/useAPIClient.ts index b54b3197..c3b52b80 100644 --- a/packages/kit/src/hooks/useAPIClient.ts +++ b/packages/kit/src/hooks/useAPIClient.ts @@ -9,9 +9,8 @@ import { DEVMODE } from '../env' export const useAPIClient = () => { const projectAccessKey = useProjectAccessKey() - const { isDev = false } = useKitConfig() - const clientUrl = isDev ? 'https://dev-api.sequence.app' : 'https://api.sequence.app' + const clientUrl = DEVMODE ? 'https://dev-api.sequence.app' : 'https://api.sequence.app' const apiClient = useMemo(() => { return new SequenceAPIClient(clientUrl, projectAccessKey) diff --git a/packages/kit/src/hooks/useIndexerClient.ts b/packages/kit/src/hooks/useIndexerClient.ts index 956d826d..c025d037 100644 --- a/packages/kit/src/hooks/useIndexerClient.ts +++ b/packages/kit/src/hooks/useIndexerClient.ts @@ -11,14 +11,12 @@ import { DEVMODE } from '../env' export const useIndexerClient = (chainId: ChainId) => { const projectAccessKey = useProjectAccessKey() - const { isDev = false } = useKitConfig() - const indexerClients = useMemo(() => { return new Map() - }, [projectAccessKey, isDev]) + }, [projectAccessKey]) const network = networks[chainId] - const clientUrl = isDev ? `https://dev-${network.name}-indexer.sequence.app` : `https://${network.name}-indexer.sequence.app` + const clientUrl = DEVMODE ? `https://dev-${network.name}-indexer.sequence.app` : `https://${network.name}-indexer.sequence.app` if (!indexerClients.has(chainId)) { indexerClients.set(chainId, new SequenceIndexer(clientUrl, projectAccessKey)) @@ -36,17 +34,17 @@ export const useIndexerClient = (chainId: ChainId) => { export const useIndexerClients = (chainIds: ChainId[]) => { const projectAccessKey = useProjectAccessKey() - const { isDev = false } = useKitConfig() - const indexerClients = useMemo(() => { return new Map() - }, [projectAccessKey, isDev]) + }, [projectAccessKey]) const result = new Map() for (const chainId of chainIds) { const network = networks[chainId] - const clientUrl = isDev ? `https://dev-${network.name}-indexer.sequence.app` : `https://${network.name}-indexer.sequence.app` + const clientUrl = DEVMODE + ? `https://dev-${network.name}-indexer.sequence.app` + : `https://${network.name}-indexer.sequence.app` if (!indexerClients.has(chainId)) { indexerClients.set(chainId, new SequenceIndexer(clientUrl, projectAccessKey)) diff --git a/packages/kit/src/hooks/useMetadataClient.ts b/packages/kit/src/hooks/useMetadataClient.ts index 5191134c..f5609091 100644 --- a/packages/kit/src/hooks/useMetadataClient.ts +++ b/packages/kit/src/hooks/useMetadataClient.ts @@ -10,10 +10,8 @@ import { DEVMODE } from '../env' export const useMetadataClient = () => { const projectAccessKey = useProjectAccessKey() - const { isDev = false } = useKitConfig() - const metadataClient = useMemo(() => { - const clientUrl = isDev ? 'https://dev-metadata.sequence.app' : 'https://metadata.sequence.app' + const clientUrl = DEVMODE ? 'https://dev-metadata.sequence.app' : 'https://metadata.sequence.app' return new SequenceMetadata(clientUrl, projectAccessKey) }, [projectAccessKey]) diff --git a/packages/kit/src/types.ts b/packages/kit/src/types.ts index 5ef32da5..f407809d 100644 --- a/packages/kit/src/types.ts +++ b/packages/kit/src/types.ts @@ -75,7 +75,6 @@ export interface KitConfig { } displayedAssets?: DisplayedAsset[] ethAuth?: EthAuthSettings - isDev?: boolean } export type StorageItem = { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 181fa49e..2a5d10eb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,9 +38,6 @@ importers: '@vanilla-extract/recipes': specifier: ^0.5.3 version: 0.5.5(@vanilla-extract/css@1.15.5) - dotenv: - specifier: ^16.4.5 - version: 16.4.5 eslint: specifier: ^8.27.0 version: 8.57.1 @@ -3987,10 +3984,6 @@ packages: dot-case@3.0.4: resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==} - dotenv@16.4.5: - resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} - engines: {node: '>=12'} - dotenv@8.6.0: resolution: {integrity: sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==} engines: {node: '>=10'} @@ -12324,8 +12317,6 @@ snapshots: no-case: 3.0.4 tslib: 2.7.0 - dotenv@16.4.5: {} - dotenv@8.6.0: {} duplexify@4.1.3: diff --git a/scripts/generate-env.js b/scripts/generate-env.js deleted file mode 100644 index a6cfdf3f..00000000 --- a/scripts/generate-env.js +++ /dev/null @@ -1,13 +0,0 @@ -const fs = require('fs') -const path = require('path') -const dotenv = require('dotenv') - -dotenv.config() - -const envFilePath = path.resolve(__dirname, '../packages/kit/src/env.ts') - -const envFileContent = `export const DEVMODE = ${process.env.DEVMODE}` - -fs.writeFileSync(envFilePath, envFileContent.trim(), 'utf8') - -console.log('env.ts file generated successfully')