flipmeme-sdk 1.2.7 → 1.2.9

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.d.mts CHANGED
@@ -139,6 +139,7 @@ declare class FlipmemeSDK {
139
139
  buyCredit(params: BuyCreditParams): Promise<string>;
140
140
  getTotalPrice(type: PurcahseType, collectionId: string, amount: number): Promise<string>;
141
141
  createMerkle(collectionId: string, depthSize: number): Promise<PublicKey>;
142
+ finalizeSale(collectionId: string): Promise<PublicKey>;
142
143
  /**For testing */
143
144
  getStateInfo(): Promise<{
144
145
  admin: PublicKey;
@@ -213,7 +214,9 @@ declare const SOLANA_PUBKEYS: {
213
214
  RENT_TOKEN_ID: PublicKey;
214
215
  };
215
216
  declare const SDK_SOLANA_CONFIG: {
216
- CHUNK_SIZE: number;
217
+ MINT_CHUNK_SIZE: number;
218
+ BUY_CHUNK_SIZE: number;
219
+ SELL_CHUNK_SIZE: number;
217
220
  };
218
221
  declare const VALID_SIZE_PAIR: {
219
222
  3: {
package/dist/index.d.ts CHANGED
@@ -139,6 +139,7 @@ declare class FlipmemeSDK {
139
139
  buyCredit(params: BuyCreditParams): Promise<string>;
140
140
  getTotalPrice(type: PurcahseType, collectionId: string, amount: number): Promise<string>;
141
141
  createMerkle(collectionId: string, depthSize: number): Promise<PublicKey>;
142
+ finalizeSale(collectionId: string): Promise<PublicKey>;
142
143
  /**For testing */
143
144
  getStateInfo(): Promise<{
144
145
  admin: PublicKey;
@@ -213,7 +214,9 @@ declare const SOLANA_PUBKEYS: {
213
214
  RENT_TOKEN_ID: PublicKey;
214
215
  };
215
216
  declare const SDK_SOLANA_CONFIG: {
216
- CHUNK_SIZE: number;
217
+ MINT_CHUNK_SIZE: number;
218
+ BUY_CHUNK_SIZE: number;
219
+ SELL_CHUNK_SIZE: number;
217
220
  };
218
221
  declare const VALID_SIZE_PAIR: {
219
222
  3: {
package/dist/index.js CHANGED
@@ -2083,6 +2083,10 @@ var flipmeme_default = {
2083
2083
  name: "name",
2084
2084
  type: "string"
2085
2085
  },
2086
+ {
2087
+ name: "uri",
2088
+ type: "string"
2089
+ },
2086
2090
  {
2087
2091
  name: "mint_count",
2088
2092
  type: "u32"
@@ -2268,7 +2272,9 @@ var SOLANA_PUBKEYS = {
2268
2272
  RENT_TOKEN_ID: new import_web3.PublicKey(SOLANA.RENT_TOKEN_STR)
2269
2273
  };
2270
2274
  var SDK_SOLANA_CONFIG = {
2271
- CHUNK_SIZE: 5
2275
+ MINT_CHUNK_SIZE: 5,
2276
+ BUY_CHUNK_SIZE: 2,
2277
+ SELL_CHUNK_SIZE: 2
2272
2278
  };
2273
2279
  var VALID_SIZE_PAIR = {
2274
2280
  3: { maxBufferSize: 8, maxDepth: 3 },
@@ -2418,7 +2424,7 @@ var import_anchor = require("@coral-xyz/anchor");
2418
2424
  var import_decimal = require("decimal.js");
2419
2425
  function analyzeBuyTransaction(program, transactionData) {
2420
2426
  var _a;
2421
- console.log("transactionData===", transactionData);
2427
+ console.log("buy transaction");
2422
2428
  let instructions = (_a = transactionData.meta) == null ? void 0 : _a.innerInstructions;
2423
2429
  let blockNumber = transactionData.slot;
2424
2430
  let blockTime = transactionData.blockTime;
@@ -2432,6 +2438,7 @@ function analyzeBuyTransaction(program, transactionData) {
2432
2438
  const base64Data = import_anchor.utils.bytes.base64.encode(rawData.subarray(8));
2433
2439
  let decodedData = program.coder.events.decode(base64Data);
2434
2440
  if ((decodedData == null ? void 0 : decodedData.name) === "mintEvent") {
2441
+ console.log("=======", decodedData);
2435
2442
  buyResponse.push({
2436
2443
  buyer: decodedData.data.buyer.toString(),
2437
2444
  collectionAddress: decodedData.data.collection.toString(),
@@ -2527,17 +2534,18 @@ var import_bn = require("bn.js");
2527
2534
  var import_lodash = __toESM(require("lodash"));
2528
2535
  var getAssetsInfo = (assetIds, merkleTree) => __async(void 0, null, function* () {
2529
2536
  let assetPubKeys = [];
2530
- for (let assetId in assetIds) {
2537
+ for (let index in assetIds) {
2538
+ console.log("log", assetIds[index]);
2531
2539
  let itemKey = yield (0, import_mpl_bubblegum.getLeafAssetId)(
2532
2540
  new import_web34.PublicKey(merkleTree),
2533
- new import_bn.BN(assetId)
2541
+ new import_bn.BN(assetIds[index])
2534
2542
  );
2535
2543
  assetPubKeys.push(itemKey.toBase58());
2536
2544
  }
2545
+ console.log("assets pub keys ====", assetPubKeys);
2537
2546
  let assetsInfo = yield heliusApi("getAssetBatch", { ids: assetPubKeys });
2538
- let assetsProof = yield Promise.all(assetPubKeys.map((item) => __async(void 0, null, function* () {
2539
- return yield heliusApi("getAssetProof", { id: item });
2540
- })));
2547
+ let assetsProof = yield heliusApi("getAssetProofBatch", { ids: assetPubKeys });
2548
+ console.log("assetInfo, assertsProof ====", assetsInfo, assetsProof);
2541
2549
  const infoObj = import_lodash.default.keyBy(assetsInfo, "compression.asset_hash");
2542
2550
  const proofObj = import_lodash.default.keyBy(assetsProof, "leaf");
2543
2551
  const merged = import_lodash.default.merge(infoObj, proofObj);
@@ -2970,6 +2978,7 @@ var SolanaConnector = class {
2970
2978
  });
2971
2979
  return merkleTreeKeyPair.publicKey;
2972
2980
  } catch (e) {
2981
+ console.log("=====================", e);
2973
2982
  throw new Error("Cannot call this function");
2974
2983
  }
2975
2984
  });
@@ -3092,7 +3101,7 @@ var SolanaConnector = class {
3092
3101
  throw new Error("Program not initialized");
3093
3102
  }
3094
3103
  yield getAssetsInfo(tokens, merkleTree);
3095
- const chunkSize = SDK_SOLANA_CONFIG.CHUNK_SIZE;
3104
+ const chunkSize = SDK_SOLANA_CONFIG.BUY_CHUNK_SIZE;
3096
3105
  const tokenChunks = getTokenChunks(tokens, chunkSize);
3097
3106
  const allInstructionSets = [];
3098
3107
  try {
@@ -3119,7 +3128,7 @@ var SolanaConnector = class {
3119
3128
  new import_web35.PublicKey(merkleTree)
3120
3129
  );
3121
3130
  const canopyDepth = merkleTreeAcount.getCanopyDepth();
3122
- const chunkSize = SDK_SOLANA_CONFIG.CHUNK_SIZE;
3131
+ const chunkSize = SDK_SOLANA_CONFIG.SELL_CHUNK_SIZE;
3123
3132
  const tokenChunks = getTokenChunks(tokens, chunkSize);
3124
3133
  const allInstructionSets = [];
3125
3134
  const { treeConfigPda: treeConfigPda2, collectionPda: collectionPda2, nftHolderPda: nftHolderPda2, collectionNftPda: collectionNftPda2 } = yield getTradingAccounts(
@@ -3182,7 +3191,7 @@ var SolanaConnector = class {
3182
3191
  if (!this.program) {
3183
3192
  throw new Error("Program not initialized");
3184
3193
  }
3185
- const chunkSize = SDK_SOLANA_CONFIG.CHUNK_SIZE;
3194
+ const chunkSize = SDK_SOLANA_CONFIG.MINT_CHUNK_SIZE;
3186
3195
  const tokenChunks = getTokenChunks(tokens, chunkSize);
3187
3196
  const allInstructionSets = [];
3188
3197
  const {
@@ -3406,7 +3415,21 @@ var FlipmemeSDK = class {
3406
3415
  }
3407
3416
  });
3408
3417
  }
3409
- createMerkle(collectionId, depthSize) {
3418
+ createMerkle(collectionId, depthSize2) {
3419
+ return __async(this, null, function* () {
3420
+ const { maxBufferSize, maxDepth } = VALID_SIZE_PAIR[depthSize2];
3421
+ if (this.blockchainType === "solana" /* SOLANA */ && this.solana) {
3422
+ return yield this.solana.createMerkle(
3423
+ collectionId,
3424
+ maxBufferSize,
3425
+ maxDepth
3426
+ );
3427
+ } else {
3428
+ throw new Error("Cannot call this function");
3429
+ }
3430
+ });
3431
+ }
3432
+ finalizeSale(collectionId) {
3410
3433
  return __async(this, null, function* () {
3411
3434
  const { maxBufferSize, maxDepth } = VALID_SIZE_PAIR[depthSize];
3412
3435
  if (this.blockchainType === "solana" /* SOLANA */ && this.solana) {