Skip to content

Commit

Permalink
refactor(wallet-metadata): new tx review metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss committed Nov 8, 2024
1 parent 9642d40 commit 0af0f36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,22 @@ export const formatMetadata = async (

try {
const hash = txBody.auxiliary_data_hash ?? null

let metadata = null
let generalTransactionMetadata = null

if (unsignedTx != null) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const msg = unsignedTx.metadata?.['674']?.['msg' as any] ?? JSON.stringify({})
metadata = hash != null && typeof msg == 'string' ? {msg: [JSON.parse(msg) as unknown]} : null
} else if (cbor != null) {
if (unsignedTx != null && unsignedTx.unsignedTx.auxiliaryData && hash != null) {
generalTransactionMetadata = await unsignedTx.unsignedTx.auxiliaryData?.metadata()
} else if (cbor != null && hash != null) {
const tx = await csl.Transaction.fromBytes(Buffer.from(cbor, 'hex'))
const auxiliaryData = await tx.auxiliaryData()
const generalTransactionMetadata = await auxiliaryData?.metadata()
const metadata674 = await generalTransactionMetadata?.get(await csl.BigNum.fromStr('674'))
generalTransactionMetadata = await auxiliaryData?.metadata()
}

if (metadata674) {
const decodedMetadata = await csl.decodeMetadatumToJsonStr(metadata674, MetadataJsonSchema.BasicConversions)
const msg = JSON.parse(decodedMetadata)?.msg ?? JSON.stringify({})
metadata = hash != null ? {msg: [msg]} : null
}
const metadata674 = await generalTransactionMetadata?.get(await csl.BigNum.fromStr('674'))
if (metadata674) {
const decodedMetadata = await csl.decodeMetadatumToJsonStr(metadata674, MetadataJsonSchema.BasicConversions)
const msg = JSON.parse(decodedMetadata)?.msg ?? JSON.stringify({})
metadata = {msg}
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const useStyles = () => {
const styles = StyleSheet.create({
root: {
...atoms.flex_1,
...atoms.px_lg,
},
modalText: {
paddingHorizontal: 70,
Expand Down

0 comments on commit 0af0f36

Please sign in to comment.