Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
fix: add set/deleteGuard (#3645)
Browse files Browse the repository at this point in the history
* fix: migrate to `TransactionTokenType` type

* fix: add `set`/`deleteGuard` tx info w/ fallback

* fix: use existing hook

* fix: remove casts, rename info + add comment

Co-authored-by: katspaugh <381895+katspaugh@users.noreply.github.com>
  • Loading branch information
iamacook and katspaugh committed Mar 10, 2022
1 parent 3f1134e commit 7995c19
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@gnosis.pm/safe-core-sdk": "^2.0.0",
"@gnosis.pm/safe-deployments": "^1.8.0",
"@gnosis.pm/safe-react-components": "^0.9.8",
"@gnosis.pm/safe-react-gateway-sdk": "^2.10.0",
"@gnosis.pm/safe-react-gateway-sdk": "^2.10.1",
"@gnosis.pm/safe-web3-lib": "^1.0.0",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.0",
Expand Down
2 changes: 2 additions & 0 deletions src/logic/safe/store/models/types/gateway.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
TransactionListItem,
TransactionListPage,
TransactionStatus,
TransactionInfo,
SettingsChange,
} from '@gnosis.pm/safe-react-gateway-sdk'

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const TxInfo = ({ info, name }: { info: AssetInfo; name?: string }) => {
case 'SWAP_OWNER':
case 'CHANGE_THRESHOLD':
case 'CHANGE_IMPLEMENTATION':
case 'SET_GUARD':
case 'DELETE_GUARD':
break
case 'ENABLE_MODULE':
case 'DISABLE_MODULE':
Expand Down
18 changes: 16 additions & 2 deletions src/routes/safe/components/Transactions/TxList/TxInfoSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SettingsChange } from '@gnosis.pm/safe-react-gateway-sdk'
import { SettingsChange, SettingsInfo } from '@gnosis.pm/safe-react-gateway-sdk'
import { ReactElement } from 'react'

import { AddressInfo } from './AddressInfo'
Expand Down Expand Up @@ -85,7 +85,21 @@ export const TxInfoSettings = ({ settingsInfo }: TxInfoSettingsProps): ReactElem
</InfoDetails>
)
}
case 'SET_GUARD': {
return (
<InfoDetails title="Set guard:">
<AddressInfo
address={settingsInfo.guard.value}
name={settingsInfo.guard?.name || undefined}
avatarUrl={settingsInfo.guard?.logoUri || undefined}
/>
</InfoDetails>
)
}
case 'DELETE_GUARD': {
return <InfoDetails title="Delete guard">{null}</InfoDetails>
}
default:
return null
return <InfoDetails title={(settingsInfo as SettingsInfo).type}>{null}</InfoDetails>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export const useTransactionType = (tx: Transaction): TxTypeProps => {
break
}
case 'SettingsChange': {
setType({ icon: SettingsTxIcon, text: tx.txInfo.dataDecoded.method })
// deleteGuard doesn't exist in Solidity
// It is decoded as 'setGuard' with a settingsInfo.type of 'DELETE_GUARD'
const isDeleteGuard = tx.txInfo.settingsInfo?.type === 'DELETE_GUARD'
setType({ icon: SettingsTxIcon, text: isDeleteGuard ? 'deleteGuard' : tx.txInfo.dataDecoded.method })
break
}
case 'Custom': {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1965,10 +1965,10 @@
react-media "^1.10.0"
web3-utils "^1.6.0"

"@gnosis.pm/safe-react-gateway-sdk@^2.10.0":
version "2.10.0"
resolved "https://registry.yarnpkg.com/@gnosis.pm/safe-react-gateway-sdk/-/safe-react-gateway-sdk-2.10.0.tgz#88e2307d21d548ea43dde8fa33630d3539e39741"
integrity sha512-P0A6XgjpEwCzZpk0vjLOYuaOmXL020khJF9FQRwCYPrllPUzrGjpm5gdqExNdnefrrDUKeWUumkucoXqBaMblA==
"@gnosis.pm/safe-react-gateway-sdk@^2.10.1":
version "2.10.1"
resolved "https://registry.yarnpkg.com/@gnosis.pm/safe-react-gateway-sdk/-/safe-react-gateway-sdk-2.10.1.tgz#62f4abf733855e734aa1eab4be4778ccd08fe689"
integrity sha512-uIosTEqmoxhCy7WS8sIzXde2nJQwzC+KfNoeDQVeLZtEpnRZQ7R+N/qDtORMUJfKeyc8cIwkKXmVc2DRgSRxOQ==
dependencies:
cross-fetch "^3.1.5"

Expand Down

0 comments on commit 7995c19

Please sign in to comment.