flipmeme-sdk 1.2.2 → 1.2.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/index.js CHANGED
@@ -51,9 +51,15 @@ var __async = (__this, __arguments, generator) => {
51
51
  var index_exports = {};
52
52
  __export(index_exports, {
53
53
  BlockchainType: () => BlockchainType,
54
+ ENV: () => ENV,
54
55
  FlipmemeSDK: () => FlipmemeSDK,
55
- PurcahseTye: () => PurcahseTye,
56
+ PurcahseType: () => PurcahseType,
57
+ RPC: () => RPC,
58
+ SDK_SOLANA_CONFIG: () => SDK_SOLANA_CONFIG,
59
+ SOLANA: () => SOLANA,
60
+ SOLANA_PUBKEYS: () => SOLANA_PUBKEYS,
56
61
  Utility: () => Utility,
62
+ VALID_SIZE_PAIR: () => VALID_SIZE_PAIR,
57
63
  isEthereumConfig: () => isEthereumConfig,
58
64
  isSolanaConfig: () => isSolanaConfig
59
65
  });
@@ -89,11 +95,11 @@ function isEthereumConfig(config) {
89
95
  function isSolanaConfig(config) {
90
96
  return "sendTransaction" in config;
91
97
  }
92
- var PurcahseTye = /* @__PURE__ */ ((PurcahseTye3) => {
93
- PurcahseTye3["BUY"] = "buy";
94
- PurcahseTye3["SELL"] = "sell";
95
- return PurcahseTye3;
96
- })(PurcahseTye || {});
98
+ var PurcahseType = /* @__PURE__ */ ((PurcahseType3) => {
99
+ PurcahseType3["BUY"] = "buy";
100
+ PurcahseType3["SELL"] = "sell";
101
+ return PurcahseType3;
102
+ })(PurcahseType || {});
97
103
 
98
104
  // src/solana/idls/flipmeme.json
99
105
  var flipmeme_default = {
@@ -751,7 +757,8 @@ var flipmeme_default = {
751
757
  "# Arguments",
752
758
  "",
753
759
  "* `ctx` - The Anchor context holding the accounts",
754
- "* `token_id` - The token_id of the NFT"
760
+ "* `token_id` - The token_id of the NFT",
761
+ ""
755
762
  ],
756
763
  discriminator: [
757
764
  156,
@@ -767,6 +774,14 @@ var flipmeme_default = {
767
774
  {
768
775
  name: "state"
769
776
  },
777
+ {
778
+ name: "merkle_tree_config",
779
+ writable: true
780
+ },
781
+ {
782
+ name: "merkle_tree",
783
+ writable: true
784
+ },
770
785
  {
771
786
  name: "collection",
772
787
  writable: true,
@@ -798,37 +813,6 @@ var flipmeme_default = {
798
813
  ]
799
814
  }
800
815
  },
801
- {
802
- name: "collection_nft",
803
- writable: true,
804
- pda: {
805
- seeds: [
806
- {
807
- kind: "const",
808
- value: [
809
- 99,
810
- 111,
811
- 108,
812
- 108,
813
- 101,
814
- 99,
815
- 116,
816
- 105,
817
- 111,
818
- 110,
819
- 95,
820
- 110,
821
- 102,
822
- 116
823
- ]
824
- },
825
- {
826
- kind: "account",
827
- path: "collection"
828
- }
829
- ]
830
- }
831
- },
832
816
  {
833
817
  name: "nft_owner"
834
818
  },
@@ -863,42 +847,26 @@ var flipmeme_default = {
863
847
  ]
864
848
  }
865
849
  },
866
- {
867
- name: "nft",
868
- writable: true,
869
- pda: {
870
- seeds: [
871
- {
872
- kind: "const",
873
- value: [
874
- 110,
875
- 102,
876
- 116
877
- ]
878
- },
879
- {
880
- kind: "account",
881
- path: "state"
882
- },
883
- {
884
- kind: "account",
885
- path: "collection"
886
- },
887
- {
888
- kind: "arg",
889
- path: "token_id"
890
- }
891
- ]
892
- }
893
- },
894
850
  {
895
851
  name: "operator",
896
852
  writable: true,
897
853
  signer: true
898
854
  },
899
855
  {
900
- name: "mpl_core",
901
- address: "CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d"
856
+ name: "compression_program",
857
+ address: "cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK"
858
+ },
859
+ {
860
+ name: "token_metadata_program",
861
+ address: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
862
+ },
863
+ {
864
+ name: "mpl_bubblegum_program",
865
+ address: "BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY"
866
+ },
867
+ {
868
+ name: "log_wrapper",
869
+ address: "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV"
902
870
  },
903
871
  {
904
872
  name: "system_program",
@@ -909,6 +877,41 @@ var flipmeme_default = {
909
877
  {
910
878
  name: "_token_id",
911
879
  type: "u32"
880
+ },
881
+ {
882
+ name: "root",
883
+ type: {
884
+ array: [
885
+ "u8",
886
+ 32
887
+ ]
888
+ }
889
+ },
890
+ {
891
+ name: "data_hash",
892
+ type: {
893
+ array: [
894
+ "u8",
895
+ 32
896
+ ]
897
+ }
898
+ },
899
+ {
900
+ name: "creator_hash",
901
+ type: {
902
+ array: [
903
+ "u8",
904
+ 32
905
+ ]
906
+ }
907
+ },
908
+ {
909
+ name: "nonce",
910
+ type: "u64"
911
+ },
912
+ {
913
+ name: "index",
914
+ type: "u32"
912
915
  }
913
916
  ]
914
917
  },
@@ -1467,37 +1470,6 @@ var flipmeme_default = {
1467
1470
  ]
1468
1471
  }
1469
1472
  },
