@b3dotfun/sdk 0.0.26-alpha.5 → 0.0.26-alpha.6
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/AnySpendCustom.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +3 -2
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -2
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +7 -3
- package/src/anyspend/react/components/AnySpendNFT.tsx +2 -1
|
@@ -40,6 +40,7 @@ var PanelView;
|
|
|
40
40
|
function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChainId, dstToken, dstAmount, contractAddress, tokenId, contractType, encodedData, spenderAddress, }) {
|
|
41
41
|
switch (orderType) {
|
|
42
42
|
case "mint_nft": {
|
|
43
|
+
(0, invariant_1.default)(contractType, "Contract type is required");
|
|
43
44
|
return {
|
|
44
45
|
type: "mint_nft",
|
|
45
46
|
srcChain: srcChainId,
|
|
@@ -98,12 +99,12 @@ function AnySpendCustom(props) {
|
|
|
98
99
|
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
99
100
|
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(AnySpendCustomInner, { ...props }) }));
|
|
100
101
|
}
|
|
101
|
-
function AnySpendCustomInner({ loadOrder, mode = "modal", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, }) {
|
|
102
|
+
function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabProps = "crypto", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, }) {
|
|
102
103
|
const hasMounted = (0, react_2.useHasMounted)();
|
|
103
104
|
const searchParams = (0, react_2.useSearchParamsSSR)();
|
|
104
105
|
const router = (0, react_2.useRouter)();
|
|
105
106
|
const [activePanel, setActivePanel] = (0, react_4.useState)(loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER);
|
|
106
|
-
const [activeTab, setActiveTab] = (0, react_4.useState)(
|
|
107
|
+
const [activeTab, setActiveTab] = (0, react_4.useState)(activeTabProps);
|
|
107
108
|
// Add state for selected payment methods
|
|
108
109
|
const [selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod] = (0, react_4.useState)(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE);
|
|
109
110
|
const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = (0, react_4.useState)(FiatPaymentMethod_1.FiatPaymentMethod.NONE);
|
|
@@ -82,11 +82,11 @@ function AnySpendNFT({ loadOrder, mode = "modal", recipientAddress, nftContract,
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
fetchContractMetadata();
|
|
85
|
-
}, [nftContract.contractAddress, nftContract.chainId, nftContract.imageUrl, nftContract.tokenId]);
|
|
85
|
+
}, [nftContract.contractAddress, nftContract.chainId, nftContract.imageUrl, nftContract.tokenId, isLoadingFallback]);
|
|
86
86
|
const header = ({ anyspendPrice, isLoadingAnyspendPrice, }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative size-[200px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 bg-black/30 blur-md" }), (0, jsx_runtime_1.jsxs)(react_1.GlareCard, { className: "overflow-hidden", children: [imageUrlWithFallback && ((0, jsx_runtime_1.jsx)("img", { src: imageUrlWithFallback, alt: nftContract.name, className: "size-full object-cover" })), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 rounded-xl border border-white/10" })] }), (0, jsx_runtime_1.jsx)(DropdownMenu, { nftContract: nftContract })] }), (0, jsx_runtime_1.jsxs)("div", { className: "from-b3-react-background to-as-on-surface-1 -mb-5 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[100px] w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [(0, jsx_runtime_1.jsx)("span", { className: "font-sf-rounded text-2xl font-semibold", children: nftContract.name }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-fit items-center gap-1", children: anyspendPrice ? ((0, jsx_runtime_1.jsx)(react_2.AnimatePresence, { mode: "wait", children: (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("text-as-primary group flex items-center text-3xl font-semibold transition-all", {
|
|
87
87
|
"opacity-0": isLoadingAnyspendPrice,
|
|
88
88
|
}), children: (0, number_1.formatDisplayNumber)(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }) }) })) : ((0, jsx_runtime_1.jsx)("div", { className: "h-[36px] w-full" })) })] })] })] }));
|
|
89
|
-
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "mint_nft", dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
89
|
+
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { loadOrder: loadOrder, mode: mode, activeTab: "fiat", recipientAddress: recipientAddress, orderType: "mint_nft", dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
90
90
|
type: "mint_nft",
|
|
91
91
|
nftContract: nftContract,
|
|
92
92
|
}, header: header, onSuccess: onSuccess }));
|
|
@@ -34,6 +34,7 @@ var PanelView;
|
|
|
34
34
|
function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChainId, dstToken, dstAmount, contractAddress, tokenId, contractType, encodedData, spenderAddress, }) {
|
|
35
35
|
switch (orderType) {
|
|
36
36
|
case "mint_nft": {
|
|
37
|
+
invariant(contractType, "Contract type is required");
|
|
37
38
|
return {
|
|
38
39
|
type: "mint_nft",
|
|
39
40
|
srcChain: srcChainId,
|
|
@@ -92,12 +93,12 @@ export function AnySpendCustom(props) {
|
|
|
92
93
|
const fingerprintConfig = getFingerprintConfig();
|
|
93
94
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomInner, { ...props }) }));
|
|
94
95
|
}
|
|
95
|
-
function AnySpendCustomInner({ loadOrder, mode = "modal", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, }) {
|
|
96
|
+
function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabProps = "crypto", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, }) {
|
|
96
97
|
const hasMounted = useHasMounted();
|
|
97
98
|
const searchParams = useSearchParamsSSR();
|
|
98
99
|
const router = useRouter();
|
|
99
100
|
const [activePanel, setActivePanel] = useState(loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER);
|
|
100
|
-
const [activeTab, setActiveTab] = useState(
|
|
101
|
+
const [activeTab, setActiveTab] = useState(activeTabProps);
|
|
101
102
|
// Add state for selected payment methods
|
|
102
103
|
const [selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod] = useState(CryptoPaymentMethodType.NONE);
|
|
103
104
|
const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = useState(FiatPaymentMethod.NONE);
|
|
@@ -79,11 +79,11 @@ export function AnySpendNFT({ loadOrder, mode = "modal", recipientAddress, nftCo
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
fetchContractMetadata();
|
|
82
|
-
}, [nftContract.contractAddress, nftContract.chainId, nftContract.imageUrl, nftContract.tokenId]);
|
|
82
|
+
}, [nftContract.contractAddress, nftContract.chainId, nftContract.imageUrl, nftContract.tokenId, isLoadingFallback]);
|
|
83
83
|
const header = ({ anyspendPrice, isLoadingAnyspendPrice, }) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative size-[200px]", children: [_jsx("div", { className: "absolute inset-0 scale-95 bg-black/30 blur-md" }), _jsxs(GlareCard, { className: "overflow-hidden", children: [imageUrlWithFallback && (_jsx("img", { src: imageUrlWithFallback, alt: nftContract.name, className: "size-full object-cover" })), _jsx("div", { className: "absolute inset-0 rounded-xl border border-white/10" })] }), _jsx(DropdownMenu, { nftContract: nftContract })] }), _jsxs("div", { className: "from-b3-react-background to-as-on-surface-1 -mb-5 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [_jsx("div", { className: "h-[100px] w-full" }), _jsxs("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [_jsx("span", { className: "font-sf-rounded text-2xl font-semibold", children: nftContract.name }), _jsx("div", { className: "flex w-fit items-center gap-1", children: anyspendPrice ? (_jsx(AnimatePresence, { mode: "wait", children: _jsx("div", { className: cn("text-as-primary group flex items-center text-3xl font-semibold transition-all", {
|
|
84
84
|
"opacity-0": isLoadingAnyspendPrice,
|
|
85
85
|
}), children: formatDisplayNumber(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }) }) })) : (_jsx("div", { className: "h-[36px] w-full" })) })] })] })] }));
|
|
86
|
-
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "mint_nft", dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
86
|
+
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, activeTab: "fiat", recipientAddress: recipientAddress, orderType: "mint_nft", dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
87
87
|
type: "mint_nft",
|
|
88
88
|
nftContract: nftContract,
|
|
89
89
|
}, header: header, onSuccess: onSuccess }));
|
package/package.json
CHANGED
|
@@ -88,6 +88,7 @@ function generateGetRelayQuoteRequest({
|
|
|
88
88
|
}): GetQuoteRequest {
|
|
89
89
|
switch (orderType) {
|
|
90
90
|
case "mint_nft": {
|
|
91
|
+
invariant(contractType, "Contract type is required");
|
|
91
92
|
return {
|
|
92
93
|
type: "mint_nft",
|
|
93
94
|
srcChain: srcChainId,
|
|
@@ -96,8 +97,8 @@ function generateGetRelayQuoteRequest({
|
|
|
96
97
|
dstTokenAddress: dstToken.address,
|
|
97
98
|
price: dstAmount,
|
|
98
99
|
contractAddress: contractAddress,
|
|
99
|
-
tokenId: tokenId
|
|
100
|
-
contractType: contractType
|
|
100
|
+
tokenId: tokenId,
|
|
101
|
+
contractType: contractType,
|
|
101
102
|
};
|
|
102
103
|
}
|
|
103
104
|
case "join_tournament": {
|
|
@@ -146,6 +147,7 @@ function generateGetRelayQuoteRequest({
|
|
|
146
147
|
export function AnySpendCustom(props: {
|
|
147
148
|
loadOrder?: string;
|
|
148
149
|
mode?: "modal" | "page";
|
|
150
|
+
activeTab?: "crypto" | "fiat";
|
|
149
151
|
recipientAddress?: string;
|
|
150
152
|
spenderAddress?: string;
|
|
151
153
|
orderType: components["schemas"]["Order"]["type"];
|
|
@@ -177,6 +179,7 @@ export function AnySpendCustom(props: {
|
|
|
177
179
|
function AnySpendCustomInner({
|
|
178
180
|
loadOrder,
|
|
179
181
|
mode = "modal",
|
|
182
|
+
activeTab: activeTabProps = "crypto",
|
|
180
183
|
recipientAddress: recipientAddressProps,
|
|
181
184
|
spenderAddress,
|
|
182
185
|
orderType,
|
|
@@ -192,6 +195,7 @@ function AnySpendCustomInner({
|
|
|
192
195
|
}: {
|
|
193
196
|
loadOrder?: string;
|
|
194
197
|
mode?: "modal" | "page";
|
|
198
|
+
activeTab?: "crypto" | "fiat";
|
|
195
199
|
recipientAddress?: string;
|
|
196
200
|
spenderAddress?: string;
|
|
197
201
|
orderType: components["schemas"]["Order"]["type"];
|
|
@@ -219,7 +223,7 @@ function AnySpendCustomInner({
|
|
|
219
223
|
const [activePanel, setActivePanel] = useState<PanelView>(
|
|
220
224
|
loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER,
|
|
221
225
|
);
|
|
222
|
-
const [activeTab, setActiveTab] = useState<"crypto" | "fiat">(
|
|
226
|
+
const [activeTab, setActiveTab] = useState<"crypto" | "fiat">(activeTabProps);
|
|
223
227
|
|
|
224
228
|
// Add state for selected payment methods
|
|
225
229
|
const [selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod] = useState<CryptoPaymentMethodType>(
|
|
@@ -100,7 +100,7 @@ export function AnySpendNFT({
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
fetchContractMetadata();
|
|
103
|
-
}, [nftContract.contractAddress, nftContract.chainId, nftContract.imageUrl, nftContract.tokenId]);
|
|
103
|
+
}, [nftContract.contractAddress, nftContract.chainId, nftContract.imageUrl, nftContract.tokenId, isLoadingFallback]);
|
|
104
104
|
|
|
105
105
|
const header = ({
|
|
106
106
|
anyspendPrice,
|
|
@@ -150,6 +150,7 @@ export function AnySpendNFT({
|
|
|
150
150
|
<AnySpendCustom
|
|
151
151
|
loadOrder={loadOrder}
|
|
152
152
|
mode={mode}
|
|
153
|
+
activeTab="fiat"
|
|
153
154
|
recipientAddress={recipientAddress}
|
|
154
155
|
orderType={"mint_nft"}
|
|
155
156
|
dstChainId={nftContract.chainId}
|