Skip to content

Commit b3eea2a

Browse files
committed
add cfg lint to token examples
1 parent bcb2a51 commit b3eea2a

File tree

59 files changed

+2525
-386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2525
-386
lines changed

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

basics/account-data/anchor/Anchor.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ seeds = false
33
skip-lint = false
44

55
[programs.localnet]
6-
anchor_program_example = "GpVcgWdgVErgLqsn8VYUch6EqDerMgNqoLSmGyKrd6MR"
6+
account_data_anchor_program = "GpVcgWdgVErgLqsn8VYUch6EqDerMgNqoLSmGyKrd6MR"
77

88
[registry]
99
url = "https://api.apr.dev"

basics/account-data/anchor/programs/anchor-program-example/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
2-
name = "account-data-anchor-program-example"
2+
name = "account-data-anchor-program"
33
version = "0.1.0"
44
description = "Created with Anchor"
55
edition = "2021"
66

77
[lib]
88
crate-type = ["cdylib", "lib"]
9-
name = "anchor_program_example"
9+
name = "account_data_anchor_program"
1010

1111
[features]
1212
default = []

basics/account-data/anchor/programs/anchor-program-example/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub mod state;
88
declare_id!("GpVcgWdgVErgLqsn8VYUch6EqDerMgNqoLSmGyKrd6MR");
99

