@b3dotfun/sdk 0.0.33 → 0.0.34-alpha.0
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/cjs/anyspend/react/components/AnySpend.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +5 -36
- package/dist/cjs/anyspend/react/components/common/InsufficientDepositPayment.d.ts +12 -0
- package/dist/cjs/anyspend/react/components/common/InsufficientDepositPayment.js +25 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +3 -3
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +65 -60
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -4
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +4 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +6 -6
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +54 -10
- package/dist/cjs/anyspend/react/hooks/useAnyspendQuote.js +1 -1
- package/dist/cjs/anyspend/types/api.d.ts +130 -14
- package/dist/cjs/anyspend/utils/chain.js +1 -1
- package/dist/cjs/anyspend/utils/format.js +1 -0
- package/dist/cjs/anyspend/utils/orderPayload.js +7 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -4
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +14 -0
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +17 -1
- package/dist/cjs/global-account/react/components/index.d.ts +8 -9
- package/dist/cjs/global-account/react/components/index.js +25 -28
- package/dist/cjs/global-account/react/index.native.d.ts +2 -1
- package/dist/cjs/global-account/react/index.native.js +5 -3
- package/dist/cjs/global-account/react/stores/index.d.ts +1 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +2 -22
- package/dist/esm/anyspend/react/components/AnySpend.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +0 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +6 -37
- package/dist/esm/anyspend/react/components/common/InsufficientDepositPayment.d.ts +12 -0
- package/dist/esm/anyspend/react/components/common/InsufficientDepositPayment.js +22 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +3 -3
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +48 -43
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -4
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +4 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +6 -6
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +54 -10
- package/dist/esm/anyspend/react/hooks/useAnyspendQuote.js +1 -1
- package/dist/esm/anyspend/types/api.d.ts +130 -14
- package/dist/esm/anyspend/utils/chain.js +1 -1
- package/dist/esm/anyspend/utils/format.js +1 -0
- package/dist/esm/anyspend/utils/orderPayload.js +7 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -4
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +11 -0
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +17 -1
- package/dist/esm/global-account/react/components/index.d.ts +8 -9
- package/dist/esm/global-account/react/components/index.js +8 -10
- package/dist/esm/global-account/react/index.native.d.ts +2 -1
- package/dist/esm/global-account/react/index.native.js +2 -1
- package/dist/esm/global-account/react/stores/index.d.ts +1 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +2 -22
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +0 -1
- package/dist/types/anyspend/react/components/common/InsufficientDepositPayment.d.ts +12 -0
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +3 -3
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -4
- package/dist/types/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +6 -6
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +54 -10
- package/dist/types/anyspend/types/api.d.ts +130 -14
- package/dist/types/global-account/react/components/index.d.ts +8 -9
- package/dist/types/global-account/react/index.native.d.ts +2 -1
- package/dist/types/global-account/react/stores/index.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +2 -22
- package/package.json +2 -4
- package/src/anyspend/react/components/AnySpend.tsx +2 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +1 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +5 -43
- package/src/anyspend/react/components/common/InsufficientDepositPayment.tsx +144 -0
- package/src/anyspend/react/components/common/OrderDetails.tsx +95 -71
- package/src/anyspend/react/components/common/OrderStatus.tsx +2 -2
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +5 -3
- package/src/anyspend/react/hooks/useAnyspendQuote.ts +1 -1
- package/src/anyspend/types/api.ts +131 -11
- package/src/anyspend/utils/chain.ts +1 -1
- package/src/anyspend/utils/format.ts +1 -0
- package/src/anyspend/utils/orderPayload.ts +7 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +0 -4
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +10 -0
- package/src/global-account/react/components/ManageAccount/BalanceContent.tsx +6 -6
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +17 -1
- package/src/global-account/react/components/index.ts +13 -16
- package/src/global-account/react/index.native.ts +2 -1
- package/src/global-account/react/stores/index.ts +1 -2
- package/src/global-account/react/stores/useModalStore.ts +1 -23
- package/dist/cjs/global-account/react/components/Transak/TransakModal.d.ts +0 -1
- package/dist/cjs/global-account/react/components/Transak/TransakModal.js +0 -110
- package/dist/esm/global-account/react/components/Transak/TransakModal.d.ts +0 -1
- package/dist/esm/global-account/react/components/Transak/TransakModal.js +0 -104
- package/dist/types/global-account/react/components/Transak/TransakModal.d.ts +0 -1
- package/src/global-account/react/components/Transak/TransakModal.tsx +0 -131
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { TextShimmer, useAccountWallet, useB3, useModalStore } from "../../../../global-account/react/index.js";
|
|
4
|
-
import debug from "../../../../shared/utils/debug.js";
|
|
5
|
-
import { Transak } from "@transak/transak-sdk";
|
|
6
|
-
import { Loader2 } from "lucide-react";
|
|
7
|
-
import { useEffect, useMemo, useState } from "react";
|
|
8
|
-
import { toast } from "sonner";
|
|
9
|
-
export function TransakModal() {
|
|
10
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
11
|
-
const [_error, setError] = useState(null);
|
|
12
|
-
const account = useAccountWallet();
|
|
13
|
-
const { environment } = useB3();
|
|
14
|
-
console.log(`process.env.NEXT_PUBLIC_TRANSAK_API_KEY`, process.env.NEXT_PUBLIC_TRANSAK_API_KEY); // d1f4e8be-cacb-4cfa-b2cd-c591084b5ef6
|
|
15
|
-
const transakConfig = useMemo(() => {
|
|
16
|
-
return {
|
|
17
|
-
apiKey: process.env.NEXT_PUBLIC_TRANSAK_API_KEY || "", // (Required)
|
|
18
|
-
// Yes, I know it looks weird to use isDevelopment for staging, but this is how this was done on Basement. Leaving till confirming difference
|
|
19
|
-
environment: environment === "development" ? Transak.ENVIRONMENTS.STAGING : Transak.ENVIRONMENTS.PRODUCTION, // (Required)
|
|
20
|
-
containerId: "transakMount", // Id of the element where you want to initialize the iframe
|
|
21
|
-
themeColor: "0c68e9",
|
|
22
|
-
widgetHeight: "650px",
|
|
23
|
-
productsAvailed: "BUY",
|
|
24
|
-
hideMenu: true,
|
|
25
|
-
colorMode: "DARK",
|
|
26
|
-
backgroundColors: "000000", // TODO: figure out why this doesn't work
|
|
27
|
-
exchangeScreenTitle: "Buy ETH on B3",
|
|
28
|
-
isFeeCalculationHidden: true,
|
|
29
|
-
cryptoCurrencyCode: "ETH",
|
|
30
|
-
network: "b3",
|
|
31
|
-
};
|
|
32
|
-
}, [environment]);
|
|
33
|
-
const { ready } = useB3();
|
|
34
|
-
const modalOptions = useModalStore(state => state.contentType);
|
|
35
|
-
const isOnRamp = modalOptions?.type === "transak";
|
|
36
|
-
const destinationWalletAddress = isOnRamp ? modalOptions?.destinationWalletAddress : undefined;
|
|
37
|
-
const defaultCryptoAmount = isOnRamp ? modalOptions?.defaultCryptoAmount : undefined;
|
|
38
|
-
const onSuccess = isOnRamp ? modalOptions?.onSuccess : undefined;
|
|
39
|
-
const fiatAmount = isOnRamp ? modalOptions?.fiatAmount : undefined;
|
|
40
|
-
const countryCode = isOnRamp ? modalOptions?.countryCode : undefined;
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (!ready || !isOnRamp)
|
|
43
|
-
return;
|
|
44
|
-
const config = {
|
|
45
|
-
...transakConfig,
|
|
46
|
-
walletAddress: destinationWalletAddress || account?.address, // In the future, this should be set to the new global B3 SCW address
|
|
47
|
-
defaultCryptoAmount,
|
|
48
|
-
disableWalletAddressForm: !!destinationWalletAddress || !!account?.address, // Only disable the form if we have an address
|
|
49
|
-
fiatAmount: fiatAmount,
|
|
50
|
-
countryCode: countryCode,
|
|
51
|
-
};
|
|
52
|
-
const transak = new Transak(config);
|
|
53
|
-
try {
|
|
54
|
-
transak.init();
|
|
55
|
-
// Add event listeners
|
|
56
|
-
Transak.on("*", data => {
|
|
57
|
-
debug("@@transak", data);
|
|
58
|
-
});
|
|
59
|
-
Transak.on(Transak.EVENTS.TRANSAK_WIDGET_CLOSE, () => {
|
|
60
|
-
setIsLoading(false);
|
|
61
|
-
debug("@@transak", "Transak SDK closed!");
|
|
62
|
-
});
|
|
63
|
-
Transak.on(Transak.EVENTS.TRANSAK_WIDGET_INITIALISED, () => {
|
|
64
|
-
debug("@@transak", "Transak SDK initialized!");
|
|
65
|
-
setIsLoading(false);
|
|
66
|
-
});
|
|
67
|
-
Transak.on(Transak.EVENTS.TRANSAK_ORDER_FAILED, orderData => {
|
|
68
|
-
debug("@@transak", orderData);
|
|
69
|
-
toast.error("Oh no! Something went wrong. Please try again.");
|
|
70
|
-
});
|
|
71
|
-
Transak.on(Transak.EVENTS.TRANSAK_ORDER_SUCCESSFUL, orderData => {
|
|
72
|
-
debug("@@transak", orderData);
|
|
73
|
-
toast.success("Successfully purchased ETH with credit card!");
|
|
74
|
-
onSuccess?.();
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
setError(err instanceof Error ? err : new Error("Failed to initialize Transak"));
|
|
79
|
-
toast.error("Oh no! Something went wrong. Please try again.");
|
|
80
|
-
setIsLoading(false);
|
|
81
|
-
}
|
|
82
|
-
// Cleanup code
|
|
83
|
-
return () => {
|
|
84
|
-
transak.close();
|
|
85
|
-
};
|
|
86
|
-
}, [
|
|
87
|
-
ready,
|
|
88
|
-
account?.address,
|
|
89
|
-
destinationWalletAddress,
|
|
90
|
-
defaultCryptoAmount,
|
|
91
|
-
isOnRamp,
|
|
92
|
-
onSuccess,
|
|
93
|
-
fiatAmount,
|
|
94
|
-
transakConfig,
|
|
95
|
-
countryCode,
|
|
96
|
-
]);
|
|
97
|
-
return (_jsxs(_Fragment, { children: [isLoading && (_jsxs("div", { className: "flex h-full min-h-[650px] flex-col items-center justify-center gap-4", children: [_jsx(Loader2, { className: "h-24 w-24 animate-spin opacity-10" }), _jsx(TextShimmer, { children: "Powering up our credit card processor..." })] })), _jsx("div", { id: "transakMount", style: {
|
|
98
|
-
display: isLoading ? "none" : "block",
|
|
99
|
-
width: "100%",
|
|
100
|
-
height: "650px",
|
|
101
|
-
borderRadius: "25px",
|
|
102
|
-
overflow: "hidden",
|
|
103
|
-
} })] }));
|
|
104
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function TransakModal(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { TextShimmer, useAccountWallet, useB3, useModalStore } from "@b3dotfun/sdk/global-account/react";
|
|
4
|
-
import debug from "@b3dotfun/sdk/shared/utils/debug";
|
|
5
|
-
import { Transak, TransakConfig } from "@transak/transak-sdk";
|
|
6
|
-
import { Loader2 } from "lucide-react";
|
|
7
|
-
import { useEffect, useMemo, useState } from "react";
|
|
8
|
-
import { toast } from "sonner";
|
|
9
|
-
|
|
10
|
-
export function TransakModal() {
|
|
11
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
12
|
-
const [_error, setError] = useState<Error | null>(null);
|
|
13
|
-
|
|
14
|
-
const account = useAccountWallet();
|
|
15
|
-
const { environment } = useB3();
|
|
16
|
-
|
|
17
|
-
console.log(`process.env.NEXT_PUBLIC_TRANSAK_API_KEY`, process.env.NEXT_PUBLIC_TRANSAK_API_KEY); // d1f4e8be-cacb-4cfa-b2cd-c591084b5ef6
|
|
18
|
-
|
|
19
|
-
const transakConfig = useMemo((): TransakConfig => {
|
|
20
|
-
return {
|
|
21
|
-
apiKey: process.env.NEXT_PUBLIC_TRANSAK_API_KEY || "", // (Required)
|
|
22
|
-
// Yes, I know it looks weird to use isDevelopment for staging, but this is how this was done on Basement. Leaving till confirming difference
|
|
23
|
-
environment: environment === "development" ? Transak.ENVIRONMENTS.STAGING : Transak.ENVIRONMENTS.PRODUCTION, // (Required)
|
|
24
|
-
containerId: "transakMount", // Id of the element where you want to initialize the iframe
|
|
25
|
-
themeColor: "0c68e9",
|
|
26
|
-
widgetHeight: "650px",
|
|
27
|
-
productsAvailed: "BUY",
|
|
28
|
-
hideMenu: true,
|
|
29
|
-
colorMode: "DARK",
|
|
30
|
-
backgroundColors: "000000", // TODO: figure out why this doesn't work
|
|
31
|
-
exchangeScreenTitle: "Buy ETH on B3",
|
|
32
|
-
isFeeCalculationHidden: true,
|
|
33
|
-
cryptoCurrencyCode: "ETH",
|
|
34
|
-
network: "b3",
|
|
35
|
-
};
|
|
36
|
-
}, [environment]);
|
|
37
|
-
|
|
38
|
-
const { ready } = useB3();
|
|
39
|
-
const modalOptions = useModalStore(state => state.contentType);
|
|
40
|
-
const isOnRamp = modalOptions?.type === "transak";
|
|
41
|
-
const destinationWalletAddress = isOnRamp ? modalOptions?.destinationWalletAddress : undefined;
|
|
42
|
-
const defaultCryptoAmount = isOnRamp ? modalOptions?.defaultCryptoAmount : undefined;
|
|
43
|
-
const onSuccess = isOnRamp ? modalOptions?.onSuccess : undefined;
|
|
44
|
-
const fiatAmount = isOnRamp ? modalOptions?.fiatAmount : undefined;
|
|
45
|
-
const countryCode = isOnRamp ? modalOptions?.countryCode : undefined;
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (!ready || !isOnRamp) return;
|
|
49
|
-
|
|
50
|
-
const config = {
|
|
51
|
-
...transakConfig,
|
|
52
|
-
walletAddress: destinationWalletAddress || account?.address, // In the future, this should be set to the new global B3 SCW address
|
|
53
|
-
defaultCryptoAmount,
|
|
54
|
-
disableWalletAddressForm: !!destinationWalletAddress || !!account?.address, // Only disable the form if we have an address
|
|
55
|
-
fiatAmount: fiatAmount,
|
|
56
|
-
countryCode: countryCode,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const transak = new Transak(config);
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
transak.init();
|
|
63
|
-
|
|
64
|
-
// Add event listeners
|
|
65
|
-
Transak.on("*", data => {
|
|
66
|
-
debug("@@transak", data);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
Transak.on(Transak.EVENTS.TRANSAK_WIDGET_CLOSE, () => {
|
|
70
|
-
setIsLoading(false);
|
|
71
|
-
debug("@@transak", "Transak SDK closed!");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
Transak.on(Transak.EVENTS.TRANSAK_WIDGET_INITIALISED, () => {
|
|
75
|
-
debug("@@transak", "Transak SDK initialized!");
|
|
76
|
-
setIsLoading(false);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
Transak.on(Transak.EVENTS.TRANSAK_ORDER_FAILED, orderData => {
|
|
80
|
-
debug("@@transak", orderData);
|
|
81
|
-
toast.error("Oh no! Something went wrong. Please try again.");
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
Transak.on(Transak.EVENTS.TRANSAK_ORDER_SUCCESSFUL, orderData => {
|
|
85
|
-
debug("@@transak", orderData);
|
|
86
|
-
toast.success("Successfully purchased ETH with credit card!");
|
|
87
|
-
onSuccess?.();
|
|
88
|
-
});
|
|
89
|
-
} catch (err) {
|
|
90
|
-
setError(err instanceof Error ? err : new Error("Failed to initialize Transak"));
|
|
91
|
-
toast.error("Oh no! Something went wrong. Please try again.");
|
|
92
|
-
setIsLoading(false);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Cleanup code
|
|
96
|
-
return () => {
|
|
97
|
-
transak.close();
|
|
98
|
-
};
|
|
99
|
-
}, [
|
|
100
|
-
ready,
|
|
101
|
-
account?.address,
|
|
102
|
-
destinationWalletAddress,
|
|
103
|
-
defaultCryptoAmount,
|
|
104
|
-
isOnRamp,
|
|
105
|
-
onSuccess,
|
|
106
|
-
fiatAmount,
|
|
107
|
-
transakConfig,
|
|
108
|
-
countryCode,
|
|
109
|
-
]);
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<>
|
|
113
|
-
{isLoading && (
|
|
114
|
-
<div className="flex h-full min-h-[650px] flex-col items-center justify-center gap-4">
|
|
115
|
-
<Loader2 className="h-24 w-24 animate-spin opacity-10" />
|
|
116
|
-
<TextShimmer>Powering up our credit card processor...</TextShimmer>
|
|
117
|
-
</div>
|
|
118
|
-
)}
|
|
119
|
-
<div
|
|
120
|
-
id="transakMount"
|
|
121
|
-
style={{
|
|
122
|
-
display: isLoading ? "none" : "block",
|
|
123
|
-
width: "100%",
|
|
124
|
-
height: "650px",
|
|
125
|
-
borderRadius: "25px",
|
|
126
|
-
overflow: "hidden",
|
|
127
|
-
}}
|
|
128
|
-
/>
|
|
129
|
-
</>
|
|
130
|
-
);
|
|
131
|
-
}
|