diff --git a/src/components/CustomReferencePage/index.tsx b/src/components/CustomReferencePage/index.tsx
index 326248eb31f..e65f2b29ee0 100644
--- a/src/components/CustomReferencePage/index.tsx
+++ b/src/components/CustomReferencePage/index.tsx
@@ -6,6 +6,7 @@ import { useLocation } from "@docusaurus/router";
import { prepareLinkItems, MM_REF_PATH } from '@site/src/plugins/plugin-json-rpc';
import styles from "./styles.module.css";
const sidebar = require("../../../wallet-sidebar.js");
+import AdmonitionWrapper from '@site/src/theme/Admonition';
function transformItems(items, dynamicItems) {
return items.map(item => {
@@ -41,6 +42,12 @@ function transformItems(items, dynamicItems) {
});
}
+const NoteMsg = () => (
+
+ MetaMask doesn't support session IDs.
+
+);
+
const CustomReferencePage = (props) => {
const customData = props.route.customData;
const { pathname } = useLocation();
@@ -61,6 +68,7 @@ const CustomReferencePage = (props) => {
}
/>
diff --git a/src/components/ParserOpenRPC/DetailsBox/RenderParams.tsx b/src/components/ParserOpenRPC/DetailsBox/RenderParams.tsx
index e7b611cf415..418c9bd8b77 100644
--- a/src/components/ParserOpenRPC/DetailsBox/RenderParams.tsx
+++ b/src/components/ParserOpenRPC/DetailsBox/RenderParams.tsx
@@ -8,12 +8,13 @@ const getRefSchemaFromComponents = (initRef, components) => {
return components[ref];
};
-const renderSchema = (schemaItem, schemas, name) => {
+const renderSchema = (schemaItem, schemas, name, mainDescr = "") => {
if (!schemaItem) return
Invalid schema
;
const resolveRef = (ref) => {
+ const mainDescr = schemaItem.description;
const newSchema = getRefSchemaFromComponents(ref, schemas);
- return renderSchema(newSchema, schemas, name);
+ return renderSchema(newSchema, schemas, name, mainDescr);
};
if (schemaItem?.schema?.$ref) return resolveRef(schemaItem.schema.$ref);
@@ -25,7 +26,7 @@ const renderSchema = (schemaItem, schemas, name) => {
title={itemName || item.title}
type="object"
required={schemaItem.required || !!item.required}
- description={item.description || item.title || ""}
+ description={mainDescr || schemaItem.description || item.description || item.title || ""}
pattern={item.pattern}
defaultVal={item.default}
/>
@@ -130,7 +131,7 @@ const renderSchema = (schemaItem, schemas, name) => {
type={schemaItem.schema.enum ? "enum" : schemaItem.schema.type}
required={!!schemaItem.required}
description={
- schemaItem.description || schemaItem.schema.description || schemaItem.schema.title || ""
+ mainDescr || schemaItem.description || schemaItem.schema.description || schemaItem.schema.title || ""
}
pattern={schemaItem.schema.pattern || schemaItem.pattern}
defaultVal={schemaItem.schema.default || schemaItem.default}
@@ -146,7 +147,7 @@ const renderSchema = (schemaItem, schemas, name) => {
title={name || schemaItem.title}
type={schemaItem.enum ? "enum" : schemaItem.type}
required={!!schemaItem.required}
- description={schemaItem.description || schemaItem.title}
+ description={mainDescr || schemaItem.description || schemaItem.title}
pattern={schemaItem.pattern}
defaultVal={schemaItem.default}
/>
diff --git a/src/plugins/multi-api.json b/src/plugins/multi-api.json
new file mode 100644
index 00000000000..a8f0c63e44a
--- /dev/null
+++ b/src/plugins/multi-api.json
@@ -0,0 +1,613 @@
+{
+ "openrpc": "1.2.4",
+ "info": {
+ "title": "MetaMask MultiChain API",
+ "version": "1.0.0",
+ "description": "This provides the specs for the MultiChain API Layer for the MetaMask API"
+ },
+ "methods": [
+ {
+ "name": "wallet_notify",
+ "paramStructure": "by-name",
+ "params": [
+ {
+ "name": "scope",
+ "description": "a valid `scope` string that has been previously authorized via `provider_authorize`",
+ "required": true,
+ "schema": {
+ "$ref": "#/components/schemas/ScopeString"
+ }
+ },
+ {
+ "name": "notification",
+ "description": "an object containing a JSON-RPC notification with `method` and `params`",
+ "deprecated": false,
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "method": {
+ "type": "string"
+ },
+ "params": true
+ }
+ }
+ }
+ ]
+ },
+ {
+ "name": "wallet_invokeMethod",
+ "paramStructure": "by-name",
+ "params": [
+ {
+ "name": "scope",
+ "description": "a valid `scope` string that has been previously authorized via `provider_authorize`",
+ "required": true,
+ "schema": {
+ "$ref": "#/components/schemas/ScopeString"
+ }
+ },
+ {
+ "name": "request",
+ "description": "an object containing a JSON-RPC request with `method` and `params`",
+ "deprecated": false,
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "method": {
+ "type": "string"
+ },
+ "params": true
+ }
+ }
+ }
+ ],
+ "result": {
+ "name": "wallet_invokeMethodResult",
+ "schema": true
+ },
+ "examples": [
+ {
+ "name": "wallet_invokeMethodExample",
+ "params": [
+ {
+ "name": "scope",
+ "value": "eip155:1"
+ },
+ {
+ "name": "request",
+ "value": {
+ "method": "eth_getBalance",
+ "params": []
+ }
+ }
+ ],
+ "result": {
+ "name": "wallet_invokeMethodResult",
+ "value": "0x1"
+ }
+ }
+ ]
+ },
+ {
+ "name": "wallet_revokeSession",
+ "description": "The `wallet_revokeSession` method revokes the entire active session.",
+ "params": [],
+ "result": {
+ "name": "wallet_revokeSessionResult",
+ "schema": {
+ "type": "boolean"
+ }
+ },
+ "examples": [
+ {
+ "name": "wallet_revokeSessionExample",
+ "params": [],
+ "result": {
+ "name": "wallet_revokeSessionExampleResult",
+ "value": true
+ }
+ }
+ ],
+ "errors": [
+ {
+ "$ref": "#/components/errors/UnknownError"
+ }
+ ]
+ },
+ {
+ "name": "wallet_sessionChanged",
+ "paramStructure": "by-name",
+ "description": "This notification is published by the wallet to notify the callers of updates to a shared session's authorization scopes. The event payload contains the new `sessionScopes`.",
+ "params": [
+ {
+ "name": "sessionScopes",
+ "schema": {
+ "$ref": "#/components/schemas/SessionScopes"
+ }
+ }
+ ],
+ "examples": [
+ {
+ "name": "wallet_sessionChangedExample",
+ "description": "Example of a wallet_sessionChanged notification.",
+ "params": [
+ {
+ "name": "sessionScopes",
+ "value": {
+ "eip155:1337": {
+ "accounts": [
+ "eip155:1337:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
+ ],
+ "methods": [
+ "wallet_watchAsset",
+ "eth_sendTransaction",
+ "eth_decrypt",
+ "eth_getEncryptionPublicKey",
+ "web3_clientVersion",
+ "eth_subscribe",
+ "eth_unsubscribe",
+ "eth_blockNumber",
+ "eth_call",
+ "eth_chainId",
+ "eth_estimateGas",
+ "eth_feeHistory",
+ "eth_gasPrice",
+ "eth_getBalance",
+ "eth_getBlockByHash",
+ "eth_getBlockByNumber",
+ "eth_getBlockTransactionCountByHash",
+ "eth_getBlockTransactionCountByNumber",
+ "eth_getCode",
+ "eth_getFilterChanges",
+ "eth_getFilterLogs",
+ "eth_getLogs",
+ "eth_getProof",
+ "eth_getStorageAt",
+ "eth_getTransactionByBlockHashAndIndex",
+ "eth_getTransactionByBlockNumberAndIndex",
+ "eth_getTransactionByHash",
+ "eth_getTransactionCount",
+ "eth_getTransactionReceipt",
+ "eth_getUncleCountByBlockHash",
+ "eth_getUncleCountByBlockNumber",
+ "eth_newBlockFilter",
+ "eth_newFilter",
+ "eth_newPendingTransactionFilter",
+ "eth_sendRawTransaction",
+ "eth_syncing",
+ "eth_uninstallFilter"
+ ],
+ "notifications": [
+ "eth_subscription"
+ ]
+ },
+ "wallet": {
+ "accounts": [],
+ "methods": [
+ "wallet_registerOnboarding",
+ "wallet_scanQRCode"
+ ],
+ "notifications": []
+ },
+ "wallet:eip155": {
+ "accounts": [
+ "wallet:eip155:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
+ ],
+ "methods": [
+ "wallet_addEthereumChain",
+ "personal_sign",
+ "eth_signTypedData_v4"
+ ],
+ "notifications": []
+ }
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "wallet_getSession",
+ "description": "The `wallet_getSession` method returns an active session.",
+ "params": [],
+ "result": {
+ "name": "wallet_getSessionResult",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "sessionScopes": {
+ "$ref": "#/components/schemas/SessionScopes"
+ }
+ }
+ }
+ },
+ "examples": [
+ {
+ "name": "wallet_getSessionExample",
+ "description": "Example of a getSession request.",
+ "params": [],
+ "result": {
+ "name": "wallet_getSessionResultExample",
+ "value": {
+ "sessionScopes": {
+ "eip155:1337": {
+ "accounts": [
+ "eip155:1337:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
+ ],
+ "methods": [
+ "wallet_watchAsset",
+ "eth_sendTransaction",
+ "eth_decrypt",
+ "eth_getEncryptionPublicKey",
+ "web3_clientVersion",
+ "eth_subscribe",
+ "eth_unsubscribe",
+ "eth_blockNumber",
+ "eth_call",
+ "eth_chainId",
+ "eth_estimateGas",
+ "eth_feeHistory",
+ "eth_gasPrice",
+ "eth_getBalance",
+ "eth_getBlockByHash",
+ "eth_getBlockByNumber",
+ "eth_getBlockTransactionCountByHash",
+ "eth_getBlockTransactionCountByNumber",
+ "eth_getCode",
+ "eth_getFilterChanges",
+ "eth_getFilterLogs",
+ "eth_getLogs",
+ "eth_getProof",
+ "eth_getStorageAt",
+ "eth_getTransactionByBlockHashAndIndex",
+ "eth_getTransactionByBlockNumberAndIndex",
+ "eth_getTransactionByHash",
+ "eth_getTransactionCount",
+ "eth_getTransactionReceipt",
+ "eth_getUncleCountByBlockHash",
+ "eth_getUncleCountByBlockNumber",
+ "eth_newBlockFilter",
+ "eth_newFilter",
+ "eth_newPendingTransactionFilter",
+ "eth_sendRawTransaction",
+ "eth_syncing",
+ "eth_uninstallFilter"
+ ],
+ "notifications": [
+ "eth_subscription"
+ ]
+ },
+ "wallet": {
+ "accounts": [],
+ "methods": [
+ "wallet_registerOnboarding",
+ "wallet_scanQRCode"
+ ],
+ "notifications": []
+ },
+ "wallet:eip155": {
+ "accounts": [
+ "wallet:eip155:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
+ ],
+ "methods": [
+ "wallet_addEthereumChain",
+ "personal_sign",
+ "eth_signTypedData_v4"
+ ],
+ "notifications": []
+ }
+ }
+ }
+ }
+ }
+ ]
+ },
+ {
+ "name": "wallet_createSession",
+ "paramStructure": "by-name",
+ "params": [
+ {
+ "name": "requiredScopes",
+ "description": "Scopes that the wallet must support in order to be used with this provider.",
+ "schema": {
+ "type": "object",
+ "$ref": "#/components/schemas/Scope"
+ }
+ },
+ {
+ "name": "optionalScopes",
+ "description": "Scopes that the wallet may support in order to be used with this provider.",
+ "schema": {
+ "type": "object",
+ "$ref": "#/components/schemas/Scope"
+ }
+ },
+ {
+ "name": "sessionProperties",
+ "description": "Properties that the wallet may use to determine if the session is valid.",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "expiry": {
+ "type": "string",
+ "format": "date-time"
+ }
+ }
+ }
+ }
+ ],
+ "result": {
+ "name": "wallet_createSessionResult",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "sessionScopes": {
+ "$ref": "#/components/schemas/SessionScopes"
+ },
+ "sessionProperties": {
+ "type": "object",
+ "properties": {
+ "expiry": {
+ "type": "string",
+ "format": "date-time"
+ }
+ }
+ }
+ }
+ }
+ },
+ "examples": [
+ {
+ "name": "wallet_createSessionExample",
+ "description": "Example of a createSession request.",
+ "params": [
+ {
+ "name": "requiredScopes",
+ "value": {
+ "eip155:1337": {
+ "methods": [
+ "wallet_watchAsset",
+ "eth_sendTransaction",
+ "eth_decrypt",
+ "eth_getEncryptionPublicKey",
+ "web3_clientVersion",
+ "eth_subscribe",
+ "eth_unsubscribe",
+ "eth_blockNumber",
+ "eth_call",
+ "eth_chainId",
+ "eth_estimateGas",
+ "eth_feeHistory",
+ "eth_gasPrice",
+ "eth_getBalance",
+ "eth_getBlockByHash",
+ "eth_getBlockByNumber",
+ "eth_getBlockTransactionCountByHash",
+ "eth_getBlockTransactionCountByNumber",
+ "eth_getCode",
+ "eth_getFilterChanges",
+ "eth_getFilterLogs",
+ "eth_getLogs",
+ "eth_getProof",
+ "eth_getStorageAt",
+ "eth_getTransactionByBlockHashAndIndex",
+ "eth_getTransactionByBlockNumberAndIndex",
+ "eth_getTransactionByHash",
+ "eth_getTransactionCount",
+ "eth_getTransactionReceipt",
+ "eth_getUncleCountByBlockHash",
+ "eth_getUncleCountByBlockNumber",
+ "eth_newBlockFilter",
+ "eth_newFilter",
+ "eth_newPendingTransactionFilter",
+ "eth_sendRawTransaction",
+ "eth_syncing",
+ "eth_uninstallFilter"
+ ],
+ "notifications": [
+ "eth_subscription"
+ ]
+ },
+ "wallet": {
+ "methods": [
+ "wallet_registerOnboarding",
+ "wallet_scanQRCode"
+ ],
+ "notifications": []
+ },
+ "wallet:eip155": {
+ "methods": [
+ "wallet_addEthereumChain",
+ "personal_sign",
+ "eth_signTypedData_v4"
+ ],
+ "notifications": []
+ }
+ }
+ },
+ {
+ "name": "sessionProperties",
+ "value": {
+ "expiry": "2022-12-24T17:07:31+00:00"
+ }
+ }
+ ],
+ "result": {
+ "name": "wallet_createSessionResultExample",
+ "value": {
+ "sessionScopes": {
+ "eip155:1337": {
+ "accounts": [
+ "eip155:1337:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
+ ],
+ "methods": [
+ "wallet_watchAsset",
+ "eth_sendTransaction",
+ "eth_decrypt",
+ "eth_getEncryptionPublicKey",
+ "web3_clientVersion",
+ "eth_subscribe",
+ "eth_unsubscribe",
+ "eth_blockNumber",
+ "eth_call",
+ "eth_chainId",
+ "eth_estimateGas",
+ "eth_feeHistory",
+ "eth_gasPrice",
+ "eth_getBalance",
+ "eth_getBlockByHash",
+ "eth_getBlockByNumber",
+ "eth_getBlockTransactionCountByHash",
+ "eth_getBlockTransactionCountByNumber",
+ "eth_getCode",
+ "eth_getFilterChanges",
+ "eth_getFilterLogs",
+ "eth_getLogs",
+ "eth_getProof",
+ "eth_getStorageAt",
+ "eth_getTransactionByBlockHashAndIndex",
+ "eth_getTransactionByBlockNumberAndIndex",
+ "eth_getTransactionByHash",
+ "eth_getTransactionCount",
+ "eth_getTransactionReceipt",
+ "eth_getUncleCountByBlockHash",
+ "eth_getUncleCountByBlockNumber",
+ "eth_newBlockFilter",
+ "eth_newFilter",
+ "eth_newPendingTransactionFilter",
+ "eth_sendRawTransaction",
+ "eth_syncing",
+ "eth_uninstallFilter"
+ ],
+ "notifications": [
+ "eth_subscription"
+ ]
+ },
+ "wallet": {
+ "accounts": [],
+ "methods": [
+ "wallet_registerOnboarding",
+ "wallet_scanQRCode"
+ ],
+ "notifications": []
+ },
+ "wallet:eip155": {
+ "accounts": [
+ "wallet:eip155:0x5cfe73b6021e818b776b421b1c4db2474086a7e1"
+ ],
+ "methods": [
+ "wallet_addEthereumChain",
+ "personal_sign",
+ "eth_signTypedData_v4"
+ ],
+ "notifications": []
+ },
+ "sessionProperties": {
+ "expiry": "2022-11-31T17:07:31+00:00"
+ }
+ }
+ }
+ }
+ }
+ ],
+ "errors": [
+ {
+ "$ref": "#/components/errors/UnknownError"
+ },
+ {
+ "code": 5100,
+ "message": "Requested networks are not supported"
+ },
+ {
+ "code": 5101,
+ "message": "Requested methods are not supported"
+ },
+ {
+ "code": 5102,
+ "message": "Requested notifications are not supported"
+ },
+ {
+ "code": 5300,
+ "message": "Invalid scopedProperties requested"
+ },
+ {
+ "code": 5301,
+ "message": "scopedProperties can only be outside of sessionScopes"
+ },
+ {
+ "code": 5302,
+ "message": "Invalid sessionProperties requested"
+ }
+ ]
+ }
+ ],
+ "components": {
+ "errors": {
+ "UnknownError": {
+ "code": 5000,
+ "message": "Unknown error with request"
+ }
+ },
+ "schemas": {
+ "SessionScopes": {
+ "type": "object",
+ "$ref": "#/components/schemas/Scope"
+
+ },
+ "ScopeString": {
+ "type": "string",
+ "pattern": "[-a-z0-9]{3,8}(:[-_a-zA-Z0-9]{1,32})?"
+ },
+ "Scope": {
+ "type": "object",
+ "title": "Scope",
+ "description": "Scope for a multi-chain connection",
+ "additionalProperties": true,
+ "required": [
+ "notifications",
+ "methods"
+ ],
+ "properties": {
+ "scopes": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ScopeString"
+ }
+ },
+ "methods": {
+ "description": "Methods that the wallet must support in order to be used with this provider.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "notifications": {
+ "description": "Notifications that the wallet must support in order to be used with this provider.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "rpcEndpoints": {
+ "description": "JSON-RPC endpoints for this namespace.",
+ "type": "array",
+ "items": {
+ "type": "string",
+ "format": "uri"
+ }
+ },
+ "rpcDocuments": {
+ "type": "array",
+ "description": "OpenRPC documents that define RPC methods in which to anchor the methods authorized in a CAIP-25 interaction.",
+ "items": {
+ "type": "string",
+ "format": "uri"
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/plugins/plugin-json-rpc.ts b/src/plugins/plugin-json-rpc.ts
index 3c7cd429707..75aafba5264 100644
--- a/src/plugins/plugin-json-rpc.ts
+++ b/src/plugins/plugin-json-rpc.ts
@@ -1,5 +1,6 @@
import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
import * as path from "path";
+import MULTI_JSON from "./multi-api.json"
export interface ResponseItem {
name: string;
@@ -8,6 +9,9 @@ export interface ResponseItem {
}
async function fetchData(url: string, name: string): Promise {
+ if (name === NETWORK_NAMES.metamask) {
+ return { name, data: MULTI_JSON, error: false };
+ }
try {
const response = await fetch(url, { method: "GET" });
const data = await response.json();