Skip to content

Commit 944167f

Browse files
author
Bingle Kruger
committed
feat: new smart contract idl
1 parent 74ae732 commit 944167f

File tree

4 files changed

+1067
-1082
lines changed

4 files changed

+1067
-1082
lines changed

Diff for: drt-manager/Anchor.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ resolution = true
2121
skip-lint = false
2222

2323
[programs.localnet]
24-
drt_manager = "C1meQCYX6KokZ2bJN7GPRmJyvPy2nZHTMxEFyKyJTLQr"
24+
drt_manager = "HQKbqH1RnoChiVkdbgoJZJ8T6P2jmLHTqvdjaE7q8NDq"
2525

2626
[registry]
2727
url = "https://api.apr.dev"

Diff for: drt-manager/programs/drt-manager/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use anchor_spl::{
2525
};
2626
use mpl_token_metadata::ID as METADATA_PROGRAM_ID;
2727

28-
declare_id!("C1meQCYX6KokZ2bJN7GPRmJyvPy2nZHTMxEFyKyJTLQr");
28+
declare_id!("HQKbqH1RnoChiVkdbgoJZJ8T6P2jmLHTqvdjaE7q8NDq");
2929

3030
/// The vault account holds tokens and is a PDA.
3131
#[account]
@@ -597,8 +597,6 @@ pub struct RedeemDrt<'info> {
597597
)]
598598
pub vault: Box<Account<'info, Vault>>,
599599
#[account(mut)]
600-
pub owner: Signer<'info>,
601-
#[account(mut)]
602600
pub user: Signer<'info>,
603601
pub token_program: Program<'info, Token>,
604602
}

Diff for: ntc-web/lib/drtHelpers.ts

+11-19
Original file line numberDiff line numberDiff line change
@@ -221,49 +221,42 @@ export async function redeemDrt(
221221
userDrtTokenAccount: PublicKey,
222222
userOwnershipTokenAccount: PublicKey,
223223
drtType: string,
224-
wallet: any // Wallet from useWallet
224+
wallet: any
225225
): Promise<string> {
226226
const provider = program.provider as AnchorProvider;
227-
const user = provider.wallet.publicKey;
227+
const user = wallet.publicKey;
228228
const connection = provider.connection;
229229

230-
// Compute vault PDA
231230
const [vaultPda] = await PublicKey.findProgramAddress(
232231
[Buffer.from("vault"), pool.toBuffer()],
233232
program.programId
234233
);
235234

236-
// Check if userDrtTokenAccount exists
237235
const userDrtAccountInfo = await connection.getAccountInfo(userDrtTokenAccount);
238236
const userOwnershipAccountInfo = await connection.getAccountInfo(userOwnershipTokenAccount);
239237

240238
const instructions: anchor.web3.TransactionInstruction[] = [];
241-
242-
// Create userDrtTokenAccount if it doesn’t exist
243239
if (!userDrtAccountInfo) {
244240
console.log("Creating user DRT token account...");
245241
const createDrtTokenAccountIx = createAssociatedTokenAccountInstruction(
246-
wallet.publicKey, // payer
247-
userDrtTokenAccount, // associated token account address
248-
wallet.publicKey, // owner
249-
drtMint // mint
242+
wallet.publicKey,
243+
userDrtTokenAccount,
244+
wallet.publicKey,
245+
drtMint
250246
);
251247
instructions.push(createDrtTokenAccountIx);
252248
}
253-
254-
// Create userOwnershipTokenAccount if it doesn’t exist
255249
if (!userOwnershipAccountInfo) {
256250
console.log("Creating user ownership token account...");
257251
const createOwnershipTokenAccountIx = createAssociatedTokenAccountInstruction(
258-
wallet.publicKey, // payer
259-
userOwnershipTokenAccount, // associated token account address
260-
wallet.publicKey, // owner
261-
ownershipMint // mint
252+
wallet.publicKey,
253+
userOwnershipTokenAccount,
254+
wallet.publicKey,
255+
ownershipMint
262256
);
263257
instructions.push(createOwnershipTokenAccountIx);
264258
}
265259

266-
// Execute the redeem_drt instruction with pre-instructions if needed
267260
const tx = await program.methods
268261
.redeemDrt(drtType)
269262
.accounts({
@@ -273,8 +266,7 @@ export async function redeemDrt(
273266
userDrtTokenAccount,
274267
userOwnershipTokenAccount,
275268
vault: vaultPda,
276-
owner: user, // Assuming user is the owner for simplicity; adjust if pool owner differs
277-
user,
269+
user, // Only user signs
278270
tokenProgram: TOKEN_PROGRAM_ID,
279271
})
280272
.preInstructions(instructions)

0 commit comments

Comments
 (0)