flipmeme-sdk 1.1.0 → 1.1.2
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 +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +38 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -38,9 +38,14 @@ interface NFTTradingData {
|
|
|
38
38
|
tokenURI: string;
|
|
39
39
|
symbol?: string;
|
|
40
40
|
}
|
|
41
|
+
interface NFTMintData {
|
|
42
|
+
name: string;
|
|
43
|
+
tokenBaseUri: string;
|
|
44
|
+
symbol?: string;
|
|
45
|
+
}
|
|
41
46
|
interface ReserveToken {
|
|
42
47
|
buy: NFTTradingData[] | null;
|
|
43
|
-
mintAndBuy:
|
|
48
|
+
mintAndBuy: NFTMintData[] | null;
|
|
44
49
|
}
|
|
45
50
|
interface BuyParams {
|
|
46
51
|
collectionId: string;
|
|
@@ -128,7 +133,6 @@ declare class FlipmemeSDK {
|
|
|
128
133
|
};
|
|
129
134
|
creator: _solana_web3_js.PublicKey;
|
|
130
135
|
totalSol: bn_js;
|
|
131
|
-
totalSupply: number;
|
|
132
136
|
mintCount: number;
|
|
133
137
|
id: number;
|
|
134
138
|
sellerFeeBasisPoints: number;
|
|
@@ -137,11 +141,10 @@ declare class FlipmemeSDK {
|
|
|
137
141
|
isPaused: number;
|
|
138
142
|
bump: number;
|
|
139
143
|
collectionNftBump: number;
|
|
140
|
-
padding: number[];
|
|
141
144
|
};
|
|
142
145
|
collectionAddress: _solana_web3_js.PublicKey;
|
|
143
146
|
}>;
|
|
144
147
|
getTransactionTest(signature: string): Promise<BuyResponse[]>;
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
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 };
|
|
150
|
+
export { BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, type CollectionInfo, type CollectionParams, type CreateCollectionResponse, type EthereumConfig, FlipmemeSDK, type NFTMintData, type NFTTradingData, type ProfileSellParams, type ReserveToken, type SellParams, type SellResponse, type SolanaConfig, isEthereumConfig, isSolanaConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -38,9 +38,14 @@ interface NFTTradingData {
|
|
|
38
38
|
tokenURI: string;
|
|
39
39
|
symbol?: string;
|
|
40
40
|
}
|
|
41
|
+
interface NFTMintData {
|
|
42
|
+
name: string;
|
|
43
|
+
tokenBaseUri: string;
|
|
44
|
+
symbol?: string;
|
|
45
|
+
}
|
|
41
46
|
interface ReserveToken {
|
|
42
47
|
buy: NFTTradingData[] | null;
|
|
43
|
-
mintAndBuy:
|
|
48
|
+
mintAndBuy: NFTMintData[] | null;
|
|
44
49
|
}
|
|
45
50
|
interface BuyParams {
|
|
46
51
|
collectionId: string;
|
|
@@ -128,7 +133,6 @@ declare class FlipmemeSDK {
|
|
|
128
133
|
};
|
|
129
134
|
creator: _solana_web3_js.PublicKey;
|
|
130
135
|
totalSol: bn_js;
|
|
131
|
-
totalSupply: number;
|
|
132
136
|
mintCount: number;
|
|
133
137
|
id: number;
|
|
134
138
|
sellerFeeBasisPoints: number;
|
|
@@ -137,11 +141,10 @@ declare class FlipmemeSDK {
|
|
|
137
141
|
isPaused: number;
|
|
138
142
|
bump: number;
|
|
139
143
|
collectionNftBump: number;
|
|
140
|
-
padding: number[];
|
|
141
144
|
};
|
|
142
145
|
collectionAddress: _solana_web3_js.PublicKey;
|
|
143
146
|
}>;
|
|
144
147
|
getTransactionTest(signature: string): Promise<BuyResponse[]>;
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
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 };
|
|
150
|
+
export { BlockchainType, type BuyCreditParams, type BuyParams, type BuyResponse, type CollectionInfo, type CollectionParams, type CreateCollectionResponse, type EthereumConfig, FlipmemeSDK, type NFTMintData, type NFTTradingData, type ProfileSellParams, type ReserveToken, type SellParams, type SellResponse, type SolanaConfig, isEthereumConfig, isSolanaConfig };
|
package/dist/index.js
CHANGED
|
@@ -1854,7 +1854,7 @@ var SOLANA = {
|
|
|
1854
1854
|
TREASURY_ID_STR: "5VmcDuGTMMxFfcZB1W7AsARSbcswvM2wq7NENqaRV9eu",
|
|
1855
1855
|
LP_PROVISIONER_ID_STR: "5VmcDuGTMMxFfcZB1W7AsARSbcswvM2wq7NENqaRV9eu",
|
|
1856
1856
|
TOKEN_METADATA_PROGRAM_ID_STR: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",
|
|
1857
|
-
EVENT_AUTHORITY_ID_STR: "
|
|
1857
|
+
EVENT_AUTHORITY_ID_STR: "GB1KPin8XL9kgMu4hTVxx6Gz6mb8ZM3K66TdBPNjAbqc",
|
|
1858
1858
|
MPL_CORE_STR: "CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d",
|
|
1859
1859
|
ADMIN_FOR_CREDIT_BUY_STR: "9pFpgiw5MUcMX3Tdjt8KmvmdphfykPqo8QDLpk2fjhBo"
|
|
1860
1860
|
};
|
|
@@ -1873,7 +1873,7 @@ var SDK_SOLANA_CONFIG = {
|
|
|
1873
1873
|
// src/solana/index.ts
|
|
1874
1874
|
var import_web34 = require("@solana/web3.js");
|
|
1875
1875
|
var import_bytes = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
|
|
1876
|
-
var import_bn = require("bn.js");
|
|
1876
|
+
var import_bn = __toESM(require("bn.js"));
|
|
1877
1877
|
|
|
1878
1878
|
// src/solana/accounts.ts
|
|
1879
1879
|
var import_web32 = require("@solana/web3.js");
|
|
@@ -2116,8 +2116,8 @@ var SolanaConnector = class {
|
|
|
2116
2116
|
name,
|
|
2117
2117
|
tokenUri,
|
|
2118
2118
|
totalSupply,
|
|
2119
|
-
new import_bn.
|
|
2120
|
-
new import_bn.
|
|
2119
|
+
new import_bn.default(1e7),
|
|
2120
|
+
new import_bn.default(1e9)
|
|
2121
2121
|
).accounts({
|
|
2122
2122
|
state: SOLANA_PUBKEYS.STATE_ID,
|
|
2123
2123
|
//@ts-ignore
|
|
@@ -2165,7 +2165,7 @@ var SolanaConnector = class {
|
|
|
2165
2165
|
//useBuy.ts
|
|
2166
2166
|
buy(params) {
|
|
2167
2167
|
return __async(this, null, function* () {
|
|
2168
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
2168
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2169
2169
|
if (!this.program) {
|
|
2170
2170
|
throw new Error("Program not initialized");
|
|
2171
2171
|
}
|
|
@@ -2183,7 +2183,7 @@ var SolanaConnector = class {
|
|
|
2183
2183
|
SOLANA_PUBKEYS.STATE_ID
|
|
2184
2184
|
);
|
|
2185
2185
|
const successTxns = [];
|
|
2186
|
-
const
|
|
2186
|
+
const faildTradingItem = [];
|
|
2187
2187
|
const instructionsChunks = [];
|
|
2188
2188
|
if ((_c = reserveToken.buy) == null ? void 0 : _c.length) {
|
|
2189
2189
|
try {
|
|
@@ -2194,12 +2194,15 @@ var SolanaConnector = class {
|
|
|
2194
2194
|
);
|
|
2195
2195
|
instructionsChunks.push(...buyInstructionsChunks);
|
|
2196
2196
|
} catch (error) {
|
|
2197
|
-
|
|
2198
|
-
(_d = params.notify) == null ? void 0 : _d.onFailed(
|
|
2197
|
+
faildTradingItem.push(...reserveToken.buy);
|
|
2198
|
+
(_d = params.notify) == null ? void 0 : _d.onFailed(faildTradingItem, quantity);
|
|
2199
2199
|
console.error("Failed to getBuyInstructions", { error });
|
|
2200
2200
|
}
|
|
2201
2201
|
}
|
|
2202
|
+
const faildMinting = [];
|
|
2202
2203
|
if ((_e = reserveToken.mintAndBuy) == null ? void 0 : _e.length) {
|
|
2204
|
+
let collectionInfo = yield this.getCollectionInfo(collectionId);
|
|
2205
|
+
let firstTokenId = collectionInfo.collectionInfo.mintCount;
|
|
2203
2206
|
try {
|
|
2204
2207
|
const mintAndBuyInstructionsChunks = yield this.getMintAndBuyInstructions(
|
|
2205
2208
|
this.config.wallet,
|
|
@@ -2207,12 +2210,12 @@ var SolanaConnector = class {
|
|
|
2207
2210
|
collectionSymbol,
|
|
2208
2211
|
creatorAddress,
|
|
2209
2212
|
reserveToken.mintAndBuy,
|
|
2210
|
-
stateAccount
|
|
2213
|
+
stateAccount,
|
|
2214
|
+
firstTokenId
|
|
2211
2215
|
);
|
|
2212
2216
|
instructionsChunks.push(...mintAndBuyInstructionsChunks);
|
|
2213
2217
|
} catch (error) {
|
|
2214
|
-
|
|
2215
|
-
(_f = params.notify) == null ? void 0 : _f.onFailed(failedItems, quantity);
|
|
2218
|
+
(_f = params.notify) == null ? void 0 : _f.onFailed(faildMinting, quantity);
|
|
2216
2219
|
console.error("Failed to getMintAndBuyInstructions", { error });
|
|
2217
2220
|
}
|
|
2218
2221
|
}
|
|
@@ -2245,8 +2248,6 @@ var SolanaConnector = class {
|
|
|
2245
2248
|
buyResponse.push(...itemBuyResponse);
|
|
2246
2249
|
}
|
|
2247
2250
|
} catch (e) {
|
|
2248
|
-
failedItems.push(...items);
|
|
2249
|
-
(_h = params.notify) == null ? void 0 : _h.onFailed(failedItems, quantity);
|
|
2250
2251
|
console.error("Buy failed:", JSON.stringify(e), { items });
|
|
2251
2252
|
throw e;
|
|
2252
2253
|
}
|
|
@@ -2373,19 +2374,6 @@ var SolanaConnector = class {
|
|
|
2373
2374
|
);
|
|
2374
2375
|
});
|
|
2375
2376
|
}
|
|
2376
|
-
//for testing
|
|
2377
|
-
getStateInfo() {
|
|
2378
|
-
return __async(this, null, function* () {
|
|
2379
|
-
if (!this.program) {
|
|
2380
|
-
throw new Error("Program not initialized");
|
|
2381
|
-
}
|
|
2382
|
-
const state = yield this.program.account.state.fetch(
|
|
2383
|
-
SOLANA_PUBKEYS.STATE_ID
|
|
2384
|
-
);
|
|
2385
|
-
return state;
|
|
2386
|
-
});
|
|
2387
|
-
}
|
|
2388
|
-
//for testing
|
|
2389
2377
|
getCollectionInfo(collectionId) {
|
|
2390
2378
|
return __async(this, null, function* () {
|
|
2391
2379
|
if (!this.program) {
|
|
@@ -2401,6 +2389,18 @@ var SolanaConnector = class {
|
|
|
2401
2389
|
return { collectionInfo, collectionAddress };
|
|
2402
2390
|
});
|
|
2403
2391
|
}
|
|
2392
|
+
//for testing
|
|
2393
|
+
getStateInfo() {
|
|
2394
|
+
return __async(this, null, function* () {
|
|
2395
|
+
if (!this.program) {
|
|
2396
|
+
throw new Error("Program not initialized");
|
|
2397
|
+
}
|
|
2398
|
+
const state = yield this.program.account.state.fetch(
|
|
2399
|
+
SOLANA_PUBKEYS.STATE_ID
|
|
2400
|
+
);
|
|
2401
|
+
return state;
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
2404
|
//useSenTxn.ts
|
|
2405
2405
|
sendTxn(instructions) {
|
|
2406
2406
|
return __async(this, null, function* () {
|
|
@@ -2521,7 +2521,7 @@ var SolanaConnector = class {
|
|
|
2521
2521
|
}
|
|
2522
2522
|
});
|
|
2523
2523
|
}
|
|
2524
|
-
getMintAndBuyInstructions(userPublicKey, collectionId, collectionSymbol, creatorAddress, tokens, stateAccount) {
|
|
2524
|
+
getMintAndBuyInstructions(userPublicKey, collectionId, collectionSymbol, creatorAddress, tokens, stateAccount, firstTokenId) {
|
|
2525
2525
|
return __async(this, null, function* () {
|
|
2526
2526
|
if (!this.program) {
|
|
2527
2527
|
throw new Error("Program not initialized");
|
|
@@ -2535,15 +2535,17 @@ var SolanaConnector = class {
|
|
|
2535
2535
|
this.program.programId,
|
|
2536
2536
|
creatorAddress
|
|
2537
2537
|
);
|
|
2538
|
+
let tokenId = firstTokenId;
|
|
2538
2539
|
try {
|
|
2539
2540
|
for (const chunk of tokenChunks) {
|
|
2540
2541
|
const instructions = yield this.setUpInstructions(
|
|
2541
2542
|
35e4 * chunk.length
|
|
2542
2543
|
);
|
|
2544
|
+
let data = [];
|
|
2543
2545
|
for (const token of chunk) {
|
|
2544
|
-
const { name,
|
|
2546
|
+
const { name, tokenBaseUri } = token;
|
|
2545
2547
|
const { nftPda: nftPda2, collectionPda: collectionPda2, nftHolderPda: nftHolderPda2, collectionNftPda: collectionNftPda2 } = yield getNftAccounts(tokenId);
|
|
2546
|
-
const instruction = yield this.program.methods.mintAndBuy(name,
|
|
2548
|
+
const instruction = yield this.program.methods.mintAndBuy(name, `${tokenBaseUri}/${tokenId}.json`).accountsStrict({
|
|
2547
2549
|
state: SOLANA_PUBKEYS.STATE_ID,
|
|
2548
2550
|
treasury: stateAccount.treasury,
|
|
2549
2551
|
buyer: userPublicKey,
|
|
@@ -2557,8 +2559,14 @@ var SolanaConnector = class {
|
|
|
2557
2559
|
eventAuthority: SOLANA_PUBKEYS.EVENT_AUTHORITY_ID
|
|
2558
2560
|
}).instruction();
|
|
2559
2561
|
instructions.push(instruction);
|
|
2562
|
+
data.push({
|
|
2563
|
+
name,
|
|
2564
|
+
tokenURI: `${tokenBaseUri}/${tokenId}.json`,
|
|
2565
|
+
tokenId
|
|
2566
|
+
});
|
|
2567
|
+
tokenId++;
|
|
2560
2568
|
}
|
|
2561
|
-
allInstructionSets.push([instructions,
|
|
2569
|
+
allInstructionSets.push([instructions, data]);
|
|
2562
2570
|
}
|
|
2563
2571
|
return allInstructionSets;
|
|
2564
2572
|
} catch (e) {
|