@b3dotfun/sdk 0.0.7-alpha.6 → 0.0.7-alpha.8

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.
Files changed (69) hide show
  1. package/dist/cjs/anyspend/constants/index.js +5 -2
  2. package/dist/cjs/anyspend/index.d.ts +1 -0
  3. package/dist/cjs/anyspend/index.js +1 -0
  4. package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +33 -33
  5. package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +2 -2
  6. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +75 -43
  7. package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +3 -2
  8. package/dist/cjs/anyspend/react/components/AnySpendNFT.js +5 -3
  9. package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +4 -3
  10. package/dist/cjs/anyspend/react/components/AnySpendTournament.js +4 -1
  11. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
  12. package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
  13. package/dist/cjs/anyspend/services/anyspend.js +1 -1
  14. package/dist/cjs/anyspend/types/index.d.ts +1 -0
  15. package/dist/cjs/anyspend/types/index.js +1 -0
  16. package/dist/cjs/anyspend/types/metadata.d.ts +26 -0
  17. package/dist/cjs/anyspend/types/metadata.js +16 -0
  18. package/dist/cjs/anyspend/types/nft.d.ts +1 -0
  19. package/dist/cjs/anyspend/types/req-res/getQuote.d.ts +11 -0
  20. package/dist/cjs/anyspend/types/req-res/getQuote.js +4 -1
  21. package/dist/cjs/anyspend/utils/orderPayload.d.ts +3 -3
  22. package/dist/cjs/anyspend/utils/orderPayload.js +18 -4
  23. package/dist/esm/anyspend/constants/index.js +5 -2
  24. package/dist/esm/anyspend/index.d.ts +1 -0
  25. package/dist/esm/anyspend/index.js +1 -0
  26. package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +5 -5
  27. package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +2 -2
  28. package/dist/esm/anyspend/react/components/AnySpendCustom.js +52 -20
  29. package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +3 -2
  30. package/dist/esm/anyspend/react/components/AnySpendNFT.js +5 -3
  31. package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +5 -4
  32. package/dist/esm/anyspend/react/components/AnySpendTournament.js +4 -1
  33. package/dist/esm/anyspend/react/components/common/OrderDetails.js +2 -2
  34. package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
  35. package/dist/esm/anyspend/services/anyspend.js +1 -1
  36. package/dist/esm/anyspend/types/index.d.ts +1 -0
  37. package/dist/esm/anyspend/types/index.js +1 -0
  38. package/dist/esm/anyspend/types/metadata.d.ts +26 -0
  39. package/dist/esm/anyspend/types/metadata.js +11 -0
  40. package/dist/esm/anyspend/types/nft.d.ts +1 -0
  41. package/dist/esm/anyspend/types/req-res/getQuote.d.ts +11 -0
  42. package/dist/esm/anyspend/types/req-res/getQuote.js +4 -1
  43. package/dist/esm/anyspend/utils/orderPayload.d.ts +3 -3
  44. package/dist/esm/anyspend/utils/orderPayload.js +19 -5
  45. package/dist/styles/index.css +1 -1
  46. package/dist/types/anyspend/index.d.ts +1 -0
  47. package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +2 -2
  48. package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +3 -2
  49. package/dist/types/anyspend/services/anyspend.d.ts +1 -1
  50. package/dist/types/anyspend/types/index.d.ts +1 -0
  51. package/dist/types/anyspend/types/metadata.d.ts +26 -0
  52. package/dist/types/anyspend/types/nft.d.ts +1 -0
  53. package/dist/types/anyspend/types/req-res/getQuote.d.ts +11 -0
  54. package/dist/types/anyspend/utils/orderPayload.d.ts +3 -3
  55. package/package.json +1 -1
  56. package/src/anyspend/constants/index.ts +5 -3
  57. package/src/anyspend/index.ts +1 -0
  58. package/src/anyspend/react/components/AnySpendBuySpin.tsx +8 -7
  59. package/src/anyspend/react/components/AnySpendCustom.tsx +68 -24
  60. package/src/anyspend/react/components/AnySpendNFT.tsx +9 -4
  61. package/src/anyspend/react/components/AnySpendStakeB3.tsx +7 -6
  62. package/src/anyspend/react/components/AnySpendTournament.tsx +4 -1
  63. package/src/anyspend/react/components/common/OrderDetails.tsx +5 -5
  64. package/src/anyspend/services/anyspend.ts +2 -2
  65. package/src/anyspend/types/index.ts +1 -0
  66. package/src/anyspend/types/metadata.ts +41 -0
  67. package/src/anyspend/types/nft.ts +1 -0
  68. package/src/anyspend/types/req-res/getQuote.ts +4 -1
  69. package/src/anyspend/utils/orderPayload.ts +17 -5
@@ -1,19 +1,16 @@
1
1
  import { B3_TOKEN, OrderType } from "@b3dotfun/sdk/anyspend";
