Skip to content

Commit 0d6aed0

Browse files
committed
Update the getTransaction documentation to mostly match that in the @solana/rpc-types documentation
1 parent 2df819e commit 0d6aed0

File tree

1 file changed

+131
-32
lines changed

1 file changed

+131
-32
lines changed

Diff for: packages/rpc-api/src/getTransaction.ts

+131-32
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,37 @@ type ReturnData = {
2424
};
2525

2626
type TransactionMetaBase = Readonly<{
27-
/** The number of compute units consumed by the transaction */
27+
/** Number of compute units consumed by the transaction */
2828
computeUnitsConsumed?: bigint;
29-
/** If the transaction failed, this property will contain the error */
29+
/** Error if transaction failed, `null` if transaction succeeded. */
3030
err: TransactionError | null;
3131
/** The fee this transaction was charged, in {@link Lamports} */
3232
fee: Lamports;
33-
/** An array of string log messages or `null` if log message recording was disabled when this transaction was processed */
33+
/**
34+
* String log messages or `null` if log message recording was not enabled during this
35+
* transaction
36+
*/
3437
logMessages: readonly string[] | null;
35-
/** An array of account balances, in {@link Lamports}, after the transaction was processed */
38+
/** Account balances after the transaction was processed */
3639
postBalances: readonly Lamports[];
37-
/** List of token balances from after the transaction was processed or omitted if token balance recording was disabled when this transaction was processed */
40+
/**
41+
* List of token balances from after the transaction was processed or omitted if token balance
42+
* recording was not yet enabled during this transaction
43+
*/
3844
postTokenBalances?: readonly TokenBalance[];
39-
/** An array of account balances, in {@link Lamports}, before the transaction was processed */
45+
/** Account balances from before the transaction was processed */
4046
preBalances: readonly Lamports[];
41-
/** List of token balances from before the transaction was processed or omitted if token balance recording was disabled when this transaction was processed */
47+
/**
48+
* List of token balances from before the transaction was processed or omitted if token balance
49+
* recording was not yet enabled during this transaction
50+
*/
4251
preTokenBalances?: readonly TokenBalance[];
4352
/** The most-recent return data generated by an instruction in the transaction */
4453
returnData?: ReturnData;
45-
/** Transaction-level rewards; currently only `"Rent"`, but other types may be added in the future */
54+
/**
55+
* Transaction-level rewards; currently only `"Rent"`, but other types may be added in the
56+
* future
57+
*/
4658
rewards: readonly Reward[] | null;
4759
/** @deprecated */
4860
status: TransactionStatus;
@@ -51,65 +63,147 @@ type TransactionMetaBase = Readonly<{
5163
type AddressTableLookup = Readonly<{
5264
/** The address of the address lookup table account. */
5365
accountKey: Address;
54-
/** The list of indices used to load addresses of readonly accounts from the lookup table. */
66+
/** Indices of accounts in a lookup table to load as read-only. */
5567
readableIndexes: readonly number[];
56-
/** The list of indices used to load addresses of writable accounts from the lookup table. */
68+
/** Indices of accounts in a lookup table to load as writable. */
5769
writableIndexes: readonly number[];
5870
}>;
5971

6072
type TransactionBase = Readonly<{
6173
message: {
74+
/**
75+
* For transactions whose lifetime is specified by a recent blockhash, this is that
76+
* blockhash, and for transactions whose lifetime is specified by a durable nonce, this is
77+
* the nonce value.
78+
*/
6279
recentBlockhash: Blockhash;
6380
};
81+
/**
82+
* An ordered list of signatures belonging to the accounts required to sign this transaction.
83+
*
84+
* Each signature is an Ed25519 signature of the transaction message using the private key
85+
* associated with the account required to sign the transaction.
86+
*/
6487
signatures: readonly Base58EncodedBytes[];
6588
}>;
6689

67-
type TransactionInstruction = Readonly<{
68-
accounts: readonly number[];
90+
type InstructionWithStackHeight = Readonly<{
91+
/**
92+
* A number indicating the height at which this instruction was called with respect to the
93+
* bottom of the call stack denoted by `1` or `null`.
94+
*
95+
* For instance, an instruction explicitly declared in the transaction message will have a `1`
96+
* or `null` height, the first instruction that it calls using a cross-program invocation (CPI)
97+
* will have a height of 2, an instruction called by that instruction using a CPI will have a
98+
* depth of 3, and so on.
99+
*/
100+
stackHeight: number; // FIXME(https://github.com/anza-xyz/agave/issues/5732) Should be `1` instead of `null` at base of stack
101+
}>;
102+
103+
type InstructionWithData = Readonly<{
104+
/** The input to the invoked program */
69105
data: Base58EncodedBytes;
70-
programIdIndex: number;
71-
stackHeight?: number;
72106
}>;
73107

108+
type TransactionInstruction = InstructionWithData &
109+
Partial<InstructionWithStackHeight> &
110+
Readonly<{
111+
/**
112+
* An ordered list of indices that indicate which accounts in the transaction message's
113+
* accounts list are loaded by this instruction.
114+
*/
115+
accounts: readonly number[];
116+
/**
117+
* The index of the address in the transaction message's accounts list associated with the
118+
* program to invoke.
119+
*/
120+
programIdIndex: number;
121+
}>;
122+
74123
type TransactionJson = Readonly<{
75124
message: {
125+
/** An ordered list of addresses belonging to the accounts loaded by this transaction */
76126
accountKeys: readonly Address[];
77127
header: {
128+
/**
129+
* The number of read-only accounts in the static accounts list that must sign this
130+
* transaction.
131+
*
132+
* Subtracting this number from `numRequiredSignatures` yields the index of the first
133+
* read-only signer account in the static accounts list.
134+
*/
78135
numReadonlySignedAccounts: number;
136+
/**
137+
* The number of accounts in the static accounts list that are neither writable nor
138+
* signers.
139+
*
140+
* Adding this number to `numRequiredSignatures` yields the index of the first read-only
141+
* non-signer account in the static accounts list.
142+
*/
79143
numReadonlyUnsignedAccounts: number;
144+
/**
145+
* The number of accounts in the static accounts list that must sign this transaction.
146+
*
147+
* Subtracting `numReadonlySignedAccounts` from this number yields the number of
148+
* writable signer accounts in the static accounts list. Writable signer accounts always
149+
* begin at index zero in the static accounts list.
150+
*
151+
* This number itself is the index of the first non-signer account in the static
152+
* accounts list.
153+
*/
80154
numRequiredSignatures: number;
81155
};
82156
instructions: readonly TransactionInstruction[];
83157
};
84158
}> &
85159
TransactionBase;
86160

87-
type PartiallyDecodedTransactionInstruction = Readonly<{
88-
accounts: readonly Address[];
89-
data: Base58EncodedBytes;
90-
programId: Address;
91-
stackHeight?: number;
92-
}>;
161+
type PartiallyDecodedTransactionInstruction = InstructionWithData &
162+
Partial<InstructionWithStackHeight> &
163+
Readonly<{
164+
/** An ordered list of addresses belonging to the accounts loaded by this instruction */
165+
accounts: readonly Address[];
166+
/** The address of the program to invoke */
167+
programId: Address;
168+
}>;
93169

94-
type ParsedTransactionInstruction = Readonly<{
95-
parsed: {
96-
info?: object;
97-
type: string;
98-
};
99-
program: string;
100-
programId: Address;
101-
stackHeight?: number;
102-
}>;
170+
type ParsedTransactionInstruction = Partial<InstructionWithStackHeight> &
171+
Readonly<{
172+
/** The output of the program's instruction parser */
173+
parsed: {
174+
/** The instruction, as interpreted the program's instruction parser. */
175+
info?: object;
176+
/**
177+
* A label that indicates the type of the instruction, as determined by the program's
178+
* instruction parser.
179+
*/
180+
type: string;
181+
};
182+
/** The name of the program. */
183+
program: string;
184+
/** The address of the program */
185+
programId: Address;
186+
}>;
103187

104188
type ParsedAccount = Readonly<{
189+
/** The address of the account */
105190
pubkey: Address;
191+
/** Whether this account is required to sign the transaction that it's a part of */
106192
signer: boolean;
193+
/**
194+
* Indicates whether the account was statically declared in the transaction message or loaded
195+
* from an address lookup table.
196+
*/
107197
source: 'lookupTable' | 'transaction';
198+
/** Whether this account must be loaded with a write-lock */
108199
writable: boolean;
109200
}>;
110201

111202
type TransactionJsonParsed = Readonly<{
112203
message: {
204+
/**
205+
* An ordered list of parsed accounts belonging to the accounts loaded by this transaction
206+
*/
113207
accountKeys: readonly ParsedAccount[];
114208
instructions: readonly (ParsedTransactionInstruction | PartiallyDecodedTransactionInstruction)[];
115209
};
@@ -166,32 +260,37 @@ type GetTransactionApiResponseBase = Readonly<{
166260
}>;
167261

168262
type TransactionMetaLoadedAddresses = Readonly<{
169-
/** Transaction account addresses loaded from address lookup tables */
263+
/** Addresses loaded from lookup tables */
170264
loadedAddresses: {
171-
/** Ordered list of base-58 encoded addresses for writable accounts */
172-
readonly: readonly Address[];
173265
/** Ordered list of base-58 encoded addresses for read-only accounts */
266+
readonly: readonly Address[];
267+
/** Ordered list of base-58 encoded addresses for writable accounts */
174268
writable: readonly Address[];
175269
};
176270
}>;
177271

178272
type InnerInstructions<TInstructionType> = Readonly<{
273+
/** The index of the instruction in the transaction */
179274
index: number;
275+
/** The instructions */
180276
instructions: readonly TInstructionType[];
181277
}>;
182278

183279
type TransactionMetaInnerInstructionsNotParsed = Readonly<{
280+
/** A list of instructions called by programs via cross-program invocation (CPI) */
184281
innerInstructions?: readonly InnerInstructions<TransactionInstruction>[] | null;
185282
}>;
186283

187284
type TransactionMetaInnerInstructionsParsed = Readonly<{
285+
/** A list of instructions called by programs via cross-program invocation (CPI) */
188286
innerInstructions?:
189287
| readonly InnerInstructions<ParsedTransactionInstruction | PartiallyDecodedTransactionInstruction>[]
190288
| null;
191289
}>;
192290

193291
type TransactionAddressTableLookups = Readonly<{
194292
message: Readonly<{
293+
/** A list of address tables and the accounts that this transaction loads from them */
195294
addressTableLookups: readonly AddressTableLookup[];
196295
}>;
197296
}>;

0 commit comments

Comments
 (0)