pyre-world-kit 2.0.0 → 2.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/intel.d.ts CHANGED
@@ -43,7 +43,7 @@ export declare function getAgentProfile(connection: Connection, wallet: string):
43
43
  /**
44
44
  * List all factions an agent holds tokens in.
45
45
  *
46
- * Checks top factions for this wallet's holdings.
46
+ * Scans the wallet's token accounts directly, then matches against known factions.
47
47
  */
48
48
  export declare function getAgentFactions(connection: Connection, wallet: string, factionLimit?: number): Promise<AgentFactionPosition[]>;
49
49
  /**
package/dist/intel.js CHANGED
@@ -5,6 +5,39 @@
5
5
  * Game-specific utility functions that compose torchsdk reads into
6
6
  * strategic intelligence. Agents use these to reason about the world.
7
7
  */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
8
41
  Object.defineProperty(exports, "__esModule", { value: true });
9
42
  exports.getFactionPower = getFactionPower;
10
43
  exports.getFactionLeaderboard = getFactionLeaderboard;
@@ -195,32 +228,50 @@ async function getAgentProfile(connection, wallet) {
195
228
  /**
196
229
  * List all factions an agent holds tokens in.
197
230
  *
198
- * Checks top factions for this wallet's holdings.
231
+ * Scans the wallet's token accounts directly, then matches against known factions.
199
232
  */
200
233
  async function getAgentFactions(connection, wallet, factionLimit = 50) {
234
+ const { TOKEN_2022_PROGRAM_ID } = await Promise.resolve().then(() => __importStar(require('@solana/spl-token')));
235
+ const walletPk = new web3_js_1.PublicKey(wallet);
236
+ // Get all Token-2022 accounts for this wallet
237
+ const tokenAccounts = await connection.getParsedTokenAccountsByOwner(walletPk, {
238
+ programId: TOKEN_2022_PROGRAM_ID,
239
+ });
240
+ // Filter to pyre mints with non-zero balance
241
+ const heldMints = tokenAccounts.value
242
+ .map(a => ({
243
+ mint: a.account.data.parsed.info.mint,
244
+ balance: Number(a.account.data.parsed.info.tokenAmount.amount),
245
+ }))
246
+ .filter(a => a.balance > 0 && (0, vanity_1.isPyreMint)(a.mint));
247
+ if (heldMints.length === 0)
248
+ return [];
249
+ // Fetch faction metadata for held mints
201
250
  const allFactions = await (0, torchsdk_1.getTokens)(connection, { limit: factionLimit });
202
- const pyreFactions = allFactions.tokens.filter(t => (0, vanity_1.isPyreMint)(t.mint));
251
+ const factionMap = new Map(allFactions.tokens.filter(t => (0, vanity_1.isPyreMint)(t.mint)).map(t => [t.mint, t]));
203
252
  const positions = [];
204
- // Check each faction for this holder
205
- await Promise.all(pyreFactions.map(async (faction) => {
253
+ for (const { mint, balance } of heldMints) {
254
+ const faction = factionMap.get(mint);
255
+ if (!faction)
256
+ continue;
257
+ // Get holder percentage from holders list
258
+ let percentage = 0;
206
259
  try {
207
- const holders = await getPyreHolders(connection, faction.mint, 100);
260
+ const holders = await getPyreHolders(connection, mint, 100);
208
261
  const holding = holders.holders.find(h => h.address === wallet);
209
- if (holding && holding.balance > 0) {
210
- positions.push({
211
- mint: faction.mint,
212
- name: faction.name,
213
- symbol: faction.symbol,
214
- balance: holding.balance,
215
- percentage: holding.percentage,
216
- value_sol: holding.balance * faction.price_sol,
217
- });
218
- }
262
+ if (holding)
263
+ percentage = holding.percentage;
219
264
  }
220
- catch {
221
- // Skip factions we can't read
222
- }
223
- }));
265
+ catch { }
266
+ positions.push({
267
+ mint,
268
+ name: faction.name,
269
+ symbol: faction.symbol,
270
+ balance,
271
+ percentage,
272
+ value_sol: balance * faction.price_sol,
273
+ });
274
+ }
224
275
  positions.sort((a, b) => b.value_sol - a.value_sol);
225
276
  return positions;
226
277
  }
@@ -2,7 +2,7 @@
2
2
  "address": "2oai1EaDnFcSNskyVwSbGkUEddxxfUSsSVRokE31gRfv",
3
3
  "metadata": {
4
4
  "name": "pyre_world",
5
- "version": "0.1.0",
5
+ "version": "1.0.1",
6
6
  "spec": "0.1.0",
7
7
  "description": "pyre.world agent registry"
8
8
  },
@@ -588,6 +588,20 @@
588
588
  "PDA bump"
589
589
  ],
