antelopeql 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/antelopeql.mjs +159 -0
- package/blockchain/deserialize_action_data.mjs +41 -0
- package/blockchain/get_abi.mjs +172 -0
- package/blockchain/get_account.mjs +233 -0
- package/blockchain/get_accounts_by_authorizers.mjs +79 -0
- package/blockchain/get_block.mjs +238 -0
- package/blockchain/get_currency_balance.mjs +48 -0
- package/blockchain/get_currency_stats.mjs +60 -0
- package/blockchain/get_info.mjs +96 -0
- package/blockchain/get_producers.mjs +104 -0
- package/blockchain/get_ram_price.mjs +57 -0
- package/blockchain/get_table_by_scope.mjs +96 -0
- package/blockchain_query_field.mjs +44 -0
- package/build_graphql_fields_from_abis.mjs +122 -0
- package/eosio_abi_to_graphql_ast.mjs +222 -0
- package/eosio_types/asset_type.mjs +35 -0
- package/eosio_types/block_timestamp_type.mjs +14 -0
- package/eosio_types/boolean_type.mjs +10 -0
- package/eosio_types/bytes_type.mjs +17 -0
- package/eosio_types/eosio_key_type.mjs +13 -0
- package/eosio_types/extended_asset_type.mjs +19 -0
- package/eosio_types/generate_checksum_type.mjs +20 -0
- package/eosio_types/generate_float_type.mjs +16 -0
- package/eosio_types/generate_int_type.mjs +28 -0
- package/eosio_types/generate_uint_type.mjs +27 -0
- package/eosio_types/name_type.mjs +29 -0
- package/eosio_types/public_key_type.mjs +26 -0
- package/eosio_types/signature_type.mjs +19 -0
- package/eosio_types/symbol_code_type.mjs +13 -0
- package/eosio_types/symbol_type.mjs +33 -0
- package/eosio_types/time_point_sec_type.mjs +12 -0
- package/eosio_types/time_point_type.mjs +12 -0
- package/eosio_types/varint32_type.mjs +13 -0
- package/eosio_types/varuint32_type.mjs +12 -0
- package/eosio_types.mjs +59 -0
- package/graphql_input_types/actions.mjs +15 -0
- package/graphql_input_types/authorization.mjs +30 -0
- package/graphql_input_types/configuration.mjs +55 -0
- package/graphql_input_types/query_argument_fields.mjs +82 -0
- package/graphql_object_types/authorization.mjs +15 -0
- package/graphql_object_types/authorizing_account_type.mjs +15 -0
- package/graphql_object_types/packed_transaction.mjs +32 -0
- package/graphql_object_types/transaction_receipt.mjs +159 -0
- package/mutation_resolver.mjs +234 -0
- package/package.json +97 -0
- package/push_serialized_transaction.mjs +24 -0
- package/push_transaction.mjs +75 -0
- package/push_transaction_rpc.mjs +37 -0
- package/query_resolver.mjs +43 -0
- package/readme.md +164 -0
- package/serialize_transaction.mjs +23 -0
- package/types.mjs +64 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GraphQLError,
|
|
3
|
+
GraphQLID,
|
|
4
|
+
GraphQLList,
|
|
5
|
+
GraphQLNonNull,
|
|
6
|
+
GraphQLObjectType,
|
|
7
|
+
GraphQLString
|
|
8
|
+
} from "graphql";
|
|
9
|
+
|
|
10
|
+
import bytes_type from "../eosio_types/bytes_type.mjs";
|
|
11
|
+
import authorization_type from "../graphql_object_types/authorization.mjs";
|
|
12
|
+
|
|
13
|
+
const action_type = new GraphQLObjectType({
|
|
14
|
+
name: "action_type",
|
|
15
|
+
fields: () => ({
|
|
16
|
+
account: {
|
|
17
|
+
type: GraphQLString
|
|
18
|
+
},
|
|
19
|
+
name: {
|
|
20
|
+
type: GraphQLString
|
|
21
|
+
},
|
|
22
|
+
authorization: {
|
|
23
|
+
type: new GraphQLList(authorization_type)
|
|
24
|
+
},
|
|
25
|
+
data: {
|
|
26
|
+
type: GraphQLString,
|
|
27
|
+
description: "JSON representation of the transaction data.",
|
|
28
|
+
resolve({ data }) {
|
|
29
|
+
return JSON.stringify(data);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
hex_data: {
|
|
33
|
+
type: bytes_type
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const producer_type = new GraphQLObjectType({
|
|
39
|
+
name: "producer_type",
|
|
40
|
+
fields: () => ({
|
|
41
|
+
producer_name: {
|
|
42
|
+
type: GraphQLString
|
|
43
|
+
},
|
|
44
|
+
block_signing_key: {
|
|
45
|
+
type: GraphQLString,
|
|
46
|
+
description: `Base58 encoded EOSIO public key.`
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const new_producer_type = new GraphQLObjectType({
|
|
52
|
+
name: "new_producer_type",
|
|
53
|
+
fields: () => ({
|
|
54
|
+
version: {
|
|
55
|
+
type: GraphQLString
|
|
56
|
+
},
|
|
57
|
+
producers: {
|
|
58
|
+
type: new GraphQLList(producer_type)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const packed_transaction_type = new GraphQLObjectType({
|
|
64
|
+
name: "packed_transaction_type",
|
|
65
|
+
fields: () => ({
|
|
66
|
+
expiration: {
|
|
67
|
+
type: GraphQLString
|
|
68
|
+
},
|
|
69
|
+
ref_block_num: {
|
|
70
|
+
type: GraphQLString
|
|
71
|
+
},
|
|
72
|
+
ref_block_prefix: {
|
|
73
|
+
type: GraphQLString
|
|
74
|
+
},
|
|
75
|
+
max_net_usage_words: {
|
|
76
|
+
type: GraphQLString
|
|
77
|
+
},
|
|
78
|
+
max_cpu_usage_ms: {
|
|
79
|
+
type: GraphQLString
|
|
80
|
+
},
|
|
81
|
+
delay_sec: {
|
|
82
|
+
type: GraphQLString
|
|
83
|
+
},
|
|
84
|
+
context_free_actions: {
|
|
85
|
+
type: new GraphQLList(action_type)
|
|
86
|
+
},
|
|
87
|
+
actions: {
|
|
88
|
+
type: new GraphQLList(action_type)
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const trx_type = new GraphQLObjectType({
|
|
94
|
+
name: "trx_type",
|
|
95
|
+
fields: () => ({
|
|
96
|
+
id: {
|
|
97
|
+
type: GraphQLID
|
|
98
|
+
},
|
|
99
|
+
signatures: {
|
|
100
|
+
type: new GraphQLList(GraphQLString)
|
|
101
|
+
},
|
|
102
|
+
compression: {
|
|
103
|
+
type: GraphQLString
|
|
104
|
+
},
|
|
105
|
+
packed_context_free_data: {
|
|
106
|
+
type: GraphQLString
|
|
107
|
+
},
|
|
108
|
+
context_free_data: {
|
|
109
|
+
type: new GraphQLList(GraphQLString)
|
|
110
|
+
},
|
|
111
|
+
packed_trx: {
|
|
112
|
+
type: GraphQLString
|
|
113
|
+
},
|
|
114
|
+
transaction: {
|
|
115
|
+
type: packed_transaction_type
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const transactions_type = new GraphQLObjectType({
|
|
121
|
+
name: "transaction_type",
|
|
122
|
+
fields: () => ({
|
|
123
|
+
status: {
|
|
124
|
+
type: GraphQLString,
|
|
125
|
+
description: "List of valid transaction receipts included in block."
|
|
126
|
+
},
|
|
127
|
+
cpu_usage_us: {
|
|
128
|
+
type: GraphQLString
|
|
129
|
+
},
|
|
130
|
+
net_usage_words: {
|
|
131
|
+
type: GraphQLString
|
|
132
|
+
},
|
|
133
|
+
trx: {
|
|
134
|
+
type: trx_type
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const block_type = new GraphQLObjectType({
|
|
140
|
+
name: "block_type",
|
|
141
|
+
description: "",
|
|
142
|
+
fields: () => ({
|
|
143
|
+
timestamp: {
|
|
144
|
+
description: "Date/time string in the format `YYYY-MM-DDTHH:MM:SS.sss`",
|
|
145
|
+
type: GraphQLString
|
|
146
|
+
},
|
|
147
|
+
producer: {
|
|
148
|
+
description: "The `name` of the producer.",
|
|
149
|
+
type: GraphQLString
|
|
150
|
+
},
|
|
151
|
+
confirmed: {
|
|
152
|
+
description:
|
|
153
|
+
"Number of prior blocks confirmed by this block producer in current schedule",
|
|
154
|
+
type: GraphQLString
|
|
155
|
+
},
|
|
156
|
+
previous: {
|
|
157
|
+
description: "The `sha256` hash representing the previous.",
|
|
158
|
+
type: GraphQLString
|
|
159
|
+
},
|
|
160
|
+
transaction_mroot: {
|
|
161
|
+
description: "The transaction merkle root `sha256`.",
|
|
162
|
+
type: GraphQLString
|
|
163
|
+
},
|
|
164
|
+
action_mroot: {
|
|
165
|
+
description: "The action merkle root `sha256` string.",
|
|
166
|
+
type: GraphQLString
|
|
167
|
+
},
|
|
168
|
+
schedule_version: {
|
|
169
|
+
description:
|
|
170
|
+
"Number of times producer schedule has changed since genesis.",
|
|
171
|
+
type: GraphQLString
|
|
172
|
+
},
|
|
173
|
+
new_producers: {
|
|
174
|
+
description: "A list of new producers.",
|
|
175
|
+
type: new_producer_type
|
|
176
|
+
},
|
|
177
|
+
header_extensions: {
|
|
178
|
+
type: new GraphQLList(GraphQLString)
|
|
179
|
+
},
|
|
180
|
+
producer_signature: {
|
|
181
|
+
type: GraphQLString,
|
|
182
|
+
description: `Base58 encoded EOSIO cryptographic signature.`
|
|
183
|
+
},
|
|
184
|
+
transactions: {
|
|
185
|
+
type: new GraphQLList(transactions_type),
|
|
186
|
+
description: "List of valid transaction receipts included in block."
|
|
187
|
+
},
|
|
188
|
+
block_extensions: {
|
|
189
|
+
type: new GraphQLList(GraphQLString)
|
|
190
|
+
},
|
|
191
|
+
id: {
|
|
192
|
+
description: "The ID of the a given block `sha256`.",
|
|
193
|
+
type: GraphQLString
|
|
194
|
+
},
|
|
195
|
+
block_num: {
|
|
196
|
+
description:
|
|
197
|
+
"Height of this block in the chain, no. of blocks since genesis.",
|
|
198
|
+
type: GraphQLString
|
|
199
|
+
},
|
|
200
|
+
ref_block_prefix: {
|
|
201
|
+
description: "32-bit portion of block ID",
|
|
202
|
+
type: GraphQLString
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const get_block = {
|
|
208
|
+
description: "Return info relating to a specific block.",
|
|
209
|
+
type: block_type,
|
|
210
|
+
args: {
|
|
211
|
+
block_num_or_id: {
|
|
212
|
+
description: "The `block number` or a `block id`.",
|
|
213
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
async resolve(
|
|
217
|
+
_,
|
|
218
|
+
{ block_num_or_id },
|
|
219
|
+
{ network: { fetch, rpc_url, ...fetchOptions } }
|
|
220
|
+
) {
|
|
221
|
+
const uri = `${rpc_url}/v1/chain/get_block`;
|
|
222
|
+
const req = await fetch(uri, {
|
|
223
|
+
method: "POST",
|
|
224
|
+
...fetchOptions,
|
|
225
|
+
body: JSON.stringify({
|
|
226
|
+
block_num_or_id,
|
|
227
|
+
json: true
|
|
228
|
+
})
|
|
229
|
+
});
|
|
230
|
+
const data = await req.json();
|
|
231
|
+
|
|
232
|
+
if (data.error) throw new GraphQLError(data.message, { extensions: data });
|
|
233
|
+
|
|
234
|
+
return data;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export default get_block;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GraphQLError,
|
|
3
|
+
GraphQLList,
|
|
4
|
+
GraphQLNonNull,
|
|
5
|
+
GraphQLString
|
|
6
|
+
} from "graphql";
|
|
7
|
+
|
|
8
|
+
import name_type from "../eosio_types/name_type.mjs";
|
|
9
|
+
import symbol_code_type from "../eosio_types/symbol_code_type.mjs";
|
|
10
|
+
|
|
11
|
+
const currency_balance = {
|
|
12
|
+
description: "Retrieve current balance.",
|
|
13
|
+
type: new GraphQLList(GraphQLString),
|
|
14
|
+
args: {
|
|
15
|
+
code: {
|
|
16
|
+
description: "The account name that holds the currency tokens",
|
|
17
|
+
type: name_type,
|
|
18
|
+
defaultValue: "eosio.token"
|
|
19
|
+
},
|
|
20
|
+
account: {
|
|
21
|
+
description: "Account name to query the balance for.",
|
|
22
|
+
type: new GraphQLNonNull(name_type)
|
|
23
|
+
},
|
|
24
|
+
symbol: {
|
|
25
|
+
description: "The crytpo currency token symbol.",
|
|
26
|
+
type: new GraphQLNonNull(symbol_code_type),
|
|
27
|
+
defaultValue: "EOS"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
async resolve(_, args, { network: { fetch, rpc_url, ...fetchOptions } }) {
|
|
31
|
+
const uri = `${rpc_url}/v1/chain/get_currency_balance`;
|
|
32
|
+
const req = await fetch(uri, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
...fetchOptions,
|
|
35
|
+
body: JSON.stringify({
|
|
36
|
+
...args,
|
|
37
|
+
json: true
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
const data = await req.json();
|
|
41
|
+
|
|
42
|
+
if (data.error) throw new GraphQLError(data.message, { extensions: data });
|
|
43
|
+
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default currency_balance;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GraphQLError,
|
|
3
|
+
GraphQLNonNull,
|
|
4
|
+
GraphQLObjectType,
|
|
5
|
+
GraphQLString
|
|
6
|
+
} from "graphql";
|
|
7
|
+
|
|
8
|
+
import name_type from "../eosio_types/name_type.mjs";
|
|
9
|
+
import symbol_code_type from "../eosio_types/symbol_code_type.mjs";
|
|
10
|
+
|
|
11
|
+
const currency_stats_type = new GraphQLObjectType({
|
|
12
|
+
name: "currency_stats_type",
|
|
13
|
+
fields: () => ({
|
|
14
|
+
supply: {
|
|
15
|
+
type: GraphQLString
|
|
16
|
+
},
|
|
17
|
+
max_supply: {
|
|
18
|
+
type: GraphQLString
|
|
19
|
+
},
|
|
20
|
+
issuer: {
|
|
21
|
+
type: name_type
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const get_currency_stats = {
|
|
27
|
+
description: "Retrieve currency stats.",
|
|
28
|
+
type: currency_stats_type,
|
|
29
|
+
args: {
|
|
30
|
+
code: {
|
|
31
|
+
type: new GraphQLNonNull(name_type)
|
|
32
|
+
},
|
|
33
|
+
symbol: {
|
|
34
|
+
type: new GraphQLNonNull(symbol_code_type)
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
async resolve(
|
|
38
|
+
_,
|
|
39
|
+
{ symbol, ...args },
|
|
40
|
+
{ network: { fetch, rpc_url, ...fetchOptions } }
|
|
41
|
+
) {
|
|
42
|
+
const uri = `${rpc_url}/v1/chain/get_currency_stats`;
|
|
43
|
+
const req = await fetch(uri, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
...fetchOptions,
|
|
46
|
+
body: JSON.stringify({
|
|
47
|
+
symbol,
|
|
48
|
+
json: true,
|
|
49
|
+
...args
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
const data = await req.json();
|
|
53
|
+
|
|
54
|
+
if (data.error) throw new GraphQLError(data.message, { extensions: data });
|
|
55
|
+
|
|
56
|
+
return data[symbol];
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default get_currency_stats;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { GraphQLError, GraphQLObjectType, GraphQLString } from "graphql";
|
|
2
|
+
|
|
3
|
+
const info_type = new GraphQLObjectType({
|
|
4
|
+
name: "info_type",
|
|
5
|
+
description: "Returns various details about the EOS blockchain",
|
|
6
|
+
fields: () => ({
|
|
7
|
+
server_version: {
|
|
8
|
+
type: GraphQLString,
|
|
9
|
+
description: "Hash representing the last commit in the tagged release"
|
|
10
|
+
},
|
|
11
|
+
chain_id: {
|
|
12
|
+
type: GraphQLString,
|
|
13
|
+
description: "Hash representing the ID of the chain"
|
|
14
|
+
},
|
|
15
|
+
head_block_num: {
|
|
16
|
+
type: GraphQLString,
|
|
17
|
+
description: "Highest block number on the chain"
|
|
18
|
+
},
|
|
19
|
+
head_block_id: {
|
|
20
|
+
type: GraphQLString,
|
|
21
|
+
description: "Highest block ID on the chain"
|
|
22
|
+
},
|
|
23
|
+
head_block_time: {
|
|
24
|
+
type: GraphQLString,
|
|
25
|
+
description: "Highest block unix timestamp"
|
|
26
|
+
},
|
|
27
|
+
head_block_producer: {
|
|
28
|
+
type: GraphQLString,
|
|
29
|
+
description: "Producer that signed the highest block (head block)"
|
|
30
|
+
},
|
|
31
|
+
last_irreversible_block_num: {
|
|
32
|
+
type: GraphQLString,
|
|
33
|
+
description:
|
|
34
|
+
"Highest block number on the chain that has been irreversibly applied to state"
|
|
35
|
+
},
|
|
36
|
+
last_irreversible_block_id: {
|
|
37
|
+
type: GraphQLString,
|
|
38
|
+
description:
|
|
39
|
+
"Highest block ID on the chain that has been irreversibly applied to state"
|
|
40
|
+
},
|
|
41
|
+
virtual_block_cpu_limit: {
|
|
42
|
+
type: GraphQLString,
|
|
43
|
+
description:
|
|
44
|
+
"CPU limit calculated after each block is produced, approximately 1000 times block_cpu_limit"
|
|
45
|
+
},
|
|
46
|
+
virtual_block_net_limit: {
|
|
47
|
+
type: GraphQLString,
|
|
48
|
+
description:
|
|
49
|
+
"NET limit calculated after each block is produced, approximately 1000 times block_net_limit"
|
|
50
|
+
},
|
|
51
|
+
block_cpu_limit: {
|
|
52
|
+
type: GraphQLString,
|
|
53
|
+
description: "Actual maximum CPU limit"
|
|
54
|
+
},
|
|
55
|
+
block_net_limit: {
|
|
56
|
+
type: GraphQLString,
|
|
57
|
+
description: "Actual maximum NET limit"
|
|
58
|
+
},
|
|
59
|
+
server_version_string: {
|
|
60
|
+
type: GraphQLString,
|
|
61
|
+
description:
|
|
62
|
+
"String representation of server version - Majorish-Minorish-Patchy - Warning - Not actually SEMVER!"
|
|
63
|
+
},
|
|
64
|
+
fork_db_head_block_num: {
|
|
65
|
+
type: GraphQLString,
|
|
66
|
+
description:
|
|
67
|
+
"Sequential block number representing the best known head in the fork database tree"
|
|
68
|
+
},
|
|
69
|
+
fork_db_head_block_id: {
|
|
70
|
+
type: GraphQLString,
|
|
71
|
+
description:
|
|
72
|
+
"Sequential block number representing the best known head in the fork database tree"
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const info = {
|
|
78
|
+
description: "Return info about the operational state of the blockchain.",
|
|
79
|
+
type: info_type,
|
|
80
|
+
args: {},
|
|
81
|
+
async resolve(_, __, { network: { fetch, rpc_url, ...fetchOptions } }) {
|
|
82
|
+
const uri = `${rpc_url}/v1/chain/get_info`;
|
|
83
|
+
const req = await fetch(uri, {
|
|
84
|
+
method: "POST",
|
|
85
|
+
...fetchOptions
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const data = await req.json();
|
|
89
|
+
|
|
90
|
+
if (data.error) throw new GraphQLError(data.message, { extensions: data });
|
|
91
|
+
|
|
92
|
+
return data;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default info;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GraphQLError,
|
|
3
|
+
GraphQLInt,
|
|
4
|
+
GraphQLList,
|
|
5
|
+
GraphQLObjectType,
|
|
6
|
+
GraphQLString
|
|
7
|
+
} from "graphql";
|
|
8
|
+
|
|
9
|
+
import EOSIO_key_type from "../eosio_types/eosio_key_type.mjs";
|
|
10
|
+
import public_key_type from "../eosio_types/public_key_type.mjs";
|
|
11
|
+
|
|
12
|
+
const producers = new GraphQLObjectType({
|
|
13
|
+
name: "blockchain_block_producers",
|
|
14
|
+
fields: {
|
|
15
|
+
owner: {
|
|
16
|
+
type: GraphQLString
|
|
17
|
+
},
|
|
18
|
+
total_votes: {
|
|
19
|
+
type: GraphQLString
|
|
20
|
+
},
|
|
21
|
+
producer_key: {
|
|
22
|
+
type: public_key_type
|
|
23
|
+
},
|
|
24
|
+
is_active: {
|
|
25
|
+
type: GraphQLString
|
|
26
|
+
},
|
|
27
|
+
url: {
|
|
28
|
+
type: GraphQLString
|
|
29
|
+
},
|
|
30
|
+
unpaid_blocks: {
|
|
31
|
+
type: GraphQLString
|
|
32
|
+
},
|
|
33
|
+
last_claim_time: {
|
|
34
|
+
type: GraphQLString
|
|
35
|
+
},
|
|
36
|
+
location: {
|
|
37
|
+
type: GraphQLString
|
|
38
|
+
},
|
|
39
|
+
producer_authority: {
|
|
40
|
+
type: new GraphQLObjectType({
|
|
41
|
+
name: "block_producer_authority",
|
|
42
|
+
fields: {
|
|
43
|
+
threshold: {
|
|
44
|
+
type: GraphQLInt
|
|
45
|
+
},
|
|
46
|
+
keys: {
|
|
47
|
+
type: new GraphQLList(EOSIO_key_type)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}),
|
|
51
|
+
resolve(data) {
|
|
52
|
+
return data.producer_authority[1];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const get_producers = {
|
|
59
|
+
description: "Return info about block producers.",
|
|
60
|
+
type: new GraphQLObjectType({
|
|
61
|
+
name: "blockchain_producers",
|
|
62
|
+
fields: {
|
|
63
|
+
total_producer_vote_weight: {
|
|
64
|
+
type: GraphQLString
|
|
65
|
+
},
|
|
66
|
+
more: {
|
|
67
|
+
type: GraphQLString,
|
|
68
|
+
description: "the next block producer in the list"
|
|
69
|
+
},
|
|
70
|
+
rows: {
|
|
71
|
+
type: new GraphQLList(producers)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
args: {
|
|
76
|
+
limit: {
|
|
77
|
+
description: "total number of producers to retrieve",
|
|
78
|
+
type: GraphQLString,
|
|
79
|
+
defaultValue: "10"
|
|
80
|
+
},
|
|
81
|
+
lower_bound: {
|
|
82
|
+
description:
|
|
83
|
+
"In conjunction with limit can be used to paginate through the results. For example, limit=10 and lower_bound=10 would be page 2.",
|
|
84
|
+
type: GraphQLString
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
async resolve(_, args, { network: { fetch, rpc_url, ...fetchOptions } }) {
|
|
88
|
+
const uri = `${rpc_url}/v1/chain/get_producers`;
|
|
89
|
+
|
|
90
|
+
const req = await fetch(uri, {
|
|
91
|
+
method: "POST",
|
|
92
|
+
body: JSON.stringify({ ...args, json: true }),
|
|
93
|
+
...fetchOptions
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const data = await req.json();
|
|
97
|
+
|
|
98
|
+
if (data.error) throw new GraphQLError(data.message, { extensions: data });
|
|
99
|
+
|
|
100
|
+
return data;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export default get_producers;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { GraphQLError, GraphQLObjectType, GraphQLString } from "graphql";
|
|
2
|
+
|
|
3
|
+
const RAM_quote_type = new GraphQLObjectType({
|
|
4
|
+
name: "blockchain_ram_price",
|
|
5
|
+
fields: () => ({
|
|
6
|
+
quote: {
|
|
7
|
+
type: GraphQLString,
|
|
8
|
+
resolve: (EOS) => EOS
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const get_ram_price = {
|
|
14
|
+
description: "RAM quote (bytes)",
|
|
15
|
+
type: RAM_quote_type,
|
|
16
|
+
args: {
|
|
17
|
+
quantity: {
|
|
18
|
+
type: GraphQLString,
|
|
19
|
+
description: "Number of bytes of RAM."
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
async resolve(
|
|
23
|
+
_,
|
|
24
|
+
{ quantity },
|
|
25
|
+
{ network: { fetch, rpc_url, ...fetchOptions } }
|
|
26
|
+
) {
|
|
27
|
+
const data = await fetch(rpc_url + "/v1/chain/get_table_rows", {
|
|
28
|
+
method: "POST",
|
|
29
|
+
...fetchOptions,
|
|
30
|
+
body: JSON.stringify({
|
|
31
|
+
code: "eosio",
|
|
32
|
+
json: true,
|
|
33
|
+
table: "rammarket",
|
|
34
|
+
scope: "eosio",
|
|
35
|
+
index_position: 1,
|
|
36
|
+
key_type: "i128",
|
|
37
|
+
lower_bound: "",
|
|
38
|
+
upper_bound: ""
|
|
39
|
+
})
|
|
40
|
+
}).then((req) => req.json());
|
|
41
|
+
|
|
42
|
+
if (data.error) throw new GraphQLError(data.message, { extensions: data });
|
|
43
|
+
|
|
44
|
+
if (data.rows) {
|
|
45
|
+
// Connector Balance / (Smart Token’s Outstanding supply × Connector Weight)
|
|
46
|
+
const [RAM] = data.rows;
|
|
47
|
+
const CORE_TOKEN = RAM.quote.balance.match(/[\sA-Z]+/gmu);
|
|
48
|
+
|
|
49
|
+
const supply = RAM.base.balance.replace(" RAM", "");
|
|
50
|
+
const total_value = RAM.quote.balance.replace(CORE_TOKEN, "");
|
|
51
|
+
const byte_price = quantity * (total_value / supply);
|
|
52
|
+
return byte_price + CORE_TOKEN;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default get_ram_price;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GraphQLError,
|
|
3
|
+
GraphQLInt,
|
|
4
|
+
GraphQLList,
|
|
5
|
+
GraphQLNonNull,
|
|
6
|
+
GraphQLObjectType,
|
|
7
|
+
GraphQLString
|
|
8
|
+
} from "graphql";
|
|
9
|
+
|
|
10
|
+
import name_type from "../eosio_types/name_type.mjs";
|
|
11
|
+
|
|
12
|
+
const table_type = new GraphQLObjectType({
|
|
13
|
+
name: "table_type",
|
|
14
|
+
fields: {
|
|
15
|
+
rows: {
|
|
16
|
+
type: new GraphQLList(
|
|
17
|
+
new GraphQLObjectType({
|
|
18
|
+
name: "table_rows_type",
|
|
19
|
+
fields: {
|
|
20
|
+
scope: { type: name_type },
|
|
21
|
+
table_name: { type: name_type, resolve: ({ table }) => table },
|
|
22
|
+
ram_payer: {
|
|
23
|
+
type: name_type,
|
|
24
|
+
description: "The account that pays for the data entries.",
|
|
25
|
+
resolve: ({ payer }) => payer
|
|
26
|
+
},
|
|
27
|
+
count: {
|
|
28
|
+
type: name_type,
|
|
29
|
+
description: "No. of entries in the table."
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
)
|
|
34
|
+
},
|
|
35
|
+
more: {
|
|
36
|
+
type: name_type
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const get_table = {
|
|
42
|
+
description: "Retrieve a table from the blockchain.",
|
|
43
|
+
type: table_type,
|
|
44
|
+
args: {
|
|
45
|
+
account_name: {
|
|
46
|
+
description: "The account name of the `smart contract`.",
|
|
47
|
+
type: new GraphQLNonNull(name_type)
|
|
48
|
+
},
|
|
49
|
+
table_name: {
|
|
50
|
+
description: "The table name on the smart contract.",
|
|
51
|
+
type: name_type
|
|
52
|
+
},
|
|
53
|
+
limit: {
|
|
54
|
+
description:
|
|
55
|
+
"Limit number of results returned (how many items to return).",
|
|
56
|
+
type: GraphQLInt,
|
|
57
|
+
defaultValue: 10
|
|
58
|
+
},
|
|
59
|
+
lower_bound: {
|
|
60
|
+
description:
|
|
61
|
+
"Filters results to return the first element that is not less than provided value in the table.",
|
|
62
|
+
type: GraphQLString
|
|
63
|
+
},
|
|
64
|
+
upper_bound: {
|
|
65
|
+
description:
|
|
66
|
+
"Filters results to return the first element that is greater than provided value in the table.",
|
|
67
|
+
type: GraphQLString
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
async resolve(
|
|
71
|
+
_,
|
|
72
|
+
{ account_name, table_name, limit, lower_bound, upper_bound },
|
|
73
|
+
{ network: { fetch, rpc_url, ...fetchOptions } }
|
|
74
|
+
) {
|
|
75
|
+
const uri = `${rpc_url}/v1/chain/get_table_by_scope`;
|
|
76
|
+
const data = await fetch(uri, {
|
|
77
|
+
method: "POST",
|
|
78
|
+
...fetchOptions,
|
|
79
|
+
body: JSON.stringify({
|
|
80
|
+
code: account_name,
|
|
81
|
+
table: table_name,
|
|
82
|
+
limit,
|
|
83
|
+
lower_bound,
|
|
84
|
+
upper_bound,
|
|
85
|
+
json: true,
|
|
86
|
+
show_payer: true
|
|
87
|
+
})
|
|
88
|
+
}).then((req) => req.json());
|
|
89
|
+
|
|
90
|
+
if (data.error) throw new GraphQLError(data.message, { extensions: data });
|
|
91
|
+
|
|
92
|
+
return data;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default get_table;
|