Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit a2c7836

Browse files
author
Cody Douglass
committed
merge conflicts to master
2 parents d100296 + 41bb99b commit a2c7836

File tree

3 files changed

+40
-22
lines changed

3 files changed

+40
-22
lines changed

docs/4.-Reading blockchain-Examples.md

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ Get the first 10 token balances of account _testacc_.
1717
```javascript
1818
const resp = await rpc.get_table_rows({
1919
json: true, // Get the response as json
20-
code: 'eosio.token', // Contract that we target
21-
scope: 'testacc' // Account that owns the data
22-
table: 'accounts' // Table name
23-
limit: 10, // maximum number of rows that we want to get
20+
code: 'eosio.token', // Contract that we target
21+
scope: 'testacc' // Account that owns the data
22+
table: 'accounts' // Table name
23+
limit: 10, // Maximum number of rows that we want to get
24+
reverse = false, // Optional: Get reversed data
25+
show_payer = false, // Optional: Show ram payer
2426
});
2527

2628
console.log(resp.rows);
2729
```
28-
Output:
30+
Output:
2931

3032
```json
3133
{
@@ -42,15 +44,17 @@ Output:
4244
```javascript
4345
const resp = await rpc.get_table_rows({
4446
json: true, // Get the response as json
45-
code: 'contract', // Contract that we target
46-
scope: 'contract' // Account that owns the data
47-
table: 'profiles' // Table name
48-
lower_bound: 'testacc' // Table primary key value
47+
code: 'contract', // Contract that we target
48+
scope: 'contract' // Account that owns the data
49+
table: 'profiles' // Table name
50+
lower_bound: 'testacc' // Table primary key value
4951
limit: 1, // Here we limit to 1 to get only the
52+
reverse = false, // Optional: Get reversed data
53+
show_payer = false, // Optional: Show ram payer
5054
});
5155
console.log(resp.rows);
5256
```
53-
Output:
57+
Output:
5458

5559
```json
5660
{
@@ -64,21 +68,23 @@ Output:
6468
}
6569
```
6670

67-
### Get one row by secondary index
71+
### Get one row by secondary index
6872

6973
```javascript
7074
const resp = await rpc.get_table_rows({
7175
json: true, // Get the response as json
72-
code: 'contract', // Contract that we target
73-
scope: 'contract' // Account that owns the data
74-
table: 'profiles' // Table name
75-
table_key: 'age' // Table secondaray key name
76-
lower_bound: 21 // Table secondary key value
77-
limit: 1, // Here we limit to 1 to get only the
76+
code: 'contract', // Contract that we target
77+
scope: 'contract' // Account that owns the data
78+
table: 'profiles' // Table name
79+
table_key: 'age' // Table secondaray key name
80+
lower_bound: 21 // Table secondary key value
81+
limit: 1, // Here we limit to 1 to get only row
82+
reverse = false, // Optional: Get reversed data
83+
show_payer = false, // Optional: Show ram payer
7884
});
7985
console.log(resp.rows);
8086
```
81-
Output:
87+
Output:
8288

8389
```json
8490
{
@@ -97,7 +103,7 @@ Output:
97103
```javascript
98104
console.log(await rpc.get_currency_balance('eosio.token', 'testacc', 'HAK'));
99105
```
100-
Output:
106+
Output:
101107

102108
```json
103109
[ "1000000000.0000 HAK" ]
@@ -108,7 +114,7 @@ Output:
108114
```javascript
109115
console.log(await rpc.get_account('testacc'));
110116
```
111-
Output:
117+
Output:
112118

113119
```json
114120
{ "account_name": "testacc",
@@ -123,7 +129,7 @@ Output:
123129
"net_limit": { "used": -1, "available": -1, "max": -1 },
124130
"cpu_limit": { "used": -1, "available": -1, "max": -1 },
125131
"ram_usage": 2724,
126-
"permissions":
132+
"permissions":
127133
[ { "perm_name": "active", "parent": "owner", "required_auth": [] },
128134
{ "perm_name": "owner", "parent": "", "required_auth": [] } ],
129135
"total_resources": null,
@@ -137,7 +143,7 @@ Output:
137143
```javascript
138144
console.log(await rpc.get_block(1));
139145
```
140-
Output:
146+
Output:
141147

142148
```json
143149
{ "timestamp": "2018-06-01T12:00:00.000",

src/eosjs-jsonrpc.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ export class JsonRpc implements AuthorityProvider, AbiProvider {
137137
index_position = 1,
138138
key_type = '',
139139
limit = 10,
140+
reverse = false,
141+
show_payer = false,
140142
}: any): Promise<any> {
141143
return await this.fetch(
142144
'/v1/chain/get_table_rows', {
@@ -150,6 +152,8 @@ export class JsonRpc implements AuthorityProvider, AbiProvider {
150152
index_position,
151153
key_type,
152154
limit,
155+
reverse,
156+
show_payer,
153157
});
154158
}
155159

src/tests/eosjs-jsonrpc.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ describe('JSON RPC', () => {
354354
const indexPosition = 1;
355355
const keyType = 'str';
356356
const expReturn = { data: '12345' };
357+
const reverse = false;
358+
const showPayer = false;
357359
const callParams = {
358360
json,
359361
code,
@@ -365,6 +367,8 @@ describe('JSON RPC', () => {
365367
index_position: indexPosition,
366368
key_type: keyType,
367369
limit,
370+
reverse,
371+
show_payer: showPayer,
368372
};
369373
const expParams = {
370374
body: JSON.stringify(callParams),
@@ -391,6 +395,8 @@ describe('JSON RPC', () => {
391395
const limit = 10;
392396
const indexPosition = 1;
393397
const keyType = '';
398+
const reverse = false;
399+
const showPayer = false;
394400
const expReturn = { data: '12345' };
395401
const callParams = {
396402
code,
@@ -409,6 +415,8 @@ describe('JSON RPC', () => {
409415
index_position: indexPosition,
410416
key_type: keyType,
411417
limit,
418+
reverse,
419+
show_payer: showPayer,
412420
}),
413421
method: 'POST',
414422
};

0 commit comments

Comments
 (0)