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

feat(BACK-8135): add support for providing literal values #109

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions ercs/calldata-erc20-tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"path": "_value",
"label": "Amount",
"format": "tokenAmount",
"params": { "tokenPath": "$.context.contract.deployments.[0].address" }
"params": { "token": "$.context.contract.deployments.[0].address" }
}
],
"required": ["_to", "_value"]
Expand All @@ -53,7 +53,7 @@
"label": "Amount",
"format": "tokenAmount",
"params": {
"tokenPath": "$.context.contract.deployments.[0].address",
"token": "$.context.contract.deployments.[0].address",
"threshold": "0x8000000000000000000000000000000000000000000000000000000000000000"
}
}
Expand Down
8 changes: 4 additions & 4 deletions registry/lido/calldata-OssifiableProxy.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

Check notice on line 1 in registry/lido/calldata-OssifiableProxy.json

View workflow job for this annotation

GitHub Actions / 🔎 validate descriptors

Proxy contract

Contract https://etherscan.io/address/0x889edc2edab5f40e902b864ad4d7ade8e412f9b1#code is likely to be a proxy, validation of descriptor ABIs skipped
"$schema": "../../specs/erc7730-v1.schema.json",
"context": {
"$id": "OssifiableProxy",
Expand All @@ -24,7 +24,7 @@
"path": "_amounts.[]",
"label": "Amount to withdraw",
"format": "tokenAmount",
"params": { "tokenPath": "$.metadata.constants.wstETHaddress" }
"params": { "token": "$.metadata.constants.wstETHaddress" }
},
{
"path": "_owner",
Expand All @@ -42,7 +42,7 @@
"path": "_amounts.[]",
"label": "Amount to withdraw",
"format": "tokenAmount",
"params": { "tokenPath": "$.metadata.constants.wstETHaddress" }
"params": { "token": "$.metadata.constants.wstETHaddress" }
},
{
"path": "_owner",
Expand All @@ -61,7 +61,7 @@
"path": "_amounts.[]",
"label": "Amount to withdraw",
"format": "tokenAmount",
"params": { "tokenPath": "$.metadata.constants.stETHaddress" }
"params": { "token": "$.metadata.constants.stETHaddress" }
},
{
"path": "_owner",
Expand All @@ -79,7 +79,7 @@
"path": "_amounts.[]",
"label": "Amount to withdraw",
"format": "tokenAmount",
"params": { "tokenPath": "$.metadata.constants.stETHaddress" }
"params": { "token": "$.metadata.constants.stETHaddress" }
},
{
"path": "_owner",
Expand Down
2 changes: 1 addition & 1 deletion registry/lido/calldata-wstETH.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"path": "_stETHAmount",
"label": "Amount to exchange",
"format": "tokenAmount",
"params": { "tokenPath": "$.metadata.constants.stETHaddress" }
"params": { "token": "$.metadata.constants.stETHaddress" }
}
]
},
Expand Down
44 changes: 22 additions & 22 deletions specs/erc-7730.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ The `display` section contains the actual formatting instructions for each field

