flipmeme-sdk 1.2.3 → 1.2.5

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
@@ -177,18 +177,133 @@ declare class FlipmemeSDK {
177
177
  getInstructionData(instruction: string): Promise<void>;
178
178
  }
179
179
 
180
+ declare const SOLANA: {
181
+ STATE_ID_STR: string;
182
+ TREASURY_ID_STR: string;
183
+ LP_PROVISIONER_ID_STR: string;
184
+ TOKEN_METADATA_PROGRAM_ID_STR: string;
185
+ MPL_CORE_STR: string;
186
+ ADMIN_FOR_CREDIT_BUY_STR: string;
187
+ MPL_BUBBLEGUM_STR: string;
188
+ SPL_ACCOUNT_COMPRESSION_STR: string;
189
+ SPL_NOOP_STR: string;
190
+ SPL_TOKEN_STR: string;
191
+ SPL_ATA_TOKEN_STR: string;
192
+ RENT_TOKEN_STR: string;
193
+ };
180
194
  declare enum ENV {
181
195
  Devnet = "Devnet",
182
196
  Mainnet = "Mainnet"
183
197
  }
198
+ declare const RPC: {
199
+ Devnet: string;
200
+ Mainnet: string;
201
+ };
202
+ declare const SOLANA_PUBKEYS: {
203
+ STATE_ID: PublicKey;
204
+ TREASURY_ID: PublicKey;
205
+ LP_PROVISIONER_ID: PublicKey;
206
+ TOKEN_METADATA_PROGRAM_ID: PublicKey;
207
+ ADMIN_FOR_CREDIT_BUY: PublicKey;
208
+ MPL_BUBBLEGUM_ID: PublicKey;
209
+ SPL_ACCOUNT_COMPRESSION_ID: PublicKey;
210
+ SPL_NOOP_ID: PublicKey;
211
+ SPL_TOKEN_ID: PublicKey;
212
+ SPL_ATA_TOKEN_ID: PublicKey;
213
+ RENT_TOKEN_ID: PublicKey;
214
+ };
215
+ declare const SDK_SOLANA_CONFIG: {
216
+ CHUNK_SIZE: number;
217
+ };
218
+ declare const VALID_SIZE_PAIR: {
219
+ 3: {
220
+ maxBufferSize: number;
221
+ maxDepth: number;
222
+ };
223
+ 4: {
224
+ maxBufferSize: number;
225
+ maxDepth: number;
226
+ };
227
+ 5: {
228
+ maxBufferSize: number;
229
+ maxDepth: number;
230
+ };
231
+ 6: {
232
+ maxBufferSize: number;
233
+ maxDepth: number;
234
+ };
235
+ 7: {
236
+ maxBufferSize: number;
237
+ maxDepth: number;
238
+ };
239
+ 8: {
240
+ maxBufferSize: number;
241
+ maxDepth: number;
242
+ };
243
+ 9: {
244
+ maxBufferSize: number;
245
+ maxDepth: number;
246
+ };
247
+ 10: {
248
+ maxBufferSize: number;
249
+ maxDepth: number;
250
+ };
251
+ 11: {
252
+ maxBufferSize: number;
253
+ maxDepth: number;
254
+ };
255
+ 12: {
256
+ maxBufferSize: number;
257
+ maxDepth: number;
258
+ };
259
+ 13: {
260
+ maxBufferSize: number;
261
+ maxDepth: number;
262
+ };
263
+ 14: {
264
+ maxBufferSize: number;
265
+ maxDepth: number;
266
+ };
267
+ 15: {
268
+ maxBufferSize: number;
269
+ maxDepth: number;
270
+ };
271
+ 16: {
272
+ maxBufferSize: number;
273
+ maxDepth: number;
274
+ };
275
+ 17: {
276
+ maxBufferSize: number;
277
+ maxDepth: number;
278
+ };
279
+ 18: {
280
+ maxBufferSize: number;
281
+ maxDepth: number;
282
+ };
283
+ 19: {
284
+ maxBufferSize: number;
285
+ maxDepth: number;
286
+ };
287
+ 20: {
288
+ maxBufferSize: number;
289
+ maxDepth: number;
290
+ };
291
+ 21: {
292
+ maxBufferSize: number;
293
+ maxDepth: number;
294
+ };
295
+ 22: {
296
+ maxBufferSize: number;
297
+ maxDepth: number;
298
+ };
299
+ 23: {
300
+ maxBufferSize: number;
301
+ maxDepth: number;
302
+ };
303
+ 24: {
304
+ maxBufferSize: number;
305
+ maxDepth: number;
306
+ };
307
+ };
184
308
 