1470
- {
1471
- name: "collection_nft",
1472
- writable: true,
1473
- pda: {
1474
- seeds: [
1475
- {
1476
- kind: "const",
1477
- value: [
1478
- 99,
1479
- 111,
1480
- 108,
1481
- 108,
1482
- 101,
1483
- 99,
1484
- 116,
1485
- 105,
1486
- 111,
1487
- 110,
1488
- 95,
1489
- 110,
1490
- 102,
1491
- 116
1492
- ]
1493
- },
1494
- {
1495
- kind: "account",
1496
- path: "collection"
1497
- }
1498
- ]
1499
- }
1500
- },
1501
1473
  {
1502
1474
  name: "treasury",
1503
1475
  writable: true
@@ -2112,10 +2084,6 @@ var flipmeme_default = {
2112
2084
  name: "name",
2113
2085
  type: "string"
2114
2086
  },
2115
- {
2116
- name: "uri",
2117
- type: "string"
2118
- },
2119
2087
  {
2120
2088
  name: "mint_count",
2121
2089
  type: "u32"
@@ -2276,6 +2244,11 @@ var SOLANA = {
2276
2244
  SPL_ATA_TOKEN_STR: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
2277
2245
  RENT_TOKEN_STR: "SysvarRent111111111111111111111111111111111"
2278
2246
  };
2247
+ var ENV = /* @__PURE__ */ ((ENV3) => {
2248
+ ENV3["Devnet"] = "Devnet";
2249
+ ENV3["Mainnet"] = "Mainnet";
2250
+ return ENV3;
2251
+ })(ENV || {});
2279
2252
  var RPC = {
2280
2253
  Devnet: "https://api.devnet.solana.com",
2281
2254
  Mainnet: "https://api.mainnet-beta.solana.com"
@@ -2512,7 +2485,6 @@ function analyzeSellTransaction(program, transactionData) {
2512
2485
  sellResponse.push({
2513
2486
  seller: decodedData.data.seller.toString(),
2514
2487
  collectionAddress: decodedData.data.collection.toString(),
2515
- nftAddress: decodedData.data.nft.toString(),
2516
2488
  tokenId: decodedData.data.tokenId.toString(),
2517
2489
  price: decodedData.data.price.toString(),
2518
2490
  nextPrice: decodedData.data.nextPrice.toString(),
@@ -2935,8 +2907,14 @@ var SolanaConnector = class {
2935
2907
  throw new Error("Program not initialized");
2936
2908
  }
2937
2909
  let merkleTreeKeyPair = new import_web35.Keypair();
2938
- let accountInx = yield this.createAccountForMerkleTree(
2939
- merkleTreeKeyPair.publicKey
2910
+ let canopyDepth = maxDepth > 6 ? 4 : 3;
2911
+ let accountInx = yield (0, import_spl_account_compression.createAllocTreeIx)(
2912
+ this.config.provider.connection,
2913
+ merkleTreeKeyPair.publicKey,
2914
+ this.config.wallet,
2915
+ //@ts-ignore
2916
+ VALID_SIZE_PAIR[maxDepth],
2917
+ canopyDepth
2940
2918
  );
2941
2919
  let collectionPda2 = collectionPda(
2942
2920
  collectionId,
@@ -2979,18 +2957,22 @@ var SolanaConnector = class {
2979
2957
  const result = yield this.config.provider.connection.simulateTransaction(
2980
2958
  versionedTransaction
2981
2959
  );
2982
- const tx = new import_web35.Transaction().add(modifyComputeUnits).add(addPriorityFee).add(accountInx).add(instruction);
2983
- const txHash = yield this.config.provider.sendAndConfirm(
2984
- tx,
2985
- [merkleTreeKeyPair],
2986
- { commitment: "confirmed", skipPreflight: true }
2987
- );
2988
- const confirmResult = yield this.config.provider.connection.confirmTransaction({
2989
- blockhash: blockHash,
2990
- lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
2991
- signature: txHash
2992
- });
2993
- return merkleTreeKeyPair.publicKey;
2960
+ try {
2961
+ const tx = new import_web35.Transaction().add(modifyComputeUnits).add(addPriorityFee).add(accountInx).add(instruction);
2962
+ const txHash = yield this.config.provider.sendAndConfirm(
2963
+ tx,
2964
+ [merkleTreeKeyPair],
2965
+ { commitment: "confirmed", skipPreflight: true }
2966
+ );
2967
+ const confirmResult = yield this.config.provider.connection.confirmTransaction({
2968
+ blockhash: blockHash,
2969
+ lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
2970
+ signature: txHash
2971
+ });
2972
+ return merkleTreeKeyPair.publicKey;
2973
+ } catch (e) {
2974
+ throw new Error("Cannot call this function");
2975
+ }
2994
2976
  });
2995
2977
  }
2996
2978
  getTotalPrice(type, collectionId, amount) {
@@ -3154,7 +3136,7 @@ var SolanaConnector = class {
3154
3136
  25e4 * chunk.length
3155
3137
  );
3156
3138
  for (const token of chunk) {
3157
- const { compression, ownership, proof, root } = token;
3139
+ const { compression, proof, root } = token;
3158
3140
  const proofPath = proof.map((node) => ({
3159
3141
  pubkey: new import_web35.PublicKey(node),
3160
3142
  isSigner: false,
@@ -3174,7 +3156,6 @@ var SolanaConnector = class {
3174
3156
  merkleTreeConfig: treeConfigPda2,
3175
3157
  merkleTree: new import_web35.PublicKey(merkleTree),
3176
3158
  collection: collectionPda2,
3177
- collectionNft: collectionNftPda2,
3178
3159
  treasury: SOLANA_PUBKEYS.TREASURY_ID,
3179
3160
  nftHolder: nftHolderPda2,
3180
3161
  seller: userPublicKey,
@@ -3285,6 +3266,11 @@ var SolanaConnector = class {
3285
3266
  return instructions;
3286
3267
  });
3287
3268
  }
3269
+ /**
3270
+ * initialize account for merkle tree
3271
+ * @param merkleTree merkle tree address which is initialized
3272
+ * @returns
3273
+ */
3288
3274
  createAccountForMerkleTree(merkleTree) {
3289
3275
  return __async(this, null, function* () {
3290
3276
  const dataLen = 5112;
@@ -3301,7 +3287,7 @@ var SolanaConnector = class {
3301
3287
  return ins;
3302
3288
  });
3303
3289
  }
3304
- getTransactionTest(signature) {
3290
+ getTransactionTest(signature, transactionType = "buy") {
3305
3291
  return __async(this, null, function* () {
3306
3292
  const transaction = yield this.config.provider.connection.getTransaction(
3307
3293
  signature,
@@ -3311,7 +3297,11 @@ var SolanaConnector = class {
3311
3297
  }
3312
3298
  );
3313
3299
  if (transaction && this.program) {
3314
- return analyzeBuyTransaction(this.program, transaction);
3300
+ if (transactionType == "buy") {
3301
+ return analyzeBuyTransaction(this.program, transaction);
3302
+ } else if (transactionType == "sell") {
3303
+ return analyzeSellTransaction(this.program, transaction);
3304
+ }
3315
3305
  }
3316
3306
  return [];
3317
3307
  });
@@ -3420,7 +3410,11 @@ var FlipmemeSDK = class {
3420
3410
  createMerkle(collectionId, maxBufferSize, maxDepth) {
3421
3411
  return __async(this, null, function* () {
3422
3412
  if (this.blockchainType === "solana" /* SOLANA */ && this.solana) {
3423
- return yield this.solana.createMerkle(collectionId, maxBufferSize, maxDepth);
3413
+ return yield this.solana.createMerkle(
3414
+ collectionId,
3415
+ maxBufferSize,
3416
+ maxDepth
3417
+ );
3424
3418
  } else {
3425
3419
  throw new Error("Cannot call this function");
3426
3420
  }
@@ -3445,10 +3439,10 @@ var FlipmemeSDK = class {
3445
3439
  }
3446
3440
  });
3447
3441
  }
3448
- getTransactionTest(signature) {
3442
+ getTransactionTest(signature, transactionType) {
3449
3443
  return __async(this, null, function* () {
3450
3444
  if (this.blockchainType === "solana" /* SOLANA */ && this.solana) {
3451
- return this.solana.getTransactionTest(signature);
3445
+ return this.solana.getTransactionTest(signature, transactionType);
3452
3446
  } else {
3453
3447
  throw new Error("Cannot call this function");
3454
3448
  }
@@ -3550,9 +3544,15 @@ var Utility = class {
3550
3544
  // Annotate the CommonJS export names for ESM import in node:
3551
3545
  0 && (module.exports = {
3552
3546
  BlockchainType,
3547
+ ENV,
3553
3548
  FlipmemeSDK,
3554
- PurcahseTye,
3549
+ PurcahseType,
3550
+ RPC,
3551
+ SDK_SOLANA_CONFIG,
3552
+ SOLANA,
3553
+ SOLANA_PUBKEYS,
3555
3554
  Utility,
3555
+ VALID_SIZE_PAIR,
3556
3556
  isEthereumConfig,
3557
3557
  isSolanaConfig
3558
3558
  });