Skip to content

Commit

Permalink
Update links and plugin version (MetaMask#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandratran authored Apr 13, 2023
1 parent 216c364 commit be50fd4
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 258 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"devDependencies": {
"@docusaurus/eslint-plugin": "^2.4.0",
"@docusaurus/module-type-aliases": "2.4.0",
"@docusaurus/plugin-client-redirects": "2.3.1",
"@docusaurus/plugin-client-redirects": "2.4.0",
"@lavamoat/allow-scripts": "^2.3.0",
"@tsconfig/docusaurus": "^1.0.5",
"@typescript-eslint/eslint-plugin": "^5.41.0",
Expand Down
4 changes: 2 additions & 2 deletions snaps/concepts/execution-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ The following globals are also available:
- `console`
- `crypto`
- `fetch` (with the
[`endowment:network-access`](../reference/permissions.md#endowment--network-access) permission)
[`endowment:network-access`](../reference/permissions.md#endowmentnetwork-access) permission)
- `setTimeout` / `clearTimeout`
- `setInterval` / `clearInterval`
- `SubtleCrypto`
- `WebAssembly` (with the
[`endowment:webassembly`](../reference/permissions.md#endowment--webassembly) permission)
[`endowment:webassembly`](../reference/permissions.md#endowmentwebassembly) permission)
- `TextEncoder` / `TextDecoder`
- `atob` / `btoa`
- `URL`
Expand Down
2 changes: 1 addition & 1 deletion snaps/concepts/user-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ For each snap, the user can:
Other than the settings page, a snap can modify the MetaMask UI using
[custom UI](../how-to/use-custom-ui.md) in only two ways:

- By opening a dialog using the [`snap_dialog`](../reference/rpc-api.md#snapdialog) RPC method.
- By opening a dialog using the [`snap_dialog`](../reference/rpc-api.md#snap_dialog) RPC method.
- By returning transaction insights from the [`onTransaction`](../reference/exports.md#ontransaction)
export.

Expand Down
6 changes: 3 additions & 3 deletions snaps/how-to/manage-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ To derive a user's private keys:
1. Choose between the BIP-32 or BIP-44 specifications to derive the user's private keys.
If the keys you want to derive conform to the
[BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) structure, use
[`snap_getBip44Entropy`](../reference/rpc-api.md#snapgetbip44entropy) to derive them.
Otherwise, use [`snap_getBip32Entropy`](../reference/rpc-api.md#snapgetbip32entropy).
[`snap_getBip44Entropy`](../reference/rpc-api.md#snap_getbip44entropy) to derive them.
Otherwise, use [`snap_getBip32Entropy`](../reference/rpc-api.md#snap_getbip32entropy).
2. Add the required permission to your manifest file.
3. Find out the derivation path to use.
This is dependent on the application you're building.
Expand All @@ -59,7 +59,7 @@ To derive a user's private keys:
For example, to derive Dogecoin keys:

1. Dogecoin uses the BIP-44 scheme, so you'll use
[`snap_getBip44Entropy`](../reference/rpc-api.md#snapgetbip44entropy).
[`snap_getBip44Entropy`](../reference/rpc-api.md#snap_getbip44entropy).
2. Dogecoin has coin type `3`, so add the following to the manifest file:

```json
Expand Down
4 changes: 2 additions & 2 deletions snaps/how-to/request-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and you must specify a snap's required permissions in the `initialPermissions` f
You must request permission to use any
[restricted JSON-RPC API methods](../reference/rpc-api.md#restricted-methods).

For example, to request to use [`snap_dialog`](../reference/rpc-api.md#snapdialog), add the
For example, to request to use [`snap_dialog`](../reference/rpc-api.md#snap_dialog), add the
following to the manifest file:

```json
Expand All @@ -29,7 +29,7 @@ Endowments are a type of permission.
See the [Snaps permissions reference](../reference/permissions.md) for the full list of endowments
you can specify in the manifest file.

For example, to request the [`endowment:long-running`](../reference/permissions.md#endowment--long-running)
For example, to request the [`endowment:long-running`](../reference/permissions.md#endowmentlong-running)
permission, add the following to the manifest file:

```json
Expand Down
2 changes: 1 addition & 1 deletion snaps/how-to/use-custom-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Use a custom user interface.

# Use custom UI

The [`snap_dialog`](../reference/rpc-api.md#snapdialog) RPC method and
The [`snap_dialog`](../reference/rpc-api.md#snap_dialog) RPC method and
[`onTransaction`](../reference/exports.md#ontransaction) exported method use the
`@metamask/snaps-ui` module to display custom user interface (UI) components.

Expand Down
6 changes: 3 additions & 3 deletions snaps/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ modify existing functionalities using the [Snaps JSON-RPC API](reference/rpc-api

For example, you can:

- [Display a custom confirmation screen](reference/rpc-api.md#snapdialog) in MetaMask.
- [Display a custom confirmation screen](reference/rpc-api.md#snap_dialog) in MetaMask.
- [Notify users](reference/rpc-api.md#snapnotify) in MetaMask.
- [Securely store and manage data](reference/rpc-api.md#snapmanagestate) on your device.
- [Control non-EVM accounts and assets](reference/rpc-api.md#snapgetbip44entropy) in MetaMask.
- [Securely store and manage data](reference/rpc-api.md#snap_managestate) on your device.
- [Control non-EVM accounts and assets](reference/rpc-api.md#snap_getbip44entropy) in MetaMask.
- [Provide transaction insights](reference/exports.md#ontransaction) in MetaMask's pre-transaction window.
- [Schedule periodic actions](reference/exports.md#oncronjob) for your users.
- [Display custom UI](how-to/use-custom-ui.md) in MetaMask using a set of pre-defined components,
Expand Down
8 changes: 4 additions & 4 deletions snaps/reference/exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ MetaMask passes the raw unsigned transaction payload to the `onTransaction` hand

:::note
For MetaMask to call the snap's `onTransaction` method, you must request the
[`endowment:transaction-insight`](permissions.md#endowment--transaction-insight) permission.
[`endowment:transaction-insight`](permissions.md#endowmenttransaction-insight) permission.
:::

### Parameters
Expand All @@ -91,7 +91,7 @@ An object containing:
- `chainId` - The [CAIP-2](https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md)
chain ID.
- `transactionOrigin` - The transaction origin if
[`allowTransactionOrigin`](permissions.md#endowment--transaction-insight) is set to `true`.
[`allowTransactionOrigin`](permissions.md#endowmenttransaction-insight) is set to `true`.

### Returns

Expand Down Expand Up @@ -151,11 +151,11 @@ module.exports.onTransaction = async ({

To run periodic actions for the user (cron jobs), a snap must export `onCronjob`.
This method is called at the specified times with the specified payloads defined in the
[`endowment:cronjob`](permissions.md#endowment--cronjob) permission.
[`endowment:cronjob`](permissions.md#endowmentcronjob) permission.

:::note
For MetaMask to call the snap's `onCronjob` method, you must request the
[`endowment:cronjob`](permissions.md#endowment--cronjob) permission.
[`endowment:cronjob`](permissions.md#endowmentcronjob) permission.
:::

### Parameters
Expand Down
4 changes: 2 additions & 2 deletions snaps/reference/rpc-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ to use a restricted method.

:::caution
This method is deprecated.
Please migrate all instances of `snap_confirm` to [`snap_dialog`](#snapdialog).
Please migrate all instances of `snap_confirm` to [`snap_dialog`](#snap_dialog).
:::

Displays a confirmation in the MetaMask UI.
Expand Down Expand Up @@ -730,7 +730,7 @@ The `*` in the name is always substituted for a string, in this case a snap ID.
:::

:::tip
[`wallet_invokeSnap`](#walletinvokesnap) provides a more convenient way of calling this method.
[`wallet_invokeSnap`](#wallet_invokesnap) provides a more convenient way of calling this method.
:::

#### Parameters
Expand Down
2 changes: 1 addition & 1 deletion snaps/tutorials/gas-estimation.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ This is a free icon, **Gas** by Mello from
### 3. Enable network access

To enable your snap to use the `fetch` API, request the
[`endowment:network-access`](../reference/permissions.md#endowment--network-access) permission by
[`endowment:network-access`](../reference/permissions.md#endowmentnetwork-access) permission by
modifying `initialPermissions` in `snap.manifest.json`:

```json title="snap.manifest.json"
Expand Down
4 changes: 2 additions & 2 deletions snaps/tutorials/transaction-insights.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ method using the global Ethereum provider made available to snaps.
To enable your snap to provide transaction insights and use the global Ethereum provider, open
`/packages/snap/snap.manifest.json` in a text editor.
Request the
[`endowment:transaction-insight`](../reference/permissions.md#endowment--transaction-insight) and
[`endowment:ethereum-provider`](../reference/permissions.md#endowment--ethereum-provider)
[`endowment:transaction-insight`](../reference/permissions.md#endowmenttransaction-insight) and
[`endowment:ethereum-provider`](../reference/permissions.md#endowmentethereum-provider)
permissions by modifying `initialPermissions`:

```json title="snap.manifest.json"
Expand Down
5 changes: 3 additions & 2 deletions wallet/concepts/signing-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ versions with hard-versioned method names:
- `eth_signTypedData_v3` – A highly used version of the EIP-712 specification.
Read the
[introductory blog post to this method](https://medium.com/metamask/eip712-is-coming-what-to-expect-and-how-to-use-it-bb92fd1a7a26).
- `eth_signTypedData_v4` – The latest version of the EIP-712 specification, with added
support for arrays and a breaking fix for the way structs are encoded.
- [`eth_signTypedData_v4`](https://metamask.github.io/api-playground/api-documentation/#eth_signTypedData_v4)
– The latest version of the EIP-712 specification, with added support for arrays and a breaking
fix for the way structs are encoded.
Read the
[introductory blog post to this method](https://medium.com/metamask/eip712-is-coming-what-to-expect-and-how-to-use-it-bb92fd1a7a26).

Expand Down
2 changes: 1 addition & 1 deletion wallet/get-started/access-accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ User accounts are used in a variety of contexts in Ethereum, including as identi
[signing transactions](../how-to/sign-data.md).
To request a signature from a user or have a user approve a transaction, your dapp must
access the user's accounts using the
[`eth_requestAccounts`](../reference/rpc-api.md#ethrequestaccounts) RPC method.
[`eth_requestAccounts`](../reference/rpc-api.md#eth_requestaccounts) RPC method.

When accessing a user's accounts:

Expand Down
4 changes: 2 additions & 2 deletions wallet/how-to/interact-with-smart-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Many dapp developers deploy their contract to a testnet first, in order to avoid
disastrous fees if something goes wrong during development and testing on Mainnet.

Regardless of which network you deploy your final dapp on, your users must be able to access it.
Use the [`wallet_switchEthereumChain`](../reference/rpc-api.md#walletswitchethereumchain) and
[`wallet_addEthereumChain`](../reference/rpc-api.md#walletaddethereumchain) RPC methods to prompt
Use the [`wallet_switchEthereumChain`](../reference/rpc-api.md#wallet_switchethereumchain) and
[`wallet_addEthereumChain`](../reference/rpc-api.md#wallet_addethereumchain) RPC methods to prompt
the user to add a chain that you suggest, and switch to it using a confirmation dialogue.

## Contract address
Expand Down
10 changes: 5 additions & 5 deletions wallet/how-to/migrate-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ you can find [here](https://github.com/ethereum/web3.js/blob/0.20.7/DOCUMENTATIO

For many web3 sites, the API provided by `window.ethereum` is sufficient.
Much of the `web3` API simply maps to RPC methods, all of which can be requested using
[`ethereum.request()`](../reference/provider-api.md#ethereumrequestargs).
[`ethereum.request()`](../reference/provider-api.md#windowethereumrequestargs).
For example, here are a couple of actions performed using first `window.web3`, and then their
equivalents using `window.ethereum`.

Expand Down Expand Up @@ -181,7 +181,7 @@ Please follow the relevant link below to install the Legacy Web3 extension in yo
The `eth_chainId` RPC method now returns correctly formatted values, e.g. `0x1` and `0x2`, instead
of _incorrectly_ formatted values, e.g. `0x01` and `0x02`.
MetaMask's implementation of `eth_chainId` used to return 0-padded values for the
[default Ethereum chains](../reference/provider-api.md#chain-ids) _except_ Kovan.
[default Ethereum chains](../get-started/detect-network.md#chain-ids) _except_ Kovan.
If you expect 0-padded chain ID values from `eth_chainId`, make sure to update your code to expect
the correct format instead.

Expand Down Expand Up @@ -216,10 +216,10 @@ introduction of MetaMask's [permission system](../reference/rpc-api.md#restricte

We recommend that you check for account access in the following ways:

1. You can call the [`wallet_getPermissions` RPC method](../reference/rpc-api.md#wallet_getpermissions)
1. You can call the [`wallet_getPermissions`](../reference/rpc-api.md#wallet_getpermissions) RPC method
and check for the `eth_accounts` permission.
1. You can call the `eth_accounts` RPC method and the
[`ethereum._metamask.isUnlocked()` method](../reference/provider-api.md#ethereum_metamaskisunlocked).
[`ethereum._metamask.isUnlocked()`](../reference/provider-api.md#windowethereum_metamaskisunlocked) method.
- MetaMask has to be unlocked before you can access the user's accounts.
If the array returned by `eth_accounts` is empty, check if MetaMask is locked using `isUnlocked()`.
- If MetaMask is unlocked and you still aren't receiving any accounts, it's time to request
Expand All @@ -233,7 +233,7 @@ and accessing the `publicConfigStore` internal state directly.

We recommend that you search your code and its dependencies for references to `publicConfigStore`.
If you find any references, you should understand what it's being used for, and migrate to
[one of the recommended provider APIs](../reference/provider-api.md#using-the-provider) instead.
[one of the recommended provider APIs](../reference/provider-api.md) instead.
If you don't find any references, you should not be affected by this change.

Although it is possible that your dependencies use the `publicConfigStore`, we have confirmed that
Expand Down
2 changes: 1 addition & 1 deletion wallet/how-to/register-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ user must register the token themselves.
This process can be cumbersome, involves the user interacting with contract addresses, and is error-prone.

You can improve the security and experience of users registering your token on their MetaMask
interface by using the [`wallet_watchAsset`](../reference/rpc-api.md#walletwatchasset) RPC method.
interface by using the [`wallet_watchAsset`](../reference/rpc-api.md#wallet_watchasset) RPC method.

For example, you can add something like the following to your project script:

Expand Down
9 changes: 5 additions & 4 deletions wallet/how-to/sign-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ description: Sign data using eth_signTypedData_v4 and personal_sign.

You can use the following RPC methods to request cryptographic signatures from users:

- [`eth_signTypedData_v4`](#use-ethsigntypeddatav4) - Use this method to request the most human-readable
- [`eth_signTypedData_v4`](#use-eth_signtypeddata_v4) - Use this method to request the most human-readable
signatures that are efficient to process on-chain.
We recommend this for most use cases.
- [`personal_sign`](#use-personalsign) - Use this method for the easiest way to request human-readable
- [`personal_sign`](#use-personal_sign) - Use this method for the easiest way to request human-readable
signatures that don't need to be efficiently processed on-chain.

Read more about [the history of the signing methods](../concepts/signing-methods.md).

:::caution
[`eth_sign`](../concepts/signing-methods.md#ethsign) is deprecated.
[`eth_sign`](../concepts/signing-methods.md#eth_sign) is deprecated.
:::

:::note
Expand All @@ -27,7 +27,8 @@ sign data using an unsupported method, in which case we recommend using your sta

## Use eth_signTypedData_v4

`eth_signTypedData_v4` provides the most human-readable signatures that are efficient to process on-chain.
[`eth_signTypedData_v4`](https://metamask.github.io/api-playground/api-documentation/#eth_signTypedData_v4)
provides the most human-readable signatures that are efficient to process on-chain.
It follows the [EIP-712](https://eips.ethereum.org/EIPS/eip-712) specification to allow users to sign
typed structured data that can be verified on-chain.
It renders the structured data as usefully as possible to the user (for example, displaying known
Expand Down
4 changes: 2 additions & 2 deletions wallet/how-to/use-sdk/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ const ethereum = MMSDK.getProvider(); // You can also access via window.ethereum

Use the SDK by calling any [provider API methods](../../reference/provider-api.md).
Always call [`eth_requestAccounts`](../../reference/rpc-api.md#eth_requestaccounts) using
[`ethereum.request()`](../../reference/provider-api.md#ethereumrequestargs) first, since it prompts
the installation or connection popup to appear.
[`ethereum.request(args)`](../../reference/provider-api.md#windowethereumrequestargs)
first, since it prompts the installation or connection popup to appear.

```javascript
ethereum.request({ method: 'eth_requestAccounts', params: [] });
Expand Down
2 changes: 1 addition & 1 deletion wallet/how-to/use-sdk/ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ project file:
```

The following examples use the
[`window.ethereum.request(args)`](../../reference/provider-api.md#windowethereumrequest--args-)
[`window.ethereum.request(args)`](../../reference/provider-api.md#windowethereumrequestargs)
provider API method to call various [RPC API](../../reference/rpc-api.md) methods.

#### Example: Get chain ID
Expand Down
4 changes: 2 additions & 2 deletions wallet/how-to/use-sdk/pure-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ To import, instantiate, and use the SDK, you can insert a script in the head sec
You can configure the SDK using any [options](../../reference/sdk-js-options.md) and call any
[provider API methods](../../reference/provider-api.md).
Always call [`eth_requestAccounts`](../../reference/rpc-api.md#eth_requestaccounts) using
[`ethereum.request()`](../../reference/provider-api.md#ethereumrequestargs) first, since it prompts
the installation or connection popup to appear.
[`ethereum.request(args)`](../../reference/provider-api.md#windowethereumrequestargs) first, since
it prompts the installation or connection popup to appear.
4 changes: 2 additions & 2 deletions wallet/how-to/use-sdk/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ const accounts = await ethereum.request({ method: 'eth_requestAccounts' });

You can configure the SDK using any [options](../../reference/sdk-js-options.md) and call any
[provider API methods](../../reference/provider-api.md).
Always call [`eth_requestAccounts`](../../reference/rpc-api.md#ethrequestaccounts) using
[`ethereum.request()`](../../reference/provider-api.md#windowethereumrequest--args-) first, since it
Always call [`eth_requestAccounts`](../../reference/rpc-api.md#eth_requestaccounts) using
[`ethereum.request()`](../../reference/provider-api.md#windowethereumrequestargs) first, since it
prompts the installation or connection popup to appear.

You can use [EthersJS](https://docs.ethers.io/v5/getting-started/) with your React Native app:
Expand Down
11 changes: 6 additions & 5 deletions wallet/reference/provider-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ window.ethereum.on('connect', handler: (connectInfo: ConnectInfo) => void);

The provider emits this event when it's first able to submit RPC requests to a chain.
We recommend listening to this event and using the
[`window.ethereum.isConnected()`](#windowethereumisconnected--) provider method to determine when
[`window.ethereum.isConnected()`](#windowethereumisconnected) provider method to determine when
the provider is connected.

### disconnect
Expand All @@ -192,7 +192,7 @@ In general, this only happens due to network connectivity issues or some unfores

When the provider emits this event, it doesn't accept new requests until the connection to the chain
is re-established, which requires reloading the page.
You can also use the [`window.ethereum.isConnected()`](#windowethereumisconnected--) provider method
You can also use the [`window.ethereum.isConnected()`](#windowethereumisconnected) provider method
to determine if the provider is disconnected.

### message
Expand All @@ -210,8 +210,9 @@ The provider emits this event when it receives a message that the user should be
The `type` property identifies the kind of message.

RPC subscription updates are a common use case for this event.
For example, if you create a subscription using `eth_subscribe`, each subscription update is emitted
as a `message` event with a `type` of `eth_subscription`.
For example, if you create a subscription using
[`eth_subscribe`](https://metamask.github.io/api-playground/api-documentation/#eth_subscribe), each
subscription update is emitted as a `message` event with a `type` of `eth_subscription`.

## Errors

Expand All @@ -225,7 +226,7 @@ interface ProviderRpcError extends Error {
}
```

The [`window.ethereum.request(args)`](#windowethereumrequest--args-) provider method throws errors
The [`window.ethereum.request(args)`](#windowethereumrequestargs) provider method throws errors
eagerly.
You can use the error `code` property to determine why the request failed.
Common codes and their meaning include:
Expand Down
Loading

0 comments on commit be50fd4

Please sign in to comment.