Skip to content

Commit 1d7415c

Browse files
committed
Rename IDl to Idl
1 parent 6c9440f commit 1d7415c

File tree

4 files changed

+31
-24
lines changed

4 files changed

+31
-24
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
- Added `sendVersionedTransaction()` to send a versioned transaction with lookup tables. Also adds priority fee support.
44
- Added `createLookupTable()` to easily create a lookup table and extend it with additional addresses
5-
- Added `getIDlByProgramId()` to fetch an IDL from a program on-chain
6-
- Added `getIDlByIdlPath()` to parse an IDL from a local file path
5+
- Added `getIdlByProgramId()` to fetch an IDL from a program on-chain
6+
- Added `getIdlByPath()` to parse an IDL from a local file path
77
- Added `getIdlParsedAccountData()` to parse account data using an IDL
88
- Added `parseAnchorTransactionEvents()` to parse anchor transaction events using an IDL
99
- Added `decodeAnchorTransaction()` to decode a transaction completely using an IDL

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,13 @@ These utilities help with:
645645
Get an IDL from a local file:
646646

647647
```typescript
648-
const idl = await getIDlbyPath("./idl/program.json");
648+
const idl = await getIdlByPath("./idl/program.json");
649649
```
650650

651651
Or fetch it from the chain:
652652

