Skip to content

Commit

Permalink
w3sper: Add query { ... } to argument given to network.query
Browse files Browse the repository at this point in the history
- Remove unused private functions from network module
  • Loading branch information
ZER0 committed Nov 22, 2024
1 parent ad0ef94 commit c69d623
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions w3sper.js/src/network/mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ export { AddressSyncer } from "./syncer/address.js";
export { AccountSyncer } from "./syncer/account.js";
export { Bookmark } from "./bookmark.js";

const abortable = (signal) =>
new Promise((resolve, reject) =>
signal?.aborted ? reject(signal.reason) : resolve(signal),
);

const once = (target, topic) =>
new Promise((resolve) =>
target.addEventListener(topic, resolve, { once: true }),
);

export class Network {
#rues;
node;
Expand Down Expand Up @@ -81,8 +71,8 @@ export class Network {
// I suspect is a GraphQL limitation. In the meantime we convert the `Number`
// to a `BigInt` for consistency and future proof of the API's consumers.
get blockHeight() {
return this.query("query { block(height: -1) { header { height } }}").then(
(body) => BigInt(body?.block?.header?.height ?? 0),
return this.query("block(height: -1) { header { height } }").then((body) =>
BigInt(body?.block?.header?.height ?? 0),
);
}

Expand Down Expand Up @@ -110,6 +100,8 @@ export class Network {
}

async query(gql, options = {}) {
gql = gql ? `query { ${gql} }` : "";

const response = await this.#rues.scope("graphql").call.query(gql, options);

switch (response.status) {
Expand Down

0 comments on commit c69d623

Please sign in to comment.