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

Sign message enters an endless loop when choosing who signs #327

Closed
Quicksaver opened this issue Nov 25, 2022 · 4 comments
Closed

Sign message enters an endless loop when choosing who signs #327

Quicksaver opened this issue Nov 25, 2022 · 4 comments

Comments

@Quicksaver
Copy link

Doing a eth_signTypedData_v4 request to sign a message, sequence endlessly asks to select the social method to login; see video. This makes it impossible to use this method, which is critical for our internal authentication.

Caller code:

  authenticating = (async () => {
    const address = await bepro.getAddress(true);
    console.log({ address });
    if (!address) {
      return null;
    }

    const { authData, signMethod } = await api.getAuthData();
    console.log({ address, authData, signMethod });
    try {
      const signature = await bepro.sign(signMethod, authData);
      console.log({ signature });
      if (signature) {
        const tokens = await api.postAuthenticate(signature);
        const newAuth = {
          address,
          declined: false,
          ...tokens,
        };

        setAuth(newAuth);
        return newAuth;
      }
    }
    ...

Authentication request:

sequenceProvider.transport.provider.request({
  method: 'eth_signTypedData_v4',
  params: [
    address: '0xwhateveraddress',
    JSON.stringify({
      domain: {
        name: "RealFevr NFTs Marketplace",
        version: "1"
      },
      message: {
        nonce: "a-unique-nonce-hash"
      },
      primaryType: "Auth",
      types: {
        eip712Domain: [
          {
            name: "name",
            type: "string"
          },
          {
            name: "version",
            type: "string"
          }
        ],
        auth: [
          {
            name: "nonce",
            type: "string"
          }
        ],
        EIP712Domain: [
          {
            name: "name",
            type: "string"
          },
          {
            name: "version",
            type: "string"
          }
        ],
        Auth: [
          {
            name: "nonce",
            type: "string"
          }
        ]
      }
    }),
  ],
});

You can see on the video how after clicking "Confirm" on the sequence modal dialog, the gmail account selector windows keeps popping up endlessly without any real effect. Take note also of how in the console, the console.log for the auth data (in the code above) appears only once, meaning the sign request really happens only once; the "loop" appears to be inside sequence itself.

Screen.Recording.2022-11-25.at.17.11.02.mov
@attente
Copy link
Contributor

attente commented Nov 28, 2022

Wow, that's super bizarre, haven't seen that before. Thanks for the report, we'll investigate!

@tolgahan-arikan
Copy link
Contributor

hey there @Quicksaver!
Can you try signing typed data using below? I just tested signing one as shown below, with chainId 56, and it worked fine.

const wallet = sequence.getWallet()
const signer = wallet.getSigner()
const sig = await signer.signTypedData(...)

@pkieltyka
Copy link
Member

btw, @Quicksaver the EIP712 domain is very similar to what we do with https://github.com/0xsequence/ethauth.js -- which in fact is built into sequence.js and used on connect. See https://docs.sequence.xyz/wallet/guides/auth-address#authenticate-wallet and https://github.com/0xsequence/sequence.js/blob/master/packages/provider/src/types.ts#L157

by passing authorize: true on connect, like so: wallet.connect({ authorize: true }) it will ask the user to connect and also sign the eip712 payload.

once thing we can do is update authorize to take either a boolean or nonce number, as you can see ETHAuth 712 domain supports a nonce as well.

@Quicksaver
Copy link
Author

Ditto from #324 (comment), we've had to rewrite our code to not use blindly web3js events and be able to use from other sources, aka Sequence's methods. Could be a blocker for projects looking to integrate Sequence into their already existing ethers/web3js-compatible code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants