Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions src/lib/utils/hooks/offer/useCreateOffers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type OfferFieldsFragment = subgraph.OfferFieldsFragment;

type UseCreateOffersProps = {
sellerToCreate: accounts.CreateSellerArgs | null;
sellerId: string | null;
offersToCreate: offers.CreateOfferArgs[];
tokenGatedInfo?: PartialTokenGating | null;
conditionDecimals?: number;
Expand All @@ -46,6 +47,7 @@ export function useCreateOffers() {
return useMutation(
async ({
sellerToCreate,
sellerId,
offersToCreate,
tokenGatedInfo,
conditionDecimals,
Expand Down Expand Up @@ -202,22 +204,15 @@ export function useCreateOffers() {
);
const decimals = await onBeforeBuildCondition();
const condition = buildCondition(tokenGatedInfo, decimals);
const sellerAddress = sellerToCreate?.assistant;
if (!sellerAddress) {
throw new Error(`sellerAddress is falsy "${sellerAddress}"`);
}
const seller = await coreSDK.getSellerByAssistant(sellerAddress);
if (!seller) {
throw new Error(
`seller could not be found with this address="${sellerAddress}"`
);
}
const sellerId = seller.id;
if (isMetaTx) {
const nonce = Date.now();
const { r, s, v, functionName, functionSignature } =
await coreSDK.signMetaTxCreateGroup({
createGroupArgs: { offerIds, sellerId, ...condition },
createGroupArgs: {
offerIds,
sellerId: sellerId as string,
...condition
},
nonce
});
txResponse = await coreSDK.relayMetaTransaction({
Expand All @@ -231,7 +226,7 @@ export function useCreateOffers() {
} else {
txResponse = await coreSDK.createGroup({
offerIds,
sellerId,
sellerId: sellerId as string,
...condition
});
}
Expand Down
1 change: 1 addition & 0 deletions src/pages/batch-create-offers/BatchCreateOffers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ function BatchCreateOffers() {
try {
const result = await createOffers({
sellerToCreate: null,
sellerId: currentSeller?.sellerIds?.[0] || null,
offersToCreate: offersToBeCreated,
tokenGatedInfo: null, // TODO: add token gated info
conditionDecimals: decimals,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/create-product/CreateProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function CreateProduct() {

if (
sellersLoading ||
curationLists.isFetching ||
curationLists.isLoading ||
(curationLists.lastSellerIdFetched !== undefined &&
seller &&
Number(curationLists.lastSellerIdFetched) < Number(seller.id))
Expand Down
1 change: 1 addition & 0 deletions src/pages/create-product/CreateProductInner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ function CreateProductInner({
const isTokenGated = productType?.tokenGatedOffer === "true";
const result = await createOffers({
sellerToCreate: null,
sellerId: currentAssistant?.id || null,
offersToCreate,
tokenGatedInfo: isTokenGated ? values.tokenGating : null,
conditionDecimals: decimals,
Expand Down
Loading