warp-contracts / warp

An implementation of the Arweave SmartWeave smart contracts protocol.
MIT License
159 stars 44 forks source link

feat: add method encoding tx tags to TagsParser #240

Closed asiaziola closed 2 years ago

asiaziola commented 2 years ago

Currently, it is only possible to get the tags for interaction input. Add method which mimics following code and enables encoding tags for any tx.

const response = await fetch(`https://gateway.redstone.finance/gateway/contract?txId=${result.contractTxId}`);
const contractTx = new Transaction((await response.json()).contractTx);
let allTags = [];
contractTx.get("tags").forEach((tag) => {
  let key = tag.get("name", {decode: true, string: true});
  let value = tag.get("value", {decode: true, string: true});
  allTags.push({key, value,});
});
console.dir(allTags, {depth: null});
ppedziwiatr commented 2 years ago

Keep in mind that currently the TagsParsers assume that tags are already decoded.