590
590
  "type": "u8"
591
+ },
592
+ {
593
+ "name": "total_sol_spent",
594
+ "docs": [
595
+ "Cumulative SOL spent on joins/buys/infiltrates (lamports)"
596
+ ],
597
+ "type": "u64"
598
+ },
599
+ {
600
+ "name": "total_sol_received",
601
+ "docs": [
602
+ "Cumulative SOL received from defects/sells (lamports)"
603
+ ],
604
+ "type": "u64"
591
605
  }
592
606
  ]
593
607
  }
@@ -698,6 +712,14 @@
698
712
  {
699
713
  "name": "personality_summary",
700
714
  "type": "string"
715
+ },
716
+ {
717
+ "name": "total_sol_spent",
718
+ "type": "u64"
719
+ },
720
+ {
721
+ "name": "total_sol_received",
722
+ "type": "u64"
701
723
  }
702
724
  ]
703
725
  }
package/dist/registry.js CHANGED
@@ -84,6 +84,8 @@ async function getRegistryProfile(connection, creator) {
84
84
  tithes: account.tithes.toNumber(),
85
85
  created_at: account.createdAt.toNumber(),
86
86
  bump: account.bump,
87
+ total_sol_spent: account.totalSolSpent?.toNumber() ?? 0,
88
+ total_sol_received: account.totalSolReceived?.toNumber() ?? 0,
87
89
  };
88
90
  }
89
91
  catch {
@@ -154,6 +156,8 @@ async function buildCheckpointTransaction(connection, params) {
154
156
  razes: new anchor_1.BN(params.razes),
155
157
  tithes: new anchor_1.BN(params.tithes),
156
158
  personalitySummary: params.personality_summary,
159
+ totalSolSpent: new anchor_1.BN(params.total_sol_spent),
160
+ totalSolReceived: new anchor_1.BN(params.total_sol_received),
157
161
  };
158
162
  const tx = new web3_js_1.Transaction();
159
163
  const ix = await program.methods.checkpoint(args)
package/dist/types.d.ts CHANGED
@@ -413,6 +413,8 @@ export interface RegistryProfile {
413
413
  tithes: number;
414
414
  created_at: number;
415
415
  bump: number;
416
+ total_sol_spent: number;
417
+ total_sol_received: number;
416
418
  }
417
419
  /** On-chain wallet link from pyre_world registry */
418
420
  export interface RegistryWalletLink {
@@ -441,6 +443,8 @@ export interface CheckpointParams {
441
443
  razes: number;
442
444
  tithes: number;
443
445
  personality_summary: string;
446
+ total_sol_spent: number;
447
+ total_sol_received: number;
444
448
  }
445
449
  /** Params for registering a new agent */
446
450
  export interface RegisterAgentParams {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyre-world-kit",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
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",
package/src/intel.ts CHANGED
@@ -245,39 +245,60 @@ export async function getAgentProfile(
245
245
  /**
246
246
  * List all factions an agent holds tokens in.
247
247
  *
248
- * Checks top factions for this wallet's holdings.
248
+ * Scans the wallet's token accounts directly, then matches against known factions.
249
249
  */
250
250
  export async function getAgentFactions(
251
251
  connection: Connection,
252
252
  wallet: string,
253
253
  factionLimit = 50,
254
254
  ): Promise<AgentFactionPosition[]> {
255
- const allFactions = await getTokens(connection, { limit: factionLimit });
256
- const pyreFactions = allFactions.tokens.filter(t => isPyreMint(t.mint));
257
- const positions: AgentFactionPosition[] = [];
255
+ const { TOKEN_2022_PROGRAM_ID } = await import('@solana/spl-token');
256
+ const walletPk = new PublicKey(wallet);
258
257
 
259
- // Check each faction for this holder
260
- await Promise.all(
261
- pyreFactions.map(async (faction) => {
262
- try {
263
- const holders = await getPyreHolders(connection, faction.mint, 100);
264
- const holding = holders.holders.find(h => h.address === wallet);
265
- if (holding && holding.balance > 0) {
266
- positions.push({
267
- mint: faction.mint,
268
- name: faction.name,
269
- symbol: faction.symbol,
270
- balance: holding.balance,
271
- percentage: holding.percentage,
272
- value_sol: holding.balance * faction.price_sol,
273
- });
274
- }
275
- } catch {
276
- // Skip factions we can't read
277
- }
278
- })
258
+ // Get all Token-2022 accounts for this wallet
259
+ const tokenAccounts = await connection.getParsedTokenAccountsByOwner(walletPk, {
260
+ programId: TOKEN_2022_PROGRAM_ID,
261
+ });
262
+
263
+ // Filter to pyre mints with non-zero balance
264
+ const heldMints = tokenAccounts.value
265
+ .map(a => ({
266
+ mint: a.account.data.parsed.info.mint as string,
267
+ balance: Number(a.account.data.parsed.info.tokenAmount.amount),
268
+ }))
269
+ .filter(a => a.balance > 0 && isPyreMint(a.mint));
270
+
271
+ if (heldMints.length === 0) return [];
272
+
273
+ // Fetch faction metadata for held mints
274
+ const allFactions = await getTokens(connection, { limit: factionLimit });
275
+ const factionMap = new Map(
276
+ allFactions.tokens.filter(t => isPyreMint(t.mint)).map(t => [t.mint, t])
279
277
  );
280
278
 
279
+ const positions: AgentFactionPosition[] = [];
280
+ for (const { mint, balance } of heldMints) {
281
+ const faction = factionMap.get(mint);
282
+ if (!faction) continue;
283
+
284
+ // Get holder percentage from holders list
285
+ let percentage = 0;
286
+ try {
287
+ const holders = await getPyreHolders(connection, mint, 100);
288
+ const holding = holders.holders.find(h => h.address === wallet);
289
+ if (holding) percentage = holding.percentage;
290
+ } catch {}
291
+
292
+ positions.push({
293
+ mint,
294
+ name: faction.name,
295
+ symbol: faction.symbol,
296
+ balance,
297
+ percentage,
298
+ value_sol: balance * faction.price_sol,
299
+ });
300
+ }
301
+
281
302
  positions.sort((a, b) => b.value_sol - a.value_sol);
282
303
  return positions;
283
304
  }
@@ -2,7 +2,7 @@
2
2
  "address": "2oai1EaDnFcSNskyVwSbGkUEddxxfUSsSVRokE31gRfv",
3
3
  "metadata": {
4
4
  "name": "pyre_world",
5
- "version": "0.1.0",
5
+ "version": "1.0.1",
6
6
  "spec": "0.1.0",
7
7
  "description": "pyre.world agent registry"
8
8
  },
@@ -588,6 +588,20 @@
588
588
  "PDA bump"
589
589
  ],
590
590
  "type": "u8"
591
+ },
592
+ {
593
+ "name": "total_sol_spent",
594
+ "docs": [
595
+ "Cumulative SOL spent on joins/buys/infiltrates (lamports)"
596
+ ],
597
+ "type": "u64"
598
+ },
599
+ {
600
+ "name": "total_sol_received",
601
+ "docs": [
602
+ "Cumulative SOL received from defects/sells (lamports)"
603
+ ],
604
+ "type": "u64"
591
605
  }
592
606
  ]
593
607
  }
@@ -698,6 +712,14 @@
698
712
  {
699
713
  "name": "personality_summary",
700
714
  "type": "string"
715
+ },
716
+ {
717
+ "name": "total_sol_spent",
718
+ "type": "u64"
719
+ },
720
+ {
721
+ "name": "total_sol_received",
722
+ "type": "u64"
701
723
  }
702
724
  ]
