@imtbl/checkout-widgets 2.4.7 → 2.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +1 -1
- package/dist/browser/{AddTokensWidget-DUK0xSaH.js → AddTokensWidget-CjsKM-T9.js} +3 -3
- package/dist/browser/{BridgeWidget-QR1xBfOF.js → BridgeWidget-DVD0vbXw.js} +79 -204
- package/dist/browser/{CommerceWidget-DbkApbhd.js → CommerceWidget-6Bk4VqFB.js} +13 -13
- package/dist/browser/{FeesBreakdown-C9jaHA04.js → FeesBreakdown-DJ8ernNZ.js} +1 -1
- package/dist/browser/{OnRampWidget-BFnyKHnm.js → OnRampWidget-70zEixzs.js} +3 -3
- package/dist/browser/{SaleWidget-Dkz59HGP.js → SaleWidget-POpNJFz2.js} +11 -10
- package/dist/browser/{SpendingCapHero-wnemhkzF.js → SpendingCapHero-C1OAzZ0n.js} +1 -1
- package/dist/browser/{SwapWidget-D4v53qed.js → SwapWidget-BhBc76QL.js} +6 -6
- package/dist/browser/{TokenImage-y9yHy5FI.js → TokenImage-9_8xOVNs.js} +1 -1
- package/dist/browser/{TopUpView-Cw5fRr6J.js → TopUpView-DpVUPPQE.js} +1 -1
- package/dist/browser/{WalletApproveHero-CqkvX4i7.js → WalletApproveHero-BHSPmZJh.js} +2 -2
- package/dist/browser/{WalletWidget-Dj-DhyiY.js → WalletWidget-JvUIuAdq.js} +3 -3
- package/dist/browser/{auto-track-BiAYJzx-.js → auto-track-Qz7LJ7YA.js} +1 -1
- package/dist/browser/{index-DAskMD3i.js → index-B8U0yV6w.js} +1 -1
- package/dist/browser/{index-OuEh4lB4.js → index-BFdJZ7kd.js} +1 -1
- package/dist/browser/{index-BBEStEr8.js → index-BLySvWQF.js} +2 -2
- package/dist/browser/{index-mwYRhIMX.js → index-DDEez-8b.js} +21 -28
- package/dist/browser/{index-YqoOzflx.js → index-JULMMCb5.js} +1 -1
- package/dist/browser/{index-CsCOnnNv.js → index-OzMQ0nH8.js} +1 -1
- package/dist/browser/{index-C2r0JBIr.js → index-nyzac6M7.js} +1 -1
- package/dist/browser/{index-D5YHQOIu.js → index-o1Wg1vKu.js} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/{index.umd-DryKZ_qj.js → index.umd-DdybBYbs.js} +1 -1
- package/dist/browser/{useInterval-D69Yoe3f.js → useInterval-CKXa8zia.js} +1 -1
- package/dist/types/components/Transactions/noTransactionStyles.d.ts +1 -0
- package/dist/types/components/Transactions/transactionItemStyles.d.ts +0 -12
- package/dist/types/lib/clients/checkoutApiType.d.ts +1 -8
- package/dist/types/lib/clients/index.d.ts +0 -1
- package/package.json +9 -9
- package/src/components/Transactions/NoTransactions.tsx +6 -0
- package/src/components/Transactions/TransactionItemWithdrawPending.tsx +3 -3
- package/src/components/Transactions/TransactionList.tsx +3 -40
- package/src/components/Transactions/Transactions.tsx +50 -28
- package/src/components/Transactions/noTransactionStyles.ts +1 -0
- package/src/components/Transactions/transactionItemStyles.ts +0 -13
- package/src/lib/clients/checkoutApiType.ts +1 -10
- package/src/lib/clients/index.ts +0 -1
- package/src/widgets/purchase/components/WithCard.tsx +1 -0
- package/src/widgets/sale/components/WithCard.tsx +1 -0
- package/dist/types/components/Transactions/TransactionItem.d.ts +0 -18
- package/dist/types/lib/clients/checkoutApi.d.ts +0 -39
- package/dist/types/lib/clients/checkoutApi.test.d.ts +0 -1
- package/src/components/Transactions/TransactionItem.tsx +0 -137
- package/src/lib/clients/checkoutApi.test.ts +0 -169
- package/src/lib/clients/checkoutApi.ts +0 -102
|
@@ -91,7 +91,7 @@ export function TransactionItemWithdrawPending({
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
return (
|
|
94
|
-
<Box testId={`transaction-item-${transaction.
|
|
94
|
+
<Box testId={`transaction-item-${transaction.details.current_status.index}`} sx={containerStyles}>
|
|
95
95
|
{requiresWithdrawalClaim && (
|
|
96
96
|
<>
|
|
97
97
|
<Box sx={actionsContainerStyles}>
|
|
@@ -107,7 +107,7 @@ export function TransactionItemWithdrawPending({
|
|
|
107
107
|
}}
|
|
108
108
|
/>
|
|
109
109
|
<Body
|
|
110
|
-
testId={`transaction-item-${transaction.
|
|
110
|
+
testId={`transaction-item-${transaction.details.current_status.index}-action-message`}
|
|
111
111
|
size="xSmall"
|
|
112
112
|
sx={{ color: 'base.color.text.body.secondary' }}
|
|
113
113
|
>
|
|
@@ -116,7 +116,7 @@ export function TransactionItemWithdrawPending({
|
|
|
116
116
|
</Box>
|
|
117
117
|
{requiresWithdrawalClaim && withdrawalReadyToClaim && (
|
|
118
118
|
<Button
|
|
119
|
-
testId={`transaction-item-${transaction.
|
|
119
|
+
testId={`transaction-item-${transaction.details.current_status.index}-action-button`}
|
|
120
120
|
variant="primary"
|
|
121
121
|
size="small"
|
|
122
122
|
onClick={handleWithdrawalClaimClick}
|
|
@@ -5,16 +5,12 @@ import { Checkout } from '@imtbl/checkout-sdk';
|
|
|
5
5
|
import {
|
|
6
6
|
useCallback,
|
|
7
7
|
useContext,
|
|
8
|
-
useEffect,
|
|
9
|
-
useState,
|
|
10
8
|
} from 'react';
|
|
11
9
|
import { useTranslation } from 'react-i18next';
|
|
12
10
|
import { formatUnits } from 'ethers';
|
|
13
|
-
import {
|
|
14
|
-
import { Transaction, TransactionStatus } from '../../lib/clients';
|
|
11
|
+
import { Transaction } from '../../lib/clients';
|
|
15
12
|
import { CryptoFiatContext } from '../../context/crypto-fiat-context/CryptoFiatContext';
|
|
16
13
|
import { calculateCryptoToFiat, getTokenImageByAddress, isNativeToken } from '../../lib/utils';
|
|
17
|
-
import { TransactionItem } from './TransactionItem';
|
|
18
14
|
import { KnownNetworkMap } from './transactionsType';
|
|
19
15
|
import { containerStyles, transactionsListStyle } from './TransactionListStyles';
|
|
20
16
|
import { TransactionItemWithdrawPending } from './TransactionItemWithdrawPending';
|
|
@@ -40,23 +36,8 @@ export function TransactionList({
|
|
|
40
36
|
}: TransactionListProps) {
|
|
41
37
|
const { cryptoFiatState } = useContext(CryptoFiatContext);
|
|
42
38
|
const { t } = useTranslation();
|
|
43
|
-
const [link, setLink] = useState('');
|
|
44
39
|
const { environment } = checkout.config;
|
|
45
40
|
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (!checkout) return;
|
|
48
|
-
setLink(AXELAR_SCAN_URL[checkout.config.environment]);
|
|
49
|
-
}, [checkout]);
|
|
50
|
-
|
|
51
|
-
const sortWithdrawalPendingFirst = useCallback((txnA, txnB) => {
|
|
52
|
-
if (
|
|
53
|
-
txnA.details.current_status.status === TransactionStatus.WITHDRAWAL_PENDING
|
|
54
|
-
&& txnB.details.current_status.status !== TransactionStatus.WITHDRAWAL_PENDING) return -1;
|
|
55
|
-
if (txnA.details.current_status.status === txnB.details.current_status.status) return 0;
|
|
56
|
-
|
|
57
|
-
return 1;
|
|
58
|
-
}, []);
|
|
59
|
-
|
|
60
41
|
const getTransactionItemIcon = useCallback((transaction) => {
|
|
61
42
|
if (isNativeToken(transaction.details.from_token_address)) {
|
|
62
43
|
// Map transaction chain slug to native symbol icon asset
|
|
@@ -76,34 +57,16 @@ export function TransactionList({
|
|
|
76
57
|
sx={containerStyles}
|
|
77
58
|
>
|
|
78
59
|
{transactions
|
|
79
|
-
.sort(sortWithdrawalPendingFirst)
|
|
80
60
|
.map((transaction) => {
|
|
81
|
-
const hash = transaction.blockchain_metadata.transaction_hash;
|
|
82
61
|
const tokens = knownTokenMap[transaction.details.from_chain];
|
|
83
62
|
const token = tokens[transaction.details.from_token_address.toLowerCase()];
|
|
84
63
|
const amount = formatUnits(transaction.details.amount, token.decimals);
|
|
85
64
|
const fiat = calculateCryptoToFiat(amount, token.symbol, cryptoFiatState.conversions);
|
|
86
65
|
|
|
87
|
-
if (transaction.details.current_status.status === TransactionStatus.WITHDRAWAL_PENDING) {
|
|
88
|
-
return (
|
|
89
|
-
<TransactionItemWithdrawPending
|
|
90
|
-
key={hash}
|
|
91
|
-
label={token.symbol}
|
|
92
|
-
transaction={transaction}
|
|
93
|
-
fiatAmount={`${t('views.TRANSACTIONS.fiatPricePrefix')}${fiat}`}
|
|
94
|
-
amount={amount}
|
|
95
|
-
icon={getTransactionItemIcon(transaction)}
|
|
96
|
-
defaultTokenImage={defaultTokenImage}
|
|
97
|
-
environment={environment}
|
|
98
|
-
/>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
66
|
return (
|
|
103
|
-
<
|
|
104
|
-
key={
|
|
67
|
+
<TransactionItemWithdrawPending
|
|
68
|
+
key={transaction.details.current_status.index}
|
|
105
69
|
label={token.symbol}
|
|
106
|
-
details={{ text: t('views.TRANSACTIONS.status.inProgress.stepInfo'), link, hash }}
|
|
107
70
|
transaction={transaction}
|
|
108
71
|
fiatAmount={`${t('views.TRANSACTIONS.fiatPricePrefix')}${fiat}`}
|
|
109
72
|
amount={amount}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1
2
|
import {
|
|
2
3
|
useCallback, useContext, useEffect, useMemo, useState,
|
|
3
4
|
} from 'react';
|
|
@@ -8,10 +9,12 @@ import {
|
|
|
8
9
|
TokenFilterTypes,
|
|
9
10
|
TokenInfo,
|
|
10
11
|
WalletProviderRdns,
|
|
12
|
+
ChainSlug,
|
|
13
|
+
Checkout,
|
|
11
14
|
} from '@imtbl/checkout-sdk';
|
|
12
|
-
import { Environment } from '@imtbl/config';
|
|
13
15
|
import { useTranslation } from 'react-i18next';
|
|
14
16
|
import { JsonRpcProvider } from 'ethers';
|
|
17
|
+
import { TokenBridge } from '@imtbl/bridge-sdk';
|
|
15
18
|
import { HeaderNavigation } from '../Header/HeaderNavigation';
|
|
16
19
|
import { SimpleLayout } from '../SimpleLayout/SimpleLayout';
|
|
17
20
|
import { FooterLogo } from '../Footer/FooterLogo';
|
|
@@ -23,7 +26,7 @@ import {
|
|
|
23
26
|
import {
|
|
24
27
|
DEFAULT_TRANSACTIONS_RETRY_POLICY,
|
|
25
28
|
} from '../../lib';
|
|
26
|
-
import {
|
|
29
|
+
import { Transaction, TransactionType } from '../../lib/clients';
|
|
27
30
|
import { retry } from '../../lib/retry';
|
|
28
31
|
import { getChainSlugById } from '../../lib/chains';
|
|
29
32
|
import {
|
|
@@ -59,6 +62,40 @@ type TransactionsProps = {
|
|
|
59
62
|
onBackButtonClick: () => void;
|
|
60
63
|
};
|
|
61
64
|
|
|
65
|
+
const getTransactionsDetails = async (tokenBridge: TokenBridge, checkout: Checkout, recipient: string) => {
|
|
66
|
+
const pendingWithdrawals = await tokenBridge.getPendingWithdrawals({ recipient });
|
|
67
|
+
|
|
68
|
+
const transactions = (await Promise.all(pendingWithdrawals.pending.map(async (withdrawal, index) => {
|
|
69
|
+
const tokenMapping = await tokenBridge.getTokenMapping({
|
|
70
|
+
rootToken: withdrawal.token,
|
|
71
|
+
rootChainId: checkout.config.l1ChainId.toString(),
|
|
72
|
+
childChainId: checkout.config.l2ChainId.toString(),
|
|
73
|
+
});
|
|
74
|
+
if (!tokenMapping.childToken) return null;
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
tx_type: TransactionType.BRIDGE,
|
|
78
|
+
details: {
|
|
79
|
+
from_address: withdrawal.withdrawer,
|
|
80
|
+
from_chain: getChainSlugById(checkout.config.l2ChainId),
|
|
81
|
+
from_token_address: tokenMapping.childToken,
|
|
82
|
+
to_address: withdrawal.recipient,
|
|
83
|
+
to_chain: getChainSlugById(checkout.config.l1ChainId),
|
|
84
|
+
to_token_address: withdrawal.token,
|
|
85
|
+
amount: withdrawal.amount.toString(),
|
|
86
|
+
current_status: {
|
|
87
|
+
status: 'withdrawal_pending',
|
|
88
|
+
index,
|
|
89
|
+
withdrawal_ready_at: new Date(withdrawal.timeoutEnd * 1000).toISOString(),
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
created_at: new Date(withdrawal.timeoutStart * 1000).toISOString(),
|
|
93
|
+
};
|
|
94
|
+
}))).filter((tx) => tx !== null);
|
|
95
|
+
|
|
96
|
+
return { result: transactions };
|
|
97
|
+
};
|
|
98
|
+
|
|
62
99
|
export function Transactions({
|
|
63
100
|
defaultTokenImage,
|
|
64
101
|
onBackButtonClick,
|
|
@@ -70,7 +107,7 @@ export function Transactions({
|
|
|
70
107
|
const { cryptoFiatDispatch } = useContext(CryptoFiatContext);
|
|
71
108
|
const {
|
|
72
109
|
bridgeDispatch,
|
|
73
|
-
bridgeState: { checkout, from },
|
|
110
|
+
bridgeState: { checkout, from, tokenBridge },
|
|
74
111
|
} = useContext(BridgeContext);
|
|
75
112
|
const { page } = useAnalytics();
|
|
76
113
|
const { t } = useTranslation();
|
|
@@ -141,7 +178,7 @@ export function Transactions({
|
|
|
141
178
|
}
|
|
142
179
|
}, [checkout, from]);
|
|
143
180
|
|
|
144
|
-
const getTokensDetails = async (tokensWithChainSlug: {
|
|
181
|
+
const getTokensDetails = useCallback(async (tokensWithChainSlug: {
|
|
145
182
|
[p: string]: string;
|
|
146
183
|
}) => {
|
|
147
184
|
const rootChainName = getChainSlugById(checkout.config.l1ChainId);
|
|
@@ -225,18 +262,7 @@ export function Transactions({
|
|
|
225
262
|
});
|
|
226
263
|
|
|
227
264
|
return { [rootChainName]: rootData, [childChainName]: childData };
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
const getTransactionsDetails = useCallback(
|
|
231
|
-
async (env: Environment, address: string) => {
|
|
232
|
-
const client = new CheckoutApi({ env });
|
|
233
|
-
return client.getTransactions({
|
|
234
|
-
txType: TransactionType.BRIDGE,
|
|
235
|
-
fromAddress: address,
|
|
236
|
-
});
|
|
237
|
-
},
|
|
238
|
-
[],
|
|
239
|
-
);
|
|
265
|
+
}, [checkout, cryptoFiatDispatch, rootChainTokensHashmap, childChainTokensHashmap]);
|
|
240
266
|
|
|
241
267
|
const handleWalletChange = useCallback(
|
|
242
268
|
async (event: WalletChangeEvent) => {
|
|
@@ -282,7 +308,7 @@ export function Transactions({
|
|
|
282
308
|
setShowWalletDrawer(false);
|
|
283
309
|
}
|
|
284
310
|
},
|
|
285
|
-
[checkout],
|
|
311
|
+
[checkout, bridgeDispatch, track],
|
|
286
312
|
);
|
|
287
313
|
|
|
288
314
|
const handleBackButtonClick = () => {
|
|
@@ -313,22 +339,18 @@ export function Transactions({
|
|
|
313
339
|
|
|
314
340
|
const fetchData = useCallback(async () => {
|
|
315
341
|
if (!from?.walletAddress) return undefined;
|
|
342
|
+
if (!tokenBridge) return undefined;
|
|
316
343
|
|
|
317
|
-
const localTxs = await getTransactionsDetails(
|
|
318
|
-
checkout.config.environment,
|
|
319
|
-
from?.walletAddress,
|
|
320
|
-
);
|
|
344
|
+
const localTxs = await getTransactionsDetails(tokenBridge, checkout, from.walletAddress);
|
|
321
345
|
|
|
322
|
-
const tokensWithChainSlug
|
|
323
|
-
|
|
324
|
-
tokensWithChainSlug[txn.details.from_token_address] = txn.details.from_chain;
|
|
325
|
-
});
|
|
346
|
+
const tokensWithChainSlug = localTxs.result.reduce<Record<string, ChainSlug>>((acc, tx) =>
|
|
347
|
+
({ ...acc, [tx.details.from_token_address]: tx.details.from_chain }), {});
|
|
326
348
|
|
|
327
349
|
return {
|
|
328
350
|
tokens: await getTokensDetails(tokensWithChainSlug),
|
|
329
351
|
transactions: localTxs.result,
|
|
330
352
|
};
|
|
331
|
-
}, [from,
|
|
353
|
+
}, [from, tokenBridge, checkout, getTokensDetails]);
|
|
332
354
|
|
|
333
355
|
const { providers } = useInjectedProviders({ checkout });
|
|
334
356
|
const walletOptions = useMemo(() => providers, [providers]);
|
|
@@ -358,14 +380,14 @@ export function Transactions({
|
|
|
358
380
|
|
|
359
381
|
setLoading(false);
|
|
360
382
|
})();
|
|
361
|
-
}, [from, checkout]);
|
|
383
|
+
}, [from, checkout, fetchData]);
|
|
362
384
|
|
|
363
385
|
useEffect(() => {
|
|
364
386
|
page({
|
|
365
387
|
userJourney: UserJourney.BRIDGE,
|
|
366
388
|
screen: 'Transactions',
|
|
367
389
|
});
|
|
368
|
-
}, []);
|
|
390
|
+
}, [page]);
|
|
369
391
|
|
|
370
392
|
return (
|
|
371
393
|
<SimpleLayout
|
|
@@ -4,13 +4,6 @@ export const containerStyles = {
|
|
|
4
4
|
borderRadius: 'base.borderRadius.x4',
|
|
5
5
|
bg: 'base.color.translucent.emphasis.100',
|
|
6
6
|
};
|
|
7
|
-
export const headingStyles = {
|
|
8
|
-
display: 'flex',
|
|
9
|
-
flexDirection: 'row',
|
|
10
|
-
justifyContent: 'space-between',
|
|
11
|
-
paddingLeft: 'base.spacing.x2',
|
|
12
|
-
alignItems: 'center',
|
|
13
|
-
};
|
|
14
7
|
|
|
15
8
|
export const actionsContainerStyles = {
|
|
16
9
|
p: 'base.spacing.x3',
|
|
@@ -25,9 +18,3 @@ export const actionsLayoutStyles = {
|
|
|
25
18
|
alignItems: 'center',
|
|
26
19
|
gap: 'base.spacing.x2',
|
|
27
20
|
};
|
|
28
|
-
|
|
29
|
-
export const actionsBadgeStyles = {
|
|
30
|
-
position: 'absolute',
|
|
31
|
-
right: 'base.spacing.x2',
|
|
32
|
-
top: 'base.spacing.x2',
|
|
33
|
-
};
|
|
@@ -8,14 +8,10 @@ export const TransactionStatus = {
|
|
|
8
8
|
WITHDRAWAL_PENDING: 'withdrawal_pending',
|
|
9
9
|
} as const;
|
|
10
10
|
|
|
11
|
-
export type Transactions = {
|
|
12
|
-
result: Transaction[]
|
|
13
|
-
};
|
|
14
|
-
|
|
15
11
|
export type CurrentStatus = {
|
|
16
12
|
status: string;
|
|
17
13
|
withdrawal_ready_at?: string;
|
|
18
|
-
index
|
|
14
|
+
index: number;
|
|
19
15
|
};
|
|
20
16
|
|
|
21
17
|
export type TransactionDetails = {
|
|
@@ -29,13 +25,8 @@ export type TransactionDetails = {
|
|
|
29
25
|
current_status: CurrentStatus
|
|
30
26
|
};
|
|
31
27
|
|
|
32
|
-
export type BlockchainMetadata = {
|
|
33
|
-
transaction_hash: string
|
|
34
|
-
};
|
|
35
|
-
|
|
36
28
|
export type Transaction = {
|
|
37
29
|
tx_type: TransactionType
|
|
38
30
|
details: TransactionDetails
|
|
39
|
-
blockchain_metadata: BlockchainMetadata
|
|
40
31
|
created_at: string
|
|
41
32
|
};
|
package/src/lib/clients/index.ts
CHANGED
|
@@ -53,6 +53,7 @@ export function WithCard(props: WithCardProps) {
|
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- TODO: fix this
|
|
56
57
|
const nftData: TransakNFTData[] = useMemo(
|
|
57
58
|
() => signResponse.order.products.map((product) => ({
|
|
58
59
|
collectionAddress: product.collectionAddress,
|
|
@@ -40,6 +40,7 @@ export function WithCard(props: WithCardProps) {
|
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- TODO: fix this
|
|
43
44
|
const nftData: TransakNFTData[] = useMemo(
|
|
44
45
|
() => signResponse.order.products.map((product) => ({
|
|
45
46
|
collectionAddress: product.collectionAddress,
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Environment } from '@imtbl/config';
|
|
2
|
-
import { Transaction } from '../../lib/clients/checkoutApiType';
|
|
3
|
-
type TransactionItemProps = {
|
|
4
|
-
label: string;
|
|
5
|
-
details: {
|
|
6
|
-
text: string;
|
|
7
|
-
link: string;
|
|
8
|
-
hash: string;
|
|
9
|
-
};
|
|
10
|
-
transaction: Transaction;
|
|
11
|
-
fiatAmount: string;
|
|
12
|
-
amount: string;
|
|
13
|
-
icon: string;
|
|
14
|
-
defaultTokenImage: string;
|
|
15
|
-
environment: Environment;
|
|
16
|
-
};
|
|
17
|
-
export declare function TransactionItem({ label, details, transaction, fiatAmount, amount, icon, defaultTokenImage, environment, }: TransactionItemProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
18
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Environment } from '@imtbl/config';
|
|
2
|
-
import { ENV_DEVELOPMENT } from '../constants';
|
|
3
|
-
import { TransactionType, Transactions } from './checkoutApiType';
|
|
4
|
-
type GetTransactions = {
|
|
5
|
-
txType: TransactionType;
|
|
6
|
-
fromAddress: string;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Checkout API class provides a client abstraction for the Checkout API.
|
|
10
|
-
*/
|
|
11
|
-
export declare class CheckoutApi {
|
|
12
|
-
readonly url: string;
|
|
13
|
-
readonly ttl: number;
|
|
14
|
-
readonly env: Environment;
|
|
15
|
-
private cacheMap;
|
|
16
|
-
private setCache;
|
|
17
|
-
private getCache;
|
|
18
|
-
/**
|
|
19
|
-
* Checkout API constructor
|
|
20
|
-
* @param env target chain
|
|
21
|
-
* @param ttl cache TTL
|
|
22
|
-
*/
|
|
23
|
-
constructor(params: {
|
|
24
|
-
env: Environment | typeof ENV_DEVELOPMENT;
|
|
25
|
-
ttl?: number;
|
|
26
|
-
});
|
|
27
|
-
/**
|
|
28
|
-
* isHttpError verifies if the error is a HTTP error
|
|
29
|
-
* @param err error to evaluate
|
|
30
|
-
*/
|
|
31
|
-
static isHttpError: (err: any) => boolean;
|
|
32
|
-
/**
|
|
33
|
-
* getTransactions fetches a list of blockchain transactions.
|
|
34
|
-
* @param txType transaction type
|
|
35
|
-
* @param fromAddress transactions executed from address
|
|
36
|
-
*/
|
|
37
|
-
getTransactions(params: GetTransactions): Promise<Transactions>;
|
|
38
|
-
}
|
|
39
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Accordion,
|
|
3
|
-
Box,
|
|
4
|
-
Divider,
|
|
5
|
-
MenuItem,
|
|
6
|
-
Link,
|
|
7
|
-
} from '@biom3/react';
|
|
8
|
-
import { MouseEvent, useMemo } from 'react';
|
|
9
|
-
import { Environment } from '@imtbl/config';
|
|
10
|
-
import { UserJourney, useAnalytics } from '../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
11
|
-
import { Transaction } from '../../lib/clients/checkoutApiType';
|
|
12
|
-
import { TokenImage } from '../TokenImage/TokenImage';
|
|
13
|
-
import { containerStyles } from './transactionItemStyles';
|
|
14
|
-
import { TransactionDetails } from './TransactionDetails';
|
|
15
|
-
|
|
16
|
-
type TransactionItemProps = {
|
|
17
|
-
label: string
|
|
18
|
-
details: {
|
|
19
|
-
text: string,
|
|
20
|
-
link: string,
|
|
21
|
-
hash: string,
|
|
22
|
-
},
|
|
23
|
-
transaction: Transaction,
|
|
24
|
-
fiatAmount: string,
|
|
25
|
-
amount: string,
|
|
26
|
-
icon: string,
|
|
27
|
-
defaultTokenImage: string,
|
|
28
|
-
environment: Environment,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export function TransactionItem({
|
|
32
|
-
label,
|
|
33
|
-
details,
|
|
34
|
-
transaction,
|
|
35
|
-
fiatAmount,
|
|
36
|
-
amount,
|
|
37
|
-
icon,
|
|
38
|
-
defaultTokenImage,
|
|
39
|
-
environment,
|
|
40
|
-
}: TransactionItemProps) {
|
|
41
|
-
const { track } = useAnalytics();
|
|
42
|
-
const txnDetailsLink = useMemo(() => `${details.link}${details.hash}`, [details]);
|
|
43
|
-
|
|
44
|
-
const handleDetailsLinkClick = (
|
|
45
|
-
event: MouseEvent<HTMLAnchorElement>,
|
|
46
|
-
linkDetail: { text: string, link: string, hash: string },
|
|
47
|
-
) => {
|
|
48
|
-
event.stopPropagation(); // prevent expanding accordian
|
|
49
|
-
|
|
50
|
-
track({
|
|
51
|
-
userJourney: UserJourney.BRIDGE,
|
|
52
|
-
screen: 'TransactionItem',
|
|
53
|
-
control: 'Details',
|
|
54
|
-
controlType: 'Link',
|
|
55
|
-
extras: {
|
|
56
|
-
linkDetail,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<Box testId={`transaction-item-${transaction.blockchain_metadata.transaction_hash}`} sx={containerStyles}>
|
|
63
|
-
<Accordion
|
|
64
|
-
chevronSide="right"
|
|
65
|
-
sx={{
|
|
66
|
-
button: {
|
|
67
|
-
p: 'base.spacing.x1',
|
|
68
|
-
},
|
|
69
|
-
article: {
|
|
70
|
-
pr: 'base.spacing.x10',
|
|
71
|
-
},
|
|
72
|
-
}}
|
|
73
|
-
onExpandChange={
|
|
74
|
-
(expanded) => expanded
|
|
75
|
-
&& track({
|
|
76
|
-
userJourney: UserJourney.BRIDGE,
|
|
77
|
-
screen: 'TransactionItem',
|
|
78
|
-
control: 'Accordion',
|
|
79
|
-
controlType: 'Button',
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
>
|
|
83
|
-
<Accordion.TargetLeftSlot sx={{ pr: 'base.spacing.x2' }}>
|
|
84
|
-
<MenuItem size="xSmall">
|
|
85
|
-
<MenuItem.FramedImage
|
|
86
|
-
circularFrame
|
|
87
|
-
use={(
|
|
88
|
-
<TokenImage
|
|
89
|
-
src={icon}
|
|
90
|
-
name={label}
|
|
91
|
-
defaultImage={defaultTokenImage}
|
|
92
|
-
/>
|
|
93
|
-
)}
|
|
94
|
-
/>
|
|
95
|
-
<MenuItem.Label>
|
|
96
|
-
{label}
|
|
97
|
-
</MenuItem.Label>
|
|
98
|
-
<MenuItem.Caption>
|
|
99
|
-
<Link
|
|
100
|
-
size="xSmall"
|
|
101
|
-
rc={(
|
|
102
|
-
<a
|
|
103
|
-
target="_blank"
|
|
104
|
-
href={txnDetailsLink}
|
|
105
|
-
rel="noreferrer"
|
|
106
|
-
onClick={(e) => handleDetailsLinkClick(e, details)}
|
|
107
|
-
/>
|
|
108
|
-
)}
|
|
109
|
-
>
|
|
110
|
-
{details.text}
|
|
111
|
-
</Link>
|
|
112
|
-
</MenuItem.Caption>
|
|
113
|
-
<MenuItem.PriceDisplay
|
|
114
|
-
fiatAmount={fiatAmount}
|
|
115
|
-
price={amount}
|
|
116
|
-
/>
|
|
117
|
-
</MenuItem>
|
|
118
|
-
</Accordion.TargetLeftSlot>
|
|
119
|
-
<Accordion.ExpandedContent sx={{
|
|
120
|
-
pr: '0',
|
|
121
|
-
pl: '0',
|
|
122
|
-
mb: 'base.spacing.x3',
|
|
123
|
-
gap: '0',
|
|
124
|
-
}}
|
|
125
|
-
>
|
|
126
|
-
<Divider
|
|
127
|
-
size="xSmall"
|
|
128
|
-
sx={{
|
|
129
|
-
px: 'base.spacing.x2',
|
|
130
|
-
}}
|
|
131
|
-
/>
|
|
132
|
-
<TransactionDetails transaction={transaction} environment={environment} />
|
|
133
|
-
</Accordion.ExpandedContent>
|
|
134
|
-
</Accordion>
|
|
135
|
-
</Box>
|
|
136
|
-
);
|
|
137
|
-
}
|