flipmeme-sdk 1.0.13 → 1.0.15

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
@@ -49,6 +49,16 @@ interface BuyParams {
49
49
  reserveToken: ReserveToken | null;
50
50
  notify: any | undefined;
51
51
  }
52
+ interface BuyResponse {
53
+ buyer: string;
54
+ collectionAddress: string;
55
+ nftAddress: string;
56
+ tokenId: string;
57
+ tokenUri: string;
58
+ price: string;
59
+ is_sold_out: boolean;
60
+ totalSolAmount: string;
61
+ }
52
62
  interface SellParams {
53
63
  collectionId: string;
54
64
  quantity: number;
@@ -113,6 +123,7 @@ declare class FlipmemeSDK {
113
123
  };
114
124
  collectionAddress: _solana_web3_js.PublicKey;
115
125
  }>;
126
+ getTransactionTest(signature: string): Promise<_solana_web3_js.VersionedTransactionResponse | null>;
116
127
  }
117
128
 
118
- export { BlockchainType, type BuyCreditParams, type BuyParams, type CollectionInfo, type CollectionParams, type CreateCollectionResponse, type EthereumConfig, FlipmemeSDK, type NFTTradingData, type ProfileSellParams, type ReserveToken, type SellParams, type SolanaConfig, isEthereumConfig, isSolanaConfig };
129
+ export { BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, type CollectionInfo, type CollectionParams, type CreateCollectionResponse, type EthereumConfig, FlipmemeSDK, type NFTTradingData, type ProfileSellParams, type ReserveToken, type SellParams, type SolanaConfig, isEthereumConfig, isSolanaConfig };
package/dist/index.d.ts CHANGED
@@ -49,6 +49,16 @@ interface BuyParams {
49
49
  reserveToken: ReserveToken | null;
50
50
  notify: any | undefined;
51
51
  }
52
+ interface BuyResponse {
53
+ buyer: string;
54
+ collectionAddress: string;
55
+ nftAddress: string;
56
+ tokenId: string;
57
+ tokenUri: string;
58
+ price: string;
59
+ is_sold_out: boolean;
60
+ totalSolAmount: string;
61
+ }
52
62
  interface SellParams {
53
63
  collectionId: string;
54
64
  quantity: number;
@@ -113,6 +123,7 @@ declare class FlipmemeSDK {
113
123
  };
114
124
  collectionAddress: _solana_web3_js.PublicKey;
115
125
  }>;
126
+ getTransactionTest(signature: string): Promise<_solana_web3_js.VersionedTransactionResponse | null>;
116
127
  }
117
128
 
