@b3dotfun/sdk 0.0.7-alpha.1 → 0.0.7-alpha.11
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.js +5 -2
- package/dist/cjs/anyspend/index.d.ts +1 -0
- package/dist/cjs/anyspend/index.js +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +33 -33
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +89 -49
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +3 -2
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +5 -3
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +4 -3
- package/dist/cjs/anyspend/react/components/AnySpendTournament.js +4 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +3 -18
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +4 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +4 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +3 -1
- package/dist/cjs/anyspend/services/anyspend.js +1 -1
- package/dist/cjs/anyspend/types/index.d.ts +1 -0
- package/dist/cjs/anyspend/types/index.js +1 -0
- package/dist/cjs/anyspend/types/metadata.d.ts +26 -0
- package/dist/cjs/anyspend/types/metadata.js +16 -0
- package/dist/cjs/anyspend/types/nft.d.ts +7 -0
- package/dist/cjs/anyspend/types/nft.js +2 -0
- package/dist/cjs/anyspend/types/order.d.ts +10 -0
- package/dist/cjs/anyspend/types/req-res/createOrder.d.ts +28 -0
- package/dist/cjs/anyspend/types/req-res/getOrderAndTransactions.d.ts +18 -0
- package/dist/cjs/anyspend/types/req-res/getOrderHistory.d.ts +14 -0
- package/dist/cjs/anyspend/types/req-res/getQuote.d.ts +11 -0
- package/dist/cjs/anyspend/types/req-res/getQuote.js +4 -1
- package/dist/cjs/anyspend/utils/orderPayload.d.ts +3 -3
- package/dist/cjs/anyspend/utils/orderPayload.js +18 -4
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +1 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.d.ts +14 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +50 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.d.ts +1 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +11 -16
- package/dist/cjs/global-account/react/components/StyleRoot.js +0 -1
- package/dist/cjs/global-account/react/components/custom/Icon.d.ts +7 -0
- package/dist/cjs/global-account/react/components/custom/Icon.js +52 -0
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.d.ts +4 -0
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +20 -0
- package/dist/cjs/global-account/react/hooks/useB3EnsName.d.ts +1 -4
- package/dist/cjs/global-account/react/hooks/useB3EnsName.js +22 -22
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/cjs/index.d.ts +0 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/shared/constants/index.d.ts +1 -0
- package/dist/cjs/shared/constants/index.js +2 -1
- package/dist/cjs/shared/utils/index.d.ts +9 -0
- package/dist/cjs/shared/utils/index.js +17 -0
- package/dist/esm/anyspend/constants/index.js +5 -2
- package/dist/esm/anyspend/index.d.ts +1 -0
- package/dist/esm/anyspend/index.js +1 -0
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +5 -5
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +66 -26
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +3 -2
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +5 -3
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +5 -4
- package/dist/esm/anyspend/react/components/AnySpendTournament.js +4 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +3 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +3 -18
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +4 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +4 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +3 -1
- package/dist/esm/anyspend/services/anyspend.js +1 -1
- package/dist/esm/anyspend/types/index.d.ts +1 -0
- package/dist/esm/anyspend/types/index.js +1 -0
- package/dist/esm/anyspend/types/metadata.d.ts +26 -0
- package/dist/esm/anyspend/types/metadata.js +11 -0
- package/dist/esm/anyspend/types/nft.d.ts +7 -0
- package/dist/esm/anyspend/types/nft.js +2 -0
- package/dist/esm/anyspend/types/order.d.ts +10 -0
- package/dist/esm/anyspend/types/req-res/createOrder.d.ts +28 -0
- package/dist/esm/anyspend/types/req-res/getOrderAndTransactions.d.ts +18 -0
- package/dist/esm/anyspend/types/req-res/getOrderHistory.d.ts +14 -0
- package/dist/esm/anyspend/types/req-res/getQuote.d.ts +11 -0
- package/dist/esm/anyspend/types/req-res/getQuote.js +4 -1
- package/dist/esm/anyspend/utils/orderPayload.d.ts +3 -3
- package/dist/esm/anyspend/utils/orderPayload.js +19 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +1 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.d.ts +14 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +44 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.d.ts +1 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +7 -12
- package/dist/esm/global-account/react/components/StyleRoot.js +0 -1
- package/dist/esm/global-account/react/components/custom/Icon.d.ts +7 -0
- package/dist/esm/global-account/react/components/custom/Icon.js +50 -0
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.d.ts +4 -0
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +17 -0
- package/dist/esm/global-account/react/hooks/useB3EnsName.d.ts +1 -4
- package/dist/esm/global-account/react/hooks/useB3EnsName.js +24 -21
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/esm/index.d.ts +0 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/shared/constants/index.d.ts +1 -0
- package/dist/esm/shared/constants/index.js +1 -0
- package/dist/esm/shared/utils/index.d.ts +9 -0
- package/dist/esm/shared/utils/index.js +15 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +2 -2
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +3 -2
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +3 -18
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendOrderAndTransactions.d.ts +4 -0
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +4 -0
- package/dist/types/anyspend/services/anyspend.d.ts +3 -1
- package/dist/types/anyspend/types/index.d.ts +1 -0
- package/dist/types/anyspend/types/metadata.d.ts +26 -0
- package/dist/types/anyspend/types/nft.d.ts +7 -0
- package/dist/types/anyspend/types/order.d.ts +10 -0
- package/dist/types/anyspend/types/req-res/createOrder.d.ts +28 -0
- package/dist/types/anyspend/types/req-res/getOrderAndTransactions.d.ts +18 -0
- package/dist/types/anyspend/types/req-res/getOrderHistory.d.ts +14 -0
- package/dist/types/anyspend/types/req-res/getQuote.d.ts +11 -0
- package/dist/types/anyspend/utils/orderPayload.d.ts +3 -3
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +1 -1
- package/dist/types/global-account/react/components/SignInWithB3/SignIn.d.ts +14 -0
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3.d.ts +1 -2
- package/dist/types/global-account/react/components/custom/Icon.d.ts +7 -0
- package/dist/types/global-account/react/components/custom/ManageAccountButton.d.ts +4 -0
- package/dist/types/global-account/react/hooks/useB3EnsName.d.ts +1 -4
- package/dist/types/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/shared/constants/index.d.ts +1 -0
- package/dist/types/shared/utils/index.d.ts +9 -0
- package/package.json +22 -3
- package/src/anyspend/constants/index.ts +5 -3
- package/src/anyspend/index.ts +1 -0
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +8 -7
- package/src/anyspend/react/components/AnySpendCustom.tsx +83 -30
- package/src/anyspend/react/components/AnySpendNFT.tsx +9 -4
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +7 -6
- package/src/anyspend/react/components/AnySpendTournament.tsx +4 -1
- package/src/anyspend/react/components/common/OrderDetails.tsx +6 -6
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +3 -13
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +2 -1
- package/src/anyspend/services/anyspend.ts +2 -2
- package/src/anyspend/types/index.ts +1 -0
- package/src/anyspend/types/metadata.ts +41 -0
- package/src/anyspend/types/nft.ts +3 -0
- package/src/anyspend/types/req-res/getQuote.ts +4 -1
- package/src/anyspend/utils/orderPayload.ts +17 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +2 -3
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +190 -0
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +15 -27
- package/src/global-account/react/components/StyleRoot.tsx +0 -1
- package/src/global-account/react/components/custom/Icon.tsx +102 -0
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +33 -0
- package/src/global-account/react/hooks/useB3EnsName.ts +26 -32
- package/src/global-account/react/stores/useModalStore.ts +2 -0
- package/src/index.ts +1 -0
- package/src/shared/constants/index.ts +2 -0
- package/src/shared/utils/index.ts +16 -0
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AnySpendMetadata,
|
|
3
|
+
CreateOrderParams,
|
|
2
4
|
eqci,
|
|
3
5
|
getDefaultToken,
|
|
4
6
|
GetQuoteRequest,
|
|
5
7
|
GetQuoteResponse,
|
|
8
|
+
isCustomTxMetadata,
|
|
9
|
+
isNftMetadata,
|
|
10
|
+
isTournamentMetadata,
|
|
11
|
+
Nft,
|
|
6
12
|
NftType,
|
|
7
13
|
OnrampVendor,
|
|
8
14
|
OrderStatus,
|
|
@@ -17,26 +23,27 @@ import {
|
|
|
17
23
|
useAnyspendTokenList,
|
|
18
24
|
useGeoOnrampOptions
|
|
19
25
|
} from "@b3dotfun/sdk/anyspend";
|
|
20
|
-
import { useB3, StyleRoot } from "@b3dotfun/sdk/global-account/react";
|
|
21
26
|
import {
|
|
22
27
|
Badge,
|
|
23
28
|
Button,
|
|
24
29
|
ShinyButton,
|
|
25
30
|
Skeleton,
|
|
31
|
+
StyleRoot,
|
|
26
32
|
Tabs,
|
|
27
33
|
TabsContent,
|
|
28
34
|
TabsList,
|
|
29
35
|
TabTrigger,
|
|
36
|
+
TextShimmer,
|
|
37
|
+
TransitionPanel,
|
|
30
38
|
useAccountWallet,
|
|
39
|
+
useB3,
|
|
31
40
|
useBsmntProfile,
|
|
32
41
|
useHasMounted,
|
|
33
|
-
useRouter,
|
|
34
|
-
useTokenBalancesByChain,
|
|
35
42
|
useModalStore,
|
|
36
|
-
|
|
43
|
+
useRouter,
|
|
44
|
+
useSearchParamsSSR,
|
|
45
|
+
useTokenBalancesByChain
|
|
37
46
|
} from "@b3dotfun/sdk/global-account/react";
|
|
38
|
-
import { TextShimmer } from "@b3dotfun/sdk/global-account/react";
|
|
39
|
-
import { TransitionPanel } from "@b3dotfun/sdk/global-account/react";
|
|
40
47
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
41
48
|
import centerTruncate from "@b3dotfun/sdk/shared/utils/centerTruncate";
|
|
42
49
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
@@ -68,6 +75,8 @@ function generateGetRelayQuoteRequest({
|
|
|
68
75
|
dstToken,
|
|
69
76
|
dstAmount,
|
|
70
77
|
contractAddress,
|
|
78
|
+
tokenId,
|
|
79
|
+
contractType,
|
|
71
80
|
encodedData,
|
|
72
81
|
spenderAddress
|
|
73
82
|
}: {
|
|
@@ -78,6 +87,8 @@ function generateGetRelayQuoteRequest({
|
|
|
78
87
|
dstToken: Token;
|
|
79
88
|
dstAmount: string;
|
|
80
89
|
contractAddress: string;
|
|
90
|
+
tokenId?: number | null;
|
|
91
|
+
contractType?: NftType;
|
|
81
92
|
encodedData: string;
|
|
82
93
|
spenderAddress?: string;
|
|
83
94
|
}): GetQuoteRequest {
|
|
@@ -90,7 +101,9 @@ function generateGetRelayQuoteRequest({
|
|
|
90
101
|
dstChain: dstChainId,
|
|
91
102
|
dstTokenAddress: dstToken.address,
|
|
92
103
|
price: dstAmount,
|
|
93
|
-
contractAddress: contractAddress
|
|
104
|
+
contractAddress: contractAddress,
|
|
105
|
+
tokenId: tokenId!,
|
|
106
|
+
contractType: contractType!
|
|
94
107
|
};
|
|
95
108
|
}
|
|
96
109
|
case OrderType.JoinTournament: {
|
|
@@ -164,7 +177,7 @@ export function AnySpendCustom({
|
|
|
164
177
|
dstAmount: string;
|
|
165
178
|
contractAddress: string;
|
|
166
179
|
encodedData: string;
|
|
167
|
-
metadata:
|
|
180
|
+
metadata: AnySpendMetadata;
|
|
168
181
|
header: ({
|
|
169
182
|
anyspendPrice,
|
|
170
183
|
isLoadingAnyspendPrice
|
|
@@ -274,6 +287,8 @@ export function AnySpendCustom({
|
|
|
274
287
|
dstToken: dstToken,
|
|
275
288
|
dstAmount: dstAmount,
|
|
276
289
|
contractAddress: contractAddress,
|
|
290
|
+
tokenId: isNftMetadata(metadata) ? metadata.nftContract.tokenId : undefined,
|
|
291
|
+
contractType: isNftMetadata(metadata) ? metadata.nftContract.type : undefined,
|
|
277
292
|
encodedData: encodedData,
|
|
278
293
|
spenderAddress: spenderAddress
|
|
279
294
|
});
|
|
@@ -372,23 +387,45 @@ export function AnySpendCustom({
|
|
|
372
387
|
srcAmount: srcAmount.toString(),
|
|
373
388
|
recipientAddress,
|
|
374
389
|
creatorAddress: currentWallet?.wallet?.address,
|
|
375
|
-
nft:
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
390
|
+
nft: isNftMetadata(metadata)
|
|
391
|
+
? metadata.nftContract.type === NftType.ERC1155
|
|
392
|
+
? ({
|
|
393
|
+
type: NftType.ERC1155,
|
|
394
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
395
|
+
tokenId: metadata.nftContract.tokenId!,
|
|
396
|
+
name: metadata.nftContract.name,
|
|
397
|
+
description: metadata.nftContract.description,
|
|
398
|
+
imageUrl: metadata.nftContract.imageUrl,
|
|
399
|
+
price: dstAmount
|
|
400
|
+
} as Nft)
|
|
401
|
+
: ({
|
|
402
|
+
type: NftType.ERC721,
|
|
403
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
404
|
+
contractType: metadata.nftContract.type,
|
|
405
|
+
price: dstAmount,
|
|
406
|
+
name: metadata.nftContract.name,
|
|
407
|
+
description: metadata.nftContract.description,
|
|
408
|
+
imageUrl: metadata.nftContract.imageUrl
|
|
409
|
+
} as Nft)
|
|
410
|
+
: undefined,
|
|
411
|
+
tournament: isTournamentMetadata(metadata)
|
|
412
|
+
? {
|
|
413
|
+
...metadata.tournament,
|
|
414
|
+
contractAddress: contractAddress,
|
|
415
|
+
entryPriceOrFundAmount: dstAmount
|
|
416
|
+
}
|
|
417
|
+
: undefined,
|
|
418
|
+
// only populate payload for custom tx
|
|
419
|
+
payload: isCustomTxMetadata(metadata)
|
|
420
|
+
? {
|
|
421
|
+
amount: dstAmount,
|
|
422
|
+
data: encodedData,
|
|
423
|
+
spenderAddress: spenderAddress,
|
|
424
|
+
to: contractAddress,
|
|
425
|
+
action: metadata.action
|
|
426
|
+
}
|
|
427
|
+
: undefined
|
|
428
|
+
} as CreateOrderParams;
|
|
392
429
|
|
|
393
430
|
if (onramp) {
|
|
394
431
|
invariant(srcToken.address === USDC_BASE.address, "Selected src token is not USDC");
|
|
@@ -749,14 +786,30 @@ export function AnySpendCustom({
|
|
|
749
786
|
onOrderCreated={(orderId: string) => setOrderId(orderId)}
|
|
750
787
|
onBack={() => setActiveTab("crypto")}
|
|
751
788
|
orderType={orderType}
|
|
752
|
-
nft={
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
789
|
+
nft={
|
|
790
|
+
isNftMetadata(metadata)
|
|
791
|
+
? metadata.nftContract.type === NftType.ERC1155
|
|
792
|
+
? {
|
|
793
|
+
type: NftType.ERC1155,
|
|
794
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
795
|
+
tokenId: metadata.nftContract.tokenId!,
|
|
796
|
+
imageUrl: metadata.nftContract.imageUrl,
|
|
797
|
+
name: metadata.nftContract.name,
|
|
798
|
+
description: metadata.nftContract.description,
|
|
799
|
+
price: dstAmount
|
|
800
|
+
}
|
|
801
|
+
: {
|
|
802
|
+
type: NftType.ERC721,
|
|
803
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
804
|
+
name: metadata.nftContract.name,
|
|
805
|
+
description: metadata.nftContract.description,
|
|
806
|
+
imageUrl: metadata.nftContract.imageUrl,
|
|
807
|
+
price: dstAmount
|
|
808
|
+
}
|
|
756
809
|
: undefined
|
|
757
810
|
}
|
|
758
811
|
payload={
|
|
759
|
-
metadata
|
|
812
|
+
isCustomTxMetadata(metadata)
|
|
760
813
|
? {
|
|
761
814
|
...metadata,
|
|
762
815
|
amount: dstAmount,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ALL_CHAINS, getChainName, getExplorerAddressUrl, GetQuoteResponse, OrderType } from "@b3dotfun/sdk/anyspend";
|
|
2
|
-
import { DEFAULT_NFT_CONTRACT } from "@b3dotfun/sdk/anyspend/constants";
|
|
3
2
|
import { NftContract } from "@b3dotfun/sdk/anyspend/types";
|
|
4
3
|
import { GlareCard, Popover, PopoverContent, PopoverTrigger } from "@b3dotfun/sdk/global-account/react";
|
|
5
4
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
@@ -16,13 +15,15 @@ export function AnySpendNFT({
|
|
|
16
15
|
loadOrder,
|
|
17
16
|
mode = "modal",
|
|
18
17
|
recipientAddress,
|
|
19
|
-
nftContract
|
|
18
|
+
nftContract,
|
|
19
|
+
onSuccess
|
|
20
20
|
}: {
|
|
21
21
|
isMainnet?: boolean;
|
|
22
22
|
loadOrder?: string;
|
|
23
23
|
mode?: "modal" | "page";
|
|
24
24
|
recipientAddress?: string;
|
|
25
|
-
nftContract
|
|
25
|
+
nftContract: NftContract;
|
|
26
|
+
onSuccess?: (txHash?: string) => void;
|
|
26
27
|
}) {
|
|
27
28
|
const header = ({
|
|
28
29
|
anyspendPrice,
|
|
@@ -78,8 +79,12 @@ export function AnySpendNFT({
|
|
|
78
79
|
dstAmount={nftContract.price}
|
|
79
80
|
contractAddress={nftContract.contractAddress}
|
|
80
81
|
encodedData="0x"
|
|
81
|
-
metadata={{
|
|
82
|
+
metadata={{
|
|
83
|
+
type: OrderType.MintNFT,
|
|
84
|
+
nftContract: nftContract
|
|
85
|
+
}}
|
|
82
86
|
header={header}
|
|
87
|
+
onSuccess={onSuccess}
|
|
83
88
|
/>
|
|
84
89
|
);
|
|
85
90
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { ABI_ERC20_STAKING, B3_TOKEN, OrderType } from "@b3dotfun/sdk/anyspend";
|
|
2
|
-
import { EthIcon } from "./icons/EthIcon";
|
|
3
|
-
import { SolIcon } from "./icons/SolIcon";
|
|
4
|
-
import { UsdcIcon } from "./icons/USDCIcon";
|
|
5
2
|
import {
|
|
6
3
|
Button,
|
|
7
4
|
GlareCardRounded,
|
|
8
5
|
Input,
|
|
6
|
+
StyleRoot,
|
|
9
7
|
TextLoop,
|
|
8
|
+
useChainSwitchWithAction,
|
|
10
9
|
useHasMounted,
|
|
11
10
|
useModalStore,
|
|
12
|
-
|
|
13
|
-
useTokenBalance,
|
|
14
|
-
StyleRoot
|
|
11
|
+
useTokenBalance
|
|
15
12
|
} from "@b3dotfun/sdk/global-account/react";
|
|
16
13
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
17
14
|
import { motion } from "framer-motion";
|
|
@@ -23,6 +20,9 @@ import { createPublicClient, encodeFunctionData, erc20Abi, http } from "viem";
|
|
|
23
20
|
import { base } from "viem/chains";
|
|
24
21
|
import { useAccount, useWaitForTransactionReceipt, useWriteContract } from "wagmi";
|
|
25
22
|
import { AnySpendCustom } from "./AnySpendCustom";
|
|
23
|
+
import { EthIcon } from "./icons/EthIcon";
|
|
24
|
+
import { SolIcon } from "./icons/SolIcon";
|
|
25
|
+
import { UsdcIcon } from "./icons/USDCIcon";
|
|
26
26
|
|
|
27
27
|
const basePublicClient = createPublicClient({
|
|
28
28
|
chain: base,
|
|
@@ -483,6 +483,7 @@ export function AnySpendStakeB3({
|
|
|
483
483
|
contractAddress={ERC20Staking}
|
|
484
484
|
encodedData={encodedData}
|
|
485
485
|
metadata={{
|
|
486
|
+
type: OrderType.Custom,
|
|
486
487
|
action: "stake B3"
|
|
487
488
|
}}
|
|
488
489
|
header={header}
|
|
@@ -100,7 +100,10 @@ export function AnySpendTournament(props: AnySpendTournamentProps) {
|
|
|
100
100
|
dstAmount={dstAmount}
|
|
101
101
|
contractAddress={tournamentContractAddress}
|
|
102
102
|
encodedData="0x"
|
|
103
|
-
metadata={{
|
|
103
|
+
metadata={{
|
|
104
|
+
type: action === "join" ? OrderType.JoinTournament : OrderType.FundTournament,
|
|
105
|
+
tournament: tournamentMetadata
|
|
106
|
+
}}
|
|
104
107
|
header={header}
|
|
105
108
|
onSuccess={onSuccess}
|
|
106
109
|
showRecipient={action === "join"}
|
|
@@ -23,17 +23,17 @@ import {
|
|
|
23
23
|
zTournament
|
|
24
24
|
} from "@b3dotfun/sdk/anyspend";
|
|
25
25
|
import {
|
|
26
|
-
CopyToClipboard,
|
|
27
26
|
Badge,
|
|
27
|
+
Button,
|
|
28
|
+
CopyToClipboard,
|
|
28
29
|
ShinyButton,
|
|
29
30
|
Skeleton,
|
|
30
31
|
TextLoop,
|
|
31
32
|
TextShimmer,
|
|
32
|
-
Button,
|
|
33
33
|
useAccountWallet,
|
|
34
34
|
useChainSwitchWithAction,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
useModalStore,
|
|
36
|
+
useOnchainName
|
|
37
37
|
} from "@b3dotfun/sdk/global-account/react";
|
|
38
38
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
39
39
|
import centerTruncate from "@b3dotfun/sdk/shared/utils/centerTruncate";
|
|
@@ -334,7 +334,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
334
334
|
|
|
335
335
|
// When waitingForDeposit is true, we show a message to the user to wait for the deposit to be processed.
|
|
336
336
|
const setWaitingForDeposit = useCallback(() => {
|
|
337
|
-
const params = new URLSearchParams(searchParams);
|
|
337
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
338
338
|
params.set("waitingForDeposit", "true");
|
|
339
339
|
router.push(`?${params}`);
|
|
340
340
|
}, [router, searchParams]);
|
|
@@ -865,7 +865,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
865
865
|
BigInt(order.srcAmount),
|
|
866
866
|
order.srcTokenAddress === RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress
|
|
867
867
|
)}
|
|
868
|
-
|
|
868
|
+
className="max-w-[200px]"
|
|
869
869
|
/>
|
|
870
870
|
<div className="mt-3 flex items-center justify-center gap-2 text-sm">
|
|
871
871
|
<span className="label-style text-as-brand/70 text-sm">Scan with</span>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { USDC_BASE } from "@b3dotfun/sdk/anyspend/constants";
|
|
2
2
|
import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
3
|
-
import {
|
|
3
|
+
import { OnrampVendor } from "@b3dotfun/sdk/anyspend/types";
|
|
4
4
|
import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
|
|
5
5
|
import { useMutation } from "@tanstack/react-query";
|
|
6
6
|
import { useMemo } from "react";
|
|
7
7
|
import { parseUnits } from "viem";
|
|
8
8
|
import { base } from "viem/chains";
|
|
9
|
+
import { CreateOrderParams } from "./useAnyspendCreateOrder";
|
|
9
10
|
|
|
10
11
|
export type OnrampOptions = {
|
|
11
12
|
vendor: OnrampVendor;
|
|
@@ -15,20 +16,9 @@ export type OnrampOptions = {
|
|
|
15
16
|
ipAddress?: string; // Required for Stripe
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
export type CreateOnrampOrderParams = {
|
|
19
|
-
isMainnet: boolean;
|
|
20
|
-
recipientAddress: string;
|
|
21
|
-
orderType: OrderType;
|
|
22
|
-
dstChain: number;
|
|
23
|
-
dstToken: Token;
|
|
19
|
+
export type CreateOnrampOrderParams = Omit<CreateOrderParams, "srcChain" | "srcToken" | "srcAmount"> & {
|
|
24
20
|
srcFiatAmount: string;
|
|
25
21
|
onramp: OnrampOptions;
|
|
26
|
-
partnerId?: string;
|
|
27
|
-
expectedDstAmount: string;
|
|
28
|
-
creatorAddress?: string;
|
|
29
|
-
nft?: Nft & { price: string };
|
|
30
|
-
tournament?: Tournament & { contractAddress: string; entryPriceOrFundAmount: string };
|
|
31
|
-
payload?: any;
|
|
32
22
|
};
|
|
33
23
|
|
|
34
24
|
export type UseAnyspendCreateOnrampOrderProps = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
2
2
|
import { Nft, OrderType, Token, Tournament } from "@b3dotfun/sdk/anyspend/types";
|
|
3
|
-
import {
|
|
3
|
+
import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
|
|
4
4
|
import { useMutation } from "@tanstack/react-query";
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
|
|
@@ -18,6 +18,7 @@ export type CreateOrderParams = {
|
|
|
18
18
|
tournament?: Tournament & { contractAddress: string; entryPriceOrFundAmount: string };
|
|
19
19
|
creatorAddress?: string;
|
|
20
20
|
payload?: any;
|
|
21
|
+
partnerId?: string;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
export type UseAnyspendCreateOrderProps = {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ANYSPEND_MAINNET_BASE_URL, ANYSPEND_TESTNET_BASE_URL } from "@b3dotfun/sdk/anyspend/constants";
|
|
2
|
+
import { OnrampOptions } from "@b3dotfun/sdk/anyspend/react";
|
|
1
3
|
import {
|
|
2
4
|
GetOrderAndTxsResponse,
|
|
3
5
|
GetQuoteRequest,
|
|
@@ -11,8 +13,6 @@ import {
|
|
|
11
13
|
} from "@b3dotfun/sdk/anyspend/types";
|
|
12
14
|
import { getNativeToken, isNativeToken } from "@b3dotfun/sdk/anyspend/utils";
|
|
13
15
|
import invariant from "invariant";
|
|
14
|
-
import { ANYSPEND_MAINNET_BASE_URL, ANYSPEND_TESTNET_BASE_URL } from "@b3dotfun/sdk/anyspend/constants";
|
|
15
|
-
import { OnrampOptions } from "@b3dotfun/sdk/anyspend/react";
|
|
16
16
|
|
|
17
17
|
// Service functions
|
|
18
18
|
export const anyspendService = {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { NftContract } from "./nft";
|
|
2
|
+
import { OrderType } from "./order";
|
|
3
|
+
|
|
4
|
+
export type BaseMetadata = {
|
|
5
|
+
type: OrderType;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type NftMetadata = BaseMetadata & {
|
|
9
|
+
type: OrderType.MintNFT;
|
|
10
|
+
nftContract: NftContract;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type TournamentMetadata = BaseMetadata & {
|
|
14
|
+
type: OrderType.JoinTournament | OrderType.FundTournament;
|
|
15
|
+
tournament: {
|
|
16
|
+
slug: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
imageUrl: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type CustomTxMetadata = BaseMetadata & {
|
|
24
|
+
type: OrderType.Custom;
|
|
25
|
+
action: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type AnySpendMetadata = NftMetadata | TournamentMetadata | CustomTxMetadata;
|
|
29
|
+
|
|
30
|
+
// Type guard functions
|
|
31
|
+
export function isNftMetadata(metadata: AnySpendMetadata): metadata is NftMetadata {
|
|
32
|
+
return metadata.type === OrderType.MintNFT;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isTournamentMetadata(metadata: AnySpendMetadata): metadata is TournamentMetadata {
|
|
36
|
+
return metadata.type === OrderType.JoinTournament || metadata.type === OrderType.FundTournament;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function isCustomTxMetadata(metadata: AnySpendMetadata): metadata is CustomTxMetadata {
|
|
40
|
+
return metadata.type === OrderType.Custom;
|
|
41
|
+
}
|
|
@@ -28,6 +28,8 @@ export type Nft = z.infer<typeof zNft>;
|
|
|
28
28
|
|
|
29
29
|
export const zMintNftPayload = z.object({
|
|
30
30
|
contractAddress: z.string(),
|
|
31
|
+
tokenId: z.number().nullable(),
|
|
32
|
+
contractType: z.nativeEnum(NftType),
|
|
31
33
|
nftPrice: z.string()
|
|
32
34
|
});
|
|
33
35
|
|
|
@@ -47,4 +49,5 @@ export interface NftContract {
|
|
|
47
49
|
name: string;
|
|
48
50
|
description: string;
|
|
49
51
|
tokenId: number | null;
|
|
52
|
+
type: NftType;
|
|
50
53
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { QuoteDetails } from "@reservoir0x/relay-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
+
import { zCustomPayload } from "../custom";
|
|
5
|
+
import { NftType } from "../nft";
|
|
4
6
|
import { OrderType } from "../order";
|
|
5
7
|
import { TradeType } from "../relay";
|
|
6
|
-
import { zCustomPayload } from "../custom";
|
|
7
8
|
|
|
8
9
|
const zGetQuoteBody = z.object({
|
|
9
10
|
srcChain: z.number(),
|
|
@@ -21,6 +22,8 @@ const zGetQuoteForSwapOrderBody = zGetQuoteBody.extend({
|
|
|
21
22
|
const zGetQuoteForMintNftOrderBody = zGetQuoteBody.extend({
|
|
22
23
|
type: z.literal(OrderType.MintNFT),
|
|
23
24
|
contractAddress: z.string(),
|
|
25
|
+
tokenId: z.number().nullable(),
|
|
26
|
+
contractType: z.nativeEnum(NftType),
|
|
24
27
|
price: z.string()
|
|
25
28
|
});
|
|
26
29
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Nft, OrderType, Token, Tournament } from "@b3dotfun/sdk/anyspend/types";
|
|
1
|
+
import { Nft, NftType, OrderType, Token, Tournament } from "@b3dotfun/sdk/anyspend/types";
|
|
2
2
|
import { normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
|
|
3
3
|
|
|
4
4
|
export type OrderParams = {
|
|
@@ -20,10 +20,22 @@ export const buildPayload = (orderType: OrderType, params: OrderParams) => {
|
|
|
20
20
|
actualDstAmount: null
|
|
21
21
|
};
|
|
22
22
|
case OrderType.MintNFT:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (nft?.type === NftType.ERC1155) {
|
|
24
|
+
return {
|
|
25
|
+
contractAddress: normalizeAddress(nft.contractAddress),
|
|
26
|
+
nftPrice: nft?.price || "",
|
|
27
|
+
tokenId: nft?.tokenId!,
|
|
28
|
+
contractType: nft?.type
|
|
29
|
+
};
|
|
30
|
+
} else if (nft?.type === NftType.ERC721) {
|
|
31
|
+
return {
|
|
32
|
+
contractAddress: normalizeAddress(nft.contractAddress),
|
|
33
|
+
nftPrice: nft?.price || "",
|
|
34
|
+
contractType: nft?.type
|
|
35
|
+
};
|
|
36
|
+
} else {
|
|
37
|
+
throw new Error(`Invalid nft payload: ${JSON.stringify(nft)}`);
|
|
38
|
+
}
|
|
27
39
|
case OrderType.JoinTournament:
|
|
28
40
|
return {
|
|
29
41
|
contractAddress: tournament?.contractAddress,
|
|
@@ -9,9 +9,9 @@ import { Account, Wallet } from "thirdweb/wallets";
|
|
|
9
9
|
import { createConfig, http, WagmiProvider } from "wagmi";
|
|
10
10
|
import { RelayKitProviderWrapper } from "../RelayKitProviderWrapper";
|
|
11
11
|
import { StyleRoot } from "../StyleRoot";
|
|
12
|
+
import { B3Context, B3ContextType } from "./types";
|
|
12
13
|
|
|
13
14
|
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
14
|
-
import { B3Context, B3ContextType } from "./types";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Default permissions configuration for B3 provider
|
|
@@ -61,9 +61,8 @@ export function B3Provider({
|
|
|
61
61
|
>
|
|
62
62
|
<RelayKitProviderWrapper isMainnet={isMainnetAnySpend}>
|
|
63
63
|
{children}
|
|
64
|
-
{/*
|
|
64
|
+
{/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
|
|
65
65
|
<StyleRoot id="b3-root" />
|
|
66
|
-
{/* For the modal https://github.com/b3-fun/b3-mono/blob/main/packages/react/src/components/ui/dialog.tsx#L46 */}
|
|
67
66
|
<Toaster theme={theme} />
|
|
68
67
|
</RelayKitProviderWrapper>
|
|
69
68
|
</InnerProvider>
|