Skip to content

Commit

Permalink
chore: Simplify example
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielePicco committed Oct 1, 2024
1 parent dd940c9 commit faaf6df
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
SystemProgram,
Transaction, TransactionInstruction
} from "@solana/web3.js";
import {DelegateAccounts, DELEGATION_PROGRAM_ID, MAGIC_PROGRAM_ID} from "@magicblock-labs/ephemeral-rollups-sdk";

const COUNTER_PDA_SEED = "test-pda";
const COUNTER_PROGRAM = new PublicKey("852a53jomx7dGmkpbFPGXNJymRxywo3WsH1vusNASJRr");
Expand Down Expand Up @@ -173,7 +172,7 @@ const App: React.FC = () => {
if(!ephemeral && !useTempKeypair){
signature = await sendTransaction(transaction, connection, { minContextSlot});
}else{
signature = await connection.sendRawTransaction(transaction.serialize());
signature = await connection.sendRawTransaction(transaction.serialize(), {skipPreflight: true});
}
await connection.confirmTransaction({ blockhash, lastValidBlockHeight, signature }, confirmCommitment);
// Transaction was successful
Expand Down Expand Up @@ -242,11 +241,6 @@ const App: React.FC = () => {
console.log("Delegate PDA transaction");
console.log(tempKeypair.current);
if (!tempKeypair.current) return;
const {
delegationPda,
delegationMetadata,
bufferPda,
} = DelegateAccounts(counterPda, counterProgramClient.current?.programId as PublicKey);
const accountTmpWallet = await connection.getAccountInfo(tempKeypair.current.publicKey);
if (!accountTmpWallet || accountTmpWallet.lamports <= 0.01 * LAMPORTS_PER_SOL) {
await transferToTempKeypair()
Expand All @@ -255,12 +249,7 @@ const App: React.FC = () => {
.delegate()
.accounts({
payer: tempKeypair.current.publicKey,
pda: counterPda,
ownerProgram: counterProgramClient.current?.programId,
delegationMetadata: delegationMetadata,
buffer: bufferPda,
delegationRecord: delegationPda,
delegationProgram: DELEGATION_PROGRAM_ID,
pda: counterPda
})
.transaction() as Transaction;
setEphemeralCounter(Number(counter));
Expand All @@ -278,7 +267,6 @@ const App: React.FC = () => {
.accounts({
payer: tempKeypair.current.publicKey,
counter: counterPda,
magicProgram: MAGIC_PROGRAM_ID,
})
.transaction() as Transaction;

Expand All @@ -292,14 +280,15 @@ const App: React.FC = () => {
if (!publicKey) return;
console.log("Mint transaction");
const transaction = await minterProgramClient.current?.methods
.mintToken(new BN(counter))
.mintToken(isDelegated ? new BN(ephemeralCounter) : new BN(counter))
.accounts({
payer: publicKey,
counter: counterPda,
})
.transaction() as Transaction;

await submitTransaction(transaction, false, false);
// eslint-disable-next-line
}, [publicKey, counter, counterPda, submitTransaction]);

/**
Expand Down

0 comments on commit faaf6df

Please sign in to comment.