Skip to content

Commit

Permalink
refactor: reorder class methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyslbw committed Jan 14, 2021
1 parent 0f38056 commit 8ac4651
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions packages/api-cardano-db-hasura/src/HasuraClient.ts
Expand Up @@ -59,6 +59,36 @@ export class HasuraClient {
})
}

private async getAdaCirculatingSupply (): Promise<AssetSupply['circulating']> {
const result = await this.client.query({
query: gql`query {
utxos_aggregate {
aggregate {
sum {
value
}
}
}
}`
})
return result.data.utxos_aggregate.aggregate.sum.value
}

private async hasuraCli (command: string) {
return new Promise((resolve, reject) => {
exec(
`${this.hasuraCliPath} --skip-update-check --project ${path.resolve(__dirname, '..', 'hasura', 'project')} --endpoint ${this.hasuraUri} ${command}`,
(error, stdout) => {
if (error) {
reject(error)
}
this.logger.debug(stdout)
resolve()
}
)
})
}

public async initialize () {
this.logger.info('Initializing Hasura', { module: 'HasuraClient' })
await pRetry(async () => {
Expand Down Expand Up @@ -202,34 +232,4 @@ export class HasuraClient {
syncPercentage: (tipUtc.valueOf() / currentUtc.valueOf()) * 100
}
}

private async getAdaCirculatingSupply (): Promise<AssetSupply['circulating']> {
const result = await this.client.query({
query: gql`query {
utxos_aggregate {
aggregate {
sum {
value
}
}
}
}`
})
return result.data.utxos_aggregate.aggregate.sum.value
}

private async hasuraCli (command: string) {
return new Promise((resolve, reject) => {
exec(
`${this.hasuraCliPath} --skip-update-check --project ${path.resolve(__dirname, '..', 'hasura', 'project')} --endpoint ${this.hasuraUri} ${command}`,
(error, stdout) => {
if (error) {
reject(error)
}
this.logger.debug(stdout)
resolve()
}
)
})
}
}

0 comments on commit 8ac4651

Please sign in to comment.