mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +08:00
Fix WalletConnect SIWE connection
Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
|
||||
|
||||
+7
-2
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user