Skip to content

Commit

Permalink
translate common error messages into understandable english phrases (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut authored Jan 8, 2025
1 parent ff9cf7d commit 576776e
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 35 deletions.
25 changes: 7 additions & 18 deletions .github/workflows/cypress-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/cache@v4
id: yarn-build-cache
with:
path: |
**/node_modules
~/.cache/Cypress
**/build
key: ${{ runner.os }}-node_modules-files-build-${{ hashFiles('./yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-build-
- name: Install indexer deps
working-directory: squid
run: npm ci
Expand Down Expand Up @@ -61,13 +50,13 @@ jobs:
wait-on: 'http://localhost:3333'
# custom test command to run
command: yarn test:ci
# store the screenshots if the tests fail
# - name: Store screenshots
# uses: actions/upload-artifact@v4
# if: failure()
# with:
# name: cypress-screenshots
# path: packages/ui/cypress/screenshots
# after the test run completes store videos and any screenshots
- name: Store screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: packages/ui/cypress/screenshots
# # store the videos if the tests fail
# - name: Store videos
# uses: actions/upload-artifact@v4
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@typescript-eslint/eslint-plugin": "^8.17.0",
"@typescript-eslint/parser": "^8.17.0",
"@vitejs/plugin-react": "^4.3.4",
"cypress": "^13.16.0",
"cypress": "^13.17.0",
"cypress-wait-until": "^3.0.2",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
Expand Down
9 changes: 2 additions & 7 deletions packages/ui/src/components/library/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const Select = ({
value,
onChange,
menuItems,
minified,
minified = false,
fullWidth,
inputSize,
inputSize = 'medium',
children,
sx,
testId
Expand Down Expand Up @@ -71,11 +71,6 @@ const Select = ({
)
}

Select.defaultProps = {
minified: false,
inputSize: 'medium'
}

const MenuPropsStyles = {
sx: {
marginTop: '.75rem',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ const GenericAccountSelection = ({
const getRenderOption = (props: React.HTMLAttributes<HTMLLIElement>, option: AccountBaseInfo) => {
return (
<OptionMenuItem
{...props}
keyValue={option.address}
key={option.address}
{...props}
>
<AccountDisplay
address={option.address}
Expand Down
8 changes: 5 additions & 3 deletions packages/ui/src/hooks/useSigningCallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useToasts } from '../contexts/ToastContext'
// import { getIncompleteMessage } from '../utils/extinsicErrorChecks'
import { TxEvent } from 'polkadot-api'
import { JSONprint } from '../utils/jsonPrint'
import { translateError, translateErrorInfo } from '../utils/translateError'

interface Args {
onSubmitting?: () => void
Expand Down Expand Up @@ -70,7 +71,7 @@ export const useSigningCallback = ({ onSubmitting, onSuccess, onFinalized, onErr
})

if (!!errorInfo && !toastErrorShown) {
addToast({ title: errorInfo, type: 'error', link })
addToast({ title: translateErrorInfo(errorInfo), type: 'error', link })
onError && onError(errorInfo)
// prevent showing several errors
toastErrorShown = true
Expand All @@ -82,8 +83,9 @@ export const useSigningCallback = ({ onSubmitting, onSuccess, onFinalized, onErr
onFinalized && onFinalized()
}
},
error: (error: Error) => {
console.error(error)
error: (e: Error) => {
console.error(e)
const error = translateError(e)
addToast({ title: error.toString(), type: 'error' })
onError && onError()
}
Expand Down
16 changes: 16 additions & 0 deletions packages/ui/src/utils/translateError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const translateError = (error: any) => {
// {"error":{"type":"Invalid","value":{"type":"Payment"}},"name":"InvalidTxError"}
if (error.error && error.error.type === 'Invalid' && error.error.value.type === 'Payment') {
return 'Not enough funds to pay for the tx'
}

return error.toString()
}

export const translateErrorInfo = (errorInfo: string) => {
if (errorInfo === 'NoTimepoint') {
return 'The same multisig transaction is already pending'
}

return errorInfo
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6620,9 +6620,9 @@ __metadata:
languageName: node
linkType: hard

"cypress@npm:^13.16.0":
version: 13.16.0
resolution: "cypress@npm:13.16.0"
"cypress@npm:^13.17.0":
version: 13.17.0
resolution: "cypress@npm:13.17.0"
dependencies:
"@cypress/request": ^3.0.6
"@cypress/xvfb": ^1.2.4
Expand Down Expand Up @@ -6669,7 +6669,7 @@ __metadata:
yauzl: ^2.10.0
bin:
cypress: bin/cypress
checksum: bdda12386d5f0404ef24c9df58e8035af47ba6cdaa09619187ccbb6e69e442cfecf013d03878b9d399eb3538536bde66ad5eea2c17d99c5a56abb1e25024fba2
checksum: 159ce620e32d2785082aaa1f4f30f203dcec466df4a8e80dfa299035358772fd513c35820070ba8db52e2bf58078a372ff7009068e26967f993656e7da62e221
languageName: node
linkType: hard

Expand Down Expand Up @@ -10174,7 +10174,7 @@ __metadata:
"@typescript-eslint/parser": ^8.17.0
"@vitejs/plugin-react": ^4.3.4
"@walletconnect/web3wallet": ^1.16.1
cypress: ^13.16.0
cypress: ^13.17.0
cypress-wait-until: ^3.0.2
dayjs: ^1.11.13
dot-connect: ^0.13.2
Expand Down

0 comments on commit 576776e

Please sign in to comment.