flipmeme-sdk 1.1.2 → 1.1.3

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/index.js CHANGED
@@ -2317,43 +2317,52 @@ var SolanaConnector = class {
2317
2317
  //useFlipProfile.ts
2318
2318
  profileSell(data) {
2319
2319
  return __async(this, null, function* () {
2320
+ var _a, _b, _c;
2320
2321
  if (!this.program) {
2321
2322
  throw new Error("Program not initialized");
2322
2323
  }
2323
2324
  let instructionsChunks = [];
2324
- Object.entries(data).forEach((_0) => __async(this, [_0], function* ([collectionId, items]) {
2325
- var _a, _b, _c;
2325
+ for (const collectionId in data.data) {
2326
+ const items = data.data[collectionId];
2326
2327
  try {
2327
2328
  console.log("items", items);
2328
- instructionsChunks = yield this.getSellInstructions(
2329
+ console.log("collectionId", collectionId);
2330
+ let instructionsChunksItem = yield this.getSellInstructions(
2329
2331
  this.config.wallet,
2330
2332
  collectionId,
2331
2333
  items
2332
2334
  );
2335
+ instructionsChunks.push(...instructionsChunksItem);
2333
2336
  } catch (error) {
2334
2337
  (_a = data.notify) == null ? void 0 : _a.onFailed(items, items.length);
2335
2338
  console.error("Failed to getSellInstructions", { error });
2336
2339
  throw error;
2337
2340
  }
2338
- const successTxns = [];
2339
- const failedItems = [];
2340
- for (const [instructions, items2] of instructionsChunks) {
2341
- try {
2342
- const { signature } = yield this.sendTxn(instructions);
2343
- successTxns.push({ items: items2, signature });
2344
- (_b = data.notify) == null ? void 0 : _b.onSuccess(
2345
- successTxns.map((txn) => txn.items).flat(),
2346
- items2.length,
2347
- signature
2348
- );
2349
- } catch (e) {
2350
- failedItems.push(...items2);
2351
- (_c = data.notify) == null ? void 0 : _c.onFailed(failedItems, items2.length);
2352
- console.error("Flip failed:", JSON.stringify(e), { items: items2 });
2353
- throw e;
2354
- }
2341
+ }
2342
+ const successTxns = [];
2343
+ const failedItems = [];
2344
+ for (const [instructions, items] of instructionsChunks) {
2345
+ try {
2346
+ const { signature, latestBlockhash } = yield this.sendTxn(instructions);
2347
+ successTxns.push({ items, signature });
2348
+ (_b = data.notify) == null ? void 0 : _b.onSuccess(
2349
+ successTxns.map((txn) => txn.items).flat(),
2350
+ items.length,
2351
+ signature
2352
+ );
2353
+ const confirmResult = yield this.config.provider.connection.confirmTransaction({
2354
+ blockhash: latestBlockhash.blockhash,
2355
+ lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
2356
+ signature
2357
+ });
2358
+ console.log("confirmResult", confirmResult);
2359
+ } catch (e) {
2360
+ failedItems.push(...items);
2361
+ (_c = data.notify) == null ? void 0 : _c.onFailed(failedItems, items.length);
2362
+ console.error("Flip failed:", JSON.stringify(e), { items });
2363
+ throw e;
2355
2364
  }
2356
- }));
2365
+ }
2357
2366
  });
2358
2367
  }
2359
2368
  buyCredit(params) {