Skip to content

Commit 5f94f8c

Browse files
holimankaralabe
authored andcommitted
signer: change the stdio jsonrpc to use legacy namespace conventions (#19047)
This PR will will break existing UIs, since it changes all calls like ApproveSignTransaction to be on the form ui_approveSignTransaction. This is to make it possible for the UI to reuse the json-rpc library from go-ethereum, which uses this convention. Also, this PR removes some unused structs, after import/export were removed from the external api (so no longer needs internal methods for approval) One more breaking change is introduced, removing passwords from the ApproveSignTxResponse and the likes. This makes the manual interface more like the rulebased interface, and integrates nicely with the credential storage. Thus, the way it worked before, it would be tempting for the UI to implement 'remember password' functionality. The way it is now, it will be easy instead to tell clef to store passwords and use them. If a pw is not found in the credential store, the user is prompted to provide the password.
1 parent eb199f1 commit 5f94f8c

13 files changed

Lines changed: 398 additions & 466 deletions

File tree

‎cmd/clef/README.md‎

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ OBS! A slight deviation from `json` standard is in place: every request and resp
661661
Whereas the `json` specification allows for linebreaks, linebreaks __should not__ be used in this communication channel, to make
662662
things simpler for both parties.
663663

664-
### ApproveTx
664+
### ApproveTx / `ui_approveTx`
665665

666666
Invoked when there's a transaction for approval.
667667

@@ -673,13 +673,13 @@ Here's a method invocation:
673673

674674
curl -i -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"account_signTransaction","params":[{"from":"0x694267f14675d7e1b9494fd8d72fefe1755710fa","gas":"0x333","gasPrice":"0x1","nonce":"0x0","to":"0x07a565b7ed7d7a678680a4c162885bedbb695fe0", "value":"0x0", "data":"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"},"safeSend(address)"],"id":67}' http://localhost:8550/
675675
```
676-
676+
Results in the following invocation on the UI:
677677
```json
678678

