Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
spec: add support for explicitly declaring excluded fields (LedgerHQ#31)
Browse files Browse the repository at this point in the history
* spec: add support for explicitly declaring excluded fields

This allows validation to properly deal with omitted fields:
 - field has no formatter and not in `excluded` => descriptor is invalid
 - field has no formatter and is in `excluded` => OK, descriptor is valid

* spec: add support for explicitly declaring excluded fields

This allows validation to properly deal with omitted fields:
 - field has no formatter and not in `excluded` => descriptor is invalid
 - field has no formatter and is in `excluded` => OK, descriptor is valid

* copy
  • Loading branch information
jnicoulaud-ledger authored Oct 8, 2024
1 parent 4418025 commit 63693b8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 10 additions & 2 deletions specs/erc-7730.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ The following is a simple example of how to clear sign a `transfer` function cal
}
}
],
"required": ["_to", "_value"]
"required": ["_to", "_value"],
"excluded": []
}
}
}
Expand All @@ -126,7 +127,8 @@ Finally, the `display` section contains the definitions of how to format each fi
In this example, the function being described is identified by its solidity signature `transfer(address _to,uint256 _value)`. This is the signature used to compute the function selector `0xa9059cbb` (using the solidity signature guarantees unicity in the context of the contract).
* The `intent` key contains a human readable string that wallets SHOULD display to explain to the user the intent of the function call.
* The `fields` key contains all the parameters that CAN be displayed, and the way to format them
* The `required` key indicates which parameters wallets SHOULD display).
* The `required` key indicates which parameters wallets SHOULD display.
* The `excluded` key indicates which parameters are intentionally left out (none in this example).

In this example, the `_to` parameter and the `_value` SHOULD both be displayed, one as an address replaceable by a trusted name (ENS or others), the other as an amount formatted using metadata of the target ERC-20 contract (USDT).

Expand Down Expand Up @@ -770,6 +772,12 @@ Required fields, as an array of *paths* referring to specific fields.

Wallets SHOULD display at least all the fields referred by the `required` key.

**`excluded`**

Intentionally excluded fields, as an array of *paths* referring to specific fields.

A field that has no formatter and is not declared in this list MAY be considered as an error by the wallet when interpreting the descriptor.

**`screens`**

Wallet specific grouping information. The structure of the `screens` sub-keys is wallet maker specific and referenced in the [Wallets](#wallets) section.
Expand Down
12 changes: 11 additions & 1 deletion specs/erc7730-v1.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@
"required": {
"$ref": "#/$display/required"
},
"excluded": {
"$ref": "#/$display/excluded"
},
"screens": {
"title": "Screens grouping information",
"description": "Screens section is used to group multiple fields to display into screens. Each key is a wallet type name. The format of the screens is wallet type dependent, as well as what can be done (reordering fields, max number of screens, etc...). See each wallet manufacturer documentation for more information.",
Expand Down Expand Up @@ -418,7 +421,14 @@
"title": "Required fields",
"description": "A list of fields that are required to be displayed to the user. A field that has a formatter and is not in this list is optional. A field that does not have a formatter should be silent, ie not shown",
"type": "array",

"items": {
"type": "string"
}
},
"excluded": {
"title": "Excluded fields",
"description": "A list of fields that are intentionally not shown to the user. A field that has no formatter and is not declared in this list may be considered as an error by the wallet when interpreting the descriptor.",
"type": "array",
"items": {
"type": "string"
}
Expand Down

0 comments on commit 63693b8

Please sign in to comment.