Skip to content

Commit a3bcf8f

Browse files
committed
Remove I prefixes before Instruction types
1 parent b1d71bd commit a3bcf8f

37 files changed

+324
-323
lines changed

.changeset/weak-boxes-stay.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@solana/transaction-messages': major
3+
'@solana/instructions': major
4+
'@solana/signers': major
5+
'@solana/compat': major
6+
'@solana/kit': major
7+
---
8+
9+
BREAKING CHANGE: Remove the `I` prefix on the following types: `IInstruction`, `IInstructionWithAccounts`, `IInstructionWithData`, `IInstructionWithSigners`, `IAccountMeta`, `IAccountLookupMeta` and `IAccountSignerMeta`.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ const stillNotNonceTransactionMessage = {
11681168
};
11691169

11701170
stillNotNonceTransactionMessage satisfies TransactionMessageWithDurableNonceLifetime;
1171-
// => 'readonly IInstruction<string>[]' is not assignable to type 'readonly [AdvanceNonceAccountInstruction<string, string>, ...IInstruction<string>[]]'
1171+
// => 'readonly Instruction<string>[]' is not assignable to type 'readonly [AdvanceNonceAccountInstruction<string, string>, ...Instruction<string>[]]'
11721172

11731173
const validNonceTransactionMessage = pipe(
11741174
createTransactionMessage({ version: 0 }),

packages/compat/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const transaction = fromVersionedTransaction(legacyVersionedTransaction);
4747

4848
### `fromLegacyTransactionInstruction()`
4949

50-
This can be used to convert a legacy `TransactionInstruction` object to a `IInstruction` object.
50+
This can be used to convert a legacy `TransactionInstruction` object to a `Instruction` object.
5151

5252
```ts
5353
import { fromLegacyTransactionInstruction } from '@solana/compat';

packages/compat/src/__tests__/instruction-test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import '@solana/test-matchers/toBeFrozenObject';
33
import { ImplicitArrayBuffer } from 'node:buffer';
44

55
import { address } from '@solana/addresses';
6-
import { AccountRole, IInstruction } from '@solana/instructions';
6+
import { AccountRole, Instruction } from '@solana/instructions';
77
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
88

99
import { fromLegacyPublicKey } from '../address';
@@ -39,7 +39,7 @@ describe('fromLegacyTransactionInstruction', () => {
3939

4040
const converted = fromLegacyTransactionInstruction(instruction);
4141

42-
expect(converted).toStrictEqual<IInstruction>({
42+
expect(converted).toStrictEqual<Instruction>({
4343
accounts: [
4444
{
4545
address: address('7EqQdEULxWcraVx3mXKFjc84LhCkMGZCkRuDpvcMwJeK'),
@@ -129,7 +129,7 @@ describe('fromLegacyTransactionInstruction', () => {
129129

130130
const converted = fromLegacyTransactionInstruction(instruction);
131131

132-
expect(converted).toStrictEqual<IInstruction>({
132+
expect(converted).toStrictEqual<Instruction>({
133133
data,
134134
programAddress: fromLegacyPublicKey(new PublicKey(programId)),
135135
});
@@ -155,7 +155,7 @@ describe('fromLegacyTransactionInstruction', () => {
155155

156156
const converted = fromLegacyTransactionInstruction(instruction);
157157

158-
expect(converted).toStrictEqual<IInstruction>({
158+
expect(converted).toStrictEqual<Instruction>({
159159
accounts: [
160160
{
161161
address: address('7EqQdEULxWcraVx3mXKFjc84LhCkMGZCkRuDpvcMwJeK'),
@@ -189,7 +189,7 @@ describe('fromLegacyTransactionInstruction', () => {
189189

190190
const converted = fromLegacyTransactionInstruction(instruction);
191191

192-
expect(converted).toStrictEqual<IInstruction>({
192+
expect(converted).toStrictEqual<Instruction>({
193193
accounts: [
194194
{
195195
address: address('F7Kzv7G6p1PvHXL1xXLPTm4myKWpLjnVphCV8ABZJfgT'),
@@ -217,7 +217,7 @@ describe('fromLegacyTransactionInstruction', () => {
217217

218218
const converted = fromLegacyTransactionInstruction(instruction);
219219

220-
expect(converted).toStrictEqual<IInstruction>({
220+
expect(converted).toStrictEqual<Instruction>({
221221
accounts: [
222222
{
223223
address: address('F7Kzv7G6p1PvHXL1xXLPTm4myKWpLjnVphCV8ABZJfgT'),
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { IInstruction } from '@solana/instructions';
1+
import { Instruction } from '@solana/instructions';
22
import { TransactionInstruction } from '@solana/web3.js';
33

44
import { fromLegacyTransactionInstruction } from '../instruction';
55

66
const legacyInstruction = null as unknown as TransactionInstruction;
77

8-
fromLegacyTransactionInstruction(legacyInstruction) satisfies IInstruction;
8+
fromLegacyTransactionInstruction(legacyInstruction) satisfies Instruction;

packages/compat/src/instruction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { AccountRole, IInstruction } from '@solana/instructions';
1+
import { AccountRole, Instruction } from '@solana/instructions';
22
import { TransactionInstruction } from '@solana/web3.js';
33

44
import { fromLegacyPublicKey } from './address';
55

66
/**
77
* This can be used to convert a legacy [`TransactionInstruction`](https://solana-foundation.github.io/solana-web3.js/classes/TransactionInstruction.html)
8-
* object to an {@link IInstruction}.
8+
* object to an {@link Instruction}.
99
*
1010
* @example
1111
* ```ts
@@ -16,7 +16,7 @@ import { fromLegacyPublicKey } from './address';
1616
* const instruction = fromLegacyTransactionInstruction(legacyInstruction);
1717
* ```
1818
*/
19-
export function fromLegacyTransactionInstruction(legacyInstruction: TransactionInstruction): IInstruction {
19+
export function fromLegacyTransactionInstruction(legacyInstruction: TransactionInstruction): Instruction {
2020
const data = legacyInstruction.data?.byteLength > 0 ? Uint8Array.from(legacyInstruction.data) : undefined;
2121
const accounts = legacyInstruction.keys.map(accountMeta =>
2222
Object.freeze({

packages/instructions/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The purpose for which an account participates in a transaction is described by t
2626
| `AccountRole.READONLY_SIGNER` | &#x2705; | &#x274c; |
2727
| `AccountRole.WRITABLE_SIGNER` | &#x2705; | &#x2705; |
2828

29-
### `IAccountMeta<TAddress>`
29+
### `AccountMeta<TAddress>`
3030

3131
This type represents an account's address and metadata about its mutability and whether it must be a signer of the transaction.
3232

@@ -45,7 +45,7 @@ For example, you could type the rent sysvar account like this:
4545
type RentSysvar = ReadonlyAccount<'SysvarRent111111111111111111111111111111111'>;
4646
```
4747

48-
### `IAccountLookupMeta<TAddress, TLookupTableAddress>`
48+
### `AccountLookupMeta<TAddress, TLookupTableAddress>`
4949

5050
This type represents a lookup of the account's address in an address lookup table. It specifies which lookup table account in which to perform the lookup, the index of the desired account address in that table, and metadata about its mutability. Notably, account addresses obtained via lookups may not act as signers.
5151

@@ -65,28 +65,28 @@ type RentSysvar = ReadonlyLookupAccount<
6565
>;
6666
```
6767

68-
### `IInstruction<TProgramAddress>`
68+
### `Instruction<TProgramAddress>`
6969

7070
Use this to specify an instruction destined for a given program.
7171

7272
```ts
73-
type StakeProgramInstruction = IInstruction<'StakeConfig11111111111111111111111111111111'>;
73+
type StakeProgramInstruction = Instruction<'StakeConfig11111111111111111111111111111111'>;
7474
```
7575

76-
### `IInstructionWithAccounts<TAccounts>`
76+
### `InstructionWithAccounts<TAccounts>`
7777

7878
Use this type to specify an instruction that loads certain accounts.
7979

8080
```ts
81-
type InstructionWithTwoAccounts = IInstructionWithAccounts<
81+
type InstructionWithTwoAccounts = InstructionWithAccounts<
8282
[
8383
WritableAccount, // First account
8484
RentSysvar, // Second account
8585
]
8686
>;
8787
```
8888

89-
### `IInstructionWithData<TData>`
89+
### `InstructionWithData<TData>`
9090

9191
Use this type to specify an instruction whose data conforms to a certain type. This is most useful when you have a branded `Uint8Array` that represents a particular instruction's data.
9292

@@ -96,15 +96,15 @@ For example, here is how the `AdvanceNonce` instruction is typed.
9696
type AdvanceNonceAccountInstruction<
9797
TNonceAccountAddress extends string = string,
9898
TNonceAuthorityAddress extends string = string,
99-
> = IInstruction<'11111111111111111111111111111111'> &
100-
IInstructionWithAccounts<
99+
> = Instruction<'11111111111111111111111111111111'> &
100+
InstructionWithAccounts<
101101
[
102102
WritableAccount<TNonceAccountAddress>,
103103
ReadonlyAccount<'SysvarRecentB1ockHashes11111111111111111111'>,
104104
ReadonlySignerAccount<TNonceAuthorityAddress>,
105105
]
106106
> &
107-
IInstructionWithData<AdvanceNonceAccountInstructionData>;
107+
InstructionWithData<AdvanceNonceAccountInstructionData>;
108108
```
109109

110110
## Functions

packages/instructions/src/__tests__/instruction-test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
assertIsInstructionForProgram,
66
assertIsInstructionWithAccounts,
77
assertIsInstructionWithData,
8-
IInstruction,
8+
Instruction,
99
isInstructionForProgram,
1010
isInstructionWithAccounts,
1111
isInstructionWithData,
@@ -16,14 +16,14 @@ const programAddress = 'address' as Address;
1616

1717
describe('isInstructionForProgram', () => {
1818
it('returns true when the instruction has the given program address', () => {
19-
const instruction: IInstruction = {
19+
const instruction: Instruction = {
2020
programAddress,
2121
};
2222
expect(isInstructionForProgram(instruction, programAddress)).toBe(true);
2323
});
2424

2525
it('returns false when the instruction does not have the given program address', () => {
26-
const instruction: IInstruction = {
26+
const instruction: Instruction = {
2727
programAddress,
2828
};
2929
const address = 'abc' as Address;
@@ -33,15 +33,15 @@ describe('isInstructionForProgram', () => {
3333

3434
describe('assertIsInstructionForProgram', () => {
3535
it('does not throw when the instruction has the given program address', () => {
36-
const instruction: IInstruction = {
36+
const instruction: Instruction = {
3737
programAddress,
3838
};
3939
const assert = () => assertIsInstructionForProgram(instruction, programAddress);
4040
expect(assert).not.toThrow();
4141
});
4242

4343
it('throws when the instruction does not have the given program address', () => {
44-
const instruction: IInstruction = {
44+
const instruction: Instruction = {
4545
programAddress,
4646
};
4747
const address = 'abc' as Address;
@@ -52,7 +52,7 @@ describe('assertIsInstructionForProgram', () => {
5252

5353
describe('isInstructionWithAccounts', () => {
5454
it('returns true when the instruction has an array of accounts', () => {
55-
const instruction: IInstruction = {
55+
const instruction: Instruction = {
5656
accounts: [
5757
{
5858
address: 'abc' as Address,
@@ -65,15 +65,15 @@ describe('isInstructionWithAccounts', () => {
6565
});
6666

6767
it('returns true when the instruction has an empty array of accounts', () => {
68-
const instruction: IInstruction = {
68+
const instruction: Instruction = {
6969
accounts: [],
7070
programAddress,
7171
};
7272
expect(isInstructionWithAccounts(instruction)).toBe(true);
7373
});
7474

7575
it('returns false when the instruction does not have accounts defined', () => {
76-
const instruction: IInstruction = {
76+
const instruction: Instruction = {
7777
programAddress,
7878
};
7979
expect(isInstructionWithAccounts(instruction)).toBe(false);
@@ -82,7 +82,7 @@ describe('isInstructionWithAccounts', () => {
8282

8383
describe('assertIsInstructionWithAccounts', () => {
8484
it('does not throw when the instruction has an array of accounts', () => {
85-
const instruction: IInstruction = {
85+
const instruction: Instruction = {
8686
accounts: [
8787
{
8888
address: 'abc' as Address,
@@ -96,7 +96,7 @@ describe('assertIsInstructionWithAccounts', () => {
9696
});
9797

9898
it('does not throw when the instruction has an empty array of accounts', () => {
99-
const instruction: IInstruction = {
99+
const instruction: Instruction = {
100100
accounts: [],
101101
programAddress,
102102
};
@@ -105,7 +105,7 @@ describe('assertIsInstructionWithAccounts', () => {
105105
});
106106

107107
it('throws when the instruction does not have accounts defined', () => {
108-
const instruction: IInstruction = {
108+
const instruction: Instruction = {
109109
programAddress,
110110
};
111111
const assert = () => assertIsInstructionWithAccounts(instruction);
@@ -115,23 +115,23 @@ describe('assertIsInstructionWithAccounts', () => {
115115

116116
describe('isInstructionWithData', () => {
117117
it('returns true when the instruction has a non-empty data', () => {
118-
const instruction: IInstruction = {
118+
const instruction: Instruction = {
119119
data: new Uint8Array([1, 2, 3, 4]),
120120
programAddress,
121121
};
122122
expect(isInstructionWithData(instruction)).toBe(true);
123123
});
124124

125125
it('returns true when the instruction has an empty data', () => {
126-
const instruction: IInstruction = {
126+
const instruction: Instruction = {
127127
data: new Uint8Array([]),
128128
programAddress,
129129
};
130130
expect(isInstructionWithData(instruction)).toBe(true);
131131
});
132132

133133
it('returns false when the instruction does not have data defined', () => {
134-
const instruction: IInstruction = {
134+
const instruction: Instruction = {
135135
programAddress,
136136
};
137137
expect(isInstructionWithData(instruction)).toBe(false);
@@ -140,7 +140,7 @@ describe('isInstructionWithData', () => {
140140

141141
describe('assertIsInstructionWithData', () => {
142142
it('does not throw when the instruction has a non-empty data', () => {
143-
const instruction: IInstruction = {
143+
const instruction: Instruction = {
144144
data: new Uint8Array([1, 2, 3, 4]),
145145
programAddress,
146146
};
@@ -149,7 +149,7 @@ describe('assertIsInstructionWithData', () => {
149149
});
150150

151151
it('does not throw when the instruction has an empty data', () => {
152-
const instruction: IInstruction = {
152+
const instruction: Instruction = {
153153
data: new Uint8Array([]),
154154
programAddress,
155155
};
@@ -158,7 +158,7 @@ describe('assertIsInstructionWithData', () => {
158158
});
159159

160160
it('throws when the instruction does not have data defined', () => {
161-
const instruction: IInstruction = {
161+
const instruction: Instruction = {
162162
programAddress,
163163
};
164164
const assert = () => assertIsInstructionWithData(instruction);

0 commit comments

Comments
 (0)