@bosonprotocol/react-kit 0.41.0 → 0.42.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/cjs/components/cta/offer/PreMintButton.d.ts +19 -0
  2. package/dist/cjs/components/cta/offer/PreMintButton.d.ts.map +1 -0
  3. package/dist/cjs/components/cta/offer/PreMintButton.js +112 -0
  4. package/dist/cjs/components/cta/offer/PreMintButton.js.map +1 -0
  5. package/dist/cjs/components/cta/offer/ReserveRangeButton.d.ts +24 -0
  6. package/dist/cjs/components/cta/offer/ReserveRangeButton.d.ts.map +1 -0
  7. package/dist/cjs/components/cta/offer/ReserveRangeButton.js +119 -0
  8. package/dist/cjs/components/cta/offer/ReserveRangeButton.js.map +1 -0
  9. package/dist/cjs/components/currencyDisplay/CurrencyDisplay.d.ts +2 -1
  10. package/dist/cjs/components/currencyDisplay/CurrencyDisplay.d.ts.map +1 -1
  11. package/dist/cjs/components/currencyDisplay/CurrencyDisplay.js +2 -2
  12. package/dist/cjs/components/currencyDisplay/CurrencyDisplay.js.map +1 -1
  13. package/dist/cjs/components/modal/components/Commit/DetailView/InnerCommitDetailView.d.ts.map +1 -1
  14. package/dist/cjs/components/modal/components/Commit/DetailView/InnerCommitDetailView.js +4 -1
  15. package/dist/cjs/components/modal/components/Commit/DetailView/InnerCommitDetailView.js.map +1 -1
  16. package/dist/cjs/components/modal/components/Commit/DetailView/InnerCommitDetailViewWithPortal.d.ts.map +1 -1
  17. package/dist/cjs/components/modal/components/Commit/DetailView/InnerCommitDetailViewWithPortal.js +4 -1
  18. package/dist/cjs/components/modal/components/Commit/DetailView/InnerCommitDetailViewWithPortal.js.map +1 -1
  19. package/dist/cjs/components/modal/components/common/OfferFullDescription/GeneralProductData.d.ts.map +1 -1
  20. package/dist/cjs/components/modal/components/common/OfferFullDescription/GeneralProductData.js +2 -1
  21. package/dist/cjs/components/modal/components/common/OfferFullDescription/GeneralProductData.js.map +1 -1
  22. package/dist/cjs/components/modal/components/common/detail/DetailViewCore.d.ts.map +1 -1
  23. package/dist/cjs/components/modal/components/common/detail/DetailViewCore.js +2 -1
  24. package/dist/cjs/components/modal/components/common/detail/DetailViewCore.js.map +1 -1
  25. package/dist/cjs/components/price/Price.d.ts +2 -1
  26. package/dist/cjs/components/price/Price.d.ts.map +1 -1
  27. package/dist/cjs/components/price/Price.js +14 -4
  28. package/dist/cjs/components/price/Price.js.map +1 -1
  29. package/dist/cjs/components/productCard/ProductCard.d.ts +1 -0
  30. package/dist/cjs/components/productCard/ProductCard.d.ts.map +1 -1
  31. package/dist/cjs/components/productCard/ProductCard.js +2 -2
  32. package/dist/cjs/components/productCard/ProductCard.js.map +1 -1
  33. package/dist/cjs/hooks/useExchanges.d.ts.map +1 -1
  34. package/dist/cjs/index.d.ts +2 -0
  35. package/dist/cjs/index.d.ts.map +1 -1
  36. package/dist/cjs/index.js +2 -0
  37. package/dist/cjs/index.js.map +1 -1
  38. package/dist/esm/components/cta/offer/PreMintButton.d.ts +19 -0
  39. package/dist/esm/components/cta/offer/PreMintButton.d.ts.map +1 -0
  40. package/dist/esm/components/cta/offer/PreMintButton.js +56 -0
  41. package/dist/esm/components/cta/offer/PreMintButton.js.map +1 -0
  42. package/dist/esm/components/cta/offer/ReserveRangeButton.d.ts +24 -0
  43. package/dist/esm/components/cta/offer/ReserveRangeButton.d.ts.map +1 -0
  44. package/dist/esm/components/cta/offer/ReserveRangeButton.js +62 -0
  45. package/dist/esm/components/cta/offer/ReserveRangeButton.js.map +1 -0
  46. package/dist/esm/components/currencyDisplay/CurrencyDisplay.d.ts +2 -1
  47. package/dist/esm/components/currencyDisplay/CurrencyDisplay.d.ts.map +1 -1
  48. package/dist/esm/components/currencyDisplay/CurrencyDisplay.js +2 -2
  49. package/dist/esm/components/currencyDisplay/CurrencyDisplay.js.map +1 -1
  50. package/dist/esm/components/modal/components/Commit/DetailView/InnerCommitDetailView.d.ts.map +1 -1
  51. package/dist/esm/components/modal/components/Commit/DetailView/InnerCommitDetailView.js +4 -1
  52. package/dist/esm/components/modal/components/Commit/DetailView/InnerCommitDetailView.js.map +1 -1
  53. package/dist/esm/components/modal/components/Commit/DetailView/InnerCommitDetailViewWithPortal.d.ts.map +1 -1
  54. package/dist/esm/components/modal/components/Commit/DetailView/InnerCommitDetailViewWithPortal.js +4 -1
  55. package/dist/esm/components/modal/components/Commit/DetailView/InnerCommitDetailViewWithPortal.js.map +1 -1
  56. package/dist/esm/components/modal/components/common/OfferFullDescription/GeneralProductData.d.ts.map +1 -1
  57. package/dist/esm/components/modal/components/common/OfferFullDescription/GeneralProductData.js +2 -1
  58. package/dist/esm/components/modal/components/common/OfferFullDescription/GeneralProductData.js.map +1 -1
  59. package/dist/esm/components/modal/components/common/detail/DetailViewCore.d.ts.map +1 -1
  60. package/dist/esm/components/modal/components/common/detail/DetailViewCore.js +2 -1
  61. package/dist/esm/components/modal/components/common/detail/DetailViewCore.js.map +1 -1
  62. package/dist/esm/components/price/Price.d.ts +2 -1
  63. package/dist/esm/components/price/Price.d.ts.map +1 -1
  64. package/dist/esm/components/price/Price.js +14 -4
  65. package/dist/esm/components/price/Price.js.map +1 -1
  66. package/dist/esm/components/productCard/ProductCard.d.ts +1 -0
  67. package/dist/esm/components/productCard/ProductCard.d.ts.map +1 -1
  68. package/dist/esm/components/productCard/ProductCard.js +2 -2
  69. package/dist/esm/components/productCard/ProductCard.js.map +1 -1
  70. package/dist/esm/hooks/useExchanges.d.ts.map +1 -1
  71. package/dist/esm/index.d.ts +2 -0
  72. package/dist/esm/index.d.ts.map +1 -1
  73. package/dist/esm/index.js +2 -0
  74. package/dist/esm/index.js.map +1 -1
  75. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  76. package/package.json +3 -3
  77. package/src/components/cta/offer/PreMintButton.tsx +117 -0
  78. package/src/components/cta/offer/ReserveRangeButton.tsx +128 -0
  79. package/src/components/currencyDisplay/CurrencyDisplay.tsx +3 -1
  80. package/src/components/modal/components/Commit/DetailView/InnerCommitDetailView.tsx +4 -1
  81. package/src/components/modal/components/Commit/DetailView/InnerCommitDetailViewWithPortal.tsx +4 -1
  82. package/src/components/modal/components/common/OfferFullDescription/GeneralProductData.tsx +2 -0
  83. package/src/components/modal/components/common/detail/DetailViewCore.tsx +2 -0
  84. package/src/components/price/Price.tsx +47 -21
  85. package/src/components/productCard/ProductCard.tsx +4 -1
  86. package/src/index.tsx +2 -0
  87. package/src/stories/ProductCard.stories.tsx +2 -1
  88. package/src/stories/cta/offer/PreMintButton.stories.tsx +63 -0
  89. package/src/stories/cta/offer/ReserveRangeButton.stories.tsx +66 -0
