Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions examples/react/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ export const getErc1155SaleContractConfig = (walletAddress: string) => ({
export const checkoutConfig: SequenceCheckoutConfig = {
env: isDev
? {
sardineCheckoutUrl: 'https://sardine-checkout-sandbox.sequence.info',
sardineOnRampUrl: 'https://crypto.sandbox.sardine.ai/',
transakApiUrl: 'https://global-stg.transak.com',
transakApiKey: 'c20f2a0e-fe6a-4133-8fa7-77e9f84edf98',
forteWidgetUrl: 'https://payments.sandbox.lemmax.com/forte-payments-widget.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/checkout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const MyComponent = () => {
recipientAddress: address,
currencyAddress,
collectionAddress,
creditCardProviders: ['sardine'],
creditCardProviders: ['transak'],
copyrightText: 'ⓒ2024 Sequence',
onSuccess: (txnHash?: string) => {
console.log('success!', txnHash)
Expand Down
236 changes: 2 additions & 234 deletions packages/checkout/src/api/data.ts
Original file line number Diff line number Diff line change
@@ -1,239 +1,7 @@
import type { SequenceAPIClient } from '@0xsequence/api'
import type { TokenMetadata } from '@0xsequence/metadata'
import { ChainId as Chains, findSupportedNetwork, networks, type ChainId } from '@0xsequence/network'
import { ChainId as Chains, findSupportedNetwork } from '@0xsequence/network'
import { zeroAddress } from 'viem'

import { type CreditCardCheckout, type ForteConfig, type StructuredCalldata } from '../contexts/index.js'

export interface FetchSardineClientTokenReturn {
token: string
orderId: string
}

export interface MethodArguments {
[key: string]: any
}

export interface FetchSardineClientTokenArgs {
order: CreditCardCheckout
projectAccessKey: string
apiClientUrl: string
tokenMetadata?: TokenMetadata
}

export const fetchSardineClientToken = async ({
order,
projectAccessKey,
tokenMetadata,
apiClientUrl
}: FetchSardineClientTokenArgs): Promise<FetchSardineClientTokenReturn> => {
// Test credentials: https://docs.sardine.ai/docs/integrate-payments/nft-checkout-testing-credentials
const url = `${apiClientUrl}/rpc/API/SardineGetNFTCheckoutToken`

const res = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Access-Key': projectAccessKey
},
body: JSON.stringify({
params: {
name: tokenMetadata?.name || 'Unknown',
imageUrl: tokenMetadata?.image || 'https://sequence.market/images/placeholder.png',
network: networks[order.chainId as ChainId].name,
recipientAddress: order.recipientAddress,
contractAddress: order.contractAddress,
platform: 'calldata_execution',
blockchainNftId: order.nftId,
quantity: Number(order.nftQuantity),
decimals: Number(order?.nftDecimals || 0),
tokenAmount: order.currencyQuantity,
tokenAddress: order.currencyAddress,
tokenSymbol: order.currencySymbol,
tokenDecimals: Number(order.currencyDecimals),
callData: order.calldata,
...(order?.approvedSpenderAddress ? { approvedSpenderAddress: order.approvedSpenderAddress } : {})
}
})
})

const {
resp: { orderId, token }
} = await res.json()

return {
token,
orderId
}
}

export const fetchSardineOrderStatus = async (orderId: string, projectAccessKey: string, apiClientBaseUrl: string) => {
// Test credentials: https://docs.sardine.ai/docs/integrate-payments/nft-checkout-testing-credentials
const url = `${apiClientBaseUrl}/rpc/API/SardineGetNFTCheckoutOrderStatus`
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Access-Key': `${projectAccessKey}`
},
body: JSON.stringify({
orderId
})
})

const json = await response.json()
console.log('json:', json)
return json
}

export interface Country {
code: string
}

export const fetchSupportedCountryCodes = async (): Promise<Country[]> => {
// Can also be fetches from sardine api
const supportedCountries = [
'AL',
'AO',
'AT',
'BB',
'BE',
'BZ',
'BJ',
'BO',
'BR',
'BG',
'KH',
'KY',
'CL',
'CO',
'KM',
'CR',
'HR',
'CY',
'CZ',
'DK',
'DM',
'DO',
'EC',
'EG',
'SV',
'GQ',
'EE',
'FO',
'FI',
'FR',
'GF',
'DE',
'GR',
'GN',
'GW',
'GY',
'HT',
'HN',
'HU',
'IS',
'ID',
'IE',
'IL',
'IT',
'JM',
'JP',
'KG',
'LA',
'LV',
'LI',
'LT',
'LU',
'MG',
'MY',
'MV',
'MT',
'MR',
'MX',
'MN',
'MZ',
'NL',
'NO',
'OM',
'PA',
'PY',
'PE',
'PH',
'PL',
'PT',
'RO',
'KN',
'MF',
'SA',
'SC',
'SG',
'SK',
'SI',
'KR',
'ES',
'LK',
'SE',
'CH',
'TZ',
'TH',
'TT',
'TR',
'AE',
'GB',
'UY',
'UZ',
'VU',
'VN'
]

return supportedCountries.map(countryCode => ({ code: countryCode }))
}