118
- export { BlockchainType, type BuyCreditParams, type BuyParams, type CollectionInfo, type CollectionParams, type CreateCollectionResponse, type EthereumConfig, FlipmemeSDK, type NFTTradingData, type ProfileSellParams, type ReserveToken, type SellParams, type SolanaConfig, isEthereumConfig, isSolanaConfig };
129
+ export { BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, type CollectionInfo, type CollectionParams, type CreateCollectionResponse, type EthereumConfig, FlipmemeSDK, type NFTTradingData, type ProfileSellParams, type ReserveToken, type SellParams, type SolanaConfig, isEthereumConfig, isSolanaConfig };
package/dist/index.js CHANGED
@@ -1559,6 +1559,21 @@ var getTradingAccounts = (collectionId, userPublicKey, programId, creatorAddress
1559
1559
  // src/solana/index.ts
1560
1560
  var import_lodash = require("lodash");
1561
1561
  var import_decimal = __toESM(require("decimal.js"));
1562
+
1563
+ // src/solana/analyze.ts
1564
+ function analyzeBuyTransaction(transactionData) {
1565
+ return __async(this, null, function* () {
1566
+ var _a, _b, _c;
1567
+ console.log("log Messages", (_a = transactionData.meta) == null ? void 0 : _a.logMessages, "log Messages");
1568
+ const eventLogs = (_c = (_b = transactionData.meta) == null ? void 0 : _b.logMessages) == null ? void 0 : _c.filter(
1569
+ (log) => log.includes("Program data:")
1570
+ );
1571
+ console.log("eventLogs", eventLogs);
1572
+ return [];
1573
+ });
1574
+ }
1575
+
1576
+ // src/solana/index.ts
1562
1577
  var SolanaConnector = class {
1563
1578
  constructor(config) {
1564
1579
  this.program = null;
@@ -1639,8 +1654,8 @@ var SolanaConnector = class {
1639
1654
  const addPriorityFee = import_web34.ComputeBudgetProgram.setComputeUnitPrice({
1640
1655
  microLamports: 1e4
1641
1656
  });
1642
- const lastestBlockhash = yield this.config.provider.connection.getLatestBlockhash();
1643
- const blockHash = lastestBlockhash.blockhash;
1657
+ const latestBlockhash = yield this.config.provider.connection.getLatestBlockhash();
1658
+ const blockHash = latestBlockhash.blockhash;
1644
1659
  const messageV0 = new import_web34.TransactionMessage({
1645
1660
  payerKey: this.config.wallet,
1646
1661
  recentBlockhash: blockHash,
@@ -1656,11 +1671,12 @@ var SolanaConnector = class {
1656
1671
  tx,
1657
1672
  this.config.provider.connection
1658
1673
  );
1659
- this.config.provider.connection.confirmTransaction({
1674
+ const confirmResult = yield this.config.provider.connection.confirmTransaction({
1660
1675
  blockhash: blockHash,
1661
- lastValidBlockHeight: lastestBlockhash.lastValidBlockHeight,
1676
+ lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
1662
1677
  signature: txHash
1663
1678
  });
1679
+ console.log("confirmResult == ", confirmResult);
1664
1680
  console.log("signature == ", txHash);
1665
1681
  return {
1666
1682
  collectionId: collectionID.toString(),
@@ -1716,9 +1732,23 @@ var SolanaConnector = class {
1716
1732
  }
1717
1733
  for (const [instructions, items] of instructionsChunks) {
1718
1734
  try {
1719
- const signature = yield this.sendTxn(instructions);
1735
+ const { signature, latestBlockhash } = yield this.sendTxn(instructions);
1720
1736
  successTxns.push({ items, signature });
1721
1737
  (_g = params.notify) == null ? void 0 : _g.onSuccess(successTxns.map((txn) => txn.items).flat(), quantity, signature);
1738
+ const confirmResult = yield this.config.provider.connection.confirmTransaction({
1739
+ blockhash: latestBlockhash.blockhash,
1740
+ lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
1741
+ signature
1742
+ });
1743
+ console.log("confirmResult", confirmResult);
1744
+ let transactionData = yield this.config.provider.connection.getTransaction(signature, {
1745
+ commitment: "confirmed",
1746
+ maxSupportedTransactionVersion: 0
1747
+ });
1748
+ if (transactionData) {
1749
+ analyzeBuyTransaction(transactionData);
1750
+ }
1751
+ console.log("transactionData", transactionData);
1722
1752
  } catch (e) {
1723
1753
  failedItems.push(...items);
1724
1754
  (_h = params.notify) == null ? void 0 : _h.onFailed(failedItems, quantity);
@@ -1752,7 +1782,7 @@ var SolanaConnector = class {
1752
1782
  const failedItems = [];
1753
1783
  for (const [instructions, items] of instructionsChunks) {
1754
1784
  try {
1755
- const signature = yield this.sendTxn(instructions);
1785
+ const { signature } = yield this.sendTxn(instructions);
1756
1786
  successTxns.push({ items, signature });
1757
1787
  notify == null ? void 0 : notify.onSuccess(successTxns.map((txn) => txn.items).flat(), quantity, signature);
1758
1788
  } catch (e) {
@@ -1789,7 +1819,7 @@ var SolanaConnector = class {
1789
1819
  const failedItems = [];
1790
1820
  for (const [instructions, items2] of instructionsChunks) {
1791
1821
  try {
1792
- const signature = yield this.sendTxn(instructions);
1822
+ const { signature } = yield this.sendTxn(instructions);
1793
1823
  successTxns.push({ items: items2, signature });
1794
1824
  (_b = data.notify) == null ? void 0 : _b.onSuccess(successTxns.map((txn) => txn.items).flat(), items2.length, signature);
1795
1825
  } catch (e) {
@@ -1847,15 +1877,20 @@ var SolanaConnector = class {
1847
1877
  }
1848
1878
  const transaction = new import_web34.Transaction();
1849
1879
  instructions.forEach((inx) => transaction.add(inx));
1850
- const { blockhash } = yield this.config.provider.connection.getLatestBlockhash("confirmed");
1880
+ const latestBlockhash = yield this.config.provider.connection.getLatestBlockhash("confirmed");
1851
1881
  const messageV0 = new import_web34.TransactionMessage({
1852
1882
  payerKey: this.config.wallet,
1853
- recentBlockhash: blockhash,
1883
+ recentBlockhash: latestBlockhash.blockhash,
1854
1884
  instructions
1855
1885
  }).compileToV0Message([]);
1856
1886
  const tx = new import_web34.VersionedTransaction(messageV0);
1857
1887
  const sim = yield this.config.provider.connection.simulateTransaction(tx);
1858
- return yield this.config.sendTransaction(tx, this.config.provider.connection);
1888
+ console.log("simulation result == ", sim);
1889
+ const signature = yield this.config.sendTransaction(tx, this.config.provider.connection);
1890
+ return {
1891
+ signature,
1892
+ latestBlockhash
1893
+ };
1859
1894
  });
1860
1895
  }
1861
1896
  getBuyInstructions(userPublicKey, collectionId, tokens) {
@@ -1962,9 +1997,6 @@ var SolanaConnector = class {
1962
1997
  const { nftPda: nftPda2, collectionPda: collectionPda2, nftHolderPda: nftHolderPda2 } = yield getNftAccounts(
1963
1998
  tokenId
1964
1999
  );
1965
- console.log("nftPda", nftPda2);
1966
- console.log("collectionPda", collectionPda2);
1967
- console.log("nftHolderPda", nftHolderPda2);
1968
2000
  const instruction = yield this.program.methods.mintAndBuy(name, tokenURI).accountsStrict({
1969
2001
  state: SOLANA_PUBKEYS.STATE_ID,
1970
2002
  treasury: stateAccount.treasury,
@@ -2018,6 +2050,18 @@ var SolanaConnector = class {
2018
2050
  return instructions;
2019
2051
  });
2020
2052
  }
2053
+ getTransactionTest(signature) {
2054
+ return __async(this, null, function* () {
2055
+ const transaction = yield this.config.provider.connection.getTransaction(signature, {
2056
+ commitment: "confirmed",
2057
+ maxSupportedTransactionVersion: 0
2058
+ });
2059
+ if (transaction) {
2060
+ analyzeBuyTransaction(transaction);
2061
+ }
2062
+ return transaction;
2063
+ });
2064
+ }
2021
2065
  };
2022
2066
 
2023
2067
  // src/types.ts
@@ -2132,6 +2176,15 @@ var FlipmemeSDK = class {
2132
2176
  }
2133
2177
  });
2134
2178
  }
2179
+ getTransactionTest(signature) {
2180
+ return __async(this, null, function* () {
2181
+ if (this.blockchainType === "solana" /* SOLANA */ && this.solana) {
2182
+ return this.solana.getTransactionTest(signature);
2183
+ } else {
2184
+ throw new Error("Cannot call this function");
2185
+ }
2186
+ });
2187
+ }
2135
2188
  /**For testing end */
2136
2189
  };
2137
2190
  // Annotate the CommonJS export names for ESM import in node: