Skip to content

Commit

Permalink
Merge branch 'main' into nvmrc
Browse files Browse the repository at this point in the history
  • Loading branch information
goastler authored Dec 13, 2023
2 parents b831354 + 2b6f214 commit 5140beb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"files.autoSave": "onFocusChange",
"vs-code-prettier-eslint.prettierLast": "true",
"vs-code-prettier-eslint.prettierLast": "false",
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true
Expand All @@ -23,7 +23,7 @@
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
15 changes: 12 additions & 3 deletions packages/provider/src/tasks/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
Hash,
PendingCaptchaRequest,
ProsopoConfigOutput,
ProviderDetails,
ProviderRegistered,
} from '@prosopo/types'
import {
Expand Down Expand Up @@ -532,12 +533,20 @@ export class Tasks {
}

/* Returns public details of provider */
async getProviderDetails(): Promise<Provider> {
return await wrapQuery(this.contract.query.getProvider, this.contract.query)(this.contract.pair.address)
async getProviderDetails(): Promise<ProviderDetails> {
const provider: Provider = await wrapQuery(
this.contract.query.getProvider,
this.contract.query
)(this.contract.pair.address)

const dbConnectionOk = await this.getCaptchaWithProof(provider.datasetId, true, 1)
.then(() => true)
.catch(() => false)

return { provider, dbConnectionOk }
}

/** Get the dataset from the databse */

async getProviderDataset(datasetId: string): Promise<DatasetWithIds> {
return await this.db.getDataset(datasetId)
}
Expand Down
6 changes: 6 additions & 0 deletions packages/types/src/provider/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { CaptchaSolutionSchema, CaptchaWithProof } from '../datasets/index.js'
import { Provider } from '@prosopo/captcha-contract/types-returns'
import { array, number, object, string, infer as zInfer } from 'zod'

export enum ApiPaths {
Expand Down Expand Up @@ -92,3 +93,8 @@ export interface PendingCaptchaRequest {
export interface ProviderRegistered {
status: 'Registered' | 'Unregistered'
}

export interface ProviderDetails {
provider: Provider
dbConnectionOk: boolean
}

0 comments on commit 5140beb

Please sign in to comment.