Skip to content

Commit 2341c2f

Browse files
anvacaruehildenb
authored andcommitted
web3.md: refactor eth_accounts (#528)
1 parent a27d26a commit 2341c2f

File tree

3 files changed

+69
-5
lines changed

3 files changed

+69
-5
lines changed

tests/web3/eth_accounts.expected.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"jsonrpc":"2.0","id":1,"result":true},{"jsonrpc":"2.0","id":2,"result":true},{"jsonrpc":"2.0","id":3,"result":true},{"jsonrpc":"2.0","id":4,"result":true},{"jsonrpc":"2.0","id":5,"result":true},{"jsonrpc":"2.0","id":6,"result":["0x64cd3de3157c82289423d85927a16e3596a7ffe4","0x805bba773af1efd0cd8be0e7aea7416e72111b3b","0x8850073ba56b1c2b6d7acb66e8038ee9aa14be13","0x9db3c363b007411468a72ad8df941ea515ad7125","0xd1af81d02bd851e4b9db6d4144b03027154392c5"]}]

tests/web3/eth_accounts.in.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
[
2+
{
3+
"jsonrpc": "2.0",
4+
"id": 1,
5+
"method": "firefly_addAccount",
6+
"params": [
7+
{
8+
"key": "0x77bcbbd9580484c1b590a9204c353f9fd1bb699679faf1b25de7a73805734a90",
9+
"balance": "0x56bc75e2d63100000"
10+
}
11+
]
12+
},
13+
{
14+
"jsonrpc": "2.0",
15+
"id": 2,
16+
"method": "firefly_addAccount",
17+
"params": [
18+
{
19+
"key": "0x0aec5005bb49ecbd568638ef77922619a27e624a9fe52942f26fb882bde5fadf",
20+
"balance": "0x56bc75e2d63100000"
21+
}
22+
]
23+
},
24+
{
25+
"jsonrpc": "2.0",
26+
"id": 3,
27+
"method": "firefly_addAccount",
28+
"params": [
29+
{
30+
"key": "0x96b039ec4e731cad6b9dcc480ad5be85ca81d5fa9ebb50dc3495c0e5bc677da9",
31+
"balance": "0x56bc75e2d63100000"
32+
}
33+
]
34+
},
35+
{
36+
"jsonrpc": "2.0",
37+
"id": 4,
38+
"method": "firefly_addAccount",
39+
"params": [
40+
{
41+
"key": "0x8d835217a5a71f2934485721b1644d7f2e229f4db84d766e82bd643828d7ef6c",
42+
"balance": "0x56bc75e2d63100000"
43+
}
44+
]
45+
},
46+
{
47+
"jsonrpc": "2.0",
48+
"id": 5,
49+
"method": "firefly_addAccount",
50+
"params": [
51+
{
52+
"key": "0x63fb18ac02bc1013c8518af4e4af422a0524b42f6868efda6708c9b795fc575b",
53+
"balance": "0x56bc75e2d63100000"
54+
}
55+
]
56+
},
57+
{
58+
"jsonrpc":"2.0",
59+
"id":6,
60+
"method": "eth_accounts",
61+
"params":[]
62+
}
63+
]

web3.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,13 @@ WEB3 JSON RPC
352352
353353
syntax KItem ::= "#eth_accounts"
354354
// --------------------------------
355-
rule <k> #eth_accounts => #sendResponse( "result" : [ #acctsToJArray( ACCTS ) ] ) ... </k>
355+
rule <k> #eth_accounts => #sendResponse( "result" : [ #acctsToJArray( qsort(Set2List(ACCTS)) ) ] ) ... </k>
356356
<activeAccounts> ACCTS </activeAccounts>
357357
358-
syntax JSONList ::= #acctsToJArray ( Set ) [function]
359-
// -----------------------------------------------------
360-
rule #acctsToJArray( .Set ) => .JSONList
361-
rule #acctsToJArray( SetItem( ACCT ) ACCTS:Set ) => #unparseData( ACCT, 20 ), #acctsToJArray( ACCTS )
358+
syntax JSONList ::= #acctsToJArray ( List ) [function]
359+
// ------------------------------------------------------
360+
rule #acctsToJArray( .List ) => .JSONList
361+
rule #acctsToJArray( ListItem( ACCT ) ACCTS:List ) => #unparseData( ACCT, 20 ), #acctsToJArray( ACCTS )
362362
363363
syntax KItem ::= "#eth_getBalance"
364364
// ----------------------------------

0 commit comments

Comments
 (0)