|
1 | | -import * as anchor from '@coral-xyz/anchor'; |
2 | | -import Idl from '../target/idl/rent_example.json'; |
3 | | -import type { RentExample } from '../target/types/rent_example'; |
| 1 | +import * as anchor from "@coral-xyz/anchor"; |
| 2 | +import Idl from "../target/idl/rent_example.json" with { type: "json" }; |
| 3 | +import type { RentExample } from "../target/types/rent_example"; |
4 | 4 |
|
5 | | -describe('Create a system account', () => { |
6 | | - const provider = anchor.AnchorProvider.env(); |
7 | | - anchor.setProvider(provider); |
8 | | - const wallet = provider.wallet as anchor.Wallet; |
9 | | - const program = anchor.workspace.RentExample as anchor.Program<RentExample>; |
| 5 | +describe("Create a system account", () => { |
| 6 | + const provider = anchor.AnchorProvider.env(); |
| 7 | + anchor.setProvider(provider); |
| 8 | + const wallet = provider.wallet as anchor.Wallet; |
| 9 | + const program = anchor.workspace.RentExample as anchor.Program<RentExample>; |
10 | 10 |
|
11 | | - it('Create the account', async () => { |
12 | | - const newKeypair = anchor.web3.Keypair.generate(); |
| 11 | + it("Create the account", async () => { |
| 12 | + const newKeypair = anchor.web3.Keypair.generate(); |
13 | 13 |
|
14 | | - const addressData: anchor.IdlTypes<RentExample>['addressData'] = { |
15 | | - name: 'Marcus', |
16 | | - address: '123 Main St. San Francisco, CA', |
17 | | - }; |
| 14 | + const addressData: anchor.IdlTypes<RentExample>["addressData"] = { |
| 15 | + name: "Marcus", |
| 16 | + address: "123 Main St. San Francisco, CA", |
| 17 | + }; |
18 | 18 |
|
19 | | - // We're just going to serialize our object here so we can check |
20 | | - // the size on the client side against the program logs |
21 | | - // |
22 | | - const addressDataBuffer = new anchor.BorshCoder(Idl as anchor.Idl).types.encode('AddressData', addressData); |
23 | | - console.log(`Address data buffer length: ${addressDataBuffer.length}`); |
| 19 | + // We're just going to serialize our object here so we can check |
| 20 | + // the size on the client side against the program logs |
| 21 | + // |
| 22 | + const addressDataBuffer = new anchor.BorshCoder( |
| 23 | + Idl as anchor.Idl, |
| 24 | + ).types.encode("AddressData", addressData); |
| 25 | + console.log(`Address data buffer length: ${addressDataBuffer.length}`); |
24 | 26 |
|
25 | | - await program.methods |
26 | | - .createSystemAccount(addressData) |
27 | | - .accounts({ |
28 | | - payer: wallet.publicKey, |
29 | | - newAccount: newKeypair.publicKey, |
30 | | - }) |
31 | | - .signers([wallet.payer, newKeypair]) |
32 | | - .rpc(); |
33 | | - }); |
| 27 | + await program.methods |
| 28 | + .createSystemAccount(addressData) |
| 29 | + .accounts({ |
| 30 | + payer: wallet.publicKey, |
| 31 | + newAccount: newKeypair.publicKey, |
| 32 | + }) |
| 33 | + .signers([wallet.payer, newKeypair]) |
| 34 | + .rpc(); |
| 35 | + }); |
34 | 36 | }); |
0 commit comments