Skip to content

Commit

Permalink
Merge pull request #92 from valory-xyz/tanya/safe-fix
Browse files Browse the repository at this point in the history
(govern, launch): fix: interaction with safe wallet not working
  • Loading branch information
Tanya-atatakai authored Aug 30, 2024
2 parents 387f360 + c04e2db commit 0711f2e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
8 changes: 7 additions & 1 deletion apps/govern/components/Login/LoginV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ export const LoginV2 = () => {
const dispatch = useAppDispatch();

const handleConnect = useCallback(
({ address }: Pick<GetAccountReturnType, 'address' | 'chainId'>) => {
async ({ address, connector }: Pick<GetAccountReturnType, 'address' | 'connector'>) => {
if (isAddressProhibited(address)) {
disconnect();
}

if (connector) {
const modalProvider = await connector.getProvider();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).MODAL_PROVIDER = modalProvider;
}
},
[disconnect],
);
Expand Down
8 changes: 7 additions & 1 deletion apps/launch/components/Login/LoginV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ export const LoginV2 = () => {
const config = useConfig();

const handleConnect = useCallback(
({ address }: Pick<GetAccountReturnType, 'address' | 'chainId'>) => {
async ({ address, connector }: Pick<GetAccountReturnType, 'address' | 'connector'>) => {
if (isAddressProhibited(address)) {
disconnect();
}

if (connector) {
const modalProvider = await connector.getProvider();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).MODAL_PROVIDER = modalProvider;
}
},
[disconnect],
);
Expand Down
1 change: 1 addition & 0 deletions libs/common-middleware/src/lib/cspHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const ALLOWED_ORIGINS = [
'https://safe-transaction-goerli.safe.global/api/',
'https://safe-transaction-gnosis-chain.safe.global/api/',
'https://safe-transaction-polygon.safe.global/api/',
'https://cloudflare-eth.com/',

// chains
'https://eth-mainnet.g.alchemy.com/v2/',
Expand Down
9 changes: 2 additions & 7 deletions libs/util-functions/src/lib/sendTransaction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ export const sendTransaction = async (
if (!provider) return false;

try {
const getCodeFn = provider?.provider?.getCode;
if (!getCodeFn) return false;

const code = await getCodeFn(account);
const code = await provider.getCode(account);
return code !== '0x';
} catch (error) {
console.error(error);
Expand All @@ -69,7 +66,7 @@ export const sendTransaction = async (
*/
notifyWarning('Please submit the transaction in your safe app.');

sendFn.on('transactionHash', async (safeTx: string) => {
return sendFn.on('transactionHash', async (safeTx: string) => {
window.console.log('safeTx', safeTx);

/**
Expand All @@ -95,6 +92,4 @@ export const sendTransaction = async (
notifyError('Error occurred while sending transaction');
throw e;
}

return null;
};

0 comments on commit 0711f2e

Please sign in to comment.