@@ -25,6 +25,7 @@ import Restart from 'react-native-restart';
2525import Menu from './Menu' ;
2626import MenuContainer from './MenuContainer' ;
2727import MenuItem from './MenuItem' ;
28+ import type { Address } from 'viem' ;
2829
2930import { addDefaultNotificationGroupSettings } from '@/notifications/settings/initialization' ;
3031import { unsubscribeAllNotifications } from '@/notifications/settings/settings' ;
@@ -37,7 +38,7 @@ import FastImage from 'react-native-fast-image';
3738import { analyzeUserAssets } from '@/state/debug/analyzeUserAssets' ;
3839import { getAllInternetCredentials , resetInternetCredentials } from 'react-native-keychain' ;
3940import { ChainId } from '@/state/backendNetworks/types' ;
40- import { executeDelegation , executeRevokeDelegation } from '@rainbow-me/delegation' ;
41+ import { executeDelegation , executeRevokeDelegation , getDelegations } from '@rainbow-me/delegation' ;
4142import { loadWallet } from '@/model/wallet' ;
4243import { getProvider } from '@/handlers/web3' ;
4344import { Wallet } from '@ethersproject/wallet' ;
@@ -167,12 +168,12 @@ const DevSection = () => {
167168 const maxFeePerGas = feeData . maxFeePerGas ?. toBigInt ( ) ;
168169 const maxPriorityFeePerGas = feeData . maxPriorityFeePerGas ?. toBigInt ( ) ;
169170
170- const nonce = await getNextNonce ( { address : accountAddress , chainId } ) ;
171-
172171 if ( ! maxFeePerGas || ! maxPriorityFeePerGas ) {
173172 throw new Error ( 'Failed to fetch gas prices from provider' ) ;
174173 }
175174
175+ const nonce = await getNextNonce ( { address : accountAddress , chainId } ) ;
176+
176177 // Use null for gasLimit to let the SDK estimate it automatically
177178 const tx = await executeDelegation ( {
178179 signer : wallet as Wallet ,
@@ -219,12 +220,12 @@ const DevSection = () => {
219220 const maxFeePerGas = feeData . maxFeePerGas ?. toBigInt ( ) ;
220221 const maxPriorityFeePerGas = feeData . maxPriorityFeePerGas ?. toBigInt ( ) ;
221222
222- const nonce = await getNextNonce ( { address : accountAddress , chainId } ) ;
223-
224223 if ( ! maxFeePerGas || ! maxPriorityFeePerGas ) {
225224 throw new Error ( 'Failed to fetch gas prices from provider' ) ;
226225 }
227226
227+ const nonce = await getNextNonce ( { address : accountAddress , chainId } ) ;
228+
228229 // Use null for gasLimit to let the SDK estimate it automatically
229230 const result = await executeRevokeDelegation ( {
230231 signer : wallet as Wallet ,
@@ -255,32 +256,15 @@ const DevSection = () => {
255256 }
256257
257258 try {
258- // Check for delegations on mainnet and base
259- const chainsToCheck = [ ChainId . mainnet , ChainId . base ] ;
260- const delegationsToRevoke : Array < { chainId : number ; contractAddress : string } > = [ ] ;
261-
262- /*
263- for (const chainId of chainsToCheck) {
264- const isDelegated = await getIsDelegated({
265- address: accountAddress,
266- chainId,
267- });
268-
269- if (isDelegated) {
270- // For this demo, we'll use a placeholder contract address
271- delegationsToRevoke.push({
272- chainId,
273- contractAddress: '0x0000000000000000000000000000000000000000',
274- });
275- logger.info('Found active delegation', { chainId, accountAddress });
276- }
277- }
278- */
259+ const delegationsToRevoke = await getDelegations ( { address : accountAddress } ) ;
279260
280261 if ( delegationsToRevoke . length > 0 ) {
281262 logger . info ( 'Delegation status required' , { delegationsToRevoke } ) ;
282263 Navigation . handleAction ( Routes . REVOKE_DELEGATION_PANEL , {
283- delegationsToRevoke,
264+ delegationsToRevoke : delegationsToRevoke . map ( delegation => ( {
265+ chainId : delegation . chainId ,
266+ contractAddress : delegation . currentContract as Address ,
267+ } ) ) ,
284268 } ) ;
285269 } else {
286270 Alert . alert (
0 commit comments