653653
```typescript
654-
const idl = await getIDlByProgramId(
654+
const idl = await getIdlByProgramId(
655655
new PublicKey("verifycLy8mB96wd9wqq3WDXQwM4oU6r42Th37Db9fC"),
656656
connection,
657657
);
@@ -662,7 +662,7 @@ const idl = await getIDlByProgramId(
662662
Usage:
663663

664664
```typescript
665-
const idl = await getIDlByProgramId(programId, connection);
665+
const idl = await getIdlByProgramId(programId, connection);
666666
const data = await getIdlParsedAccountData(
667667
idl,
668668
"counter",
@@ -680,7 +680,7 @@ Fetches and parses an account's data using an Anchor IDL file. This is useful wh
680680
Usage:
681681

682682
```typescript
683-
const idl = await getIDlbyPath("./idl/program.json");
683+
const idl = await getIdlByPath("./idl/program.json");
684684
const events = await parseAnchorTransactionEvents(idl, signature, connection);
685685

686686
// Events will be an array of:
@@ -697,7 +697,7 @@ Parses all Anchor events emitted in a transaction. This helps you track and veri
697697
Usage:
698698

699699
```typescript
700-
const idl = await getIDlByProgramId(programId, connection);
700+
const idl = await getIdlByProgramId(programId, connection);
701701
const decoded = await decodeAnchorTransaction(idl, signature, connection);
702702

703703
// Print human-readable format

src/lib/idl.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import { formatIdl } from "./convertLegacyIdl";
2525
*
2626
* @example
2727
* ```typescript
28-
* const idl = await getIDlbyPath("./idl/program.json");
28+
* const idl = await getIdlByPath("./idl/program.json");
2929
* ```
3030
*/
31-
export async function getIDlbyPath<Idl>(idlPath: string): Promise<Idl> {
31+
export async function getIdlByPath<Idl>(idlPath: string): Promise<Idl> {
3232
const fs = await import("node:fs");
3333
const path = await import("node:path");
3434

@@ -48,13 +48,13 @@ export async function getIDlbyPath<Idl>(idlPath: string): Promise<Idl> {
4848
*
4949
* @example
5050
* ```typescript
51-
* const idl = await getIDlByProgramId(
51+
* const idl = await getIdlByProgramId(
5252
* new PublicKey("Foo1111111111111111111111111111111111111"),
5353
* connection
5454
* );
5555
* ```
5656
*/
57-
export async function getIDlByProgramId<Idl>(
57+
export async function getIdlByProgramId<Idl>(
5858
programId: PublicKey,
5959
connection: Connection,
6060
): Promise<Idl> {
@@ -73,7 +73,7 @@ export async function getIDlByProgramId<Idl>(
7373
/**
7474
* Fetches and parses an account's data using an Anchor IDL
7575
*
76-
* @param idl - The Anchor IDL (use getIDlByProgramId or getIDlbyPath to obtain)
76+
* @param idl - The Anchor IDL (use getIdlByProgramId or getIdlByPath to obtain)
7777
* @param accountName - The name of the account as defined in the IDL
7878
* @param accountAddress - The public key of the account to fetch
7979
* @param connection - Optional connection object (uses default provider if not specified)
@@ -82,7 +82,7 @@ export async function getIDlByProgramId<Idl>(
8282
*
8383
* @example
8484
* ```typescript
85-
* const idl = await getIDlByProgramId(programId, connection);
85+
* const idl = await getIdlByProgramId(programId, connection);
8686
* const data = await getIdlParsedAccountData(idl, "counter", accountAddress);
8787
* ```
8888
*/
@@ -115,15 +115,15 @@ export async function getIdlParsedAccountData<T = any>(
115115
/**
116116
* Parses Anchor events from a transaction
117117
*
118-
* @param idl - The Anchor IDL (use getIDlByProgramId or getIDlbyPath to obtain)
118+
* @param idl - The Anchor IDL (use getIdlByProgramId or getIdlByPath to obtain)
119119
* @param signature - Transaction signature to parse events from
120120
* @param connection - Connection object (uses default provider if not specified)
121121
* @param programId - Optional program ID needed for legacy IDLs
122122
* @returns Array of parsed events with their name and data
123123
*
124124
* @example
125125
* ```typescript
126-
* const idl = await getIDlbyPath("./idl/program.json");
126+
* const idl = await getIdlByPath("./idl/program.json");
127127
* const events = await parseAnchorTransactionEvents(idl, signature);
128128
* ```
129129
*/
@@ -200,15 +200,15 @@ export type DecodedTransaction = {
200200
/**
201201
* Decodes all Anchor instructions and their involved accounts in a transaction
202202
*
203-
* @param idl - The Anchor IDL (use getIDlByProgramId or getIDlbyPath to obtain)
203+
* @param idl - The Anchor IDL (use getIdlByProgramId or getIdlByPath to obtain)
204204
* @param signature - Transaction signature to decode
205205
* @param connection - Optional connection object (uses default provider if not specified)
206206
* @param programId - Optional program ID needed for legacy IDLs
207207
* @returns Decoded transaction with instructions and accounts
208208
*
209209
* @example
210210
* ```typescript
211-
* const idl = await getIDlByProgramId(programId, connection);
211+
* const idl = await getIdlByProgramId(programId, connection);
212212
* const decoded = await decodeAnchorTransaction(idl, signature);
213213
* ```
214214
*/
@@ -275,7 +275,11 @@ export async function decodeAnchorTransaction(
275275
const accountType = idl.accounts?.find((acc) =>
276276
accountInfo.data
277277
.slice(0, 8)
278-
.equals(accountsCoder.accountDiscriminator(acc.name.toLowerCase())),
278+
.equals(
279+
accountsCoder.accountDiscriminator(
280+
acc.name.toLowerCase(),
281+
),
282+
),
279283
);
280284
if (accountType) {
281285
accountData = accountsCoder.decode(

tests/src/idl.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, test } from "node:test";
22
import { Connection, PublicKey } from "@solana/web3.js";
33
import {
44
decodeAnchorTransaction,
5-
getIDlByProgramId,
5+
getIdlByProgramId,
66
getIdlParsedAccountData,
77
parseAnchorTransactionEvents,
88
} from "../../src";
@@ -15,7 +15,7 @@ const MAINNET = "https://api.mainnet-beta.solana.com";
1515
describe("confirmTransaction", () => {
1616
test("Parsing verify transaction contains two events", async () => {
1717
const connection = new Connection(MAINNET);
18-
const idl: Idl = await getIDlByProgramId(
18+
const idl: Idl = await getIdlByProgramId(
1919
new PublicKey("verifycLy8mB96wd9wqq3WDXQwM4oU6r42Th37Db9fC"),
2020
connection,
2121
);
@@ -36,7 +36,7 @@ describe("confirmTransaction", () => {
3636
"ancA4duevpt3eSgS5J7cD8oJntmfLKJDM59GhMtegES",
3737
);
3838

39-
const idl: Idl | null = await getIDlByProgramId(programId, connection);
39+
const idl: Idl | null = await getIdlByProgramId(programId, connection);
4040
if (!idl)
4141
throw new Error(`IDL not found for program ${programId.toString()}`);
4242

@@ -90,7 +90,7 @@ describe("confirmTransaction", () => {
9090
"ancA4duevpt3eSgS5J7cD8oJntmfLKJDM59GhMtegES",
9191
);
9292

93-
const idl: Idl | null = await getIDlByProgramId(programId, connection);
93+
const idl: Idl | null = await getIdlByProgramId(programId, connection);
9494
if (!idl)
9595
throw new Error(`IDL not found for program ${programId.toString()}`);
9696

@@ -134,7 +134,7 @@ describe("confirmTransaction", () => {
134134

135135
test("Parsing verify account returns correct data", async () => {
136136
const connection = new Connection(MAINNET);
137-
const idl: Idl = await getIDlByProgramId(
137+
const idl: Idl = await getIdlByProgramId(
138138
new PublicKey("verifycLy8mB96wd9wqq3WDXQwM4oU6r42Th37Db9fC"),
139139
connection,
140140
);
@@ -172,6 +172,9 @@ describe("confirmTransaction", () => {
172172
);
173173
assert.ok(Array.isArray(buildParams.args), "Should have args array");
174174
assert.ok(buildParams.deploySlot, "Should have deploySlot");
175-
assert.ok(typeof buildParams.bump === "number", "Should have bump of type number");
175+
assert.ok(
176+
typeof buildParams.bump === "number",
177+
"Should have bump of type number",
178+
);
176179
});
177180
});

0 commit comments

Comments
 (0)