pyre-world-kit 2.0.12 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/.prettierrc.json +6 -0
  2. package/dist/index.d.ts +38 -4
  3. package/dist/index.js +100 -85
  4. package/dist/providers/action.provider.d.ts +46 -0
  5. package/dist/providers/action.provider.js +331 -0
  6. package/dist/providers/intel.provider.d.ts +29 -0
  7. package/dist/providers/intel.provider.js +363 -0
  8. package/dist/providers/mapper.provider.d.ts +197 -0
  9. package/dist/providers/mapper.provider.js +158 -0
  10. package/dist/providers/registry.provider.d.ts +25 -0
  11. package/dist/providers/registry.provider.js +229 -0
  12. package/dist/providers/state.provider.d.ts +42 -0
  13. package/dist/providers/state.provider.js +348 -0
  14. package/dist/pyre_world.json +34 -229
  15. package/dist/types/action.types.d.ts +41 -0
  16. package/dist/types/action.types.js +2 -0
  17. package/dist/types/intel.types.d.ts +20 -0
  18. package/dist/types/intel.types.js +2 -0
  19. package/dist/types/mapper.types.d.ts +27 -0
  20. package/dist/types/mapper.types.js +22 -0
  21. package/dist/types/registry.types.d.ts +0 -0
  22. package/dist/types/registry.types.js +1 -0
  23. package/dist/types/state.types.d.ts +112 -0
  24. package/dist/types/state.types.js +2 -0
  25. package/dist/types.d.ts +8 -24
  26. package/dist/util.d.ts +29 -0
  27. package/dist/util.js +144 -0
  28. package/dist/vanity.d.ts +3 -3
  29. package/dist/vanity.js +18 -15
  30. package/package.json +4 -2
  31. package/readme.md +134 -122
  32. package/src/index.ts +127 -92
  33. package/src/providers/action.provider.ts +443 -0
  34. package/src/providers/intel.provider.ts +383 -0
  35. package/src/providers/mapper.provider.ts +195 -0
  36. package/src/providers/registry.provider.ts +277 -0
  37. package/src/providers/state.provider.ts +357 -0
  38. package/src/pyre_world.json +35 -230
  39. package/src/types/action.types.ts +76 -0
  40. package/src/types/intel.types.ts +22 -0
  41. package/src/types/mapper.types.ts +84 -0
  42. package/src/types/registry.types.ts +0 -0
  43. package/src/types/state.types.ts +144 -0
  44. package/src/types.ts +329 -333
  45. package/src/util.ts +148 -0
  46. package/src/vanity.ts +27 -14
  47. package/tests/test_e2e.ts +339 -172
  48. package/src/actions.ts +0 -719
  49. package/src/intel.ts +0 -521
  50. package/src/mappers.ts +0 -302
  51. package/src/registry.ts +0 -317
  52. package/tests/test_devnet_e2e.ts +0 -401
  53. package/tests/test_sim.ts +0 -458
