antelopeql 2.0.0-rc.4 → 2.0.0-rc.6
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/blockchain/get_currency_balance.mjs +1 -2
- package/blockchain/get_ram_price.mjs +1 -1
- package/eosio_types/signature_type.mjs +1 -3
- package/graphql_object_types/packed_transaction.mjs +11 -4
- package/mutation_resolver.mjs +1 -1
- package/package.json +1 -1
- package/serialize_transaction.mjs +32 -3
|
@@ -23,8 +23,7 @@ const currency_balance = {
|
|
|
23
23
|
},
|
|
24
24
|
symbol: {
|
|
25
25
|
description: "The crytpo currency token symbol.",
|
|
26
|
-
type: new GraphQLNonNull(symbol_code_type)
|
|
27
|
-
defaultValue: "EOS"
|
|
26
|
+
type: new GraphQLNonNull(symbol_code_type)
|
|
28
27
|
}
|
|
29
28
|
},
|
|
30
29
|
async resolve(_, args, { network: { fetch, rpc_url, ...fetchOptions } }) {
|
|
@@ -3,15 +3,13 @@ import { GraphQLScalarType } from "graphql";
|
|
|
3
3
|
const signature_type = new GraphQLScalarType({
|
|
4
4
|
description: `\`Signature type\`
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Antelope based signature, K1, R1 WA.`,
|
|
7
7
|
name: "signature",
|
|
8
8
|
parseValue(signature) {
|
|
9
9
|
if (signature == "") return "";
|
|
10
10
|
if (typeof signature !== "string")
|
|
11
11
|
throw new TypeError("Expected signature to be string");
|
|
12
12
|
|
|
13
|
-
if (signature.slice(0, 7) != "SIG_K1_")
|
|
14
|
-
throw new TypeError("Signature prefix is should be SIG_K1_.");
|
|
15
13
|
return signature;
|
|
16
14
|
}
|
|
17
15
|
});
|
|
@@ -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/mutation_resolver.mjs
CHANGED
|
@@ -216,7 +216,7 @@ async function mutation_resolver(
|
|
|
216
216
|
delay_sec: configuration.delay_sec
|
|
217
217
|
};
|
|
218
218
|
|
|
219
|
-
// Generates a transaction header for a
|
|
219
|
+
// Generates a transaction header for a Antelope transaction.
|
|
220
220
|
const transaction_header = serialize_transaction_header(txn_header);
|
|
221
221
|
txn_header.expiration = timestamp;
|
|
222
222
|
|
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.6",
|
|
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
|
|