flipmeme-sdk 1.0.16 → 1.0.17

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
@@ -59,6 +59,16 @@ interface BuyResponse {
59
59
  price: string;
60
60
  is_sold_out: boolean;
61
61
  totalSolAmount: string;
62
+ timestamp: string;
63
+ }
64
+ interface SellResponse {
65
+ seller: string;
66
+ collectionAddress: string;
67
+ nftAddress: string;
68
+ tokenId: string;
69
+ price: string;
70
+ totalSolAmount: string;
71
+ timestamp: string;
62
72
  }
63
73
  interface SellParams {
64
74
  collectionId: string;
@@ -86,7 +96,7 @@ declare class FlipmemeSDK {
86
96
  createCollection(params: CollectionParams): Promise<CreateCollectionResponse>;
87
97
  getCollectionPda(): Promise<CollectionInfo>;
88
98
  buy(params: BuyParams): Promise<BuyResponse[]>;
89
- flipSell(params: SellParams): Promise<void>;
99
+ flipSell(params: SellParams): Promise<SellResponse[]>;
90
100
  profileSell(data: ProfileSellParams): Promise<void>;
91
101
  buyCredit(params: BuyCreditParams): Promise<string>;
92
102
  /**For testing */
@@ -127,4 +137,4 @@ declare class FlipmemeSDK {
127
137
  getTransactionTest(signature: string): Promise<_solana_web3_js.VersionedTransactionResponse | null>;
128
138
  }
129
139
 
130
- 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 };
140
+ 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 SellResponse, type SolanaConfig, isEthereumConfig, isSolanaConfig };
package/dist/index.d.ts CHANGED
@@ -59,6 +59,16 @@ interface BuyResponse {
59
59
  price: string;
60
60
  is_sold_out: boolean;
61
61
  totalSolAmount: string;
62
+ timestamp: string;
63
+ }
64
+ interface SellResponse {
65
+ seller: string;
66
+ collectionAddress: string;
67
+ nftAddress: string;
68
+ tokenId: string;
69
+ price: string;
70
+ totalSolAmount: string;
71
+ timestamp: string;
62
72
  }
63
73
  interface SellParams {
64
74
  collectionId: string;
@@ -86,7 +96,7 @@ declare class FlipmemeSDK {
86
96
  createCollection(params: CollectionParams): Promise<CreateCollectionResponse>;
87
97
  getCollectionPda(): Promise<CollectionInfo>;
88
98
  buy(params: BuyParams): Promise<BuyResponse[]>;
89
- flipSell(params: SellParams): Promise<void>;
99
+ flipSell(params: SellParams): Promise<SellResponse[]>;
90
100
  profileSell(data: ProfileSellParams): Promise<void>;
91
101
  buyCredit(params: BuyCreditParams): Promise<string>;
92
102
  /**For testing */
@@ -127,4 +137,4 @@ declare class FlipmemeSDK {
127
137
  getTransactionTest(signature: string): Promise<_solana_web3_js.VersionedTransactionResponse | null>;
128
138
  }
129
139
 
130
- 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 };
140
+ 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 SellResponse, type SolanaConfig, isEthereumConfig, isSolanaConfig };
package/dist/index.js CHANGED
@@ -1471,6 +1471,9 @@ var SOLANA_PUBKEYS = {
1471
1471
  EVENT_AUTHORITY_ID: new import_web3.PublicKey(SOLANA.EVENT_AUTHORITY_ID_STR),
1472
1472
  ADMIN_FOR_CREDIT_BUY: new import_web3.PublicKey(SOLANA.ADMIN_FOR_CREDIT_BUY_STR)
1473
1473
  };
1474
+ var SDK_SOLANA_CONFIG = {
1475
+ CHUNK_SIZE: 20
1476
+ };
1474
1477
 
1475
1478
  // src/solana/index.ts
1476
1479
  var import_web34 = require("@solana/web3.js");
@@ -1582,7 +1585,8 @@ function analyzeBuyTransaction(program, transactionData) {
1582
1585
  tokenUri: decodedData.data.uri.toString(),
1583
1586
  price: decodedData.data.price.toString(),
1584
1587
  is_sold_out: decodedData.data.isSoldOut,
1585
- totalSolAmount: decodedData.data.totalSol.toString()
1588
+ totalSolAmount: decodedData.data.totalSol.toString(),
1589
+ timestamp: decodedData.data.timestamp.toString()
1586
1590
  });
1587
1591
  }
1588
1592
  }
@@ -1590,6 +1594,33 @@ function analyzeBuyTransaction(program, transactionData) {
1590
1594
  }
1591
1595
  return buyResponse;
1592
1596
  }
