@verii/endpoints-event-processing 1.1.0-pre.1770078755 → 1.1.0-pre.1770080046
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 +30 -29
- package/src/controllers/health-probes/controller.js +5 -5
- package/src/entities/burned-coupons/repo.js +1 -1
- package/src/entities/purchases/repo.js +1 -1
- package/src/handlers/handle-coupons-burned-logging-event.js +2 -2
- package/src/handlers/handle-coupons-burned-verification-event.js +12 -13
- package/src/handlers/handle-coupons-minted-logging-event.js +2 -2
- package/src/handlers/handle-credential-issued-logging-event.js +2 -2
- package/src/handlers/handle-credential-issued-rewards-event.js +10 -10
- package/src/index.js +0 -1
- package/src/init-server.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verii/endpoints-event-processing",
|
|
3
|
-
"version": "1.1.0-pre.
|
|
3
|
+
"version": "1.1.0-pre.1770080046",
|
|
4
4
|
"description": "Event processing",
|
|
5
5
|
"repository": "https://github.com/LFDT-Verii/core",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"test": "cross-env NODE_ENV=test node --test --test-concurrency=1 --experimental-test-module-mocks --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout 'test/**/*.test.js'",
|
|
13
13
|
"test:ci": "NODE_ENV=test node --test --test-concurrency=1 --experimental-test-module-mocks --experimental-test-coverage --test-coverage-include='src/**' --test-reporter=spec --test-reporter=junit --test-reporter-destination=stdout --test-reporter-destination=test-results.junit.xml --test-reporter=lcov --test-reporter-destination=lcov.info 'test/**/*.test.js'",
|
|
14
|
-
"lint": "eslint
|
|
14
|
+
"lint": "eslint .",
|
|
15
15
|
"lint:ci": "eslint . --format json >> eslint-results.json",
|
|
16
|
-
"lint:fix": "eslint --fix
|
|
16
|
+
"lint:fix": "eslint --fix ."
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@fastify/autoload": "^6.0.0",
|
|
@@ -23,20 +23,20 @@
|
|
|
23
23
|
"@fastify/swagger": "^9.0.0",
|
|
24
24
|
"@fastify/swagger-ui": "^5.0.0",
|
|
25
25
|
"@spencejs/spence-mongo-repos": "~0.10.2",
|
|
26
|
-
"@verii/auth": "1.1.0-pre.
|
|
27
|
-
"@verii/aws-clients": "1.1.0-pre.
|
|
28
|
-
"@verii/base-contract-io": "1.1.0-pre.
|
|
29
|
-
"@verii/blockchain-functions": "1.1.0-pre.
|
|
30
|
-
"@verii/config": "1.1.0-pre.
|
|
31
|
-
"@verii/crypto": "1.1.0-pre.
|
|
32
|
-
"@verii/did-doc": "1.1.0-pre.
|
|
33
|
-
"@verii/endpoints-organizations-registrar": "1.1.0-pre.
|
|
34
|
-
"@verii/fastify-plugins": "1.1.0-pre.
|
|
35
|
-
"@verii/fineract-client": "1.1.0-pre.
|
|
36
|
-
"@verii/jwt": "1.1.0-pre.
|
|
37
|
-
"@verii/math": "1.1.0-pre.
|
|
38
|
-
"@verii/metadata-registration": "1.1.0-pre.
|
|
39
|
-
"@verii/spencer-mongo-extensions": "1.1.0-pre.
|
|
26
|
+
"@verii/auth": "1.1.0-pre.1770080046",
|
|
27
|
+
"@verii/aws-clients": "1.1.0-pre.1770080046",
|
|
28
|
+
"@verii/base-contract-io": "1.1.0-pre.1770080046",
|
|
29
|
+
"@verii/blockchain-functions": "1.1.0-pre.1770080046",
|
|
30
|
+
"@verii/config": "1.1.0-pre.1770080046",
|
|
31
|
+
"@verii/crypto": "1.1.0-pre.1770080046",
|
|
32
|
+
"@verii/did-doc": "1.1.0-pre.1770080046",
|
|
33
|
+
"@verii/endpoints-organizations-registrar": "1.1.0-pre.1770080046",
|
|
34
|
+
"@verii/fastify-plugins": "1.1.0-pre.1770080046",
|
|
35
|
+
"@verii/fineract-client": "1.1.0-pre.1770080046",
|
|
36
|
+
"@verii/jwt": "1.1.0-pre.1770080046",
|
|
37
|
+
"@verii/math": "1.1.0-pre.1770080046",
|
|
38
|
+
"@verii/metadata-registration": "1.1.0-pre.1770080046",
|
|
39
|
+
"@verii/spencer-mongo-extensions": "1.1.0-pre.1770080046",
|
|
40
40
|
"date-fns": "~4.1.0",
|
|
41
41
|
"env-var": "^7.0.0",
|
|
42
42
|
"fastify": "^5.0.0",
|
|
@@ -45,22 +45,23 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@spencejs/spence-factories": "0.10.2",
|
|
48
|
-
"@verii/common-functions": "1.1.0-pre.
|
|
49
|
-
"@verii/server-provider": "1.1.0-pre.
|
|
50
|
-
"@verii/tests-helpers": "1.1.0-pre.
|
|
51
|
-
"eslint": "
|
|
52
|
-
"eslint-config-airbnb-
|
|
53
|
-
"eslint-config-prettier": "
|
|
54
|
-
"eslint-plugin-autofix": "
|
|
55
|
-
"eslint-plugin-better-mutation": "1.
|
|
48
|
+
"@verii/common-functions": "1.1.0-pre.1770080046",
|
|
49
|
+
"@verii/server-provider": "1.1.0-pre.1770080046",
|
|
50
|
+
"@verii/tests-helpers": "1.1.0-pre.1770080046",
|
|
51
|
+
"eslint": "9.39.2",
|
|
52
|
+
"eslint-config-airbnb-extended": "3.0.1",
|
|
53
|
+
"eslint-config-prettier": "10.1.8",
|
|
54
|
+
"eslint-plugin-autofix": "2.2.0",
|
|
55
|
+
"eslint-plugin-better-mutation": "2.1.0",
|
|
56
56
|
"eslint-plugin-import": "2.32.0",
|
|
57
57
|
"eslint-plugin-prefer-arrow-functions": "3.9.1",
|
|
58
|
-
"eslint-plugin-prettier": "
|
|
59
|
-
"eslint-watch": "
|
|
58
|
+
"eslint-plugin-prettier": "5.5.5",
|
|
59
|
+
"eslint-watch": "8.0.0",
|
|
60
60
|
"ethers": "6.15.0",
|
|
61
61
|
"expect": "30.2.0",
|
|
62
|
+
"globals": "16.5.0",
|
|
62
63
|
"mongodb": "6.20.0",
|
|
63
|
-
"prettier": "
|
|
64
|
+
"prettier": "3.8.1"
|
|
64
65
|
},
|
|
65
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "b095afed30b67c9643860bfddec83169ef8a50b4"
|
|
66
67
|
}
|
|
@@ -54,7 +54,7 @@ const signerMetricsController = async (fastify) => {
|
|
|
54
54
|
: { status: HealthStates.Up };
|
|
55
55
|
|
|
56
56
|
return status;
|
|
57
|
-
}
|
|
57
|
+
},
|
|
58
58
|
);
|
|
59
59
|
|
|
60
60
|
fastify.get(
|
|
@@ -83,7 +83,7 @@ const signerMetricsController = async (fastify) => {
|
|
|
83
83
|
const metrics = await getSignerMetrics();
|
|
84
84
|
const nodeMetrics = flow(
|
|
85
85
|
filter((metric) => metric.address === address),
|
|
86
|
-
first
|
|
86
|
+
first,
|
|
87
87
|
)(metrics);
|
|
88
88
|
const nodesCount = metrics.length;
|
|
89
89
|
const blockNumber = await getBlockNumber();
|
|
@@ -97,8 +97,8 @@ const signerMetricsController = async (fastify) => {
|
|
|
97
97
|
fromBigNumber(
|
|
98
98
|
subtractBigNumbers(
|
|
99
99
|
toBigNumber(blockNumber),
|
|
100
|
-
toBigNumber(nodeMetrics.lastProposedBlockNumber, 16)
|
|
101
|
-
)
|
|
100
|
+
toBigNumber(nodeMetrics.lastProposedBlockNumber, 16),
|
|
101
|
+
),
|
|
102
102
|
) >
|
|
103
103
|
nodesCount * blocksDeltaMultiplier
|
|
104
104
|
? { status: HealthStates.Down }
|
|
@@ -110,7 +110,7 @@ const signerMetricsController = async (fastify) => {
|
|
|
110
110
|
});
|
|
111
111
|
|
|
112
112
|
return status;
|
|
113
|
-
}
|
|
113
|
+
},
|
|
114
114
|
);
|
|
115
115
|
};
|
|
116
116
|
|
|
@@ -11,7 +11,7 @@ const initReadEventsFromBlock = async (context) => {
|
|
|
11
11
|
contractAddress: config.couponContractAddress,
|
|
12
12
|
rpcProvider: context.rpcProvider,
|
|
13
13
|
},
|
|
14
|
-
context
|
|
14
|
+
context,
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return async (block) => {
|
|
@@ -31,7 +31,7 @@ const handleCouponsBurnedLoggingEvent = async (context) => {
|
|
|
31
31
|
log.info({ task, lastReadBlock });
|
|
32
32
|
|
|
33
33
|
const { eventsCursor, latestBlock } = await readEventsFromBlock(
|
|
34
|
-
lastReadBlock + 1
|
|
34
|
+
lastReadBlock + 1,
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
let numberOfEventsRead = 0;
|
|
@@ -15,7 +15,7 @@ const initReadEventsFromBlock = async (context) => {
|
|
|
15
15
|
contractAddress: config.couponContractAddress,
|
|
16
16
|
rpcProvider: context.rpcProvider,
|
|
17
17
|
},
|
|
18
|
-
context
|
|
18
|
+
context,
|
|
19
19
|
);
|
|
20
20
|
|
|
21
21
|
return async (block) => {
|
|
@@ -24,7 +24,7 @@ const initReadEventsFromBlock = async (context) => {
|
|
|
24
24
|
};
|
|
25
25
|
const syncBurnsWithFineract = async (
|
|
26
26
|
{ burnerDidToBundleMap, organizationsMap, burnEvents },
|
|
27
|
-
context
|
|
27
|
+
context,
|
|
28
28
|
) => {
|
|
29
29
|
const { log } = context;
|
|
30
30
|
if (burnerDidToBundleMap.size === 0) {
|
|
@@ -43,12 +43,12 @@ const syncBurnsWithFineract = async (
|
|
|
43
43
|
log.info({ task, voucherQuantitiesToBurn });
|
|
44
44
|
const batchResponses = await batchOperations(
|
|
45
45
|
{ clientVoucherBurns: voucherQuantitiesToBurn, transactionalBatch: false },
|
|
46
|
-
context
|
|
46
|
+
context,
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
for (const [payload, batchResponse] of zip(
|
|
50
50
|
voucherQuantitiesToBurn,
|
|
51
|
-
batchResponses
|
|
51
|
+
batchResponses,
|
|
52
52
|
)) {
|
|
53
53
|
if (batchResponse.statusCode >= 400)
|
|
54
54
|
log.warn({
|
|
@@ -63,7 +63,7 @@ const syncBurnsWithFineract = async (
|
|
|
63
63
|
|
|
64
64
|
const writeBurnsToDatabase = async (
|
|
65
65
|
{ burnerDidToBundleMap, organizationsMap },
|
|
66
|
-
context
|
|
66
|
+
context,
|
|
67
67
|
) => {
|
|
68
68
|
const { repos } = context;
|
|
69
69
|
if (burnerDidToBundleMap.size === 0) {
|
|
@@ -89,7 +89,7 @@ const writeBurnsToDatabase = async (
|
|
|
89
89
|
$inc: {
|
|
90
90
|
'couponBundle.used': count,
|
|
91
91
|
},
|
|
92
|
-
}
|
|
92
|
+
},
|
|
93
93
|
);
|
|
94
94
|
|
|
95
95
|
return repos.burnedCoupons.insert({
|
|
@@ -112,7 +112,7 @@ const processEventGenerator = async ({ eventsCursor }, context) => {
|
|
|
112
112
|
for await (const selectedEvents of eventsCursor()) {
|
|
113
113
|
const mappedEvents = map(
|
|
114
114
|
(evt) => mapCouponBurned(evt, context),
|
|
115
|
-
selectedEvents
|
|
115
|
+
selectedEvents,
|
|
116
116
|
);
|
|
117
117
|
burnEvents = [...burnEvents, ...mappedEvents];
|
|
118
118
|
numberOfEventsRead += selectedEvents.length;
|
|
@@ -147,9 +147,8 @@ const handleCouponsBurnedVerificationEvent = async (context) => {
|
|
|
147
147
|
const lastReadBlock = await readLastSuccessfulBlock();
|
|
148
148
|
log.info({ task, lastReadBlock });
|
|
149
149
|
const initialBlockNumber = lastReadBlock + 1;
|
|
150
|
-
const { eventsCursor, latestBlock } =
|
|
151
|
-
initialBlockNumber
|
|
152
|
-
);
|
|
150
|
+
const { eventsCursor, latestBlock } =
|
|
151
|
+
await readEventsFromBlock(initialBlockNumber);
|
|
153
152
|
|
|
154
153
|
const { numberOfEventsRead, burnEvents, burnerDidToBundleMap } =
|
|
155
154
|
await processEventGenerator({ eventsCursor }, context);
|
|
@@ -160,7 +159,7 @@ const handleCouponsBurnedVerificationEvent = async (context) => {
|
|
|
160
159
|
});
|
|
161
160
|
|
|
162
161
|
const organizations = await repos.organizations.findByDids(
|
|
163
|
-
Array.from(burnerDidToBundleMap.keys())
|
|
162
|
+
Array.from(burnerDidToBundleMap.keys()),
|
|
164
163
|
);
|
|
165
164
|
const organizationsMap = new Map();
|
|
166
165
|
for (const organization of organizations) {
|
|
@@ -172,11 +171,11 @@ const handleCouponsBurnedVerificationEvent = async (context) => {
|
|
|
172
171
|
|
|
173
172
|
await writeBurnsToDatabase(
|
|
174
173
|
{ burnerDidToBundleMap, organizationsMap },
|
|
175
|
-
context
|
|
174
|
+
context,
|
|
176
175
|
);
|
|
177
176
|
await syncBurnsWithFineract(
|
|
178
177
|
{ burnerDidToBundleMap, organizationsMap, burnEvents },
|
|
179
|
-
context
|
|
178
|
+
context,
|
|
180
179
|
);
|
|
181
180
|
|
|
182
181
|
log.info({ task, latestBlock });
|
|
@@ -27,7 +27,7 @@ const initReadEventsFromBlock = async (context) => {
|
|
|
27
27
|
contractAddress: config.couponContractAddress,
|
|
28
28
|
rpcProvider: context.rpcProvider,
|
|
29
29
|
},
|
|
30
|
-
context
|
|
30
|
+
context,
|
|
31
31
|
);
|
|
32
32
|
|
|
33
33
|
return async (block) => {
|
|
@@ -47,7 +47,7 @@ const handleCouponsMintedLoggingEvent = async (context) => {
|
|
|
47
47
|
log.info({ task, lastReadBlock });
|
|
48
48
|
|
|
49
49
|
const { eventsCursor, latestBlock } = await readEventsFromBlock(
|
|
50
|
-
lastReadBlock + 1
|
|
50
|
+
lastReadBlock + 1,
|
|
51
51
|
);
|
|
52
52
|
let numberOfEventsRead = 0;
|
|
53
53
|
for await (const events of eventsCursor()) {
|
|
@@ -26,7 +26,7 @@ const initReadEventsFromBlock = async (context) => {
|
|
|
26
26
|
contractAddress: config.metadataRegistryContractAddress,
|
|
27
27
|
rpcProvider: context.rpcProvider,
|
|
28
28
|
},
|
|
29
|
-
context
|
|
29
|
+
context,
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
return async (block) => {
|
|
@@ -46,7 +46,7 @@ const handleCredentialIssuedLoggingEvent = async (context) => {
|
|
|
46
46
|
log.info({ task, lastReadBlock });
|
|
47
47
|
|
|
48
48
|
const { eventsCursor, latestBlock } = await readEventsFromBlock(
|
|
49
|
-
lastReadBlock + 1
|
|
49
|
+
lastReadBlock + 1,
|
|
50
50
|
);
|
|
51
51
|
let numberOfEventsRead = 0;
|
|
52
52
|
for await (const events of eventsCursor()) {
|
|
@@ -26,7 +26,7 @@ const initReadEventsFromBlock = async (context) => {
|
|
|
26
26
|
contractAddress: config.metadataRegistryContractAddress,
|
|
27
27
|
rpcProvider: context.rpcProvider,
|
|
28
28
|
},
|
|
29
|
-
context
|
|
29
|
+
context,
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
return async (block) => {
|
|
@@ -35,7 +35,7 @@ const initReadEventsFromBlock = async (context) => {
|
|
|
35
35
|
};
|
|
36
36
|
const executeTransfers = async (
|
|
37
37
|
{ rewardsDictionary, organizations },
|
|
38
|
-
context
|
|
38
|
+
context,
|
|
39
39
|
) => {
|
|
40
40
|
const {
|
|
41
41
|
config: { vnfRewardDispersalAccountId },
|
|
@@ -71,7 +71,7 @@ const executeTransfers = async (
|
|
|
71
71
|
return acc;
|
|
72
72
|
},
|
|
73
73
|
[],
|
|
74
|
-
organizations
|
|
74
|
+
organizations,
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
log.info({ task, transfers });
|
|
@@ -81,7 +81,7 @@ const executeTransfers = async (
|
|
|
81
81
|
|
|
82
82
|
const eventsToOrganizationTransactions = async (
|
|
83
83
|
{ eventsCursor, credentialTypes },
|
|
84
|
-
context
|
|
84
|
+
context,
|
|
85
85
|
) => {
|
|
86
86
|
const {
|
|
87
87
|
config: { issuerRewardAmount, caoRewardAmount },
|
|
@@ -102,7 +102,7 @@ const eventsToOrganizationTransactions = async (
|
|
|
102
102
|
numberOfEventsRead += events.length;
|
|
103
103
|
const validEvents = getRewardableEvents(
|
|
104
104
|
{ events, credentialTypes },
|
|
105
|
-
context
|
|
105
|
+
context,
|
|
106
106
|
);
|
|
107
107
|
for (const { issuerKey, caoKey, issuerDid, caoDid } of validEvents) {
|
|
108
108
|
dids.push(issuerDid);
|
|
@@ -125,12 +125,12 @@ const handleCredentialIssuedRewardsEvent = async (context) => {
|
|
|
125
125
|
const lastReadBlock = await readLastSuccessfulBlock();
|
|
126
126
|
log.info({ task, lastReadBlock });
|
|
127
127
|
const { eventsCursor, latestBlock } = await readEventsFromBlock(
|
|
128
|
-
lastReadBlock + 1
|
|
128
|
+
lastReadBlock + 1,
|
|
129
129
|
);
|
|
130
130
|
const { rewardsDictionary, numberOfEventsRead, dids } =
|
|
131
131
|
await eventsToOrganizationTransactions(
|
|
132
132
|
{ eventsCursor, credentialTypes },
|
|
133
|
-
context
|
|
133
|
+
context,
|
|
134
134
|
);
|
|
135
135
|
log.info({
|
|
136
136
|
task,
|
|
@@ -143,7 +143,7 @@ const handleCredentialIssuedRewardsEvent = async (context) => {
|
|
|
143
143
|
|
|
144
144
|
const [organizations, rejectedOrganizations] = partition(
|
|
145
145
|
'ids.tokenAccountId',
|
|
146
|
-
allOrganizations
|
|
146
|
+
allOrganizations,
|
|
147
147
|
);
|
|
148
148
|
|
|
149
149
|
const rejectOrgsCounts = size(rejectedOrganizations);
|
|
@@ -163,7 +163,7 @@ const handleCredentialIssuedRewardsEvent = async (context) => {
|
|
|
163
163
|
const getRewardableEvents = ({ events, credentialTypes }, context) => {
|
|
164
164
|
const [rewardableEvents, unRewardableEvents] = flow(
|
|
165
165
|
map(mapEvent),
|
|
166
|
-
partition(isRewardedEvent(credentialTypes))
|
|
166
|
+
partition(isRewardedEvent(credentialTypes)),
|
|
167
167
|
)(events);
|
|
168
168
|
context.log.info({
|
|
169
169
|
rewardableEvents,
|
|
@@ -209,7 +209,7 @@ const getCredentialTypes = async (context) => {
|
|
|
209
209
|
credentialType2BytesHash: get2BytesHash(credentialType),
|
|
210
210
|
layer1,
|
|
211
211
|
}),
|
|
212
|
-
credentialTypes
|
|
212
|
+
credentialTypes,
|
|
213
213
|
);
|
|
214
214
|
};
|
|
215
215
|
|
package/src/index.js
CHANGED