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

(govern, launch): fix: interaction with safe wallet not working #92

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 Great, hopefully, we'll move these to the NX library someday. Just one more question—are the other apps working well with Gnosis Safe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes they all have this piece of code, don't know why I didn't migrate this, thought that's redundant.
agree, the whole login component ideally should be in libs

},
[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;
};
Loading