@b3dotfun/sdk 0.0.29 → 0.0.30-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/constants/index.d.ts +1 -0
- package/dist/cjs/anyspend/constants/index.js +2 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +23 -24
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +17 -10
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +9 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +130 -41
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +6 -3
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +6 -4
- package/dist/cjs/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PaySection.js +6 -4
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +34 -3
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/cjs/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/cjs/bondkit/abis/BondkitTokenABI.js +41 -9
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.js +0 -9
- package/dist/cjs/bondkit/constants.js +1 -1
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +28 -15
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +1 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/cjs/shared/constants/chains/supported.d.ts +4 -4
- package/dist/esm/anyspend/constants/index.d.ts +1 -0
- package/dist/esm/anyspend/constants/index.js +1 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +23 -24
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +19 -12
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +133 -44
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +7 -4
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +7 -5
- package/dist/esm/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaySection.js +7 -5
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +35 -4
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/esm/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/esm/bondkit/abis/BondkitTokenABI.js +41 -9
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.js +0 -9
- package/dist/esm/bondkit/constants.js +1 -1
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +28 -15
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +1 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/esm/shared/constants/chains/supported.d.ts +4 -4
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/types/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/types/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/types/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/types/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/types/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/types/shared/constants/chains/supported.d.ts +4 -4
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +2 -0
- package/src/anyspend/react/components/AnySpend.tsx +1 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +28 -28
- package/src/anyspend/react/components/AnySpendCustom.tsx +1 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +142 -130
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +9 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +289 -103
- package/src/anyspend/react/components/common/OrderDetails.tsx +7 -3
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +10 -4
- package/src/anyspend/react/components/common/OrderStatus.tsx +9 -2
- package/src/anyspend/react/components/common/PaySection.tsx +9 -7
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +41 -3
- package/src/bondkit/abis/BondkitTokenABI.ts +41 -9
- package/src/bondkit/abis/BondkitTokenFactoryABI.ts +0 -9
- package/src/bondkit/constants.ts +1 -1
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +26 -10
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +5 -1
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +1 -0
- package/src/global-account/react/stores/useModalStore.ts +4 -2
- package/dist/cjs/anyspend/abis/bondKit.d.ts +0 -35
- package/dist/cjs/anyspend/abis/bondKit.js +0 -29
- package/dist/esm/anyspend/abis/bondKit.d.ts +0 -35
- package/dist/esm/anyspend/abis/bondKit.js +0 -26
- package/dist/types/anyspend/abis/bondKit.d.ts +0 -35
- package/src/anyspend/abis/bondKit.ts +0 -26
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LinkAccount = LinkAccount;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const constants_1 = require("../../../../shared/constants");
|
|
5
6
|
const thirdweb_1 = require("../../../../shared/utils/thirdweb");
|
|
6
7
|
const lucide_react_1 = require("lucide-react");
|
|
7
8
|
const react_1 = require("react");
|
|
@@ -97,6 +98,10 @@ function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, chain, pa
|
|
|
97
98
|
client: thirdweb_1.client,
|
|
98
99
|
strategy: "email",
|
|
99
100
|
email,
|
|
101
|
+
ecosystem: {
|
|
102
|
+
id: constants_1.ecosystemWalletId,
|
|
103
|
+
partnerId: partnerId,
|
|
104
|
+
},
|
|
100
105
|
});
|
|
101
106
|
}
|
|
102
107
|
else if (selectedMethod === "phone") {
|
|
@@ -104,6 +109,10 @@ function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, chain, pa
|
|
|
104
109
|
client: thirdweb_1.client,
|
|
105
110
|
strategy: "phone",
|
|
106
111
|
phoneNumber: phone,
|
|
112
|
+
ecosystem: {
|
|
113
|
+
id: constants_1.ecosystemWalletId,
|
|
114
|
+
partnerId: partnerId,
|
|
115
|
+
},
|
|
107
116
|
});
|
|
108
117
|
}
|
|
109
118
|
setOtpSent(true);
|
|
@@ -117,10 +126,12 @@ function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, chain, pa
|
|
|
117
126
|
};
|
|
118
127
|
const handleLinkAccount = async () => {
|
|
119
128
|
if (!otp) {
|
|
129
|
+
console.error("No OTP entered");
|
|
120
130
|
setError("Please enter the verification code");
|
|
121
131
|
return;
|
|
122
132
|
}
|
|
123
133
|
try {
|
|
134
|
+
setOtpSent(false);
|
|
124
135
|
setLinkingState(true, selectedMethod);
|
|
125
136
|
setError(null);
|
|
126
137
|
if (selectedMethod === "email") {
|
|
@@ -139,17 +150,12 @@ function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, chain, pa
|
|
|
139
150
|
verificationCode: otp,
|
|
140
151
|
}, mutationOptions);
|
|
141
152
|
}
|
|
142
|
-
onSuccess?.();
|
|
143
|
-
onClose?.();
|
|
144
153
|
}
|
|
145
154
|
catch (error) {
|
|
146
155
|
console.error("Error linking account:", error);
|
|
147
156
|
setError(error instanceof Error ? error.message : "Failed to link account");
|
|
148
157
|
onError?.(error);
|
|
149
158
|
}
|
|
150
|
-
finally {
|
|
151
|
-
setLinkingState(false);
|
|
152
|
-
}
|
|
153
159
|
};
|
|
154
160
|
const handleSocialLink = async (strategy) => {
|
|
155
161
|
try {
|
|
@@ -200,17 +206,24 @@ function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, chain, pa
|
|
|
200
206
|
setError(null);
|
|
201
207
|
setLinkingState(false);
|
|
202
208
|
}, [isLinking, setSelectedMethod, setEmail, setPhone, setOtp, setOtpSent, setError, setLinkingState]);
|
|
209
|
+
const handleFinishedLinking = (0, react_1.useCallback)((success) => {
|
|
210
|
+
if (success) {
|
|
211
|
+
onSuccess?.();
|
|
212
|
+
onClose?.();
|
|
213
|
+
}
|
|
214
|
+
setLinkingState(false);
|
|
215
|
+
navigateBack();
|
|
216
|
+
setB3ModalContentType({
|
|
217
|
+
type: "manageAccount",
|
|
218
|
+
activeTab: "settings",
|
|
219
|
+
setActiveTab: () => { },
|
|
220
|
+
chain,
|
|
221
|
+
partnerId,
|
|
222
|
+
});
|
|
223
|
+
}, [chain, navigateBack, partnerId, setB3ModalContentType, setLinkingState, onSuccess, onClose]);
|
|
203
224
|
(0, react_1.useEffect)(() => {
|
|
204
225
|
if (isLinking) {
|
|
205
|
-
|
|
206
|
-
navigateBack();
|
|
207
|
-
setB3ModalContentType({
|
|
208
|
-
type: "manageAccount",
|
|
209
|
-
activeTab: "settings",
|
|
210
|
-
setActiveTab: () => { },
|
|
211
|
-
chain,
|
|
212
|
-
partnerId,
|
|
213
|
-
});
|
|
226
|
+
handleFinishedLinking(true);
|
|
214
227
|
}
|
|
215
228
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
216
229
|
}, [profiles.length]);
|
|
@@ -224,5 +237,5 @@ function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, chain, pa
|
|
|
224
237
|
else {
|
|
225
238
|
handleSocialLink(method.id);
|
|
226
239
|
}
|
|
227
|
-
}, disabled: linkingMethod === method.id, children: isLinking && linkingMethod === method.id ? (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "animate-spin" }) : method.label }, method.id))), availableAuthMethods.length === 0 && ((0, jsx_runtime_1.jsx)("div", { className: "text-b3-foreground-muted py-8 text-center", children: "All available authentication methods have been connected" }))] })) : ((0, jsx_runtime_1.jsxs)("div", { className: "space-y-4", children: [selectedMethod === "email" && ((0, jsx_runtime_1.jsxs)("div", { className: "space-y-2", children: [(0, jsx_runtime_1.jsx)("label", { className: "text-b3-grey font-neue-montreal-medium text-sm", children: "Email Address" }), (0, jsx_runtime_1.jsx)("input", { type: "email", placeholder: "Enter your email", className: "bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2", value: email, onChange: e => setEmail(e.target.value), disabled: otpSent || (isLinking && linkingMethod === "email") })] })), selectedMethod === "phone" && ((0, jsx_runtime_1.jsxs)("div", { className: "space-y-2", children: [(0, jsx_runtime_1.jsx)("label", { className: "text-b3-grey font-neue-montreal-medium text-sm", children: "Phone Number" }), (0, jsx_runtime_1.jsx)("input", { type: "tel", placeholder: "Enter your phone number", className: "bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2", value: phone, onChange: e => setPhone(e.target.value), disabled: otpSent || (isLinking && linkingMethod === "phone") }), (0, jsx_runtime_1.jsx)("p", { className: "text-b3-foreground-muted font-neue-montreal-medium text-sm", children: "Include country code (e.g., +1 for US)" })] })), error && (0, jsx_runtime_1.jsx)("div", { className: "text-b3-negative font-neue-montreal-medium py-2 text-sm", children: error }), otpSent ? ((0, jsx_runtime_1.jsxs)("div", { className: "space-y-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "space-y-2", children: [(0, jsx_runtime_1.jsx)("label", { className: "text-b3-grey font-neue-montreal-medium text-sm", children: "Verification Code" }), (0, jsx_runtime_1.jsx)("input", { type: "text", placeholder: "Enter verification code", className: "bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2", value: otp, onChange: e => setOtp(e.target.value)
|
|
240
|
+
}, disabled: linkingMethod === method.id, children: isLinking && linkingMethod === method.id ? (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "animate-spin" }) : method.label }, method.id))), availableAuthMethods.length === 0 && ((0, jsx_runtime_1.jsx)("div", { className: "text-b3-foreground-muted py-8 text-center", children: "All available authentication methods have been connected" }))] })) : ((0, jsx_runtime_1.jsxs)("div", { className: "space-y-4", children: [selectedMethod === "email" && ((0, jsx_runtime_1.jsxs)("div", { className: "space-y-2", children: [(0, jsx_runtime_1.jsx)("label", { className: "text-b3-grey font-neue-montreal-medium text-sm", children: "Email Address" }), (0, jsx_runtime_1.jsx)("input", { type: "email", placeholder: "Enter your email", className: "bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2", value: email, onChange: e => setEmail(e.target.value), disabled: otpSent || (isLinking && linkingMethod === "email") })] })), selectedMethod === "phone" && ((0, jsx_runtime_1.jsxs)("div", { className: "space-y-2", children: [(0, jsx_runtime_1.jsx)("label", { className: "text-b3-grey font-neue-montreal-medium text-sm", children: "Phone Number" }), (0, jsx_runtime_1.jsx)("input", { type: "tel", placeholder: "Enter your phone number", className: "bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2", value: phone, onChange: e => setPhone(e.target.value), disabled: otpSent || (isLinking && linkingMethod === "phone") }), (0, jsx_runtime_1.jsx)("p", { className: "text-b3-foreground-muted font-neue-montreal-medium text-sm", children: "Include country code (e.g., +1 for US)" })] })), error && (0, jsx_runtime_1.jsx)("div", { className: "text-b3-negative font-neue-montreal-medium py-2 text-sm", children: error }), otpSent ? ((0, jsx_runtime_1.jsxs)("div", { className: "space-y-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "space-y-2", children: [(0, jsx_runtime_1.jsx)("label", { className: "text-b3-grey font-neue-montreal-medium text-sm", children: "Verification Code" }), (0, jsx_runtime_1.jsx)("input", { type: "text", placeholder: "Enter verification code", className: "bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2", value: otp, onChange: e => setOtp(e.target.value) })] }), (0, jsx_runtime_1.jsx)(button_1.Button, { className: "bg-b3-primary-blue hover:bg-b3-primary-blue/90 font-neue-montreal-semibold h-12 w-full text-white", onClick: handleLinkAccount, children: "Link Account" })] })) : ((0, jsx_runtime_1.jsx)(button_1.Button, { className: "bg-b3-primary-blue hover:bg-b3-primary-blue/90 font-neue-montreal-semibold h-12 w-full text-white", onClick: handleSendOTP, disabled: (!email && !phone) || (isLinking && linkingMethod === selectedMethod), children: isLinking && linkingMethod === selectedMethod ? ((0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "animate-spin" })) : ("Send Verification Code") }))] }))] }));
|
|
228
241
|
}
|
|
@@ -140,5 +140,5 @@ function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain
|
|
|
140
140
|
if (["balance", "assets", "apps", "settings"].includes(tab)) {
|
|
141
141
|
setActiveTab?.(tab);
|
|
142
142
|
}
|
|
143
|
-
}, children: [(0, jsx_runtime_1.jsxs)(react_1.TabsListPrimitive, { className: "font-neue-montreal-semibold text-b3-grey flex h-8 w-full items-start justify-start gap-8 border-0 text-xl md:p-4", children: [(0, jsx_runtime_1.jsx)(react_1.TabTriggerPrimitive, { value: "balance", className: "data-[state=active]:text-b3-primary-blue data-[state=active]:border-b-b3-primary-blue flex-none rounded-none border-0 p-0 pb-1 text-xl leading-none tracking-wide transition-colors data-[state=active]:border-b data-[state=active]:bg-white md:pb-4", children: "Overview" }), (0, jsx_runtime_1.jsx)(react_1.TabTriggerPrimitive, { value: "assets", className: "data-[state=active]:text-b3-primary-blue data-[state=active]:border-b-b3-primary-blue flex-none rounded-none border-0 p-0 pb-1 text-xl leading-none tracking-wide transition-colors data-[state=active]:border-b data-[state=active]:bg-white md:pb-4", children: "Mints" }), (0, jsx_runtime_1.jsx)(react_1.TabTriggerPrimitive, { value: "
|
|
143
|
+
}, children: [(0, jsx_runtime_1.jsxs)(react_1.TabsListPrimitive, { className: "font-neue-montreal-semibold text-b3-grey flex h-8 w-full items-start justify-start gap-8 border-0 text-xl md:p-4", children: [(0, jsx_runtime_1.jsx)(react_1.TabTriggerPrimitive, { value: "balance", className: "data-[state=active]:text-b3-primary-blue data-[state=active]:border-b-b3-primary-blue flex-none rounded-none border-0 p-0 pb-1 text-xl leading-none tracking-wide transition-colors data-[state=active]:border-b data-[state=active]:bg-white md:pb-4", children: "Overview" }), (0, jsx_runtime_1.jsx)(react_1.TabTriggerPrimitive, { value: "assets", className: "data-[state=active]:text-b3-primary-blue data-[state=active]:border-b-b3-primary-blue flex-none rounded-none border-0 p-0 pb-1 text-xl leading-none tracking-wide transition-colors data-[state=active]:border-b data-[state=active]:bg-white md:pb-4", children: "Mints" }), (0, jsx_runtime_1.jsx)(react_1.TabTriggerPrimitive, { value: "settings", className: "data-[state=active]:text-b3-primary-blue data-[state=active]:border-b-b3-primary-blue flex-none rounded-none border-0 p-0 pb-1 text-xl leading-none tracking-wide transition-colors data-[state=active]:border-b data-[state=active]:bg-white md:pb-4", children: "Settings" })] }), (0, jsx_runtime_1.jsx)(react_1.TabsContentPrimitive, { value: "balance", className: "pt-4 md:p-4", children: (0, jsx_runtime_1.jsx)(BalanceContent, {}) }), (0, jsx_runtime_1.jsx)(react_1.TabsContentPrimitive, { value: "assets", className: "pt-4 md:p-4", children: (0, jsx_runtime_1.jsx)(AssetsContent, {}) }), (0, jsx_runtime_1.jsx)(react_1.TabsContentPrimitive, { value: "apps", className: "pt-4 md:p-4", children: (0, jsx_runtime_1.jsx)(AppsContent, {}) }), (0, jsx_runtime_1.jsx)(react_1.TabsContentPrimitive, { value: "settings", className: "pt-4 md:p-4", children: (0, jsx_runtime_1.jsx)(SettingsContent, {}) })] }) }) }));
|
|
144
144
|
}
|
|
@@ -5,6 +5,7 @@ export interface UnifiedTransactionParams {
|
|
|
5
5
|
}
|
|
6
6
|
export declare function useUnifiedChainSwitchAndExecute(): {
|
|
7
7
|
switchChainAndExecute: (targetChainId: number, params: UnifiedTransactionParams) => Promise<string | undefined>;
|
|
8
|
+
switchChainAndExecuteWithEOA: (targetChainId: number, params: UnifiedTransactionParams) => Promise<string | undefined>;
|
|
8
9
|
isSwitchingOrExecuting: boolean;
|
|
9
10
|
isActiveSmartWallet: boolean | undefined;
|
|
10
11
|
isActiveEOAWallet: boolean | undefined;
|
|
@@ -164,6 +164,7 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
164
164
|
}, [isActiveSmartWallet, isActiveEOAWallet, handleAASendTransaction, handleEOASwitchChainAndSendTransaction]);
|
|
165
165
|
return {
|
|
166
166
|
switchChainAndExecute,
|
|
167
|
+
switchChainAndExecuteWithEOA: handleEOASwitchChainAndSendTransaction,
|
|
167
168
|
isSwitchingOrExecuting,
|
|
168
169
|
isActiveSmartWallet,
|
|
169
170
|
isActiveEOAWallet,
|
|
@@ -273,8 +273,8 @@ export interface AnySpendBondKitProps extends BaseModalProps {
|
|
|
273
273
|
imageUrl?: string;
|
|
274
274
|
/** Token name to display */
|
|
275
275
|
tokenName?: string;
|
|
276
|
-
/** Optional pre-filled
|
|
277
|
-
|
|
276
|
+
/** Optional pre-filled B3 amount */
|
|
277
|
+
b3Amount?: string;
|
|
278
278
|
/** Callback function called when purchase is successful */
|
|
279
279
|
onSuccess?: (txHash?: string) => void;
|
|
280
280
|
}
|
|
@@ -300,6 +300,8 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
|
|
|
300
300
|
paymentType?: "crypto" | "fiat";
|
|
301
301
|
/** Deposit contract address */
|
|
302
302
|
depositContractAddress: string;
|
|
303
|
+
/** Main footer */
|
|
304
|
+
mainFooter?: React.ReactNode;
|
|
303
305
|
/** Callback function called when the deposit is successful */
|
|
304
306
|
onSuccess?: () => void;
|
|
305
307
|
}
|
|
@@ -88,9 +88,9 @@ export declare const getViemChainConfig: (config: ChainNetworks) => {
|
|
|
88
88
|
readonly rpc: string;
|
|
89
89
|
readonly icon: {
|
|
90
90
|
format: string;
|
|
91
|
-
url: string;
|
|
92
|
-
width: number;
|
|
93
91
|
height: number;
|
|
92
|
+
width: number;
|
|
93
|
+
url: string;
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
96
|
export declare const thirdwebB3Testnet: ThirdwebChain;
|
|
@@ -10,9 +10,9 @@ export declare const supportedChainNetworks: {
|
|
|
10
10
|
testnet?: boolean | undefined;
|
|
11
11
|
fees?: Record<string, any> | undefined;
|
|
12
12
|
formatters?: Record<string, any> | undefined;
|
|
13
|
+
color?: string | undefined;
|
|
13
14
|
testnetConfigID?: number | undefined;
|
|
14
15
|
badge?: string | undefined;
|
|
15
|
-
color?: string | undefined;
|
|
16
16
|
enabledFeatures?: string[] | undefined;
|
|
17
17
|
blockExplorers: {
|
|
18
18
|
default: string;
|
|
@@ -35,13 +35,13 @@ export declare const supportedChainNetworks: {
|
|
|
35
35
|
uri: string;
|
|
36
36
|
}[];
|
|
37
37
|
};
|
|
38
|
-
_id: string | {};
|
|
39
38
|
icon: {
|
|
40
39
|
format: string;
|
|
41
|
-
url: string;
|
|
42
|
-
width: number;
|
|
43
40
|
height: number;
|
|
41
|
+
width: number;
|
|
42
|
+
url: string;
|
|
44
43
|
};
|
|
44
|
+
_id: string | {};
|
|
45
45
|
}[];
|
|
46
46
|
export declare const coingeckoChains: Record<number, {
|
|
47
47
|
coingecko_id: string;
|
|
@@ -650,7 +650,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
650
650
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
651
651
|
}, [activePanel]);
|
|
652
652
|
const historyView = (_jsx("div", { className: "mx-auto flex w-[560px] max-w-full flex-col items-center", children: _jsx(OrderHistory, { mode: mode, onBack: () => setActivePanel(PanelView.MAIN), onSelectOrder: onSelectOrder }) }));
|
|
653
|
-
const orderDetailsView = (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: oat.data.order }), _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: () => {
|
|
653
|
+
const orderDetailsView = (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: oat.data.order, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod }), _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: () => {
|
|
654
654
|
setOrderId(undefined);
|
|
655
655
|
setActivePanel(PanelView.MAIN);
|
|
656
656
|
setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE); // Reset payment method when going back
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnySpendBondKitProps } from "../../../global-account/react/stores/useModalStore";
|
|
2
|
-
export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl,
|
|
2
|
+
export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, b3Amount: initialB3Amount, onSuccess, }: AnySpendBondKitProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { BondkitToken } from "../../../bondkit/index.js";
|
|
3
2
|
import { Button, GlareCardRounded, Input, StyleRoot, useHasMounted, useTokenData, } from "../../../global-account/react/index.js";
|
|
4
3
|
import { baseMainnet } from "../../../shared/constants/chains/supported.js";
|
|
5
4
|
import { motion } from "motion/react";
|
|
6
5
|
import { useEffect, useMemo, useState } from "react";
|
|
7
6
|
import { createPublicClient, encodeFunctionData, formatEther, http, parseEther } from "viem";
|
|
8
|
-
import {
|
|
7
|
+
import { BondkitToken, BondkitTokenABI } from "../../../bondkit/index.js";
|
|
9
8
|
import { AnySpendCustom } from "./AnySpendCustom.js";
|
|
10
9
|
// Debounce utility function
|
|
11
10
|
function debounce(func, wait) {
|
|
@@ -21,11 +20,11 @@ function formatNumberWithCommas(x) {
|
|
|
21
20
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
22
21
|
return parts.join(".");
|
|
23
22
|
}
|
|
24
|
-
export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl,
|
|
23
|
+
export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, b3Amount: initialB3Amount, onSuccess, }) {
|
|
25
24
|
const hasMounted = useHasMounted();
|
|
26
|
-
const [showAmountPrompt, setShowAmountPrompt] = useState(!
|
|
27
|
-
const [
|
|
28
|
-
const [isAmountValid, setIsAmountValid] = useState(!!
|
|
25
|
+
const [showAmountPrompt, setShowAmountPrompt] = useState(!initialB3Amount);
|
|
26
|
+
const [b3Amount, setB3Amount] = useState(initialB3Amount || "");
|
|
27
|
+
const [isAmountValid, setIsAmountValid] = useState(!!initialB3Amount);
|
|
29
28
|
const [validationError, setValidationError] = useState("");
|
|
30
29
|
const [tokenName, setTokenName] = useState("");
|
|
31
30
|
const [tokenSymbol, setTokenSymbol] = useState("");
|
|
@@ -57,12 +56,12 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
57
56
|
const [name, symbol] = await Promise.all([
|
|
58
57
|
basePublicClient.readContract({
|
|
59
58
|
address: contractAddress,
|
|
60
|
-
abi:
|
|
59
|
+
abi: BondkitTokenABI,
|
|
61
60
|
functionName: "name",
|
|
62
61
|
}),
|
|
63
62
|
basePublicClient.readContract({
|
|
64
63
|
address: contractAddress,
|
|
65
|
-
abi:
|
|
64
|
+
abi: BondkitTokenABI,
|
|
66
65
|
functionName: "symbol",
|
|
67
66
|
}),
|
|
68
67
|
]);
|
|
@@ -79,8 +78,8 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
79
78
|
fetchTokenName();
|
|
80
79
|
}
|
|
81
80
|
}, [contractAddress, basePublicClient]);
|
|
82
|
-
// Get
|
|
83
|
-
const { data: tokenData, isError: isTokenError, isLoading, } = useTokenData(baseMainnet.id, "
|
|
81
|
+
// Get b3 token data
|
|
82
|
+
const { data: tokenData, isError: isTokenError, isLoading, } = useTokenData(baseMainnet.id, "0xB3B32F9f8827D4634fE7d973Fa1034Ec9fdDB3B3");
|
|
84
83
|
// Convert token data to AnySpend Token type
|
|
85
84
|
const dstToken = useMemo(() => {
|
|
86
85
|
if (!tokenData)
|
|
@@ -116,16 +115,16 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
116
115
|
setIsLoadingQuote(false);
|
|
117
116
|
}
|
|
118
117
|
}, 500), [bondkitTokenClient]);
|
|
119
|
-
// Fetch initial quote if
|
|
118
|
+
// Fetch initial quote if b3Amount is provided
|
|
120
119
|
useEffect(() => {
|
|
121
|
-
if (
|
|
122
|
-
debouncedGetQuote(
|
|
120
|
+
if (initialB3Amount && bondkitTokenClient) {
|
|
121
|
+
debouncedGetQuote(initialB3Amount);
|
|
123
122
|
}
|
|
124
|
-
}, [
|
|
123
|
+
}, [initialB3Amount, bondkitTokenClient, debouncedGetQuote]);
|
|
125
124
|
const validateAndSetAmount = (value) => {
|
|
126
125
|
// Allow empty input
|
|
127
126
|
if (value === "") {
|
|
128
|
-
|
|
127
|
+
setB3Amount("");
|
|
129
128
|
setIsAmountValid(false);
|
|
130
129
|
setValidationError("");
|
|
131
130
|
setQuote(null);
|
|
@@ -141,14 +140,14 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
141
140
|
if ((value.match(/\./g) || []).length > 1) {
|
|
142
141
|
return;
|
|
143
142
|
}
|
|
144
|
-
// Prevent more than 18 decimal places (
|
|
143
|
+
// Prevent more than 18 decimal places (B3 precision)
|
|
145
144
|
const parts = value.split(".");
|
|
146
145
|
if (parts[1] && parts[1].length > 18) {
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
149
148
|
// Clean the input - remove leading zeros if not decimal
|
|
150
149
|
const cleanedValue = value.startsWith("0") && !value.startsWith("0.") ? value.replace(/^0+/, "0") : value;
|
|
151
|
-
|
|
150
|
+
setB3Amount(cleanedValue);
|
|
152
151
|
try {
|
|
153
152
|
const parsedAmount = parseEther(cleanedValue);
|
|
154
153
|
if (parsedAmount <= BigInt(0)) {
|
|
@@ -166,7 +165,7 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
166
165
|
setValidationError("Please enter a valid amount");
|
|
167
166
|
}
|
|
168
167
|
};
|
|
169
|
-
const header = () => (_jsx("div", { className: "bg-as-surface-primary w-full px-6 py-4", children: _jsxs("div", { className: "flex w-full flex-col items-center space-y-6", children: [_jsxs("h2", { className: "text-[28px] font-bold", children: ["Buy ", tokenName, " (", tokenSymbol, ")"] }), _jsxs("div", { className: "flex w-full flex-col items-center space-y-2", children: [_jsxs("span", { className: "text-[28px] font-bold", children: [
|
|
168
|
+
const header = () => (_jsx("div", { className: "bg-as-surface-primary w-full px-6 py-4", children: _jsxs("div", { className: "flex w-full flex-col items-center space-y-6", children: [_jsxs("h2", { className: "text-[28px] font-bold", children: ["Buy ", tokenName, " (", tokenSymbol, ")"] }), _jsxs("div", { className: "flex w-full flex-col items-center space-y-2", children: [_jsxs("span", { className: "text-[28px] font-bold", children: [b3Amount, " B3"] }), quote && (_jsxs("span", { className: "text-lg", children: ["\u2248 ", formatNumberWithCommas(parseFloat(quote).toFixed(4)), " ", tokenSymbol] }))] })] }) }));
|
|
170
169
|
// Show loading state while fetching token data
|
|
171
170
|
if (isLoading) {
|
|
172
171
|
return (_jsx(StyleRoot, { children: _jsx("div", { className: "b3-root b3-modal bg-b3-react-background flex w-full flex-col items-center p-8", children: _jsx("p", { className: "text-as-primary/70 text-center text-sm", children: "Loading payment information..." }) }) }));
|
|
@@ -188,18 +187,18 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
188
187
|
opacity: hasMounted ? 1 : 0,
|
|
189
188
|
y: hasMounted ? 0 : 20,
|
|
190
189
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
191
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: _jsxs("div", { className: "space-y-4", children: [_jsx("div", { className: "flex items-center justify-between", children: _jsx("p", { className: "text-as-primary/70 text-sm font-medium", children: "
|
|
192
|
-
if (isAmountValid &&
|
|
190
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: _jsxs("div", { className: "space-y-4", children: [_jsx("div", { className: "flex items-center justify-between", children: _jsx("p", { className: "text-as-primary/70 text-sm font-medium", children: "B3 Amount" }) }), _jsx("div", { className: "relative", children: _jsx(Input, { type: "text", inputMode: "decimal", placeholder: "0.1", value: b3Amount, onChange: e => validateAndSetAmount(e.target.value), className: `h-14 px-4 text-lg ${!isAmountValid && b3Amount ? "border-as-red" : "border-b3-react-border"}` }) }), !isAmountValid && b3Amount && _jsx("p", { className: "text-as-red text-sm", children: validationError }), _jsxs("div", { className: "bg-as-on-surface-2/30 rounded-lg border border-white/10 p-4 backdrop-blur-sm", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-as-primary/70 text-sm font-medium", children: "Total Cost:" }), _jsx("div", { className: "flex items-center gap-2", children: _jsxs("span", { className: "text-as-primary text-lg font-bold", children: [b3Amount || "0", " B3"] }) })] }), isLoadingQuote ? (_jsx("div", { className: "mt-2 text-center", children: _jsx("span", { className: "text-as-primary/70 text-sm", children: "Calculating tokens..." }) })) : quote ? (_jsxs("div", { className: "mt-2 flex items-center justify-between", children: [_jsx("span", { className: "text-as-primary/70 text-sm font-medium", children: "You'll receive:" }), _jsxs("span", { className: "text-as-primary text-sm font-medium", children: ["\u2248 ", formatNumberWithCommas(parseFloat(quote).toFixed(4)), " ", tokenSymbol] })] })) : null] }), _jsx(Button, { onClick: () => {
|
|
191
|
+
if (isAmountValid && b3Amount) {
|
|
193
192
|
setShowAmountPrompt(false);
|
|
194
193
|
}
|
|
195
|
-
}, disabled: !isAmountValid || !
|
|
194
|
+
}, disabled: !isAmountValid || !b3Amount || isLoadingQuote, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary mt-4 h-14 w-full rounded-xl text-lg font-medium", children: "Continue" })] }) })] }) }));
|
|
196
195
|
}
|
|
197
196
|
const encodedData = encodeFunctionData({
|
|
198
|
-
abi:
|
|
197
|
+
abi: BondkitTokenABI,
|
|
199
198
|
functionName: "buyFor",
|
|
200
|
-
args: [recipientAddress, BigInt(minTokensOut)],
|
|
199
|
+
args: [recipientAddress, parseEther(b3Amount), BigInt(minTokensOut)],
|
|
201
200
|
});
|
|
202
|
-
return (_jsx(AnySpendCustom, { mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: baseMainnet.id, dstToken: dstToken, dstAmount: parseEther(
|
|
201
|
+
return (_jsx(AnySpendCustom, { mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: baseMainnet.id, dstToken: dstToken, dstAmount: parseEther(b3Amount).toString(), contractAddress: contractAddress, encodedData: encodedData, metadata: {
|
|
203
202
|
type: "custom",
|
|
204
203
|
action: "BondKit Buy",
|
|
205
204
|
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
@@ -413,7 +413,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
413
413
|
const historyView = (_jsx("div", { className: cn("mx-auto flex w-full max-w-2xl flex-col items-center p-5", mode === "modal" && "bg-b3-react-background"), children: _jsx(OrderHistory, { mode: mode, onBack: () => {
|
|
414
414
|
setActivePanel(PanelView.HISTORY);
|
|
415
415
|
}, onSelectOrder: onSelectOrder }) }));
|
|
416
|
-
const orderDetailsView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatusDisplay, { order: oat.data.order }), _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: activeTab === "fiat" ? CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, onBack: () => {
|
|
416
|
+
const orderDetailsView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatusDisplay, { order: oat.data.order, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod }), _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: activeTab === "fiat" ? CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, onBack: () => {
|
|
417
417
|
setOrderId(undefined);
|
|
418
418
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
419
419
|
// Remove orderId from URL when canceling
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface AnySpendDepositHypeProps {
|
|
2
2
|
loadOrder?: string;
|
|
3
3
|
mode?: "modal" | "page";
|
|
4
4
|
recipientAddress: string;
|
|
@@ -7,4 +7,6 @@ export declare function AnySpendDepositHype(props: {
|
|
|
7
7
|
sourceTokenChainId?: number;
|
|
8
8
|
onSuccess?: () => void;
|
|
9
9
|
depositContractAddress?: string;
|
|
10
|
-
|
|
10
|
+
mainFooter?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import { B3_TOKEN } from "../../../anyspend/index.js";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { B3_TOKEN, DEPOSIT_HYPE_ACTION } from "../../../anyspend/index.js";
|
|
3
3
|
import { Button, ShinyButton, StyleRoot, TransitionPanel } from "../../../global-account/react/index.js";
|
|
4
4
|
import { cn } from "../../../shared/utils/cn.js";
|
|
5
5
|
import invariant from "invariant";
|
|
@@ -21,6 +21,7 @@ import { RecipientSelection } from "./common/RecipientSelection.js";
|
|
|
21
21
|
import { ESCROW_ABI } from "../../../anyspend/abis/escrow.js";
|
|
22
22
|
import { ArrowDown } from "lucide-react";
|
|
23
23
|
import { PanelOnramp } from "./common/PanelOnramp.js";
|
|
24
|
+
const SLIPPAGE_PERCENT = 3;
|
|
24
25
|
function generateEncodedDataForDepositHype(amount, beneficiary) {
|
|
25
26
|
invariant(BigInt(amount) > 0, "Amount must be greater than zero");
|
|
26
27
|
const encodedData = encodeFunctionData({
|
|
@@ -34,9 +35,9 @@ export function AnySpendDepositHype(props) {
|
|
|
34
35
|
const fingerprintConfig = getFingerprintConfig();
|
|
35
36
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendDepositHypeInner, { ...props }) }));
|
|
36
37
|
}
|
|
37
|
-
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, depositContractAddress, }) {
|
|
38
|
+
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, depositContractAddress, mainFooter, }) {
|
|
38
39
|
// Use shared flow hook
|
|
39
|
-
const { activePanel, setActivePanel, orderId, oat, selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, dstAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod, selectedFiatPaymentMethod, setSelectedFiatPaymentMethod, selectedRecipientAddress, setSelectedRecipientAddress, recipientName, globalAddress, anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError, activeInputAmountInWei, geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support, createOrder, isCreatingOrder, createOnrampOrder, isCreatingOnrampOrder, } = useAnyspendFlow({
|
|
40
|
+
const { activePanel, setActivePanel, orderId, setOrderId, oat, selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, dstAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod, selectedFiatPaymentMethod, setSelectedFiatPaymentMethod, selectedRecipientAddress, setSelectedRecipientAddress, recipientName, globalAddress, anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError, activeInputAmountInWei, geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support, createOrder, isCreatingOrder, createOnrampOrder, isCreatingOnrampOrder, } = useAnyspendFlow({
|
|
40
41
|
paymentType,
|
|
41
42
|
recipientAddress,
|
|
42
43
|
loadOrder,
|
|
@@ -44,6 +45,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
44
45
|
onTransactionSuccess: onSuccess,
|
|
45
46
|
sourceTokenAddress,
|
|
46
47
|
sourceTokenChainId,
|
|
48
|
+
slippage: SLIPPAGE_PERCENT,
|
|
47
49
|
});
|
|
48
50
|
// Button state logic
|
|
49
51
|
const btnInfo = useMemo(() => {
|
|
@@ -116,6 +118,10 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
116
118
|
await handleFiatOrder();
|
|
117
119
|
}
|
|
118
120
|
};
|
|
121
|
+
const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [_jsx("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: _jsx("div", { children: _jsx("h1", { className: "text-as-primary text-xl font-bold", children: paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat" }) }) }), _jsx("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "crypto" ? (_jsx(PaySection, { paymentType: "crypto", selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, selectedFiatPaymentMethod: selectedFiatPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), onSelectFiatPaymentMethod: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : (_jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmount, setSrcAmountOnRamp: setSrcAmount, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: B3_TOKEN, destinationChainId: base.id, destinationAmount: dstAmount, onDestinationTokenChange: () => { }, onDestinationChainChange: () => { }, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD }) })), _jsx("div", { className: cn("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: _jsx(Button, { variant: "ghost", className: cn("swap-direction-button border-as-stroke bg-as-surface-primary z-10 h-10 w-10 cursor-default rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl"), children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }) }), paymentType === "crypto" && (_jsx(CryptoReceiveSection, { isDepositMode: false, isBuyMode: true, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(PanelView.RECIPIENT_SELECTION), dstAmount: dstAmount, dstToken: B3_TOKEN, selectedDstChainId: base.id, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, onChangeDstAmount: value => {
|
|
122
|
+
setIsSrcInputDirty(false);
|
|
123
|
+
setSrcAmount(value);
|
|
124
|
+
}, anyspendQuote: anyspendQuote }))] }) }), _jsx(ErrorSection, { error: getAnyspendQuoteError }), _jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: cn("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: btnInfo.text }) }), mainFooter ? mainFooter : null] }));
|
|
119
125
|
// Handle crypto order creation
|
|
120
126
|
const handleCryptoOrder = async () => {
|
|
121
127
|
try {
|
|
@@ -123,7 +129,10 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
123
129
|
invariant(selectedRecipientAddress, "Recipient address is not found");
|
|
124
130
|
invariant(depositContractAddress, "Deposit contract address is not found");
|
|
125
131
|
const srcAmountBigInt = BigInt(activeInputAmountInWei);
|
|
126
|
-
|
|
132
|
+
// TODO: temp subtract 3% for slippage
|
|
133
|
+
const originalDepositAmountWei = anyspendQuote.data?.currencyOut?.amount || "0";
|
|
134
|
+
const depositAmountWei = ((BigInt(originalDepositAmountWei) * BigInt(100 - SLIPPAGE_PERCENT)) /
|
|
135
|
+
BigInt(100)).toString();
|
|
127
136
|
const encodedData = generateEncodedDataForDepositHype(depositAmountWei, selectedRecipientAddress);
|
|
128
137
|
createOrder({
|
|
129
138
|
recipientAddress: selectedRecipientAddress,
|
|
@@ -138,7 +147,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
138
147
|
amount: depositAmountWei,
|
|
139
148
|
data: encodedData,
|
|
140
149
|
to: depositContractAddress,
|
|
141
|
-
action:
|
|
150
|
+
action: DEPOSIT_HYPE_ACTION,
|
|
142
151
|
},
|
|
143
152
|
});
|
|
144
153
|
}
|
|
@@ -200,7 +209,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
200
209
|
amount: depositAmountWei,
|
|
201
210
|
data: encodedData,
|
|
202
211
|
to: depositContractAddress,
|
|
203
|
-
action:
|
|
212
|
+
action: DEPOSIT_HYPE_ACTION,
|
|
204
213
|
},
|
|
205
214
|
});
|
|
206
215
|
}
|
|
@@ -210,7 +219,8 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
210
219
|
}
|
|
211
220
|
};
|
|
212
221
|
// Order details view
|
|
213
|
-
const orderDetailsView = (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: oat.data.order }), _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: paymentType === "fiat" ? CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, onBack: () => {
|
|
222
|
+
const orderDetailsView = (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: oat.data.order, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod }), _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: paymentType === "fiat" ? CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, onBack: () => {
|
|
223
|
+
setOrderId(undefined);
|
|
214
224
|
setActivePanel(PanelView.MAIN);
|
|
215
225
|
onSuccess?.();
|
|
216
226
|
} })] })) }) }));
|
|
@@ -244,10 +254,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
244
254
|
center: { x: 0, opacity: 1 },
|
|
245
255
|
exit: { x: -300, opacity: 0 },
|
|
246
256
|
}, transition: { type: "spring", stiffness: 300, damping: 30 }, children: [
|
|
247
|
-
_jsx("div", { className: cn(mode === "page" && "p-6"), children:
|
|
248
|
-
setIsSrcInputDirty(false);
|
|
249
|
-
setSrcAmount(value);
|
|
250
|
-
}, anyspendQuote: anyspendQuote }))] }) }), _jsx(ErrorSection, { error: getAnyspendQuoteError }), _jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: cn("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: btnInfo.text }) })] }) }, "main-view"),
|
|
257
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: mainView }, "main-view"),
|
|
251
258
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
252
259
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
253
260
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: recipientSelectionView }, "recipient-selection-view"),
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { RELAY_SOLANA_MAINNET_CHAIN_ID } from "../../../../anyspend/index.js";
|
|
4
4
|
import { ShinyButton, useProfile } from "../../../../global-account/react/index.js";
|
|
5
|
+
import centerTruncate from "../../../../shared/utils/centerTruncate.js";
|
|
5
6
|
import { formatTokenAmount } from "../../../../shared/utils/number.js";
|
|
6
7
|
import { motion } from "framer-motion";
|
|
7
8
|
import { ChevronRight, Loader2 } from "lucide-react";
|
|
9
|
+
import { useAccount } from "wagmi";
|
|
8
10
|
import { OrderDetailsCollapsible } from "./OrderDetailsCollapsible.js";
|
|
9
11
|
export default function ConnectWalletPayment({ order, onPayment, txLoading, isSwitchingOrExecuting, phantomWalletAddress, tournament, nft, }) {
|
|
10
12
|
const profile = useProfile({ address: order.recipientAddress });
|
|
11
13
|
const recipientName = profile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
14
|
+
const { address: connectedAddress } = useAccount();
|
|
12
15
|
const srcToken = order.metadata.srcToken;
|
|
13
16
|
const dstToken = order.metadata.dstToken;
|
|
14
17
|
const expectedDstAmount = order.type === "mint_nft" ||
|
|
@@ -23,5 +26,7 @@ export default function ConnectWalletPayment({ order, onPayment, txLoading, isSw
|
|
|
23
26
|
}
|
|
24
27
|
return (_jsx("div", { className: "flex w-full flex-col items-center gap-6", children: _jsxs(motion.div, { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, transition: { delay: 0.5 }, className: "flex w-full flex-col items-center gap-2", children: [_jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "flex w-5/6 max-w-[400px] items-center gap-2 sm:px-0", disabled: txLoading || isSwitchingOrExecuting, onClick: onPayment, children: txLoading ? (_jsxs(_Fragment, { children: ["Transaction Pending", _jsx(Loader2, { className: "ml-2 h-5 w-5 animate-spin" })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "whitespace-nowrap pl-4 text-lg md:text-sm", children: order.srcChain === RELAY_SOLANA_MAINNET_CHAIN_ID && phantomWalletAddress
|
|
25
28
|
? "Pay from Phantom Wallet"
|
|
26
|
-
: "Pay from Connected Wallet" }), _jsx(ChevronRight, { className: "h-4 w-4" })] })) }),
|
|
29
|
+
: "Pay from Connected Wallet" }), _jsx(ChevronRight, { className: "h-4 w-4" })] })) }), _jsxs("span", { className: "label-style text-as-primary/50 text-xs", children: ["Connected to:", " ", order.srcChain === RELAY_SOLANA_MAINNET_CHAIN_ID && phantomWalletAddress
|
|
30
|
+
? centerTruncate(phantomWalletAddress, 6)
|
|
31
|
+
: centerTruncate(connectedAddress || "")] }), _jsx("div", { className: "mt-4", children: _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount }) })] }) }));
|
|
27
32
|
}
|