Skip to content

Commit 86a78e4

Browse files
authored
Fix/release 20260115 (#3739)
1 parent 7fe4d54 commit 86a78e4

34 files changed

Lines changed: 2508 additions & 2529 deletions

File tree

.changeset/empty-streets-wait.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@human-protocol/sdk": major
3+
"@human-protocol/python-sdk": major
4+
---
5+
6+
- Replace statistics client by utils
7+
- Delete agreement module

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ HUMAN is a permissionless protocol to facilitate the exchange of HUMAN work, kno
2525

2626
### Documentation
2727

28-
For a more detailed description of the HUMAN Protocol architecture and vision see [here](https://tech-docs.humanprotocol.org/)
28+
For a more detailed description of the HUMAN Protocol architecture and vision see [here](https://docs.humanprotocol.org/)
2929

3030
### Description
3131

@@ -59,7 +59,7 @@ The contribution guidelines are as per the CONTRIBUTING.MD file.
5959
│ │ │ ├── subgraph # Human Protocol Subgraph
6060
```
6161
### Smart contracts
62-
To access comprehensive information about the smart contracts, please visit the following URL: https://tech-docs.humanprotocol.org/contracts. This resource provides detailed documentation that covers various aspects of the smart contracts used within the Human Protocol ecosystem.
62+
To access comprehensive information about the smart contracts, please visit the following URL: https://docs.humanprotocol.org/architecture/contracts/escrow.sol. This resource provides detailed documentation that covers various aspects of the smart contracts used within the Human Protocol ecosystem.
6363

6464
### How To Use This Repo
6565

packages/apps/dashboard/client/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ VITE_NAVBAR_LINK_LAUNCH_JOBS=https://job-launcher.humanprotocol.org/
1010
VITE_NAVBAR_LINK_WORK_AND_EARN=https://app.humanprotocol.org/
1111

1212
# Link to button on 'Role details' page
13-
VITE_HUMANPROTOCOL_CORE_ARCHITECTURE=https://docs.humanprotocol.org/hub/human-tech-docs/architecture
13+
VITE_HUMANPROTOCOL_CORE_ARCHITECTURE=https://docs.humanprotocol.org/architecture/overview/
1414

1515
# Links to footer socials
1616
VITE_FOOTER_LINK_GITHUB=https://github.com/humanprotocol/human-protocol

packages/apps/dashboard/server/src/modules/networks/networks.service.spec.ts

Lines changed: 92 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createMock } from '@golevelup/ts-jest';
2-
import { NETWORKS, StatisticsClient } from '@human-protocol/sdk';
2+
import { NETWORKS, StatisticsUtils } from '@human-protocol/sdk';
33
import { HttpService } from '@nestjs/axios';
44
import { CACHE_MANAGER } from '@nestjs/cache-manager';
55
import { ConfigService } from '@nestjs/config';
@@ -10,11 +10,6 @@ import { NetworkConfigService } from '../../common/config/network-config.service
1010
import { DevelopmentChainId } from '../../common/constants';
1111
import { NetworksService } from './networks.service';
1212

13-
jest.mock('@human-protocol/sdk', () => ({
14-
...jest.requireActual('@human-protocol/sdk'),
15-
StatisticsClient: jest.fn(),
16-
}));
17-
1813
describe('NetworksService', () => {
1914
let networksService: NetworksService;
2015
let cacheManager: Cache;
@@ -53,6 +48,10 @@ describe('NetworksService', () => {
5348
cacheManager = module.get<Cache>(CACHE_MANAGER);
5449
});
5550

51+
afterEach(() => {
52+
jest.restoreAllMocks();
53+
});
54+
5655
it('should regenerate network list when cache TTL expires', async () => {
5756
const mockNetworkList = [
5857
DevelopmentChainId.SEPOLIA,
@@ -64,15 +63,18 @@ describe('NetworksService', () => {
6463
jest.spyOn(cacheManager, 'get').mockResolvedValue(null);
6564
jest.spyOn(cacheManager, 'set').mockResolvedValue(undefined);
6665

67-
const mockStatisticsClient = {
68-
getHMTDailyData: jest
69-
.fn()
70-
.mockResolvedValue([{ totalTransactionCount: 7 }]),
71-
getEscrowStatistics: jest.fn().mockResolvedValue({ totalEscrows: 1 }),
72-
};
73-
(StatisticsClient as jest.Mock).mockImplementation(
74-
() => mockStatisticsClient,
75-
);
66+
jest.spyOn(StatisticsUtils, 'getHMTDailyData').mockResolvedValue([
67+
{
68+
timestamp: 0,
69+
totalTransactionCount: 7,
70+
totalTransactionAmount: 0n,
71+
dailyUniqueSenders: 0,
72+
dailyUniqueReceivers: 0,
73+
},
74+
]);
75+
jest
76+
.spyOn(StatisticsUtils, 'getEscrowStatistics')
77+
.mockResolvedValue({ totalEscrows: 1, dailyEscrowsData: [] });
7678

7779
// First call should populate cache
7880
const firstCallResult = await networksService.getOperatingNetworks();
@@ -113,18 +115,25 @@ describe('NetworksService', () => {
113115

114116
it('should fetch and filter available networks correctly', async () => {
115117
jest.spyOn(cacheManager, 'get').mockResolvedValue(null);
116-
const mockStatisticsClient = {
117-
getHMTDailyData: jest
118-
.fn()
119-
.mockResolvedValue([
120-
{ totalTransactionCount: 4 },
121-
{ totalTransactionCount: 3 },
122-
]),
123-
getEscrowStatistics: jest.fn().mockResolvedValue({ totalEscrows: 1 }),
124-
};
125-
(StatisticsClient as jest.Mock).mockImplementation(
126-
() => mockStatisticsClient,
127-
);
118+
jest.spyOn(StatisticsUtils, 'getHMTDailyData').mockResolvedValue([
119+
{
120+
timestamp: 0,
121+
totalTransactionCount: 4,
122+
totalTransactionAmount: 0n,
123+
dailyUniqueSenders: 0,
124+
dailyUniqueReceivers: 0,
125+
},
126+
{
127+
timestamp: 0,
128+
totalTransactionCount: 3,
129+
totalTransactionAmount: 0n,
130+
dailyUniqueSenders: 0,
131+
dailyUniqueReceivers: 0,
132+
},
133+
]);
134+
jest
135+
.spyOn(StatisticsUtils, 'getEscrowStatistics')
136+
.mockResolvedValue({ totalEscrows: 1, dailyEscrowsData: [] });
128137

129138
const result = await networksService.getOperatingNetworks();
130139
expect(result).toEqual(
@@ -143,15 +152,18 @@ describe('NetworksService', () => {
143152

144153
it('should exclude networks without sufficient HMT transfers', async () => {
145154
jest.spyOn(cacheManager, 'get').mockResolvedValue(null);
146-
const mockStatisticsClient = {
147-
getHMTDailyData: jest
148-
.fn()
149-
.mockResolvedValue([{ totalTransactionCount: 2 }]),
150-
getEscrowStatistics: jest.fn().mockResolvedValue({ totalEscrows: 1 }),
151-
};
152-
(StatisticsClient as jest.Mock).mockImplementation(
153-
() => mockStatisticsClient,
154-
);
155+
jest.spyOn(StatisticsUtils, 'getHMTDailyData').mockResolvedValue([
156+
{
157+
timestamp: 0,
158+
totalTransactionCount: 2,
159+
totalTransactionAmount: 0n,
160+
dailyUniqueSenders: 0,
161+
dailyUniqueReceivers: 0,
162+
},
163+
]);
164+
jest
165+
.spyOn(StatisticsUtils, 'getEscrowStatistics')
166+
.mockResolvedValue({ totalEscrows: 1, dailyEscrowsData: [] });
155167

156168
const result = await networksService.getOperatingNetworks();
157169
expect(result).toEqual([]);
@@ -163,18 +175,25 @@ describe('NetworksService', () => {
163175
const originalNetworkConfig = NETWORKS[DevelopmentChainId.SEPOLIA];
164176
NETWORKS[DevelopmentChainId.SEPOLIA] = undefined;
165177

166-
const mockStatisticsClient = {
167-
getHMTDailyData: jest
168-
.fn()
169-
.mockResolvedValue([
170-
{ totalTransactionCount: 3 },
171-
{ totalTransactionCount: 3 },
172-
]),
173-
getEscrowStatistics: jest.fn().mockResolvedValue({ totalEscrows: 1 }),
174-
};
175-
(StatisticsClient as jest.Mock).mockImplementation(
176-
() => mockStatisticsClient,
177-
);
178+
jest.spyOn(StatisticsUtils, 'getHMTDailyData').mockResolvedValue([
179+
{
180+
timestamp: 0,
181+
totalTransactionCount: 3,
182+
totalTransactionAmount: 0n,
183+
dailyUniqueSenders: 0,
184+
dailyUniqueReceivers: 0,
185+
},
186+
{
187+
timestamp: 0,
188+
totalTransactionCount: 3,
189+
totalTransactionAmount: 0n,
190+
dailyUniqueSenders: 0,
191+
dailyUniqueReceivers: 0,
192+
},
193+
]);
194+
jest
195+
.spyOn(StatisticsUtils, 'getEscrowStatistics')
196+
.mockResolvedValue({ totalEscrows: 1, dailyEscrowsData: [] });
178197

179198
const result = await networksService.getOperatingNetworks();
180199

@@ -186,36 +205,38 @@ describe('NetworksService', () => {
186205

187206
it('should handle errors in getHMTDailyData gracefully', async () => {
188207
jest.spyOn(cacheManager, 'get').mockResolvedValue(null);
189-
const mockStatisticsClient = {
190-
getHMTDailyData: jest
191-
.fn()
192-
.mockRejectedValue(new Error('Failed to fetch HMT data')),
193-
getEscrowStatistics: jest.fn().mockResolvedValue({ totalEscrows: 1 }),
194-
};
195-
(StatisticsClient as jest.Mock).mockImplementation(
196-
() => mockStatisticsClient,
197-
);
208+
jest
209+
.spyOn(StatisticsUtils, 'getHMTDailyData')
210+
.mockRejectedValue(new Error('Failed to fetch HMT data'));
211+
jest
212+
.spyOn(StatisticsUtils, 'getEscrowStatistics')
213+
.mockResolvedValue({ totalEscrows: 1, dailyEscrowsData: [] });
198214

199215
const result = await networksService.getOperatingNetworks();
200216
expect(result).toEqual([]);
201217
});
202218

203219
it('should handle errors in getEscrowStatistics gracefully', async () => {
204220
jest.spyOn(cacheManager, 'get').mockResolvedValue(null);
205-
const mockStatisticsClient = {
206-
getHMTDailyData: jest
207-
.fn()
208-
.mockResolvedValue([
209-
{ totalTransactionCount: 3 },
210-
{ totalTransactionCount: 2 },
211-
]),
212-
getEscrowStatistics: jest
213-
.fn()
214-
.mockRejectedValue(new Error('Failed to fetch escrow stats')),
215-
};
216-
(StatisticsClient as jest.Mock).mockImplementation(
217-
() => mockStatisticsClient,
218-
);
221+
jest.spyOn(StatisticsUtils, 'getHMTDailyData').mockResolvedValue([
222+
{
223+
timestamp: 0,
224+
totalTransactionCount: 3,
225+
totalTransactionAmount: 0n,
226+
dailyUniqueSenders: 0,
227+
dailyUniqueReceivers: 0,
228+
},
229+
{
230+
timestamp: 0,
231+
totalTransactionCount: 2,
232+
totalTransactionAmount: 0n,
233+
dailyUniqueSenders: 0,
234+
dailyUniqueReceivers: 0,
235+
},
236+
]);
237+
jest
238+
.spyOn(StatisticsUtils, 'getEscrowStatistics')
239+
.mockRejectedValue(new Error('Failed to fetch escrow stats'));
219240

220241
const result = await networksService.getOperatingNetworks();
221242
expect(result).toEqual([]);

packages/apps/dashboard/server/src/modules/networks/networks.service.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NETWORKS, StatisticsClient } from '@human-protocol/sdk';
1+
import { NETWORKS, StatisticsUtils } from '@human-protocol/sdk';
22
import { Cache, CACHE_MANAGER } from '@nestjs/cache-manager';
33
import { Inject, Injectable } from '@nestjs/common';
44

@@ -46,13 +46,12 @@ export class NetworksService {
4646
const networkConfig = NETWORKS[network.chainId];
4747
if (!networkConfig) continue;
4848

49-
const statisticsClient = new StatisticsClient(networkConfig);
5049
try {
5150
const [hmtData, escrowStats] = await Promise.all([
52-
statisticsClient.getHMTDailyData({
51+
StatisticsUtils.getHMTDailyData(networkConfig, {
5352
from: new Date(Math.floor(filterDate.getTime() / 1000) * 1000),
5453
}),
55-
statisticsClient.getEscrowStatistics({
54+
StatisticsUtils.getEscrowStatistics(networkConfig, {
5655
from: new Date(Math.floor(oneMonthAgo.getTime() / 1000) * 1000),
5756
}),
5857
]);

packages/apps/dashboard/server/src/modules/stats/stats.service.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IDailyHMT, NETWORKS, StatisticsClient } from '@human-protocol/sdk';
1+
import { IDailyHMT, NETWORKS, StatisticsUtils } from '@human-protocol/sdk';
22
import { HttpService } from '@nestjs/axios';
33
import { Cache, CACHE_MANAGER } from '@nestjs/cache-manager';
44
import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
@@ -244,8 +244,9 @@ export class StatsService implements OnModuleInit {
244244
const operatingNetworks =
245245
await this.networksService.getOperatingNetworks();
246246
for (const network of operatingNetworks) {
247-
const statisticsClient = new StatisticsClient(NETWORKS[network]);
248-
const generalStats = await statisticsClient.getHMTStatistics();
247+
const generalStats = await StatisticsUtils.getHMTStatistics(
248+
NETWORKS[network],
249+
);
249250
aggregatedStats.totalHolders += generalStats.totalHolders;
250251
aggregatedStats.totalTransactions += generalStats.totalTransferCount;
251252
}
@@ -295,17 +296,19 @@ export class StatsService implements OnModuleInit {
295296
// Fetch daily data for each network
296297
await Promise.all(
297298
operatingNetworks.map(async (network) => {
298-
const statisticsClient = new StatisticsClient(NETWORKS[network]);
299299
let skip = 0;
300300
let fetchedRecords: IDailyHMT[] = [];
301301

302302
do {
303-
fetchedRecords = await statisticsClient.getHMTDailyData({
304-
from,
305-
to,
306-
first: 1000, // Max subgraph query size
307-
skip,
308-
});
303+
fetchedRecords = await StatisticsUtils.getHMTDailyData(
304+
NETWORKS[network],
305+
{
306+
from,
307+
to,
308+
first: 1000, // Max subgraph query size
309+
skip,
310+
},
311+
);
309312

310313
for (const record of fetchedRecords) {
311314
const dailyCacheKey = `${HMT_PREFIX}${

packages/apps/fortune/exchange-oracle/client/src/components/SolutionForm/index.tsx

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,43 @@ import { Box, Button, Grid, TextField, Typography } from '@mui/material';
22
import { useState } from 'react';
33
import { useParams } from 'react-router-dom';
44
import { useSnackbar } from '../../providers/SnackProvider';
5-
import { useWalletClient } from 'wagmi';
5+
import { useAccount, useWalletClient } from 'wagmi';
66
import * as jobService from '../../services/job';
77

88
const SolutionForm: React.FC = () => {
99
const { assignmentId } = useParams<{ assignmentId: string }>();
1010

11-
const { data: signer } = useWalletClient();
11+
const { address, chainId, connector, isConnected } = useAccount();
12+
const { data: signer } = useWalletClient({
13+
account: address,
14+
chainId,
15+
connector,
16+
query: {
17+
enabled: isConnected && !!address && !!connector,
18+
},
19+
});
1220
const [solution, setSolution] = useState('');
13-
const { showError, openSnackbar } = useSnackbar();
21+
22+
type SnackbarApi = {
23+
openSnackbar: (
24+
message: string,
25+
severity?: 'success' | 'error' | 'info' | 'warning',
26+
) => void;
27+
showError: (error: unknown) => void;
28+
};
29+
30+
const { showError, openSnackbar } = useSnackbar() as SnackbarApi;
1431

1532
const handleSubmit = async () => {
33+
if (!signer) {
34+
openSnackbar('Please connect your wallet first', 'error');
35+
return;
36+
}
37+
38+
if (!assignmentId) {
39+
openSnackbar('Missing assignment id', 'error');
40+
return;
41+
}
1642
const message = {
1743
solution,
1844
assignment_id: assignmentId,
@@ -69,7 +95,11 @@ const SolutionForm: React.FC = () => {
6995
sx={{ mb: 3, width: '300px' }}
7096
/>
7197
<br />
72-
<Button variant="contained" onClick={handleSubmit}>
98+
<Button
99+
variant="contained"
100+
onClick={handleSubmit}
101+
disabled={!signer || !assignmentId || !solution}
102+
>
73103
Submit
74104
</Button>
75105
</Box>

packages/apps/fortune/exchange-oracle/server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ $ yarn migration:show
115115

116116
## 📚 Documentation
117117

118-
For detailed information about the Exchange Oracle, please refer to the [Human Protocol Tech Docs](https://human-protocol.gitbook.io/hub/human-tech-docs/architecture/components/exchange-oracle).
118+
For detailed information about the Exchange Oracle, please refer to the [Human Protocol Tech Docs](https://docs.humanprotocol.org/architecture/exchange_oracle/overview/).
119119

120120
## 📝 License
121121

0 commit comments

Comments
 (0)