Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle more transactions types and check for new tx types on oasisscan testnet too #1895

Merged
merged 8 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/1895.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Display staking.Burn transactions
31 changes: 14 additions & 17 deletions cypress/e2e/api-transaction-methods.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,45 @@ function ignoreTimeoutError() {
}

describe('check all transaction methods from API are mapped in transactionMethodMap', () => {
it('by parsing latest transactions on oasismonitor', () => {
it('by comparing list of methods from oasisscan mainnet', () => {
ignoreTimeoutError() // Ignore if API is not responding

cy.request({
url: 'https://monitor.oasis.dev/data/transactions?limit=2000',
url: 'https://api.oasisscan.com/mainnet/chain/methods', // does not include consensus methods
retryOnNetworkFailure: false,
failOnStatusCode: false,
timeout: 5000,
}).then(response => {
if (!response.isOkStatusCode) return // Ignore if API is broken

const allApiMethods = response.body.data.list
expect(allApiMethods).to.have.length.lte(Object.keys(OperationsRowMethodEnum).length)
cy.visit('/e2e')
cy.window()
.should('have.a.property', 'monitor')
.then((monitor) => {
response.body.forEach(transactionFromApi => {
const [parsedTransaction] = monitor.parseTransactionsList([transactionFromApi])
expect(parsedTransaction.type).to.be.a('string', `parse transaction type "${transactionFromApi.type}" to a string`)
.should('have.a.property', 'oasisscan')
.then((oasisscan) => {
expect(oasisscan.transactionMethodMap).to.include.keys(allApiMethods)
})
})
})
})

it('by comparing list of methods from oasisscan', () => {
ignoreTimeoutError() // Ignore if API is not responding

it('by comparing list of methods from oasisscan testnet', () => {
cy.request({
url: 'https://api.oasisscan.com/mainnet/chain/methods', // does not include consensus methods
url: 'https://api.oasisscan.com/testnet/chain/methods', // does not include consensus methods
retryOnNetworkFailure: false,
failOnStatusCode: false,
timeout: 5000,
}).then(response => {
if (!response.isOkStatusCode) return // Ignore if API is broken

const allApiMethods = response.body.data.list
expect(allApiMethods).to.have.length(Object.keys(OperationsRowMethodEnum).length)
expect(allApiMethods).to.have.length.lte(Object.keys(OperationsRowMethodEnum).length)
cy.visit('/e2e')
cy.window()
.should('have.a.property', 'oasisscan')
.then((oasisscan) => {
expect(oasisscan.transactionMethodMap).to.include.keys(allApiMethods)
})
.should('have.a.property', 'oasisscan')
.then((oasisscan) => {
expect(oasisscan.transactionMethodMap).to.include.keys(allApiMethods)
})
})
})
})
4 changes: 2 additions & 2 deletions src/app/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FormDown } from 'grommet-icons/es6/icons/FormDown'
import { Home } from 'grommet-icons/es6/icons/Home'
import { Inherit } from 'grommet-icons/es6/icons/Inherit'
import { LineChart } from 'grommet-icons/es6/icons/LineChart'
import { Lock } from 'grommet-icons/es6/icons/Lock'
import { MuiLockIcon } from '../../../styles/theme/icons/mui-icons/MuiLockIcon'
import { Logout } from 'grommet-icons/es6/icons/Logout'
import { Menu as MenuIcon } from 'grommet-icons/es6/icons/Menu'
import { Money } from 'grommet-icons/es6/icons/Money'
Expand Down Expand Up @@ -189,7 +189,7 @@ const SidebarFooter = (props: SidebarFooterProps) => {
)}
{isLockableOrCloseable === 'lockable' && (
<SidebarButton
icon={<Lock />}
icon={<MuiLockIcon />}
label={t('menu.lockProfile', 'Lock profile')}
onClick={() => lockProfile()}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,10 +825,8 @@ exports[`<Profile /> should render unavailable state 1`] = `
viewBox="0 0 24 24"
>
<path
d="M19 23V11H5v12h14zm-7-8v4m5-8V7c0-3 0-6-5-6S7 4 7 7v4"
fill="none"
stroke="#000"
stroke-width="2"
d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1z"
fill="#333"
/>
</svg>
<div
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/Toolbar/Features/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { User } from 'grommet-icons/es6/icons/User'
import { selectUnlockedStatus } from 'app/state/selectUnlockedStatus'
import { UpdatePassword } from './UpdatePassword'
import { DeleteProfileButton } from '../../../Persist/DeleteProfileButton'
import { Lock } from 'grommet-icons/es6/icons/Lock'
import { MuiLockIcon } from '../../../../../styles/theme/icons/mui-icons/MuiLockIcon'
import { Logout } from 'grommet-icons/es6/icons/Logout'
import { selectIsLockableOrCloseable } from 'app/state/selectIsLockableOrCloseable'
import { persistActions } from 'app/state/persist'
Expand Down Expand Up @@ -92,7 +92,7 @@ export const Profile = ({ closeHandler }: ProfileProps) => {
{isLockableOrCloseable === 'lockable' && (
<Button
data-testid="profile-modal-lock-wallet"
icon={<Lock />}
icon={<MuiLockIcon />}
label={t('menu.lockProfile', 'Lock profile')}
onClick={() => lockProfile()}
/>
Expand Down
24 changes: 24 additions & 0 deletions src/app/components/Transaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { LinkPrevious } from 'grommet-icons/es6/icons/LinkPrevious'
import { LinkNext } from 'grommet-icons/es6/icons/LinkNext'
import { Atm } from 'grommet-icons/es6/icons/Atm'
import { Alert } from 'grommet-icons/es6/icons/Alert'
import { MuiLocalFireDepartmentIcon } from '../../../styles/theme/icons/mui-icons/MuiLocalFireDepartmentIcon'
// eslint-disable-next-line no-restricted-imports
import type { Icon } from 'grommet-icons/es6/icons'
import * as React from 'react'
Expand Down Expand Up @@ -288,6 +289,21 @@ export function Transaction(props: TransactionProps) {
),
},
},
[transactionTypes.TransactionType.StakingBurn]: {
[TransactionSide.Received]: genericTransaction,
[TransactionSide.Sent]: {
destination: t('account.transaction.genericTransaction.destination', 'Other address'),
icon: MuiLocalFireDepartmentIcon,
header: () => (
<Trans
i18nKey="account.transaction.stakingBurn.sent"
t={t}
components={{ Amount }}
defaults="Burned <Amount/>"
/>
),
},
},

[transactionTypes.TransactionType.StakingAmendCommissionSchedule]: {
[TransactionSide.Received]: genericTransaction,
Expand All @@ -305,6 +321,10 @@ export function Transaction(props: TransactionProps) {
[TransactionSide.Received]: genericTransaction,
[TransactionSide.Sent]: genericTransaction,
},
[transactionTypes.TransactionType.RoothashSubmitMsg]: {
[TransactionSide.Received]: genericTransaction,
[TransactionSide.Sent]: genericTransaction,
},
[transactionTypes.TransactionType.RegistryDeregisterEntity]: {
[TransactionSide.Received]: genericTransaction,
[TransactionSide.Sent]: genericTransaction,
Expand All @@ -321,6 +341,10 @@ export function Transaction(props: TransactionProps) {
[TransactionSide.Received]: genericTransaction,
[TransactionSide.Sent]: genericTransaction,
},
[transactionTypes.TransactionType.RegistryUnfreezeNode]: {
[TransactionSide.Received]: genericTransaction,
[TransactionSide.Sent]: genericTransaction,
},
[transactionTypes.TransactionType.GovernanceCastVote]: {
[TransactionSide.Received]: genericTransaction,
[TransactionSide.Sent]: genericTransaction,
Expand Down
3 changes: 3 additions & 0 deletions src/app/state/transaction/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ export enum TransactionType {
StakingAmendCommissionSchedule = 'staking.AmendCommissionSchedule',
StakingAllow = 'staking.Allow',
StakingWithdraw = 'staking.Withdraw',
StakingBurn = 'staking.Burn',
RoothashExecutorCommit = 'roothash.ExecutorCommit',
RoothashExecutorProposerTimeout = 'roothash.ExecutorProposerTimeout',
RoothashSubmitMsg = 'roothash.SubmitMsg',
RegistryDeregisterEntity = 'registry.DeregisterEntity',
RegistryRegisterEntity = 'registry.RegisterEntity',
RegistryRegisterNode = 'registry.RegisterNode',
RegistryRegisterRuntime = 'registry.RegisterRuntime',
RegistryUnfreezeNode = 'registry.UnfreezeNode',
GovernanceCastVote = 'governance.CastVote',
GovernanceSubmitProposal = 'governance.SubmitProposal',
BeaconPvssCommit = 'beacon.PVSSCommit',
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
"received": "Received <Amount/> allowance",
"sent": "Set <Amount/> allowance"
},
"stakingBurn": {
"sent": "Burned <Amount/>"
},
"successful": "Successful",
"transfer": {
"received": "Received <Amount/>",
Expand Down
21 changes: 21 additions & 0 deletions src/styles/theme/icons/mui-icons/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Call-Em-All

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions src/styles/theme/icons/mui-icons/MuiLocalFireDepartmentIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Blank } from 'grommet-icons/es6/icons/Blank'
/* eslint-disable-next-line no-restricted-imports */
import { IconProps } from 'grommet-icons/es6/icons'

// From https://github.com/mui/material-ui/blob/4c336b8bd492749117a34947db44b0157a44c18b/packages/mui-icons-material/material-icons/local_fire_department_24px.svg
export const MuiLocalFireDepartmentIcon = (props: IconProps) => (
<Blank aria-hidden={undefined} aria-label="Lock" {...props}>
<g>
<rect fill="none" height="24" width="24" />
</g>
<g>
<g>
<g>
<path d="M12,12.9l-2.13,2.09C9.31,15.55,9,16.28,9,17.06C9,18.68,10.35,20,12,20s3-1.32,3-2.94c0-0.78-0.31-1.52-0.87-2.07 L12,12.9z" />
</g>
<g>
<path d="M16,6l-0.44,0.55C14.38,8.02,12,7.19,12,5.3V2c0,0-8,4-8,11c0,2.92,1.56,5.47,3.89,6.86C7.33,19.07,7,18.1,7,17.06 c0-1.32,0.52-2.56,1.47-3.5L12,10.1l3.53,3.47c0.95,0.93,1.47,2.17,1.47,3.5c0,1.02-0.31,1.96-0.85,2.75 c1.89-1.15,3.29-3.06,3.71-5.3C20.52,10.97,18.79,7.62,16,6z" />
</g>
</g>
</g>
</Blank>
)
13 changes: 13 additions & 0 deletions src/styles/theme/icons/mui-icons/MuiLockIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Blank } from 'grommet-icons/es6/icons/Blank'
/* eslint-disable-next-line no-restricted-imports */
import { IconProps } from 'grommet-icons/es6/icons'

// From https://github.com/mui/material-ui/blob/4c336b8bd492749117a34947db44b0157a44c18b/packages/mui-icons-material/lib/esm/Lock.js#L6
export const MuiLockIcon = (props: IconProps) => (
<Blank aria-hidden={undefined} aria-label="Lock" {...props}>
<path
fill="#333"
d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1z"
></path>
</Blank>
)
2 changes: 1 addition & 1 deletion src/vendors/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function parseTransactionsList(transactionsList: OperationsRow[]): Transa
status: t.status,
timestamp: t.timestamp == null ? undefined : t.timestamp * 1000,
to: t.to,
type: transactionMethodMap[t.type!],
type: transactionMethodMap[t.type!] ?? t.type,
runtimeName: undefined,
runtimeId: undefined,
round: undefined,
Expand Down
7 changes: 5 additions & 2 deletions src/vendors/oasisscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,15 @@ export const transactionMethodMap: {
[OperationsRowMethodEnum.StakingAmendCommissionSchedule]: TransactionType.StakingAmendCommissionSchedule,
[OperationsRowMethodEnum.StakingAllow]: TransactionType.StakingAllow,
[OperationsRowMethodEnum.StakingWithdraw]: TransactionType.StakingWithdraw,
[OperationsRowMethodEnum.StakingBurn]: TransactionType.StakingBurn,
[OperationsRowMethodEnum.RoothashExecutorCommit]: TransactionType.RoothashExecutorCommit,
[OperationsRowMethodEnum.RoothashExecutorProposerTimeout]: TransactionType.RoothashExecutorProposerTimeout,
[OperationsRowMethodEnum.RoothashSubmitMsg]: TransactionType.RoothashSubmitMsg,
[OperationsRowMethodEnum.RegistryDeregisterEntity]: TransactionType.RegistryDeregisterEntity,
[OperationsRowMethodEnum.RegistryRegisterEntity]: TransactionType.RegistryRegisterEntity,
[OperationsRowMethodEnum.RegistryRegisterNode]: TransactionType.RegistryRegisterNode,
[OperationsRowMethodEnum.RegistryRegisterRuntime]: TransactionType.RegistryRegisterRuntime,
[OperationsRowMethodEnum.RegistryUnfreezeNode]: TransactionType.RegistryUnfreezeNode,
[OperationsRowMethodEnum.GovernanceCastVote]: TransactionType.GovernanceCastVote,
[OperationsRowMethodEnum.GovernanceSubmitProposal]: TransactionType.GovernanceSubmitProposal,
[OperationsRowMethodEnum.BeaconPvssCommit]: TransactionType.BeaconPvssCommit,
Expand All @@ -158,7 +161,7 @@ export function parseTransactionsList(list: (OperationsRow | RuntimeTransactionI
status: t.result,
timestamp: t.timestamp * 1000,
to: t.ctx.to ?? undefined,
type: transactionMethodMap[t.ctx.method],
type: transactionMethodMap[t.ctx.method] ?? t.ctx.method,
runtimeName: t.runtimeName,
runtimeId: t.runtimeId,
round: t.round,
Expand All @@ -174,7 +177,7 @@ export function parseTransactionsList(list: (OperationsRow | RuntimeTransactionI
status: t.status,
timestamp: t.timestamp * 1000,
to: t.to ?? undefined,
type: transactionMethodMap[t.method],
type: transactionMethodMap[t.method] ?? t.method,
runtimeName: undefined,
runtimeId: undefined,
round: undefined,
Expand Down
3 changes: 3 additions & 0 deletions src/vendors/oasisscan/models/OperationsRow.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/vendors/oasisscan/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,15 @@ components:
- staking.AmendCommissionSchedule
- staking.Allow
- staking.Withdraw
- staking.Burn
- roothash.ExecutorCommit
- roothash.ExecutorProposerTimeout
- roothash.SubmitMsg
- registry.DeregisterEntity
- registry.RegisterEntity
- registry.RegisterNode
- registry.RegisterRuntime
- registry.UnfreezeNode
- governance.CastVote
- governance.SubmitProposal
- beacon.PVSSCommit
Expand Down
Loading