Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Fix WalletConnect SIWE connection
Sebastian Martinez committed 4 years ago
commit cf371e31edbdb60971cce325373064a841b69018
parent 41b82decfe0418a484f338de53b96344011608ce
2 files changed +9 -4
modified src/WalletConnectSigner.ts
@@ -51,13 +51,13 @@ export class WalletConnectSigner extends ethers.Signer {
    const prefix = ethers.utils.toUtf8Bytes(
      `\x19Ethereum Signed Message:\n${message.length}`
    );
-
    const data = ((typeof(message) === "string") ? ethers.utils.toUtf8Bytes(message): message);
+
    const data = ((typeof (message) === "string") ? ethers.utils.toUtf8Bytes(message) : message);

    const msg = ethers.utils.concat([prefix, data]);
    const address = await this.getAddress();
    const keccakMessage = ethers.utils.keccak256(msg);
    const signature = await this.walletConnect.signMessage([
-
      address.toLowerCase(),
+
      address,
      keccakMessage,
    ]);

modified src/siwe.ts
@@ -4,6 +4,7 @@ import { Request, type Host } from '@app/api';
import type { Config } from "@app/config";
import { connectSeed } from "@app/session";
import type { Seed } from "@app/base/seeds/Seed";
+
import { ethers } from "ethers";

export interface SeedSession {
  domain: string;
@@ -45,9 +46,13 @@ export async function signInWithEthereum(seed: Seed, config: Config): Promise<{
    return null;
  }

-
  const result = await createUnauthorizedSession(seed.api);
  const address = await config.signer.getAddress();
-
  const message = createSiweMessage(seed, address, result.nonce, config);
+
  // We convert the address to a checksummed address, since WalletConnect returns a lowercase address.
+
  // We need a checksummed address to verify it on the seed node.
+
  const checksummedAddress = ethers.utils.getAddress(address);
+

+
  const result = await createUnauthorizedSession(seed.api);
+
  const message = createSiweMessage(seed, checksummedAddress, result.nonce, config);
  const signature = await config.signer.signMessage(message);

  const auth: {