export interface SardineLinkOnRampArgs {
sardineOnRampUrl: string
apiClient: SequenceAPIClient
walletAddress: string
currencyCode?: string
fundingAmount?: string
network?: string
}

export const fetchSardineOnRampLink = async ({
sardineOnRampUrl,
apiClient,
walletAddress,
currencyCode,
fundingAmount,
network
}: SardineLinkOnRampArgs) => {
const response = await apiClient.sardineGetClientToken()

interface SardineOptions {
client_token: string
address: string
fiat_amount?: string
asset_type?: string
network?: string
}

const options: SardineOptions = {
client_token: response.token,
address: walletAddress,
fiat_amount: fundingAmount,
asset_type: currencyCode,
network
}

const url = new URL(sardineOnRampUrl)
Object.keys(options).forEach(k => {
if (options[k as keyof SardineOptions] !== undefined) {
url.searchParams.append(k, options[k as keyof SardineOptions] as string)
}
})

return url.href
}
import { type ForteConfig, type StructuredCalldata } from '../contexts/index.js'

export interface FetchForteAccessTokenReturn {
accessToken: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@ export const SequenceCheckoutProvider = ({ children, config }: SequenceCheckoutP
<EnvironmentContextProvider
value={{
marketplaceApiUrl: config?.env?.marketplaceApiUrl ?? 'https://marketplace-api.sequence.app',
sardineCheckoutUrl: config?.env?.sardineCheckoutUrl ?? 'https://sardine-checkout.sequence.info',
sardineOnRampUrl: config?.env?.sardineOnRampUrl ?? 'https://crypto.sardine.ai/',
transakApiUrl: config?.env?.transakApiUrl ?? 'https://global.transak.com',
transakApiKey: config?.env?.transakApiKey ?? '5911d9ec-46b5-48fa-a755-d59a715ff0cf',
forteWidgetUrl: config?.env?.forteWidgetUrl ?? 'https://payments.prod.lemmax.com/forte-payments-widget.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/checkout/src/contexts/CheckoutModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export interface CreditCardCheckout {
nftQuantity: string
nftDecimals?: string
calldata: string
provider?: 'sardine' | 'transak' | 'forte'
provider?: 'transak' | 'forte'
transakConfig?: TransakConfig
forteConfig?: ForteConfig
onSuccess?: (transactionHash?: string, settings?: CreditCardCheckout) => void
Expand Down
2 changes: 0 additions & 2 deletions packages/checkout/src/contexts/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export interface EnvironmentOverrides {
marketplaceApiUrl: string
transakApiUrl: string
transakApiKey: string
sardineCheckoutUrl: string
sardineOnRampUrl: string
forteWidgetUrl: string
}

Expand Down
7 changes: 1 addition & 6 deletions packages/checkout/src/contexts/SelectPaymentModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ForteConfig, TransakConfig } from '../contexts/CheckoutModal.js'

import { createGenericContext } from './genericContext.js'

export type CreditCardProviders = 'sardine' | 'transak' | 'forte'
export type CreditCardProviders = 'transak' | 'forte'

export interface Collectible {
tokenId?: string
Expand All @@ -19,10 +19,6 @@ export interface SupplementaryAnalyticsInfo {
[key: string]: string
}

export interface SardineConfig {
approvedSpenderAddress?: string
}

export interface ActionButtons {
label: string
action: () => void
Expand All @@ -45,7 +41,6 @@ export interface SelectPaymentSettings {
onRampProvider?: TransactionOnRampProvider
creditCardProviders?: string[]
transakConfig?: TransakConfig
sardineConfig?: SardineConfig
forteConfig?: ForteConfig
customProviderCallback?: (onSuccess: (txHash: string) => void, onError: (error: Error) => void, onClose: () => void) => void
supplementaryAnalyticsInfo?: SupplementaryAnalyticsInfo
Expand Down
4 changes: 0 additions & 4 deletions packages/checkout/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ export * from './useAddFundsModal.js'
export * from './useCheckoutModal.js'
export * from './useNavigation.js'
export * from './useModalTheme.js'
export * from './useCheckoutWhitelistStatus.js'
export * from './useSardineClientToken.js'
export * from './useSelectPaymentModal.js'
export * from './useTransferFundsModal.js'
export * from './useTransactionStatusModal.js'
export * from './useSwapModal.js'
export * from './useCheckoutOptionsSalesContract.js'
export * from './useERC1155SaleContractCheckout.js'
export * from './useSkipOnCloseCallback.js'
export * from './useSardineOnRampLink.js'
export * from './useFortePaymentIntent.js'
export * from './useAddFundsModal.js'
Loading