679679
{
680680
"jsonrpc": "2.0",
681681
"id": 1,
682-
"method": "ApproveTx",
682+
"method": "ui_approveTx",
683683
"params": [
684684
{
685685
"transaction": {
@@ -724,7 +724,7 @@ curl -i -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","me
724724
{
725725
"jsonrpc": "2.0",
726726
"id": 1,
727-
"method": "ApproveTx",
727+
"method": "ui_approveTx",
728728
"params": [
729729
{
730730
"transaction": {
@@ -767,7 +767,7 @@ One which has missing `to`, but with no `data`:
767767
{
768768
"jsonrpc": "2.0",
769769
"id": 3,
770-
"method": "ApproveTx",
770+
"method": "ui_approveTx",
771771
"params": [
772772
{
773773
"transaction": {
@@ -796,33 +796,7 @@ One which has missing `to`, but with no `data`:
796796
}
797797
```
798798

799-
### ApproveExport
800-
801-
Invoked when a request to export an account has been made.
802-
803-
#### Sample call
804-
805-
```json
806-
807-
{
808-
"jsonrpc": "2.0",
809-
"id": 7,
810-
"method": "ApproveExport",
811-
"params": [
812-
{
813-
"address": "0x0000000000000000000000000000000000000000",
814-
"meta": {
815-
"remote": "signer binary",
816-
"local": "main",
817-
"scheme": "in-proc"
818-
}
819-
}
820-
]
821-
}
822-
823-
```
824-
825-
### ApproveListing
799+
### ApproveListing / `ui_approveListing`
826800

827801
Invoked when a request for account listing has been made.
828802

@@ -833,7 +807,7 @@ Invoked when a request for account listing has been made.
833807
{
834808
"jsonrpc": "2.0",
835809
"id": 5,
836-
"method": "ApproveListing",
810+
"method": "ui_approveListing",
837811
"params": [
838812
{
839813
"accounts": [
@@ -860,15 +834,15 @@ Invoked when a request for account listing has been made.
860834
```
861835

862836

863-
### ApproveSignData
837+
### ApproveSignData / `ui_approveSignData`
864838

865839
#### Sample call
866840

867841
```json
868842
{
869843
"jsonrpc": "2.0",
870844
"id": 4,
871-
"method": "ApproveSignData",
845+
"method": "ui_approveSignData",
872846
"params": [
873847
{
874848
"address": "0x123409812340981234098123409812deadbeef42",
@@ -886,7 +860,7 @@ Invoked when a request for account listing has been made.
886860

887861
```
888862

889-
### ShowInfo
863+
### ShowInfo / `ui_showInfo`
890864

891865
The UI should show the info to the user. Does not expect response.
892866

@@ -896,7 +870,7 @@ The UI should show the info to the user. Does not expect response.
896870
{
897871
"jsonrpc": "2.0",
898872
"id": 9,
899-
"method": "ShowInfo",
873+
"method": "ui_showInfo",
900874
"params": [
901875
{
902876
"text": "Tests completed"
@@ -906,7 +880,7 @@ The UI should show the info to the user. Does not expect response.
906880

907881
```
908882

909-
### ShowError
883+
### ShowError / `ui_showError`
910884

911885
The UI should show the info to the user. Does not expect response.
912886

@@ -925,15 +899,15 @@ The UI should show the info to the user. Does not expect response.
925899

926900
```
927901

928-
### OnApproved
902+
### OnApprovedTx / `ui_onApprovedTx`
929903

930904
`OnApprovedTx` is called when a transaction has been approved and signed. The call contains the return value that will be sent to the external caller. The return value from this method is ignored - the reason for having this callback is to allow the ruleset to keep track of approved transactions.
931905

932906
When implementing rate-limited rules, this callback should be used.
933907

934908
TLDR; Use this method to keep track of signed transactions, instead of using the data in `ApproveTx`.
935909

936-
### OnSignerStartup
910+
### OnSignerStartup / `ui_onSignerStartup`
937911

938912
This method provide the UI with information about what API version the signer uses (both internal and external) aswell as build-info and external api,
939913
in k/v-form.
@@ -944,7 +918,7 @@ Example call:
944918
{
945919
"jsonrpc": "2.0",
946920
"id": 1,
947-
"method": "OnSignerStartup",
921+
"method": "ui_onSignerStartup",
948922
"params": [
949923
{
950924
"info": {

‎cmd/clef/datatypes.md‎

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ Response to SignDataRequest
3535
Example:
3636
```json
3737
{
38-
"approved": true,
39-
"Password": "apassword"
38+
"approved": true
4039
}
4140
```
4241
### SignDataResponse - deny
@@ -46,8 +45,7 @@ Response to SignDataRequest
4645
Example:
4746
```json
4847
{
49-
"approved": false,
50-
"Password": ""
48+
"approved": false
5149
}
5250
```
5351
### SignTxRequest
@@ -89,9 +87,9 @@ Example:
8987
}
9088
}
9189
```
92-
### SignDataResponse - approve
90+
### SignTxResponse - approve
9391

94-
Response to SignDataRequest. This response needs to contain the `transaction`, because the UI is free to make modifications to the transaction.
92+
Response to request to sign a transaction. This response needs to contain the `transaction`, because the UI is free to make modifications to the transaction.
9593

9694
Example:
9795
```json
@@ -105,19 +103,26 @@ Example:
105103
"nonce": "0x4",
106104
"data": "0x04030201"
107105
},
108-
"approved": true,
109-
"password": "apassword"
106+
"approved": true
110107
}
111108
```
112-
### SignDataResponse - deny
109+
### SignTxResponse - deny
113110

114-
Response to SignDataRequest. When denying a request, there's no need to provide the transaction in return
111+
Response to SignTxRequest. When denying a request, there's no need to provide the transaction in return
115112

116113
Example:
117114
```json
118115
{
119-
"approved": false,
120-
"Password": ""
116+
"transaction": {
117+
"from": "0x",
118+
"to": null,
119+
"gas": "0x0",
120+
"gasPrice": "0x0",
121+
"value": "0x0",
122+
"nonce": "0x0",
123+
"data": null
124+
},
125+
"approved": false
121126
}
122127
```
123128
### OnApproved - SignTransactionResult
@@ -164,7 +169,7 @@ Example:
164169
```
165170
### UserInputResponse
166171

167-
Response to SignDataRequest
172+
Response to UserInputRequest
168173

169174
Example:
170175
```json
@@ -198,7 +203,7 @@ Example:
198203
}
199204
}
200205
```
201-
### UserInputResponse
206+
### ListResponse
202207

203208
Response to list request. The response contains a list of all addresses to show to the caller. Note: the UI is free to respond with any address the caller, regardless of whether it exists or not
204209

‎cmd/clef/intapi_changelog.md‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
### Changelog for internal API (ui-api)
22

3+
### 6.0.0
4+
5+
Removed `password` from responses to operations which require them. This is for two reasons,
6+
7+
- Consistency between how rulesets operate and how manual processing works. A rule can `Approve` but require the actual password to be stored in the clef storage.
8+
With this change, the same stored password can be used even if rulesets are not enabled, but storage is.
9+
- It also removes the usability-shortcut that a UI might otherwise want to implement; remembering passwords. Since we now will not require the
10+
password on every `Approve`, there's no need for the UI to cache it locally.
11+
- In a future update, we'll likely add `clef_storePassword` to the internal API, so the user can store it via his UI (currently only CLI works).
12+
13+
Affected datatypes:
14+
- `SignTxResponse`
15+
- `SignDataResponse`
16+
- `NewAccountResponse`
17+
18+
If `clef` requires a password, the `OnInputRequired` will be used to collect it.
19+
20+
21+
### 5.0.0
22+
23+
Changed the namespace format to adhere to the legacy ethereum format: `name_methodName`. Changes:
24+
25+
* `ApproveTx` -> `ui_approveTx`
26+
* `ApproveSignData` -> `ui_approveSignData`
27+
* `ApproveExport` -> `removed`
28+
* `ApproveImport` -> `removed`
29+
* `ApproveListing` -> `ui_approveListing`
30+
* `ApproveNewAccount` -> `ui_approveNewAccount`
31+
* `ShowError` -> `ui_showError`
32+
* `ShowInfo` -> `ui_showInfo`
33+
* `OnApprovedTx` -> `ui_onApprovedTx`
34+
* `OnSignerStartup` -> `ui_onSignerStartup`
35+
* `OnInputRequired` -> `ui_onInputRequired`
36+
37+
338
### 4.0.0
439

540
* Bidirectional communication implemented, so the UI can query `clef` via the stdin/stdout RPC channel. Methods implemented are:

0 commit comments

Comments
 (0)