package/src/mappers.ts DELETED
@@ -1,302 +0,0 @@
1
- /**
2
- * Pyre Kit Mappers
3
- *
4
- * Internal mapping functions between Torch SDK types and Pyre game types.
5
- */
6
-
7
- import type {
8
- TokenStatus,
9
- TokenSummary,
10
- TokenDetail,
11
- TokenStatusFilter,
12
- VaultInfo,
13
- VaultWalletLinkInfo,
14
- TokenMessage,
15
- LendingInfo,
16
- LoanPositionInfo,
17
- LoanPositionWithKey,
18
- Holder,
19
- HoldersResult,
20
- MessagesResult,
21
- TokenListResult,
22
- AllLoanPositionsResult,
23
- BuyTransactionResult,
24
- CreateTokenResult,
25
- } from 'torchsdk';
26
-
27
- import type {
28
- FactionStatus,
29
- FactionTier,
30
- FactionStatusFilter,
31
- Strategy,
32
- FactionSummary,
33
- FactionDetail,
34
- Stronghold,
35
- AgentLink,
36
- Comms,
37
- WarChest,
38
- WarLoan,
39
- WarLoanWithAgent,
40
- Member,
41
- FactionListResult,
42
- MembersResult,
43
- CommsResult,
44
- AllWarLoansResult,
45
- JoinFactionResult,
46
- LaunchFactionResult,
47
- } from './types';
48
-
49
- // ─── Status Mapping ────────────────────────────────────────────────
50
-
51
- const STATUS_MAP: Record<TokenStatus, FactionStatus> = {
52
- bonding: 'rising',
53
- complete: 'ready',
54
- migrated: 'ascended',
55
- reclaimed: 'razed',
56
- };
57
-
58
- const STATUS_REVERSE: Record<FactionStatus, TokenStatus> = {
59
- rising: 'bonding',
60
- ready: 'complete',
61
- ascended: 'migrated',
62
- razed: 'reclaimed',
63
- };
64
-
65
- const STATUS_FILTER_REVERSE: Record<FactionStatusFilter, TokenStatusFilter> = {
66
- rising: 'bonding',
67
- ready: 'complete',
68
- ascended: 'migrated',
69
- razed: 'reclaimed',
70
- all: 'all',
71
- };
72
-
73
- export function mapFactionStatus(status: TokenStatus): FactionStatus {
74
- return STATUS_MAP[status];
75
- }
76
-
77
- export function mapTokenStatus(status: FactionStatus): TokenStatus {
78
- return STATUS_REVERSE[status];
79
- }
80
-
81
- export function mapTokenStatusFilter(status: FactionStatusFilter): TokenStatusFilter {
82
- return STATUS_FILTER_REVERSE[status];
83
- }
84
-
85
- // ─── Tier Mapping ──────────────────────────────────────────────────
86
-
87
- /** Map SOL target to faction tier */
88
- export function mapFactionTier(sol_target: number): FactionTier {
89
- // Torch tiers: spark (≤50 SOL), flame (≤100 SOL), torch (200 SOL default)
90
- if (sol_target <= 50_000_000_000) return 'ember'; // ≤50 SOL in lamports
91
- if (sol_target <= 100_000_000_000) return 'blaze'; // ≤100 SOL
92
- return 'inferno'; // 200 SOL (default)
93
- }
94
-
95
- /** Infer tier from sol_target in SOL (not lamports) */
96
- export function mapFactionTierFromSol(sol_target: number): FactionTier {
97
- if (sol_target <= 50) return 'ember';
98
- if (sol_target <= 100) return 'blaze';
99
- return 'inferno';
100
- }
101
-
102
- // ─── Strategy Mapping ──────────────────────────────────────────────
103
-
104
- export function mapStrategy(vote: 'burn' | 'return'): Strategy {
105
- return vote === 'burn' ? 'scorched_earth' : 'fortify';
106
- }
107
-
108
- export function mapVote(strategy: Strategy): 'burn' | 'return' {
109
- return strategy === 'scorched_earth' ? 'burn' : 'return';
110
- }
111
-
112
- // ─── Core Type Mappers ─────────────────────────────────────────────
113
-
114
- export function mapTokenSummaryToFaction(t: TokenSummary): FactionSummary {
115
- return {
116
- mint: t.mint,
117
- name: t.name,
118
- symbol: t.symbol,
119
- status: mapFactionStatus(t.status),
120
- tier: mapFactionTierFromSol(t.market_cap_sol > 0 ? 200 : 200), // default tier from target
121
- price_sol: t.price_sol,
122
- market_cap_sol: t.market_cap_sol,
123
- progress_percent: t.progress_percent,
124
- members: t.holders,
125
- created_at: t.created_at,
126
- last_activity_at: t.last_activity_at,
127
- };
128
- }
129
-
130
- export function mapTokenDetailToFaction(t: TokenDetail): FactionDetail {
131
- return {
132
- mint: t.mint,
133
- name: t.name,
134
- symbol: t.symbol,
135
- description: t.description,
136
- image: t.image,
137
- status: mapFactionStatus(t.status),
138
- tier: mapFactionTierFromSol(t.sol_target),
139
- price_sol: t.price_sol,
140
- price_usd: t.price_usd,
141
- market_cap_sol: t.market_cap_sol,
142
- market_cap_usd: t.market_cap_usd,
143
- progress_percent: t.progress_percent,
144
- sol_raised: t.sol_raised,
145
- sol_target: t.sol_target,
146
- total_supply: t.total_supply,
147
- circulating_supply: t.circulating_supply,
148
- tokens_in_curve: t.tokens_in_curve,
149
- tokens_in_vote_vault: t.tokens_in_vote_vault,
150
- tokens_burned: t.tokens_burned,
151
- war_chest_sol: t.treasury_sol_balance,
152
- war_chest_tokens: t.treasury_token_balance,
153
- total_bought_back: t.total_bought_back,
154
- buyback_count: t.buyback_count,
155
- votes_scorched_earth: t.votes_burn,
156
- votes_fortify: t.votes_return,
157
- founder: t.creator,
158
- members: t.holders,
159
- rallies: t.stars,
160
- created_at: t.created_at,
161
- last_activity_at: t.last_activity_at,
162
- twitter: t.twitter,
163
- telegram: t.telegram,
164
- website: t.website,
165
- founder_verified: t.creator_verified,
166
- founder_trust_tier: t.creator_trust_tier,
167
- founder_said_name: t.creator_said_name,
168
- founder_badge_url: t.creator_badge_url,
169
- warnings: t.warnings,
170
- };
171
- }
172
-
173
- export function mapVaultToStronghold(v: VaultInfo): Stronghold {
174
- return {
175
- address: v.address,
176
- creator: v.creator,
177
- authority: v.authority,
178
- sol_balance: v.sol_balance,
179
- total_deposited: v.total_deposited,
180
- total_withdrawn: v.total_withdrawn,
181
- total_spent: v.total_spent,
182
- total_received: v.total_received,
183
- linked_agents: v.linked_wallets,
184
- created_at: v.created_at,
185
- };
186
- }
187
-
188
- export function mapWalletLinkToAgentLink(l: VaultWalletLinkInfo): AgentLink {
189
- return {
190
- address: l.address,
191
- stronghold: l.vault,
192
- wallet: l.wallet,
193
- linked_at: l.linked_at,
194
- };
195
- }
196
-
197
- export function mapTokenMessageToComms(m: TokenMessage): Comms {
198
- return {
199
- signature: m.signature,
200
- memo: m.memo,
201
- sender: m.sender,
202
- timestamp: m.timestamp,
203
- sender_verified: m.sender_verified,
204
- sender_trust_tier: m.sender_trust_tier,
205
- sender_said_name: m.sender_said_name,
206
- sender_badge_url: m.sender_badge_url,
207
- };
208
- }
209
-
210
- export function mapLendingToWarChest(l: LendingInfo): WarChest {
211
- return {
212
- interest_rate_bps: l.interest_rate_bps,
213
- max_ltv_bps: l.max_ltv_bps,
214
- liquidation_threshold_bps: l.liquidation_threshold_bps,
215
- liquidation_bonus_bps: l.liquidation_bonus_bps,
216
- utilization_cap_bps: l.utilization_cap_bps,
217
- borrow_share_multiplier: l.borrow_share_multiplier,
218
- total_sol_lent: l.total_sol_lent,
219
- active_loans: l.active_loans,
220
- war_chest_sol_available: l.treasury_sol_available,
221
- warnings: l.warnings,
222
- };
223
- }
224
-
225
- export function mapLoanToWarLoan(l: LoanPositionInfo): WarLoan {
226
- return {
227
- collateral_amount: l.collateral_amount,
228
- borrowed_amount: l.borrowed_amount,
229
- accrued_interest: l.accrued_interest,
230
- total_owed: l.total_owed,
231
- collateral_value_sol: l.collateral_value_sol,
232
- current_ltv_bps: l.current_ltv_bps,
233
- health: l.health,
234
- warnings: l.warnings,
235
- };
236
- }
237
-
238
- export function mapLoanWithKeyToWarLoan(l: LoanPositionWithKey): WarLoanWithAgent {
239
- return {
240
- ...mapLoanToWarLoan(l),
241
- borrower: l.borrower,
242
- };
243
- }
244
-
245
- export function mapHolderToMember(h: Holder): Member {
246
- return {
247
- address: h.address,
248
- balance: h.balance,
249
- percentage: h.percentage,
250
- };
251
- }
252
-
253
- // ─── Result Mappers ────────────────────────────────────────────────
254
-
255
- export function mapTokenListResult(r: TokenListResult): FactionListResult {
256
- return {
257
- factions: r.tokens.map(mapTokenSummaryToFaction),
258
- total: r.total,
259
- limit: r.limit,
260
- offset: r.offset,
261
- };
262
- }
263
-
264
- export function mapHoldersResult(r: HoldersResult): MembersResult {
265
- return {
266
- members: r.holders.map(mapHolderToMember),
267
- total_members: r.total_holders,
268
- };
269
- }
270
-
271
- export function mapMessagesResult(r: MessagesResult): CommsResult {
272
- return {
273
- comms: r.messages.map(mapTokenMessageToComms),
274
- total: r.total,
275
- };
276
- }
277
-
278
- export function mapAllLoansResult(r: AllLoanPositionsResult): AllWarLoansResult {
279
- return {
280
- positions: r.positions.map(mapLoanWithKeyToWarLoan),
281
- pool_price_sol: r.pool_price_sol,
282
- };
283
- }
284
-
285
- export function mapBuyResult(r: BuyTransactionResult): JoinFactionResult {
286
- return {
287
- transaction: r.transaction,
288
- additionalTransactions: r.additionalTransactions,
289
- message: r.message,
290
- migrationTransaction: r.migrationTransaction,
291
- };
292
- }
293
-
294
- export function mapCreateResult(r: CreateTokenResult): LaunchFactionResult {
295
- return {
296
- transaction: r.transaction,
297
- additionalTransactions: r.additionalTransactions,
298
- message: r.message,
299
- mint: r.mint,
300
- mintKeypair: r.mintKeypair,
301
- };
302
- }
package/src/registry.ts DELETED
@@ -1,317 +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
-
9
- import {
10
- Connection,
11
- PublicKey,
12
- Transaction,
13
- SystemProgram,
14
- } from '@solana/web3.js';
15
- import { BN, Program, AnchorProvider, type Wallet } from '@coral-xyz/anchor';
16
- import type { TransactionResult } from 'torchsdk';
17
- import type {
18
- RegistryProfile,
19
- RegistryWalletLink,
20
- RegisterAgentParams,
21
- CheckpointParams,
22
- LinkAgentWalletParams,
23
- UnlinkAgentWalletParams,
24
- TransferAgentAuthorityParams,
25
- } from './types';
26
-
27
- import idl from './pyre_world.json';
28
-
29
- // ─── Program ID ─────────────────────────────────────────────────────
30
-
31
- export const REGISTRY_PROGRAM_ID = new PublicKey(idl.address);
32
-
33
- // ─── PDA Seeds ──────────────────────────────────────────────────────
34
-
35
- const AGENT_SEED = 'pyre_agent';
36
- const AGENT_WALLET_SEED = 'pyre_agent_wallet';
37
-
38
- // ─── PDA Helpers ────────────────────────────────────────────────────
39
-
40
- export function getAgentProfilePda(creator: PublicKey): [PublicKey, number] {
41
- return PublicKey.findProgramAddressSync(
42
- [Buffer.from(AGENT_SEED), creator.toBuffer()],
43
- REGISTRY_PROGRAM_ID,
44
- );
45
- }
46
-
47
- export function getAgentWalletLinkPda(wallet: PublicKey): [PublicKey, number] {
48
- return PublicKey.findProgramAddressSync(
49
- [Buffer.from(AGENT_WALLET_SEED), wallet.toBuffer()],
50
- REGISTRY_PROGRAM_ID,
51
- );
52
- }
53
-
54
- // ─── Anchor Program Helper ──────────────────────────────────────────
55
-
56
- function makeDummyProvider(connection: Connection, payer: PublicKey): AnchorProvider {
57
- const dummyWallet = {
58
- publicKey: payer,
59
- signTransaction: async (t: Transaction) => t,
60
- signAllTransactions: async (t: Transaction[]) => t,
61
- };
62
- return new AnchorProvider(connection, dummyWallet as unknown as Wallet, {});
63
- }
64
-
65
- async function finalizeTransaction(
66
- connection: Connection,
67
- tx: Transaction,
68
- feePayer: PublicKey,
69
- ): Promise<void> {
70
- const { blockhash } = await connection.getLatestBlockhash();
71
- tx.recentBlockhash = blockhash;
72
- tx.feePayer = feePayer;
73
- }
74
-
75
- function getProgram(connection: Connection, payer: PublicKey): Program {
76
- const provider = makeDummyProvider(connection, payer);
77
- return new Program(idl as any, provider);
78
- }
79
-
80
- // ─── Read Operations ────────────────────────────────────────────────
81
-
82
- /** Fetch an agent's on-chain registry profile by creator wallet */
83
- export async function getRegistryProfile(
84
- connection: Connection,
85
- creator: string,
86
- ): Promise<RegistryProfile | null> {
87
- const creatorPk = new PublicKey(creator);
88
- const [profilePda] = getAgentProfilePda(creatorPk);
89
- const program = getProgram(connection, creatorPk);
90
-
91
- try {
92
- const account = await (program.account as any).agentProfile.fetch(profilePda);
93
- return {
94
- address: profilePda.toBase58(),
95
- creator: account.creator.toBase58(),
96
- authority: account.authority.toBase58(),
97
- linked_wallet: account.linkedWallet.toBase58(),
98
- personality_summary: account.personalitySummary,
99
- last_checkpoint: account.lastCheckpoint.toNumber(),
100
- joins: account.joins.toNumber(),
101
- defects: account.defects.toNumber(),
102
- rallies: account.rallies.toNumber(),
103
- launches: account.launches.toNumber(),
104
- messages: account.messages.toNumber(),
105
- fuds: account.fuds.toNumber(),
106
- infiltrates: account.infiltrates.toNumber(),
107
- reinforces: account.reinforces.toNumber(),
108
- war_loans: account.warLoans.toNumber(),
109
- repay_loans: account.repayLoans.toNumber(),
110
- sieges: account.sieges.toNumber(),
111
- ascends: account.ascends.toNumber(),
112
- razes: account.razes.toNumber(),
113
- tithes: account.tithes.toNumber(),
114
- created_at: account.createdAt.toNumber(),
115
- bump: account.bump,
116
- total_sol_spent: account.totalSolSpent?.toNumber() ?? 0,
117
- total_sol_received: account.totalSolReceived?.toNumber() ?? 0,
118
- };
119
- } catch {
120
- return null;
121
- }
122
- }
123
-
124
- /** Fetch a wallet link by wallet address (reverse lookup: wallet → profile) */
125
- export async function getRegistryWalletLink(
126
- connection: Connection,
127
- wallet: string,
128
- ): Promise<RegistryWalletLink | null> {
129
- const walletPk = new PublicKey(wallet);
130
- const [linkPda] = getAgentWalletLinkPda(walletPk);
131
- const program = getProgram(connection, walletPk);
132
-
133
- try {
134
- const account = await (program.account as any).agentWalletLink.fetch(linkPda);
135
- return {
136
- address: linkPda.toBase58(),
137
- profile: account.profile.toBase58(),
138
- wallet: account.wallet.toBase58(),
139
- linked_at: account.linkedAt.toNumber(),
140
- bump: account.bump,
141
- };
142
- } catch {
143
- return null;
144
- }
145
- }
146
-
147
- // ─── Transaction Builders ───────────────────────────────────────────
148
-
149
- /** Register a new agent profile and auto-link the creator's wallet */
150
- export async function buildRegisterAgentTransaction(
151
- connection: Connection,
152
- params: RegisterAgentParams,
153
- ): Promise<TransactionResult> {
154
- const creator = new PublicKey(params.creator);
155
- const [profile] = getAgentProfilePda(creator);
156
- const [walletLink] = getAgentWalletLinkPda(creator);
157
- const program = getProgram(connection, creator);
158
-
159
- const tx = new Transaction();
160
- const ix = await (program.methods.register() as any)
161
- .accounts({
162
- creator,
163
- profile,
164
- walletLink,
165
- systemProgram: SystemProgram.programId,
166
- })
167
- .instruction();
168
-
169
- tx.add(ix);
170
- await finalizeTransaction(connection, tx, creator);
171
-
172
- return {
173
- transaction: tx,
174
- message: `Register agent profile [${profile.toBase58()}]`,
175
- };
176
- }
177
-
178
- /** Checkpoint agent action counters and personality summary */
179
- export async function buildCheckpointTransaction(
180
- connection: Connection,
181
- params: CheckpointParams,
182
- ): Promise<TransactionResult> {
183
- const signer = new PublicKey(params.signer);
184
- const creatorPk = new PublicKey(params.creator);
185
- const [profile] = getAgentProfilePda(creatorPk);
186
- const program = getProgram(connection, signer);
187
-
188
- const args = {
189
- joins: new BN(params.joins),
190
- defects: new BN(params.defects),
191
- rallies: new BN(params.rallies),
192
- launches: new BN(params.launches),
193
- messages: new BN(params.messages),
194
- fuds: new BN(params.fuds),
195
- infiltrates: new BN(params.infiltrates),
196
- reinforces: new BN(params.reinforces),
197
- warLoans: new BN(params.war_loans),
198
- repayLoans: new BN(params.repay_loans),
199
- sieges: new BN(params.sieges),
200
- ascends: new BN(params.ascends),
201
- razes: new BN(params.razes),
202
- tithes: new BN(params.tithes),
203
- personalitySummary: params.personality_summary,
204
- totalSolSpent: new BN(params.total_sol_spent),
205
- totalSolReceived: new BN(params.total_sol_received),
206
- };
207
-
208
- const tx = new Transaction();
209
- const ix = await (program.methods.checkpoint(args) as any)
210
- .accounts({
211
- signer,
212
- profile,
213
- systemProgram: SystemProgram.programId,
214
- })
215
- .instruction();
216
-
217
- tx.add(ix);
218
- await finalizeTransaction(connection, tx, signer);
219
-
220
- return {
221
- transaction: tx,
222
- message: `Checkpoint agent [${profile.toBase58()}]`,
223
- };
224
- }
225
-
226
- /** Link a new wallet to an agent profile (authority only) */
227
- export async function buildLinkAgentWalletTransaction(
228
- connection: Connection,
229
- params: LinkAgentWalletParams,
230
- ): Promise<TransactionResult> {
231
- const authority = new PublicKey(params.authority);
232
- const creatorPk = new PublicKey(params.creator);
233
- const walletToLink = new PublicKey(params.wallet_to_link);
234
- const [profile] = getAgentProfilePda(creatorPk);
235
- const [walletLink] = getAgentWalletLinkPda(walletToLink);
236
- const program = getProgram(connection, authority);
237
-
238
- const tx = new Transaction();
239
- const ix = await (program.methods.linkWallet() as any)
240
- .accounts({
241
- authority,
242
- profile,
243
- walletToLink,
244
- walletLink,
245
- systemProgram: SystemProgram.programId,
246
- })
247
- .instruction();
248
-
249
- tx.add(ix);
250
- await finalizeTransaction(connection, tx, authority);
251
-
252
- return {
253
- transaction: tx,
254
- message: `Link wallet ${walletToLink.toBase58()} to agent [${profile.toBase58()}]`,
255
- };
256
- }
257
-
258
- /** Unlink the current wallet from an agent profile (authority only) */
259
- export async function buildUnlinkAgentWalletTransaction(
260
- connection: Connection,
261
- params: UnlinkAgentWalletParams,
262
- ): Promise<TransactionResult> {
263
- const authority = new PublicKey(params.authority);
264
- const creatorPk = new PublicKey(params.creator);
265
- const walletToUnlink = new PublicKey(params.wallet_to_unlink);
266
- const [profile] = getAgentProfilePda(creatorPk);
267
- const [walletLink] = getAgentWalletLinkPda(walletToUnlink);
268
- const program = getProgram(connection, authority);
269
-
270
- const tx = new Transaction();
271
- const ix = await (program.methods.unlinkWallet() as any)
272
- .accounts({
273
- authority,
274
- profile,
275
- walletToUnlink,
276
- walletLink,
277
- systemProgram: SystemProgram.programId,
278
- })
279
- .instruction();
280
-
281
- tx.add(ix);
282
- await finalizeTransaction(connection, tx, authority);
283
-
284
- return {
285
- transaction: tx,
286
- message: `Unlink wallet ${walletToUnlink.toBase58()} from agent [${profile.toBase58()}]`,
287
- };
288
- }
289
-
290
- /** Transfer agent profile authority to a new wallet */
291
- export async function buildTransferAgentAuthorityTransaction(
292
- connection: Connection,
293
- params: TransferAgentAuthorityParams,
294
- ): Promise<TransactionResult> {
295
- const authority = new PublicKey(params.authority);
296
- const creatorPk = new PublicKey(params.creator);
297
- const newAuthority = new PublicKey(params.new_authority);
298
- const [profile] = getAgentProfilePda(creatorPk);
299
- const program = getProgram(connection, authority);
300
-
301
- const tx = new Transaction();
302
- const ix = await (program.methods.transferAuthority() as any)
303
- .accounts({
304
- authority,
305
- profile,
306
- newAuthority,
307
- })
308
- .instruction();
309
-
310
- tx.add(ix);
311
- await finalizeTransaction(connection, tx, authority);
312
-
313
- return {
314
- transaction: tx,
315
- message: `Transfer agent authority to ${newAuthority.toBase58()}`,
316
- };
317
- }