Skip to content

Commit

Permalink
Support calls with no params (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut authored Dec 15, 2024
1 parent b8e7995 commit c38955b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/components/CallInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const CallInfo = ({
() => aggregatedData.callData && getDecodeUrl(aggregatedData.callData),
[aggregatedData, getDecodeUrl]
)
const hasArgs = useMemo(() => decodedCall && Object.keys(decodedCall).length > 0, [decodedCall])
const hasArgs = useMemo(() => decodedCall && decodedCall?.value?.value, [decodedCall])

return (
<div
Expand Down
28 changes: 17 additions & 11 deletions packages/ui/src/utils/jsonPrint.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { Binary } from 'polkadot-api'
import json5 from 'json5'

export const JSONprint = (e: unknown) =>
json5
.stringify(e, {
replacer: (_, v) =>
typeof v === 'bigint' ? v.toString() : v instanceof Binary ? v.asText() : v,
space: 4
})
// remove { and }
.slice(1, -1)
// remove trailing comma if any
.replace(/,\s*$/, '')
export const JSONprint = (e: unknown) => {
if (e === null || e === undefined) {
return ''
}
return (
json5
.stringify(e, {
replacer: (_, v) =>
typeof v === 'bigint' ? v.toString() : v instanceof Binary ? v.asText() : v,
space: 4
})
// remove { and }
.slice(1, -1)
// remove trailing comma if any
.replace(/,\s*$/, '')
)
}

0 comments on commit c38955b

Please sign in to comment.