2
- import { baseMainnet } from "@b3dotfun/sdk/shared/constants/chains/supported";
3
- import { EthIcon } from "./icons/EthIcon";
4
- import { SolIcon } from "./icons/SolIcon";
5
- import { UsdcIcon } from "./icons/USDCIcon";
6
- import { StyleRoot } from "@b3dotfun/sdk/global-account/react";
7
2
  import {
8
3
  Button,
9
4
  GlareCardRounded,
10
5
  Input,
6
+ StyleRoot,
11
7
  TextLoop,
12
8
  useChainSwitchWithAction,
13
9
  useHasMounted,
14
- useTokenBalance,
15
- useModalStore
10
+ useModalStore,
11
+ useTokenBalance
16
12
  } from "@b3dotfun/sdk/global-account/react";
13
+ import { baseMainnet } from "@b3dotfun/sdk/shared/constants/chains/supported";
17
14
  import { motion } from "framer-motion";
18
15
  import invariant from "invariant";
19
16
  import { ArrowRight, Loader2 } from "lucide-react";
@@ -22,6 +19,9 @@ import { toast } from "sonner";
22
19
  import { createPublicClient, encodeFunctionData, erc20Abi, formatUnits, http } from "viem";
23
20
  import { useAccount, useWaitForTransactionReceipt, useWriteContract } from "wagmi";
24
21
  import { AnySpendCustom } from "./AnySpendCustom";
22
+ import { EthIcon } from "./icons/EthIcon";
23
+ import { SolIcon } from "./icons/SolIcon";
24
+ import { UsdcIcon } from "./icons/USDCIcon";
25
25
 