185
- declare class Utility {
186
- /**
187
- * this function is used to create merkle tree on backend side for bubblegum cNFT for metaplex
188
- * backend pays the merkle tree create fee
189
- * this function works on mpl_bubblegum version 4.3.1 but I downgrade the mpl_bubblegum for getLeafAsset function
190
- */
191
- static createMerkleTreeFromContract(env: ENV, privateKey: string, collectionSize: number, collectionId: string): Promise<PublicKey>;
192
- }
193
-
194
- export { type AssetData, type AssetInfo, BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, type CollectionInfo, type CollectionParams, type Compression, type CreateCollectionResponse, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NFTTradingData, type Ownership, type ProfileSellParams, PurcahseType, type ReserveToken, type SellParams, type SellResponse, type SolanaConfig, Utility, isEthereumConfig, isSolanaConfig };
309
+ export { type AssetData, type AssetInfo, BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, type CollectionInfo, type CollectionParams, type Compression, type CreateCollectionResponse, ENV, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NFTTradingData, type Ownership, type ProfileSellParams, PurcahseType, RPC, type ReserveToken, SDK_SOLANA_CONFIG, SOLANA, SOLANA_PUBKEYS, type SellParams, type SellResponse, type SolanaConfig, VALID_SIZE_PAIR, isEthereumConfig, isSolanaConfig };
package/dist/index.d.ts CHANGED
@@ -177,18 +177,133 @@ declare class FlipmemeSDK {
177
177
  getInstructionData(instruction: string): Promise<void>;
178
178
  }
179
179
 
180
+ declare const SOLANA: {
181
+ STATE_ID_STR: string;
182
+ TREASURY_ID_STR: string;
183
+ LP_PROVISIONER_ID_STR: string;
184
+ TOKEN_METADATA_PROGRAM_ID_STR: string;
185
+ MPL_CORE_STR: string;
186
+ ADMIN_FOR_CREDIT_BUY_STR: string;
187
+ MPL_BUBBLEGUM_STR: string;
188
+ SPL_ACCOUNT_COMPRESSION_STR: string;
189
+ SPL_NOOP_STR: string;
190
+ SPL_TOKEN_STR: string;
191
+ SPL_ATA_TOKEN_STR: string;
192
+ RENT_TOKEN_STR: string;
193
+ };
180
194
  declare enum ENV {
181
195
  Devnet = "Devnet",
182
196
  Mainnet = "Mainnet"
183
197
  }
