flipmeme-sdk 1.2.65 → 1.3.0

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
@@ -93,6 +93,15 @@ interface SellResponse {
93
93
  interface SDKTransaction {
94
94
  tx: Transaction;
95
95
  additionalSigher: [Keypair] | null;
96
+ instructionCount: number;
97
+ }
98
+ interface SDKSignature {
99
+ signature: string;
100
+ index: number;
101
+ }
102
+ interface ConfirmResult {
103
+ successCount: number;
104
+ failedCount: number;
96
105
  }
97
106
  interface SellParams {
98
107
  collectionId: string;
@@ -150,9 +159,9 @@ declare class FlipmemeSDK {
150
159
  constructor(chainType: BlockchainType, isMain: boolean, config: EthereumConfig | SolanaConfig);
151
160
  updateConfig(chainType: BlockchainType, isMain: boolean, config: EthereumConfig | SolanaConfig): void;
152
161
  createCollection(params: CollectionParams): Promise<CreateCollectionResponse>;
153
- buy(params: BuyParams): Promise<BuyResponse[]>;
154
- flipSell(params: SellParams): Promise<SellResponse[]>;
155
- profileSell(data: ProfileSellParams): Promise<SellResponse[]>;
162
+ buy(params: BuyParams): Promise<ConfirmResult>;
163
+ flipSell(params: SellParams): Promise<ConfirmResult>;
164
+ profileSell(data: ProfileSellParams): Promise<ConfirmResult>;
156
165
  buyCredit(params: BuyCreditParams): Promise<string>;
157
166
  getTotalPrice(type: PurcahseType, collectionId: string, amount: number): Promise<string>;
158
167
  /**
@@ -361,4 +370,4 @@ declare function placeTensorCollectionBid(price: number, quantity: number, colle
361
370
 
362
371
  declare function decodeStr(str: string): string;
363
372
 
364
- export { type AssetData, type AssetInfo, BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, COLLECTION_BID_PRICE, type CollectionInfo, type CollectionParams, type Compression, type CreateCollectionResponse, ENV, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NetworkAddress, type NftInfo, type Ownership, type ProfileSellParams, PurcahseType, RPC, type ReserveToken, type SDKTransaction, SDK_SOLANA_CONFIG, SOLANA_COMMON, SOLANA_DEV, SOLANA_MAIN, SOLANA_PUBKEYS, SOLANA_PUBKEYS_DEV, type SellData, type SellParams, type SellResponse, type SolanaConfig, VALID_SIZE_PAIR, decodeStr, isEthereumConfig, isSolanaConfig, placeTensorCollectionBid };
373
+ export { type AssetData, type AssetInfo, BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, COLLECTION_BID_PRICE, type CollectionInfo, type CollectionParams, type Compression, type ConfirmResult, type CreateCollectionResponse, ENV, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NetworkAddress, type NftInfo, type Ownership, type ProfileSellParams, PurcahseType, RPC, type ReserveToken, type SDKSignature, type SDKTransaction, SDK_SOLANA_CONFIG, SOLANA_COMMON, SOLANA_DEV, SOLANA_MAIN, SOLANA_PUBKEYS, SOLANA_PUBKEYS_DEV, type SellData, type SellParams, type SellResponse, type SolanaConfig, VALID_SIZE_PAIR, decodeStr, isEthereumConfig, isSolanaConfig, placeTensorCollectionBid };
package/dist/index.d.ts CHANGED
@@ -93,6 +93,15 @@ interface SellResponse {
93
93
  interface SDKTransaction {
94
94
  tx: Transaction;
95
95
  additionalSigher: [Keypair] | null;
96
+ instructionCount: number;
97
+ }
98
+ interface SDKSignature {
99
+ signature: string;
100
+ index: number;
101
+ }
102
+ interface ConfirmResult {
103
+ successCount: number;
104
+ failedCount: number;
96
105
  }
97
106
  interface SellParams {
98
107
  collectionId: string;
@@ -150,9 +159,9 @@ declare class FlipmemeSDK {
150
159
  constructor(chainType: BlockchainType, isMain: boolean, config: EthereumConfig | SolanaConfig);
151
160
  updateConfig(chainType: BlockchainType, isMain: boolean, config: EthereumConfig | SolanaConfig): void;
152
161
  createCollection(params: CollectionParams): Promise<CreateCollectionResponse>;
153
- buy(params: BuyParams): Promise<BuyResponse[]>;
154
- flipSell(params: SellParams): Promise<SellResponse[]>;
155
- profileSell(data: ProfileSellParams): Promise<SellResponse[]>;
162
+ buy(params: BuyParams): Promise<ConfirmResult>;
163
+ flipSell(params: SellParams): Promise<ConfirmResult>;
164
+ profileSell(data: ProfileSellParams): Promise<ConfirmResult>;
156
165
  buyCredit(params: BuyCreditParams): Promise<string>;
157
166
  getTotalPrice(type: PurcahseType, collectionId: string, amount: number): Promise<string>;
158
167
  /**
@@ -361,4 +370,4 @@ declare function placeTensorCollectionBid(price: number, quantity: number, colle
361
370
 
362
371
  declare function decodeStr(str: string): string;
363
372
 
364
- export { type AssetData, type AssetInfo, BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, COLLECTION_BID_PRICE, type CollectionInfo, type CollectionParams, type Compression, type CreateCollectionResponse, ENV, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NetworkAddress, type NftInfo, type Ownership, type ProfileSellParams, PurcahseType, RPC, type ReserveToken, type SDKTransaction, SDK_SOLANA_CONFIG, SOLANA_COMMON, SOLANA_DEV, SOLANA_MAIN, SOLANA_PUBKEYS, SOLANA_PUBKEYS_DEV, type SellData, type SellParams, type SellResponse, type SolanaConfig, VALID_SIZE_PAIR, decodeStr, isEthereumConfig, isSolanaConfig, placeTensorCollectionBid };
373
+ export { type AssetData, type AssetInfo, BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, COLLECTION_BID_PRICE, type CollectionInfo, type CollectionParams, type Compression, type ConfirmResult, type CreateCollectionResponse, ENV, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NetworkAddress, type NftInfo, type Ownership, type ProfileSellParams, PurcahseType, RPC, type ReserveToken, type SDKSignature, type SDKTransaction, SDK_SOLANA_CONFIG, SOLANA_COMMON, SOLANA_DEV, SOLANA_MAIN, SOLANA_PUBKEYS, SOLANA_PUBKEYS_DEV, type SellData, type SellParams, type SellResponse, type SolanaConfig, VALID_SIZE_PAIR, decodeStr, isEthereumConfig, isSolanaConfig, placeTensorCollectionBid };
package/dist/index.js CHANGED
@@ -2327,8 +2327,8 @@ var SolanaConnector = class {
2327
2327
  name,
2328
2328
  tokenUri,
2329
2329
  totalSupply,
2330
- new import_bn.default(2e5),
2331
- new import_bn.default(1e6)
2330
+ new import_bn.default(2e7),
2331
+ new import_bn.default(1e9)
2332
2332
  ).accountsStrict({
2333
2333
  state: this.configAddresses.STATE_ID,
2334
2334
  collection: collectionPda2,
@@ -2394,18 +2394,21 @@ var SolanaConnector = class {
2394
2394
  console.error("Failed to getMintAndBuyInstructions", { error });
2395
2395
  }
2396
2396
  }
2397
- let buyResponse = [];
2398
2397
  try {
2399
2398
  const { signatures, latestBlockhash } = yield this.sendTxnForBatch(
2400
2399
  transactions,
2401
2400
  this.lookupTableAccounts
2402
2401
  );
2403
- console.log("signatures", signatures);
2402
+ const result = yield this.confirmSignatures(
2403
+ transactions,
2404
+ signatures,
2405
+ latestBlockhash
2406
+ );
2407
+ return result;
2404
2408
  } catch (e) {
2405
2409
  console.error("Buy failed:", JSON.stringify(e));
2406
- throw e;
2407
2410
  }
2408
- return buyResponse;
2411
+ return { successCount: 0, failedCount: 0 };
2409
2412
  });
2410
2413
  }
2411
2414
  //useFlip.ts
@@ -2427,17 +2430,21 @@ var SolanaConnector = class {
2427
2430
  console.error("Failed to getSellInstructions", { error });
2428
2431
  throw error;
2429
2432
  }
2430
- let sellResponse = [];
2431
2433
  try {
2432
2434
  const { signatures, latestBlockhash } = yield this.sendTxnForBatch(
2433
2435
  transactions,
2434
2436
  this.lookupTableAccounts
2435
2437
  );
2438
+ const result = yield this.confirmSignatures(
2439
+ transactions,
2440
+ signatures,
2441
+ latestBlockhash
2442
+ );
2443
+ return result;
2436
2444
  } catch (e) {
2437
2445
  console.error("Flip failed:", JSON.stringify(e));
2438
- throw e;
2439
2446
  }
2440
- return sellResponse;
2447
+ return { successCount: 0, failedCount: 0 };
2441
2448
  });
2442
2449
  }
2443
2450
  //useFlipProfile.ts
@@ -2461,17 +2468,21 @@ var SolanaConnector = class {
2461
2468
  throw error;
2462
2469
  }
2463
2470
  }
2464
- let sellResponse = [];
2465
2471
  try {
2466
2472
  const { signatures, latestBlockhash } = yield this.sendTxnForBatch(
2467
2473
  transactions,
2468
2474
  this.lookupTableAccounts
2469
2475
  );
2476
+ const result = yield this.confirmSignatures(
2477
+ transactions,
2478
+ signatures,
2479
+ latestBlockhash
2480
+ );
2481
+ return result;
2470
2482
  } catch (e) {
2471
2483
  console.error("Flip failed:", JSON.stringify(e));
2472
- throw e;
2473
2484
  }
2474
- return sellResponse;
2485
+ return { successCount: 0, failedCount: 0 };
2475
2486
  });
2476
2487
  }
2477
2488
  buyCredit(params) {
@@ -2810,29 +2821,49 @@ var SolanaConnector = class {
2810
2821
  );
2811
2822
  console.log("transaction size ", messageV0.serialize().length);
2812
2823
  let versionedTx = new import_web34.VersionedTransaction(messageV0);
2813
- if (sdkTx.additionalSigher)
2814
- versionedTx.sign(sdkTx.additionalSigher);
2824
+ if (sdkTx.additionalSigher) versionedTx.sign(sdkTx.additionalSigher);
2815
2825
  return versionedTx;
2816
2826
  });
2817
2827
  const signedTxs = yield this.config.signAllTransactions(txs);
2818
2828
  let signatures = yield Promise.all(
2819
- signedTxs.map((signedTx) => __async(this, null, function* () {
2829
+ signedTxs.map((signedTx, index) => __async(this, null, function* () {
2820
2830
  if (signedTx instanceof import_web34.VersionedTransaction) {
2821
2831
  let signature = yield this.config.provider.connection.sendTransaction(
2822
2832
  signedTx,
2823
2833
  { skipPreflight: true, preflightCommitment: "confirmed" }
2824
2834
  );
2825
- return signature;
2835
+ return { signature, index };
2826
2836
  }
2827
2837
  }))
2828
2838
  );
2829
- console.log("signatures", signatures);
2839
+ console.log("signatures from Promisze all ===============", signatures);
2830
2840
  return {
2831
2841
  signatures,
2832
2842
  latestBlockhash
2833
2843
  };
2834
2844
  });
2835
2845
  }
2846
+ confirmSignatures(transactions, signatures, latestBlockhash) {
2847
+ return __async(this, null, function* () {
2848
+ let successCount = 0;
2849
+ let failedCount = 0;
2850
+ for (const index in signatures) {
2851
+ if (signatures[index]) {
2852
+ const confirmResult = yield this.config.provider.connection.confirmTransaction({
2853
+ blockhash: latestBlockhash.blockhash,
2854
+ lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
2855
+ signature: signatures[index].signature
2856
+ });
2857
+ if (confirmResult.value.err == null) {
2858
+ successCount += transactions[index].instructionCount;
2859
+ } else {
2860
+ failedCount += transactions[index].instructionCount;
2861
+ }
2862
+ }
2863
+ }
2864
+ return { successCount, failedCount };
2865
+ });
2866
+ }
2836
2867
  getBuyInstructions(userPublicKey, collectionId, tokens) {
2837
2868
  return __async(this, null, function* () {
2838
2869
  if (!this.program) {
@@ -2876,7 +2907,11 @@ var SolanaConnector = class {
2876
2907
  }).instruction();
2877
2908
  transaction.add(instruction);
2878
2909
  }
2879
- transactions.push({ tx: transaction, additionalSigher: null });
2910
+ transactions.push({
2911
+ tx: transaction,
2912
+ additionalSigher: null,
2913
+ instructionCount: chunk.length
2914
+ });
2880
2915
  }
2881
2916
  return transactions;
2882
2917
  } catch (e) {
@@ -2928,7 +2963,11 @@ var SolanaConnector = class {
2928
2963
  }).instruction();
2929
2964
  transaction.add(instruction);
2930
2965
  }
2931
- transactions.push({ tx: transaction, additionalSigher: null });
2966
+ transactions.push({
2967
+ tx: transaction,
2968
+ additionalSigher: null,
2969
+ instructionCount: chunk.length
2970
+ });
2932
2971
  }
2933
2972
  return transactions;
2934
2973
  } catch (e) {
@@ -2989,7 +3028,8 @@ var SolanaConnector = class {
2989
3028
  }
2990
3029
  transactions.push({
2991
3030
  tx: transaction,
2992
- additionalSigher: [this.updateAuthority]
3031
+ additionalSigher: [this.updateAuthority],
3032
+ instructionCount: chunks.length
2993
3033
  });
2994
3034
  }
2995
3035
  return transactions;