@coin-voyage/paykit 2.4.1-beta.0 → 2.4.2
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/dist/components/Pages/PayToAddress/copyable-info.d.ts +2 -2
- package/dist/components/Pages/PayToAddress/copyable-info.js +1 -1
- package/dist/components/Pages/PayToAddress/index.js +3 -3
- package/dist/hooks/useDepositAddressQuery.d.ts +2 -2
- package/dist/hooks/useDepositAddressQuery.js +3 -1
- package/dist/hooks/usePayWithToken.js +8 -4
- package/dist/hooks/usePaymentLifecycle.js +1 -1
- package/dist/types/{payment-details.d.ts → deposit-details.d.ts} +3 -2
- package/dist/types/state.d.ts +1 -1
- package/package.json +2 -2
- /package/dist/types/{payment-details.js → deposit-details.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DepositDetails } from "../../../types/deposit-details";
|
|
2
2
|
interface CopyableInfoProps {
|
|
3
|
-
details?:
|
|
3
|
+
details?: DepositDetails;
|
|
4
4
|
remainingS: number;
|
|
5
5
|
totalS: number;
|
|
6
6
|
}
|
|
@@ -7,5 +7,5 @@ import { CopyableInfoWrapper, CountdownWrap } from "./styles";
|
|
|
7
7
|
export function CopyableInfo({ details, remainingS, totalS }) {
|
|
8
8
|
const isExpired = details?.expirationS != null && remainingS === 0;
|
|
9
9
|
const locales = useLocales();
|
|
10
|
-
return (_jsxs(CopyableInfoWrapper, { children: [_jsx(CopyRowOrThrobber, { title: locales.sendExactly, value: details?.amount
|
|
10
|
+
return (_jsxs(CopyableInfoWrapper, { children: [_jsx(CopyRowOrThrobber, { title: locales.sendExactly, value: details?.amount.toString(), valueText: details?.amount_display, smallText: details?.ticker, disabled: isExpired }), _jsx(CopyRowOrThrobber, { title: locales.depositAddress, value: details?.depositAddress, valueText: details?.depositAddress && truncateAddress(details.depositAddress), disabled: isExpired }), _jsx(CountdownWrap, { children: _jsx(CountdownTimer, { remainingS: remainingS, totalS: totalS }) })] }));
|
|
11
11
|
}
|
|
@@ -22,16 +22,16 @@ export default function PayToAddress() {
|
|
|
22
22
|
function PayToAddressView() {
|
|
23
23
|
const { paymentState, triggerResize } = usePayContext();
|
|
24
24
|
const { payToAddressChainId: payToAddressChain, payToAddressCurrency } = paymentState;
|
|
25
|
-
const { data:
|
|
25
|
+
const { data: depositDetails, isLoading, isError, } = useDepositAddressQuery({
|
|
26
26
|
enabled: payToAddressCurrency != undefined,
|
|
27
27
|
});
|
|
28
28
|
if (isError) {
|
|
29
29
|
return payToAddressChain ? _jsx(DepositFailed, {}) : null;
|
|
30
30
|
}
|
|
31
|
-
if (isLoading || !
|
|
31
|
+
if (isLoading || !depositDetails) {
|
|
32
32
|
return _jsx(DepositAddressLoading, {});
|
|
33
33
|
}
|
|
34
|
-
return (_jsx(DepositAddressInfo, { details:
|
|
34
|
+
return (_jsx(DepositAddressInfo, { details: depositDetails, triggerResize: triggerResize, isDeposit: paymentState.payOrder?.mode === PayOrderMode.DEPOSIT }));
|
|
35
35
|
}
|
|
36
36
|
function DepositAddressLoading() {
|
|
37
37
|
const locales = useLocales();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DepositDetails } from "../types/deposit-details";
|
|
2
2
|
type Params = {
|
|
3
3
|
enabled?: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare function useDepositAddressQuery({ enabled }: Params): import("@tanstack/react-query").UseQueryResult<
|
|
5
|
+
export declare function useDepositAddressQuery({ enabled }: Params): import("@tanstack/react-query").UseQueryResult<DepositDetails, Error>;
|
|
6
6
|
export {};
|
|
@@ -28,8 +28,10 @@ export function useDepositAddressQuery({ enabled }) {
|
|
|
28
28
|
throw new Error("Deposit address is unavailable for this pay order");
|
|
29
29
|
return {
|
|
30
30
|
...currency,
|
|
31
|
+
address: tokenAddress,
|
|
31
32
|
depositAddress,
|
|
32
|
-
amount: response.data.src.total.ui_amount
|
|
33
|
+
amount: response.data.src.total.ui_amount,
|
|
34
|
+
amount_display: response.data.src.total.ui_amount_display,
|
|
33
35
|
ticker: response.data.src.ticker,
|
|
34
36
|
expirationS: Math.floor(new Date(response.data.expires_at).getTime() / 1000),
|
|
35
37
|
chainId,
|
|
@@ -10,8 +10,9 @@ export function usePayFromWallet({ senderAddr, payOrder, setPayOrder, chainType,
|
|
|
10
10
|
assert(payOrder != undefined, "PayOrder is required");
|
|
11
11
|
assert(senderAddr != undefined, "Sender address is required");
|
|
12
12
|
assert(actions != undefined, "Transaction actions must be defined");
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const quoteId = currency.quote_id;
|
|
14
|
+
const params = quoteId
|
|
15
|
+
? { payorder_id: payOrder.id, quote_id: quoteId }
|
|
15
16
|
: {
|
|
16
17
|
payorder_id: payOrder.id,
|
|
17
18
|
source_currency: {
|
|
@@ -42,10 +43,13 @@ export function usePayFromWallet({ senderAddr, payOrder, setPayOrder, chainType,
|
|
|
42
43
|
? { address: paymentData.src.address, decimals: paymentData.src.decimals }
|
|
43
44
|
: undefined,
|
|
44
45
|
});
|
|
45
|
-
|
|
46
|
+
const nextPaymentData = {
|
|
47
|
+
...paymentData,
|
|
48
|
+
source_tx_hash: txHash,
|
|
49
|
+
};
|
|
46
50
|
setPayOrder({
|
|
47
51
|
...payOrder,
|
|
48
|
-
payment:
|
|
52
|
+
payment: nextPaymentData,
|
|
49
53
|
status: paymentDetails.status,
|
|
50
54
|
});
|
|
51
55
|
log(`[PAY-WITH-TOKEN] Transaction hash: ${txHash}`);
|
|
@@ -57,7 +57,7 @@ export function usePaymentLifecycle(order, handlers) {
|
|
|
57
57
|
status: order.status,
|
|
58
58
|
metadata: order.metadata,
|
|
59
59
|
payment_data: order.payment,
|
|
60
|
-
refund_address: order.payment.refund_address,
|
|
60
|
+
refund_address: order.payment.refund_address ?? "",
|
|
61
61
|
refund_tx_hash: order.payment.refund_tx_hash ?? "",
|
|
62
62
|
});
|
|
63
63
|
return;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Token } from "@coin-voyage/shared/currency";
|
|
2
|
-
export interface
|
|
2
|
+
export interface DepositDetails extends Token {
|
|
3
3
|
depositAddress: string;
|
|
4
4
|
expirationS?: number;
|
|
5
|
-
amount
|
|
5
|
+
amount: number;
|
|
6
|
+
amount_display: string;
|
|
6
7
|
}
|
package/dist/types/state.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coin-voyage/paykit",
|
|
3
3
|
"description": "Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "Lars <lars@coinvoyage.io>",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"styled-components": "^5.3.11",
|
|
65
65
|
"uuid": "13.0.0",
|
|
66
66
|
"@coin-voyage/crypto": "2.4.0",
|
|
67
|
-
"@coin-voyage/shared": "2.4.
|
|
67
|
+
"@coin-voyage/shared": "2.4.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/qrcode": "1.5.5",
|
|
File without changes
|