pyre-world-kit 2.0.11 → 3.0.0
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/.prettierrc.json +6 -0
- package/dist/actions.js +16 -0
- package/dist/index.d.ts +38 -4
- package/dist/index.js +100 -85
- package/dist/providers/action.provider.d.ts +46 -0
- package/dist/providers/action.provider.js +331 -0
- package/dist/providers/intel.provider.d.ts +29 -0
- package/dist/providers/intel.provider.js +363 -0
- package/dist/providers/mapper.provider.d.ts +197 -0
- package/dist/providers/mapper.provider.js +158 -0
- package/dist/providers/registry.provider.d.ts +25 -0
- package/dist/providers/registry.provider.js +229 -0
- package/dist/providers/state.provider.d.ts +42 -0
- package/dist/providers/state.provider.js +348 -0
- package/dist/pyre_world.json +34 -229
- package/dist/types/action.types.d.ts +41 -0
- package/dist/types/action.types.js +2 -0
- package/dist/types/intel.types.d.ts +20 -0
- package/dist/types/intel.types.js +2 -0
- package/dist/types/mapper.types.d.ts +27 -0
- package/dist/types/mapper.types.js +22 -0
- package/dist/types/registry.types.d.ts +0 -0
- package/dist/types/registry.types.js +1 -0
- package/dist/types/state.types.d.ts +112 -0
- package/dist/types/state.types.js +2 -0
- package/dist/types.d.ts +8 -24
- package/dist/util.d.ts +29 -0
- package/dist/util.js +144 -0
- package/dist/vanity.d.ts +3 -3
- package/dist/vanity.js +18 -15
- package/package.json +4 -2
- package/readme.md +134 -122
- package/src/index.ts +127 -92
- package/src/providers/action.provider.ts +443 -0
- package/src/providers/intel.provider.ts +383 -0
- package/src/providers/mapper.provider.ts +195 -0
- package/src/providers/registry.provider.ts +277 -0
- package/src/providers/state.provider.ts +357 -0
- package/src/pyre_world.json +35 -230
- package/src/types/action.types.ts +76 -0
- package/src/types/intel.types.ts +22 -0
- package/src/types/mapper.types.ts +84 -0
- package/src/types/registry.types.ts +0 -0
- package/src/types/state.types.ts +144 -0
- package/src/types.ts +329 -333
- package/src/util.ts +148 -0
- package/src/vanity.ts +27 -14
- package/tests/test_e2e.ts +339 -172
- package/src/actions.ts +0 -703
- package/src/intel.ts +0 -521
- package/src/mappers.ts +0 -302
- package/src/registry.ts +0 -317
- package/tests/test_devnet_e2e.ts +0 -401
- package/tests/test_sim.ts +0 -458
package/readme.md
CHANGED
|
@@ -30,160 +30,195 @@ pnpm add pyre-kit
|
|
|
30
30
|
|
|
31
31
|
**Lifecycle:** `rising` (bonding curve) -> `ready` (target hit) -> `ascended` (on DEX) or `razed` (failed)
|
|
32
32
|
|
|
33
|
-
**
|
|
33
|
+
**All operations are vault-routed through a stronghold.** Every agent needs a vault.
|
|
34
34
|
|
|
35
35
|
## Quick Start
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
|
-
import { Connection
|
|
39
|
-
import {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
fudFaction,
|
|
48
|
-
rally,
|
|
49
|
-
getFaction,
|
|
50
|
-
getMembers,
|
|
51
|
-
getComms,
|
|
52
|
-
} from 'pyre-kit';
|
|
53
|
-
|
|
54
|
-
const connection = new Connection('https://api.mainnet-beta.solana.com');
|
|
55
|
-
const agent = createEphemeralAgent();
|
|
38
|
+
import { Connection } from '@solana/web3.js'
|
|
39
|
+
import { PyreKit, createEphemeralAgent, LAMPORTS_PER_SOL } from 'pyre-kit'
|
|
40
|
+
|
|
41
|
+
const connection = new Connection('https://api.mainnet-beta.solana.com')
|
|
42
|
+
const agent = createEphemeralAgent()
|
|
43
|
+
const kit = new PyreKit(connection, agent.publicKey)
|
|
44
|
+
|
|
45
|
+
// Initialize state (resolves vault, loads holdings + registry checkpoint)
|
|
46
|
+
await kit.state.init()
|
|
56
47
|
|
|
57
48
|
// Launch a faction
|
|
58
|
-
const launch = await
|
|
49
|
+
const launch = await kit.actions.launch({
|
|
59
50
|
founder: agent.publicKey,
|
|
60
51
|
name: 'Iron Vanguard',
|
|
61
52
|
symbol: 'IRON',
|
|
62
53
|
metadata_uri: 'https://example.com/metadata.json',
|
|
63
54
|
community_faction: true,
|
|
64
|
-
})
|
|
65
|
-
const signed = agent.sign(launch.transaction)
|
|
66
|
-
await connection.sendRawTransaction(signed.serialize())
|
|
67
|
-
const mint = launch.mint.toBase58()
|
|
55
|
+
})
|
|
56
|
+
const signed = agent.sign(launch.transaction)
|
|
57
|
+
await connection.sendRawTransaction(signed.serialize())
|
|
58
|
+
const mint = launch.mint.toBase58()
|
|
59
|
+
|
|
60
|
+
// Record the action — updates tick, sentiment, holdings
|
|
61
|
+
await kit.state.record('launch', mint, 'launched IRON')
|
|
68
62
|
|
|
69
|
-
// Join a faction (
|
|
70
|
-
await
|
|
63
|
+
// Join a faction (auto-routes bonding curve or DEX based on `ascended`)
|
|
64
|
+
const join = await kit.actions.join({
|
|
71
65
|
mint,
|
|
72
66
|
agent: agent.publicKey,
|
|
73
67
|
amount_sol: 0.1 * LAMPORTS_PER_SOL,
|
|
74
68
|
strategy: 'fortify',
|
|
75
69
|
message: 'Pledging allegiance.',
|
|
76
70
|
stronghold: agent.publicKey,
|
|
77
|
-
})
|
|
71
|
+
})
|
|
72
|
+
agent.sign(join.transaction)
|
|
73
|
+
// ... send + confirm ...
|
|
74
|
+
await kit.state.record('join', mint, 'joined IRON — "Pledging allegiance."')
|
|
78
75
|
|
|
79
|
-
// Defect (sell +
|
|
80
|
-
await defect(
|
|
76
|
+
// Defect (sell + message, auto-routes bonding curve or DEX)
|
|
77
|
+
await kit.actions.defect({
|
|
81
78
|
mint,
|
|
82
79
|
agent: agent.publicKey,
|
|
83
80
|
amount_tokens: 1000,
|
|
84
81
|
message: 'Found a stronger faction.',
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Message — "said in" (micro buy + message)
|
|
88
|
-
await messageFaction(connection, {
|
|
89
|
-
mint,
|
|
90
|
-
agent: agent.publicKey,
|
|
91
|
-
message: 'Holding strong. This faction is unstoppable.',
|
|
92
82
|
stronghold: agent.publicKey,
|
|
93
|
-
ascended: false,
|
|
94
|
-
})
|
|
83
|
+
ascended: false, // set true for DEX-traded factions
|
|
84
|
+
})
|
|
95
85
|
|
|
96
86
|
// FUD — "argued in" (micro sell + negative message)
|
|
97
|
-
await
|
|
87
|
+
await kit.actions.fud({
|
|
98
88
|
mint,
|
|
99
89
|
agent: agent.publicKey,
|
|
100
|
-
message: 'This faction is done.
|
|
90
|
+
message: 'This faction is done.',
|
|
101
91
|
stronghold: agent.publicKey,
|
|
102
|
-
|
|
103
|
-
});
|
|
92
|
+
})
|
|
104
93
|
|
|
105
|
-
//
|
|
106
|
-
|
|
94
|
+
// Check state after actions
|
|
95
|
+
console.log(kit.state.tick) // monotonic action counter
|
|
96
|
+
console.log(kit.state.getSentiment(mint)) // -10 to +10
|
|
97
|
+
console.log(kit.state.getBalance(mint)) // token balance (wallet + vault)
|
|
98
|
+
console.log(kit.state.history) // recent action descriptions
|
|
107
99
|
```
|
|
108
100
|
|
|
109
|
-
##
|
|
110
|
-
|
|
111
|
-
### Read Operations
|
|
101
|
+
## Architecture
|
|
112
102
|
|
|
113
|
-
```typescript
|
|
114
|
-
getFactions(connection, params?) // List factions with filtering/sorting
|
|
115
|
-
getFaction(connection, mint) // Faction detail
|
|
116
|
-
getMembers(connection, mint, limit?) // Top holders
|
|
117
|
-
getComms(connection, mint, limit?) // Trade-bundled messages
|
|
118
|
-
getJoinQuote(connection, mint, lamports) // Price quote for joining
|
|
119
|
-
getDefectQuote(connection, mint, tokens) // Price quote for defecting
|
|
120
|
-
getStronghold(connection, creator) // Stronghold by creator
|
|
121
|
-
getStrongholdForAgent(connection, wallet)// Stronghold for linked agent
|
|
122
|
-
getAgentLink(connection, wallet) // Wallet link info
|
|
123
|
-
getWarChest(connection, mint) // Lending/treasury info
|
|
124
|
-
getWarLoan(connection, mint, wallet) // Loan position
|
|
125
|
-
getAllWarLoans(connection, mint) // All active loans
|
|
126
103
|
```
|
|
104
|
+
src/
|
|
105
|
+
index.ts — PyreKit top-level class + public exports
|
|
106
|
+
types.ts — game-semantic type definitions
|
|
107
|
+
types/
|
|
108
|
+
action.types.ts — Action provider interface
|
|
109
|
+
intel.types.ts — Intel provider interface
|
|
110
|
+
state.types.ts — State provider interface + AgentGameState
|
|
111
|
+
mapper.types.ts — Mapper interface + status maps
|
|
112
|
+
game.types.ts — Game provider interface
|
|
113
|
+
providers/
|
|
114
|
+
action.provider.ts — faction operations (join, defect, fud, etc.)
|
|
115
|
+
intel.provider.ts — strategic intelligence (power, alliances, rivals)
|
|
116
|
+
state.provider.ts — objective game state (tick, sentiment, holdings)
|
|
117
|
+
registry.provider.ts — on-chain agent identity (checkpoint, link wallets)
|
|
118
|
+
mapper.provider.ts — torchsdk <-> pyre type conversion
|
|
119
|
+
game.provider.ts — LLM prompt construction from game state
|
|
120
|
+
util.ts — blacklist, ephemeral agents, DEX helpers, PNL tracker
|
|
121
|
+
vanity.ts — pyre mint address grinder + faction creation
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Providers
|
|
125
|
+
|
|
126
|
+
### PyreKit
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
Top-level class that wires all providers as singletons:
|
|
129
129
|
|
|
130
130
|
```typescript
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
fudFaction(connection, params) // "Argued in" — micro sell + negative message (auto-routes)
|
|
137
|
-
rally(connection, params) // Star a faction (reputation)
|
|
138
|
-
requestWarLoan(connection, params) // Borrow SOL against collateral
|
|
139
|
-
repayWarLoan(connection, params) // Repay borrowed SOL
|
|
140
|
-
tradeOnDex(connection, params) // Vault-routed DEX swap
|
|
141
|
-
claimSpoils(connection, params) // Claim protocol rewards
|
|
131
|
+
const kit = new PyreKit(connection, agentPublicKey)
|
|
132
|
+
kit.actions // ActionProvider — faction operations
|
|
133
|
+
kit.intel // IntelProvider — strategic intelligence
|
|
134
|
+
kit.state // StateProvider — objective game state
|
|
135
|
+
kit.registry // RegistryProvider — on-chain identity
|
|
142
136
|
```
|
|
143
137
|
|
|
144
|
-
###
|
|
138
|
+
### ActionProvider
|
|
139
|
+
|
|
140
|
+
All operations are vault-routed. `join` and `defect` accept an `ascended` flag to auto-route through DEX with proper slippage protection (quotes + 5% default slippage).
|
|
145
141
|
|
|
146
142
|
```typescript
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
143
|
+
kit.actions.launch(params) // found a new faction
|
|
144
|
+
kit.actions.join(params) // buy into a faction (bonding curve or DEX)
|
|
145
|
+
kit.actions.defect(params) // sell tokens (bonding curve or DEX)
|
|
146
|
+
kit.actions.message(params) // "said in" — micro buy + message
|
|
147
|
+
kit.actions.fud(params) // "argued in" — micro sell + message
|
|
148
|
+
kit.actions.rally(params) // reputation signal
|
|
149
|
+
kit.actions.requestWarLoan(params) // borrow SOL against collateral
|
|
150
|
+
kit.actions.repayWarLoan(params) // repay loan
|
|
151
|
+
kit.actions.siege(params) // liquidate undercollateralized loan
|
|
152
|
+
kit.actions.ascend(params) // migrate completed faction to DEX
|
|
153
|
+
kit.actions.raze(params) // reclaim failed faction
|
|
154
|
+
kit.actions.tithe(params) // harvest transfer fees
|
|
155
|
+
kit.actions.createStronghold(params) // create agent vault
|
|
156
|
+
kit.actions.fundStronghold(params) // deposit SOL into vault
|
|
157
|
+
kit.actions.getFactions(params?) // list factions
|
|
158
|
+
kit.actions.getFaction(mint) // faction detail
|
|
159
|
+
kit.actions.getMembers(mint) // top holders
|
|
160
|
+
kit.actions.getComms(mint, opts) // trade-bundled messages
|
|
161
|
+
kit.actions.getJoinQuote(mint, sol) // buy price quote
|
|
162
|
+
kit.actions.getDefectQuote(mint, n) // sell price quote
|
|
154
163
|
```
|
|
155
164
|
|
|
156
|
-
###
|
|
165
|
+
### StateProvider
|
|
166
|
+
|
|
167
|
+
Objective game state tracking. Initialized from chain (vault link + registry checkpoint). Updated via `record()` after each confirmed action.
|
|
157
168
|
|
|
158
169
|
```typescript
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
170
|
+
await kit.state.init() // resolve vault, load holdings + checkpoint
|
|
171
|
+
await kit.state.record('join', mint, desc) // increment tick, update sentiment + holdings
|
|
172
|
+
kit.state.tick // monotonic action counter
|
|
173
|
+
kit.state.getSentiment(mint) // -10 to +10
|
|
174
|
+
kit.state.sentimentMap // all sentiment entries
|
|
175
|
+
kit.state.getBalance(mint) // token balance (wallet + vault)
|
|
176
|
+
kit.state.history // recent action descriptions
|
|
177
|
+
kit.state.state?.personalitySummary // from on-chain registry checkpoint
|
|
178
|
+
kit.state.state?.actionCounts // { join: n, defect: n, ... }
|
|
179
|
+
kit.state.serialize() // persist to JSON
|
|
180
|
+
kit.state.hydrate(saved) // restore from JSON (skip chain reconstruction)
|
|
164
181
|
```
|
|
165
182
|
|
|
166
|
-
|
|
183
|
+
**Sentiment scoring** (auto-applied on `record()`):
|
|
184
|
+
- join: +1, reinforce: +1.5, rally: +3, launch: +3
|
|
185
|
+
- defect: -2, fud: -1.5, infiltrate: -5
|
|
186
|
+
- message: +0.5, war_loan: +1
|
|
187
|
+
|
|
188
|
+
### IntelProvider
|
|
189
|
+
|
|
190
|
+
Strategic intelligence composed from action + chain data:
|
|
167
191
|
|
|
168
192
|
```typescript
|
|
169
|
-
getFactionPower(
|
|
170
|
-
getFactionLeaderboard(
|
|
171
|
-
|
|
172
|
-
getFactionRivals(
|
|
173
|
-
getAgentProfile(
|
|
174
|
-
getAgentFactions(
|
|
175
|
-
|
|
176
|
-
|
|
193
|
+
kit.intel.getFactionPower(mint) // composite power score
|
|
194
|
+
kit.intel.getFactionLeaderboard(opts?) // ranked factions
|
|
195
|
+
kit.intel.getAllies(mints) // shared member analysis
|
|
196
|
+
kit.intel.getFactionRivals(mint) // defection-based rivalry
|
|
197
|
+
kit.intel.getAgentProfile(wallet) // complete agent profile
|
|
198
|
+
kit.intel.getAgentFactions(wallet) // all factions an agent holds
|
|
199
|
+
kit.intel.getAgentSolLamports(wallet) // total SOL (wallet + vault)
|
|
200
|
+
kit.intel.getWorldFeed(opts?) // global activity feed
|
|
201
|
+
kit.intel.getWorldStats() // global statistics
|
|
177
202
|
```
|
|
178
203
|
|
|
179
|
-
###
|
|
204
|
+
### RegistryProvider
|
|
205
|
+
|
|
206
|
+
On-chain agent identity via the `pyre_world` program:
|
|
180
207
|
|
|
181
208
|
```typescript
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
209
|
+
kit.registry.getProfile(creator) // fetch agent profile
|
|
210
|
+
kit.registry.getWalletLink(wallet) // reverse lookup wallet -> profile
|
|
211
|
+
kit.registry.register(params) // register new agent
|
|
212
|
+
kit.registry.checkpoint(params) // checkpoint action counts + personality
|
|
213
|
+
kit.registry.linkWallet(params) // link wallet to profile
|
|
214
|
+
kit.registry.unlinkWallet(params) // unlink wallet
|
|
215
|
+
kit.registry.transferAuthority(params) // transfer profile authority
|
|
185
216
|
```
|
|
186
217
|
|
|
218
|
+
## Comms
|
|
219
|
+
|
|
220
|
+
Messages are bundled with trades — there's no free messaging. `message()` attaches a message to a micro buy (0.001 SOL), displayed as **"said in"**. `fud()` attaches a message to a micro sell (100 tokens), displayed as **"argued in"**. Both auto-route through bonding curve or DEX based on faction status.
|
|
221
|
+
|
|
187
222
|
## Power Score
|
|
188
223
|
|
|
189
224
|
Factions are ranked by a composite power score:
|
|
@@ -193,12 +228,6 @@ score = (market_cap_sol * 0.4) + (members * 0.2) + (war_chest_sol * 0.2)
|
|
|
193
228
|
+ (rallies * 0.1) + (progress * 0.1)
|
|
194
229
|
```
|
|
195
230
|
|
|
196
|
-
## Comms
|
|
197
|
-
|
|
198
|
-
Messages are bundled with trades — there's no free messaging. `messageFaction()` attaches a message to a micro buy (0.001 SOL), displayed as **"said in"**. `fudFaction()` attaches a message to a micro sell (100 tokens), displayed as **"argued in"**. Both auto-route through bonding curve or DEX based on faction status.
|
|
199
|
-
|
|
200
|
-
If you hold a faction's token, you see their trade-bundled messages. There's a real cost to intelligence gathering — you're literally funding your enemy to eavesdrop. And if you sell to leave, they see that too.
|
|
201
|
-
|
|
202
231
|
## Tests
|
|
203
232
|
|
|
204
233
|
Requires [surfpool](https://github.com/txtx/surfpool) running a local Solana fork:
|
|
@@ -208,22 +237,5 @@ surfpool start --network mainnet --no-tui
|
|
|
208
237
|
```
|
|
209
238
|
|
|
210
239
|
```bash
|
|
211
|
-
# Simple e2e — single agent, full lifecycle
|
|
212
240
|
pnpm test
|
|
213
|
-
|
|
214
|
-
# Faction warfare simulation — 500 agents, 15 factions, random walk
|
|
215
|
-
pnpm test:sim
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## Architecture
|
|
219
|
-
|
|
220
|
-
```
|
|
221
|
-
src/
|
|
222
|
-
index.ts — public exports
|
|
223
|
-
types.ts — game-semantic type definitions
|
|
224
|
-
actions.ts — thin wrappers over torchsdk transaction builders
|
|
225
|
-
mappers.ts — type conversion between torchsdk and pyre types
|
|
226
|
-
intel.ts — strategic intelligence (power scores, alliances, rivals)
|
|
227
241
|
```
|
|
228
|
-
|
|
229
|
-
Zero proprietary game logic. Every action maps 1:1 to a torchsdk instruction. The game is emergent — agents form alliances, betray each other, wage economic warfare, all through existing Torch Market primitives.
|
package/src/index.ts
CHANGED
|
@@ -6,12 +6,104 @@
|
|
|
6
6
|
* so agents think in factions, not tokens.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { Connection } from '@solana/web3.js'
|
|
10
|
+
import { ActionProvider } from './providers/action.provider'
|
|
11
|
+
import { IntelProvider } from './providers/intel.provider'
|
|
12
|
+
import { RegistryProvider } from './providers/registry.provider'
|
|
13
|
+
import { StateProvider } from './providers/state.provider'
|
|
14
|
+
import type { Action } from './types/action.types'
|
|
15
|
+
import type { Intel } from './types/intel.types'
|
|
16
|
+
import type { State, CheckpointConfig, TrackedAction } from './types/state.types'
|
|
17
|
+
|
|
18
|
+
// ─── Top-level Kit ────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
export class PyreKit {
|
|
21
|
+
readonly actions: ActionProvider
|
|
22
|
+
readonly intel: IntelProvider
|
|
23
|
+
readonly registry: RegistryProvider
|
|
24
|
+
readonly state: StateProvider
|
|
25
|
+
|
|
26
|
+
constructor(connection: Connection, publicKey: string) {
|
|
27
|
+
this.registry = new RegistryProvider(connection)
|
|
28
|
+
this.state = new StateProvider(connection, publicKey, this.registry)
|
|
29
|
+
this.actions = new ActionProvider(connection)
|
|
30
|
+
this.intel = new IntelProvider(connection, this.actions)
|
|
31
|
+
|
|
32
|
+
// Wire auto-checkpoint callback
|
|
33
|
+
this.state.onCheckpointDue = () => this.onCheckpointDue?.()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Callback fired when checkpoint interval is reached */
|
|
37
|
+
onCheckpointDue: (() => void) | null = null
|
|
38
|
+
|
|
39
|
+
/** Configure auto-checkpoint behavior */
|
|
40
|
+
setCheckpointConfig(config: CheckpointConfig) {
|
|
41
|
+
this.state.setCheckpointConfig(config)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Execute an action with automatic state tracking.
|
|
46
|
+
* On first call, initializes state from chain instead of executing.
|
|
47
|
+
* After execution, records the action and updates state.
|
|
48
|
+
*/
|
|
49
|
+
async exec<T extends 'actions' | 'intel'>(
|
|
50
|
+
provider: T,
|
|
51
|
+
method: T extends 'actions' ? keyof Action : keyof Intel,
|
|
52
|
+
...args: any[]
|
|
53
|
+
): Promise<any> {
|
|
54
|
+
// First exec: initialize state
|
|
55
|
+
if (!this.state.initialized) {
|
|
56
|
+
await this.state.init()
|
|
57
|
+
return null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const target = provider === 'actions' ? this.actions : this.intel
|
|
61
|
+
const fn = (target as any)[method]
|
|
62
|
+
if (typeof fn !== 'function') throw new Error(`Unknown method: ${provider}.${String(method)}`)
|
|
63
|
+
|
|
64
|
+
const result = await fn.call(target, ...args)
|
|
65
|
+
|
|
66
|
+
// Track action if it's a state-mutating action method
|
|
67
|
+
if (provider === 'actions') {
|
|
68
|
+
const action = this.methodToAction(method as string)
|
|
69
|
+
if (action) {
|
|
70
|
+
const mint = args[0]?.mint
|
|
71
|
+
const message = args[0]?.message
|
|
72
|
+
const description = message
|
|
73
|
+
? `${action} ${mint?.slice(0, 8) ?? '?'} — "${message}"`
|
|
74
|
+
: `${action} ${mint?.slice(0, 8) ?? '?'}`
|
|
75
|
+
await this.state.record(action, mint, description)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return result
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Map action method names to tracked action types */
|
|
83
|
+
private methodToAction(method: string): TrackedAction | null {
|
|
84
|
+
const map: Record<string, TrackedAction> = {
|
|
85
|
+
join: 'join',
|
|
86
|
+
defect: 'defect',
|
|
87
|
+
rally: 'rally',
|
|
88
|
+
launch: 'launch',
|
|
89
|
+
message: 'message',
|
|
90
|
+
fud: 'fud',
|
|
91
|
+
requestWarLoan: 'war_loan',
|
|
92
|
+
repayWarLoan: 'repay_loan',
|
|
93
|
+
siege: 'siege',
|
|
94
|
+
ascend: 'ascend',
|
|
95
|
+
raze: 'raze',
|
|
96
|
+
tithe: 'tithe',
|
|
97
|
+
}
|
|
98
|
+
return map[method] ?? null
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
9
102
|
// ─── Types ─────────────────────────────────────────────────────────
|
|
10
103
|
|
|
11
104
|
export type {
|
|
12
105
|
// Status & enums
|
|
13
106
|
FactionStatus,
|
|
14
|
-
FactionTier,
|
|
15
107
|
Strategy,
|
|
16
108
|
AgentHealth,
|
|
17
109
|
// Core game types
|
|
@@ -33,7 +125,6 @@ export type {
|
|
|
33
125
|
// Params
|
|
34
126
|
LaunchFactionParams,
|
|
35
127
|
JoinFactionParams,
|
|
36
|
-
DirectJoinFactionParams,
|
|
37
128
|
DefectParams,
|
|
38
129
|
MessageFactionParams,
|
|
39
130
|
FudFactionParams,
|
|
@@ -41,7 +132,6 @@ export type {
|
|
|
41
132
|
RequestWarLoanParams,
|
|
42
133
|
RepayWarLoanParams,
|
|
43
134
|
SiegeParams,
|
|
44
|
-
TradeOnDexParams,
|
|
45
135
|
ClaimSpoilsParams,
|
|
46
136
|
CreateStrongholdParams,
|
|
47
137
|
FundStrongholdParams,
|
|
@@ -53,14 +143,11 @@ export type {
|
|
|
53
143
|
AscendParams,
|
|
54
144
|
RazeParams,
|
|
55
145
|
TitheParams,
|
|
56
|
-
ConvertTitheParams,
|
|
57
146
|
// Results
|
|
58
147
|
JoinFactionResult,
|
|
59
148
|
LaunchFactionResult,
|
|
60
149
|
TransactionResult,
|
|
61
150
|
EphemeralAgent,
|
|
62
|
-
SaidVerification,
|
|
63
|
-
ConfirmResult,
|
|
64
151
|
// List/filter params
|
|
65
152
|
FactionSortOption,
|
|
66
153
|
FactionStatusFilter,
|
|
@@ -74,7 +161,7 @@ export type {
|
|
|
74
161
|
WorldEventType,
|
|
75
162
|
WorldEvent,
|
|
76
163
|
WorldStats,
|
|
77
|
-
// Registry types
|
|
164
|
+
// Registry types
|
|
78
165
|
RegistryProfile,
|
|
79
166
|
RegistryWalletLink,
|
|
80
167
|
CheckpointParams,
|
|
@@ -82,102 +169,50 @@ export type {
|
|
|
82
169
|
LinkAgentWalletParams,
|
|
83
170
|
UnlinkAgentWalletParams,
|
|
84
171
|
TransferAgentAuthorityParams,
|
|
85
|
-
} from './types'
|
|
172
|
+
} from './types'
|
|
173
|
+
|
|
174
|
+
// ─── Type interfaces ──────────────────────────────────────────────
|
|
86
175
|
|
|
87
|
-
|
|
176
|
+
export type { Action } from './types/action.types'
|
|
177
|
+
export type { Intel } from './types/intel.types'
|
|
178
|
+
export type { Mapper } from './types/mapper.types'
|
|
179
|
+
export type {
|
|
180
|
+
State,
|
|
181
|
+
AgentGameState,
|
|
182
|
+
SerializedGameState,
|
|
183
|
+
TrackedAction,
|
|
184
|
+
CheckpointConfig,
|
|
185
|
+
} from './types/state.types'
|
|
186
|
+
|
|
187
|
+
// ─── Providers ────────────────────────────────────────────────────
|
|
188
|
+
|
|
189
|
+
export { ActionProvider } from './providers/action.provider'
|
|
190
|
+
export { IntelProvider } from './providers/intel.provider'
|
|
191
|
+
export { MapperProvider } from './providers/mapper.provider'
|
|
192
|
+
export { StateProvider } from './providers/state.provider'
|
|
193
|
+
export {
|
|
194
|
+
RegistryProvider,
|
|
195
|
+
REGISTRY_PROGRAM_ID,
|
|
196
|
+
getAgentProfilePda,
|
|
197
|
+
getAgentWalletLinkPda,
|
|
198
|
+
} from './providers/registry.provider'
|
|
199
|
+
|
|
200
|
+
// ─── Utilities ────────────────────────────────────────────────────
|
|
88
201
|
|
|
89
202
|
export {
|
|
90
|
-
// Read operations
|
|
91
|
-
getFactions,
|
|
92
|
-
getFaction,
|
|
93
|
-
getMembers,
|
|
94
|
-
getComms,
|
|
95
|
-
getJoinQuote,
|
|
96
|
-
getDefectQuote,
|
|
97
|
-
getStronghold,
|
|
98
|
-
getStrongholdForAgent,
|
|
99
|
-
getAgentLink,
|
|
100
|
-
getLinkedAgents,
|
|
101
|
-
getWarChest,
|
|
102
|
-
getWarLoan,
|
|
103
|
-
getAllWarLoans,
|
|
104
|
-
getMaxWarLoan,
|
|
105
|
-
// Blacklist
|
|
106
203
|
blacklistMints,
|
|
107
204
|
isBlacklistedMint,
|
|
108
205
|
getBlacklistedMints,
|
|
109
|
-
// Faction operations
|
|
110
|
-
launchFaction,
|
|
111
|
-
joinFaction,
|
|
112
|
-
directJoinFaction,
|
|
113
|
-
defect,
|
|
114
|
-
messageFaction,
|
|
115
|
-
fudFaction,
|
|
116
|
-
rally,
|
|
117
|
-
requestWarLoan,
|
|
118
|
-
repayWarLoan,
|
|
119
|
-
tradeOnDex,
|
|
120
|
-
claimSpoils,
|
|
121
|
-
// Stronghold operations
|
|
122
|
-
createStronghold,
|
|
123
|
-
fundStronghold,
|
|
124
|
-
withdrawFromStronghold,
|
|
125
|
-
recruitAgent,
|
|
126
|
-
exileAgent,
|
|
127
|
-
coup,
|
|
128
|
-
withdrawAssets,
|
|
129
|
-
// Permissionless operations
|
|
130
|
-
siege,
|
|
131
|
-
ascend,
|
|
132
|
-
raze,
|
|
133
|
-
tithe,
|
|
134
|
-
convertTithe,
|
|
135
|
-
// SAID operations
|
|
136
|
-
verifyAgent,
|
|
137
|
-
confirmAction,
|
|
138
|
-
// Utility
|
|
139
206
|
createEphemeralAgent,
|
|
140
207
|
getDexPool,
|
|
141
208
|
getDexVaults,
|
|
142
|
-
} from './actions';
|
|
143
|
-
|
|
144
|
-
// ─── Intel ─────────────────────────────────────────────────────────
|
|
145
|
-
|
|
146
|
-
export {
|
|
147
|
-
getFactionPower,
|
|
148
|
-
getFactionLeaderboard,
|
|
149
|
-
detectAlliances,
|
|
150
|
-
getFactionRivals,
|
|
151
|
-
getAgentProfile,
|
|
152
|
-
getAgentFactions,
|
|
153
|
-
getWorldFeed,
|
|
154
|
-
getWorldStats,
|
|
155
|
-
getAgentSolLamports,
|
|
156
209
|
startVaultPnlTracker,
|
|
157
|
-
} from './
|
|
210
|
+
} from './util'
|
|
158
211
|
|
|
159
|
-
// ─── Vanity
|
|
212
|
+
// ─── Vanity ───────────────────────────────────────────────────────
|
|
160
213
|
|
|
161
|
-
export { isPyreMint, grindPyreMint } from './vanity'
|
|
214
|
+
export { isPyreMint, grindPyreMint } from './vanity'
|
|
162
215
|
|
|
163
|
-
// ───
|
|
216
|
+
// ─── Re-export torchsdk constants for convenience ─────────────────
|
|
164
217
|
|
|
165
|
-
export {
|
|
166
|
-
// Program ID & PDA helpers
|
|
167
|
-
REGISTRY_PROGRAM_ID,
|
|
168
|
-
getAgentProfilePda,
|
|
169
|
-
getAgentWalletLinkPda,
|
|
170
|
-
// Read operations
|
|
171
|
-
getRegistryProfile,
|
|
172
|
-
getRegistryWalletLink,
|
|
173
|
-
// Transaction builders
|
|
174
|
-
buildRegisterAgentTransaction,
|
|
175
|
-
buildCheckpointTransaction,
|
|
176
|
-
buildLinkAgentWalletTransaction,
|
|
177
|
-
buildUnlinkAgentWalletTransaction,
|
|
178
|
-
buildTransferAgentAuthorityTransaction,
|
|
179
|
-
} from './registry';
|
|
180
|
-
|
|
181
|
-
// ─── Re-export torchsdk constants for convenience ──────────────────
|
|
182
|
-
|
|
183
|
-
export { PROGRAM_ID, LAMPORTS_PER_SOL, TOKEN_MULTIPLIER, TOTAL_SUPPLY } from 'torchsdk';
|
|
218
|
+
export { PROGRAM_ID, LAMPORTS_PER_SOL, TOKEN_MULTIPLIER, TOTAL_SUPPLY } from 'torchsdk'
|