The `definitions` key is an object in which each sub-key is a [*field format specification*](#field-format-specification). The sub-key name is the name of the common definition and is used to refer to this object in the form of a path starting with root node `$.` (i.e. `$.display.definitions.DEF_NAME`).

Definitions don't usually include the `path` key of a [*field format specification*](#field-format-specification), since they are intended for re-use in other fields specifications, that will specify locally what path they apply to.
Definitions don't usually include the `path` or `value` key of a [*field format specification*](#field-format-specification), since they are intended for re-use in other fields specifications, that will specify locally what path they apply to.

*Example*

Expand Down Expand Up @@ -792,7 +792,7 @@ Wallets SHOULD NOT override formatting information in the `fields` key in the wa

A *field format specification* is a json object defining how to format a single field of the structured data.

* The `path` is the absolute or relative path to the field location in the structured data, as described in the [path section](#path-references)
* The `path` is the absolute or relative path to the field location in the structured data, as described in the [path section](#path-references). A literal `value` can be used instead to display a constant rather than looking up a field in the structured data.
* The `label` is a displayable string that should be shown before displaying this field
* The `format` key indicates how the value of the field should be formatted before being displayed. The list of supported formats are in the [Reference](#field-formats) section
* Each field format might have parameters in a `params` sub-key. Available parameters are described in the [Reference](#field-formats) section
Expand Down Expand Up @@ -930,25 +930,25 @@ Formats usable for uint/int solidity types.
| *Examples* | Value 0x2c1c986f1c48000 is displayed as `0.19866144 ETH` |

---
| **`tokenAmount`** | |
|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| *Description* | Convert value using token decimals, and append token ticker name. If value is above optional `threshold`, display instead `message` with ticker. |
| *Parameters* | --- |
| `tokenPath` | path reference to the address of the token contract. Used to associate correct ticker. If ticker is not found or tokenPath is not set, the wallet SHOULD display the raw value instead with an "Unknown token" warning |
| `nativeCurencyAddress` | Either a string or an array of strings. If the address pointed to by `tokenPath` is equal to one of the addresses in `nativeCurrencyAddress`, the tokenAmount is interpreted as expressed in native currency |
| `threshold` | integer value, above which value is displayed as a special message. Optional |
| `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" |
| `Max DAI` | Field value = 0xFFFFFFFF <br> `tokenPath` =0x6B17...1d0F (DAI, 6 decimals) <br> `threshold` "0xFFFFFFFF" <br> `message` = "Max" |
| **`tokenAmount`** | |
|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| *Description* | Convert value using token decimals, and append token ticker name. If value is above optional `threshold`, display instead `message` with ticker. |
| *Parameters* | --- |
| `tokenPath` or `token` | path reference, or constant value for the address of the token contract. Used to associate correct ticker. If ticker is not found or `tokenPath`/`token` is not set, the wallet SHOULD display the raw value instead with an "Unknown token" warning |
| `nativeCurencyAddress` | Either a string or an array of strings. If the address pointed to by `tokenPath` is equal to one of the addresses in `nativeCurrencyAddress`, the tokenAmount is interpreted as expressed in native currency |
| `threshold` | integer value, above which value is displayed as a special message. Optional |
| `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" |
| `Max DAI` | Field value = 0xFFFFFFFF <br> `tokenPath` =0x6B17...1d0F (DAI, 6 decimals) <br> `threshold` "0xFFFFFFFF" <br> `message` = "Max" |

---
| **`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` | A path reference to the collection address |
| `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) |

Expand Down Expand Up @@ -1013,13 +1013,13 @@ Formats usable for bytes
| `123456789A` | Field Value = Value ['12','34','56','78','9a'] |

---
| **`calldata`** | |
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| *Description* | Data contains a call to another smart contract. To look for relevant ERC-7730 files matching this embedded calldata, use `callee` parameter and `selector`. If an ERC-7730 is not found or if embedded calldata are not supported by the wallet, it MAY display a hash of the embedded calldata instead, with target `calleePath` resolved to a trusted name if possible. |
| *Parameters* | --- |
| `selector` | Optional selector, if not present the first 4 bytes of the calldata are interpreted as the selector |
| `calleePath` | A path reference to the contract being called |
| *Examples* | |
| **`calldata`** | |
|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| *Description* | Data contains a call to another smart contract. To look for relevant ERC-7730 files matching this embedded calldata, use `callee` parameter and `selector`. If an ERC-7730 is not found or if embedded calldata are not supported by the wallet, it MAY display a hash of the embedded calldata instead, with target `calleePath` resolved to a trusted name if possible. |
| *Parameters* | --- |
| `selector` | Optional selector, if not present the first 4 bytes of the calldata are interpreted as the selector |
| `calleePath` or `callee` | A path reference or constant value for the contract being called |
| *Examples* | |

#### Address

Expand Down
Loading