pyre-world-kit 1.0.0 → 1.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/actions.d.ts +4 -2
- package/dist/actions.js +78 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/types.d.ts +5 -1
- package/package.json +8 -7
- package/src/actions.ts +92 -4
- package/src/index.ts +2 -0
- package/src/intel.ts +2 -1
- package/src/types.ts +9 -1
package/dist/actions.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Thin wrappers that call torchsdk functions and map params/results
|
|
5
5
|
* into game-semantic Pyre types. No new on-chain logic.
|
|
6
6
|
*/
|
|
7
|
-
import { Connection } from '@solana/web3.js';
|
|
7
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
8
8
|
import type { BuyQuoteResult, SellQuoteResult, TransactionResult, SaidVerification, ConfirmResult } from 'torchsdk';
|
|
9
9
|
import type { FactionListParams, FactionListResult, FactionDetail, MembersResult, CommsResult, Stronghold, AgentLink, WarChest, WarLoan, AllWarLoansResult, LaunchFactionParams, JoinFactionParams, DirectJoinFactionParams, DefectParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, TradeOnDexParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, ConvertTitheParams, JoinFactionResult, LaunchFactionResult } from './types';
|
|
10
10
|
/** List all factions with optional filtering and sorting */
|
|
@@ -13,7 +13,7 @@ export declare function getFactions(connection: Connection, params?: FactionList
|
|
|
13
13
|
export declare function getFaction(connection: Connection, mint: string): Promise<FactionDetail>;
|
|
14
14
|
/** Get faction members (top holders) */
|
|
15
15
|
export declare function getMembers(connection: Connection, mint: string, limit?: number): Promise<MembersResult>;
|
|
16
|
-
/** Get faction comms (trade-bundled messages) */
|
|
16
|
+
/** Get faction comms (trade-bundled messages, including post-ascension DEX messages) */
|
|
17
17
|
export declare function getComms(connection: Connection, mint: string, limit?: number): Promise<CommsResult>;
|
|
18
18
|
/** Get a quote for joining a faction (buying tokens) */
|
|
19
19
|
export declare function getJoinQuote(connection: Connection, mint: string, amountSolLamports: number): Promise<BuyQuoteResult>;
|
|
@@ -79,3 +79,5 @@ export declare function verifyAgent(wallet: string): Promise<SaidVerification>;
|
|
|
79
79
|
export declare function confirmAction(connection: Connection, signature: string, wallet: string): Promise<ConfirmResult>;
|
|
80
80
|
/** Create an ephemeral agent keypair (memory-only, zero key management) */
|
|
81
81
|
export { createEphemeralAgent } from 'torchsdk';
|
|
82
|
+
/** Get the Raydium pool state PDA for an ascended faction's DEX pool */
|
|
83
|
+
export declare function getDexPool(mint: string): PublicKey;
|
package/dist/actions.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* Thin wrappers that call torchsdk functions and map params/results
|
|
6
6
|
* into game-semantic Pyre types. No new on-chain logic.
|
|
7
7
|
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.createEphemeralAgent = void 0;
|
|
10
13
|
exports.getFactions = getFactions;
|
|
@@ -42,6 +45,9 @@ exports.tithe = tithe;
|
|
|
42
45
|
exports.convertTithe = convertTithe;
|
|
43
46
|
exports.verifyAgent = verifyAgent;
|
|
44
47
|
exports.confirmAction = confirmAction;
|
|
48
|
+
exports.getDexPool = getDexPool;
|
|
49
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
50
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
45
51
|
const torchsdk_1 = require("torchsdk");
|
|
46
52
|
const mappers_1 = require("./mappers");
|
|
47
53
|
const vanity_1 = require("./vanity");
|
|
@@ -67,10 +73,73 @@ async function getMembers(connection, mint, limit) {
|
|
|
67
73
|
const result = await (0, torchsdk_1.getHolders)(connection, mint, limit);
|
|
68
74
|
return (0, mappers_1.mapHoldersResult)(result);
|
|
69
75
|
}
|
|
70
|
-
/** Get faction comms (trade-bundled messages) */
|
|
76
|
+
/** Get faction comms (trade-bundled messages, including post-ascension DEX messages) */
|
|
71
77
|
async function getComms(connection, mint, limit) {
|
|
72
|
-
const
|
|
73
|
-
|
|
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) {
|
|
88
|
+
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));
|
|
91
|
+
for (let i = 0; i < txs.length; i++) {
|
|
92
|
+
const tx = txs[i];
|
|
93
|
+
if (!tx?.meta || tx.meta.err)
|
|
94
|
+
continue;
|
|
95
|
+
const sig = signatures[i];
|
|
96
|
+
if (existingSigs.has(sig.signature))
|
|
97
|
+
continue;
|
|
98
|
+
// Check top-level and inner instructions for memo
|
|
99
|
+
const allInstructions = [
|
|
100
|
+
...tx.transaction.message.instructions,
|
|
101
|
+
...(tx.meta.innerInstructions || []).flatMap(inner => inner.instructions),
|
|
102
|
+
];
|
|
103
|
+
for (const ix of allInstructions) {
|
|
104
|
+
const programId = 'programId' in ix ? ix.programId.toString() : '';
|
|
105
|
+
const programName = 'program' in ix ? ix.program : '';
|
|
106
|
+
const isMemo = programId === MEMO_PROGRAM || programName === 'spl-memo';
|
|
107
|
+
if (isMemo) {
|
|
108
|
+
let memoText = '';
|
|
109
|
+
if ('parsed' in ix) {
|
|
110
|
+
memoText = typeof ix.parsed === 'string' ? ix.parsed : JSON.stringify(ix.parsed);
|
|
111
|
+
}
|
|
112
|
+
else if ('data' in ix && typeof ix.data === 'string') {
|
|
113
|
+
try {
|
|
114
|
+
memoText = new TextDecoder().decode(bs58_1.default.decode(ix.data));
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
memoText = ix.data;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (memoText && memoText.trim()) {
|
|
121
|
+
const sender = tx.transaction.message.accountKeys[0]?.pubkey?.toString() || 'Unknown';
|
|
122
|
+
commsResult.comms.push({
|
|
123
|
+
signature: sig.signature,
|
|
124
|
+
memo: memoText.trim(),
|
|
125
|
+
sender,
|
|
126
|
+
timestamp: sig.blockTime || 0,
|
|
127
|
+
});
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
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;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
// Pool may not exist for non-ascended factions — ignore
|
|
141
|
+
}
|
|
142
|
+
return commsResult;
|
|
74
143
|
}
|
|
75
144
|
/** Get a quote for joining a faction (buying tokens) */
|
|
76
145
|
async function getJoinQuote(connection, mint, amountSolLamports) {
|
|
@@ -195,6 +264,7 @@ async function tradeOnDex(connection, params) {
|
|
|
195
264
|
amount_in: params.amount_in,
|
|
196
265
|
minimum_amount_out: params.minimum_amount_out,
|
|
197
266
|
is_buy: params.is_buy,
|
|
267
|
+
message: params.message,
|
|
198
268
|
});
|
|
199
269
|
}
|
|
200
270
|
/** Claim spoils (protocol rewards) */
|
|
@@ -316,3 +386,8 @@ async function confirmAction(connection, signature, wallet) {
|
|
|
316
386
|
/** Create an ephemeral agent keypair (memory-only, zero key management) */
|
|
317
387
|
var torchsdk_2 = require("torchsdk");
|
|
318
388
|
Object.defineProperty(exports, "createEphemeralAgent", { enumerable: true, get: function () { return torchsdk_2.createEphemeralAgent; } });
|
|
389
|
+
/** Get the Raydium pool state PDA for an ascended faction's DEX pool */
|
|
390
|
+
function getDexPool(mint) {
|
|
391
|
+
const { poolState } = (0, torchsdk_1.getRaydiumMigrationAccounts)(new web3_js_1.PublicKey(mint));
|
|
392
|
+
return poolState;
|
|
393
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* This kit translates protocol primitives into faction warfare language
|
|
6
6
|
* so agents think in factions, not tokens.
|
|
7
7
|
*/
|
|
8
|
-
export type { FactionStatus, FactionTier, Strategy, AgentHealth, FactionSummary, FactionDetail, Stronghold, AgentLink, Comms, WarChest, WarLoan, WarLoanWithAgent, Member, FactionListResult, MembersResult, CommsResult, AllWarLoansResult, LaunchFactionParams, JoinFactionParams, DirectJoinFactionParams, DefectParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, TradeOnDexParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, ConvertTitheParams, JoinFactionResult, LaunchFactionResult, TransactionResult, EphemeralAgent, SaidVerification, ConfirmResult, FactionSortOption, FactionStatusFilter, FactionListParams, FactionPower, AllianceCluster, RivalFaction, AgentProfile, AgentFactionPosition, WorldEvent, WorldStats, } from './types';
|
|
9
|
-
export { getFactions, getFaction, getMembers, getComms, getJoinQuote, getDefectQuote, getStronghold, getStrongholdForAgent, getAgentLink, getWarChest, getWarLoan, getAllWarLoans, launchFaction, joinFaction, directJoinFaction, defect, rally, requestWarLoan, repayWarLoan, tradeOnDex, claimSpoils, createStronghold, fundStronghold, withdrawFromStronghold, recruitAgent, exileAgent, coup, withdrawAssets, siege, ascend, raze, tithe, convertTithe, verifyAgent, confirmAction, createEphemeralAgent, } from './actions';
|
|
8
|
+
export type { FactionStatus, FactionTier, Strategy, AgentHealth, FactionSummary, FactionDetail, Stronghold, AgentLink, Comms, WarChest, WarLoan, WarLoanWithAgent, Member, FactionListResult, MembersResult, CommsResult, AllWarLoansResult, LaunchFactionParams, JoinFactionParams, DirectJoinFactionParams, DefectParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, TradeOnDexParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, ConvertTitheParams, JoinFactionResult, LaunchFactionResult, TransactionResult, EphemeralAgent, SaidVerification, ConfirmResult, FactionSortOption, FactionStatusFilter, FactionListParams, FactionPower, AllianceCluster, RivalFaction, AgentProfile, AgentFactionPosition, WorldEventType, WorldEvent, WorldStats, } from './types';
|
|
9
|
+
export { getFactions, getFaction, getMembers, getComms, getJoinQuote, getDefectQuote, getStronghold, getStrongholdForAgent, getAgentLink, getWarChest, getWarLoan, getAllWarLoans, launchFaction, joinFaction, directJoinFaction, defect, rally, requestWarLoan, repayWarLoan, tradeOnDex, claimSpoils, createStronghold, fundStronghold, withdrawFromStronghold, recruitAgent, exileAgent, coup, withdrawAssets, siege, ascend, raze, tithe, convertTithe, verifyAgent, confirmAction, createEphemeralAgent, getDexPool, } from './actions';
|
|
10
10
|
export { getFactionPower, getFactionLeaderboard, detectAlliances, getFactionRivals, getAgentProfile, getAgentFactions, getWorldFeed, getWorldStats, } from './intel';
|
|
11
11
|
export { isPyreMint, grindPyreMint } from './vanity';
|
|
12
12
|
export { PROGRAM_ID, LAMPORTS_PER_SOL, TOKEN_MULTIPLIER, TOTAL_SUPPLY } from 'torchsdk';
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* so agents think in factions, not tokens.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.TOKEN_MULTIPLIER = exports.LAMPORTS_PER_SOL = exports.PROGRAM_ID = exports.grindPyreMint = exports.isPyreMint = exports.getWorldStats = exports.getWorldFeed = exports.getAgentFactions = exports.getAgentProfile = exports.getFactionRivals = exports.detectAlliances = exports.getFactionLeaderboard = exports.getFactionPower = exports.getDexPool = exports.createEphemeralAgent = exports.confirmAction = exports.verifyAgent = exports.convertTithe = exports.tithe = exports.raze = exports.ascend = exports.siege = exports.withdrawAssets = exports.coup = exports.exileAgent = exports.recruitAgent = exports.withdrawFromStronghold = exports.fundStronghold = exports.createStronghold = exports.claimSpoils = exports.tradeOnDex = exports.repayWarLoan = exports.requestWarLoan = exports.rally = exports.defect = exports.directJoinFaction = exports.joinFaction = exports.launchFaction = exports.getAllWarLoans = exports.getWarLoan = exports.getWarChest = exports.getAgentLink = exports.getStrongholdForAgent = exports.getStronghold = exports.getDefectQuote = exports.getJoinQuote = exports.getComms = exports.getMembers = exports.getFaction = exports.getFactions = void 0;
|
|
11
|
+
exports.TOTAL_SUPPLY = void 0;
|
|
11
12
|
// ─── Actions ───────────────────────────────────────────────────────
|
|
12
13
|
var actions_1 = require("./actions");
|
|
13
14
|
// Read operations
|
|
@@ -52,6 +53,7 @@ Object.defineProperty(exports, "verifyAgent", { enumerable: true, get: function
|
|
|
52
53
|
Object.defineProperty(exports, "confirmAction", { enumerable: true, get: function () { return actions_1.confirmAction; } });
|
|
53
54
|
// Utility
|
|
54
55
|
Object.defineProperty(exports, "createEphemeralAgent", { enumerable: true, get: function () { return actions_1.createEphemeralAgent; } });
|
|
56
|
+
Object.defineProperty(exports, "getDexPool", { enumerable: true, get: function () { return actions_1.getDexPool; } });
|
|
55
57
|
// ─── Intel ─────────────────────────────────────────────────────────
|
|
56
58
|
var intel_1 = require("./intel");
|
|
57
59
|
Object.defineProperty(exports, "getFactionPower", { enumerable: true, get: function () { return intel_1.getFactionPower; } });
|
package/dist/types.d.ts
CHANGED
|
@@ -217,6 +217,8 @@ export interface TradeOnDexParams {
|
|
|
217
217
|
amount_in: number;
|
|
218
218
|
minimum_amount_out: number;
|
|
219
219
|
is_buy: boolean;
|
|
220
|
+
/** Optional message bundled as SPL Memo instruction (max 500 chars) */
|
|
221
|
+
message?: string;
|
|
220
222
|
}
|
|
221
223
|
export interface ClaimSpoilsParams {
|
|
222
224
|
agent: string;
|
|
@@ -334,8 +336,10 @@ export interface AgentFactionPosition {
|
|
|
334
336
|
percentage: number;
|
|
335
337
|
value_sol: number;
|
|
336
338
|
}
|
|
339
|
+
/** Action types for world events and stage feed */
|
|
340
|
+
export type WorldEventType = 'launch' | 'join' | 'reinforce' | 'defect' | 'rally' | 'ascend' | 'raze' | 'messaged' | 'siege' | 'tithe' | 'war_loan' | 'repay_loan';
|
|
337
341
|
export interface WorldEvent {
|
|
338
|
-
type:
|
|
342
|
+
type: WorldEventType;
|
|
339
343
|
faction_mint: string;
|
|
340
344
|
faction_name: string;
|
|
341
345
|
agent?: string;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pyre-world-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.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",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
@@ -11,15 +11,16 @@
|
|
|
11
11
|
"test:devnet": "npx tsx tests/test_devnet_e2e.ts"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"
|
|
15
|
-
"@solana/web3.js": "^1.98.4",
|
|
14
|
+
"@coral-xyz/anchor": "^0.32.1",
|
|
16
15
|
"@solana/spl-token": "^0.4.6",
|
|
17
|
-
"@
|
|
16
|
+
"@solana/web3.js": "^1.98.4",
|
|
17
|
+
"bs58": "^6.0.0",
|
|
18
|
+
"torchsdk": "^3.7.32"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@types/node": "^22.15.0",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
22
|
+
"tsx": "^4.19.4",
|
|
23
|
+
"typescript": "^5.9.3"
|
|
23
24
|
},
|
|
24
25
|
"packageManager": "pnpm@9.10.0+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c"
|
|
25
26
|
}
|
package/src/actions.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* into game-semantic Pyre types. No new on-chain logic.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Connection } from '@solana/web3.js';
|
|
8
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
9
|
+
import bs58 from 'bs58';
|
|
9
10
|
import {
|
|
10
11
|
// Read operations
|
|
11
12
|
getTokens,
|
|
@@ -20,6 +21,8 @@ import {
|
|
|
20
21
|
getLendingInfo,
|
|
21
22
|
getLoanPosition,
|
|
22
23
|
getAllLoanPositions,
|
|
24
|
+
// PDA derivation
|
|
25
|
+
getRaydiumMigrationAccounts,
|
|
23
26
|
// Transaction builders
|
|
24
27
|
buildBuyTransaction,
|
|
25
28
|
buildDirectBuyTransaction,
|
|
@@ -138,14 +141,92 @@ export async function getMembers(
|
|
|
138
141
|
return mapHoldersResult(result);
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
/** Get faction comms (trade-bundled messages) */
|
|
144
|
+
/** Get faction comms (trade-bundled messages, including post-ascension DEX messages) */
|
|
142
145
|
export async function getComms(
|
|
143
146
|
connection: Connection,
|
|
144
147
|
mint: string,
|
|
145
148
|
limit?: number,
|
|
146
149
|
): Promise<CommsResult> {
|
|
147
|
-
const
|
|
148
|
-
|
|
150
|
+
const safeLimit = Math.min(limit || 50, 100);
|
|
151
|
+
|
|
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
|
+
);
|
|
166
|
+
|
|
167
|
+
if (signatures.length > 0) {
|
|
168
|
+
const txs = await connection.getParsedTransactions(
|
|
169
|
+
signatures.map(s => s.signature),
|
|
170
|
+
{ maxSupportedTransactionVersion: 0 },
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const MEMO_PROGRAM = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr';
|
|
174
|
+
const existingSigs = new Set(commsResult.comms.map(c => c.signature));
|
|
175
|
+
|
|
176
|
+
for (let i = 0; i < txs.length; i++) {
|
|
177
|
+
const tx = txs[i];
|
|
178
|
+
if (!tx?.meta || tx.meta.err) continue;
|
|
179
|
+
|
|
180
|
+
const sig = signatures[i];
|
|
181
|
+
if (existingSigs.has(sig.signature)) continue;
|
|
182
|
+
|
|
183
|
+
// Check top-level and inner instructions for memo
|
|
184
|
+
const allInstructions = [
|
|
185
|
+
...tx.transaction.message.instructions,
|
|
186
|
+
...(tx.meta.innerInstructions || []).flatMap(inner => inner.instructions),
|
|
187
|
+
];
|
|
188
|
+
|
|
189
|
+
for (const ix of allInstructions) {
|
|
190
|
+
const programId = 'programId' in ix ? ix.programId.toString() : '';
|
|
191
|
+
const programName = 'program' in ix ? (ix as { program: string }).program : '';
|
|
192
|
+
const isMemo = programId === MEMO_PROGRAM || programName === 'spl-memo';
|
|
193
|
+
|
|
194
|
+
if (isMemo) {
|
|
195
|
+
let memoText = '';
|
|
196
|
+
if ('parsed' in ix) {
|
|
197
|
+
memoText = typeof ix.parsed === 'string' ? ix.parsed : JSON.stringify(ix.parsed);
|
|
198
|
+
} else if ('data' in ix && typeof ix.data === 'string') {
|
|
199
|
+
try {
|
|
200
|
+
memoText = new TextDecoder().decode(bs58.decode(ix.data));
|
|
201
|
+
} catch {
|
|
202
|
+
memoText = ix.data;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (memoText && memoText.trim()) {
|
|
207
|
+
const sender = tx.transaction.message.accountKeys[0]?.pubkey?.toString() || 'Unknown';
|
|
208
|
+
commsResult.comms.push({
|
|
209
|
+
signature: sig.signature,
|
|
210
|
+
memo: memoText.trim(),
|
|
211
|
+
sender,
|
|
212
|
+
timestamp: sig.blockTime || 0,
|
|
213
|
+
});
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
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;
|
|
224
|
+
}
|
|
225
|
+
} catch {
|
|
226
|
+
// Pool may not exist for non-ascended factions — ignore
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return commsResult;
|
|
149
230
|
}
|
|
150
231
|
|
|
151
232
|
/** Get a quote for joining a faction (buying tokens) */
|
|
@@ -338,6 +419,7 @@ export async function tradeOnDex(
|
|
|
338
419
|
amount_in: params.amount_in,
|
|
339
420
|
minimum_amount_out: params.minimum_amount_out,
|
|
340
421
|
is_buy: params.is_buy,
|
|
422
|
+
message: params.message,
|
|
341
423
|
});
|
|
342
424
|
}
|
|
343
425
|
|
|
@@ -521,3 +603,9 @@ export async function confirmAction(
|
|
|
521
603
|
|
|
522
604
|
/** Create an ephemeral agent keypair (memory-only, zero key management) */
|
|
523
605
|
export { createEphemeralAgent } from 'torchsdk';
|
|
606
|
+
|
|
607
|
+
/** Get the Raydium pool state PDA for an ascended faction's DEX pool */
|
|
608
|
+
export function getDexPool(mint: string): PublicKey {
|
|
609
|
+
const { poolState } = getRaydiumMigrationAccounts(new PublicKey(mint));
|
|
610
|
+
return poolState;
|
|
611
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -68,6 +68,7 @@ export type {
|
|
|
68
68
|
RivalFaction,
|
|
69
69
|
AgentProfile,
|
|
70
70
|
AgentFactionPosition,
|
|
71
|
+
WorldEventType,
|
|
71
72
|
WorldEvent,
|
|
72
73
|
WorldStats,
|
|
73
74
|
} from './types';
|
|
@@ -117,6 +118,7 @@ export {
|
|
|
117
118
|
confirmAction,
|
|
118
119
|
// Utility
|
|
119
120
|
createEphemeralAgent,
|
|
121
|
+
getDexPool,
|
|
120
122
|
} from './actions';
|
|
121
123
|
|
|
122
124
|
// ─── Intel ─────────────────────────────────────────────────────────
|
package/src/intel.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* strategic intelligence. Agents use these to reason about the world.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Connection } from '@solana/web3.js';
|
|
8
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
9
9
|
import {
|
|
10
10
|
getTokens,
|
|
11
11
|
getToken,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getMessages,
|
|
14
14
|
getVaultForWallet,
|
|
15
15
|
verifySaid,
|
|
16
|
+
PROGRAM_ID,
|
|
16
17
|
} from 'torchsdk';
|
|
17
18
|
import type { TokenDetail, TokenSummary } from 'torchsdk';
|
|
18
19
|
|
package/src/types.ts
CHANGED
|
@@ -259,6 +259,8 @@ export interface TradeOnDexParams {
|
|
|
259
259
|
amount_in: number;
|
|
260
260
|
minimum_amount_out: number;
|
|
261
261
|
is_buy: boolean;
|
|
262
|
+
/** Optional message bundled as SPL Memo instruction (max 500 chars) */
|
|
263
|
+
message?: string;
|
|
262
264
|
}
|
|
263
265
|
|
|
264
266
|
export interface ClaimSpoilsParams {
|
|
@@ -405,8 +407,14 @@ export interface AgentFactionPosition {
|
|
|
405
407
|
value_sol: number;
|
|
406
408
|
}
|
|
407
409
|
|
|
410
|
+
/** Action types for world events and stage feed */
|
|
411
|
+
export type WorldEventType =
|
|
412
|
+
| 'launch' | 'join' | 'reinforce' | 'defect' | 'rally'
|
|
413
|
+
| 'ascend' | 'raze' | 'messaged'
|
|
414
|
+
| 'siege' | 'tithe' | 'war_loan' | 'repay_loan';
|
|
415
|
+
|
|
408
416
|
export interface WorldEvent {
|
|
409
|
-
type:
|
|
417
|
+
type: WorldEventType;
|
|
410
418
|
faction_mint: string;
|
|
411
419
|
faction_name: string;
|
|
412
420
|
agent?: string;
|