Giter Site home page Giter Site logo

api-specs's Introduction

MetaMask API Specs

API Playground: https://metamask.github.io/api-playground/api-documentation API Reference Docs: https://docs.metamask.io/wallet/reference/json-rpc-api/

Latest build: https://metamask.github.io/api-specs/latest/openrpc.json

JSON-RPC API provided by MetaMask.

MetaMask dapp developers lack a formal RPC specification. This attempts to document which methods MetaMask supports in a way that's versionable, human-readable and machine-readable. It will improve the accuracy of documentation, API, and clients.

MetaMasks effectiveness as an enterprise-grade application platform depends on its ability to provide a reliable and predictable developer experience.

Contributing

Edit the openrpc.yaml file.

You can then run yarn run build to generate the output file again.

To test the result, you can paste the resulting file from dist/build/openrpc.json into the OpenRPC playground and view the result.

Build Process

  • filter out methods that are not supported/implemented by metamask
  • merge wallet methods with execution api methods
  • output to build

Deploy

  • On release uploads to npm at @metamask/api-specs
  • On release uploads to github pages at https://metamask.github.io/api-specs/latest/metamask-openrpc.json

api-specs's People

Contributors

adonesky1 avatar aednikanov avatar alaahd avatar alexandratran avatar belfordz avatar danfinlay avatar dependabot[bot] avatar github-actions[bot] avatar httpjunkie avatar jiexi avatar joaniefromtheblock avatar lukaw3d avatar metamaskbot avatar rekmarks avatar shanejonas avatar tmashuang avatar vandan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-specs's Issues

How to recover some tokens from one network to another via MetaMask API.

Hello:
I have an issue which I want to solve it by MetaMask API, but before I spend more time on this topic, please provide some advice.
A few weeks ago, I sent some cryptocurrency tokens (Ruff Chain) from one exchange to another exchange. Unfortunately, even the sender’s exchange shows the successful sending, but the only network for sending this token on the sender’s exchange is on HECO network, but the receiver’s deposit address can receive the same token using only ERC20 network.
So those sent tokens stayed in the network for more than one month. The receiver’s exchange has recently released some kind of token recovery tools, so I can recover those tokens sent to my deposit address using ERC20 network. But I have to pay 100USDT each time if I use their tools.
I want to know if I can write some code (JavaScript) to do the similar job?
Or, if it is not easy to do this, then, can I use MetaMask wallet to receive similar tokens, which the sending network and the receiving network don’t match, thus cause the tokens not reaching their deposit addresses forever. If I can use MetaMask wallet to receive those tokens first, then change their network, then send them again from MetaMask wallet using the same network as the receiver’s deposits address network. That is changing from HECO network to REC20 network.
If not possible, then let me know, I will pay the fee to use the receiver’s exchange tools to recover my tokens.
If possible, please give some general ideas on how I can do this or provide some further readings on this topic. I can do this by hand for a few times, if possible, but I wish to be able to do this more via API, since there could be more chances to use this API functions.
Thanks,

personal_sign spec and docs are incorrect about signature length

Spec and docs say:

description: A hex-encoded 129-byte array starting with `0x`.

But personal_sign signatures are 65-bytes long, e.g.:

  • 0x587c03f5289ecc735901934bd7c60266848212bb6609e7865885963e9884b2ac68c05b61307aca7ad3fffb62ff9f37eab85f93e8bf4fb84c720d99c8598086871b
  • 0x6449b69d356d6cded96ae3d0a30ad041b2a070a21d9b88047a4c377a1fe655646bb0b69e17201203e1131b0f7103db242c1bd87b0c72fa57f5782e7f7ec127451c

Missing Specs Audit

Missing MetaMask Methods

  • eth_requestAccounts [https://eips.ethereum.org/EIPS/eip-1102] (issue: #101)

Missing Client methods

  • eth_getUncleByBlockHashAndIndex, eth_getUncleByBlockNumberAndIndex, (not in ethereum/execution-apis but supported by major infra nodes including infura)
  • eth_protocolVersion (removed from ethereum/execution-apis? but infura supports)
  • eth_subscribe / eth_unsubscribe [https://eips.ethereum.org/EIPS/eip-758] (issue: #89)
  • eth_sign [we've semi deprecated so maybe not?]

WIP

  • eth_signTypedData [https://github.com//pull/123]

MetaMask specific methods that are complete:

  • wallet_addEthereumChain
  • wallet_switchEthereumChain
  • wallet_requestPermissions
  • wallet_getPermissions
  • wallet_registerOnboarding
  • wallet_watchAsset
  • eth_decrypt
  • eth_getEncryptionPublicKey
  • eth_accounts
  • personal_sign

Publish builds to NPM via CI

Add npm publish step to our publish action

When this repo was made we hadn't really figured out the npm publish part. but we should be able to use whats in the metamask-module-template now since it has support for npm publishing.

add this at the bottom of .github/workflows/publish-release.yml. and follow the instructions in the comment below to set up the token.

      - name: Publish NPM
        uses: MetaMask/action-npm-publish@v2
        with:
          # This `NPM_TOKEN` needs to be manually set per-repository.
          # Look in the repository settings under "Environments", and set this token in the `npm-publish` environment.
          npm-token: ${{ secrets.NPM_TOKEN }}
        env:
          SKIP_PREPACK: true

source: https://github.com/MetaMask/metamask-module-template/blob/c2b55bce243483c4edcc3c454bba415ff996335b/.github/workflows/publish-release.yml#L64-L86

Invalid `wallet_requestSnaps` and `wallet_invokeSnap` specs

wallet_requestSnaps and wallet_invokeSnap use an object as params, but on the docs, the params are currently being wrapped in an array.

The spec and examples should be updated to use this format:

wallet_requestSnaps

type Request = {
  method: 'wallet_requestSnaps';
  params: Record<SnapId, { version?: SemVerVersion; }>;
}

wallet_invokeSnap

type Request = {
  method: 'wallet_invokeSnap',
  params: {
    snapId: SnapId;
    request: {
      method: string;
      params: Json;
    }
  }
}

Setup preview builds

We want to be able to have a preview link to the built openrpc document so that metamask-docs's previews will work with un-merged changes to api-specs.

Add getLocale rpc method

Create a new rpc API endpoint to get current language

Mirko's notes:

  • Implementation should live inside Lib/rpc-method-middleware
  • Look for other methods implementation (e.g. addCustomChain)
  • Look into createMethodMiddleware
  • Test on the test dapp and/or playground

the open-rpc document should be paste-able into playground

At the moment, the document is using local refs to a schema that doesnt exist until you bundle it. This ticket is to make the document more easy to work on by only using remote refs when the underlying ref is from execution-apis document.

Add error codes for methods

Each method has a common set of error codes but also in some cases unique error codes we need to document

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.