26
26
  const SPIN_WHEEL_ABI = [
27
27
  {
@@ -668,6 +668,7 @@ export function AnySpendBuySpin({
668
668
  spenderAddress={paymentConfig.entryModule}
669
669
  encodedData={encodedData}
670
670
  metadata={{
671
+ type: OrderType.Custom,
671
672
  action: `buy ${userSpinQuantity} spin${userSpinQuantity !== "1" ? "s" : ""}`
672
673
  }}
673
674
  header={header}
@@ -1,8 +1,13 @@
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,
6
11
  NftType,
7
12
  OnrampVendor,
8
13
  OrderStatus,
@@ -17,26 +22,27 @@ import {
17
22
  useAnyspendTokenList,
18
23
  useGeoOnrampOptions
19
24
  } from "@b3dotfun/sdk/anyspend";
20
- import { useB3, StyleRoot } from "@b3dotfun/sdk/global-account/react";
21
25
  import {
22
26
  Badge,
23
27
  Button,
24
28
  ShinyButton,
25
29
  Skeleton,
30
+ StyleRoot,
26
31
  Tabs,
27
32
  TabsContent,
28
33
  TabsList,
29
34
  TabTrigger,
35
+ TextShimmer,
36
+ TransitionPanel,
30
37
  useAccountWallet,
38
+ useB3,
31
39
  useBsmntProfile,
32
40
  useHasMounted,
33
- useRouter,
34
- useTokenBalancesByChain,
35
41
  useModalStore,
36
- useSearchParamsSSR
42
+ useRouter,
43
+ useSearchParamsSSR,
44
+ useTokenBalancesByChain
37
45
  } 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
46
  import { cn } from "@b3dotfun/sdk/shared/utils";
41
47
  import centerTruncate from "@b3dotfun/sdk/shared/utils/centerTruncate";
42
48
  import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
@@ -68,6 +74,8 @@ function generateGetRelayQuoteRequest({
68
74
  dstToken,
69
75
  dstAmount,
70
76
  contractAddress,
77
+ tokenId,
78
+ contractType,
71
79
  encodedData,
72
80
  spenderAddress
73
81
  }: {
@@ -78,6 +86,8 @@ function generateGetRelayQuoteRequest({
78
86
  dstToken: Token;
79
87
  dstAmount: string;
80
88
  contractAddress: string;
89
+ tokenId?: number | null;
90
+ contractType?: NftType;
81
91
  encodedData: string;
82
92
  spenderAddress?: string;
83
93
  }): GetQuoteRequest {
@@ -90,7 +100,9 @@ function generateGetRelayQuoteRequest({
90
100
  dstChain: dstChainId,
91
101
  dstTokenAddress: dstToken.address,
92
102
  price: dstAmount,
93
- contractAddress: contractAddress
103
+ contractAddress: contractAddress,
104
+ tokenId: tokenId!,
105
+ contractType: contractType!
94
106
  };
95
107
  }
96
108
  case OrderType.JoinTournament: {
@@ -164,7 +176,7 @@ export function AnySpendCustom({
164
176
  dstAmount: string;
165
177
  contractAddress: string;
166
178
  encodedData: string;
167
- metadata: any;
179
+ metadata: AnySpendMetadata;
168
180
  header: ({
169
181
  anyspendPrice,
170
182
  isLoadingAnyspendPrice
@@ -274,6 +286,8 @@ export function AnySpendCustom({
274
286
  dstToken: dstToken,
275
287
  dstAmount: dstAmount,
276
288
  contractAddress: contractAddress,
289
+ tokenId: isNftMetadata(metadata) ? metadata.nftContract.tokenId : undefined,
290
+ contractType: isNftMetadata(metadata) ? metadata.nftContract.type : undefined,
277
291
  encodedData: encodedData,
278
292
  spenderAddress: spenderAddress
279
293
  });
@@ -372,23 +386,37 @@ export function AnySpendCustom({
372
386
  srcAmount: srcAmount.toString(),
373
387
  recipientAddress,
374
388
  creatorAddress: currentWallet?.wallet?.address,
375
- nft: {
376
- ...metadata.nftContract,
377
- type: NftType.ERC721
378
- },
379
- tournament: {
380
- ...metadata.tournament,
381
- contractAddress: contractAddress,
382
- entryPriceOrFundAmount: dstAmount
383
- },
389
+ nft: isNftMetadata(metadata)
390
+ ? metadata.nftContract.type === NftType.ERC1155
391
+ ? {
392
+ type: NftType.ERC1155,
393
+ contractAddress: metadata.nftContract.contractAddress,
394
+ tokenId: metadata.nftContract.tokenId!,
395
+ imageUrl: metadata.nftContract.imageUrl,
396
+ nftPrice: dstAmount
397
+ }
398
+ : {
399
+ type: NftType.ERC721,
400
+ contractAddress: metadata.nftContract.contractAddress,
401
+ contractType: metadata.nftContract.type,
402
+ nftPrice: dstAmount
403
+ }
404
+ : undefined,
405
+ tournament: isTournamentMetadata(metadata)
406
+ ? {
407
+ ...metadata.tournament,
408
+ contractAddress: contractAddress,
409
+ entryPriceOrFundAmount: dstAmount
410
+ }
411
+ : undefined,
384
412
  payload: {
385
413
  amount: dstAmount,
386
414
  data: encodedData,
387
415
  spenderAddress: spenderAddress,
388
416
  to: contractAddress,
389
- action: metadata.action
417
+ action: isCustomTxMetadata(metadata) ? metadata.action : undefined
390
418
  }
391
- };
419
+ } as CreateOrderParams;
392
420
 
393
421
  if (onramp) {
394
422
  invariant(srcToken.address === USDC_BASE.address, "Selected src token is not USDC");
@@ -749,14 +777,30 @@ export function AnySpendCustom({
749
777
  onOrderCreated={(orderId: string) => setOrderId(orderId)}
750
778
  onBack={() => setActiveTab("crypto")}
751
779
  orderType={orderType}
752
- nft={metadata.nftContract ? { ...metadata.nftContract, price: dstAmount } : undefined}
753
- tournament={
754
- metadata.tournament
755
- ? { ...metadata.tournament, contractAddress: contractAddress, entryPriceOrFundAmount: dstAmount }
780
+ nft={
781
+ isNftMetadata(metadata)
782
+ ? metadata.nftContract.type === NftType.ERC1155
783
+ ? {
784
+ type: NftType.ERC1155,
785
+ contractAddress: metadata.nftContract.contractAddress,
786
+ tokenId: metadata.nftContract.tokenId!,
787
+ imageUrl: metadata.nftContract.imageUrl,
788
+ name: metadata.nftContract.name,
789
+ description: metadata.nftContract.description,
790
+ price: dstAmount
791
+ }
792
+ : {
793
+ type: NftType.ERC721,
794
+ contractAddress: metadata.nftContract.contractAddress,
795
+ name: metadata.nftContract.name,
796
+ description: metadata.nftContract.description,
797
+ imageUrl: metadata.nftContract.imageUrl,
798
+ price: dstAmount
799
+ }
756
800
  : undefined
757
801
  }
758
802
  payload={
759
- metadata.action
803
+ isCustomTxMetadata(metadata)
760
804
  ? {
761
805
  ...metadata,
762
806
  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 = DEFAULT_NFT_CONTRACT
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?: 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={{ nftContract }}
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
- useChainSwitchWithAction,
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={{ tournament: tournamentMetadata }}
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
- useOnchainName,
36
- useModalStore
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]);
@@ -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 = {
@@ -3,6 +3,7 @@ export * from "./req-res";
3
3
  export * from "./chain";
4
4
  export * from "./custom";
5
5
  export * from "./globalWallet";
6
+ export * from "./metadata";
6
7
  export * from "./nft";
7
8
  export * from "./onramp";
8
9
  export * from "./order";
@@ -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
+ }
@@ -49,4 +49,5 @@ export interface NftContract {
49
49
  name: string;
50
50
  description: string;
51
51
  tokenId: number | null;
52
+ type: NftType;
52
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
- return {
24
- contractAddress: nft ? normalizeAddress(nft.contractAddress) : "",
25
- nftPrice: nft?.price || ""
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,