Skip to content

Commit

Permalink
added missing network field to Transak
Browse files Browse the repository at this point in the history
  • Loading branch information
SamueleA committed Dec 12, 2024
1 parent e4cd28b commit 7d0b862
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
11 changes: 9 additions & 2 deletions examples/react/src/components/Connected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,15 @@ export const Connected = () => {
recipientAddress: address,
currencyAddress,
collectionAddress,
creditCardProviders: ['sardine'],
isDev: true,
creditCardProviders: ['transak'],
transakConfig: {
// contractId for native sale contract: '0xf0056139095224f4eec53c578ab4de1e227b9597'
// contractId: '674eb55a3d739107bbd18ecb',
// contractId for ERC20 sale contract: '0xe65b75eb7c58ffc0bf0e671d64d0e1c6cd0d3e5b'
contractId: '674eb5613d739107bbd18ed2',
apiKey: '5911d9ec-46b5-48fa-a755-d59a715ff0cf'
},
isDev: false,
copyrightText: 'ⓒ2024 Sequence',
onSuccess: (txnHash: string) => {
console.log('success!', txnHash)
Expand Down
18 changes: 12 additions & 6 deletions packages/checkout/src/views/PendingCreditCardTransaction.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Box, Spinner, Text } from '@0xsequence/design-system'
import { useProjectAccessKey, useContractInfo, useTokenMetadata } from '@0xsequence/kit'
import { findSupportedNetwork } from '@0xsequence/network'
import pako from 'pako'
import React, { useEffect } from 'react'
import { formatUnits, parseUnits } from 'viem'
import { useEffect } from 'react'
import { formatUnits } from 'viem'

import { fetchSardineOrderStatus } from '../api'
import { TransactionPendingNavigation } from '../contexts'
Expand All @@ -20,7 +21,7 @@ export const PendingCreditCardTransaction = () => {

switch (provider) {
case 'transak':
return <PendingCreditCardTransactionSardine />
return <PendingCreditCardTransactionTransak />
case 'sardine':
default:
return <PendingCreditCardTransactionSardine />
Expand Down Expand Up @@ -50,6 +51,8 @@ export const PendingCreditCardTransactionTransak = () => {
isError: isErrorCollectionInfo
} = useContractInfo(creditCardCheckout.chainId, creditCardCheckout.nftAddress)

const network = findSupportedNetwork(creditCardCheckout.chainId)

const tokenMetadata = tokensMetadata ? tokensMetadata[0] : undefined

const transakConfig = settings?.creditCardCheckout?.transakConfig
Expand Down Expand Up @@ -81,10 +84,13 @@ export const PendingCreditCardTransactionTransak = () => {

const partnerOrderId = `${creditCardCheckout.recipientAddress}-${new Date().getTime()}`

const transakLink = `${baseUrl}?apiKey=${transakConfig?.apiKey}&isNFT=true&calldata=${transakCallData}&contractId=${transakConfig?.contractId}&cryptoCurrencyCode=${creditCardCheckout.currencySymbol}&estimatedGasLimit=${estimatedGasLimit}&nftData=${transakNftData}&walletAddress=${creditCardCheckout.recipientAddress}&disableWalletAddressForm=true&partnerOrderId=${partnerOrderId}`
// Note: the network name might not always line up with Transak. A conversion function might be necessary
const networkName = network?.name.toLowerCase()

const transakLink = `${baseUrl}?apiKey=${transakConfig?.apiKey}&isNFT=true&calldata=${transakCallData}&contractId=${transakConfig?.contractId}&cryptoCurrencyCode=${creditCardCheckout.currencySymbol}&estimatedGasLimit=${estimatedGasLimit}&nftData=${transakNftData}&walletAddress=${creditCardCheckout.recipientAddress}&disableWalletAddressForm=true&partnerOrderId=${partnerOrderId}&network=${networkName}`

const isLoading = isLoadingTokenMetadata
const isError = isErrorTokenMetadata
const isLoading = isLoadingTokenMetadata || isLoadingCollectionInfo
const isError = isErrorTokenMetadata || isErrorCollectionInfo

useEffect(() => {
const transakIframeElement = document.getElementById('transakIframe') as HTMLIFrameElement
Expand Down

0 comments on commit 7d0b862

Please sign in to comment.