Skip to content

Commit

Permalink
removed env files and scripts - causing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlee348 committed Nov 18, 2024
1 parent c5eb2ec commit 503120d
Show file tree
Hide file tree
Showing 25 changed files with 35 additions and 88 deletions.
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@ dist/
*.iml
.cache
package-lock.json
coverage

.env
packages/kit/src/env.ts
coverage
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ interface CreateConfigOptions {
chainId: number
}>
ethAuth?: EthAuthSettings
isDev?: boolean

wagmiConfig?: WagmiConfig // optional wagmiConfig overrides

Expand Down
2 changes: 0 additions & 2 deletions examples/react/src/components/Connected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ export const Connected = () => {
currencyAddress,
collectionAddress,
creditCardProviders: ['sardine'],
isDev: true,
copyrightText: 'ⓒ2024 Sequence',
onSuccess: (txnHash: string) => {
console.log('success!', txnHash)
Expand Down Expand Up @@ -382,7 +381,6 @@ export const Connected = () => {
nftId: checkoutTokenId,
nftAddress: checkoutTokenContractAddress,
nftQuantity,
isDev: true,
approvedSpenderAddress: orderbookAddress,
calldata: getOrderbookCalldata({
orderId: checkoutOrderId,
Expand Down
1 change: 0 additions & 1 deletion examples/react/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const kitConfig: KitConfig = {
projectName: 'Kit Demo',
useMock: isDebugMode
},
isDev: isDebugMode,
displayedAssets: [
// Native token
{
Expand Down
1 change: 0 additions & 1 deletion examples/react/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export interface GetCheckoutSettings {
calldata: string
approvedSpenderAddress?: string
nftDecimals?: string
isDev?: boolean
}

export const getCheckoutSettings = (args: GetCheckoutSettings) => {
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*}",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/checkout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ const creditCardCheckout = {
nftId: checkoutTokenId,
nftAddress: checkoutTokenContractAddress,
nftQuantity,
isDev: true,
calldata: getOrderbookCalldata({
orderId: checkoutOrderId,
quantity: nftQuantity,
Expand Down
12 changes: 5 additions & 7 deletions packages/checkout/src/api/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FetchSardineClientTokenReturn> => {
// 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'

Expand Down Expand Up @@ -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, {
Expand Down
1 change: 0 additions & 1 deletion packages/checkout/src/contexts/CheckoutModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 1 addition & 2 deletions packages/checkout/src/contexts/SelectPaymentModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface Collectible {
quantity: string
decimals?: number
price?: string
}
}

export interface SelectPaymentSettings {
collectibles: Collectible[]
Expand All @@ -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
Expand Down
12 changes: 9 additions & 3 deletions packages/checkout/src/hooks/useSelectPaymentModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const getERC1155SaleContractConfig = ({
recipientAddress,
collectibles,
collectionAddress,
isDev = false,
...restProps
}: ERC1155SaleContractSettings): SelectPaymentSettings => {
const erc1155SalesContractAbi = [
Expand All @@ -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 {
Expand All @@ -53,7 +60,6 @@ export const getERC1155SaleContractConfig = ({
recipientAddress,
collectibles,
collectionAddress,
isDev,
txData: purchaseTransactionData,
...restProps
}
Expand Down
7 changes: 3 additions & 4 deletions packages/checkout/src/utils/sardine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const PayWithCreditCard = ({ settings, disableButtons }: PayWithCreditCar
collectibles,
collectionAddress,
approvedSpenderAddress,
isDev = false,
onSuccess = () => {},
onError = () => {},
creditCardProviders = []
Expand Down Expand Up @@ -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
}
Expand Down
8 changes: 2 additions & 6 deletions packages/checkout/src/views/PendingTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand All @@ -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`

Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion packages/kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ interface CreateConfigOptions {
chainId: number
}>
ethAuth?: EthAuthSettings
isDev?: boolean

wagmiConfig?: WagmiConfig // optional wagmiConfig overrides

Expand Down
12 changes: 4 additions & 8 deletions packages/kit/src/config/defaultConnectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export interface CommonConnectorOptions {
export interface DefaultWaasConnectorOptions extends CommonConnectorOptions {
waasConfigKey: string
enableConfirmationModal?: boolean
isDev?: boolean

email?: boolean

Expand Down Expand Up @@ -98,7 +97,7 @@ export const getDefaultConnectors = <T extends WalletType>(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[] = []

Expand All @@ -108,8 +107,7 @@ export const getDefaultWaasConnectors = (options: DefaultWaasConnectorOptions):
projectAccessKey,
waasConfigKey,
enableConfirmationModal,
network: defaultChainId,
isDev
network: defaultChainId
})
)
}
Expand All @@ -123,8 +121,7 @@ export const getDefaultWaasConnectors = (options: DefaultWaasConnectorOptions):
waasConfigKey,
googleClientId,
enableConfirmationModal,
network: defaultChainId,
isDev
network: defaultChainId
})
)
}
Expand All @@ -140,8 +137,7 @@ export const getDefaultWaasConnectors = (options: DefaultWaasConnectorOptions):
appleClientId,
appleRedirectURI,
enableConfirmationModal,
network: defaultChainId,
isDev
network: defaultChainId
})
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface SequenceWaasConnectConfig {
appleRedirectURI?: string
enableConfirmationModal?: boolean
loginType: 'email' | 'google' | 'apple'
isDev?: boolean
}

export type BaseSequenceWaasConnectorOptions = SequenceConfig & SequenceWaasConnectConfig & Partial<ExtendedSequenceConfig>
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DEVMODE = false
3 changes: 1 addition & 2 deletions packages/kit/src/hooks/useAPIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 6 additions & 8 deletions packages/kit/src/hooks/useIndexerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChainId, SequenceIndexer>()
}, [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))
Expand All @@ -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<ChainId, SequenceIndexer>()
}, [projectAccessKey, isDev])
}, [projectAccessKey])

const result = new Map<ChainId, SequenceIndexer>()

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))
Expand Down
4 changes: 1 addition & 3 deletions packages/kit/src/hooks/useMetadataClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
1 change: 0 additions & 1 deletion packages/kit/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export interface KitConfig {
}
displayedAssets?: DisplayedAsset[]
ethAuth?: EthAuthSettings
isDev?: boolean
}

export type StorageItem = {
Expand Down
Loading

0 comments on commit 503120d

Please sign in to comment.