pyre-world-kit 1.0.1 → 1.0.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/actions.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * Thin wrappers that call torchsdk functions and map params/results
5
5
  * into game-semantic Pyre types. No new on-chain logic.
6
6
  */
7
- import { Connection } from '@solana/web3.js';
7
+ import { Connection, PublicKey } from '@solana/web3.js';
8
8
  import type { BuyQuoteResult, SellQuoteResult, TransactionResult, SaidVerification, ConfirmResult } from 'torchsdk';
9
9
  import type { FactionListParams, FactionListResult, FactionDetail, MembersResult, CommsResult, Stronghold, AgentLink, WarChest, WarLoan, AllWarLoansResult, LaunchFactionParams, JoinFactionParams, DirectJoinFactionParams, DefectParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, TradeOnDexParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, ConvertTitheParams, JoinFactionResult, LaunchFactionResult } from './types';
10
10
  /** List all factions with optional filtering and sorting */
@@ -13,7 +13,7 @@ export declare function getFactions(connection: Connection, params?: FactionList
13
13
  export declare function getFaction(connection: Connection, mint: string): Promise<FactionDetail>;
14
14
  /** Get faction members (top holders) */
15
15
  export declare function getMembers(connection: Connection, mint: string, limit?: number): Promise<MembersResult>;
16
- /** Get faction comms (trade-bundled messages) */
16
+ /** Get faction comms (trade-bundled messages, including post-ascension DEX messages) */
17
17
  export declare function getComms(connection: Connection, mint: string, limit?: number): Promise<CommsResult>;
18
18
  /** Get a quote for joining a faction (buying tokens) */
19
19
  export declare function getJoinQuote(connection: Connection, mint: string, amountSolLamports: number): Promise<BuyQuoteResult>;
@@ -79,3 +79,5 @@ export declare function verifyAgent(wallet: string): Promise<SaidVerification>;
79
79
  export declare function confirmAction(connection: Connection, signature: string, wallet: string): Promise<ConfirmResult>;
80
80
  /** Create an ephemeral agent keypair (memory-only, zero key management) */
81
81
  export { createEphemeralAgent } from 'torchsdk';
82
+ /** Get the Raydium pool state PDA for an ascended faction's DEX pool */
83
+ export declare function getDexPool(mint: string): PublicKey;
package/dist/actions.js CHANGED
@@ -5,6 +5,9 @@
5
5
  * Thin wrappers that call torchsdk functions and map params/results
6
6
  * into game-semantic Pyre types. No new on-chain logic.
7
7
  */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.createEphemeralAgent = void 0;
10
13
  exports.getFactions = getFactions;
@@ -42,6 +45,9 @@ exports.tithe = tithe;
42
45
  exports.convertTithe = convertTithe;
43
46
  exports.verifyAgent = verifyAgent;
44
47
  exports.confirmAction = confirmAction;
48
+ exports.getDexPool = getDexPool;
49
+ const web3_js_1 = require("@solana/web3.js");
50
+ const bs58_1 = __importDefault(require("bs58"));
45
51
  const torchsdk_1 = require("torchsdk");
46
52
  const mappers_1 = require("./mappers");
47
53
  const vanity_1 = require("./vanity");
@@ -67,10 +73,73 @@ async function getMembers(connection, mint, limit) {
67
73
  const result = await (0, torchsdk_1.getHolders)(connection, mint, limit);
68
74
  return (0, mappers_1.mapHoldersResult)(result);
69
75
  }
70
- /** Get faction comms (trade-bundled messages) */
76
+ /** Get faction comms (trade-bundled messages, including post-ascension DEX messages) */
71
77
  async function getComms(connection, mint, limit) {
72
- const result = await (0, torchsdk_1.getMessages)(connection, mint, limit);
73
- return (0, mappers_1.mapMessagesResult)(result);
78
+ const safeLimit = Math.min(limit || 50, 100);
79
+ // Fetch bonding curve messages
80
+ const result = await (0, torchsdk_1.getMessages)(connection, mint, safeLimit);
81
+ const commsResult = (0, mappers_1.mapMessagesResult)(result);
82
+ // Also scan Raydium pool state for post-ascension DEX messages
83
+ try {
84
+ const mintPubkey = new web3_js_1.PublicKey(mint);
85
+ const { poolState } = (0, torchsdk_1.getRaydiumMigrationAccounts)(mintPubkey);
86
+ const signatures = await connection.getSignaturesForAddress(poolState, { limit: Math.min(safeLimit, 50) }, 'confirmed');
87
+ if (signatures.length > 0) {
88
+ const txs = await connection.getParsedTransactions(signatures.map(s => s.signature), { maxSupportedTransactionVersion: 0 });
89
+ const MEMO_PROGRAM = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr';
90
+ const existingSigs = new Set(commsResult.comms.map(c => c.signature));
91
+ for (let i = 0; i < txs.length; i++) {
92
+ const tx = txs[i];
93
+ if (!tx?.meta || tx.meta.err)
94
+ continue;
95
+ const sig = signatures[i];
96
+ if (existingSigs.has(sig.signature))
97
+ continue;
98
+ // Check top-level and inner instructions for memo
99
+ const allInstructions = [
100
+ ...tx.transaction.message.instructions,
101
+ ...(tx.meta.innerInstructions || []).flatMap(inner => inner.instructions),
102
+ ];
103
+ for (const ix of allInstructions) {
104
+ const programId = 'programId' in ix ? ix.programId.toString() : '';
105
+ const programName = 'program' in ix ? ix.program : '';
106
+ const isMemo = programId === MEMO_PROGRAM || programName === 'spl-memo';
107
+ if (isMemo) {
108
+ let memoText = '';
109
+ if ('parsed' in ix) {
110
+ memoText = typeof ix.parsed === 'string' ? ix.parsed : JSON.stringify(ix.parsed);
111
+ }
112
+ else if ('data' in ix && typeof ix.data === 'string') {
113
+ try {
114
+ memoText = new TextDecoder().decode(bs58_1.default.decode(ix.data));
115
+ }
116
+ catch {
117
+ memoText = ix.data;
118
+ }
119
+ }
120
+ if (memoText && memoText.trim()) {
121
+ const sender = tx.transaction.message.accountKeys[0]?.pubkey?.toString() || 'Unknown';
122
+ commsResult.comms.push({
123
+ signature: sig.signature,
124
+ memo: memoText.trim(),
125
+ sender,
126
+ timestamp: sig.blockTime || 0,
127
+ });
128
+ break;
129
+ }
130
+ }
131
+ }
132
+ }
133
+ // Re-sort by timestamp descending and trim to limit
134
+ commsResult.comms.sort((a, b) => b.timestamp - a.timestamp);
135
+ commsResult.comms = commsResult.comms.slice(0, safeLimit);
136
+ commsResult.total = commsResult.comms.length;
137
+ }
138
+ }
139
+ catch {
140
+ // Pool may not exist for non-ascended factions — ignore
141
+ }
142
+ return commsResult;
74
143
  }
75
144
  /** Get a quote for joining a faction (buying tokens) */
76
145
  async function getJoinQuote(connection, mint, amountSolLamports) {
@@ -317,3 +386,8 @@ async function confirmAction(connection, signature, wallet) {
317
386
  /** Create an ephemeral agent keypair (memory-only, zero key management) */
318
387
  var torchsdk_2 = require("torchsdk");
319
388
  Object.defineProperty(exports, "createEphemeralAgent", { enumerable: true, get: function () { return torchsdk_2.createEphemeralAgent; } });
389
+ /** Get the Raydium pool state PDA for an ascended faction's DEX pool */
390
+ function getDexPool(mint) {
391
+ const { poolState } = (0, torchsdk_1.getRaydiumMigrationAccounts)(new web3_js_1.PublicKey(mint));
392
+ return poolState;
393
+ }
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * so agents think in factions, not tokens.
7
7
  */
8
8
  export type { FactionStatus, FactionTier, Strategy, AgentHealth, FactionSummary, FactionDetail, Stronghold, AgentLink, Comms, WarChest, WarLoan, WarLoanWithAgent, Member, FactionListResult, MembersResult, CommsResult, AllWarLoansResult, LaunchFactionParams, JoinFactionParams, DirectJoinFactionParams, DefectParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, TradeOnDexParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, ConvertTitheParams, JoinFactionResult, LaunchFactionResult, TransactionResult, EphemeralAgent, SaidVerification, ConfirmResult, FactionSortOption, FactionStatusFilter, FactionListParams, FactionPower, AllianceCluster, RivalFaction, AgentProfile, AgentFactionPosition, WorldEventType, WorldEvent, WorldStats, } from './types';
9
- export { getFactions, getFaction, getMembers, getComms, getJoinQuote, getDefectQuote, getStronghold, getStrongholdForAgent, getAgentLink, getWarChest, getWarLoan, getAllWarLoans, launchFaction, joinFaction, directJoinFaction, defect, rally, requestWarLoan, repayWarLoan, tradeOnDex, claimSpoils, createStronghold, fundStronghold, withdrawFromStronghold, recruitAgent, exileAgent, coup, withdrawAssets, siege, ascend, raze, tithe, convertTithe, verifyAgent, confirmAction, createEphemeralAgent, } from './actions';
9
+ export { getFactions, getFaction, getMembers, getComms, getJoinQuote, getDefectQuote, getStronghold, getStrongholdForAgent, getAgentLink, getWarChest, getWarLoan, getAllWarLoans, launchFaction, joinFaction, directJoinFaction, defect, rally, requestWarLoan, repayWarLoan, tradeOnDex, claimSpoils, createStronghold, fundStronghold, withdrawFromStronghold, recruitAgent, exileAgent, coup, withdrawAssets, siege, ascend, raze, tithe, convertTithe, verifyAgent, confirmAction, createEphemeralAgent, getDexPool, } from './actions';
10
10
  export { getFactionPower, getFactionLeaderboard, detectAlliances, getFactionRivals, getAgentProfile, getAgentFactions, getWorldFeed, getWorldStats, } from './intel';
11
11
  export { isPyreMint, grindPyreMint } from './vanity';
12
12
  export { PROGRAM_ID, LAMPORTS_PER_SOL, TOKEN_MULTIPLIER, TOTAL_SUPPLY } from 'torchsdk';
package/dist/index.js CHANGED
@@ -7,7 +7,8 @@
7
7
  * so agents think in factions, not tokens.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.TOTAL_SUPPLY = exports.TOKEN_MULTIPLIER = exports.LAMPORTS_PER_SOL = exports.PROGRAM_ID = exports.grindPyreMint = exports.isPyreMint = exports.getWorldStats = exports.getWorldFeed = exports.getAgentFactions = exports.getAgentProfile = exports.getFactionRivals = exports.detectAlliances = exports.getFactionLeaderboard = exports.getFactionPower = exports.createEphemeralAgent = exports.confirmAction = exports.verifyAgent = exports.convertTithe = exports.tithe = exports.raze = exports.ascend = exports.siege = exports.withdrawAssets = exports.coup = exports.exileAgent = exports.recruitAgent = exports.withdrawFromStronghold = exports.fundStronghold = exports.createStronghold = exports.claimSpoils = exports.tradeOnDex = exports.repayWarLoan = exports.requestWarLoan = exports.rally = exports.defect = exports.directJoinFaction = exports.joinFaction = exports.launchFaction = exports.getAllWarLoans = exports.getWarLoan = exports.getWarChest = exports.getAgentLink = exports.getStrongholdForAgent = exports.getStronghold = exports.getDefectQuote = exports.getJoinQuote = exports.getComms = exports.getMembers = exports.getFaction = exports.getFactions = void 0;
10
+ exports.TOKEN_MULTIPLIER = exports.LAMPORTS_PER_SOL = exports.PROGRAM_ID = exports.grindPyreMint = exports.isPyreMint = exports.getWorldStats = exports.getWorldFeed = exports.getAgentFactions = exports.getAgentProfile = exports.getFactionRivals = exports.detectAlliances = exports.getFactionLeaderboard = exports.getFactionPower = exports.getDexPool = exports.createEphemeralAgent = exports.confirmAction = exports.verifyAgent = exports.convertTithe = exports.tithe = exports.raze = exports.ascend = exports.siege = exports.withdrawAssets = exports.coup = exports.exileAgent = exports.recruitAgent = exports.withdrawFromStronghold = exports.fundStronghold = exports.createStronghold = exports.claimSpoils = exports.tradeOnDex = exports.repayWarLoan = exports.requestWarLoan = exports.rally = exports.defect = exports.directJoinFaction = exports.joinFaction = exports.launchFaction = exports.getAllWarLoans = exports.getWarLoan = exports.getWarChest = exports.getAgentLink = exports.getStrongholdForAgent = exports.getStronghold = exports.getDefectQuote = exports.getJoinQuote = exports.getComms = exports.getMembers = exports.getFaction = exports.getFactions = void 0;
11
+ exports.TOTAL_SUPPLY = void 0;
11
12
  // ─── Actions ───────────────────────────────────────────────────────
12
13
  var actions_1 = require("./actions");
13
14
  // Read operations
@@ -52,6 +53,7 @@ Object.defineProperty(exports, "verifyAgent", { enumerable: true, get: function
52
53
  Object.defineProperty(exports, "confirmAction", { enumerable: true, get: function () { return actions_1.confirmAction; } });
53
54
  // Utility
54
55
  Object.defineProperty(exports, "createEphemeralAgent", { enumerable: true, get: function () { return actions_1.createEphemeralAgent; } });
56
+ Object.defineProperty(exports, "getDexPool", { enumerable: true, get: function () { return actions_1.getDexPool; } });
55
57
  // ─── Intel ─────────────────────────────────────────────────────────
56
58
  var intel_1 = require("./intel");
57
59
  Object.defineProperty(exports, "getFactionPower", { enumerable: true, get: function () { return intel_1.getFactionPower; } });
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "pyre-world-kit",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Agent-first faction warfare kit — game-semantic wrapper over torchsdk",
5
- "main": "dist/index.js",
5
+ "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
@@ -11,15 +11,16 @@
11
11
  "test:devnet": "npx tsx tests/test_devnet_e2e.ts"
12
12
  },
13
13
  "dependencies": {
14
- "torchsdk": "^3.7.31",
15
- "@solana/web3.js": "^1.98.4",
14
+ "@coral-xyz/anchor": "^0.32.1",
16
15
  "@solana/spl-token": "^0.4.6",
17
- "@coral-xyz/anchor": "^0.32.1"
16
+ "@solana/web3.js": "^1.98.4",
17
+ "bs58": "^6.0.0",
18
+ "torchsdk": "^3.7.32"
18
19
  },
19
20
  "devDependencies": {
20
21
  "@types/node": "^22.15.0",
21
- "typescript": "^5.9.3",
22
- "tsx": "^4.19.4"
22
+ "tsx": "^4.19.4",
23
+ "typescript": "^5.9.3"
23
24
  },
24
25
  "packageManager": "pnpm@9.10.0+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c"
25
26
  }
package/src/actions.ts CHANGED
@@ -5,7 +5,8 @@
5
5
  * into game-semantic Pyre types. No new on-chain logic.
6
6
  */
7
7
 
8
- import { Connection } from '@solana/web3.js';
8
+ import { Connection, PublicKey } from '@solana/web3.js';
9
+ import bs58 from 'bs58';
9
10
  import {
10
11
  // Read operations
11
12
  getTokens,
@@ -20,6 +21,8 @@ import {
20
21
  getLendingInfo,
21
22
  getLoanPosition,
22
23
  getAllLoanPositions,
24
+ // PDA derivation
25
+ getRaydiumMigrationAccounts,
23
26
  // Transaction builders
24
27
  buildBuyTransaction,
25
28
  buildDirectBuyTransaction,
@@ -138,14 +141,92 @@ export async function getMembers(
138
141
  return mapHoldersResult(result);
139
142
  }
140
143
 
141
- /** Get faction comms (trade-bundled messages) */
144
+ /** Get faction comms (trade-bundled messages, including post-ascension DEX messages) */
142
145
  export async function getComms(
143
146
  connection: Connection,
144
147
  mint: string,
145
148
  limit?: number,
146
149
  ): Promise<CommsResult> {
147
- const result = await getMessages(connection, mint, limit);
148
- return mapMessagesResult(result);
150
+ const safeLimit = Math.min(limit || 50, 100);
151
+
152
+ // Fetch bonding curve messages
153
+ const result = await getMessages(connection, mint, safeLimit);
154
+ const commsResult = mapMessagesResult(result);
155
+
156
+ // Also scan Raydium pool state for post-ascension DEX messages
157
+ try {
158
+ const mintPubkey = new PublicKey(mint);
159
+ const { poolState } = getRaydiumMigrationAccounts(mintPubkey);
160
+
161
+ const signatures = await connection.getSignaturesForAddress(
162
+ poolState,
163
+ { limit: Math.min(safeLimit, 50) },
164
+ 'confirmed',
165
+ );
166
+
167
+ if (signatures.length > 0) {
168
+ const txs = await connection.getParsedTransactions(
169
+ signatures.map(s => s.signature),
170
+ { maxSupportedTransactionVersion: 0 },
171
+ );
172
+
173
+ const MEMO_PROGRAM = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr';
174
+ const existingSigs = new Set(commsResult.comms.map(c => c.signature));
175
+
176
+ for (let i = 0; i < txs.length; i++) {
177
+ const tx = txs[i];
178
+ if (!tx?.meta || tx.meta.err) continue;
179
+
180
+ const sig = signatures[i];
181
+ if (existingSigs.has(sig.signature)) continue;
182
+
183
+ // Check top-level and inner instructions for memo
184
+ const allInstructions = [
185
+ ...tx.transaction.message.instructions,
186
+ ...(tx.meta.innerInstructions || []).flatMap(inner => inner.instructions),
187
+ ];
188
+
189
+ for (const ix of allInstructions) {
190
+ const programId = 'programId' in ix ? ix.programId.toString() : '';
191
+ const programName = 'program' in ix ? (ix as { program: string }).program : '';
192
+ const isMemo = programId === MEMO_PROGRAM || programName === 'spl-memo';
193
+
194
+ if (isMemo) {
195
+ let memoText = '';
196
+ if ('parsed' in ix) {
197
+ memoText = typeof ix.parsed === 'string' ? ix.parsed : JSON.stringify(ix.parsed);
198
+ } else if ('data' in ix && typeof ix.data === 'string') {
199
+ try {
200
+ memoText = new TextDecoder().decode(bs58.decode(ix.data));
201
+ } catch {
202
+ memoText = ix.data;
203
+ }
204
+ }
205
+
206
+ if (memoText && memoText.trim()) {
207
+ const sender = tx.transaction.message.accountKeys[0]?.pubkey?.toString() || 'Unknown';
208
+ commsResult.comms.push({
209
+ signature: sig.signature,
210
+ memo: memoText.trim(),
211
+ sender,
212
+ timestamp: sig.blockTime || 0,
213
+ });
214
+ break;
215
+ }
216
+ }
217
+ }
218
+ }
219
+
220
+ // Re-sort by timestamp descending and trim to limit
221
+ commsResult.comms.sort((a, b) => b.timestamp - a.timestamp);
222
+ commsResult.comms = commsResult.comms.slice(0, safeLimit);
223
+ commsResult.total = commsResult.comms.length;
224
+ }
225
+ } catch {
226
+ // Pool may not exist for non-ascended factions — ignore
227
+ }
228
+
229
+ return commsResult;
149
230
  }
150
231
 
151
232
  /** Get a quote for joining a faction (buying tokens) */
@@ -522,3 +603,9 @@ export async function confirmAction(
522
603
 
523
604
  /** Create an ephemeral agent keypair (memory-only, zero key management) */
524
605
  export { createEphemeralAgent } from 'torchsdk';
606
+
607
+ /** Get the Raydium pool state PDA for an ascended faction's DEX pool */
608
+ export function getDexPool(mint: string): PublicKey {
609
+ const { poolState } = getRaydiumMigrationAccounts(new PublicKey(mint));
610
+ return poolState;
611
+ }
package/src/index.ts CHANGED
@@ -118,6 +118,7 @@ export {
118
118
  confirmAction,
119
119
  // Utility
120
120
  createEphemeralAgent,
121
+ getDexPool,
121
122
  } from './actions';
122
123
 
123
124
  // ─── Intel ─────────────────────────────────────────────────────────