198
+ declare const RPC: {
199
+ Devnet: string;
200
+ Mainnet: string;
201
+ };
202
+ declare const SOLANA_PUBKEYS: {
203
+ STATE_ID: PublicKey;
204
+ TREASURY_ID: PublicKey;
205
+ LP_PROVISIONER_ID: PublicKey;
206
+ TOKEN_METADATA_PROGRAM_ID: PublicKey;
207
+ ADMIN_FOR_CREDIT_BUY: PublicKey;
208
+ MPL_BUBBLEGUM_ID: PublicKey;
209
+ SPL_ACCOUNT_COMPRESSION_ID: PublicKey;
210
+ SPL_NOOP_ID: PublicKey;
211
+ SPL_TOKEN_ID: PublicKey;
212
+ SPL_ATA_TOKEN_ID: PublicKey;
213
+ RENT_TOKEN_ID: PublicKey;
214
+ };
215
+ declare const SDK_SOLANA_CONFIG: {
216
+ CHUNK_SIZE: number;
217
+ };
218
+ declare const VALID_SIZE_PAIR: {
219
+ 3: {
220
+ maxBufferSize: number;
221
+ maxDepth: number;
222
+ };
223
+ 4: {
224
+ maxBufferSize: number;
225
+ maxDepth: number;
226
+ };
227
+ 5: {
228
+ maxBufferSize: number;
229
+ maxDepth: number;
230
+ };
231
+ 6: {
232
+ maxBufferSize: number;
233
+ maxDepth: number;
234
+ };
235
+ 7: {
236
+ maxBufferSize: number;
237
+ maxDepth: number;
238
+ };
239
+ 8: {
240
+ maxBufferSize: number;
241
+ maxDepth: number;
242
+ };
243
+ 9: {
244
+ maxBufferSize: number;
245
+ maxDepth: number;
246
+ };
247
+ 10: {
248
+ maxBufferSize: number;
249
+ maxDepth: number;
250
+ };
251
+ 11: {
252
+ maxBufferSize: number;
253
+ maxDepth: number;
254
+ };
255
+ 12: {
256
+ maxBufferSize: number;
257
+ maxDepth: number;
258
+ };
259
+ 13: {
260
+ maxBufferSize: number;
261
+ maxDepth: number;
262
+ };
263
+ 14: {
264
+ maxBufferSize: number;
265
+ maxDepth: number;
266
+ };
267
+ 15: {
268
+ maxBufferSize: number;
269
+ maxDepth: number;
270
+ };
271
+ 16: {
272
+ maxBufferSize: number;
273
+ maxDepth: number;
274
+ };
275
+ 17: {
276
+ maxBufferSize: number;
277
+ maxDepth: number;
278
+ };
279
+ 18: {
280
+ maxBufferSize: number;
281
+ maxDepth: number;
282
+ };
283
+ 19: {
284
+ maxBufferSize: number;
285
+ maxDepth: number;
286
+ };
287
+ 20: {
288
+ maxBufferSize: number;
289
+ maxDepth: number;
290
+ };
291
+ 21: {
292
+ maxBufferSize: number;
293
+ maxDepth: number;
294
+ };
295
+ 22: {
296
+ maxBufferSize: number;
297
+ maxDepth: number;
298
+ };
299
+ 23: {
300
+ maxBufferSize: number;
301
+ maxDepth: number;
302
+ };
303
+ 24: {
304
+ maxBufferSize: number;
305
+ maxDepth: number;
306
+ };
307
+ };
184
308
 
185
- declare class Utility {
186
- /**
187
- * this function is used to create merkle tree on backend side for bubblegum cNFT for metaplex
188
- * backend pays the merkle tree create fee
189
- * this function works on mpl_bubblegum version 4.3.1 but I downgrade the mpl_bubblegum for getLeafAsset function
190
- */
191
- static createMerkleTreeFromContract(env: ENV, privateKey: string, collectionSize: number, collectionId: string): Promise<PublicKey>;
192
- }
193
-
194
- export { type AssetData, type AssetInfo, BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, type CollectionInfo, type CollectionParams, type Compression, type CreateCollectionResponse, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NFTTradingData, type Ownership, type ProfileSellParams, PurcahseType, type ReserveToken, type SellParams, type SellResponse, type SolanaConfig, Utility, isEthereumConfig, isSolanaConfig };
309
+ export { type AssetData, type AssetInfo, BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, type CollectionInfo, type CollectionParams, type Compression, type CreateCollectionResponse, ENV, type EthereumConfig, FlipmemeSDK, type MerkleProof, type NFTTradingData, type Ownership, type ProfileSellParams, PurcahseType, RPC, type ReserveToken, SDK_SOLANA_CONFIG, SOLANA, SOLANA_PUBKEYS, type SellParams, type SellResponse, type SolanaConfig, VALID_SIZE_PAIR, isEthereumConfig, isSolanaConfig };
package/dist/index.js CHANGED
@@ -51,9 +51,14 @@ 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
56
  PurcahseType: () => PurcahseType,
56
- Utility: () => Utility,
57
+ RPC: () => RPC,
58
+ SDK_SOLANA_CONFIG: () => SDK_SOLANA_CONFIG,
59
+ SOLANA: () => SOLANA,
60
+ SOLANA_PUBKEYS: () => SOLANA_PUBKEYS,
61
+ VALID_SIZE_PAIR: () => VALID_SIZE_PAIR,
57
62
  isEthereumConfig: () => isEthereumConfig,
58
63
  isSolanaConfig: () => isSolanaConfig
59
64
  });
