pnp-sdk 0.2.0 → 0.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/{chunk-PODGM4UD.js → chunk-JBFSLIVK.js} +76 -2
- package/dist/{chunk-PODGM4UD.js.map → chunk-JBFSLIVK.js.map} +1 -1
- package/dist/cli.cjs +77 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +77 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -11031,7 +11031,7 @@ import {
|
|
|
11031
11031
|
TOKEN_PROGRAM_ID as TOKEN_PROGRAM_ID6,
|
|
11032
11032
|
getAssociatedTokenAddressSync as getAssociatedTokenAddressSync3
|
|
11033
11033
|
} from "@solana/spl-token";
|
|
11034
|
-
import { BN as BN3 } from "
|
|
11034
|
+
import { BN as BN3 } from "bn.js";
|
|
11035
11035
|
var PNPClient = class _PNPClient {
|
|
11036
11036
|
client;
|
|
11037
11037
|
signer;
|
|
@@ -11227,6 +11227,80 @@ var PNPClient = class _PNPClient {
|
|
|
11227
11227
|
creator
|
|
11228
11228
|
});
|
|
11229
11229
|
}
|
|
11230
|
+
/**
|
|
11231
|
+
* Create a V2 (AMM) market with Twitter URL detection (high-level wrapper).
|
|
11232
|
+
* Automatically detects and extracts Twitter URLs from the question.
|
|
11233
|
+
* Serializes PublicKeys to base58 strings.
|
|
11234
|
+
*/
|
|
11235
|
+
async createMarketTwitter(params) {
|
|
11236
|
+
const { question, tweetUrl, initialLiquidity, endTime, collateralTokenMint } = params;
|
|
11237
|
+
if (!this.market) {
|
|
11238
|
+
throw new Error("MarketModule not available. Initialize client with a signer.");
|
|
11239
|
+
}
|
|
11240
|
+
const patterns = [
|
|
11241
|
+
/https?:\/\/(?:www\.)?twitter\.com\/[^/]+\/status\/(\d+)/i,
|
|
11242
|
+
/https?:\/\/(?:www\.)?x\.com\/[^/]+\/status\/(\d+)/i,
|
|
11243
|
+
/https?:\/\/(?:mobile\.)?twitter\.com\/[^/]+\/status\/(\d+)/i
|
|
11244
|
+
];
|
|
11245
|
+
let tweetId = null;
|
|
11246
|
+
for (const re of patterns) {
|
|
11247
|
+
const m = tweetUrl.match(re);
|
|
11248
|
+
if (m && m[1]) {
|
|
11249
|
+
tweetId = m[1];
|
|
11250
|
+
break;
|
|
11251
|
+
}
|
|
11252
|
+
}
|
|
11253
|
+
if (!tweetId) {
|
|
11254
|
+
const m = tweetUrl.match(/(\d{8,})/);
|
|
11255
|
+
if (m && m[1]) tweetId = m[1];
|
|
11256
|
+
}
|
|
11257
|
+
if (!tweetId) {
|
|
11258
|
+
throw new Error("Unable to extract tweet ID from tweetUrl");
|
|
11259
|
+
}
|
|
11260
|
+
const finalQuestion = `${question}${question.endsWith(" ") ? "" : " "}X {${tweetId}}`;
|
|
11261
|
+
const result = await this.market.createMarket({
|
|
11262
|
+
question: finalQuestion,
|
|
11263
|
+
initialLiquidity,
|
|
11264
|
+
endTime,
|
|
11265
|
+
baseMint: collateralTokenMint
|
|
11266
|
+
});
|
|
11267
|
+
if (!result.signature) {
|
|
11268
|
+
throw new Error("Transaction failed: No signature returned");
|
|
11269
|
+
}
|
|
11270
|
+
return {
|
|
11271
|
+
signature: result.signature,
|
|
11272
|
+
market: result.market.toBase58(),
|
|
11273
|
+
detectedTwitterUrl: tweetUrl,
|
|
11274
|
+
isTweetIdFormat: true
|
|
11275
|
+
};
|
|
11276
|
+
}
|
|
11277
|
+
/**
|
|
11278
|
+
* Create a V2 (AMM) market with YouTube URL detection (high-level wrapper).
|
|
11279
|
+
* Automatically detects and extracts YouTube URLs from the question.
|
|
11280
|
+
* Serializes PublicKeys to base58 strings.
|
|
11281
|
+
*/
|
|
11282
|
+
async createMarketYoutube(params) {
|
|
11283
|
+
const { question, youtubeUrl, initialLiquidity, endTime, collateralTokenMint } = params;
|
|
11284
|
+
if (!this.market) {
|
|
11285
|
+
throw new Error("MarketModule not available. Initialize client with a signer.");
|
|
11286
|
+
}
|
|
11287
|
+
const questionWithUrl = youtubeUrl && youtubeUrl.length > 0 ? `${question}${question.endsWith(" ") ? "" : " "}${youtubeUrl}` : question;
|
|
11288
|
+
const detected = _PNPClient.detectYoutubeUrl(questionWithUrl);
|
|
11289
|
+
const result = await this.market.createMarket({
|
|
11290
|
+
question: questionWithUrl,
|
|
11291
|
+
initialLiquidity,
|
|
11292
|
+
endTime,
|
|
11293
|
+
baseMint: collateralTokenMint
|
|
11294
|
+
});
|
|
11295
|
+
if (!result.signature) {
|
|
11296
|
+
throw new Error("Transaction failed: No signature returned");
|
|
11297
|
+
}
|
|
11298
|
+
return {
|
|
11299
|
+
signature: result.signature,
|
|
11300
|
+
market: result.market.toBase58(),
|
|
11301
|
+
detectedYoutubeUrl: youtubeUrl || detected.youtubeUrl
|
|
11302
|
+
};
|
|
11303
|
+
}
|
|
11230
11304
|
/**
|
|
11231
11305
|
* Create a P2P market with Twitter URL detection (high-level wrapper).
|
|
11232
11306
|
* Automatically detects and extracts Twitter URLs from the question.
|
|
@@ -12251,4 +12325,4 @@ export {
|
|
|
12251
12325
|
RedemptionModule,
|
|
12252
12326
|
PNPClient
|
|
12253
12327
|
};
|
|
12254
|
-
//# sourceMappingURL=chunk-
|
|
12328
|
+
//# sourceMappingURL=chunk-JBFSLIVK.js.map
|