@prosopo/provider 0.1.16 → 0.1.18
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/package.json +68 -69
- package/dist/api.d.ts +0 -10
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js +0 -136
- package/dist/api.js.map +0 -1
- package/dist/batch/commitments.d.ts +0 -24
- package/dist/batch/commitments.d.ts.map +0 -1
- package/dist/batch/commitments.js +0 -150
- package/dist/batch/commitments.js.map +0 -1
- package/dist/batch/index.d.ts +0 -2
- package/dist/batch/index.d.ts.map +0 -1
- package/dist/batch/index.js +0 -5
- package/dist/batch/index.js.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -21
- package/dist/index.js.map +0 -1
- package/dist/scheduler.d.ts +0 -4
- package/dist/scheduler.d.ts.map +0 -1
- package/dist/scheduler.js +0 -34
- package/dist/scheduler.js.map +0 -1
- package/dist/tasks/index.d.ts +0 -2
- package/dist/tasks/index.d.ts.map +0 -1
- package/dist/tasks/index.js +0 -18
- package/dist/tasks/index.js.map +0 -1
- package/dist/tasks/tasks.d.ts +0 -108
- package/dist/tasks/tasks.d.ts.map +0 -1
- package/dist/tasks/tasks.js +0 -405
- package/dist/tasks/tasks.js.map +0 -1
- package/dist/util.d.ts +0 -20
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -92
- package/dist/util.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,71 +1,70 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"sideEffects": false
|
|
2
|
+
"name": "@prosopo/provider",
|
|
3
|
+
"version": "0.1.18",
|
|
4
|
+
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"clean": "tsc --build --clean",
|
|
10
|
+
"build": "tsc --build --verbose",
|
|
11
|
+
"build:debug": "tsc --build --verbose",
|
|
12
|
+
"build:test": "tsc --build --verbose tsconfig.test.json",
|
|
13
|
+
"build:config": "tsc --project",
|
|
14
|
+
"mnemonic": "ts-node ./scripts/generateMnemonic.ts",
|
|
15
|
+
"coverage": "npx c8 npm run test",
|
|
16
|
+
"populate-data": "ts-node ./tests/dataUtils/populateDatabase.ts",
|
|
17
|
+
"lint": "npx eslint .",
|
|
18
|
+
"lint:fix": "npx eslint . --fix --config ../../.eslintrc.js"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@polkadot/api": "10.9.1",
|
|
22
|
+
"@polkadot/keyring": "12.3.2",
|
|
23
|
+
"@polkadot/types": "10.9.1",
|
|
24
|
+
"@polkadot/util": "12.3.2",
|
|
25
|
+
"@polkadot/util-crypto": "12.3.2",
|
|
26
|
+
"@prosopo/common": "^0.1.18",
|
|
27
|
+
"@prosopo/contract": "^0.1.18",
|
|
28
|
+
"@prosopo/database": "^0.1.18",
|
|
29
|
+
"@prosopo/datasets": "^0.1.18",
|
|
30
|
+
"@prosopo/env": "^0.1.18",
|
|
31
|
+
"@prosopo/types": "^0.1.18",
|
|
32
|
+
"@prosopo/types-database": "^0.1.18",
|
|
33
|
+
"@prosopo/types-env": "^0.1.18",
|
|
34
|
+
"cron": "^2.1.0",
|
|
35
|
+
"cron-parser": "^4.5.0",
|
|
36
|
+
"express": "^4.18.1",
|
|
37
|
+
"jsonwebtoken": "^9.0.1",
|
|
38
|
+
"nodejs-polars": "^0.6.0",
|
|
39
|
+
"yargs": "^17.5.1",
|
|
40
|
+
"yargs-parser": "^21.0.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/chai-as-promised": "^7.1.5",
|
|
44
|
+
"@types/fs-extra": "^9.0.13",
|
|
45
|
+
"@types/mocha": "^10.0.1",
|
|
46
|
+
"@types/node": "^18.0.6",
|
|
47
|
+
"@types/sinon": "^10.0.15",
|
|
48
|
+
"@types/yargs": "^17.0.10",
|
|
49
|
+
"c8": "^7.11.3",
|
|
50
|
+
"chai": "^4.3.6",
|
|
51
|
+
"chai-as-promised": "^7.1.1",
|
|
52
|
+
"fs-extra": "^10.1.0",
|
|
53
|
+
"mocha": "^10.2.0",
|
|
54
|
+
"sinon": "^15.2.0",
|
|
55
|
+
"ts-mocha": "^10.0.0",
|
|
56
|
+
"ts-node": "^10.9.1",
|
|
57
|
+
"tslib": "^2.6.2",
|
|
58
|
+
"typescript": "^5.1.6"
|
|
59
|
+
},
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "git+ssh://git@github.com/prosopo/provider.git"
|
|
63
|
+
},
|
|
64
|
+
"description": "> NOTE: The easiest way to deploy the Prosopo contract and run the Provider node is via the [integration repository](https://github.com/prosopo/captcha/). The following instructions explain how to set up the repositories manually.",
|
|
65
|
+
"bugs": {
|
|
66
|
+
"url": "https://github.com/prosopo/captcha/issues"
|
|
67
|
+
},
|
|
68
|
+
"homepage": "https://github.com/prosopo/captcha#readme",
|
|
69
|
+
"sideEffects": false
|
|
71
70
|
}
|
package/dist/api.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ProviderEnvironment } from '@prosopo/types-env';
|
|
2
|
-
import { Router } from 'express';
|
|
3
|
-
/**
|
|
4
|
-
* Returns a router connected to the database which can interact with the Proposo protocol
|
|
5
|
-
*
|
|
6
|
-
* @return {Router} - A middleware router that can interact with the Prosopo protocol
|
|
7
|
-
* @param {Environment} env - The Prosopo environment
|
|
8
|
-
*/
|
|
9
|
-
export declare function prosopoRouter(env: ProviderEnvironment): Router;
|
|
10
|
-
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAMxD,OAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEzC;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,mBAAmB,GAAG,MAAM,CAiH9D"}
|
package/dist/api.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prosopoRouter = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
// Copyright 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
-
//
|
|
7
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
// you may not use this file except in compliance with the License.
|
|
9
|
-
// You may obtain a copy of the License at
|
|
10
|
-
//
|
|
11
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
//
|
|
13
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
// See the License for the specific language governing permissions and
|
|
17
|
-
// limitations under the License.
|
|
18
|
-
const types_1 = require("@prosopo/types");
|
|
19
|
-
const types_2 = require("@prosopo/types");
|
|
20
|
-
const common_1 = require("@prosopo/common");
|
|
21
|
-
const tasks_1 = require("./tasks/tasks");
|
|
22
|
-
const util_1 = require("./util");
|
|
23
|
-
const datasets_1 = require("@prosopo/datasets");
|
|
24
|
-
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
25
|
-
const express_1 = tslib_1.__importDefault(require("express"));
|
|
26
|
-
/**
|
|
27
|
-
* Returns a router connected to the database which can interact with the Proposo protocol
|
|
28
|
-
*
|
|
29
|
-
* @return {Router} - A middleware router that can interact with the Prosopo protocol
|
|
30
|
-
* @param {Environment} env - The Prosopo environment
|
|
31
|
-
*/
|
|
32
|
-
function prosopoRouter(env) {
|
|
33
|
-
const router = express_1.default.Router();
|
|
34
|
-
const tasks = new tasks_1.Tasks(env);
|
|
35
|
-
/**
|
|
36
|
-
* Provides a Captcha puzzle to a Dapp User
|
|
37
|
-
* @param {string} datasetId - Provider datasetId
|
|
38
|
-
* @param {string} userAccount - Dapp User AccountId
|
|
39
|
-
* @param {string} blockNumber - Block number
|
|
40
|
-
* @return {Captcha} - The Captcha data
|
|
41
|
-
*/
|
|
42
|
-
router.get(`${types_1.ApiPaths.GetCaptchaChallenge}/:${types_1.ApiParams.datasetId}/:${types_1.ApiParams.user}/:${types_1.ApiParams.dapp}/:${types_1.ApiParams.blockNumber}`, async (req, res, next) => {
|
|
43
|
-
try {
|
|
44
|
-
const { blockNumber, datasetId, user, dapp } = types_2.CaptchaRequestBody.parse(req.params);
|
|
45
|
-
(0, util_crypto_1.validateAddress)(user, false, env.api.registry.chainSS58);
|
|
46
|
-
const blockNumberParsed = (0, util_1.parseBlockNumber)(blockNumber);
|
|
47
|
-
await tasks.validateProviderWasRandomlyChosen(user, dapp, datasetId, blockNumberParsed);
|
|
48
|
-
const taskData = await tasks.getRandomCaptchasAndRequestHash(datasetId, user);
|
|
49
|
-
taskData.captchas = taskData.captchas.map((cwp) => ({
|
|
50
|
-
...cwp,
|
|
51
|
-
captcha: {
|
|
52
|
-
...cwp.captcha,
|
|
53
|
-
items: cwp.captcha.items.map((item) => (0, datasets_1.parseCaptchaAssets)(item, env.assetsResolver)),
|
|
54
|
-
},
|
|
55
|
-
}));
|
|
56
|
-
return res.json(taskData);
|
|
57
|
-
}
|
|
58
|
-
catch (err) {
|
|
59
|
-
return next(new common_1.ProsopoApiError(err, undefined, 400));
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
/**
|
|
63
|
-
* Receives solved CAPTCHA challenges, store to database, and check against solution commitment
|
|
64
|
-
*
|
|
65
|
-
* @param {string} userAccount - Dapp User id
|
|
66
|
-
* @param {string} dappAccount - Dapp Contract AccountId
|
|
67
|
-
* @param {Captcha[]} captchas - The Captcha solutions
|
|
68
|
-
* @return {DappUserSolutionResult} - The Captcha solution result and proof
|
|
69
|
-
*/
|
|
70
|
-
router.post(types_1.ApiPaths.SubmitCaptchaSolution, async (req, res, next) => {
|
|
71
|
-
let parsed;
|
|
72
|
-
try {
|
|
73
|
-
parsed = types_1.CaptchaSolutionBody.parse(req.body);
|
|
74
|
-
}
|
|
75
|
-
catch (err) {
|
|
76
|
-
return next(new common_1.ProsopoApiError(err, undefined, 400));
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
const result = await tasks.dappUserSolution(parsed[types_1.ApiParams.user], parsed[types_1.ApiParams.dapp], parsed[types_1.ApiParams.requestHash], parsed[types_1.ApiParams.captchas], parsed[types_1.ApiParams.signature]);
|
|
80
|
-
return res.json({
|
|
81
|
-
status: req.i18n.t(result.solutionApproved ? 'API.CAPTCHA_PASSED' : 'API.CAPTCHA_FAILED'),
|
|
82
|
-
...result,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
return next(new common_1.ProsopoApiError(err, undefined, 400));
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
/**
|
|
90
|
-
* Verifies a user's solution as being approved or not
|
|
91
|
-
*
|
|
92
|
-
* @param {string} userAccount - Dapp User id
|
|
93
|
-
* @param {string} commitmentId - The captcha solution to look up
|
|
94
|
-
*/
|
|
95
|
-
router.post(types_1.ApiPaths.VerifyCaptchaSolution, async (req, res, next) => {
|
|
96
|
-
let parsed;
|
|
97
|
-
try {
|
|
98
|
-
parsed = types_1.VerifySolutionBody.parse(req.body);
|
|
99
|
-
}
|
|
100
|
-
catch (err) {
|
|
101
|
-
return next(new common_1.ProsopoApiError(err, undefined, 400));
|
|
102
|
-
}
|
|
103
|
-
try {
|
|
104
|
-
let solution;
|
|
105
|
-
let statusMessage = 'API.USER_NOT_VERIFIED';
|
|
106
|
-
if (!parsed.commitmentId) {
|
|
107
|
-
solution = await tasks.getDappUserCommitmentByAccount(parsed.user);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
solution = await tasks.getDappUserCommitmentById(parsed.commitmentId);
|
|
111
|
-
}
|
|
112
|
-
if (solution) {
|
|
113
|
-
let approved = false;
|
|
114
|
-
if (solution.status === types_1.CaptchaStatus.approved) {
|
|
115
|
-
statusMessage = 'API.USER_VERIFIED';
|
|
116
|
-
approved = true;
|
|
117
|
-
}
|
|
118
|
-
return res.json({
|
|
119
|
-
status: req.t(statusMessage),
|
|
120
|
-
solutionApproved: approved,
|
|
121
|
-
commitmentId: solution.id,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return res.json({
|
|
125
|
-
status: req.t(statusMessage),
|
|
126
|
-
solutionApproved: false,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
catch (err) {
|
|
130
|
-
return next(new common_1.ProsopoApiError(err, undefined, 400));
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
return router;
|
|
134
|
-
}
|
|
135
|
-
exports.prosopoRouter = prosopoRouter;
|
|
136
|
-
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;;AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,0CAQuB;AACvB,0CAAmD;AAEnD,4CAAiD;AAEjD,yCAAqC;AAErC,iCAAyC;AACzC,gDAAsD;AACtD,uDAAuD;AACvD,8DAAyC;AAEzC;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,GAAwB;IAClD,MAAM,MAAM,GAAG,iBAAO,CAAC,MAAM,EAAE,CAAA;IAC/B,MAAM,KAAK,GAAG,IAAI,aAAK,CAAC,GAAG,CAAC,CAAA;IAE5B;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,CACN,GAAG,gBAAQ,CAAC,mBAAmB,KAAK,iBAAS,CAAC,SAAS,KAAK,iBAAS,CAAC,IAAI,KAAK,iBAAS,CAAC,IAAI,KAAK,iBAAS,CAAC,WAAW,EAAE,EACzH,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACrB,IAAI;YACA,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,0BAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YAEnF,IAAA,6BAAe,EAAC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,CAAC,IAAI,CAAC,CAAA;aACrE;iBAAM;gBACH,QAAQ,GAAG,MAAM,KAAK,CAAC,yBAAyB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;aACxE;YACD,IAAI,QAAQ,EAAE;gBACV,IAAI,QAAQ,GAAG,KAAK,CAAA;gBACpB,IAAI,QAAQ,CAAC,MAAM,KAAK,qBAAa,CAAC,QAAQ,EAAE;oBAC5C,aAAa,GAAG,mBAAmB,CAAA;oBACnC,QAAQ,GAAG,IAAI,CAAA;iBAClB;gBACD,OAAO,GAAG,CAAC,IAAI,CAAC;oBACZ,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC;oBAC5B,gBAAgB,EAAE,QAAQ;oBAC1B,YAAY,EAAE,QAAQ,CAAC,EAAE;iBAC5B,CAAC,CAAA;aACL;YACD,OAAO,GAAG,CAAC,IAAI,CAAC;gBACZ,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC;gBAC5B,gBAAgB,EAAE,KAAK;aAC1B,CAAC,CAAA;SACL;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,IAAI,CAAC,IAAI,wBAAe,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAA;SACxD;IACL,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACjB,CAAC;AAjHD,sCAiHC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
|
-
import { ArgumentTypes, Commit } from '@prosopo/types';
|
|
3
|
-
import { BN } from '@polkadot/util';
|
|
4
|
-
import { BatchCommitConfig, ExtrinsicBatch } from '@prosopo/types';
|
|
5
|
-
import { Database, UserCommitmentRecord } from '@prosopo/types-database';
|
|
6
|
-
import { Logger } from '@prosopo/common';
|
|
7
|
-
import { ProsopoCaptchaContract } from '@prosopo/contract';
|
|
8
|
-
import { WeightV2 } from '@polkadot/types/interfaces';
|
|
9
|
-
export declare class BatchCommitments {
|
|
10
|
-
contract: ProsopoCaptchaContract;
|
|
11
|
-
db: Database;
|
|
12
|
-
batchCommitConfig: BatchCommitConfig;
|
|
13
|
-
logger: Logger;
|
|
14
|
-
private nonce;
|
|
15
|
-
constructor(batchCommitConfig: BatchCommitConfig, contractApi: ProsopoCaptchaContract, db: Database, concurrent: number, startNonce: bigint, logger: Logger);
|
|
16
|
-
runBatch(): Promise<void>;
|
|
17
|
-
createExtrinsics(commitments: UserCommitmentRecord[]): Promise<ExtrinsicBatch>;
|
|
18
|
-
extrinsicTooHigh(totalRefTime: BN, totalProofSize: BN, maxBlockWeight: WeightV2): boolean;
|
|
19
|
-
batchIntervalExceeded(): Promise<boolean>;
|
|
20
|
-
getCommitments(): Promise<UserCommitmentRecord[]>;
|
|
21
|
-
removeCommitmentsAndSolutions(commitmentIds: ArgumentTypes.Hash[]): Promise<void>;
|
|
22
|
-
convertCommit(commitment: UserCommitmentRecord): Commit;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=commitments.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commitments.d.ts","sourceRoot":"","sources":["../../src/batch/commitments.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAA2C,MAAM,gBAAgB,CAAA;AAC3G,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,sBAAsB,EAA0D,MAAM,mBAAmB,CAAA;AAElH,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAMrD,qBAAa,gBAAgB;IACzB,QAAQ,EAAE,sBAAsB,CAAA;IAChC,EAAE,EAAE,QAAQ,CAAA;IACZ,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,KAAK,CAAQ;gBAEjB,iBAAiB,EAAE,iBAAiB,EACpC,WAAW,EAAE,sBAAsB,EACnC,EAAE,EAAE,QAAQ,EACZ,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM;IAQZ,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAiDzB,gBAAgB,CAAC,WAAW,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAkFpF,gBAAgB,CAAC,YAAY,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,cAAc,EAAE,QAAQ,GAAG,OAAO;IAOnF,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC;IAMzC,cAAc,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAKjD,6BAA6B,CAAC,aAAa,EAAE,aAAa,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOvF,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM;CAY1D"}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BatchCommitments = void 0;
|
|
4
|
-
const util_1 = require("@polkadot/util");
|
|
5
|
-
const types_1 = require("@prosopo/types");
|
|
6
|
-
const contract_1 = require("@prosopo/contract");
|
|
7
|
-
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
8
|
-
const BN_TEN_THOUSAND = new util_1.BN(10_000);
|
|
9
|
-
const CONTRACT_METHOD_NAME = 'providerCommitMany';
|
|
10
|
-
class BatchCommitments {
|
|
11
|
-
contract;
|
|
12
|
-
db;
|
|
13
|
-
batchCommitConfig;
|
|
14
|
-
logger;
|
|
15
|
-
nonce;
|
|
16
|
-
constructor(batchCommitConfig, contractApi, db, concurrent, startNonce, logger) {
|
|
17
|
-
this.contract = contractApi;
|
|
18
|
-
this.db = db;
|
|
19
|
-
this.batchCommitConfig = batchCommitConfig;
|
|
20
|
-
this.logger = logger;
|
|
21
|
-
this.nonce = startNonce;
|
|
22
|
-
}
|
|
23
|
-
async runBatch() {
|
|
24
|
-
// create a task id
|
|
25
|
-
const taskId = (0, util_crypto_1.randomAsHex)(32);
|
|
26
|
-
if (await this.batchIntervalExceeded()) {
|
|
27
|
-
try {
|
|
28
|
-
// update last commit time
|
|
29
|
-
await this.db.storeScheduledTaskStatus(taskId, types_1.ScheduledTaskNames.BatchCommitment, types_1.ScheduledTaskStatus.Running);
|
|
30
|
-
//get commitments
|
|
31
|
-
const commitments = await this.getCommitments();
|
|
32
|
-
if (commitments.length > 0) {
|
|
33
|
-
this.logger.info(`Found ${commitments.length} commitments to commit`);
|
|
34
|
-
// get the extrinsics that are to be batched and an id associated with each one
|
|
35
|
-
const { extrinsics, ids: commitmentIds } = await this.createExtrinsics(commitments);
|
|
36
|
-
// commit and get the Ids of the commitments that were committed on-chain
|
|
37
|
-
await (0, contract_1.batch)(this.contract.contract, this.contract.pair, extrinsics, this.logger);
|
|
38
|
-
// remove commitments
|
|
39
|
-
await this.removeCommitmentsAndSolutions(commitmentIds);
|
|
40
|
-
// update last commit time and store the commitmentIds that were batched
|
|
41
|
-
await this.db.storeScheduledTaskStatus(taskId, types_1.ScheduledTaskNames.BatchCommitment, types_1.ScheduledTaskStatus.Completed, {
|
|
42
|
-
data: {
|
|
43
|
-
commitmentIds: commitments
|
|
44
|
-
.filter((commitment) => commitmentIds.indexOf(commitment.id) > -1)
|
|
45
|
-
.map((c) => c.id),
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
catch (e) {
|
|
51
|
-
this.logger.error(e);
|
|
52
|
-
await this.db.storeScheduledTaskStatus(taskId, types_1.ScheduledTaskNames.BatchCommitment, types_1.ScheduledTaskStatus.Failed, {
|
|
53
|
-
error: JSON.stringify(e && e.message ? e.message : e),
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
async createExtrinsics(commitments) {
|
|
59
|
-
const txs = [];
|
|
60
|
-
const fragment = this.contract.abi.findMessage(CONTRACT_METHOD_NAME);
|
|
61
|
-
const batchedCommitmentIds = [];
|
|
62
|
-
let totalRefTime = new util_1.BN(0);
|
|
63
|
-
let totalProofSize = new util_1.BN(0);
|
|
64
|
-
let totalFee = new util_1.BN(0);
|
|
65
|
-
const maxBlockWeight = this.contract.api.consts.system.blockWeights.maxBlock;
|
|
66
|
-
const commitmentArray = [];
|
|
67
|
-
let extrinsic;
|
|
68
|
-
for (const commitment of commitments) {
|
|
69
|
-
const commit = this.convertCommit(commitment);
|
|
70
|
-
commitmentArray.push(commit);
|
|
71
|
-
const encodedArgs = (0, contract_1.encodeStringArgs)(this.contract.abi, fragment, [commitmentArray]);
|
|
72
|
-
// TODO can we get storage deposit from the provided query method?
|
|
73
|
-
// https://matrix.to/#/!utTuYglskDvqRRMQta:matrix.org/$tELySFxCORlHCHveOknGJBx-MdVe-SxFN8_BsYvcDmI?via=matrix.org&via=t2bot.io&via=cardinal.ems.host
|
|
74
|
-
// const response = await this.contract.query.providerCommitMany(commitmentArray)
|
|
75
|
-
const buildExtrinsicResult = await this.contract.getExtrinsicAndGasEstimates('providerCommitMany', encodedArgs);
|
|
76
|
-
extrinsic = buildExtrinsicResult.extrinsic;
|
|
77
|
-
const { options, storageDeposit } = buildExtrinsicResult;
|
|
78
|
-
let paymentInfo;
|
|
79
|
-
try {
|
|
80
|
-
paymentInfo = (await extrinsic.paymentInfo(this.contract.pair)).partialFee.toBn();
|
|
81
|
-
this.logger.debug(`${CONTRACT_METHOD_NAME} paymentInfo:`, paymentInfo.toNumber());
|
|
82
|
-
}
|
|
83
|
-
catch (e) {
|
|
84
|
-
// TODO https://github.com/polkadot-js/api/issues/5504
|
|
85
|
-
paymentInfo = new util_1.BN(0);
|
|
86
|
-
}
|
|
87
|
-
//totalEncodedLength += extrinsic.encodedLength
|
|
88
|
-
totalRefTime = totalRefTime.add(this.contract.api.registry.createType('WeightV2', options.gasLimit).refTime.toBn());
|
|
89
|
-
totalProofSize = totalProofSize.add(this.contract.api.registry.createType('WeightV2', options.gasLimit).proofSize.toBn());
|
|
90
|
-
totalFee = totalFee.add(paymentInfo.add(storageDeposit.asCharge.toBn()));
|
|
91
|
-
const extrinsicTooHigh = this.extrinsicTooHigh(totalRefTime, totalProofSize, maxBlockWeight);
|
|
92
|
-
this.logger.debug('Free balance', '`', (await this.contract.api.query.system.account(this.contract.pair.address)).data.free
|
|
93
|
-
.toBn()
|
|
94
|
-
.div((0, contract_1.oneUnit)(this.contract.api))
|
|
95
|
-
.toString(), '`', 'UNIT');
|
|
96
|
-
this.logger.debug('Total Fee `', totalFee.div((0, contract_1.oneUnit)(this.contract.api)).toString(), '`', 'UNIT');
|
|
97
|
-
const feeTooHigh = totalFee.gt((await this.contract.api.query.system.account(this.contract.pair.address)).data.free.toBn());
|
|
98
|
-
// Check if we have a maximum number of transactions that we can successfully submit in a block or if the
|
|
99
|
-
// total fee is more than the provider has left in their account
|
|
100
|
-
if (extrinsicTooHigh || feeTooHigh) {
|
|
101
|
-
const msg = extrinsicTooHigh ? 'Max batch extrinsic percentage reached' : 'Fee too high';
|
|
102
|
-
this.logger.warn(msg);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
batchedCommitmentIds.push(commitment.id);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (!extrinsic) {
|
|
110
|
-
throw new contract_1.ProsopoContractError('No extrinsics created');
|
|
111
|
-
}
|
|
112
|
-
txs.push(extrinsic);
|
|
113
|
-
this.logger.info(`${txs.length} transactions will be batched`);
|
|
114
|
-
this.logger.debug('totalRefTime:', totalRefTime.toString());
|
|
115
|
-
this.logger.debug('totalProofSize:', totalProofSize.toString());
|
|
116
|
-
return { extrinsics: txs, ids: batchedCommitmentIds, totalFee, totalRefTime, totalProofSize };
|
|
117
|
-
}
|
|
118
|
-
extrinsicTooHigh(totalRefTime, totalProofSize, maxBlockWeight) {
|
|
119
|
-
return (totalRefTime.mul(BN_TEN_THOUSAND).div(maxBlockWeight.refTime.toBn()).toNumber() / 100 >
|
|
120
|
-
this.batchCommitConfig.maxBatchExtrinsicPercentage);
|
|
121
|
-
}
|
|
122
|
-
async batchIntervalExceeded() {
|
|
123
|
-
//if time since last commit > batchCommitInterval
|
|
124
|
-
const lastTime = await this.db.getLastBatchCommitTime();
|
|
125
|
-
return Date.now() - lastTime.getSeconds() > this.batchCommitConfig.interval;
|
|
126
|
-
}
|
|
127
|
-
async getCommitments() {
|
|
128
|
-
// get commitments that have already been used to generate a solution
|
|
129
|
-
return await this.db.getProcessedDappUserCommitments();
|
|
130
|
-
}
|
|
131
|
-
async removeCommitmentsAndSolutions(commitmentIds) {
|
|
132
|
-
const removeSolutionsResult = await this.db.removeProcessedDappUserSolutions(commitmentIds);
|
|
133
|
-
const removeCommitmentsResult = await this.db.removeProcessedDappUserCommitments(commitmentIds);
|
|
134
|
-
this.logger.info('Deleted user solutions', removeSolutionsResult);
|
|
135
|
-
this.logger.info('Deleted user commitments', removeCommitmentsResult);
|
|
136
|
-
}
|
|
137
|
-
convertCommit(commitment) {
|
|
138
|
-
const { processed, userSignature, requestedAt, completedAt, ...commit } = commitment;
|
|
139
|
-
return {
|
|
140
|
-
...commit,
|
|
141
|
-
userSignaturePart1: userSignature.slice(0, userSignature.length / 2),
|
|
142
|
-
userSignaturePart2: userSignature.slice(userSignature.length / 2),
|
|
143
|
-
// to satisfy typescript
|
|
144
|
-
requestedAt: new util_1.BN(requestedAt).toNumber(),
|
|
145
|
-
completedAt: new util_1.BN(completedAt).toNumber(),
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
exports.BatchCommitments = BatchCommitments;
|
|
150
|
-
//# sourceMappingURL=commitments.js.map
|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C,CAAC;YACpE,kBAAkB,EAAE,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;YACjE,wBAAwB;YACxB,WAAW,EAAE,IAAI,SAAE,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;YAC3C,WAAW,EAAE,IAAI,SAAE,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;SAC9C,CAAA;IACL,CAAC;CACJ;AA5LD,4CA4LC"}
|
package/dist/batch/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/batch/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
|
package/dist/batch/index.js
DELETED
package/dist/batch/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/batch/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA"}
|
package/dist/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
// Copyright 2021-2022 Prosopo (UK) Ltd.
|
|
5
|
-
//
|
|
6
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
// you may not use this file except in compliance with the License.
|
|
8
|
-
// You may obtain a copy of the License at
|
|
9
|
-
//
|
|
10
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
//
|
|
12
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
// See the License for the specific language governing permissions and
|
|
16
|
-
// limitations under the License.
|
|
17
|
-
tslib_1.__exportStar(require("./tasks"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./util"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./batch"), exports);
|
|
20
|
-
tslib_1.__exportStar(require("./api"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,kDAAuB;AACvB,iDAAsB;AACtB,kDAAuB;AACvB,gDAAqB"}
|
package/dist/scheduler.d.ts
DELETED
package/dist/scheduler.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAI9C,yBAA+B,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,iBActE"}
|
package/dist/scheduler.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2021-2022 Prosopo (UK) Ltd.
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
15
|
-
// [object Object]
|
|
16
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const cron_1 = require("cron");
|
|
19
|
-
const env_1 = require("@prosopo/env");
|
|
20
|
-
const tasks_1 = require("./tasks/tasks");
|
|
21
|
-
async function default_1(pair, config) {
|
|
22
|
-
const env = new env_1.ProviderEnvironment(pair, config);
|
|
23
|
-
await env.isReady();
|
|
24
|
-
const tasks = new tasks_1.Tasks(env);
|
|
25
|
-
const job = new cron_1.CronJob(process.argv[2], () => {
|
|
26
|
-
env.logger.debug('It works....');
|
|
27
|
-
tasks.calculateCaptchaSolutions().catch((err) => {
|
|
28
|
-
env.logger.error(err);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
job.start();
|
|
32
|
-
}
|
|
33
|
-
exports.default = default_1;
|
|
34
|
-
//# sourceMappingURL=scheduler.js.map
|
package/dist/scheduler.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,kBAAkB;AAClB,sCAAsC;;AAEtC,+BAA8B;AAI9B,sCAAkD;AAClD,yCAAqC;AAEtB,KAAK,oBAAW,IAAiB,EAAE,MAAqB;IACnE,MAAM,GAAG,GAAG,IAAI,yBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAEjD,MAAM,GAAG,CAAC,OAAO,EAAE,CAAA;IAEnB,MAAM,KAAK,GAAG,IAAI,aAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,MAAM,GAAG,GAAG,IAAI,cAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE;QAC1C,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QAChC,KAAK,CAAC,yBAAyB,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YAC5C,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,GAAG,CAAC,KAAK,EAAE,CAAA;AACf,CAAC;AAdD,4BAcC"}
|
package/dist/tasks/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAA"}
|