antelopeql 2.0.0-rc.4 → 2.0.0-rc.5
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.
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GraphQLList, GraphQLObjectType } from "graphql";
|
|
2
2
|
|
|
3
|
+
import bytes_type from "../eosio_types/bytes_type.mjs";
|
|
4
|
+
import public_key_type from "../eosio_types/public_key_type.mjs";
|
|
3
5
|
/**
|
|
4
6
|
* The packed transaction type.
|
|
5
7
|
* @kind typedef
|
|
@@ -8,6 +10,7 @@ import { GraphQLObjectType, GraphQLString } from "graphql";
|
|
|
8
10
|
* @prop {String} chain_id Hash representing the blockchain.
|
|
9
11
|
* @prop {String} transaction_header Hex string representing the serialized transaction header.
|
|
10
12
|
* @prop {String} transaction_body Hex string representing the serialized transaction body.
|
|
13
|
+
* @prop {String} transaction_body Hex string representing the serialized transaction body.
|
|
11
14
|
|
|
12
15
|
*/
|
|
13
16
|
const packed_transaction_type = new GraphQLObjectType({
|
|
@@ -15,16 +18,20 @@ const packed_transaction_type = new GraphQLObjectType({
|
|
|
15
18
|
description: "Packed transaction, chain ID and transaction header",
|
|
16
19
|
fields: {
|
|
17
20
|
chain_id: {
|
|
18
|
-
type:
|
|
21
|
+
type: bytes_type,
|
|
19
22
|
description: "A unique ID that specifies which chain we are operating on."
|
|
20
23
|
},
|
|
21
24
|
transaction_header: {
|
|
22
|
-
type:
|
|
25
|
+
type: bytes_type,
|
|
23
26
|
description: "Serialized transaction header."
|
|
24
27
|
},
|
|
25
28
|
transaction_body: {
|
|
26
|
-
type:
|
|
29
|
+
type: bytes_type,
|
|
27
30
|
description: "Serialized transaction body _(bytecode instructions)_."
|
|
31
|
+
},
|
|
32
|
+
required_keys: {
|
|
33
|
+
type: new GraphQLList(public_key_type),
|
|
34
|
+
description: "List of public keys needed to authorize transaction"
|
|
28
35
|
}
|
|
29
36
|
}
|
|
30
37
|
});
|
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.5",
|
|
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",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { GraphQLNonNull } from "graphql";
|
|
1
|
+
import { GraphQLList, GraphQLNonNull } from "graphql";
|
|
2
2
|
|
|
3
|
+
import public_key_type from "./eosio_types/public_key_type.mjs";
|
|
3
4
|
import configuration_type from "./graphql_input_types/configuration.mjs";
|
|
4
5
|
import packed_transaction_type from "./graphql_object_types/packed_transaction.mjs";
|
|
5
6
|
import mutation_resolver from "./mutation_resolver.mjs";
|
|
@@ -13,10 +14,38 @@ const serialize_transaction = (actions, ast_list) => ({
|
|
|
13
14
|
},
|
|
14
15
|
configuration: {
|
|
15
16
|
type: configuration_type
|
|
17
|
+
},
|
|
18
|
+
available_keys: {
|
|
19
|
+
type: new GraphQLList(public_key_type)
|
|
16
20
|
}
|
|
17
21
|
},
|
|
18
|
-
resolve(_, args, { network }) {
|
|
19
|
-
|
|
22
|
+
async resolve(_, { available_keys, ...args }, { network }) {
|
|
23
|
+
const { transaction, ...serialized_txn } = await mutation_resolver(
|
|
24
|
+
args,
|
|
25
|
+
network,
|
|
26
|
+
ast_list
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
let required_keys;
|
|
30
|
+
if (available_keys?.length) {
|
|
31
|
+
try {
|
|
32
|
+
const { required_keys: rk } = await fetch(
|
|
33
|
+
network.rpc_url + "/v1/chain/get_required_keys",
|
|
34
|
+
{
|
|
35
|
+
method: "post",
|
|
36
|
+
body: JSON.stringify({
|
|
37
|
+
transaction,
|
|
38
|
+
available_keys: await Promise.all(available_keys)
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
).then((res) => res.json);
|
|
42
|
+
required_keys = rk;
|
|
43
|
+
} catch (err) {
|
|
44
|
+
// gracefully catch the error
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return { ...serialized_txn, required_keys };
|
|
20
49
|
}
|
|
21
50
|
});
|
|
22
51
|
|