@@ -0,0 +1,128 @@
1
+ import React, { useState } from "react";
2
+ import { BigNumberish, providers } from "ethers";
3
+ import { TransactionResponse } from "@bosonprotocol/common";
4
+
5
+ import { Button } from "../../buttons/Button";
6
+ import { ButtonTextWrapper, ExtraInfo, LoadingWrapper } from "../common/styles";
7
+ import { CtaButtonProps } from "../common/types";
8
+ import { Loading } from "../../ui/loading/Loading";
9
+ import { ButtonSize } from "../../ui/buttonSize";
10
+ import { useCoreSdkOverrides } from "../../../hooks/core-sdk/useCoreSdkOverrides";
11
+ import { useMetaTx } from "../../../hooks/useMetaTx";
12
+ import { withQueryClientProvider } from "../../queryClient/withQueryClientProvider";
13
+
14
+ type Props = {
15
+ /**
16
+ * ID of offer to reserve range for.
17
+ */
18
+ offerId: BigNumberish;
19
+ /**
20
+ * Length of the range to reserve.
21
+ */
22
+ length: number;
23
+ /**
24
+ * To whom the range is being reserved: "seller" or "contract".
25
+ */
26
+ to: "seller" | "contract";
27
+ } & CtaButtonProps<{
28
+ offerId: BigNumberish;
29
+ length: number;
30
+ to: "seller" | "contract";
31
+ }>;
32
+
33
+ export const ReserveRangeButton = withQueryClientProvider(
34
+ ({
35
+ offerId,
36
+ length,
37
+ to,
38
+ disabled = false,
39
+ showLoading = false,
40
+ extraInfo,
41
+ onSuccess,
42
+ onError,
43
+ onPendingSignature,
44
+ onPendingTransaction,
45
+ waitBlocks = 1,
46
+ size = ButtonSize.Large,
47
+ variant = "secondaryFill",
48
+ children,
49
+ coreSdkConfig,
50
+ ...rest
51
+ }: Props) => {
52
+ const coreSdk = useCoreSdkOverrides({ coreSdkConfig });
53
+ const [isLoading, setIsLoading] = useState<boolean>(false);
54
+
55
+ const { isMetaTx } = useMetaTx(coreSdk);
56
+
57
+ return (
58
+ <Button
59
+ variant={variant}
60
+ disabled={disabled}
61
+ size={size}
62
+ onClick={async () => {
63
+ if (!isLoading) {
64
+ let txResponse: TransactionResponse | undefined = undefined;
65
+ try {
66
+ setIsLoading(true);
67
+ onPendingSignature?.();
68
+
69
+ if (isMetaTx) {
70
+ const nonce = Date.now();
71
+
72
+ const { r, s, v, functionName, functionSignature } =
73
+ await coreSdk.signMetaTxReserveRange({
74
+ offerId,
75
+ length,
76
+ to,
77
+ nonce
78
+ });
79
+
80
+ txResponse = await coreSdk.relayMetaTransaction({
81
+ functionName,
82
+ functionSignature,
83
+ sigR: r,
84
+ sigS: s,
85
+ sigV: v,
86
+ nonce
87
+ });
88
+ } else {
89
+ txResponse = await coreSdk.reserveRange(offerId, length, to);
90
+ }
91
+
92
+ onPendingTransaction?.(txResponse.hash, isMetaTx);
93
+ const receipt = await txResponse.wait(waitBlocks);
94
+
95
+ onSuccess?.(receipt as providers.TransactionReceipt, {
96
+ offerId,
97
+ length,
98
+ to
99
+ });
100
+ } catch (error) {
101
+ onError?.(error as Error, {
102
+ txResponse: txResponse as providers.TransactionResponse
103
+ });
104
+ } finally {
105
+ setIsLoading(false);
106
+ }
107
+ }
108
+ }}
109
+ {...rest}
110
+ >
111
+ <ButtonTextWrapper>
112
+ {children || "Reserve Range"}
113
+ {extraInfo && ((!isLoading && showLoading) || !showLoading) ? (
114
+ <ExtraInfo>{extraInfo}</ExtraInfo>
115
+ ) : (
116
+ <>
117
+ {isLoading && showLoading && (
118
+ <LoadingWrapper>
119
+ <Loading />
120
+ </LoadingWrapper>
121
+ )}
122
+ </>
123
+ )}
124
+ </ButtonTextWrapper>
125
+ </Button>
126
+ );
127
+ }
128
+ );
@@ -35,6 +35,7 @@ export interface CurrencyDisplayProps {
35
35
  gap?: number | string;
36
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
37
  [x: string]: any;
38
+ isPriceDiscoveryOffer?: boolean;
38
39
  }