703
725
  }
package/src/registry.ts CHANGED
@@ -113,6 +113,8 @@ export async function getRegistryProfile(
113
113
  tithes: account.tithes.toNumber(),
114
114
  created_at: account.createdAt.toNumber(),
115
115
  bump: account.bump,
116
+ total_sol_spent: account.totalSolSpent?.toNumber() ?? 0,
117
+ total_sol_received: account.totalSolReceived?.toNumber() ?? 0,
116
118
  };
117
119
  } catch {
118
120
  return null;
@@ -199,6 +201,8 @@ export async function buildCheckpointTransaction(
199
201
  razes: new BN(params.razes),
200
202
  tithes: new BN(params.tithes),
201
203
  personalitySummary: params.personality_summary,
204
+ totalSolSpent: new BN(params.total_sol_spent),
205
+ totalSolReceived: new BN(params.total_sol_received),
202
206
  };
203
207
 
204
208
  const tx = new Transaction();
package/src/types.ts CHANGED
@@ -497,6 +497,8 @@ export interface RegistryProfile {
497
497
  tithes: number;
498
498
  created_at: number;
499
499
  bump: number;
500
+ total_sol_spent: number;
501
+ total_sol_received: number;
500
502
  }
501
503
 
502
504
  /** On-chain wallet link from pyre_world registry */
@@ -527,6 +529,8 @@ export interface CheckpointParams {
527
529
  razes: number;
528
530
  tithes: number;
529
531
  personality_summary: string;
532
+ total_sol_spent: number;
533
+ total_sol_received: number;
530
534
  }
531
535
 
532
536
  /** Params for registering a new agent */