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

Wallet Connect Session Request Handler #34

Merged
merged 7 commits into from
May 13, 2024
Merged

Wallet Connect Session Request Handler #34

merged 7 commits into from
May 13, 2024

Conversation

bh2smith
Copy link
Collaborator

@bh2smith bh2smith commented May 7, 2024

This PR, when merged, should minimally meet expectations to close #33. We introduce a method wcRouter that builds relevant byte array payload to for Near MPC contract to sign. It handles all immediately apparent request types (eth_sign, personal_sign, eth_sendTransaction, eth_signTypedData and eth_signTypedData_v4).

Vague Example Usage

From a browser wallet with adapter instance connected to a dapp via Wallet Connect:

Given:

adapter: NearEthAdapter;
request: Web3WalletTypes.SessionRequest;
const { evmMessage, nearPayload } = await adapter.handleSessionRequest(request);

console.log(`Request to sign EVM data ${evmMessage} via MPC Contract` );
console.log(`Payload to sign ${nearPayload}`);

// Execute the near transaction and get the hash
const evmSignature = signatureFromTxHash(nearTxHash);

Note:

  1. The evmSignature is still in a form that no front end should have to deal with. More refined signature recovery will be introduced in a follow-up PR.
  2. Might also be nice to provide validation of the (evmMessage, nearPayload) pairing construction.

Test Plan

Unit tests are added for each of the supported handler routes.

cc @SurgeCode

@bh2smith bh2smith changed the base branch from main to quick-refactor May 8, 2024 12:29
@bh2smith bh2smith requested a review from tifrel May 8, 2024 12:49
@bh2smith bh2smith changed the title Wallet Connect SessionRequest Interface Wallet Connect Session Request Handler May 8, 2024
@bh2smith bh2smith marked this pull request as ready for review May 8, 2024 12:53
Base automatically changed from quick-refactor to main May 8, 2024 13:05
@bh2smith bh2smith mentioned this pull request May 8, 2024
@bh2smith bh2smith added the alpha label May 13, 2024
@bh2smith bh2smith merged commit 09b7e00 into main May 13, 2024
1 check passed
@bh2smith bh2smith deleted the 33/wallet-connect branch May 13, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle Wallet Connect session_requests
1 participant