@bosonprotocol/react-kit 0.29.0-alpha.9 → 0.29.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 (231) hide show
  1. package/dist/cjs/assets/logo.svg +11 -5
  2. package/dist/cjs/components/buttons/Button.d.ts +3 -3
  3. package/dist/cjs/components/buttons/Button.d.ts.map +1 -1
  4. package/dist/cjs/components/buttons/Button.js.map +1 -1
  5. package/dist/cjs/components/buttons/CommitButtonView.d.ts +20 -0
  6. package/dist/cjs/components/buttons/CommitButtonView.d.ts.map +1 -0
  7. package/dist/cjs/components/buttons/CommitButtonView.js +81 -0
  8. package/dist/cjs/components/buttons/CommitButtonView.js.map +1 -0
  9. package/dist/cjs/components/cta/offer/CommitButton.js +1 -1
  10. package/dist/cjs/components/cta/offer/CommitButton.js.map +1 -1
  11. package/dist/cjs/components/modal/components/Commit/CommitNonModal.js +2 -2
  12. package/dist/cjs/components/modal/components/Commit/CommitNonModal.js.map +1 -1
  13. package/dist/cjs/components/modal/components/PurchaseOverview/PurchaseOverview.d.ts +9 -0
  14. package/dist/cjs/components/modal/components/PurchaseOverview/PurchaseOverview.d.ts.map +1 -0
  15. package/dist/cjs/components/modal/components/PurchaseOverview/PurchaseOverview.js +47 -0
  16. package/dist/cjs/components/modal/components/PurchaseOverview/PurchaseOverview.js.map +1 -0
  17. package/dist/cjs/components/modal/components/SellerFinance/FinanceDeposit.d.ts.map +1 -1
  18. package/dist/cjs/components/modal/components/SellerFinance/FinanceDeposit.js +4 -1
  19. package/dist/cjs/components/modal/components/SellerFinance/FinanceDeposit.js.map +1 -1
  20. package/dist/cjs/components/modal/components/SellerFinance/FinanceWithdraw.d.ts.map +1 -1
  21. package/dist/cjs/components/modal/components/SellerFinance/FinanceWithdraw.js +7 -2
  22. package/dist/cjs/components/modal/components/SellerFinance/FinanceWithdraw.js.map +1 -1
  23. package/dist/cjs/components/modal/components/common/StepsOverview/PurchaseOverview.js +3 -3
  24. package/dist/cjs/components/modal/components/common/StepsOverview/PurchaseOverview.js.map +1 -1
  25. package/dist/cjs/components/modal/components/common/StepsOverview/PurchaseOverviewView.d.ts +1 -1
  26. package/dist/cjs/components/modal/components/common/StepsOverview/PurchaseOverviewView.d.ts.map +1 -1
  27. package/dist/cjs/components/modal/components/common/StepsOverview/PurchaseOverviewView.js +4 -4
  28. package/dist/cjs/components/modal/components/common/StepsOverview/PurchaseOverviewView.js.map +1 -1
  29. package/dist/cjs/components/modal/components/common/detail/Detail.style.d.ts +7 -7
  30. package/dist/cjs/components/modal/components/common/detail/DetailSlider.d.ts.map +1 -1
  31. package/dist/cjs/components/modal/components/common/detail/DetailSlider.js +1 -1
  32. package/dist/cjs/components/modal/components/common/detail/DetailSlider.js.map +1 -1
  33. package/dist/cjs/components/modal/nonModal/Header.d.ts.map +1 -1
  34. package/dist/cjs/components/modal/nonModal/Header.js +1 -0
  35. package/dist/cjs/components/modal/nonModal/Header.js.map +1 -1
  36. package/dist/cjs/components/styles/GlobalStyle.d.ts.map +1 -1
  37. package/dist/cjs/components/styles/GlobalStyle.js +0 -1
  38. package/dist/cjs/components/styles/GlobalStyle.js.map +1 -1
  39. package/dist/cjs/components/ui/ThemedButton.d.ts +11 -5
  40. package/dist/cjs/components/ui/ThemedButton.d.ts.map +1 -1
  41. package/dist/cjs/components/ui/ThemedButton.js +14 -8
  42. package/dist/cjs/components/ui/ThemedButton.js.map +1 -1
  43. package/dist/cjs/components/ui/Video.d.ts +1 -0
  44. package/dist/cjs/components/ui/Video.d.ts.map +1 -1
  45. package/dist/cjs/components/ui/Video.js +2 -2
  46. package/dist/cjs/components/ui/Video.js.map +1 -1
  47. package/dist/cjs/components/ui/styles.js +1 -1
  48. package/dist/cjs/components/wallet/wallet-connection.d.ts +136 -136
  49. package/dist/cjs/components/widgets/finance/FinanceWidget.d.ts +4 -9
  50. package/dist/cjs/components/widgets/finance/FinanceWidget.d.ts.map +1 -1
  51. package/dist/cjs/components/widgets/finance/FinanceWidget.js +6 -24
  52. package/dist/cjs/components/widgets/finance/FinanceWidget.js.map +1 -1
  53. package/dist/cjs/components/widgets/finance/FinanceWidgetProviders.d.ts +11 -0
  54. package/dist/cjs/components/widgets/finance/FinanceWidgetProviders.d.ts.map +1 -0
  55. package/dist/cjs/components/widgets/finance/FinanceWidgetProviders.js +41 -0
  56. package/dist/cjs/components/widgets/finance/FinanceWidgetProviders.js.map +1 -0
  57. package/dist/cjs/hooks/useCtaClickHandler.d.ts.map +1 -1
  58. package/dist/cjs/hooks/useCtaClickHandler.js +3 -1
  59. package/dist/cjs/hooks/useCtaClickHandler.js.map +1 -1
  60. package/dist/cjs/hooks/useCurrentSellers.d.ts.map +1 -1
  61. package/dist/cjs/hooks/useCurrentSellers.js +3 -1
  62. package/dist/cjs/hooks/useCurrentSellers.js.map +1 -1
  63. package/dist/cjs/hooks/useExchanges.d.ts +0 -1
  64. package/dist/cjs/hooks/useExchanges.d.ts.map +1 -1
  65. package/dist/cjs/index.d.ts +2 -0
  66. package/dist/cjs/index.d.ts.map +1 -1
  67. package/dist/cjs/index.js +2 -0
  68. package/dist/cjs/index.js.map +1 -1
  69. package/dist/cjs/lib/bundle/filter.d.ts +0 -1
  70. package/dist/cjs/lib/bundle/filter.d.ts.map +1 -1
  71. package/dist/cjs/lib/const/chainInfo.d.ts.map +1 -1
  72. package/dist/cjs/lib/const/chainInfo.js +0 -9
  73. package/dist/cjs/lib/const/chainInfo.js.map +1 -1
  74. package/dist/cjs/lib/const/chains.d.ts +1 -1
  75. package/dist/cjs/lib/const/chains.d.ts.map +1 -1
  76. package/dist/cjs/lib/const/chains.js +2 -2
  77. package/dist/cjs/lib/const/chains.js.map +1 -1
  78. package/dist/cjs/lib/errors/eth-revert-reason.js +1 -1
  79. package/dist/cjs/lib/errors/eth-revert-reason.js.map +1 -1
  80. package/dist/cjs/lib/numbers/numbers.d.ts.map +1 -1
  81. package/dist/cjs/lib/numbers/numbers.js +2 -8
  82. package/dist/cjs/lib/numbers/numbers.js.map +1 -1
  83. package/dist/cjs/lib/opensea/getOpenSeaUrl.d.ts.map +1 -1
  84. package/dist/cjs/lib/opensea/getOpenSeaUrl.js +0 -8
  85. package/dist/cjs/lib/opensea/getOpenSeaUrl.js.map +1 -1
  86. package/dist/esm/assets/logo.svg +11 -5
  87. package/dist/esm/components/buttons/Button.d.ts +3 -3
  88. package/dist/esm/components/buttons/Button.d.ts.map +1 -1
  89. package/dist/esm/components/buttons/Button.js.map +1 -1
  90. package/dist/esm/components/buttons/CommitButtonView.d.ts +20 -0
  91. package/dist/esm/components/buttons/CommitButtonView.d.ts.map +1 -0
  92. package/dist/esm/components/buttons/CommitButtonView.js +52 -0
  93. package/dist/esm/components/buttons/CommitButtonView.js.map +1 -0
  94. package/dist/esm/components/cta/offer/CommitButton.js +1 -1
  95. package/dist/esm/components/cta/offer/CommitButton.js.map +1 -1
  96. package/dist/esm/components/modal/components/Commit/CommitNonModal.js +2 -2
  97. package/dist/esm/components/modal/components/Commit/CommitNonModal.js.map +1 -1
  98. package/dist/esm/components/modal/components/PurchaseOverview/PurchaseOverview.d.ts +9 -0
  99. package/dist/esm/components/modal/components/PurchaseOverview/PurchaseOverview.d.ts.map +1 -0
  100. package/dist/esm/components/modal/components/PurchaseOverview/PurchaseOverview.js +17 -0
  101. package/dist/esm/components/modal/components/PurchaseOverview/PurchaseOverview.js.map +1 -0
  102. package/dist/esm/components/modal/components/SellerFinance/FinanceDeposit.d.ts.map +1 -1
  103. package/dist/esm/components/modal/components/SellerFinance/FinanceDeposit.js +5 -2
  104. package/dist/esm/components/modal/components/SellerFinance/FinanceDeposit.js.map +1 -1
  105. package/dist/esm/components/modal/components/SellerFinance/FinanceWithdraw.d.ts.map +1 -1
  106. package/dist/esm/components/modal/components/SellerFinance/FinanceWithdraw.js +7 -2
  107. package/dist/esm/components/modal/components/SellerFinance/FinanceWithdraw.js.map +1 -1
  108. package/dist/esm/components/modal/components/common/StepsOverview/PurchaseOverview.js +3 -3
  109. package/dist/esm/components/modal/components/common/StepsOverview/PurchaseOverview.js.map +1 -1
  110. package/dist/esm/components/modal/components/common/StepsOverview/PurchaseOverviewView.d.ts +1 -1
  111. package/dist/esm/components/modal/components/common/StepsOverview/PurchaseOverviewView.d.ts.map +1 -1
  112. package/dist/esm/components/modal/components/common/StepsOverview/PurchaseOverviewView.js +4 -4
  113. package/dist/esm/components/modal/components/common/StepsOverview/PurchaseOverviewView.js.map +1 -1
  114. package/dist/esm/components/modal/components/common/detail/Detail.style.d.ts +7 -7
  115. package/dist/esm/components/modal/components/common/detail/DetailSlider.d.ts.map +1 -1
  116. package/dist/esm/components/modal/components/common/detail/DetailSlider.js +1 -1
  117. package/dist/esm/components/modal/components/common/detail/DetailSlider.js.map +1 -1
  118. package/dist/esm/components/modal/nonModal/Header.d.ts.map +1 -1
  119. package/dist/esm/components/modal/nonModal/Header.js +1 -0
  120. package/dist/esm/components/modal/nonModal/Header.js.map +1 -1
  121. package/dist/esm/components/styles/GlobalStyle.d.ts.map +1 -1
  122. package/dist/esm/components/styles/GlobalStyle.js +0 -1
  123. package/dist/esm/components/styles/GlobalStyle.js.map +1 -1
  124. package/dist/esm/components/ui/ThemedButton.d.ts +11 -5
  125. package/dist/esm/components/ui/ThemedButton.d.ts.map +1 -1
  126. package/dist/esm/components/ui/ThemedButton.js +14 -8
  127. package/dist/esm/components/ui/ThemedButton.js.map +1 -1
  128. package/dist/esm/components/ui/Video.d.ts +1 -0
  129. package/dist/esm/components/ui/Video.d.ts.map +1 -1
  130. package/dist/esm/components/ui/Video.js +2 -2
  131. package/dist/esm/components/ui/Video.js.map +1 -1
  132. package/dist/esm/components/ui/styles.js +1 -1
  133. package/dist/esm/components/wallet/wallet-connection.d.ts +136 -136
  134. package/dist/esm/components/widgets/finance/FinanceWidget.d.ts +4 -9
  135. package/dist/esm/components/widgets/finance/FinanceWidget.d.ts.map +1 -1
  136. package/dist/esm/components/widgets/finance/FinanceWidget.js +6 -24
  137. package/dist/esm/components/widgets/finance/FinanceWidget.js.map +1 -1
  138. package/dist/esm/components/widgets/finance/FinanceWidgetProviders.d.ts +11 -0
  139. package/dist/esm/components/widgets/finance/FinanceWidgetProviders.d.ts.map +1 -0
  140. package/dist/esm/components/widgets/finance/FinanceWidgetProviders.js +23 -0
  141. package/dist/esm/components/widgets/finance/FinanceWidgetProviders.js.map +1 -0
  142. package/dist/esm/hooks/useCtaClickHandler.d.ts.map +1 -1
  143. package/dist/esm/hooks/useCtaClickHandler.js +3 -1
  144. package/dist/esm/hooks/useCtaClickHandler.js.map +1 -1
  145. package/dist/esm/hooks/useCurrentSellers.d.ts.map +1 -1
  146. package/dist/esm/hooks/useCurrentSellers.js +3 -1
  147. package/dist/esm/hooks/useCurrentSellers.js.map +1 -1
  148. package/dist/esm/hooks/useExchanges.d.ts +0 -1
  149. package/dist/esm/hooks/useExchanges.d.ts.map +1 -1
  150. package/dist/esm/index.d.ts +2 -0
  151. package/dist/esm/index.d.ts.map +1 -1
  152. package/dist/esm/index.js +2 -0
  153. package/dist/esm/index.js.map +1 -1
  154. package/dist/esm/lib/bundle/filter.d.ts +0 -1
  155. package/dist/esm/lib/bundle/filter.d.ts.map +1 -1
  156. package/dist/esm/lib/const/chainInfo.d.ts.map +1 -1
  157. package/dist/esm/lib/const/chainInfo.js +0 -9
  158. package/dist/esm/lib/const/chainInfo.js.map +1 -1
  159. package/dist/esm/lib/const/chains.d.ts +1 -1
  160. package/dist/esm/lib/const/chains.d.ts.map +1 -1
  161. package/dist/esm/lib/const/chains.js +2 -2
  162. package/dist/esm/lib/const/chains.js.map +1 -1
  163. package/dist/esm/lib/errors/eth-revert-reason.js +1 -1
  164. package/dist/esm/lib/errors/eth-revert-reason.js.map +1 -1
  165. package/dist/esm/lib/numbers/numbers.d.ts.map +1 -1
  166. package/dist/esm/lib/numbers/numbers.js +3 -9
  167. package/dist/esm/lib/numbers/numbers.js.map +1 -1
  168. package/dist/esm/lib/opensea/getOpenSeaUrl.d.ts.map +1 -1
  169. package/dist/esm/lib/opensea/getOpenSeaUrl.js +0 -8
  170. package/dist/esm/lib/opensea/getOpenSeaUrl.js.map +1 -1
  171. package/package.json +4 -4
  172. package/src/assets/logo.svg +11 -5
  173. package/src/components/buttons/Button.tsx +2 -1
  174. package/src/components/buttons/CommitButtonView.tsx +118 -0
  175. package/src/components/cta/offer/CommitButton.tsx +1 -1
  176. package/src/components/modal/components/Commit/CommitNonModal.tsx +2 -2
  177. package/src/components/modal/components/PurchaseOverview/PurchaseOverview.tsx +45 -0
  178. package/src/components/modal/components/SellerFinance/FinanceDeposit.tsx +8 -2
  179. package/src/components/modal/components/SellerFinance/FinanceWithdraw.tsx +9 -5
  180. package/src/components/modal/components/common/StepsOverview/PurchaseOverview.tsx +5 -5
  181. package/src/components/modal/components/common/StepsOverview/PurchaseOverviewView.tsx +11 -8
  182. package/src/components/modal/components/common/detail/DetailSlider.tsx +1 -0
  183. package/src/components/modal/nonModal/Header.tsx +1 -0
  184. package/src/components/styles/GlobalStyle.tsx +0 -1
  185. package/src/components/ui/ThemedButton.tsx +14 -8
  186. package/src/components/ui/Video.tsx +8 -4
  187. package/src/components/ui/styles.ts +1 -1
  188. package/src/components/widgets/finance/FinanceWidget.tsx +16 -57
  189. package/src/components/widgets/finance/FinanceWidgetProviders.tsx +60 -0
  190. package/src/hooks/useCtaClickHandler.ts +8 -3
  191. package/src/hooks/useCurrentSellers.ts +3 -1
  192. package/src/index.tsx +2 -0
  193. package/src/lib/const/chainInfo.ts +0 -9
  194. package/src/lib/const/chains.ts +2 -2
  195. package/src/lib/errors/eth-revert-reason.ts +1 -1
  196. package/src/lib/numbers/numbers.ts +3 -9
  197. package/src/lib/opensea/getOpenSeaUrl.ts +0 -10
  198. package/src/stories/PurchaseOverview.stories.tsx +29 -0
  199. package/src/stories/buttons/CommitButtonView.stories.tsx +44 -0
  200. package/src/stories/cta/dispute/AddFeesDisputeResolverButton.stories.tsx +2 -2
  201. package/src/stories/cta/dispute/AddSellerToDisputeResolverButton.stories.tsx +4 -2
  202. package/src/stories/cta/dispute/CreateDisputeResolverButton.stories.tsx +4 -2
  203. package/src/stories/cta/dispute/DecideDisputeButton.stories.tsx +4 -2
  204. package/src/stories/cta/dispute/EscalateDisputeButton.stories.tsx +4 -2
  205. package/src/stories/cta/dispute/ExpireDisputeButton.stories.tsx +4 -2
  206. package/src/stories/cta/dispute/ExpireEscalationDisputeButton.stories.tsx +2 -2
  207. package/src/stories/cta/dispute/ExtendDisputeTimeoutButton.stories.tsx +4 -2
  208. package/src/stories/cta/dispute/RaiseDisputeButton.stories.tsx +4 -2
  209. package/src/stories/cta/dispute/RefuseDisputeButton.stories.tsx +4 -2
  210. package/src/stories/cta/dispute/RemoveFeesDisputeResolverButton.stories.tsx +4 -2
  211. package/src/stories/cta/dispute/RemoveSellerFromDisputeResolverButton.stories.tsx +2 -2
  212. package/src/stories/cta/dispute/ResolveDisputeButton.stories.tsx +4 -2
  213. package/src/stories/cta/dispute/RetractDisputeButton.stories.tsx +4 -2
  214. package/src/stories/cta/dispute/UpdateDisputeResolverButton.stories.tsx +4 -2
  215. package/src/stories/cta/exchange/BatchCompleteButton.stories.tsx +4 -2
  216. package/src/stories/cta/exchange/CancelButton.stories.tsx +4 -2
  217. package/src/stories/cta/exchange/CompleteButton.stories.tsx +4 -2
  218. package/src/stories/cta/exchange/ExpireButton.stories.tsx +4 -2
  219. package/src/stories/cta/exchange/RevokeButton.stories.tsx +4 -2
  220. package/src/stories/cta/funds/DepositFundsButton.stories.tsx +4 -2
  221. package/src/stories/cta/funds/WithdrawAllFunds.stories.tsx +4 -2
  222. package/src/stories/cta/funds/WithdrawFundsButton.stories.tsx +4 -2
  223. package/src/stories/cta/offer/BatchVoidButton.stories.tsx +4 -2
  224. package/src/stories/cta/offer/CommitButton.stories.tsx +4 -2
  225. package/src/stories/cta/offer/CreateOfferButton.stories.tsx +4 -2
  226. package/src/stories/cta/offer/VoidButton.stories.tsx +4 -2
  227. package/src/stories/cta/seller/CreateSellerButton.stories.tsx +4 -2
  228. package/src/stories/cta/seller/UpdateSellerButton.stories.tsx +4 -2
  229. package/src/stories/helpers/CtaButtonWrapper.tsx +32 -5
  230. package/src/stories/helpers/connect-wallet.ts +45 -15
  231. package/src/stories/widgets/Finance.stories.tsx +1 -1