@@ -2238,6 +2243,11 @@ var SOLANA = {
2238
2243
  SPL_ATA_TOKEN_STR: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
2239
2244
  RENT_TOKEN_STR: "SysvarRent111111111111111111111111111111111"
2240
2245
  };
2246
+ var ENV = /* @__PURE__ */ ((ENV2) => {
2247
+ ENV2["Devnet"] = "Devnet";
2248
+ ENV2["Mainnet"] = "Mainnet";
2249
+ return ENV2;
2250
+ })(ENV || {});
2241
2251
  var RPC = {
2242
2252
  Devnet: "https://api.devnet.solana.com",
2243
2253
  Mainnet: "https://api.mainnet-beta.solana.com"
@@ -2896,8 +2906,14 @@ var SolanaConnector = class {
2896
2906
  throw new Error("Program not initialized");
2897
2907
  }
2898
2908
  let merkleTreeKeyPair = new import_web35.Keypair();
2899
- let accountInx = yield this.createAccountForMerkleTree(
2900
- merkleTreeKeyPair.publicKey
2909
+ let canopyDepth = maxDepth > 6 ? 4 : 3;
2910
+ let accountInx = yield (0, import_spl_account_compression.createAllocTreeIx)(
2911
+ this.config.provider.connection,
2912
+ merkleTreeKeyPair.publicKey,
2913
+ this.config.wallet,
2914
+ //@ts-ignore
2915
+ VALID_SIZE_PAIR[maxDepth],
2916
+ canopyDepth
2901
2917
  );
2902
2918
  let collectionPda2 = collectionPda(
2903
2919
  collectionId,
@@ -2940,18 +2956,22 @@ var SolanaConnector = class {
2940
2956
  const result = yield this.config.provider.connection.simulateTransaction(
2941
2957
  versionedTransaction
2942
2958
  );
2943
- const tx = new import_web35.Transaction().add(modifyComputeUnits).add(addPriorityFee).add(accountInx).add(instruction);
2944
- const txHash = yield this.config.provider.sendAndConfirm(
2945
- tx,
2946
- [merkleTreeKeyPair],
2947
- { commitment: "confirmed", skipPreflight: true }
2948
- );
2949
- const confirmResult = yield this.config.provider.connection.confirmTransaction({
2950
- blockhash: blockHash,
2951
- lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
2952
- signature: txHash
2953
- });
2954
- return merkleTreeKeyPair.publicKey;
2959
+ try {
2960
+ const tx = new import_web35.Transaction().add(modifyComputeUnits).add(addPriorityFee).add(accountInx).add(instruction);
2961
+ const txHash = yield this.config.provider.sendAndConfirm(
2962
+ tx,
2963
+ [merkleTreeKeyPair],
2964
+ { commitment: "confirmed", skipPreflight: true }
2965
+ );
2966
+ const confirmResult = yield this.config.provider.connection.confirmTransaction({
2967
+ blockhash: blockHash,
2968
+ lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
2969
+ signature: txHash
2970
+ });
2971
+ return merkleTreeKeyPair.publicKey;
2972
+ } catch (e) {
2973
+ throw new Error("Cannot call this function");
2974
+ }
2955
2975
  });
2956
2976
  }
2957
2977
  getTotalPrice(type, collectionId, amount) {
@@ -3245,6 +3265,11 @@ var SolanaConnector = class {
3245
3265
  return instructions;
3246
3266
  });
3247
3267
  }
