flipmeme-sdk 1.2.0 → 1.2.1
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 +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +31 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -52
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -44,7 +44,7 @@ interface NFTMintData {
|
|
|
44
44
|
}
|
|
45
45
|
interface ReserveToken {
|
|
46
46
|
buy: NFTTradingData[] | null;
|
|
47
|
-
mintAndBuy:
|
|
47
|
+
mintAndBuy: string[] | null;
|
|
48
48
|
}
|
|
49
49
|
interface BuyParams {
|
|
50
50
|
merkleTree: PublicKey;
|
|
@@ -54,12 +54,10 @@ interface BuyParams {
|
|
|
54
54
|
quantity: number;
|
|
55
55
|
baseUri: string;
|
|
56
56
|
reserveToken: ReserveToken | null;
|
|
57
|
-
notify: any | undefined;
|
|
58
57
|
}
|
|
59
58
|
interface BuyResponse {
|
|
60
59
|
buyer: string;
|
|
61
60
|
collectionAddress: string;
|
|
62
|
-
nftAddress: string;
|
|
63
61
|
tokenId: string;
|
|
64
62
|
tokenName?: string;
|
|
65
63
|
tokenUri?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ interface NFTMintData {
|
|
|
44
44
|
}
|
|
45
45
|
interface ReserveToken {
|
|
46
46
|
buy: NFTTradingData[] | null;
|
|
47
|
-
mintAndBuy:
|
|
47
|
+
mintAndBuy: string[] | null;
|
|
48
48
|
}
|
|
49
49
|
interface BuyParams {
|
|
50
50
|
merkleTree: PublicKey;
|
|
@@ -54,12 +54,10 @@ interface BuyParams {
|
|
|
54
54
|
quantity: number;
|
|
55
55
|
baseUri: string;
|
|
56
56
|
reserveToken: ReserveToken | null;
|
|
57
|
-
notify: any | undefined;
|
|
58
57
|
}
|
|
59
58
|
interface BuyResponse {
|
|
60
59
|
buyer: string;
|
|
61
60
|
collectionAddress: string;
|
|
62
|
-
nftAddress: string;
|
|
63
61
|
tokenId: string;
|
|
64
62
|
tokenName?: string;
|
|
65
63
|
tokenUri?: string;
|
package/dist/index.js
CHANGED
|
@@ -2296,7 +2296,7 @@ var SOLANA_PUBKEYS = {
|
|
|
2296
2296
|
RENT_TOKEN_ID: new import_web3.PublicKey(SOLANA.RENT_TOKEN_STR)
|
|
2297
2297
|
};
|
|
2298
2298
|
var SDK_SOLANA_CONFIG = {
|
|
2299
|
-
CHUNK_SIZE:
|
|
2299
|
+
CHUNK_SIZE: 5
|
|
2300
2300
|
};
|
|
2301
2301
|
var VALID_SIZE_PAIR = {
|
|
2302
2302
|
3: { maxBufferSize: 8, maxDepth: 3 },
|
|
@@ -2465,7 +2465,6 @@ function analyzeBuyTransaction(program, transactionData) {
|
|
|
2465
2465
|
buyResponse.push({
|
|
2466
2466
|
buyer: decodedData.data.buyer.toString(),
|
|
2467
2467
|
collectionAddress: decodedData.data.collection.toString(),
|
|
2468
|
-
nftAddress: decodedData.data.nft.toString(),
|
|
2469
2468
|
tokenId: decodedData.data.tokenId.toString(),
|
|
2470
2469
|
tokenName: decodedData.data.name.toString(),
|
|
2471
2470
|
tokenUri: decodedData.data.uri.toString(),
|
|
@@ -2482,7 +2481,6 @@ function analyzeBuyTransaction(program, transactionData) {
|
|
|
2482
2481
|
buyResponse.push({
|
|
2483
2482
|
buyer: decodedData.data.buyer.toString(),
|
|
2484
2483
|
collectionAddress: decodedData.data.collection.toString(),
|
|
2485
|
-
nftAddress: decodedData.data.nft.toString(),
|
|
2486
2484
|
tokenId: decodedData.data.tokenId.toString(),
|
|
2487
2485
|
price: decodedData.data.price.toString(),
|
|
2488
2486
|
nextPrice: decodedData.data.nextPrice.toString(),
|
|
@@ -2683,7 +2681,7 @@ var SolanaConnector = class {
|
|
|
2683
2681
|
//useBuy.ts
|
|
2684
2682
|
buy(params) {
|
|
2685
2683
|
return __async(this, null, function* () {
|
|
2686
|
-
var _a, _b, _c, _d
|
|
2684
|
+
var _a, _b, _c, _d;
|
|
2687
2685
|
if (!this.program) {
|
|
2688
2686
|
throw new Error("Program not initialized");
|
|
2689
2687
|
}
|
|
@@ -2693,13 +2691,12 @@ var SolanaConnector = class {
|
|
|
2693
2691
|
creatorAddress,
|
|
2694
2692
|
quantity,
|
|
2695
2693
|
reserveToken,
|
|
2696
|
-
merkleTree
|
|
2694
|
+
merkleTree,
|
|
2695
|
+
baseUri
|
|
2697
2696
|
} = params;
|
|
2698
2697
|
if (!reserveToken || ((_a = reserveToken.mintAndBuy) == null ? void 0 : _a.length) === 0 && ((_b = reserveToken.buy) == null ? void 0 : _b.length) === 0) {
|
|
2699
2698
|
throw new Error("No available token to buy");
|
|
2700
2699
|
}
|
|
2701
|
-
const successTxns = [];
|
|
2702
|
-
const faildTradingItem = [];
|
|
2703
2700
|
const instructionsChunks = [];
|
|
2704
2701
|
if ((_c = reserveToken.buy) == null ? void 0 : _c.length) {
|
|
2705
2702
|
try {
|
|
@@ -2710,24 +2707,22 @@ var SolanaConnector = class {
|
|
|
2710
2707
|
);
|
|
2711
2708
|
instructionsChunks.push(...buyInstructionsChunks);
|
|
2712
2709
|
} catch (error) {
|
|
2713
|
-
faildTradingItem.push(...reserveToken.buy);
|
|
2714
|
-
(_d = params.notify) == null ? void 0 : _d.onFailed(faildTradingItem, quantity);
|
|
2715
2710
|
console.error("Failed to getBuyInstructions", { error });
|
|
2716
2711
|
}
|
|
2717
2712
|
}
|
|
2718
2713
|
const faildMinting = [];
|
|
2719
|
-
if ((
|
|
2714
|
+
if ((_d = reserveToken.mintAndBuy) == null ? void 0 : _d.length) {
|
|
2720
2715
|
try {
|
|
2721
2716
|
const mintAndBuyInstructionsChunks = yield this.getMintAndBuyInstructions(
|
|
2722
2717
|
this.config.wallet,
|
|
2723
2718
|
collectionId,
|
|
2724
2719
|
creatorAddress,
|
|
2725
2720
|
reserveToken.mintAndBuy,
|
|
2721
|
+
baseUri,
|
|
2726
2722
|
merkleTree
|
|
2727
2723
|
);
|
|
2728
2724
|
instructionsChunks.push(...mintAndBuyInstructionsChunks);
|
|
2729
2725
|
} catch (error) {
|
|
2730
|
-
(_f = params.notify) == null ? void 0 : _f.onFailed(faildMinting, quantity);
|
|
2731
2726
|
console.error("Failed to getMintAndBuyInstructions", { error });
|
|
2732
2727
|
}
|
|
2733
2728
|
}
|
|
@@ -2736,12 +2731,6 @@ var SolanaConnector = class {
|
|
|
2736
2731
|
for (const [instructions, items] of instructionsChunks) {
|
|
2737
2732
|
try {
|
|
2738
2733
|
const { signature, latestBlockhash } = yield this.sendTxn(instructions);
|
|
2739
|
-
successTxns.push({ items, signature });
|
|
2740
|
-
(_g = params.notify) == null ? void 0 : _g.onSuccess(
|
|
2741
|
-
successTxns.map((txn) => txn.items).flat(),
|
|
2742
|
-
quantity,
|
|
2743
|
-
signature
|
|
2744
|
-
);
|
|
2745
2734
|
const confirmResult = yield this.config.provider.connection.confirmTransaction({
|
|
2746
2735
|
blockhash: latestBlockhash.blockhash,
|
|
2747
2736
|
lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
|
|
@@ -3140,7 +3129,7 @@ var SolanaConnector = class {
|
|
|
3140
3129
|
}
|
|
3141
3130
|
});
|
|
3142
3131
|
}
|
|
3143
|
-
getMintAndBuyInstructions(userPublicKey, collectionId, creatorAddress, tokens, merkleTree) {
|
|
3132
|
+
getMintAndBuyInstructions(userPublicKey, collectionId, creatorAddress, tokens, baseUri, merkleTree) {
|
|
3144
3133
|
return __async(this, null, function* () {
|
|
3145
3134
|
if (!this.program) {
|
|
3146
3135
|
throw new Error("Program not initialized");
|
|
@@ -3169,40 +3158,30 @@ var SolanaConnector = class {
|
|
|
3169
3158
|
for (const chunk of tokenChunks) {
|
|
3170
3159
|
const instructions = yield this.setUpInstructions(14e5);
|
|
3171
3160
|
let data = [];
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
eventAuthority: eventAuthority(this.program.programId),
|
|
3197
|
-
program: this.program.programId
|
|
3198
|
-
}).instruction();
|
|
3199
|
-
instructions.push(instruction);
|
|
3200
|
-
data.push({
|
|
3201
|
-
name,
|
|
3202
|
-
tokenURI: `test`,
|
|
3203
|
-
tokenId: 1
|
|
3204
|
-
});
|
|
3205
|
-
}
|
|
3161
|
+
const instruction = yield this.program.methods.mintAndBuy(chunk, baseUri).accountsStrict({
|
|
3162
|
+
state: SOLANA_PUBKEYS.STATE_ID,
|
|
3163
|
+
merkleTreeConfig: treeConfigPda2,
|
|
3164
|
+
treeCreatorOrDelegate: treeCreator,
|
|
3165
|
+
nftHolder: nftHolderPda2,
|
|
3166
|
+
merkleTree,
|
|
3167
|
+
collection: collectionPda2,
|
|
3168
|
+
collectionNft: collectionNftPda2,
|
|
3169
|
+
collectionMint: collectionMintPda2,
|
|
3170
|
+
collectionMetadata: collectionMetaDataPda,
|
|
3171
|
+
collectionEdition: collectionEditionPda,
|
|
3172
|
+
bubblegumSigner,
|
|
3173
|
+
logWrapper: SOLANA_PUBKEYS.SPL_NOOP_ID,
|
|
3174
|
+
compressionProgram: SOLANA_PUBKEYS.SPL_ACCOUNT_COMPRESSION_ID,
|
|
3175
|
+
tokenMetadataProgram: SOLANA_PUBKEYS.TOKEN_METADATA_PROGRAM_ID,
|
|
3176
|
+
mplBubblegumProgram: SOLANA_PUBKEYS.MPL_BUBBLEGUM_ID,
|
|
3177
|
+
treasury: SOLANA_PUBKEYS.TREASURY_ID,
|
|
3178
|
+
buyer: userPublicKey,
|
|
3179
|
+
systemProgram: import_web34.SystemProgram.programId,
|
|
3180
|
+
eventAuthority: eventAuthority(this.program.programId),
|
|
3181
|
+
program: this.program.programId
|
|
3182
|
+
}).instruction();
|
|
3183
|
+
instructions.push(instruction);
|
|
3184
|
+
data.push(...chunk);
|
|
3206
3185
|
allInstructionSets.push([instructions, data]);
|
|
3207
3186
|
}
|
|
3208
3187
|
return allInstructionSets;
|