pyre-world-kit 3.1.1 → 3.2.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/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 +9 -4
- package/dist/providers/state.provider.js +150 -135
- 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/util.js +8 -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 +183 -156
- package/src/types/intel.types.ts +9 -1
- package/src/types/state.types.ts +14 -18
- package/src/types.ts +6 -0
- package/src/util.ts +8 -0
- package/src/vanity.ts +15 -13
- package/tests/test_e2e.ts +145 -23
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare class PyreKit {
|
|
|
39
39
|
/** Map action method names to tracked action types */
|
|
40
40
|
private methodToAction;
|
|
41
41
|
}
|
|
42
|
-
export type { FactionStatus, Strategy, AgentHealth, FactionSummary, FactionDetail, Stronghold, AgentLink, Comms, WarChest, WarLoan, WarLoanWithAgent, Member, FactionListResult, MembersResult, CommsResult, AllWarLoansResult, WarLoanQuote, LaunchFactionParams, JoinFactionParams, DefectParams, MessageFactionParams, FudFactionParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, JoinFactionResult, LaunchFactionResult, TransactionResult, EphemeralAgent, FactionSortOption, FactionStatusFilter, FactionListParams, FactionPower, AllianceCluster, RivalFaction, AgentProfile, AgentFactionPosition, WorldEventType, WorldEvent, WorldStats, RegistryProfile, RegistryWalletLink, CheckpointParams, RegisterAgentParams, LinkAgentWalletParams, UnlinkAgentWalletParams, TransferAgentAuthorityParams, } from './types';
|
|
42
|
+
export type { FactionStatus, Strategy, AgentHealth, FactionSummary, FactionDetail, Stronghold, AgentLink, Comms, WarChest, WarLoan, WarLoanWithAgent, Member, FactionListResult, NearbyResult, MembersResult, CommsResult, AllWarLoansResult, WarLoanQuote, LaunchFactionParams, JoinFactionParams, DefectParams, MessageFactionParams, FudFactionParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, JoinFactionResult, LaunchFactionResult, TransactionResult, EphemeralAgent, FactionSortOption, FactionStatusFilter, FactionListParams, FactionPower, AllianceCluster, RivalFaction, AgentProfile, AgentFactionPosition, WorldEventType, WorldEvent, WorldStats, RegistryProfile, RegistryWalletLink, CheckpointParams, RegisterAgentParams, LinkAgentWalletParams, UnlinkAgentWalletParams, TransferAgentAuthorityParams, } from './types';
|
|
43
43
|
export type { Action } from './types/action.types';
|
|
44
44
|
export type { Intel } from './types/intel.types';
|
|
45
45
|
export type { Mapper } from './types/mapper.types';
|
|
@@ -194,7 +194,7 @@ class ActionProvider {
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
async fud(params) {
|
|
197
|
-
const MICRO_SELL_TOKENS =
|
|
197
|
+
const MICRO_SELL_TOKENS = 10 * 1_000_000; // 10 tokens in raw units (6 decimals)
|
|
198
198
|
if (params.ascended) {
|
|
199
199
|
const quote = await (0, torchsdk_1.getSellQuote)(this.connection, params.mint, MICRO_SELL_TOKENS);
|
|
200
200
|
const minOut = Math.max(1, Math.floor(quote.output_sol * (1 - 500 / 10_000)));
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { Connection } from '@solana/web3.js';
|
|
2
|
-
import { AgentFactionPosition, AgentProfile, AllianceCluster, FactionPower, FactionStatus, WorldEvent, WorldStats, RivalFaction } from '../types';
|
|
2
|
+
import { AgentFactionPosition, AgentProfile, AllianceCluster, FactionListResult, FactionPower, FactionStatus, NearbyResult, WorldEvent, WorldStats, RivalFaction } from '../types';
|
|
3
3
|
import { Intel } from '../types/intel.types';
|
|
4
4
|
import { Action } from '../types/action.types';
|
|
5
5
|
export declare class IntelProvider implements Intel {
|
|
6
6
|
private connection;
|
|
7
7
|
private actionProvider;
|
|
8
8
|
constructor(connection: Connection, actionProvider: Action);
|
|
9
|
-
getAgentFactions(wallet: string
|
|
9
|
+
getAgentFactions(wallet: string): Promise<AgentFactionPosition[]>;
|
|
10
|
+
getRisingFactions(limit?: number): Promise<FactionListResult>;
|
|
11
|
+
getAscendedFactions(limit?: number): Promise<FactionListResult>;
|
|
12
|
+
getNearbyFactions(wallet: string, { depth, limit }?: {
|
|
13
|
+
depth?: number;
|
|
14
|
+
limit?: number;
|
|
15
|
+
}): Promise<NearbyResult>;
|
|
10
16
|
getAgentProfile(wallet: string): Promise<AgentProfile>;
|
|
11
17
|
getAgentSolLamports(wallet: string): Promise<number>;
|
|
12
18
|
getAllies(mints: string[], holderLimit?: number): Promise<AllianceCluster[]>;
|
|
@@ -44,28 +44,28 @@ class IntelProvider {
|
|
|
44
44
|
this.connection = connection;
|
|
45
45
|
this.actionProvider = actionProvider;
|
|
46
46
|
}
|
|
47
|
-
async getAgentFactions(wallet
|
|
47
|
+
async getAgentFactions(wallet) {
|
|
48
48
|
const { TOKEN_2022_PROGRAM_ID } = await Promise.resolve().then(() => __importStar(require('@solana/spl-token')));
|
|
49
49
|
const walletPk = new web3_js_1.PublicKey(wallet);
|
|
50
|
-
//
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const vaultPk = new web3_js_1.PublicKey(vault.address);
|
|
61
|
-
vaultAccounts = await this.connection.getParsedTokenAccountsByOwner(vaultPk, {
|
|
50
|
+
// Parallel scan: wallet + vault
|
|
51
|
+
const vaultPromise = this.actionProvider.getStrongholdForAgent(wallet).catch(() => undefined);
|
|
52
|
+
const scanWallet = this.connection
|
|
53
|
+
.getParsedTokenAccountsByOwner(walletPk, { programId: TOKEN_2022_PROGRAM_ID })
|
|
54
|
+
.then((r) => r.value)
|
|
55
|
+
.catch(() => []);
|
|
56
|
+
const vault = await vaultPromise;
|
|
57
|
+
const scanVault = vault
|
|
58
|
+
? this.connection
|
|
59
|
+
.getParsedTokenAccountsByOwner(new web3_js_1.PublicKey(vault.address), {
|
|
62
60
|
programId: TOKEN_2022_PROGRAM_ID,
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
})
|
|
62
|
+
.then((r) => r.value)
|
|
63
|
+
.catch(() => [])
|
|
64
|
+
: Promise.resolve([]);
|
|
65
|
+
const [walletValues, vaultValues] = await Promise.all([scanWallet, scanVault]);
|
|
66
|
+
// Merge balances from both sources
|
|
67
67
|
const balanceMap = new Map();
|
|
68
|
-
for (const a of [...
|
|
68
|
+
for (const a of [...walletValues, ...vaultValues]) {
|
|
69
69
|
const mint = a.account.data.parsed.info.mint;
|
|
70
70
|
const balance = Number(a.account.data.parsed.info.tokenAmount.uiAmount ?? 0);
|
|
71
71
|
if (balance > 0 && (0, vanity_1.isPyreMint)(mint) && !(0, util_1.isBlacklistedMint)(mint)) {
|
|
@@ -74,28 +74,151 @@ class IntelProvider {
|
|
|
74
74
|
}
|
|
75
75
|
if (balanceMap.size === 0)
|
|
76
76
|
return [];
|
|
77
|
-
//
|
|
78
|
-
const allFactions = await this.actionProvider.getFactions({ limit: factionLimit });
|
|
79
|
-
const factionMap = new Map(allFactions.factions.map((t) => [t.mint, t]));
|
|
77
|
+
// Per-mint faction lookups (parallel)
|
|
80
78
|
const positions = [];
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
}
|
|
79
|
+
await Promise.all([...balanceMap.entries()].map(async ([mint, balance]) => {
|
|
80
|
+
try {
|
|
81
|
+
const faction = await this.actionProvider.getFaction(mint);
|
|
82
|
+
const percentage = (balance / 1_000_000_000) * 100;
|
|
83
|
+
positions.push({
|
|
84
|
+
mint,
|
|
85
|
+
name: faction.name,
|
|
86
|
+
symbol: faction.symbol,
|
|
87
|
+
balance,
|
|
88
|
+
percentage,
|
|
89
|
+
value_sol: balance * faction.price_sol,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch { }
|
|
93
|
+
}));
|
|
96
94
|
positions.sort((a, b) => b.value_sol - a.value_sol);
|
|
97
95
|
return positions;
|
|
98
96
|
}
|
|
97
|
+
async getRisingFactions(limit = 50) {
|
|
98
|
+
return this.actionProvider.getFactions({ limit, status: 'rising' });
|
|
99
|
+
}
|
|
100
|
+
async getAscendedFactions(limit = 50) {
|
|
101
|
+
return this.actionProvider.getFactions({ limit, status: 'ascended' });
|
|
102
|
+
}
|
|
103
|
+
async getNearbyFactions(wallet, { depth = 1, limit = 50 } = {}) {
|
|
104
|
+
const { TOKEN_2022_PROGRAM_ID } = await Promise.resolve().then(() => __importStar(require('@solana/spl-token')));
|
|
105
|
+
// Resolve wallet → vault (tokens live in vaults, not wallets)
|
|
106
|
+
let seedAddress = wallet;
|
|
107
|
+
try {
|
|
108
|
+
const vault = await this.actionProvider.getStrongholdForAgent(wallet);
|
|
109
|
+
if (vault)
|
|
110
|
+
seedAddress = vault.address;
|
|
111
|
+
}
|
|
112
|
+
catch { }
|
|
113
|
+
const discoveredMints = new Set();
|
|
114
|
+
const factionCache = new Map();
|
|
115
|
+
const visitedAddresses = new Set([wallet, seedAddress]);
|
|
116
|
+
/** Scan an address (wallet or vault) for Pyre token holdings */
|
|
117
|
+
const scanHoldings = async (address) => {
|
|
118
|
+
const mints = [];
|
|
119
|
+
try {
|
|
120
|
+
const accounts = await this.connection.getParsedTokenAccountsByOwner(new web3_js_1.PublicKey(address), { programId: TOKEN_2022_PROGRAM_ID });
|
|
121
|
+
for (const a of accounts.value) {
|
|
122
|
+
const mint = a.account.data.parsed.info.mint;
|
|
123
|
+
const balance = Number(a.account.data.parsed.info.tokenAmount.uiAmount ?? 0);
|
|
124
|
+
if (balance > 0 && (0, vanity_1.isPyreMint)(mint) && !(0, util_1.isBlacklistedMint)(mint)) {
|
|
125
|
+
mints.push(mint);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch { }
|
|
130
|
+
return mints;
|
|
131
|
+
};
|
|
132
|
+
/** Look up faction metadata, skip if already cached */
|
|
133
|
+
const resolveFaction = async (mint) => {
|
|
134
|
+
if (factionCache.has(mint))
|
|
135
|
+
return;
|
|
136
|
+
try {
|
|
137
|
+
const detail = await this.actionProvider.getFaction(mint);
|
|
138
|
+
factionCache.set(mint, {
|
|
139
|
+
mint: detail.mint,
|
|
140
|
+
name: detail.name,
|
|
141
|
+
symbol: detail.symbol,
|
|
142
|
+
status: detail.status,
|
|
143
|
+
market_cap_sol: detail.market_cap_sol,
|
|
144
|
+
price_sol: detail.price_sol,
|
|
145
|
+
members: detail.members ?? 0,
|
|
146
|
+
progress_percent: detail.progress_percent,
|
|
147
|
+
created_at: detail.created_at,
|
|
148
|
+
last_activity_at: detail.last_activity_at,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
catch { }
|
|
152
|
+
};
|
|
153
|
+
// Seed: scan own vault for held factions
|
|
154
|
+
const seedMints = await scanHoldings(seedAddress);
|
|
155
|
+
for (const m of seedMints)
|
|
156
|
+
discoveredMints.add(m);
|
|
157
|
+
if (discoveredMints.size === 0) {
|
|
158
|
+
const fallback = await this.actionProvider.getFactions({ limit, sort: 'newest' });
|
|
159
|
+
return { ...fallback, allies: [] };
|
|
160
|
+
}
|
|
161
|
+
// BFS across the social graph via comms — senders are wallet addresses
|
|
162
|
+
const COMMS_PER_FACTION = 20;
|
|
163
|
+
const MAX_WALLETS_PER_HOP = 20;
|
|
164
|
+
const discoveredAllies = [];
|
|
165
|
+
let frontierMints = new Set(discoveredMints);
|
|
166
|
+
for (let d = 0; d < depth; d++) {
|
|
167
|
+
// 1. Get recent comms senders from frontier factions → next frontier wallets
|
|
168
|
+
const nextFrontier = new Set();
|
|
169
|
+
await Promise.all([...frontierMints].slice(0, 10).map(async (mint) => {
|
|
170
|
+
try {
|
|
171
|
+
const { comms } = await this.actionProvider.getComms(mint, { limit: COMMS_PER_FACTION });
|
|
172
|
+
for (const c of comms) {
|
|
173
|
+
if (!visitedAddresses.has(c.sender)) {
|
|
174
|
+
nextFrontier.add(c.sender);
|
|
175
|
+
visitedAddresses.add(c.sender);
|
|
176
|
+
discoveredAllies.push(c.sender);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch { }
|
|
181
|
+
}));
|
|
182
|
+
if (nextFrontier.size === 0)
|
|
183
|
+
break;
|
|
184
|
+
// 2. Resolve wallets → vaults, scan for holdings → discover new mints
|
|
185
|
+
const newMints = new Set();
|
|
186
|
+
await Promise.all([...nextFrontier].slice(0, MAX_WALLETS_PER_HOP).map(async (walletAddr) => {
|
|
187
|
+
// Resolve to vault — tokens live there
|
|
188
|
+
let scanAddr = walletAddr;
|
|
189
|
+
try {
|
|
190
|
+
const v = await this.actionProvider.getStrongholdForAgent(walletAddr);
|
|
191
|
+
if (v)
|
|
192
|
+
scanAddr = v.address;
|
|
193
|
+
}
|
|
194
|
+
catch { }
|
|
195
|
+
const mints = await scanHoldings(scanAddr);
|
|
196
|
+
for (const mint of mints) {
|
|
197
|
+
if (!discoveredMints.has(mint)) {
|
|
198
|
+
newMints.add(mint);
|
|
199
|
+
discoveredMints.add(mint);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}));
|
|
203
|
+
// New mints become the frontier for the next depth level
|
|
204
|
+
frontierMints = newMints;
|
|
205
|
+
if (frontierMints.size === 0)
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
// Resolve faction metadata per mint (parallel, cached)
|
|
209
|
+
await Promise.all([...discoveredMints].map(resolveFaction));
|
|
210
|
+
const nearbyFactions = [...discoveredMints]
|
|
211
|
+
.map((mint) => factionCache.get(mint))
|
|
212
|
+
.filter((f) => f != null)
|
|
213
|
+
.slice(0, limit);
|
|
214
|
+
return {
|
|
215
|
+
factions: nearbyFactions,
|
|
216
|
+
allies: discoveredAllies,
|
|
217
|
+
total: nearbyFactions.length,
|
|
218
|
+
limit,
|
|
219
|
+
offset: 0,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
99
222
|
async getAgentProfile(wallet) {
|
|
100
223
|
const vault = await this.actionProvider.getStrongholdForAgent(wallet);
|
|
101
224
|
const factions = await this.getAgentFactions(wallet);
|
|
@@ -3,10 +3,11 @@ import type { TransactionResult } from 'torchsdk';
|
|
|
3
3
|
import type { RegistryProfile, RegistryWalletLink, RegisterAgentParams, CheckpointParams, LinkAgentWalletParams, UnlinkAgentWalletParams, TransferAgentAuthorityParams } from '../types';
|
|
4
4
|
import { Registry } from '../types/registry.types';
|
|
5
5
|
export declare const REGISTRY_PROGRAM_ID: PublicKey;
|
|
6
|
-
export declare
|
|
7
|
-
export declare
|
|
6
|
+
export declare const getAgentProfilePda: (creator: PublicKey) => [PublicKey, number];
|
|
7
|
+
export declare const getAgentWalletLinkPda: (wallet: PublicKey) => [PublicKey, number];
|
|
8
8
|
export declare class RegistryProvider implements Registry {
|
|
9
9
|
private connection;
|
|
10
|
+
private _programCache;
|
|
10
11
|
constructor(connection: Connection);
|
|
11
12
|
private getProgram;
|
|
12
13
|
getProfile(creator: string): Promise<RegistryProfile | undefined>;
|
|
@@ -3,29 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RegistryProvider = exports.REGISTRY_PROGRAM_ID = void 0;
|
|
7
|
-
exports.getAgentProfilePda = getAgentProfilePda;
|
|
8
|
-
exports.getAgentWalletLinkPda = getAgentWalletLinkPda;
|
|
6
|
+
exports.RegistryProvider = exports.getAgentWalletLinkPda = exports.getAgentProfilePda = exports.REGISTRY_PROGRAM_ID = void 0;
|
|
9
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
10
8
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
11
9
|
const pyre_world_json_1 = __importDefault(require("../pyre_world.json"));
|
|
12
10
|
exports.REGISTRY_PROGRAM_ID = new web3_js_1.PublicKey(pyre_world_json_1.default.address);
|
|
13
11
|
const AGENT_SEED = 'pyre_agent';
|
|
14
12
|
const AGENT_WALLET_SEED = 'pyre_agent_wallet';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
signTransaction: async (t) => t,
|
|
25
|
-
signAllTransactions: async (t) => t,
|
|
26
|
-
};
|
|
27
|
-
return new anchor_1.AnchorProvider(connection, dummyWallet, {});
|
|
28
|
-
}
|
|
13
|
+
const getAgentProfilePda = (creator) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(AGENT_SEED), creator.toBuffer()], exports.REGISTRY_PROGRAM_ID);
|
|
14
|
+
exports.getAgentProfilePda = getAgentProfilePda;
|
|
15
|
+
const getAgentWalletLinkPda = (wallet) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(AGENT_WALLET_SEED), wallet.toBuffer()], exports.REGISTRY_PROGRAM_ID);
|
|
16
|
+
exports.getAgentWalletLinkPda = getAgentWalletLinkPda;
|
|
17
|
+
const makeDummyProvider = (connection, payer) => new anchor_1.AnchorProvider(connection, {
|
|
18
|
+
publicKey: payer,
|
|
19
|
+
signTransaction: async (t) => t,
|
|
20
|
+
signAllTransactions: async (t) => t,
|
|
21
|
+
}, {});
|
|
29
22
|
async function finalizeTransaction(connection, tx, feePayer) {
|
|
30
23
|
const { blockhash } = await connection.getLatestBlockhash();
|
|
31
24
|
tx.recentBlockhash = blockhash;
|
|
@@ -33,16 +26,23 @@ async function finalizeTransaction(connection, tx, feePayer) {
|
|
|
33
26
|
}
|
|
34
27
|
class RegistryProvider {
|
|
35
28
|
connection;
|
|
29
|
+
_programCache = new Map();
|
|
36
30
|
constructor(connection) {
|
|
37
31
|
this.connection = connection;
|
|
38
32
|
}
|
|
39
33
|
getProgram(payer) {
|
|
40
|
-
const
|
|
41
|
-
|
|
34
|
+
const key = payer.toBase58();
|
|
35
|
+
let program = this._programCache.get(key);
|
|
36
|
+
if (!program) {
|
|
37
|
+
const provider = makeDummyProvider(this.connection, payer);
|
|
38
|
+
program = new anchor_1.Program(pyre_world_json_1.default, provider);
|
|
39
|
+
this._programCache.set(key, program);
|
|
40
|
+
}
|
|
41
|
+
return program;
|
|
42
42
|
}
|
|
43
43
|
async getProfile(creator) {
|
|
44
44
|
const creatorPk = new web3_js_1.PublicKey(creator);
|
|
45
|
-
const [profilePda] = getAgentProfilePda(creatorPk);
|
|
45
|
+
const [profilePda] = (0, exports.getAgentProfilePda)(creatorPk);
|
|
46
46
|
const program = this.getProgram(creatorPk);
|
|
47
47
|
try {
|
|
48
48
|
const account = await program.account.agentProfile.fetch(profilePda);
|
|
@@ -79,7 +79,7 @@ class RegistryProvider {
|
|
|
79
79
|
}
|
|
80
80
|
async getWalletLink(wallet) {
|
|
81
81
|
const walletPk = new web3_js_1.PublicKey(wallet);
|
|
82
|
-
const [linkPda] = getAgentWalletLinkPda(walletPk);
|
|
82
|
+
const [linkPda] = (0, exports.getAgentWalletLinkPda)(walletPk);
|
|
83
83
|
const program = this.getProgram(walletPk);
|
|
84
84
|
try {
|
|
85
85
|
const account = await program.account.agentWalletLink.fetch(linkPda);
|
|
@@ -97,8 +97,8 @@ class RegistryProvider {
|
|
|
97
97
|
}
|
|
98
98
|
async register(params) {
|
|
99
99
|
const creator = new web3_js_1.PublicKey(params.creator);
|
|
100
|
-
const [profile] = getAgentProfilePda(creator);
|
|
101
|
-
const [walletLink] = getAgentWalletLinkPda(creator);
|
|
100
|
+
const [profile] = (0, exports.getAgentProfilePda)(creator);
|
|
101
|
+
const [walletLink] = (0, exports.getAgentWalletLinkPda)(creator);
|
|
102
102
|
const program = this.getProgram(creator);
|
|
103
103
|
const tx = new web3_js_1.Transaction();
|
|
104
104
|
const ix = await program.methods.register()
|
|
@@ -114,7 +114,7 @@ class RegistryProvider {
|
|
|
114
114
|
async checkpoint(params) {
|
|
115
115
|
const signer = new web3_js_1.PublicKey(params.signer);
|
|
116
116
|
const creatorPk = new web3_js_1.PublicKey(params.creator);
|
|
117
|
-
const [profile] = getAgentProfilePda(creatorPk);
|
|
117
|
+
const [profile] = (0, exports.getAgentProfilePda)(creatorPk);
|
|
118
118
|
const program = this.getProgram(signer);
|
|
119
119
|
const args = {
|
|
120
120
|
joins: new anchor_1.BN(params.joins),
|
|
@@ -150,8 +150,8 @@ class RegistryProvider {
|
|
|
150
150
|
const authority = new web3_js_1.PublicKey(params.authority);
|
|
151
151
|
const creatorPk = new web3_js_1.PublicKey(params.creator);
|
|
152
152
|
const walletToLink = new web3_js_1.PublicKey(params.wallet_to_link);
|
|
153
|
-
const [profile] = getAgentProfilePda(creatorPk);
|
|
154
|
-
const [walletLink] = getAgentWalletLinkPda(walletToLink);
|
|
153
|
+
const [profile] = (0, exports.getAgentProfilePda)(creatorPk);
|
|
154
|
+
const [walletLink] = (0, exports.getAgentWalletLinkPda)(walletToLink);
|
|
155
155
|
const program = this.getProgram(authority);
|
|
156
156
|
const tx = new web3_js_1.Transaction();
|
|
157
157
|
const ix = await program.methods.linkWallet()
|
|
@@ -174,8 +174,8 @@ class RegistryProvider {
|
|
|
174
174
|
const authority = new web3_js_1.PublicKey(params.authority);
|
|
175
175
|
const creatorPk = new web3_js_1.PublicKey(params.creator);
|
|
176
176
|
const walletToUnlink = new web3_js_1.PublicKey(params.wallet_to_unlink);
|
|
177
|
-
const [profile] = getAgentProfilePda(creatorPk);
|
|
178
|
-
const [walletLink] = getAgentWalletLinkPda(walletToUnlink);
|
|
177
|
+
const [profile] = (0, exports.getAgentProfilePda)(creatorPk);
|
|
178
|
+
const [walletLink] = (0, exports.getAgentWalletLinkPda)(walletToUnlink);
|
|
179
179
|
const program = this.getProgram(authority);
|
|
180
180
|
const tx = new web3_js_1.Transaction();
|
|
181
181
|
const ix = await program.methods.unlinkWallet()
|
|
@@ -198,7 +198,7 @@ class RegistryProvider {
|
|
|
198
198
|
const authority = new web3_js_1.PublicKey(params.authority);
|
|
199
199
|
const creatorPk = new web3_js_1.PublicKey(params.creator);
|
|
200
200
|
const newAuthority = new web3_js_1.PublicKey(params.new_authority);
|
|
201
|
-
const [profile] = getAgentProfilePda(creatorPk);
|
|
201
|
+
const [profile] = (0, exports.getAgentProfilePda)(creatorPk);
|
|
202
202
|
const program = this.getProgram(authority);
|
|
203
203
|
const tx = new web3_js_1.Transaction();
|
|
204
204
|
const ix = await program.methods.transferAuthority()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Connection } from '@solana/web3.js';
|
|
2
|
+
import type { Stronghold } from '../types';
|
|
2
3
|
import type { State, AgentGameState, SerializedGameState, TrackedAction, CheckpointConfig } from '../types/state.types';
|
|
3
4
|
import { Registry } from '../types/registry.types';
|
|
4
5
|
export declare class StateProvider implements State {
|
|
@@ -8,22 +9,26 @@ export declare class StateProvider implements State {
|
|
|
8
9
|
private _state;
|
|
9
10
|
private checkpointConfig;
|
|
10
11
|
private ticksSinceCheckpoint;
|
|
12
|
+
private _vaultCreator;
|
|
13
|
+
private _stronghold;
|
|
14
|
+
private _vaultPromise;
|
|
11
15
|
constructor(connection: Connection, registry: Registry, publicKey: string);
|
|
12
16
|
get state(): AgentGameState | null;
|
|
13
|
-
get vaultCreator(): string | null;
|
|
14
17
|
get initialized(): boolean;
|
|
15
18
|
get tick(): number;
|
|
16
|
-
/** Configure auto-checkpoint behavior */
|
|
17
19
|
setCheckpointConfig(config: CheckpointConfig): void;
|
|
20
|
+
private resolveVault;
|
|
21
|
+
getVaultCreator(): Promise<string | null>;
|
|
22
|
+
getStronghold(): Promise<Stronghold | null>;
|
|
18
23
|
init(): Promise<AgentGameState>;
|
|
19
24
|
record(action: TrackedAction, mint?: string, description?: string): Promise<void>;
|
|
20
25
|
private updateSentiment;
|
|
21
26
|
onCheckpointDue: (() => void) | null;
|
|
22
|
-
|
|
27
|
+
getHoldings(): Promise<Map<string, number>>;
|
|
28
|
+
getBalance(mint: string): Promise<number>;
|
|
23
29
|
getSentiment(mint: string): number;
|
|
24
30
|
get sentimentMap(): ReadonlyMap<string, number>;
|
|
25
31
|
get history(): readonly string[];
|
|
26
|
-
getBalance(mint: string): number;
|
|
27
32
|
hasVoted(mint: string): boolean;
|
|
28
33
|
hasRallied(mint: string): boolean;
|
|
29
34
|
markVoted(mint: string): void;
|