@b3dotfun/sdk 0.0.34 → 0.0.35-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.js +5 -3
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -2
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +16 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +58 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +22 -15
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +12 -4
- package/dist/cjs/anyspend/react/components/common/PaySection.d.ts +2 -6
- package/dist/cjs/anyspend/react/components/common/PaySection.js +10 -15
- package/dist/cjs/anyspend/react/components/index.d.ts +2 -2
- package/dist/cjs/anyspend/react/components/index.js +5 -5
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +6 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +3 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +20 -0
- package/dist/cjs/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/cjs/global-account/react/stores/useAuthStore.js +4 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +5 -3
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +5 -2
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +16 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +55 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +1 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +22 -15
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +12 -4
- package/dist/esm/anyspend/react/components/common/PaySection.d.ts +2 -6
- package/dist/esm/anyspend/react/components/common/PaySection.js +10 -15
- package/dist/esm/anyspend/react/components/index.d.ts +2 -2
- package/dist/esm/anyspend/react/components/index.js +2 -2
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +6 -3
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +3 -3
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.js +21 -1
- package/dist/esm/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/esm/global-account/react/stores/useAuthStore.js +4 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/common/ConnectWalletPayment.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +16 -0
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +1 -0
- package/dist/types/anyspend/react/components/common/PaySection.d.ts +2 -6
- package/dist/types/anyspend/react/components/index.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -0
- package/dist/types/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +2 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +7 -6
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +2 -5
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +6 -1
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +153 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +80 -43
- package/src/anyspend/react/components/common/OrderDetails.tsx +13 -4
- package/src/anyspend/react/components/common/PaySection.tsx +64 -140
- package/src/anyspend/react/components/index.ts +2 -2
- package/src/global-account/react/components/B3DynamicModal.tsx +1 -6
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +92 -82
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +3 -3
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +3 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +5 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +3 -0
- package/src/global-account/react/hooks/useAuthentication.ts +24 -1
- package/src/global-account/react/stores/useAuthStore.ts +8 -0
- package/src/global-account/react/stores/useModalStore.ts +2 -0
- package/src/styles/index.css +5 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useProfile, useTokenData } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { formatUsername } from "@b3dotfun/sdk/shared/utils";
|
|
3
3
|
import { shortenAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
|
|
4
4
|
import { formatDisplayNumber } from "@b3dotfun/sdk/shared/utils/number";
|
|
@@ -8,12 +8,10 @@ import { useEffect, useRef } from "react";
|
|
|
8
8
|
import { useAccount } from "wagmi";
|
|
9
9
|
import { components } from "../../../types/api";
|
|
10
10
|
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
11
|
-
import { FiatPaymentMethod } from "./FiatPaymentMethod";
|
|
12
11
|
import { OrderTokenAmount } from "./OrderTokenAmount";
|
|
13
12
|
import { TokenBalance } from "./TokenBalance";
|
|
14
13
|
|
|
15
|
-
interface
|
|
16
|
-
paymentType: "crypto" | "fiat";
|
|
14
|
+
interface CryptoPaySectionProps {
|
|
17
15
|
// Token state
|
|
18
16
|
selectedSrcChainId: number;
|
|
19
17
|
setSelectedSrcChainId: (chainId: number) => void;
|
|
@@ -24,15 +22,12 @@ interface PaySectionProps {
|
|
|
24
22
|
setIsSrcInputDirty: (dirty: boolean) => void;
|
|
25
23
|
// Payment method state
|
|
26
24
|
selectedCryptoPaymentMethod: CryptoPaymentMethodType;
|
|
27
|
-
selectedFiatPaymentMethod: FiatPaymentMethod;
|
|
28
25
|
onSelectCryptoPaymentMethod: () => void;
|
|
29
|
-
onSelectFiatPaymentMethod: () => void;
|
|
30
26
|
// Quote data
|
|
31
27
|
anyspendQuote?: any;
|
|
32
28
|
}
|
|
33
29
|
|
|
34
|
-
export function
|
|
35
|
-
paymentType,
|
|
30
|
+
export function CryptoPaySection({
|
|
36
31
|
selectedSrcChainId,
|
|
37
32
|
setSelectedSrcChainId,
|
|
38
33
|
selectedSrcToken,
|
|
@@ -41,11 +36,9 @@ export function PaySection({
|
|
|
41
36
|
setSrcAmount,
|
|
42
37
|
setIsSrcInputDirty,
|
|
43
38
|
selectedCryptoPaymentMethod,
|
|
44
|
-
selectedFiatPaymentMethod,
|
|
45
39
|
onSelectCryptoPaymentMethod,
|
|
46
|
-
onSelectFiatPaymentMethod,
|
|
47
40
|
anyspendQuote,
|
|
48
|
-
}:
|
|
41
|
+
}: CryptoPaySectionProps) {
|
|
49
42
|
const { address: connectedAddress, isConnected } = useAccount();
|
|
50
43
|
const { data: profileData } = useProfile({ address: connectedAddress });
|
|
51
44
|
const connectedName = profileData?.displayName;
|
|
@@ -88,137 +81,68 @@ export function PaySection({
|
|
|
88
81
|
>
|
|
89
82
|
<div className="flex items-center justify-between">
|
|
90
83
|
<div className="text-as-primary/50 flex h-7 items-center text-sm">Pay</div>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
{connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "")}
|
|
101
|
-
</div>
|
|
102
|
-
) : (
|
|
103
|
-
"Connect wallet"
|
|
104
|
-
)}
|
|
105
|
-
<ChevronRight className="h-4 w-4" />
|
|
106
|
-
</>
|
|
107
|
-
) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (
|
|
108
|
-
<>
|
|
109
|
-
Transfer crypto
|
|
110
|
-
<ChevronRight className="h-4 w-4" />
|
|
111
|
-
</>
|
|
112
|
-
) : (
|
|
113
|
-
<>
|
|
114
|
-
Select payment method
|
|
115
|
-
<ChevronRight className="h-4 w-4" />
|
|
116
|
-
</>
|
|
117
|
-
)}
|
|
118
|
-
</button>
|
|
119
|
-
) : (
|
|
120
|
-
<button
|
|
121
|
-
className="text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors"
|
|
122
|
-
onClick={onSelectFiatPaymentMethod}
|
|
123
|
-
>
|
|
124
|
-
{selectedFiatPaymentMethod === FiatPaymentMethod.COINBASE_PAY ? (
|
|
125
|
-
<>
|
|
126
|
-
<div className="flex items-center gap-2">
|
|
127
|
-
<div className="flex h-5 w-5 items-center justify-center rounded-full bg-blue-600">
|
|
128
|
-
<span className="text-xs font-bold text-white">C</span>
|
|
129
|
-
</div>
|
|
130
|
-
Coinbase Pay
|
|
84
|
+
<button
|
|
85
|
+
className="text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none"
|
|
86
|
+
onClick={onSelectCryptoPaymentMethod}
|
|
87
|
+
>
|
|
88
|
+
{selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (
|
|
89
|
+
<>
|
|
90
|
+
{isConnected ? (
|
|
91
|
+
<div className="flex items-center gap-1">
|
|
92
|
+
{connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "")}
|
|
131
93
|
</div>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
94
|
+
) : (
|
|
95
|
+
"Connect wallet"
|
|
96
|
+
)}
|
|
97
|
+
<ChevronRight className="h-4 w-4" />
|
|
98
|
+
</>
|
|
99
|
+
) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET ? (
|
|
100
|
+
<>
|
|
101
|
+
Global Account
|
|
102
|
+
<ChevronRight className="h-4 w-4" />
|
|
103
|
+
</>
|
|
104
|
+
) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (
|
|
105
|
+
<>
|
|
106
|
+
Transfer crypto
|
|
107
|
+
<ChevronRight className="h-4 w-4" />
|
|
108
|
+
</>
|
|
109
|
+
) : (
|
|
110
|
+
<>
|
|
111
|
+
Select payment method
|
|
112
|
+
<ChevronRight className="h-4 w-4" />
|
|
113
|
+
</>
|
|
114
|
+
)}
|
|
115
|
+
</button>
|
|
116
|
+
</div>
|
|
117
|
+
<OrderTokenAmount
|
|
118
|
+
address={connectedAddress}
|
|
119
|
+
context="from"
|
|
120
|
+
inputValue={srcAmount}
|
|
121
|
+
onChangeInput={value => {
|
|
122
|
+
setIsSrcInputDirty(true);
|
|
123
|
+
setSrcAmount(value);
|
|
124
|
+
}}
|
|
125
|
+
chainId={selectedSrcChainId}
|
|
126
|
+
setChainId={setSelectedSrcChainId}
|
|
127
|
+
token={selectedSrcToken}
|
|
128
|
+
setToken={setSelectedSrcToken}
|
|
129
|
+
/>
|
|
130
|
+
<div className="flex items-center justify-between">
|
|
131
|
+
<div className="text-as-primary/50 flex h-5 items-center text-sm">
|
|
132
|
+
{formatDisplayNumber(anyspendQuote?.data?.currencyIn?.amountUsd, {
|
|
133
|
+
style: "currency",
|
|
134
|
+
fallback: "",
|
|
135
|
+
})}
|
|
136
|
+
</div>
|
|
137
|
+
<TokenBalance
|
|
138
|
+
token={selectedSrcToken}
|
|
139
|
+
walletAddress={connectedAddress}
|
|
140
|
+
onChangeInput={value => {
|
|
141
|
+
setIsSrcInputDirty(true);
|
|
142
|
+
setSrcAmount(value);
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
152
145
|
</div>
|
|
153
|
-
{paymentType === "crypto" ? (
|
|
154
|
-
<>
|
|
155
|
-
<OrderTokenAmount
|
|
156
|
-
address={connectedAddress}
|
|
157
|
-
context="from"
|
|
158
|
-
inputValue={srcAmount}
|
|
159
|
-
onChangeInput={value => {
|
|
160
|
-
setIsSrcInputDirty(true);
|
|
161
|
-
setSrcAmount(value);
|
|
162
|
-
}}
|
|
163
|
-
chainId={selectedSrcChainId}
|
|
164
|
-
setChainId={setSelectedSrcChainId}
|
|
165
|
-
token={selectedSrcToken}
|
|
166
|
-
setToken={setSelectedSrcToken}
|
|
167
|
-
/>
|
|
168
|
-
<div className="flex items-center justify-between">
|
|
169
|
-
<div className="text-as-primary/50 flex h-5 items-center text-sm">
|
|
170
|
-
{formatDisplayNumber(anyspendQuote?.data?.currencyIn?.amountUsd, {
|
|
171
|
-
style: "currency",
|
|
172
|
-
fallback: "",
|
|
173
|
-
})}
|
|
174
|
-
</div>
|
|
175
|
-
<TokenBalance
|
|
176
|
-
token={selectedSrcToken}
|
|
177
|
-
walletAddress={connectedAddress}
|
|
178
|
-
onChangeInput={value => {
|
|
179
|
-
setIsSrcInputDirty(true);
|
|
180
|
-
setSrcAmount(value);
|
|
181
|
-
}}
|
|
182
|
-
/>
|
|
183
|
-
</div>
|
|
184
|
-
</>
|
|
185
|
-
) : (
|
|
186
|
-
<>
|
|
187
|
-
{/* Fiat amount input - styled like PanelOnramp */}
|
|
188
|
-
<div className="flex items-center justify-center pb-2 pt-8">
|
|
189
|
-
<div className="flex gap-1">
|
|
190
|
-
<span className="text-as-tertiarry text-2xl font-bold">$</span>
|
|
191
|
-
<Input
|
|
192
|
-
type="text"
|
|
193
|
-
value={srcAmount}
|
|
194
|
-
onChange={e => setSrcAmount(e.target.value.replace(/[^0-9.]/g, ""))}
|
|
195
|
-
placeholder="5"
|
|
196
|
-
className="text-as-primary placeholder:text-as-primary/50 h-auto min-w-[70px] border-0 bg-transparent p-0 px-3 pt-1 text-4xl font-bold focus-visible:ring-0 focus-visible:ring-offset-0"
|
|
197
|
-
style={{
|
|
198
|
-
width: `${Math.max(50, srcAmount.length * 34)}px`,
|
|
199
|
-
}}
|
|
200
|
-
/>
|
|
201
|
-
</div>
|
|
202
|
-
</div>
|
|
203
|
-
|
|
204
|
-
{/* Quick Amount Buttons */}
|
|
205
|
-
<div className="mx-auto mb-6 inline-grid grid-cols-4 gap-2">
|
|
206
|
-
{["5", "10", "20", "25"].map(value => (
|
|
207
|
-
<button
|
|
208
|
-
key={value}
|
|
209
|
-
onClick={() => setSrcAmount(value)}
|
|
210
|
-
className={`bg-as-surface-secondary border-as-border-secondary hover:border-as-border-secondary h-7 w-14 rounded-lg border text-sm font-medium transition-all duration-200 ${
|
|
211
|
-
srcAmount === value
|
|
212
|
-
? "border-as-border-secondary bg-as-surface-secondary"
|
|
213
|
-
: "bg-as-surface-secondary hover:bg-as-surface-secondary"
|
|
214
|
-
}`}
|
|
215
|
-
>
|
|
216
|
-
${value}
|
|
217
|
-
</button>
|
|
218
|
-
))}
|
|
219
|
-
</div>
|
|
220
|
-
</>
|
|
221
|
-
)}
|
|
222
146
|
</motion.div>
|
|
223
147
|
);
|
|
224
148
|
}
|
|
@@ -5,13 +5,14 @@ export { AnySpendBuySpin } from "./AnySpendBuySpin";
|
|
|
5
5
|
export { AnySpendCustom } from "./AnySpendCustom";
|
|
6
6
|
export * from "./AnySpendFingerprintWrapper";
|
|
7
7
|
export { AnySpendNFT } from "./AnySpendNFT";
|
|
8
|
-
export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
|
|
9
8
|
export { AnySpendStakeB3 } from "./AnySpendStakeB3";
|
|
10
9
|
export { AnySpendTournament } from "./AnySpendTournament";
|
|
10
|
+
export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
|
|
11
11
|
export { AnySpendNFTButton } from "./common/AnySpendNFTButton";
|
|
12
12
|
|
|
13
13
|
// Common Components
|
|
14
14
|
export { ChainTokenIcon } from "./common/ChainTokenIcon";
|
|
15
|
+
export { CryptoPaySection } from "./common/CryptoPaySection";
|
|
15
16
|
export { CryptoReceiveSection } from "./common/CryptoReceiveSection";
|
|
16
17
|
export { OrderDetails } from "./common/OrderDetails";
|
|
17
18
|
export { OrderDetailsCollapsible } from "./common/OrderDetailsCollapsible";
|
|
@@ -20,7 +21,6 @@ export { OrderHistoryItem } from "./common/OrderHistoryItem";
|
|
|
20
21
|
export { OrderStatus } from "./common/OrderStatus";
|
|
21
22
|
export { OrderToken } from "./common/OrderToken";
|
|
22
23
|
export { OrderTokenAmount } from "./common/OrderTokenAmount";
|
|
23
|
-
export { PaySection } from "./common/PaySection";
|
|
24
24
|
export { RecipientSelection } from "./common/RecipientSelection";
|
|
25
25
|
export { StepProgress } from "./common/StepProgress";
|
|
26
26
|
export { TokenBalance } from "./common/TokenBalance";
|
|
@@ -127,12 +127,7 @@ export function B3DynamicModal() {
|
|
|
127
127
|
>
|
|
128
128
|
<ModalTitle className="sr-only hidden">{contentType?.type || "Modal"}</ModalTitle>
|
|
129
129
|
<ModalDescription className="sr-only hidden">{contentType?.type || "Modal Body"}</ModalDescription>
|
|
130
|
-
<div
|
|
131
|
-
className={cn(
|
|
132
|
-
"no-scrollbar max-h-[90dvh] overflow-auto sm:max-h-[80dvh]",
|
|
133
|
-
contentType?.type === "manageAccount" && "h-[90dvh]",
|
|
134
|
-
)}
|
|
135
|
-
>
|
|
130
|
+
<div className={cn("no-scrollbar max-h-[90dvh] overflow-auto sm:max-h-[80dvh]")}>
|
|
136
131
|
{history.length > 0 && contentType?.showBackButton && (
|
|
137
132
|
<button
|
|
138
133
|
onClick={navigateBack}
|
|
@@ -133,7 +133,7 @@ export function ManageAccount({
|
|
|
133
133
|
const [unlinkingAccountId, setUnlinkingAccountId] = useState<string | null>(null);
|
|
134
134
|
const { data: profilesRaw = [], isLoading: isLoadingProfiles } = useProfiles({ client });
|
|
135
135
|
const { mutate: unlinkProfile, isPending: isUnlinking } = useUnlinkProfile();
|
|
136
|
-
const { setB3ModalOpen, setB3ModalContentType, isLinking } = useModalStore();
|
|
136
|
+
const { setB3ModalOpen, setB3ModalContentType, isLinking, contentType } = useModalStore();
|
|
137
137
|
const { user, setUser } = useB3();
|
|
138
138
|
const [isUpdatingCode, setIsUpdatingCode] = useState(false);
|
|
139
139
|
const [newReferralCode, setNewReferralCode] = useState("");
|
|
@@ -145,6 +145,7 @@ export function ManageAccount({
|
|
|
145
145
|
{ query: { referrerId: user?.userId } },
|
|
146
146
|
!!user?.userId,
|
|
147
147
|
);
|
|
148
|
+
const showReferralInfo = (contentType as ManageAccountModalProps)?.showReferralInfo ?? false;
|
|
148
149
|
|
|
149
150
|
const mutationOptions = {
|
|
150
151
|
onError: (error: Error) => {
|
|
@@ -305,22 +306,14 @@ export function ManageAccount({
|
|
|
305
306
|
)}
|
|
306
307
|
</div>
|
|
307
308
|
|
|
308
|
-
{
|
|
309
|
-
|
|
310
|
-
<
|
|
309
|
+
{showReferralInfo && (
|
|
310
|
+
/* Referral Section */
|
|
311
|
+
<div className="space-y-4">
|
|
312
|
+
<h3 className="text-b3-grey font-neue-montreal-semibold text-xl">Referrals</h3>
|
|
311
313
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
<div>
|
|
316
|
-
<div className="text-b3-grey font-neue-montreal-semibold">Your Referral Code</div>
|
|
317
|
-
<div className="text-b3-foreground-muted font-neue-montreal-medium text-sm">
|
|
318
|
-
Share this code with friends to earn rewards
|
|
319
|
-
</div>
|
|
320
|
-
</div>
|
|
321
|
-
)}
|
|
322
|
-
<div className="flex items-center justify-between">
|
|
323
|
-
{!isEditingCode && (
|
|
314
|
+
{/* Referral Code */}
|
|
315
|
+
<div className="bg-b3-line rounded-xl p-4">
|
|
316
|
+
{isEditingCode && (
|
|
324
317
|
<div>
|
|
325
318
|
<div className="text-b3-grey font-neue-montreal-semibold">Your Referral Code</div>
|
|
326
319
|
<div className="text-b3-foreground-muted font-neue-montreal-medium text-sm">
|
|
@@ -328,78 +321,95 @@ export function ManageAccount({
|
|
|
328
321
|
</div>
|
|
329
322
|
</div>
|
|
330
323
|
)}
|
|
331
|
-
<div className="flex items-center
|
|
332
|
-
{isEditingCode
|
|
333
|
-
<div
|
|
334
|
-
<
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
onChange={e => setNewReferralCode(e.target.value)}
|
|
338
|
-
className="rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm"
|
|
339
|
-
placeholder="Enter new code"
|
|
340
|
-
ref={referallCodeRef}
|
|
341
|
-
/>
|
|
342
|
-
<Button size="sm" onClick={handleUpdateReferralCode} disabled={isUpdatingCode || !newReferralCode}>
|
|
343
|
-
{isUpdatingCode ? <Loader2 className="h-4 w-4 animate-spin" /> : "Save"}
|
|
344
|
-
</Button>
|
|
345
|
-
<Button
|
|
346
|
-
size="sm"
|
|
347
|
-
variant="ghost"
|
|
348
|
-
onClick={() => {
|
|
349
|
-
setIsEditingCode(false);
|
|
350
|
-
setNewReferralCode("");
|
|
351
|
-
}}
|
|
352
|
-
>
|
|
353
|
-
Cancel
|
|
354
|
-
</Button>
|
|
355
|
-
</div>
|
|
356
|
-
) : (
|
|
357
|
-
<>
|
|
358
|
-
<div className="rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm">
|
|
359
|
-
{currentReferralCode}
|
|
324
|
+
<div className="flex items-center justify-between">
|
|
325
|
+
{!isEditingCode && (
|
|
326
|
+
<div>
|
|
327
|
+
<div className="text-b3-grey font-neue-montreal-semibold">Your Referral Code</div>
|
|
328
|
+
<div className="text-b3-foreground-muted font-neue-montreal-medium text-sm">
|
|
329
|
+
Share this code with friends to earn rewards
|
|
360
330
|
</div>
|
|
361
|
-
|
|
362
|
-
<Copy className="h-4 w-4" />
|
|
363
|
-
</Button>
|
|
364
|
-
<Button
|
|
365
|
-
size="icon"
|
|
366
|
-
variant="ghost"
|
|
367
|
-
onClick={() => {
|
|
368
|
-
setIsEditingCode(true);
|
|
369
|
-
setTimeout(() => {
|
|
370
|
-
referallCodeRef.current?.focus();
|
|
371
|
-
}, 100);
|
|
372
|
-
}}
|
|
373
|
-
>
|
|
374
|
-
<Pencil className="h-4 w-4" />
|
|
375
|
-
</Button>
|
|
376
|
-
</>
|
|
331
|
+
</div>
|
|
377
332
|
)}
|
|
333
|
+
<div className="flex items-center gap-2">
|
|
334
|
+
{isEditingCode ? (
|
|
335
|
+
<div className="flex items-center gap-2">
|
|
336
|
+
<input
|
|
337
|
+
type="text"
|
|
338
|
+
value={newReferralCode}
|
|
339
|
+
onChange={e => setNewReferralCode(e.target.value)}
|
|
340
|
+
className="rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm"
|
|
341
|
+
placeholder="Enter new code"
|
|
342
|
+
ref={referallCodeRef}
|
|
343
|
+
/>
|
|
344
|
+
<Button
|
|
345
|
+
size="sm"
|
|
346
|
+
onClick={handleUpdateReferralCode}
|
|
347
|
+
disabled={isUpdatingCode || !newReferralCode}
|
|
348
|
+
>
|
|
349
|
+
{isUpdatingCode ? <Loader2 className="h-4 w-4 animate-spin" /> : "Save"}
|
|
350
|
+
</Button>
|
|
351
|
+
<Button
|
|
352
|
+
size="sm"
|
|
353
|
+
variant="ghost"
|
|
354
|
+
onClick={() => {
|
|
355
|
+
setIsEditingCode(false);
|
|
356
|
+
setNewReferralCode("");
|
|
357
|
+
}}
|
|
358
|
+
>
|
|
359
|
+
Cancel
|
|
360
|
+
</Button>
|
|
361
|
+
</div>
|
|
362
|
+
) : (
|
|
363
|
+
<>
|
|
364
|
+
<div className="rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm">
|
|
365
|
+
{currentReferralCode}
|
|
366
|
+
</div>
|
|
367
|
+
<Button size="icon" variant="ghost" onClick={handleCopyCode}>
|
|
368
|
+
<Copy className="h-4 w-4" />
|
|
369
|
+
</Button>
|
|
370
|
+
<Button
|
|
371
|
+
size="icon"
|
|
372
|
+
variant="ghost"
|
|
373
|
+
onClick={() => {
|
|
374
|
+
setIsEditingCode(true);
|
|
375
|
+
setTimeout(() => {
|
|
376
|
+
referallCodeRef.current?.focus();
|
|
377
|
+
}, 100);
|
|
378
|
+
}}
|
|
379
|
+
>
|
|
380
|
+
<Pencil className="h-4 w-4" />
|
|
381
|
+
</Button>
|
|
382
|
+
</>
|
|
383
|
+
)}
|
|
384
|
+
</div>
|
|
378
385
|
</div>
|
|
379
386
|
</div>
|
|
380
|
-
</div>
|
|
381
387
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
388
|
+
{/* Referred Users */}
|
|
389
|
+
<div className="bg-b3-line rounded-xl p-4">
|
|
390
|
+
<div className="text-b3-grey font-neue-montreal-semibold mb-4">Referred Users</div>
|
|
391
|
+
{isLoadingReferrals ? (
|
|
392
|
+
<div className="flex justify-center py-4">
|
|
393
|
+
<Loader2 className="h-6 w-6 animate-spin text-gray-400" />
|
|
394
|
+
</div>
|
|
395
|
+
) : referrals?.data?.length ? (
|
|
396
|
+
<div className="space-y-3">
|
|
397
|
+
{referrals.data.map((referral: Referrals) => (
|
|
398
|
+
<div
|
|
399
|
+
key={String(referral._id)}
|
|
400
|
+
className="flex items-center justify-between rounded-lg bg-white p-3"
|
|
401
|
+
>
|
|
402
|
+
<div className="text-sm font-medium">{referral.referreeId}</div>
|
|
403
|
+
<div className="text-sm text-gray-500">{new Date(referral.createdAt).toLocaleDateString()}</div>
|
|
404
|
+
</div>
|
|
405
|
+
))}
|
|
406
|
+
</div>
|
|
407
|
+
) : (
|
|
408
|
+
<div className="py-4 text-center text-gray-500">No referred users yet</div>
|
|
409
|
+
)}
|
|
410
|
+
</div>
|
|
401
411
|
</div>
|
|
402
|
-
|
|
412
|
+
)}
|
|
403
413
|
|
|
404
414
|
{/* Additional Settings Sections */}
|
|
405
415
|
<div className="space-y-4">
|
|
@@ -21,7 +21,7 @@ export type SignInWithB3Props = Omit<SignInWithB3ModalProps, "type" | "showBackB
|
|
|
21
21
|
export function SignInWithB3(props: SignInWithB3Props) {
|
|
22
22
|
const { setB3ModalOpen, setB3ModalContentType, setEcoSystemAccountAddress } = useModalStore();
|
|
23
23
|
const { account } = useB3();
|
|
24
|
-
const {
|
|
24
|
+
const { isAuthenticatingV2, isAuthenticated } = useAuthentication(props.partnerId, props.loginWithSiwe);
|
|
25
25
|
const isMobile = useIsMobile();
|
|
26
26
|
|
|
27
27
|
useEffect(() => {
|
|
@@ -39,11 +39,11 @@ export function SignInWithB3(props: SignInWithB3Props) {
|
|
|
39
39
|
setB3ModalOpen(true);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
if (
|
|
42
|
+
if (isAuthenticated) {
|
|
43
43
|
return <ManageAccountButton {...props} />;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
if (
|
|
46
|
+
if (isAuthenticatingV2) {
|
|
47
47
|
return (
|
|
48
48
|
<StyleRoot>
|
|
49
49
|
<Button disabled style={{ backgroundColor: "#3368ef" }} className="flex items-center gap-2 text-white">
|
|
@@ -41,6 +41,7 @@ export function SignInWithB3Flow({
|
|
|
41
41
|
const { setB3ModalContentType, setB3ModalOpen, isOpen } = useModalStore();
|
|
42
42
|
const account = useActiveAccount();
|
|
43
43
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
44
|
+
const setIsAuthenticatingV2 = useAuthStore(state => state.setIsAuthenticatingV2);
|
|
44
45
|
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
45
46
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
46
47
|
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
@@ -198,6 +199,7 @@ export function SignInWithB3Flow({
|
|
|
198
199
|
if (loginWithSiwe) {
|
|
199
200
|
debug("setIsAuthenticating:true:1");
|
|
200
201
|
setIsAuthenticating(true);
|
|
202
|
+
setIsAuthenticatingV2(true);
|
|
201
203
|
const userAuth = await authenticate(account, partnerId);
|
|
202
204
|
setUser(userAuth.user);
|
|
203
205
|
}
|
|
@@ -205,8 +207,18 @@ export function SignInWithB3Flow({
|
|
|
205
207
|
onLoginSuccess?.(account);
|
|
206
208
|
debug("setIsAuthenticating:false:1");
|
|
207
209
|
setIsAuthenticating(false);
|
|
210
|
+
setIsAuthenticatingV2(false);
|
|
208
211
|
},
|
|
209
|
-
[
|
|
212
|
+
[
|
|
213
|
+
loginWithSiwe,
|
|
214
|
+
onLoginSuccess,
|
|
215
|
+
setIsAuthenticating,
|
|
216
|
+
authenticate,
|
|
217
|
+
partnerId,
|
|
218
|
+
setUser,
|
|
219
|
+
setIsConnected,
|
|
220
|
+
setIsAuthenticatingV2,
|
|
221
|
+
],
|
|
210
222
|
);
|
|
211
223
|
|
|
212
224
|
useEffect(() => {
|
|
@@ -21,6 +21,7 @@ interface SignInWithB3PrivyProps {
|
|
|
21
21
|
export function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }: SignInWithB3PrivyProps) {
|
|
22
22
|
const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(partnerId, chain, onSuccess);
|
|
23
23
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
24
|
+
const setIsAuthenticatingV2 = useAuthStore(state => state.setIsAuthenticatingV2);
|
|
24
25
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
25
26
|
const { logout } = useAuthentication(partnerId);
|
|
26
27
|
|
|
@@ -48,10 +49,11 @@ export function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }: Sign
|
|
|
48
49
|
} finally {
|
|
49
50
|
debug("setIsAuthenticating:false:7");
|
|
50
51
|
setIsAuthenticating(false);
|
|
52
|
+
setIsAuthenticatingV2(false);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
autoConnect();
|
|
54
|
-
}, [connectTw, onSuccess, onError, setIsAuthenticating, setIsAuthenticated, logout]);
|
|
56
|
+
}, [connectTw, onSuccess, onError, setIsAuthenticating, setIsAuthenticated, logout, setIsAuthenticatingV2]);
|
|
55
57
|
|
|
56
58
|
// Currently we auto login, so we can show loading immediately and the onSuccess will proceed to the next modal
|
|
57
59
|
return (
|
|
@@ -42,9 +42,9 @@ export function LoginStepContainer({ children, partnerId }: LoginStepContainerPr
|
|
|
42
42
|
const partnerLogo = partner?.data?.[0]?.loginCustomization?.logoUrl;
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
|
-
<div className="flex flex-col items-center justify-center">
|
|
45
|
+
<div className="flex flex-col items-center justify-center pt-6">
|
|
46
46
|
{partnerLogo && (
|
|
47
|
-
<img src={partnerLogo} alt="Partner Logo" className="partner-logo mb-6
|
|
47
|
+
<img src={partnerLogo} alt="Partner Logo" className="partner-logo mb-6 h-12 w-auto object-contain" />
|
|
48
48
|
)}
|
|
49
49
|
{children}
|
|
50
50
|
<h2 className="mt-6 flex items-center gap-2 text-lg font-bold">
|
|
@@ -63,6 +63,7 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }: LoginStepPro
|
|
|
63
63
|
|
|
64
64
|
const { theme } = useB3();
|
|
65
65
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
66
|
+
const setIsAuthenticatingV2 = useAuthStore(state => state.setIsAuthenticatingV2);
|
|
66
67
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
67
68
|
const { logout } = useAuthentication(partnerId);
|
|
68
69
|
|
|
@@ -117,6 +118,7 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }: LoginStepPro
|
|
|
117
118
|
onConnect={async wallet => {
|
|
118
119
|
try {
|
|
119
120
|
setIsAuthenticating(true);
|
|
121
|
+
setIsAuthenticatingV2(true);
|
|
120
122
|
debug("setIsAuthenticating:true:6");
|
|
121
123
|
|
|
122
124
|
const account = wallet.getAccount();
|
|
@@ -133,6 +135,7 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }: LoginStepPro
|
|
|
133
135
|
} finally {
|
|
134
136
|
debug("setIsAuthenticating:false:6");
|
|
135
137
|
setIsAuthenticating(false);
|
|
138
|
+
setIsAuthenticatingV2(false);
|
|
136
139
|
}
|
|
137
140
|
}}
|
|
138
141
|
/>
|
|
@@ -40,6 +40,7 @@ export function LoginStepCustom({
|
|
|
40
40
|
const [showAllWallets, setShowAllWallets] = useState(false);
|
|
41
41
|
const { connect } = useConnect(partnerId, chain);
|
|
42
42
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
43
|
+
const setIsAuthenticatingV2 = useAuthStore(state => state.setIsAuthenticatingV2);
|
|
43
44
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
44
45
|
const { logout } = useAuthentication(partnerId);
|
|
45
46
|
const { connect: connectTW } = useConnectTW();
|
|
@@ -55,6 +56,7 @@ export function LoginStepCustom({
|
|
|
55
56
|
setIsLoading(true);
|
|
56
57
|
debug("setIsAuthenticating:true:3");
|
|
57
58
|
setIsAuthenticating(true);
|
|
59
|
+
setIsAuthenticatingV2(true);
|
|
58
60
|
const options = getConnectOptionsFromStrategy(strategy);
|
|
59
61
|
let connectResult: Wallet | null;
|
|
60
62
|
|
|
@@ -88,6 +90,7 @@ export function LoginStepCustom({
|
|
|
88
90
|
setIsLoading(false);
|
|
89
91
|
debug("setIsAuthenticating:false:3");
|
|
90
92
|
setIsAuthenticating(false);
|
|
93
|
+
setIsAuthenticatingV2(false);
|
|
91
94
|
}
|
|
92
95
|
};
|
|
93
96
|
|