Skip to content

Commit f1763c0

Browse files
committed
format code
1 parent fba6bd1 commit f1763c0

File tree

3 files changed

+47
-60
lines changed

3 files changed

+47
-60
lines changed

basics/transfer-sol/poseidon/tests/bankrun.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as anchor from '@coral-xyz/anchor';
33
import { Keypair, LAMPORTS_PER_SOL, PublicKey, SystemProgram, Transaction, sendAndConfirmTransaction } from '@solana/web3.js';
44
import { BankrunProvider } from 'anchor-bankrun';
55
import { startAnchor } from 'solana-bankrun';
6-
import { TransferSolProgram } from "../target/types/transfer_sol_program";
6+
import { TransferSolProgram } from '../target/types/transfer_sol_program';
77

88
const IDL = require('../target/idl/transfer_sol.json');
99
const PROGRAM_ID = new PublicKey(IDL.address);
@@ -20,7 +20,6 @@ describe('Bankrun example', async () => {
2020
// Generate a new keypair for the recipient
2121
const recipient = new Keypair();
2222

23-
2423
it('Transfer SOL with CPI', async () => {
2524
await getBalances(payer.publicKey, recipient.publicKey, 'Beginning');
2625

@@ -35,12 +34,11 @@ describe('Bankrun example', async () => {
3534
await getBalances(payer.publicKey, recipient.publicKey, 'Resulting');
3635
});
3736

38-
3937
async function getBalances(payerPubkey: PublicKey, recipientPubkey: PublicKey, timeframe: string) {
4038
const payerBalance = await provider.connection.getBalance(payerPubkey);
4139
const recipientBalance = await provider.connection.getBalance(recipientPubkey);
4240
console.log(`${timeframe} balances:`);
4341
console.log(` Payer: ${payerBalance / LAMPORTS_PER_SOL}`);
4442
console.log(` Recipient: ${recipientBalance / LAMPORTS_PER_SOL}`);
4543
}
46-
});
44+
});
Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
1-
import * as anchor from "@coral-xyz/anchor";
2-
import { Program } from "@coral-xyz/anchor";
3-
import { TransferSolProgram } from "../target/types/transfer_sol_program";
4-
import { Keypair, LAMPORTS_PER_SOL, type PublicKey } from '@solana/web3.js';
5-
6-
describe("transfer-sol", () => {
7-
// Configure the client to use the local cluster.
8-
const provider = anchor.AnchorProvider.env();
9-
10-
anchor.setProvider(provider);
11-
12-
const payer = provider.wallet as anchor.Wallet;
13-
const program = anchor.workspace.CreateAccount as Program<TransferSolProgram>;
14-
const transferAmount = 1 * LAMPORTS_PER_SOL;
15-
const recipient = new Keypair();
16-
17-
it("It transfer sol!", async () => {
18-
19-
await getBalances(payer.publicKey, recipient.publicKey, 'Beginning');
20-
21-
// Add your test here.
22-
const tx = await program.methods.initialize(new anchor.BN(transferAmount)).accounts({
23-
sender: payer.publicKey,
24-
receiver: recipient.publicKey
25-
}).rpc();
26-
27-
console.log("Your transaction signature", tx);
28-
29-
await getBalances(payer.publicKey, recipient.publicKey, 'Resulting');
30-
31-
32-
});
33-
34-
async function getBalances(payerPubkey: PublicKey, recipientPubkey: PublicKey, timeframe: string) {
35-
const payerBalance = await provider.connection.getBalance(payerPubkey);
36-
const recipientBalance = await provider.connection.getBalance(recipientPubkey);
37-
console.log(`${timeframe} balances:`);
38-
console.log(` Payer: ${payerBalance / LAMPORTS_PER_SOL}`);
39-
console.log(` Recipient: ${recipientBalance / LAMPORTS_PER_SOL}`);
40-
}
1+
import * as anchor from '@coral-xyz/anchor';
2+
import { Program } from '@coral-xyz/anchor';
3+
import { Keypair, LAMPORTS_PER_SOL, type PublicKey } from '@solana/web3.js';
4+
import { TransferSolProgram } from '../target/types/transfer_sol_program';
5+
6+
describe('transfer-sol', () => {
7+
// Configure the client to use the local cluster.
8+
const provider = anchor.AnchorProvider.env();
9+
10+
anchor.setProvider(provider);
11+
12+
const payer = provider.wallet as anchor.Wallet;
13+
const program = anchor.workspace.CreateAccount as Program<TransferSolProgram>;
14+
const transferAmount = 1 * LAMPORTS_PER_SOL;
15+
const recipient = new Keypair();
16+
17+
it('It transfer sol!', async () => {
18+
await getBalances(payer.publicKey, recipient.publicKey, 'Beginning');
19+
20+
// Add your test here.
21+
const tx = await program.methods
22+
.initialize(new anchor.BN(transferAmount))
23+
.accounts({
24+
sender: payer.publicKey,
25+
receiver: recipient.publicKey,
26+
})
27+
.rpc();
28+
29+
console.log('Your transaction signature', tx);
30+
31+
await getBalances(payer.publicKey, recipient.publicKey, 'Resulting');
32+
});
33+
34+
async function getBalances(payerPubkey: PublicKey, recipientPubkey: PublicKey, timeframe: string) {
35+
const payerBalance = await provider.connection.getBalance(payerPubkey);
36+
const recipientBalance = await provider.connection.getBalance(recipientPubkey);
37+
console.log(`${timeframe} balances:`);
38+
console.log(` Payer: ${payerBalance / LAMPORTS_PER_SOL}`);
39+
console.log(` Recipient: ${recipientBalance / LAMPORTS_PER_SOL}`);
40+
}
4141
});
42-
Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
import { Pubkey, Result, u64, Signer, SystemAccount, SystemProgram } from "@solanaturbine/poseidon";
1+
import { Pubkey, Result, Signer, SystemAccount, SystemProgram, u64 } from '@solanaturbine/poseidon';
22

33
export default class TransferSolProgram {
4-
static PROGRAM_ID = new Pubkey("7VjyAirb4LLbGGTBqzCuYqeirue9S9Zj2fDfUYVU4YdA");
5-
6-
sendSol(
7-
sender: Signer,
8-
receiver: SystemAccount,
9-
amount: u64,
10-
): Result {
11-
12-
SystemProgram.transfer(
13-
sender,
14-
receiver,
15-
amount
16-
)
4+
static PROGRAM_ID = new Pubkey('7VjyAirb4LLbGGTBqzCuYqeirue9S9Zj2fDfUYVU4YdA');
175

6+
sendSol(sender: Signer, receiver: SystemAccount, amount: u64): Result {
7+
SystemProgram.transfer(sender, receiver, amount);
188
}
19-
}
9+
}

0 commit comments

Comments
 (0)