@@ -0,0 +1,45 @@
1
+ import React, { ReactNode, useCallback } from "react";
2
+ import { PurchaseOverviewView } from "../common/StepsOverview/PurchaseOverviewView";
3
+ import NonModal from "../../nonModal/NonModal";
4
+ import { BosonFooter } from "../common/BosonFooter";
5
+ import { theme } from "../../../../theme";
6
+ import { CSSProperties } from "styled-components";
7
+ const colors = theme.colors.light;
8
+
9
+ export type PurchaseOverviewProps = {
10
+ lookAndFeel: "regular" | "modal";
11
+ hideModal: () => void;
12
+ modalMargin?: CSSProperties["margin"];
13
+ };
14
+
15
+ export const PurchaseOverview: React.FC<PurchaseOverviewProps> = ({
16
+ lookAndFeel,
17
+ hideModal,
18
+ modalMargin
19
+ }) => {
20
+ const Wrapper = useCallback(
21
+ ({ children }: { children: ReactNode }) => {
22
+ return lookAndFeel === "regular" ? (
23
+ <>{children}</>
24
+ ) : (
25
+ <div style={{ margin: modalMargin }}>{children}</div>
26
+ );
27
+ },
28
+ [lookAndFeel, modalMargin]
29
+ );
30
+ return (
31
+ <Wrapper>
32
+ <NonModal
33
+ hideModal={hideModal}
34
+ footerComponent={<BosonFooter />}
35
+ contentStyle={{
36
+ background: colors.white
37
+ }}
38
+ lookAndFeel={lookAndFeel}
39
+ showConnectButton={false}
40
+ >
41
+ <PurchaseOverviewView />
42
+ </NonModal>
43
+ </Wrapper>
44
+ );
45
+ };
@@ -15,7 +15,10 @@ import {
15
15
  extractUserFriendlyError,
16
16
  getHasUserRejectedTx
17
17
  } from "../../../../lib/errors/transactions";
