pyre-world-kit 3.0.4 → 3.0.5

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/mappers.js DELETED
@@ -1,258 +0,0 @@
1
- "use strict";
2
- /**
3
- * Pyre Kit Mappers
4
- *
5
- * Internal mapping functions between Torch SDK types and Pyre game types.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.mapFactionStatus = mapFactionStatus;
9
- exports.mapTokenStatus = mapTokenStatus;
10
- exports.mapTokenStatusFilter = mapTokenStatusFilter;
11
- exports.mapFactionTier = mapFactionTier;
12
- exports.mapFactionTierFromSol = mapFactionTierFromSol;
13
- exports.mapStrategy = mapStrategy;
14
- exports.mapVote = mapVote;
15
- exports.mapTokenSummaryToFaction = mapTokenSummaryToFaction;
16
- exports.mapTokenDetailToFaction = mapTokenDetailToFaction;
17
- exports.mapVaultToStronghold = mapVaultToStronghold;
18
- exports.mapWalletLinkToAgentLink = mapWalletLinkToAgentLink;
19
- exports.mapTokenMessageToComms = mapTokenMessageToComms;
20
- exports.mapLendingToWarChest = mapLendingToWarChest;
21
- exports.mapLoanToWarLoan = mapLoanToWarLoan;
22
- exports.mapLoanWithKeyToWarLoan = mapLoanWithKeyToWarLoan;
23
- exports.mapHolderToMember = mapHolderToMember;
24
- exports.mapTokenListResult = mapTokenListResult;
25
- exports.mapHoldersResult = mapHoldersResult;
26
- exports.mapMessagesResult = mapMessagesResult;
27
- exports.mapAllLoansResult = mapAllLoansResult;
28
- exports.mapBuyResult = mapBuyResult;
29
- exports.mapCreateResult = mapCreateResult;
30
- // ─── Status Mapping ────────────────────────────────────────────────
31
- const STATUS_MAP = {
32
- bonding: 'rising',
33
- complete: 'ready',
34
- migrated: 'ascended',
35
- reclaimed: 'razed',
36
- };
37
- const STATUS_REVERSE = {
38
- rising: 'bonding',
39
- ready: 'complete',
40
- ascended: 'migrated',
41
- razed: 'reclaimed',
42
- };
43
- const STATUS_FILTER_REVERSE = {
44
- rising: 'bonding',
45
- ready: 'complete',
46
- ascended: 'migrated',
47
- razed: 'reclaimed',
48
- all: 'all',
49
- };
50
- function mapFactionStatus(status) {
51
- return STATUS_MAP[status];
52
- }
53
- function mapTokenStatus(status) {
54
- return STATUS_REVERSE[status];
55
- }
56
- function mapTokenStatusFilter(status) {
57
- return STATUS_FILTER_REVERSE[status];
58
- }
59
- // ─── Tier Mapping ──────────────────────────────────────────────────
60
- /** Map SOL target to faction tier */
61
- function mapFactionTier(sol_target) {
62
- // Torch tiers: spark (≤50 SOL), flame (≤100 SOL), torch (200 SOL default)
63
- if (sol_target <= 50_000_000_000)
64
- return 'ember'; // ≤50 SOL in lamports
65
- if (sol_target <= 100_000_000_000)
66
- return 'blaze'; // ≤100 SOL
67
- return 'inferno'; // 200 SOL (default)
68
- }
69
- /** Infer tier from sol_target in SOL (not lamports) */
70
- function mapFactionTierFromSol(sol_target) {
71
- if (sol_target <= 50)
72
- return 'ember';
73
- if (sol_target <= 100)
74
- return 'blaze';
75
- return 'inferno';
76
- }
77
- // ─── Strategy Mapping ──────────────────────────────────────────────
78
- function mapStrategy(vote) {
79
- return vote === 'burn' ? 'scorched_earth' : 'fortify';
80
- }
81
- function mapVote(strategy) {
82
- return strategy === 'scorched_earth' ? 'burn' : 'return';
83
- }
84
- // ─── Core Type Mappers ─────────────────────────────────────────────
85
- function mapTokenSummaryToFaction(t) {
86
- return {
87
- mint: t.mint,
88
- name: t.name,
89
- symbol: t.symbol,
90
- status: mapFactionStatus(t.status),
91
- tier: mapFactionTierFromSol(t.market_cap_sol > 0 ? 200 : 200), // default tier from target
92
- price_sol: t.price_sol,
93
- market_cap_sol: t.market_cap_sol,
94
- progress_percent: t.progress_percent,
95
- members: t.holders,
96
- created_at: t.created_at,
97
- last_activity_at: t.last_activity_at,
98
- };
99
- }
100
- function mapTokenDetailToFaction(t) {
101
- return {
102
- mint: t.mint,
103
- name: t.name,
104
- symbol: t.symbol,
105
- description: t.description,
106
- image: t.image,
107
- status: mapFactionStatus(t.status),
108
- tier: mapFactionTierFromSol(t.sol_target),
109
- price_sol: t.price_sol,
110
- price_usd: t.price_usd,
111
- market_cap_sol: t.market_cap_sol,
112
- market_cap_usd: t.market_cap_usd,
113
- progress_percent: t.progress_percent,
114
- sol_raised: t.sol_raised,
115
- sol_target: t.sol_target,
116
- total_supply: t.total_supply,
117
- circulating_supply: t.circulating_supply,
118
- tokens_in_curve: t.tokens_in_curve,
119
- tokens_in_vote_vault: t.tokens_in_vote_vault,
120
- tokens_burned: t.tokens_burned,
121
- war_chest_sol: t.treasury_sol_balance,
122
- war_chest_tokens: t.treasury_token_balance,
123
- total_bought_back: t.total_bought_back,
124
- buyback_count: t.buyback_count,
125
- votes_scorched_earth: t.votes_burn,
126
- votes_fortify: t.votes_return,
127
- founder: t.creator,
128
- members: t.holders,
129
- rallies: t.stars,
130
- created_at: t.created_at,
131
- last_activity_at: t.last_activity_at,
132
- twitter: t.twitter,
133
- telegram: t.telegram,
134
- website: t.website,
135
- founder_verified: t.creator_verified,
136
- founder_trust_tier: t.creator_trust_tier,
137
- founder_said_name: t.creator_said_name,
138
- founder_badge_url: t.creator_badge_url,
139
- warnings: t.warnings,
140
- };
141
- }
142
- function mapVaultToStronghold(v) {
143
- return {
144
- address: v.address,
145
- creator: v.creator,
146
- authority: v.authority,
147
- sol_balance: v.sol_balance,
148
- total_deposited: v.total_deposited,
149
- total_withdrawn: v.total_withdrawn,
150
- total_spent: v.total_spent,
151
- total_received: v.total_received,
152
- linked_agents: v.linked_wallets,
153
- created_at: v.created_at,
154
- };
155
- }
156
- function mapWalletLinkToAgentLink(l) {
157
- return {
158
- address: l.address,
159
- stronghold: l.vault,
160
- wallet: l.wallet,
161
- linked_at: l.linked_at,
162
- };
163
- }
164
- function mapTokenMessageToComms(m) {
165
- return {
166
- signature: m.signature,
167
- memo: m.memo,
168
- sender: m.sender,
169
- timestamp: m.timestamp,
170
- sender_verified: m.sender_verified,
171
- sender_trust_tier: m.sender_trust_tier,
172
- sender_said_name: m.sender_said_name,
173
- sender_badge_url: m.sender_badge_url,
174
- };
175
- }
176
- function mapLendingToWarChest(l) {
177
- return {
178
- interest_rate_bps: l.interest_rate_bps,
179
- max_ltv_bps: l.max_ltv_bps,
180
- liquidation_threshold_bps: l.liquidation_threshold_bps,
181
- liquidation_bonus_bps: l.liquidation_bonus_bps,
182
- utilization_cap_bps: l.utilization_cap_bps,
183
- borrow_share_multiplier: l.borrow_share_multiplier,
184
- total_sol_lent: l.total_sol_lent,
185
- active_loans: l.active_loans,
186
- war_chest_sol_available: l.treasury_sol_available,
187
- warnings: l.warnings,
188
- };
189
- }
190
- function mapLoanToWarLoan(l) {
191
- return {
192
- collateral_amount: l.collateral_amount,
193
- borrowed_amount: l.borrowed_amount,
194
- accrued_interest: l.accrued_interest,
195
- total_owed: l.total_owed,
196
- collateral_value_sol: l.collateral_value_sol,
197
- current_ltv_bps: l.current_ltv_bps,
198
- health: l.health,
199
- warnings: l.warnings,
200
- };
201
- }
202
- function mapLoanWithKeyToWarLoan(l) {
203
- return {
204
- ...mapLoanToWarLoan(l),
205
- borrower: l.borrower,
206
- };
207
- }
208
- function mapHolderToMember(h) {
209
- return {
210
- address: h.address,
211
- balance: h.balance,
212
- percentage: h.percentage,
213
- };
214
- }
215
- // ─── Result Mappers ────────────────────────────────────────────────
216
- function mapTokenListResult(r) {
217
- return {
218
- factions: r.tokens.map(mapTokenSummaryToFaction),
219
- total: r.total,
220
- limit: r.limit,
221
- offset: r.offset,
222
- };
223
- }
224
- function mapHoldersResult(r) {
225
- return {
226
- members: r.holders.map(mapHolderToMember),
227
- total_members: r.total_holders,
228
- };
229
- }
230
- function mapMessagesResult(r) {
231
- return {
232
- comms: r.messages.map(mapTokenMessageToComms),
233
- total: r.total,
234
- };
235
- }
236
- function mapAllLoansResult(r) {
237
- return {
238
- positions: r.positions.map(mapLoanWithKeyToWarLoan),
239
- pool_price_sol: r.pool_price_sol,
240
- };
241
- }
242
- function mapBuyResult(r) {
243
- return {
244
- transaction: r.transaction,
245
- additionalTransactions: r.additionalTransactions,
246
- message: r.message,
247
- migrationTransaction: r.migrationTransaction,
248
- };
249
- }
250
- function mapCreateResult(r) {
251
- return {
252
- transaction: r.transaction,
253
- additionalTransactions: r.additionalTransactions,
254
- message: r.message,
255
- mint: r.mint,
256
- mintKeypair: r.mintKeypair,
257
- };
258
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Pyre World Agent Registry
3
- *
4
- * On-chain agent identity and state persistence.
5
- * Agents checkpoint their action distributions and personality summaries
6
- * so any machine with the wallet key can reconstruct the agent.
7
- */
8
- import { Connection, PublicKey } from '@solana/web3.js';
9
- import type { TransactionResult } from 'torchsdk';
10
- import type { RegistryProfile, RegistryWalletLink, RegisterAgentParams, CheckpointParams, LinkAgentWalletParams, UnlinkAgentWalletParams, TransferAgentAuthorityParams } from './types';
11
- export declare const REGISTRY_PROGRAM_ID: PublicKey;
12
- export declare function getAgentProfilePda(creator: PublicKey): [PublicKey, number];
13
- export declare function getAgentWalletLinkPda(wallet: PublicKey): [PublicKey, number];
14
- /** Fetch an agent's on-chain registry profile by creator wallet */
15
- export declare function getRegistryProfile(connection: Connection, creator: string): Promise<RegistryProfile | null>;
16
- /** Fetch a wallet link by wallet address (reverse lookup: wallet → profile) */
17
- export declare function getRegistryWalletLink(connection: Connection, wallet: string): Promise<RegistryWalletLink | null>;
18
- /** Register a new agent profile and auto-link the creator's wallet */
19
- export declare function buildRegisterAgentTransaction(connection: Connection, params: RegisterAgentParams): Promise<TransactionResult>;
20
- /** Checkpoint agent action counters and personality summary */
21
- export declare function buildCheckpointTransaction(connection: Connection, params: CheckpointParams): Promise<TransactionResult>;
22
- /** Link a new wallet to an agent profile (authority only) */
23
- export declare function buildLinkAgentWalletTransaction(connection: Connection, params: LinkAgentWalletParams): Promise<TransactionResult>;
24
- /** Unlink the current wallet from an agent profile (authority only) */
25
- export declare function buildUnlinkAgentWalletTransaction(connection: Connection, params: UnlinkAgentWalletParams): Promise<TransactionResult>;
26
- /** Transfer agent profile authority to a new wallet */
27
- export declare function buildTransferAgentAuthorityTransaction(connection: Connection, params: TransferAgentAuthorityParams): Promise<TransactionResult>;
package/dist/registry.js DELETED
@@ -1,248 +0,0 @@
1
- "use strict";
2
- /**
3
- * Pyre World Agent Registry
4
- *
5
- * On-chain agent identity and state persistence.
6
- * Agents checkpoint their action distributions and personality summaries
7
- * so any machine with the wallet key can reconstruct the agent.
8
- */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.REGISTRY_PROGRAM_ID = void 0;
14
- exports.getAgentProfilePda = getAgentProfilePda;
15
- exports.getAgentWalletLinkPda = getAgentWalletLinkPda;
16
- exports.getRegistryProfile = getRegistryProfile;
17
- exports.getRegistryWalletLink = getRegistryWalletLink;
18
- exports.buildRegisterAgentTransaction = buildRegisterAgentTransaction;
19
- exports.buildCheckpointTransaction = buildCheckpointTransaction;
20
- exports.buildLinkAgentWalletTransaction = buildLinkAgentWalletTransaction;
21
- exports.buildUnlinkAgentWalletTransaction = buildUnlinkAgentWalletTransaction;
22
- exports.buildTransferAgentAuthorityTransaction = buildTransferAgentAuthorityTransaction;
23
- const web3_js_1 = require("@solana/web3.js");
24
- const anchor_1 = require("@coral-xyz/anchor");
25
- const pyre_world_json_1 = __importDefault(require("./pyre_world.json"));
26
- // ─── Program ID ─────────────────────────────────────────────────────
27
- exports.REGISTRY_PROGRAM_ID = new web3_js_1.PublicKey(pyre_world_json_1.default.address);
28
- // ─── PDA Seeds ──────────────────────────────────────────────────────
29
- const AGENT_SEED = 'pyre_agent';
30
- const AGENT_WALLET_SEED = 'pyre_agent_wallet';
31
- // ─── PDA Helpers ────────────────────────────────────────────────────
32
- function getAgentProfilePda(creator) {
33
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(AGENT_SEED), creator.toBuffer()], exports.REGISTRY_PROGRAM_ID);
34
- }
35
- function getAgentWalletLinkPda(wallet) {
36
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(AGENT_WALLET_SEED), wallet.toBuffer()], exports.REGISTRY_PROGRAM_ID);
37
- }
38
- // ─── Anchor Program Helper ──────────────────────────────────────────
39
- function makeDummyProvider(connection, payer) {
40
- const dummyWallet = {
41
- publicKey: payer,
42
- signTransaction: async (t) => t,
43
- signAllTransactions: async (t) => t,
44
- };
45
- return new anchor_1.AnchorProvider(connection, dummyWallet, {});
46
- }
47
- async function finalizeTransaction(connection, tx, feePayer) {
48
- const { blockhash } = await connection.getLatestBlockhash();
49
- tx.recentBlockhash = blockhash;
50
- tx.feePayer = feePayer;
51
- }
52
- function getProgram(connection, payer) {
53
- const provider = makeDummyProvider(connection, payer);
54
- return new anchor_1.Program(pyre_world_json_1.default, provider);
55
- }
56
- // ─── Read Operations ────────────────────────────────────────────────
57
- /** Fetch an agent's on-chain registry profile by creator wallet */
58
- async function getRegistryProfile(connection, creator) {
59
- const creatorPk = new web3_js_1.PublicKey(creator);
60
- const [profilePda] = getAgentProfilePda(creatorPk);
61
- const program = getProgram(connection, creatorPk);
62
- try {
63
- const account = await program.account.agentProfile.fetch(profilePda);
64
- return {
65
- address: profilePda.toBase58(),
66
- creator: account.creator.toBase58(),
67
- authority: account.authority.toBase58(),
68
- linked_wallet: account.linkedWallet.toBase58(),
69
- personality_summary: account.personalitySummary,
70
- last_checkpoint: account.lastCheckpoint.toNumber(),
71
- joins: account.joins.toNumber(),
72
- defects: account.defects.toNumber(),
73
- rallies: account.rallies.toNumber(),
74
- launches: account.launches.toNumber(),
75
- messages: account.messages.toNumber(),
76
- fuds: account.fuds.toNumber(),
77
- infiltrates: account.infiltrates.toNumber(),
78
- reinforces: account.reinforces.toNumber(),
79
- war_loans: account.warLoans.toNumber(),
80
- repay_loans: account.repayLoans.toNumber(),
81
- sieges: account.sieges.toNumber(),
82
- ascends: account.ascends.toNumber(),
83
- razes: account.razes.toNumber(),
84
- tithes: account.tithes.toNumber(),
85
- created_at: account.createdAt.toNumber(),
86
- bump: account.bump,
87
- total_sol_spent: account.totalSolSpent?.toNumber() ?? 0,
88
- total_sol_received: account.totalSolReceived?.toNumber() ?? 0,
89
- };
90
- }
91
- catch {
92
- return null;
93
- }
94
- }
95
- /** Fetch a wallet link by wallet address (reverse lookup: wallet → profile) */
96
- async function getRegistryWalletLink(connection, wallet) {
97
- const walletPk = new web3_js_1.PublicKey(wallet);
98
- const [linkPda] = getAgentWalletLinkPda(walletPk);
99
- const program = getProgram(connection, walletPk);
100
- try {
101
- const account = await program.account.agentWalletLink.fetch(linkPda);
102
- return {
103
- address: linkPda.toBase58(),
104
- profile: account.profile.toBase58(),
105
- wallet: account.wallet.toBase58(),
106
- linked_at: account.linkedAt.toNumber(),
107
- bump: account.bump,
108
- };
109
- }
110
- catch {
111
- return null;
112
- }
113
- }
114
- // ─── Transaction Builders ───────────────────────────────────────────
115
- /** Register a new agent profile and auto-link the creator's wallet */
116
- async function buildRegisterAgentTransaction(connection, params) {
117
- const creator = new web3_js_1.PublicKey(params.creator);
118
- const [profile] = getAgentProfilePda(creator);
119
- const [walletLink] = getAgentWalletLinkPda(creator);
120
- const program = getProgram(connection, creator);
121
- const tx = new web3_js_1.Transaction();
122
- const ix = await program.methods.register()
123
- .accounts({
124
- creator,
125
- profile,
126
- walletLink,
127
- systemProgram: web3_js_1.SystemProgram.programId,
128
- })
129
- .instruction();
130
- tx.add(ix);
131
- await finalizeTransaction(connection, tx, creator);
132
- return {
133
- transaction: tx,
134
- message: `Register agent profile [${profile.toBase58()}]`,
135
- };
136
- }
137
- /** Checkpoint agent action counters and personality summary */
138
- async function buildCheckpointTransaction(connection, params) {
139
- const signer = new web3_js_1.PublicKey(params.signer);
140
- const creatorPk = new web3_js_1.PublicKey(params.creator);
141
- const [profile] = getAgentProfilePda(creatorPk);
142
- const program = getProgram(connection, signer);
143
- const args = {
144
- joins: new anchor_1.BN(params.joins),
145
- defects: new anchor_1.BN(params.defects),
146
- rallies: new anchor_1.BN(params.rallies),
147
- launches: new anchor_1.BN(params.launches),
148
- messages: new anchor_1.BN(params.messages),
149
- fuds: new anchor_1.BN(params.fuds),
150
- infiltrates: new anchor_1.BN(params.infiltrates),
151
- reinforces: new anchor_1.BN(params.reinforces),
152
- warLoans: new anchor_1.BN(params.war_loans),
153
- repayLoans: new anchor_1.BN(params.repay_loans),
154
- sieges: new anchor_1.BN(params.sieges),
155
- ascends: new anchor_1.BN(params.ascends),
156
- razes: new anchor_1.BN(params.razes),
157
- tithes: new anchor_1.BN(params.tithes),
158
- personalitySummary: params.personality_summary,
159
- totalSolSpent: new anchor_1.BN(params.total_sol_spent),
160
- totalSolReceived: new anchor_1.BN(params.total_sol_received),
161
- };
162
- const tx = new web3_js_1.Transaction();
163
- const ix = await program.methods.checkpoint(args)
164
- .accounts({
165
- signer,
166
- profile,
167
- systemProgram: web3_js_1.SystemProgram.programId,
168
- })
169
- .instruction();
170
- tx.add(ix);
171
- await finalizeTransaction(connection, tx, signer);
172
- return {
173
- transaction: tx,
174
- message: `Checkpoint agent [${profile.toBase58()}]`,
175
- };
176
- }
177
- /** Link a new wallet to an agent profile (authority only) */
178
- async function buildLinkAgentWalletTransaction(connection, params) {
179
- const authority = new web3_js_1.PublicKey(params.authority);
180
- const creatorPk = new web3_js_1.PublicKey(params.creator);
181
- const walletToLink = new web3_js_1.PublicKey(params.wallet_to_link);
182
- const [profile] = getAgentProfilePda(creatorPk);
183
- const [walletLink] = getAgentWalletLinkPda(walletToLink);
184
- const program = getProgram(connection, authority);
185
- const tx = new web3_js_1.Transaction();
186
- const ix = await program.methods.linkWallet()
187
- .accounts({
188
- authority,
189
- profile,
190
- walletToLink,
191
- walletLink,
192
- systemProgram: web3_js_1.SystemProgram.programId,
193
- })
194
- .instruction();
195
- tx.add(ix);
196
- await finalizeTransaction(connection, tx, authority);
197
- return {
198
- transaction: tx,
199
- message: `Link wallet ${walletToLink.toBase58()} to agent [${profile.toBase58()}]`,
200
- };
201
- }
202
- /** Unlink the current wallet from an agent profile (authority only) */
203
- async function buildUnlinkAgentWalletTransaction(connection, params) {
204
- const authority = new web3_js_1.PublicKey(params.authority);
205
- const creatorPk = new web3_js_1.PublicKey(params.creator);
206
- const walletToUnlink = new web3_js_1.PublicKey(params.wallet_to_unlink);
207
- const [profile] = getAgentProfilePda(creatorPk);
208
- const [walletLink] = getAgentWalletLinkPda(walletToUnlink);
209
- const program = getProgram(connection, authority);
210
- const tx = new web3_js_1.Transaction();
211
- const ix = await program.methods.unlinkWallet()
212
- .accounts({
213
- authority,
214
- profile,
215
- walletToUnlink,
216
- walletLink,
217
- systemProgram: web3_js_1.SystemProgram.programId,
218
- })
219
- .instruction();
220
- tx.add(ix);
221
- await finalizeTransaction(connection, tx, authority);
222
- return {
223
- transaction: tx,
224
- message: `Unlink wallet ${walletToUnlink.toBase58()} from agent [${profile.toBase58()}]`,
225
- };
226
- }
227
- /** Transfer agent profile authority to a new wallet */
228
- async function buildTransferAgentAuthorityTransaction(connection, params) {
229
- const authority = new web3_js_1.PublicKey(params.authority);
230
- const creatorPk = new web3_js_1.PublicKey(params.creator);
231
- const newAuthority = new web3_js_1.PublicKey(params.new_authority);
232
- const [profile] = getAgentProfilePda(creatorPk);
233
- const program = getProgram(connection, authority);
234
- const tx = new web3_js_1.Transaction();
235
- const ix = await program.methods.transferAuthority()
236
- .accounts({
237
- authority,
238
- profile,
239
- newAuthority,
240
- })
241
- .instruction();
242
- tx.add(ix);
243
- await finalizeTransaction(connection, tx, authority);
244
- return {
245
- transaction: tx,
246
- message: `Transfer agent authority to ${newAuthority.toBase58()}`,
247
- };
248
- }