Skip to content

Commit

Permalink
Merge pull request #198 from leighmcculloch/issue-197
Browse files Browse the repository at this point in the history
Be resilient to unrecognized operation types
  • Loading branch information
chatch authored Feb 6, 2021
2 parents 27d7e48 + 7e3f163 commit 6f66b47
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/operations/Operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Offer from './Offer'
import PathPayment from './PathPayment'
import Payment from './Payment'
import SetOptions from './SetOptions'
import Unrecognized from './Unrecognized'

const opTypeComponentMap = {
account_merge: AccountMerge,
Expand Down Expand Up @@ -47,7 +48,7 @@ const opTypeComponentMap = {
const opTypes = Object.keys(opTypeComponentMap)

const SubOperation = ({op}) => {
const SubOpComponent = opTypeComponentMap[op.type]
const SubOpComponent = opTypeComponentMap[op.type] || Unrecognized
return <SubOpComponent {...op} />
}

Expand Down
11 changes: 11 additions & 0 deletions src/components/operations/Unrecognized.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'
import {FormattedMessage} from 'react-intl'

const Unrecognized = ({type}) => <FormattedMessage
id="operation.unrecognized"
values={{
type: type,
}}
/>

export default Unrecognized
1 change: 1 addition & 0 deletions src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
"operation.trust": "Trust {trustee} issuing {assetCode}",
"operation.trust.allow": " [authorize: {authorize}, trustor: {trustor}]",
"operation.trust.change": " with limit {limit}",
"operation.unrecognized": "Operation {type}",

"optional": "Optional",
"order.amount": "Amount",
Expand Down
1 change: 1 addition & 0 deletions src/languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"operation.trust": "Доверие {trustee} выпускающему {assetCode}",
"operation.trust.allow": " [authorize: {authorize}, trustor: {trustor}]",
"operation.trust.change": " с лимитом {limit}",
"operation.unregoznied": "Операция {type}",

"optional": "Необязательно",
"order.amount": "Сумма",
Expand Down
1 change: 1 addition & 0 deletions src/languages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"operation.trust": "Tin tưởng {trustee} phát hành {assetCode}",
"operation.trust.allow": " [authorize: {authorize}, trustor: {trustor}]",
"operation.trust.change": " với giới hạn {limit}",
"operation.unregoznied": "Hoạt động {type}",

"optional": "Không bắt buộc",
"order.amount": "Số tiền",
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"operation.trust": "信任 {trustee} 发行 {assetCode}",
"operation.trust.allow": " [authorize: {authorize}, trustor: {trustor}]",
"operation.trust.change": "至限额 {limit}",
"operation.unregoznied": "操作 {type}",

"optional": "可选",
"order.amount": "数量",
Expand Down

0 comments on commit 6f66b47

Please sign in to comment.