pyre-world-kit 1.0.2 → 1.0.5

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.js CHANGED
@@ -76,25 +76,25 @@ async function getMembers(connection, mint, limit) {
76
76
  /** Get faction comms (trade-bundled messages, including post-ascension DEX messages) */
77
77
  async function getComms(connection, mint, limit) {
78
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) {
79
+ const MEMO_PROGRAM = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr';
80
+ // Fetch bonding curve messages AND pool state messages in parallel
81
+ const bondingCommsPromise = (0, torchsdk_1.getMessages)(connection, mint, safeLimit)
82
+ .then(r => (0, mappers_1.mapMessagesResult)(r))
83
+ .catch(() => ({ comms: [], total: 0 }));
84
+ const poolCommsPromise = (async () => {
85
+ try {
86
+ const mintPubkey = new web3_js_1.PublicKey(mint);
87
+ const { poolState } = (0, torchsdk_1.getRaydiumMigrationAccounts)(mintPubkey);
88
+ const signatures = await connection.getSignaturesForAddress(poolState, { limit: Math.min(safeLimit, 50) }, 'confirmed');
89
+ if (signatures.length === 0)
90
+ return { comms: [], total: 0 };
88
91
  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));
92
+ const comms = [];
91
93
  for (let i = 0; i < txs.length; i++) {
92
94
  const tx = txs[i];
93
95
  if (!tx?.meta || tx.meta.err)
94
96
  continue;
95
97
  const sig = signatures[i];
96
- if (existingSigs.has(sig.signature))
97
- continue;
98
98
  // Check top-level and inner instructions for memo
99
99
  const allInstructions = [
100
100
  ...tx.transaction.message.instructions,
@@ -119,7 +119,7 @@ async function getComms(connection, mint, limit) {
119
119
  }
120
120
  if (memoText && memoText.trim()) {
121
121
  const sender = tx.transaction.message.accountKeys[0]?.pubkey?.toString() || 'Unknown';
122
- commsResult.comms.push({
122
+ comms.push({
123
123
  signature: sig.signature,
124
124
  memo: memoText.trim(),
125
125
  sender,
@@ -130,16 +130,27 @@ async function getComms(connection, mint, limit) {
130
130
  }
131
131
  }
132
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;
133
+ return { comms, total: comms.length };
134
+ }
135
+ catch {
136
+ return { comms: [], total: 0 };
137
+ }
138
+ })();
139
+ const [bondingResult, poolResult] = await Promise.all([bondingCommsPromise, poolCommsPromise]);
140
+ // Merge, dedupe by signature, sort newest first, trim to limit
141
+ const seen = new Set();
142
+ const allComms = [];
143
+ for (const c of [...bondingResult.comms, ...poolResult.comms]) {
144
+ if (!seen.has(c.signature)) {
145
+ seen.add(c.signature);
146
+ allComms.push(c);
137
147
  }
138
148
  }
139
- catch {
140
- // Pool may not exist for non-ascended factions — ignore
141
- }
142
- return commsResult;
149
+ allComms.sort((a, b) => b.timestamp - a.timestamp);
150
+ return {
151
+ comms: allComms.slice(0, safeLimit),
152
+ total: allComms.length,
153
+ };
143
154
  }
144
155
  /** Get a quote for joining a faction (buying tokens) */
145
156
  async function getJoinQuote(connection, mint, amountSolLamports) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyre-world-kit",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "Agent-first faction warfare kit — game-semantic wrapper over torchsdk",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "@solana/spl-token": "^0.4.6",
16
16
  "@solana/web3.js": "^1.98.4",
17
17
  "bs58": "^6.0.0",
18
- "torchsdk": "^3.7.32"
18
+ "torchsdk": "^3.7.34"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/node": "^22.15.0",
package/src/actions.ts CHANGED
@@ -148,37 +148,38 @@ export async function getComms(
148
148
  limit?: number,
149
149
  ): Promise<CommsResult> {
150
150
  const safeLimit = Math.min(limit || 50, 100);
151
+ const MEMO_PROGRAM = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr';
152
+
153
+ // Fetch bonding curve messages AND pool state messages in parallel
154
+ const bondingCommsPromise = getMessages(connection, mint, safeLimit)
155
+ .then(r => mapMessagesResult(r))
156
+ .catch(() => ({ comms: [], total: 0 } as CommsResult));
157
+
158
+ const poolCommsPromise = (async (): Promise<CommsResult> => {
159
+ try {
160
+ const mintPubkey = new PublicKey(mint);
161
+ const { poolState } = getRaydiumMigrationAccounts(mintPubkey);
162
+
163
+ const signatures = await connection.getSignaturesForAddress(
164
+ poolState,
165
+ { limit: Math.min(safeLimit, 50) },
166
+ 'confirmed',
167
+ );
151
168
 
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
- );
169
+ if (signatures.length === 0) return { comms: [], total: 0 };
166
170
 
167
- if (signatures.length > 0) {
168
171
  const txs = await connection.getParsedTransactions(
169
172
  signatures.map(s => s.signature),
170
173
  { maxSupportedTransactionVersion: 0 },
171
174
  );
172
175
 
173
- const MEMO_PROGRAM = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr';
174
- const existingSigs = new Set(commsResult.comms.map(c => c.signature));
176
+ const comms: CommsResult['comms'] = [];
175
177
 
176
178
  for (let i = 0; i < txs.length; i++) {
177
179
  const tx = txs[i];
178
180
  if (!tx?.meta || tx.meta.err) continue;
179
181
 
180
182
  const sig = signatures[i];
181
- if (existingSigs.has(sig.signature)) continue;
182
183
 
183
184
  // Check top-level and inner instructions for memo
184
185
  const allInstructions = [
@@ -205,7 +206,7 @@ export async function getComms(
205
206
 
206
207
  if (memoText && memoText.trim()) {
207
208
  const sender = tx.transaction.message.accountKeys[0]?.pubkey?.toString() || 'Unknown';
208
- commsResult.comms.push({
209
+ comms.push({
209
210
  signature: sig.signature,
210
211
  memo: memoText.trim(),
211
212
  sender,
@@ -217,16 +218,31 @@ export async function getComms(
217
218
  }
218
219
  }
219
220
 
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;
221
+ return { comms, total: comms.length };
222
+ } catch {
223
+ return { comms: [], total: 0 };
224
+ }
225
+ })();
226
+
227
+ const [bondingResult, poolResult] = await Promise.all([bondingCommsPromise, poolCommsPromise]);
228
+
229
+ // Merge, dedupe by signature, sort newest first, trim to limit
230
+ const seen = new Set<string>();
231
+ const allComms: CommsResult['comms'] = [];
232
+
233
+ for (const c of [...bondingResult.comms, ...poolResult.comms]) {
234
+ if (!seen.has(c.signature)) {
235
+ seen.add(c.signature);
236
+ allComms.push(c);
224
237
  }
225
- } catch {
226
- // Pool may not exist for non-ascended factions — ignore
227
238
  }
228
239
 
229
- return commsResult;
240
+ allComms.sort((a, b) => b.timestamp - a.timestamp);
241
+
242
+ return {
243
+ comms: allComms.slice(0, safeLimit),
244
+ total: allComms.length,
245
+ };
230
246
  }
231
247
 
232
248
  /** Get a quote for joining a faction (buying tokens) */