antelopeql 2.0.0-rc.13 → 2.0.0-rc.15

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.
@@ -54,19 +54,6 @@ const require_auth_type = new GraphQLObjectType({
54
54
  })
55
55
  })
56
56
  )
57
- },
58
- waits: {
59
- type: new GraphQLList(
60
- new GraphQLObjectType({
61
- name: "account_auth_waits_type",
62
- description:
63
- "specifies that a transaction will not be executed without a required delay",
64
- fields: () => ({
65
- wait_sec: { type: GraphQLInt },
66
- weight: { type: GraphQLInt }
67
- })
68
- })
69
- )
70
57
  }
71
58
  })
72
59
  });
@@ -72,9 +72,9 @@ const accounts_by_authorizers = {
72
72
  body: JSON.stringify({
73
73
  keys: await Promise.all(
74
74
  awaited_keys.map((x) =>
75
- x.startsWith(symbol)
76
- ? x
77
- : legacy_from_public_key(public_key_from_wif(x), "EOS")
75
+ x.startsWith("PUB_K1")
76
+ ? legacy_from_public_key(public_key_from_wif(x), symbol)
77
+ : x
78
78
  )
79
79
  ),
80
80
  accounts,
@@ -78,7 +78,9 @@ export default function build_graphql_fields_from_abis(abi_list) {
78
78
  const name = account_name.replace(/\./gmu, "_");
79
79
  const AST = eosio_abi_to_graphql_ast(abi);
80
80
 
81
+ // console.log(AST.variant_block_signing_authority_v0);
81
82
  ast_list[name] = AST; // For use in serializing data in mutation resolver.
83
+
82
84
  const { query_fields, mutation_fields } = get_graphql_fields_from_AST(
83
85
  AST,
84
86
  abi,
@@ -66,31 +66,26 @@ function handleStructs(structs) {
66
66
  * @returns {Object} a GraphQL AST for a given smart contract.
67
67
  */
68
68
  export function eosio_abi_to_graphql_ast(abi) {
69
- const { types, variants } = abi;
70
-
71
- let structs = [
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
- : []),
79
- ...abi.structs
80
- ];
81
-
82
- if (types?.length)
69
+ const { types, variants, structs } = abi;
70
+ const new_structs = structs;
71
+
72
+ if (variants?.length)
73
+ for (const { name, types: variant_types } of variants)
74
+ new_structs.push({
75
+ name,
76
+ base: "",
77
+ fields: variant_types.map((item) => ({ name: item, type: item + "$@" })) // @ indiacted a variant type and binary extention.
78
+ });
79
+
80
+ if (types?.length) {
83
81
  for (const { type: real_type, new_type_name } of types)
84
- structs = structs.map(({ fields, ...struct }) => ({
85
- ...struct,
86
- fields: fields.map(({ name, type }) =>
87
- type.match(new RegExp(`^${new_type_name}[?$]?([])?$`, "gmu"))
88
- ? { name, type: type.replace(new_type_name, real_type) }
89
- : { name, type }
90
- )
91
- }));
82
+ new_structs.push({
83
+ ...new_structs.find((x) => x.name == real_type),
84
+ name: new_type_name
85
+ });
86
+ }
92
87
 
93
- const structs_ast = handleStructs(structs);
88
+ const structs_ast = handleStructs(new_structs);
94
89
 
95
90
  return Object.freeze(structs_ast);
96
91
  }
@@ -127,6 +122,7 @@ export function get_graphql_fields_from_AST(AST, ABI, account_name = "") {
127
122
 
128
123
  for (const table of tables) {
129
124
  let { name: table_name, type: table_type } = table;
125
+
130
126
  table_name = table_name.replace(/\./gmu, "_");
131
127
  const table_fields = AST[table_type];
132
128
 
@@ -144,7 +140,16 @@ export function get_graphql_fields_from_AST(AST, ABI, account_name = "") {
144
140
  if (!GQL_TYPES[type])
145
141
  GQL_TYPES[type] = new GraphQLObjectType({
146
142
  name: gql_account_name + type,
147
- fields: buildQGL(AST[type])
143
+ fields: (() => {
144
+ if (AST[type]) {
145
+ // console.log(AST);
146
+ // console.log(type);
147
+ // console.log(JSON.stringify(Object.keys(AST)));
148
+ // console.log(type);
149
+ }
150
+
151
+ return buildQGL(AST[type]);
152
+ })()
148
153
  });
149
154
 
150
155
  acc = {
@@ -160,7 +165,7 @@ export function get_graphql_fields_from_AST(AST, ABI, account_name = "") {
160
165
  return acc;
161
166
  };
162
167
 
163
- if (!queryTypes[table_type])
168
+ if (!queryTypes[table_type]) {
164
169
  queryTypes[table_type] = {
165
170
  type: new GraphQLList(
166
171
  new GraphQLObjectType({
@@ -176,6 +181,7 @@ export function get_graphql_fields_from_AST(AST, ABI, account_name = "") {
176
181
  },
177
182
  resolve
178
183
  };
184
+ }
179
185
 
180
186
  query_fields[table_name] = queryTypes[table_type];
181
187
  }
@@ -21,6 +21,7 @@ An eosio symbol is an all uppercase string of 7 or less characters from [A-Z].
21
21
  throw new Error(
22
22
  "Invalid symbol format, correct format is <precision,code>"
23
23
  );
24
+
24
25
  const [precision] = symbol.split(",");
25
26
 
26
27
  if (!(precision > -1 && precision < 18))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antelopeql",
3
- "version": "2.0.0-rc.13",
3
+ "version": "2.0.0-rc.15",
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",