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

Basic WC Recover Signature #41

Merged
merged 12 commits into from
May 15, 2024
Merged

Basic WC Recover Signature #41

merged 12 commits into from
May 15, 2024

Conversation

bh2smith
Copy link
Collaborator

@bh2smith bh2smith commented May 13, 2024

Just trying to handle signature reconstruction for session request types.

How to use this:

  const handleRequest = async (request: Web3WalletTypes.SessionRequest) => {
    if (!web3wallet) {
      console.error("No Web3Wallet connected");
      return;
    }
    if (!adapter) {
      console.error("No Adapter set");
      return;
    }
    console.log("Received SessionRequest", JSON.stringify(request));
    const {evmMessage, nearPayload, recoveryData} = await adapter.handleSessionRequest(request);
    console.log("signing request for\n", evmMessage);
    const signArgs = nearPayload.actions[0].params.args as SignArgs;
    const nearSig = await adapter.mpcContract.requestSignature(signArgs);
    const result = await adapter.recoverSignature(recoveryData, nearSig);
    web3wallet.respondSessionRequest({
      topic: request.topic,
      response: {
        id: request.id,
        jsonrpc: "2.0",
        result
      }
    });
  };

@bh2smith bh2smith marked this pull request as ready for review May 15, 2024 12:58
@bh2smith bh2smith merged commit 4c98911 into main May 15, 2024
2 checks passed
@bh2smith bh2smith deleted the recoverSignature branch May 15, 2024 13:00
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

Successfully merging this pull request may close these issues.

1 participant