From 8aa398ff92eddac99d7b79a8489f0165bd3c4313 Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Wed, 11 Oct 2023 15:19:15 +0100 Subject: [PATCH 1/3] custodian_sign and custodian_signTypedData --- src/openrpc.json | 71 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 12 deletions(-) diff --git a/src/openrpc.json b/src/openrpc.json index aefd32b..758a713 100644 --- a/src/openrpc.json +++ b/src/openrpc.json @@ -148,23 +148,22 @@ "summary": "Requests that the custodian calculate Ethereum specific signature prefixed with \"\\x19Ethereum Signed Message:\\n\" + len(message)", "params": [ { - "name": "address", + "name": "SignedMessageParameters", "required": true, "schema": { - "$ref": "#/components/schemas/address" + "$ref": "#/components/schemas/SignedMessageParameters" } }, { - "name": "message", + "name": "SignedMessageMetadata", "required": true, "schema": { - "title": "message", - "$ref": "#/components/schemas/bytes" + "$ref": "#/components/schemas/SignedMessageMetadata" } } ], "result": { - "name": "Signed Message ID", + "name": "SignedMessage ID", "schema": { "title": "signedMessageId", "type": "string" @@ -175,13 +174,17 @@ "name": "Signing the string 'hello world'", "params": [ { - "name": "custodianSignExampleAddress", - "value": "0xb2c77973279baaaf48c295145802695631d50c01" + "name": "custodianSignExampleAddressAndPayload", + "value": { + "address": "0xb2c77973279baaaf48c295145802695631d50c01", + "payload": "0x48656c6c6f20776f726c64" + } }, { - "name": "custodianSignExampleMessage", - "value": "0x48656c6c6f20776f726c64", - "description": "Hello world" + "name": "custodianSignExampleMetadata", + "chainId": "0x4", + "originUrl": "https://www.example.com", + "note": "personal_sign message" } ], "result": { @@ -210,7 +213,7 @@ } }, { - "name": "encodingVersion", + "name": "version", "required": true, "schema": { "$ref": "#/components/schemas/EIP712EncodingVersion" @@ -544,6 +547,50 @@ ], "components": { "schemas": { + "SignedMessageParameters": { + "title": "Signed Message object", + "type": "object", + "allOf": [ + { + "required": ["address", "payload"], + "properties": { + "address": { + "title": "From address", + "$ref": "#/components/schemas/address" + }, + "payload": { + "title": "Message payload", + "$ref": "#/components/schemas/bytes" + } + } + } + ] + }, + "SignedMessageMetadata": { + "title": "Signed Message Metadata", + "type": "object", + "allOf": [ + { + "required": ["chainId", "originUrl"], + "properties": { + "chainId": { + "title": "Chain ID", + "$ref": "#/components/schemas/uint" + }, + "originUrl": { + "title": "Origin URL", + "description": "The web page/dapp where the transaction originated", + "$ref": "#/components/schemas/uri" + }, + "note": { + "title": "Note", + "description": "A note to be attached to the transaction which can be specified by the user", + "type": "string" + } + } + } + ] + }, "address": { "title": "hex encoded address", "type": "string", From 98f458ef004dc22a9608a7fc146002f631c67f57 Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Wed, 11 Oct 2023 16:03:17 +0100 Subject: [PATCH 2/3] prettier and lint --- .prettierrc.yml | 5 +++++ gatsby-config.js | 28 ++++++++++++++-------------- gatsby-node.js | 12 +++++------- 3 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 .prettierrc.yml diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000..9912c96 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,5 @@ +# All of these are defaults except singleQuote and endOfLine, but we specify them +# for explicitness +endOfLine: auto +singleQuote: true +trailingComma: all diff --git a/gatsby-config.js b/gatsby-config.js index 8c973ab..76e2452 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,32 +1,33 @@ module.exports = { pathPrefix: '/api-playground', -siteMetadata: { + siteMetadata: { title: 'Ethereum Custodian API', description: 'API for Ethereum Custodians', - logoUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ0StI_jeguVNslskUuiqljELX9cAZMq9YIdftuAIfDpTtPCViYV3xiAkTYjKpNvAKHhno&usqp=CAU', - primaryColor: '#3f51b5', //material-ui primary color - secondaryColor: '#f50057', //material-ui secondary color + logoUrl: + 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ0StI_jeguVNslskUuiqljELX9cAZMq9YIdftuAIfDpTtPCViYV3xiAkTYjKpNvAKHhno&usqp=CAU', + primaryColor: '#3f51b5', // material-ui primary color + secondaryColor: '#f50057', // material-ui secondary color author: '', menuLinks: [ { name: 'home', link: '/', - ignoreNextPrev: true + ignoreNextPrev: true, }, { name: 'API Documentation', - link: '/api-documentation' - } + link: '/api-documentation', + }, ], footerLinks: [ { name: 'OpenRPC', - link: 'https://open-rpc.org' - } - ] + link: 'https://open-rpc.org', + }, + ], }, plugins: [ - "@xops.net/gatsby-openrpc-theme", + '@xops.net/gatsby-openrpc-theme', { resolve: 'gatsby-plugin-manifest', options: { @@ -38,7 +39,6 @@ siteMetadata: { display: 'minimal-ui', icon: 'src/images/gatsby-icon.png', // This path is relative to the root of the site. }, - } + }, ], -} - +}; diff --git a/gatsby-node.js b/gatsby-node.js index a30fa48..78108d3 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -3,19 +3,17 @@ * * See: https://www.gatsbyjs.org/docs/node-apis/ */ +const fs = require('fs'); const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'); -const fs = require("fs"); - // get OpenRPC Document at build time -const resultData = fs.readFileSync(__dirname + "/src/openrpc.json").toString(); +// eslint-disable-next-line +const resultData = fs.readFileSync(`${__dirname}/src/openrpc.json`).toString(); exports.sourceNodes = async ({ actions: { createNode }, createContentDigest, }) => { - // deref doc - const openrpcDocument = JSON.parse(resultData); // create node for build time openrpc document on the site createNode({ openrpcDocument: resultData, @@ -27,8 +25,8 @@ exports.sourceNodes = async ({ type: `OpenrpcDocument`, contentDigest: createContentDigest(resultData), }, - }) -} + }); +}; exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => { if (stage === 'build-html' || stage === 'develop-html') { From e3f5e329ccc80d4f10c8565fb1ff2ef22dac14f6 Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Wed, 11 Oct 2023 16:35:07 +0100 Subject: [PATCH 3/3] custodian_signTypedData fix --- src/openrpc.json | 205 +++++++++++++++++++++++++++++------------------ 1 file changed, 126 insertions(+), 79 deletions(-) diff --git a/src/openrpc.json b/src/openrpc.json index 758a713..9f30f5f 100644 --- a/src/openrpc.json +++ b/src/openrpc.json @@ -182,9 +182,11 @@ }, { "name": "custodianSignExampleMetadata", - "chainId": "0x4", - "originUrl": "https://www.example.com", - "note": "personal_sign message" + "value": { + "chainId": "0x4", + "originUrl": "https://www.example.com", + "note": "personal_sign message" + } } ], "result": { @@ -199,24 +201,17 @@ "summary": "Requests that the custodian perform a signature according to EIP-712", "params": [ { - "name": "address", - "required": true, - "schema": { - "$ref": "#/components/schemas/address" - } - }, - { - "name": "payload", + "name": "SignedTypedDataParameters", "required": true, "schema": { - "$ref": "#/components/schemas/TypedData" + "$ref": "#/components/schemas/SignedTypedDataParameters" } }, { - "name": "version", + "name": "SignedTypedDataMetadata", "required": true, "schema": { - "$ref": "#/components/schemas/EIP712EncodingVersion" + "$ref": "#/components/schemas/SignedTypedDataMetadata" } } ], @@ -233,78 +228,82 @@ "params": [ { "name": "custodianSignTypedDataExampleAddress", - "value": "0xb2c77973279baaaf48c295145802695631d50c01" - }, - { - "name": "custodianSignTypedDataExamplePayload", "value": { - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "Person": [ - { - "name": "name", - "type": "string" - }, - { - "name": "wallet", - "type": "address" - } - ], - "Mail": [ - { - "name": "from", - "type": "Person" + "address": "0xb2c77973279baaaf48c295145802695631d50c01", + "payload": { + "types": { + "EIP712Domain": [ + { + "name": "name", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "chainId", + "type": "uint256" + }, + { + "name": "verifyingContract", + "type": "address" + } + ], + "Person": [ + { + "name": "name", + "type": "string" + }, + { + "name": "wallet", + "type": "address" + } + ], + "Mail": [ + { + "name": "from", + "type": "Person" + }, + { + "name": "to", + "type": "Person" + }, + { + "name": "contents", + "type": "string" + } + ] + }, + "primaryType": "Mail", + "domain": { + "name": "Ether Mail", + "version": "1", + "chainId": 1, + "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" + }, + "message": { + "from": { + "name": "Cow", + "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" }, - { - "name": "to", - "type": "Person" + "to": { + "name": "Bob", + "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" }, - { - "name": "contents", - "type": "string" - } - ] - }, - "primaryType": "Mail", - "domain": { - "name": "Ether Mail", - "version": "1", - "chainId": 1, - "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" + "contents": "Hello, Bob!" + } }, - "message": { - "from": { - "name": "Cow", - "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" - }, - "to": { - "name": "Bob", - "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" - }, - "contents": "Hello, Bob!" - } + "version": "v4" } }, { - "name": "custodianSignTypedDataExampleEncodingVersion", - "value": "v4" + "name": "custodianSignTypedDataExampleMetadata", + "value": { + "chainId": "0x4", + "originUrl": "https://www.example.com", + "note": "Signed typed data" + } } ], "result": { @@ -591,6 +590,54 @@ } ] }, + "SignedTypedDataParameters": { + "title": "Signed Typed Data object", + "type": "object", + "allOf": [ + { + "required": ["address", "payload", "version"], + "properties": { + "address": { + "title": "From address", + "$ref": "#/components/schemas/address" + }, + "payload": { + "title": "Message payload", + "$ref": "#/components/schemas/bytes" + }, + "version": { + "title": "Message payload", + "$ref": "#/components/schemas/EIP712EncodingVersion" + } + } + } + ] + }, + "SignedTypedDataMetadata": { + "title": "Signed Typed Data Metadata", + "type": "object", + "allOf": [ + { + "required": ["chainId", "originUrl"], + "properties": { + "chainId": { + "title": "Chain ID", + "$ref": "#/components/schemas/uint" + }, + "originUrl": { + "title": "Origin URL", + "description": "The web page/dapp where the transaction originated", + "$ref": "#/components/schemas/uri" + }, + "note": { + "title": "Note", + "description": "A note to be attached to the transaction which can be specified by the user", + "type": "string" + } + } + } + ] + }, "address": { "title": "hex encoded address", "type": "string",