pyre-world-kit 3.1.2 → 3.2.1
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 +1 -1
- package/dist/providers/action.provider.js +1 -1
- package/dist/providers/intel.provider.d.ts +8 -2
- package/dist/providers/intel.provider.js +159 -36
- package/dist/providers/registry.provider.d.ts +3 -2
- package/dist/providers/registry.provider.js +29 -29
- package/dist/providers/state.provider.d.ts +11 -4
- package/dist/providers/state.provider.js +165 -132
- package/dist/types/intel.types.d.ts +8 -2
- package/dist/types/state.types.d.ts +11 -16
- package/dist/types.d.ts +5 -0
- package/dist/vanity.d.ts +2 -2
- package/dist/vanity.js +8 -11
- package/package.json +1 -1
- package/readme.md +79 -18
- package/src/index.ts +1 -0
- package/src/providers/action.provider.ts +1 -2
- package/src/providers/intel.provider.ts +182 -36
- package/src/providers/registry.provider.ts +24 -22
- package/src/providers/state.provider.ts +196 -151
- package/src/types/intel.types.ts +9 -1
- package/src/types/state.types.ts +14 -18
- package/src/types.ts +6 -0
- package/src/vanity.ts +15 -13
- package/tests/test_e2e.ts +145 -23
|
@@ -37,6 +37,9 @@ exports.StateProvider = void 0;
|
|
|
37
37
|
const web3_js_1 = require("@solana/web3.js");
|
|
38
38
|
const vanity_1 = require("../vanity");
|
|
39
39
|
const util_1 = require("../util");
|
|
40
|
+
// Pre-warm imports — resolved once, cached as module-level promises
|
|
41
|
+
const splTokenImport = Promise.resolve().then(() => __importStar(require('@solana/spl-token')));
|
|
42
|
+
const torchsdkImport = Promise.resolve().then(() => __importStar(require('torchsdk')));
|
|
40
43
|
const EMPTY_COUNTS = {
|
|
41
44
|
join: 0,
|
|
42
45
|
defect: 0,
|
|
@@ -60,6 +63,10 @@ class StateProvider {
|
|
|
60
63
|
_state = null;
|
|
61
64
|
checkpointConfig = null;
|
|
62
65
|
ticksSinceCheckpoint = 0;
|
|
66
|
+
// Lazy vault — undefined = not resolved, null = resolved to nothing
|
|
67
|
+
_vaultCreator = undefined;
|
|
68
|
+
_stronghold = undefined;
|
|
69
|
+
_vaultPromise = null;
|
|
63
70
|
constructor(connection, registry, publicKey) {
|
|
64
71
|
this.connection = connection;
|
|
65
72
|
this.registry = registry;
|
|
@@ -68,90 +75,108 @@ class StateProvider {
|
|
|
68
75
|
get state() {
|
|
69
76
|
return this._state;
|
|
70
77
|
}
|
|
71
|
-
get vaultCreator() {
|
|
72
|
-
return this._state?.vaultCreator ?? null;
|
|
73
|
-
}
|
|
74
78
|
get initialized() {
|
|
75
79
|
return this._state?.initialized ?? false;
|
|
76
80
|
}
|
|
77
81
|
get tick() {
|
|
78
82
|
return this._state?.tick ?? 0;
|
|
79
83
|
}
|
|
80
|
-
/** Configure auto-checkpoint behavior */
|
|
81
84
|
setCheckpointConfig(config) {
|
|
82
85
|
this.checkpointConfig = config;
|
|
83
86
|
}
|
|
84
|
-
async
|
|
85
|
-
if (this.
|
|
86
|
-
return
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
total_withdrawn: vault.total_withdrawn,
|
|
119
|
-
total_spent: vault.total_spent,
|
|
120
|
-
total_received: vault.total_received,
|
|
121
|
-
linked_agents: vault.linked_wallets,
|
|
122
|
-
created_at: vault.created_at,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
87
|
+
async resolveVault() {
|
|
88
|
+
if (this._vaultCreator !== undefined)
|
|
89
|
+
return;
|
|
90
|
+
if (!this._vaultPromise) {
|
|
91
|
+
this._vaultPromise = (async () => {
|
|
92
|
+
const { getVaultForWallet } = await torchsdkImport;
|
|
93
|
+
try {
|
|
94
|
+
const vault = await getVaultForWallet(this.connection, this.publicKey);
|
|
95
|
+
if (vault) {
|
|
96
|
+
this._vaultCreator = vault.creator;
|
|
97
|
+
this._stronghold = {
|
|
98
|
+
address: vault.address,
|
|
99
|
+
creator: vault.creator,
|
|
100
|
+
authority: vault.authority,
|
|
101
|
+
sol_balance: vault.sol_balance,
|
|
102
|
+
total_deposited: vault.total_deposited,
|
|
103
|
+
total_withdrawn: vault.total_withdrawn,
|
|
104
|
+
total_spent: vault.total_spent,
|
|
105
|
+
total_received: vault.total_received,
|
|
106
|
+
linked_agents: vault.linked_wallets,
|
|
107
|
+
created_at: vault.created_at,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
this._vaultCreator = null;
|
|
112
|
+
this._stronghold = null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
this._vaultCreator = null;
|
|
117
|
+
this._stronghold = null;
|
|
118
|
+
}
|
|
119
|
+
this._vaultPromise = null;
|
|
120
|
+
})();
|
|
125
121
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
122
|
+
return this._vaultPromise;
|
|
123
|
+
}
|
|
124
|
+
async getVaultCreator() {
|
|
125
|
+
await this.resolveVault();
|
|
126
|
+
return this._vaultCreator ?? null;
|
|
127
|
+
}
|
|
128
|
+
async getStronghold() {
|
|
129
|
+
await this.resolveVault();
|
|
130
|
+
return this._stronghold ?? null;
|
|
131
|
+
}
|
|
132
|
+
async init() {
|
|
133
|
+
if (!this._state?.initialized) {
|
|
134
|
+
const state = {
|
|
135
|
+
publicKey: this.publicKey,
|
|
136
|
+
tick: 0,
|
|
137
|
+
actionCounts: { ...EMPTY_COUNTS },
|
|
138
|
+
activeLoans: new Set(),
|
|
139
|
+
founded: [],
|
|
140
|
+
rallied: new Set(),
|
|
141
|
+
voted: new Set(),
|
|
142
|
+
sentiment: new Map(),
|
|
143
|
+
recentHistory: [],
|
|
144
|
+
personalitySummary: null,
|
|
145
|
+
totalSolSpent: 0,
|
|
146
|
+
totalSolReceived: 0,
|
|
147
|
+
initialized: false,
|
|
148
|
+
};
|
|
149
|
+
// Fire vault resolution in background — don't block init
|
|
150
|
+
this.resolveVault();
|
|
151
|
+
try {
|
|
152
|
+
const profile = await this.registry.getProfile(this.publicKey);
|
|
153
|
+
if (profile) {
|
|
154
|
+
state.personalitySummary = profile.personality_summary || null;
|
|
155
|
+
state.totalSolSpent = profile.total_sol_spent;
|
|
156
|
+
state.totalSolReceived = profile.total_sol_received;
|
|
157
|
+
state.actionCounts.join = Math.max(state.actionCounts.join, profile.joins);
|
|
158
|
+
state.actionCounts.defect = Math.max(state.actionCounts.defect, profile.defects);
|
|
159
|
+
state.actionCounts.rally = Math.max(state.actionCounts.rally, profile.rallies);
|
|
160
|
+
state.actionCounts.launch = Math.max(state.actionCounts.launch, profile.launches);
|
|
161
|
+
state.actionCounts.message = Math.max(state.actionCounts.message, profile.messages);
|
|
162
|
+
state.actionCounts.reinforce = Math.max(state.actionCounts.reinforce, profile.reinforces);
|
|
163
|
+
state.actionCounts.fud = Math.max(state.actionCounts.fud, profile.fuds);
|
|
164
|
+
state.actionCounts.infiltrate = Math.max(state.actionCounts.infiltrate, profile.infiltrates);
|
|
165
|
+
state.actionCounts.war_loan = Math.max(state.actionCounts.war_loan, profile.war_loans);
|
|
166
|
+
state.actionCounts.repay_loan = Math.max(state.actionCounts.repay_loan, profile.repay_loans);
|
|
167
|
+
state.actionCounts.siege = Math.max(state.actionCounts.siege, profile.sieges);
|
|
168
|
+
state.actionCounts.ascend = Math.max(state.actionCounts.ascend, profile.ascends);
|
|
169
|
+
state.actionCounts.raze = Math.max(state.actionCounts.raze, profile.razes);
|
|
170
|
+
state.actionCounts.tithe = Math.max(state.actionCounts.tithe, profile.tithes);
|
|
171
|
+
const totalFromCheckpoint = Object.values(state.actionCounts).reduce((a, b) => a + b, 0);
|
|
172
|
+
state.tick = totalFromCheckpoint;
|
|
173
|
+
}
|
|
149
174
|
}
|
|
175
|
+
catch { }
|
|
176
|
+
state.initialized = true;
|
|
177
|
+
this._state = state;
|
|
150
178
|
}
|
|
151
|
-
|
|
152
|
-
await this.refreshHoldings();
|
|
153
|
-
state.initialized = true;
|
|
154
|
-
return state;
|
|
179
|
+
return this._state;
|
|
155
180
|
}
|
|
156
181
|
async record(action, mint, description) {
|
|
157
182
|
if (!this._state)
|
|
@@ -171,7 +196,10 @@ class StateProvider {
|
|
|
171
196
|
this._state.recentHistory = this._state.recentHistory.slice(-20);
|
|
172
197
|
}
|
|
173
198
|
}
|
|
174
|
-
|
|
199
|
+
// Sync P&L from vault every 10 ticks
|
|
200
|
+
if (this._state.tick % 10 === 0) {
|
|
201
|
+
this.syncPnl();
|
|
202
|
+
}
|
|
175
203
|
if (this.checkpointConfig && this.ticksSinceCheckpoint >= this.checkpointConfig.interval) {
|
|
176
204
|
this.ticksSinceCheckpoint = 0;
|
|
177
205
|
this.onCheckpointDue?.();
|
|
@@ -182,15 +210,15 @@ class StateProvider {
|
|
|
182
210
|
return;
|
|
183
211
|
const current = this._state.sentiment.get(mint) ?? 0;
|
|
184
212
|
const SENTIMENT_DELTAS = {
|
|
185
|
-
join: 1,
|
|
186
|
-
reinforce:
|
|
187
|
-
defect: -2,
|
|
188
|
-
rally: 3,
|
|
189
|
-
infiltrate: -5,
|
|
190
|
-
message: 0.
|
|
191
|
-
fud: -
|
|
192
|
-
war_loan: 1,
|
|
193
|
-
launch: 3,
|
|
213
|
+
join: 0.1,
|
|
214
|
+
reinforce: 0.15,
|
|
215
|
+
defect: -0.2,
|
|
216
|
+
rally: 0.3,
|
|
217
|
+
infiltrate: -0.5,
|
|
218
|
+
message: 0.05,
|
|
219
|
+
fud: -0.15,
|
|
220
|
+
war_loan: 0.1,
|
|
221
|
+
launch: 0.3,
|
|
194
222
|
};
|
|
195
223
|
const delta = SENTIMENT_DELTAS[action] ?? 0;
|
|
196
224
|
if (delta !== 0) {
|
|
@@ -198,42 +226,51 @@ class StateProvider {
|
|
|
198
226
|
}
|
|
199
227
|
}
|
|
200
228
|
onCheckpointDue = null;
|
|
201
|
-
|
|
229
|
+
/** Sync totalSolSpent/Received from on-chain vault data (fresh read) */
|
|
230
|
+
async syncPnl() {
|
|
202
231
|
if (!this._state)
|
|
203
232
|
return;
|
|
204
|
-
const { TOKEN_2022_PROGRAM_ID } = await Promise.resolve().then(() => __importStar(require('@solana/spl-token')));
|
|
205
|
-
const walletPk = new web3_js_1.PublicKey(this.publicKey);
|
|
206
|
-
let walletValues = [];
|
|
207
233
|
try {
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
catch { }
|
|
214
|
-
let vaultValues = [];
|
|
215
|
-
if (this._state.stronghold) {
|
|
216
|
-
try {
|
|
217
|
-
const vaultPk = new web3_js_1.PublicKey(this._state.stronghold.address);
|
|
218
|
-
const vaultAccounts = await this.connection.getParsedTokenAccountsByOwner(vaultPk, {
|
|
219
|
-
programId: TOKEN_2022_PROGRAM_ID,
|
|
220
|
-
});
|
|
221
|
-
vaultValues = vaultAccounts.value;
|
|
234
|
+
const { getVaultForWallet } = await torchsdkImport;
|
|
235
|
+
const vault = await getVaultForWallet(this.connection, this.publicKey);
|
|
236
|
+
if (vault) {
|
|
237
|
+
this._state.totalSolSpent = Math.round(vault.total_spent * 1e9);
|
|
238
|
+
this._state.totalSolReceived = Math.round(vault.total_received * 1e9);
|
|
222
239
|
}
|
|
223
|
-
catch { }
|
|
224
240
|
}
|
|
225
|
-
|
|
241
|
+
catch { }
|
|
242
|
+
}
|
|
243
|
+
async getHoldings() {
|
|
244
|
+
const { TOKEN_2022_PROGRAM_ID } = await splTokenImport;
|
|
245
|
+
const walletPk = new web3_js_1.PublicKey(this.publicKey);
|
|
246
|
+
// Parallel scan: wallet + vault
|
|
247
|
+
const stronghold = await this.getStronghold();
|
|
248
|
+
const scanWallet = this.connection
|
|
249
|
+
.getParsedTokenAccountsByOwner(walletPk, { programId: TOKEN_2022_PROGRAM_ID })
|
|
250
|
+
.then((r) => r.value)
|
|
251
|
+
.catch(() => []);
|
|
252
|
+
const scanVault = stronghold
|
|
253
|
+
? this.connection
|
|
254
|
+
.getParsedTokenAccountsByOwner(new web3_js_1.PublicKey(stronghold.address), {
|
|
255
|
+
programId: TOKEN_2022_PROGRAM_ID,
|
|
256
|
+
})
|
|
257
|
+
.then((r) => r.value)
|
|
258
|
+
.catch(() => [])
|
|
259
|
+
: Promise.resolve([]);
|
|
260
|
+
const [walletValues, vaultValues] = await Promise.all([scanWallet, scanVault]);
|
|
261
|
+
const holdings = new Map();
|
|
226
262
|
for (const a of [...walletValues, ...vaultValues]) {
|
|
227
263
|
const mint = a.account.data.parsed.info.mint;
|
|
228
264
|
const balance = Number(a.account.data.parsed.info.tokenAmount.uiAmount ?? 0);
|
|
229
265
|
if (balance > 0 && (0, vanity_1.isPyreMint)(mint) && !(0, util_1.isBlacklistedMint)(mint)) {
|
|
230
|
-
|
|
266
|
+
holdings.set(mint, (holdings.get(mint) ?? 0) + balance);
|
|
231
267
|
}
|
|
232
268
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
269
|
+
return holdings;
|
|
270
|
+
}
|
|
271
|
+
async getBalance(mint) {
|
|
272
|
+
const holdings = await this.getHoldings();
|
|
273
|
+
return holdings.get(mint) ?? 0;
|
|
237
274
|
}
|
|
238
275
|
getSentiment(mint) {
|
|
239
276
|
return this._state?.sentiment.get(mint) ?? 0;
|
|
@@ -244,9 +281,6 @@ class StateProvider {
|
|
|
244
281
|
get history() {
|
|
245
282
|
return this._state?.recentHistory ?? [];
|
|
246
283
|
}
|
|
247
|
-
getBalance(mint) {
|
|
248
|
-
return this._state?.holdings.get(mint) ?? 0;
|
|
249
|
-
}
|
|
250
284
|
hasVoted(mint) {
|
|
251
285
|
return this._state?.voted.has(mint) ?? false;
|
|
252
286
|
}
|
|
@@ -260,8 +294,8 @@ class StateProvider {
|
|
|
260
294
|
this._state?.rallied.add(mint);
|
|
261
295
|
}
|
|
262
296
|
serialize() {
|
|
263
|
-
|
|
264
|
-
|
|
297
|
+
return !this._state
|
|
298
|
+
? {
|
|
265
299
|
publicKey: this.publicKey,
|
|
266
300
|
vaultCreator: null,
|
|
267
301
|
tick: 0,
|
|
@@ -276,33 +310,32 @@ class StateProvider {
|
|
|
276
310
|
personalitySummary: null,
|
|
277
311
|
totalSolSpent: 0,
|
|
278
312
|
totalSolReceived: 0,
|
|
313
|
+
}
|
|
314
|
+
: {
|
|
315
|
+
publicKey: this._state.publicKey,
|
|
316
|
+
vaultCreator: this._vaultCreator ?? null,
|
|
317
|
+
tick: this._state.tick,
|
|
318
|
+
actionCounts: { ...this._state.actionCounts },
|
|
319
|
+
holdings: {},
|
|
320
|
+
activeLoans: Array.from(this._state.activeLoans),
|
|
321
|
+
founded: [...this._state.founded],
|
|
322
|
+
rallied: Array.from(this._state.rallied),
|
|
323
|
+
voted: Array.from(this._state.voted),
|
|
324
|
+
sentiment: Object.fromEntries(this._state.sentiment),
|
|
325
|
+
recentHistory: this._state.recentHistory.slice(-20),
|
|
326
|
+
personalitySummary: this._state.personalitySummary,
|
|
327
|
+
totalSolSpent: this._state.totalSolSpent,
|
|
328
|
+
totalSolReceived: this._state.totalSolReceived,
|
|
279
329
|
};
|
|
280
|
-
}
|
|
281
|
-
return {
|
|
282
|
-
publicKey: this._state.publicKey,
|
|
283
|
-
vaultCreator: this._state.vaultCreator,
|
|
284
|
-
tick: this._state.tick,
|
|
285
|
-
actionCounts: { ...this._state.actionCounts },
|
|
286
|
-
holdings: Object.fromEntries(this._state.holdings),
|
|
287
|
-
activeLoans: Array.from(this._state.activeLoans),
|
|
288
|
-
founded: [...this._state.founded],
|
|
289
|
-
rallied: Array.from(this._state.rallied),
|
|
290
|
-
voted: Array.from(this._state.voted),
|
|
291
|
-
sentiment: Object.fromEntries(this._state.sentiment),
|
|
292
|
-
recentHistory: this._state.recentHistory.slice(-20),
|
|
293
|
-
personalitySummary: this._state.personalitySummary,
|
|
294
|
-
totalSolSpent: this._state.totalSolSpent,
|
|
295
|
-
totalSolReceived: this._state.totalSolReceived,
|
|
296
|
-
};
|
|
297
330
|
}
|
|
298
331
|
hydrate(saved) {
|
|
332
|
+
if (saved.vaultCreator) {
|
|
333
|
+
this._vaultCreator = saved.vaultCreator;
|
|
334
|
+
}
|
|
299
335
|
this._state = {
|
|
300
336
|
publicKey: saved.publicKey,
|
|
301
|
-
vaultCreator: saved.vaultCreator,
|
|
302
|
-
stronghold: null, // will be resolved on next refreshHoldings or init
|
|
303
337
|
tick: saved.tick,
|
|
304
338
|
actionCounts: { ...EMPTY_COUNTS, ...saved.actionCounts },
|
|
305
|
-
holdings: new Map(Object.entries(saved.holdings)),
|
|
306
339
|
activeLoans: new Set(saved.activeLoans),
|
|
307
340
|
founded: [...saved.founded],
|
|
308
341
|
rallied: new Set(saved.rallied),
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AgentFactionPosition, AgentProfile, AllianceCluster, FactionPower, FactionStatus, RivalFaction, WorldEvent, WorldStats } from '../types';
|
|
1
|
+
import { AgentFactionPosition, AgentProfile, AllianceCluster, FactionListResult, FactionPower, FactionStatus, NearbyResult, RivalFaction, WorldEvent, WorldStats } from '../types';
|
|
2
2
|
export interface Intel {
|
|
3
|
-
getAgentFactions(wallet: string
|
|
3
|
+
getAgentFactions(wallet: string): Promise<AgentFactionPosition[]>;
|
|
4
4
|
getAgentProfile(wallet: string): Promise<AgentProfile>;
|
|
5
5
|
getAgentSolLamports(wallet: string): Promise<number>;
|
|
6
6
|
getAllies(mints: string[], holderLimit?: number): Promise<AllianceCluster[]>;
|
|
7
|
+
getAscendedFactions(limit?: number): Promise<FactionListResult>;
|
|
7
8
|
getFactionPower(mint: string): Promise<FactionPower>;
|
|
8
9
|
getFactionLeaderboard(opts?: {
|
|
9
10
|
status?: FactionStatus;
|
|
@@ -12,6 +13,11 @@ export interface Intel {
|
|
|
12
13
|
getFactionRivals(mint: string, opts?: {
|
|
13
14
|
limit?: number;
|
|
14
15
|
}): Promise<RivalFaction[]>;
|
|
16
|
+
getNearbyFactions(wallet: string, opts?: {
|
|
17
|
+
depth?: number;
|
|
18
|
+
limit?: number;
|
|
19
|
+
}): Promise<NearbyResult>;
|
|
20
|
+
getRisingFactions(limit?: number): Promise<FactionListResult>;
|
|
15
21
|
getWorldFeed(opts?: {
|
|
16
22
|
limit?: number;
|
|
17
23
|
factionLimit?: number;
|
|
@@ -5,16 +5,10 @@ export type TrackedAction = 'join' | 'defect' | 'rally' | 'launch' | 'message' |
|
|
|
5
5
|
export interface AgentGameState {
|
|
6
6
|
/** Agent wallet public key */
|
|
7
7
|
publicKey: string;
|
|
8
|
-
/** Vault creator key (resolved from on-chain vault link) */
|
|
9
|
-
vaultCreator: string | null;
|
|
10
|
-
/** Vault info (null if no vault found) */
|
|
11
|
-
stronghold: Stronghold | null;
|
|
12
8
|
/** Monotonic tick counter — increments on each successful action */
|
|
13
9
|
tick: number;
|
|
14
10
|
/** Cumulative action counts keyed by action type */
|
|
15
11
|
actionCounts: Record<TrackedAction, number>;
|
|
16
|
-
/** Token holdings: mint → balance (wallet + vault combined) */
|
|
17
|
-
holdings: Map<string, number>;
|
|
18
12
|
/** Mints with active war loans */
|
|
19
13
|
activeLoans: Set<string>;
|
|
20
14
|
/** Mints this agent founded */
|
|
@@ -69,34 +63,35 @@ export interface CheckpointConfig {
|
|
|
69
63
|
export interface State {
|
|
70
64
|
/** Current game state (null before init) */
|
|
71
65
|
readonly state: AgentGameState | null;
|
|
72
|
-
/** Vault creator key (shorthand for state.vaultCreator) */
|
|
73
|
-
readonly vaultCreator: string | null;
|
|
74
66
|
/** Whether state has been initialized */
|
|
75
67
|
readonly initialized: boolean;
|
|
76
68
|
/** Current tick count */
|
|
77
69
|
readonly tick: number;
|
|
78
70
|
/**
|
|
79
71
|
* Initialize state from chain.
|
|
80
|
-
*
|
|
81
|
-
*
|
|
72
|
+
* Loads action counts from registry checkpoint.
|
|
73
|
+
* Vault and holdings are resolved lazily on first access.
|
|
82
74
|
*/
|
|
83
75
|
init(): Promise<AgentGameState>;
|
|
84
76
|
/**
|
|
85
77
|
* Record a successful action — increments tick, updates action counts,
|
|
86
|
-
* updates sentiment, appends to history
|
|
87
|
-
* Called by ActionProvider after tx confirmation.
|
|
78
|
+
* updates sentiment, appends to history.
|
|
88
79
|
*/
|
|
89
80
|
record(action: TrackedAction, mint?: string, description?: string): Promise<void>;
|
|
90
|
-
/**
|
|
91
|
-
|
|
81
|
+
/** Get vault creator key (lazy — resolves on first call, cached after) */
|
|
82
|
+
getVaultCreator(): Promise<string | null>;
|
|
83
|
+
/** Get stronghold info (lazy — resolves on first call, cached after) */
|
|
84
|
+
getStronghold(): Promise<Stronghold | null>;
|
|
85
|
+
/** Get token holdings fresh from chain (wallet + vault) */
|
|
86
|
+
getHoldings(): Promise<Map<string, number>>;
|
|
87
|
+
/** Get token balance for a specific mint (fresh from chain) */
|
|
88
|
+
getBalance(mint: string): Promise<number>;
|
|
92
89
|
/** Get sentiment score for a faction (-10 to +10) */
|
|
93
90
|
getSentiment(mint: string): number;
|
|
94
91
|
/** Get all sentiment entries */
|
|
95
92
|
readonly sentimentMap: ReadonlyMap<string, number>;
|
|
96
93
|
/** Get recent action history (for LLM memory block) */
|
|
97
94
|
readonly history: readonly string[];
|
|
98
|
-
/** Get token balance for a specific mint */
|
|
99
|
-
getBalance(mint: string): number;
|
|
100
95
|
/** Check if agent has voted on a faction */
|
|
101
96
|
hasVoted(mint: string): boolean;
|
|
102
97
|
/** Check if agent has rallied a faction */
|
package/dist/types.d.ts
CHANGED
|
@@ -327,6 +327,11 @@ export interface FactionPower {
|
|
|
327
327
|
progress_percent: number;
|
|
328
328
|
status: FactionStatus;
|
|
329
329
|
}
|
|
330
|
+
/** Result from getNearbyFactions — factions + discovered agents in the social graph */
|
|
331
|
+
export interface NearbyResult extends FactionListResult {
|
|
332
|
+
/** Wallet addresses discovered as co-holders (natural allies) */
|
|
333
|
+
allies: string[];
|
|
334
|
+
}
|
|
330
335
|
export interface AllianceCluster {
|
|
331
336
|
factions: string[];
|
|
332
337
|
shared_members: number;
|
package/dist/vanity.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ import type { CreateTokenResult, CreateTokenParams } from 'torchsdk';
|
|
|
10
10
|
export declare const getBondingCurvePda: (mint: PublicKey) => [PublicKey, number];
|
|
11
11
|
export declare const getTokenTreasuryPda: (mint: PublicKey) => [PublicKey, number];
|
|
12
12
|
export declare const getTreasuryLockPda: (mint: PublicKey) => [PublicKey, number];
|
|
13
|
-
/** Grind for a keypair whose base58 address ends with "
|
|
13
|
+
/** Grind for a keypair whose base58 address ends with "pw" (pyreworld) */
|
|
14
14
|
export declare const grindPyreMint: (maxAttempts?: number) => Keypair;
|
|
15
|
-
/** Check if a mint address is a pyre faction (ends with "
|
|
15
|
+
/** Check if a mint address is a pyre faction (ends with "pw") */
|
|
16
16
|
export declare const isPyreMint: (mint: string) => boolean;
|
|
17
17
|
export declare const buildCreateFactionTransaction: (connection: Connection, params: CreateTokenParams) => Promise<CreateTokenResult>;
|
package/dist/vanity.js
CHANGED
|
@@ -34,22 +34,19 @@ const getTreasuryTokenAccount = (mint, treasury) => (0, spl_token_1.getAssociate
|
|
|
34
34
|
const getTreasuryLockPda = (mint) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(TREASURY_LOCK_SEED), mint.toBuffer()], torchsdk_1.PROGRAM_ID);
|
|
35
35
|
exports.getTreasuryLockPda = getTreasuryLockPda;
|
|
36
36
|
const getTreasuryLockTokenAccount = (mint, treasuryLock) => (0, spl_token_1.getAssociatedTokenAddressSync)(mint, treasuryLock, true, TOKEN_2022_PROGRAM_ID);
|
|
37
|
-
const makeDummyProvider = (connection, payer) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
return new anchor_1.AnchorProvider(connection, dummyWallet, {});
|
|
44
|
-
};
|
|
37
|
+
const makeDummyProvider = (connection, payer) => new anchor_1.AnchorProvider(connection, {
|
|
38
|
+
publicKey: payer,
|
|
39
|
+
signTransaction: async (t) => t,
|
|
40
|
+
signAllTransactions: async (t) => t,
|
|
41
|
+
}, {});
|
|
45
42
|
const finalizeTransaction = async (connection, tx, feePayer) => {
|
|
46
43
|
const { blockhash } = await connection.getLatestBlockhash();
|
|
47
44
|
tx.recentBlockhash = blockhash;
|
|
48
45
|
tx.feePayer = feePayer;
|
|
49
46
|
};
|
|
50
47
|
// ── Vanity grinder ──
|
|
51
|
-
const PYRE_SUFFIX = '
|
|
52
|
-
/** Grind for a keypair whose base58 address ends with "
|
|
48
|
+
const PYRE_SUFFIX = 'pw';
|
|
49
|
+
/** Grind for a keypair whose base58 address ends with "pw" (pyreworld) */
|
|
53
50
|
const grindPyreMint = (maxAttempts = 500_000) => {
|
|
54
51
|
for (let i = 0; i < maxAttempts; i++) {
|
|
55
52
|
const kp = web3_js_1.Keypair.generate();
|
|
@@ -61,7 +58,7 @@ const grindPyreMint = (maxAttempts = 500_000) => {
|
|
|
61
58
|
return web3_js_1.Keypair.generate();
|
|
62
59
|
};
|
|
63
60
|
exports.grindPyreMint = grindPyreMint;
|
|
64
|
-
/** Check if a mint address is a pyre faction (ends with "
|
|
61
|
+
/** Check if a mint address is a pyre faction (ends with "pw") */
|
|
65
62
|
const isPyreMint = (mint) => mint.endsWith(PYRE_SUFFIX);
|
|
66
63
|
exports.isPyreMint = isPyreMint;
|
|
67
64
|
// ── Build create transaction with pyre vanity address ──
|