A function to fetch a decompiled `Transaction` by signature
- Linguagem predominante
- TypeScript
- Estrelas
- 695
- Forks
- 210
- Merge médio
- 21h 33min
- PRs com merge (30d)
- 90
Descrição
## Motivation
If you want to fetch a transaction from the RPC by signature today you might do something like this:
```ts
const result = await rpc
.getTransaction(
signature(
"265Vry9E7VMD92AX79R1A5zaBmyYAMVarZq4YTWCrCnhzBtEAFaHYrbWHmdi5wvJoWGdeH9jKvAgMLVncQUBGEK1"
),
{ encoding: "base64" }
)
.send();
if (!result) {
throw Error("Transaction not found");
}
const {
transaction: [wireTransaction],
} = result;
const transferCheckedInstruction = pipe(
wireTransaction,
// Decode the wire transaction.
getBase64Encoder().encode,
getTransactionDecoder().decode,
// Decode the message.
(transaction) =>
getCompiledTransactionMessageDecoder().decode(transaction.messageBytes),
decompileTransactionMessage
);
```
That's probably enough boilerplate to extract into a helper.
## Example use case
```ts
const transaction = await fetchDecompiledTransaction(
rpc,
signature('265Vry9E7VMD92AX79R1A5zaBmyYAMVarZq4YTWCrCnhzBtEAFaHYrbWHmdi5wvJoWGdeH9jKvAgMLVncQUBGEK1'),
);
for (const instruction in transaction.instructions) {
// ...
}
```
## Details
Implement this in `@solana/transactions` as `fetchDecompiledTransaction(rpc: Rpc, signature: Signature)`.
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.