Skip to content

Commit 4fa7df4

Browse files
author
lukaw3d
committed
Parse ROFL machine commands in transaction body
1 parent dad2884 commit 4fa7df4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.changelog/2043.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Parse ROFL machine commands in transaction body

src/oasis-nexus/api.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { getConsensusTransactionAmount, getConsensusTransactionToAddress } from
3434
import { API_MAX_TOTAL_COUNT } from '../config'
3535
import { hasTextMatchesForAll } from '../app/components/HighlightedText/text-matching'
3636
import { decodeAbiParameters } from 'viem'
37+
import * as oasis from '@oasisprotocol/client'
3738

3839
export * from './generated/api'
3940
export type { RuntimeEvmBalance as Token } from './generated/api'
@@ -1649,7 +1650,20 @@ function transformRuntimeTransactionList(
16491650
}
16501651
}
16511652
})()
1652-
1653+
if (tx.method?.startsWith('roflmarket')) {
1654+
if (tx.body?.cmds) {
1655+
tx.body.cmds = tx.body.cmds.map((cmd: string) => {
1656+
const parsed = oasis.misc.fromCBOR(Buffer.from(cmd, 'base64')) as { method: string; args: any }
1657+
if (parsed.args?.deployment?.app_id) {
1658+
parsed.args.deployment.app_id = oasis.address.toBech32('rofl', parsed.args.deployment.app_id)
1659+
}
1660+
return parsed
1661+
})
1662+
}
1663+
if (Array.isArray(tx.body?.id) && tx.body.id.length === 8) {
1664+
tx.body.id = `0x${Buffer.from(tx.body.id).toString('hex')}`
1665+
}
1666+
}
16531667
return {
16541668
...tx,
16551669
to_eth: tx.to_eth || fallbackEthAddress(tx.to, relAddress),

0 commit comments

Comments
 (0)