flipmeme-sdk 1.3.24 → 1.3.26
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 +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +80 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -14,9 +14,9 @@ interface EthereumConfig {
|
|
|
14
14
|
}
|
|
15
15
|
interface SolanaConfig {
|
|
16
16
|
provider: AnchorProvider;
|
|
17
|
-
wallet
|
|
18
|
-
sendTransaction
|
|
19
|
-
signAllTransactions
|
|
17
|
+
wallet?: PublicKey | undefined;
|
|
18
|
+
sendTransaction?: (transaction: Transaction | VersionedTransaction, connection: Connection, options?: SendTransactionOptions) => Promise<TransactionSignature>;
|
|
19
|
+
signAllTransactions?: (txs: Array<Transaction | VersionedTransaction>) => Promise<Array<Transaction | VersionedTransaction>>;
|
|
20
20
|
}
|
|
21
21
|
interface CollectionParams {
|
|
22
22
|
sessionId: string;
|
|
@@ -397,4 +397,9 @@ declare function placeTensorCollectionBid(price: number, quantity: number, colle
|
|
|
397
397
|
|
|
398
398
|
declare function decodeStr(str: string): string;
|
|
399
399
|
|
|
400
|
-
|
|
400
|
+
/**
|
|
401
|
+
* this function only works for solana mainnet. So don't need to get connection as parameter
|
|
402
|
+
*/
|
|
403
|
+
declare function placeMagicEdenCollectionBid(price: number, quantity: number, collectionMint: string, privateKey: string, magicApiKey: string): Promise<String | undefined>;
|
|
404
|
+
|
|
405
|
+
export { type AssetData, type AssetInfo, BlockchainType, 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, PLATFORM, type ProfileSellParams, PurcahseType, RPC, type ReserveToken, type SDKSignature, type SDKTransaction, SDK_SOLANA_CONFIG, SOLANA_COMMON, SOLANA_DEV, SOLANA_MAIN, SOLANA_PUBKEYS, SOLANA_PUBKEYS_DEV, SOLANA_PUBKEYS_STAGE, SOLANA_STAGE, type SellData, type SellParams, type SellResponse, type SolanaConfig, type TransferParams, VALID_SIZE_PAIR, decodeStr, isEthereumConfig, isSolanaConfig, placeMagicEdenCollectionBid, placeTensorCollectionBid };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,9 +14,9 @@ interface EthereumConfig {
|
|
|
14
14
|
}
|
|
15
15
|
interface SolanaConfig {
|
|
16
16
|
provider: AnchorProvider;
|
|
17
|
-
wallet
|
|
18
|
-
sendTransaction
|
|
19
|
-
signAllTransactions
|
|
17
|
+
wallet?: PublicKey | undefined;
|
|
18
|
+
sendTransaction?: (transaction: Transaction | VersionedTransaction, connection: Connection, options?: SendTransactionOptions) => Promise<TransactionSignature>;
|
|
19
|
+
signAllTransactions?: (txs: Array<Transaction | VersionedTransaction>) => Promise<Array<Transaction | VersionedTransaction>>;
|
|
20
20
|
}
|
|
21
21
|
interface CollectionParams {
|
|
22
22
|
sessionId: string;
|
|
@@ -397,4 +397,9 @@ declare function placeTensorCollectionBid(price: number, quantity: number, colle
|
|
|
397
397
|
|
|
398
398
|
declare function decodeStr(str: string): string;
|
|
399
399
|
|
|
400
|
-
|
|
400
|
+
/**
|
|
401
|
+
* this function only works for solana mainnet. So don't need to get connection as parameter
|
|
402
|
+
*/
|
|
403
|
+
declare function placeMagicEdenCollectionBid(price: number, quantity: number, collectionMint: string, privateKey: string, magicApiKey: string): Promise<String | undefined>;
|
|
404
|
+
|
|
405
|
+
export { type AssetData, type AssetInfo, BlockchainType, 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, PLATFORM, type ProfileSellParams, PurcahseType, RPC, type ReserveToken, type SDKSignature, type SDKTransaction, SDK_SOLANA_CONFIG, SOLANA_COMMON, SOLANA_DEV, SOLANA_MAIN, SOLANA_PUBKEYS, SOLANA_PUBKEYS_DEV, SOLANA_PUBKEYS_STAGE, SOLANA_STAGE, type SellData, type SellParams, type SellResponse, type SolanaConfig, type TransferParams, VALID_SIZE_PAIR, decodeStr, isEthereumConfig, isSolanaConfig, placeMagicEdenCollectionBid, placeTensorCollectionBid };
|
package/dist/index.js
CHANGED
|
@@ -83,6 +83,7 @@ __export(index_exports, {
|
|
|
83
83
|
decodeStr: () => decodeStr,
|
|
84
84
|
isEthereumConfig: () => isEthereumConfig,
|
|
85
85
|
isSolanaConfig: () => isSolanaConfig,
|
|
86
|
+
placeMagicEdenCollectionBid: () => placeMagicEdenCollectionBid,
|
|
86
87
|
placeTensorCollectionBid: () => placeTensorCollectionBid
|
|
87
88
|
});
|
|
88
89
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -115,7 +116,7 @@ function isEthereumConfig(config) {
|
|
|
115
116
|
return "chainId" in config;
|
|
116
117
|
}
|
|
117
118
|
function isSolanaConfig(config) {
|
|
118
|
-
return "
|
|
119
|
+
return "provider" in config;
|
|
119
120
|
}
|
|
120
121
|
var PurcahseType = /* @__PURE__ */ ((PurcahseType3) => {
|
|
121
122
|
PurcahseType3["BUY"] = "buy";
|
|
@@ -5458,6 +5459,83 @@ function placeTensorCollectionBid(price, quantity, collectionMint, privateKey, t
|
|
|
5458
5459
|
}
|
|
5459
5460
|
});
|
|
5460
5461
|
}
|
|
5462
|
+
|
|
5463
|
+
// src/solana/magic_eden.ts
|
|
5464
|
+
var import_bytes4 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
|
|
5465
|
+
var import_web36 = require("@solana/web3.js");
|
|
5466
|
+
var import_axios2 = __toESM(require("axios"));
|
|
5467
|
+
var cheerio = __toESM(require("cheerio"));
|
|
5468
|
+
var MAGIC_EDEN_URI = "https://magiceden.us/marketplace/";
|
|
5469
|
+
function getCollectionSymbol(collectionMint) {
|
|
5470
|
+
return __async(this, null, function* () {
|
|
5471
|
+
const symbols = [];
|
|
5472
|
+
const { data } = yield import_axios2.default.get(`${MAGIC_EDEN_URI}/${collectionMint}`);
|
|
5473
|
+
const $ = cheerio.load(data);
|
|
5474
|
+
$("head link").each((i, el) => {
|
|
5475
|
+
const href = $(el).attr("href");
|
|
5476
|
+
if (href && href.includes(MAGIC_EDEN_URI)) {
|
|
5477
|
+
symbols.push(href.replace(MAGIC_EDEN_URI, ""));
|
|
5478
|
+
}
|
|
5479
|
+
});
|
|
5480
|
+
if (symbols.length > 0) {
|
|
5481
|
+
return symbols[0];
|
|
5482
|
+
}
|
|
5483
|
+
return void 0;
|
|
5484
|
+
});
|
|
5485
|
+
}
|
|
5486
|
+
function placeMagicEdenCollectionBid(price, quantity, collectionMint, privateKey, magicApiKey) {
|
|
5487
|
+
return __async(this, null, function* () {
|
|
5488
|
+
try {
|
|
5489
|
+
const collectionSymbol = yield getCollectionSymbol(collectionMint);
|
|
5490
|
+
console.log("==========collection Symbol=========", collectionSymbol);
|
|
5491
|
+
if (collectionSymbol == void 0) return void 0;
|
|
5492
|
+
const keypair = import_web36.Keypair.fromSecretKey(import_bytes4.bs58.decode(decodeStr(privateKey)));
|
|
5493
|
+
const rpc = "https://api.mainnet-beta.solana.com";
|
|
5494
|
+
const connectionA = new import_web36.Connection(rpc, "confirmed");
|
|
5495
|
+
const curveType = "exp";
|
|
5496
|
+
const curveDelta = 0;
|
|
5497
|
+
const reinvestBuy = false;
|
|
5498
|
+
const reinvestSell = false;
|
|
5499
|
+
const expiry = 0;
|
|
5500
|
+
const lpFeeBp = 0;
|
|
5501
|
+
const buysideCreatorRoyaltyBp = 500;
|
|
5502
|
+
const owner = keypair.publicKey;
|
|
5503
|
+
const paymentMint = "11111111111111111111111111111111";
|
|
5504
|
+
const baseUrl = "https://api-mainnet.magiceden.dev/v2/instructions/mmm/create-pool";
|
|
5505
|
+
const endpointUrl = `${baseUrl}?spotPrice=${price}&curveType=${curveType}&curveDelta=${curveDelta}&reinvestBuy=${reinvestBuy}&reinvestSell=${reinvestSell}&expiry=${expiry}&lpFeeBp=${lpFeeBp}&buysideCreatorRoyaltyBp=${buysideCreatorRoyaltyBp}&paymentMint=${paymentMint}&collectionSymbol=${collectionSymbol}&owner=${owner}&sharedEscrowCount=${quantity}`;
|
|
5506
|
+
const txData = yield fetchTxData(endpointUrl, magicApiKey);
|
|
5507
|
+
console.log("========tx data=====", txData);
|
|
5508
|
+
const serializedTxData = new Uint8Array(txData.txSigned.data);
|
|
5509
|
+
const tx = import_web36.VersionedTransaction.deserialize(serializedTxData);
|
|
5510
|
+
tx.sign([keypair]);
|
|
5511
|
+
const txId = yield connectionA.sendTransaction(tx);
|
|
5512
|
+
yield connectionA.confirmTransaction({
|
|
5513
|
+
signature: txId,
|
|
5514
|
+
blockhash: txData.blockhashData.blockhash,
|
|
5515
|
+
lastValidBlockHeight: txData.blockhashData.lastValidBlockHeight
|
|
5516
|
+
});
|
|
5517
|
+
console.log(`Transaction sent. Signature: ${txId}`);
|
|
5518
|
+
return txId;
|
|
5519
|
+
} catch (e) {
|
|
5520
|
+
console.log("Error on Magic Eden collection bid : ", e);
|
|
5521
|
+
return void 0;
|
|
5522
|
+
}
|
|
5523
|
+
});
|
|
5524
|
+
}
|
|
5525
|
+
function fetchTxData(endpoint, apiKey) {
|
|
5526
|
+
return __async(this, null, function* () {
|
|
5527
|
+
const response = yield fetch(endpoint, {
|
|
5528
|
+
method: "GET",
|
|
5529
|
+
headers: {
|
|
5530
|
+
Authorization: `Bearer ${apiKey}`
|
|
5531
|
+
}
|
|
5532
|
+
});
|
|
5533
|
+
if (!response.ok) {
|
|
5534
|
+
throw new Error(`Failed to fetch transaction data: ${response.statusText}`);
|
|
5535
|
+
}
|
|
5536
|
+
return yield response.json();
|
|
5537
|
+
});
|
|
5538
|
+
}
|
|
5461
5539
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5462
5540
|
0 && (module.exports = {
|
|
5463
5541
|
BlockchainType,
|
|
@@ -5479,6 +5557,7 @@ function placeTensorCollectionBid(price, quantity, collectionMint, privateKey, t
|
|
|
5479
5557
|
decodeStr,
|
|
5480
5558
|
isEthereumConfig,
|
|
5481
5559
|
isSolanaConfig,
|
|
5560
|
+
placeMagicEdenCollectionBid,
|
|
5482
5561
|
placeTensorCollectionBid
|
|
5483
5562
|
});
|
|
5484
5563
|
//# sourceMappingURL=index.js.map
|