├── .editorconfig ├── .github ├── CODEOWNERS └── workflows │ ├── build-test.yml │ ├── create-release-pr.yml │ ├── publish-docs.yml │ ├── publish-release.yml │ └── security-code-scanner.yml ├── .gitignore ├── .nvmrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── RELEASING.md ├── jest.config.js ├── merge-openrpc.js ├── merge-utils.js ├── multichain └── openrpc.yaml ├── nodemon.json ├── openrpc.yaml ├── package.json ├── scripts ├── get.sh ├── prepack.sh ├── show-changelog.awk └── update-package-version.js ├── src └── index.ts ├── tests ├── index.test.ts └── merge-utils.test.ts ├── tsconfig.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | indent_style = space 9 | indent_size = 2 10 | tab_width = 2 11 | end_of_line = lf 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Lines starting with '#' are comments. 2 | # Each line is a file pattern followed by one or more owners. 3 | 4 | * @MetaMask/wallet-api-platform-engineers @MetaMask/tech-writers -------------------------------------------------------------------------------- /.github/workflows/build-test.yml: -------------------------------------------------------------------------------- 1 | name: Build and Test 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | 8 | jobs: 9 | build-test: 10 | name: Build and Test 11 | runs-on: ubuntu-latest 12 | strategy: 13 | matrix: 14 | node-version: [18.x, 20.x, 22.x] 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Use Node.js ${{ matrix.node-version }} 18 | uses: actions/setup-node@v1 19 | with: 20 | node-version: ${{ matrix.node-version }} 21 | - run: yarn 22 | - run: yarn build 23 | - run: yarn test 24 | all-jobs-pass: 25 | name: All jobs pass 26 | runs-on: ubuntu-latest 27 | needs: 28 | - build-test 29 | steps: 30 | - uses: actions/checkout@v2 31 | -------------------------------------------------------------------------------- /.github/workflows/create-release-pr.yml: -------------------------------------------------------------------------------- 1 | name: Create Release Pull Request 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | base-branch: 7 | description: 'The base branch for git operations and the pull request.' 8 | default: 'main' 9 | required: true 10 | release-type: 11 | description: 'A SemVer version diff, i.e. major, minor, patch, prerelease etc. Mutually exclusive with "release-version".' 12 | required: false 13 | release-version: 14 | description: 'A specific version to bump to. Mutually exclusive with "release-type".' 15 | required: false 16 | 17 | jobs: 18 | create-release-pr: 19 | runs-on: ubuntu-latest 20 | permissions: 21 | contents: write 22 | pull-requests: write 23 | steps: 24 | - uses: actions/checkout@v2 25 | with: 26 | # This is to guarantee that the most recent tag is fetched. 27 | # This can be configured to a more reasonable value by consumers. 28 | fetch-depth: 0 29 | # We check out the specified branch, which will be used as the base 30 | # branch for all git operations and the release PR. 31 | ref: ${{ github.event.inputs.base-branch }} 32 | - name: Get Node.js version 33 | id: nvm 34 | run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) 35 | - uses: actions/setup-node@v2 36 | with: 37 | node-version: ${{ steps.nvm.outputs.NODE_VERSION }} 38 | - uses: MetaMask/action-create-release-pr@v1 39 | env: 40 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 41 | with: 42 | release-type: ${{ github.event.inputs.release-type }} 43 | release-version: ${{ github.event.inputs.release-version }} 44 | -------------------------------------------------------------------------------- /.github/workflows/publish-docs.yml: -------------------------------------------------------------------------------- 1 | name: Publish docs to GitHub Pages 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | destination_dir: 7 | required: true 8 | type: string 9 | secrets: 10 | PUBLISH_DOCS_TOKEN: 11 | required: true 12 | 13 | jobs: 14 | publish-docs-to-gh-pages: 15 | name: Publish docs to GitHub Pages 16 | runs-on: ubuntu-latest 17 | environment: github-pages 18 | permissions: 19 | contents: write 20 | steps: 21 | - name: Ensure `destination_dir` is not empty 22 | if: ${{ inputs.destination_dir == '' }} 23 | run: exit 1 24 | - name: Checkout the repository 25 | uses: actions/checkout@v4 26 | - name: Use Node.js 27 | uses: actions/setup-node@v4 28 | with: 29 | node-version-file: '.nvmrc' 30 | cache: 'yarn' 31 | - uses: actions/cache@v3 32 | id: restore-build 33 | with: 34 | path: | 35 | ./dist 36 | ./node_modules/.yarn-state.yml 37 | key: ${{ github.sha }} 38 | - name: Deploy to `${{ inputs.destination_dir }}` directory of `gh-pages` branch 39 | uses: peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935 40 | with: 41 | # This `PUBLISH_DOCS_TOKEN` needs to be manually set per-repository. 42 | # Look in the repository settings under "Environments", and set this token in the `github-pages` environment. 43 | personal_token: ${{ secrets.PUBLISH_DOCS_TOKEN }} 44 | publish_dir: dist/build 45 | destination_dir: ${{ inputs.destination_dir }} 46 | -------------------------------------------------------------------------------- /.github/workflows/publish-release.yml: -------------------------------------------------------------------------------- 1 | name: Publish Release 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | 7 | jobs: 8 | is-release: 9 | # Filtering by `push` events ensures that we only release from the `main` branch, which is a 10 | # requirement for our npm publishing environment. 11 | # The commit author should always be 'github-actions' for releases created by the 12 | # 'create-release-pr' workflow, so we filter by that as well to prevent accidentally 13 | # triggering a release. 14 | if: github.event_name == 'push' && startsWith(github.event.head_commit.author.name, 'github-actions') 15 | outputs: 16 | IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }} 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: MetaMask/action-is-release@v1 20 | id: is-release 21 | publish-release: 22 | permissions: 23 | contents: write 24 | needs: is-release 25 | if: needs.is-release.outputs.IS_RELEASE == 'true' 26 | runs-on: ubuntu-latest 27 | steps: 28 | - uses: actions/checkout@v4 29 | with: 30 | ref: ${{ github.sha }} 31 | - name: Setup Node.js 32 | uses: actions/setup-node@v4 33 | with: 34 | node-version-file: ".nvmrc" 35 | - uses: MetaMask/action-publish-release@v3 36 | env: 37 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 38 | - name: Install 39 | run: | 40 | yarn install 41 | yarn build 42 | - uses: actions/cache@v3 43 | id: restore-build 44 | with: 45 | path: | 46 | ./dist 47 | ./node_modules/.yarn-state.yml 48 | key: ${{ github.sha }} 49 | publish-npm-dry-run: 50 | runs-on: ubuntu-latest 51 | needs: publish-release 52 | steps: 53 | - uses: actions/checkout@v4 54 | with: 55 | ref: ${{ github.sha }} 56 | - uses: actions/cache@v3 57 | id: restore-build 58 | with: 59 | path: | 60 | ./dist 61 | ./node_modules/.yarn-state.yml 62 | key: ${{ github.sha }} 63 | - name: Dry Run Publish 64 | # omit npm-token token to perform dry run publish 65 | uses: MetaMask/action-npm-publish@v1 66 | env: 67 | SKIP_PREPACK: true 68 | publish-npm: 69 | environment: npm-publish 70 | runs-on: ubuntu-latest 71 | needs: publish-npm-dry-run 72 | steps: 73 | - uses: actions/checkout@v4 74 | with: 75 | ref: ${{ github.sha }} 76 | - uses: actions/cache@v3 77 | id: restore-build 78 | with: 79 | path: | 80 | ./dist 81 | ./node_modules/.yarn-state.yml 82 | key: ${{ github.sha }} 83 | - name: Publish 84 | uses: MetaMask/action-npm-publish@v1 85 | with: 86 | # This `NPM_TOKEN` needs to be manually set per-repository. 87 | # Look in the repository settings under "Environments", and set this token in the `npm-publish` environment. 88 | npm-token: ${{ secrets.NPM_TOKEN }} 89 | env: 90 | SKIP_PREPACK: true 91 | get-release-version: 92 | runs-on: ubuntu-latest 93 | needs: publish-npm 94 | outputs: 95 | RELEASE_VERSION: ${{ steps.get-release-version.outputs.RELEASE_VERSION }} 96 | steps: 97 | - uses: actions/checkout@v4 98 | with: 99 | ref: ${{ github.sha }} 100 | - id: get-release-version 101 | shell: bash 102 | run: ./scripts/get.sh ".version" "RELEASE_VERSION" 103 | publish-release-to-gh-pages: 104 | needs: get-release-version 105 | name: Publish docs to `${{ needs.get-release-version.outputs.RELEASE_VERSION }}` directory of `gh-pages` branch 106 | permissions: 107 | contents: write 108 | uses: ./.github/workflows/publish-docs.yml 109 | with: 110 | destination_dir: ${{ needs.get-release-version.outputs.RELEASE_VERSION }} 111 | secrets: 112 | PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }} 113 | publish-release-to-latest-gh-pages: 114 | needs: publish-npm 115 | name: Publish docs to `latest` directory of `gh-pages` branch 116 | permissions: 117 | contents: write 118 | uses: ./.github/workflows/publish-docs.yml 119 | with: 120 | destination_dir: latest 121 | secrets: 122 | PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }} 123 | -------------------------------------------------------------------------------- /.github/workflows/security-code-scanner.yml: -------------------------------------------------------------------------------- 1 | name: MetaMask Security Code Scanner 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | workflow_dispatch: 11 | 12 | jobs: 13 | run-security-scan: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | actions: read 17 | contents: read 18 | security-events: write 19 | steps: 20 | - name: MetaMask Security Code Scanner 21 | uses: MetaMask/Security-Code-Scanner@main 22 | with: 23 | repo: ${{ github.repository }} 24 | paths_ignored: | 25 | .storybook/ 26 | '**/__snapshots__/' 27 | '**/*.snap' 28 | '**/*.stories.js' 29 | '**/*.stories.tsx' 30 | '**/*.test.browser.ts*' 31 | '**/*.test.js*' 32 | '**/*.test.ts*' 33 | '**/fixtures/' 34 | '**/jest.config.js' 35 | '**/jest.environment.js' 36 | '**/mocks/' 37 | '**/test*/' 38 | docs/ 39 | e2e/ 40 | merged-packages/ 41 | node_modules 42 | storybook/ 43 | test*/ 44 | rules_excluded: example 45 | project_metrics_token: ${{ secrets.SECURITY_SCAN_METRICS_TOKEN }} 46 | slack_webhook: ${{ secrets.APPSEC_BOT_SLACK_WEBHOOK }} 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build 3 | dist 4 | *.tgz 5 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | lts/* 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [Unreleased] 8 | 9 | ## [0.14.0] 10 | ### Added 11 | - Add EIP-5792 methods: `wallet_sendCalls`, `wallet_getCallsStatus`, `wallet_getCapabilities` ([#284](https://github.com/MetaMask/api-specs/pull/284)) 12 | 13 | ## [0.13.0] 14 | ### Changed 15 | - Add `wallet_createSessionUnsupportedScopesExample` to the multichain spec, given a new error we throw in the wallet_createSession handler when all requested scopes are not supported ([#300](https://github.com/MetaMask/api-specs/pull/300)) 16 | 17 | ## [0.12.0] 18 | ### Changed 19 | - **BREAKING:** Add empty sessionProperties values as expected return from wallet_createSession ([#297](https://github.com/MetaMask/api-specs/pull/297)) 20 | - Bump minimum Node version to v18.20 ([#294](https://github.com/MetaMask/api-specs/pull/294)) 21 | 22 | ## [0.11.0] 23 | ### Removed 24 | - **BREAKING:** Remove `wallet_swapAsset` ([#289](https://github.com/MetaMask/api-specs/pull/289)) 25 | - This is not quite ready for primetime. 26 | 27 | ## [0.10.17] 28 | ### Changed 29 | - modify ordering of methods in `sessionScopes` to satisfy strict API specs testing requirements ([#287](https://github.com/MetaMask/api-specs/pull/287)) 30 | 31 | ## [0.10.16] 32 | ### Changed 33 | - Remove `sessionProperties`, switch `requiredScopes` to `optionalScopes`, and move methods to correct scopes in multichain spec examples ([#285](https://github.com/MetaMask/api-specs/pull/285)) 34 | 35 | ### Fixed 36 | - Fix spec for doc rendering ([#282](https://github.com/MetaMask/api-specs/pull/282)) 37 | 38 | ## [0.10.15] 39 | ### Uncategorized 40 | - Fix wallet_createSessionUnsupportedScopesExample results value [#281](https://github.com/MetaMask/api-specs/pull/281)) 41 | 42 | ## [0.10.14] 43 | ### Uncategorized 44 | - Update `wallet_createSession` examples ([#279](https://github.com/MetaMask/api-specs/pull/279)) 45 | - Fix spec for doc rendering (Part 1) ([#277](https://github.com/MetaMask/api-specs/pull/277)) 46 | - Add `wallet_swapAsset` ([#201](https://github.com/MetaMask/api-specs/pull/201)) 47 | 48 | ## [0.10.13] 49 | ### Uncategorized 50 | - Add multichain tag ([#275](https://github.com/MetaMask/api-specs/pull/275)) 51 | 52 | ## [0.10.12] 53 | ### Uncategorized 54 | - Added wallet_notify + remove everything sessionId related ([#272](https://github.com/MetaMask/api-specs/pull/272)) 55 | - Added sessionChanged ([#271](https://github.com/MetaMask/api-specs/pull/271)) 56 | - Added revokeSession + add description to getSession ([#270](https://github.com/MetaMask/api-specs/pull/270)) 57 | - Added getSession ([#269](https://github.com/MetaMask/api-specs/pull/269)) 58 | 59 | ## [0.10.11] 60 | ### Uncategorized 61 | - fix: update eth spec version to latest ([#267](https://github.com/MetaMask/api-specs/pull/267)) 62 | - Update `README.md` ([#251](https://github.com/MetaMask/api-specs/pull/251)) 63 | 64 | ## [0.10.10] 65 | ### Uncategorized 66 | - fix: rename multichain methods ([#264](https://github.com/MetaMask/api-specs/pull/264)) 67 | 68 | ## [0.10.9] 69 | ### Uncategorized 70 | - Update execution-apis reference ([#262](https://github.com/MetaMask/api-specs/pull/262)) 71 | 72 | ## [0.10.8] 73 | ### Uncategorized 74 | - Remove 5203 and 5204 from provider_authorize ([#260](https://github.com/MetaMask/api-specs/pull/260)) 75 | 76 | ## [0.10.7] 77 | ### Uncategorized 78 | - fix: remove unused multichain error codes ([#258](https://github.com/MetaMask/api-specs/pull/258)) 79 | 80 | ## [0.10.6] 81 | ### Uncategorized 82 | - fix: error codes for caip-25 ([#255](https://github.com/MetaMask/api-specs/pull/255)) 83 | - Filter out eth_blobBaseFee ([#254](https://github.com/MetaMask/api-specs/pull/254)) 84 | - fix: filter unsupported methods ([#249](https://github.com/MetaMask/api-specs/pull/249)) 85 | 86 | ## [0.10.5] 87 | ### Uncategorized 88 | - Fix TypedData schema ([#252](https://github.com/MetaMask/api-specs/pull/252)) 89 | - fix: remove unsupported filter types ([#250](https://github.com/MetaMask/api-specs/pull/250)) 90 | 91 | ## [0.10.4] 92 | ### Uncategorized 93 | - update wallet_scanQRCode and eth_decrypt ([#247](https://github.com/MetaMask/api-specs/pull/247)) 94 | 95 | ## [0.10.3] 96 | ### Uncategorized 97 | - Format wallet_getPermission properly ([#232](https://github.com/MetaMask/api-specs/pull/232)) 98 | - fix: personal_sign is 65 bytes long (not 129 bytes) ([#244](https://github.com/MetaMask/api-specs/pull/244)) 99 | - added some fixes to the schema ([#245](https://github.com/MetaMask/api-specs/pull/245)) 100 | 101 | ## [0.10.2] 102 | ### Uncategorized 103 | - fix: provider_authorize scopes ([#242](https://github.com/MetaMask/api-specs/pull/242)) 104 | - fix: change scope to scope string ([#240](https://github.com/MetaMask/api-specs/pull/240)) 105 | 106 | ## [0.10.1] 107 | ### Uncategorized 108 | - fix: add caip-27 + fix strings in yaml for multichain ([#238](https://github.com/MetaMask/api-specs/pull/238)) 109 | 110 | ## [0.10.0] 111 | ### Uncategorized 112 | - Added Transport OpenRPC Document for the MultiChain API ([#236](https://github.com/MetaMask/api-specs/pull/236)) 113 | 114 | ## [0.9.3] 115 | ### Uncategorized 116 | - Fixed npm publish via downgrading action ([#229](https://github.com/MetaMask/api-specs/pull/229)) 117 | - Fixed prepack script ([#228](https://github.com/MetaMask/api-specs/pull/228)) 118 | 119 | ## [0.9.2] 120 | ### Uncategorized 121 | - Fixed publish release to be on main branch instead ([#226](https://github.com/MetaMask/api-specs/pull/226)) 122 | 123 | ## [0.9.1] 124 | ### Uncategorized 125 | - Add npm publish to gh actions workflow ([#224](https://github.com/MetaMask/api-specs/pull/224)) 126 | 127 | ## [0.9.0] 128 | ### Uncategorized 129 | - Fixed execution-apis spec version to specific commit + added API Reference docs to README ([#222](https://github.com/MetaMask/api-specs/pull/222)) 130 | - remove Snaps methods ([#218](https://github.com/MetaMask/api-specs/pull/218)) 131 | 132 | ## [0.8.4] 133 | ### Uncategorized 134 | - Fix eth_requestAccounts example ([#219](https://github.com/MetaMask/api-specs/pull/219)) 135 | 136 | ## [0.8.3] 137 | ### Uncategorized 138 | - Fixed eth_accounts example params ([#216](https://github.com/MetaMask/api-specs/pull/216)) 139 | 140 | ## [0.8.2] 141 | ### Uncategorized 142 | - small typo correction ([#213](https://github.com/MetaMask/api-specs/pull/213)) 143 | - remove files throwing erros ([#211](https://github.com/MetaMask/api-specs/pull/211)) 144 | 145 | ## [0.8.1] 146 | ### Uncategorized 147 | - Convert native currency decimal properties non-negative min property to minimum ([#200](https://github.com/MetaMask/api-specs/pull/200)) 148 | - Add examples ([#207](https://github.com/MetaMask/api-specs/pull/207)) 149 | - Update restricted text ([#202](https://github.com/MetaMask/api-specs/pull/202)) 150 | 151 | ## [0.8.0] 152 | ### Uncategorized 153 | - Update method tags ([#195](https://github.com/MetaMask/api-specs/pull/195)) 154 | - Adjust iconUrls param description ([#196](https://github.com/MetaMask/api-specs/pull/196)) 155 | - Enabling MetaMask security code scanner ([#188](https://github.com/MetaMask/api-specs/pull/188)) 156 | - Remove duplicates ([#194](https://github.com/MetaMask/api-specs/pull/194)) 157 | - Update nodemon.json to openrpc.yaml ([#192](https://github.com/MetaMask/api-specs/pull/192)) 158 | - Update README.md to use openrpc.yaml ([#191](https://github.com/MetaMask/api-specs/pull/191)) 159 | 160 | ## [0.7.0] 161 | ### Uncategorized 162 | - Added yaml conversion to build and converted current json doc to yaml ([#189](https://github.com/MetaMask/api-specs/pull/189)) 163 | - Reorder and order MetaMask API entries ([#187](https://github.com/MetaMask/api-specs/pull/187)) 164 | 165 | ## [0.6.2] 166 | ### Uncategorized 167 | - Update description (for docs index page) ([#185](https://github.com/MetaMask/api-specs/pull/185)) 168 | 169 | ## [0.6.1] 170 | ### Uncategorized 171 | - added snapid + request schemas ([#183](https://github.com/MetaMask/api-specs/pull/183)) 172 | 173 | ## [0.6.0] 174 | ### Uncategorized 175 | - Document Snap `wallet_*` methods ([#181](https://github.com/MetaMask/api-specs/pull/181)) 176 | - more addEthereumChain spec fixes ([#180](https://github.com/MetaMask/api-specs/pull/180)) 177 | - Add info to revokePermissions description ([#178](https://github.com/MetaMask/api-specs/pull/178)) 178 | 179 | ## [0.5.0] 180 | ### Uncategorized 181 | - Fix `wallet_addEthereumChain` request ([#174](https://github.com/MetaMask/api-specs/pull/174)) 182 | - Changed revokePermissions result type to be null ([#176](https://github.com/MetaMask/api-specs/pull/176)) 183 | - Add deprecation label to decryption methods ([#175](https://github.com/MetaMask/api-specs/pull/175)) 184 | - Wallet revoke permissions ([#145](https://github.com/MetaMask/api-specs/pull/145)) 185 | 186 | ## [0.4.4] 187 | ### Uncategorized 188 | - Add description for index page ([#172](https://github.com/MetaMask/api-specs/pull/172)) 189 | 190 | ## [0.4.3] 191 | ### Uncategorized 192 | - Added web3_clientVersion ([#164](https://github.com/MetaMask/api-specs/pull/164)) 193 | - build(deps): bump @babel/traverse from 7.20.13 to 7.23.2 ([#170](https://github.com/MetaMask/api-specs/pull/170)) 194 | - Edit descriptions ([#166](https://github.com/MetaMask/api-specs/pull/166)) 195 | - Doc wallet_scanQRCode ([#167](https://github.com/MetaMask/api-specs/pull/167)) 196 | 197 | ## [0.4.2] 198 | ### Uncategorized 199 | - Added eth_requestAccounts ([#163](https://github.com/MetaMask/api-specs/pull/163)) 200 | - add new wallet_watchAsset error ([#162](https://github.com/MetaMask/api-specs/pull/162)) 201 | - MIP-1 proposed watch asset changes ([#138](https://github.com/MetaMask/api-specs/pull/138)) 202 | 203 | ## [0.4.1] 204 | ### Uncategorized 205 | - Fixed permission caveat value + added descriptions ([#160](https://github.com/MetaMask/api-specs/pull/160)) 206 | 207 | ## [0.4.0] 208 | ### Uncategorized 209 | - Added custom sendTransaction since we don't support accessList just yet ([#158](https://github.com/MetaMask/api-specs/pull/158)) 210 | 211 | ## [0.3.1] 212 | ### Uncategorized 213 | - Fixed schema to better render in the docs side + removed createAccessList ([#156](https://github.com/MetaMask/api-specs/pull/156)) 214 | 215 | ## [0.3.0] 216 | ### Uncategorized 217 | - Update README.md ([#141](https://github.com/MetaMask/api-specs/pull/141)) 218 | - Fixed watchAsset example image url ([#142](https://github.com/MetaMask/api-specs/pull/142)) 219 | - fix duplicate methods in built result ([#143](https://github.com/MetaMask/api-specs/pull/143)) 220 | - add link to latest build in readme ([#132](https://github.com/MetaMask/api-specs/pull/132)) 221 | - update broken rpcURL for addEthereumChain ([#135](https://github.com/MetaMask/api-specs/pull/135)) 222 | - Added a watch command to rebuild on change ([#139](https://github.com/MetaMask/api-specs/pull/139)) 223 | - update wallet_watchAsset description to acknowledge the divergence between EIP-747 and our implementation ([#137](https://github.com/MetaMask/api-specs/pull/137)) 224 | 225 | ## [0.2.1] 226 | ### Uncategorized 227 | - Update merge-openrpc.js ([#130](https://github.com/MetaMask/api-specs/pull/130)) 228 | 229 | ## [0.2.0] 230 | ### Added 231 | - specs for eth_subscribe and eth_unsubscribe ([#127](https://github.com/MetaMask/api-specs/pull/127)) 232 | - add eth_signTypedData_v4 ([#123](https://github.com/MetaMask/api-specs/pull/123)) 233 | 234 | ### Changed 235 | - API docs descriptions ([#125](https://github.com/MetaMask/api-specs/pull/125)) 236 | 237 | ## [0.1.0] 238 | ### Changed 239 | - Removed unused files ([#115](https://github.com/MetaMask/api-specs/pull/115)) 240 | - Changed OpenRPC Document to be one file instead of many ([#114](https://github.com/MetaMask/api-specs/pull/114)) 241 | 242 | ## [0.0.39] 243 | ### Uncategorized 244 | - Fixed chain name for addEthereumChain example ([#109](https://github.com/MetaMask/api-specs/pull/109)) 245 | - Update metamask-openrpc.json ([#108](https://github.com/MetaMask/api-specs/pull/108)) 246 | - Update wallet_addEthereumChain errors ([#106](https://github.com/MetaMask/api-specs/pull/106)) 247 | - Changed wallet_watchAsset description to 11 characters ([#105](https://github.com/MetaMask/api-specs/pull/105)) 248 | 249 | ## [0.0.38] 250 | ### Fixed 251 | - xdai chain pointing to dead url ([#102](https://github.com/MetaMask/api-specs/pull/102)) 252 | 253 | ## [0.0.37] 254 | ### Added 255 | - yarn build to gh pages publish step ([#99](https://github.com/MetaMask/api-specs/pull/99)) 256 | 257 | ## [0.0.36] 258 | ### Fixed 259 | - hash pointer for gh-pages action ([#97](https://github.com/MetaMask/api-specs/pull/97)) 260 | 261 | ## [0.0.35] 262 | ### Fixed 263 | - Deploy for latest ([#95](https://github.com/MetaMask/api-specs/pull/95)) 264 | 265 | ## [0.0.34] 266 | ### Added 267 | - homepage to package.json ([#84](https://github.com/MetaMask/api-specs/pull/84)) 268 | 269 | ## [0.0.33] 270 | ### Changed 271 | - publish-release.yml ([#82](https://github.com/MetaMask/api-specs/pull/82)) 272 | 273 | ## [0.0.32] 274 | ### Fixed 275 | - automated build release branch ([#80](https://github.com/MetaMask/api-specs/pull/80)) 276 | 277 | ## [0.0.31] 278 | ### Added 279 | - link to encoding example to `personal_sign` ([#77](https://github.com/MetaMask/api-specs/pull/77)) 280 | - extra publish steps for gh-pages ([#78](https://github.com/MetaMask/api-specs/pull/78)) 281 | 282 | ## [0.0.30] 283 | ### Added 284 | - `personal_sign` ([#74](https://github.com/MetaMask/api-specs/pull/74)) 285 | 286 | ## [0.0.29] 287 | ### Added 288 | - add ethereum chain to openrpc document ([#71](https://github.com/MetaMask/api-specs/pull/71)) 289 | 290 | ## [0.0.28] 291 | ### Added 292 | - feat: add wallet_switchEthereumChain ([#66](https://github.com/MetaMask/api-specs/pull/66)) 293 | 294 | ### Changed 295 | - build(deps): bump ws from 7.4.4 to 7.5.0 ([#67](https://github.com/MetaMask/api-specs/pull/67)) 296 | 297 | ### Fixed 298 | - Fix release automation compatibility ([#69](https://github.com/MetaMask/api-specs/pull/69)) 299 | 300 | [Unreleased]: https://github.com/MetaMask/api-specs/compare/v0.14.0...HEAD 301 | [0.14.0]: https://github.com/MetaMask/api-specs/compare/v0.13.0...v0.14.0 302 | [0.13.0]: https://github.com/MetaMask/api-specs/compare/v0.12.0...v0.13.0 303 | [0.12.0]: https://github.com/MetaMask/api-specs/compare/v0.11.0...v0.12.0 304 | [0.11.0]: https://github.com/MetaMask/api-specs/compare/v0.10.17...v0.11.0 305 | [0.10.17]: https://github.com/MetaMask/api-specs/compare/v0.10.16...v0.10.17 306 | [0.10.16]: https://github.com/MetaMask/api-specs/compare/v0.10.15...v0.10.16 307 | [0.10.15]: https://github.com/MetaMask/api-specs/compare/v0.10.14...v0.10.15 308 | [0.10.14]: https://github.com/MetaMask/api-specs/compare/v0.10.13...v0.10.14 309 | [0.10.13]: https://github.com/MetaMask/api-specs/compare/v0.10.12...v0.10.13 310 | [0.10.12]: https://github.com/MetaMask/api-specs/compare/v0.10.11...v0.10.12 311 | [0.10.11]: https://github.com/MetaMask/api-specs/compare/v0.10.10...v0.10.11 312 | [0.10.10]: https://github.com/MetaMask/api-specs/compare/v0.10.9...v0.10.10 313 | [0.10.9]: https://github.com/MetaMask/api-specs/compare/v0.10.8...v0.10.9 314 | [0.10.8]: https://github.com/MetaMask/api-specs/compare/v0.10.7...v0.10.8 315 | [0.10.7]: https://github.com/MetaMask/api-specs/compare/v0.10.6...v0.10.7 316 | [0.10.6]: https://github.com/MetaMask/api-specs/compare/v0.10.5...v0.10.6 317 | [0.10.5]: https://github.com/MetaMask/api-specs/compare/v0.10.4...v0.10.5 318 | [0.10.4]: https://github.com/MetaMask/api-specs/compare/v0.10.3...v0.10.4 319 | [0.10.3]: https://github.com/MetaMask/api-specs/compare/v0.10.2...v0.10.3 320 | [0.10.2]: https://github.com/MetaMask/api-specs/compare/v0.10.1...v0.10.2 321 | [0.10.1]: https://github.com/MetaMask/api-specs/compare/v0.10.0...v0.10.1 322 | [0.10.0]: https://github.com/MetaMask/api-specs/compare/v0.9.3...v0.10.0 323 | [0.9.3]: https://github.com/MetaMask/api-specs/compare/v0.9.2...v0.9.3 324 | [0.9.2]: https://github.com/MetaMask/api-specs/compare/v0.9.1...v0.9.2 325 | [0.9.1]: https://github.com/MetaMask/api-specs/compare/v0.9.0...v0.9.1 326 | [0.9.0]: https://github.com/MetaMask/api-specs/compare/v0.8.4...v0.9.0 327 | [0.8.4]: https://github.com/MetaMask/api-specs/compare/v0.8.3...v0.8.4 328 | [0.8.3]: https://github.com/MetaMask/api-specs/compare/v0.8.2...v0.8.3 329 | [0.8.2]: https://github.com/MetaMask/api-specs/compare/v0.8.1...v0.8.2 330 | [0.8.1]: https://github.com/MetaMask/api-specs/compare/v0.8.0...v0.8.1 331 | [0.8.0]: https://github.com/MetaMask/api-specs/compare/v0.7.0...v0.8.0 332 | [0.7.0]: https://github.com/MetaMask/api-specs/compare/v0.6.2...v0.7.0 333 | [0.6.2]: https://github.com/MetaMask/api-specs/compare/v0.6.1...v0.6.2 334 | [0.6.1]: https://github.com/MetaMask/api-specs/compare/v0.6.0...v0.6.1 335 | [0.6.0]: https://github.com/MetaMask/api-specs/compare/v0.5.0...v0.6.0 336 | [0.5.0]: https://github.com/MetaMask/api-specs/compare/v0.4.4...v0.5.0 337 | [0.4.4]: https://github.com/MetaMask/api-specs/compare/v0.4.3...v0.4.4 338 | [0.4.3]: https://github.com/MetaMask/api-specs/compare/v0.4.2...v0.4.3 339 | [0.4.2]: https://github.com/MetaMask/api-specs/compare/v0.4.1...v0.4.2 340 | [0.4.1]: https://github.com/MetaMask/api-specs/compare/v0.4.0...v0.4.1 341 | [0.4.0]: https://github.com/MetaMask/api-specs/compare/v0.3.1...v0.4.0 342 | [0.3.1]: https://github.com/MetaMask/api-specs/compare/v0.3.0...v0.3.1 343 | [0.3.0]: https://github.com/MetaMask/api-specs/compare/v0.2.1...v0.3.0 344 | [0.2.1]: https://github.com/MetaMask/api-specs/compare/v0.2.0...v0.2.1 345 | [0.2.0]: https://github.com/MetaMask/api-specs/compare/v0.1.0...v0.2.0 346 | [0.1.0]: https://github.com/MetaMask/api-specs/compare/v0.0.39...v0.1.0 347 | [0.0.39]: https://github.com/MetaMask/api-specs/compare/v0.0.38...v0.0.39 348 | [0.0.38]: https://github.com/MetaMask/api-specs/compare/v0.0.37...v0.0.38 349 | [0.0.37]: https://github.com/MetaMask/api-specs/compare/v0.0.36...v0.0.37 350 | [0.0.36]: https://github.com/MetaMask/api-specs/compare/v0.0.35...v0.0.36 351 | [0.0.35]: https://github.com/MetaMask/api-specs/compare/v0.0.34...v0.0.35 352 | [0.0.34]: https://github.com/MetaMask/api-specs/compare/v0.0.33...v0.0.34 353 | [0.0.33]: https://github.com/MetaMask/api-specs/compare/v0.0.32...v0.0.33 354 | [0.0.32]: https://github.com/MetaMask/api-specs/compare/v0.0.31...v0.0.32 355 | [0.0.31]: https://github.com/MetaMask/api-specs/compare/v0.0.30...v0.0.31 356 | [0.0.30]: https://github.com/MetaMask/api-specs/compare/v0.0.29...v0.0.30 357 | [0.0.29]: https://github.com/MetaMask/api-specs/compare/v0.0.28...v0.0.29 358 | [0.0.28]: https://github.com/MetaMask/api-specs/releases/tag/v0.0.28 359 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MetaMask Wallet API specification 2 | 3 | This repository contains the OpenRPC specification for MetaMask's Wallet JSON-RPC API. 4 | You can view the specs in the following formats: 5 | 6 | - [MetaMask developer docs interactive API reference](https://docs.metamask.io/wallet/reference/json-rpc-api/) 7 | - [OpenRPC playground](https://metamask.github.io/api-playground/api-documentation) 8 | - [Latest build](https://metamask.github.io/api-specs/latest/openrpc.json) 9 | 10 | [OpenRPC](https://open-rpc.org/) is way to specify JSON-RPC APIs that is versionable, 11 | human-readable, and machine-readable. 12 | It improves the accuracy of documentation, APIs, and clients. 13 | 14 | ## Contribute 15 | 16 | You can contribute to the API specs using the following steps. 17 | 18 | > **Note:** These steps are for updating the API specs. 19 | > To make a significant change to the API itself, please submit a 20 | > [MetaMask Improvement Proposal (MIP)](https://github.com/MetaMask/metamask-improvement-proposals/tree/main). 21 | 22 | 1. Edit the API specs in the `openrpc.yaml` file. 23 | See the [OpenRPC](https://open-rpc.org/) docs for more information on how to format the specs. 24 | 2. Run `yarn install` if you haven't previously set up the repository. 25 | 3. Run `yarn run build` to re-generate the output file: `dist/build/openrpc.json`. 26 | 4. To view the result, paste that file's contents into the 27 | [OpenRPC playground](https://playground.open-rpc.org/). 28 | 29 | For information about publishing changes to the interactive API reference in the MetaMask developer 30 | docs, see the 31 | [docs contribution guidelines](https://github.com/MetaMask/metamask-docs/blob/main/CONTRIBUTING.md#update-the-interactive-api-reference). 32 | 33 | ## Build process 34 | 35 | When you build the project, the following happens: 36 | 37 | 1. The MetaMask-specific API specs `openrpc.yaml` are loaded from the local file system. 38 | 2. The [Ethereum Execution API specs](https://github.com/ethereum/execution-apis) are 39 | fetched from a remote URL and methods not supported/implemented by MetaMask are filtered out. 40 | 3. The local MetaMask specs are merged with the Ethereum specs. 41 | 4. Each Ethereum method is tagged with the "Ethereum API" tag. 42 | 5. The merged and filtered specs are written out to temporary files: 43 | - `src/build/openrpc.json` 44 | - `src/build/multichain-openrpc.json` 45 | 6. These files are output to the `dist` folder and the `src/build` contents are deleted. 46 | 47 | ## Publishing process 48 | 49 | On release, the specs are published to npm at `@metamask/api-specs` and to 50 | [GitHub Pages](https://metamask.github.io/api-specs/latest/metamask-openrpc.json). 51 | 52 | For information about publishing to the interactive API reference in the MetaMask developer docs, 53 | see the 54 | [docs contribution guidelines](https://github.com/MetaMask/metamask-docs/blob/main/CONTRIBUTING.md#update-the-interactive-api-reference). 55 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | 2 | Creating a new release: 3 | 4 | This repository uses [Github Actions](https://docs.github.com/en/actions) to release. 5 | 6 | 1. Start on the `main` branch and on latest 7 | ``` 8 | git checkout main 9 | git pull origin main 10 | ``` 11 | 1. Create a branch with the correct name: `release-v${version}` 12 | 13 | ex: 14 | ``` 15 | git checkout -b release-v0.0.1 16 | ``` 17 | 18 | 1. Push the branch to origin 19 | 20 | ``` 21 | git push origin release-v0.0.1 22 | ``` 23 | 24 | 1. kicks off [.github/workflows/release-pr.yml](/.github/workflows/release-pr.yml) 25 | 1. A [Pull Request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests) should be created 26 | 1. Review pull request 27 | 1. Merge PR when ready to release 28 | 1. Release kicks off and runs [.github/workflows/release-merge.yml](/.github/workflows/release-merge.yml) 29 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * For a detailed explanation regarding each configuration property and type check, visit: 3 | * https://jestjs.io/docs/configuration 4 | */ 5 | 6 | module.exports = { 7 | // All imported modules in your tests should be mocked automatically 8 | // automock: false, 9 | 10 | // Stop running tests after `n` failures 11 | // bail: 0, 12 | 13 | // The directory where Jest should store its cached dependency information 14 | // cacheDirectory: "/private/var/folders/fk/c3y07g0576j8_2s9m01pk4qw0000gn/T/jest_dx", 15 | 16 | // Automatically clear mock calls, instances and results before every test. 17 | // This does not remove any mock implementation that may have been provided, 18 | // so we disable it. 19 | // clearMocks: true, 20 | 21 | // Indicates whether the coverage information should be collected while executing the test 22 | collectCoverage: false, 23 | 24 | // An array of glob patterns indicating a set of files for which coverage information should be collected 25 | // collectCoverageFrom: ['./src/**/*.ts'], 26 | 27 | // The directory where Jest should output its coverage files 28 | // coverageDirectory: 'coverage', 29 | 30 | // An array of regexp pattern strings used to skip coverage collection 31 | // coveragePathIgnorePatterns: [ 32 | // "/node_modules/" 33 | // ], 34 | 35 | // Indicates which provider should be used to instrument code for coverage 36 | // coverageProvider: 'babel', 37 | 38 | // A list of reporter names that Jest uses when writing coverage reports 39 | // coverageReporters: ['html', 'json-summary', 'text'], 40 | 41 | // An object that configures minimum threshold enforcement for coverage results 42 | // coverageThreshold: { 43 | // global: { 44 | // branches: 100, 45 | // functions: 100, 46 | // lines: 100, 47 | // statements: 100, 48 | // }, 49 | // }, 50 | 51 | // A path to a custom dependency extractor 52 | // dependencyExtractor: undefined, 53 | 54 | // Make calling deprecated APIs throw helpful error messages 55 | // errorOnDeprecated: false, 56 | 57 | // Force coverage collection from ignored files using an array of glob patterns 58 | // forceCoverageMatch: [], 59 | 60 | // A path to a module which exports an async function that is triggered once before all test suites 61 | // globalSetup: undefined, 62 | 63 | // A path to a module which exports an async function that is triggered once after all test suites 64 | // globalTeardown: undefined, 65 | 66 | // A set of global variables that need to be available in all test environments 67 | // globals: {}, 68 | 69 | // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. 70 | // maxWorkers: "50%", 71 | 72 | // An array of directory names to be searched recursively up from the requiring module's location 73 | // moduleDirectories: [ 74 | // "node_modules" 75 | // ], 76 | 77 | // An array of file extensions your modules use 78 | // moduleFileExtensions: [ 79 | // "js", 80 | // "jsx", 81 | // "ts", 82 | // "tsx", 83 | // "json", 84 | // "node" 85 | // ], 86 | 87 | // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module 88 | // moduleNameMapper: {}, 89 | 90 | // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader 91 | // modulePathIgnorePatterns: [], 92 | 93 | // Activates notifications for test results 94 | // notify: false, 95 | 96 | // An enum that specifies notification mode. Requires { notify: true } 97 | // notifyMode: "failure-change", 98 | 99 | // A preset that is used as a base for Jest's configuration 100 | preset: 'ts-jest', 101 | 102 | // Run tests from one or more projects 103 | // projects: undefined, 104 | 105 | // Use this configuration option to add custom reporters to Jest 106 | // reporters: undefined, 107 | 108 | // "resetMocks" resets all mocks, including mocked modules, to jest.fn(), 109 | // between each test case. 110 | resetMocks: true, 111 | 112 | // Reset the module registry before running each individual test 113 | // resetModules: false, 114 | 115 | // A path to a custom resolver 116 | // resolver: undefined, 117 | 118 | // "restoreMocks" restores all mocks created using jest.spyOn to their 119 | // original implementations, between each test. It does not affect mocked 120 | // modules. 121 | restoreMocks: true, 122 | 123 | // The root directory that Jest should scan for tests and modules within 124 | // rootDir: undefined, 125 | 126 | // A list of paths to directories that Jest should use to search for files in 127 | // roots: [ 128 | // "" 129 | // ], 130 | 131 | // Allows you to use a custom runner instead of Jest's default test runner 132 | // runner: "jest-runner", 133 | 134 | // The paths to modules that run some code to configure or set up the testing environment before each test 135 | // setupFiles: [], 136 | 137 | // A list of paths to modules that run some code to configure or set up the testing framework before each test 138 | // setupFilesAfterEnv: [], 139 | 140 | // The number of seconds after which a test is considered as slow and reported as such in the results. 141 | // slowTestThreshold: 5, 142 | 143 | // A list of paths to snapshot serializer modules Jest should use for snapshot testing 144 | // snapshotSerializers: [], 145 | 146 | // The test environment that will be used for testing 147 | // testEnvironment: "jest-environment-node", 148 | 149 | // Options that will be passed to the testEnvironment 150 | // testEnvironmentOptions: {}, 151 | 152 | // Adds a location field to test results 153 | // testLocationInResults: false, 154 | 155 | // The glob patterns Jest uses to detect test files 156 | // testMatch: [ 157 | // "**/__tests__/**/*.[jt]s?(x)", 158 | // "**/?(*.)+(spec|test).[tj]s?(x)" 159 | // ], 160 | 161 | // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped 162 | // testPathIgnorePatterns: [ 163 | // "/node_modules/" 164 | // ], 165 | 166 | // The regexp pattern or array of patterns that Jest uses to detect test files 167 | // testRegex: [], 168 | 169 | // This option allows the use of a custom results processor 170 | // testResultsProcessor: undefined, 171 | 172 | // This option allows use of a custom test runner 173 | // testRunner: "jest-circus/runner", 174 | 175 | // Reduce the default test timeout from 5s to 2.5s 176 | testTimeout: 2500, 177 | 178 | // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href 179 | // testURL: "http://localhost", 180 | 181 | // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" 182 | // timers: "real", 183 | 184 | // A map from regular expressions to paths to transformers 185 | // transform: undefined, 186 | 187 | // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation 188 | // transformIgnorePatterns: [ 189 | // "/node_modules/", 190 | // "\\.pnp\\.[^\\/]+$" 191 | // ], 192 | 193 | // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them 194 | // unmockedModulePathPatterns: undefined, 195 | 196 | // Indicates whether each individual test should be reported during the run 197 | // verbose: undefined, 198 | 199 | // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode 200 | // watchPathIgnorePatterns: [], 201 | 202 | // Whether to use watchman for file crawling 203 | // watchman: true, 204 | }; 205 | -------------------------------------------------------------------------------- /merge-openrpc.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const fetch = require("node-fetch"); 3 | const mergeOpenRPC = require("./merge-utils"); 4 | const yaml = require("js-yaml"); 5 | 6 | const MetaMaskOpenRPC = yaml.load(fs.readFileSync(__dirname + "/openrpc.yaml", "utf8")); 7 | const TransportOpenRPC = yaml.load(fs.readFileSync(__dirname + "/multichain/openrpc.yaml", "utf8")); 8 | 9 | const getFilteredExecutionAPIs = () => { 10 | return fetch("https://raw.githubusercontent.com/ethereum/execution-apis/337eec34772dc15228092e032fd299042e1ece99/refs-openrpc.json") 11 | .then(async (res) => { 12 | return filterExecutionAPIs(await res.json()); 13 | }); 14 | } 15 | 16 | // fetch, merge and write 17 | getFilteredExecutionAPIs().then((EthereumOpenRPC) => { 18 | EthereumOpenRPC.methods.forEach((method) => { 19 | const ethereumTag = { 20 | name: "Ethereum API", 21 | description: "Ethereum Node JSON-RPC method", 22 | }; 23 | const multichainTag = { 24 | name: "Multichain API", 25 | description: "Multichain JSON-RPC method", 26 | }; 27 | if (method.tags) { 28 | method.tags.push(ethereumTag, multichainTag); 29 | } else { 30 | method.tags = [ethereumTag, multichainTag]; 31 | } 32 | }); 33 | fs.writeFileSync(__dirname + "/src/build/openrpc.json", 34 | JSON.stringify( 35 | mergeOpenRPC(MetaMaskOpenRPC, EthereumOpenRPC), 36 | null, 37 | 4 38 | ) 39 | ); 40 | fs.writeFileSync(__dirname + "/src/build/multichain-openrpc.json", 41 | JSON.stringify( 42 | TransportOpenRPC, 43 | null, 44 | 4 45 | ) 46 | ); 47 | 48 | }); 49 | 50 | const unneeded = [ 51 | /eth_signTransaction/, 52 | /eth_sign/, 53 | /debug_.*/, 54 | /engine_.*/, 55 | /eth_createAccessList/, 56 | /eth_getBlockReceipts/, 57 | /eth_maxPriorityFeePerGas/, 58 | /eth_blobBaseFee/, 59 | ]; 60 | 61 | const filterExecutionAPIs = (openrpcDocument) => { 62 | openrpcDocument.methods = openrpcDocument.methods.filter((method) => { 63 | const matches = unneeded.some((regex) => regex.test(method.name)); 64 | return !matches; 65 | }); 66 | return openrpcDocument; 67 | }; 68 | -------------------------------------------------------------------------------- /merge-utils.js: -------------------------------------------------------------------------------- 1 | 2 | const dedupe = (methods1, methods2) => { 3 | return methods2.reduce( 4 | (arr, method) => { 5 | if (arr.find((m) => m.name === method.name) === undefined) { 6 | arr.push(method); 7 | } 8 | return arr; 9 | }, 10 | methods1 11 | ); 12 | }; 13 | 14 | const mergeOpenRPC = (first, second) => { 15 | return { 16 | openrpc: first.openrpc, 17 | info: first.info, 18 | methods: dedupe(first.methods, second.methods), 19 | components: { 20 | errors: { 21 | ...first.components.errors, 22 | ...second.components.errors 23 | }, 24 | schemas: { 25 | ...first.components.schemas, 26 | ...second.components.schemas 27 | }, 28 | tags: { 29 | ...first.components.tags, 30 | ...second.components.tags 31 | }, 32 | contentDescriptors: { 33 | ...first.components.contentDescriptors, 34 | ...second.components.contentDescriptors 35 | }, 36 | examplePairings: { 37 | ...first.components.examplePairings, 38 | ...second.components.examplePairings 39 | }, 40 | links: { 41 | ...first.components.links, 42 | ...second.components.links 43 | }, 44 | examples: { 45 | ...first.components.examples, 46 | ...second.components.examples 47 | } 48 | } 49 | }; 50 | }; 51 | 52 | module.exports = mergeOpenRPC; 53 | -------------------------------------------------------------------------------- /multichain/openrpc.yaml: -------------------------------------------------------------------------------- 1 | openrpc: 1.2.4 2 | info: 3 | title: MetaMask Multichain API 4 | version: 1.0.0 5 | description: >- 6 | Specification for the Multichain API layer of MetaMask's Wallet API. 7 | methods: 8 | - name: wallet_notify 9 | paramStructure: by-name 10 | params: 11 | - name: scope 12 | description: A valid `scope` string that has been previously authorized to the dapp. 13 | required: true 14 | schema: 15 | $ref: "#/components/schemas/ScopeString" 16 | - name: notification 17 | description: An object containing a JSON-RPC notification with `method` and `params`. 18 | deprecated: false 19 | required: true 20 | schema: 21 | type: "object" 22 | properties: 23 | method: 24 | type: "string" 25 | params: true 26 | - name: wallet_invokeMethod 27 | paramStructure: by-name 28 | params: 29 | - name: scope 30 | description: A valid `scope` string that has been previously authorized to the dapp. 31 | required: true 32 | schema: 33 | $ref: "#/components/schemas/ScopeString" 34 | - name: request 35 | description: An object containing a JSON-RPC request with `method` and `params`. 36 | deprecated: false 37 | required: true 38 | schema: 39 | type: "object" 40 | properties: 41 | method: 42 | type: "string" 43 | params: true 44 | result: 45 | name: wallet_invokeMethodResult 46 | schema: true 47 | examples: 48 | - name: wallet_invokeMethodExample 49 | params: 50 | - name: scope 51 | value: eip155:1 52 | - name: request 53 | value: 54 | method: eth_getBalance 55 | params: [] 56 | result: 57 | name: wallet_invokeMethodResult 58 | value: "0x1" 59 | - name: wallet_revokeSession 60 | description: The `wallet_revokeSession` method revokes the entire active session. 61 | params: [] 62 | result: 63 | name: wallet_revokeSessionResult 64 | schema: 65 | type: boolean 66 | examples: 67 | - name: wallet_revokeSessionExample 68 | params: [] 69 | result: 70 | name: wallet_revokeSessionExampleResult 71 | value: true 72 | errors: 73 | - $ref: "#/components/errors/UnknownError" 74 | - name: wallet_sessionChanged 75 | paramStructure: by-name 76 | description: >- 77 | This notification is published by the wallet to notify the callers of updates to a shared session's authorization scopes. 78 | The event payload contains the new `sessionScopes`. 79 | params: 80 | - name: sessionScopes 81 | schema: 82 | $ref: "#/components/schemas/SessionScopes" 83 | examples: 84 | - name: wallet_sessionChangedExample 85 | description: Example of a wallet_sessionChanged notification. 86 | params: 87 | - name: sessionScopes 88 | value: 89 | eip155:1337: 90 | accounts: 91 | - eip155:1337:0x5cfe73b6021e818b776b421b1c4db2474086a7e1 92 | methods: 93 | - personal_sign 94 | - eth_signTypedData_v4 95 | - wallet_watchAsset 96 | - eth_sendTransaction 97 | - eth_decrypt 98 | - eth_getEncryptionPublicKey 99 | - web3_clientVersion 100 | - eth_subscribe 101 | - eth_unsubscribe 102 | - wallet_swapAsset 103 | - eth_blockNumber 104 | - eth_call 105 | - eth_chainId 106 | - eth_estimateGas 107 | - eth_feeHistory 108 | - eth_gasPrice 109 | - eth_getBalance 110 | - eth_getBlockByHash 111 | - eth_getBlockByNumber 112 | - eth_getBlockTransactionCountByHash 113 | - eth_getBlockTransactionCountByNumber 114 | - eth_getCode 115 | - eth_getFilterChanges 116 | - eth_getFilterLogs 117 | - eth_getLogs 118 | - eth_getProof 119 | - eth_getStorageAt 120 | - eth_getTransactionByBlockHashAndIndex 121 | - eth_getTransactionByBlockNumberAndIndex 122 | - eth_getTransactionByHash 123 | - eth_getTransactionCount 124 | - eth_getTransactionReceipt 125 | - eth_getUncleCountByBlockHash 126 | - eth_getUncleCountByBlockNumber 127 | - eth_newBlockFilter 128 | - eth_newFilter 129 | - eth_newPendingTransactionFilter 130 | - eth_sendRawTransaction 131 | - eth_syncing 132 | - eth_uninstallFilter 133 | notifications: 134 | - eth_subscription 135 | wallet: 136 | accounts: [] 137 | methods: 138 | - wallet_registerOnboarding 139 | - wallet_scanQRCode 140 | notifications: [] 141 | wallet:eip155: 142 | accounts: 143 | - wallet:eip155:0x5cfe73b6021e818b776b421b1c4db2474086a7e1 144 | methods: 145 | - wallet_addEthereumChain 146 | notifications: [] 147 | - name: wallet_getSession 148 | description: The `wallet_getSession` method returns an active session. 149 | params: [] 150 | result: 151 | name: wallet_getSessionResult 152 | schema: 153 | type: object 154 | properties: 155 | sessionScopes: 156 | $ref: "#/components/schemas/SessionScopes" 157 | examples: 158 | - name: wallet_getSessionExample 159 | description: Example of a getSession request. 160 | params: [] 161 | result: 162 | name: wallet_getSessionResultExample 163 | value: 164 | sessionScopes: 165 | eip155:1337: 166 | accounts: 167 | - eip155:1337:0x5cfe73b6021e818b776b421b1c4db2474086a7e1 168 | methods: 169 | - personal_sign 170 | - eth_signTypedData_v4 171 | - wallet_watchAsset 172 | - eth_sendTransaction 173 | - eth_decrypt 174 | - eth_getEncryptionPublicKey 175 | - web3_clientVersion 176 | - eth_subscribe 177 | - eth_unsubscribe 178 | - wallet_swapAsset 179 | - eth_blockNumber 180 | - eth_call 181 | - eth_chainId 182 | - eth_estimateGas 183 | - eth_feeHistory 184 | - eth_gasPrice 185 | - eth_getBalance 186 | - eth_getBlockByHash 187 | - eth_getBlockByNumber 188 | - eth_getBlockTransactionCountByHash 189 | - eth_getBlockTransactionCountByNumber 190 | - eth_getCode 191 | - eth_getFilterChanges 192 | - eth_getFilterLogs 193 | - eth_getLogs 194 | - eth_getProof 195 | - eth_getStorageAt 196 | - eth_getTransactionByBlockHashAndIndex 197 | - eth_getTransactionByBlockNumberAndIndex 198 | - eth_getTransactionByHash 199 | - eth_getTransactionCount 200 | - eth_getTransactionReceipt 201 | - eth_getUncleCountByBlockHash 202 | - eth_getUncleCountByBlockNumber 203 | - eth_newBlockFilter 204 | - eth_newFilter 205 | - eth_newPendingTransactionFilter 206 | - eth_sendRawTransaction 207 | - eth_syncing 208 | - eth_uninstallFilter 209 | notifications: 210 | - eth_subscription 211 | wallet: 212 | accounts: [] 213 | methods: 214 | - wallet_registerOnboarding 215 | - wallet_scanQRCode 216 | notifications: [] 217 | wallet:eip155: 218 | accounts: 219 | - wallet:eip155:0x5cfe73b6021e818b776b421b1c4db2474086a7e1 220 | methods: 221 | - wallet_addEthereumChain 222 | notifications: [] 223 | - name: wallet_createSession 224 | paramStructure: by-name 225 | params: 226 | - name: requiredScopes 227 | description: Scopes that the wallet must support in order to be used with this provider. 228 | schema: 229 | type: object 230 | patternProperties: 231 | "[-a-z0-9]{3,8}(:[-_a-zA-Z0-9]{1,32})?": 232 | $ref: "#/components/schemas/Scope" 233 | - name: optionalScopes 234 | description: Scopes that the wallet may support in order to be used with this provider. 235 | schema: 236 | type: object 237 | patternProperties: 238 | "[-a-z0-9]{3,8}(:[-_a-zA-Z0-9]{1,32})?": 239 | $ref: "#/components/schemas/Scope" 240 | - name: sessionProperties 241 | description: Properties that the wallet may use to determine if the session is valid. 242 | schema: 243 | type: object 244 | result: 245 | name: wallet_createSessionResult 246 | schema: 247 | type: object 248 | properties: 249 | sessionScopes: 250 | $ref: "#/components/schemas/SessionScopes" 251 | sessionProperties: 252 | type: object 253 | examples: 254 | - name: wallet_createSessionEthExample 255 | description: Example of a createSession request. 256 | params: 257 | - name: optionalScopes 258 | value: 259 | eip155:1337: 260 | methods: 261 | - wallet_watchAsset 262 | - eth_sendTransaction 263 | - eth_decrypt 264 | - eth_getEncryptionPublicKey 265 | - web3_clientVersion 266 | - eth_subscribe 267 | - eth_unsubscribe 268 | - eth_blockNumber 269 | - eth_call 270 | - eth_chainId 271 | - eth_estimateGas 272 | - eth_feeHistory 273 | - eth_gasPrice 274 | - eth_getBalance 275 | - eth_getBlockByHash 276 | - eth_getBlockByNumber 277 | - eth_getBlockTransactionCountByHash 278 | - eth_getBlockTransactionCountByNumber 279 | - eth_getCode 280 | - eth_getFilterChanges 281 | - eth_getFilterLogs 282 | - eth_getLogs 283 | - eth_getProof 284 | - eth_getStorageAt 285 | - eth_getTransactionByBlockHashAndIndex 286 | - eth_getTransactionByBlockNumberAndIndex 287 | - eth_getTransactionByHash 288 | - eth_getTransactionCount 289 | - eth_getTransactionReceipt 290 | - eth_getUncleCountByBlockHash 291 | - eth_getUncleCountByBlockNumber 292 | - eth_newBlockFilter 293 | - eth_newFilter 294 | - eth_newPendingTransactionFilter 295 | - eth_sendRawTransaction 296 | - eth_syncing 297 | - eth_uninstallFilter 298 | notifications: 299 | - eth_subscription 300 | wallet: 301 | methods: 302 | - wallet_registerOnboarding 303 | - wallet_scanQRCode 304 | notifications: [] 305 | wallet:eip155: 306 | methods: 307 | - wallet_addEthereumChain 308 | notifications: [] 309 | result: 310 | name: wallet_createSessionResultExample 311 | value: 312 | sessionProperties: {} 313 | sessionScopes: 314 | eip155:1337: 315 | accounts: 316 | - eip155:1337:0x5cfe73b6021e818b776b421b1c4db2474086a7e1 317 | methods: 318 | - personal_sign 319 | - eth_signTypedData_v4 320 | - wallet_watchAsset 321 | - eth_sendTransaction 322 | - eth_decrypt 323 | - eth_getEncryptionPublicKey 324 | - web3_clientVersion 325 | - eth_subscribe 326 | - eth_unsubscribe 327 | - wallet_swapAsset 328 | - eth_blockNumber 329 | - eth_call 330 | - eth_chainId 331 | - eth_estimateGas 332 | - eth_feeHistory 333 | - eth_gasPrice 334 | - eth_getBalance 335 | - eth_getBlockByHash 336 | - eth_getBlockByNumber 337 | - eth_getBlockTransactionCountByHash 338 | - eth_getBlockTransactionCountByNumber 339 | - eth_getCode 340 | - eth_getFilterChanges 341 | - eth_getFilterLogs 342 | - eth_getLogs 343 | - eth_getProof 344 | - eth_getStorageAt 345 | - eth_getTransactionByBlockHashAndIndex 346 | - eth_getTransactionByBlockNumberAndIndex 347 | - eth_getTransactionByHash 348 | - eth_getTransactionCount 349 | - eth_getTransactionReceipt 350 | - eth_getUncleCountByBlockHash 351 | - eth_getUncleCountByBlockNumber 352 | - eth_newBlockFilter 353 | - eth_newFilter 354 | - eth_newPendingTransactionFilter 355 | - eth_sendRawTransaction 356 | - eth_syncing 357 | - eth_uninstallFilter 358 | notifications: 359 | - eth_subscription 360 | wallet: 361 | accounts: [] 362 | methods: 363 | - wallet_registerOnboarding 364 | - wallet_scanQRCode 365 | notifications: [] 366 | wallet:eip155: 367 | accounts: 368 | - wallet:eip155:0x5cfe73b6021e818b776b421b1c4db2474086a7e1 369 | methods: 370 | - wallet_addEthereumChain 371 | notifications: [] 372 | 373 | - name: wallet_createSessionEthUnsupportedMethodsExample 374 | description: Example of a createSession request with unsupported eip155 methods. 375 | params: 376 | - name: optionalScopes 377 | value: 378 | eip155:1337: 379 | methods: 380 | - not_supported 381 | notifications: [] 382 | wallet: 383 | methods: [] 384 | notifications: [] 385 | wallet:eip155: 386 | methods: [] 387 | notifications: [] 388 | result: 389 | name: wallet_createSessionEthUnsupportedMethodsResultExample 390 | value: 391 | sessionProperties: {} 392 | sessionScopes: 393 | eip155:1337: 394 | accounts: 395 | - eip155:1337:0x5cfe73b6021e818b776b421b1c4db2474086a7e1 396 | methods: 397 | - personal_sign 398 | - eth_signTypedData_v4 399 | - wallet_watchAsset 400 | - eth_sendTransaction 401 | - eth_decrypt 402 | - eth_getEncryptionPublicKey 403 | - web3_clientVersion 404 | - eth_subscribe 405 | - eth_unsubscribe 406 | - wallet_swapAsset 407 | - eth_blockNumber 408 | - eth_call 409 | - eth_chainId 410 | - eth_estimateGas 411 | - eth_feeHistory 412 | - eth_gasPrice 413 | - eth_getBalance 414 | - eth_getBlockByHash 415 | - eth_getBlockByNumber 416 | - eth_getBlockTransactionCountByHash 417 | - eth_getBlockTransactionCountByNumber 418 | - eth_getCode 419 | - eth_getFilterChanges 420 | - eth_getFilterLogs 421 | - eth_getLogs 422 | - eth_getProof 423 | - eth_getStorageAt 424 | - eth_getTransactionByBlockHashAndIndex 425 | - eth_getTransactionByBlockNumberAndIndex 426 | - eth_getTransactionByHash 427 | - eth_getTransactionCount 428 | - eth_getTransactionReceipt 429 | - eth_getUncleCountByBlockHash 430 | - eth_getUncleCountByBlockNumber 431 | - eth_newBlockFilter 432 | - eth_newFilter 433 | - eth_newPendingTransactionFilter 434 | - eth_sendRawTransaction 435 | - eth_syncing 436 | - eth_uninstallFilter 437 | notifications: 438 | - eth_subscription 439 | wallet: 440 | accounts: [] 441 | methods: 442 | - wallet_registerOnboarding 443 | - wallet_scanQRCode 444 | notifications: [] 445 | wallet:eip155: 446 | accounts: 447 | - wallet:eip155:0x5cfe73b6021e818b776b421b1c4db2474086a7e1 448 | methods: 449 | - wallet_addEthereumChain 450 | notifications: [] 451 | - name: wallet_createSessionUnsupportedScopesExample 452 | description: Example of a createSession request with unsupported scopes. 453 | params: 454 | - name: optionalScopes 455 | value: 456 | foobar: 457 | methods: 458 | - eth_getBalance 459 | notifications: 460 | - eth_subscription 461 | eip155:1: 462 | accounts: 463 | - eip155:1:0x5cfe73b6021e818b776b421b1c4db2474086a7e1 464 | methods: 465 | - personal_sign 466 | - eth_signTypedData_v4 467 | - wallet_watchAsset 468 | - eth_sendTransaction 469 | - eth_decrypt 470 | - eth_getEncryptionPublicKey 471 | - web3_clientVersion 472 | - eth_subscribe 473 | - eth_unsubscribe 474 | - wallet_swapAsset 475 | - eth_blockNumber 476 | - eth_call 477 | - eth_chainId 478 | - eth_estimateGas 479 | - eth_feeHistory 480 | - eth_gasPrice 481 | - eth_getBalance 482 | - eth_getBlockByHash 483 | - eth_getBlockByNumber 484 | - eth_getBlockTransactionCountByHash 485 | - eth_getBlockTransactionCountByNumber 486 | - eth_getCode 487 | - eth_getFilterChanges 488 | - eth_getFilterLogs 489 | - eth_getLogs 490 | - eth_getProof 491 | - eth_getStorageAt 492 | - eth_getTransactionByBlockHashAndIndex 493 | - eth_getTransactionByBlockNumberAndIndex 494 | - eth_getTransactionByHash 495 | - eth_getTransactionCount 496 | - eth_getTransactionReceipt 497 | - eth_getUncleCountByBlockHash 498 | - eth_getUncleCountByBlockNumber 499 | - eth_newBlockFilter 500 | - eth_newFilter 501 | - eth_newPendingTransactionFilter 502 | - eth_sendRawTransaction 503 | - eth_syncing 504 | - eth_uninstallFilter 505 | notifications: 506 | - eth_subscription 507 | result: 508 | name: wallet_createSessionUnsupportedScopesResultExample 509 | value: 510 | sessionProperties: {} 511 | sessionScopes: 512 | eip155:1: 513 | accounts: 514 | - eip155:1:0x5cfe73b6021e818b776b421b1c4db2474086a7e1 515 | methods: 516 | - personal_sign 517 | - eth_signTypedData_v4 518 | - wallet_watchAsset 519 | - eth_sendTransaction 520 | - eth_decrypt 521 | - eth_getEncryptionPublicKey 522 | - web3_clientVersion 523 | - eth_subscribe 524 | - eth_unsubscribe 525 | - wallet_swapAsset 526 | - eth_blockNumber 527 | - eth_call 528 | - eth_chainId 529 | - eth_estimateGas 530 | - eth_feeHistory 531 | - eth_gasPrice 532 | - eth_getBalance 533 | - eth_getBlockByHash 534 | - eth_getBlockByNumber 535 | - eth_getBlockTransactionCountByHash 536 | - eth_getBlockTransactionCountByNumber 537 | - eth_getCode 538 | - eth_getFilterChanges 539 | - eth_getFilterLogs 540 | - eth_getLogs 541 | - eth_getProof 542 | - eth_getStorageAt 543 | - eth_getTransactionByBlockHashAndIndex 544 | - eth_getTransactionByBlockNumberAndIndex 545 | - eth_getTransactionByHash 546 | - eth_getTransactionCount 547 | - eth_getTransactionReceipt 548 | - eth_getUncleCountByBlockHash 549 | - eth_getUncleCountByBlockNumber 550 | - eth_newBlockFilter 551 | - eth_newFilter 552 | - eth_newPendingTransactionFilter 553 | - eth_sendRawTransaction 554 | - eth_syncing 555 | - eth_uninstallFilter 556 | notifications: 557 | - eth_subscription 558 | 559 | errors: 560 | - $ref: "#/components/errors/UnknownError" 561 | - code: 5100 562 | message: Requested networks are not supported 563 | - code: 5101 564 | message: Requested methods are not supported 565 | - code: 5102 566 | message: Requested notifications are not supported 567 | - code: 5300 568 | message: Invalid scopedProperties requested 569 | - code: 5301 570 | message: scopedProperties can only be outside of sessionScopes 571 | - code: 5302 572 | message: Invalid sessionProperties requested 573 | components: 574 | errors: 575 | UnknownError: 576 | code: 5000 577 | message: Unknown error with request 578 | schemas: 579 | SessionScopes: 580 | type: object 581 | patternProperties: 582 | "[-a-z0-9]{3,8}(:[-_a-zA-Z0-9]{1,32})?": 583 | $ref: "#/components/schemas/Scope" 584 | ScopeString: 585 | type: string 586 | pattern: "[-a-z0-9]{3,8}(:[-_a-zA-Z0-9]{1,32})?" 587 | Scope: 588 | type: object 589 | title: Scope 590 | description: Scope for a multichain connection. 591 | additionalProperties: true 592 | required: 593 | - notifications 594 | - methods 595 | properties: 596 | references: 597 | description: >- 598 | References to specific blockchains associated with this scope. 599 | Primarily used for shorthand when there would otherwise be 600 | duplicate scopes. Supported only in requests. 601 | type: array 602 | items: 603 | type: string 604 | methods: 605 | description: >- 606 | Methods associated with this scope. Supported in both requests and 607 | responses. 608 | type: array 609 | items: 610 | type: string 611 | notifications: 612 | description: >- 613 | Notifications associated with this scope. Supported in both requests 614 | and responses. 615 | type: array 616 | items: 617 | type: string 618 | accounts: 619 | type: array 620 | description: >- 621 | Account associated with this scope. Supported in both requests and 622 | responses. 623 | items: 624 | type: string 625 | -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": [ "./openrpc.yaml", "./merge-openrpc.js" ], 3 | "exec": "yarn start" 4 | } 5 | -------------------------------------------------------------------------------- /openrpc.yaml: -------------------------------------------------------------------------------- 1 | openrpc: 1.2.4 2 | info: 3 | title: JSON-RPC API 4 | version: 1.0.0 5 | description: >- 6 | This section provides an interactive reference for MetaMask's Wallet 7 | JSON-RPC API. The API builds on a set of standard Ethereum methods with 8 | MetaMask-specific enhancements, and is designed for seamless integration 9 | into dapps. 10 | methods: 11 | - name: wallet_addEthereumChain 12 | tags: 13 | - $ref: '#/components/tags/MetaMask' 14 | - $ref: '#/components/tags/Multichain' 15 | summary: Adds an Ethereum chain to the wallet. 16 | description: >- 17 | Creates a confirmation asking the user to add the specified chain to the 18 | wallet application. The caller must specify a chain ID and some chain metadata. 19 | Specified by [EIP-3085](https://eips.ethereum.org/EIPS/eip-3085). 20 | params: 21 | - name: Chain 22 | schema: 23 | $ref: '#/components/schemas/AddEthereumChainParameter' 24 | errors: 25 | - code: -32602 26 | message: >- 27 | Expected null or array with at least one valid string HTTPS URL 28 | 'blockExplorerUrl'. Received: ${blockExplorerUrls} 29 | - code: -32602 30 | message: >- 31 | Expected 0x-prefixed, unpadded, non-zero hexadecimal string 'chainId'. 32 | Received: 33 | 34 | ${chainId} 35 | - code: -32602 36 | message: >- 37 | Invalid chain ID "${_chainId}": numerical value greater than max safe 38 | value. Received: 39 | 40 | ${chainId} 41 | - code: -32602 42 | message: May not specify default MetaMask chain. 43 | - code: -32602 44 | message: |- 45 | Expected 2-6 character string 'nativeCurrency.symbol'. Received: 46 | ${ticker} 47 | - code: -32602 48 | message: >- 49 | nativeCurrency.symbol does not match currency symbol for a network the 50 | user already has added with the same chainId. Received: 51 | 52 | ${ticker} 53 | result: 54 | name: Null response 55 | description: This method returns `null` if the chain is added. 56 | schema: 57 | type: 'null' 58 | examples: 59 | - name: wallet_addEthereumChain example 60 | params: 61 | - name: Chain 62 | value: 63 | chainId: '0x64' 64 | chainName: Gnosis 65 | rpcUrls: 66 | - 'https://rpc.gnosischain.com' 67 | iconUrls: 68 | - 'https://xdaichain.com/fake/example/url/xdai.svg' 69 | - 'https://xdaichain.com/fake/example/url/xdai.png' 70 | nativeCurrency: 71 | name: XDAI 72 | symbol: XDAI 73 | decimals: 18 74 | blockExplorerUrls: 75 | - 'https://blockscout.com/poa/xdai/' 76 | result: 77 | name: Null response 78 | value: 'null' 79 | - name: wallet_switchEthereumChain 80 | tags: 81 | - $ref: '#/components/tags/MetaMask' 82 | summary: Switches the wallet's active Ethereum chain. 83 | description: >- 84 | Requests that the wallet switches its active Ethereum chain. Specified by 85 | [EIP-3326](https://eips.ethereum.org/EIPS/eip-3326). 86 | params: 87 | - name: Chain 88 | schema: 89 | title: Chain 90 | description: Object containing the chain ID to switch to. 91 | type: object 92 | required: 93 | - chainId 94 | properties: 95 | chainId: 96 | description: >- 97 | The chain ID as a `0x`-prefixed hexadecimal string, as returned by the 98 | `eth_chainId` method. 99 | type: string 100 | result: 101 | name: Null response 102 | description: This method returns `null` if the active chain is switched. 103 | schema: 104 | type: 'null' 105 | errors: 106 | - code: 4902 107 | message: >- 108 | Unrecognized chain ID. Try adding the chain using 109 | wallet_addEthereumChain first. 110 | examples: 111 | - name: wallet_switchEthereumChain example 112 | params: 113 | - name: Chain 114 | value: 115 | chainId: '0x64' 116 | result: 117 | name: Null response 118 | value: 'null' 119 | - name: wallet_getPermissions 120 | tags: 121 | - $ref: '#/components/tags/MetaMask' 122 | summary: Gets the user's permissions. 123 | description: >- 124 | Gets the user's permissions. Specified by 125 | [EIP-2255](https://eips.ethereum.org/EIPS/eip-2255). 126 | params: [] 127 | result: 128 | name: Permissions list 129 | schema: 130 | $ref: '#/components/schemas/PermissionsList' 131 | examples: 132 | - name: wallet_getPermissions example 133 | params: [] 134 | result: 135 | name: Permission list 136 | value: 137 | eth_accounts: {} 138 | - name: wallet_requestPermissions 139 | tags: 140 | - $ref: '#/components/tags/MetaMask' 141 | summary: Requests additional permissions. 142 | description: >- 143 | Requests additional permissions from the user. This method accepts 144 | a single permission per call. Specified by 145 | [EIP-2255](https://eips.ethereum.org/EIPS/eip-2255). 146 | params: 147 | - name: Permission 148 | required: true 149 | schema: 150 | title: Permission 151 | description: Object containing the permission to request. 152 | type: object 153 | properties: 154 | permission_name: 155 | type: object 156 | description: >- 157 | The permission object. `permission_name` is the name of the permission 158 | being requested. 159 | additionalProperties: true 160 | result: 161 | name: Permissions list 162 | schema: 163 | $ref: '#/components/schemas/PermissionsList' 164 | examples: 165 | - name: >- 166 | wallet_requestPermissions example 167 | params: 168 | - name: Permission 169 | value: 170 | eth_accounts: {} 171 | result: 172 | name: Permission list 173 | value: 174 | eth_accounts: {} 175 | errors: 176 | - $ref: '#/components/errors/UserRejected' 177 | - name: wallet_revokePermissions 178 | tags: 179 | - $ref: '#/components/tags/MetaMask' 180 | - $ref: '#/components/tags/Experimental' 181 | summary: Revokes the current dapp permissions. 182 | description: >- 183 | Revokes previously granted permissions for the current dapp identified by its 184 | origin. This method accepts a single permission per call. Specified by 185 | [MIP-2](https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-2.md) 186 | and only available for the MetaMask browser extension. 187 | params: 188 | - name: Permission 189 | required: true 190 | schema: 191 | title: Permission 192 | description: Object containing the permission to revoke. 193 | type: object 194 | properties: 195 | permission_name: 196 | type: object 197 | description: >- 198 | The permission object. `permission_name` is the name of the permission 199 | being revoked. 200 | additionalProperties: true 201 | result: 202 | name: Null response 203 | description: This method returns `null` if the permission is revoked. 204 | schema: 205 | type: 'null' 206 | errors: [] 207 | examples: 208 | - name: >- 209 | wallet_revokePermissions example 210 | params: 211 | - name: Permission 212 | value: 213 | eth_accounts: {} 214 | result: 215 | name: Null response 216 | value: 'null' 217 | - name: personal_sign 218 | tags: 219 | - $ref: '#/components/tags/MetaMask' 220 | - $ref: '#/components/tags/Restricted' 221 | - $ref: '#/components/tags/Multichain' 222 | summary: Presents a plain text signature challenge to the user. 223 | description: >- 224 | Presents a plain text signature challenge to the user and returns the 225 | signed response. Prepends a safe prefix to the signed message to prevent the challenge 226 | tricking users into signing a financial transaction. 227 |

