diff --git a/.changeset/warm-pillows-crash.md b/.changeset/warm-pillows-crash.md new file mode 100644 index 0000000000..66e1e29a0d --- /dev/null +++ b/.changeset/warm-pillows-crash.md @@ -0,0 +1,6 @@ +--- +"@human-protocol/sdk": patch +"@human-protocol/python-sdk": patch +--- + +Delete references to totalHMTAmountReceived that was removed from subgraph diff --git a/packages/apps/dashboard/client/src/features/searchResults/model/addressDetailsSchema.ts b/packages/apps/dashboard/client/src/features/searchResults/model/addressDetailsSchema.ts index fe9c339c49..2a5a2926a4 100644 --- a/packages/apps/dashboard/client/src/features/searchResults/model/addressDetailsSchema.ts +++ b/packages/apps/dashboard/client/src/features/searchResults/model/addressDetailsSchema.ts @@ -11,7 +11,6 @@ const walletSchema = z.object({ lockedAmount: z.string(), withdrawableAmount: z.string(), reputation: reputationSchema, - totalHMTAmountReceived: z.string(), payoutCount: z.number().or(z.string()), }); diff --git a/packages/apps/dashboard/client/src/features/searchResults/ui/WalletAddress.tsx b/packages/apps/dashboard/client/src/features/searchResults/ui/WalletAddress.tsx index 29b551a00e..673d27a825 100644 --- a/packages/apps/dashboard/client/src/features/searchResults/ui/WalletAddress.tsx +++ b/packages/apps/dashboard/client/src/features/searchResults/ui/WalletAddress.tsx @@ -30,7 +30,7 @@ const WalletAddress: FC = ({ data }) => { reputation, withdrawableAmount, } = data; - const isWallet = 'totalHMTAmountReceived' in data; + const isWallet = 'payoutCount' in data; return ( <> @@ -51,10 +51,10 @@ const WalletAddress: FC = ({ data }) => { {isWallet && ( - + )} diff --git a/packages/apps/dashboard/server/src/modules/details/details.service.ts b/packages/apps/dashboard/server/src/modules/details/details.service.ts index 0b40757ced..72a73d03c2 100644 --- a/packages/apps/dashboard/server/src/modules/details/details.service.ts +++ b/packages/apps/dashboard/server/src/modules/details/details.service.ts @@ -128,9 +128,6 @@ export class DetailsService { withdrawableAmount: ethers.formatEther(stakingData.withdrawableAmount), reputation: (await this.fetchOperatorReputation(chainId, address)) .reputation, - totalHMTAmountReceived: ethers.formatEther( - workerData?.totalHMTAmountReceived || 0, - ), payoutCount: workerData?.payoutCount || 0, }); diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/worker.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/worker.py index ee21af1ef7..2a12dad238 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/worker.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/worker.py @@ -4,7 +4,6 @@ fragment WorkerFields on Worker { id address - totalHMTAmountReceived payoutCount } """ diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/worker/worker_utils.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/worker/worker_utils.py index 27de33976a..e6d7ba70d2 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/worker/worker_utils.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/worker/worker_utils.py @@ -9,7 +9,7 @@ WorkerFilter(chain_id=ChainId.POLYGON_AMOY) ) for worker in workers: - print(f"{worker.address}: {worker.total_amount_received}") + print(f"{worker.address}: {worker.payout_count}") ``` """ @@ -37,7 +37,6 @@ class WorkerData: Attributes: id (str): Unique worker identifier. address (str): Worker's Ethereum address. - total_amount_received (int): Total amount of HMT tokens received by the worker. payout_count (int): Number of payouts the worker has received. """ @@ -45,12 +44,10 @@ def __init__( self, id: str, address: str, - total_amount_received: str, payout_count: str, ): self.id = id self.address = address - self.total_amount_received = int(total_amount_received) self.payout_count = int(payout_count) @@ -94,7 +91,7 @@ def get_workers( WorkerFilter(chain_id=ChainId.POLYGON_AMOY) ) for worker in workers: - print(f"{worker.address}: {worker.total_amount_received} HMT") + print(f"{worker.address}: {worker.payout_count} payouts") # Get specific worker workers = WorkerUtils.get_workers( @@ -141,7 +138,6 @@ def get_workers( WorkerData( id=worker.get("id"), address=worker.get("address"), - total_amount_received=worker.get("totalHMTAmountReceived"), payout_count=worker.get("payoutCount"), ) ) @@ -180,7 +176,6 @@ def get_worker( "0x1234567890123456789012345678901234567890", ) if worker: - print(f"Total received: {worker.total_amount_received} HMT") print(f"Payout count: {worker.payout_count}") ``` """ @@ -215,6 +210,5 @@ def get_worker( return WorkerData( id=worker.get("id"), address=worker.get("address"), - total_amount_received=worker.get("totalHMTAmountReceived"), payout_count=worker.get("payoutCount"), ) diff --git a/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/worker/test_worker_utils.py b/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/worker/test_worker_utils.py index 806547042d..cdd0902081 100644 --- a/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/worker/test_worker_utils.py +++ b/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/worker/test_worker_utils.py @@ -15,13 +15,11 @@ def test_get_workers(self): mock_worker_1 = { "id": "worker1", "address": "0x1234567890123456789012345678901234567890", - "totalHMTAmountReceived": "1000", "payoutCount": 5, } mock_worker_2 = { "id": "worker2", "address": "0x9876543210987654321098765432109876543210", - "totalHMTAmountReceived": "2000", "payoutCount": 10, } @@ -31,7 +29,7 @@ def test_get_workers(self): filter = WorkerFilter( chain_id=ChainId.POLYGON_AMOY, - order_by="totalHMTAmountReceived", + order_by="payoutCount", order_direction=OrderDirection.ASC, ) @@ -44,7 +42,7 @@ def test_get_workers(self): "address": None, "first": 10, "skip": 0, - "orderBy": "totalHMTAmountReceived", + "orderBy": "payoutCount", "orderDirection": "asc", }, options=None, @@ -52,6 +50,8 @@ def test_get_workers(self): self.assertEqual(len(workers), 2) self.assertEqual(workers[0].id, "worker1") self.assertEqual(workers[1].id, "worker2") + self.assertEqual(workers[0].payout_count, 5) + self.assertEqual(workers[1].payout_count, 10) def test_get_workers_empty_response(self): with patch( @@ -93,7 +93,6 @@ def test_get_worker(self): mock_worker = { "id": "worker1", "address": "0x1234567890123456789012345678901234567890", - "totalHMTAmountReceived": "1000", "payoutCount": 5, } @@ -115,6 +114,7 @@ def test_get_worker(self): self.assertEqual( worker.address, "0x1234567890123456789012345678901234567890" ) + self.assertEqual(worker.payout_count, 5) def test_get_worker_empty_data(self): with patch( diff --git a/packages/sdk/typescript/human-protocol-sdk/src/graphql/queries/worker.ts b/packages/sdk/typescript/human-protocol-sdk/src/graphql/queries/worker.ts index 5242e64988..78aebd7a03 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/graphql/queries/worker.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/graphql/queries/worker.ts @@ -6,7 +6,6 @@ export const GET_WORKER_QUERY = gql` worker(id: $address) { id address - totalHMTAmountReceived payoutCount } } @@ -34,7 +33,6 @@ export const GET_WORKERS_QUERY = (filter: IWorkersFilter) => { ) { id address - totalHMTAmountReceived payoutCount } }`; diff --git a/packages/sdk/typescript/human-protocol-sdk/src/graphql/types.ts b/packages/sdk/typescript/human-protocol-sdk/src/graphql/types.ts index 295acaac4a..bdeead4b28 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/graphql/types.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/graphql/types.ts @@ -30,7 +30,6 @@ export type EscrowData = { export type WorkerData = { id: string; address: string; - totalHMTAmountReceived: string; payoutCount: string; }; diff --git a/packages/sdk/typescript/human-protocol-sdk/src/interfaces.ts b/packages/sdk/typescript/human-protocol-sdk/src/interfaces.ts index cac654ae4c..7158268abf 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/interfaces.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/interfaces.ts @@ -181,7 +181,6 @@ export interface IStatusEventFilter extends IPagination { export interface IWorker { id: string; address: string; - totalHMTAmountReceived: bigint; payoutCount: number; } diff --git a/packages/sdk/typescript/human-protocol-sdk/src/worker/worker_utils.ts b/packages/sdk/typescript/human-protocol-sdk/src/worker/worker_utils.ts index d26c847f8d..1f5fd9684e 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/worker/worker_utils.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/worker/worker_utils.ts @@ -93,7 +93,6 @@ export class WorkerUtils { * type IWorker = { * id: string; * address: string; - * totalHMTAmountReceived: bigint; * payoutCount: number; * }; * ``` @@ -162,7 +161,6 @@ function mapWorker(w: WorkerData): IWorker { return { id: w.id, address: w.address, - totalHMTAmountReceived: BigInt(w.totalHMTAmountReceived || 0), payoutCount: Number(w.payoutCount || 0), }; } diff --git a/packages/sdk/typescript/human-protocol-sdk/test/worker.test.ts b/packages/sdk/typescript/human-protocol-sdk/test/worker.test.ts index f50f2da8f4..56b256124e 100644 --- a/packages/sdk/typescript/human-protocol-sdk/test/worker.test.ts +++ b/packages/sdk/typescript/human-protocol-sdk/test/worker.test.ts @@ -27,8 +27,7 @@ describe('WorkerUtils', () => { const mockWorker: WorkerData = { id: workerAddress, address: workerAddress, - totalHMTAmountReceived: '1000', - payoutCount: 10, + payoutCount: '10', }; test('should return worker details', async () => { @@ -51,7 +50,7 @@ describe('WorkerUtils', () => { ); const expected: IWorker = { ...mockWorker, - totalHMTAmountReceived: BigInt(mockWorker.totalHMTAmountReceived || 0), + payoutCount: Number(mockWorker.payoutCount || 0), }; expect(result).toEqual(expected); }); @@ -100,14 +99,12 @@ describe('WorkerUtils', () => { { id: '0x1234567890abcdef1234567890abcdef12345678', address: '0x1234567890abcdef1234567890abcdef12345678', - totalHMTAmountReceived: '1000', - payoutCount: 10, + payoutCount: '10', }, { id: '0xabcdefabcdefabcdefabcdefabcdefabcdef', address: '0xabcdefabcdefabcdefabcdefabcdefabcdef', - totalHMTAmountReceived: '2000', - payoutCount: 20, + payoutCount: '20', }, ]; @@ -120,7 +117,7 @@ describe('WorkerUtils', () => { chainId: ChainId.LOCALHOST, first: 10, skip: 0, - orderBy: 'totalHMTAmountReceived', + orderBy: 'payoutCount', orderDirection: OrderDirection.ASC, }; @@ -133,14 +130,14 @@ describe('WorkerUtils', () => { address: undefined, first: 10, skip: 0, - orderBy: 'totalHMTAmountReceived', + orderBy: 'payoutCount', orderDirection: 'asc', }, undefined ); const expected: IWorker[] = mockWorkers.map((mockWorker) => ({ ...mockWorker, - totalHMTAmountReceived: BigInt(mockWorker.totalHMTAmountReceived || 0), + payoutCount: Number(mockWorker.payoutCount || 0), })); expect(result).toEqual(expected); }); @@ -215,7 +212,7 @@ describe('WorkerUtils', () => { const expected: IWorker[] = mockWorkers.map((mockWorker) => ({ ...mockWorker, - totalHMTAmountReceived: BigInt(mockWorker.totalHMTAmountReceived || 0), + payoutCount: Number(mockWorker.payoutCount || 0), })); expect(result).toEqual(expected); });