@bosonprotocol/react-kit 0.41.0-alpha.2 → 0.41.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/widgets/roblox/components/ConnectRoblox.js +3 -3
- package/dist/cjs/components/widgets/roblox/components/ConnectRoblox.js.map +1 -1
- package/dist/cjs/components/widgets/roblox/components/RobloxExchangesGrid.d.ts +1 -1
- package/dist/cjs/components/widgets/roblox/components/RobloxExchangesGrid.d.ts.map +1 -1
- package/dist/cjs/components/widgets/roblox/components/RobloxExchangesGrid.js.map +1 -1
- package/dist/cjs/components/widgets/roblox/components/RobloxProductsGrid.d.ts +1 -1
- package/dist/cjs/components/widgets/roblox/components/RobloxProductsGrid.d.ts.map +1 -1
- package/dist/cjs/components/widgets/roblox/components/RobloxProductsGrid.js +1 -1
- package/dist/cjs/components/widgets/roblox/components/RobloxProductsGrid.js.map +1 -1
- package/dist/cjs/hooks/roblox/context/RobloxProvider.js +2 -2
- package/dist/cjs/hooks/roblox/context/RobloxProvider.js.map +1 -1
- package/dist/cjs/hooks/roblox/useGetRobloxWalletAuth.d.ts +1 -1
- package/dist/cjs/hooks/roblox/useGetRobloxWalletAuth.d.ts.map +1 -1
- package/dist/cjs/hooks/roblox/useIsRobloxLoggedIn.d.ts +1 -1
- package/dist/cjs/hooks/roblox/useIsRobloxLoggedIn.d.ts.map +1 -1
- package/dist/cjs/hooks/roblox/useRobloxBackendLogin.d.ts +1 -1
- package/dist/cjs/hooks/roblox/useRobloxBackendLogin.d.ts.map +1 -1
- package/dist/cjs/hooks/roblox/useRobloxExchanges.d.ts +1 -1
- package/dist/cjs/hooks/roblox/useRobloxExchanges.d.ts.map +1 -1
- package/dist/cjs/hooks/roblox/useRobloxLocalStorage.d.ts +1 -1
- package/dist/cjs/hooks/roblox/useRobloxLocalStorage.d.ts.map +1 -1
- package/dist/cjs/hooks/roblox/useRobloxProducts.d.ts +1 -1
- package/dist/cjs/hooks/roblox/useRobloxProducts.d.ts.map +1 -1
- package/dist/cjs/hooks/useExchanges.d.ts.map +1 -1
- package/dist/cjs/hooks/useRenderTemplate.js +4 -6
- package/dist/cjs/hooks/useRenderTemplate.js.map +1 -1
- package/dist/cjs/lib/roblox/config.d.ts +11 -0
- package/dist/cjs/lib/roblox/config.d.ts.map +1 -0
- package/dist/cjs/lib/roblox/config.js +56 -0
- package/dist/cjs/lib/roblox/config.js.map +1 -0
- package/dist/cjs/lib/roblox/constants.d.ts +13 -0
- package/dist/cjs/lib/roblox/constants.d.ts.map +1 -0
- package/dist/cjs/lib/roblox/constants.js +16 -0
- package/dist/cjs/lib/roblox/constants.js.map +1 -0
- package/dist/cjs/lib/roblox/getIsOfferRobloxGated.js +2 -2
- package/dist/cjs/lib/roblox/getIsOfferRobloxGated.js.map +1 -1
- package/dist/cjs/lib/roblox/types.d.ts +86 -0
- package/dist/cjs/lib/roblox/types.d.ts.map +1 -0
- package/dist/cjs/lib/roblox/types.js +3 -0
- package/dist/cjs/lib/roblox/types.js.map +1 -0
- package/dist/cjs/lib/roblox/utils.d.ts +15 -0
- package/dist/cjs/lib/roblox/utils.d.ts.map +1 -0
- package/dist/cjs/lib/roblox/utils.js +40 -0
- package/dist/cjs/lib/roblox/utils.js.map +1 -0
- package/dist/esm/components/widgets/roblox/components/ConnectRoblox.js +1 -1
- package/dist/esm/components/widgets/roblox/components/ConnectRoblox.js.map +1 -1
- package/dist/esm/components/widgets/roblox/components/RobloxExchangesGrid.d.ts +1 -1
- package/dist/esm/components/widgets/roblox/components/RobloxExchangesGrid.d.ts.map +1 -1
- package/dist/esm/components/widgets/roblox/components/RobloxExchangesGrid.js.map +1 -1
- package/dist/esm/components/widgets/roblox/components/RobloxProductsGrid.d.ts +1 -1
- package/dist/esm/components/widgets/roblox/components/RobloxProductsGrid.d.ts.map +1 -1
- package/dist/esm/components/widgets/roblox/components/RobloxProductsGrid.js +1 -1
- package/dist/esm/components/widgets/roblox/components/RobloxProductsGrid.js.map +1 -1
- package/dist/esm/hooks/roblox/context/RobloxProvider.js +1 -1
- package/dist/esm/hooks/roblox/context/RobloxProvider.js.map +1 -1
- package/dist/esm/hooks/roblox/useGetRobloxWalletAuth.d.ts +1 -1
- package/dist/esm/hooks/roblox/useGetRobloxWalletAuth.d.ts.map +1 -1
- package/dist/esm/hooks/roblox/useIsRobloxLoggedIn.d.ts +1 -1
- package/dist/esm/hooks/roblox/useIsRobloxLoggedIn.d.ts.map +1 -1
- package/dist/esm/hooks/roblox/useRobloxBackendLogin.d.ts +1 -1
- package/dist/esm/hooks/roblox/useRobloxBackendLogin.d.ts.map +1 -1
- package/dist/esm/hooks/roblox/useRobloxExchanges.d.ts +1 -1
- package/dist/esm/hooks/roblox/useRobloxExchanges.d.ts.map +1 -1
- package/dist/esm/hooks/roblox/useRobloxLocalStorage.d.ts +1 -1
- package/dist/esm/hooks/roblox/useRobloxLocalStorage.d.ts.map +1 -1
- package/dist/esm/hooks/roblox/useRobloxProducts.d.ts +1 -1
- package/dist/esm/hooks/roblox/useRobloxProducts.d.ts.map +1 -1
- package/dist/esm/hooks/useExchanges.d.ts.map +1 -1
- package/dist/esm/hooks/useRenderTemplate.js +4 -6
- package/dist/esm/hooks/useRenderTemplate.js.map +1 -1
- package/dist/esm/lib/roblox/config.d.ts +11 -0
- package/dist/esm/lib/roblox/config.d.ts.map +1 -0
- package/dist/esm/lib/roblox/config.js +53 -0
- package/dist/esm/lib/roblox/config.js.map +1 -0
- package/dist/esm/lib/roblox/constants.d.ts +13 -0
- package/dist/esm/lib/roblox/constants.d.ts.map +1 -0
- package/dist/esm/lib/roblox/constants.js +13 -0
- package/dist/esm/lib/roblox/constants.js.map +1 -0
- package/dist/esm/lib/roblox/getIsOfferRobloxGated.js +1 -1
- package/dist/esm/lib/roblox/getIsOfferRobloxGated.js.map +1 -1
- package/dist/esm/lib/roblox/types.d.ts +86 -0
- package/dist/esm/lib/roblox/types.d.ts.map +1 -0
- package/dist/esm/lib/roblox/types.js +2 -0
- package/dist/esm/lib/roblox/types.js.map +1 -0
- package/dist/esm/lib/roblox/utils.d.ts +15 -0
- package/dist/esm/lib/roblox/utils.d.ts.map +1 -0
- package/dist/esm/lib/roblox/utils.js +36 -0
- package/dist/esm/lib/roblox/utils.js.map +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/components/widgets/roblox/components/ConnectRoblox.tsx +1 -1
- package/src/components/widgets/roblox/components/ProductsRoblox.tsx +1 -1
- package/src/components/widgets/roblox/components/RobloxExchangesGrid.tsx +2 -2
- package/src/components/widgets/roblox/components/RobloxProductsGrid.tsx +3 -3
- package/src/hooks/roblox/context/RobloxProvider.tsx +1 -1
- package/src/hooks/roblox/useGetRobloxWalletAuth.ts +1 -1
- package/src/hooks/roblox/useIsRobloxLoggedIn.ts +1 -1
- package/src/hooks/roblox/useRobloxBackendLogin.ts +1 -1
- package/src/hooks/roblox/useRobloxExchanges.ts +1 -1
- package/src/hooks/roblox/useRobloxLocalStorage.ts +1 -1
- package/src/hooks/roblox/useRobloxProducts.ts +1 -1
- package/src/hooks/useRenderTemplate.ts +4 -6
- package/src/lib/roblox/config.ts +70 -0
- package/src/lib/roblox/constants.ts +15 -0
- package/src/lib/roblox/getIsOfferRobloxGated.ts +1 -1
- package/src/lib/roblox/types.ts +94 -0
- package/src/lib/roblox/utils.ts +57 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { subgraph } from "@bosonprotocol/core-sdk";
|
|
2
|
+
|
|
3
|
+
export type RobloxClaims = {
|
|
4
|
+
sub: string;
|
|
5
|
+
name: string;
|
|
6
|
+
nickname?: string;
|
|
7
|
+
picture?: string;
|
|
8
|
+
preferred_username?: string;
|
|
9
|
+
email?: string;
|
|
10
|
+
profile?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type RobloxUser = Omit<RobloxClaims, "sub"> & { userId: string };
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Product Metadata subgraph, with related Roblox assetId
|
|
17
|
+
*/
|
|
18
|
+
export type BosonRobloxProduct =
|
|
19
|
+
subgraph.ProductV1MetadataEntityFieldsFragment & {
|
|
20
|
+
robloxAssetId: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type BosonRobloxExchange = subgraph.ExchangeFieldsFragment & {
|
|
24
|
+
robloxAssetId: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type RobloxInventoryItem = {
|
|
28
|
+
path: string;
|
|
29
|
+
assetDetails: {
|
|
30
|
+
assetId: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type RobloxAsset = {
|
|
35
|
+
productType: string;
|
|
36
|
+
assetId: string;
|
|
37
|
+
productId: number;
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
iconImageAssetId: number;
|
|
41
|
+
assetTypeId: number;
|
|
42
|
+
isLimited: boolean;
|
|
43
|
+
isLimitedUnique: boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type GetInfoResponse = {
|
|
47
|
+
userId: string;
|
|
48
|
+
claims: RobloxClaims;
|
|
49
|
+
inventoryItems: RobloxInventoryItem[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type GetAssetDetailsResponse = RobloxAsset;
|
|
53
|
+
|
|
54
|
+
export type GetLoggedInResponse = {
|
|
55
|
+
isLoggedIn: boolean;
|
|
56
|
+
claims: RobloxClaims | null;
|
|
57
|
+
nonce: string | null;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type GetWalletAuthResponse = {
|
|
61
|
+
walletAuth: boolean;
|
|
62
|
+
address: string | null;
|
|
63
|
+
sellerId: string | null;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type PendingRequest = { txHash: string; txId: string };
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A Product can be:
|
|
70
|
+
* - Unknown: the user is not authenticated on roblox
|
|
71
|
+
* - Not available: the roblox user is authenticated and it doesn't have the required Roblox asset
|
|
72
|
+
* - Potentially: the roblox user is authenticated and it has the required Roblox asset, the user wallet is not known yet
|
|
73
|
+
* - Pending: the roblox user is authenticated and it has the required Roblox asset and their wallet doesn't own the required NFT yet (minting is pending)
|
|
74
|
+
* - Available: the roblox user is authenticated and it has the required Roblox asset and their wallet owns the required NFT
|
|
75
|
+
* */
|
|
76
|
+
export type ProductAvailabilityStatus =
|
|
77
|
+
| { status: "UNKNOWN" | "POTENTIALLY" | "NOT_AVAILABLE" | "AVAILABLE" }
|
|
78
|
+
| { status: "PENDING"; pendingData: PendingRequest };
|
|
79
|
+
|
|
80
|
+
export type BosonRobloxProductWithAvailability = BosonRobloxProduct & {
|
|
81
|
+
availability: ProductAvailabilityStatus;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type HasMore = true | false | "maybe";
|
|
85
|
+
|
|
86
|
+
export type GetProductsResponse = {
|
|
87
|
+
products: BosonRobloxProductWithAvailability[];
|
|
88
|
+
hasMore: HasMore;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type GetExchangesResponse = {
|
|
92
|
+
exchanges: BosonRobloxExchange[];
|
|
93
|
+
hasMore: HasMore;
|
|
94
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { subgraph } from "@bosonprotocol/core-sdk";
|
|
2
|
+
import { ASSET_ID_ATTR_TRAIT_TYPE, ROBLOX_PRODUCT_TAG } from "./constants";
|
|
3
|
+
import { ConditionStruct, TokenType } from "@bosonprotocol/common";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Filter a Boson product, whether it's Roblox-related or not
|
|
7
|
+
* @param offerMetadata the Product Metadata object from Boson subgraph
|
|
8
|
+
* @param condition the ConditionStruct attached to the Boson offer
|
|
9
|
+
* @param nftContract address of the NFT contract used to token-gate the Roblox-Boson offer
|
|
10
|
+
* @param offerMetadata the Product Metadata object from Boson subgraph
|
|
11
|
+
* @returns false if not Roblox-related,
|
|
12
|
+
* otherwise returns the Roblox assetId the offer is related to
|
|
13
|
+
*/
|
|
14
|
+
export function filterRobloxProduct(
|
|
15
|
+
offerMetadata: Pick<
|
|
16
|
+
subgraph.ProductV1MetadataEntityFieldsFragment,
|
|
17
|
+
"attributes"
|
|
18
|
+
> & { product: Pick<subgraph.ProductV1Product, "details_tags"> },
|
|
19
|
+
condition: ConditionStruct | undefined,
|
|
20
|
+
nftContract: string
|
|
21
|
+
): string | false {
|
|
22
|
+
if (
|
|
23
|
+
offerMetadata.product &&
|
|
24
|
+
offerMetadata.product.details_tags &&
|
|
25
|
+
offerMetadata.product.details_tags
|
|
26
|
+
.map((t) => t.toLowerCase())
|
|
27
|
+
.includes(ROBLOX_PRODUCT_TAG.toLowerCase())
|
|
28
|
+
) {
|
|
29
|
+
const robloxAssetId = offerMetadata.attributes?.find(
|
|
30
|
+
(attr) =>
|
|
31
|
+
attr.traitType.toLowerCase() === ASSET_ID_ATTR_TRAIT_TYPE.toLowerCase()
|
|
32
|
+
)?.value;
|
|
33
|
+
if (
|
|
34
|
+
condition &&
|
|
35
|
+
robloxAssetId &&
|
|
36
|
+
checkTokenGatingCondition(condition, {
|
|
37
|
+
tokenId: robloxAssetId,
|
|
38
|
+
nftContract
|
|
39
|
+
})
|
|
40
|
+
) {
|
|
41
|
+
return robloxAssetId;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function checkTokenGatingCondition(
|
|
48
|
+
condition: ConditionStruct,
|
|
49
|
+
expected: { tokenId: string; nftContract: string }
|
|
50
|
+
): boolean {
|
|
51
|
+
return (
|
|
52
|
+
condition.minTokenId.toString() === expected.tokenId &&
|
|
53
|
+
condition.maxTokenId.toString() === expected.tokenId &&
|
|
54
|
+
condition.tokenType === TokenType.MultiToken &&
|
|
55
|
+
condition.tokenAddress === expected.nftContract.toLowerCase()
|
|
56
|
+
);
|
|
57
|
+
}
|