Skip to content

Commit 158a62e

Browse files
authored
feat(checkout): Send new params to the create widget URL (#2745)
1 parent 3669e79 commit 158a62e

File tree

3 files changed

+16
-31
lines changed

3 files changed

+16
-31
lines changed

packages/checkout/widgets-lib/src/components/Transak/TransakIframe.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export function TransakIframe(props: TransakIframeProps) {
9898
transition: 'opacity 0.5s ease-out',
9999
}}
100100
onLoad={onLoad}
101+
referrerPolicy="strict-origin-when-cross-origin"
101102
onError={() => onFailedToLoad?.()}
102103
/>
103104
);

packages/checkout/widgets-lib/src/components/Transak/useTransakIframe.ts

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type UseTransakIframeProps = {
2727
onError?: () => void;
2828
};
2929

30-
const MAX_GAS_LIMIT = '30000000';
30+
const MAX_GAS_LIMIT = 30000000;
3131

3232
export const TRANSAK_API_BASE_URL = {
3333
[Environment.SANDBOX]: 'https://api-stg.transak.com',
@@ -69,42 +69,25 @@ export const useTransakIframe = (props: UseTransakIframeProps) => {
6969
// as transak currently only supports on nft at a time
7070
const nftData = nfts?.slice(0, 1)
7171
.map((item) => ({
72-
...item,
73-
imageURL: sanitizeToLatin1(item.imageURL),
74-
nftName: sanitizeToLatin1(item.nftName),
72+
collection_address: item.collectionAddress,
73+
image_url: sanitizeToLatin1(item.imageURL),
74+
nft_name: sanitizeToLatin1(item.nftName),
75+
nft_type: item.nftType,
76+
price: item.price,
77+
quantity: item.quantity,
78+
token_id: item.tokenID,
7579
}));
7680

7781
const gasLimit = estimatedGasLimit > 0 ? estimatedGasLimit : MAX_GAS_LIMIT;
7882

79-
const params = {
80-
contractId,
81-
cryptoCurrencyCode,
82-
calldata,
83-
nftData,
84-
estimatedGasLimit: gasLimit.toString(),
85-
};
86-
87-
// eslint-disable-next-line max-len
88-
const baseApiUrl = `${TRANSAK_API_BASE_URL[environment]}/cryptocoverage/api/v1/public/one-click-protocol/nft-transaction-id`;
89-
90-
const response = await fetch(baseApiUrl, {
91-
method: 'POST',
92-
headers: {
93-
// eslint-disable-next-line @typescript-eslint/naming-convention
94-
'Content-Type': 'application/json',
95-
},
96-
body: JSON.stringify(params),
97-
});
98-
99-
if (!response.ok) {
100-
throw new Error('Failed to get NFT transaction ID');
101-
}
102-
103-
const { id: nftTransactionId } = await response.json();
104-
10583
const requestBody: Record<string, unknown> = {
84+
is_nft: true,
85+
contract_id: contractId,
86+
crypto_currency_code: cryptoCurrencyCode,
87+
calldata,
88+
nft_data: nftData,
89+
estimated_gas_limit: gasLimit,
10690
api_key: TRANSAK_API_KEY[environment],
107-
nft_transaction_id: nftTransactionId,
10891
theme_color: '0D0D0D',
10992
exchange_screen_title: exchangeScreenTitle,
11093
wallet_address: walletAddress,

packages/checkout/widgets-lib/src/widgets/on-ramp/views/OnRampMain.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ export function OnRampMain({
329329
id={transakIframeId}
330330
src={widgetUrl}
331331
allow="camera;microphone;fullscreen;payment"
332+
referrerPolicy="strict-origin-when-cross-origin"
332333
style={{
333334
height: '100%',
334335
width: '100%',

0 commit comments

Comments
 (0)