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

fix: handle nullable SafeInfo['version'] #1340

Merged
merged 5 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@reduxjs/toolkit": "^1.8.2",
"@safe-global/safe-core-sdk": "^3.2.0",
"@safe-global/safe-ethers-lib": "^1.7.0",
"@safe-global/safe-gateway-typescript-sdk": "^3.5.3",
"@safe-global/safe-gateway-typescript-sdk": "^3.5.4",
"@sentry/react": "^7.8.1",
"@sentry/tracing": "^7.8.1",
"@truffle/hdwallet-provider": "^2.0.14",
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/ContractVersion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const ContractVersion = ({ isGranted }: { isGranted: boolean }) => {
Contract version
</Typography>
<ExternalLink href={safeMasterCopy?.deployerRepoUrl}>
{safe.version}
{safe?.version}
{getSafeVersionUpdate()}
</ExternalLink>

Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/TransactionGuards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const GUARD_SUPPORTED_SAFE_VERSION = '1.3.0'
const TransactionGuards = () => {
const { safe, safeLoaded } = useSafeInfo()

const isVersionWithGuards = safeLoaded && gte(safe.version, GUARD_SUPPORTED_SAFE_VERSION)
const isVersionWithGuards = safeLoaded && safe?.version && gte(safe.version, GUARD_SUPPORTED_SAFE_VERSION)

if (!isVersionWithGuards) {
return null
Expand Down
2 changes: 1 addition & 1 deletion src/components/tx/TxSimulation/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const _getMultiSendCallOnlyPayload = (
params: MultiSendTransactionSimulationParams,
): Pick<TenderlySimulatePayload, 'to' | 'input'> => {
const data = encodeMultiSendData(params.transactions)
const instance = getMultiSendCallOnlyContractInstance(params.safe.chainId, params.safe.version)
const instance = getMultiSendCallOnlyContractInstance(params.safe.chainId, params.safe?.version)

return {
to: instance.getAddress(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ const ReviewBatchExecute = ({ data, onSubmit }: { data: BatchExecuteData; onSubm
}, [data.txs, chain?.chainId])

const multiSendContract = useMemo(() => {
if (!chain?.chainId) return
if (!chain?.chainId || !safe?.version) return
return getMultiSendCallOnlyContractInstance(chain.chainId, safe.version)
}, [chain?.chainId, safe.version])
}, [chain?.chainId, safe?.version])

const multiSendTxs = useMemo(() => {
if (!txsWithDetails || !chain) return
if (!txsWithDetails || !chain || !safe?.version) return
return getMultiSendTxs(txsWithDetails, chain, safe.address.value, safe.version)
}, [chain, safe.address.value, safe.version, txsWithDetails])
}, [chain, safe.address.value, safe?.version, txsWithDetails])

const multiSendTxData = useMemo(() => {
if (!txsWithDetails || !multiSendTxs) return
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/coreSDK/safeCoreSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export const initSafeSDK = async (
provider: EIP1193Provider,
chainId: string,
safeAddress: string,
safeVersion: string,
safeVersion?: string,
): Promise<Safe> => {
let isL1SafeMasterCopy = chainId === chains.eth
// Legacy Safe contracts
if (isLegacyVersion(safeVersion)) {
if (safeVersion && isLegacyVersion(safeVersion)) {
isL1SafeMasterCopy = true
}

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/coreSDK/useInitSafeCoreSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useInitSafeCoreSDK = () => {
const dispatch = useAppDispatch()

useEffect(() => {
if (!safeLoaded || !wallet?.provider || safe.chainId !== wallet.chainId) {
if (!safeLoaded || !wallet?.provider || safe.chainId !== wallet.chainId || !safe?.version) {
// If we don't reset the SDK, a previous Safe could remain in the store
setSafeSDK(undefined)
return
Expand All @@ -31,5 +31,5 @@ export const useInitSafeCoreSDK = () => {
)
trackError(ErrorCodes._105, (e as Error).message)
})
}, [wallet?.provider, wallet?.chainId, safe.chainId, safe.address.value, safe.version, safeLoaded, dispatch])
}, [wallet?.provider, wallet?.chainId, safe.chainId, safe.address.value, safe?.version, safeLoaded, dispatch])
}
2 changes: 1 addition & 1 deletion src/services/contracts/safeContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const getSpecificGnosisSafeContractInstance = (safe: SafeInfo) => {

return ethAdapter.getSafeContract({
customContractAddress: safe.address.value,
..._getValidatedGetContractProps(safe.chainId, safe.version),
..._getValidatedGetContractProps(safe.chainId, safe?.version),
})
}

Expand Down