@b3dotfun/sdk 0.0.40-test.3 → 0.0.40
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 +0 -1
- package/dist/cjs/anyspend/constants/index.js +1 -2
- package/dist/cjs/anyspend/react/components/AnySpend.js +5 -6
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +8 -9
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +4 -5
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +3 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +23 -19
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +9 -8
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.js +24 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +3 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +8 -27
- package/dist/esm/anyspend/constants/index.d.ts +0 -1
- package/dist/esm/anyspend/constants/index.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +6 -7
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +8 -9
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +5 -6
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +3 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +24 -20
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +10 -9
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.js +21 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +3 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +7 -27
- package/dist/types/anyspend/constants/index.d.ts +0 -1
- package/dist/types/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +3 -3
- package/package.json +4 -5
- package/src/anyspend/constants/index.ts +0 -2
- package/src/anyspend/react/components/AnySpend.tsx +15 -17
- package/src/anyspend/react/components/AnySpendCustom.tsx +19 -21
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +16 -18
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +5 -0
- package/src/anyspend/react/components/common/OrderDetails.tsx +60 -43
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +62 -41
- package/src/anyspend/react/components/common/PaymentMethodSwitch.tsx +38 -0
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +65 -43
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +9 -35
- package/dist/cjs/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/cjs/global-account/examples/client-selection-example.js +0 -96
- package/dist/esm/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/esm/global-account/examples/client-selection-example.js +0 -93
- package/dist/types/global-account/examples/client-selection-example.d.ts +0 -5
- package/src/global-account/docs/client-selection.md +0 -292
- package/src/global-account/examples/client-selection-example.tsx +0 -197
|
@@ -11,7 +11,9 @@ import { QRCodeSVG } from "qrcode.react";
|
|
|
11
11
|
import { memo, useEffect, useMemo, useState } from "react";
|
|
12
12
|
import { toast } from "sonner";
|
|
13
13
|
import { b3 } from "viem/chains";
|
|
14
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
14
15
|
import { OrderDetailsCollapsible } from "./OrderDetailsCollapsible";
|
|
16
|
+
import { PaymentMethodSwitch } from "./PaymentMethodSwitch";
|
|
15
17
|
|
|
16
18
|
type Order = components["schemas"]["Order"];
|
|
17
19
|
type Token = components["schemas"]["Token"];
|
|
@@ -26,6 +28,7 @@ interface TransferCryptoDetailsProps {
|
|
|
26
28
|
nft?: NFT;
|
|
27
29
|
onBack: () => void;
|
|
28
30
|
recipientName?: string;
|
|
31
|
+
onPaymentMethodChange?: (method: CryptoPaymentMethodType) => void;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
@@ -36,6 +39,7 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
36
39
|
nft,
|
|
37
40
|
onBack,
|
|
38
41
|
recipientName,
|
|
42
|
+
onPaymentMethodChange,
|
|
39
43
|
}: TransferCryptoDetailsProps) {
|
|
40
44
|
const [timeLeft, setTimeLeft] = useState(0);
|
|
41
45
|
|
|
@@ -98,21 +102,21 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
98
102
|
};
|
|
99
103
|
|
|
100
104
|
return (
|
|
101
|
-
<div className="flex w-full flex-col gap-6">
|
|
105
|
+
<div className="order-transfer-crypto flex w-full flex-col gap-6">
|
|
102
106
|
{/* Header */}
|
|
103
|
-
<div className="flex items-center justify-between">
|
|
107
|
+
<div className="order-transfer-crypto-header flex items-center justify-between">
|
|
104
108
|
<button
|
|
105
109
|
onClick={onBack}
|
|
106
|
-
className="text-as-primary/60 hover:text-as-primary flex h-10 w-10 items-center justify-center rounded-full transition-colors"
|
|
110
|
+
className="order-transfer-crypto-back-btn text-as-primary/60 hover:text-as-primary flex h-10 w-10 items-center justify-center rounded-full transition-colors"
|
|
107
111
|
>
|
|
108
112
|
<ChevronLeft size={24} className="text-as-quaternary" />
|
|
109
113
|
</button>
|
|
110
114
|
|
|
111
|
-
<h2 className="text-as-primary text-lg font-semibold">Transfer crypto</h2>
|
|
115
|
+
<h2 className="order-transfer-crypto-title text-as-primary text-lg font-semibold">Transfer crypto</h2>
|
|
112
116
|
|
|
113
117
|
{/* Countdown Timer */}
|
|
114
|
-
<div className="relative flex h-11 w-11 items-center justify-center">
|
|
115
|
-
<svg className="h-11 w-11 -rotate-90" viewBox="0 0 44 44">
|
|
118
|
+
<div className="order-transfer-crypto-timer relative flex h-11 w-11 items-center justify-center">
|
|
119
|
+
<svg className="order-transfer-crypto-timer-svg h-11 w-11 -rotate-90" viewBox="0 0 44 44">
|
|
116
120
|
<circle
|
|
117
121
|
cx="22"
|
|
118
122
|
cy="22"
|
|
@@ -120,7 +124,7 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
120
124
|
stroke="currentColor"
|
|
121
125
|
strokeWidth="3"
|
|
122
126
|
fill="none"
|
|
123
|
-
className="text-gray-200"
|
|
127
|
+
className="order-transfer-crypto-timer-bg text-gray-200"
|
|
124
128
|
/>
|
|
125
129
|
<circle
|
|
126
130
|
cx="22"
|
|
@@ -130,7 +134,7 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
130
134
|
strokeWidth="3"
|
|
131
135
|
fill="none"
|
|
132
136
|
strokeLinecap="round"
|
|
133
|
-
className="text-blue-500"
|
|
137
|
+
className="order-transfer-crypto-timer-progress text-blue-500"
|
|
134
138
|
strokeDasharray={`${2 * Math.PI * 18}`}
|
|
135
139
|
strokeDashoffset={`${2 * Math.PI * 18 * (1 - timeLeft / totalTime)}`}
|
|
136
140
|
style={{
|
|
@@ -138,57 +142,66 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
138
142
|
}}
|
|
139
143
|
/>
|
|
140
144
|
</svg>
|
|
141
|
-
<div className="absolute inset-0 flex items-center justify-center">
|
|
145
|
+
<div className="order-transfer-crypto-timer-text absolute inset-0 flex items-center justify-center">
|
|
142
146
|
<span className="text-as-primary text-[10px] font-semibold">{formatTime(timeLeft)}</span>
|
|
143
147
|
</div>
|
|
144
148
|
</div>
|
|
145
149
|
</div>
|
|
146
150
|
|
|
147
151
|
{/* Main Content Cards */}
|
|
148
|
-
<div className="flex w-full flex-col gap-4">
|
|
152
|
+
<div className="order-transfer-crypto-content flex w-full flex-col gap-4">
|
|
149
153
|
{/* Amount Card */}
|
|
150
|
-
<div className="flex items-center gap-4">
|
|
151
|
-
<div className="w-full">
|
|
152
|
-
<span className="text-as-content-secondary text-sm font-medium">
|
|
153
|
-
|
|
154
|
+
<div className="order-transfer-crypto-cards flex items-center gap-4">
|
|
155
|
+
<div className="order-transfer-crypto-amount-card w-full">
|
|
156
|
+
<span className="order-transfer-crypto-amount-label text-as-content-secondary text-sm font-medium">
|
|
157
|
+
Amount
|
|
158
|
+
</span>
|
|
159
|
+
<div className="order-transfer-crypto-amount-container border-as-border-primary rounded-lg border p-2 shadow-sm">
|
|
154
160
|
<CopyToClipboard
|
|
155
161
|
text={roundedUpSrcAmount || ""}
|
|
156
162
|
onCopy={() => {
|
|
157
163
|
toast.success("Amount copied to clipboard");
|
|
158
164
|
}}
|
|
159
165
|
>
|
|
160
|
-
<div className="flex cursor-pointer items-center justify-between gap-2">
|
|
161
|
-
<strong className="text-as-primary font-semibold">
|
|
166
|
+
<div className="order-transfer-crypto-amount-copy flex cursor-pointer items-center justify-between gap-2">
|
|
167
|
+
<strong className="order-transfer-crypto-amount-text text-as-primary font-semibold">
|
|
162
168
|
{roundedUpSrcAmount} {srcToken.symbol}
|
|
163
169
|
</strong>
|
|
164
|
-
<Copy className="text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" />
|
|
170
|
+
<Copy className="order-transfer-crypto-amount-copy-icon text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" />
|
|
165
171
|
</div>
|
|
166
172
|
</CopyToClipboard>
|
|
167
173
|
</div>
|
|
168
174
|
</div>
|
|
169
175
|
|
|
170
176
|
{/* Chain Card */}
|
|
171
|
-
<div className="w-full">
|
|
172
|
-
<span className="text-as-content-secondary text-sm font-medium">
|
|
173
|
-
|
|
174
|
-
|
|
177
|
+
<div className="order-transfer-crypto-chain-card w-full">
|
|
178
|
+
<span className="order-transfer-crypto-chain-label text-as-content-secondary text-sm font-medium">
|
|
179
|
+
Chain
|
|
180
|
+
</span>
|
|
181
|
+
<div className="order-transfer-crypto-chain-container border-as-border-primary rounded-lg border p-2 shadow-sm">
|
|
182
|
+
<div className="order-transfer-crypto-chain-info flex items-center gap-2">
|
|
175
183
|
<img
|
|
176
184
|
src={ALL_CHAINS[order.srcChain].logoUrl}
|
|
177
185
|
alt={getChainName(order.srcChain)}
|
|
178
|
-
className={cn(
|
|
186
|
+
className={cn(
|
|
187
|
+
"order-transfer-crypto-chain-logo h-6 rounded-full",
|
|
188
|
+
order.srcChain === b3.id && "h-5 rounded-none",
|
|
189
|
+
)}
|
|
179
190
|
/>
|
|
180
|
-
<span className="text-as-primary text-sm font-semibold">
|
|
191
|
+
<span className="order-transfer-crypto-chain-name text-as-primary text-sm font-semibold">
|
|
192
|
+
{getChainName(order.srcChain)}
|
|
193
|
+
</span>
|
|
181
194
|
</div>
|
|
182
195
|
</div>
|
|
183
196
|
</div>
|
|
184
197
|
</div>
|
|
185
198
|
|
|
186
199
|
{/* QR Code and Deposit Address Card */}
|
|
187
|
-
<div className="border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border">
|
|
200
|
+
<div className="order-transfer-crypto-qr-deposit-card border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border">
|
|
188
201
|
{/* QR Code Section */}
|
|
189
|
-
<div className="border-as-border-primary h-full w-full border-r">
|
|
190
|
-
<div className="flex justify-center">
|
|
191
|
-
<div className="bg-as-surface-secondary flex flex-col items-center rounded-lg p-6">
|
|
202
|
+
<div className="order-transfer-crypto-qr-section border-as-border-primary h-full w-full border-r">
|
|
203
|
+
<div className="order-transfer-crypto-qr-wrapper flex justify-center">
|
|
204
|
+
<div className="order-transfer-crypto-qr-container bg-as-surface-secondary flex flex-col items-center rounded-lg p-6">
|
|
192
205
|
<QRCodeSVG
|
|
193
206
|
value={getPaymentUrl(
|
|
194
207
|
order.globalAddress,
|
|
@@ -197,15 +210,17 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
197
210
|
order.srcChain,
|
|
198
211
|
srcToken?.decimals,
|
|
199
212
|
)}
|
|
200
|
-
className="bg-as-surface-secondary max-h-48 max-w-48"
|
|
213
|
+
className="order-transfer-crypto-qr-code bg-as-surface-secondary max-h-48 max-w-48"
|
|
201
214
|
/>
|
|
202
|
-
<div className="mt-3 flex items-center justify-center gap-2 text-sm">
|
|
203
|
-
<span className="text-as-brand/70 text-sm font-medium">
|
|
215
|
+
<div className="order-transfer-crypto-wallet-hint mt-3 flex items-center justify-center gap-2 text-sm">
|
|
216
|
+
<span className="order-transfer-crypto-wallet-text text-as-brand/70 text-sm font-medium">
|
|
217
|
+
SCAN WITH
|
|
218
|
+
</span>
|
|
204
219
|
<TextLoop interval={3}>
|
|
205
|
-
<WalletMetamask className="h-5 w-5" variant="branded" />
|
|
206
|
-
<WalletCoinbase className="h-5 w-5" variant="branded" />
|
|
207
|
-
<WalletPhantom className="h-5 w-5" variant="branded" />
|
|
208
|
-
<WalletTrust className="h-5 w-5" variant="branded" />
|
|
220
|
+
<WalletMetamask className="order-transfer-crypto-wallet-icon h-5 w-5" variant="branded" />
|
|
221
|
+
<WalletCoinbase className="order-transfer-crypto-wallet-icon h-5 w-5" variant="branded" />
|
|
222
|
+
<WalletPhantom className="order-transfer-crypto-wallet-icon h-5 w-5" variant="branded" />
|
|
223
|
+
<WalletTrust className="order-transfer-crypto-wallet-icon h-5 w-5" variant="branded" />
|
|
209
224
|
</TextLoop>
|
|
210
225
|
</div>
|
|
211
226
|
</div>
|
|
@@ -213,17 +228,19 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
213
228
|
</div>
|
|
214
229
|
|
|
215
230
|
{/* Deposit Address Section */}
|
|
216
|
-
<div className="flex h-full w-full flex-col gap-2 p-6">
|
|
217
|
-
<span className="text-as-content-secondary text-sm font-medium">
|
|
231
|
+
<div className="order-transfer-crypto-address-section flex h-full w-full flex-col gap-2 p-6">
|
|
232
|
+
<span className="order-transfer-crypto-address-label text-as-content-secondary text-sm font-medium">
|
|
233
|
+
Deposit address:
|
|
234
|
+
</span>
|
|
218
235
|
<div
|
|
219
|
-
className="flex h-full cursor-pointer flex-col items-stretch justify-between gap-4"
|
|
236
|
+
className="order-transfer-crypto-address-copy flex h-full cursor-pointer flex-col items-stretch justify-between gap-4"
|
|
220
237
|
onClick={handleCopyAddress}
|
|
221
238
|
>
|
|
222
|
-
<div className="text-as-primary break-all font-mono text-sm font-semibold leading-relaxed">
|
|
239
|
+
<div className="order-transfer-crypto-address-text text-as-primary break-all font-mono text-sm font-semibold leading-relaxed">
|
|
223
240
|
{order.globalAddress}
|
|
224
241
|
</div>
|
|
225
|
-
<div className="place-self-end">
|
|
226
|
-
<Copy className="group-hover:text-as-brand text-as-tertiarry h-4 w-4 cursor-pointer transition-all duration-200" />
|
|
242
|
+
<div className="order-transfer-crypto-address-copy-icon-wrapper place-self-end">
|
|
243
|
+
<Copy className="order-transfer-crypto-address-copy-icon group-hover:text-as-brand text-as-tertiarry h-4 w-4 cursor-pointer transition-all duration-200" />
|
|
227
244
|
</div>
|
|
228
245
|
</div>
|
|
229
246
|
</div>
|
|
@@ -240,23 +257,28 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
240
257
|
</div>
|
|
241
258
|
|
|
242
259
|
{/* Action Buttons */}
|
|
243
|
-
<div className="flex flex-col gap-3">
|
|
260
|
+
<div className="order-transfer-crypto-actions flex flex-col gap-3">
|
|
244
261
|
<ShinyButton
|
|
245
262
|
accentColor="hsl(var(--as-brand))"
|
|
246
263
|
textColor="text-white"
|
|
247
|
-
className="w-full py-3"
|
|
264
|
+
className="order-transfer-crypto-copy-btn w-full py-3"
|
|
248
265
|
onClick={handleCopyAddress}
|
|
249
266
|
>
|
|
250
267
|
Copy deposit address
|
|
251
268
|
</ShinyButton>
|
|
252
269
|
|
|
253
270
|
{/* <button
|
|
254
|
-
className="text-as-primary/60 hover:text-as-primary flex w-full items-center justify-center gap-2 py-2 transition-colors"
|
|
271
|
+
className="order-transfer-crypto-cancel-btn text-as-primary/60 hover:text-as-primary flex w-full items-center justify-center gap-2 py-2 transition-colors"
|
|
255
272
|
onClick={onBack}
|
|
256
273
|
>
|
|
257
274
|
<RefreshCcw className="h-4 w-4" />
|
|
258
275
|
Cancel and start over
|
|
259
276
|
</button> */}
|
|
277
|
+
|
|
278
|
+
<PaymentMethodSwitch
|
|
279
|
+
currentMethod={CryptoPaymentMethodType.TRANSFER_CRYPTO}
|
|
280
|
+
onMethodChange={onPaymentMethodChange}
|
|
281
|
+
/>
|
|
260
282
|
</div>
|
|
261
283
|
</div>
|
|
262
284
|
);
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
2
1
|
import { RelayKitProviderWrapper, TooltipProvider, useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
3
2
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
4
3
|
import { loadGA4Script } from "@b3dotfun/sdk/global-account/utils/analytics";
|
|
5
|
-
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
6
4
|
import { supportedChains } from "@b3dotfun/sdk/shared/constants/chains/supported";
|
|
7
|
-
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
8
|
-
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
9
5
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
10
|
-
import {
|
|
11
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
6
|
+
import { useCallback, useEffect, useState } from "react";
|
|
12
7
|
import { Toaster } from "sonner";
|
|
13
8
|
import {
|
|
14
9
|
getLastAuthProvider,
|
|
@@ -23,6 +18,9 @@ import { ClientType, setClientType } from "../../../client-manager";
|
|
|
23
18
|
import { StyleRoot } from "../StyleRoot";
|
|
24
19
|
import { B3Context, B3ContextType } from "./types";
|
|
25
20
|
|
|
21
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
22
|
+
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
23
|
+
|
|
26
24
|
/**
|
|
27
25
|
* Default permissions configuration for B3 provider
|
|
28
26
|
*/
|
|
@@ -33,6 +31,11 @@ const DEFAULT_PERMISSIONS = {
|
|
|
33
31
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
34
32
|
};
|
|
35
33
|
|
|
34
|
+
export const wagmiConfig = createConfig({
|
|
35
|
+
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
36
|
+
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http()])) as any,
|
|
37
|
+
});
|
|
38
|
+
|
|
36
39
|
// Create queryClient instance
|
|
37
40
|
const queryClient = new QueryClient();
|
|
38
41
|
|
|
@@ -48,7 +51,6 @@ export function B3Provider({
|
|
|
48
51
|
simDuneApiKey,
|
|
49
52
|
toaster,
|
|
50
53
|
clientType = "rest",
|
|
51
|
-
partnerId,
|
|
52
54
|
}: {
|
|
53
55
|
theme: "light" | "dark";
|
|
54
56
|
children: React.ReactNode;
|
|
@@ -61,7 +63,6 @@ export function B3Provider({
|
|
|
61
63
|
style?: React.CSSProperties;
|
|
62
64
|
};
|
|
63
65
|
clientType?: ClientType;
|
|
64
|
-
partnerId?: string;
|
|
65
66
|
}) {
|
|
66
67
|
// Initialize Google Analytics on mount
|
|
67
68
|
useEffect(() => {
|
|
@@ -73,33 +74,6 @@ export function B3Provider({
|
|
|
73
74
|
setClientType(clientType);
|
|
74
75
|
}, [clientType]);
|
|
75
76
|
|
|
76
|
-
const ecocystemConfig = useMemo(() => {
|
|
77
|
-
if (!partnerId) return undefined;
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
ecosystemId: ecosystemWalletId,
|
|
81
|
-
partnerId: partnerId,
|
|
82
|
-
client,
|
|
83
|
-
};
|
|
84
|
-
}, [partnerId]);
|
|
85
|
-
|
|
86
|
-
const wagmiConfig = useMemo(
|
|
87
|
-
() =>
|
|
88
|
-
createConfig({
|
|
89
|
-
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
90
|
-
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http()])) as any,
|
|
91
|
-
connectors: [
|
|
92
|
-
inAppWalletConnector({
|
|
93
|
-
...ecocystemConfig,
|
|
94
|
-
client,
|
|
95
|
-
}),
|
|
96
|
-
// injected(),
|
|
97
|
-
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
98
|
-
],
|
|
99
|
-
}),
|
|
100
|
-
[partnerId],
|
|
101
|
-
);
|
|
102
|
-
|
|
103
77
|
return (
|
|
104
78
|
<WagmiProvider config={wagmiConfig}>
|
|
105
79
|
<QueryClientProvider client={queryClient}>
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClientSelectionApp = ClientSelectionApp;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("../../global-account/react");
|
|
6
|
-
const react_2 = require("react");
|
|
7
|
-
/**
|
|
8
|
-
* Example component showing how to use the client selection system
|
|
9
|
-
*/
|
|
10
|
-
function ClientSelectionExample() {
|
|
11
|
-
const { clientType, switchClientType, getCurrentClient, authenticateWithType } = (0, react_1.useClient)();
|
|
12
|
-
const { user } = (0, react_1.useB3)();
|
|
13
|
-
const [data, setData] = (0, react_2.useState)(null);
|
|
14
|
-
const [loading, setLoading] = (0, react_2.useState)(false);
|
|
15
|
-
const handleSwitchClient = (type) => {
|
|
16
|
-
switchClientType(type);
|
|
17
|
-
};
|
|
18
|
-
const handleFetchData = async () => {
|
|
19
|
-
setLoading(true);
|
|
20
|
-
try {
|
|
21
|
-
const client = getCurrentClient();
|
|
22
|
-
const result = await client.service("users").find();
|
|
23
|
-
setData(result);
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
console.error("Failed to fetch data:", error);
|
|
27
|
-
}
|
|
28
|
-
finally {
|
|
29
|
-
setLoading(false);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const handleAuthenticateWithType = async (type) => {
|
|
33
|
-
try {
|
|
34
|
-
const result = await authenticateWithType(type, "your-access-token", "your-identity-token");
|
|
35
|
-
console.log(`Authenticated with ${type}:`, result);
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
console.error(`Authentication failed with ${type}:`, error);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: { padding: "20px", fontFamily: "Arial, sans-serif" }, children: [(0, jsx_runtime_1.jsx)("h2", { children: "Client Selection Example" }), (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: "20px" }, children: [(0, jsx_runtime_1.jsxs)("h3", { children: ["Current Client Type: ", clientType] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", gap: "10px", marginBottom: "10px" }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => handleSwitchClient("socket"), style: {
|
|
42
|
-
padding: "8px 16px",
|
|
43
|
-
backgroundColor: clientType === "socket" ? "#007bff" : "#f8f9fa",
|
|
44
|
-
color: clientType === "socket" ? "white" : "black",
|
|
45
|
-
border: "1px solid #007bff",
|
|
46
|
-
borderRadius: "4px",
|
|
47
|
-
cursor: "pointer"
|
|
48
|
-
}, children: "Switch to Socket" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => handleSwitchClient("rest"), style: {
|
|
49
|
-
padding: "8px 16px",
|
|
50
|
-
backgroundColor: clientType === "rest" ? "#007bff" : "#f8f9fa",
|
|
51
|
-
color: clientType === "rest" ? "white" : "black",
|
|
52
|
-
border: "1px solid #007bff",
|
|
53
|
-
borderRadius: "4px",
|
|
54
|
-
cursor: "pointer"
|
|
55
|
-
}, children: "Switch to REST" })] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: "20px" }, children: [(0, jsx_runtime_1.jsx)("h3", { children: "Test API Calls" }), (0, jsx_runtime_1.jsx)("button", { onClick: handleFetchData, disabled: loading, style: {
|
|
56
|
-
padding: "8px 16px",
|
|
57
|
-
backgroundColor: "#28a745",
|
|
58
|
-
color: "white",
|
|
59
|
-
border: "none",
|
|
60
|
-
borderRadius: "4px",
|
|
61
|
-
cursor: loading ? "not-allowed" : "pointer"
|
|
62
|
-
}, children: loading ? "Loading..." : "Fetch Data" }), data && ((0, jsx_runtime_1.jsx)("pre", { style: {
|
|
63
|
-
marginTop: "10px",
|
|
64
|
-
padding: "10px",
|
|
65
|
-
backgroundColor: "#f8f9fa",
|
|
66
|
-
borderRadius: "4px",
|
|
67
|
-
overflow: "auto"
|
|
68
|
-
}, children: JSON.stringify(data, null, 2) }))] }), (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: "20px" }, children: [(0, jsx_runtime_1.jsx)("h3", { children: "Authentication Tests" }), (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", gap: "10px" }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => handleAuthenticateWithType("socket"), style: {
|
|
69
|
-
padding: "8px 16px",
|
|
70
|
-
backgroundColor: "#17a2b8",
|
|
71
|
-
color: "white",
|
|
72
|
-
border: "none",
|
|
73
|
-
borderRadius: "4px",
|
|
74
|
-
cursor: "pointer"
|
|
75
|
-
}, children: "Auth with Socket" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => handleAuthenticateWithType("rest"), style: {
|
|
76
|
-
padding: "8px 16px",
|
|
77
|
-
backgroundColor: "#17a2b8",
|
|
78
|
-
color: "white",
|
|
79
|
-
border: "none",
|
|
80
|
-
borderRadius: "4px",
|
|
81
|
-
cursor: "pointer"
|
|
82
|
-
}, children: "Auth with REST" })] })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h3", { children: "User Status" }), (0, jsx_runtime_1.jsxs)("p", { children: ["Authenticated: ", user ? "Yes" : "No"] }), user && ((0, jsx_runtime_1.jsx)("pre", { style: {
|
|
83
|
-
padding: "10px",
|
|
84
|
-
backgroundColor: "#f8f9fa",
|
|
85
|
-
borderRadius: "4px",
|
|
86
|
-
overflow: "auto"
|
|
87
|
-
}, children: JSON.stringify(user, null, 2) }))] })] }));
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Example app showing different client configurations
|
|
91
|
-
*/
|
|
92
|
-
function ClientSelectionApp() {
|
|
93
|
-
const [clientType, setClientType] = (0, react_2.useState)("socket");
|
|
94
|
-
return ((0, jsx_runtime_1.jsx)(react_1.B3Provider, { environment: "development", clientType: clientType, automaticallySetFirstEoa: true, theme: "light", children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1", { children: "B3 SDK Client Selection Demo" }), (0, jsx_runtime_1.jsx)("div", { style: { marginBottom: "20px" }, children: (0, jsx_runtime_1.jsxs)("label", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Provider Client Type:" }), (0, jsx_runtime_1.jsxs)("select", { value: clientType, onChange: (e) => setClientType(e.target.value), style: { marginLeft: "10px", padding: "4px 8px" }, children: [(0, jsx_runtime_1.jsx)("option", { value: "socket", children: "Socket (Default)" }), (0, jsx_runtime_1.jsx)("option", { value: "rest", children: "REST" })] })] }) }), (0, jsx_runtime_1.jsx)(ClientSelectionExample, {})] }) }));
|
|
95
|
-
}
|
|
96
|
-
exports.default = ClientSelectionApp;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { B3Provider, useB3, useClient } from "../../global-account/react/index.js";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
/**
|
|
5
|
-
* Example component showing how to use the client selection system
|
|
6
|
-
*/
|
|
7
|
-
function ClientSelectionExample() {
|
|
8
|
-
const { clientType, switchClientType, getCurrentClient, authenticateWithType } = useClient();
|
|
9
|
-
const { user } = useB3();
|
|
10
|
-
const [data, setData] = useState(null);
|
|
11
|
-
const [loading, setLoading] = useState(false);
|
|
12
|
-
const handleSwitchClient = (type) => {
|
|
13
|
-
switchClientType(type);
|
|
14
|
-
};
|
|
15
|
-
const handleFetchData = async () => {
|
|
16
|
-
setLoading(true);
|
|
17
|
-
try {
|
|
18
|
-
const client = getCurrentClient();
|
|
19
|
-
const result = await client.service("users").find();
|
|
20
|
-
setData(result);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
console.error("Failed to fetch data:", error);
|
|
24
|
-
}
|
|
25
|
-
finally {
|
|
26
|
-
setLoading(false);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const handleAuthenticateWithType = async (type) => {
|
|
30
|
-
try {
|
|
31
|
-
const result = await authenticateWithType(type, "your-access-token", "your-identity-token");
|
|
32
|
-
console.log(`Authenticated with ${type}:`, result);
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
console.error(`Authentication failed with ${type}:`, error);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
return (_jsxs("div", { style: { padding: "20px", fontFamily: "Arial, sans-serif" }, children: [_jsx("h2", { children: "Client Selection Example" }), _jsxs("div", { style: { marginBottom: "20px" }, children: [_jsxs("h3", { children: ["Current Client Type: ", clientType] }), _jsxs("div", { style: { display: "flex", gap: "10px", marginBottom: "10px" }, children: [_jsx("button", { onClick: () => handleSwitchClient("socket"), style: {
|
|
39
|
-
padding: "8px 16px",
|
|
40
|
-
backgroundColor: clientType === "socket" ? "#007bff" : "#f8f9fa",
|
|
41
|
-
color: clientType === "socket" ? "white" : "black",
|
|
42
|
-
border: "1px solid #007bff",
|
|
43
|
-
borderRadius: "4px",
|
|
44
|
-
cursor: "pointer"
|
|
45
|
-
}, children: "Switch to Socket" }), _jsx("button", { onClick: () => handleSwitchClient("rest"), style: {
|
|
46
|
-
padding: "8px 16px",
|
|
47
|
-
backgroundColor: clientType === "rest" ? "#007bff" : "#f8f9fa",
|
|
48
|
-
color: clientType === "rest" ? "white" : "black",
|
|
49
|
-
border: "1px solid #007bff",
|
|
50
|
-
borderRadius: "4px",
|
|
51
|
-
cursor: "pointer"
|
|
52
|
-
}, children: "Switch to REST" })] })] }), _jsxs("div", { style: { marginBottom: "20px" }, children: [_jsx("h3", { children: "Test API Calls" }), _jsx("button", { onClick: handleFetchData, disabled: loading, style: {
|
|
53
|
-
padding: "8px 16px",
|
|
54
|
-
backgroundColor: "#28a745",
|
|
55
|
-
color: "white",
|
|
56
|
-
border: "none",
|
|
57
|
-
borderRadius: "4px",
|
|
58
|
-
cursor: loading ? "not-allowed" : "pointer"
|
|
59
|
-
}, children: loading ? "Loading..." : "Fetch Data" }), data && (_jsx("pre", { style: {
|
|
60
|
-
marginTop: "10px",
|
|
61
|
-
padding: "10px",
|
|
62
|
-
backgroundColor: "#f8f9fa",
|
|
63
|
-
borderRadius: "4px",
|
|
64
|
-
overflow: "auto"
|
|
65
|
-
}, children: JSON.stringify(data, null, 2) }))] }), _jsxs("div", { style: { marginBottom: "20px" }, children: [_jsx("h3", { children: "Authentication Tests" }), _jsxs("div", { style: { display: "flex", gap: "10px" }, children: [_jsx("button", { onClick: () => handleAuthenticateWithType("socket"), style: {
|
|
66
|
-
padding: "8px 16px",
|
|
67
|
-
backgroundColor: "#17a2b8",
|
|
68
|
-
color: "white",
|
|
69
|
-
border: "none",
|
|
70
|
-
borderRadius: "4px",
|
|
71
|
-
cursor: "pointer"
|
|
72
|
-
}, children: "Auth with Socket" }), _jsx("button", { onClick: () => handleAuthenticateWithType("rest"), style: {
|
|
73
|
-
padding: "8px 16px",
|
|
74
|
-
backgroundColor: "#17a2b8",
|
|
75
|
-
color: "white",
|
|
76
|
-
border: "none",
|
|
77
|
-
borderRadius: "4px",
|
|
78
|
-
cursor: "pointer"
|
|
79
|
-
}, children: "Auth with REST" })] })] }), _jsxs("div", { children: [_jsx("h3", { children: "User Status" }), _jsxs("p", { children: ["Authenticated: ", user ? "Yes" : "No"] }), user && (_jsx("pre", { style: {
|
|
80
|
-
padding: "10px",
|
|
81
|
-
backgroundColor: "#f8f9fa",
|
|
82
|
-
borderRadius: "4px",
|
|
83
|
-
overflow: "auto"
|
|
84
|
-
}, children: JSON.stringify(user, null, 2) }))] })] }));
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Example app showing different client configurations
|
|
88
|
-
*/
|
|
89
|
-
export function ClientSelectionApp() {
|
|
90
|
-
const [clientType, setClientType] = useState("socket");
|
|
91
|
-
return (_jsx(B3Provider, { environment: "development", clientType: clientType, automaticallySetFirstEoa: true, theme: "light", children: _jsxs("div", { children: [_jsx("h1", { children: "B3 SDK Client Selection Demo" }), _jsx("div", { style: { marginBottom: "20px" }, children: _jsxs("label", { children: [_jsx("strong", { children: "Provider Client Type:" }), _jsxs("select", { value: clientType, onChange: (e) => setClientType(e.target.value), style: { marginLeft: "10px", padding: "4px 8px" }, children: [_jsx("option", { value: "socket", children: "Socket (Default)" }), _jsx("option", { value: "rest", children: "REST" })] })] }) }), _jsx(ClientSelectionExample, {})] }) }));
|
|
92
|
-
}
|
|
93
|
-
export default ClientSelectionApp;
|