Remove any type (#57)

* Remove any type for requestEvent parameter

* Handle review changes
This commit is contained in:
shreerang6921 2024-03-15 13:50:57 +05:30 committed by GitHub
parent 8bd3b4b567
commit 63faa74e2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 8 deletions

View File

@ -9,6 +9,7 @@ import {
NativeStackNavigationProp, NativeStackNavigationProp,
createNativeStackNavigator, createNativeStackNavigator,
} from '@react-navigation/native-stack'; } from '@react-navigation/native-stack';
import { Web3WalletTypes } from '@walletconnect/web3wallet';
import SignMessage from './components/SignMessage'; import SignMessage from './components/SignMessage';
import HomeScreen from './components/HomeScreen'; import HomeScreen from './components/HomeScreen';
@ -47,7 +48,7 @@ const App = (): React.JSX.Element => {
); );
const onSessionRequest = useCallback( const onSessionRequest = useCallback(
async (requestEvent: SignClientTypes.EventArguments['session_request']) => { async (requestEvent: Web3WalletTypes.SessionRequest) => {
const { topic, params } = requestEvent; const { topic, params } = requestEvent;
const { request } = params; const { request } = params;

View File

@ -124,7 +124,7 @@ const PairingModal = ({
} }
const namespaceAccounts: string[] = []; const namespaceAccounts: string[] = [];
requiredNamespaces[key].chains!.map((chain: any) => { requiredNamespaces[key].chains!.map((chain: string) => {
currentAddresses.map(acc => currentAddresses.map(acc =>
namespaceAccounts.push(`${chain}:${acc}`), namespaceAccounts.push(`${chain}:${acc}`),
); );

View File

@ -39,11 +39,13 @@ const SignRequest = ({ route }: SignRequestProps) => {
useNavigation<NativeStackNavigationProp<StackParamsList>>(); useNavigation<NativeStackNavigationProp<StackParamsList>>();
const isCosmosSignDirect = useMemo(() => { const isCosmosSignDirect = useMemo(() => {
const requestParams = route.params!.requestEvent const requestParams = route.params!.requestEvent;
? route.params!.requestEvent.params.request
: {};
return requestParams.method === 'cosmos_signDirect'; if (!requestParams) {
return false;
}
return requestParams.params.request.method === 'cosmos_signDirect';
}, [route.params]); }, [route.params]);
const retrieveData = async ( const retrieveData = async (
@ -116,6 +118,10 @@ const SignRequest = ({ route }: SignRequestProps) => {
throw new Error('account not found'); throw new Error('account not found');
} }
if (!requestEvent) {
throw new Error('Request event not found');
}
const response = await approveWalletConnectRequest( const response = await approveWalletConnectRequest(
requestEvent, requestEvent,
account, account,

View File

@ -1,4 +1,5 @@
import { SignClientTypes, SessionTypes } from '@walletconnect/types'; import { SignClientTypes, SessionTypes } from '@walletconnect/types';
import { Web3WalletTypes } from '@walletconnect/web3wallet';
export type StackParamsList = { export type StackParamsList = {
Laconic: undefined; Laconic: undefined;
@ -8,8 +9,7 @@ export type StackParamsList = {
network: string; network: string;
address: string; address: string;
message: string; message: string;
// TODO: remove any requestEvent?: Web3WalletTypes.SessionRequest;
requestEvent?: any;
requestSession?: any; requestSession?: any;
} }
| undefined; | undefined;