228 | MetaMask implements `personal_sign` similarly to the Go Ethereum client's `eth_sign` 229 | implementation. MetaMask's `personal_sign` doesn't accept a password. 230 |

231 | This method requires that the user has granted permission to interact 232 | with their account first, so make sure to call `eth_requestAccounts` (recommended) 233 | or `wallet_requestPermissions` first. 234 | deprecated: false 235 | params: 236 | - name: Challenge 237 | required: true 238 | description: >- 239 | A hex-encoded UTF-8 string to present to the user. See how to encode a 240 | string like this in the 241 | [`browser-string-hexer`](https://github.com/danfinlay/browser-string-hexer) 242 | module. 243 | schema: 244 | type: string 245 | pattern: '^0x[a-fA-F\d]+$' 246 | - name: Address 247 | required: true 248 | description: The address of the requested signing account. 249 | schema: 250 | type: string 251 | pattern: '^0x[0-9a-fA-F]{40}$' 252 | result: 253 | name: Signature 254 | description: A hex-encoded signature. 255 | schema: 256 | type: string 257 | pattern: '^0x[0-9a-f]*$' 258 | examples: 259 | - name: personal_sign example 260 | params: 261 | - name: Challenge 262 | value: '0x506c65617365207369676e2074686973206d65737361676520746f20636f6e6669726d20796f7572206964656e746974792e' 263 | - name: Address 264 | value: '0x4B0897b0513FdBeEc7C469D9aF4fA6C0752aBea7' 265 | result: 266 | name: Signature 267 | value: '0x43d7215ebe96c09a5adac69fc76dea5647286b501954ea273e417cf65e6c80e1db4891826375a7de02467a3e01caf125f64c851a8e9ee9467fd6f7e83523b2115bed8e79d527a85e28a36807d79b85fc551b5c15c1ead2e43456c31f565219203db2aed86cb3601b33ec3b410836d4be7718c6148dc9ac82ecc0a04c5edecd8914' 268 | - name: eth_signTypedData_v4 269 | tags: 270 | - $ref: '#/components/tags/MetaMask' 271 | - $ref: '#/components/tags/Restricted' 272 | - $ref: '#/components/tags/Multichain' 273 | summary: Presents a structured data message for the user to sign. 274 | description: >- 275 | Presents a data message for the user to sign in a structured and readable 276 | format and returns the signed response. Introduced by 277 | [EIP-712](https://eips.ethereum.org/EIPS/eip-712). 278 | This method requires that the user has granted permission to interact with their account first, 279 | so make sure to call `eth_requestAccounts` (recommended) or `wallet_requestPermissions` first. 280 | params: 281 | - name: Address 282 | required: true 283 | description: The address of the requested signing account. 284 | schema: 285 | type: string 286 | pattern: '^0x[0-9a-fA-F]{40}$' 287 | - name: Typed data 288 | required: true 289 | schema: 290 | $ref: '#/components/schemas/TypedData' 291 | result: 292 | name: Signature 293 | description: A hex-encoded signature. 294 | schema: 295 | type: string 296 | pattern: '^0x[0-9a-f]*$' 297 | examples: 298 | - name: eth_SignTypedData_v4 example 299 | params: 300 | - name: Address 301 | value: '0x0000000000000000000000000000000000000000' 302 | - name: Typed data 303 | value: 304 | types: 305 | EIP712Domain: 306 | - name: name 307 | type: string 308 | - name: version 309 | type: string 310 | - name: chainId 311 | type: uint256 312 | - name: verifyingContract 313 | type: address 314 | Person: 315 | - name: name 316 | type: string 317 | - name: wallet 318 | type: address 319 | Mail: 320 | - name: from 321 | type: Person 322 | - name: to 323 | type: Person 324 | - name: contents 325 | type: string 326 | primaryType: Mail 327 | domain: 328 | name: Ether Mail 329 | version: '1' 330 | chainId: 1 331 | verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC' 332 | message: 333 | from: 334 | name: Cow 335 | wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826' 336 | to: 337 | name: Bob 338 | wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB' 339 | contents: 'Hello, Bob!' 340 | result: 341 | name: Signature 342 | value: >- 343 | 0x4355c47d63924e8a72e509b65029052eb6c299d53a04e167c5775fd466751c9d07299936d304c153f6443dfa05f40ff007d72911b6f72307f996231605b915621c 344 | - name: wallet_registerOnboarding 345 | tags: 346 | - $ref: '#/components/tags/MetaMask' 347 | - $ref: '#/components/tags/Multichain' 348 | summary: Redirects the user back to the site after onboarding. 349 | description: >- 350 | Registers the requesting site with MetaMask as the initiator of 351 | onboarding, enabling MetaMask to redirect the user back to the site after 352 | onboarding. Returns a promise that resolves to `true`, or rejects the request if 353 | there's an error. Instead of calling this method directly, you should use 354 | the 355 | [`@metamask/onboarding`](https://github.com/MetaMask/metamask-onboarding) 356 | library. 357 | params: [] 358 | result: 359 | name: Registered 360 | description: '`true` if the request was successful, `false` otherwise.' 361 | schema: 362 | type: boolean 363 | examples: 364 | - name: wallet_registerOnboarding example 365 | params: [] 366 | result: 367 | name: Registered 368 | value: true 369 | - name: wallet_watchAsset 370 | tags: 371 | - $ref: '#/components/tags/MetaMask' 372 | - $ref: '#/components/tags/Experimental' 373 | - $ref: '#/components/tags/Multichain' 374 | summary: Tracks a token in MetaMask. 375 | description: >- 376 | Requests that the user track the specified token in MetaMask. Returns a 377 | boolean indicating if the token was successfully added. Once added, the 378 | token is indistinguishable from those added using legacy methods, such as 379 | a centralized registry. Introduced by 380 | [EIP-747](https://eips.ethereum.org/EIPS/eip-747). 381 | paramStructure: by-name 382 | params: 383 | - name: type 384 | schema: 385 | type: string 386 | description: >- 387 | The token type (`ERC20`, `ERC721`, or `ERC1155`). Support for ERC-721 388 | and ERC-1155 tokens is experimental and currently only available on 389 | the extension (not on mobile). See 390 | [MIP-1](https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-1.md) 391 | and the [MIP proposal 392 | lifecycle](https://github.com/MetaMask/metamask-improvement-proposals/blob/main/PROCESS-GUIDE.md#proposal-lifecycle) 393 | for more information. 394 | enum: 395 | - ERC20 396 | - ERC721 397 | - ERC1155 398 | required: true 399 | - name: options 400 | schema: 401 | description: An object containing information about the token. 402 | type: object 403 | required: 404 | - address 405 | properties: 406 | address: 407 | description: The address of the token contract. 408 | type: string 409 | symbol: 410 | description: >- 411 | A ticker symbol or shorthand, up to 11 characters (optional for 412 | ERC-20 tokens). 413 | minLength: 2 414 | maxLength: 11 415 | type: string 416 | decimals: 417 | description: The number of token decimals (optional for ERC-20 tokens). 418 | type: number 419 | image: 420 | description: A string URL of the token logo (optional for ERC-20 tokens). 421 | type: string 422 | tokenId: 423 | description: >- 424 | The unique identifier of the NFT (required for ERC-721 and 425 | ERC-1155 tokens). 426 | type: string 427 | errors: 428 | - code: -32602 429 | message: 'Must specify address, symbol, and decimals.' 430 | - code: -32602 431 | message: 'Invalid symbol: not a string.' 432 | - code: -32602 433 | message: 'Invalid symbol ''${symbol}'': longer than 11 characters.' 434 | - code: -32602 435 | message: 'Invalid decimals ''${decimals}'': must be 0 <= 36.' 436 | - code: -32602 437 | message: 'Invalid address ''${address}''.' 438 | - code: -32602 439 | message: Asset type is required. 440 | - code: -32602 441 | message: Both address and tokenId are required. 442 | - code: -32602 443 | message: Invalid address. 444 | - code: -32000 445 | message: Suggested NFT is not owned by the selected account. 446 | - code: -32000 447 | message: >- 448 | Suggested NFT of type ${standard} does not match received type 449 | ${type}. 450 | - code: -32002 451 | message: >- 452 | Unable to verify ownership. Possibly because the standard is not 453 | supported or the user's currently selected network does not match the 454 | chain of the asset in question. 455 | result: 456 | name: Added 457 | description: '`true` if the token was added, `false` otherwise.' 458 | schema: 459 | type: boolean 460 | examples: 461 | - name: wallet_watchAsset ERC-20 example 462 | params: 463 | - name: type 464 | value: ERC20 465 | - name: options 466 | value: 467 | address: '0xb60e8dd61c5d32be8058bb8eb970870f07233155' 468 | symbol: FOO 469 | decimals: 18 470 | image: 'https://foo.io/token-image.svg' 471 | result: 472 | name: Added 473 | value: true 474 | - name: wallet_watchAsset ERC-721 example 475 | params: 476 | - name: type 477 | value: ERC721 478 | - name: options 479 | value: 480 | address: '0x123456789abcdef0123456789abcdef01234567' 481 | tokenId: '42' 482 | result: 483 | name: Added 484 | value: true 485 | - name: wallet_watchAsset ERC-1155 example 486 | params: 487 | - name: type 488 | value: ERC1155 489 | - name: options 490 | value: 491 | address: '0xabcdef0123456789abcdef0123456789abcdef01' 492 | tokenId: '1337' 493 | result: 494 | name: Added 495 | value: true 496 | - name: wallet_scanQRCode 497 | tags: 498 | - $ref: '#/components/tags/MetaMask' 499 | - $ref: '#/components/tags/Mobile' 500 | - $ref: '#/components/tags/Multichain' 501 | summary: Requests that the user scan a QR code. 502 | description: >- 503 | Requests that the user scan a QR code using their device camera. 504 | Introduced by [EIP-945](https://github.com/ethereum/EIPs/issues/945). 505 | params: 506 | - name: Regex 507 | required: false 508 | description: >- 509 | A regular expression (regex) string for matching arbitrary QR code 510 | strings. 511 | schema: 512 | type: string 513 | title: regex 514 | result: 515 | name: QR code string 516 | description: >- 517 | A string corresponding to the scanned QR code. If a regex string is 518 | provided, the resulting string matches it. If no regex string is 519 | provided, the resulting string matches an Ethereum address. If neither 520 | condition is met, the method returns an error. 521 | schema: 522 | type: string 523 | title: QR code string 524 | - name: wallet_sendCalls 525 | tags: 526 | - $ref: '#/components/tags/MetaMask' 527 | summary: Sends a batch of calls. 528 | description: >- 529 | Requests that the wallet submits a batch of calls. Specified by 530 | [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792). 531 | params: 532 | - name: Calls 533 | required: true 534 | schema: 535 | $ref: '#/components/schemas/SendCallsParameter' 536 | result: 537 | name: Batch result 538 | schema: 539 | description: An object containing information about the sent batch. 540 | type: object 541 | properties: 542 | id: 543 | description: The ID of the batch of calls. 544 | type: string 545 | capabilities: 546 | description: >- 547 | Wallets can use this object to attach capability-specific metadata. 548 | type: object 549 | errors: 550 | - $ref: '#/components/errors/InvalidParams' 551 | - code: -32000 552 | message: Version not supported. 553 | - $ref: '#/components/errors/UserRejected' 554 | - $ref: '#/components/errors/Unauthorized' 555 | - code: 5700 556 | message: >- 557 | The wallet does not support a capability that was not marked as optional. 558 | - code: 5710 559 | message: EIP-7702 not supported on the specified chain ID. 560 | - code: 5720 561 | message: There is already a batch submitted with the specified batch ID. 562 | - code: 5740 563 | message: The batch is too large for the wallet to process. 564 | - code: 5750 565 | message: EIP-7702 upgrade rejected for this chain and account. 566 | examples: 567 | - name: wallet_sendCalls example 568 | params: 569 | - name: Calls 570 | value: 571 | version: '2.0.0' 572 | from: '0xd46e8dd67c5d32be8058bb8eb970870f07244567' 573 | chainId: '0xaa36a7' 574 | atomicRequired: true 575 | calls: 576 | - to: '0x54f1C1965B355e1AB9ec3465616136be35bb5Ff7' 577 | value: '0x0' 578 | - to: '0x2D48e6f5Ae053e4E918d2be53570961D880905F2' 579 | value: '0x0' 580 | result: 581 | name: Batch result 582 | value: 583 | id: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331' 584 | - name: wallet_getCallsStatus 585 | tags: 586 | - $ref: '#/components/tags/MetaMask' 587 | summary: Gets the status of a call batch. 588 | description: >- 589 | Gets the status of a batch of calls that was previously sent using 590 | `wallet_sendCalls`. Specified by 591 | [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792). 592 | params: 593 | - name: Batch ID 594 | required: true 595 | description: >- 596 | The ID of a batch of calls (the `id` value returned by `wallet_sendCalls`). 597 | schema: 598 | type: string 599 | result: 600 | name: Batch status 601 | schema: 602 | description: >- 603 | An object containing status information of the batch of calls. 604 | type: object 605 | properties: 606 | version: 607 | description: The version of the API format. 608 | type: string 609 | id: 610 | description: The ID of the batch of calls. 611 | $ref: '#/components/schemas/uint' 612 | chainId: 613 | description: The chain ID of the calls. 614 | $ref: '#/components/schemas/uint' 615 | status: 616 | description: >- 617 | The status code of the batch of calls. Possible values are: 618 |
619 | 626 | type: number 627 | atomic: 628 | description: >- 629 | `true` if the wallet executed the calls atomically. `false` if the 630 | wallet executed the calls non-atomically. 631 | type: boolean 632 | receipts: 633 | description: >- 634 | An array of transaction receipts. If the wallet executed the calls 635 | atomically, a single receipt or an array of receipts may be returned, 636 | corresponding to how the batch of calls were included onchain. 637 | type: array 638 | items: 639 | title: Receipt 640 | description: A transaction receipt object. 641 | type: object 642 | properties: 643 | logs: 644 | description: An array of log objects. 645 | type: array 646 | items: 647 | title: Log 648 | description: An object containing information about the log. 649 | type: object 650 | properties: 651 | address: 652 | description: The address that generated the log. 653 | type: string 654 | pattern: '^0x[0-9a-fA-F]{40}$' 655 | data: 656 | description: The data of the log. 657 | type: string 658 | pattern: '^0x[0-9a-f]*$' 659 | topics: 660 | description: An array of log topics. 661 | type: array 662 | items: 663 | title: Topic 664 | description: A log topic. 665 | type: string 666 | pattern: '^0x[0-9a-f]*$' 667 | status: 668 | description: >- 669 | The status of the transaction. `0x1` indicates success, and `0x0` 670 | indicates failure. 671 | type: string 672 | pattern: '^0x[0-1]$' 673 | blockHash: 674 | description: The hash of the block containing the transaction. 675 | type: string 676 | pattern: '^0x[0-9a-f]{64}$' 677 | blockNumber: 678 | description: The number of the block containing the transaction. 679 | type: string 680 | pattern: '^0x([1-9a-f]+[0-9a-f]*|0)$' 681 | gasUsed: 682 | description: The amount of gas used by the transaction. 683 | type: string 684 | pattern: '^0x([1-9a-f]+[0-9a-f]*|0)$' 685 | transactionHash: 686 | description: The hash of the transaction. 687 | type: string 688 | pattern: '^0x[0-9a-f]{64}$' 689 | additionalProperties: true 690 | capabilities: 691 | description: Capabilities associated with the batch of calls. 692 | type: object 693 | additionalProperties: true 694 | errors: 695 | - $ref: '#/components/errors/InvalidParams' 696 | - $ref: '#/components/errors/Unauthorized' 697 | - code: 5730 698 | message: No matching bundle found. 699 | examples: 700 | - name: wallet_getCallsStatus example 701 | params: 702 | - name: Batch ID 703 | value: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331' 704 | result: 705 | name: Batch status 706 | value: 707 | version: '2.0.0' 708 | chainId: '0xaa36a7' 709 | id: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331' 710 | status: 200 711 | atomic: true 712 | receipts: 713 | - logs: 714 | - address: '0xa922b54716264130634d6ff183747a8ead91a40b' 715 | topics: 716 | - '0x5a2a90727cc9d000dd060b1132a5c977c9702bb3a52afe360c9c22f0e9451a68' 717 | data: '0xabcd' 718 | status: '0x1' 719 | blockHash: '0xf19bbafd9fd0124ec110b848e8de4ab4f62bf60c189524e54213285e7f540d4a' 720 | blockNumber: '0xabcd' 721 | gasUsed: '0xdef' 722 | transactionHash: '0x9b7bb827c2e5e3c1a0a44dc53e573aa0b3af3bd1f9f5ed03071b100bb039eaff' 723 | - name: wallet_getCapabilities 724 | tags: 725 | - $ref: '#/components/tags/MetaMask' 726 | summary: Gets the capabilities of the wallet. 727 | description: >- 728 | Returns information about the wallet's support for the `atomic` 729 | capability. The `atomic` capability specifies how the wallet will 730 | execute batches of transactions sent using `wallet_sendCalls`. 731 | `wallet_getCapabilities` is specified by 732 | [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792). 733 | params: 734 | - name: Address 735 | description: A wallet address. 736 | required: true 737 | schema: 738 | type: string 739 | pattern: '^0x[0-9a-fA-F]{40}$' 740 | - name: Chain IDs 741 | description: An array of chain IDs to get capabilities for. 742 | schema: 743 | type: array 744 | items: 745 | title: Chain ID 746 | description: >- 747 | An [EIP-155](https://eips.ethereum.org/EIPS/eip-155) 748 | chain ID in hexadecimal format. 749 | $ref: '#/components/schemas/uint' 750 | result: 751 | name: Capabilities 752 | schema: 753 | description: >- 754 | An object specifying the status of the `atomic` capability for 755 | specific [EIP-155](https://eips.ethereum.org/EIPS/eip-155) chain IDs. 756 | For each chain, the `atomic` capability can have a `status` of: 757 |
758 | 764 | If the `atomic` capability is not `supported` or `ready` for a 765 | specified chain ID, the wallet will not return anything for that chain ID. 766 | type: object 767 | errors: 768 | - $ref: '#/components/errors/InvalidParams' 769 | - $ref: '#/components/errors/Unauthorized' 770 | examples: 771 | - name: wallet_getCapabilities example 772 | params: 773 | - name: Address 774 | value: '0xd46e8dd67c5d32be8058bb8eb970870f07244567' 775 | - name: Chain IDs 776 | value: 777 | - '0xaa36a7' 778 | result: 779 | name: Capabilities 780 | value: 781 | '0xaa36a7': 782 | atomic: 783 | status: ready 784 | - name: eth_requestAccounts 785 | tags: 786 | - $ref: '#/components/tags/MetaMask' 787 | description: >- 788 | Requests that the user provide access to one or more Ethereum addresses. 789 | This method is specified by 790 | [EIP-1102](https://eips.ethereum.org/EIPS/eip-1102). Internally, this 791 | method calls `wallet_requestPermissions` for permission to call 792 | `eth_accounts`. 793 | summary: Requests that the user provide access to addresses. 794 | params: [] 795 | result: 796 | name: Address list 797 | schema: 798 | type: array 799 | description: >- 800 | An array of Ethereum addresses that the user has authorized the dapp 801 | to access. 802 | items: 803 | title: Address 804 | description: A hex-encoded address. 805 | type: string 806 | pattern: '^0x[0-9a-fA-F]{40}$' 807 | errors: 808 | - $ref: '#/components/errors/UserRejected' 809 | examples: 810 | - name: eth_requestAccounts example 811 | params: [] 812 | result: 813 | name: Address list 814 | value: 815 | - '0xa77392123a1085f75e62eec7dea7e0e1e5142d5f' 816 | - name: eth_accounts 817 | tags: 818 | - $ref: '#/components/tags/MetaMask' 819 | - $ref: '#/components/tags/Restricted' 820 | description: >- 821 | Returns a list of addresses that the user has authorized the dapp to access. 822 | This method requires calling `wallet_requestPermissions` for permission. 823 | We recommend using `eth_requestAccounts`, which internally calls `wallet_requestPermission`. 824 | summary: Gets a list of authorized addresses. 825 | params: [] 826 | result: 827 | name: Address list 828 | schema: 829 | type: array 830 | description: >- 831 | An array of Ethereum addresses that the user has authorized the dapp 832 | to access. 833 | items: 834 | title: Address 835 | description: A hex-encoded address. 836 | type: string 837 | pattern: '^0x[0-9a-fA-F]{40}$' 838 | examples: 839 | - name: eth_accounts example 840 | params: [] 841 | result: 842 | name: Address list 843 | value: 844 | - '0xa77392123a1085f75e62eec7dea7e0e1e5142d5f' 845 | - name: eth_sendTransaction 846 | tags: 847 | - $ref: '#/components/tags/MetaMask' 848 | - $ref: '#/components/tags/Restricted' 849 | - $ref: '#/components/tags/Multichain' 850 | description: >- 851 | Creates a new wallet confirmation to make an Ethereum transaction from the 852 | user's account. This method requires that the user has granted permission 853 | to interact with their account first, so make sure to call `eth_requestAccounts` (recommended) 854 | or `wallet_requestPermissions` first. 855 | summary: Initiates a new transaction. 856 | params: 857 | - name: Transaction 858 | required: true 859 | description: The transaction object to sign and send. 860 | schema: 861 | type: object 862 | title: Transaction 863 | description: >- 864 | The parameters to customize a transaction. If a `to` address is not 865 | provided, the transaction is assumed to be a contract 866 | creation transaction, and the `data` field is 867 | used as the contract initialization code. `gasPrice` cannot be 868 | used together with `maxPriorityFeePerGas` and `maxFeePerGas`. 869 | required: 870 | - from 871 | if: 872 | properties: 873 | to: 874 | not: 875 | type: string 876 | then: 877 | required: 878 | - data 879 | properties: 880 | to: 881 | description: The recipient's address. 882 | $ref: '#/components/schemas/address' 883 | from: 884 | description: The sender's address. 885 | $ref: '#/components/schemas/address' 886 | gas: 887 | description: >- 888 | The maximum amount of gas the transaction is allowed to use. 889 | $ref: '#/components/schemas/uint' 890 | value: 891 | description: The amount to transfer in wei. 892 | $ref: '#/components/schemas/uint' 893 | data: 894 | description: >- 895 | The data to include in the transaction. Used for contract 896 | creation transactions. 897 | $ref: '#/components/schemas/bytes' 898 | gasPrice: 899 | description: >- 900 | The gas price the sender is willing to pay to miners in wei. 901 | Used in pre-1559 transactions. 902 | $ref: '#/components/schemas/uint' 903 | maxPriorityFeePerGas: 904 | description: >- 905 | Maximum fee per gas the sender is willing to pay to miners in 906 | wei. Used in 1559 transactions. 907 | $ref: '#/components/schemas/uint' 908 | maxFeePerGas: 909 | description: >- 910 | The maximum total fee per gas the sender is willing to pay 911 | (includes the network / base fee and miner / priority fee) in 912 | wei. Used in 1559 transactions. 913 | $ref: '#/components/schemas/uint' 914 | result: 915 | name: Transaction hash 916 | description: The transaction hash of the sent transaction. 917 | schema: 918 | type: string 919 | pattern: '^0x[0-9a-f]{64}$' 920 | errors: 921 | - code: 4100 922 | message: >- 923 | The requested account and/or method has not been authorized by the user. 924 | examples: 925 | - name: sendTransaction 926 | params: 927 | - name: Transaction 928 | value: 929 | to: '0x4B0897b0513FdBeEc7C469D9aF4fA6C0752aBea7' 930 | from: '0xDeaDbeefdEAdbeefdEadbEEFdeadbeefDEADbEEF' 931 | gas: '0x76c0' 932 | value: '0x8ac7230489e80000' 933 | data: '0x' 934 | gasPrice: '0x4a817c800' 935 | result: 936 | name: eth_sendTransactionExampleResult 937 | value: '0x4e306b5a5a37532e1734503f7d2427a86f2c992fbe471f5be403b9f734e667c8' 938 | - name: eth_decrypt 939 | tags: 940 | - $ref: '#/components/tags/MetaMask' 941 | - $ref: '#/components/tags/Restricted' 942 | - $ref: '#/components/tags/Deprecated' 943 | summary: Decrypts an encrypted message. 944 | description: |- 945 | This method is deprecated and may be removed in the future. 946 | 947 | Requests that MetaMask decrypt the specified encrypted message. 948 | The message must have been encrypted using the public encryption key of the specified Ethereum address. 949 | Returns a promise that resolves to the decrypted message, or rejects if the decryption attempt fails. 950 | params: 951 | - name: EncryptedMessage 952 | required: true 953 | description: The encrypted message to decrypt. 954 | schema: 955 | type: string 956 | - name: Address 957 | required: true 958 | description: The address of the Ethereum account that can decrypt the message. 959 | schema: 960 | $ref: '#/components/schemas/address' 961 | result: 962 | name: PermissionsList 963 | schema: 964 | $ref: '#/components/schemas/PermissionsList' 965 | errors: 966 | - code: 4100 967 | message: >- 968 | The requested account and/or method has not been authorized by the user. 969 | examples: 970 | - name: decryptExample 971 | params: 972 | - name: EncryptedMessage 973 | value: '0x7b2276657273696f6e223a227832353531392d7873616c736132302d706f6c7931333035222c226e6f6e6365223a2243533967507076467071765358704655416679726a7179774e35302b7a747766222c22657068656d5075626c69634b6579223a224372774b61456d2f4b356d6d714239764c376f5872636d6441417757764479324f784c3333527135576e553d222c2263697068657274657874223a2248347a65336e7177572b753174663956343945506167454e343872774f766b6952676244566e47587a38493d227d' 974 | - name: Address 975 | value: '0xD1F5279BE4B4dD94133A23deE1B23F5bfC0Db1d0' 976 | result: 977 | name: eth_decryptExampleResult 978 | value: 'Hello, Ethereum!' 979 | - name: eth_getEncryptionPublicKey 980 | tags: 981 | - $ref: '#/components/tags/MetaMask' 982 | - $ref: '#/components/tags/Restricted' 983 | - $ref: '#/components/tags/Deprecated' 984 | summary: Gets a public key used for encryption. 985 | description: |- 986 | This method is deprecated and may be removed in the future. 987 | 988 | Requests that the user share their public encryption key. 989 | Returns a public encryption key, or rejects if the user denies the request. 990 | The public key is computed from entropy associated with the specified user account, using the NaCl implementation of the `X25519_XSalsa20_Poly1305` algorithm. 991 | params: 992 | - name: Address 993 | required: true 994 | description: The address of the Ethereum account that can decrypt the message. 995 | schema: 996 | $ref: '#/components/schemas/address' 997 | result: 998 | name: EncryptionKey 999 | schema: 1000 | type: string 1001 | examples: 1002 | - name: eth_getEncryptionPublicKey 1003 | params: 1004 | - name: Address 1005 | value: '0x4B0897b0513FdBeEc7C469D9aF4fA6C0752aBea7' 1006 | result: 1007 | name: eth_getEncryptionPublicKeyExampleResult 1008 | value: '0x04bfcab3b7ca7e8b3f3b62b2f7f77e9e4b68080bbf8f0f4a1c8f890864d2c7c1d3c45d8b2e3f5f1c27dfeea4c2f5733e90bfc7484e2a690aa9b8ac4559d2e6a8d7' 1009 | - name: web3_clientVersion 1010 | tags: 1011 | - $ref: '#/components/tags/Ethereum' 1012 | - $ref: '#/components/tags/Multichain' 1013 | description: >- 1014 | Returns the current MetaMask client version. This differs slightly per 1015 | client. For example, the browser extension returns a string like 1016 | `MetaMask/v10.33.1`, while the mobile app returns a string like 1017 | `MetaMask/8.1.2/Mobile`. 1018 | summary: Current client version. 1019 | params: [] 1020 | examples: 1021 | - name: MetaMaskClientVersionExample 1022 | description: Example version response from MetaMask. 1023 | params: [] 1024 | result: 1025 | name: MetaMaskClientVersion 1026 | description: The current client version. 1027 | value: MetaMask/v10.33.1 1028 | - name: MetaMaskMobileClientVersionExample 1029 | description: Example version response from MetaMask Mobile. 1030 | params: [] 1031 | result: 1032 | name: MetaMaskClientVersion 1033 | description: The current client version. 1034 | value: MetaMask/8.1.2/Mobile 1035 | result: 1036 | name: CurrentVersion 1037 | description: The current client version. 1038 | schema: 1039 | title: CurrentClientVersion 1040 | type: string 1041 | - name: eth_subscribe 1042 | tags: 1043 | - $ref: '#/components/tags/Ethereum' 1044 | - $ref: '#/components/tags/Multichain' 1045 | summary: >- 1046 | Subscribes to specific Ethereum events, returning a subscription ID used 1047 | to receive notifications. 1048 | description: >- 1049 | Subscribes to specific events on the Ethereum network, such as new blocks, 1050 | or logs. When an event occurs, a notification is sent to the client with the corresponding 1051 | data. To stop receiving notifications, the client can unsubscribe using 1052 | `eth_unsubscribe`. 1053 | params: 1054 | - name: subscriptionType 1055 | required: true 1056 | schema: 1057 | title: subscriptionType 1058 | type: string 1059 | enum: 1060 | - newHeads 1061 | - logs 1062 | description: |- 1063 | The type of subscription to create. Must be one of the following: 1064 | 1. `newHeads` - New block headers. 1065 | 2. `logs` - Logs matching a filter object. 1066 | - name: filterOptions 1067 | required: false 1068 | schema: 1069 | title: filterOptions 1070 | type: object 1071 | description: >- 1072 | (Optional) An object containing filter options specific to the 1073 | subscription type. Only applicable for the `logs` subscription type. 1074 | required: 1075 | - topics 1076 | properties: 1077 | address: 1078 | type: string 1079 | description: >- 1080 | (Optional) A single address or an array of addresses to filter 1081 | the logs by. 1082 | topics: 1083 | type: array 1084 | description: An array of topics to filter the logs by. 1085 | items: 1086 | type: string 1087 | result: 1088 | name: subscriptionId 1089 | schema: 1090 | type: string 1091 | description: >- 1092 | A unique subscription ID that can be used to unsubscribe or identify 1093 | incoming notifications. 1094 | examples: 1095 | - name: eth_subscribe example 1096 | params: 1097 | - name: subscriptionType 1098 | value: newHeads 1099 | result: 1100 | name: eth_subscribeExampleResult 1101 | value: '0x1b84f2cdf29a204b79e450c1939b30c1' 1102 | - name: eth_unsubscribe 1103 | tags: 1104 | - $ref: '#/components/tags/Ethereum' 1105 | - $ref: '#/components/tags/Multichain' 1106 | summary: >- 1107 | Unsubscribes from a specific Ethereum event, using the subscription ID 1108 | provided by `eth_subscribe`. 1109 | description: >- 1110 | Unsubscribes from specific events on the Ethereum network, to which the 1111 | client has been previously subscribed using `eth_subscribe`. The client 1112 | must provide the subscription ID obtained from `eth_subscribe` to stop 1113 | receiving notifications for the corresponding event. 1114 | params: 1115 | - name: subscriptionId 1116 | required: true 1117 | schema: 1118 | type: string 1119 | description: >- 1120 | The unique subscription ID obtained from `eth_subscribe`, used to 1121 | identify the subscription to be unsubscribed. 1122 | result: 1123 | name: unsubscribed 1124 | schema: 1125 | type: boolean 1126 | description: A boolean value indicating whether the unsubscription was successful. 1127 | examples: 1128 | - name: eth_unsubscribe example 1129 | params: 1130 | - name: subscriptionId 1131 | value: '0x1b84f2cdf29a204b79e450c1939b30c1' 1132 | result: 1133 | name: eth_unsubscribeExampleResult 1134 | value: true 1135 | components: 1136 | schemas: 1137 | TypedData: 1138 | title: Typed data 1139 | description: Object containing information about the typed data to sign. 1140 | type: object 1141 | required: 1142 | - types 1143 | - primaryType 1144 | - domain 1145 | - message 1146 | properties: 1147 | types: 1148 | type: object 1149 | description: Object containing type information. 1150 | required: 1151 | - EIP712Domain 1152 | properties: 1153 | EIP712Domain: 1154 | type: array 1155 | items: 1156 | type: object 1157 | title: Domain separator value 1158 | description: Object containing information about the domain separator value. 1159 | properties: 1160 | name: 1161 | type: string 1162 | description: Name of the domain separator value. 1163 | type: 1164 | type: string 1165 | description: Data type of the domain separator value. 1166 | description: >- 1167 | An array specifying one or more of the following domain 1168 | separator values: 1169 |

1170 | 1177 | additionalProperties: 1178 | type: array 1179 | required: 1180 | - name 1181 | - type 1182 | items: 1183 | type: object 1184 | properties: 1185 | name: 1186 | type: string 1187 | type: 1188 | type: string 1189 | domain: 1190 | type: object 1191 | description: >- 1192 | Object containing the domain separator values specified in the `EIP712Domain` 1193 | type. 1194 | primaryType: 1195 | type: string 1196 | description: The primary type of the message. 1197 | message: 1198 | type: object 1199 | description: The message you're proposing the user to sign. 1200 | SendCallsParameter: 1201 | title: Calls 1202 | description: An object containing information about a batch of calls. 1203 | type: object 1204 | required: 1205 | - version 1206 | - from 1207 | - chainId 1208 | - atomicRequired 1209 | - calls 1210 | properties: 1211 | version: 1212 | description: >- 1213 | The version of the API format. This must be `2.0.0`. 1214 | type: string 1215 | id: 1216 | description: The ID of the batch of calls. 1217 | type: string 1218 | from: 1219 | description: The sender's address. 1220 | type: string 1221 | pattern: '^0x[0-9a-fA-F]{40}$' 1222 | chainId: 1223 | description: >- 1224 | The [EIP-155](https://eips.ethereum.org/EIPS/eip-155) chain ID 1225 | of the calls. This must match the currently selected network in 1226 | the wallet. 1227 | type: string 1228 | pattern: '^0x([1-9a-f]+[0-9a-f]*|0)$' 1229 | atomicRequired: 1230 | description: >- 1231 | `true` if the wallet must execute all calls atomically. If `false`, the 1232 | wallet may execute the calls sequentially without atomicity. If `false` 1233 | and the wallet is capable of executing the calls atomically, it may do so. 1234 | type: boolean 1235 | calls: 1236 | type: array 1237 | description: An array of call objects. 1238 | items: 1239 | title: Call 1240 | description: An object containing information about the call. 1241 | type: object 1242 | properties: 1243 | to: 1244 | description: The address of the call's recipient. 1245 | type: string 1246 | pattern: '^0x[0-9a-fA-F]{40}$' 1247 | data: 1248 | description: The data to send with the call. 1249 | type: string 1250 | pattern: '^0x[0-9a-f]*$' 1251 | value: 1252 | description: The value to send with the call. 1253 | type: string 1254 | pattern: '^0x([1-9a-f]+[0-9a-f]*|0)$' 1255 | capabilities: 1256 | description: >- 1257 | Dapps can use this object to communicate with the wallet about 1258 | supported capabilities. 1259 | type: object 1260 | capabilities: 1261 | description: >- 1262 | Dapps can use this object to communicate with the wallet about 1263 | supported capabilities. 1264 | type: object 1265 | AddEthereumChainParameter: 1266 | title: Chain 1267 | description: Object containing information about the chain to add. 1268 | type: object 1269 | required: 1270 | - chainId 1271 | - chainName 1272 | - nativeCurrency 1273 | - rpcUrls 1274 | properties: 1275 | chainId: 1276 | description: >- 1277 | The chain ID as a `0x`-prefixed hexadecimal string, per the 1278 | `eth_chainId` method. MetaMask compares this chain ID value with the 1279 | `eth_chainId` return value. If these values aren't identical, 1280 | MetaMask rejects the request. 1281 | type: string 1282 | blockExplorerUrls: 1283 | description: >- 1284 | (Optional) An array of one or more URLs pointing to block explorer sites for the 1285 | chain. 1286 | type: array 1287 | items: 1288 | type: string 1289 | description: Block explorer URL. 1290 | chainName: 1291 | description: A human-readable name for the chain. 1292 | type: string 1293 | iconUrls: 1294 | description: >- 1295 | (Optional) An array of one or more URLs pointing to icons that 1296 | can be used to visually identify the chain. Note: MetaMask will not 1297 | currently display these icons. You can still include icon URLs so 1298 | they are used if MetaMask incorporates them into the display 1299 | of custom networks in the future. 1300 | type: array 1301 | items: 1302 | format: uri 1303 | type: string 1304 | description: Icon URL. 1305 | nativeCurrency: 1306 | $ref: '#/components/schemas/NativeCurrency' 1307 | rpcUrls: 1308 | description: >- 1309 | An array of one or more URLs pointing to RPC endpoints that can be used to 1310 | communicate with the chain. At least one item is required, and only 1311 | the first item is used. 1312 | type: array 1313 | minItems: 1 1314 | items: 1315 | format: uri 1316 | type: string 1317 | description: RPC URL. 1318 | NativeCurrency: 1319 | title: NativeCurrency 1320 | type: object 1321 | description: >- 1322 | An object containing information about the native currency of the chain. 1323 | required: 1324 | - decimals 1325 | - symbol 1326 | properties: 1327 | decimals: 1328 | description: A non-negative integer representing the number of decimals the native currency uses. 1329 | minimum: 0 1330 | type: integer 1331 | name: 1332 | description: A human-readable name of the native currency. 1333 | type: string 1334 | symbol: 1335 | description: A human-readable symbol of the native currency. 1336 | type: string 1337 | Caveats: 1338 | title: Caveats 1339 | description: >- 1340 | An array of caveats that specify restrictions on the permission. 1341 | type: array 1342 | items: 1343 | title: Caveat 1344 | description: Object containing information about the caveat. 1345 | type: object 1346 | properties: 1347 | type: 1348 | title: Type 1349 | type: string 1350 | description: Type of caveat. 1351 | value: 1352 | title: CaveatValue 1353 | description: Value of the caveat. 1354 | name: 1355 | title: Name 1356 | type: string 1357 | description: Name of the caveat. 1358 | Permission: 1359 | title: Permission 1360 | description: Object containing information about the permission. 1361 | type: object 1362 | properties: 1363 | id: 1364 | description: The permission ID. 1365 | type: string 1366 | parentCapability: 1367 | description: >- 1368 | The name of the permission being granted. For example, `eth_accounts` or 1369 | `endowment:permitted-chains`. 1370 | type: string 1371 | invoker: 1372 | description: The URI of the dapp being granted this permission. 1373 | type: string 1374 | caveats: 1375 | $ref: '#/components/schemas/Caveats' 1376 | date: 1377 | description: The timestamp of the permission request. 1378 | type: number 1379 | PermissionsList: 1380 | title: Permissions list 1381 | description: An array of the user's permissions. 1382 | type: array 1383 | items: 1384 | $ref: '#/components/schemas/Permission' 1385 | tags: 1386 | MetaMask: 1387 | name: MetaMask 1388 | description: MetaMask-specific methods. 1389 | Restricted: 1390 | name: Restricted 1391 | description: >- 1392 | Restricted methods. If a method is restricted, the caller must have the 1393 | corresponding permission via `wallet_requestPermissions` in order to 1394 | call it. 1395 | Mobile: 1396 | name: Mobile 1397 | description: Mobile-specific methods. 1398 | Experimental: 1399 | name: Experimental 1400 | description: Experimental methods. 1401 | Deprecated: 1402 | name: Deprecated 1403 | description: Deprecated methods. 1404 | Ethereum: 1405 | name: Ethereum API 1406 | description: Ethereum execution API methods. 1407 | Multichain: 1408 | name: Multichain API 1409 | description: Multichain API methods. 1410 | errors: 1411 | UserRejected: 1412 | code: 4001 1413 | message: User rejected the request. 1414 | InvalidParams: 1415 | code: -32602 1416 | message: The wallet cannot parse the request. 1417 | Unauthorized: 1418 | code: 4100 1419 | message: The requested account and/or method has not been authorized by the user. 1420 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@metamask/api-specs", 3 | "description": "", 4 | "publishConfig": { 5 | "access": "public" 6 | }, 7 | "homepage": "https://metamask.github.io/api-specs/", 8 | "main": "dist/index.js", 9 | "files": [ 10 | "dist/", 11 | "dist/build" 12 | ], 13 | "scripts": { 14 | "start": "yarn build", 15 | "build": "mkdir -p src/build && node merge-openrpc.js && tsc && rm -rf src/build", 16 | "build:watch": "nodemon", 17 | "prepublishOnly": "./scripts/prepack.sh", 18 | "test": "yarn build && jest" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "https://github.com/MetaMask/api-specs.git" 23 | }, 24 | "author": "", 25 | "license": "Apache-2.0", 26 | "devDependencies": { 27 | "@open-rpc/meta-schema": "^1.14.2", 28 | "@open-rpc/schema-utils-js": "^1.16.1", 29 | "@types/jest": "^29.2.6", 30 | "@xops.net/openrpc-cli": "^1.0.2", 31 | "jest": "^29.3.1", 32 | "js-yaml": "^4.1.0", 33 | "json-schema-merge-allof": "^0.8.1", 34 | "node-fetch": "^2.6.1", 35 | "nodemon": "^2.0.22", 36 | "ts-jest": "^29.0.5", 37 | "typescript": "~4.8.4" 38 | }, 39 | "version": "0.14.0", 40 | "engines": { 41 | "node": "^18.20 || ^20.17 || >=22" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /scripts/get.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -u 5 | set -o pipefail 6 | 7 | if [[ ${RUNNER_DEBUG:-0} == 1 ]]; then 8 | set -x 9 | fi 10 | 11 | KEY="${1}" 12 | OUTPUT="${2}" 13 | 14 | if [[ -z $KEY ]]; then 15 | echo "Error: KEY not specified." 16 | exit 1 17 | fi 18 | 19 | if [[ -z $OUTPUT ]]; then 20 | echo "Error: OUTPUT not specified." 21 | exit 1 22 | fi 23 | 24 | echo "$OUTPUT=$(jq --raw-output "$KEY" package.json)" >> "$GITHUB_OUTPUT" 25 | -------------------------------------------------------------------------------- /scripts/prepack.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -o pipefail 5 | 6 | if [[ -n $SKIP_PREPACK ]]; then 7 | echo "Notice: skipping prepack." 8 | exit 0 9 | fi 10 | 11 | yarn build 12 | -------------------------------------------------------------------------------- /scripts/show-changelog.awk: -------------------------------------------------------------------------------- 1 | # DESCRIPTION 2 | # 3 | # This script will print out all of the CHANGELOG.md lines for a given version 4 | # with the assumption that the CHANGELOG.md files looks something along the 5 | # lines of: 6 | # 7 | # ``` 8 | # ## 6.6.2 Fri Jun 07 2019 9 | # 10 | # - [#6690](https://github.com/MetaMask/metamask-extension/pull/6690): Some words 11 | # - [#6700](https://github.com/MetaMask/metamask-extension/pull/6700): some more words 12 | # 13 | # ## 6.6.1 Thu Jun 06 2019 14 | # 15 | # - [#6691](https://github.com/MetaMask/metamask-extension/pull/6691): Revert other words 16 | # 17 | # ## 6.6.0 Mon Jun 03 2019 18 | # 19 | # - [#6659](https://github.com/MetaMask/metamask-extension/pull/6659): foo 20 | # - [#6671](https://github.com/MetaMask/metamask-extension/pull/6671): bar 21 | # - [#6625](https://github.com/MetaMask/metamask-extension/pull/6625): baz 22 | # - [#6633](https://github.com/MetaMask/metamask-extension/pull/6633): Many many words 23 | # 24 | # 25 | # ``` 26 | # 27 | # EXAMPLE 28 | # 29 | # Run this script like so, passing in the version: 30 | # 31 | # ``` 32 | # awk -v version='6.6.0' -f .circleci/scripts/show-changelog.awk CHANGELOG.md 33 | # ``` 34 | # 35 | 36 | BEGIN { 37 | inside_section = 0; 38 | } 39 | 40 | $1 == "##" && $2 == version { 41 | inside_section = 1; 42 | next; 43 | } 44 | 45 | $1 == "##" && $2 != version { 46 | inside_section = 0; 47 | next; 48 | } 49 | 50 | inside_section && !/^$/ { 51 | print $0; 52 | } 53 | -------------------------------------------------------------------------------- /scripts/update-package-version.js: -------------------------------------------------------------------------------- 1 | const util = require("util"); 2 | const fs = require("fs"); 3 | const path = require("path"); 4 | 5 | const promisifiedFsReadFile = util.promisify(fs.readFile); 6 | const promisifiedFsWriteFile = util.promisify(fs.writeFile); 7 | 8 | const changeVersion = async (filePath, version) => { 9 | const file = await promisifiedFsReadFile(filePath); 10 | const json = JSON.parse(file.toString()); 11 | json.version = version; 12 | return promisifiedFsWriteFile(filePath, JSON.stringify(json, null, 4) + "\n"); 13 | }; 14 | const p = path.resolve(__dirname, "..", "package.json"); 15 | 16 | changeVersion(p, process.env.NEW_VERSION).then(() => { 17 | console.log("wrote new version") 18 | }).catch((err) => { 19 | console.error("error writing new version") 20 | console.error(err); 21 | }); 22 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import MetaMaskOpenRPCDocument from "./build/openrpc.json"; 2 | import MultiChainOpenRPCDocument from "./build/multichain-openrpc.json"; 3 | export { MetaMaskOpenRPCDocument, MultiChainOpenRPCDocument }; 4 | export default MetaMaskOpenRPCDocument; 5 | -------------------------------------------------------------------------------- /tests/index.test.ts: -------------------------------------------------------------------------------- 1 | import {OpenrpcDocument} from "@open-rpc/meta-schema" 2 | import mm from '../dist/build/openrpc.json'; 3 | 4 | const MetaMaskOpenRPCDocument = mm as OpenrpcDocument; 5 | 6 | 7 | import {parseOpenRPCDocument} from '@open-rpc/schema-utils-js' 8 | 9 | describe("MetaMask API Reference", () => { 10 | 11 | it('can be parsed', async () => { 12 | expect(MetaMaskOpenRPCDocument).toBeDefined(); 13 | const result = await parseOpenRPCDocument(MetaMaskOpenRPCDocument); 14 | expect(result).toBeDefined(); 15 | }); 16 | 17 | }); 18 | 19 | -------------------------------------------------------------------------------- /tests/merge-utils.test.ts: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | import mergeOpenRPC from '../merge-utils'; 3 | 4 | describe("merge openrpc document", () => { 5 | describe('mergeOpenRPC', () => { 6 | it('result does not contain duplicate methods', () => { 7 | const doc1 = { 8 | info: {}, 9 | methods: [ 10 | { name: 'foo', description: 'abc' }, 11 | { name: 'bar' }, 12 | { name: 'baz' }, 13 | ], 14 | components: {} 15 | }; 16 | const doc2 = { 17 | info: {}, 18 | methods: [ 19 | { name: 'foo', description: '123' }, 20 | { name: 'bling' }, 21 | { name: 'blang' }, 22 | ], 23 | components: {} 24 | }; 25 | expect(mergeOpenRPC(doc1, doc2).methods[0].description).toBe("abc"); 26 | }); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true, 4 | "forceConsistentCasingInFileNames": true, 5 | "resolveJsonModule": true, 6 | "declaration": true, 7 | "rootDir": "./src", 8 | "lib": ["ES2020"], 9 | "module": "CommonJS", 10 | "moduleResolution": "node", 11 | "outDir": "./dist", 12 | "noErrorTruncation": true, 13 | "noUncheckedIndexedAccess": true, 14 | "strict": true, 15 | "target": "es2017" 16 | }, 17 | "exclude": ["./dist/**/*", "node_modules/", "./tests"] 18 | } 19 | --------------------------------------------------------------------------------