(
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,
)
| 187 | } & ParsedCreateAccountAllowPrefundInstruction<TProgram>); |
| 188 | |
| 189 | export function parseSystemInstruction<TProgram extends string>( |
| 190 | instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>, |
| 191 | ): ParsedSystemInstruction<TProgram> { |
| 192 | const instructionType = identifySystemInstruction(instruction); |
| 193 | switch (instructionType) { |
| 194 | case SystemInstruction.CreateAccount: { |
| 195 | assertIsInstructionWithAccounts(instruction); |
| 196 | return { instructionType: SystemInstruction.CreateAccount, ...parseCreateAccountInstruction(instruction) }; |
| 197 | } |
| 198 | case SystemInstruction.Assign: { |
| 199 | assertIsInstructionWithAccounts(instruction); |
| 200 | return { instructionType: SystemInstruction.Assign, ...parseAssignInstruction(instruction) }; |
| 201 | } |
| 202 | case SystemInstruction.TransferSol: { |
| 203 | assertIsInstructionWithAccounts(instruction); |
| 204 | return { instructionType: SystemInstruction.TransferSol, ...parseTransferSolInstruction(instruction) }; |
| 205 | } |
| 206 | case SystemInstruction.CreateAccountWithSeed: { |
| 207 | assertIsInstructionWithAccounts(instruction); |
| 208 | return { |
| 209 | instructionType: SystemInstruction.CreateAccountWithSeed, |
| 210 | ...parseCreateAccountWithSeedInstruction(instruction), |
| 211 | }; |
| 212 | } |
| 213 | case SystemInstruction.AdvanceNonceAccount: { |
| 214 | assertIsInstructionWithAccounts(instruction); |
| 215 | return { |
| 216 | instructionType: SystemInstruction.AdvanceNonceAccount, |
| 217 | ...parseAdvanceNonceAccountInstruction(instruction), |
| 218 | }; |
| 219 | } |
| 220 | case SystemInstruction.WithdrawNonceAccount: { |
| 221 | assertIsInstructionWithAccounts(instruction); |
| 222 | return { |
| 223 | instructionType: SystemInstruction.WithdrawNonceAccount, |
| 224 | ...parseWithdrawNonceAccountInstruction(instruction), |
| 225 | }; |
| 226 | } |
| 227 | case SystemInstruction.InitializeNonceAccount: { |
| 228 | assertIsInstructionWithAccounts(instruction); |
| 229 | return { |
| 230 | instructionType: SystemInstruction.InitializeNonceAccount, |
| 231 | ...parseInitializeNonceAccountInstruction(instruction), |
| 232 | }; |
| 233 | } |
| 234 | case SystemInstruction.AuthorizeNonceAccount: { |
| 235 | assertIsInstructionWithAccounts(instruction); |
| 236 | return { |
| 237 | instructionType: SystemInstruction.AuthorizeNonceAccount, |
| 238 | ...parseAuthorizeNonceAccountInstruction(instruction), |
| 239 | }; |
| 240 | } |
| 241 | case SystemInstruction.Allocate: { |
| 242 | assertIsInstructionWithAccounts(instruction); |
| 243 | return { instructionType: SystemInstruction.Allocate, ...parseAllocateInstruction(instruction) }; |
| 244 | } |
| 245 | case SystemInstruction.AllocateWithSeed: { |
| 246 | assertIsInstructionWithAccounts(instruction); |
no test coverage detected