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

chore(Error): add error wrapper for wallet rpc error code #374

Merged
merged 4 commits into from
Oct 9, 2024

Conversation

stanleyyconsensys
Copy link
Collaborator

@stanleyyconsensys stanleyyconsensys commented Oct 9, 2024

This PR is to add an error wrapper to integrate the error code from 'get-starknet' wallet rpc error

To avoid breaking any existing error format/type
we extends the current snap error and create a error wrapper walletRpcError by using the data field from the SnapError Constructor

Example of an error object return to the Snap Consumer

{
    "code": 4001,
    "message": "User rejected the request.",
    "data": {
// Error wrapper
        "walletRpcError": {
// 'get-starknet' wallet rpc error code
            "code": 113
        }
    }
}

for now we have implement above format into

  • UserRejectedOpError // Error that extends UserRejectedRequestError
  • InvalidRequestParamsError // Error that extends InvalidParamsError
  • UnknownError // Error that extends SnapError
  • InvalidNetworkError // when network switch to a unknown error

BEGIN_COMMIT_OVERRIDE
feat: Add custom error code to meet get-starknet v4 exception format (#374)
END_COMMIT_OVERRIDE

@stanleyyconsensys stanleyyconsensys requested a review from a team as a code owner October 9, 2024 08:50
@stanleyyconsensys stanleyyconsensys requested review from Akaryatrh and wantedsystem and removed request for a team October 9, 2024 08:50
@stanleyyconsensys stanleyyconsensys changed the title chore(Error): add error wrapper chore(Error): add error wrapper for wallet rpc error code Oct 9, 2024
Copy link
Collaborator

@khanti42 khanti42 left a comment

Choose a reason for hiding this comment

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

nit comment

packages/starknet-snap/src/index.ts Outdated Show resolved Hide resolved
packages/starknet-snap/src/rpcs/displayPrivateKey.test.ts Outdated Show resolved Hide resolved
Copy link

sonarqubecloud bot commented Oct 9, 2024

Quality Gate Passed Quality Gate passed for 'consensys_starknet-snap-wallet-ui'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

sonarqubecloud bot commented Oct 9, 2024

Quality Gate Passed Quality Gate passed for 'consensys_starknet-snap-starknet-snap'

Issues
5 New issues
0 Accepted issues

Measures
0 Security Hotspots
30.2% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@stanleyyconsensys stanleyyconsensys added this pull request to the merge queue Oct 9, 2024
Merged via the queue into main with commit e61eb8b Oct 9, 2024
14 checks passed
@stanleyyconsensys stanleyyconsensys deleted the chore/add-snap-error-wrapper branch October 9, 2024 10:47
@github-actions github-actions bot mentioned this pull request Oct 28, 2024
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.

2 participants