Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: Add some missing examples #140

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 54 additions & 17 deletions specs/erc-7730.md
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,36 @@ This snippet introduces an enumeration describing the displayable values of an i

It also shows how to describe a more dynamic enumeration, like a list of possible vaultIDs as integer values, retrievable through an URL. This dynamic enumeration can be referenced using `$.metadata.enums.vaultIDs`.

```json
{
"display": {
"formats": {
"repay(address asset, uint256 amount, uint256 interestRateMode)": {
"$id": "repay",
"intent": "Repay loan",
"fields": [
{
"path": "amount",
"format": "tokenAmount",
"label": "Amount to repay",
"params": { "tokenPath": "asset" }
},
{
"path": "interestRateMode",
"format": "enum",
"label": "Interest rate mode",
"params": { "$ref": "$.metadata.enums.interestRateMode" }
}
],
"required": ["amount", "interestRateMode"]
}
}
}
}
```

In this example, the `interestRateMode` field is formatted using the enumeration defined under `$.metadata.enums.interestRateMode`.

### `Display` section

The `display` section contains the actual formatting instructions for each field of the bound structured data. It is split into two parts, a `display.definitions` key that contains common formats that can be re-used in the other parts and a `display.formats` key containing the actual format instructions for each function / message type bound to the specification file.
Expand Down Expand Up @@ -940,17 +970,18 @@ Formats usable for uint/int solidity types.
| `message` | message to display above threshold. Optional, defaults to "Unlimited" |
| *Examples* | --- |
| `1 DAI` | Field value = 1000000 <br> `tokenPath` =0x6B17...1d0F (DAI, 6 decimals) |
| `Unlimited DAI` | Field value = 0xFFFFFFFF <br> `tokenPath` =0x6B17...1d0F (DAI, 6 decimals) <br> `threshold` "0xFFFFFFFF" |
| `Unlimited DAI` | Field value = 0xFFFFFFFF <br> `token` =0x6B17...1d0F (DAI, 6 decimals) <br> `threshold` "0xFFFFFFFF" |
| `Max DAI` | Field value = 0xFFFFFFFF <br> `tokenPath` =0x6B17...1d0F (DAI, 6 decimals) <br> `threshold` "0xFFFFFFFF" <br> `message` = "Max" |
| `0.002 ETH` | Field value = 2000000000000000 <br> `tokenPath` = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE <br> `nativeCurrencyAddress` = ["0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"] |

---
| **`nftName`** | |
|-----------------------------------------|---------------------------------------------------------------------------------------------------------------|
| *Description* | Display value as a specific NFT in a collection, if found by wallet, or fallback to a raw int token ID if not |
| *Parameters* | --- |
| `collectionPath` or `collection` | A path reference, or constant value for the collection address |
| *Examples* | --- |
| `ETH-USD December 10, 2021 3:48 PM GMT` | Field Value = 674 <br> `collectionPath` = "0xaa3a...84ea" (from rarible) |
| **`nftName`** | |
|------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
| *Description* | Display value as a specific NFT in a collection, if found by wallet, or fallback to a raw int token ID if not |
| *Parameters* | --- |
| `collectionPath` or `collection` | A path reference, or constant value for the collection address |
| *Examples* | --- |
| `Collection Name: BoredApeYachtClub` <br> `Token ID: 1036` | Field Value = 1036 <br> `collectionPath` = ""0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D |

---
| **`date`** | |
Expand All @@ -969,6 +1000,7 @@ Formats usable for uint/int solidity types.
| *Description* | Display int as a duration interpreted in seconds and represented as a duration HH:MM:ss |
| *Parameters* | None |
| *Examples* | --- |
| `02:17:30` | Field Value = 8250 |

---
| **`unit`** | |
Expand All @@ -979,6 +1011,9 @@ Formats usable for uint/int solidity types.
| `decimals` | Number of decimals in integer representation, defaults to 0 |
| `prefix` | A boolean indicating whether an SI prefix should be appended, defaults to `False` |
| *Examples* | --- |
| `10h` | Field Value = 10 <br> `base` = "h" |
| `1.5d` | Field Value = 15 <br> `base` = "d" <br> `decimals` = 1 |
| `36ks` | Field Value = 36000 <br> `base` = "s" <br> `prefix` = True |

---
| **`enum`** | |
Expand Down Expand Up @@ -1034,15 +1069,17 @@ Formats usable for address
| `0x5aAe...eAed` | Field Value 0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed |

---
| **`addressName`** | |
|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| *Description* | Display address as a trusted name if a trusted source exists, an EIP-55 formatted address otherwise. See [next section](#address-types-and-sources) for a reference of trusted sources |
| *Parameters* | --- |
| `types` | An array of expected types of the address (see [next section](#address-types-and-sources)). If set, the wallet SHOULD check that the address matches one of the types provided |
| `sources` | An array of acceptable sources for names (see [next section](#address-types-and-sources)). If set, the wallet SHOULD restrict name lookup to relevant sources |
| `senderAddress` | Either a string or an array of strings. If the address pointed to by `addressName` is equal to one of the addresses in `senderAddress`, the addressName is interpreted as the sender referenced by `@.from` |
| *Examples* | --- |
| `vitalik.eth` | Field Value 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 |
| **`addressName`** | |
|-------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| *Description* | Display address as a trusted name if a trusted source exists, an EIP-55 formatted address otherwise. See [next section](#address-types-and-sources) for a reference of trusted sources |
| *Parameters* | --- |
| `types` | An array of expected types of the address (see [next section](#address-types-and-sources)). If set, the wallet SHOULD check that the address matches one of the types provided |
| `sources` | An array of acceptable sources for names (see [next section](#address-types-and-sources)). If set, the wallet SHOULD restrict name lookup to relevant sources |
| `senderAddress` | Either a string or an array of strings. If the address pointed to by `addressName` is equal to one of the addresses in `senderAddress`, the addressName is interpreted as the sender referenced by `@.from` |
| *Examples* | --- |
| `vitalik.eth` | Field Value 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 <br> `types` = ["eoa"] (Externally Owned Account) <br> `sources` = ["ens"] (Ethereum Name Service) |
| `Uniswap V3: WBTC-USDC` | Field Value 0x99ac8cA7087fA4A2A1FB6357269965A2014ABc35 <br> `types` = ["contract"] |
| `Sender` | Field Value 0x0000000000000000000000000000000000000000 <br> `senderAddress` = ["0x0000000000000000000000000000000000000000"] <br> `types` = ["eoa"] |

#### Address types and sources

Expand Down