Skip to content

Commit

Permalink
set allowance to the processor address
Browse files Browse the repository at this point in the history
  • Loading branch information
mmv08 committed Oct 11, 2024
1 parent 28c44f6 commit 6d12ee6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ReviewEnableSafenet = ({ params }: { params: EnableSafenetFlowProps
params.tokensForPresetAllowances.forEach((tokenAddress) => {
txs.push({
to: tokenAddress,
data: ERC20_INTERFACE.encodeFunctionData('approve', [params.guardAddress, UNLIMITED_APPROVAL_AMOUNT]),
data: ERC20_INTERFACE.encodeFunctionData('approve', [params.allowanceSpender, UNLIMITED_APPROVAL_AMOUNT]),
value: '0',
operation: OperationType.Call,
})
Expand All @@ -36,7 +36,7 @@ export const ReviewEnableSafenet = ({ params }: { params: EnableSafenetFlowProps
}

getTxs().then(setSafeTx).catch(setSafeTxError)
}, [setSafeTx, setSafeTxError, params.guardAddress, params.tokensForPresetAllowances])
}, [setSafeTx, setSafeTxError, params.allowanceSpender, params.tokensForPresetAllowances, params.guardAddress])

useEffect(() => {
if (safeTxError) {
Expand Down
5 changes: 3 additions & 2 deletions src/components/tx-flow/flows/EnableSafenet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { ReviewEnableSafenet } from './ReviewEnableSafenet'
export type EnableSafenetFlowProps = {
guardAddress: string
tokensForPresetAllowances: string[]
allowanceSpender: string
}

const EnableSafenetFlow = ({ guardAddress, tokensForPresetAllowances }: EnableSafenetFlowProps) => {
const EnableSafenetFlow = ({ guardAddress, tokensForPresetAllowances, allowanceSpender }: EnableSafenetFlowProps) => {
return (
<TxLayout title="Confirm transaction" subtitle="Enable SafeNet">
<ReviewEnableSafenet params={{ guardAddress, tokensForPresetAllowances }} />
<ReviewEnableSafenet params={{ guardAddress, tokensForPresetAllowances, allowanceSpender }} />
</TxLayout>
)
}
Expand Down
7 changes: 6 additions & 1 deletion src/pages/settings/safenet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const getSafeNetTokensByChain = (chainId: number, safeNetConfig: SafeNetConfigEn
const SafeNetContent = ({ safeNetConfig, safe }: { safeNetConfig: SafeNetConfigEntity; safe: ExtendedSafeInfo }) => {
const isVersionWithGuards = hasSafeFeature(SAFE_FEATURES.SAFE_TX_GUARDS, safe.version)
const safeNetGuardAddress = safeNetConfig.guards[safe.chainId]
const safeNetProcessorAddress = safeNetConfig.processors[safe.chainId]
const isSafeNetGuardEnabled = isVersionWithGuards && sameAddress(safe.guard?.value, safeNetGuardAddress)
const chainSupported = isSupportedChain(Number(safe.chainId), safeNetConfig, SafenetChainType.SOURCE)
const { setTxFlow } = useContext(TxModalContext)
Expand Down Expand Up @@ -105,7 +106,11 @@ const SafeNetContent = ({ safeNetConfig, safe }: { safeNetConfig: SafeNetConfigE
variant="contained"
onClick={() =>
setTxFlow(
<EnableSafenetFlow guardAddress={safeNetGuardAddress} tokensForPresetAllowances={safeNetAssets} />,
<EnableSafenetFlow
guardAddress={safeNetGuardAddress}
tokensForPresetAllowances={safeNetAssets}
allowanceSpender={safeNetProcessorAddress}
/>,
)
}
sx={{ mt: 2 }}
Expand Down
1 change: 1 addition & 0 deletions src/store/safenet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type SafeNetConfigEntity = {
}
guards: Record<string, string>
tokens: Record<string, Record<string, string>>
processors: Record<string, string>
}

export type SafeNetBalanceEntity = {
Expand Down

0 comments on commit 6d12ee6

Please sign in to comment.