vue-dapp icon indicating copy to clipboard operation
vue-dapp copied to clipboard

Add Gnosis Safe

Open johnson86tw opened this issue 3 years ago • 8 comments

sdk: https://docs.gnosis-safe.io/build/sdks/safe-apps/build

johnson86tw avatar Jun 13 '22 03:06 johnson86tw

Any update on this one ?

re2005 avatar Jul 05 '22 11:07 re2005

@re2005 No, sorry. My hands are full recently. Do you want to make it work?

johnson86tw avatar Jul 07 '22 15:07 johnson86tw

Already trying to fix this.

https://github.com/safe-global/safe-apps-sdk/issues/337

re2005 avatar Jul 08 '22 07:07 re2005

Hi @re2005 Any update on the integration of gnosis ? If not I might give it a try soon Thanks

fberger-xyz avatar Aug 29 '22 05:08 fberger-xyz

@fran6brg in order to use Gnosis Safe you should do something like this:

You will need to install @gnosis.pm/safe-apps-wagmi

import { MetaMaskConnector, WalletConnectConnector } from 'vue-dapp';
import { SafeConnector } from '@gnosis.pm/safe-apps-wagmi';

const isServer = typeof window === 'undefined';
const isIframe = !isServer && window?.parent !== window;

const connectors: any = [
    new MetaMaskConnector({
        appUrl: window.location.href,
    }),
    new WalletConnectConnector({
        qrcode: true,
        rpc: {},
    }),
];

if (isIframe) {
    connectors.push(new SafeConnector({}));
}

export const isGnosisSafeApp = isIframe;

export default connectors;

So basically within your connect you can check if your dapp is running inside GnosisSafe and than just use

new SafeConnector({})

Give it a try ;)

re2005 avatar Aug 29 '22 08:08 re2005

Just tested your suggestion of code, for me it works perfectly 🙏 I only had some minor typescript issues but surely because I modified the vue-dapp package a bit

fberger-xyz avatar Aug 29 '22 10:08 fberger-xyz

@fran6brg please feel free to suggest improvements for this repo as well.

Cheers.

re2005 avatar Aug 29 '22 15:08 re2005

You will need to install @gnosis.pm/safe-apps-wagmi

import { MetaMaskConnector, WalletConnectConnector } from 'vue-dapp';
import { SafeConnector } from '@gnosis.pm/safe-apps-wagmi';

const isServer = typeof window === 'undefined';
const isIframe = !isServer && window?.parent !== window;

const connectors: any = [
    new MetaMaskConnector({
        appUrl: window.location.href,
    }),
    new WalletConnectConnector({
        qrcode: true,
        rpc: {},
    }),
];

if (isIframe) {
    connectors.push(new SafeConnector({}));
}

export const isGnosisSafeApp = isIframe;

export default connectors;

So basically within your connect you can check if your dapp is running inside GnosisSafe and than just use

new SafeConnector({})

Give it a try ;)

Seems that this solution can be written down on the document and then it's better to close this issue

johnson86tw avatar Aug 31 '22 06:08 johnson86tw