antelopeql 3.0.0-alpha.5 → 3.0.0-rc.1
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/dist/abi_to_graphql_ast.d.ts +58 -0
- package/dist/abi_to_graphql_ast.js +235 -0
- package/dist/abi_to_graphql_ast.js.map +1 -0
- package/dist/antelope_types/asset_type.d.ts +2 -0
- package/dist/antelope_types/asset_type.js +34 -0
- package/dist/antelope_types/asset_type.js.map +1 -0
- package/dist/antelope_types/block_timestamp_type.d.ts +2 -0
- package/dist/antelope_types/block_timestamp_type.js +17 -0
- package/dist/antelope_types/block_timestamp_type.js.map +1 -0
- package/dist/antelope_types/boolean_type.d.ts +2 -0
- package/dist/antelope_types/boolean_type.js +20 -0
- package/dist/antelope_types/boolean_type.js.map +1 -0
- package/dist/antelope_types/bytes_type.d.ts +2 -0
- package/dist/antelope_types/bytes_type.js +20 -0
- package/dist/antelope_types/bytes_type.js.map +1 -0
- package/dist/antelope_types/extended_asset_type.d.ts +2 -0
- package/dist/antelope_types/extended_asset_type.js +25 -0
- package/dist/antelope_types/extended_asset_type.js.map +1 -0
- package/dist/antelope_types/generate_checksum_type.d.ts +7 -0
- package/dist/antelope_types/generate_checksum_type.js +30 -0
- package/dist/antelope_types/generate_checksum_type.js.map +1 -0
- package/dist/antelope_types/generate_float_type.d.ts +7 -0
- package/dist/antelope_types/generate_float_type.js +20 -0
- package/dist/antelope_types/generate_float_type.js.map +1 -0
- package/dist/antelope_types/generate_int_type.d.ts +7 -0
- package/dist/antelope_types/generate_int_type.js +39 -0
- package/dist/antelope_types/generate_int_type.js.map +1 -0
- package/dist/antelope_types/generate_uint_type.d.ts +7 -0
- package/dist/antelope_types/generate_uint_type.js +36 -0
- package/dist/antelope_types/generate_uint_type.js.map +1 -0
- package/dist/antelope_types/key_type.d.ts +2 -0
- package/dist/antelope_types/key_type.js +10 -0
- package/dist/antelope_types/key_type.js.map +1 -0
- package/dist/antelope_types/name_type.d.ts +2 -0
- package/dist/antelope_types/name_type.js +30 -0
- package/dist/antelope_types/name_type.js.map +1 -0
- package/dist/antelope_types/public_key_type.d.ts +2 -0
- package/dist/antelope_types/public_key_type.js +36 -0
- package/dist/antelope_types/public_key_type.js.map +1 -0
- package/dist/antelope_types/signature_type.d.ts +2 -0
- package/dist/antelope_types/signature_type.js +18 -0
- package/dist/antelope_types/signature_type.js.map +1 -0
- package/dist/antelope_types/symbol_code_type.d.ts +2 -0
- package/dist/antelope_types/symbol_code_type.js +15 -0
- package/dist/antelope_types/symbol_code_type.js.map +1 -0
- package/dist/antelope_types/symbol_type.d.ts +2 -0
- package/dist/antelope_types/symbol_type.js +33 -0
- package/dist/antelope_types/symbol_type.js.map +1 -0
- package/dist/antelope_types/time_point_sec_type.d.ts +2 -0
- package/dist/antelope_types/time_point_sec_type.js +24 -0
- package/dist/antelope_types/time_point_sec_type.js.map +1 -0
- package/dist/antelope_types/time_point_type.d.ts +2 -0
- package/dist/antelope_types/time_point_type.js +23 -0
- package/dist/antelope_types/time_point_type.js.map +1 -0
- package/dist/antelope_types/varint32_type.d.ts +2 -0
- package/dist/antelope_types/varint32_type.js +17 -0
- package/dist/antelope_types/varint32_type.js.map +1 -0
- package/dist/antelope_types/varuint32_type.d.ts +2 -0
- package/dist/antelope_types/varuint32_type.js +31 -0
- package/dist/antelope_types/varuint32_type.js.map +1 -0
- package/dist/antelope_types.d.ts +7 -0
- package/dist/antelope_types.js +56 -0
- package/dist/antelope_types.js.map +1 -0
- package/dist/antelopeql.d.ts +21 -0
- package/dist/antelopeql.js +77 -0
- package/dist/antelopeql.js.map +1 -0
- package/dist/blockchain/abi_bin_to_json.d.ts +33 -0
- package/dist/blockchain/abi_bin_to_json.js +39 -0
- package/dist/blockchain/abi_bin_to_json.js.map +1 -0
- package/dist/blockchain/get_abi.d.ts +54 -0
- package/dist/blockchain/get_abi.js +104 -0
- package/dist/blockchain/get_abi.js.map +1 -0
- package/dist/blockchain/get_account.d.ts +11 -0
- package/dist/blockchain/get_account.js +171 -0
- package/dist/blockchain/get_account.js.map +1 -0
- package/dist/blockchain/get_accounts_by_authorizers.d.ts +12 -0
- package/dist/blockchain/get_accounts_by_authorizers.js +62 -0
- package/dist/blockchain/get_accounts_by_authorizers.js.map +1 -0
- package/dist/blockchain/get_block.d.ts +78 -0
- package/dist/blockchain/get_block.js +161 -0
- package/dist/blockchain/get_block.js.map +1 -0
- package/dist/blockchain/get_currency_balance.d.ts +34 -0
- package/dist/blockchain/get_currency_balance.js +39 -0
- package/dist/blockchain/get_currency_balance.js.map +1 -0
- package/dist/blockchain/get_currency_stats.d.ts +31 -0
- package/dist/blockchain/get_currency_stats.js +49 -0
- package/dist/blockchain/get_currency_stats.js.map +1 -0
- package/dist/blockchain/get_info.d.ts +9 -0
- package/dist/blockchain/get_info.js +98 -0
- package/dist/blockchain/get_info.js.map +1 -0
- package/dist/blockchain/get_producers.d.ts +14 -0
- package/dist/blockchain/get_producers.js +95 -0
- package/dist/blockchain/get_producers.js.map +1 -0
- package/dist/blockchain/get_ram_price.d.ts +13 -0
- package/dist/blockchain/get_ram_price.js +67 -0
- package/dist/blockchain/get_ram_price.js.map +1 -0
- package/dist/blockchain/get_required_keys.d.ts +30 -0
- package/dist/blockchain/get_required_keys.js +72 -0
- package/dist/blockchain/get_required_keys.js.map +1 -0
- package/dist/blockchain/get_smart_contract.d.ts +13 -0
- package/dist/blockchain/get_smart_contract.js +45 -0
- package/dist/blockchain/get_smart_contract.js.map +1 -0
- package/dist/blockchain/get_table_by_scope.d.ts +16 -0
- package/dist/blockchain/get_table_by_scope.js +114 -0
- package/dist/blockchain/get_table_by_scope.js.map +1 -0
- package/dist/blockchain_query_field.d.ts +2 -0
- package/dist/blockchain_query_field.js +39 -0
- package/dist/blockchain_query_field.js.map +1 -0
- package/dist/build_graphql_fields_from_abis.d.ts +24 -0
- package/dist/build_graphql_fields_from_abis.js +39 -0
- package/dist/build_graphql_fields_from_abis.js.map +1 -0
- package/dist/get_abis.d.ts +20 -0
- package/dist/get_abis.js +35 -0
- package/dist/get_abis.js.map +1 -0
- package/dist/graphql_input_types/actions.d.ts +2 -0
- package/dist/graphql_input_types/actions.js +6 -0
- package/dist/graphql_input_types/actions.js.map +1 -0
- package/dist/graphql_input_types/authorization.d.ts +11 -0
- package/dist/graphql_input_types/authorization.js +18 -0
- package/dist/graphql_input_types/authorization.js.map +1 -0
- package/dist/graphql_input_types/configuration.d.ts +10 -0
- package/dist/graphql_input_types/configuration.js +35 -0
- package/dist/graphql_input_types/configuration.js.map +1 -0
- package/dist/graphql_input_types/query_argument_fields.d.ts +14 -0
- package/dist/graphql_input_types/query_argument_fields.js +66 -0
- package/dist/graphql_input_types/query_argument_fields.js.map +1 -0
- package/dist/graphql_object_types/authorization.d.ts +6 -0
- package/dist/graphql_object_types/authorization.js +9 -0
- package/dist/graphql_object_types/authorization.js.map +1 -0
- package/dist/graphql_object_types/authorizing_account_type.d.ts +6 -0
- package/dist/graphql_object_types/authorizing_account_type.js +13 -0
- package/dist/graphql_object_types/authorizing_account_type.js.map +1 -0
- package/dist/graphql_object_types/packed_transaction.d.ts +16 -0
- package/dist/graphql_object_types/packed_transaction.js +71 -0
- package/dist/graphql_object_types/packed_transaction.js.map +1 -0
- package/dist/graphql_object_types/transaction_receipt.d.ts +32 -0
- package/dist/graphql_object_types/transaction_receipt.js +120 -0
- package/dist/graphql_object_types/transaction_receipt.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/mutation_resolver.d.ts +44 -0
- package/dist/mutation_resolver.js +164 -0
- package/dist/mutation_resolver.js.map +1 -0
- package/dist/query_resolver.d.ts +27 -0
- package/dist/query_resolver.js +34 -0
- package/dist/query_resolver.js.map +1 -0
- package/dist/send_serialized_transaction.d.ts +13 -0
- package/dist/send_serialized_transaction.js +21 -0
- package/dist/send_serialized_transaction.js.map +1 -0
- package/dist/send_transaction.d.ts +19 -0
- package/dist/send_transaction.js +38 -0
- package/dist/send_transaction.js.map +1 -0
- package/dist/send_transaction_rpc.d.ts +18 -0
- package/dist/send_transaction_rpc.js +27 -0
- package/dist/send_transaction_rpc.js.map +1 -0
- package/dist/serialize_abi.d.ts +58 -0
- package/dist/serialize_abi.js +164 -0
- package/dist/serialize_abi.js.map +1 -0
- package/dist/serialize_transaction.d.ts +27 -0
- package/dist/serialize_transaction.js +28 -0
- package/dist/serialize_transaction.js.map +1 -0
- package/dist/types/Context.d.ts +13 -0
- package/dist/types/Context.js +3 -0
- package/dist/types/Context.js.map +1 -0
- package/dist/utils/sha256.d.ts +1 -0
- package/dist/utils/sha256.js +15 -0
- package/dist/utils/sha256.js.map +1 -0
- package/package.json +28 -56
- package/readme.md +3 -22
- package/antelopeql.d.ts +0 -52
- package/antelopeql.mjs +0 -119
- package/blockchain/abi_bin_to_json.mjs +0 -45
- package/blockchain/get_abi.mjs +0 -172
- package/blockchain/get_account.mjs +0 -222
- package/blockchain/get_accounts_by_authorizers.mjs +0 -90
- package/blockchain/get_block.mjs +0 -237
- package/blockchain/get_currency_balance.mjs +0 -51
- package/blockchain/get_currency_stats.mjs +0 -60
- package/blockchain/get_info.mjs +0 -111
- package/blockchain/get_producers.mjs +0 -106
- package/blockchain/get_ram_price.mjs +0 -65
- package/blockchain/get_required_keys.mjs +0 -85
- package/blockchain/get_smart_contract.mjs +0 -53
- package/blockchain/get_table_by_scope.mjs +0 -135
- package/blockchain_query_field.mjs +0 -49
- package/build_graphql_fields_from_abis.mjs +0 -135
- package/eosio_abi_to_graphql_ast.mjs +0 -246
- package/eosio_types/asset_type.mjs +0 -35
- package/eosio_types/block_timestamp_type.mjs +0 -14
- package/eosio_types/boolean_type.mjs +0 -10
- package/eosio_types/bytes_type.mjs +0 -17
- package/eosio_types/eosio_key_type.mjs +0 -13
- package/eosio_types/extended_asset_type.mjs +0 -19
- package/eosio_types/generate_checksum_type.mjs +0 -20
- package/eosio_types/generate_float_type.mjs +0 -16
- package/eosio_types/generate_int_type.mjs +0 -28
- package/eosio_types/generate_uint_type.mjs +0 -27
- package/eosio_types/name_type.mjs +0 -29
- package/eosio_types/public_key_type.mjs +0 -41
- package/eosio_types/signature_type.mjs +0 -17
- package/eosio_types/symbol_code_type.mjs +0 -13
- package/eosio_types/symbol_type.mjs +0 -34
- package/eosio_types/time_point_sec_type.mjs +0 -12
- package/eosio_types/time_point_type.mjs +0 -12
- package/eosio_types/varint32_type.mjs +0 -13
- package/eosio_types/varuint32_type.mjs +0 -12
- package/eosio_types.mjs +0 -59
- package/get_abis.mjs +0 -41
- package/graphql_input_types/actions.mjs +0 -15
- package/graphql_input_types/authorization.mjs +0 -30
- package/graphql_input_types/configuration.mjs +0 -49
- package/graphql_input_types/query_argument_fields.mjs +0 -78
- package/graphql_object_types/authorization.mjs +0 -15
- package/graphql_object_types/authorizing_account_type.mjs +0 -15
- package/graphql_object_types/packed_transaction.mjs +0 -99
- package/graphql_object_types/transaction_receipt.mjs +0 -159
- package/mutation_resolver.mjs +0 -232
- package/query_resolver.mjs +0 -45
- package/send_serialized_transaction.mjs +0 -25
- package/send_transaction.mjs +0 -57
- package/send_transaction_rpc.mjs +0 -40
- package/serialize_abi.mjs +0 -273
- package/serialize_transaction.mjs +0 -35
- package/types.mjs +0 -77
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { GraphQLFieldConfigMap, GraphQLInputFieldConfigMap } from "graphql";
|
|
2
|
+
import type { Abi } from "./blockchain/get_abi.js";
|
|
3
|
+
interface BaseFieldInfo {
|
|
4
|
+
object: boolean;
|
|
5
|
+
optional: boolean;
|
|
6
|
+
list: boolean;
|
|
7
|
+
binary_ex: boolean;
|
|
8
|
+
variant: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface ASTField {
|
|
11
|
+
name: string;
|
|
12
|
+
type: string;
|
|
13
|
+
$info: BaseFieldInfo;
|
|
14
|
+
}
|
|
15
|
+
interface ABIField {
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}
|
|
19
|
+
interface ABIStruct {
|
|
20
|
+
name: string;
|
|
21
|
+
base?: string;
|
|
22
|
+
fields: ABIField[];
|
|
23
|
+
}
|
|
24
|
+
interface ABIAction {
|
|
25
|
+
name: string;
|
|
26
|
+
type: string;
|
|
27
|
+
ricardian_contract?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ABI {
|
|
30
|
+
version: string;
|
|
31
|
+
tables: {
|
|
32
|
+
name: string;
|
|
33
|
+
type: string;
|
|
34
|
+
}[];
|
|
35
|
+
actions: ABIAction[];
|
|
36
|
+
structs: ABIStruct[];
|
|
37
|
+
types?: any[];
|
|
38
|
+
variants?: any[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Generate an Abstract syntax tree (AST) for an EOSIO application Binary interface (ABI).
|
|
42
|
+
* @param abi EOSIO smart contract Application Binary interface (ABI).
|
|
43
|
+
* @returns a GraphQL AST for a given smart contract.
|
|
44
|
+
*/
|
|
45
|
+
export declare function abi_to_graphql_ast(abi: ABI): Readonly<Record<string, ASTField[]>>;
|
|
46
|
+
/**
|
|
47
|
+
* Generates GraphQL query and mutation fields from an ABI AST.
|
|
48
|
+
* @param AST Abstract syntax tree generated by abi_to_graphql_ast function.
|
|
49
|
+
* @param ABI Antelope application binary interface (ABI).
|
|
50
|
+
* @param account_name Blockchain account name.
|
|
51
|
+
* @param chainName Optional chain name.
|
|
52
|
+
* @returns GraphQL query and mutation fields.
|
|
53
|
+
*/
|
|
54
|
+
export declare function get_graphql_fields_from_AST(AST: Readonly<Record<string, ASTField[]>>, ABI: Abi, account_name?: string, chainName?: string): {
|
|
55
|
+
query_fields: GraphQLFieldConfigMap<any, any>;
|
|
56
|
+
mutation_fields: GraphQLInputFieldConfigMap;
|
|
57
|
+
};
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { GraphQLInputObjectType, GraphQLList, GraphQLNonNull, GraphQLObjectType } from "graphql";
|
|
2
|
+
import { antelope_types } from "./antelope_types.js";
|
|
3
|
+
import { authorization_type } from "./graphql_input_types/authorization.js";
|
|
4
|
+
import { query_arg_fields as query_argument_fields } from "./graphql_input_types/query_argument_fields.js";
|
|
5
|
+
import { query_resolver as resolve } from "./query_resolver.js";
|
|
6
|
+
/**
|
|
7
|
+
* Recursively resolves all the base fields and collects them into a single array.
|
|
8
|
+
* @param base Base struct field name.
|
|
9
|
+
* @param structs List of ABI structs.
|
|
10
|
+
* @returns List of base fields.
|
|
11
|
+
*/
|
|
12
|
+
function handleBaseFields(base, structs) {
|
|
13
|
+
const base_struct = structs.find(({ name }) => name === base);
|
|
14
|
+
if (!base_struct) {
|
|
15
|
+
throw new Error(`Base struct "${base}" not found`);
|
|
16
|
+
}
|
|
17
|
+
const { fields, base: nested_base } = base_struct;
|
|
18
|
+
return [
|
|
19
|
+
...(nested_base ? handleBaseFields(nested_base, structs) : []),
|
|
20
|
+
...fields
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Performs some transformations on the ABI structs to make it malleable to the GraphQL spec.
|
|
25
|
+
* ABI structs are converted onto GraphQL Types.
|
|
26
|
+
* @param structs ABI structs
|
|
27
|
+
* @param type_alias Type alias map
|
|
28
|
+
* @returns Struct AST that will be consumed by abi_to_graphql_ast
|
|
29
|
+
*/
|
|
30
|
+
function handleStructs(structs, type_alias) {
|
|
31
|
+
const graphql_ast_structs = {};
|
|
32
|
+
for (const struct of structs) {
|
|
33
|
+
const { name, base, fields } = struct;
|
|
34
|
+
const fields_with_base_fields = base
|
|
35
|
+
? [...handleBaseFields(base, structs), ...fields]
|
|
36
|
+
: fields;
|
|
37
|
+
const ast_fields = [];
|
|
38
|
+
for (const field of fields_with_base_fields) {
|
|
39
|
+
const optional = !!field.type.match(/[$?]/g);
|
|
40
|
+
const binary_ex = !!field.type.match(/\$/g);
|
|
41
|
+
const variant = !!field.type.match(/@/g);
|
|
42
|
+
const list = !!field.type.match(/\[\]/g);
|
|
43
|
+
let type = field.type.replace(/[[\]?$@]/g, "");
|
|
44
|
+
type = type_alias[type] ?? type;
|
|
45
|
+
const object = !antelope_types[type];
|
|
46
|
+
ast_fields.push({
|
|
47
|
+
name: field.name,
|
|
48
|
+
type,
|
|
49
|
+
$info: { object, optional, list, binary_ex, variant }
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
graphql_ast_structs[name] = ast_fields;
|
|
53
|
+
}
|
|
54
|
+
return graphql_ast_structs;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Generate an Abstract syntax tree (AST) for an EOSIO application Binary interface (ABI).
|
|
58
|
+
* @param abi EOSIO smart contract Application Binary interface (ABI).
|
|
59
|
+
* @returns a GraphQL AST for a given smart contract.
|
|
60
|
+
*/
|
|
61
|
+
export function abi_to_graphql_ast(abi) {
|
|
62
|
+
const { types, variants, structs } = abi;
|
|
63
|
+
const type_alias = {};
|
|
64
|
+
const new_structs = [...structs];
|
|
65
|
+
if (variants?.length) {
|
|
66
|
+
for (const { name, types: variant_types } of variants) {
|
|
67
|
+
new_structs.push({
|
|
68
|
+
name: name,
|
|
69
|
+
base: "",
|
|
70
|
+
fields: variant_types.map((item) => ({
|
|
71
|
+
name: item,
|
|
72
|
+
type: item + "$@"
|
|
73
|
+
})) // @ indiacted a variant type and binary extension.
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (types?.length) {
|
|
78
|
+
for (const { type: real_type, new_type_name } of types) {
|
|
79
|
+
if (real_type && new_type_name) {
|
|
80
|
+
if (antelope_types[real_type]) {
|
|
81
|
+
type_alias[new_type_name] = real_type;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (real_type.endsWith("[]")) {
|
|
85
|
+
new_structs.push({
|
|
86
|
+
name: new_type_name,
|
|
87
|
+
base: "",
|
|
88
|
+
fields: [
|
|
89
|
+
{
|
|
90
|
+
name: real_type.replace("[]", ""),
|
|
91
|
+
type: real_type
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const foundStruct = new_structs.find((x) => x.name === real_type);
|
|
98
|
+
if (foundStruct) {
|
|
99
|
+
new_structs.push({
|
|
100
|
+
...foundStruct,
|
|
101
|
+
name: new_type_name
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const structs_ast = handleStructs(new_structs, type_alias);
|
|
108
|
+
return Object.freeze(structs_ast);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Wraps a GraphQL type in a GraphQLNonNullType and GraphQLListType.
|
|
112
|
+
* @param type GraphQL type to wrap.
|
|
113
|
+
* @param param1 Optional and list info.
|
|
114
|
+
* @returns wrapped GraphQL type.
|
|
115
|
+
*/
|
|
116
|
+
function Wrap(type, { optional, list }) {
|
|
117
|
+
let gql_type = type;
|
|
118
|
+
if (list)
|
|
119
|
+
gql_type = new GraphQLList(gql_type);
|
|
120
|
+
if (!optional)
|
|
121
|
+
gql_type = new GraphQLNonNull(gql_type);
|
|
122
|
+
return gql_type;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Generates GraphQL query and mutation fields from an ABI AST.
|
|
126
|
+
* @param AST Abstract syntax tree generated by abi_to_graphql_ast function.
|
|
127
|
+
* @param ABI Antelope application binary interface (ABI).
|
|
128
|
+
* @param account_name Blockchain account name.
|
|
129
|
+
* @param chainName Optional chain name.
|
|
130
|
+
* @returns GraphQL query and mutation fields.
|
|
131
|
+
*/
|
|
132
|
+
export function get_graphql_fields_from_AST(AST, ABI, account_name = "", chainName = "") {
|
|
133
|
+
const { tables = [], actions = [] } = ABI;
|
|
134
|
+
const gql_account_name = account_name.replace(/\./g, "_") + "_";
|
|
135
|
+
const query_fields = {};
|
|
136
|
+
const queryTypes = {};
|
|
137
|
+
const GQL_TYPES = {};
|
|
138
|
+
for (let table of tables) {
|
|
139
|
+
let { name: table_name, type: table_type } = table;
|
|
140
|
+
table_name = table_name.replace(/\./g, "_");
|
|
141
|
+
const table_fields = AST[table_type];
|
|
142
|
+
const buildQGL = (fields, acc = {}) => {
|
|
143
|
+
for (const field of fields) {
|
|
144
|
+
const { name, type, $info } = field;
|
|
145
|
+
// Do this because of variant type from table.
|
|
146
|
+
const resolveFn = (data, args, context, info) => {
|
|
147
|
+
if ($info.variant)
|
|
148
|
+
return type === data[0] ? data[1] : null;
|
|
149
|
+
return data[info.fieldName];
|
|
150
|
+
};
|
|
151
|
+
if ($info.object) {
|
|
152
|
+
if (!GQL_TYPES[type])
|
|
153
|
+
GQL_TYPES[type] = new GraphQLObjectType({
|
|
154
|
+
name: gql_account_name + type + chainName,
|
|
155
|
+
fields: buildQGL(AST[type])
|
|
156
|
+
});
|
|
157
|
+
acc[name] = {
|
|
158
|
+
type: Wrap(GQL_TYPES[type], $info),
|
|
159
|
+
resolve: resolveFn
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
acc[name] = {
|
|
164
|
+
type: Wrap(antelope_types[type], $info),
|
|
165
|
+
resolve: resolveFn
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return acc;
|
|
170
|
+
};
|
|
171
|
+
if (!queryTypes[table_type]) {
|
|
172
|
+
queryTypes[table_type] = {
|
|
173
|
+
type: new GraphQLList(new GraphQLObjectType({
|
|
174
|
+
name: gql_account_name + table_type + "_query" + chainName,
|
|
175
|
+
fields: buildQGL(table_fields)
|
|
176
|
+
})),
|
|
177
|
+
args: {
|
|
178
|
+
arg: {
|
|
179
|
+
// @ts-ignore
|
|
180
|
+
name: "argument_type",
|
|
181
|
+
type: query_argument_fields
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
resolve
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
query_fields[table_name] = queryTypes[table_type];
|
|
188
|
+
}
|
|
189
|
+
const GQL_MTYPES = {};
|
|
190
|
+
const mutation_fields = {};
|
|
191
|
+
const mutationTypes = {};
|
|
192
|
+
for (const action of actions) {
|
|
193
|
+
let { name: action_name, type: action_type, ricardian_contract = "" } = action;
|
|
194
|
+
action_name = action_name.replace(/\./g, "_");
|
|
195
|
+
const action_fields = AST[action_type];
|
|
196
|
+
const buildQGL = (fields, acc = {}) => {
|
|
197
|
+
for (const field of fields) {
|
|
198
|
+
const { name, type, $info } = field;
|
|
199
|
+
if ($info.object) {
|
|
200
|
+
if (!GQL_MTYPES[type])
|
|
201
|
+
GQL_MTYPES[type] = new GraphQLInputObjectType({
|
|
202
|
+
name: gql_account_name + "input_" + type + chainName,
|
|
203
|
+
fields: buildQGL(AST[type])
|
|
204
|
+
});
|
|
205
|
+
acc[name] = { type: Wrap(GQL_MTYPES[type], $info) };
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
acc[name] = { type: Wrap(antelope_types[type], $info) };
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return acc;
|
|
212
|
+
};
|
|
213
|
+
if (!mutationTypes[action_type]) {
|
|
214
|
+
mutationTypes[action_type] = {
|
|
215
|
+
type: new GraphQLInputObjectType({
|
|
216
|
+
name: gql_account_name + action_type + chainName,
|
|
217
|
+
description: ricardian_contract
|
|
218
|
+
.replace(/(https?|http|ftp):\/\/[^\s$.?#].[^\s]*$/g, "")
|
|
219
|
+
.replace(/icon:/g, "")
|
|
220
|
+
.replace(/(\s)?nowrap(\s)?/g, ""),
|
|
221
|
+
fields: {
|
|
222
|
+
...buildQGL(action_fields),
|
|
223
|
+
authorization: {
|
|
224
|
+
description: "Authorization to sign the transaction",
|
|
225
|
+
type: new GraphQLList(new GraphQLNonNull(authorization_type))
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
mutation_fields[action_name] = mutationTypes[action_type];
|
|
232
|
+
}
|
|
233
|
+
return { query_fields, mutation_fields };
|
|
234
|
+
}
|
|
235
|
+
//#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
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { GraphQLScalarType, GraphQLError } from "graphql";
|
|
2
|
+
export const asset_type = new GraphQLScalarType({
|
|
3
|
+
description: `
|
|
4
|
+
\`Asset type\`
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
An \`asset\` type describes a blockchain asset and includes a quantity and a symbol section.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
- The quantity must include decimal precision (with a maximum precision of 18)
|
|
12
|
+
- Symbol must be an uppercase string of 7 or less characters from [A-Z]
|
|
13
|
+
|
|
14
|
+
***example*** - \`1.0010 EOS\`
|
|
15
|
+
|
|
16
|
+
- Quantity is 1.0010
|
|
17
|
+
- Symbol is EOS
|
|
18
|
+
|
|
19
|
+
`,
|
|
20
|
+
name: "asset",
|
|
21
|
+
parseValue(value) {
|
|
22
|
+
if (typeof value !== "string") {
|
|
23
|
+
throw new GraphQLError("Asset value must be a string.");
|
|
24
|
+
}
|
|
25
|
+
if (value == "")
|
|
26
|
+
return "";
|
|
27
|
+
if (!value.match(/^\d+(\.\d+)?\s[A-Z]{1,7}$/gmu))
|
|
28
|
+
throw new GraphQLError("Invalid asset type supplied.");
|
|
29
|
+
if (value.replace(/[A-Z.\s]/gmu, "").length > 21)
|
|
30
|
+
throw new GraphQLError("Invalid asset size, maximum (2 ^ 62) - 1");
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=asset_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset_type.js","sourceRoot":"","sources":["../../src/antelope_types/asset_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC;IAC9C,WAAW,EAAE;;;;;;;;;;;;;;;;CAgBd;IACC,IAAI,EAAE,OAAO;IACb,UAAU,CAAC,KAAc;QACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,YAAY,CAAC,+BAA+B,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,KAAK,IAAI,EAAE;YAAE,OAAO,EAAE,CAAC;QAE3B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC;YAC9C,MAAM,IAAI,YAAY,CAAC,8BAA8B,CAAC,CAAC;QAEzD,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,MAAM,GAAG,EAAE;YAC9C,MAAM,IAAI,YAAY,CAAC,0CAA0C,CAAC,CAAC;QAErE,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GraphQLScalarType, GraphQLError } from "graphql";
|
|
2
|
+
export const block_timestamp_type = new GraphQLScalarType({
|
|
3
|
+
name: "block_timestamp_type",
|
|
4
|
+
description: "`Block timestamp type`",
|
|
5
|
+
parseValue(value) {
|
|
6
|
+
if (typeof value !== "string") {
|
|
7
|
+
throw new GraphQLError("Block timestamp must be a string");
|
|
8
|
+
}
|
|
9
|
+
if (value === "")
|
|
10
|
+
return "";
|
|
11
|
+
if (Number.isNaN(Date.parse(value))) {
|
|
12
|
+
throw new GraphQLError("Invalid block timestamp " + value);
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=block_timestamp_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_timestamp_type.js","sourceRoot":"","sources":["../../src/antelope_types/block_timestamp_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,iBAAiB,CAAC;IACxD,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,wBAAwB;IACrC,UAAU,CAAC,KAAc;QACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,YAAY,CAAC,kCAAkC,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,KAAK,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC;QAC5B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,YAAY,CAAC,0BAA0B,GAAG,KAAK,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GraphQLScalarType } from "graphql";
|
|
2
|
+
export const boolean_type = new GraphQLScalarType({
|
|
3
|
+
name: "bool",
|
|
4
|
+
description: "`Boolean type` true=1 or false=0",
|
|
5
|
+
parseValue(value) {
|
|
6
|
+
// Accept true, false, 1, 0 (coerce to boolean)
|
|
7
|
+
if (value === 1 || value === "1")
|
|
8
|
+
return true;
|
|
9
|
+
if (value === 0 || value === "0")
|
|
10
|
+
return false;
|
|
11
|
+
if (typeof value === "boolean")
|
|
12
|
+
return value;
|
|
13
|
+
throw new TypeError("Boolean type must be true, false, 1, or 0");
|
|
14
|
+
},
|
|
15
|
+
serialize(value) {
|
|
16
|
+
// Serialize truthy/falsy to boolean
|
|
17
|
+
return Boolean(value);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=boolean_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean_type.js","sourceRoot":"","sources":["../../src/antelope_types/boolean_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,iBAAiB,CAAC;IAChD,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,kCAAkC;IAE/C,UAAU,CAAC,KAAc;QACvB,+CAA+C;QAC/C,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QAC9C,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,GAAG;YAAE,OAAO,KAAK,CAAC;QAC/C,IAAI,OAAO,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC7C,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;IACnE,CAAC;IAED,SAAS,CAAC,KAAc;QACtB,oCAAoC;QACpC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GraphQLScalarType, GraphQLError } from "graphql";
|
|
2
|
+
export const bytes_type = new GraphQLScalarType({
|
|
3
|
+
name: "bytes",
|
|
4
|
+
description: "Hexadecimal text string type.",
|
|
5
|
+
parseValue(value) {
|
|
6
|
+
if (typeof value !== "string") {
|
|
7
|
+
throw new GraphQLError("Value must be a string");
|
|
8
|
+
}
|
|
9
|
+
if (value === "")
|
|
10
|
+
return value;
|
|
11
|
+
if (!/^[A-Fa-f0-9]+$/gmu.test(value)) {
|
|
12
|
+
throw new GraphQLError("Invalid hexadecimal string: " + value);
|
|
13
|
+
}
|
|
14
|
+
if (value.length % 2 !== 0) {
|
|
15
|
+
throw new GraphQLError("Invalid hexadecimal string length");
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=bytes_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes_type.js","sourceRoot":"","sources":["../../src/antelope_types/bytes_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC;IAC9C,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,+BAA+B;IAC5C,UAAU,CAAC,KAAc;QACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,YAAY,CAAC,wBAAwB,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,KAAK,KAAK,EAAE;YAAE,OAAO,KAAK,CAAC;QAC/B,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,YAAY,CAAC,8BAA8B,GAAG,KAAK,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,YAAY,CAAC,mCAAmC,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { GraphQLScalarType, GraphQLError } from "graphql";
|
|
2
|
+
export const extended_asset_type = new GraphQLScalarType({
|
|
3
|
+
name: "extended_asset",
|
|
4
|
+
description: `
|
|
5
|
+
\`Extended_asset\`
|
|
6
|
+
|
|
7
|
+
Extended asset which stores the information of the owner of the asset.
|
|
8
|
+
|
|
9
|
+
### extended asset
|
|
10
|
+
- Start with asset type followed by “@” and the account name.
|
|
11
|
+
|
|
12
|
+
example:
|
|
13
|
+
|
|
14
|
+
1.0000 EOS@eosio.token
|
|
15
|
+
`,
|
|
16
|
+
parseValue(value) {
|
|
17
|
+
if (typeof value !== "string") {
|
|
18
|
+
throw new GraphQLError("Extended asset must be a string");
|
|
19
|
+
}
|
|
20
|
+
// Optionally add validation here if needed
|
|
21
|
+
const [symbol, contract] = value.split("@");
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=extended_asset_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extended_asset_type.js","sourceRoot":"","sources":["../../src/antelope_types/extended_asset_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,iBAAiB,CAAC;IACvD,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE;;;;;;;;;;;GAWZ;IACD,UAAU,CAAC,KAAc;QACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,YAAY,CAAC,iCAAiC,CAAC,CAAC;QAC5D,CAAC;QACD,2CAA2C;QAC3C,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE5C,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GraphQLScalarType } from "graphql";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a GraphQL scalar type for checksum of `size`.
|
|
4
|
+
* @param size Size of the checksum in bytes.
|
|
5
|
+
* @returns GraphQLScalarType representing the checksum.
|
|
6
|
+
*/
|
|
7
|
+
export declare function generate_checksum(size: number): GraphQLScalarType;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { GraphQLScalarType, GraphQLError } from "graphql";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a GraphQL scalar type for checksum of `size`.
|
|
4
|
+
* @param size Size of the checksum in bytes.
|
|
5
|
+
* @returns GraphQLScalarType representing the checksum.
|
|
6
|
+
*/
|
|
7
|
+
export function generate_checksum(size) {
|
|
8
|
+
return new GraphQLScalarType({
|
|
9
|
+
name: `checksum${size * 8}`,
|
|
10
|
+
description: `\`Checksum${size * 8} type\`
|
|
11
|
+
|
|
12
|
+
Represented as a hexadecimal string of ${size * 2} characters.
|
|
13
|
+
`,
|
|
14
|
+
parseValue(value) {
|
|
15
|
+
if (typeof value !== "string") {
|
|
16
|
+
throw new GraphQLError("Checksum value must be a string");
|
|
17
|
+
}
|
|
18
|
+
// Optionally validate length and hex format here
|
|
19
|
+
// e.g. length check:
|
|
20
|
+
if (value.length !== size * 2) {
|
|
21
|
+
throw new GraphQLError(`Checksum must be exactly ${size * 2} hex characters long`);
|
|
22
|
+
}
|
|
23
|
+
if (!/^[A-Fa-f0-9]+$/g.test(value)) {
|
|
24
|
+
throw new GraphQLError("Checksum must be a hexadecimal string");
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=generate_checksum_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate_checksum_type.js","sourceRoot":"","sources":["../../src/antelope_types/generate_checksum_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,IAAI,iBAAiB,CAAC;QAC3B,IAAI,EAAE,WAAW,IAAI,GAAG,CAAC,EAAE;QAC3B,WAAW,EAAE,aAAa,IAAI,GAAG,CAAC;;yCAEG,IAAI,GAAG,CAAC;CAChD;QACG,UAAU,CAAC,KAAc;YACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,MAAM,IAAI,YAAY,CAAC,iCAAiC,CAAC,CAAC;YAC5D,CAAC;YACD,iDAAiD;YACjD,qBAAqB;YACrB,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,YAAY,CACpB,4BAA4B,IAAI,GAAG,CAAC,sBAAsB,CAC3D,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,YAAY,CAAC,uCAAuC,CAAC,CAAC;YAClE,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GraphQLScalarType } from "graphql";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a GraphQL scalar Float type of `size`.
|
|
4
|
+
* @param size Size of the float; typically 32, 64 or 128.
|
|
5
|
+
* @returns GraphQLScalarType representing the float type.
|
|
6
|
+
*/
|
|
7
|
+
export declare function generate_float_type(size: number): GraphQLScalarType;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GraphQLScalarType, GraphQLError } from "graphql";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a GraphQL scalar Float type of `size`.
|
|
4
|
+
* @param size Size of the float; typically 32, 64 or 128.
|
|
5
|
+
* @returns GraphQLScalarType representing the float type.
|
|
6
|
+
*/
|
|
7
|
+
export function generate_float_type(size) {
|
|
8
|
+
return new GraphQLScalarType({
|
|
9
|
+
name: `float${size}`,
|
|
10
|
+
description: `\`Float${size} type\``,
|
|
11
|
+
parseValue(value) {
|
|
12
|
+
if (typeof value !== "number" && typeof value !== "string") {
|
|
13
|
+
throw new GraphQLError(`Float${size} value must be a number or string`);
|
|
14
|
+
}
|
|
15
|
+
// Just return it as-is, cast to any to avoid TS error
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=generate_float_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate_float_type.js","sourceRoot":"","sources":["../../src/antelope_types/generate_float_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAI,iBAAiB,CAAC;QAC3B,IAAI,EAAE,QAAQ,IAAI,EAAE;QACpB,WAAW,EAAE,UAAU,IAAI,SAAS;QAEpC,UAAU,CAAC,KAAc;YACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC3D,MAAM,IAAI,YAAY,CAAC,QAAQ,IAAI,mCAAmC,CAAC,CAAC;YAC1E,CAAC;YACD,sDAAsD;YACtD,OAAO,KAAY,CAAC;QACtB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GraphQLScalarType } from "graphql";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a GraphQL scalar signed integer type of size `bits`.
|
|
4
|
+
* @param bits Size of the integer in bits.
|
|
5
|
+
* @returns GraphQLScalarType representing the signed integer type.
|
|
6
|
+
*/
|
|
7
|
+
export declare function generate_int_type(bits: number): GraphQLScalarType;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { GraphQLScalarType, GraphQLError } from "graphql";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a GraphQL scalar signed integer type of size `bits`.
|
|
4
|
+
* @param bits Size of the integer in bits.
|
|
5
|
+
* @returns GraphQLScalarType representing the signed integer type.
|
|
6
|
+
*/
|
|
7
|
+
export function generate_int_type(bits) {
|
|
8
|
+
const bitsBigInt = BigInt(bits);
|
|
9
|
+
const max = 2n ** (bitsBigInt - 1n) - 1n;
|
|
10
|
+
const min = -(2n ** (bitsBigInt - 1n));
|
|
11
|
+
return new GraphQLScalarType({
|
|
12
|
+
name: `int${bits}`,
|
|
13
|
+
description: `\`Integer t${bits} type\`
|
|
14
|
+
|
|
15
|
+
Signed integer range is between ${min} - ${max}`,
|
|
16
|
+
parseValue(value) {
|
|
17
|
+
if (value == "")
|
|
18
|
+
return "";
|
|
19
|
+
if (typeof value !== "string" &&
|
|
20
|
+
typeof value !== "number" &&
|
|
21
|
+
typeof value !== "bigint") {
|
|
22
|
+
throw new GraphQLError("Value must be a string, number, or bigint");
|
|
23
|
+
}
|
|
24
|
+
// Convert value to BigInt safely
|
|
25
|
+
let intVal;
|
|
26
|
+
try {
|
|
27
|
+
intVal = BigInt(value);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw new GraphQLError("Value cannot be converted to BigInt");
|
|
31
|
+
}
|
|
32
|
+
if (intVal > max || intVal < min) {
|
|
33
|
+
throw new GraphQLError(`Integer range is outside int${bits}.`);
|
|
34
|
+
}
|
|
35
|
+
return intVal.toString();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=generate_int_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate_int_type.js","sourceRoot":"","sources":["../../src/antelope_types/generate_int_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;IACzC,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC;IAEvC,OAAO,IAAI,iBAAiB,CAAC;QAC3B,IAAI,EAAE,MAAM,IAAI,EAAE;QAClB,WAAW,EAAE,cAAc,IAAI;;kCAED,GAAG,MAAM,GAAG,EAAE;QAC5C,UAAU,CAAC,KAAc;YACvB,IAAI,KAAK,IAAI,EAAE;gBAAE,OAAO,EAAE,CAAC;YAC3B,IACE,OAAO,KAAK,KAAK,QAAQ;gBACzB,OAAO,KAAK,KAAK,QAAQ;gBACzB,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;gBACD,MAAM,IAAI,YAAY,CAAC,2CAA2C,CAAC,CAAC;YACtE,CAAC;YAED,iCAAiC;YACjC,IAAI,MAAc,CAAC;YACnB,IAAI,CAAC;gBACH,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,IAAI,YAAY,CAAC,qCAAqC,CAAC,CAAC;YAChE,CAAC;YAED,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC;gBACjC,MAAM,IAAI,YAAY,CAAC,+BAA+B,IAAI,GAAG,CAAC,CAAC;YACjE,CAAC;YAED,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC3B,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GraphQLScalarType } from "graphql";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a GraphQL scalar unsigned integer type of size `bits`.
|
|
4
|
+
* @param bits Size of the unsigned int in bits.
|
|
5
|
+
* @returns GraphQLScalarType representing the unsigned integer type.
|
|
6
|
+
*/
|
|
7
|
+
export declare function generate_uint_type(bits: number): GraphQLScalarType;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GraphQLScalarType, GraphQLError } from "graphql";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a GraphQL scalar unsigned integer type of size `bits`.
|
|
4
|
+
* @param bits Size of the unsigned int in bits.
|
|
5
|
+
* @returns GraphQLScalarType representing the unsigned integer type.
|
|
6
|
+
*/
|
|
7
|
+
export function generate_uint_type(bits) {
|
|
8
|
+
const size = 2n ** BigInt(bits);
|
|
9
|
+
return new GraphQLScalarType({
|
|
10
|
+
name: `uint${bits}`,
|
|
11
|
+
description: `\`Unsigned integer${bits} type\`
|
|
12
|
+
|
|
13
|
+
Unsigned integer range is between 0 - ${size.toString()}`,
|
|
14
|
+
parseValue(value) {
|
|
15
|
+
if (value === "")
|
|
16
|
+
return "";
|
|
17
|
+
if (typeof value !== "string" &&
|
|
18
|
+
typeof value !== "number" &&
|
|
19
|
+
typeof value !== "bigint") {
|
|
20
|
+
throw new GraphQLError("Value must be a string, number, or bigint");
|
|
21
|
+
}
|
|
22
|
+
let uintVal;
|
|
23
|
+
try {
|
|
24
|
+
uintVal = BigInt(value);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
throw new GraphQLError("Value cannot be converted to BigInt");
|
|
28
|
+
}
|
|
29
|
+
if (uintVal >= size || uintVal < 0n) {
|
|
30
|
+
throw new GraphQLError(`Integer range is outside uint${bits}.`);
|
|
31
|
+
}
|
|
32
|
+
return uintVal.toString();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=generate_uint_type.js.map
|