flipmeme-sdk 1.2.16 → 1.2.18
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 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +93 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -48,6 +48,10 @@ interface BuyParams {
|
|
|
48
48
|
baseUri: string;
|
|
49
49
|
reserveToken: ReserveToken | null;
|
|
50
50
|
}
|
|
51
|
+
interface NftInfo {
|
|
52
|
+
nftId: number;
|
|
53
|
+
nftOnwer: string;
|
|
54
|
+
}
|
|
51
55
|
interface BuyResponse {
|
|
52
56
|
buyer: string;
|
|
53
57
|
collectionAddress: string;
|
|
@@ -145,6 +149,7 @@ declare class FlipmemeSDK {
|
|
|
145
149
|
createLookupTableAndExtend(addressesToAdd: PublicKey[]): Promise<PublicKey>;
|
|
146
150
|
extendLookupTable(lookupTableAddress: PublicKey, addressesToAdd: PublicKey[], isInitial?: boolean): Promise<void>;
|
|
147
151
|
finalizeSale(collectionId: string): Promise<void>;
|
|
152
|
+
ejectNfts(collectionId: string, merkleTree: string, nftInfos: NftInfo[]): Promise<void>;
|
|
148
153
|
/**For testing */
|
|
149
154
|
getStateInfo(): Promise<{
|
|
150
155
|
admin: PublicKey;
|
|
@@ -223,6 +228,7 @@ declare const SDK_SOLANA_CONFIG: {
|
|
|
223
228
|
MINT_CHUNK_SIZE: number;
|
|
224
229
|
BUY_CHUNK_SIZE: number;
|
|
225
230
|
SELL_CHUNK_SIZE: number;
|
|
231
|
+
EJECT_CHUNK_SIZE: number;
|
|
226
232
|
};
|
|
227
233
|
declare const VALID_SIZE_PAIR: {
|
|
228
234
|
3: {
|
|
@@ -315,4 +321,4 @@ declare const VALID_SIZE_PAIR: {
|
|
|
315
321
|
};
|
|
316
322
|
};
|
|
317
323
|
|
|
318
|
-
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 };
|
|
324
|
+
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 NftInfo, 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
|
@@ -48,6 +48,10 @@ interface BuyParams {
|
|
|
48
48
|
baseUri: string;
|
|
49
49
|
reserveToken: ReserveToken | null;
|
|
50
50
|
}
|
|
51
|
+
interface NftInfo {
|
|
52
|
+
nftId: number;
|
|
53
|
+
nftOnwer: string;
|
|
54
|
+
}
|
|
51
55
|
interface BuyResponse {
|
|
52
56
|
buyer: string;
|
|
53
57
|
collectionAddress: string;
|
|
@@ -145,6 +149,7 @@ declare class FlipmemeSDK {
|
|
|
145
149
|
createLookupTableAndExtend(addressesToAdd: PublicKey[]): Promise<PublicKey>;
|
|
146
150
|
extendLookupTable(lookupTableAddress: PublicKey, addressesToAdd: PublicKey[], isInitial?: boolean): Promise<void>;
|
|
147
151
|
finalizeSale(collectionId: string): Promise<void>;
|
|
152
|
+
ejectNfts(collectionId: string, merkleTree: string, nftInfos: NftInfo[]): Promise<void>;
|
|
148
153
|
/**For testing */
|
|
149
154
|
getStateInfo(): Promise<{
|
|
150
155
|
admin: PublicKey;
|
|
@@ -223,6 +228,7 @@ declare const SDK_SOLANA_CONFIG: {
|
|
|
223
228
|
MINT_CHUNK_SIZE: number;
|
|
224
229
|
BUY_CHUNK_SIZE: number;
|
|
225
230
|
SELL_CHUNK_SIZE: number;
|
|
231
|
+
EJECT_CHUNK_SIZE: number;
|
|
226
232
|
};
|
|
227
233
|
declare const VALID_SIZE_PAIR: {
|
|
228
234
|
3: {
|
|
@@ -315,4 +321,4 @@ declare const VALID_SIZE_PAIR: {
|
|
|
315
321
|
};
|
|
316
322
|
};
|
|
317
323
|
|
|
318
|
-
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 };
|
|
324
|
+
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 NftInfo, 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
|
@@ -2246,9 +2246,10 @@ var SOLANA_PUBKEYS = {
|
|
|
2246
2246
|
RENT_TOKEN_ID: new import_web3.PublicKey(SOLANA.RENT_TOKEN_STR)
|
|
2247
2247
|
};
|
|
2248
2248
|
var SDK_SOLANA_CONFIG = {
|
|
2249
|
-
MINT_CHUNK_SIZE:
|
|
2250
|
-
BUY_CHUNK_SIZE:
|
|
2251
|
-
SELL_CHUNK_SIZE:
|
|
2249
|
+
MINT_CHUNK_SIZE: 4,
|
|
2250
|
+
BUY_CHUNK_SIZE: 2,
|
|
2251
|
+
SELL_CHUNK_SIZE: 2,
|
|
2252
|
+
EJECT_CHUNK_SIZE: 2
|
|
2252
2253
|
};
|
|
2253
2254
|
var VALID_SIZE_PAIR = {
|
|
2254
2255
|
3: { maxBufferSize: 8, maxDepth: 3 },
|
|
@@ -2390,7 +2391,7 @@ var getTradingAccounts = (collectionId, userPublicKey, programId, merkleTree, cr
|
|
|
2390
2391
|
});
|
|
2391
2392
|
|
|
2392
2393
|
// src/solana/index.ts
|
|
2393
|
-
var import_lodash2 = require("lodash");
|
|
2394
|
+
var import_lodash2 = __toESM(require("lodash"));
|
|
2394
2395
|
var import_decimal2 = __toESM(require("decimal.js"));
|
|
2395
2396
|
|
|
2396
2397
|
// src/solana/analyze.ts
|
|
@@ -2618,8 +2619,8 @@ var SolanaConnector = class {
|
|
|
2618
2619
|
name,
|
|
2619
2620
|
tokenUri,
|
|
2620
2621
|
totalSupply,
|
|
2621
|
-
new import_bn2.default(
|
|
2622
|
-
new import_bn2.default(
|
|
2622
|
+
new import_bn2.default(1e5),
|
|
2623
|
+
new import_bn2.default(1e7)
|
|
2623
2624
|
).accountsStrict({
|
|
2624
2625
|
state: SOLANA_PUBKEYS.STATE_ID,
|
|
2625
2626
|
collection: collectionPda2,
|
|
@@ -3099,6 +3100,79 @@ var SolanaConnector = class {
|
|
|
3099
3100
|
}
|
|
3100
3101
|
});
|
|
3101
3102
|
}
|
|
3103
|
+
ejectAllNftsOfCollection(collectionId, merkleTree, nftInfos) {
|
|
3104
|
+
return __async(this, null, function* () {
|
|
3105
|
+
if (!this.program) {
|
|
3106
|
+
throw new Error("Program not initialized");
|
|
3107
|
+
}
|
|
3108
|
+
const arr = import_lodash2.default.map(nftInfos, "nftId");
|
|
3109
|
+
let assets = yield getAssetsInfo(arr, merkleTree);
|
|
3110
|
+
const lookupTableAccounts = yield this.getLookupTableAccounts(
|
|
3111
|
+
SOLANA_PUBKEYS.LOOKUP_TABLE
|
|
3112
|
+
);
|
|
3113
|
+
const ejectTokens = (0, import_lodash2.sampleSize)(assets, nftInfos.length);
|
|
3114
|
+
const infoById = import_lodash2.default.mapValues(import_lodash2.default.keyBy(nftInfos, "nftId"), "nftOwner");
|
|
3115
|
+
const merkleTreeAcount = yield import_spl_account_compression.ConcurrentMerkleTreeAccount.fromAccountAddress(
|
|
3116
|
+
this.config.provider.connection,
|
|
3117
|
+
new import_web35.PublicKey(merkleTree)
|
|
3118
|
+
);
|
|
3119
|
+
const canopyDepth = merkleTreeAcount.getCanopyDepth();
|
|
3120
|
+
const tokenChunks = getTokenChunks(
|
|
3121
|
+
ejectTokens,
|
|
3122
|
+
SDK_SOLANA_CONFIG.EJECT_CHUNK_SIZE
|
|
3123
|
+
);
|
|
3124
|
+
let transactions = [];
|
|
3125
|
+
try {
|
|
3126
|
+
for (const chunk of tokenChunks) {
|
|
3127
|
+
let transaction = yield this.setUpInstructions(14e5);
|
|
3128
|
+
for (const token of chunk) {
|
|
3129
|
+
const { compression, proof, root } = token;
|
|
3130
|
+
const { treeConfigPda: treeConfigPda2, collectionPda: collectionPda2, nftHolderPda: nftHolderPda2 } = yield getTradingAccounts(
|
|
3131
|
+
collectionId,
|
|
3132
|
+
infoById[compression.leaf_id],
|
|
3133
|
+
this.program.programId,
|
|
3134
|
+
new import_web35.PublicKey(merkleTree),
|
|
3135
|
+
void 0
|
|
3136
|
+
);
|
|
3137
|
+
const proofPath = proof.map((node) => ({
|
|
3138
|
+
pubkey: new import_web35.PublicKey(node),
|
|
3139
|
+
isSigner: false,
|
|
3140
|
+
isWritable: false
|
|
3141
|
+
})).slice(0, proof.length - canopyDepth);
|
|
3142
|
+
const instruction = yield this.program.methods.ejectNft(
|
|
3143
|
+
compression.leaf_id,
|
|
3144
|
+
Array.from(new import_web35.PublicKey(root.trim()).toBytes()),
|
|
3145
|
+
Array.from(new import_web35.PublicKey(compression.data_hash.trim()).toBytes()),
|
|
3146
|
+
Array.from(
|
|
3147
|
+
new import_web35.PublicKey(compression.creator_hash.trim()).toBytes()
|
|
3148
|
+
),
|
|
3149
|
+
new import_bn2.default(compression.leaf_id),
|
|
3150
|
+
compression.leaf_id
|
|
3151
|
+
).accountsStrict({
|
|
3152
|
+
state: SOLANA_PUBKEYS.STATE_ID,
|
|
3153
|
+
merkleTreeConfig: treeConfigPda2,
|
|
3154
|
+
merkleTree: new import_web35.PublicKey(merkleTree),
|
|
3155
|
+
collection: collectionPda2,
|
|
3156
|
+
nftOwner: new import_web35.PublicKey(infoById[compression.leaf_id]),
|
|
3157
|
+
nftHolder: nftHolderPda2,
|
|
3158
|
+
operator: this.config.wallet,
|
|
3159
|
+
compressionProgram: SOLANA_PUBKEYS.SPL_ACCOUNT_COMPRESSION_ID,
|
|
3160
|
+
tokenMetadataProgram: SOLANA_PUBKEYS.TOKEN_METADATA_PROGRAM_ID,
|
|
3161
|
+
mplBubblegumProgram: SOLANA_PUBKEYS.MPL_BUBBLEGUM_ID,
|
|
3162
|
+
logWrapper: SOLANA_PUBKEYS.SPL_NOOP_ID,
|
|
3163
|
+
systemProgram: import_web35.SystemProgram.programId
|
|
3164
|
+
}).remainingAccounts(proofPath).instruction();
|
|
3165
|
+
transaction.add(instruction);
|
|
3166
|
+
}
|
|
3167
|
+
transactions.push(transaction);
|
|
3168
|
+
}
|
|
3169
|
+
const { signatures } = yield this.sendTxnForBatch(transactions, lookupTableAccounts);
|
|
3170
|
+
} catch (e) {
|
|
3171
|
+
console.log("ERRORR in getBuyInstructions", JSON.stringify(e));
|
|
3172
|
+
throw e;
|
|
3173
|
+
}
|
|
3174
|
+
});
|
|
3175
|
+
}
|
|
3102
3176
|
//for testing
|
|
3103
3177
|
getStateInfo() {
|
|
3104
3178
|
return __async(this, null, function* () {
|
|
@@ -3111,6 +3185,9 @@ var SolanaConnector = class {
|
|
|
3111
3185
|
return state;
|
|
3112
3186
|
});
|
|
3113
3187
|
}
|
|
3188
|
+
/**
|
|
3189
|
+
* not used for now. sendTxnForBatch function is used
|
|
3190
|
+
*/
|
|
3114
3191
|
//useSenTxn.ts
|
|
3115
3192
|
sendTxn(instructions, lookupTableAccounts) {
|
|
3116
3193
|
return __async(this, null, function* () {
|
|
@@ -3259,7 +3336,7 @@ var SolanaConnector = class {
|
|
|
3259
3336
|
const chunkSize = SDK_SOLANA_CONFIG.SELL_CHUNK_SIZE;
|
|
3260
3337
|
const tokenChunks = getTokenChunks(tokens, chunkSize);
|
|
3261
3338
|
const transactions = [];
|
|
3262
|
-
const { treeConfigPda: treeConfigPda2, collectionPda: collectionPda2, nftHolderPda: nftHolderPda2
|
|
3339
|
+
const { treeConfigPda: treeConfigPda2, collectionPda: collectionPda2, nftHolderPda: nftHolderPda2 } = yield getTradingAccounts(
|
|
3263
3340
|
collectionId,
|
|
3264
3341
|
userPublicKey,
|
|
3265
3342
|
this.program.programId,
|
|
@@ -3598,6 +3675,15 @@ var FlipmemeSDK = class {
|
|
|
3598
3675
|
}
|
|
3599
3676
|
});
|
|
3600
3677
|
}
|
|
3678
|
+
ejectNfts(collectionId, merkleTree, nftInfos) {
|
|
3679
|
+
return __async(this, null, function* () {
|
|
3680
|
+
if (this.blockchainType === "solana" /* SOLANA */ && this.solana) {
|
|
3681
|
+
yield this.solana.ejectAllNftsOfCollection(collectionId, merkleTree, nftInfos);
|
|
3682
|
+
} else {
|
|
3683
|
+
throw new Error("Cannot call this function");
|
|
3684
|
+
}
|
|
3685
|
+
});
|
|
3686
|
+
}
|
|
3601
3687
|
/**For testing */
|
|
3602
3688
|
getStateInfo() {
|
|
3603
3689
|
return __async(this, null, function* () {
|