1010
#[program]
11-
pub mod anchor_program_example {
11+
pub mod account_data_anchor_program {
1212
use super::*;
1313

1414
pub fn create_address_info(

basics/account-data/anchor/tests/bankrun.test.ts

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,61 @@ import * as anchor from "@coral-xyz/anchor";
33
import { Keypair, PublicKey } from "@solana/web3.js";
44
import { BankrunProvider } from "anchor-bankrun";
55
import { startAnchor } from "solana-bankrun";
6-
import type { AnchorProgramExample } from "../target/types/anchor_program_example";
6+
import type { AccountDataAnchorProgram } from "../target/types/account_data_anchor_program";
77

8-
import IDL from "../target/idl/anchor_program_example.json" with { type: "json" };
8+
import IDL from "../target/idl/account_data_anchor_program.json" with {
9+
type: "json",
10+
};
911
const PROGRAM_ID = new PublicKey(IDL.address);
1012

1113
describe("Account Data!", async () => {
12-
const context = await startAnchor(
13-
"",
14-
[{ name: "anchor_program_example", programId: PROGRAM_ID }],
15-
[],
16-
);
17-
const provider = new BankrunProvider(context);
18-
19-
const payer = provider.wallet as anchor.Wallet;
20-
const program = new anchor.Program<AnchorProgramExample>(IDL, provider);
21-
22-
// Generate a new keypair for the addressInfo account
23-
const addressInfoAccount = new Keypair();
24-
25-
it("Create the address info account", async () => {
26-
console.log(`Payer Address : ${payer.publicKey}`);
27-
console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`);
28-
29-
// Instruction Ix data
30-
const addressInfo = {
31-
name: "Joe C",
32-
houseNumber: 136,
33-
street: "Mile High Dr.",
34-
city: "Solana Beach",
35-
};
36-
37-
await program.methods
38-
.createAddressInfo(
39-
addressInfo.name,
40-
addressInfo.houseNumber,
41-
addressInfo.street,
42-
addressInfo.city,
43-
)
44-
.accounts({
45-
addressInfo: addressInfoAccount.publicKey,
46-
payer: payer.publicKey,
47-
})
48-
.signers([addressInfoAccount])
49-
.rpc();
50-
});
51-
52-
it("Read the new account's data", async () => {
53-
const addressInfo = await program.account.addressInfo.fetch(
54-
addressInfoAccount.publicKey,
55-
);
56-
console.log(`Name : ${addressInfo.name}`);
57-
console.log(`House Num: ${addressInfo.houseNumber}`);
58-
console.log(`Street : ${addressInfo.street}`);
59-
console.log(`City : ${addressInfo.city}`);
60-
});
14+
const context = await startAnchor(
15+
"",
16+
[{ name: "account_data_anchor_program", programId: PROGRAM_ID }],
17+
[],
18+
);
19+
const provider = new BankrunProvider(context);
20+
21+
const payer = provider.wallet as anchor.Wallet;
22+
const program = new anchor.Program<AccountDataAnchorProgram>(IDL, provider);
23+
24+
// Generate a new keypair for the addressInfo account
25+
const addressInfoAccount = new Keypair();
26+
27+
it("Create the address info account", async () => {
28+
console.log(`Payer Address : ${payer.publicKey}`);
29+
console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`);
30+
31+
// Instruction Ix data
32+
const addressInfo = {
33+
name: "Joe C",
34+
houseNumber: 136,
35+
street: "Mile High Dr.",
36+
city: "Solana Beach",
37+
};
38+
39+
await program.methods
40+
.createAddressInfo(
41+
addressInfo.name,
42+
addressInfo.houseNumber,
43+
addressInfo.street,
44+
addressInfo.city,
45+
)
46+
.accounts({
47+
addressInfo: addressInfoAccount.publicKey,
48+
payer: payer.publicKey,
49+
})
50+
.signers([addressInfoAccount])
51+
.rpc();
52+
});
53+
54+
it("Read the new account's data", async () => {
55+
const addressInfo = await program.account.addressInfo.fetch(
56+
addressInfoAccount.publicKey,
57+
);
58+
console.log(`Name : ${addressInfo.name}`);
59+
console.log(`House Num: ${addressInfo.houseNumber}`);
60+
console.log(`Street : ${addressInfo.street}`);
61+
console.log(`City : ${addressInfo.city}`);
62+
});
6163
});
Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,51 @@
1-
import * as anchor from '@coral-xyz/anchor';
2-
import { Keypair } from '@solana/web3.js';
3-
import type { AnchorProgramExample } from '../target/types/anchor_program_example';
1+
import * as anchor from "@coral-xyz/anchor";
2+
import { Keypair } from "@solana/web3.js";
3+
import type { AccountDataAnchorProgram } from "../target/types/account_data_anchor_program";
44

5-
describe('Account Data!', () => {
6-
const provider = anchor.AnchorProvider.env();
7-
anchor.setProvider(provider);
8-
const payer = provider.wallet as anchor.Wallet;
9-
const program = anchor.workspace.AnchorProgramExample as anchor.Program<AnchorProgramExample>;
5+
describe("Account Data!", () => {
6+
const provider = anchor.AnchorProvider.env();
7+
anchor.setProvider(provider);
8+
const payer = provider.wallet as anchor.Wallet;
9+
const program = anchor.workspace
10+
.AccountDataAnchorProgram as anchor.Program<AccountDataAnchorProgram>;
1011

11-
// Generate a new keypair for the addressInfo account
12-
const addressInfoAccount = new Keypair();
12+
// Generate a new keypair for the addressInfo account
13+
const addressInfoAccount = new Keypair();
1314

14-
it('Create the address info account', async () => {
15-
console.log(`Payer Address : ${payer.publicKey}`);
16-
console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`);
15+
it("Create the address info account", async () => {
16+
console.log(`Payer Address : ${payer.publicKey}`);
17+
console.log(`Address Info Acct : ${addressInfoAccount.publicKey}`);
1718

18-
// Instruction Ix data
19-
const addressInfo = {
20-
name: 'Joe C',
21-
houseNumber: 136,
22-
street: 'Mile High Dr.',
23-
city: 'Solana Beach',
24-
};
19+
// Instruction Ix data
20+
const addressInfo = {
21+
name: "Joe C",
22+
houseNumber: 136,
23+
street: "Mile High Dr.",
24+
city: "Solana Beach",
25+
};
2526

26-
await program.methods
27-
.createAddressInfo(addressInfo.name, addressInfo.houseNumber, addressInfo.street, addressInfo.city)
28-
.accounts({
29-
addressInfo: addressInfoAccount.publicKey,
30-
payer: payer.publicKey,
31-
})
32-
.signers([addressInfoAccount])
33-
.rpc();
34-
});
27+
await program.methods
28+
.createAddressInfo(
29+
addressInfo.name,
30+
addressInfo.houseNumber,
31+
addressInfo.street,
32+
addressInfo.city,
33+
)
34+
.accounts({
35+
addressInfo: addressInfoAccount.publicKey,
36+
payer: payer.publicKey,
37+
})
38+
.signers([addressInfoAccount])
39+
.rpc();
40+
});
3541

36-
it("Read the new account's data", async () => {
37-
const addressInfo = await program.account.addressInfo.fetch(addressInfoAccount.publicKey);
38-
console.log(`Name : ${addressInfo.name}`);
39-
console.log(`House Num: ${addressInfo.houseNumber}`);
40-
console.log(`Street : ${addressInfo.street}`);
41-
console.log(`City : ${addressInfo.city}`);
42-
});
42+
it("Read the new account's data", async () => {
43+
const addressInfo = await program.account.addressInfo.fetch(
44+
addressInfoAccount.publicKey,
45+
);
46+
console.log(`Name : ${addressInfo.name}`);
47+
console.log(`House Num: ${addressInfo.houseNumber}`);
48+
console.log(`Street : ${addressInfo.street}`);
49+
console.log(`City : ${addressInfo.city}`);
50+
});
4351
});

basics/account-data/native/program/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "account-data-program"
2+
name = "account-data-native-program"
33
version = "0.1.0"
44
edition = "2021"
55

0 commit comments

Comments
 (0)