Skip to content

Commit

Permalink
add eth_signTypedData_v4 (#123)
Browse files Browse the repository at this point in the history
* add eth_signTypedData_v4

Co-authored-by: Shane <jonas.shane@gmail.com>
  • Loading branch information
adonesky1 and shanejonas authored Mar 28, 2023
1 parent 52986c6 commit 9282784
Showing 1 changed file with 130 additions and 20 deletions.
150 changes: 130 additions & 20 deletions openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@
"value": {
"chainId": "0x64",
"chainName": "Gnosis",
"rpcUrls": [
"https://dai.poa.network"
],
"rpcUrls": ["https://dai.poa.network"],
"iconUrls": [
"https://xdaichain.com/fake/example/url/xdai.svg",
"https://xdaichain.com/fake/example/url/xdai.png"
Expand All @@ -76,9 +74,7 @@
"symbol": "xDAI",
"decimals": 18
},
"blockExplorerUrls": [
"https://blockscout.com/poa/xdai/"
]
"blockExplorerUrls": ["https://blockscout.com/poa/xdai/"]
}
}
],
Expand All @@ -105,9 +101,7 @@
"schema": {
"title": "SwitchEthereumChainParameter",
"type": "object",
"required": [
"chainId"
],
"required": ["chainId"],
"properties": {
"chainId": {
"description": "MUST specify the integer ID of the chain as a hexadecimal string, per the `eth_chainId` Ethereum RPC method.",
Expand Down Expand Up @@ -247,9 +241,7 @@
"schema": {
"type": "string",
"description": "Only ERC20 supported. In the future, other standards will be supported",
"enum": [
"ERC20"
]
"enum": ["ERC20"]
}
},
{
Expand Down Expand Up @@ -391,6 +383,95 @@
}
}
},
{
"name": "eth_signTypedData_v4",
"tags": [
{
"$ref": "#/components/tags/Metamask"
}
],
"summary": "Presents a structured data message for the user to sign.",
"description": "Presents a data message for the user to sign in a structured and readable format and returns the signed response. Introduced By [EIP-712](https://eips.ethereum.org/EIPS/eip-712).",
"params": [
{
"name": "Address",
"required": true,
"description": "The address of the requested signing account.",
"schema": {
"$ref": "#/components/schemas/address"
}
},
{
"name": "TypedData",
"required": true,
"description": "The TypedData parameter",
"schema": {
"$ref": "#/components/schemas/TypedData"
}
}
],
"result": {
"name": "Signature",
"schema": {
"$ref": "#/components/schemas/bytes"
}
},
"examples": [
{
"name": "eth_SignTypedData_v4Example",
"params": [
{
"name": "Address",
"value": "0x0000000000000000000000000000000000000000"
},
{
"name": "TypedData",
"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" },
{ "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"
},
"to": {
"name": "Bob",
"wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
},
"contents": "Hello, Bob!"
}
}
}
],
"result": {
"name": "Signature",
"value": "0x4355c47d63924e8a72e509b65029052eb6c299d53a04e167c5775fd466751c9d07299936d304c153f6443dfa05f40ff007d72911b6f72307f996231605b915621c"
}
}
]
},
{
"name": "personal_sign",
"summary": "Presents a plain text signature challenge to the user.",
Expand All @@ -417,6 +498,7 @@
],
"result": {
"name": "Signature",
"description": "a hex encoded 129 byte array starting with 0x",
"schema": {
"$ref": "#/components/schemas/bytes"
}
Expand All @@ -425,12 +507,44 @@
],
"components": {
"schemas": {
"TypedData": {
"title": "TypedData",
"type": "object",
"required": ["types", "primaryType", "domain", "message"],
"properties": {
"types": {
"type": "object",
"required": ["EIP712Domain"],
"properties": {
"EIP712Domain": {
"type": "array",
"description": "An array specifying one or more of the following domain separator values 1) 'name': the user readable name of signing domain, i.e. the name of the DApp or the protocol. 2) 'version': the current major version of the signing domain. 3) chainId: the EIP-155 chain id. 4) verifyingContract: the address of the contract that will verify the signature. 5) salt: a disambiguating salt for the protocol."
}
},
"additionalProperties": {
"type": "array",
"required": ["name", "type"],
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"type": { "type": "string" }
}
}
}
},
"domain": {
"type": "object",
"description": "contains the domain separator values specified in the EIP712Domain type"
},
"primaryType": { "type": "string" },
"message": { "type": "object" }
}
},
"AddEthereumChainParameter": {
"title": "AddEthereumChainParameter",
"type": "object",
"required": [
"chainId"
],
"required": ["chainId"],
"properties": {
"chainId": {
"description": "MUST specify the integer ID of the chain as a hexadecimal string, per the eth_chainId Ethereum RPC method. The wallet SHOULD compare the specified chainId value with the eth_chainId return value from the endpoint. If these values are not identical, the wallet MUST reject the request.",
Expand Down Expand Up @@ -470,11 +584,7 @@
"title": "NativeCurrency",
"type": "object",
"description": "If provided, MUST describe the native currency of the chain using the name, symbol, and decimals fields. ",
"required": [
"decimals",
"name",
"symbol"
],
"required": ["decimals", "name", "symbol"],
"properties": {
"decimals": {
"description": "Non-negative integer",
Expand Down

0 comments on commit 9282784

Please sign in to comment.