3268
+ /**
3269
+ * initialize account for merkle tree
3270
+ * @param merkleTree merkle tree address which is initialized
3271
+ * @returns
3272
+ */
3248
3273
  createAccountForMerkleTree(merkleTree) {
3249
3274
  return __async(this, null, function* () {
3250
3275
  const dataLen = 5112;
@@ -3433,94 +3458,17 @@ var FlipmemeSDK = class {
3433
3458
  }
3434
3459
  /**For testing end */
3435
3460
  };
3436
-
3437
- // src/utility.ts
3438
- var import_bytes = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
3439
- var import_web36 = require("@solana/web3.js");
3440
- var import_anchor3 = require("@coral-xyz/anchor");
3441
- var Utility = class {
3442
- /**
3443
- * this function is used to create merkle tree on backend side for bubblegum cNFT for metaplex
3444
- * backend pays the merkle tree create fee
3445
- * this function works on mpl_bubblegum version 4.3.1 but I downgrade the mpl_bubblegum for getLeafAsset function
3446
- */
3447
- // static async createMerkleTree(
3448
- // env: ENV,
3449
- // payerPrivateKey: string,
3450
- // collectionSize: number,
3451
- // collectionId: string
3452
- // ): Promise<PublicKey> {
3453
- // if (collectionSize < 3 || collectionSize > 24)
3454
- // throw new Error(`collection size won't be such value ${collectionSize}`);
3455
- // const rpc = RPC[env];
3456
- // const privKeyUtf8 = bs58.decode(payerPrivateKey);
3457
- // let depthSize = Math.ceil(Math.log2(collectionSize));
3458
- // //@ts-ignore
3459
- // const { maxBufferSize, maxDepth } = VALID_SIZE_PAIR[depthSize];
3460
- // let umi = createUmi(rpc);
3461
- // const payer = umi.eddsa.createKeypairFromSecretKey(privKeyUtf8);
3462
- // const signer = createSignerFromKeypair(umi, payer);
3463
- // const merkleTree = generateSigner(umi);
3464
- // umi.use(signerIdentity(signer));
3465
- // let builder = await createTree(umi, {
3466
- // merkleTree,
3467
- // maxDepth,
3468
- // maxBufferSize,
3469
- // });
3470
- // let res = await builder.sendAndConfirm(umi);
3471
- // console.log(
3472
- // "merkle tree create transaction signature",
3473
- // res.signature.toString()
3474
- // );
3475
- // return new PublicKey(merkleTree.publicKey);
3476
- // }
3477
- static createMerkleTreeFromContract(env, privateKey, collectionSize, collectionId) {
3478
- return __async(this, null, function* () {
3479
- const rpc = RPC[env];
3480
- let depthSize = Math.ceil(Math.log2(collectionSize));
3481
- const { maxBufferSize, maxDepth } = VALID_SIZE_PAIR[depthSize];
3482
- const keypair = import_web36.Keypair.fromSecretKey(import_bytes.bs58.decode(privateKey));
3483
- const wallet = new import_anchor3.Wallet(keypair);
3484
- const connectionA = new import_web36.Connection(rpc);
3485
- const provider = new import_anchor3.AnchorProvider(connectionA, wallet, {
3486
- skipPreflight: true,
3487
- preflightCommitment: "confirmed"
3488
- });
3489
- const sendTransaction = (transaction, connection) => __async(this, null, function* () {
3490
- if (transaction instanceof import_web36.Transaction) {
3491
- let signature = yield (0, import_web36.sendAndConfirmTransaction)(
3492
- connection,
3493
- transaction,
3494
- [keypair]
3495
- );
3496
- console.log("sendAndConfrimTransaction : signature", signature);
3497
- return signature;
3498
- } else {
3499
- transaction.sign([keypair]);
3500
- let signature = yield connectionA.sendTransaction(transaction, {
3501
- skipPreflight: true,
3502
- preflightCommitment: "confirmed"
3503
- });
3504
- console.log("signature", signature);
3505
- return signature;
3506
- }
3507
- });
3508
- const flipmemeSDK = new FlipmemeSDK("solana" /* SOLANA */, {
3509
- provider,
3510
- wallet: wallet.publicKey,
3511
- sendTransaction
3512
- });
3513
- let merkleTreePubKey = yield flipmemeSDK.createMerkle(collectionId, maxBufferSize, maxDepth);
3514
- return merkleTreePubKey;
3515
- });
3516
- }
3517
- };
3518
3461
  // Annotate the CommonJS export names for ESM import in node:
3519
3462
  0 && (module.exports = {
3520
3463
  BlockchainType,
3464
+ ENV,
3521
3465
  FlipmemeSDK,
3522
3466
  PurcahseType,
3523
- Utility,
3467
+ RPC,
3468
+ SDK_SOLANA_CONFIG,
3469
+ SOLANA,
3470
+ SOLANA_PUBKEYS,
3471
+ VALID_SIZE_PAIR,
3524
3472
  isEthereumConfig,
3525
3473
  isSolanaConfig
3526
3474
  });