Skip to content

Commit 9d3096d

Browse files
committed
Merge branch 'release/22.1.1'
2 parents 12025a3 + cb45284 commit 9d3096d

13 files changed

+333
-41
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ Open a connection to JSON-RPC, include `fetch` when on Node.js.
7474
const rpc = new JsonRpc('http://127.0.0.1:8888', { fetch });
7575
```
7676

77+
A new chain API that infrablockchain has is also implemented in `infrablockchain-js`.
78+
```js
79+
const systemTokenBalance = await rpc.get_system_token_balance("systoken.a");
80+
const systemTokenList = await rpc.get_system_token_list(true);
81+
const tokenBalance = await rpc.get_token_balance("systoken.a", "systoken.a");
82+
const tokenInfo = await rpc.get_token_info("systoken.a");
83+
const txVoteReceiverList = await rpc.get_top_tx_vote_receiver_list();
84+
const txVoteStat = await rpc.get_tx_vote_stat_for_account("producer.a");
85+
const txFeeItem = await rpc.get_txfee_item("", "");
86+
const txFeeList = await rpc.get_txfee_list();
87+
```
88+
89+
7790
### API
7891

7992
Include textDecoder and textEncoder when using in Node. You may exclude these when running in a browser since most modern browsers now natively support these. If your browser does not support these (https://caniuse.com/#feat=textencoder), then you can import them as a dependency through the following deprecated npm package: https://www.npmjs.com/package/text-encoding
@@ -85,6 +98,8 @@ const api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), te
8598

8699
`transact()` is used to sign and push transactions onto the blockchain with an optional configuration object parameter. This parameter can override the default value of `broadcast: true`, and can be used to fill TAPOS fields given `expireSeconds` and either `blocksBehind` or `useLastIrreversible`. Given no configuration options, transactions are expected to be unpacked with TAPOS fields (`expiration`, `ref_block_num`, `ref_block_prefix`) and will automatically be broadcast onto the chain.
87100

101+
also with `transaction_extensions` parameter can be set txfee-payer or trx-votes
102+
88103
```js
89104
(async () => {
90105
const result = await api.transact({
Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
To vote for a block produder, [submit a transaction](01_how-to-submit-a-transaction.md) to the [`voteproducer`](https://github.com/EOSIO/eosio.contracts/blob/52fbd4ac7e6c38c558302c48d00469a4bed35f7c/contracts/eosio.system/include/eosio.system/eosio.system.hpp#L1130) action of the `eosio` account.
1+
To vote for a block produder, [submit a transaction](01_how-to-submit-a-transaction.md) with `transaction_extensions` parameter
22

3-
In the example shown below `useraaaaaaaa` votes for producers `userbbbbbbbb` and `usercccccccc`.
3+
In the example shown below `useraaaaaaaa` votes for producers `userbbbbbbbb`
44
```javascript
55
(async () => {
66
await api.transact({
7+
transaction_extensions: [
8+
[
9+
11, // trx-vote
10+
encodeName("userbbbbbbbb")
11+
]
12+
],
713
actions: [{
8-
account: 'eosio',
9-
name: 'voteproducer',
14+
account: 'useraaaaaaaa',
15+
name: 'transfer',
1016
authorization: [{
1117
actor: 'useraaaaaaaa',
1218
permission: 'active',
1319
}],
1420
data: {
15-
voter: 'useraaaaaaaa',
16-
proxy: '',
17-
producers: ['userbbbbbbbb', 'usercccccccc']
21+
from: 'useraaaaaaaa',
22+
to: 'eosio',
23+
quantity: '0.0001 DUSD',
24+
memo: "?"
1825
},
1926
}]
2027
}, {
@@ -24,32 +31,4 @@ In the example shown below `useraaaaaaaa` votes for producers `userbbbbbbbb` and
2431
sign: true
2532
});
2633
})();
27-
```
28-
29-
`useraaaaaaaa` can also delegate their vote to a proxy. In the example shown below, `useraaaaaaaa` delegates their vote to the proxy `userbbbbbbbb`.
30-
```javascript
31-
(async () => {
32-
await api.transact({
33-
actions: [{
34-
account: 'eosio',
35-
name: 'voteproducer',
36-
authorization: [{
37-
actor: 'useraaaaaaaa',
38-
permission: 'active',
39-
}],
40-
data: {
41-
voter: 'useraaaaaaaa',
42-
proxy: 'userbbbbbbbb',
43-
producers: []
44-
},
45-
}]
46-
}, {
47-
blocksBehind: 3,
48-
expireSeconds: 30,
49-
broadcast: true,
50-
sign: true
51-
});
52-
})();
53-
```
54-
55-
**Note** that if the `proxy` field is used, the `producers` list must be empty, and vice verse, if the `producers` list is used, the `proxy` field must be an empty string.
34+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
To set a transaction fee payer, [submit a transaction](01_how-to-submit-a-transaction.md) with `transaction_extensions` parameter
2+
3+
In the example shown below `useraaaaaaaa` submit a transaction with setting fee payer `userbbbbbbbb`
4+
5+
```javascript
6+
(async () => {
7+
await api.transact({
8+
transaction_extensions: [
9+
[
10+
10, // txfee-payer
11+
encodeName("userbbbbbbbb")
12+
],
13+
],
14+
actions: [{
15+
account: 'useraaaaaaaa',
16+
name: 'transfer',
17+
authorization: [{
18+
actor: 'useraaaaaaaa',
19+
permission: 'active',
20+
}],
21+
data: {
22+
from: 'useraaaaaaaa',
23+
to: 'eosio',
24+
quantity: '0.0001 DUSD',
25+
memo: "?"
26+
},
27+
}]
28+
}, {
29+
blocksBehind: 3,
30+
expireSeconds: 30,
31+
broadcast: true,
32+
sign: true
33+
});
34+
})();
35+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
To get a specific account's system token balance call `get_system_token_balance` on the rpc object passing in the account name as a function argument.
2+
```javascript
3+
(async () => {
4+
await rpc.get_system_token_balance('alice');
5+
})();
6+
```
7+
8+
The account info is returned as JSON.
9+
```json
10+
{
11+
"total": "487.8550 SYS",
12+
"sys_tokens": [ { "t": "systoken.a", "qty": "487.8550 DUSD" } ]
13+
}
14+
```
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
To get a system token list call `get_system_token_list` on the rpc object passing in the token_meta as a function argument.
2+
```javascript
3+
(async () => {
4+
await rpc.get_system_token_list(true) // should return with metadata of token
5+
await rpc.get_system_token_list(false) // should return without metadata of token
6+
})();
7+
```
8+
9+
The account info is returned as JSON.
10+
```json
11+
// with metadata
12+
{
13+
"count":2,
14+
"tokens":[
15+
{
16+
"id":"systoken.a",
17+
"weight":10000,
18+
"sym":"4,DUSD",
19+
"total_supply":"31700.0000 DUSD",
20+
"url":"http://sysdepo-a.org",
21+
"desc":"system depository a"
22+
},
23+
{
24+
"id":"systoken.b",
25+
"weight":10000,
26+
"sym":"4,DUSDB",
27+
"total_supply":"3000.0000 DUSDB",
28+
"url":"http://sysdepo-b.org",
29+
"desc":"system depository b"
30+
}
31+
]
32+
}
33+
34+
// without metadata
35+
{
36+
"count":2,
37+
"tokens":[
38+
{
39+
"id":"systoken.a",
40+
"weight":10000
41+
},
42+
{
43+
"id":"systoken.b",
44+
"weight":10000
45+
}
46+
]
47+
}
48+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
To get a specific account's token balance call `get_token_balance` on the rpc object passing in the account name and token id as a function argument.
2+
```javascript
3+
(async () => {
4+
await rpc.get_token_balance("systoken.a", "systoken.a");
5+
})();
6+
```
7+
8+
The account info is returned as string.
9+
```text
10+
"487.8550 DUSD"
11+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
To get a specific token's information call `get_token_info` on the rpc object passing in the token id as a function argument.
2+
```javascript
3+
(async () => {
4+
await rpc.get_token_info('systoken.a');
5+
})();
6+
```
7+
8+
The account info is returned as JSON.
9+
```json
10+
{
11+
"token_id":"systoken.a",
12+
"sym":"4,DUSD",
13+
"total_supply":"31700.0000 DUSD",
14+
"url":"http://sysdepo-a.org",
15+
"desc":"system depository a"
16+
}
17+
```
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
To get a top transaction vote receiver list call `get_top_tx_vote_receiver_list` on the rpc object passing in the offset and limit as a function argument.
2+
3+
if call function without arguments return with default value `offset = 0, limit = 30`
4+
5+
```javascript
6+
(async () => {
7+
await rpc.get_top_tx_vote_receiver_list();
8+
})();
9+
```
10+
11+
The account info is returned as JSON.
12+
```json
13+
{
14+
"tx_vote_receiver_list":[
15+
{
16+
"account":"producer.c",
17+
"tx_votes_weighted":"36349.84243691926531028",
18+
"tx_votes":1600
19+
},
20+
{
21+
"account":"producer.g",
22+
"tx_votes_weighted":"10223.39017168970167404",
23+
"tx_votes":450
24+
},
25+
{
26+
"account":"producer.a",
27+
"tx_votes_weighted":"6815.59494994622400554",
28+
"tx_votes":300
29+
},
30+
{
31+
"account":"producer.f",
32+
"tx_votes_weighted":"5679.66100620731231174",
33+
"tx_votes":250
34+
},
35+
{
36+
"account":"producer.e",
37+
"tx_votes_weighted":"2271.86370648571210040",
38+
"tx_votes":100
39+
},
40+
{
41+
"account":"producer.d",
42+
"tx_votes_weighted":"2271.86368144984771789",
43+
"tx_votes":100
44+
},
45+
{
46+
"account":"producer.b",
47+
"tx_votes_weighted":"2271.86368144984771789",
48+
"tx_votes":100
49+
},
50+
{
51+
"account":"producer.j",
52+
"tx_votes_weighted":"1135.93184072492363157",
53+
"tx_votes":50
54+
},
55+
{
56+
"account":"producer.i",
57+
"tx_votes_weighted":"1135.93184072492363157",
58+
"tx_votes":50
59+
},
60+
{
61+
"account":"producer.h",
62+
"tx_votes_weighted":"1135.93184072492363157",
63+
"tx_votes":50
64+
}
65+
],
66+
"total_tx_votes_weighted":"69291.87515632268332411",
67+
"total_tx_votes":3050,
68+
"more":false
69+
}
70+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
To get a specific account's transaction vote stat call `get_tx_vote_stat_for_account` on the rpc object passing in the account name as a function argument.
2+
```javascript
3+
(async () => {
4+
await rpc.get_tx_vote_stat_for_account("producer.a");
5+
})();
6+
```
7+
8+
The account info is returned as JSON.
9+
```json
10+
{
11+
"account":"producer.a",
12+
"tx_votes_weighted":"6815.59494994622400554",
13+
"tx_votes":300
14+
}
15+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
To get a specific action's transaction fee call `get_txfee_item` on the rpc object passing in the code and action as a function argument.
2+
```javascript
3+
(async () => {
4+
await rpc.get_txfee_item("", "");
5+
})();
6+
```
7+
8+
The account info is returned as JSON.
9+
```json
10+
{
11+
"value":1000,
12+
"fee_type":1
13+
}
14+
```

0 commit comments

Comments
 (0)