-
Notifications
You must be signed in to change notification settings - Fork 154
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Motivation
When requesting a base64 tx via RPC, the transaction is encoded as base64, however meta is provided in a fully-inflated format. The issue with this is any service that wishes to cache the result of getTransaction needs to implement JSON.stringify and JSON.parse replace functions to handle BigInts etc, and the size of the stored result is v large.
Also when parsing using plain JSON the branded types (Lamports, Address etc) are lost.
Example use case
/*
* {
* transaction: Base64EncodedDataResponse,
* meta: Base64EncodedDataResponse
* }
*/
const result = await client.rpc.getTransaction(txSignature, { encoding: "base64", encodeMeta: true }).send();
await env.CACHE.put(txSignature, JSON.stringify(result));
const { transaction, meta } = JSON.parse(await env.CACHE.get(txSignature));
const encodedMeta = getBase64Encoder().encode(meta)
const decodedMeta = getTransactionMetaDecoder().decode(encodedMeta);
// decodedMeta has the same data structure as would have been received by `rpc.getTransaction(sig, { encoding: 'json' })`Details
A transactionMetaCodec would need to be added to encode and decode transaction meta from an array of bytes.
The functionality should be opt-in so as to not break existing implementations (encodeMeta flag or similar)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request