A function to fetch a decompiled `Transaction` by signature
- 主要語言
- TypeScript
- 星號
- 695
- 分支
- 210
- 平均合併
- 21 小時 33 分鐘
- 30 天內合併 PR
- 90
描述
## 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)`.
貢獻指南
評估
這個 Issue 還沒有評估資料。