antelopeql 2.0.0-rc.28 → 2.0.0-rc.29

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,4 +1,6 @@
1
+ import serializeName from "eosio-wasm-js/name.mjs";
1
2
  import {
3
+ GraphQLEnumType,
2
4
  GraphQLError,
3
5
  GraphQLInt,
4
6
  GraphQLList,
@@ -9,6 +11,13 @@ import {
9
11
 
10
12
  import name_type from "../eosio_types/name_type.mjs";
11
13
 
14
+ function convertNameToSymbol(scope) {
15
+ return (serializeName(scope).match(/[0-9A-Fa-f]{2}/g) || [])
16
+ .map((hex) => String.fromCharCode(parseInt(hex, 16)))
17
+ .filter((x) => !!x.charCodeAt())
18
+ .join("");
19
+ }
20
+
12
21
  const table_type = new GraphQLObjectType({
13
22
  name: "table_type",
14
23
  fields: {
@@ -17,7 +26,9 @@ const table_type = new GraphQLObjectType({
17
26
  new GraphQLObjectType({
18
27
  name: "table_rows_type",
19
28
  fields: {
20
- scope: { type: name_type },
29
+ scope: {
30
+ type: name_type
31
+ },
21
32
  table_name: { type: name_type, resolve: ({ table }) => table },
22
33
  ram_payer: {
23
34
  type: name_type,
@@ -65,11 +76,21 @@ const get_table = {
65
76
  description:
66
77
  "Filters results to return the first element that is greater than provided value in the table.",
67
78
  type: GraphQLString
79
+ },
80
+ scope_type: {
81
+ defaultValue: 0,
82
+ type: new GraphQLEnumType({
83
+ name: "scope_type",
84
+ values: {
85
+ name: { value: 0 },
86
+ symbol_code: { value: 1 }
87
+ }
88
+ })
68
89
  }
69
90
  },
70
91
  async resolve(
71
92
  root,
72
- { account_name, table_name, limit, lower_bound, upper_bound },
93
+ { account_name, table_name, limit, lower_bound, upper_bound, scope_type },
73
94
  getContext,
74
95
  info
75
96
  ) {
@@ -97,8 +118,16 @@ const get_table = {
97
118
  }).then((req) => req.json());
98
119
 
99
120
  if (data.error) throw new GraphQLError(data.message, { extensions: data });
121
+ if (!scope_type) return data;
100
122
 
101
- return data;
123
+ if (scope_type == 1)
124
+ return {
125
+ ...data,
126
+ rows: data.rows.map((x) => ({
127
+ ...x,
128
+ scope: convertNameToSymbol(x.scope)
129
+ }))
130
+ };
102
131
  }
103
132
  };
104
133
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antelopeql",
3
- "version": "2.0.0-rc.28",
3
+ "version": "2.0.0-rc.29",
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",