anza-xyz / anza-xyz/kit

A function to fetch a decompiled `Transaction` by signature

未關閉
#275 4 則留言 3 個 reaction 已指派 0 人 在 GitHub 檢視
do-not-close enhancement
主要語言
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 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。