1597
+ function analyzeSellTransaction(program, transactionData) {
1598
+ var _a;
1599
+ let instructions = (_a = transactionData.meta) == null ? void 0 : _a.innerInstructions;
1600
+ let sellResponse = [];
1601
+ if (instructions) {
1602
+ for (const instruction of instructions) {
1603
+ for (const subInstruction of instruction.instructions) {
1604
+ let rawData = import_anchor.utils.bytes.bs58.decode(subInstruction.data);
1605
+ const base64Data = import_anchor.utils.bytes.base64.encode(rawData.subarray(8));
1606
+ let decodedData = program.coder.events.decode(base64Data);
1607
+ if ((decodedData == null ? void 0 : decodedData.name) === "sellEvent") {
1608
+ sellResponse.push({
1609
+ seller: decodedData.data.seller.toString(),
1610
+ collectionAddress: decodedData.data.collection.toString(),
1611
+ nftAddress: decodedData.data.nft.toString(),
1612
+ tokenId: decodedData.data.tokenId.toString(),
1613
+ price: decodedData.data.price.toString(),
1614
+ totalSolAmount: decodedData.data.totalSol.toString(),
1615
+ timestamp: decodedData.data.timestamp.toString()
1616
+ });
1617
+ }
1618
+ }
1619
+ }
1620
+ }
1621
+ console.log("sellResponse", sellResponse);
1622
+ return sellResponse;
1623
+ }
1593
1624
 
1594
1625
  // src/solana/index.ts
1595
1626
  var SolanaConnector = class {
@@ -1812,15 +1843,30 @@ var SolanaConnector = class {
1812
1843
  }
1813
1844
  const successTxns = [];
1814
1845
  const failedItems = [];
1846
+ let sellResponse = [];
1815
1847
  for (const [instructions, items] of instructionsChunks) {
1816
1848
  try {
1817
- const { signature } = yield this.sendTxn(instructions);
1849
+ const { signature, latestBlockhash } = yield this.sendTxn(instructions);
1818
1850
  successTxns.push({ items, signature });
1819
1851
  notify == null ? void 0 : notify.onSuccess(
1820
1852
  successTxns.map((txn) => txn.items).flat(),
1821
1853
  quantity,
1822
1854
  signature
1823
1855
  );
1856
+ const confirmResult = yield this.config.provider.connection.confirmTransaction({
1857
+ blockhash: latestBlockhash.blockhash,
1858
+ lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
1859
+ signature
1860
+ });
1861
+ console.log("confirmResult", confirmResult);
1862
+ let transactionData = yield this.config.provider.connection.getTransaction(signature, {
1863
+ commitment: "confirmed",
1864
+ maxSupportedTransactionVersion: 0
1865
+ });
1866
+ if (transactionData) {
1867
+ let itemSellResponse = yield analyzeSellTransaction(this.program, transactionData);
1868
+ sellResponse.push(...itemSellResponse);
1869
+ }
1824
1870
  } catch (e) {
1825
1871
  failedItems.push(...items);
1826
1872
  notify == null ? void 0 : notify.onFailed(failedItems, quantity);
@@ -1828,6 +1874,7 @@ var SolanaConnector = class {
1828
1874
  throw e;
1829
1875
  }
1830
1876
  }
1877
+ return sellResponse;
1831
1878
  });
1832
1879
  }
1833
1880
  //useFlipProfile.ts
@@ -1951,7 +1998,7 @@ var SolanaConnector = class {
1951
1998
  if (!this.program) {
1952
1999
  throw new Error("Program not initialized");
1953
2000
  }
1954
- const chunkSize = 1;
2001
+ const chunkSize = SDK_SOLANA_CONFIG.CHUNK_SIZE;
1955
2002
  const tokenChunks = getTokenChunks(tokens, chunkSize);
1956
2003
  const allInstructionSets = [];
1957
2004
  try {
@@ -1987,7 +2034,7 @@ var SolanaConnector = class {
1987
2034
  userPublicKey,
1988
2035
  this.program.programId
1989
2036
  );
1990
- const chunkSize = 1;
2037
+ const chunkSize = SDK_SOLANA_CONFIG.CHUNK_SIZE;
1991
2038
  const tokenChunks = getTokenChunks(tokens, chunkSize);
1992
2039
  const allInstructionSets = [];
1993
2040
  const state = yield this.program.account.state.fetch(
@@ -2037,7 +2084,7 @@ var SolanaConnector = class {
2037
2084
  if (!this.program) {
2038
2085
  throw new Error("Program not initialized");
2039
2086
  }
2040
- const chunkSize = 20;
2087
+ const chunkSize = SDK_SOLANA_CONFIG.CHUNK_SIZE;
2041
2088
  const tokenChunks = getTokenChunks(tokens, chunkSize);
2042
2089
  const allInstructionSets = [];
2043
2090
  const { getNftAccounts } = yield getTradingAccounts(