-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add snaps execution environment OpenRPC spec (#23)
* add snaps execution environment OpenRPC spec * fix EE usage to align with spec
- Loading branch information
1 parent
0ce2b7d
commit 6804291
Showing
3 changed files
with
190 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
{ | ||
"openrpc": "1.2.4", | ||
"info": { | ||
"title": "MetaMask Snaps Execution Environment API", | ||
"version": "0.0.0-development" | ||
}, | ||
"methods": [ | ||
{ | ||
"name": "handshake", | ||
"description": "confirms that a connection has been established with the execution environment", | ||
"params": [], | ||
"result": { | ||
"name": "HandshakeResult", | ||
"schema": { | ||
"$ref": "#/components/schemas/OK" | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "executePlugin", | ||
"description": "executes a plugin in the environment. The plugin can then be interacted with via `pluginRpc`", | ||
"paramStructure": "by-name", | ||
"params": [ | ||
{ | ||
"name": "pluginName", | ||
"required": true, | ||
"description": "the name of the plugin", | ||
"schema": { | ||
"title": "PluginName", | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "sourceCode", | ||
"description": "a plugins source code that gets executed in the environment", | ||
"required": true, | ||
"schema": { | ||
"title": "SourceCode", | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"result": { | ||
"name": "executePluginResult", | ||
"schema": { | ||
"$ref": "#/components/schemas/OK" | ||
} | ||
}, | ||
"examples": [ | ||
{ | ||
"name": "BasicTestPluginExecuteExample", | ||
"params": [ | ||
{ | ||
"name": "pluginName", | ||
"value": "TestPlugin" | ||
}, | ||
{ | ||
"name": "sourceCode", | ||
"value": "wallet.registerRpcMessageHandler(async (_, request) => { return request.method + request.id })" | ||
} | ||
], | ||
"result": { | ||
"name": "BasicTestPluginExampleResult", | ||
"value": "OK" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "pluginRpc", | ||
"paramStructure": "by-name", | ||
"params": [ | ||
{ | ||
"name": "target", | ||
"required": true, | ||
"description": "the name of the plugin method", | ||
"schema": { | ||
"title": "Target", | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "origin", | ||
"required": true, | ||
"description": "Origin of the plugin JSON-RPC request", | ||
"schema": { | ||
"title": "Origin", | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "request", | ||
"required": true, | ||
"description": "JSON-RPC request", | ||
"schema": { | ||
"title": "JSONRPCRequest", | ||
"description": "JSON-RPC request object to pass through to the plugin", | ||
"type": "object", | ||
"required": ["method", "params"], | ||
"properties": { | ||
"jsonrpc": { | ||
"title": "JSONRPCString", | ||
"type": "string", | ||
"const": "2.0" | ||
}, | ||
"id": { | ||
"title": "JSONRPCID", | ||
"oneOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "number" | ||
} | ||
] | ||
}, | ||
"method": { | ||
"title": "JSONRPCMethod", | ||
"description": "the name of the method", | ||
"type": "string" | ||
}, | ||
"params": { | ||
"title": "JSONRPCParams", | ||
"type": ["array", "object"] | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"result": { | ||
"name": "HandlePluginRpcResult", | ||
"schema": { | ||
"title": "PluginRpcResult", | ||
"type": "object", | ||
"properties": { | ||
"result": true, | ||
"error": true | ||
} | ||
} | ||
}, | ||
"examples": [ | ||
{ | ||
"name": "TestPluginExample", | ||
"params": [ | ||
{ | ||
"name": "target", | ||
"value": "TestPlugin" | ||
}, | ||
{ | ||
"name": "origin", | ||
"value": "foo.com" | ||
}, | ||
{ | ||
"name": "request", | ||
"value": { | ||
"method": "hello", | ||
"params": [], | ||
"id": 1 | ||
} | ||
} | ||
], | ||
"result": { | ||
"name": "TestPluginResultExample", | ||
"value": { | ||
"jsonrpc": "2.0", | ||
"id": 1, | ||
"result": "hello1" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"components": { | ||
"schemas": { | ||
"OK": { | ||
"title": "OK", | ||
"type": "string", | ||
"const": "OK" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters