@bosonprotocol/react-kit 0.42.0-alpha.2 → 0.42.0-alpha.4
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/components/boson/BosonProvider.js +1 -1
- package/dist/cjs/components/contractualAgreement/ContractualAgreement.d.ts.map +1 -1
- package/dist/cjs/components/contractualAgreement/ContractualAgreement.js +8 -3
- package/dist/cjs/components/contractualAgreement/ContractualAgreement.js.map +1 -1
- package/dist/cjs/components/modal/components/common/detail/PhygitalProduct.d.ts.map +1 -1
- package/dist/cjs/components/modal/components/common/detail/PhygitalProduct.js +1 -1
- package/dist/cjs/components/modal/components/common/detail/PhygitalProduct.js.map +1 -1
- package/dist/cjs/components/modal/components/common/detail/useGetOfferDetailData.d.ts.map +1 -1
- package/dist/cjs/components/modal/components/common/detail/useGetOfferDetailData.js +9 -2
- package/dist/cjs/components/modal/components/common/detail/useGetOfferDetailData.js.map +1 -1
- package/dist/cjs/components/offerPolicy/OfferPolicyDetails.d.ts.map +1 -1
- package/dist/cjs/components/offerPolicy/OfferPolicyDetails.js +18 -8
- package/dist/cjs/components/offerPolicy/OfferPolicyDetails.js.map +1 -1
- package/dist/cjs/hooks/useCheckExchangePolicy.d.ts.map +1 -1
- package/dist/cjs/hooks/useCheckExchangePolicy.js +21 -16
- package/dist/cjs/hooks/useCheckExchangePolicy.js.map +1 -1
- package/dist/cjs/hooks/useRenderTemplate.d.ts.map +1 -1
- package/dist/cjs/hooks/useRenderTemplate.js +16 -5
- package/dist/cjs/hooks/useRenderTemplate.js.map +1 -1
- package/dist/cjs/lib/offer/getOfferDetails.d.ts.map +1 -1
- package/dist/cjs/lib/offer/getOfferDetails.js +7 -6
- package/dist/cjs/lib/offer/getOfferDetails.js.map +1 -1
- package/dist/esm/components/boson/BosonProvider.js +1 -1
- package/dist/esm/components/contractualAgreement/ContractualAgreement.d.ts.map +1 -1
- package/dist/esm/components/contractualAgreement/ContractualAgreement.js +8 -3
- package/dist/esm/components/contractualAgreement/ContractualAgreement.js.map +1 -1
- package/dist/esm/components/modal/components/common/detail/PhygitalProduct.d.ts.map +1 -1
- package/dist/esm/components/modal/components/common/detail/PhygitalProduct.js +1 -1
- package/dist/esm/components/modal/components/common/detail/PhygitalProduct.js.map +1 -1
- package/dist/esm/components/modal/components/common/detail/useGetOfferDetailData.d.ts.map +1 -1
- package/dist/esm/components/modal/components/common/detail/useGetOfferDetailData.js +9 -2
- package/dist/esm/components/modal/components/common/detail/useGetOfferDetailData.js.map +1 -1
- package/dist/esm/components/offerPolicy/OfferPolicyDetails.d.ts.map +1 -1
- package/dist/esm/components/offerPolicy/OfferPolicyDetails.js +17 -10
- package/dist/esm/components/offerPolicy/OfferPolicyDetails.js.map +1 -1
- package/dist/esm/hooks/useCheckExchangePolicy.d.ts.map +1 -1
- package/dist/esm/hooks/useCheckExchangePolicy.js +20 -15
- package/dist/esm/hooks/useCheckExchangePolicy.js.map +1 -1
- package/dist/esm/hooks/useRenderTemplate.d.ts.map +1 -1
- package/dist/esm/hooks/useRenderTemplate.js +14 -6
- package/dist/esm/hooks/useRenderTemplate.js.map +1 -1
- package/dist/esm/lib/offer/getOfferDetails.d.ts.map +1 -1
- package/dist/esm/lib/offer/getOfferDetails.js +7 -6
- package/dist/esm/lib/offer/getOfferDetails.js.map +1 -1
- package/package.json +9 -5
- package/src/components/boson/BosonProvider.tsx +1 -1
- package/src/components/contractualAgreement/ContractualAgreement.tsx +14 -3
- package/src/components/modal/components/common/detail/PhygitalProduct.tsx +1 -0
- package/src/components/modal/components/common/detail/useGetOfferDetailData.tsx +10 -1
- package/src/components/offerPolicy/OfferPolicyDetails.tsx +26 -16
- package/src/hooks/useCheckExchangePolicy.ts +30 -26
- package/src/hooks/useRenderTemplate.ts +25 -6
- package/src/lib/offer/getOfferDetails.ts +7 -5
- package/src/stories/widgets/Commit.stories.tsx +15 -15
|
@@ -32,29 +32,34 @@ const getRulesTemplate = async (
|
|
|
32
32
|
const rulesTemplate = JSON.parse(
|
|
33
33
|
rulesTemplateText
|
|
34
34
|
) as offers.CheckExchangePolicyRules;
|
|
35
|
-
// replace DEFAULT_DISPUTE_RESOLVER_ID (environment dependent)
|
|
36
|
-
const disputeResolverId_matches =
|
|
37
|
-
rulesTemplate?.yupSchema?.properties?.disputeResolverId?.matches?.replace(
|
|
38
|
-
"<DEFAULT_DISPUTE_RESOLVER_ID>",
|
|
39
|
-
defaultDisputeResolverId
|
|
40
|
-
);
|
|
41
|
-
if (disputeResolverId_matches) {
|
|
42
|
-
rulesTemplate.yupSchema.properties.disputeResolverId.matches =
|
|
43
|
-
disputeResolverId_matches;
|
|
44
|
-
}
|
|
45
|
-
// replace TOKENS_LIST (environment dependent)
|
|
46
35
|
const tokensList = defaultTokens.map((token) => token.address);
|
|
47
|
-
const
|
|
48
|
-
rulesTemplate
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
36
|
+
for (const schema of [
|
|
37
|
+
rulesTemplate.yupSchema,
|
|
38
|
+
...(rulesTemplate.yupSchemas || [])
|
|
39
|
+
]) {
|
|
40
|
+
// replace DEFAULT_DISPUTE_RESOLVER_ID (environment dependent)
|
|
41
|
+
if (schema.properties?.disputeResolverId?.matches) {
|
|
42
|
+
const disputeResolverId_matches =
|
|
43
|
+
schema.properties?.disputeResolverId?.matches?.replace(
|
|
44
|
+
"<DEFAULT_DISPUTE_RESOLVER_ID>",
|
|
45
|
+
defaultDisputeResolverId
|
|
46
|
+
);
|
|
47
|
+
if (disputeResolverId_matches) {
|
|
48
|
+
schema.properties.disputeResolverId.matches = disputeResolverId_matches;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// replace TOKENS_LIST (environment dependent)
|
|
52
|
+
if (schema.properties?.exchangeToken?.properties?.address?.pattern) {
|
|
53
|
+
const tokensList_pattern =
|
|
54
|
+
schema.properties?.exchangeToken?.properties?.address?.pattern?.replace(
|
|
55
|
+
"<TOKENS_LIST>",
|
|
56
|
+
tokensList.join("|")
|
|
57
|
+
);
|
|
58
|
+
if (schema.properties.exchangeToken.properties && tokensList_pattern) {
|
|
59
|
+
schema.properties.exchangeToken.properties.address.pattern =
|
|
60
|
+
tokensList_pattern;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
58
63
|
}
|
|
59
64
|
return rulesTemplate;
|
|
60
65
|
};
|
|
@@ -78,14 +83,13 @@ export default function useCheckExchangePolicy({
|
|
|
78
83
|
defaultDisputeResolverId,
|
|
79
84
|
defaultTokens
|
|
80
85
|
],
|
|
81
|
-
() =>
|
|
82
|
-
|
|
86
|
+
() =>
|
|
87
|
+
getRulesTemplate(
|
|
83
88
|
fairExchangePolicyRules,
|
|
84
89
|
ipfsGateway,
|
|
85
90
|
defaultDisputeResolverId,
|
|
86
91
|
defaultTokens
|
|
87
|
-
)
|
|
88
|
-
}
|
|
92
|
+
)
|
|
89
93
|
);
|
|
90
94
|
useEffect(() => {
|
|
91
95
|
if (!core || !offerId || !fairExchangePolicyRules || !rulesTemplate) {
|
|
@@ -6,6 +6,7 @@ import { ProgressStatus } from "../lib/progress/progressStatus";
|
|
|
6
6
|
import { useCoreSDKWithContext } from "./core-sdk/useCoreSdkWithContext";
|
|
7
7
|
|
|
8
8
|
import { useIpfsStorage } from "./useIpfsStorage";
|
|
9
|
+
import { isBundle } from "..";
|
|
9
10
|
|
|
10
11
|
type OfferFieldsFragment = subgraph.OfferFieldsFragment;
|
|
11
12
|
type AdditionalOfferMetadata = offers.AdditionalOfferMetadata;
|
|
@@ -81,6 +82,13 @@ function buildOfferData(offerFields: OfferFieldsFragment): {
|
|
|
81
82
|
offerArgs: CreateOfferArgs;
|
|
82
83
|
offerMetadata: AdditionalOfferMetadata;
|
|
83
84
|
} {
|
|
85
|
+
const productItemMetadata = isBundle(offerFields)
|
|
86
|
+
? (offerFields.metadata as subgraph.BundleMetadataEntity).items?.find(
|
|
87
|
+
(item): item is subgraph.ProductV1ItemMetadataEntity =>
|
|
88
|
+
item.type === subgraph.ItemMetadataType.ITEM_PRODUCT_V1
|
|
89
|
+
)
|
|
90
|
+
: undefined;
|
|
91
|
+
|
|
84
92
|
return {
|
|
85
93
|
offerArgs: {
|
|
86
94
|
price: offerFields.price as string,
|
|
@@ -104,6 +112,11 @@ function buildOfferData(offerFields: OfferFieldsFragment): {
|
|
|
104
112
|
)
|
|
105
113
|
.mul(1000)
|
|
106
114
|
.toString(),
|
|
115
|
+
voucherValidDurationInMS: ethers.BigNumber.from(
|
|
116
|
+
offerFields.voucherValidDuration
|
|
117
|
+
)
|
|
118
|
+
.mul(1000)
|
|
119
|
+
.toString(),
|
|
107
120
|
disputePeriodDurationInMS: ethers.BigNumber.from(
|
|
108
121
|
offerFields.disputePeriodDuration
|
|
109
122
|
)
|
|
@@ -128,11 +141,15 @@ function buildOfferData(offerFields: OfferFieldsFragment): {
|
|
|
128
141
|
},
|
|
129
142
|
offerMetadata: {
|
|
130
143
|
sellerContactMethod:
|
|
131
|
-
(
|
|
132
|
-
|
|
144
|
+
(
|
|
145
|
+
productItemMetadata ||
|
|
146
|
+
(offerFields.metadata as ProductV1MetadataFields)
|
|
147
|
+
)?.exchangePolicy?.sellerContactMethod || "undefined",
|
|
133
148
|
disputeResolverContactMethod:
|
|
134
|
-
(
|
|
135
|
-
|
|
149
|
+
(
|
|
150
|
+
productItemMetadata ||
|
|
151
|
+
(offerFields.metadata as ProductV1MetadataFields)
|
|
152
|
+
)?.exchangePolicy?.disputeResolverContactMethod || "undefined",
|
|
136
153
|
escalationDeposit:
|
|
137
154
|
offerFields.disputeResolutionTerms.buyerEscalationDeposit,
|
|
138
155
|
escalationResponsePeriodInSec:
|
|
@@ -141,8 +158,10 @@ function buildOfferData(offerFields: OfferFieldsFragment): {
|
|
|
141
158
|
(offerFields.metadata as ProductV1MetadataFields)?.productV1Seller
|
|
142
159
|
?.name || "undefined",
|
|
143
160
|
returnPeriodInDays:
|
|
144
|
-
(
|
|
145
|
-
|
|
161
|
+
(
|
|
162
|
+
productItemMetadata ||
|
|
163
|
+
(offerFields.metadata as ProductV1MetadataFields)
|
|
164
|
+
)?.shipping?.returnPeriodInDays || 0
|
|
146
165
|
}
|
|
147
166
|
};
|
|
148
167
|
}
|
|
@@ -90,13 +90,15 @@ export const getOfferDetails = (
|
|
|
90
90
|
const shippingInfo = {
|
|
91
91
|
returnPeriodInDays:
|
|
92
92
|
productV1ItemMetadataEntity?.shipping?.returnPeriodInDays ||
|
|
93
|
-
isProductV1(offer)
|
|
93
|
+
(isProductV1(offer)
|
|
94
94
|
? (offer.metadata as ProductV1Sub).shipping?.returnPeriodInDays
|
|
95
|
-
: undefined,
|
|
95
|
+
: undefined),
|
|
96
96
|
shippingTable:
|
|
97
|
-
(
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
(
|
|
98
|
+
productV1ItemMetadataEntity?.shipping ||
|
|
99
|
+
(isProductV1(offer)
|
|
100
|
+
? (offer.metadata as ProductV1Sub).shipping
|
|
101
|
+
: undefined)
|
|
100
102
|
)?.supportedJurisdictions?.map((jurisdiction) => ({
|
|
101
103
|
name: jurisdiction.label,
|
|
102
104
|
value: jurisdiction.deliveryTime
|
|
@@ -45,7 +45,7 @@ Commit.args = {
|
|
|
45
45
|
defaultCurrencyTicker: "USD",
|
|
46
46
|
contactSellerForExchangeUrl: "https://bosonapp.io/#/chat/{id}",
|
|
47
47
|
fairExchangePolicyRules:
|
|
48
|
-
"ipfs://
|
|
48
|
+
"ipfs://QmPBjCyxLdYFGQRJnD1xfdtBTEUsviwJV5Y4ZN3rCBo2QQ",
|
|
49
49
|
ipfsGateway: process.env.STORYBOOK_DATA_IPFS_GATEWAY,
|
|
50
50
|
ipfsProjectId: process.env.STORYBOOK_DATA_IPFS_PROJECT_ID,
|
|
51
51
|
ipfsProjectSecret: process.env.STORYBOOK_DATA_IPFS_PROJECT_SECRET,
|
|
@@ -80,7 +80,7 @@ CommitTokenGated_ERC20.args = {
|
|
|
80
80
|
defaultCurrencyTicker: "USD",
|
|
81
81
|
contactSellerForExchangeUrl: "https://bosonapp.io/#/chat/{id}",
|
|
82
82
|
fairExchangePolicyRules:
|
|
83
|
-
"ipfs://
|
|
83
|
+
"ipfs://QmPBjCyxLdYFGQRJnD1xfdtBTEUsviwJV5Y4ZN3rCBo2QQ",
|
|
84
84
|
ipfsGateway: process.env.STORYBOOK_DATA_IPFS_GATEWAY,
|
|
85
85
|
ipfsProjectId: process.env.STORYBOOK_DATA_IPFS_PROJECT_ID,
|
|
86
86
|
ipfsProjectSecret: process.env.STORYBOOK_DATA_IPFS_PROJECT_SECRET,
|
|
@@ -88,8 +88,8 @@ CommitTokenGated_ERC20.args = {
|
|
|
88
88
|
defaultSelectedOfferId: "",
|
|
89
89
|
disableVariationsSelects: false,
|
|
90
90
|
bundleUuid: "",
|
|
91
|
-
productUuid: "
|
|
92
|
-
sellerId: "
|
|
91
|
+
productUuid: "ee68e2-d038-f433-e421-d053af38c887", // token gated no variations
|
|
92
|
+
sellerId: "33",
|
|
93
93
|
metaTx: {
|
|
94
94
|
apiKey: process.env.STORYBOOK_DATA_META_TX_API_KEY as string,
|
|
95
95
|
apiIds: process.env.STORYBOOK_DATA_META_TX_API_IDS as string
|
|
@@ -114,7 +114,7 @@ CommitWithColorAndSizeVariations.args = {
|
|
|
114
114
|
...BASE_ARGS,
|
|
115
115
|
contactSellerForExchangeUrl: "https://bosonapp.io/#/chat/{id}",
|
|
116
116
|
fairExchangePolicyRules:
|
|
117
|
-
"ipfs://
|
|
117
|
+
"ipfs://QmPBjCyxLdYFGQRJnD1xfdtBTEUsviwJV5Y4ZN3rCBo2QQ",
|
|
118
118
|
ipfsGateway: process.env.STORYBOOK_DATA_IPFS_GATEWAY,
|
|
119
119
|
ipfsProjectId: process.env.STORYBOOK_DATA_IPFS_PROJECT_ID,
|
|
120
120
|
ipfsProjectSecret: process.env.STORYBOOK_DATA_IPFS_PROJECT_SECRET,
|
|
@@ -122,8 +122,8 @@ CommitWithColorAndSizeVariations.args = {
|
|
|
122
122
|
defaultSelectedOfferId: "",
|
|
123
123
|
disableVariationsSelects: false,
|
|
124
124
|
bundleUuid: "",
|
|
125
|
-
productUuid: "
|
|
126
|
-
sellerId: "
|
|
125
|
+
productUuid: "f4bb0f8-2f2c-d151-2801-0d3c6250461", // with color and size variations
|
|
126
|
+
sellerId: "20",
|
|
127
127
|
metaTx: {
|
|
128
128
|
apiKey: process.env.STORYBOOK_DATA_META_TX_API_KEY as string,
|
|
129
129
|
apiIds: process.env.STORYBOOK_DATA_META_TX_API_IDS as string
|
|
@@ -151,7 +151,7 @@ CommitTokenGated_ERC721.args = {
|
|
|
151
151
|
defaultCurrencyTicker: "USD",
|
|
152
152
|
contactSellerForExchangeUrl: "https://bosonapp.io/#/chat/{id}",
|
|
153
153
|
fairExchangePolicyRules:
|
|
154
|
-
"ipfs://
|
|
154
|
+
"ipfs://QmPBjCyxLdYFGQRJnD1xfdtBTEUsviwJV5Y4ZN3rCBo2QQ",
|
|
155
155
|
ipfsGateway: process.env.STORYBOOK_DATA_IPFS_GATEWAY,
|
|
156
156
|
ipfsProjectId: process.env.STORYBOOK_DATA_IPFS_PROJECT_ID,
|
|
157
157
|
ipfsProjectSecret: process.env.STORYBOOK_DATA_IPFS_PROJECT_SECRET,
|
|
@@ -159,8 +159,8 @@ CommitTokenGated_ERC721.args = {
|
|
|
159
159
|
defaultSelectedOfferId: "",
|
|
160
160
|
disableVariationsSelects: false,
|
|
161
161
|
bundleUuid: "",
|
|
162
|
-
productUuid: "
|
|
163
|
-
sellerId: "
|
|
162
|
+
productUuid: "5366841-ded3-b381-0d8-1536bc1d83a4",
|
|
163
|
+
sellerId: "2",
|
|
164
164
|
metaTx: {
|
|
165
165
|
apiKey: process.env.STORYBOOK_DATA_META_TX_API_KEY as string,
|
|
166
166
|
apiIds: process.env.STORYBOOK_DATA_META_TX_API_IDS as string
|
|
@@ -188,7 +188,7 @@ CommitTokenGated_ERC721_2.args = {
|
|
|
188
188
|
defaultCurrencyTicker: "USD",
|
|
189
189
|
contactSellerForExchangeUrl: "https://bosonapp.io/#/chat/{id}",
|
|
190
190
|
fairExchangePolicyRules:
|
|
191
|
-
"ipfs://
|
|
191
|
+
"ipfs://QmPBjCyxLdYFGQRJnD1xfdtBTEUsviwJV5Y4ZN3rCBo2QQ",
|
|
192
192
|
ipfsGateway: process.env.STORYBOOK_DATA_IPFS_GATEWAY,
|
|
193
193
|
ipfsProjectId: process.env.STORYBOOK_DATA_IPFS_PROJECT_ID,
|
|
194
194
|
ipfsProjectSecret: process.env.STORYBOOK_DATA_IPFS_PROJECT_SECRET,
|
|
@@ -225,7 +225,7 @@ CommitTokenGated_ERC1155.args = {
|
|
|
225
225
|
defaultCurrencyTicker: "USD",
|
|
226
226
|
contactSellerForExchangeUrl: "https://bosonapp.io/#/chat/{id}",
|
|
227
227
|
fairExchangePolicyRules:
|
|
228
|
-
"ipfs://
|
|
228
|
+
"ipfs://QmPBjCyxLdYFGQRJnD1xfdtBTEUsviwJV5Y4ZN3rCBo2QQ",
|
|
229
229
|
ipfsGateway: process.env.STORYBOOK_DATA_IPFS_GATEWAY,
|
|
230
230
|
ipfsProjectId: process.env.STORYBOOK_DATA_IPFS_PROJECT_ID,
|
|
231
231
|
ipfsProjectSecret: process.env.STORYBOOK_DATA_IPFS_PROJECT_SECRET,
|
|
@@ -233,8 +233,8 @@ CommitTokenGated_ERC1155.args = {
|
|
|
233
233
|
defaultSelectedOfferId: "",
|
|
234
234
|
disableVariationsSelects: false,
|
|
235
235
|
bundleUuid: "",
|
|
236
|
-
productUuid: "
|
|
237
|
-
sellerId: "
|
|
236
|
+
productUuid: "5b60fd-de6d-f33-db11-7c70e20bb70e", // token gated 1155
|
|
237
|
+
sellerId: "6",
|
|
238
238
|
metaTx: {
|
|
239
239
|
apiKey: process.env.STORYBOOK_DATA_META_TX_API_KEY as string,
|
|
240
240
|
apiIds: process.env.STORYBOOK_DATA_META_TX_API_IDS as string
|
|
@@ -262,7 +262,7 @@ CommitBundle.args = {
|
|
|
262
262
|
defaultCurrencyTicker: "USD",
|
|
263
263
|
contactSellerForExchangeUrl: "https://bosonapp.io/#/chat/{id}",
|
|
264
264
|
fairExchangePolicyRules:
|
|
265
|
-
"ipfs://
|
|
265
|
+
"ipfs://QmPBjCyxLdYFGQRJnD1xfdtBTEUsviwJV5Y4ZN3rCBo2QQ",
|
|
266
266
|
ipfsGateway: process.env.STORYBOOK_DATA_IPFS_GATEWAY,
|
|
267
267
|
ipfsProjectId: process.env.STORYBOOK_DATA_IPFS_PROJECT_ID,
|
|
268
268
|
ipfsProjectSecret: process.env.STORYBOOK_DATA_IPFS_PROJECT_SECRET,
|