pyre-world-kit 3.0.1 → 3.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/index.d.ts CHANGED
@@ -8,15 +8,15 @@
8
8
  import { Connection } from '@solana/web3.js';
9
9
  import { ActionProvider } from './providers/action.provider';
10
10
  import { IntelProvider } from './providers/intel.provider';
11
- import { RegistryProvider } from './providers/registry.provider';
12
11
  import { StateProvider } from './providers/state.provider';
13
12
  import type { Action } from './types/action.types';
14
13
  import type { Intel } from './types/intel.types';
15
14
  import type { CheckpointConfig } from './types/state.types';
15
+ import { Registry } from './types/registry.types';
16
16
  export declare class PyreKit {
17
17
  readonly actions: ActionProvider;
18
18
  readonly intel: IntelProvider;
19
- readonly registry: RegistryProvider;
19
+ readonly registry: Registry;
20
20
  readonly state: StateProvider;
21
21
  constructor(connection: Connection, publicKey: string);
22
22
  /** Callback fired when checkpoint interval is reached */
package/dist/index.js CHANGED
@@ -20,8 +20,8 @@ class PyreKit {
20
20
  state;
21
21
  constructor(connection, publicKey) {
22
22
  this.registry = new registry_provider_1.RegistryProvider(connection);
23
- this.state = new state_provider_1.StateProvider(connection, publicKey, this.registry);
24
- this.actions = new action_provider_1.ActionProvider(connection);
23
+ this.state = new state_provider_1.StateProvider(connection, this.registry, publicKey);
24
+ this.actions = new action_provider_1.ActionProvider(connection, this.registry);
25
25
  this.intel = new intel_provider_1.IntelProvider(connection, this.actions);
26
26
  // Wire auto-checkpoint callback
27
27
  this.state.onCheckpointDue = () => this.onCheckpointDue?.();
@@ -2,10 +2,12 @@ import { Connection } from '@solana/web3.js';
2
2
  import { Action } from '../types/action.types';
3
3
  import { BuyQuoteResult, SellQuoteResult, TransactionResult } from 'torchsdk';
4
4
  import { AgentLink, AllWarLoansResult, AscendParams, ClaimSpoilsParams, CommsResult, CoupParams, CreateStrongholdParams, DefectParams, ExileAgentParams, FactionDetail, FactionListParams, FactionListResult, FactionStatus, FudFactionParams, FundStrongholdParams, JoinFactionParams, JoinFactionResult, LaunchFactionParams, LaunchFactionResult, MembersResult, MessageFactionParams, RallyParams, RazeParams, RecruitAgentParams, RepayWarLoanParams, RequestWarLoanParams, SiegeParams, Stronghold, TitheParams, WarChest, WarLoan, WarLoanQuote, WithdrawAssetsParams, WithdrawFromStrongholdParams } from '../types';
5
+ import { Registry } from '../types/registry.types';
5
6
  export declare class ActionProvider implements Action {
6
7
  private connection;
8
+ private registryProvider;
7
9
  private mapper;
8
- constructor(connection: Connection);
10
+ constructor(connection: Connection, registryProvider: Registry);
9
11
  createStronghold(params: CreateStrongholdParams): Promise<TransactionResult>;
10
12
  coup(params: CoupParams): Promise<TransactionResult>;
11
13
  exileAgent(params: ExileAgentParams): Promise<TransactionResult>;
@@ -41,6 +43,7 @@ export declare class ActionProvider implements Action {
41
43
  raze(params: RazeParams): Promise<TransactionResult>;
42
44
  repayWarLoan(params: RepayWarLoanParams): Promise<TransactionResult>;
43
45
  requestWarLoan(params: RequestWarLoanParams): Promise<TransactionResult>;
46
+ scout(targetAddress: string): Promise<string>;
44
47
  siege(params: SiegeParams): Promise<TransactionResult>;
45
48
  tithe(params: TitheParams): Promise<TransactionResult>;
46
49
  }
@@ -8,9 +8,11 @@ const vanity_1 = require("../vanity");
8
8
  const util_1 = require("../util");
9
9
  class ActionProvider {
10
10
  connection;
11
+ registryProvider;
11
12
  mapper = new mapper_provider_1.MapperProvider();
12
- constructor(connection) {
13
+ constructor(connection, registryProvider) {
13
14
  this.connection = connection;
15
+ this.registryProvider = registryProvider;
14
16
  }
15
17
  async createStronghold(params) {
16
18
  return (0, torchsdk_1.buildCreateVaultTransaction)(this.connection, { creator: params.creator });
@@ -310,6 +312,55 @@ class ActionProvider {
310
312
  vault: params.stronghold,
311
313
  });
312
314
  }
315
+ async scout(targetAddress) {
316
+ try {
317
+ const p = await this.registryProvider.getProfile(targetAddress);
318
+ if (!p)
319
+ return ` @${targetAddress.slice(0, 8)}: no pyre identity found`;
320
+ const total = p.joins +
321
+ p.defects +
322
+ p.rallies +
323
+ p.launches +
324
+ p.messages +
325
+ p.fuds +
326
+ p.infiltrates +
327
+ p.reinforces +
328
+ p.war_loans +
329
+ p.repay_loans +
330
+ p.sieges +
331
+ p.ascends +
332
+ p.razes +
333
+ p.tithes;
334
+ const topActions = [
335
+ { n: 'joins', v: p.joins },
336
+ { n: 'defects', v: p.defects },
337
+ { n: 'rallies', v: p.rallies },
338
+ { n: 'messages', v: p.messages },
339
+ { n: 'fuds', v: p.fuds },
340
+ { n: 'infiltrates', v: p.infiltrates },
341
+ { n: 'reinforces', v: p.reinforces },
342
+ { n: 'war_loans', v: p.war_loans },
343
+ { n: 'sieges', v: p.sieges },
344
+ ]
345
+ .sort((a, b) => b.v - a.v)
346
+ .filter((a) => a.v > 0)
347
+ .slice(0, 4)
348
+ .map((a) => `${a.n}:${a.v}`)
349
+ .join(', ');
350
+ const personality = p.personality_summary || 'unknown';
351
+ const checkpoint = p.last_checkpoint > 0
352
+ ? new Date(p.last_checkpoint * 1000).toISOString().slice(0, 10)
353
+ : 'never';
354
+ const spent = (p.total_sol_spent ?? 0) / 1e9;
355
+ const received = (p.total_sol_received ?? 0) / 1e9;
356
+ const pnl = received - spent;
357
+ const pnlStr = pnl >= 0 ? `+${pnl.toFixed(3)}` : pnl.toFixed(3);
358
+ return ` @${targetAddress.slice(0, 8)}: "${personality}" | ${total} actions (${topActions}) | P&L: ${pnlStr} SOL | last seen: ${checkpoint}`;
359
+ }
360
+ catch {
361
+ return ` @${targetAddress.slice(0, 8)}: lookup failed`;
362
+ }
363
+ }
313
364
  async siege(params) {
314
365
  return (0, torchsdk_1.buildLiquidateTransaction)(this.connection, {
315
366
  mint: params.mint,
@@ -8,15 +8,16 @@
8
8
  import { Connection, PublicKey } from '@solana/web3.js';
9
9
  import type { TransactionResult } from 'torchsdk';
10
10
  import type { RegistryProfile, RegistryWalletLink, RegisterAgentParams, CheckpointParams, LinkAgentWalletParams, UnlinkAgentWalletParams, TransferAgentAuthorityParams } from '../types';
11
+ import { Registry } from '../types/registry.types';
11
12
  export declare const REGISTRY_PROGRAM_ID: PublicKey;
12
13
  export declare function getAgentProfilePda(creator: PublicKey): [PublicKey, number];
13
14
  export declare function getAgentWalletLinkPda(wallet: PublicKey): [PublicKey, number];
14
- export declare class RegistryProvider {
15
+ export declare class RegistryProvider implements Registry {
15
16
  private connection;
16
17
  constructor(connection: Connection);
17
18
  private getProgram;
18
- getProfile(creator: string): Promise<RegistryProfile | null>;
19
- getWalletLink(wallet: string): Promise<RegistryWalletLink | null>;
19
+ getProfile(creator: string): Promise<RegistryProfile | undefined>;
20
+ getWalletLink(wallet: string): Promise<RegistryWalletLink | undefined>;
20
21
  register(params: RegisterAgentParams): Promise<TransactionResult>;
21
22
  checkpoint(params: CheckpointParams): Promise<TransactionResult>;
22
23
  linkWallet(params: LinkAgentWalletParams): Promise<TransactionResult>;
@@ -87,7 +87,7 @@ class RegistryProvider {
87
87
  };
88
88
  }
89
89
  catch {
90
- return null;
90
+ return undefined;
91
91
  }
92
92
  }
93
93
  async getWalletLink(wallet) {
@@ -105,7 +105,7 @@ class RegistryProvider {
105
105
  };
106
106
  }
107
107
  catch {
108
- return null;
108
+ return undefined;
109
109
  }
110
110
  }
111
111
  // ─── Transaction Builders ─────────────────────────────────────────
@@ -7,15 +7,15 @@
7
7
  */
8
8
  import { Connection } from '@solana/web3.js';
9
9
  import type { State, AgentGameState, SerializedGameState, TrackedAction, CheckpointConfig } from '../types/state.types';
10
- import { RegistryProvider } from './registry.provider';
10
+ import { Registry } from '../types/registry.types';
11
11
  export declare class StateProvider implements State {
12
12
  private connection;
13
- private publicKey;
14
13
  private registry;
14
+ private publicKey;
15
15
  private _state;
16
16
  private checkpointConfig;
17
17
  private ticksSinceCheckpoint;
18
- constructor(connection: Connection, publicKey: string, registry: RegistryProvider);
18
+ constructor(connection: Connection, registry: Registry, publicKey: string);
19
19
  get state(): AgentGameState | null;
20
20
  get vaultCreator(): string | null;
21
21
  get initialized(): boolean;
@@ -62,15 +62,15 @@ const EMPTY_COUNTS = {
62
62
  };
63
63
  class StateProvider {
64
64
  connection;
65
- publicKey;
66
65
  registry;
66
+ publicKey;
67
67
  _state = null;
68
68
  checkpointConfig = null;
69
69
  ticksSinceCheckpoint = 0;
70
- constructor(connection, publicKey, registry) {
70
+ constructor(connection, registry, publicKey) {
71
71
  this.connection = connection;
72
- this.publicKey = publicKey;
73
72
  this.registry = registry;
73
+ this.publicKey = publicKey;
74
74
  }
75
75
  // ─── Readonly accessors ─────────────────────────────────────────
76
76
  get state() {
@@ -36,6 +36,7 @@ export interface Action {
36
36
  raze(params: RazeParams): Promise<TransactionResult>;
37
37
  repayWarLoan(params: RepayWarLoanParams): Promise<TransactionResult>;
38
38
  requestWarLoan(params: RequestWarLoanParams): Promise<TransactionResult>;
39
+ scout(targetAddress: string): Promise<string>;
39
40
  siege(params: SiegeParams): Promise<TransactionResult>;
40
41
  tithe(params: TitheParams): Promise<TransactionResult>;
41
42
  }
@@ -0,0 +1,10 @@
1
+ import { CheckpointParams, LinkAgentWalletParams, RegisterAgentParams, RegistryProfile, RegistryWalletLink, TransactionResult, TransferAgentAuthorityParams, UnlinkAgentWalletParams } from '../types';
2
+ export interface Registry {
3
+ getProfile(creator: string): Promise<RegistryProfile | undefined>;
4
+ getWalletLink(wallet: string): Promise<RegistryWalletLink | undefined>;
5
+ register(params: RegisterAgentParams): Promise<TransactionResult>;
6
+ checkpoint(params: CheckpointParams): Promise<TransactionResult>;
7
+ linkWallet(params: LinkAgentWalletParams): Promise<TransactionResult>;
8
+ unlinkWallet(params: UnlinkAgentWalletParams): Promise<TransactionResult>;
9
+ transferAuthority(params: TransferAgentAuthorityParams): Promise<TransactionResult>;
10
+ }
@@ -1 +1,2 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyre-world-kit",
3
- "version": "3.0.1",
3
+ "version": "3.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/index.ts CHANGED
@@ -14,19 +14,20 @@ import { StateProvider } from './providers/state.provider'
14
14
  import type { Action } from './types/action.types'
15
15
  import type { Intel } from './types/intel.types'
16
16
  import type { State, CheckpointConfig, TrackedAction } from './types/state.types'
17
+ import { Registry } from './types/registry.types'
17
18
 
18
19
  // ─── Top-level Kit ────────────────────────────────────────────────
19
20
 
20
21
  export class PyreKit {
21
22
  readonly actions: ActionProvider
22
23
  readonly intel: IntelProvider
23
- readonly registry: RegistryProvider
24
+ readonly registry: Registry
24
25
  readonly state: StateProvider
25
26
 
26
27
  constructor(connection: Connection, publicKey: string) {
27
28
  this.registry = new RegistryProvider(connection)
28
- this.state = new StateProvider(connection, publicKey, this.registry)
29
- this.actions = new ActionProvider(connection)
29
+ this.state = new StateProvider(connection, this.registry, publicKey)
30
+ this.actions = new ActionProvider(connection, this.registry)
30
31
  this.intel = new IntelProvider(connection, this.actions)
31
32
 
32
33
  // Wire auto-checkpoint callback
@@ -83,10 +83,14 @@ import {
83
83
  isPyreMint,
84
84
  } from '../vanity'
85
85
  import { isBlacklistedMint } from '../util'
86
+ import { Registry } from '../types/registry.types'
86
87
 
87
88
  export class ActionProvider implements Action {
88
89
  private mapper = new MapperProvider()
89
- constructor(private connection: Connection) {}
90
+ constructor(
91
+ private connection: Connection,
92
+ private registryProvider: Registry,
93
+ ) {}
90
94
 
91
95
  async createStronghold(params: CreateStrongholdParams): Promise<TransactionResult> {
92
96
  return buildCreateVaultTransaction(this.connection, { creator: params.creator })
@@ -422,6 +426,61 @@ export class ActionProvider implements Action {
422
426
  })
423
427
  }
424
428
 
429
+ async scout(targetAddress: string): Promise<string> {
430
+ try {
431
+ const p = await this.registryProvider.getProfile(targetAddress)
432
+ if (!p) return ` @${targetAddress.slice(0, 8)}: no pyre identity found`
433
+
434
+ const total =
435
+ p.joins +
436
+ p.defects +
437
+ p.rallies +
438
+ p.launches +
439
+ p.messages +
440
+ p.fuds +
441
+ p.infiltrates +
442
+ p.reinforces +
443
+ p.war_loans +
444
+ p.repay_loans +
445
+ p.sieges +
446
+ p.ascends +
447
+ p.razes +
448
+ p.tithes
449
+
450
+ const topActions = [
451
+ { n: 'joins', v: p.joins },
452
+ { n: 'defects', v: p.defects },
453
+ { n: 'rallies', v: p.rallies },
454
+ { n: 'messages', v: p.messages },
455
+ { n: 'fuds', v: p.fuds },
456
+ { n: 'infiltrates', v: p.infiltrates },
457
+ { n: 'reinforces', v: p.reinforces },
458
+ { n: 'war_loans', v: p.war_loans },
459
+ { n: 'sieges', v: p.sieges },
460
+ ]
461
+ .sort((a, b) => b.v - a.v)
462
+ .filter((a) => a.v > 0)
463
+ .slice(0, 4)
464
+ .map((a) => `${a.n}:${a.v}`)
465
+ .join(', ')
466
+
467
+ const personality = p.personality_summary || 'unknown'
468
+ const checkpoint =
469
+ p.last_checkpoint > 0
470
+ ? new Date(p.last_checkpoint * 1000).toISOString().slice(0, 10)
471
+ : 'never'
472
+
473
+ const spent = (p.total_sol_spent ?? 0) / 1e9
474
+ const received = (p.total_sol_received ?? 0) / 1e9
475
+ const pnl = received - spent
476
+ const pnlStr = pnl >= 0 ? `+${pnl.toFixed(3)}` : pnl.toFixed(3)
477
+
478
+ return ` @${targetAddress.slice(0, 8)}: "${personality}" | ${total} actions (${topActions}) | P&L: ${pnlStr} SOL | last seen: ${checkpoint}`
479
+ } catch {
480
+ return ` @${targetAddress.slice(0, 8)}: lookup failed`
481
+ }
482
+ }
483
+
425
484
  async siege(params: SiegeParams): Promise<TransactionResult> {
426
485
  return buildLiquidateTransaction(this.connection, {
427
486
  mint: params.mint,
@@ -20,6 +20,7 @@ import type {
20
20
  } from '../types'
21
21
 
22
22
  import idl from '../pyre_world.json'
23
+ import { Registry } from '../types/registry.types'
23
24
 
24
25
  // ─── Program ID ─────────────────────────────────────────────────────
25
26
 
@@ -69,7 +70,7 @@ async function finalizeTransaction(
69
70
 
70
71
  // ─── Provider ───────────────────────────────────────────────────────
71
72
 
72
- export class RegistryProvider {
73
+ export class RegistryProvider implements Registry {
73
74
  constructor(private connection: Connection) {}
74
75
 
75
76
  private getProgram(payer: PublicKey): Program {
@@ -79,7 +80,7 @@ export class RegistryProvider {
79
80
 
80
81
  // ─── Read Operations ──────────────────────────────────────────────
81
82
 
82
- async getProfile(creator: string): Promise<RegistryProfile | null> {
83
+ async getProfile(creator: string): Promise<RegistryProfile | undefined> {
83
84
  const creatorPk = new PublicKey(creator)
84
85
  const [profilePda] = getAgentProfilePda(creatorPk)
85
86
  const program = this.getProgram(creatorPk)
@@ -113,11 +114,11 @@ export class RegistryProvider {
113
114
  total_sol_received: account.totalSolReceived?.toNumber() ?? 0,
114
115
  }
115
116
  } catch {
116
- return null
117
+ return undefined
117
118
  }
118
119
  }
119
120
 
120
- async getWalletLink(wallet: string): Promise<RegistryWalletLink | null> {
121
+ async getWalletLink(wallet: string): Promise<RegistryWalletLink | undefined> {
121
122
  const walletPk = new PublicKey(wallet)
122
123
  const [linkPda] = getAgentWalletLinkPda(walletPk)
123
124
  const program = this.getProgram(walletPk)
@@ -132,7 +133,7 @@ export class RegistryProvider {
132
133
  bump: account.bump,
133
134
  }
134
135
  } catch {
135
- return null
136
+ return undefined
136
137
  }
137
138
  }
138
139
 
@@ -17,6 +17,7 @@ import type {
17
17
  import { RegistryProvider } from './registry.provider'
18
18
  import { isPyreMint } from '../vanity'
19
19
  import { isBlacklistedMint } from '../util'
20
+ import { Registry } from '../types/registry.types'
20
21
 
21
22
  const EMPTY_COUNTS: Record<TrackedAction, number> = {
22
23
  join: 0,
@@ -40,11 +41,7 @@ export class StateProvider implements State {
40
41
  private checkpointConfig: CheckpointConfig | null = null
41
42
  private ticksSinceCheckpoint = 0
42
43
 
43
- constructor(
44
- private connection: Connection,
45
- private publicKey: string,
46
- private registry: RegistryProvider,
47
- ) {}
44
+ constructor(private connection: Connection, private registry: Registry, private publicKey: string) {}
48
45
 
49
46
  // ─── Readonly accessors ─────────────────────────────────────────
50
47
 
@@ -71,6 +71,7 @@ export interface Action {
71
71
  raze(params: RazeParams): Promise<TransactionResult>
72
72
  repayWarLoan(params: RepayWarLoanParams): Promise<TransactionResult>
73
73
  requestWarLoan(params: RequestWarLoanParams): Promise<TransactionResult>
74
+ scout(targetAddress: string): Promise<string>
74
75
  siege(params: SiegeParams): Promise<TransactionResult>
75
76
  tithe(params: TitheParams): Promise<TransactionResult>
76
77
  }
@@ -0,0 +1,21 @@
1
+ import {
2
+ CheckpointParams,
3
+ LinkAgentWalletParams,
4
+ RegisterAgentParams,
5
+ RegistryProfile,
6
+ RegistryWalletLink,
7
+ TransactionResult,
8
+ TransferAgentAuthorityParams,
9
+ UnlinkAgentWalletParams,
10
+ } from '../types'
11
+
12
+ export interface Registry {
13
+ getProfile(creator: string): Promise<RegistryProfile | undefined>
14
+ getWalletLink(wallet: string): Promise<RegistryWalletLink | undefined>
15
+
16
+ register(params: RegisterAgentParams): Promise<TransactionResult>
17
+ checkpoint(params: CheckpointParams): Promise<TransactionResult>
18
+ linkWallet(params: LinkAgentWalletParams): Promise<TransactionResult>
19
+ unlinkWallet(params: UnlinkAgentWalletParams): Promise<TransactionResult>
20
+ transferAuthority(params: TransferAgentAuthorityParams): Promise<TransactionResult>
21
+ }