antelopeql 2.0.0-rc.1 → 2.0.0-rc.4
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/antelopeql.mjs +6 -29
- package/blockchain/get_required_keys.mjs +75 -11
- package/blockchain_query_field.mjs +7 -8
- package/build_graphql_fields_from_abis.mjs +3 -3
- package/eosio_abi_to_graphql_ast.mjs +8 -6
- package/graphql_object_types/packed_transaction.mjs +2 -2
- package/package.json +17 -20
- package/readme.md +35 -61
- package/{push_serialized_transaction.mjs → send_serialized_transaction.mjs} +5 -5
- package/{push_transaction.mjs → send_transaction.mjs} +4 -4
- package/{push_transaction_rpc.mjs → send_transaction_rpc.mjs} +3 -3
package/antelopeql.mjs
CHANGED
|
@@ -12,8 +12,8 @@ import blockchain_query_field from "./blockchain_query_field.mjs";
|
|
|
12
12
|
import build_graphql_fields_from_abis from "./build_graphql_fields_from_abis.mjs";
|
|
13
13
|
import get_abis from "./get_abis.mjs";
|
|
14
14
|
import actions from "./graphql_input_types/actions.mjs";
|
|
15
|
-
import
|
|
16
|
-
import
|
|
15
|
+
import send_serialized_transaction from "./send_serialized_transaction.mjs";
|
|
16
|
+
import send_transaction from "./send_transaction.mjs";
|
|
17
17
|
import serialize_transaction from "./serialize_transaction.mjs";
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -22,7 +22,6 @@ import serialize_transaction from "./serialize_transaction.mjs";
|
|
|
22
22
|
* @property {String} rpc_url Chain remote proceedure call (RPC) Uniform Resource Locator (URL).
|
|
23
23
|
* @property {*} [variableValues] GraphQL variables.
|
|
24
24
|
* @property {String} [operationName] GraphQL operation name (query resolution).
|
|
25
|
-
* @property {Function} [fetch] Custom fetch implementation.
|
|
26
25
|
* @property {Array<String>} [contracts] List of Antelope smart contracts.
|
|
27
26
|
* @property {async Function} [signTransaction] A function to sign the Antelope transaction.
|
|
28
27
|
* @property {Headers} [headers] Headers to pass to the network request.
|
|
@@ -39,30 +38,12 @@ import serialize_transaction from "./serialize_transaction.mjs";
|
|
|
39
38
|
* AntelopeQL for interacting with Antelope based blockchains.
|
|
40
39
|
* @param {AntelopeQLArgument} Argument
|
|
41
40
|
* @returns {AntelopeQLResult}
|
|
42
|
-
* @example
|
|
43
|
-
* ```js
|
|
44
|
-
* import AntelopeQL from 'antelopeql/antelopeql.mjs'
|
|
45
|
-
* import fetch from 'node-fetch'
|
|
46
|
-
*
|
|
47
|
-
* const query = `{ eosio_token { accounts(arg: { scope: "relockeblock" }){ balance } } }`
|
|
48
|
-
*
|
|
49
|
-
* AntelopeQL({
|
|
50
|
-
* query,
|
|
51
|
-
* contracts: ["eosio.token"],
|
|
52
|
-
* fetch,
|
|
53
|
-
* rpc_url: "https://eos.relocke.io",
|
|
54
|
-
* headers: { "content-type": "application/json" }
|
|
55
|
-
* }).then(console.log);
|
|
56
|
-
* ```
|
|
57
|
-
* > Logged output was "data": {"eosio_token": {"accounts": [{"balance": "100.0211 EOS"}]}}}
|
|
58
41
|
*/
|
|
59
|
-
|
|
60
42
|
export default async function AntelopeQL({
|
|
61
43
|
query,
|
|
62
44
|
variableValues,
|
|
63
45
|
operationName,
|
|
64
46
|
signTransaction,
|
|
65
|
-
fetch,
|
|
66
47
|
contracts = [],
|
|
67
48
|
ABIs = [],
|
|
68
49
|
rpc_url,
|
|
@@ -70,9 +51,7 @@ export default async function AntelopeQL({
|
|
|
70
51
|
signal
|
|
71
52
|
}) {
|
|
72
53
|
try {
|
|
73
|
-
if (!fetch
|
|
74
|
-
if (!fetch && typeof window == "undefined")
|
|
75
|
-
throw new GraphQLError("No fetch implementation provided");
|
|
54
|
+
if (!fetch) throw new GraphQLError("No fetch implementation provided");
|
|
76
55
|
|
|
77
56
|
const fetchOptions = {};
|
|
78
57
|
if (headers) fetchOptions.headers = headers;
|
|
@@ -96,19 +75,17 @@ export default async function AntelopeQL({
|
|
|
96
75
|
const action_fields = actions(mutation_fields);
|
|
97
76
|
mutations = new GraphQLObjectType({
|
|
98
77
|
name: "Mutation",
|
|
99
|
-
description: "Push transactions to the blockchain.",
|
|
100
78
|
fields: {
|
|
101
|
-
|
|
79
|
+
send_transaction: send_transaction(action_fields, ast_list),
|
|
102
80
|
serialize_transaction: serialize_transaction(action_fields, ast_list),
|
|
103
|
-
|
|
81
|
+
send_serialized_transaction
|
|
104
82
|
}
|
|
105
83
|
});
|
|
106
84
|
} else
|
|
107
85
|
mutations = new GraphQLObjectType({
|
|
108
86
|
name: "Mutation",
|
|
109
|
-
description: "Push transactions to the blockchain.",
|
|
110
87
|
fields: {
|
|
111
|
-
|
|
88
|
+
send_serialized_transaction
|
|
112
89
|
}
|
|
113
90
|
});
|
|
114
91
|
|
|
@@ -1,11 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { GraphQLInputObjectType, GraphQLList, GraphQLString } from "graphql";
|
|
2
|
+
|
|
3
|
+
import bytes_type from "../eosio_types/bytes_type.mjs";
|
|
4
|
+
import name_type from "../eosio_types/name_type.mjs";
|
|
5
|
+
import public_key_type from "../eosio_types/public_key_type.mjs";
|
|
6
|
+
import authorization_type from "../graphql_input_types/authorization.mjs";
|
|
7
|
+
|
|
8
|
+
const action_type = new GraphQLInputObjectType({
|
|
9
|
+
name: "required_keys_action",
|
|
10
|
+
fields: {
|
|
11
|
+
account: {
|
|
12
|
+
type: name_type,
|
|
13
|
+
description: "The smart contract name"
|
|
14
|
+
},
|
|
15
|
+
name: { type: name_type },
|
|
16
|
+
authorization: { type: new GraphQLList(authorization_type) },
|
|
17
|
+
data: { type: GraphQLString },
|
|
18
|
+
hex_data: { type: bytes_type }
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const transaction_type = new GraphQLInputObjectType({
|
|
23
|
+
name: "required_keys_transaction",
|
|
24
|
+
fields: {
|
|
25
|
+
expiration: { type: GraphQLString },
|
|
26
|
+
ref_block_num: { type: GraphQLString },
|
|
27
|
+
ref_block_prefix: { type: GraphQLString },
|
|
28
|
+
max_net_usage_words: { type: GraphQLString },
|
|
29
|
+
max_cpu_usage_ms: { type: GraphQLString },
|
|
30
|
+
actions: { type: new GraphQLList(action_type) },
|
|
31
|
+
context_free_actions: { type: GraphQLString }
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const get_required_keys = {
|
|
36
|
+
description: "Retrieve a table from the blockchain.",
|
|
37
|
+
type: new GraphQLList(public_key_type),
|
|
38
|
+
args: {
|
|
39
|
+
transaction: {
|
|
40
|
+
type: transaction_type
|
|
41
|
+
},
|
|
42
|
+
available_keys: {
|
|
43
|
+
type: new GraphQLList(public_key_type)
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
async resolve(
|
|
47
|
+
_,
|
|
48
|
+
{ available_keys, transaction },
|
|
49
|
+
{ network: { fetch, rpc_url } }
|
|
50
|
+
) {
|
|
51
|
+
const uri = `${rpc_url}/v1/chain/get_required_keys`;
|
|
52
|
+
|
|
53
|
+
const { actions, ...txn } = transaction;
|
|
54
|
+
|
|
55
|
+
const data = await fetch(uri, {
|
|
56
|
+
method: "POST",
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
available_keys: await Promise.all(available_keys),
|
|
59
|
+
transaction: {
|
|
60
|
+
...txn,
|
|
61
|
+
actions: actions.map(({ data, ...object }) => ({
|
|
62
|
+
...object,
|
|
63
|
+
...(data ? { data: JSON.parse(data) } : {})
|
|
64
|
+
}))
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const { required_keys } = await data.json();
|
|
70
|
+
|
|
71
|
+
return required_keys;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default get_required_keys;
|
|
@@ -10,6 +10,7 @@ import get_currency_stats from "./blockchain/get_currency_stats.mjs";
|
|
|
10
10
|
import get_info from "./blockchain/get_info.mjs";
|
|
11
11
|
import get_producers from "./blockchain/get_producers.mjs";
|
|
12
12
|
import get_ram_price from "./blockchain/get_ram_price.mjs";
|
|
13
|
+
import get_required_keys from "./blockchain/get_required_keys.mjs";
|
|
13
14
|
import get_smart_contract from "./blockchain/get_smart_contract.mjs";
|
|
14
15
|
import get_table from "./blockchain/get_table_by_scope.mjs";
|
|
15
16
|
|
|
@@ -22,23 +23,21 @@ const blockchain_query_field = {
|
|
|
22
23
|
get_abi,
|
|
23
24
|
get_accounts_by_authorizers,
|
|
24
25
|
get_block,
|
|
25
|
-
get_smart_contract,
|
|
26
26
|
get_currency_balance,
|
|
27
27
|
get_currency_stats,
|
|
28
|
+
get_required_keys,
|
|
29
|
+
get_smart_contract,
|
|
28
30
|
get_info,
|
|
29
31
|
get_producers,
|
|
30
|
-
deserialize_action_data,
|
|
31
32
|
get_table,
|
|
32
|
-
get_ram_price
|
|
33
|
+
get_ram_price,
|
|
34
|
+
deserialize_action_data
|
|
33
35
|
}
|
|
34
36
|
}),
|
|
35
|
-
resolve(_, __, { network: {
|
|
36
|
-
if (!fetch)
|
|
37
|
-
throw new GraphQLError(
|
|
38
|
-
"Fetch was not supplied to the `antelopeql_context`."
|
|
39
|
-
);
|
|
37
|
+
resolve(_, __, { network: { rpc_url } }) {
|
|
40
38
|
if (!rpc_url)
|
|
41
39
|
throw new GraphQLError("No RPC url supplied to `antelopeql_context`");
|
|
40
|
+
|
|
42
41
|
return {};
|
|
43
42
|
}
|
|
44
43
|
};
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
* ```js
|
|
27
27
|
* import actions_type from 'antelopeql/graphql_input_types/actions.js'
|
|
28
28
|
* import serialize_transaction from 'antelopeql/graphql_input_types/actions.js'
|
|
29
|
-
* import
|
|
29
|
+
* import send_transaction from 'antelopeql/send_transaction.js'
|
|
30
30
|
*
|
|
31
31
|
* const network = { fetch, rpc_url: 'https://eos.relocke.io', headers: {}, signal }
|
|
32
32
|
* const ABI_list = [{ account_name: 'eosio.token', abi: … }]
|
|
@@ -45,9 +45,9 @@ import {
|
|
|
45
45
|
* const mutations = new GraphQLObjectType({
|
|
46
46
|
* name: 'Mutation',
|
|
47
47
|
* fields: {
|
|
48
|
-
*
|
|
48
|
+
* send_transaction: send_transaction(action_fields, ast_list),
|
|
49
49
|
* serialize_transaction: serialize_transaction(action_fields, ast_list),
|
|
50
|
-
*
|
|
50
|
+
* send_serialized_transaction
|
|
51
51
|
* }
|
|
52
52
|
* })
|
|
53
53
|
*
|
|
@@ -69,15 +69,17 @@ export function eosio_abi_to_graphql_ast(abi) {
|
|
|
69
69
|
const { types, variants } = abi;
|
|
70
70
|
|
|
71
71
|
let structs = [
|
|
72
|
-
...variants
|
|
73
|
-
name,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
...(variants?.length
|
|
73
|
+
? variants.map(({ name, types }) => ({
|
|
74
|
+
name,
|
|
75
|
+
base: "",
|
|
76
|
+
fields: types.map((item) => ({ name: item, type: item + "$@" })) // @ indiacted a variant type and binary extention.
|
|
77
|
+
}))
|
|
78
|
+
: []),
|
|
77
79
|
...abi.structs
|
|
78
80
|
];
|
|
79
81
|
|
|
80
|
-
if (types
|
|
82
|
+
if (types?.length)
|
|
81
83
|
for (const { type: real_type, new_type_name } of types)
|
|
82
84
|
structs = structs.map(({ fields, ...struct }) => ({
|
|
83
85
|
...struct,
|
|
@@ -16,11 +16,11 @@ const packed_transaction_type = new GraphQLObjectType({
|
|
|
16
16
|
fields: {
|
|
17
17
|
chain_id: {
|
|
18
18
|
type: GraphQLString,
|
|
19
|
-
description: "A unique ID that
|
|
19
|
+
description: "A unique ID that specifies which chain we are operating on."
|
|
20
20
|
},
|
|
21
21
|
transaction_header: {
|
|
22
22
|
type: GraphQLString,
|
|
23
|
-
description: "Serialized transaction header
|
|
23
|
+
description: "Serialized transaction header."
|
|
24
24
|
},
|
|
25
25
|
transaction_body: {
|
|
26
26
|
type: GraphQLString,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antelopeql",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.4",
|
|
4
4
|
"description": "A GraphQL implementation for interacting with Antelope based blockchains.",
|
|
5
5
|
"repository": "github:pur3miish/antelopeql",
|
|
6
6
|
"bugs": "https://github.com/pur3miish/antelopeql/issues",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"eslint": "eslint .",
|
|
12
12
|
"prettier": "prettier -c .",
|
|
13
13
|
"prettier:readme": "prettier --write readme.md",
|
|
14
|
+
"server": "nodemon test/server.mjs",
|
|
14
15
|
"types": "tsc -p jsconfig.json",
|
|
15
16
|
"snapshot": "SAVE_SNAPSHOTS=1 coverage-node test/index.test.mjs",
|
|
16
17
|
"coverage": "coverage-node test/index.test.mjs",
|
|
@@ -19,26 +20,26 @@
|
|
|
19
20
|
"prepublishOnly": "npm test"
|
|
20
21
|
},
|
|
21
22
|
"engines": {
|
|
22
|
-
"node": "
|
|
23
|
+
"node": ">= 18.0.0"
|
|
23
24
|
},
|
|
24
25
|
"files": [
|
|
25
26
|
"blockchain/*.mjs",
|
|
26
27
|
"eosio_types/*.mjs",
|
|
27
28
|
"graphql_input_types/*.mjs",
|
|
28
29
|
"graphql_object_types/*.mjs",
|
|
30
|
+
"antelopeql.mjs",
|
|
29
31
|
"blockchain_query_field.mjs",
|
|
30
32
|
"build_graphql_fields_from_abis.mjs",
|
|
31
33
|
"eosio_abi_to_graphql_ast.mjs",
|
|
32
34
|
"eosio_types.mjs",
|
|
35
|
+
"get_abis.mjs",
|
|
33
36
|
"mutation_resolver.mjs",
|
|
34
|
-
"push_serialized_transaction.mjs",
|
|
35
|
-
"push_transaction_rpc.mjs",
|
|
36
|
-
"push_transaction.mjs",
|
|
37
37
|
"query_resolver.mjs",
|
|
38
|
+
"send_serialized_transaction.mjs",
|
|
39
|
+
"send_transaction_rpc.mjs",
|
|
40
|
+
"send_transaction.mjs",
|
|
38
41
|
"serialize_transaction.mjs",
|
|
39
|
-
"
|
|
40
|
-
"types.mjs",
|
|
41
|
-
"get_abis.mjs"
|
|
42
|
+
"types.mjs"
|
|
42
43
|
],
|
|
43
44
|
"sideEffects": false,
|
|
44
45
|
"exports": {
|
|
@@ -46,19 +47,19 @@
|
|
|
46
47
|
"./eosio_types/*.mjs": "./eosio_types/*.mjs",
|
|
47
48
|
"./graphql_input_types/*.mjs": "./graphql_input_types/*.mjs",
|
|
48
49
|
"./graphql_object_types/*.mjs": "./graphql_object_types/*.mjs",
|
|
50
|
+
"./antelopeql.mjs": "./antelopeql.mjs",
|
|
49
51
|
"./blockchain_query_field.mjs": "./blockchain_query_field.mjs",
|
|
50
52
|
"./build_graphql_fields_from_abis.mjs": "./build_graphql_fields_from_abis.mjs",
|
|
51
53
|
"./eosio_abi_to_graphql_ast.mjs": "./eosio_abi_to_graphql_ast.mjs",
|
|
52
54
|
"./eosio_types.mjs": "./eosio_types.mjs",
|
|
55
|
+
"./get_abis.mjs": "./get_abis.mjs",
|
|
53
56
|
"./mutation_resolver.mjs": "./mutation_resolver.mjs",
|
|
54
|
-
"./push_serialized_transaction.mjs": "./push_serialized_transaction.mjs",
|
|
55
|
-
"./push_transaction_rpc.mjs": "./push_transaction_rpc.mjs",
|
|
56
|
-
"./push_transaction.mjs": "./push_transaction.mjs",
|
|
57
57
|
"./query_resolver.mjs": "./query_resolver.mjs",
|
|
58
|
+
"./send_serialized_transaction.mjs": "./send_serialized_transaction.mjs",
|
|
59
|
+
"./send_transaction_rpc.mjs": "./send_transaction_rpc.mjs",
|
|
60
|
+
"./send_transaction.mjs": "./send_transaction.mjs",
|
|
58
61
|
"./serialize_transaction.mjs": "./serialize_transaction.mjs",
|
|
59
|
-
"./
|
|
60
|
-
"./types.mjs": "./types.mjs",
|
|
61
|
-
"./get_abis.mjs": "./get_abis.mjs"
|
|
62
|
+
"./types.mjs": "./types.mjs"
|
|
62
63
|
},
|
|
63
64
|
"browserslist": [
|
|
64
65
|
"> 0.5%, not OperaMini all, not IE > 0, not dead"
|
|
@@ -79,17 +80,13 @@
|
|
|
79
80
|
"coverage-node": "^8.0.0",
|
|
80
81
|
"eslint": "^8.34.0",
|
|
81
82
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
82
|
-
"graphql": "^16.
|
|
83
|
-
"
|
|
84
|
-
"nodemon": "^2.0.20",
|
|
83
|
+
"graphql": "^16.8.0",
|
|
84
|
+
"nodemon": "^3.0.1",
|
|
85
85
|
"prettier": "^2.8.4",
|
|
86
86
|
"snapshot-assertion": "^5.0.0",
|
|
87
87
|
"test-director": "^10.0.0",
|
|
88
88
|
"typescript": "^4.9.5"
|
|
89
89
|
},
|
|
90
|
-
"peerDependencies": {
|
|
91
|
-
"graphql": "^16.6.0"
|
|
92
|
-
},
|
|
93
90
|
"dependencies": {
|
|
94
91
|
"base58-js": "^2.0.0",
|
|
95
92
|
"eosio-wasm-js": "^4.1.1",
|
package/readme.md
CHANGED
|
@@ -31,42 +31,35 @@ See the examples folder on how to run AntelopeQL as a [Node.js](https://nodejs.o
|
|
|
31
31
|
### Query a blockchain account
|
|
32
32
|
|
|
33
33
|
```js
|
|
34
|
-
import fetch from "node-fetch";
|
|
35
34
|
import AntelopeQL from "antelopeql/antelopeql.mjs";
|
|
36
35
|
|
|
37
|
-
const { data } = await AntelopeQL(
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
const { data } = await AntelopeQL({
|
|
37
|
+
query: /*GraphQL*/ `{
|
|
38
|
+
blockchain{
|
|
39
|
+
get_account(account_name:"relockeblock") {
|
|
40
|
+
core_liquid_balance
|
|
41
|
+
ram_quota
|
|
42
|
+
net_weight
|
|
43
|
+
cpu_weight
|
|
44
|
+
ram_usage
|
|
45
|
+
permissions {
|
|
46
|
+
linked_actions {
|
|
47
|
+
account
|
|
48
|
+
action
|
|
49
|
+
}
|
|
50
|
+
required_auth {
|
|
51
|
+
keys {
|
|
52
|
+
key
|
|
53
|
+
weight
|
|
54
|
+
}
|
|
55
|
+
threshold
|
|
56
56
|
}
|
|
57
|
-
threshold
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
rpc_url: "https://jungle.relocke.io",
|
|
65
|
-
headers: {
|
|
66
|
-
"content-type": "application/json"
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
);
|
|
60
|
+
}`,
|
|
61
|
+
rpc_url: "https://jungle.relocke.io"
|
|
62
|
+
});
|
|
70
63
|
|
|
71
64
|
console.log(data);
|
|
72
65
|
```
|
|
@@ -76,13 +69,13 @@ console.log(data);
|
|
|
76
69
|
### Transfer EOS cryptocurrency
|
|
77
70
|
|
|
78
71
|
```js
|
|
79
|
-
import fetch from "node-fetch";
|
|
80
72
|
import AntelopeQL from "antelopeql/antelopeql.mjs";
|
|
73
|
+
import sign_txn from "antelopeql-ecc/sign_txn.mjs";
|
|
81
74
|
|
|
82
75
|
const { data } = await AntelopeQL({
|
|
83
76
|
query: /*GraphQL*/ `
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
mutation {
|
|
78
|
+
send_transaction(actions: [{
|
|
86
79
|
eosio_token:{
|
|
87
80
|
transfer: {
|
|
88
81
|
authorization:{
|
|
@@ -98,18 +91,14 @@ const { data } = await AntelopeQL({
|
|
|
98
91
|
transaction_id
|
|
99
92
|
block_num
|
|
100
93
|
}
|
|
101
|
-
|
|
102
|
-
contracts: ["eosio.token"],
|
|
103
|
-
signTransaction: async () => {
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
rpc_url: "https://eos.relocke.io", // eos blockchain.
|
|
110
|
-
headers: {
|
|
111
|
-
"content-type": "application/json"
|
|
112
|
-
}
|
|
94
|
+
}`,
|
|
95
|
+
contracts: ["eosio.token", "eosio"], // List of smart contracts
|
|
96
|
+
signTransaction: async (hash) => {
|
|
97
|
+
const wif_private_key = "PVT_K1_…"; // your private key
|
|
98
|
+
const signature = await sign_txn({ hash, wif_private_key });
|
|
99
|
+
return [signature]; // signaures must return array
|
|
100
|
+
},
|
|
101
|
+
rpc_url: "https://eos.relocke.io" // eos blockchain url.
|
|
113
102
|
});
|
|
114
103
|
|
|
115
104
|
console.log(data);
|
|
@@ -134,24 +123,9 @@ console.log(data);
|
|
|
134
123
|
|
|
135
124
|
Supported runtime environments:
|
|
136
125
|
|
|
137
|
-
- [Node.js](https://nodejs.org) versions `>=
|
|
126
|
+
- [Node.js](https://nodejs.org) versions `>=18.0.0`.
|
|
138
127
|
- Browsers matching the [Browserslist](https://browsersl.ist) query [`> 0.5%, not OperaMini all, not dead`](https://browsersl.ist/?q=%3E+0.5%25%2C+not+OperaMini+all%2C+not+dead).
|
|
139
|
-
- [Deno](https://deno.land) version `>=1.30.0`.
|
|
140
128
|
|
|
141
129
|
## Exports
|
|
142
130
|
|
|
143
131
|
The [npm](https://npmjs.com) package [`AntelopeQL`](https://npm.im/antelopeql) features [optimal JavaScript module design](https://jaydenseric.com/blog/optimal-javascript-module-design). It doesn’t have a main index module, so use deep imports from the ECMAScript modules that are exported via the [`package.json`](./package.json) field [`exports`](https://nodejs.org/api/packages.html#exports):
|
|
144
|
-
|
|
145
|
-
- [`antelopeql.mjs`](./antelopeql.mjs)
|
|
146
|
-
- [`blockchain_query_field.mjs`](blockchain_query_field.mjs)
|
|
147
|
-
- [`build_graphql_fields_from_abis.mjs`](build_graphql_fields_from_abis.mjs)
|
|
148
|
-
- [`eosio_abi_to_graphql_ast.mjs`](eosio_abi_to_graphql_ast.mjs)
|
|
149
|
-
- [`eosio_types.mjs`](eosio_types.mjs)
|
|
150
|
-
- [`mutation_resolver.mjs`](mutation_resolver.mjs)
|
|
151
|
-
- [`push_serialized_transaction.mjs`](push_serialized_transaction.mjs)
|
|
152
|
-
- [`push_transaction_rpc.mjs`](push_transaction_rpc.mjs)
|
|
153
|
-
- [`push_transaction.mjs`](push_transaction.mjs)
|
|
154
|
-
- [`query_resolver.mjs`](query_resolver.mjs)
|
|
155
|
-
- [`serialize_transaction.mjs`](serialize_transaction.mjs)
|
|
156
|
-
- [`antelopeql.mjs`](antelopeql.mjs)
|
|
157
|
-
- [`types.mjs`](types.mjs)
|
|
@@ -3,13 +3,13 @@ import { GraphQLList, GraphQLNonNull } from "graphql";
|
|
|
3
3
|
import bytes_type from "./eosio_types/bytes_type.mjs";
|
|
4
4
|
import signature_type from "./eosio_types/signature_type.mjs";
|
|
5
5
|
import transaction_receipt from "./graphql_object_types/transaction_receipt.mjs";
|
|
6
|
-
import
|
|
6
|
+
import send_transaction_rpc from "./send_transaction_rpc.mjs";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Push transaction type.
|
|
10
10
|
*/
|
|
11
|
-
const
|
|
12
|
-
description: "
|
|
11
|
+
const send_serialized_transaction = {
|
|
12
|
+
description: "Sends a serialized transaction to the blockchain.",
|
|
13
13
|
type: new GraphQLNonNull(transaction_receipt),
|
|
14
14
|
args: {
|
|
15
15
|
transaction_header: { type: new GraphQLNonNull(bytes_type) },
|
|
@@ -17,8 +17,8 @@ const push_serialized_transaction = {
|
|
|
17
17
|
signaures: { type: new GraphQLNonNull(new GraphQLList(signature_type)) }
|
|
18
18
|
},
|
|
19
19
|
resolve(_, args, ctx) {
|
|
20
|
-
return
|
|
20
|
+
return send_transaction_rpc(args, ctx.network);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export default
|
|
24
|
+
export default send_serialized_transaction;
|
|
@@ -4,9 +4,9 @@ import sha256 from "universal-sha256-js/sha256.mjs";
|
|
|
4
4
|
import configuration_type from "./graphql_input_types/configuration.mjs";
|
|
5
5
|
import transaction_receipt from "./graphql_object_types/transaction_receipt.mjs";
|
|
6
6
|
import mutation_resolver from "./mutation_resolver.mjs";
|
|
7
|
-
import
|
|
7
|
+
import send_transaction_rpc from "./send_transaction_rpc.mjs";
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const send_transaction = (actions, ast_list) => ({
|
|
10
10
|
description:
|
|
11
11
|
"Serialize a list of actions and push them to the blockchain in one step, requires private keys to be supplied to AntelopeQL.",
|
|
12
12
|
type: new GraphQLNonNull(transaction_receipt),
|
|
@@ -41,11 +41,11 @@ const push_transaction = (actions, ast_list) => ({
|
|
|
41
41
|
transaction
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
return
|
|
44
|
+
return send_transaction_rpc(
|
|
45
45
|
{ transaction_body, transaction_header, signatures },
|
|
46
46
|
network
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
export default
|
|
51
|
+
export default send_transaction;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GraphQLError } from "graphql";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Send a serialized transaction to the blockchain.
|
|
5
5
|
* @param {Object} root Argument
|
|
6
6
|
* @param {String} root.transaction_header Serialized transaction header.
|
|
7
7
|
* @param {String} root.transaction_body Serialized transaction body.
|
|
@@ -12,13 +12,13 @@ import { GraphQLError } from "graphql";
|
|
|
12
12
|
* @param {Object} network.headers transaction headers.
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
15
|
-
export default async function
|
|
15
|
+
export default async function send_transaction_rpc(
|
|
16
16
|
{ transaction_header, transaction_body, signatures },
|
|
17
17
|
network
|
|
18
18
|
) {
|
|
19
19
|
const { fetch, rpc_url, ...fetchOptions } = network;
|
|
20
20
|
|
|
21
|
-
const pushed_txn_req = await fetch(`${rpc_url}/v1/chain/
|
|
21
|
+
const pushed_txn_req = await fetch(`${rpc_url}/v1/chain/send_transaction`, {
|
|
22
22
|
method: "POST",
|
|
23
23
|
...fetchOptions,
|
|
24
24
|
body: JSON.stringify({
|