18
- import { getNumberWithoutDecimals } from "../../../../lib/numbers/numbers";
18
+ import {
19
+ getNumberWithDecimals,
20
+ getNumberWithoutDecimals
21
+ } from "../../../../lib/numbers/numbers";
19
22
  import { poll } from "../../../../lib/promises/promises";
20
23
  import { DepositFundsButton } from "../../../cta/funds/DepositFundsButton";
21
24
  import { useEnvContext } from "../../../environment/EnvironmentContext";
@@ -75,6 +78,9 @@ export default function FinanceDeposit({
75
78
 
76
79
  const tokenStep = 10 ** -Number(tokenDecimals);
77
80
  const step = 0.01;
81
+ const balanceWithDecimals = dataBalance
82
+ ? getNumberWithDecimals(dataBalance.toString(), tokenDecimals)
83
+ : Number.MAX_SAFE_INTEGER;
78
84
 
79
85
  const handleChangeDepositAmount = (
80
86
  e: React.ChangeEvent<HTMLInputElement>
@@ -84,7 +90,7 @@ export default function FinanceDeposit({
84
90
  const value = e.target.valueAsNumber || 0;
85
91
  setIsDepositInvalid(false);
86
92
  setDepositError(null);
87
- if (value < tokenStep || value > Number.MAX_SAFE_INTEGER) {
93
+ if (value < tokenStep || value > balanceWithDecimals) {
88
94
  setIsDepositInvalid(true);
89
95
  }
90
96
  setAmountToDeposit(valueStr);
@@ -97,12 +97,16 @@ export default function FinanceWithdraw({
97
97
  const value = e.target.valueAsNumber || 0;
98
98
  setIsWithdrawInvalid(false);
99
99
 
100
- const availableFundsBig = getNumberWithDecimals(
101
- availableAmount,
102
- tokenDecimals
103
- );
100
+ try {
101
+ const availableFundsBig = getNumberWithDecimals(
102
+ availableAmount,
103
+ tokenDecimals
104
+ );
104
105
 
105
- if (value < tokenStep || value > availableFundsBig || !value) {
106
+ if (value < tokenStep || value > availableFundsBig || !value) {
107
+ setIsWithdrawInvalid(true);
108
+ }
109
+ } catch (e) {
106
110
  setIsWithdrawInvalid(true);
107
111
  }
108
112
 
@@ -35,9 +35,9 @@ const CommitStepWrapper = styled.div`
35
35
  const COMMIT_STEPS = [
36
36
  {
37
37
  icon: ShoppingCart,
38
- header: "Commit",
38
+ header: "Commit to Buy",
39
39
  description:
40
- "Commit to an Offer to receive a Redeemable NFT (rNFT) that can be exchanged for the real-world item it represents"
40
+ "Commit to buy an offer to receive a Redeemable NFT (rNFT) that can be exchanged for the real-world item it represents"
41
41
  },
42
42
  {
43
43
  icon: CurrencyCircleDollar,
@@ -63,9 +63,9 @@ export default function PurchaseOverview() {
63
63
  <b>How does the purchase process work?</b>
64
64
  </Typography>
65
65
  <Typography tag="p">
66
- When Committing, the item price will be transferred into escrow and
67
- you will receive a redeemable NFT (rNFT) that can be exchanged for the
68
- real-world item it represents.
66
+ When Committing to Buy, the item price will be transferred into escrow
67
+ and you will receive a redeemable NFT (rNFT) that can be exchanged for
68
+ the real-world item it represents.
69
69
  </Typography>
70
70
  </Grid>
71
71
  <CommitStepWrapper>
@@ -7,7 +7,7 @@ import { Grid } from "../../../../ui/Grid";
7
7
 
8
8
  const colors = theme.colors.light;
9
9
  type Props = {
10
- onBackClick: () => void;
10
+ onBackClick?: () => void;
11
11
  };
12
12
  export function PurchaseOverviewView({ onBackClick }: Props) {
13
13
  const dispatch = useNonModalContext();
@@ -16,11 +16,15 @@ export function PurchaseOverviewView({ onBackClick }: Props) {
16
16
  payload: {
17
17
  headerComponent: (
18
18
  <Grid style={{ flex: "1" }}>
19
- <ArrowLeft
20
- onClick={onBackClick}
21
- size={32}
22
- style={{ cursor: "pointer" }}
23
- />
19
+ {onBackClick && (
20
+ <ArrowLeft
21
+ onClick={() => {
22
+ onBackClick();
23
+ }}
24
+ size={32}
25
+ style={{ cursor: "pointer" }}
26
+ />
27
+ )}
24
28
  </Grid>
25
29
  ),
26
30
  contentStyle: {
@@ -28,7 +32,6 @@ export function PurchaseOverviewView({ onBackClick }: Props) {
28
32
  }
29
33
  }
30
34
  });
31
- // eslint-disable-next-line react-hooks/exhaustive-deps
32
- }, [dispatch]);
35
+ }, [dispatch, onBackClick]);
33
36
  return <PurchaseOverview />;
34
37
  }
@@ -294,6 +294,7 @@ export default function DetailSlider({
294
294
  style={{ cursor: "pointer" }}
295
295
  dataTestId="offerAnimationUrl"
296
296
  videoProps={{ muted: true, loop: true, autoPlay: true }}
297
+ withMuteButton
297
298
  />
298
299
  )}
299
300
  </>
@@ -9,6 +9,7 @@ import { useBreakpoints } from "../../../hooks/useBreakpoints";
9
9
 
10
10
  const colors = theme.colors.light;
11
11
  const Wrapper = styled.div<{ $flexWrap: string }>`
12
+ box-sizing: border-box;
12
13
  container-type: inline-size;
13
14
  position: relative;
14
15
  width: 100%;
@@ -117,7 +117,6 @@ const GlobalStyle = createGlobalStyle<
117
117
  margin: 0;
118
118
  padding: 0;
119
119
 
120
- background-color: var(--primaryBgColor);
121
120
  color: var(--textColor);
122
121
 
123
122
  font-family: ${(props) => props.$fontFamily || "Plus Jakarta Sans"};
@@ -207,7 +207,7 @@ const allThemes = ({ withBosonStyle }: { withBosonStyle?: boolean }) => {
207
207
  outline: {
208
208
  color: colors.black,
209
209
  borderColor: colors.border,
210
- borderWidth: 1,
210
+ borderWidth: 2,
211
211
  hover: {
212
212
  background: colors.border,
213
213
  color: "var(--accent)"
@@ -222,7 +222,6 @@ const allThemes = ({ withBosonStyle }: { withBosonStyle?: boolean }) => {
222
222
  },
223
223
  blank: {
224
224
  color: `${colors.black}4d`,
225
- padding: "0.75rem 0.5rem",
226
225
  hover: {
227
226
  color: colors.black
228
227
  },
@@ -233,7 +232,6 @@ const allThemes = ({ withBosonStyle }: { withBosonStyle?: boolean }) => {
233
232
  },
234
233
  blankSecondary: {
235
234
  color: "var(--accent)",
236
- padding: "0.75rem 0.5rem",
237
235
  hover: {
238
236
  borderColor: colors.secondary,
239
237
  background: colors.border,
@@ -242,7 +240,7 @@ const allThemes = ({ withBosonStyle }: { withBosonStyle?: boolean }) => {
242
240
  },
243
241
  blankSecondaryOutline: {
244
242
  color: "var(--accent)",
245
- borderWidth: 1,
243
+ borderWidth: 2,
246
244
  borderColor: colors.secondary,
247
245
  hover: {
248
246
  borderColor: colors.secondary,
@@ -252,8 +250,7 @@ const allThemes = ({ withBosonStyle }: { withBosonStyle?: boolean }) => {
252
250
  },
253
251
  blankOutline: {
254
252
  color: colors.black,
255
- padding: "1rem 2rem",
256
- borderWidth: 1,
253
+ borderWidth: 2,
257
254
  hover: {
258
255
  borderColor: colors.secondary,
259
256
  background: colors.border,
@@ -263,14 +260,23 @@ const allThemes = ({ withBosonStyle }: { withBosonStyle?: boolean }) => {
263
260
  white: {
264
261
  color: colors.black,
265
262
  background: colors.white,
266
- padding: "1rem",
267
- borderWidth: 1,
263
+ borderWidth: 2,
268
264
  borderColor: colors.border,
269
265
  hover: {
270
266
  color: colors.white,
271
267
  background: colors.black
272
268
  }
273
269
  },
270
+ black: {
271
+ color: colors.white,
272
+ background: colors.black,
273
+ borderWidth: 2,
274
+ borderColor: colors.black,
275
+ hover: {
276
+ color: colors.black,
277
+ background: colors.white
278
+ }
279
+ },
274
280
  warning: {
275
281
  color: colors.black,
276
282
  borderColor: colors.orange,
@@ -96,6 +96,7 @@ interface IVideo {
96
96
  showPlaceholderText?: boolean;
97
97
  noPreload?: boolean;
98
98
  videoProps?: VideoHTMLAttributes<HTMLElement>;
99
+ withMuteButton?: boolean;
99
100
  componentWhileLoading?: () => ReactElement;
100
101
  }
101
102
  const Video: React.FC<IVideo & React.HTMLAttributes<HTMLDivElement>> = ({
@@ -105,6 +106,7 @@ const Video: React.FC<IVideo & React.HTMLAttributes<HTMLDivElement>> = ({
105
106
  showPlaceholderText = true,
106
107
  noPreload = false,
107
108
  videoProps,
109
+ withMuteButton,
108
110
  componentWhileLoading: ComponentWhileLoading,
109
111
  ...rest
110
112
  }) => {
@@ -222,10 +224,12 @@ const Video: React.FC<IVideo & React.HTMLAttributes<HTMLDivElement>> = ({
222
224
  {children || ""}
223
225
  {videoSrc && (
224
226
  <>
225
- <StyledMuteButton
226
- muted={muted}
227
- onClick={() => setMuted((prev) => !prev)}
228
- />
227
+ {withMuteButton && (
228
+ <StyledMuteButton
229
+ muted={muted}
230
+ onClick={() => setMuted((prev) => !prev)}
231
+ />
232
+ )}
229
233
  <VideoHtml
230
234
  ref={videoRef}
231
235
  data-testid={dataTestId}
@@ -14,7 +14,7 @@ export const button = css`
14
14
  align-items: center;
15
15
  padding: 1rem 1.5px;
16
16
  gap: 0.5rem;
17
- margin: 1px;
17
+ margin: 0;
18
18
  position: relative;
19
19
  overflow: hidden;
20
20
  box-shadow: 0px 0px 0px #000000;
@@ -7,32 +7,20 @@ import styled from "styled-components";
7
7
  import { useAccount } from "../../../hooks/connection/connection";
8
8
  import { useDisconnect } from "../../../hooks/connection/useDisconnect";
9
9
  import { useCurrentSellers } from "../../../hooks/useCurrentSellers";
10
- import { CONFIG } from "../../../lib/config/config";
11
- import {
12
- ConfigProvider,
13
- ConfigProviderProps
14
- } from "../../config/ConfigProvider";
15
- import { MagicProvider } from "../../magicLink/MagicProvider";
16
- import ModalProvider from "../../modal/ModalProvider";
17
- import { SignerProvider } from "../../signer/SignerProvider";
18
- import GlobalStyle from "../../styles/GlobalStyle";
19
10
  import { Grid } from "../../ui/Grid";
20
11
  import Loading from "../../ui/loading/Loading";
21
12
  import ConnectButton from "../../wallet/ConnectButton";
22
- import WalletConnectionProvider from "../../wallet/WalletConnectionProvider";
23
- import { getParentWindowOrigin } from "../common";
24
- import { CommonWidgetTypes } from "../types";
25
13
  import Finance, { Props } from "./Finance";
26
- import ConvertionRateProvider, {
27
- ConvertionRateProviderProps
28
- } from "./convertion-rate/ConvertionRateProvider";
29
14
  import { useConvertionRate } from "./convertion-rate/useConvertionRate";
30
15
  import { useExchangeTokens } from "./exchange-tokens/useExchangeTokens";
31
16
  import useFunds from "./useFunds";
32
17
  import { useOffersBacked } from "./useOffersBacked";
33
18
  import { useSellerDeposit } from "./useSellerDeposit";
34
19
  import { useSellerRoles } from "./useSellerRoles";
35
- import { withQueryClientProvider } from "../../queryClient/withQueryClientProvider";
20
+ import {
21
+ FinanceWidgetProviders,
22
+ FinanceWidgetProvidersProps
23
+ } from "./FinanceWidgetProviders";
36
24
  dayjs.extend(isBetween);
37
25
 
38
26
  const StyledConnectButton = styled(ConnectButton)`
@@ -146,49 +134,20 @@ function WithSellerData(WrappedComponent: React.ComponentType<Props>) {
146
134
  }
147
135
 
148
136
  const Component = WithSellerData(Finance);
149
- type FinanceWidgetProps = {
150
- walletConnectProjectId: string;
151
- } & Omit<ConfigProviderProps, "magicLinkKey" | "infuraKey"> &
152
- CommonWidgetTypes &
153
- ConvertionRateProviderProps & {
154
- sellerId: string | null | undefined;
155
- };
156
-
157
- const { infuraKey, magicLinkKey } = CONFIG;
137
+ type FinanceWidgetProps = FinanceWidgetProvidersProps & {
138
+ sellerId: string | null | undefined;
139
+ };
158
140
 
159
141
  export function FinanceWidget(props: FinanceWidgetProps) {
160
- const parentOrigin = getParentWindowOrigin();
161
- const { walletConnectProjectId, sellerId, withExternalSigner } = props;
142
+ const { sellerId, withExternalSigner } = props;
162
143
  return (
163
- <ConfigProvider
164
- magicLinkKey={magicLinkKey}
165
- infuraKey={infuraKey}
166
- {...props}
167
- >
168
- <GlobalStyle />
169
- <SignerProvider
170
- parentOrigin={parentOrigin}
171
- withExternalSigner={withExternalSigner}
172
- >
173
- <MagicProvider>
174
- <WalletConnectionProvider
175
- walletConnectProjectId={walletConnectProjectId}
176
- >
177
- <ConvertionRateProvider>
178
- <ModalProvider>
179
- {!withExternalSigner && (
180
- <Grid justifyContent="flex-end">
181
- <StyledConnectButton showChangeWallet />
182
- </Grid>
183
- )}
184
- <Component sellerId={sellerId ?? undefined} />
185
- </ModalProvider>
186
- </ConvertionRateProvider>
187
- </WalletConnectionProvider>
188
- </MagicProvider>
189
- </SignerProvider>
190
- </ConfigProvider>
144
+ <FinanceWidgetProviders {...props}>
145
+ {!withExternalSigner && (
146
+ <Grid justifyContent="flex-end">
147
+ <StyledConnectButton showChangeWallet />
148
+ </Grid>
149
+ )}
150
+ <Component sellerId={sellerId ?? undefined} />
151
+ </FinanceWidgetProviders>
191
152
  );
192
153
  }
193
-
194
- export default withQueryClientProvider(FinanceWidget);
@@ -0,0 +1,60 @@
1
+ import React, { ReactNode } from "react";
2
+ import { CONFIG } from "../../../lib/config/config";
3
+ import { withQueryClientProvider } from "../../queryClient/withQueryClientProvider";
4
+ import { Omit } from "utility-types";
5
+ import { CommonWidgetTypes } from "../types";
6
+ import { SignerProvider } from "../../signer/SignerProvider";
7
+ import GlobalStyle from "../../styles/GlobalStyle";
8
+ import {
9
+ ConfigProvider,
10
+ ConfigProviderProps
11
+ } from "../../config/ConfigProvider";
12
+ import ConvertionRateProvider, {
13
+ ConvertionRateProviderProps
14
+ } from "./convertion-rate/ConvertionRateProvider";
15
+ import WalletConnectionProvider, {
16
+ WalletConnectionProviderProps
17
+ } from "../../wallet/WalletConnectionProvider";
18
+ import ModalProvider from "../../modal/ModalProvider";
19
+ import { MagicProvider } from "../../magicLink/MagicProvider";
20
+ import { getParentWindowOrigin } from "../common";
21
+
22
+ export type FinanceWidgetProvidersProps = Omit<
23
+ WalletConnectionProviderProps,
24
+ "children" | "envName"
25
+ > &
26
+ Omit<ConfigProviderProps, "magicLinkKey" | "infuraKey"> &
27
+ CommonWidgetTypes &
28
+ ConvertionRateProviderProps & {
29
+ children: ReactNode;
30
+ };
31
+
32
+ const { infuraKey, magicLinkKey } = CONFIG;
33
+
34
+ export const FinanceWidgetProviders: React.FC<FinanceWidgetProvidersProps> =
35
+ withQueryClientProvider(({ children, ...props }) => {
36
+ const parentOrigin = getParentWindowOrigin();
37
+ return (
38
+ <ConfigProvider
39
+ magicLinkKey={magicLinkKey}
40
+ infuraKey={infuraKey}
41
+ {...props}
42
+ >
43
+ <GlobalStyle />
44
+ <SignerProvider
45
+ parentOrigin={parentOrigin}
46
+ withExternalSigner={props.withExternalSigner}
47
+ >
48
+ <MagicProvider>
49
+ <WalletConnectionProvider
50
+ walletConnectProjectId={props.walletConnectProjectId}
51
+ >
52
+ <ConvertionRateProvider>
53
+ <ModalProvider>{children}</ModalProvider>
54
+ </ConvertionRateProvider>
55
+ </WalletConnectionProvider>
56
+ </MagicProvider>
57
+ </SignerProvider>
58
+ </ConfigProvider>
59
+ );
60
+ });
@@ -135,9 +135,14 @@ export function useCtaClickHandler<T>({
135
135
  onSuccess?.(receipt as providers.TransactionReceipt, payload);
136
136
  }
137
137
  } catch (error) {
138
- onError?.(error as Error, {
139
- txResponse: txResponse as providers.TransactionResponse
140
- });
138
+ onError?.(
139
+ typeof error === "object"
140
+ ? (coreSdk.parseError(error as object) as Error)
141
+ : (error as Error),
142
+ {
143
+ txResponse: txResponse as providers.TransactionResponse
144
+ }
145
+ );
141
146
  } finally {
142
147
  setIsLoading(false);
143
148
  }
@@ -360,7 +360,9 @@ export function useCurrentSellers(
360
360
  resultByAddress.data
361
361
  ? resultByAddress.data.sellers.map((seller) => seller.id)
362
362
  : sellerAddressType === "SELLER_IDS"
363
- ? [sellerAddress]
363
+ ? Array.isArray(sellerAddress)
364
+ ? sellerAddress
365
+ : [sellerAddress]
364
366
  : []
365
367
  ).filter((sellerId) => !!sellerId) as string[];
366
368
  }, [resultByAddress.data, sellerAddress, sellerAddressType]);
package/src/index.tsx CHANGED
@@ -6,6 +6,7 @@ export { default as ThemedButton, IButton } from "./components/ui/ThemedButton";
6
6
  export * from "./components/ui/zIndex";
7
7
  export * from "./components/ui/buttonSize";
8
8
  export * from "./components/buttons/Button";
9
+ export * from "./components/buttons/CommitButtonView";
9
10
  export * from "./components/cta/exchange/BatchCompleteButton";
10
11
  export * from "./components/cta/exchange/CancelButton";
11
12
  export * from "./components/cta/exchange/CompleteButton";
@@ -49,6 +50,7 @@ export * from "./components/magicLink/MagicProvider";
49
50
  export * from "./components/magicLink/UserContext";
50
51
  export * from "./components/modal/components/common/OfferFullDescription/ExternalOfferFullDescription";
51
52
  export * from "./components/modal/components/common/detail/useGetOfferDetailData";
53
+ export * from "./components/modal/components/PurchaseOverview/PurchaseOverview";
52
54
  export * from "./components/modal/components/Commit/DetailView/ExternalCommitDetailView";
53
55
  export * from "./components/modal/components/Redeem/DetailView/ExternalExchangeDetailView";
54
56
  export * from "./components/ui/Grid";
@@ -62,15 +62,6 @@ const CHAIN_INFO: ChainInfoMap = {
62
62
  logoUrl: ethereumLogoUrl,
63
63
  nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }
64
64
  },
65
- [ChainId.GOERLI]: {
66
- networkType: NetworkType.L1,
67
- docs: "https://docs.uniswap.org/",
68
- explorer: "https://goerli.etherscan.io/",
69
- infoLink: "https://info.uniswap.org/#/",
70
- label: "Görli",
71
- logoUrl: ethereumLogoUrl,
72
- nativeCurrency: { name: "Görli Ether", symbol: "görETH", decimals: 18 }
73
- },
74
65
  [ChainId.SEPOLIA]: {
75
66
  networkType: NetworkType.L1,
76
67
  docs: "https://docs.uniswap.org/",
@@ -22,8 +22,8 @@ export const CHAIN_IDS_TO_NAMES = {
22
22
  */
23
23
  export const L1_CHAIN_IDS = [
24
24
  ChainId.MAINNET,
25
- ChainId.GOERLI,
26
- // ChainId.SEPOLIA,
25
+ // ChainId.GOERLI,
26
+ ChainId.SEPOLIA,
27
27
  ChainId.POLYGON,
28
28
  ChainId.POLYGON_MUMBAI
29
29
  // LocalChainId
@@ -45,7 +45,7 @@ async function validateInputPreProvider(txHash: string, network: string) {
45
45
  ) {
46
46
  throw new Error("Invalid transaction hash");
47
47
  }
48
- const networks = ["mainnet", "kovan", "goerli", "ropsten", "rinkeby"];
48
+ const networks = ["mainnet", "sepolia"];
49
49
  if (!networks.includes(network)) {
50
50
  throw new Error("Not a valid network");
51
51
  }
@@ -1,23 +1,17 @@
1
- import { BigNumber } from "ethers";
1
+ import { utils } from "ethers";
2
2
 
3
3
  export const getNumberWithoutDecimals = (
4
4
  value: string,
5
5
  decimals: string
6
6
  ): string => {
7
- const valueAsNumber = Number(value);
8
- if (!Number.isInteger(valueAsNumber)) {
9
- return Math.floor(valueAsNumber * 10 ** Number(decimals)).toString();
10
- }
11
- return BigNumber.from(valueAsNumber + "")
12
- .mul(BigNumber.from(10).pow(BigNumber.from(decimals)))
13
- .toString();
7
+ return utils.parseUnits(value, decimals).toString();
14
8
  };
15
9
 
16
10
  export const getNumberWithDecimals = (
17
11
  value: string,
18
12
  decimals: string
19
13
  ): number => {
20
- return Number(value) * 10 ** -Number(decimals);
14
+ return Number(utils.formatUnits(value, decimals));
21
15
  };
22
16
 
23
17
  /**
@@ -11,11 +11,6 @@ const openSeaUrlMap = new Map([
11
11
  (tokenId: string, contractAddress: string) =>
12
12
  `https://testnets.opensea.io/assets/mumbai/${contractAddress}/${tokenId}`
13
13
  ],
14
- [
15
- "testing-5-0",
16
- (tokenId: string, contractAddress: string) =>
17
- `https://testnets.opensea.io/assets/goerli/${contractAddress}/${tokenId}`
18
- ],
19
14
  [
20
15
  "testing-11155111-0",
21
16
  (tokenId: string, contractAddress: string) =>
@@ -31,11 +26,6 @@ const openSeaUrlMap = new Map([
31
26
  (tokenId: string, contractAddress: string) =>
32
27
  `https://testnets.opensea.io/assets/mumbai/${contractAddress}/${tokenId}`
33
28
  ],
34
- [
35
- "staging-5-0",
36
- (tokenId: string, contractAddress: string) =>
37
- `https://testnets.opensea.io/assets/goerli/${contractAddress}/${tokenId}`
38
- ],
39
29
  [
40
30
  "staging-11155111-0",
41
31
  (tokenId: string, contractAddress: string) =>
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ import { ComponentStory, ComponentMeta } from "@storybook/react";
3
+ import { PurchaseOverview } from "../components/modal/components/PurchaseOverview/PurchaseOverview";
4
+
5
+ // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
6
+ export default {
7
+ title: "Visual Components/PurchaseOverview",
8
+ component: PurchaseOverview,
9
+ argTypes: {
10
+ lookAndFeel: {
11
+ options: ["modal", "regular"],
12
+ control: { type: "radio" }
13
+ }
14
+ }
15
+ } as ComponentMeta<typeof PurchaseOverview>;
16
+
17
+ // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
18
+ const Template: ComponentStory<typeof PurchaseOverview> = (args) => (
19
+ <PurchaseOverview {...args} />
20
+ );
21
+
22
+ export const Base: ComponentStory<typeof PurchaseOverview> = Template.bind({});
23
+
24
+ // More on args: https://storybook.js.org/docs/react/writing-stories/args
25
+ Base.args = {
26
+ hideModal: () => console.log("hideModal"),
27
+ lookAndFeel: "modal",
28
+ modalMargin: "2%"
29
+ };