@prosopo/procaptcha 0.1.5 → 0.1.7
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.
- package/.eslintignore +3 -0
- package/.eslintrc.js +21 -0
- package/README.md +1 -1
- package/package.json +10 -4
- package/dist/api/AsyncFactory.d.ts +0 -7
- package/dist/api/AsyncFactory.d.ts.map +0 -1
- package/dist/api/AsyncFactory.js +0 -29
- package/dist/api/AsyncFactory.js.map +0 -1
- package/dist/api/Extension.d.ts +0 -22
- package/dist/api/Extension.d.ts.map +0 -1
- package/dist/api/Extension.js +0 -103
- package/dist/api/Extension.js.map +0 -1
- package/dist/api/HttpClientBase.d.ts +0 -9
- package/dist/api/HttpClientBase.d.ts.map +0 -1
- package/dist/api/HttpClientBase.js +0 -36
- package/dist/api/HttpClientBase.js.map +0 -1
- package/dist/api/ProsopoContract.d.ts +0 -13
- package/dist/api/ProsopoContract.d.ts.map +0 -1
- package/dist/api/ProsopoContract.js +0 -40
- package/dist/api/ProsopoContract.js.map +0 -1
- package/dist/api/ProsopoContractBase.d.ts +0 -31
- package/dist/api/ProsopoContractBase.d.ts.map +0 -1
- package/dist/api/ProsopoContractBase.js +0 -131
- package/dist/api/ProsopoContractBase.js.map +0 -1
- package/dist/api/ProviderApi.d.ts +0 -21
- package/dist/api/ProviderApi.d.ts.map +0 -1
- package/dist/api/ProviderApi.js +0 -54
- package/dist/api/ProviderApi.js.map +0 -1
- package/dist/api/handlers.d.ts +0 -5
- package/dist/api/handlers.d.ts.map +0 -1
- package/dist/api/handlers.js +0 -14
- package/dist/api/handlers.js.map +0 -1
- package/dist/api/index.d.ts +0 -7
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -25
- package/dist/api/index.js.map +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
- package/dist/modules/ProsopoCaptchaApi.d.ts +0 -16
- package/dist/modules/ProsopoCaptchaApi.d.ts.map +0 -1
- package/dist/modules/ProsopoCaptchaApi.js +0 -86
- package/dist/modules/ProsopoCaptchaApi.js.map +0 -1
- package/dist/modules/ProsopoCaptchaClient.d.ts +0 -27
- package/dist/modules/ProsopoCaptchaClient.d.ts.map +0 -1
- package/dist/modules/ProsopoCaptchaClient.js +0 -97
- package/dist/modules/ProsopoCaptchaClient.js.map +0 -1
- package/dist/modules/ProsopoCaptchaStateClient.d.ts +0 -17
- package/dist/modules/ProsopoCaptchaStateClient.d.ts.map +0 -1
- package/dist/modules/ProsopoCaptchaStateClient.js +0 -104
- package/dist/modules/ProsopoCaptchaStateClient.js.map +0 -1
- package/dist/modules/client.d.ts +0 -9
- package/dist/modules/client.d.ts.map +0 -1
- package/dist/modules/client.js +0 -40
- package/dist/modules/client.js.map +0 -1
- package/dist/modules/contract.d.ts +0 -7
- package/dist/modules/contract.d.ts.map +0 -1
- package/dist/modules/contract.js +0 -42
- package/dist/modules/contract.js.map +0 -1
- package/dist/modules/extension.d.ts +0 -3
- package/dist/modules/extension.d.ts.map +0 -1
- package/dist/modules/extension.js +0 -25
- package/dist/modules/extension.js.map +0 -1
- package/dist/modules/index.d.ts +0 -8
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/index.js +0 -26
- package/dist/modules/index.js.map +0 -1
- package/dist/modules/storage.d.ts +0 -14
- package/dist/modules/storage.d.ts.map +0 -1
- package/dist/modules/storage.js +0 -35
- package/dist/modules/storage.js.map +0 -1
- package/dist/types/api.d.ts +0 -45
- package/dist/types/api.d.ts.map +0 -1
- package/dist/types/api.js +0 -22
- package/dist/types/api.js.map +0 -1
- package/dist/types/client.d.ts +0 -60
- package/dist/types/client.d.ts.map +0 -1
- package/dist/types/client.js +0 -3
- package/dist/types/client.js.map +0 -1
- package/dist/types/contract.d.ts +0 -5
- package/dist/types/contract.d.ts.map +0 -1
- package/dist/types/contract.js +0 -3
- package/dist/types/contract.js.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -22
- package/dist/types/index.js.map +0 -1
- package/img/contracts-page.png +0 -0
- package/tsconfig.tsbuildinfo +0 -1
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": true,
|
|
4
|
+
"es2021": true
|
|
5
|
+
},
|
|
6
|
+
"extends": [
|
|
7
|
+
"eslint:recommended",
|
|
8
|
+
"plugin:@typescript-eslint/recommended"
|
|
9
|
+
],
|
|
10
|
+
"parser": "@typescript-eslint/parser",
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"ecmaVersion": "latest",
|
|
13
|
+
"sourceType": "module"
|
|
14
|
+
},
|
|
15
|
+
"plugins": [
|
|
16
|
+
"@typescript-eslint"
|
|
17
|
+
],
|
|
18
|
+
"rules": {
|
|
19
|
+
"indent": ["error", 4],
|
|
20
|
+
}
|
|
21
|
+
}
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Contains interfaces for accessing the Prosopo [protocol](https://github.com/pros
|
|
|
6
6
|
|
|
7
7
|
The Dapp smart contract account must be [registered](https://github.com/prosopo-io/protocol/blob/5cb282a911522bfbf29d34d1830badee3eecec83/contracts/lib.rs#L698-L737) in the Prosopo [protocol](https://github.com/prosopo-io/protocol/) contract in order to interact with the Prosopo protocol. You can complete Dapp registration by navigating to [polkadot-js apps](https://polkadot.js.org/apps/) and using the contracts page.
|
|
8
8
|
|
|
9
|
-

|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,23 +8,29 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "NODE_ENV=test ts-mocha \"tests/**/*.test.ts\" && exit 0",
|
|
10
10
|
"clean": "tsc --build --clean",
|
|
11
|
-
"build": "tsc --build --verbose"
|
|
11
|
+
"build": "tsc --build --verbose",
|
|
12
|
+
"lint": "npx eslint .",
|
|
13
|
+
"lint:fix": "npx eslint . --fix"
|
|
12
14
|
},
|
|
13
15
|
"dependencies": {
|
|
14
16
|
"@polkadot/api": "^8.13.1",
|
|
15
17
|
"@polkadot/api-contract": "^8.13.1",
|
|
16
18
|
"@polkadot/extension-dapp": "^0.44.1",
|
|
19
|
+
"@polkadot/extension-base": "^0.44.1",
|
|
17
20
|
"@polkadot/extension-inject": "^0.44.1",
|
|
18
21
|
"@polkadot/rpc-provider": "^8.13.1",
|
|
19
22
|
"@polkadot/types": "^8.13.1",
|
|
20
23
|
"@polkadot/util": "^10.0.2",
|
|
21
24
|
"@polkadot/util-crypto": "^10.0.2",
|
|
22
|
-
"@prosopo/contract": "0.1.
|
|
25
|
+
"@prosopo/contract": "0.1.7",
|
|
23
26
|
"axios": "^0.27.2"
|
|
24
27
|
},
|
|
25
28
|
"devDependencies": {
|
|
26
29
|
"@types/chai": "^4.3.1",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
31
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
27
32
|
"chai": "^4.3.6",
|
|
33
|
+
"eslint": "^8.20.0",
|
|
28
34
|
"mocha": "^10.0.0",
|
|
29
35
|
"ts-mocha": "^10.0.0",
|
|
30
36
|
"typescript": "^4.7.4"
|
|
@@ -40,6 +46,6 @@
|
|
|
40
46
|
"homepage": "https://github.com/prosopo-io/procaptcha#readme",
|
|
41
47
|
"description": "",
|
|
42
48
|
"publishConfig": {
|
|
43
|
-
"registry":"https://registry.npmjs.org"
|
|
49
|
+
"registry": "https://registry.npmjs.org"
|
|
44
50
|
}
|
|
45
51
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncFactory.d.ts","sourceRoot":"","sources":["../../src/api/AsyncFactory.ts"],"names":[],"mappings":"AAeA,8BAAsB,YAAY;;WAMV,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;aAIzB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAEtD;AAED,eAAe,YAAY,CAAC"}
|
package/dist/api/AsyncFactory.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsyncFactory = void 0;
|
|
4
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
5
|
-
// This file is part of procaptcha <https://github.com/prosopo-io/procaptcha>.
|
|
6
|
-
//
|
|
7
|
-
// procaptcha is free software: you can redistribute it and/or modify
|
|
8
|
-
// it under the terms of the GNU General Public License as published by
|
|
9
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
// (at your option) any later version.
|
|
11
|
-
//
|
|
12
|
-
// procaptcha is distributed in the hope that it will be useful,
|
|
13
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
// GNU General Public License for more details.
|
|
16
|
-
//
|
|
17
|
-
// You should have received a copy of the GNU General Public License
|
|
18
|
-
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
-
class AsyncFactory {
|
|
20
|
-
constructor() {
|
|
21
|
-
throw new Error("Use `create` factory method");
|
|
22
|
-
}
|
|
23
|
-
static async create(...args) {
|
|
24
|
-
return await Object.create(this.prototype).init(...args);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.AsyncFactory = AsyncFactory;
|
|
28
|
-
exports.default = AsyncFactory;
|
|
29
|
-
//# sourceMappingURL=AsyncFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncFactory.js","sourceRoot":"","sources":["../../src/api/AsyncFactory.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,8EAA8E;AAC9E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,MAAsB,YAAY;IAE9B;QACI,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACnD,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAW;QACrC,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7D,CAAC;CAIJ;AAZD,oCAYC;AAED,kBAAe,YAAY,CAAC"}
|
package/dist/api/Extension.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { InjectedAccountWithMeta, InjectedExtension } from "@polkadot/extension-inject/types";
|
|
2
|
-
import { IExtensionInterface } from "../types/client";
|
|
3
|
-
import AsyncFactory from "./AsyncFactory";
|
|
4
|
-
export declare class Extension extends AsyncFactory implements IExtensionInterface {
|
|
5
|
-
private extension;
|
|
6
|
-
private account;
|
|
7
|
-
private accounts;
|
|
8
|
-
private injectedExtensions;
|
|
9
|
-
init(): Promise<this>;
|
|
10
|
-
checkExtension(): Promise<void>;
|
|
11
|
-
getExtension(): InjectedExtension;
|
|
12
|
-
private setExtension;
|
|
13
|
-
getAccounts(): InjectedAccountWithMeta[];
|
|
14
|
-
private setAccounts;
|
|
15
|
-
getAccount(): InjectedAccountWithMeta | undefined;
|
|
16
|
-
setAccount(address: string): void;
|
|
17
|
-
unsetAccount(): void;
|
|
18
|
-
getDefaultAccount(): InjectedAccountWithMeta | undefined;
|
|
19
|
-
setDefaultAccount(): void;
|
|
20
|
-
}
|
|
21
|
-
export default Extension;
|
|
22
|
-
//# sourceMappingURL=Extension.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../src/api/Extension.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAG7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAG1C,qBAAa,SAAU,SAAQ,YAAa,YAAW,mBAAmB;IAEtE,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,kBAAkB,CAAsB;IAEnC,IAAI;IAOJ,cAAc;IAWpB,YAAY;YAIL,YAAY;IAYnB,WAAW;YAIJ,WAAW;IASlB,UAAU;IAIV,UAAU,CAAC,OAAO,EAAE,MAAM;IAY1B,YAAY;IAKZ,iBAAiB;IAKjB,iBAAiB;CAc3B;AAED,eAAe,SAAS,CAAC"}
|
package/dist/api/Extension.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Extension = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
-
// This file is part of procaptcha <https://github.com/prosopo-io/procaptcha>.
|
|
7
|
-
//
|
|
8
|
-
// procaptcha is free software: you can redistribute it and/or modify
|
|
9
|
-
// it under the terms of the GNU General Public License as published by
|
|
10
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
// (at your option) any later version.
|
|
12
|
-
//
|
|
13
|
-
// procaptcha is distributed in the hope that it will be useful,
|
|
14
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
// GNU General Public License for more details.
|
|
17
|
-
//
|
|
18
|
-
// You should have received a copy of the GNU General Public License
|
|
19
|
-
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
const extension_dapp_1 = require("@polkadot/extension-dapp");
|
|
21
|
-
const storage_1 = tslib_1.__importDefault(require("../modules/storage"));
|
|
22
|
-
const AsyncFactory_1 = tslib_1.__importDefault(require("./AsyncFactory"));
|
|
23
|
-
class Extension extends AsyncFactory_1.default {
|
|
24
|
-
extension;
|
|
25
|
-
account;
|
|
26
|
-
accounts;
|
|
27
|
-
injectedExtensions;
|
|
28
|
-
async init() {
|
|
29
|
-
await this.checkExtension();
|
|
30
|
-
await this.setAccounts();
|
|
31
|
-
await this.setExtension();
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
async checkExtension() {
|
|
35
|
-
try {
|
|
36
|
-
this.injectedExtensions = await (0, extension_dapp_1.web3Enable)('Prosopo');
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
throw new Error(err);
|
|
40
|
-
}
|
|
41
|
-
if (!this.injectedExtensions.length) {
|
|
42
|
-
throw new Error("No extension found");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
getExtension() {
|
|
46
|
-
return this.extension;
|
|
47
|
-
}
|
|
48
|
-
async setExtension() {
|
|
49
|
-
try {
|
|
50
|
-
// https://polkadot.js.org/docs/extension/cookbook/
|
|
51
|
-
this.extension = await (0, extension_dapp_1.web3FromSource)(this.accounts[0].meta.source);
|
|
52
|
-
}
|
|
53
|
-
catch (err) {
|
|
54
|
-
throw new Error(err);
|
|
55
|
-
}
|
|
56
|
-
if (!this.extension) {
|
|
57
|
-
throw new Error("Extension not found");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
getAccounts() {
|
|
61
|
-
return this.accounts;
|
|
62
|
-
}
|
|
63
|
-
async setAccounts() {
|
|
64
|
-
try {
|
|
65
|
-
this.accounts = await (0, extension_dapp_1.web3Accounts)();
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
throw new Error(err);
|
|
69
|
-
}
|
|
70
|
-
this.setDefaultAccount();
|
|
71
|
-
}
|
|
72
|
-
getAccount() {
|
|
73
|
-
return this.account;
|
|
74
|
-
}
|
|
75
|
-
setAccount(address) {
|
|
76
|
-
if (!this.accounts.length) {
|
|
77
|
-
throw new Error("No accounts found");
|
|
78
|
-
}
|
|
79
|
-
const account = this.accounts.find(acc => acc.address === address);
|
|
80
|
-
if (!account) {
|
|
81
|
-
throw new Error("Account not found");
|
|
82
|
-
}
|
|
83
|
-
this.account = account;
|
|
84
|
-
storage_1.default.setAccount(account.address);
|
|
85
|
-
}
|
|
86
|
-
unsetAccount() {
|
|
87
|
-
this.account = undefined;
|
|
88
|
-
storage_1.default.setAccount("");
|
|
89
|
-
}
|
|
90
|
-
getDefaultAccount() {
|
|
91
|
-
const defaultAccount = storage_1.default.getAccount();
|
|
92
|
-
return this.accounts.find(acc => acc.address === defaultAccount);
|
|
93
|
-
}
|
|
94
|
-
setDefaultAccount() {
|
|
95
|
-
const defaultAccount = storage_1.default.getAccount();
|
|
96
|
-
if (defaultAccount) {
|
|
97
|
-
this.setAccount(defaultAccount);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.Extension = Extension;
|
|
102
|
-
exports.default = Extension;
|
|
103
|
-
//# sourceMappingURL=Extension.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Extension.js","sourceRoot":"","sources":["../../src/api/Extension.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,8EAA8E;AAC9E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCA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C,cAAc,CAAC,CAAC;SACnC;IACL,CAAC;CASJ;AA9FD,8BA8FC;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosResponse } from "axios";
|
|
2
|
-
export declare class HttpClientBase {
|
|
3
|
-
protected readonly axios: AxiosInstance;
|
|
4
|
-
constructor(baseURL: string, prefix?: string);
|
|
5
|
-
protected responseHandler: (response: AxiosResponse) => any;
|
|
6
|
-
protected errorHandler: (error: any) => Promise<never>;
|
|
7
|
-
}
|
|
8
|
-
export default HttpClientBase;
|
|
9
|
-
//# sourceMappingURL=HttpClientBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClientBase.d.ts","sourceRoot":"","sources":["../../src/api/HttpClientBase.ts"],"names":[],"mappings":"AAeA,OAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE5D,qBAAa,cAAc;IAEzB,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;gBAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAK;IAMxC,SAAS,CAAC,eAAe,aAAc,aAAa,SAGnD;IAED,SAAS,CAAC,YAAY,UAAW,GAAG,oBAAoC;CAEzE;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpClientBase = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
-
// This file is part of procaptcha <https://github.com/prosopo-io/procaptcha>.
|
|
7
|
-
//
|
|
8
|
-
// procaptcha is free software: you can redistribute it and/or modify
|
|
9
|
-
// it under the terms of the GNU General Public License as published by
|
|
10
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
// (at your option) any later version.
|
|
12
|
-
//
|
|
13
|
-
// procaptcha is distributed in the hope that it will be useful,
|
|
14
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
// GNU General Public License for more details.
|
|
17
|
-
//
|
|
18
|
-
// You should have received a copy of the GNU General Public License
|
|
19
|
-
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
21
|
-
class HttpClientBase {
|
|
22
|
-
axios;
|
|
23
|
-
constructor(baseURL, prefix = "") {
|
|
24
|
-
baseURL = baseURL + prefix;
|
|
25
|
-
this.axios = axios_1.default.create({ baseURL });
|
|
26
|
-
this.axios.interceptors.response.use(this.responseHandler, this.errorHandler);
|
|
27
|
-
}
|
|
28
|
-
responseHandler = (response) => {
|
|
29
|
-
console.log("API REQUEST", response.request);
|
|
30
|
-
return response.data;
|
|
31
|
-
};
|
|
32
|
-
errorHandler = (error) => Promise.reject(error.response);
|
|
33
|
-
}
|
|
34
|
-
exports.HttpClientBase = HttpClientBase;
|
|
35
|
-
exports.default = HttpClientBase;
|
|
36
|
-
//# sourceMappingURL=HttpClientBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClientBase.js","sourceRoot":"","sources":["../../src/api/HttpClientBase.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,8EAA8E;AAC9E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,0DAA4D;AAE5D,MAAa,cAAc;IAEN,KAAK,CAAgB;IAExC,YAAY,OAAe,EAAE,MAAM,GAAG,EAAE;QACtC,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,eAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAChF,CAAC;IAES,eAAe,GAAG,CAAC,QAAuB,EAAE,EAAE;QACtD,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC,CAAA;IAES,YAAY,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;CAEzE;AAjBD,wCAiBC;AAED,kBAAe,cAAc,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import ProsopoContractBase from "./ProsopoContractBase";
|
|
2
|
-
import { Signer } from '@polkadot/api/types';
|
|
3
|
-
import { ProsopoDappOperatorIsHumanUserResponse, TransactionResponse } from '../types';
|
|
4
|
-
import { ProsopoRandomProviderResponse } from "../types";
|
|
5
|
-
import { CaptchaSolutionCommitment } from "@prosopo/contract";
|
|
6
|
-
export declare class ProsopoContract extends ProsopoContractBase {
|
|
7
|
-
getRandomProvider(): Promise<ProsopoRandomProviderResponse>;
|
|
8
|
-
getCaptchaSolutionCommitment(commitmentId: string): Promise<CaptchaSolutionCommitment>;
|
|
9
|
-
dappUserCommit(signer: Signer, captchaDatasetId: string, userMerkleTreeRoot: string, providerAddress: string): Promise<TransactionResponse>;
|
|
10
|
-
dappOperatorIsHumanUser(threshold: number): Promise<ProsopoDappOperatorIsHumanUserResponse>;
|
|
11
|
-
}
|
|
12
|
-
export default ProsopoContract;
|
|
13
|
-
//# sourceMappingURL=ProsopoContract.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProsopoContract.d.ts","sourceRoot":"","sources":["../../src/api/ProsopoContract.ts"],"names":[],"mappings":"AAgBA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,sCAAsC,EAAE,mBAAmB,EAAC,MAAM,UAAU,CAAC;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAG9D,qBAAa,eAAgB,SAAQ,mBAAmB;IAEvC,iBAAiB,IAAI,OAAO,CAAC,6BAA6B,CAAC;IAI3D,4BAA4B,CAAC,YAAY,EAAE,MAAM;IAIjD,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI3I,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,sCAAsC,CAAC;CAO3G;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProsopoContract = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
-
// This file is part of procaptcha <https://github.com/prosopo-io/procaptcha>.
|
|
7
|
-
//
|
|
8
|
-
// procaptcha is free software: you can redistribute it and/or modify
|
|
9
|
-
// it under the terms of the GNU General Public License as published by
|
|
10
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
// (at your option) any later version.
|
|
12
|
-
//
|
|
13
|
-
// procaptcha is distributed in the hope that it will be useful,
|
|
14
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
// GNU General Public License for more details.
|
|
17
|
-
//
|
|
18
|
-
// You should have received a copy of the GNU General Public License
|
|
19
|
-
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
// import {Hash} from '@polkadot/types/interfaces';
|
|
21
|
-
const ProsopoContractBase_1 = tslib_1.__importDefault(require("./ProsopoContractBase"));
|
|
22
|
-
// TODO: import return types from provider: separate types/common package.
|
|
23
|
-
class ProsopoContract extends ProsopoContractBase_1.default {
|
|
24
|
-
async getRandomProvider() {
|
|
25
|
-
return await this.query('getRandomActiveProvider', [this.account.address, this.dappAddress]);
|
|
26
|
-
}
|
|
27
|
-
async getCaptchaSolutionCommitment(commitmentId) {
|
|
28
|
-
return await this.query('getCaptchaSolutionCommitment', [commitmentId]);
|
|
29
|
-
}
|
|
30
|
-
async dappUserCommit(signer, captchaDatasetId, userMerkleTreeRoot, providerAddress) {
|
|
31
|
-
return await this.transaction(signer, 'dappUserCommit', [this.dappAddress, captchaDatasetId, userMerkleTreeRoot, providerAddress]);
|
|
32
|
-
}
|
|
33
|
-
async dappOperatorIsHumanUser(threshold) {
|
|
34
|
-
// TODO get threshold from dapp contract using getStorage or allow override in UI and fallback on contract protection layer?
|
|
35
|
-
return await this.query('dappOperatorIsHumanUser', [this.account.address, threshold]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.ProsopoContract = ProsopoContract;
|
|
39
|
-
exports.default = ProsopoContract;
|
|
40
|
-
//# sourceMappingURL=ProsopoContract.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProsopoContract.js","sourceRoot":"","sources":["../../src/api/ProsopoContract.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,8EAA8E;AAC9E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,mDAAmD;AACnD,wFAAwD;AAMxD,0EAA0E;AAC1E,MAAa,eAAgB,SAAQ,6BAAmB;IAE7C,KAAK,CAAC,iBAAiB;QAC1B,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAkC,CAAC;IAClI,CAAC;IAEM,KAAK,CAAC,4BAA4B,CAAC,YAAoB;QAC1D,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,8BAA8B,EAAE,CAAC,YAAY,CAAC,CAA8B,CAAC;IACzG,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,MAAc,EAAE,gBAAwB,EAAE,kBAA0B,EAAE,eAAuB;QACrH,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAC,CAAC;IACvI,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAAC,SAAiB;QAClD,4HAA4H;QAC5H,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAA2C,CAAC;IACpI,CAAC;CAIJ;AArBD,0CAqBC;AAED,kBAAe,eAAe,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ApiPromise } from "@polkadot/api";
|
|
2
|
-
import { Abi, ContractPromise } from "@polkadot/api-contract";
|
|
3
|
-
import { InjectedAccountWithMeta } from "@polkadot/extension-inject/types";
|
|
4
|
-
import { AnyJson } from "@polkadot/types/types/codec";
|
|
5
|
-
import { ProviderInterface } from "@polkadot/rpc-provider/types";
|
|
6
|
-
import { Signer } from "@polkadot/api/types";
|
|
7
|
-
import { TransactionResponse } from '../types';
|
|
8
|
-
import AsyncFactory from "./AsyncFactory";
|
|
9
|
-
export declare class ProsopoContractBase extends AsyncFactory {
|
|
10
|
-
protected api: ApiPromise;
|
|
11
|
-
protected abi: Abi;
|
|
12
|
-
protected contract: ContractPromise;
|
|
13
|
-
protected account: InjectedAccountWithMeta;
|
|
14
|
-
protected dappAddress: string;
|
|
15
|
-
address: string;
|
|
16
|
-
/**
|
|
17
|
-
* @param address
|
|
18
|
-
* @param dappAddress
|
|
19
|
-
* @param account
|
|
20
|
-
* @param providerInterface
|
|
21
|
-
*/
|
|
22
|
-
init(address: string, dappAddress: string, account: InjectedAccountWithMeta, providerInterface: ProviderInterface): Promise<this>;
|
|
23
|
-
getApi(): ApiPromise;
|
|
24
|
-
getContract(): ContractPromise;
|
|
25
|
-
getAccount(): InjectedAccountWithMeta;
|
|
26
|
-
getDappAddress(): string;
|
|
27
|
-
query<T>(method: string, args: any[]): Promise<T | AnyJson | null>;
|
|
28
|
-
transaction(signer: Signer, method: string, args: any[]): Promise<TransactionResponse>;
|
|
29
|
-
}
|
|
30
|
-
export default ProsopoContractBase;
|
|
31
|
-
//# sourceMappingURL=ProsopoContractBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProsopoContractBase.d.ts","sourceRoot":"","sources":["../../src/api/ProsopoContractBase.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAqB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAG3E,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,YAAY;IAEnD,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC;IAC1B,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IACnB,SAAS,CAAC,QAAQ,EAAE,eAAe,CAAC;IACpC,SAAS,CAAC,OAAO,EAAE,uBAAuB,CAAC;IAC3C,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;IAEvB,OAAO,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;IACU,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,iBAAiB;IAUvH,MAAM,IAAI,UAAU;IAIpB,WAAW,IAAI,eAAe;IAI9B,UAAU,IAAI,uBAAuB;IAIrC,cAAc,IAAI,MAAM;IAIlB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;IA0BlE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAwEpG;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProsopoContractBase = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
-
// This file is part of procaptcha <https://github.com/prosopo-io/procaptcha>.
|
|
7
|
-
//
|
|
8
|
-
// procaptcha is free software: you can redistribute it and/or modify
|
|
9
|
-
// it under the terms of the GNU General Public License as published by
|
|
10
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
// (at your option) any later version.
|
|
12
|
-
//
|
|
13
|
-
// procaptcha is distributed in the hope that it will be useful,
|
|
14
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
// GNU General Public License for more details.
|
|
17
|
-
//
|
|
18
|
-
// You should have received a copy of the GNU General Public License
|
|
19
|
-
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
const api_1 = require("@polkadot/api");
|
|
21
|
-
const api_contract_1 = require("@polkadot/api-contract");
|
|
22
|
-
const contract_1 = require("@prosopo/contract");
|
|
23
|
-
const AsyncFactory_1 = tslib_1.__importDefault(require("./AsyncFactory"));
|
|
24
|
-
class ProsopoContractBase extends AsyncFactory_1.default {
|
|
25
|
-
api;
|
|
26
|
-
abi;
|
|
27
|
-
contract;
|
|
28
|
-
account;
|
|
29
|
-
dappAddress;
|
|
30
|
-
address;
|
|
31
|
-
/**
|
|
32
|
-
* @param address
|
|
33
|
-
* @param dappAddress
|
|
34
|
-
* @param account
|
|
35
|
-
* @param providerInterface
|
|
36
|
-
*/
|
|
37
|
-
async init(address, dappAddress, account, providerInterface) {
|
|
38
|
-
this.api = await api_1.ApiPromise.create({ provider: providerInterface });
|
|
39
|
-
this.abi = new api_contract_1.Abi(contract_1.abiJson, this.api.registry.getChainProperties());
|
|
40
|
-
this.contract = new api_contract_1.ContractPromise(this.api, this.abi, address);
|
|
41
|
-
this.address = address;
|
|
42
|
-
this.dappAddress = dappAddress;
|
|
43
|
-
this.account = account;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
getApi() {
|
|
47
|
-
return this.api;
|
|
48
|
-
}
|
|
49
|
-
getContract() {
|
|
50
|
-
return this.contract;
|
|
51
|
-
}
|
|
52
|
-
getAccount() {
|
|
53
|
-
return this.account;
|
|
54
|
-
}
|
|
55
|
-
getDappAddress() {
|
|
56
|
-
return this.dappAddress;
|
|
57
|
-
}
|
|
58
|
-
async query(method, args) {
|
|
59
|
-
try {
|
|
60
|
-
const abiMessage = this.abi.findMessage(method);
|
|
61
|
-
const response = await this.contract.query[method](this.account.address, {}, ...(0, contract_1.encodeStringArgs)(abiMessage, args));
|
|
62
|
-
console.log("QUERY RESPONSE", method, args, response);
|
|
63
|
-
if (response.result.isOk) {
|
|
64
|
-
if (response.output) {
|
|
65
|
-
return (0, contract_1.unwrap)(response.output.toHuman());
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
throw new contract_1.ProsopoContractError(response.result.asErr);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
console.error("ERROR", e);
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// https://polkadot.js.org/docs/api/cookbook/tx/
|
|
81
|
-
// https://polkadot.js.org/docs/api/start/api.tx.subs/
|
|
82
|
-
async transaction(signer, method, args) {
|
|
83
|
-
// TODO if DEBUG==true || env.development
|
|
84
|
-
const queryBeforeTx = await this.query(method, args);
|
|
85
|
-
console.log("QUERY BEFORE TX....................", queryBeforeTx);
|
|
86
|
-
const abiMessage = this.abi.findMessage(method);
|
|
87
|
-
const extrinsic = this.contract.tx[method]({}, ...(0, contract_1.encodeStringArgs)(abiMessage, args));
|
|
88
|
-
// this.api.setSigner(signer);
|
|
89
|
-
// const response = await buildTx(this.api.registry, extrinsic, this.account.address, { signer });
|
|
90
|
-
// console.log("buildTx RESPONSE", response);
|
|
91
|
-
// return;
|
|
92
|
-
return new Promise((resolve, reject) => {
|
|
93
|
-
extrinsic.signAndSend(this.account.address, { signer }, (result) => {
|
|
94
|
-
const { dispatchError, dispatchInfo, events, internalError, status, txHash, txIndex } = result;
|
|
95
|
-
console.log("TX STATUS", status.type);
|
|
96
|
-
console.log("IS FINALIZED", status?.isFinalized);
|
|
97
|
-
console.log("IN BLOCK", status?.isInBlock);
|
|
98
|
-
console.log("EVENTS", events);
|
|
99
|
-
if (internalError) {
|
|
100
|
-
console.error("internalError", internalError);
|
|
101
|
-
reject(internalError);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (dispatchError) {
|
|
105
|
-
console.error("dispatchError", dispatchError);
|
|
106
|
-
reject(dispatchError);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
// [Ready, InBlock, Finalized...]
|
|
110
|
-
// Instant seal ON.
|
|
111
|
-
if (status?.isInBlock) {
|
|
112
|
-
const blockHash = status.asInBlock.toHex();
|
|
113
|
-
resolve({ dispatchError, dispatchInfo, events, internalError, status, txHash, txIndex, blockHash });
|
|
114
|
-
}
|
|
115
|
-
// TODO
|
|
116
|
-
// Instant seal OFF.
|
|
117
|
-
// if (status?.isFinalized) {
|
|
118
|
-
// const blockHash = status.asFinalized.toHex();
|
|
119
|
-
// resolve({ dispatchError, dispatchInfo, events, internalError, status, txHash, txIndex, blockHash });
|
|
120
|
-
// }
|
|
121
|
-
})
|
|
122
|
-
.catch((e) => {
|
|
123
|
-
console.error("signAndSend ERROR", e);
|
|
124
|
-
reject(e);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
exports.ProsopoContractBase = ProsopoContractBase;
|
|
130
|
-
exports.default = ProsopoContractBase;
|
|
131
|
-
//# sourceMappingURL=ProsopoContractBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProsopoContractBase.js","sourceRoot":"","sources":["../../src/api/ProsopoContractBase.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,8EAA8E;AAC9E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF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DAAkD;gBAElD,yGAAyG;gBAEzG,IAAI;YAEN,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACX,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;gBACtC,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;QAEL,CAAC,CAAC,CAAC;IAEL,CAAC;CAEF;AA5ID,kDA4IC;AAED,kBAAe,mBAAmB,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import HttpClientBase from "./HttpClientBase";
|
|
2
|
-
import { ProsopoCaptchaConfig, ProsopoRandomProviderResponse, GetCaptchaResponse, CaptchaSolution, CaptchaSolutionResponse } from '../types';
|
|
3
|
-
export declare class ProviderApi extends HttpClientBase {
|
|
4
|
-
protected config: ProsopoCaptchaConfig;
|
|
5
|
-
constructor(config: ProsopoCaptchaConfig);
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @deprecated use ProsopoContract$getRandomProvider instead.
|
|
9
|
-
*/
|
|
10
|
-
getRandomProvider(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
11
|
-
getProviders(): Promise<{
|
|
12
|
-
accounts: string[];
|
|
13
|
-
}>;
|
|
14
|
-
getContractAddress(): Promise<{
|
|
15
|
-
contractAddress: string;
|
|
16
|
-
}>;
|
|
17
|
-
getCaptchaChallenge(randomProvider: ProsopoRandomProviderResponse): Promise<GetCaptchaResponse>;
|
|
18
|
-
submitCaptchaSolution(blockHash: string, captchas: CaptchaSolution[], requestHash: string, txHash: string, userAccount: string): Promise<CaptchaSolutionResponse>;
|
|
19
|
-
}
|
|
20
|
-
export default ProviderApi;
|
|
21
|
-
//# sourceMappingURL=ProviderApi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProviderApi.d.ts","sourceRoot":"","sources":["../../src/api/ProviderApi.ts"],"names":[],"mappings":"AAeA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,kBAAkB,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAE7I,qBAAa,WAAY,SAAQ,cAAc;IAE7C,SAAS,CAAC,MAAM,EAAE,oBAAoB,CAAC;gBAE3B,MAAM,EAAE,oBAAoB;IAKxC;;;OAGG;IACI,iBAAiB;IAKjB,YAAY,IAAI,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAC,CAAC;IAI7C,kBAAkB,IAAI,OAAO,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAC,CAAC;IAIxD,mBAAmB,CAAC,cAAc,EAAE,6BAA6B,GAAI,OAAO,CAAC,kBAAkB,CAAC;IAOhG,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAI,OAAO,CAAC,uBAAuB,CAAC;CAI1K;AAED,eAAe,WAAW,CAAC"}
|