Skip to content

Jl/caip multichain/verify scope method#25589

Merged
adonesky1 merged 7 commits intojl/mmp-2360/caip-25-pocfrom
jl/caip-multichain/verify-scope-method
Jun 29, 2024
Merged

Jl/caip multichain/verify scope method#25589
adonesky1 merged 7 commits intojl/mmp-2360/caip-25-pocfrom
jl/caip-multichain/verify-scope-method

Conversation

@jiexi
Copy link
Copy Markdown
Member

@jiexi jiexi commented Jun 28, 2024

Description

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@jiexi jiexi requested review from adonesky1 and shanejonas June 28, 2024 19:49
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-wallet-api-platform-deprecated DEPRECATED: please use "team-wallet-integrations" instead label Jun 28, 2024
}

const chainId = scope.split(':')[1];
// TODO: consider case when scope is defined in requireScopes and optionalScopes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙄 💯

return false;
};

export const flattenScope = (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just add a jsdoc or comment indicating the formatting case (linking to CAIP-25) this is handling?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added here 936858a

if (!chainId) {
return end(new Error('missing chainId'));
if (!scopeObject.methods.includes(wrappedRequest.method)) {
return end(new Error('unauthorized (method missing in scopeObject)'));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return end(new Error('unauthorized (method missing in scopeObject)'));
return end(new Error('unauthorized (method not authorized)'));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were going to come back and decide on proper error codes and messages at a later point haha

Comment on lines +37 to +38
// Do we need to try catch this?
const { reference } = parseCaipChainId(scope);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes for sure, unless we're validating the CAIP-2 scope somewhere above?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh dumb question. When i wrote this i was thinking it wasn't coming from the request for some reason

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved here 3c687d8

@adonesky1 adonesky1 marked this pull request as ready for review June 29, 2024 01:41
@adonesky1 adonesky1 requested a review from a team as a code owner June 29, 2024 01:41
@adonesky1 adonesky1 merged commit afa3153 into jl/mmp-2360/caip-25-poc Jun 29, 2024
@adonesky1 adonesky1 deleted the jl/caip-multichain/verify-scope-method branch June 29, 2024 01:41
@github-actions github-actions bot locked and limited conversation to collaborators Jun 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

team-wallet-api-platform-deprecated DEPRECATED: please use "team-wallet-integrations" instead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants