Skip to content

Commit

Permalink
Fix date and add test (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut authored Dec 2, 2024
1 parent 5de4ac0 commit 708504e
Show file tree
Hide file tree
Showing 17 changed files with 17 additions and 21 deletions.
Binary file modified packages/ui/.papi/metadata/acala.scale
Binary file not shown.
Binary file modified packages/ui/.papi/metadata/bifrostDot.scale
Binary file not shown.
Binary file modified packages/ui/.papi/metadata/dot.scale
Binary file not shown.
Binary file modified packages/ui/.papi/metadata/dotAssetHub.scale
Binary file not shown.
Binary file modified packages/ui/.papi/metadata/dotPpl.scale
Binary file not shown.
Binary file modified packages/ui/.papi/metadata/hydration.scale
Binary file not shown.
Binary file modified packages/ui/.papi/metadata/ksm.scale
Binary file not shown.
Binary file modified packages/ui/.papi/metadata/ksmAssetHub.scale
Binary file not shown.
Binary file modified packages/ui/.papi/metadata/ksmPpl.scale
Binary file not shown.
Binary file modified packages/ui/.papi/metadata/pasPpl.scale
Binary file not shown.
Binary file modified packages/ui/.papi/metadata/paseo.scale
Binary file not shown.
1 change: 1 addition & 0 deletions packages/ui/cypress/support/page-objects/multisigPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const multisigPage = {
transactionList: () => cy.get('[data-cy=container-transaction-list]', { timeout: 20000 }),
pendingTransactionItem: (timeout = 4000) =>
cy.get('[data-cy=container-pending-tx-item]', { timeout }),
dateLabel: () => cy.get('[data-cy=label-date]'),
pendingTransactionCallName: () => cy.get('[data-cy=label-call-name]'),
unknownCallIcon: () => cy.get('[data-cy=icon-unknown-call]'),
unknownCallAlert: () => cy.get('[data-cy=alert-no-call-data]')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('Verify extrinsics display', () => {
.should('be.visible')
.within(() => {
multisigPage.pendingTransactionItem().should('have.length', 1)
multisigPage.dateLabel().should('have.length', 1).contains('November 5, 2024')
multisigPage.pendingTransactionItem().within(() => {
multisigPage.pendingTransactionCallName().should('contain.text', 'Router.sell')
multisigPage.unknownCallIcon().should('not.exist')
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/cypress/tests/unknown-transaction.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ describe('Unknown Transaction', () => {
.should('be.visible')
.within(() => {
multisigPage.pendingTransactionItem().should('have.length', 2)
multisigPage.dateLabel().should('have.length', 1)
multisigPage.dateLabel().eq(0).contains('September 12, 2024')
multisigPage
.pendingTransactionItem()
.eq(1)
Expand Down
22 changes: 11 additions & 11 deletions packages/ui/src/components/CallInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,41 +58,41 @@ const isBatchedCall = (type: string, value: string) => {
return ['Utility.batch', 'Utility.batch_all', 'Utility.force_batch'].includes(`${type}.${value}`)
}

const formatBalance = (amount: bigint, label: string, chainInfo: ChainInfoHuman) => (
<li>
const formatBalance = (amount: bigint, label: string, chainInfo: ChainInfoHuman, id: string) => (
<li key={id}>
{label}:{' '}
{formatBigIntBalance(amount, chainInfo?.tokenDecimals, {
tokenSymbol: chainInfo?.tokenSymbol
})}
</li>
)

const eachFieldRendered = (value: Record<string, any>, chainInfo: ChainInfoHuman) => {
const eachFieldRendered = (value: Record<string, any>, chainInfo: ChainInfoHuman, id: string) => {
// for transfer, nomination, staking, bounties
const bigIntKey = ['value', 'fee', 'max_additional'].find((key) => typeof value[key] === 'bigint')

if (bigIntKey) {
return formatBalance(value[bigIntKey], bigIntKey, chainInfo)
return formatBalance(value[bigIntKey], bigIntKey, chainInfo, id)
}

// for Staking.nominate
if (Array.isArray(value.targets) && value.targets.length > 0) {
return (
<li key="targets">
<li key={`${id}-targets`}>
targets:{' '}
<ul>
{value.targets.map((target: any) => {
{value.targets.map((target: any, index) => {
const address = target.type === 'Id' ? target.value : null

if (address) {
return (
<li key={address}>
<li key={`${index}-${address}`}>
<MultisigCompactDisplay address={address} />
</li>
)
}

return <li key={address}>{JSONprint(target)}</li>
return <li key={`${index}-${address}`}>{JSONprint(target)}</li>
})}
</ul>
</li>
Expand Down Expand Up @@ -130,7 +130,7 @@ const eachFieldRendered = (value: Record<string, any>, chainInfo: ChainInfoHuman
)
}

return <li key="not-pretty-decoded">{JSONprint(value)} </li>
return <li key={`not-pretty-decoded-${id}`}>{JSONprint(value)} </li>
}

const preparedCall = (
Expand Down Expand Up @@ -163,8 +163,8 @@ const preparedCall = (
</ExtrinsicNameStyled>
)}
<ul>
{Object.entries(lowerLevelCall).map(([key, value]) =>
eachFieldRendered({ [key]: value }, chainInfo)
{Object.entries(lowerLevelCall).map(([key, value], index) =>
eachFieldRendered({ [key]: value }, chainInfo, `${decodedCall.type}-${index}`)
)}
</ul>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const TransactionList = ({ className }: Props) => {
Object.entries(txWithCallDataByDate).map(([date, aggregatedData]) => {
return (
<TransactionWrapper key={date}>
<DateContainerStyled>{date}</DateContainerStyled>
<DateContainerStyled data-cy="label-date">{date}</DateContainerStyled>
{aggregatedData.map((agg, index) => {
const { callData, info, from } = agg
const { threshold, signatories } =
Expand Down
10 changes: 1 addition & 9 deletions packages/ui/src/hooks/usePendingTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const getMultisigInfo = async (
api: ApiType
): Promise<Partial<CallDataInfoFromChain>[]> => {
const compatibilityToken = await api.compatibilityToken

const result: any[] = []

// console.log('----for call', JSONprint(call));
Expand Down Expand Up @@ -99,7 +98,6 @@ const getMultisigInfo = async (
}

getCallResults(call)
// console.log('result', JSONprint(result))
return result
}

Expand Down Expand Up @@ -143,9 +141,7 @@ const getCallDataFromChainPromise = (
// get the timestamp which is an unsigned extrinsic set by the validator in each block
// the information for each of the contained extrinsics
allDecodedTxs.some(({ decodedCall: { type, value } }) => {
// check for timestamp.set
if (type === 'Timestamp' && value.type === 'Set') {
// extract the Option<Moment> as Moment
if (type === 'Timestamp' && value.type === 'set') {
const moment = value.value.now as string

// convert to date (unix ms since epoch in Moment - exactly as per the Rust code)
Expand All @@ -157,10 +153,6 @@ const getCallDataFromChainPromise = (
})

const ext = allDecodedTxs[pendingTx.info.when.index]

// const decoded = parseGenericCall(ext.method as GenericCall, ext.registry)
// console.log('pendingTxData', pendingTxData)
// console.log('decoded', decoded)
const multisigTxs = (await getMultisigInfo(ext.decodedCall, api)) || []

const multisigTxInfo = multisigTxs.find((info) => {
Expand Down

0 comments on commit 708504e

Please sign in to comment.