39
40
 
40
41
  export const CurrencyDisplay = ({
@@ -45,6 +46,7 @@ export const CurrencyDisplay = ({
45
46
  iconSize,
46
47
  color,
47
48
  gap,
49
+ isPriceDiscoveryOffer,
48
50
  ...rest
49
51
  }: CurrencyDisplayProps) => {
50
52
  return (
@@ -60,7 +62,7 @@ export const CurrencyDisplay = ({
60
62
  $gap={gap}
61
63
  $color={color}
62
64
  >
63
- {value}
65
+ {isPriceDiscoveryOffer ? "??" : value}
64
66
  </CurrencyDisplayValue>
65
67
  )}
66
68
  </CurrencyDisplayValueWrapper>
@@ -48,6 +48,7 @@ import dayjs from "dayjs";
48
48
  import { getDateTimestamp } from "../../../../../lib/dates/getDateTimestamp";
49
49
  import { LabelType, labelValueToText } from "../../../../exchangeCard/const";
50
50
  import { ExchangeStatus } from "../../../../exchangeCard/ExchangeCard.styles";
51
+ import { PriceType } from "@bosonprotocol/common";
51
52
 
52
53
  type ActionName = "approveExchangeToken" | "depositFunds" | "commit";
53
54
 
@@ -168,6 +169,7 @@ export default function InnerCommitDetailView(
168
169
  };
169
170
  const isVoidedOffer = !!offer.voidedAt;
170
171
  const isPreview = !offer.id;
172
+ const isPriceDiscoveryOffer = offer.priceType === PriceType.Discovery;
171
173
  const isCommitDisabled =
172
174
  !address ||
173
175
  !hasSellerEnoughFunds ||
@@ -178,7 +180,8 @@ export default function InnerCommitDetailView(
178
180
  isPreview ||
179
181
  isOfferNotValidYet ||
180
182
  isBuyerInsufficientFunds ||
181
- (offer.condition && !isConditionMet);
183
+ (offer.condition && !isConditionMet) ||
184
+ isPriceDiscoveryOffer;
182
185
  const handleOnGetSignerAddress = useCallback(
183
186
  (signerAddress: string | undefined) => {
184
187
  const isConnectWalletFromCommit = getItemFromStorage(
@@ -1,6 +1,7 @@
1
1
  import { ArrowRight, ArrowsLeftRight } from "phosphor-react";
2
2
  import React, { useMemo } from "react";
3
3
  import styled from "styled-components";
4
+ import { PriceType } from "@bosonprotocol/common";
4
5
  import { Button } from "../../../../buttons/Button";
5
6
  import { Grid } from "../../../../ui/Grid";
6
7
  import { InnerDetailViewWithPortal } from "../../common/detail/InnerDetailViewWithPortal";
@@ -50,6 +51,7 @@ export function InnerCommitDetailViewWithPortal(
50
51
  );
51
52
 
52
53
  const isOfferEmpty = quantity < 1;
54
+ const isPriceDiscoveryOffer = offer.priceType === PriceType.Discovery;
53
55
 
54
56
  const isNotCommittableOffer =
55
57
  isOfferEmpty ||
@@ -57,7 +59,8 @@ export function InnerCommitDetailViewWithPortal(
57
59
  isExpiredOffer ||
58
60
  offer.voided ||
59
61
  !hasSellerEnoughFunds ||
60
- isBuyerInsufficientFunds;
62
+ isBuyerInsufficientFunds ||
63
+ isPriceDiscoveryOffer;
61
64
 
62
65
  const tokenOrCoinSymbol = offer.exchangeToken.symbol;
63
66
  return (
@@ -22,6 +22,7 @@ import {
22
22
  import { Exchange } from "../../../../../types/exchange";
23
23
  import { PhygitalProduct } from "../detail/PhygitalProduct";
24
24
  import { getIsOfferRobloxGated } from "../../../../../lib/roblox/getIsOfferRobloxGated";
25
+ import { PriceType } from "@bosonprotocol/common";
25
26
 
26
27
  const StyledPrice = styled(Price)`
27
28
  h3 {
@@ -105,6 +106,7 @@ export const GeneralProductData: React.FC<GeneralProductDataProps> = ({
105
106
  tag="h3"
106
107
  convert
107
108
  withAsterisk={false}
109
+ isPriceDiscoveryOffer={offer.priceType === PriceType.Discovery}
108
110
  />
109
111
  </Grid>
110
112
  </GridContainer>
@@ -28,6 +28,7 @@ import { DetailViewProps } from "./types";
28
28
  import { useGetOfferDetailData } from "./useGetOfferDetailData";
29
29
  import { SvgImage } from "../../../../ui/SvgImage";
30
30
  import { getIsOfferRobloxGated } from "../../../../../lib/roblox/getIsOfferRobloxGated";
31
+ import { PriceType } from "@bosonprotocol/common";
31
32
 
32
33
  const StyledPrice = styled(Price)`
33
34
  h3 {
@@ -116,6 +117,7 @@ export const DetailViewCore = forwardRef<ElementRef<"div">, Props>(
116
117
  tag="h3"
117
118
  convert
118
119
  withAsterisk={showPriceAsterisk}
120
+ isPriceDiscoveryOffer={offer.priceType === PriceType.Discovery}
119
121
  />
120
122
  {priceSibling}
121
123
  </WidgetUpperGrid>
@@ -56,6 +56,7 @@ interface IProps {
56
56
  isExchange?: boolean;
57
57
  tag?: keyof JSX.IntrinsicElements;
58
58
  withAsterisk?: boolean;
59
+ isPriceDiscoveryOffer?: boolean;
59
60
  }
60
61
 
61
62
  export default function Price({
@@ -66,6 +67,7 @@ export default function Price({
66
67
  isExchange = false,
67
68
  tag = "h4",
68
69
  withAsterisk,
70
+ isPriceDiscoveryOffer = false,
69
71
  ...rest
70
72
  }: IProps) {
71
73
  const [isSymbolShown] = useState<boolean>(false); // TODO: remove once CSS :has is supported
@@ -86,27 +88,51 @@ export default function Price({
86
88
  flexWrap="wrap"
87
89
  data-testid="price-grid"
88
90
  >
89
- <Typography
90
- tag={tag}
91
- style={{
92
- fontWeight: "600",
93
- letterSpacing: "-1px",
94
- margin: "0",
95
- wordBreak: "break-word"
96
- }}
97
- data-icon-price
98
- {...(isSymbolShown && { "data-with-symbol": true })}
99
- >
100
- <Tooltip content={currencySymbol} wrap={false}>
101
- <CurrencyDisplay
102
- currency={currencySymbol as Currencies}
103
- height={18}
104
- />
105
- </Tooltip>
106
- {displayFloat(price.price)}
107
- {withAsterisk && <div>*</div>}
108
- </Typography>
109
- {convert && price?.currency && (
91
+ {isPriceDiscoveryOffer ? (
92
+ <Typography
93
+ tag={tag}
94
+ style={{
95
+ fontSize: "20px",
96
+ fontWeight: "500",
97
+ fontStyle: "italic",
98
+ margin: "0",
99
+ wordBreak: "break-word"
100
+ }}
101
+ data-icon-price
102
+ {...(isSymbolShown && { "data-with-symbol": true })}
103
+ >
104
+ <Tooltip content={currencySymbol} wrap={false}>
105
+ <CurrencyDisplay
106
+ currency={currencySymbol as Currencies}
107
+ height={18}
108
+ />
109
+ </Tooltip>
110
+ Price on discovery
111
+ {withAsterisk && <div>*</div>}
112
+ </Typography>
113
+ ) : (
114
+ <Typography
115
+ tag={tag}
116
+ style={{
117
+ fontWeight: "600",
118
+ letterSpacing: "-1px",
119
+ margin: "0",
120
+ wordBreak: "break-word"
121
+ }}
122
+ data-icon-price
123
+ {...(isSymbolShown && { "data-with-symbol": true })}
124
+ >
125
+ <Tooltip content={currencySymbol} wrap={false}>
126
+ <CurrencyDisplay
127
+ currency={currencySymbol as Currencies}
128
+ height={18}
129
+ />
130
+ </Tooltip>
131
+ {displayFloat(price.price)}
132
+ {withAsterisk && <div>*</div>}
133
+ </Typography>
134
+ )}
135
+ {convert && !isPriceDiscoveryOffer && price?.currency && (
110
136
  <ConvertedPrice price={price} isExchange={isExchange} />
111
137
  )}
112
138
  </Grid>
@@ -60,6 +60,7 @@ export interface IProductCard {
60
60
  className?: string;
61
61
  currencyColor?: CurrencyDisplayProps["color"];
62
62
  status?: ExchangeCardStatus;
63
+ isPriceDiscoveryOffer?: boolean;
63
64
  }
64
65
 
65
66
  const Wrapper = ({
@@ -99,7 +100,8 @@ export const ProductCard = (props: IProductCard) => {
99
100
  isImageFitCover = false,
100
101
  className,
101
102
  productType,
102
- currencyColor
103
+ currencyColor,
104
+ isPriceDiscoveryOffer = false
103
105
  } = props;
104
106
 
105
107
  const [isHovered, setIsHovered] = useState(false);
@@ -152,6 +154,7 @@ export const ProductCard = (props: IProductCard) => {
152
154
  color={currencyColor}
153
155
  iconSize={16}
154
156
  gap={"0.3125rem"}
157
+ isPriceDiscoveryOffer={isPriceDiscoveryOffer}
155
158
  style={{
156
159
  alignItems: "center",
157
160
  justifyContent: "center"
package/src/index.tsx CHANGED
@@ -27,6 +27,8 @@ export * from "./components/cta/offer/CommitButton";
27
27
  export * from "./components/cta/offer/ThemedCommitButton";
28
28
  export * from "./components/cta/offer/CreateOfferButton";
29
29
  export * from "./components/cta/offer/VoidButton";
30
+ export * from "./components/cta/offer/ReserveRangeButton";
31
+ export * from "./components/cta/offer/PreMintButton";
30
32
  export * from "./components/currencyDisplay/CurrencyDisplay";
31
33
  export * from "./components/error/ErrorMessage";
32
34
  export * from "./components/error/SimpleError";
@@ -70,7 +70,8 @@ ProductCardPrimary.args = {
70
70
  errorImageText: "Unable to ..."
71
71
  }
72
72
  },
73
- bottomText: "Redeemable until 30 days after commit"
73
+ bottomText: "Redeemable until 30 days after commit",
74
+ isPriceDiscoveryOffer: false
74
75
  };
75
76
 
76
77
  ProductCardPrimary.decorators = [(Story) => wrapper(Story)];
@@ -0,0 +1,63 @@
1
+ import React from "react";
2
+ import { ComponentStory, ComponentMeta } from "@storybook/react";
3
+
4
+ import { PreMintButton } from "../../../components/cta/offer/PreMintButton";
5
+
6
+ import { hooks } from "../../helpers/connect-wallet";
7
+ import { CtaButtonWrapper } from "../../helpers/CtaButtonWrapper";
8
+
9
+ export default {
10
+ title: "Visual Components/CTA/Offer/PreMintButton",
11
+ component: PreMintButton,
12
+ parameters: {
13
+ // TODO: delete once storybook doesnt freeze if an arg is an object https://github.com/storybookjs/storybook/issues/17098
14
+ docs: {
15
+ source: {
16
+ type: "code"
17
+ }
18
+ }
19
+ }
20
+ } as ComponentMeta<typeof PreMintButton>;
21
+
22
+ const Template: ComponentStory<typeof PreMintButton> = (
23
+ args: Parameters<typeof PreMintButton>[0]
24
+ ) => {
25
+ const provider = hooks.useProvider();
26
+
27
+ return (
28
+ <CtaButtonWrapper configId={args.coreSdkConfig.configId}>
29
+ <PreMintButton
30
+ {...args}
31
+ coreSdkConfig={{ ...args.coreSdkConfig, web3Provider: provider }}
32
+ />
33
+ </CtaButtonWrapper>
34
+ );
35
+ };
36
+
37
+ export const Simple: ComponentStory<typeof PreMintButton> = Template.bind({});
38
+
39
+ Simple.args = {
40
+ coreSdkConfig: {
41
+ configId: "testing-80002-0",
42
+ envName: "testing",
43
+ web3Provider: undefined
44
+ },
45
+ offerId: "28",
46
+ amount: 5,
47
+ onPendingSignature: () => {
48
+ console.log("----------ON PENDING SIGNATURE-------------");
49
+ },
50
+ onPendingTransaction: (txHash: string) => {
51
+ console.log("----------ON PENDING TRANSACTION-------------");
52
+ console.log("txHash", txHash);
53
+ },
54
+ onSuccess: (receipt, payload) => {
55
+ console.log("----------ON SUCCESS-------------");
56
+ console.log("receipt", receipt);
57
+ console.log("payload", payload);
58
+ },
59
+ onError: (error) => {
60
+ console.log("----------ON ERROR-------------");
61
+ console.log("error", error);
62
+ }
63
+ };
@@ -0,0 +1,66 @@
1
+ import React from "react";
2
+ import { ComponentStory, ComponentMeta } from "@storybook/react";
3
+
4
+ import { ReserveRangeButton } from "../../../components/cta/offer/ReserveRangeButton";
5
+
6
+ import { hooks } from "../../helpers/connect-wallet";
7
+ import { CtaButtonWrapper } from "../../helpers/CtaButtonWrapper";
8
+
9
+ export default {
10
+ title: "Visual Components/CTA/Offer/ReserveRangeButton",
11
+ component: ReserveRangeButton,
12
+ parameters: {
13
+ // TODO: delete once storybook doesnt freeze if an arg is an object https://github.com/storybookjs/storybook/issues/17098
14
+ docs: {
15
+ source: {
16
+ type: "code"
17
+ }
18
+ }
19
+ }
20
+ } as ComponentMeta<typeof ReserveRangeButton>;
21
+
22
+ const Template: ComponentStory<typeof ReserveRangeButton> = (
23
+ args: Parameters<typeof ReserveRangeButton>[0]
24
+ ) => {
25
+ const provider = hooks.useProvider();
26
+
27
+ return (
28
+ <CtaButtonWrapper configId={args.coreSdkConfig.configId}>
29
+ <ReserveRangeButton
30
+ {...args}
31
+ coreSdkConfig={{ ...args.coreSdkConfig, web3Provider: provider }}
32
+ />
33
+ </CtaButtonWrapper>
34
+ );
35
+ };
36
+
37
+ export const Simple: ComponentStory<typeof ReserveRangeButton> = Template.bind(
38
+ {}
39
+ );
40
+
41
+ Simple.args = {
42
+ coreSdkConfig: {
43
+ configId: "testing-80002-0",
44
+ envName: "testing",
45
+ web3Provider: undefined
46
+ },
47
+ offerId: "28",
48
+ length: 5,
49
+ to: "seller",
50
+ onPendingSignature: () => {
51
+ console.log("----------ON PENDING SIGNATURE-------------");
52
+ },
53
+ onPendingTransaction: (txHash: string) => {
54
+ console.log("----------ON PENDING TRANSACTION-------------");
55
+ console.log("txHash", txHash);
56
+ },
57
+ onSuccess: (receipt, payload) => {
58
+ console.log("----------ON SUCCESS-------------");
59
+ console.log("receipt", receipt);
60
+ console.log("payload", payload);
61
+ },
62
+ onError: (error) => {
63
+ console.log("----------ON ERROR-------------");
64
+ console.log("error", error);
65
+ }
66
+ };