@b3dotfun/sdk 0.0.70-alpha.1 → 0.0.70-alpha.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/cjs/anyspend/react/components/AnySpend.d.ts +0 -6
- package/dist/cjs/anyspend/react/components/AnySpend.js +1 -13
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +1 -3
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +57 -0
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +82 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +1 -3
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +1 -3
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendTournament.d.ts +0 -2
- package/dist/cjs/anyspend/react/components/AnySpendTournament.js +1 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.d.ts +1 -2
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/index.js +3 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +5 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +5 -2
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +5 -0
- package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +35 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +2 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +4 -3
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +1 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.js +1 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +23 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +0 -6
- package/dist/esm/anyspend/react/components/AnySpend.js +1 -13
- package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +1 -3
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +57 -0
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +79 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +1 -3
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +1 -3
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendTournament.d.ts +0 -2
- package/dist/esm/anyspend/react/components/AnySpendTournament.js +1 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.d.ts +1 -2
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/esm/anyspend/react/components/index.d.ts +1 -0
- package/dist/esm/anyspend/react/components/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +5 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +5 -2
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +5 -0
- package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +32 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +4 -3
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +1 -0
- package/dist/esm/global-account/react/components/B3Provider/types.js +1 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +23 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +0 -6
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +1 -3
- package/dist/types/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +57 -0
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpendDepositUpside.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendStakeUpside.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnySpendTournament.d.ts +0 -2
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +1 -2
- package/dist/types/anyspend/react/components/AnyspendSignatureMint.d.ts +1 -2
- package/dist/types/anyspend/react/components/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useValidatedClientReferenceId.d.ts +5 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -2
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +23 -1
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +0 -23
- package/src/anyspend/react/components/AnySpendBondKit.tsx +1 -3
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -3
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +178 -0
- package/src/anyspend/react/components/AnySpendCustom.tsx +0 -5
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +0 -4
- package/src/anyspend/react/components/AnySpendDepositUpside.tsx +0 -3
- package/src/anyspend/react/components/AnySpendNFT.tsx +0 -3
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -3
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +0 -3
- package/src/anyspend/react/components/AnySpendStakeUpside.tsx +0 -3
- package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +0 -3
- package/src/anyspend/react/components/AnySpendTournament.tsx +0 -3
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +0 -3
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +0 -3
- package/src/anyspend/react/components/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +5 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +6 -13
- package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +40 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +3 -0
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +6 -0
- package/src/global-account/react/components/B3Provider/types.ts +2 -0
- package/src/global-account/react/stores/useModalStore.ts +25 -1
|
@@ -9,11 +9,14 @@ const react_query_1 = require("@tanstack/react-query");
|
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const viem_1 = require("viem");
|
|
11
11
|
const chains_1 = require("viem/chains");
|
|
12
|
+
const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId");
|
|
12
13
|
/**
|
|
13
14
|
* Hook for creating onramp orders in the Anyspend protocol
|
|
14
15
|
* Specifically handles orders that involve fiat-to-crypto onramp functionality
|
|
15
16
|
*/
|
|
16
17
|
function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
18
|
+
// Get validated client reference ID from B3 context
|
|
19
|
+
const validatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
|
|
17
20
|
// Get fingerprint data
|
|
18
21
|
const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
|
|
19
22
|
const visitorData = fpData && {
|
|
@@ -22,7 +25,7 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
22
25
|
};
|
|
23
26
|
const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
|
|
24
27
|
mutationFn: async (params) => {
|
|
25
|
-
const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, partnerId,
|
|
28
|
+
const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, partnerId, } = params;
|
|
26
29
|
try {
|
|
27
30
|
// Validate required onramp fields
|
|
28
31
|
if (!onramp.vendor || !onramp.country) {
|
|
@@ -65,7 +68,7 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
65
68
|
}),
|
|
66
69
|
creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
|
|
67
70
|
partnerId,
|
|
68
|
-
clientReferenceId,
|
|
71
|
+
clientReferenceId: validatedClientReferenceId,
|
|
69
72
|
visitorData,
|
|
70
73
|
});
|
|
71
74
|
}
|
|
@@ -6,12 +6,15 @@ const utils_1 = require("../../../anyspend/utils");
|
|
|
6
6
|
const fingerprintjs_pro_react_1 = require("@fingerprintjs/fingerprintjs-pro-react");
|
|
7
7
|
const react_query_1 = require("@tanstack/react-query");
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
+
const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId");
|
|
9
10
|
/**
|
|
10
11
|
* Hook for creating orders in the Anyspend protocol
|
|
11
12
|
* Handles regular order creation for swaps, NFT minting, tournament participation, etc.
|
|
12
13
|
* For onramp orders, use useAnyspendCreateOnrampOrder instead.
|
|
13
14
|
*/
|
|
14
15
|
function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
16
|
+
// Get validated client reference ID from B3 context
|
|
17
|
+
const validatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
|
|
15
18
|
// Get fingerprint data
|
|
16
19
|
const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
|
|
17
20
|
const visitorData = fpData && {
|
|
@@ -20,7 +23,7 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
20
23
|
};
|
|
21
24
|
const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
|
|
22
25
|
mutationFn: async (params) => {
|
|
23
|
-
const { recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress
|
|
26
|
+
const { recipientAddress, orderType, srcChain, dstChain, srcToken, dstToken, srcAmount, creatorAddress } = params;
|
|
24
27
|
try {
|
|
25
28
|
return await anyspend_1.anyspendService.createOrder({
|
|
26
29
|
recipientAddress: (0, utils_1.normalizeAddress)(recipientAddress),
|
|
@@ -53,7 +56,7 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
|
53
56
|
},
|
|
54
57
|
}),
|
|
55
58
|
creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
|
|
56
|
-
clientReferenceId,
|
|
59
|
+
clientReferenceId: validatedClientReferenceId,
|
|
57
60
|
visitorData,
|
|
58
61
|
});
|
|
59
62
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useValidatedClientReferenceId = useValidatedClientReferenceId;
|
|
4
|
+
const validation_1 = require("../../../anyspend/utils/validation");
|
|
5
|
+
const react_1 = require("../../../global-account/react");
|
|
6
|
+
const react_2 = require("react");
|
|
7
|
+
/**
|
|
8
|
+
* Hook that provides a validated client reference ID
|
|
9
|
+
* Gets the createClientReferenceId function from B3 context and validates the result
|
|
10
|
+
*/
|
|
11
|
+
function useValidatedClientReferenceId() {
|
|
12
|
+
const { createClientReferenceId } = (0, react_1.useB3)();
|
|
13
|
+
const validatedClientReferenceId = (0, react_2.useMemo)(() => {
|
|
14
|
+
// If no function provided, return undefined
|
|
15
|
+
if (!createClientReferenceId) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
// Call the function to generate the ID
|
|
20
|
+
const generatedId = createClientReferenceId();
|
|
21
|
+
// Validate the generated ID
|
|
22
|
+
const validation = validation_1.Validators.clientReferenceId(generatedId);
|
|
23
|
+
if (!validation.isValid) {
|
|
24
|
+
console.error(`[AnySpend] Invalid clientReferenceId generated: ${validation.error || "Validation failed"}. Will be set to undefined.`);
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return validation.cleaned;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error("[AnySpend] Error generating clientReferenceId:", error);
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
}, [createClientReferenceId]);
|
|
34
|
+
return validatedClientReferenceId;
|
|
35
|
+
}
|
|
@@ -118,6 +118,8 @@ function B3DynamicModal() {
|
|
|
118
118
|
return (0, jsx_runtime_1.jsx)(LinkAccount_1.LinkAccount, { ...contentType });
|
|
119
119
|
case "anySpendDepositHype":
|
|
120
120
|
return (0, jsx_runtime_1.jsx)(AnyspendDepositHype_1.AnySpendDepositHype, { ...contentType, mode: "modal" });
|
|
121
|
+
case "anySpendCollectorClubPurchase":
|
|
122
|
+
return (0, jsx_runtime_1.jsx)(react_1.AnySpendCollectorClubPurchase, { ...contentType, mode: "modal" });
|
|
121
123
|
case "avatarEditor":
|
|
122
124
|
return (0, jsx_runtime_1.jsx)(AvatarEditor_1.AvatarEditor, { onSetAvatar: contentType.onSuccess });
|
|
123
125
|
case "profileEditor":
|
|
@@ -7,7 +7,7 @@ import { B3ContextType } from "./types";
|
|
|
7
7
|
/**
|
|
8
8
|
* Main B3Provider component
|
|
9
9
|
*/
|
|
10
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors, }: {
|
|
10
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, }: {
|
|
11
11
|
theme: "light" | "dark";
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
accountOverride?: Account;
|
|
@@ -24,11 +24,12 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
24
24
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
25
25
|
connectors?: CreateConnectorFn[];
|
|
26
26
|
overrideDefaultConnectors?: boolean;
|
|
27
|
+
createClientReferenceId?: () => string;
|
|
27
28
|
}): import("react/jsx-runtime").JSX.Element;
|
|
28
29
|
/**
|
|
29
30
|
* Inner provider component that provides the actual B3Context
|
|
30
31
|
*/
|
|
31
|
-
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, }: {
|
|
32
|
+
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, createClientReferenceId, }: {
|
|
32
33
|
children: React.ReactNode;
|
|
33
34
|
accountOverride?: Account;
|
|
34
35
|
environment: B3ContextType["environment"];
|
|
@@ -37,4 +38,5 @@ export declare function InnerProvider({ children, accountOverride, environment,
|
|
|
37
38
|
theme: "light" | "dark";
|
|
38
39
|
clientType?: ClientType;
|
|
39
40
|
partnerId: string;
|
|
41
|
+
createClientReferenceId?: () => string;
|
|
40
42
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -32,7 +32,7 @@ const queryClient = new react_query_1.QueryClient();
|
|
|
32
32
|
/**
|
|
33
33
|
* Main B3Provider component
|
|
34
34
|
*/
|
|
35
|
-
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors = false, }) {
|
|
35
|
+
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, }) {
|
|
36
36
|
// Initialize Google Analytics on mount
|
|
37
37
|
(0, react_2.useEffect)(() => {
|
|
38
38
|
(0, analytics_1.loadGA4Script)();
|
|
@@ -42,12 +42,12 @@ function B3Provider({ theme = "light", children, accountOverride, environment, a
|
|
|
42
42
|
(0, client_manager_1.setClientType)(clientType);
|
|
43
43
|
}, [clientType]);
|
|
44
44
|
const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls, connectors, overrideDefaultConnectors });
|
|
45
|
-
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, children: (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" }), (0, jsx_runtime_1.jsx)(sonner_1.Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }) }));
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, createClientReferenceId: createClientReferenceId, children: (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" }), (0, jsx_runtime_1.jsx)(sonner_1.Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }) }));
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Inner provider component that provides the actual B3Context
|
|
49
49
|
*/
|
|
50
|
-
function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", partnerId, }) {
|
|
50
|
+
function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", partnerId, createClientReferenceId, }) {
|
|
51
51
|
const activeAccount = (0, react_3.useActiveAccount)();
|
|
52
52
|
const [manuallySelectedWallet, setManuallySelectedWallet] = (0, react_2.useState)(undefined);
|
|
53
53
|
const wallets = (0, react_3.useConnectedWallets)();
|
|
@@ -101,6 +101,7 @@ function InnerProvider({ children, accountOverride, environment, defaultPermissi
|
|
|
101
101
|
theme,
|
|
102
102
|
clientType,
|
|
103
103
|
partnerId: partnerId,
|
|
104
|
+
createClientReferenceId,
|
|
104
105
|
}, children: (0, jsx_runtime_1.jsx)(InnerProvider2, { children: children }) }));
|
|
105
106
|
}
|
|
106
107
|
const InnerProvider2 = ({ children }) => {
|
|
@@ -13,8 +13,8 @@ export declare function useAuthentication(partnerId: string): {
|
|
|
13
13
|
onConnect: (_walleAutoConnectedWith: Wallet, allConnectedWallets: Wallet[]) => Promise<void>;
|
|
14
14
|
user: {
|
|
15
15
|
email?: string | undefined;
|
|
16
|
-
username?: string | undefined;
|
|
17
16
|
telNumber?: string | undefined;
|
|
17
|
+
username?: string | undefined;
|
|
18
18
|
ens?: string | undefined;
|
|
19
19
|
avatar?: string | undefined;
|
|
20
20
|
preferences?: {} | undefined;
|
|
@@ -8,8 +8,8 @@ import { Users } from "@b3dotfun/b3-api";
|
|
|
8
8
|
export declare function useUserQuery(): {
|
|
9
9
|
user: {
|
|
10
10
|
email?: string | undefined;
|
|
11
|
-
username?: string | undefined;
|
|
12
11
|
telNumber?: string | undefined;
|
|
12
|
+
username?: string | undefined;
|
|
13
13
|
ens?: string | undefined;
|
|
14
14
|
avatar?: string | undefined;
|
|
15
15
|
preferences?: {} | undefined;
|
|
@@ -381,10 +381,32 @@ export interface ProfileEditorModalProps extends BaseModalProps {
|
|
|
381
381
|
/** Callback function called when profile is successfully updated */
|
|
382
382
|
onSuccess?: () => void;
|
|
383
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Props for the AnySpend Collector Club Purchase modal
|
|
386
|
+
* Handles Collector Club pack purchases
|
|
387
|
+
*/
|
|
388
|
+
export interface AnySpendCollectorClubPurchaseProps extends BaseModalProps {
|
|
389
|
+
/** Modal type identifier */
|
|
390
|
+
type: "anySpendCollectorClubPurchase";
|
|
391
|
+
/** The pack ID to purchase */
|
|
392
|
+
packId: number;
|
|
393
|
+
/** The number of packs to purchase */
|
|
394
|
+
packAmount: number;
|
|
395
|
+
/** Price per pack in wei (e.g., "10000" for 0.01 USDC with 6 decimals) */
|
|
396
|
+
pricePerPack: string;
|
|
397
|
+
/** Recipient address to receive the packs */
|
|
398
|
+
recipientAddress: string;
|
|
399
|
+
/** Payment type - crypto or fiat */
|
|
400
|
+
paymentType?: "crypto" | "fiat";
|
|
401
|
+
/** Callback function called when the purchase is successful */
|
|
402
|
+
onSuccess?: (txHash?: string) => void;
|
|
403
|
+
/** Client-provided reference ID for tracking orders */
|
|
404
|
+
clientReferenceId?: string;
|
|
405
|
+
}
|
|
384
406
|
/**
|
|
385
407
|
* Union type of all possible modal content types
|
|
386
408
|
*/
|
|
387
|
-
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendDepositUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | ProfileEditorModalProps;
|
|
409
|
+
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendDepositUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | ProfileEditorModalProps | AnySpendCollectorClubPurchaseProps;
|
|
388
410
|
/**
|
|
389
411
|
* State interface for the modal store
|
|
390
412
|
*/
|
|
@@ -34,10 +34,4 @@ export declare function AnySpend(props: {
|
|
|
34
34
|
}) => void;
|
|
35
35
|
onSuccess?: (txHash?: string) => void;
|
|
36
36
|
customUsdInputValues?: string[];
|
|
37
|
-
/**
|
|
38
|
-
* Client-provided reference ID for tracking orders.
|
|
39
|
-
* Must be alphanumeric with optional hyphens, underscores, and dots (max 255 chars).
|
|
40
|
-
* Auto-generates UUID if not provided.
|
|
41
|
-
*/
|
|
42
|
-
clientReferenceId?: string;
|
|
43
37
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { getDefaultToken, USDC_BASE } from "../../../anyspend/index.js";
|
|
4
4
|
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
5
|
-
import { Validators } from "../../../anyspend/utils/validation.js";
|
|
6
5
|
import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet, useProfile, useRouter, useSearchParamsSSR, useTokenBalanceDirect, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
|
|
7
6
|
import { cn } from "../../../shared/utils/cn.js";
|
|
8
7
|
import { formatTokenAmount } from "../../../shared/utils/number.js";
|
|
@@ -49,18 +48,9 @@ export function AnySpend(props) {
|
|
|
49
48
|
const fingerprintConfig = getFingerprintConfig();
|
|
50
49
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendInner, { ...props }) }));
|
|
51
50
|
}
|
|
52
|
-
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, onSuccess, customUsdInputValues,
|
|
51
|
+
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, onSuccess, customUsdInputValues, }) {
|
|
53
52
|
const searchParams = useSearchParamsSSR();
|
|
54
53
|
const router = useRouter();
|
|
55
|
-
// Validate and clean clientReferenceId
|
|
56
|
-
const validatedClientReferenceId = useMemo(() => {
|
|
57
|
-
const validation = Validators.clientReferenceId(clientReferenceIdFromProps);
|
|
58
|
-
if (!validation.isValid) {
|
|
59
|
-
console.error(`[AnySpend] Invalid clientReferenceId: ${validation.error || "Validation failed"}. Will be set to undefined.`);
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
return validation.cleaned;
|
|
63
|
-
}, [clientReferenceIdFromProps]);
|
|
64
54
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
65
55
|
const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
|
|
66
56
|
// Add refs to track URL state
|
|
@@ -648,7 +638,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
648
638
|
srcAmount: srcAmountBigInt.toString(),
|
|
649
639
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount || "0",
|
|
650
640
|
creatorAddress: globalAddress,
|
|
651
|
-
clientReferenceId: validatedClientReferenceId,
|
|
652
641
|
});
|
|
653
642
|
}
|
|
654
643
|
catch (err) {
|
|
@@ -713,7 +702,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
713
702
|
},
|
|
714
703
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
715
704
|
creatorAddress: globalAddress,
|
|
716
|
-
clientReferenceId: validatedClientReferenceId,
|
|
717
705
|
});
|
|
718
706
|
}
|
|
719
707
|
catch (err) {
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { AnySpendBondKitProps } from "../../../global-account/react/stores/useModalStore";
|
|
2
|
-
export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, b3Amount: initialB3Amount, onSuccess,
|
|
3
|
-
clientReferenceId?: string;
|
|
4
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, b3Amount: initialB3Amount, onSuccess, }: AnySpendBondKitProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -20,7 +20,7 @@ function formatNumberWithCommas(x) {
|
|
|
20
20
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
21
21
|
return parts.join(".");
|
|
22
22
|
}
|
|
23
|
-
export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, b3Amount: initialB3Amount, onSuccess,
|
|
23
|
+
export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, b3Amount: initialB3Amount, onSuccess, }) {
|
|
24
24
|
const hasMounted = useHasMounted();
|
|
25
25
|
const [showAmountPrompt, setShowAmountPrompt] = useState(!initialB3Amount);
|
|
26
26
|
const [b3Amount, setB3Amount] = useState(initialB3Amount || "");
|
|
@@ -200,5 +200,5 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
200
200
|
});
|
|
201
201
|
return (_jsx(AnySpendCustom, { mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: baseMainnet.id, dstToken: dstToken, dstAmount: parseEther(b3Amount).toString(), contractAddress: contractAddress, encodedData: encodedData, metadata: {
|
|
202
202
|
action: "BondKit Buy",
|
|
203
|
-
}, header: header, onSuccess: onSuccess, showRecipient: true
|
|
203
|
+
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
204
204
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function AnySpendBuySpin({ loadOrder, mode, spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess,
|
|
1
|
+
export declare function AnySpendBuySpin({ loadOrder, mode, spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess, }: {
|
|
2
2
|
loadOrder?: string;
|
|
3
3
|
mode?: "modal" | "page";
|
|
4
4
|
spinwheelContractAddress: string;
|
|
@@ -6,5 +6,4 @@ export declare function AnySpendBuySpin({ loadOrder, mode, spinwheelContractAddr
|
|
|
6
6
|
recipientAddress: string;
|
|
7
7
|
prefillQuantity?: string;
|
|
8
8
|
onSuccess?: (txHash?: string) => void;
|
|
9
|
-
clientReferenceId?: string;
|
|
10
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -85,7 +85,7 @@ const basePublicClient = createPublicClient({
|
|
|
85
85
|
chain: baseMainnet,
|
|
86
86
|
transport: http(PUBLIC_BASE_RPC_URL),
|
|
87
87
|
});
|
|
88
|
-
export function AnySpendBuySpin({ loadOrder, mode = "modal", spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess,
|
|
88
|
+
export function AnySpendBuySpin({ loadOrder, mode = "modal", spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess, }) {
|
|
89
89
|
const hasMounted = useHasMounted();
|
|
90
90
|
const { setB3ModalOpen } = useModalStore();
|
|
91
91
|
// Payment config state
|
|
@@ -391,5 +391,5 @@ export function AnySpendBuySpin({ loadOrder, mode = "modal", spinwheelContractAd
|
|
|
391
391
|
const encodedData = generateEncodedDataForBuyEntriesAndSpin(address || "", userSpinQuantity);
|
|
392
392
|
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: chainId, dstToken: B3_TOKEN, dstAmount: totalCost.toString(), contractAddress: spinwheelContractAddress, spenderAddress: paymentConfig.entryModule, encodedData: encodedData, metadata: {
|
|
393
393
|
action: `buy ${userSpinQuantity} spin${userSpinQuantity !== "1" ? "s" : ""}`,
|
|
394
|
-
}, header: header, onSuccess: txHash => onSuccess?.(txHash), showRecipient: false
|
|
394
|
+
}, header: header, onSuccess: txHash => onSuccess?.(txHash), showRecipient: false }));
|
|
395
395
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { components } from "../../../anyspend/types/api";
|
|
2
|
+
import { GetQuoteResponse } from "../../../anyspend/types/api_req_res";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export interface AnySpendCollectorClubPurchaseProps {
|
|
5
|
+
/**
|
|
6
|
+
* Optional order ID to load existing order
|
|
7
|
+
*/
|
|
8
|
+
loadOrder?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Display mode
|
|
11
|
+
*/
|
|
12
|
+
mode?: "modal" | "page";
|
|
13
|
+
/**
|
|
14
|
+
* Active tab (crypto or fiat payment)
|
|
15
|
+
*/
|
|
16
|
+
activeTab?: "crypto" | "fiat";
|
|
17
|
+
/**
|
|
18
|
+
* The pack ID to purchase
|
|
19
|
+
*/
|
|
20
|
+
packId: number;
|
|
21
|
+
/**
|
|
22
|
+
* The number of packs to purchase
|
|
23
|
+
*/
|
|
24
|
+
packAmount: number;
|
|
25
|
+
/**
|
|
26
|
+
* Price per pack in wei (e.g., "10000" for 0.01 USDC with 6 decimals)
|
|
27
|
+
*/
|
|
28
|
+
pricePerPack: string;
|
|
29
|
+
/**
|
|
30
|
+
* The payment token (defaults to USDC on Base)
|
|
31
|
+
*/
|
|
32
|
+
paymentToken?: components["schemas"]["Token"];
|
|
33
|
+
/**
|
|
34
|
+
* Address that will receive the packs
|
|
35
|
+
*/
|
|
36
|
+
recipientAddress: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional spender address (defaults to contract address)
|
|
39
|
+
*/
|
|
40
|
+
spenderAddress?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Success callback
|
|
43
|
+
*/
|
|
44
|
+
onSuccess?: (txHash?: string) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Optional custom header component
|
|
47
|
+
*/
|
|
48
|
+
header?: (props: {
|
|
49
|
+
anyspendPrice: GetQuoteResponse | undefined;
|
|
50
|
+
isLoadingAnyspendPrice: boolean;
|
|
51
|
+
}) => React.JSX.Element;
|
|
52
|
+
/**
|
|
53
|
+
* Show recipient selection (default: true)
|
|
54
|
+
*/
|
|
55
|
+
showRecipient?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare function AnySpendCollectorClubPurchase({ loadOrder, mode, activeTab, packId, packAmount, pricePerPack, paymentToken, recipientAddress, spenderAddress, onSuccess, header, showRecipient, }: AnySpendCollectorClubPurchaseProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* AnySpend component for Collector Club pack purchases
|
|
4
|
+
*
|
|
5
|
+
* This component enables users to purchase Collector Club packs using any token via AnySpend.
|
|
6
|
+
* It calls the `buyPacksFor` function on the Collector Club Shop contract on Base.
|
|
7
|
+
* Uses exact-out flow to ensure the contract receives exactly the required USDC amount.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { AnySpendCollectorClubPurchase } from "../../..";
|
|
12
|
+
* import { USDC_BASE } from "../../../anyspend/constants/index.js";
|
|
13
|
+
*
|
|
14
|
+
* function MyComponent() {
|
|
15
|
+
* return (
|
|
16
|
+
* <AnySpendCollectorClubPurchase
|
|
17
|
+
* packId={1}
|
|
18
|
+
* packAmount={5}
|
|
19
|
+
* pricePerPack="10000" // 0.01 USDC in wei (6 decimals)
|
|
20
|
+
* paymentToken={USDC_BASE}
|
|
21
|
+
* recipientAddress="0x123..."
|
|
22
|
+
* onSuccess={(txHash) => console.log("Purchase successful!", txHash)}
|
|
23
|
+
* />
|
|
24
|
+
* );
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
import { USDC_BASE } from "../../../anyspend/constants/index.js";
|
|
29
|
+
import { useMemo } from "react";
|
|
30
|
+
import { encodeFunctionData } from "viem";
|
|
31
|
+
import { AnySpendCustom } from "./AnySpendCustom.js";
|
|
32
|
+
// Collector Club Shop contract on Base
|
|
33
|
+
const CC_SHOP_ADDRESS = "0x68B32D594E3c7E5B8cd8046BD66AfB0DB5b9BF9c";
|
|
34
|
+
const BASE_CHAIN_ID = 8453;
|
|
35
|
+
// ABI for buyPacksFor function only
|
|
36
|
+
const BUY_PACKS_FOR_ABI = {
|
|
37
|
+
inputs: [
|
|
38
|
+
{ internalType: "address", name: "user", type: "address" },
|
|
39
|
+
{ internalType: "uint256", name: "packId", type: "uint256" },
|
|
40
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
41
|
+
],
|
|
42
|
+
name: "buyPacksFor",
|
|
43
|
+
outputs: [],
|
|
44
|
+
stateMutability: "nonpayable",
|
|
45
|
+
type: "function",
|
|
46
|
+
};
|
|
47
|
+
export function AnySpendCollectorClubPurchase({ loadOrder, mode = "modal", activeTab = "crypto", packId, packAmount, pricePerPack, paymentToken = USDC_BASE, recipientAddress, spenderAddress = CC_SHOP_ADDRESS, onSuccess, header, showRecipient = true, }) {
|
|
48
|
+
// Calculate total amount needed (pricePerPack * packAmount)
|
|
49
|
+
const totalAmount = useMemo(() => {
|
|
50
|
+
try {
|
|
51
|
+
return (BigInt(pricePerPack) * BigInt(packAmount)).toString();
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error("Failed to calculate total amount from props", { pricePerPack, packAmount, error });
|
|
55
|
+
return "0";
|
|
56
|
+
}
|
|
57
|
+
}, [pricePerPack, packAmount]);
|
|
58
|
+
// Encode the buyPacksFor function call
|
|
59
|
+
const encodedData = useMemo(() => {
|
|
60
|
+
try {
|
|
61
|
+
return encodeFunctionData({
|
|
62
|
+
abi: [BUY_PACKS_FOR_ABI],
|
|
63
|
+
functionName: "buyPacksFor",
|
|
64
|
+
args: [recipientAddress, BigInt(packId), BigInt(packAmount)],
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error("Failed to encode function data", { recipientAddress, packId, packAmount, error });
|
|
69
|
+
return "0x";
|
|
70
|
+
}
|
|
71
|
+
}, [recipientAddress, packId, packAmount]);
|
|
72
|
+
// Default header if not provided
|
|
73
|
+
const defaultHeader = () => (_jsx("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: _jsxs("div", { children: [_jsx("h1", { className: "text-as-primary text-xl font-bold", children: "Buy Collector Club Packs" }), _jsxs("p", { className: "text-as-secondary text-sm", children: ["Purchase ", packAmount, " pack", packAmount !== 1 ? "s" : "", " using any token"] })] }) }));
|
|
74
|
+
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, activeTab: activeTab, recipientAddress: recipientAddress, spenderAddress: spenderAddress, orderType: "custom", dstChainId: BASE_CHAIN_ID, dstToken: paymentToken, dstAmount: totalAmount, contractAddress: CC_SHOP_ADDRESS, encodedData: encodedData, metadata: {
|
|
75
|
+
packId,
|
|
76
|
+
packAmount,
|
|
77
|
+
pricePerPack,
|
|
78
|
+
}, header: header || defaultHeader, onSuccess: onSuccess, showRecipient: showRecipient }));
|
|
79
|
+
}
|
|
@@ -108,7 +108,7 @@ export function AnySpendCustom(props) {
|
|
|
108
108
|
const fingerprintConfig = getFingerprintConfig();
|
|
109
109
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomInner, { ...props }) }));
|
|
110
110
|
}
|
|
111
|
-
function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabProps = "crypto", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, onShowPointsDetail,
|
|
111
|
+
function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabProps = "crypto", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, onShowPointsDetail, }) {
|
|
112
112
|
const hasMounted = useHasMounted();
|
|
113
113
|
const featureFlags = useFeatureFlags();
|
|
114
114
|
const searchParams = useSearchParamsSSR();
|
|
@@ -351,13 +351,11 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
351
351
|
: window.location.origin,
|
|
352
352
|
},
|
|
353
353
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
354
|
-
clientReferenceId: clientReferenceId,
|
|
355
354
|
});
|
|
356
355
|
}
|
|
357
356
|
else {
|
|
358
357
|
void createRegularOrder({
|
|
359
358
|
...createOrderParams,
|
|
360
|
-
clientReferenceId: clientReferenceId,
|
|
361
359
|
});
|
|
362
360
|
}
|
|
363
361
|
}
|
|
@@ -31,7 +31,6 @@ export interface AnySpendCustomExactInProps {
|
|
|
31
31
|
anyspendPrice: GetQuoteResponse | undefined;
|
|
32
32
|
isLoadingAnyspendPrice: boolean;
|
|
33
33
|
}) => React.JSX.Element;
|
|
34
|
-
clientReferenceId?: string;
|
|
35
34
|
}
|
|
36
35
|
export declare function AnySpendCustomExactIn(props: AnySpendCustomExactInProps): import("react/jsx-runtime").JSX.Element;
|
|
37
36
|
export {};
|
|
@@ -25,7 +25,7 @@ export function AnySpendCustomExactIn(props) {
|
|
|
25
25
|
const fingerprintConfig = getFingerprintConfig();
|
|
26
26
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomExactInInner, { ...props }) }));
|
|
27
27
|
}
|
|
28
|
-
function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, orderType = "custom_exact_in", minDestinationAmount, header,
|
|
28
|
+
function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, orderType = "custom_exact_in", minDestinationAmount, header, }) {
|
|
29
29
|
const actionLabel = customExactInConfig?.action ?? "Custom Execution";
|
|
30
30
|
const DESTINATION_TOKEN_DETAILS = {
|
|
31
31
|
SYMBOL: destinationToken.symbol ?? "TOKEN",
|
|
@@ -189,7 +189,6 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
189
189
|
expectedDstAmount: expectedDstAmountRaw,
|
|
190
190
|
creatorAddress: globalAddress,
|
|
191
191
|
payload,
|
|
192
|
-
clientReferenceId: clientReferenceId,
|
|
193
192
|
});
|
|
194
193
|
}
|
|
195
194
|
catch (err) {
|
|
@@ -242,7 +241,6 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
242
241
|
expectedDstAmount: expectedDstAmountRaw,
|
|
243
242
|
creatorAddress: globalAddress,
|
|
244
243
|
payload,
|
|
245
|
-
clientReferenceId: clientReferenceId,
|
|
246
244
|
});
|
|
247
245
|
}
|
|
248
246
|
catch (err) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
|
-
export declare function AnySpendDepositUpside({ loadOrder, mode, recipientAddress, sourceTokenAddress, sourceTokenChainId, depositContractAddress, token, onSuccess,
|
|
2
|
+
export declare function AnySpendDepositUpside({ loadOrder, mode, recipientAddress, sourceTokenAddress, sourceTokenChainId, depositContractAddress, token, onSuccess, }: {
|
|
3
3
|
loadOrder?: string;
|
|
4
4
|
mode?: "modal" | "page";
|
|
5
5
|
recipientAddress: string;
|
|
@@ -8,5 +8,4 @@ export declare function AnySpendDepositUpside({ loadOrder, mode, recipientAddres
|
|
|
8
8
|
depositContractAddress: string;
|
|
9
9
|
token: components["schemas"]["Token"];
|
|
10
10
|
onSuccess?: (amount: string) => void;
|
|
11
|
-
clientReferenceId?: string;
|
|
12
11
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -22,7 +22,7 @@ const DEPOSIT_FOR_FUNCTION_ABI = JSON.stringify([
|
|
|
22
22
|
type: "function",
|
|
23
23
|
},
|
|
24
24
|
]);
|
|
25
|
-
export function AnySpendDepositUpside({ loadOrder, mode = "modal", recipientAddress, sourceTokenAddress, sourceTokenChainId, depositContractAddress, token, onSuccess,
|
|
25
|
+
export function AnySpendDepositUpside({ loadOrder, mode = "modal", recipientAddress, sourceTokenAddress, sourceTokenChainId, depositContractAddress, token, onSuccess, }) {
|
|
26
26
|
if (!recipientAddress)
|
|
27
27
|
return null;
|
|
28
28
|
const header = () => (_jsx(_Fragment, { children: _jsx("div", { className: "from-b3-react-background to-as-on-surface-1 w-full rounded-t-lg bg-gradient-to-t", children: _jsx("div", { className: "mb-1 flex w-full flex-col items-center gap-2", children: _jsxs("span", { className: "font-sf-rounded text-2xl font-semibold", children: ["Swap & Deposit ", token.symbol] }) }) }) }));
|
|
@@ -34,5 +34,5 @@ export function AnySpendDepositUpside({ loadOrder, mode = "modal", recipientAddr
|
|
|
34
34
|
spenderAddress: depositContractAddress,
|
|
35
35
|
action: `deposit ${token.symbol}`,
|
|
36
36
|
};
|
|
37
|
-
return (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: sourceTokenChainId, destinationToken: token, destinationChainId: base.id, customExactInConfig: customExactInConfig, header: header, onSuccess: onSuccess
|
|
37
|
+
return (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: sourceTokenChainId, destinationToken: token, destinationChainId: base.id, customExactInConfig: customExactInConfig, header: header, onSuccess: onSuccess }));
|
|
38
38
|
}
|