From 37c51d4dffe90fc24bbd3009fe153fb94db0207a Mon Sep 17 00:00:00 2001 From: portuu3 Date: Fri, 20 Feb 2026 10:35:28 +0100 Subject: [PATCH 01/10] remove HMToken related entities and handlers from subgraph --- packages/sdk/typescript/subgraph/package.json | 3 +- .../sdk/typescript/subgraph/schema.graphql | 79 --- .../subgraph/src/mapping/EscrowTemplate.ts | 60 +- .../subgraph/src/mapping/HMTokenTemplate.ts | 313 --------- .../subgraph/src/mapping/utils/dayUpdates.ts | 5 - .../sdk/typescript/subgraph/template.yaml | 42 +- .../typescript/subgraph/tests/hmt/fixtures.ts | 153 ----- .../typescript/subgraph/tests/hmt/hmt.test.ts | 597 ------------------ 8 files changed, 25 insertions(+), 1227 deletions(-) delete mode 100644 packages/sdk/typescript/subgraph/src/mapping/HMTokenTemplate.ts delete mode 100644 packages/sdk/typescript/subgraph/tests/hmt/fixtures.ts delete mode 100644 packages/sdk/typescript/subgraph/tests/hmt/hmt.test.ts diff --git a/packages/sdk/typescript/subgraph/package.json b/packages/sdk/typescript/subgraph/package.json index 3a84c97f38..03dfb3d969 100644 --- a/packages/sdk/typescript/subgraph/package.json +++ b/packages/sdk/typescript/subgraph/package.json @@ -8,9 +8,8 @@ ], "scripts": { "clean": "rm -rf build generated subgraph.yaml", - "generate": "mustache ./config/$NETWORK.json template.yaml > subgraph.yaml && yarn generate-escrow && yarn generate-hmt && yarn generate-staking && graph codegen", + "generate": "mustache ./config/$NETWORK.json template.yaml > subgraph.yaml && yarn generate-escrow && yarn generate-staking && graph codegen", "generate-escrow": "mustache ./config/$NETWORK.json src/mapping/EscrowTemplate.ts > src/mapping/Escrow.ts", - "generate-hmt": "mustache ./config/$NETWORK.json src/mapping/HMTokenTemplate.ts > src/mapping/HMToken.ts", "generate-staking": "mustache ./config/$NETWORK.json src/mapping/StakingTemplate.ts > src/mapping/Staking.ts", "codegen": "graph codegen", "build": "graph build", diff --git a/packages/sdk/typescript/subgraph/schema.graphql b/packages/sdk/typescript/subgraph/schema.graphql index e4d122605c..82bbd4f403 100644 --- a/packages/sdk/typescript/subgraph/schema.graphql +++ b/packages/sdk/typescript/subgraph/schema.graphql @@ -2,33 +2,12 @@ # Entities # ################################################## -type Holder @entity(immutable: false) { - id: Bytes! - address: Bytes! # address - balance: BigInt! -} - type Worker @entity(immutable: false) { id: Bytes! address: Bytes! - totalHMTAmountReceived: BigInt! payoutCount: BigInt! } -type UniqueSender @entity(immutable: false) { - id: Bytes! - address: Bytes! - transferCount: BigInt! - timestamp: BigInt! -} - -type UniqueReceiver @entity(immutable: false) { - id: Bytes! - address: Bytes! - receiveCount: BigInt! - timestamp: BigInt! -} - type Operator @entity(immutable: false) { id: Bytes! address: Bytes! @@ -111,49 +90,6 @@ type DailyWorker @entity(immutable: true) { # Events # ################################################## -# HMToken -type HMTTransferEvent @entity(immutable: true) { - id: Bytes! - block: BigInt! - timestamp: BigInt! - txHash: Bytes! - - from: Bytes! # address - to: Bytes! # address - amount: BigInt! -} - -type HMTBulkTransferEvent @entity(immutable: true) { - id: Bytes! - block: BigInt! - timestamp: BigInt! - txHash: Bytes! - - txId: BigInt! - bulkCount: BigInt! -} - -type HMTApprovalEvent @entity(immutable: true) { - id: Bytes! - block: BigInt! - timestamp: BigInt! - txHash: Bytes! - - owner: Bytes! # address - spender: Bytes! # address - amount: BigInt! -} - -type HMTBulkApprovalEvent @entity(immutable: true) { - id: Bytes! - block: BigInt! - timestamp: BigInt! - txHash: Bytes! - - txId: BigInt! - bulkCount: BigInt! -} - # Escrow type FundEvent @entity(immutable: true) { id: Bytes! @@ -316,16 +252,6 @@ type StakeSlashedEvent @entity(immutable: true) { # Statistics # ################################################## -type HMTokenStatistics @entity(immutable: false) { - id: Bytes! - totalTransferEventCount: BigInt! - totalBulkTransferEventCount: BigInt! - totalApprovalEventCount: BigInt! - totalBulkApprovalEventCount: BigInt! - totalValueTransfered: BigInt! - holders: BigInt! -} - type EscrowStatistics @entity(immutable: false) { id: Bytes! fundEventCount: BigInt! @@ -357,11 +283,6 @@ type EventDayData @entity(immutable: false) { dailyEscrowCount: BigInt! dailyWorkerCount: BigInt! dailyPayoutCount: BigInt! - dailyHMTPayoutAmount: BigInt! - dailyHMTTransferCount: BigInt! - dailyHMTTransferAmount: BigInt! - dailyUniqueSenders: BigInt! - dailyUniqueReceivers: BigInt! } ################################################## diff --git a/packages/sdk/typescript/subgraph/src/mapping/EscrowTemplate.ts b/packages/sdk/typescript/subgraph/src/mapping/EscrowTemplate.ts index 83d89d7f0a..76c8b13d8b 100644 --- a/packages/sdk/typescript/subgraph/src/mapping/EscrowTemplate.ts +++ b/packages/sdk/typescript/subgraph/src/mapping/EscrowTemplate.ts @@ -43,7 +43,6 @@ import { createTransaction } from './utils/transaction'; import { toBytes } from './utils/string'; import { createOrLoadOperator } from './KVStore'; -export const HMT_ADDRESS = Address.fromString('{{ HMToken.address }}'); export const STATISTICS_ENTITY_ID = toBytes('escrow-statistics-id'); function constructStatsEntity(): EscrowStatistics { @@ -80,7 +79,6 @@ export function createOrLoadWorker(address: Address): Worker { if (!worker) { worker = new Worker(address); worker.address = address; - worker.totalHMTAmountReceived = ZERO_BI; worker.payoutCount = ZERO_BI; } @@ -547,21 +545,18 @@ function handleBulkTransferCommon( } eventDayData.save(); - // If the escrow is non-HMT, create the internal transaction - if (Address.fromBytes(escrowEntity.token) != HMT_ADDRESS) { - const internalTransaction = new InternalTransaction( - event.transaction.hash - .concatI32(i) - .concatI32(event.block.timestamp.toI32()) - ); - internalTransaction.from = Address.fromBytes(escrowEntity.address); - internalTransaction.to = recipient; - internalTransaction.value = amount; - internalTransaction.transaction = transaction.id; - internalTransaction.method = 'transfer'; - internalTransaction.escrow = Address.fromBytes(escrowEntity.address); - internalTransaction.save(); - } + const internalTransaction = new InternalTransaction( + event.transaction.hash + .concatI32(i) + .concatI32(event.block.timestamp.toI32()) + ); + internalTransaction.from = Address.fromBytes(escrowEntity.address); + internalTransaction.to = recipient; + internalTransaction.value = amount; + internalTransaction.transaction = transaction.id; + internalTransaction.method = 'transfer'; + internalTransaction.escrow = Address.fromBytes(escrowEntity.address); + internalTransaction.save(); } // Assign finalResultsUrl directly from the event @@ -685,11 +680,7 @@ export function handleCompleted(event: Completed): void { null, Address.fromBytes(escrowEntity.address) ); - if ( - escrowEntity.balance && - escrowEntity.balance.gt(ZERO_BI) && - escrowEntity.token != HMT_ADDRESS - ) { + if (escrowEntity.balance && escrowEntity.balance.gt(ZERO_BI)) { const internalTransaction = new InternalTransaction(toEventId(event)); internalTransaction.from = escrowEntity.address; internalTransaction.to = escrowEntity.launcher; @@ -743,9 +734,7 @@ export function handleFund(event: Fund): void { // Update escrow entity escrowEntity.totalFundedAmount = event.params.amount; - if (escrowEntity.token != HMT_ADDRESS) { - escrowEntity.balance = event.params.amount; - } + escrowEntity.balance = event.params.amount; escrowEntity.save(); } @@ -841,18 +830,15 @@ export function handleCancellationRefund(event: CancellationRefund): void { event.params.amount, Address.fromBytes(escrowEntity.token) ); - if (Address.fromBytes(escrowEntity.token) != HMT_ADDRESS) { - // If escrow is funded with HMT, balance is already tracked by HMT transfer - const internalTransaction = new InternalTransaction(toEventId(event)); - internalTransaction.from = escrowEntity.address; - internalTransaction.to = Address.fromBytes(escrowEntity.token); - internalTransaction.receiver = escrowEntity.canceler; - internalTransaction.value = escrowEntity.balance; - internalTransaction.transaction = transaction.id; - internalTransaction.method = 'transfer'; - internalTransaction.token = Address.fromBytes(escrowEntity.token); - internalTransaction.save(); - } + const internalTransaction = new InternalTransaction(toEventId(event)); + internalTransaction.from = escrowEntity.address; + internalTransaction.to = Address.fromBytes(escrowEntity.token); + internalTransaction.receiver = escrowEntity.canceler; + internalTransaction.value = escrowEntity.balance; + internalTransaction.transaction = transaction.id; + internalTransaction.method = 'transfer'; + internalTransaction.token = Address.fromBytes(escrowEntity.token); + internalTransaction.save(); escrowEntity.balance = escrowEntity.balance.minus(event.params.amount); escrowEntity.save(); diff --git a/packages/sdk/typescript/subgraph/src/mapping/HMTokenTemplate.ts b/packages/sdk/typescript/subgraph/src/mapping/HMTokenTemplate.ts deleted file mode 100644 index cb47c48fa0..0000000000 --- a/packages/sdk/typescript/subgraph/src/mapping/HMTokenTemplate.ts +++ /dev/null @@ -1,313 +0,0 @@ -import { Address, BigInt, Bytes, dataSource } from '@graphprotocol/graph-ts'; - -import { - Approval, - BulkApproval, - BulkTransfer, - Transfer, -} from '../../generated/HMToken/HMToken'; -import { - Escrow, - HMTApprovalEvent, - HMTBulkApprovalEvent, - HMTBulkTransferEvent, - HMTTransferEvent, - HMTokenStatistics, - Holder, - UniqueReceiver, - UniqueSender, -} from '../../generated/schema'; -import { toEventId } from './utils/event'; -import { ONE_BI, ONE_DAY, ZERO_BI } from './utils/number'; -import { getEventDayData } from './utils/dayUpdates'; -import { createTransaction } from './utils/transaction'; -import { toBytes } from './utils/string'; - -export const HMT_STATISTICS_ENTITY_ID = toBytes('hmt-statistics-id'); -export const TOTAL_SUPPLY = BigInt.fromString('{{ HMToken.totalSupply }}'); -export const CONTRACT_DEPLOYER = '{{ HMToken.contractDeployer }}'; - -function constructStatsEntity(): HMTokenStatistics { - const entity = new HMTokenStatistics(HMT_STATISTICS_ENTITY_ID); - - entity.totalTransferEventCount = BigInt.fromI32(0); - entity.totalApprovalEventCount = BigInt.fromI32(0); - entity.totalBulkApprovalEventCount = BigInt.fromI32(0); - entity.totalBulkTransferEventCount = BigInt.fromI32(0); - entity.totalValueTransfered = BigInt.fromI32(0); - entity.holders = BigInt.fromI32(0); - - return entity; -} - -export function createOrLoadUniqueSender( - dayStartTimestamp: BigInt, - timestamp: BigInt, - address: Address -): UniqueSender { - const id = Bytes.fromI32(dayStartTimestamp.toI32()).concat(address); - let uniqueSender = UniqueSender.load(id); - - if (!uniqueSender) { - uniqueSender = new UniqueSender(id); - uniqueSender.address = address; - uniqueSender.transferCount = ZERO_BI; - uniqueSender.timestamp = timestamp; - uniqueSender.save(); - } - - return uniqueSender; -} - -export function createOrLoadUniqueReceiver( - dayStartTimestamp: BigInt, - timestamp: BigInt, - address: Address -): UniqueReceiver { - const id = Bytes.fromI32(dayStartTimestamp.toI32()).concat(address); - let uniqueReceiver = UniqueReceiver.load(id); - - if (!uniqueReceiver) { - uniqueReceiver = new UniqueReceiver(id); - uniqueReceiver.address = address; - uniqueReceiver.receiveCount = ZERO_BI; - uniqueReceiver.timestamp = timestamp; - uniqueReceiver.save(); - } - - return uniqueReceiver; -} - -function updateHolders( - holderAddress: Address, - value: BigInt, - increase: boolean -): BigInt { - if ( - holderAddress.toHexString() == '0x0000000000000000000000000000000000000000' - ) - return ZERO_BI; - let count = ZERO_BI; - const id = holderAddress; - let holder = Holder.load(id); - - if (holder == null) { - holder = new Holder(id); - holder.address = holderAddress; - if (holderAddress.toHex() == CONTRACT_DEPLOYER) { - holder.balance = TOTAL_SUPPLY; - } else { - holder.balance = BigInt.fromI32(0); - } - } - const balanceBeforeTransfer = holder.balance; - holder.balance = increase - ? holder.balance.plus(value) - : holder.balance.minus(value); - - if (balanceBeforeTransfer.isZero() && !holder.balance.isZero()) { - count = ONE_BI; - } else if (!balanceBeforeTransfer.isZero() && holder.balance.isZero()) { - count = ONE_BI.neg(); - } - - holder.save(); - - return count; -} - -export function createOrLoadHMTStatistics(): HMTokenStatistics { - let statsEntity = HMTokenStatistics.load(HMT_STATISTICS_ENTITY_ID); - - if (!statsEntity) { - statsEntity = constructStatsEntity(); - } - - return statsEntity; -} - -export function handleTransfer(event: Transfer): void { - // Create HMTTransferEvent entity - const eventEntity = new HMTTransferEvent(toEventId(event)); - eventEntity.block = event.block.number; - eventEntity.timestamp = event.block.timestamp; - eventEntity.txHash = event.transaction.hash; - eventEntity.from = event.params._from; - eventEntity.to = event.params._to; - eventEntity.amount = event.params._value; - eventEntity.save(); - - // Update statistics - const statsEntity = createOrLoadHMTStatistics(); - statsEntity.totalTransferEventCount = - statsEntity.totalTransferEventCount.plus(ONE_BI); - statsEntity.totalValueTransfered = statsEntity.totalValueTransfered.plus( - event.params._value - ); - - const eventDayData = getEventDayData(event); - const escrow = Escrow.load(event.params._to); - if (escrow) { - // Update escrow balance - escrow.balance = escrow.balance.plus(event.params._value); - escrow.totalFundedAmount = escrow.totalFundedAmount.plus( - event.params._value - ); - escrow.save(); - - createTransaction( - event, - 'fund', - event.params._from, - dataSource.address(), - event.params._to, - event.params._to, - event.params._value, - dataSource.address() - ); - } else { - createTransaction( - event, - 'transfer', - event.params._from, - dataSource.address(), - event.params._to, - null, - event.params._value, - dataSource.address() - ); - } - - // Update holders - const diffHolders = updateHolders( - event.params._from, - event.params._value, - false - ).plus(updateHolders(event.params._to, event.params._value, true)); - statsEntity.holders = statsEntity.holders.plus(diffHolders); - - // Update event day data for HMT transfer - eventDayData.dailyHMTTransferCount = - eventDayData.dailyHMTTransferCount.plus(ONE_BI); - eventDayData.dailyHMTTransferAmount = - eventDayData.dailyHMTTransferAmount.plus(event.params._value); - - const timestamp = event.block.timestamp.toI32(); - const dayID = timestamp / ONE_DAY; - const dayStartTimestamp = dayID * ONE_DAY; - - // Update unique sender - const uniqueSender = createOrLoadUniqueSender( - BigInt.fromI32(dayStartTimestamp), - event.block.timestamp, - event.params._from - ); - if (uniqueSender.transferCount === ZERO_BI) { - eventDayData.dailyUniqueSenders = - eventDayData.dailyUniqueSenders.plus(ONE_BI); - } - uniqueSender.transferCount = uniqueSender.transferCount.plus( - event.params._value - ); - uniqueSender.save(); - - // Update unique receiver - const uniqueReceiver = createOrLoadUniqueReceiver( - BigInt.fromI32(dayStartTimestamp), - event.block.timestamp, - event.params._to - ); - if (uniqueReceiver.receiveCount === ZERO_BI) { - eventDayData.dailyUniqueReceivers = - eventDayData.dailyUniqueReceivers.plus(ONE_BI); - } - uniqueReceiver.receiveCount = uniqueReceiver.receiveCount.plus( - event.params._value - ); - uniqueReceiver.save(); - - eventDayData.save(); - statsEntity.save(); -} - -export function handleBulkTransfer(event: BulkTransfer): void { - createTransaction( - event, - 'transferBulk', - event.transaction.from, - dataSource.address(), - null, - null, - null, - dataSource.address() - ); - // Create HMTBulkTransferEvent entity - const eventEntity = new HMTBulkTransferEvent(toEventId(event)); - eventEntity.block = event.block.number; - eventEntity.timestamp = event.block.timestamp; - eventEntity.txHash = event.transaction.hash; - eventEntity.txId = event.params._txId; - eventEntity.bulkCount = event.params._bulkCount; - eventEntity.save(); - - // Update statistics - const statsEntity = createOrLoadHMTStatistics(); - statsEntity.totalBulkTransferEventCount = - statsEntity.totalBulkTransferEventCount.plus(ONE_BI); - statsEntity.save(); -} - -export function handleApproval(event: Approval): void { - createTransaction( - event, - 'approve', - event.params._owner, - dataSource.address(), - event.params._spender, - null, - event.params._value, - dataSource.address() - ); - // Create HMTApprovalEvent entity - const eventEntity = new HMTApprovalEvent(toEventId(event)); - eventEntity.block = event.block.number; - eventEntity.timestamp = event.block.timestamp; - eventEntity.txHash = event.transaction.hash; - eventEntity.owner = event.params._owner; - eventEntity.spender = event.params._spender; - eventEntity.amount = event.params._value; - eventEntity.save(); - - // Update statistics - const statsEntity = createOrLoadHMTStatistics(); - statsEntity.totalApprovalEventCount = - statsEntity.totalApprovalEventCount.plus(ONE_BI); - statsEntity.save(); -} - -export function handleBulkApproval(event: BulkApproval): void { - createTransaction( - event, - 'increaseApprovalBulk', - event.transaction.from, - dataSource.address(), - null, - null, - null, - dataSource.address() - ); - // Create HMTBulkApprovalEvent entity - const eventEntity = new HMTBulkApprovalEvent(toEventId(event)); - eventEntity.block = event.block.number; - eventEntity.timestamp = event.block.timestamp; - eventEntity.txHash = event.transaction.hash; - eventEntity.txId = event.params._txId; - eventEntity.bulkCount = event.params._bulkCount; - eventEntity.save(); - - // Update statistics - const statsEntity = createOrLoadHMTStatistics(); - statsEntity.totalBulkApprovalEventCount = - statsEntity.totalBulkApprovalEventCount.plus(ONE_BI); - statsEntity.save(); -} diff --git a/packages/sdk/typescript/subgraph/src/mapping/utils/dayUpdates.ts b/packages/sdk/typescript/subgraph/src/mapping/utils/dayUpdates.ts index 6d615b15a5..463f0db316 100644 --- a/packages/sdk/typescript/subgraph/src/mapping/utils/dayUpdates.ts +++ b/packages/sdk/typescript/subgraph/src/mapping/utils/dayUpdates.ts @@ -26,11 +26,6 @@ export function getEventDayData(event: ethereum.Event): EventDayData { eventDayData.dailyEscrowCount = ZERO_BI; eventDayData.dailyWorkerCount = ZERO_BI; eventDayData.dailyPayoutCount = ZERO_BI; - eventDayData.dailyHMTPayoutAmount = ZERO_BI; - eventDayData.dailyHMTTransferCount = ZERO_BI; - eventDayData.dailyHMTTransferAmount = ZERO_BI; - eventDayData.dailyUniqueSenders = ZERO_BI; - eventDayData.dailyUniqueReceivers = ZERO_BI; } return eventDayData; } diff --git a/packages/sdk/typescript/subgraph/template.yaml b/packages/sdk/typescript/subgraph/template.yaml index fa3b45fd4f..cab926747c 100644 --- a/packages/sdk/typescript/subgraph/template.yaml +++ b/packages/sdk/typescript/subgraph/template.yaml @@ -33,46 +33,6 @@ dataSources: handler: handleLaunched - event: LaunchedV2(address,address,string) handler: handleLaunchedV2 - - kind: ethereum - name: HMToken - network: '{{ network }}' - source: - abi: HMToken - address: '{{ HMToken.address }}' - startBlock: {{ HMToken.startBlock }} - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - DailyWorker - - Escrow - - EventDayData - - HMTApprovalEvent - - HMTBulkApprovalEvent - - HMTBulkTransferEvent - - HMTTransferEvent - - HMTokenStatistics - - Holder - - Payout - - UniqueReceiver - - UniqueSender - - Worker - - Transaction - - InternalTransaction - abis: - - name: HMToken - file: '{{{ HMToken.abi }}}' - eventHandlers: - - event: Approval(indexed address,indexed address,uint256) - handler: handleApproval - - event: BulkApproval(indexed uint256,uint256) - handler: handleBulkApproval - - event: BulkTransfer(indexed uint256,uint256) - handler: handleBulkTransfer - - event: Transfer(indexed address,indexed address,uint256) - handler: handleTransfer - file: ./src/mapping/HMToken.ts - kind: ethereum name: KVStore network: '{{ network }}' @@ -244,4 +204,4 @@ templates: handler: handlePending - event: BulkTransfer(indexed uint256,uint256) handler: handleBulkTransfer -{{ /LegacyEscrow }} \ No newline at end of file +{{ /LegacyEscrow }} diff --git a/packages/sdk/typescript/subgraph/tests/hmt/fixtures.ts b/packages/sdk/typescript/subgraph/tests/hmt/fixtures.ts deleted file mode 100644 index 259a0ac3da..0000000000 --- a/packages/sdk/typescript/subgraph/tests/hmt/fixtures.ts +++ /dev/null @@ -1,153 +0,0 @@ -import { newMockEvent } from 'matchstick-as/assembly/index'; -import { Address, ethereum, BigInt, dataSource } from '@graphprotocol/graph-ts'; - -import { - Transfer, - Approval, - BulkTransfer, - BulkApproval, -} from '../../generated/HMToken/HMToken'; -import { generateUniqueHash } from '../../tests/utils'; - -export function createTransferEvent( - from: string, - to: string, - value: i32, - timestamp: BigInt -): Transfer { - const transferEvent = changetype(newMockEvent()); - transferEvent.transaction.hash = generateUniqueHash( - to, - timestamp, - transferEvent.transaction.nonce - ); - - transferEvent.parameters = []; - transferEvent.transaction.from = Address.fromString(from); - transferEvent.transaction.to = Address.fromString( - dataSource.address().toHexString() - ); - transferEvent.block.timestamp = timestamp; - const fromParam = new ethereum.EventParam( - '_from', - ethereum.Value.fromAddress(Address.fromString(from)) - ); - const toParam = new ethereum.EventParam( - '_to', - ethereum.Value.fromAddress(Address.fromString(to)) - ); - const valueParam = new ethereum.EventParam( - '_value', - ethereum.Value.fromI32(value) - ); - - transferEvent.parameters.push(fromParam); - transferEvent.parameters.push(toParam); - transferEvent.parameters.push(valueParam); - - return transferEvent; -} - -export function createApprovalEvent( - spender: string, - owner: string, - value: i32, - timestamp: BigInt -): Approval { - const approvalEvent = changetype(newMockEvent()); - approvalEvent.transaction.hash = generateUniqueHash( - owner, - timestamp, - approvalEvent.transaction.nonce - ); - - approvalEvent.transaction.from = Address.fromString(spender); - approvalEvent.transaction.to = Address.fromString( - dataSource.address().toHexString() - ); - approvalEvent.parameters = []; - approvalEvent.block.timestamp = timestamp; - const ownerParam = new ethereum.EventParam( - '_spender', - ethereum.Value.fromAddress(Address.fromString(spender)) - ); - const spenderParam = new ethereum.EventParam( - '_owner', - ethereum.Value.fromAddress(Address.fromString(owner)) - ); - const valueParam = new ethereum.EventParam( - '_value', - ethereum.Value.fromI32(value) - ); - - approvalEvent.parameters.push(ownerParam); - approvalEvent.parameters.push(spenderParam); - approvalEvent.parameters.push(valueParam); - - return approvalEvent; -} - -export function createBulkTransferEvent( - txId: i32, - bulkCount: i32, - timestamp: BigInt -): BulkTransfer { - const bulkTransferEvent = changetype(newMockEvent()); - bulkTransferEvent.transaction.hash = generateUniqueHash( - bulkCount.toString(), - timestamp, - bulkTransferEvent.transaction.nonce - ); - bulkTransferEvent.transaction.to = Address.fromString( - dataSource.address().toHexString() - ); - - bulkTransferEvent.parameters = []; - bulkTransferEvent.block.timestamp = timestamp; - const txIdParam = new ethereum.EventParam( - '_txId', - ethereum.Value.fromI32(txId) - ); - const bulkCountParam = new ethereum.EventParam( - '_bulkCount', - ethereum.Value.fromI32(bulkCount) - ); - - bulkTransferEvent.parameters.push(txIdParam); - bulkTransferEvent.parameters.push(bulkCountParam); - - return bulkTransferEvent; -} - -export function createBulkApprovalEvent( - txId: i32, - bulkCount: i32, - timestamp: BigInt -): BulkApproval { - const bulkApprovalEvent = changetype(newMockEvent()); - bulkApprovalEvent.transaction.hash = generateUniqueHash( - bulkCount.toString(), - timestamp, - bulkApprovalEvent.transaction.nonce - ); - - bulkApprovalEvent.transaction.to = Address.fromString( - dataSource.address().toHexString() - ); - - bulkApprovalEvent.parameters = []; - bulkApprovalEvent.block.timestamp = timestamp; - const txIdParam = new ethereum.EventParam( - '_txId', - ethereum.Value.fromI32(txId) - ); - const bulkCountParam = new ethereum.EventParam( - '_bulkCount', - ethereum.Value.fromI32(bulkCount) - ); - - bulkApprovalEvent.parameters.push(txIdParam); - bulkApprovalEvent.parameters.push(bulkCountParam); - - return bulkApprovalEvent; -} diff --git a/packages/sdk/typescript/subgraph/tests/hmt/hmt.test.ts b/packages/sdk/typescript/subgraph/tests/hmt/hmt.test.ts deleted file mode 100644 index d8ac0bce0d..0000000000 --- a/packages/sdk/typescript/subgraph/tests/hmt/hmt.test.ts +++ /dev/null @@ -1,597 +0,0 @@ -import { Address, BigInt, DataSourceContext } from '@graphprotocol/graph-ts'; -import { - describe, - test, - assert, - clearStore, - dataSourceMock, - beforeAll, - afterAll, - beforeEach, -} from 'matchstick-as/assembly'; - -import { Escrow } from '../../generated/schema'; -import { - HMT_STATISTICS_ENTITY_ID, - handleTransfer, - handleBulkTransfer, - handleApproval, - handleBulkApproval, -} from '../../src/mapping/HMToken'; -import { toEventId } from '../../src/mapping/utils/event'; -import { ZERO_BI } from '../../src/mapping/utils/number'; -import { - createTransferEvent, - createBulkTransferEvent, - createApprovalEvent, - createBulkApprovalEvent, -} from './fixtures'; - -const tokenAddressString = '0xa16081f360e3847006db660bae1c6d1b2e17ffaa'; -const escrowAddressString = '0xa16081f360e3847006db660bae1c6d1b2e17ec2a'; -const escrowAddress = Address.fromString(escrowAddressString); -const operatorAddressString = '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'; -const holderAddressString = '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'; -const holderAddress = Address.fromString(holderAddressString); -const holder1AddressString = '0x92a2eEF7Ff696BCef98957a0189872680600a959'; -const holder1Address = Address.fromString(holder1AddressString); - -describe('HMToken', () => { - beforeAll(() => { - dataSourceMock.setReturnValues( - tokenAddressString, - 'rinkeby', - new DataSourceContext() - ); - - const escrow = new Escrow(escrowAddress); - escrow.address = escrowAddress; - escrow.token = Address.zero(); - escrow.factoryAddress = Address.zero(); - escrow.launcher = Address.zero(); - escrow.canceler = Address.zero(); - escrow.count = ZERO_BI; - escrow.balance = BigInt.fromI32(100); - escrow.totalFundedAmount = BigInt.fromI32(100); - escrow.amountPaid = ZERO_BI; - escrow.createdAt = BigInt.fromI32(0); - escrow.status = 'Launched'; - - escrow.save(); - }); - - afterAll(() => { - dataSourceMock.resetValues(); - }); - - describe('Transfer', () => { - test('Should properly handle Transfer event to Escrow', () => { - const transfer = createTransferEvent( - operatorAddressString, - escrowAddressString, - 1, - BigInt.fromI32(10) - ); - - handleTransfer(transfer); - - const id = toEventId(transfer).toHex(); - - // HMTTransferEvent - assert.fieldEquals( - 'HMTTransferEvent', - id, - 'block', - transfer.block.number.toString() - ); - assert.fieldEquals( - 'HMTTransferEvent', - id, - 'timestamp', - transfer.block.timestamp.toString() - ); - assert.fieldEquals( - 'HMTTransferEvent', - id, - 'txHash', - transfer.transaction.hash.toHex() - ); - assert.fieldEquals('HMTTransferEvent', id, 'from', operatorAddressString); - assert.fieldEquals('HMTTransferEvent', id, 'to', escrowAddressString); - assert.fieldEquals('HMTTransferEvent', id, 'amount', '1'); - - // Escrow - assert.fieldEquals('Escrow', escrowAddressString, 'balance', '101'); - assert.fieldEquals( - 'Escrow', - escrowAddressString, - 'totalFundedAmount', - '101' - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'txHash', - transfer.transaction.hash.toHex() - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'method', - 'fund' - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'block', - transfer.block.number.toString() - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'from', - operatorAddressString - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'to', - tokenAddressString - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'receiver', - escrowAddressString - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'escrow', - escrowAddressString - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'token', - tokenAddressString - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'value', - '1' - ); - }); - - test('Should properly handle Transfer event to Holder', () => { - const transfer = createTransferEvent( - operatorAddressString, - holderAddressString, - 1, - BigInt.fromI32(20) - ); - - handleTransfer(transfer); - - const id = toEventId(transfer).toHex(); - - // HMTTransferEvent - assert.fieldEquals( - 'HMTTransferEvent', - id, - 'block', - transfer.block.number.toString() - ); - assert.fieldEquals( - 'HMTTransferEvent', - id, - 'timestamp', - transfer.block.timestamp.toString() - ); - assert.fieldEquals( - 'HMTTransferEvent', - id, - 'txHash', - transfer.transaction.hash.toHex() - ); - assert.fieldEquals('HMTTransferEvent', id, 'from', operatorAddressString); - assert.fieldEquals('HMTTransferEvent', id, 'to', holderAddressString); - assert.fieldEquals('HMTTransferEvent', id, 'amount', '1'); - - // Holder - assert.fieldEquals( - 'Holder', - holderAddressString, - 'address', - holderAddressString - ); - assert.fieldEquals('Holder', holderAddressString, 'balance', '1'); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'txHash', - transfer.transaction.hash.toHex() - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'method', - 'transfer' - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'block', - transfer.block.number.toString() - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'from', - operatorAddressString - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'to', - tokenAddressString - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'receiver', - holderAddressString - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'token', - tokenAddressString - ); - assert.fieldEquals( - 'Transaction', - transfer.transaction.hash.toHex(), - 'value', - '1' - ); - }); - }); - - test('Should properly handle BulkTransfer event', () => { - const bulkTransfer = createBulkTransferEvent(1, 3, BigInt.fromI32(10)); - - handleBulkTransfer(bulkTransfer); - - const id = toEventId(bulkTransfer).toHex(); - - // HMTBulkTransferEvent - assert.fieldEquals( - 'HMTBulkTransferEvent', - id, - 'block', - bulkTransfer.block.number.toString() - ); - assert.fieldEquals( - 'HMTBulkTransferEvent', - id, - 'timestamp', - bulkTransfer.block.timestamp.toString() - ); - assert.fieldEquals( - 'HMTBulkTransferEvent', - id, - 'txHash', - bulkTransfer.transaction.hash.toHex() - ); - assert.fieldEquals('HMTBulkTransferEvent', id, 'txId', '1'); - assert.fieldEquals('HMTBulkTransferEvent', id, 'bulkCount', '3'); - assert.fieldEquals( - 'Transaction', - bulkTransfer.transaction.hash.toHex(), - 'txHash', - bulkTransfer.transaction.hash.toHex() - ); - assert.fieldEquals( - 'Transaction', - bulkTransfer.transaction.hash.toHex(), - 'method', - 'transferBulk' - ); - assert.fieldEquals( - 'Transaction', - bulkTransfer.transaction.hash.toHex(), - 'block', - bulkTransfer.block.number.toString() - ); - assert.fieldEquals( - 'Transaction', - bulkTransfer.transaction.hash.toHex(), - 'from', - bulkTransfer.transaction.from.toHex() - ); - }); - - test('Should properly handle Approval event', () => { - const approval = createApprovalEvent( - holderAddressString, - operatorAddressString, - 1, - BigInt.fromI32(100) - ); - - handleApproval(approval); - - const id = toEventId(approval).toHex(); - - // HMTApprovalEvent - assert.fieldEquals( - 'HMTApprovalEvent', - id, - 'block', - approval.block.number.toString() - ); - assert.fieldEquals( - 'HMTApprovalEvent', - id, - 'timestamp', - approval.block.timestamp.toString() - ); - assert.fieldEquals( - 'HMTApprovalEvent', - id, - 'txHash', - approval.transaction.hash.toHex() - ); - assert.fieldEquals('HMTApprovalEvent', id, 'owner', holderAddressString); - assert.fieldEquals( - 'HMTApprovalEvent', - id, - 'spender', - operatorAddressString - ); - assert.fieldEquals('HMTApprovalEvent', id, 'amount', '1'); - assert.fieldEquals( - 'Transaction', - approval.transaction.hash.toHex(), - 'txHash', - approval.transaction.hash.toHex() - ); - assert.fieldEquals( - 'Transaction', - approval.transaction.hash.toHex(), - 'method', - 'approve' - ); - assert.fieldEquals( - 'Transaction', - approval.transaction.hash.toHex(), - 'block', - approval.block.number.toString() - ); - assert.fieldEquals( - 'Transaction', - approval.transaction.hash.toHex(), - 'from', - approval.transaction.from.toHex() - ); - assert.fieldEquals( - 'Transaction', - approval.transaction.hash.toHex(), - 'value', - '1' - ); - }); - - test('Should properly handle BulkApproval event', () => { - const bulkApproval = createBulkApprovalEvent(1, 3, BigInt.fromI32(200)); - - handleBulkApproval(bulkApproval); - - const id = toEventId(bulkApproval).toHex(); - - // HMTBulkApprovalEvent - assert.fieldEquals( - 'HMTBulkApprovalEvent', - id, - 'block', - bulkApproval.block.number.toString() - ); - assert.fieldEquals( - 'HMTBulkApprovalEvent', - id, - 'timestamp', - bulkApproval.block.timestamp.toString() - ); - assert.fieldEquals( - 'HMTBulkApprovalEvent', - id, - 'txHash', - bulkApproval.transaction.hash.toHex() - ); - assert.fieldEquals('HMTBulkApprovalEvent', id, 'txId', '1'); - assert.fieldEquals('HMTBulkApprovalEvent', id, 'bulkCount', '3'); - assert.fieldEquals( - 'Transaction', - bulkApproval.transaction.hash.toHex(), - 'txHash', - bulkApproval.transaction.hash.toHex() - ); - assert.fieldEquals( - 'Transaction', - bulkApproval.transaction.hash.toHex(), - 'method', - 'increaseApprovalBulk' - ); - assert.fieldEquals( - 'Transaction', - bulkApproval.transaction.hash.toHex(), - 'block', - bulkApproval.block.number.toString() - ); - assert.fieldEquals( - 'Transaction', - bulkApproval.transaction.hash.toHex(), - 'from', - bulkApproval.transaction.from.toHex() - ); - }); - - describe('Statistics', () => { - beforeEach(() => { - clearStore(); - }); - - test('Should properly calculate Transfer event in statistics', () => { - const transfer1 = createTransferEvent( - '0xD979105297fB0eee83F7433fC09279cb5B94fFC6', - '0x92a2eEF7Ff696BCef98957a0189872680600a959', - 1, - BigInt.fromI32(10) - ); - const transfer2 = createTransferEvent( - '0xD979105297fB0eee83F7433fC09279cb5B94fFC6', - '0x92a2eEF7Ff696BCef98957a0189872680600a959', - 2, - BigInt.fromI32(10) - ); - - handleTransfer(transfer1); - handleTransfer(transfer2); - - assert.fieldEquals( - 'HMTokenStatistics', - HMT_STATISTICS_ENTITY_ID.toHex(), - 'totalTransferEventCount', - '2' - ); - assert.fieldEquals( - 'HMTokenStatistics', - HMT_STATISTICS_ENTITY_ID.toHex(), - 'totalValueTransfered', - '3' - ); - }); - - test('Should properly calculate holders in statistics', () => { - const transfer1 = createTransferEvent( - '0x0000000000000000000000000000000000000000', - holderAddressString, - 10, - BigInt.fromI32(10) - ); - - const transfer2 = createTransferEvent( - holderAddressString, - holder1AddressString, - 0, - BigInt.fromI32(10) - ); - - handleTransfer(transfer1); - handleTransfer(transfer2); - - assert.fieldEquals('Holder', holderAddress.toHex(), 'balance', '10'); - assert.fieldEquals('Holder', holder1Address.toHex(), 'balance', '0'); - - assert.fieldEquals( - 'HMTokenStatistics', - HMT_STATISTICS_ENTITY_ID.toHex(), - 'holders', - '1' - ); - - const transfer3 = createTransferEvent( - '0x0000000000000000000000000000000000000000', - holder1AddressString, - 10, - BigInt.fromI32(10) - ); - - handleTransfer(transfer3); - - assert.fieldEquals('Holder', holderAddress.toHex(), 'balance', '10'); - assert.fieldEquals('Holder', holder1Address.toHex(), 'balance', '10'); - assert.fieldEquals( - 'HMTokenStatistics', - HMT_STATISTICS_ENTITY_ID.toHex(), - 'holders', - '2' - ); - - const transfer4 = createTransferEvent( - holderAddressString, - holder1AddressString, - 10, - BigInt.fromI32(10) - ); - - handleTransfer(transfer4); - - assert.fieldEquals('Holder', holderAddress.toHex(), 'balance', '0'); - assert.fieldEquals('Holder', holder1Address.toHex(), 'balance', '20'); - assert.fieldEquals( - 'HMTokenStatistics', - HMT_STATISTICS_ENTITY_ID.toHex(), - 'holders', - '1' - ); - }); - - test('Should properly calculate BulkTransfer event in statistics', () => { - const bulkTransfer1 = createBulkTransferEvent(1, 3, BigInt.fromI32(10)); - const bulkTransfer2 = createBulkTransferEvent(2, 3, BigInt.fromI32(10)); - - handleBulkTransfer(bulkTransfer1); - handleBulkTransfer(bulkTransfer2); - - assert.fieldEquals( - 'HMTokenStatistics', - HMT_STATISTICS_ENTITY_ID.toHex(), - 'totalBulkTransferEventCount', - '2' - ); - }); - - test('Should properly calculate Approval event in statistics', () => { - const approval1 = createApprovalEvent( - '0x92a2eEF7Ff696BCef98957a0189872680600a959', - '0xD979105297fB0eee83F7433fC09279cb5B94fFC6', - 10, - BigInt.fromI32(10) - ); - - const approval2 = createApprovalEvent( - '0x92a2eEF7Ff696BCef98957a0189872680600a959', - '0xD979105297fB0eee83F7433fC09279cb5B94fFC6', - 10, - BigInt.fromI32(10) - ); - - handleApproval(approval1); - handleApproval(approval2); - - assert.fieldEquals( - 'HMTokenStatistics', - HMT_STATISTICS_ENTITY_ID.toHex(), - 'totalApprovalEventCount', - '2' - ); - }); - - test('Should properly calculate BulkApproval event in statistics', () => { - const bulkApproval1 = createBulkApprovalEvent(1, 3, BigInt.fromI32(10)); - const bulkApproval2 = createBulkApprovalEvent(2, 3, BigInt.fromI32(10)); - - handleBulkApproval(bulkApproval1); - handleBulkApproval(bulkApproval2); - - assert.fieldEquals( - 'HMTokenStatistics', - HMT_STATISTICS_ENTITY_ID.toHex(), - 'totalBulkApprovalEventCount', - '2' - ); - }); - }); -}); From f7568d2ce846c8f5c3ca2b48d8cd4a85ae6ff454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Wed, 25 Feb 2026 15:57:22 +0100 Subject: [PATCH 02/10] Add Human HMT statistics subgraph - Introduced a dedicated subgraph to index HMToken statistics. - Updated network configurations for Ethereum, BSC, Polygon, and Sepolia. - Implemented event handlers for Transfer, Approval, BulkTransfer, and BulkApproval events. - Created entities for HMTokenStatistics, Holder, UniqueSender, UniqueReceiver, and EventDayData. - Added tests to validate statistics calculations and daily metrics. - Included necessary configurations, scripts, and dependencies in package.json. - Set up ESLint and Prettier configurations for code quality. -Updated TS SDK with new Subgraph data --- .../human-protocol-sdk/example/statistics.ts | 18 +- .../human-protocol-sdk/src/constants.ts | 8 +- .../src/graphql/queries/statistics.ts | 38 ++- .../human-protocol-sdk/src/graphql/types.ts | 5 +- .../human-protocol-sdk/src/interfaces.ts | 2 - .../src/statistics/statistics_utils.ts | 30 +- .../human-protocol-sdk/src/types.ts | 8 + .../human-protocol-sdk/src/utils.ts | 20 ++ .../test/statistics.test.ts | 7 +- .../typescript/subgraph-hmt-stats/.gitignore | 12 + .../subgraph-hmt-stats/.prettierignore | 2 + .../typescript/subgraph-hmt-stats/.prettierrc | 7 + .../typescript/subgraph-hmt-stats/README.md | 66 ++++ .../subgraph-hmt-stats/config/amoy.json | 9 + .../config/bsc-testnet.json | 9 + .../subgraph-hmt-stats/config/bsc.json | 9 + .../subgraph-hmt-stats/config/ethereum.json | 9 + .../subgraph-hmt-stats/config/localhost.json | 9 + .../subgraph-hmt-stats/config/polygon.json | 9 + .../subgraph-hmt-stats/config/sepolia.json | 9 + .../subgraph-hmt-stats/eslint.config.mjs | 59 ++++ .../subgraph-hmt-stats/matchstick.yaml | 1 + .../subgraph-hmt-stats/package.json | 53 +++ .../subgraph-hmt-stats/schema.graphql | 38 +++ .../subgraph-hmt-stats/src/mapping/HMToken.ts | 203 ++++++++++++ .../src/mapping/utils/dayUpdates.ts | 24 ++ .../src/mapping/utils/number.ts | 6 + .../subgraph-hmt-stats/template.yaml | 37 +++ .../subgraph-hmt-stats/tests/hmt/fixtures.ts | 138 ++++++++ .../subgraph-hmt-stats/tests/hmt/hmt.test.ts | 302 ++++++++++++++++++ .../subgraph-hmt-stats/tests/utils.ts | 11 + .../subgraph-hmt-stats/tsconfig.json | 8 + .../sdk/typescript/subgraph/config/amoy.json | 6 +- .../subgraph/config/bsc-testnet.json | 6 +- .../sdk/typescript/subgraph/config/bsc.json | 6 +- .../typescript/subgraph/config/ethereum.json | 6 +- .../typescript/subgraph/config/localhost.json | 6 +- .../typescript/subgraph/config/polygon.json | 6 +- .../typescript/subgraph/config/sepolia.json | 6 +- yarn.lock | 17 + 40 files changed, 1142 insertions(+), 83 deletions(-) create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/.gitignore create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/.prettierignore create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/.prettierrc create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/README.md create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/config/amoy.json create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/config/bsc-testnet.json create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/config/bsc.json create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/config/ethereum.json create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/config/localhost.json create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/config/polygon.json create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/config/sepolia.json create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/eslint.config.mjs create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/matchstick.yaml create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/package.json create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/schema.graphql create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/src/mapping/HMToken.ts create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/dayUpdates.ts create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/number.ts create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/template.yaml create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/fixtures.ts create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/hmt.test.ts create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/tests/utils.ts create mode 100644 packages/sdk/typescript/subgraph-hmt-stats/tsconfig.json diff --git a/packages/sdk/typescript/human-protocol-sdk/example/statistics.ts b/packages/sdk/typescript/human-protocol-sdk/example/statistics.ts index 9a3c0f8f2b..f5979df609 100644 --- a/packages/sdk/typescript/human-protocol-sdk/example/statistics.ts +++ b/packages/sdk/typescript/human-protocol-sdk/example/statistics.ts @@ -38,14 +38,7 @@ import { ChainId } from '../src/enums'; const paymentStatistics = await StatisticsUtils.getPaymentStatistics(networkData); - console.log('Payment statistics:', { - ...paymentStatistics, - dailyPaymentsData: paymentStatistics.dailyPaymentsData.map((p) => ({ - ...p, - totalAmountPaid: p.totalAmountPaid.toString(), - averageAmountPerWorker: p.averageAmountPerWorker.toString(), - })), - }); + console.log('Payment statistics:', paymentStatistics); const paymentStatisticsRange = await StatisticsUtils.getPaymentStatistics( networkData, @@ -55,14 +48,7 @@ import { ChainId } from '../src/enums'; } ); - console.log('Payment statistics from 5/8 - 6/8:', { - ...paymentStatisticsRange, - dailyPaymentsData: paymentStatisticsRange.dailyPaymentsData.map((p) => ({ - ...p, - totalAmountPaid: p.totalAmountPaid.toString(), - averageAmountPerWorker: p.averageAmountPerWorker.toString(), - })), - }); + console.log('Payment statistics from 5/8 - 6/8:', paymentStatisticsRange); const hmtStatistics = await StatisticsUtils.getHMTStatistics(networkData); diff --git a/packages/sdk/typescript/human-protocol-sdk/src/constants.ts b/packages/sdk/typescript/human-protocol-sdk/src/constants.ts index 6a9006c802..92d20d79e8 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/constants.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/constants.ts @@ -111,11 +111,15 @@ export const NETWORKS: { stakingAddress: '0xffE496683F842a923110415b7278ded3F265f2C5', kvstoreAddress: '0x724AeFC243EdacCA27EAB86D3ec5a76Af4436Fc7', subgraphUrl: - 'https://api.studio.thegraph.com/query/74256/amoy/version/latest', + 'https://api.studio.thegraph.com/query/74256/human-amoy/version/latest', subgraphUrlApiKey: - 'https://gateway.thegraph.com/api/deployments/id/QmcLwLMw3UzCSbNbjegrpNu6PB3kAd67xquuyaVWvc5Q7Q', + 'https://gateway.thegraph.com/api/deployments/id/QmP7D2irmx3WP2pP97QTcQxiv91KEyTGftHBy98Foh7WHg', oldSubgraphUrl: '', oldFactoryAddress: '', + hmtSubgraphUrl: + 'https://api.studio.thegraph.com/query/74256/hmt-stats-amoy/version/latest', + hmtSubgraphUrlApiKey: + 'https://gateway.thegraph.com/api/deployments/id/QmZJYBQKyrsEJHQwNQ8JhkKcB5G8zQdrcwnr7ecGRNTBit', }, [ChainId.LOCALHOST]: { chainId: ChainId.LOCALHOST, diff --git a/packages/sdk/typescript/human-protocol-sdk/src/graphql/queries/statistics.ts b/packages/sdk/typescript/human-protocol-sdk/src/graphql/queries/statistics.ts index 2135d3ca7c..2490d561ed 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/graphql/queries/statistics.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/graphql/queries/statistics.ts @@ -42,7 +42,12 @@ const EVENT_DAY_DATA_FRAGMENT = gql` dailyEscrowCount dailyWorkerCount dailyPayoutCount - dailyHMTPayoutAmount + } +`; + +const HMT_EVENT_DAY_DATA_FRAGMENT = gql` + fragment HMTEventDayDataFields on EventDayData { + timestamp dailyHMTTransferCount dailyHMTTransferAmount dailyUniqueSenders @@ -102,3 +107,34 @@ export const GET_EVENT_DAY_DATA_QUERY = (params: IStatisticsFilter) => { ${EVENT_DAY_DATA_FRAGMENT} `; }; + +export const GET_HMT_EVENT_DAY_DATA_QUERY = (params: IStatisticsFilter) => { + const { from, to } = params; + const WHERE_CLAUSE = ` + where: { + ${from !== undefined ? `timestamp_gte: $from` : ''} + ${to !== undefined ? `timestamp_lte: $to` : ''} + } + `; + + return gql` + query GetHMTDayData( + $from: Int, + $to: Int, + $orderDirection: String + $first: Int + $skip: Int + ) { + eventDayDatas( + ${WHERE_CLAUSE}, + orderBy: timestamp, + orderDirection: $orderDirection, + first: $first, + skip: $skip + ) { + ...HMTEventDayDataFields + } + } + ${HMT_EVENT_DAY_DATA_FRAGMENT} + `; +}; 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 fed501218f..295acaac4a 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/graphql/types.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/graphql/types.ts @@ -95,7 +95,10 @@ export type EventDayData = { dailyEscrowCount: string; dailyWorkerCount: string; dailyPayoutCount: string; - dailyHMTPayoutAmount: string; +}; + +export type HMTEventDayData = { + timestamp: string; dailyHMTTransferCount: string; dailyHMTTransferAmount: string; dailyUniqueSenders: string; diff --git a/packages/sdk/typescript/human-protocol-sdk/src/interfaces.ts b/packages/sdk/typescript/human-protocol-sdk/src/interfaces.ts index e9bca41378..2da0a383af 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/interfaces.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/interfaces.ts @@ -254,9 +254,7 @@ export interface IWorkerStatistics { export interface IDailyPayment { timestamp: number; - totalAmountPaid: bigint; totalCount: number; - averageAmountPerWorker: bigint; } export interface IPaymentStatistics { diff --git a/packages/sdk/typescript/human-protocol-sdk/src/statistics/statistics_utils.ts b/packages/sdk/typescript/human-protocol-sdk/src/statistics/statistics_utils.ts index 1cf4b4422c..aceb9e63e0 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/statistics/statistics_utils.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/statistics/statistics_utils.ts @@ -3,8 +3,10 @@ import { OrderDirection } from '../enums'; import { EscrowStatisticsData, EventDayData, + HMTEventDayData, GET_ESCROW_STATISTICS_QUERY, GET_EVENT_DAY_DATA_QUERY, + GET_HMT_EVENT_DAY_DATA_QUERY, GET_HMTOKEN_STATISTICS_QUERY, GET_HOLDERS_QUERY, HMTHolderData, @@ -23,6 +25,7 @@ import { } from '../interfaces'; import { NetworkData } from '../types'; import { + getHMTSubgraphUrl, getSubgraphUrl, getUnixTimestamp, customGqlFetch, @@ -253,9 +256,7 @@ export class StatisticsUtils { * ```ts * interface IDailyPayment { * timestamp: number; - * totalAmountPaid: bigint; * totalCount: number; - * averageAmountPerWorker: bigint; * }; * * interface IPaymentStatistics { @@ -274,14 +275,7 @@ export class StatisticsUtils { * * const networkData = NETWORKS[ChainId.POLYGON_AMOY]; * const paymentStats = await StatisticsUtils.getPaymentStatistics(networkData); - * console.log( - * 'Payment statistics:', - * paymentStats.dailyPaymentsData.map((p) => ({ - * ...p, - * totalAmountPaid: p.totalAmountPaid.toString(), - * averageAmountPerWorker: p.averageAmountPerWorker.toString(), - * })) - * ); + * console.log('Payment statistics:', paymentStats.dailyPaymentsData); * * const paymentStatsRange = await StatisticsUtils.getPaymentStatistics( * networkData, @@ -323,13 +317,7 @@ export class StatisticsUtils { return { dailyPaymentsData: eventDayDatas.map((eventDayData) => ({ timestamp: +eventDayData.timestamp * 1000, - totalAmountPaid: BigInt(eventDayData.dailyHMTPayoutAmount), totalCount: +eventDayData.dailyPayoutCount, - averageAmountPerWorker: - eventDayData.dailyWorkerCount === '0' - ? BigInt(0) - : BigInt(eventDayData.dailyHMTPayoutAmount) / - BigInt(eventDayData.dailyWorkerCount), })), }; } catch (e: any) { @@ -369,7 +357,7 @@ export class StatisticsUtils { options?: SubgraphOptions ): Promise { try { - const subgraphUrl = getSubgraphUrl(networkData); + const subgraphUrl = getHMTSubgraphUrl(networkData); const { hmtokenStatistics } = await customGqlFetch<{ hmtokenStatistics: HMTStatisticsData; }>(subgraphUrl, GET_HMTOKEN_STATISTICS_QUERY, options); @@ -412,7 +400,7 @@ export class StatisticsUtils { options?: SubgraphOptions ): Promise { try { - const subgraphUrl = getSubgraphUrl(networkData); + const subgraphUrl = getHMTSubgraphUrl(networkData); const { address, orderDirection } = params; const query = GET_HOLDERS_QUERY(address); @@ -490,17 +478,17 @@ export class StatisticsUtils { options?: SubgraphOptions ): Promise { try { - const subgraphUrl = getSubgraphUrl(networkData); + const subgraphUrl = getHMTSubgraphUrl(networkData); const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10; const skip = filter.skip || 0; const orderDirection = filter.orderDirection || OrderDirection.ASC; const { eventDayDatas } = await customGqlFetch<{ - eventDayDatas: EventDayData[]; + eventDayDatas: HMTEventDayData[]; }>( subgraphUrl, - GET_EVENT_DAY_DATA_QUERY(filter), + GET_HMT_EVENT_DAY_DATA_QUERY(filter), { from: filter.from ? getUnixTimestamp(filter.from) : undefined, to: filter.to ? getUnixTimestamp(filter.to) : undefined, diff --git a/packages/sdk/typescript/human-protocol-sdk/src/types.ts b/packages/sdk/typescript/human-protocol-sdk/src/types.ts index 9ced185a32..b6ea17852a 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/types.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/types.ts @@ -76,6 +76,14 @@ export type NetworkData = { * Subgraph URL API key */ subgraphUrlApiKey: string; + /** + * HMT statistics subgraph URL + */ + hmtSubgraphUrl?: string; + /** + * HMT statistics subgraph URL API key + */ + hmtSubgraphUrlApiKey?: string; /** * Old subgraph URL */ diff --git a/packages/sdk/typescript/human-protocol-sdk/src/utils.ts b/packages/sdk/typescript/human-protocol-sdk/src/utils.ts index 5d28485d4e..5a9de8a2e5 100644 --- a/packages/sdk/typescript/human-protocol-sdk/src/utils.ts +++ b/packages/sdk/typescript/human-protocol-sdk/src/utils.ts @@ -98,6 +98,26 @@ export const getSubgraphUrl = (networkData: NetworkData) => { return subgraphUrl; }; +/** + * Gets the HMT statistics subgraph URL for the given network. + * Falls back to the default subgraph URL when a dedicated HMT endpoint is not configured. + * + * @param networkData - The network data containing subgraph URLs + * @returns The HMT statistics subgraph URL with API key if available + */ +export const getHMTSubgraphUrl = (networkData: NetworkData) => { + let subgraphUrl = networkData.hmtSubgraphUrl || networkData.subgraphUrl; + if (process.env.SUBGRAPH_API_KEY) { + subgraphUrl = + networkData.hmtSubgraphUrlApiKey || networkData.subgraphUrlApiKey; + } else if (networkData.chainId !== ChainId.LOCALHOST) { + // eslint-disable-next-line no-console + console.warn(WarnSubgraphApiKeyNotProvided); + } + + return subgraphUrl; +}; + /** * Converts a Date object to Unix timestamp (seconds since epoch). * diff --git a/packages/sdk/typescript/human-protocol-sdk/test/statistics.test.ts b/packages/sdk/typescript/human-protocol-sdk/test/statistics.test.ts index e3b152056f..2ddd183cee 100644 --- a/packages/sdk/typescript/human-protocol-sdk/test/statistics.test.ts +++ b/packages/sdk/typescript/human-protocol-sdk/test/statistics.test.ts @@ -12,6 +12,7 @@ import { StatisticsUtils } from '../src/statistics'; import { GET_ESCROW_STATISTICS_QUERY, GET_EVENT_DAY_DATA_QUERY, + GET_HMT_EVENT_DAY_DATA_QUERY, GET_HOLDERS_QUERY, } from '../src/graphql/queries'; @@ -171,8 +172,6 @@ describe('StatisticsUtils', () => { { timestamp: 1, dailyPayoutCount: '4', - dailyHMTPayoutAmount: '100', - dailyWorkerCount: '4', }, ], }); @@ -202,9 +201,7 @@ describe('StatisticsUtils', () => { dailyPaymentsData: [ { timestamp: 1000, - totalAmountPaid: ethers.toBigInt(100), totalCount: 4, - averageAmountPerWorker: ethers.toBigInt(25), }, ], }); @@ -447,7 +444,7 @@ describe('StatisticsUtils', () => { expect(gqlFetchSpy).toHaveBeenCalledWith( 'https://api.studio.thegraph.com/query/74256/polygon/version/latest', - GET_EVENT_DAY_DATA_QUERY({ from, to }), + GET_HMT_EVENT_DAY_DATA_QUERY({ from, to }), { from: Math.floor(from.getTime() / 1000), to: Math.floor(to.getTime() / 1000), diff --git a/packages/sdk/typescript/subgraph-hmt-stats/.gitignore b/packages/sdk/typescript/subgraph-hmt-stats/.gitignore new file mode 100644 index 0000000000..814a4b37a2 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/.gitignore @@ -0,0 +1,12 @@ +# Graph build +build/ + +# Graph generated +generated/ + +# Mustache generated +subgraph.yaml + +# Graph test generated +tests/.bin +tests/.latest.json diff --git a/packages/sdk/typescript/subgraph-hmt-stats/.prettierignore b/packages/sdk/typescript/subgraph-hmt-stats/.prettierignore new file mode 100644 index 0000000000..55be744ac5 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/.prettierignore @@ -0,0 +1,2 @@ +# Mustache template; not valid YAML for Prettier's YAML parser +template.yaml diff --git a/packages/sdk/typescript/subgraph-hmt-stats/.prettierrc b/packages/sdk/typescript/subgraph-hmt-stats/.prettierrc new file mode 100644 index 0000000000..4a2b9855ac --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/.prettierrc @@ -0,0 +1,7 @@ +{ + "semi": true, + "trailingComma": "es5", + "singleQuote": true, + "printWidth": 80, + "arrowParens": "always" +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/README.md b/packages/sdk/typescript/subgraph-hmt-stats/README.md new file mode 100644 index 0000000000..8c9d054dca --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/README.md @@ -0,0 +1,66 @@ +

+ Human Protocol +

+ +

Human HMT statistics subgraph

+

+Dedicated subgraph to index HMToken statistics only. +

+ +## Installation + +Package installation: + +```bash +yarn install && yarn workspace human-protocol build:core +``` + +## Development + +Generate and build artifacts for a network: + +```bash +NETWORK=polygon yarn workspace @tools/subgraph-hmt-stats generate +NETWORK=polygon yarn workspace @tools/subgraph-hmt-stats build +``` + +### Tests + +To run subgraph tests: + +```bash +NETWORK=polygon yarn workspace @tools/subgraph-hmt-stats generate +yarn workspace @tools/subgraph-hmt-stats test +``` + +This subgraph does not use staking/escrow templates. + +## Indexed entities + +- `HMTokenStatistics` +- `Holder` +- `UniqueSender` +- `UniqueReceiver` +- `EventDayData` (HMT daily fields only) + +## Supported networks + +- Ethereum Mainnet +- Sepolia (testnet) +- BSC Mainnet +- BSC Testnet (testnet) +- Polygon Mainnet +- Polygon Amoy (testnet) +- Localhost + +## Add a new network + +1. Add network configuration as `config/NETWORK.json`. +2. Ensure required fields are present: + - `network` + - `description` + - `HMToken.address` + - `HMToken.startBlock` + - `HMToken.abi` +3. Generate artifacts: `NETWORK=NETWORK yarn workspace @tools/subgraph-hmt-stats generate`. +4. Build subgraph: `yarn workspace @tools/subgraph-hmt-stats build`. diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/amoy.json b/packages/sdk/typescript/subgraph-hmt-stats/config/amoy.json new file mode 100644 index 0000000000..937cafd584 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/config/amoy.json @@ -0,0 +1,9 @@ +{ + "network": "polygon-amoy", + "description": "HUMAN subgraph on Amoy Testnet", + "HMToken": { + "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33", + "startBlock": 5769546, + "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + } +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/bsc-testnet.json b/packages/sdk/typescript/subgraph-hmt-stats/config/bsc-testnet.json new file mode 100644 index 0000000000..19bfc537e5 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/config/bsc-testnet.json @@ -0,0 +1,9 @@ +{ + "network": "chapel", + "description": "Human subgraph on Binance Smart Chain testnet", + "HMToken": { + "address": "0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d", + "startBlock": 26716354, + "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + } +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/bsc.json b/packages/sdk/typescript/subgraph-hmt-stats/config/bsc.json new file mode 100644 index 0000000000..4cb6113d3d --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/config/bsc.json @@ -0,0 +1,9 @@ +{ + "network": "bsc", + "description": "Human subgraph on BSC mainnet", + "HMToken": { + "address": "0x711Fd6ab6d65A98904522d4e3586F492B989c527", + "startBlock": 25383172, + "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + } +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/ethereum.json b/packages/sdk/typescript/subgraph-hmt-stats/config/ethereum.json new file mode 100644 index 0000000000..1bbab2e103 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/config/ethereum.json @@ -0,0 +1,9 @@ +{ + "network": "mainnet", + "description": "Human subgraph on Ethereum Mainnet", + "HMToken": { + "address": "0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867", + "startBlock": 12184475, + "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + } +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/localhost.json b/packages/sdk/typescript/subgraph-hmt-stats/config/localhost.json new file mode 100644 index 0000000000..7095fe08c2 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/config/localhost.json @@ -0,0 +1,9 @@ +{ + "network": "localhost", + "description": "Human subgraph on localhost", + "HMToken": { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "startBlock": 1, + "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + } +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/polygon.json b/packages/sdk/typescript/subgraph-hmt-stats/config/polygon.json new file mode 100644 index 0000000000..8910397dec --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/config/polygon.json @@ -0,0 +1,9 @@ +{ + "network": "matic", + "description": "Human subgraph on Polygon mainnet", + "HMToken": { + "address": "0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571Bf", + "startBlock": 20181701, + "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + } +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/sepolia.json b/packages/sdk/typescript/subgraph-hmt-stats/config/sepolia.json new file mode 100644 index 0000000000..8530750796 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/config/sepolia.json @@ -0,0 +1,9 @@ +{ + "network": "sepolia", + "description": "HUMAN subgraph on Sepolia Ethereum Testnet", + "HMToken": { + "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33", + "startBlock": 5716225, + "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + } +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/eslint.config.mjs b/packages/sdk/typescript/subgraph-hmt-stats/eslint.config.mjs new file mode 100644 index 0000000000..666059c3d0 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/eslint.config.mjs @@ -0,0 +1,59 @@ +import eslint from '@eslint/js'; +import globals from 'globals'; +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; +import tseslint from 'typescript-eslint'; +import { flatConfigs as graphqlFlatConfigs } from '@graphql-eslint/eslint-plugin'; +const graphqlOperations = graphqlFlatConfigs['operations-recommended']; + +export default tseslint.config( + { + ignores: ['build', 'generated', 'schema.graphql'], + }, + eslint.configs.recommended, + tseslint.configs.recommended, + eslintPluginPrettierRecommended, + { + files: ['**/*.ts', '**/*.js'], + languageOptions: { + globals: { + ...globals.node, + ...globals.es2022, + }, + ecmaVersion: 2022, + sourceType: 'module', + parserOptions: { + projectService: true, + tsconfigRootDir: import.meta.dirname, + }, + }, + rules: { + 'no-useless-assignment': 'off', + 'preserve-caught-error': 'off', + 'no-console': 'warn', + '@/quotes': [ + 'error', + 'single', + { avoidEscape: true, allowTemplateLiterals: true }, + ], + }, + }, + { + files: ['**/*.graphql'], + languageOptions: { + ...(graphqlOperations.languageOptions ?? {}), + parserOptions: { + ...(graphqlOperations.languageOptions?.parserOptions ?? {}), + schema: './schema.graphql', + }, + }, + rules: graphqlOperations.rules, + }, + { + files: ['**/*.spec.ts', '**/*.spec.tsx', '**/*.test.ts', '**/*.test.tsx'], + languageOptions: { + globals: { + ...globals.jest, + }, + }, + } +); diff --git a/packages/sdk/typescript/subgraph-hmt-stats/matchstick.yaml b/packages/sdk/typescript/subgraph-hmt-stats/matchstick.yaml new file mode 100644 index 0000000000..b6dd695aba --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/matchstick.yaml @@ -0,0 +1 @@ +libsFolder: ../../../../node_modules diff --git a/packages/sdk/typescript/subgraph-hmt-stats/package.json b/packages/sdk/typescript/subgraph-hmt-stats/package.json new file mode 100644 index 0000000000..d65873590f --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/package.json @@ -0,0 +1,53 @@ +{ + "name": "@tools/subgraph-hmt-stats", + "private": true, + "description": "Human Protocol HMT Statistics Subgraph", + "version": "1.0.0", + "files": [ + "generated" + ], + "scripts": { + "clean": "rm -rf build generated subgraph.yaml", + "generate": "mustache ./config/$NETWORK.json template.yaml > subgraph.yaml && graph codegen", + "codegen": "graph codegen", + "build": "graph build", + "test": "NETWORK=polygon yarn generate && graph test", + "lint": "eslint .", + "lint:fix": "eslint . --fix", + "format": "prettier --write '**/*.{ts,json,graphql,yaml}'" + }, + "repository": { + "type": "git", + "url": "https://github.com/humanprotocol/human-protocol.git", + "directory": "packages/sdk/typescript/subgraph-hmt-stats" + }, + "keywords": [ + "human-protocol", + "sdk", + "subgraph", + "hmt", + "statistics" + ], + "license": "MIT", + "devDependencies": { + "@graphprotocol/graph-cli": "^0.97.1", + "@graphprotocol/graph-ts": "^0.38.0", + "@graphql-eslint/eslint-plugin": "^3.19.1", + "@human-protocol/core": "workspace:*", + "eslint": "^9.39.1", + "ethers": "~6.15.0", + "graphql": "^16.6.0", + "matchstick-as": "^0.6.0", + "mustache": "^4.2.0", + "prettier": "^3.8.1" + }, + "lint-staged": { + "*.{ts,graphql}": [ + "prettier --write", + "eslint --fix" + ], + "*.{yaml,json}": [ + "prettier --write" + ] + } +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/schema.graphql b/packages/sdk/typescript/subgraph-hmt-stats/schema.graphql new file mode 100644 index 0000000000..75ae97773a --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/schema.graphql @@ -0,0 +1,38 @@ +type HMTokenStatistics @entity(immutable: false) { + id: Bytes! + totalTransferEventCount: BigInt! + totalBulkTransferEventCount: BigInt! + totalApprovalEventCount: BigInt! + totalBulkApprovalEventCount: BigInt! + totalValueTransfered: BigInt! + holders: BigInt! +} + +type Holder @entity(immutable: false) { + id: Bytes! + address: Bytes! + balance: BigInt! +} + +type UniqueSender @entity(immutable: false) { + id: Bytes! + address: Bytes! + transferCount: BigInt! + timestamp: BigInt! +} + +type UniqueReceiver @entity(immutable: false) { + id: Bytes! + address: Bytes! + receiveCount: BigInt! + timestamp: BigInt! +} + +type EventDayData @entity(immutable: false) { + id: Bytes! + timestamp: Int! + dailyHMTTransferCount: BigInt! + dailyHMTTransferAmount: BigInt! + dailyUniqueSenders: BigInt! + dailyUniqueReceivers: BigInt! +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/HMToken.ts b/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/HMToken.ts new file mode 100644 index 0000000000..e94ce96287 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/HMToken.ts @@ -0,0 +1,203 @@ +import { Address, BigInt, Bytes } from '@graphprotocol/graph-ts'; + +import { + Approval, + BulkApproval, + BulkTransfer, + Transfer, +} from '../../generated/HMToken/HMToken'; +import { + HMTokenStatistics, + Holder, + UniqueReceiver, + UniqueSender, +} from '../../generated/schema'; +import { getEventDayData } from './utils/dayUpdates'; +import { ONE_BI, ONE_DAY, ZERO_BI } from './utils/number'; + +export const HMT_STATISTICS_ENTITY_ID = Bytes.fromUTF8('hmt-statistics-id'); +const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; + +function constructStatsEntity(): HMTokenStatistics { + const entity = new HMTokenStatistics(HMT_STATISTICS_ENTITY_ID); + + entity.totalTransferEventCount = ZERO_BI; + entity.totalApprovalEventCount = ZERO_BI; + entity.totalBulkApprovalEventCount = ZERO_BI; + entity.totalBulkTransferEventCount = ZERO_BI; + entity.totalValueTransfered = ZERO_BI; + entity.holders = ZERO_BI; + + return entity; +} + +function createOrLoadUniqueSender( + dayStartTimestamp: BigInt, + timestamp: BigInt, + address: Address +): UniqueSender { + const id = Bytes.fromI32(dayStartTimestamp.toI32()).concat(address); + let uniqueSender = UniqueSender.load(id); + + if (!uniqueSender) { + uniqueSender = new UniqueSender(id); + uniqueSender.address = address; + uniqueSender.transferCount = ZERO_BI; + uniqueSender.timestamp = timestamp; + uniqueSender.save(); + } + + return uniqueSender; +} + +function createOrLoadUniqueReceiver( + dayStartTimestamp: BigInt, + timestamp: BigInt, + address: Address +): UniqueReceiver { + const id = Bytes.fromI32(dayStartTimestamp.toI32()).concat(address); + let uniqueReceiver = UniqueReceiver.load(id); + + if (!uniqueReceiver) { + uniqueReceiver = new UniqueReceiver(id); + uniqueReceiver.address = address; + uniqueReceiver.receiveCount = ZERO_BI; + uniqueReceiver.timestamp = timestamp; + uniqueReceiver.save(); + } + + return uniqueReceiver; +} + +function updateHolders( + holderAddress: Address, + value: BigInt, + increase: boolean +): BigInt { + if (holderAddress.toHexString() == ZERO_ADDRESS) { + return ZERO_BI; + } + + let count = ZERO_BI; + let holder = Holder.load(holderAddress); + + if (holder == null) { + holder = new Holder(holderAddress); + holder.address = holderAddress; + holder.balance = ZERO_BI; + } + + const balanceBeforeTransfer = holder.balance; + holder.balance = increase + ? holder.balance.plus(value) + : holder.balance.minus(value); + + if (balanceBeforeTransfer.isZero() && !holder.balance.isZero()) { + count = ONE_BI; + } else if (!balanceBeforeTransfer.isZero() && holder.balance.isZero()) { + count = ONE_BI.neg(); + } + + holder.save(); + + return count; +} + +function createOrLoadHMTStatistics(): HMTokenStatistics { + let statsEntity = HMTokenStatistics.load(HMT_STATISTICS_ENTITY_ID); + + if (!statsEntity) { + statsEntity = constructStatsEntity(); + } + + return statsEntity; +} + +export function handleTransfer(event: Transfer): void { + const statsEntity = createOrLoadHMTStatistics(); + statsEntity.totalTransferEventCount = + statsEntity.totalTransferEventCount.plus(ONE_BI); + statsEntity.totalValueTransfered = statsEntity.totalValueTransfered.plus( + event.params._value + ); + + const diffHolders = updateHolders( + event.params._from, + event.params._value, + false + ).plus(updateHolders(event.params._to, event.params._value, true)); + statsEntity.holders = statsEntity.holders.plus(diffHolders); + + const eventDayData = getEventDayData(event); + eventDayData.dailyHMTTransferCount = + eventDayData.dailyHMTTransferCount.plus(ONE_BI); + eventDayData.dailyHMTTransferAmount = + eventDayData.dailyHMTTransferAmount.plus(event.params._value); + + const timestamp = event.block.timestamp.toI32(); + const dayID = timestamp / ONE_DAY; + const dayStartTimestamp = BigInt.fromI32(dayID * ONE_DAY); + + if (event.params._from.toHexString() != ZERO_ADDRESS) { + const uniqueSender = createOrLoadUniqueSender( + dayStartTimestamp, + event.block.timestamp, + event.params._from + ); + + if (uniqueSender.transferCount.equals(ZERO_BI)) { + eventDayData.dailyUniqueSenders = + eventDayData.dailyUniqueSenders.plus(ONE_BI); + } + + uniqueSender.transferCount = uniqueSender.transferCount.plus( + event.params._value + ); + uniqueSender.save(); + } + + if (event.params._to.toHexString() != ZERO_ADDRESS) { + const uniqueReceiver = createOrLoadUniqueReceiver( + dayStartTimestamp, + event.block.timestamp, + event.params._to + ); + + if (uniqueReceiver.receiveCount.equals(ZERO_BI)) { + eventDayData.dailyUniqueReceivers = + eventDayData.dailyUniqueReceivers.plus(ONE_BI); + } + + uniqueReceiver.receiveCount = uniqueReceiver.receiveCount.plus( + event.params._value + ); + uniqueReceiver.save(); + } + + eventDayData.save(); + statsEntity.save(); +} + +export function handleBulkTransfer(event: BulkTransfer): void { + void event; + const statsEntity = createOrLoadHMTStatistics(); + statsEntity.totalBulkTransferEventCount = + statsEntity.totalBulkTransferEventCount.plus(ONE_BI); + statsEntity.save(); +} + +export function handleApproval(event: Approval): void { + void event; + const statsEntity = createOrLoadHMTStatistics(); + statsEntity.totalApprovalEventCount = + statsEntity.totalApprovalEventCount.plus(ONE_BI); + statsEntity.save(); +} + +export function handleBulkApproval(event: BulkApproval): void { + void event; + const statsEntity = createOrLoadHMTStatistics(); + statsEntity.totalBulkApprovalEventCount = + statsEntity.totalBulkApprovalEventCount.plus(ONE_BI); + statsEntity.save(); +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/dayUpdates.ts b/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/dayUpdates.ts new file mode 100644 index 0000000000..2706271424 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/dayUpdates.ts @@ -0,0 +1,24 @@ +import { Bytes, ethereum } from '@graphprotocol/graph-ts'; +import { EventDayData } from '../../../generated/schema'; +import { ONE_DAY, ZERO_BI } from './number'; + +export function getEventDayData(event: ethereum.Event): EventDayData { + const timestamp = event.block.timestamp.toI32(); + const dayID = timestamp / ONE_DAY; + const dayStartTimestamp = dayID * ONE_DAY; + + const id = Bytes.fromI32(dayID); + let eventDayData = EventDayData.load(id); + + if (eventDayData == null) { + eventDayData = new EventDayData(id); + eventDayData.timestamp = dayStartTimestamp; + eventDayData.dailyHMTTransferCount = ZERO_BI; + eventDayData.dailyHMTTransferAmount = ZERO_BI; + eventDayData.dailyUniqueSenders = ZERO_BI; + eventDayData.dailyUniqueReceivers = ZERO_BI; + eventDayData.save(); + } + + return eventDayData; +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/number.ts b/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/number.ts new file mode 100644 index 0000000000..476fba0237 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/number.ts @@ -0,0 +1,6 @@ +import { BigInt } from '@graphprotocol/graph-ts'; + +export const ZERO_BI = BigInt.fromI32(0); +export const ONE_BI = BigInt.fromI32(1); + +export const ONE_DAY = 86400; diff --git a/packages/sdk/typescript/subgraph-hmt-stats/template.yaml b/packages/sdk/typescript/subgraph-hmt-stats/template.yaml new file mode 100644 index 0000000000..ae4cb544ab --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/template.yaml @@ -0,0 +1,37 @@ +specVersion: 1.0.0 +description: '{{ description }}' +schema: + file: ./schema.graphql +indexerHints: + prune: auto +dataSources: + - kind: ethereum + name: HMToken + network: '{{ network }}' + source: + abi: HMToken + address: '{{ HMToken.address }}' + startBlock: {{ HMToken.startBlock }} + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - HMTokenStatistics + - Holder + - EventDayData + - UniqueSender + - UniqueReceiver + abis: + - name: HMToken + file: '{{{ HMToken.abi }}}' + eventHandlers: + - event: Approval(indexed address,indexed address,uint256) + handler: handleApproval + - event: BulkApproval(indexed uint256,uint256) + handler: handleBulkApproval + - event: BulkTransfer(indexed uint256,uint256) + handler: handleBulkTransfer + - event: Transfer(indexed address,indexed address,uint256) + handler: handleTransfer + file: ./src/mapping/HMToken.ts diff --git a/packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/fixtures.ts b/packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/fixtures.ts new file mode 100644 index 0000000000..11f8ce43dd --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/fixtures.ts @@ -0,0 +1,138 @@ +import { newMockEvent } from 'matchstick-as/assembly/index'; +import { Address, BigInt, ethereum } from '@graphprotocol/graph-ts'; + +import { + Transfer, + Approval, + BulkTransfer, + BulkApproval, +} from '../../generated/HMToken/HMToken'; +import { generateUniqueHash } from '../../tests/utils'; + +const TOKEN_ADDRESS = '0xa16081f360e3847006db660bae1c6d1b2e17ffaa'; + +export function createTransferEvent( + from: string, + to: string, + value: i32, + timestamp: BigInt +): Transfer { + const transferEvent = changetype(newMockEvent()); + transferEvent.transaction.hash = generateUniqueHash( + to, + timestamp, + transferEvent.transaction.nonce + ); + transferEvent.transaction.from = Address.fromString(from); + transferEvent.transaction.to = Address.fromString(TOKEN_ADDRESS); + transferEvent.block.timestamp = timestamp; + transferEvent.block.number = timestamp; + + transferEvent.parameters = []; + transferEvent.parameters.push( + new ethereum.EventParam( + '_from', + ethereum.Value.fromAddress(Address.fromString(from)) + ) + ); + transferEvent.parameters.push( + new ethereum.EventParam( + '_to', + ethereum.Value.fromAddress(Address.fromString(to)) + ) + ); + transferEvent.parameters.push( + new ethereum.EventParam('_value', ethereum.Value.fromI32(value)) + ); + + return transferEvent; +} + +export function createApprovalEvent( + owner: string, + spender: string, + value: i32, + timestamp: BigInt +): Approval { + const approvalEvent = changetype(newMockEvent()); + approvalEvent.transaction.hash = generateUniqueHash( + owner, + timestamp, + approvalEvent.transaction.nonce + ); + approvalEvent.transaction.from = Address.fromString(owner); + approvalEvent.transaction.to = Address.fromString(TOKEN_ADDRESS); + approvalEvent.block.timestamp = timestamp; + approvalEvent.block.number = timestamp; + + approvalEvent.parameters = []; + approvalEvent.parameters.push( + new ethereum.EventParam( + '_owner', + ethereum.Value.fromAddress(Address.fromString(owner)) + ) + ); + approvalEvent.parameters.push( + new ethereum.EventParam( + '_spender', + ethereum.Value.fromAddress(Address.fromString(spender)) + ) + ); + approvalEvent.parameters.push( + new ethereum.EventParam('_value', ethereum.Value.fromI32(value)) + ); + + return approvalEvent; +} + +export function createBulkTransferEvent( + txId: i32, + bulkCount: i32, + timestamp: BigInt +): BulkTransfer { + const bulkTransferEvent = changetype(newMockEvent()); + bulkTransferEvent.transaction.hash = generateUniqueHash( + txId.toString(), + timestamp, + bulkTransferEvent.transaction.nonce + ); + bulkTransferEvent.transaction.to = Address.fromString(TOKEN_ADDRESS); + bulkTransferEvent.block.timestamp = timestamp; + bulkTransferEvent.block.number = timestamp; + + bulkTransferEvent.parameters = []; + bulkTransferEvent.parameters.push( + new ethereum.EventParam('_txId', ethereum.Value.fromI32(txId)) + ); + bulkTransferEvent.parameters.push( + new ethereum.EventParam('_bulkCount', ethereum.Value.fromI32(bulkCount)) + ); + + return bulkTransferEvent; +} + +export function createBulkApprovalEvent( + txId: i32, + bulkCount: i32, + timestamp: BigInt +): BulkApproval { + const bulkApprovalEvent = changetype(newMockEvent()); + bulkApprovalEvent.transaction.hash = generateUniqueHash( + txId.toString(), + timestamp, + bulkApprovalEvent.transaction.nonce + ); + bulkApprovalEvent.transaction.to = Address.fromString(TOKEN_ADDRESS); + bulkApprovalEvent.block.timestamp = timestamp; + bulkApprovalEvent.block.number = timestamp; + + bulkApprovalEvent.parameters = []; + bulkApprovalEvent.parameters.push( + new ethereum.EventParam('_txId', ethereum.Value.fromI32(txId)) + ); + bulkApprovalEvent.parameters.push( + new ethereum.EventParam('_bulkCount', ethereum.Value.fromI32(bulkCount)) + ); + + return bulkApprovalEvent; +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/hmt.test.ts b/packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/hmt.test.ts new file mode 100644 index 0000000000..92ab93fb4d --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/hmt.test.ts @@ -0,0 +1,302 @@ +import { Address, BigInt, Bytes } from '@graphprotocol/graph-ts'; +import { + afterAll, + assert, + beforeEach, + clearStore, + describe, + test, +} from 'matchstick-as/assembly'; + +import { + HMT_STATISTICS_ENTITY_ID, + handleApproval, + handleBulkApproval, + handleBulkTransfer, + handleTransfer, +} from '../../src/mapping/HMToken'; +import { ONE_DAY } from '../../src/mapping/utils/number'; +import { + createApprovalEvent, + createBulkApprovalEvent, + createBulkTransferEvent, + createTransferEvent, +} from './fixtures'; + +const zeroAddressString = '0x0000000000000000000000000000000000000000'; +const operatorAddressString = '0xD979105297fB0eee83F7433fC09279cb5B94fFC6'; +const holderAddressString = '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'; +const holderAddress = Address.fromString(holderAddressString); +const holder1AddressString = '0x92a2eEF7Ff696BCef98957a0189872680600a959'; +const holder1Address = Address.fromString(holder1AddressString); + +describe('HMToken', () => { + beforeEach(() => { + clearStore(); + }); + + afterAll(() => { + clearStore(); + }); + + describe('Statistics', () => { + test('Should properly calculate Transfer event in statistics', () => { + const transfer1 = createTransferEvent( + operatorAddressString, + holder1AddressString, + 1, + BigInt.fromI32(10) + ); + const transfer2 = createTransferEvent( + operatorAddressString, + holder1AddressString, + 2, + BigInt.fromI32(10) + ); + + handleTransfer(transfer1); + handleTransfer(transfer2); + + assert.fieldEquals( + 'HMTokenStatistics', + HMT_STATISTICS_ENTITY_ID.toHex(), + 'totalTransferEventCount', + '2' + ); + assert.fieldEquals( + 'HMTokenStatistics', + HMT_STATISTICS_ENTITY_ID.toHex(), + 'totalValueTransfered', + '3' + ); + }); + + test('Should properly calculate holders in statistics', () => { + const transfer1 = createTransferEvent( + zeroAddressString, + holderAddressString, + 10, + BigInt.fromI32(10) + ); + + const transfer2 = createTransferEvent( + holderAddressString, + holder1AddressString, + 0, + BigInt.fromI32(10) + ); + + handleTransfer(transfer1); + handleTransfer(transfer2); + + assert.fieldEquals('Holder', holderAddress.toHex(), 'balance', '10'); + assert.fieldEquals('Holder', holder1Address.toHex(), 'balance', '0'); + + assert.fieldEquals( + 'HMTokenStatistics', + HMT_STATISTICS_ENTITY_ID.toHex(), + 'holders', + '1' + ); + + const transfer3 = createTransferEvent( + zeroAddressString, + holder1AddressString, + 10, + BigInt.fromI32(10) + ); + + handleTransfer(transfer3); + + assert.fieldEquals('Holder', holderAddress.toHex(), 'balance', '10'); + assert.fieldEquals('Holder', holder1Address.toHex(), 'balance', '10'); + assert.fieldEquals( + 'HMTokenStatistics', + HMT_STATISTICS_ENTITY_ID.toHex(), + 'holders', + '2' + ); + + const transfer4 = createTransferEvent( + holderAddressString, + holder1AddressString, + 10, + BigInt.fromI32(10) + ); + + handleTransfer(transfer4); + + assert.fieldEquals('Holder', holderAddress.toHex(), 'balance', '0'); + assert.fieldEquals('Holder', holder1Address.toHex(), 'balance', '20'); + assert.fieldEquals( + 'HMTokenStatistics', + HMT_STATISTICS_ENTITY_ID.toHex(), + 'holders', + '1' + ); + }); + + test('Should properly calculate Transfer daily metrics in statistics', () => { + const transfer1 = createTransferEvent( + operatorAddressString, + holderAddressString, + 1, + BigInt.fromI32(100) + ); + const transfer2 = createTransferEvent( + operatorAddressString, + holder1AddressString, + 2, + BigInt.fromI32(100) + ); + const transfer3 = createTransferEvent( + holder1AddressString, + holderAddressString, + 3, + BigInt.fromI32(100) + ); + + handleTransfer(transfer1); + handleTransfer(transfer2); + handleTransfer(transfer3); + + const dayZeroId = Bytes.fromI32(0).toHex(); + assert.fieldEquals('EventDayData', dayZeroId, 'timestamp', '0'); + assert.fieldEquals( + 'EventDayData', + dayZeroId, + 'dailyHMTTransferCount', + '3' + ); + assert.fieldEquals( + 'EventDayData', + dayZeroId, + 'dailyHMTTransferAmount', + '6' + ); + assert.fieldEquals('EventDayData', dayZeroId, 'dailyUniqueSenders', '2'); + assert.fieldEquals( + 'EventDayData', + dayZeroId, + 'dailyUniqueReceivers', + '2' + ); + + const operatorSenderId = Bytes.fromI32(0) + .concat(Address.fromString(operatorAddressString)) + .toHex(); + const holder1SenderId = Bytes.fromI32(0).concat(holder1Address).toHex(); + const holderReceiverId = Bytes.fromI32(0).concat(holderAddress).toHex(); + const holder1ReceiverId = Bytes.fromI32(0).concat(holder1Address).toHex(); + + assert.fieldEquals( + 'UniqueSender', + operatorSenderId, + 'transferCount', + '3' + ); + assert.fieldEquals('UniqueSender', holder1SenderId, 'transferCount', '3'); + assert.fieldEquals( + 'UniqueReceiver', + holderReceiverId, + 'receiveCount', + '4' + ); + assert.fieldEquals( + 'UniqueReceiver', + holder1ReceiverId, + 'receiveCount', + '2' + ); + }); + + test('Should properly create separate daily stats per day', () => { + const day0Transfer = createTransferEvent( + zeroAddressString, + holderAddressString, + 5, + BigInt.fromI32(100) + ); + const day1Transfer = createTransferEvent( + zeroAddressString, + holderAddressString, + 7, + BigInt.fromI32(ONE_DAY + 100) + ); + + handleTransfer(day0Transfer); + handleTransfer(day1Transfer); + + assert.entityCount('EventDayData', 2); + + const day0Id = Bytes.fromI32(0).toHex(); + const day1Id = Bytes.fromI32(1).toHex(); + + assert.fieldEquals('EventDayData', day0Id, 'dailyHMTTransferCount', '1'); + assert.fieldEquals('EventDayData', day0Id, 'dailyHMTTransferAmount', '5'); + assert.fieldEquals('EventDayData', day0Id, 'dailyUniqueSenders', '0'); + assert.fieldEquals('EventDayData', day0Id, 'dailyUniqueReceivers', '1'); + + assert.fieldEquals('EventDayData', day1Id, 'dailyHMTTransferCount', '1'); + assert.fieldEquals('EventDayData', day1Id, 'dailyHMTTransferAmount', '7'); + assert.fieldEquals('EventDayData', day1Id, 'dailyUniqueSenders', '0'); + assert.fieldEquals('EventDayData', day1Id, 'dailyUniqueReceivers', '1'); + }); + + test('Should properly calculate BulkTransfer event in statistics', () => { + const bulkTransfer1 = createBulkTransferEvent(1, 3, BigInt.fromI32(10)); + const bulkTransfer2 = createBulkTransferEvent(2, 3, BigInt.fromI32(10)); + + handleBulkTransfer(bulkTransfer1); + handleBulkTransfer(bulkTransfer2); + + assert.fieldEquals( + 'HMTokenStatistics', + HMT_STATISTICS_ENTITY_ID.toHex(), + 'totalBulkTransferEventCount', + '2' + ); + }); + + test('Should properly calculate Approval event in statistics', () => { + const approval1 = createApprovalEvent( + holder1AddressString, + operatorAddressString, + 10, + BigInt.fromI32(10) + ); + + const approval2 = createApprovalEvent( + holder1AddressString, + operatorAddressString, + 10, + BigInt.fromI32(10) + ); + + handleApproval(approval1); + handleApproval(approval2); + + assert.fieldEquals( + 'HMTokenStatistics', + HMT_STATISTICS_ENTITY_ID.toHex(), + 'totalApprovalEventCount', + '2' + ); + }); + + test('Should properly calculate BulkApproval event in statistics', () => { + const bulkApproval1 = createBulkApprovalEvent(1, 3, BigInt.fromI32(10)); + const bulkApproval2 = createBulkApprovalEvent(2, 3, BigInt.fromI32(10)); + + handleBulkApproval(bulkApproval1); + handleBulkApproval(bulkApproval2); + + assert.fieldEquals( + 'HMTokenStatistics', + HMT_STATISTICS_ENTITY_ID.toHex(), + 'totalBulkApprovalEventCount', + '2' + ); + }); + }); +}); diff --git a/packages/sdk/typescript/subgraph-hmt-stats/tests/utils.ts b/packages/sdk/typescript/subgraph-hmt-stats/tests/utils.ts new file mode 100644 index 0000000000..95dd417cce --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/tests/utils.ts @@ -0,0 +1,11 @@ +import { BigInt, Bytes } from '@graphprotocol/graph-ts'; + +export function generateUniqueHash( + value: string, + timestamp: BigInt, + nonce: BigInt +): Bytes { + const uniqueString = + value + '-' + timestamp.toString() + '-' + nonce.toString(); + return Bytes.fromUTF8(uniqueString); +} diff --git a/packages/sdk/typescript/subgraph-hmt-stats/tsconfig.json b/packages/sdk/typescript/subgraph-hmt-stats/tsconfig.json new file mode 100644 index 0000000000..f9e6cb7174 --- /dev/null +++ b/packages/sdk/typescript/subgraph-hmt-stats/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": ".", + "types": ["@graphprotocol/graph-ts", "node"] + }, + "include": ["src", "tests"] +} diff --git a/packages/sdk/typescript/subgraph/config/amoy.json b/packages/sdk/typescript/subgraph/config/amoy.json index 2253b3495f..3948cf4f1e 100644 --- a/packages/sdk/typescript/subgraph/config/amoy.json +++ b/packages/sdk/typescript/subgraph/config/amoy.json @@ -7,11 +7,7 @@ "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { - "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33", - "startBlock": 5769546, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json", - "totalSupply": "1000000000000000000000000000", - "contractDeployer": "0xF3D9a0ba9FA14273C515e519DFD0826Ff87d5164" + "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33" }, "Escrow": { "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" diff --git a/packages/sdk/typescript/subgraph/config/bsc-testnet.json b/packages/sdk/typescript/subgraph/config/bsc-testnet.json index aaf5db6347..cde9a5c59c 100644 --- a/packages/sdk/typescript/subgraph/config/bsc-testnet.json +++ b/packages/sdk/typescript/subgraph/config/bsc-testnet.json @@ -7,11 +7,7 @@ "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { - "address": "0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d", - "startBlock": 26716354, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json", - "totalSupply": "1000000000000000000000000000", - "contractDeployer": "0xf183b3B34E70Dd17859455389A3aB54D49D41e6f" + "address": "0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d" }, "Escrow": { "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" diff --git a/packages/sdk/typescript/subgraph/config/bsc.json b/packages/sdk/typescript/subgraph/config/bsc.json index cfbb32fd9b..1273ac5d20 100644 --- a/packages/sdk/typescript/subgraph/config/bsc.json +++ b/packages/sdk/typescript/subgraph/config/bsc.json @@ -7,11 +7,7 @@ "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { - "address": "0x711Fd6ab6d65A98904522d4e3586F492B989c527", - "startBlock": 25383172, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json", - "totalSupply": "0", - "contractDeployer": "bridge" + "address": "0x711Fd6ab6d65A98904522d4e3586F492B989c527" }, "Escrow": { "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" diff --git a/packages/sdk/typescript/subgraph/config/ethereum.json b/packages/sdk/typescript/subgraph/config/ethereum.json index 4cf773b86c..c91e0ca8af 100644 --- a/packages/sdk/typescript/subgraph/config/ethereum.json +++ b/packages/sdk/typescript/subgraph/config/ethereum.json @@ -7,11 +7,7 @@ "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { - "address": "0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867", - "startBlock": 12184475, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json", - "totalSupply": "1000000000000000000000000000", - "contractDeployer": "0x3895d913a9A231d2B215F402c528511B569C676D" + "address": "0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867" }, "Escrow": { "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" diff --git a/packages/sdk/typescript/subgraph/config/localhost.json b/packages/sdk/typescript/subgraph/config/localhost.json index 0f617bae82..15b69817b4 100644 --- a/packages/sdk/typescript/subgraph/config/localhost.json +++ b/packages/sdk/typescript/subgraph/config/localhost.json @@ -7,11 +7,7 @@ "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { - "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", - "startBlock": 1, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json", - "totalSupply": "1000000000000000000000000000", - "contractDeployer": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3" }, "Escrow": { "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" diff --git a/packages/sdk/typescript/subgraph/config/polygon.json b/packages/sdk/typescript/subgraph/config/polygon.json index 82ea7715ad..91bd092cc7 100644 --- a/packages/sdk/typescript/subgraph/config/polygon.json +++ b/packages/sdk/typescript/subgraph/config/polygon.json @@ -7,11 +7,7 @@ "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { - "address": "0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571Bf", - "startBlock": 20181701, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json", - "totalSupply": "0", - "contractDeployer": "bridge" + "address": "0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571Bf" }, "Escrow": { "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" diff --git a/packages/sdk/typescript/subgraph/config/sepolia.json b/packages/sdk/typescript/subgraph/config/sepolia.json index 544eec59ef..812bc64390 100644 --- a/packages/sdk/typescript/subgraph/config/sepolia.json +++ b/packages/sdk/typescript/subgraph/config/sepolia.json @@ -7,11 +7,7 @@ "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { - "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33", - "startBlock": 5716225, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json", - "totalSupply": "1000000000000000000000000000", - "contractDeployer": "0xF3D9a0ba9FA14273C515e519DFD0826Ff87d5164" + "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33" }, "Escrow": { "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" diff --git a/yarn.lock b/yarn.lock index e09fa5ba8f..4a70e1d6d4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11162,6 +11162,23 @@ __metadata: languageName: node linkType: hard +"@tools/subgraph-hmt-stats@workspace:packages/sdk/typescript/subgraph-hmt-stats": + version: 0.0.0-use.local + resolution: "@tools/subgraph-hmt-stats@workspace:packages/sdk/typescript/subgraph-hmt-stats" + dependencies: + "@graphprotocol/graph-cli": "npm:^0.97.1" + "@graphprotocol/graph-ts": "npm:^0.38.0" + "@graphql-eslint/eslint-plugin": "npm:^3.19.1" + "@human-protocol/core": "workspace:*" + eslint: "npm:^9.39.1" + ethers: "npm:~6.15.0" + graphql: "npm:^16.6.0" + matchstick-as: "npm:^0.6.0" + mustache: "npm:^4.2.0" + prettier: "npm:^3.8.1" + languageName: unknown + linkType: soft + "@tools/subgraph@workspace:packages/sdk/typescript/subgraph": version: 0.0.0-use.local resolution: "@tools/subgraph@workspace:packages/sdk/typescript/subgraph" From 91d10db1f72165567e800ee48ca00c3fcd7555aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Wed, 25 Feb 2026 17:27:42 +0100 Subject: [PATCH 03/10] integrate HMT subgraph support and update related queries in Python SDK --- .../human_protocol_sdk/constants.py | 6 ++ .../human_protocol_sdk/gql/statistics.py | 37 +++++++++- .../statistics/statistics_utils.py | 25 ++----- .../human_protocol_sdk/utils.py | 44 ++++++++++- .../statistics/test_statistics_utils.py | 15 ++-- .../test/human_protocol_sdk/test_utils.py | 73 ++++++++++++++++++- 6 files changed, 165 insertions(+), 35 deletions(-) diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/constants.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/constants.py index a059cc86d4..967c0cb969 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/constants.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/constants.py @@ -143,6 +143,12 @@ class OperatorCategory(Enum): "subgraph_url_api_key": ( "https://gateway.thegraph.com/api/deployments/id/QmcLwLMw3UzCSbNbjegrpNu6PB3kAd67xquuyaVWvc5Q7Q" ), + "hmt_subgraph_url": ( + "https://api.studio.thegraph.com/query/74256/hmt-stats-amoy/version/latest" + ), + "hmt_subgraph_url_api_key": ( + "https://gateway.thegraph.com/api/deployments/id/QmZJYBQKyrsEJHQwNQ8JhkKcB5G8zQdrcwnr7ecGRNTBit" + ), "hmt_address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33", "factory_address": "0xAFf5a986A530ff839d49325A5dF69F96627E8D29", "staking_address": "0xffE496683F842a923110415b7278ded3F265f2C5", diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/statistics.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/statistics.py index e726402117..988914d436 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/statistics.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/statistics.py @@ -41,7 +41,12 @@ dailyEscrowCount dailyWorkerCount dailyPayoutCount - dailyHMTPayoutAmount +} +""" + +hmt_event_day_data_fragment = """ +fragment HMTEventDayDataFields on EventDayData { + timestamp dailyHMTTransferCount dailyHMTTransferAmount dailyUniqueSenders @@ -100,3 +105,33 @@ def get_event_day_data_query(filter: StatisticsFilter) -> str: from_clause="timestamp_gte: $from" if filter.date_from else "", to_clause="timestamp_lte: $to" if filter.date_to else "", ) + + +def get_hmt_event_day_data_query(filter: StatisticsFilter) -> str: + return """ +query GetHMTDayData( + $from: Int + $to: Int + $orderDirection: String + $first: Int + $skip: Int +) {{ + eventDayDatas( + where: {{ + {from_clause} + {to_clause} + }}, + orderBy: timestamp, + orderDirection: $orderDirection + first: $first + skip: $skip + ) {{ + ...HMTEventDayDataFields + }} +}} +{hmt_event_day_data_fragment} +""".format( + hmt_event_day_data_fragment=hmt_event_day_data_fragment, + from_clause="timestamp_gte: $from" if filter.date_from else "", + to_clause="timestamp_lte: $to" if filter.date_to else "", + ) diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/statistics/statistics_utils.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/statistics/statistics_utils.py index 5d79cb567a..32c1c0ab04 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/statistics/statistics_utils.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/statistics/statistics_utils.py @@ -127,22 +127,16 @@ class DailyPaymentData: Attributes: timestamp (datetime): Day boundary timestamp. - total_amount_paid (int): Total amount paid out on this day. total_count (int): Number of payment transactions. - average_amount_per_worker (int): Average payout amount per worker. """ def __init__( self, timestamp: datetime, - total_amount_paid: int, total_count: int, - average_amount_per_worker: int, ): self.timestamp = timestamp - self.total_amount_paid = total_amount_paid self.total_count = total_count - self.average_amount_per_worker = average_amount_per_worker class PaymentStatistics: @@ -446,8 +440,7 @@ def get_payment_statistics( ) ) for day_data in stats.daily_payments_data: - print(f"{day_data.timestamp}: {day_data.total_amount_paid} paid") - print(f" Average per worker: {day_data.average_amount_per_worker}") + print(f"{day_data.total_count}: {day_data.total_count} payments") ``` """ if chain_id.value not in [cid.value for cid in ChainId]: @@ -481,16 +474,7 @@ def get_payment_statistics( timestamp=datetime.fromtimestamp( int(event_day_data.get("timestamp", 0)) ), - total_amount_paid=int( - event_day_data.get("dailyHMTPayoutAmount", 0) - ), total_count=int(event_day_data.get("dailyPayoutCount", 0)), - average_amount_per_worker=( - int(event_day_data.get("dailyHMTPayoutAmount", 0)) - / int(event_day_data.get("dailyWorkerCount")) - if event_day_data.get("dailyWorkerCount", "0") != "0" - else 0 - ), ) for event_day_data in event_day_datas ], @@ -540,6 +524,7 @@ def get_hmt_statistics( network, query=get_hmtoken_statistics_query, options=options, + use_hmt_subgraph=True, ) hmtoken_statistics = hmtoken_statistics_data["data"]["hmtokenStatistics"] @@ -612,6 +597,7 @@ def get_hmt_holders( "orderDirection": param.order_direction, }, options=options, + use_hmt_subgraph=True, ) holders = holders_data["data"]["holders"] @@ -675,12 +661,12 @@ def get_hmt_daily_data( raise StatisticsUtilsError("Empty network configuration") from human_protocol_sdk.gql.statistics import ( - get_event_day_data_query, + get_hmt_event_day_data_query, ) event_day_datas_data = custom_gql_fetch( network, - query=get_event_day_data_query(filter), + query=get_hmt_event_day_data_query(filter), params={ "from": int(filter.date_from.timestamp()) if filter.date_from else None, "to": int(filter.date_to.timestamp()) if filter.date_to else None, @@ -689,6 +675,7 @@ def get_hmt_daily_data( "orderDirection": filter.order_direction.value, }, options=options, + use_hmt_subgraph=True, ) event_day_datas = event_day_datas_data["data"]["eventDayDatas"] diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/utils.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/utils.py index a8f7281d92..0f16e73606 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/utils.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/utils.py @@ -207,11 +207,30 @@ def is_indexer_error(error: Exception) -> bool: return "bad indexers" in message.lower() +def _resolve_subgraph_urls( + network: Dict[str, Any], use_hmt_subgraph: bool = False +) -> Tuple[str, str]: + """Resolve public/API-key URLs for either default or HMT subgraph.""" + if not use_hmt_subgraph: + return network["subgraph_url"], network["subgraph_url_api_key"] + + hmt_subgraph_url = network.get("hmt_subgraph_url") + hmt_subgraph_url_api_key = network.get("hmt_subgraph_url_api_key") + + public_url = hmt_subgraph_url or network["subgraph_url"] + api_key_url = ( + hmt_subgraph_url_api_key or hmt_subgraph_url or network["subgraph_url_api_key"] + ) + + return public_url, api_key_url + + def custom_gql_fetch( network: Dict[str, Any], query: str, params: Optional[Dict[str, Any]] = None, options: Optional[SubgraphOptions] = None, + use_hmt_subgraph: bool = False, ) -> Dict[str, Any]: """Fetch data from the subgraph with optional retry logic and indexer routing. @@ -220,6 +239,7 @@ def custom_gql_fetch( query (str): GraphQL query string to execute. params (Optional[Dict[str, Any]]): Optional query parameters/variables dictionary. options (Optional[SubgraphOptions]): Optional subgraph configuration for retries and indexer selection. + use_hmt_subgraph (bool): If true, resolves URL using HMT subgraph keys with fallback. Returns: JSON response from the subgraph containing the query results. @@ -250,7 +270,12 @@ def custom_gql_fetch( subgraph_api_key = os.getenv("SUBGRAPH_API_KEY", "") if not options: - return _fetch_subgraph_data(network, query, params) + return _fetch_subgraph_data( + network, + query, + params, + use_hmt_subgraph=use_hmt_subgraph, + ) has_max_retries = options.max_retries is not None has_base_delay = options.base_delay is not None @@ -272,7 +297,13 @@ def custom_gql_fetch( for attempt in range(max_retries + 1): try: - return _fetch_subgraph_data(network, query, params, options.indexer_id) + return _fetch_subgraph_data( + network, + query, + params, + options.indexer_id, + use_hmt_subgraph, + ) except Exception as error: last_error = error @@ -290,6 +321,7 @@ def _fetch_subgraph_data( query: str, params: Optional[Dict[str, Any]] = None, indexer_id: Optional[str] = None, + use_hmt_subgraph: bool = False, ) -> Dict[str, Any]: """Internal function to fetch data from the subgraph API. @@ -298,6 +330,7 @@ def _fetch_subgraph_data( query (str): GraphQL query string to execute. params (Optional[Dict[str, Any]]): Optional query parameters/variables dictionary. indexer_id (Optional[str]): Optional indexer ID to route the request to. + use_hmt_subgraph (bool): If true, resolves URL using HMT subgraph keys with fallback. Returns: JSON response from the subgraph. @@ -305,14 +338,17 @@ def _fetch_subgraph_data( Raises: Exception: If the HTTP request fails or returns a non-200 status code. """ + default_subgraph_url, default_subgraph_url_api_key = _resolve_subgraph_urls( + network, use_hmt_subgraph + ) subgraph_api_key = os.getenv("SUBGRAPH_API_KEY", "") if subgraph_api_key: - subgraph_url = network["subgraph_url_api_key"] + subgraph_url = default_subgraph_url_api_key else: logger.warning( "Warning: SUBGRAPH_API_KEY is not provided. It might cause issues with the subgraph." ) - subgraph_url = network["subgraph_url"] + subgraph_url = default_subgraph_url subgraph_url = _attach_indexer_id(subgraph_url, indexer_id) diff --git a/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/statistics/test_statistics_utils.py b/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/statistics/test_statistics_utils.py index c17523e5f7..4e53363602 100644 --- a/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/statistics/test_statistics_utils.py +++ b/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/statistics/test_statistics_utils.py @@ -1,12 +1,13 @@ import unittest from datetime import datetime -from unittest.mock import MagicMock, patch +from unittest.mock import patch from human_protocol_sdk.constants import NETWORKS, ChainId from human_protocol_sdk.gql.hmtoken import get_holders_query from human_protocol_sdk.gql.statistics import ( get_event_day_data_query, get_escrow_statistics_query, + get_hmt_event_day_data_query, get_hmtoken_statistics_query, ) from human_protocol_sdk.statistics import ( @@ -147,7 +148,6 @@ def test_get_payment_statistics(self): { "timestamp": 1, "dailyPayoutCount": "4", - "dailyHMTPayoutAmount": "100", "dailyWorkerCount": "4", }, ], @@ -177,13 +177,7 @@ def test_get_payment_statistics(self): payment_statistics.daily_payments_data[0].timestamp, datetime.fromtimestamp(1), ) - self.assertEqual( - payment_statistics.daily_payments_data[0].total_amount_paid, 100 - ) self.assertEqual(payment_statistics.daily_payments_data[0].total_count, 4) - self.assertEqual( - payment_statistics.daily_payments_data[0].average_amount_per_worker, 25 - ) def test_get_hmt_statistics(self): with patch( @@ -207,6 +201,7 @@ def test_get_hmt_statistics(self): NETWORKS[ChainId.LOCALHOST], query=get_hmtoken_statistics_query, options=None, + use_hmt_subgraph=True, ) self.assertEqual(hmt_statistics.total_transfer_amount, 100) @@ -245,6 +240,7 @@ def test_get_hmt_holders(self): "orderDirection": param.order_direction, }, options=None, + use_hmt_subgraph=True, ) self.assertEqual(len(holders), 2) @@ -283,7 +279,7 @@ def test_get_hmt_daily_data(self): mock_function.assert_any_call( NETWORKS[ChainId.LOCALHOST], - query=get_event_day_data_query(param), + query=get_hmt_event_day_data_query(param), params={ "from": 1683811973, "to": 1683812007, @@ -292,6 +288,7 @@ def test_get_hmt_daily_data(self): "orderDirection": "asc", }, options=None, + use_hmt_subgraph=True, ) self.assertEqual(len(hmt_statistics), 1) diff --git a/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/test_utils.py b/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/test_utils.py index 54e5bc65bb..9c9fd026d5 100644 --- a/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/test_utils.py +++ b/packages/sdk/python/human-protocol-sdk/test/human_protocol_sdk/test_utils.py @@ -72,7 +72,12 @@ def test_returns_response_without_options(self): result = custom_gql_fetch(self.network, self.query, self.variables) self.assertEqual(result, expected) - mock_fetch.assert_called_once_with(self.network, self.query, self.variables) + mock_fetch.assert_called_once_with( + self.network, + self.query, + self.variables, + use_hmt_subgraph=False, + ) def test_retries_on_indexer_error_and_succeeds(self): options = SubgraphOptions(max_retries=2, base_delay=100) @@ -151,7 +156,7 @@ def test_routes_requests_to_specific_indexer(self): self.assertEqual(result, expected) mock_fetch.assert_called_once_with( - self.network, self.query, self.variables, "0xabc123" + self.network, self.query, self.variables, "0xabc123", False ) def test_raises_when_indexer_without_api_key(self): @@ -184,6 +189,70 @@ def test_fetch_subgraph_adds_authorization_header(self): {"Authorization": "Bearer token"}, ) + def test_fetch_hmt_subgraph_uses_hmt_public_url_without_api_key(self): + network = { + "subgraph_url": "http://subgraph", + "subgraph_url_api_key": "http://subgraph-with-key", + "hmt_subgraph_url": "http://hmt-subgraph", + "hmt_subgraph_url_api_key": "http://hmt-subgraph-with-key", + } + + with patch("human_protocol_sdk.utils.requests.post") as mock_post: + mock_post.return_value.status_code = 200 + mock_post.return_value.json.return_value = {"data": {}} + + _fetch_subgraph_data( + network, + self.query, + self.variables, + use_hmt_subgraph=True, + ) + + self.assertEqual(mock_post.call_args.args[0], "http://hmt-subgraph") + + def test_fetch_hmt_subgraph_uses_hmt_api_key_url_with_api_key(self): + network = { + "subgraph_url": "http://subgraph", + "subgraph_url_api_key": "http://subgraph-with-key", + "hmt_subgraph_url": "http://hmt-subgraph", + "hmt_subgraph_url_api_key": "http://hmt-subgraph-with-key", + } + + with patch.dict(os.environ, {"SUBGRAPH_API_KEY": "token"}, clear=True): + with patch("human_protocol_sdk.utils.requests.post") as mock_post: + mock_post.return_value.status_code = 200 + mock_post.return_value.json.return_value = {"data": {}} + + _fetch_subgraph_data( + network, + self.query, + self.variables, + use_hmt_subgraph=True, + ) + + self.assertEqual(mock_post.call_args.args[0], "http://hmt-subgraph-with-key") + + def test_fetch_hmt_subgraph_falls_back_to_hmt_public_url_for_api_key_mode(self): + network = { + "subgraph_url": "http://subgraph", + "subgraph_url_api_key": "http://subgraph-with-key", + "hmt_subgraph_url": "http://hmt-subgraph", + } + + with patch.dict(os.environ, {"SUBGRAPH_API_KEY": "token"}, clear=True): + with patch("human_protocol_sdk.utils.requests.post") as mock_post: + mock_post.return_value.status_code = 200 + mock_post.return_value.json.return_value = {"data": {}} + + _fetch_subgraph_data( + network, + self.query, + self.variables, + use_hmt_subgraph=True, + ) + + self.assertEqual(mock_post.call_args.args[0], "http://hmt-subgraph") + class TestAttachIndexerId(unittest.TestCase): def test_converts_subgraph_path_to_deployment(self): From 543e99b6159d2ed103da81dc3e613fd1a9b40349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Thu, 26 Feb 2026 13:52:03 +0100 Subject: [PATCH 04/10] Generated changeset for SDKs --- .changeset/nine-seas-dream.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/nine-seas-dream.md diff --git a/.changeset/nine-seas-dream.md b/.changeset/nine-seas-dream.md new file mode 100644 index 0000000000..6b9f135b78 --- /dev/null +++ b/.changeset/nine-seas-dream.md @@ -0,0 +1,6 @@ +--- +"@human-protocol/sdk": major +"@human-protocol/python-sdk": major +--- + +Updated SDK to use a dedicated HMT stats subgraph endpoint for HMT statistics methods and removed `totalAmountPaid` and `averageAmountPerWorker` from `IDailyPayment` From b49415895fe3c787dc2b1fcee895769f0e8e6a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Wed, 4 Mar 2026 12:47:43 +0100 Subject: [PATCH 05/10] Move subgraphs into new /subgraph folder --- .github/workflows/cd-subgraph.yaml | 4 ++-- .github/workflows/ci-test-subgraph.yaml | 14 ++++++++++---- .../hmt}/.gitignore | 0 .../hmt}/.prettierignore | 0 .../hmt}/.prettierrc | 0 .../{subgraph-hmt-stats => subgraph/hmt}/README.md | 0 .../hmt}/config/amoy.json | 2 +- .../hmt}/config/bsc-testnet.json | 2 +- .../hmt}/config/bsc.json | 2 +- .../hmt}/config/ethereum.json | 2 +- .../hmt}/config/localhost.json | 2 +- .../hmt}/config/polygon.json | 2 +- .../hmt}/config/sepolia.json | 2 +- .../hmt}/eslint.config.mjs | 0 .../hmt}/matchstick.yaml | 0 .../hmt}/package.json | 2 +- .../hmt}/schema.graphql | 0 .../hmt}/src/mapping/HMToken.ts | 0 .../hmt}/src/mapping/utils/dayUpdates.ts | 0 .../hmt}/src/mapping/utils/number.ts | 0 .../hmt}/template.yaml | 0 .../hmt}/tests/hmt/fixtures.ts | 0 .../hmt}/tests/hmt/hmt.test.ts | 0 .../hmt}/tests/utils.ts | 0 .../hmt}/tsconfig.json | 0 .../subgraph/{ => human-protocol}/.gitignore | 0 .../subgraph/{ => human-protocol}/.prettierignore | 0 .../subgraph/{ => human-protocol}/.prettierrc | 0 .../subgraph/{ => human-protocol}/README.md | 0 .../subgraph/{ => human-protocol}/config/amoy.json | 8 ++++---- .../{ => human-protocol}/config/bsc-testnet.json | 12 ++++++------ .../subgraph/{ => human-protocol}/config/bsc.json | 12 ++++++------ .../{ => human-protocol}/config/ethereum.json | 12 ++++++------ .../{ => human-protocol}/config/localhost.json | 8 ++++---- .../{ => human-protocol}/config/polygon.json | 12 ++++++------ .../{ => human-protocol}/config/sepolia.json | 10 +++++----- .../{ => human-protocol}/eslint.config.mjs | 0 .../{ => human-protocol}/local-graph-status.sh | 0 .../subgraph/{ => human-protocol}/matchstick.yaml | 0 .../subgraph/{ => human-protocol}/package.json | 2 +- .../subgraph/{ => human-protocol}/schema.graphql | 0 .../src/mapping/EscrowFactory.ts | 0 .../src/mapping/EscrowTemplate.ts | 0 .../{ => human-protocol}/src/mapping/KVStore.ts | 0 .../src/mapping/StakingTemplate.ts | 0 .../src/mapping/legacy/Escrow.ts | 0 .../src/mapping/legacy/EscrowFactory.ts | 0 .../src/mapping/utils/dayUpdates.ts | 0 .../src/mapping/utils/ethAdrress.ts | 0 .../src/mapping/utils/event.ts | 0 .../src/mapping/utils/number.ts | 0 .../src/mapping/utils/string.ts | 0 .../src/mapping/utils/transaction.ts | 0 .../subgraph/{ => human-protocol}/template.yaml | 0 .../tests/escrow-factory/escrow-factory.test.ts | 0 .../tests/escrow-factory/fixtures.ts | 0 .../tests/escrow/escrow.test.ts | 0 .../{ => human-protocol}/tests/escrow/fixtures.ts | 0 .../{ => human-protocol}/tests/kvstore/fixtures.ts | 0 .../tests/kvstore/kvstore.test.ts | 0 .../legacy/escrow-factory/escrow-factory.test.ts | 0 .../tests/legacy/escrow-factory/fixtures.ts | 0 .../tests/legacy/escrow/escrow.test.ts | 0 .../tests/legacy/escrow/fixtures.ts | 0 .../{ => human-protocol}/tests/staking/fixtures.ts | 0 .../tests/staking/staking.test.ts | 0 .../subgraph/{ => human-protocol}/tests/utils.ts | 0 .../subgraph/{ => human-protocol}/tsconfig.json | 0 yarn.lock | 8 ++++---- 69 files changed, 62 insertions(+), 56 deletions(-) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/.gitignore (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/.prettierignore (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/.prettierrc (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/README.md (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/config/amoy.json (70%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/config/bsc-testnet.json (71%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/config/bsc.json (69%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/config/ethereum.json (70%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/config/localhost.json (69%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/config/polygon.json (70%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/config/sepolia.json (71%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/eslint.config.mjs (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/matchstick.yaml (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/package.json (95%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/schema.graphql (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/src/mapping/HMToken.ts (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/src/mapping/utils/dayUpdates.ts (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/src/mapping/utils/number.ts (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/template.yaml (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/tests/hmt/fixtures.ts (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/tests/hmt/hmt.test.ts (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/tests/utils.ts (100%) rename packages/sdk/typescript/{subgraph-hmt-stats => subgraph/hmt}/tsconfig.json (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/.gitignore (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/.prettierignore (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/.prettierrc (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/README.md (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/config/amoy.json (61%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/config/bsc-testnet.json (57%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/config/bsc.json (56%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/config/ethereum.json (56%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/config/localhost.json (60%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/config/polygon.json (56%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/config/sepolia.json (56%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/eslint.config.mjs (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/local-graph-status.sh (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/matchstick.yaml (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/package.json (96%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/schema.graphql (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/EscrowFactory.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/EscrowTemplate.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/KVStore.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/StakingTemplate.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/legacy/Escrow.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/legacy/EscrowFactory.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/utils/dayUpdates.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/utils/ethAdrress.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/utils/event.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/utils/number.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/utils/string.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/src/mapping/utils/transaction.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/template.yaml (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/escrow-factory/escrow-factory.test.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/escrow-factory/fixtures.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/escrow/escrow.test.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/escrow/fixtures.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/kvstore/fixtures.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/kvstore/kvstore.test.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/legacy/escrow-factory/escrow-factory.test.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/legacy/escrow-factory/fixtures.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/legacy/escrow/escrow.test.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/legacy/escrow/fixtures.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/staking/fixtures.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/staking/staking.test.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tests/utils.ts (100%) rename packages/sdk/typescript/subgraph/{ => human-protocol}/tsconfig.json (100%) diff --git a/.github/workflows/cd-subgraph.yaml b/.github/workflows/cd-subgraph.yaml index 4bd0f85114..0472bc0637 100644 --- a/.github/workflows/cd-subgraph.yaml +++ b/.github/workflows/cd-subgraph.yaml @@ -55,7 +55,7 @@ jobs: - name: Generate and build Subgraph if: steps.filter_networks.outputs.continue == 'true' run: yarn generate && yarn build - working-directory: ./packages/sdk/typescript/subgraph + working-directory: ./packages/sdk/typescript/subgraph/human-protocol env: NETWORK: ${{ matrix.network.name }} - name: Authenticate & Deploy @@ -64,7 +64,7 @@ jobs: API_KEY: ${{ secrets.HP_GRAPH_API_KEY }} NETWORK: ${{ matrix.network.name }} LABEL: ${{ github.event.inputs.label }} - working-directory: ./packages/sdk/typescript/subgraph + working-directory: ./packages/sdk/typescript/subgraph/human-protocol run: | yarn dlx @graphprotocol/graph-cli@0.71.2 \ auth --studio "$API_KEY" diff --git a/.github/workflows/ci-test-subgraph.yaml b/.github/workflows/ci-test-subgraph.yaml index d569f765f2..748ee80230 100644 --- a/.github/workflows/ci-test-subgraph.yaml +++ b/.github/workflows/ci-test-subgraph.yaml @@ -9,9 +9,15 @@ on: jobs: subgraph-test: - name: Subgraph Test + name: Subgraph Test (${{ matrix.workspace }}) # TODO: Use ubuntu-latest when graph binary is not failing on ubuntu 24.04 runs-on: ubuntu-22.04 + strategy: + matrix: + workspace: + - "@tools/subgraph" + - "@tools/subgraph-hmt-stats" + fail-fast: true steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 @@ -19,10 +25,10 @@ jobs: node-version-file: .nvmrc cache: yarn - name: Install dependencies - run: yarn workspaces focus @tools/subgraph + run: yarn workspaces focus @tools/subgraph @tools/subgraph-hmt-stats - name: Build core package run: yarn workspace @human-protocol/core build - name: Generate manifest for Polygon for tests - run: NETWORK=polygon yarn workspace @tools/subgraph generate + run: NETWORK=polygon yarn workspace ${{ matrix.workspace }} generate - name: Run subgraph test - run: yarn workspace @tools/subgraph test + run: yarn workspace ${{ matrix.workspace }} test diff --git a/packages/sdk/typescript/subgraph-hmt-stats/.gitignore b/packages/sdk/typescript/subgraph/hmt/.gitignore similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/.gitignore rename to packages/sdk/typescript/subgraph/hmt/.gitignore diff --git a/packages/sdk/typescript/subgraph-hmt-stats/.prettierignore b/packages/sdk/typescript/subgraph/hmt/.prettierignore similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/.prettierignore rename to packages/sdk/typescript/subgraph/hmt/.prettierignore diff --git a/packages/sdk/typescript/subgraph-hmt-stats/.prettierrc b/packages/sdk/typescript/subgraph/hmt/.prettierrc similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/.prettierrc rename to packages/sdk/typescript/subgraph/hmt/.prettierrc diff --git a/packages/sdk/typescript/subgraph-hmt-stats/README.md b/packages/sdk/typescript/subgraph/hmt/README.md similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/README.md rename to packages/sdk/typescript/subgraph/hmt/README.md diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/amoy.json b/packages/sdk/typescript/subgraph/hmt/config/amoy.json similarity index 70% rename from packages/sdk/typescript/subgraph-hmt-stats/config/amoy.json rename to packages/sdk/typescript/subgraph/hmt/config/amoy.json index 937cafd584..a3d9f907a9 100644 --- a/packages/sdk/typescript/subgraph-hmt-stats/config/amoy.json +++ b/packages/sdk/typescript/subgraph/hmt/config/amoy.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33", "startBlock": 5769546, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/bsc-testnet.json b/packages/sdk/typescript/subgraph/hmt/config/bsc-testnet.json similarity index 71% rename from packages/sdk/typescript/subgraph-hmt-stats/config/bsc-testnet.json rename to packages/sdk/typescript/subgraph/hmt/config/bsc-testnet.json index 19bfc537e5..ed6d9b491c 100644 --- a/packages/sdk/typescript/subgraph-hmt-stats/config/bsc-testnet.json +++ b/packages/sdk/typescript/subgraph/hmt/config/bsc-testnet.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d", "startBlock": 26716354, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/bsc.json b/packages/sdk/typescript/subgraph/hmt/config/bsc.json similarity index 69% rename from packages/sdk/typescript/subgraph-hmt-stats/config/bsc.json rename to packages/sdk/typescript/subgraph/hmt/config/bsc.json index 4cb6113d3d..e69df3d9f8 100644 --- a/packages/sdk/typescript/subgraph-hmt-stats/config/bsc.json +++ b/packages/sdk/typescript/subgraph/hmt/config/bsc.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0x711Fd6ab6d65A98904522d4e3586F492B989c527", "startBlock": 25383172, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/ethereum.json b/packages/sdk/typescript/subgraph/hmt/config/ethereum.json similarity index 70% rename from packages/sdk/typescript/subgraph-hmt-stats/config/ethereum.json rename to packages/sdk/typescript/subgraph/hmt/config/ethereum.json index 1bbab2e103..8a520e7319 100644 --- a/packages/sdk/typescript/subgraph-hmt-stats/config/ethereum.json +++ b/packages/sdk/typescript/subgraph/hmt/config/ethereum.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867", "startBlock": 12184475, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/localhost.json b/packages/sdk/typescript/subgraph/hmt/config/localhost.json similarity index 69% rename from packages/sdk/typescript/subgraph-hmt-stats/config/localhost.json rename to packages/sdk/typescript/subgraph/hmt/config/localhost.json index 7095fe08c2..56e613392a 100644 --- a/packages/sdk/typescript/subgraph-hmt-stats/config/localhost.json +++ b/packages/sdk/typescript/subgraph/hmt/config/localhost.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "startBlock": 1, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/polygon.json b/packages/sdk/typescript/subgraph/hmt/config/polygon.json similarity index 70% rename from packages/sdk/typescript/subgraph-hmt-stats/config/polygon.json rename to packages/sdk/typescript/subgraph/hmt/config/polygon.json index 8910397dec..657ebf2e03 100644 --- a/packages/sdk/typescript/subgraph-hmt-stats/config/polygon.json +++ b/packages/sdk/typescript/subgraph/hmt/config/polygon.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571Bf", "startBlock": 20181701, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph-hmt-stats/config/sepolia.json b/packages/sdk/typescript/subgraph/hmt/config/sepolia.json similarity index 71% rename from packages/sdk/typescript/subgraph-hmt-stats/config/sepolia.json rename to packages/sdk/typescript/subgraph/hmt/config/sepolia.json index 8530750796..70698bd2d9 100644 --- a/packages/sdk/typescript/subgraph-hmt-stats/config/sepolia.json +++ b/packages/sdk/typescript/subgraph/hmt/config/sepolia.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33", "startBlock": 5716225, - "abi": "../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph-hmt-stats/eslint.config.mjs b/packages/sdk/typescript/subgraph/hmt/eslint.config.mjs similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/eslint.config.mjs rename to packages/sdk/typescript/subgraph/hmt/eslint.config.mjs diff --git a/packages/sdk/typescript/subgraph-hmt-stats/matchstick.yaml b/packages/sdk/typescript/subgraph/hmt/matchstick.yaml similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/matchstick.yaml rename to packages/sdk/typescript/subgraph/hmt/matchstick.yaml diff --git a/packages/sdk/typescript/subgraph-hmt-stats/package.json b/packages/sdk/typescript/subgraph/hmt/package.json similarity index 95% rename from packages/sdk/typescript/subgraph-hmt-stats/package.json rename to packages/sdk/typescript/subgraph/hmt/package.json index d65873590f..ceb9a600b1 100644 --- a/packages/sdk/typescript/subgraph-hmt-stats/package.json +++ b/packages/sdk/typescript/subgraph/hmt/package.json @@ -19,7 +19,7 @@ "repository": { "type": "git", "url": "https://github.com/humanprotocol/human-protocol.git", - "directory": "packages/sdk/typescript/subgraph-hmt-stats" + "directory": "packages/sdk/typescript/subgraph/hmt" }, "keywords": [ "human-protocol", diff --git a/packages/sdk/typescript/subgraph-hmt-stats/schema.graphql b/packages/sdk/typescript/subgraph/hmt/schema.graphql similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/schema.graphql rename to packages/sdk/typescript/subgraph/hmt/schema.graphql diff --git a/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/HMToken.ts b/packages/sdk/typescript/subgraph/hmt/src/mapping/HMToken.ts similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/src/mapping/HMToken.ts rename to packages/sdk/typescript/subgraph/hmt/src/mapping/HMToken.ts diff --git a/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/dayUpdates.ts b/packages/sdk/typescript/subgraph/hmt/src/mapping/utils/dayUpdates.ts similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/dayUpdates.ts rename to packages/sdk/typescript/subgraph/hmt/src/mapping/utils/dayUpdates.ts diff --git a/packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/number.ts b/packages/sdk/typescript/subgraph/hmt/src/mapping/utils/number.ts similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/src/mapping/utils/number.ts rename to packages/sdk/typescript/subgraph/hmt/src/mapping/utils/number.ts diff --git a/packages/sdk/typescript/subgraph-hmt-stats/template.yaml b/packages/sdk/typescript/subgraph/hmt/template.yaml similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/template.yaml rename to packages/sdk/typescript/subgraph/hmt/template.yaml diff --git a/packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/fixtures.ts b/packages/sdk/typescript/subgraph/hmt/tests/hmt/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/fixtures.ts rename to packages/sdk/typescript/subgraph/hmt/tests/hmt/fixtures.ts diff --git a/packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/hmt.test.ts b/packages/sdk/typescript/subgraph/hmt/tests/hmt/hmt.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/tests/hmt/hmt.test.ts rename to packages/sdk/typescript/subgraph/hmt/tests/hmt/hmt.test.ts diff --git a/packages/sdk/typescript/subgraph-hmt-stats/tests/utils.ts b/packages/sdk/typescript/subgraph/hmt/tests/utils.ts similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/tests/utils.ts rename to packages/sdk/typescript/subgraph/hmt/tests/utils.ts diff --git a/packages/sdk/typescript/subgraph-hmt-stats/tsconfig.json b/packages/sdk/typescript/subgraph/hmt/tsconfig.json similarity index 100% rename from packages/sdk/typescript/subgraph-hmt-stats/tsconfig.json rename to packages/sdk/typescript/subgraph/hmt/tsconfig.json diff --git a/packages/sdk/typescript/subgraph/.gitignore b/packages/sdk/typescript/subgraph/human-protocol/.gitignore similarity index 100% rename from packages/sdk/typescript/subgraph/.gitignore rename to packages/sdk/typescript/subgraph/human-protocol/.gitignore diff --git a/packages/sdk/typescript/subgraph/.prettierignore b/packages/sdk/typescript/subgraph/human-protocol/.prettierignore similarity index 100% rename from packages/sdk/typescript/subgraph/.prettierignore rename to packages/sdk/typescript/subgraph/human-protocol/.prettierignore diff --git a/packages/sdk/typescript/subgraph/.prettierrc b/packages/sdk/typescript/subgraph/human-protocol/.prettierrc similarity index 100% rename from packages/sdk/typescript/subgraph/.prettierrc rename to packages/sdk/typescript/subgraph/human-protocol/.prettierrc diff --git a/packages/sdk/typescript/subgraph/README.md b/packages/sdk/typescript/subgraph/human-protocol/README.md similarity index 100% rename from packages/sdk/typescript/subgraph/README.md rename to packages/sdk/typescript/subgraph/human-protocol/README.md diff --git a/packages/sdk/typescript/subgraph/config/amoy.json b/packages/sdk/typescript/subgraph/human-protocol/config/amoy.json similarity index 61% rename from packages/sdk/typescript/subgraph/config/amoy.json rename to packages/sdk/typescript/subgraph/human-protocol/config/amoy.json index 3948cf4f1e..33d2f27c9a 100644 --- a/packages/sdk/typescript/subgraph/config/amoy.json +++ b/packages/sdk/typescript/subgraph/human-protocol/config/amoy.json @@ -4,22 +4,22 @@ "EscrowFactory": { "address": "0xAFf5a986A530ff839d49325A5dF69F96627E8D29", "startBlock": 5773000, - "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33" }, "Escrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "KVStore": { "address": "0x724AeFC243EdacCA27EAB86D3ec5a76Af4436Fc7", "startBlock": 5773002, - "abi": "../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "Staking": { "address": "0xffE496683F842a923110415b7278ded3F265f2C5", "startBlock": 14983952, - "abi": "../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" } } diff --git a/packages/sdk/typescript/subgraph/config/bsc-testnet.json b/packages/sdk/typescript/subgraph/human-protocol/config/bsc-testnet.json similarity index 57% rename from packages/sdk/typescript/subgraph/config/bsc-testnet.json rename to packages/sdk/typescript/subgraph/human-protocol/config/bsc-testnet.json index cde9a5c59c..4e40cc0b33 100644 --- a/packages/sdk/typescript/subgraph/config/bsc-testnet.json +++ b/packages/sdk/typescript/subgraph/human-protocol/config/bsc-testnet.json @@ -4,30 +4,30 @@ "EscrowFactory": { "address": "0x2bfA592DBDaF434DDcbb893B1916120d181DAD18", "startBlock": 26716359, - "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d" }, "Escrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "Staking": { "address": "0xD6D347ba6987519B4e42EcED43dF98eFf5465a23", "startBlock": 45938762, - "abi": "../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" }, "KVStore": { "address": "0x32e27177BA6Ea91cf28dfd91a0Da9822A4b74EcF", "startBlock": 34883905, - "abi": "../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "LegacyEscrowFactory": { "address": "0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f", "startBlock": 23632686, - "abi": "../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" }, "LegacyEscrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" } } diff --git a/packages/sdk/typescript/subgraph/config/bsc.json b/packages/sdk/typescript/subgraph/human-protocol/config/bsc.json similarity index 56% rename from packages/sdk/typescript/subgraph/config/bsc.json rename to packages/sdk/typescript/subgraph/human-protocol/config/bsc.json index 1273ac5d20..1812daf14e 100644 --- a/packages/sdk/typescript/subgraph/config/bsc.json +++ b/packages/sdk/typescript/subgraph/human-protocol/config/bsc.json @@ -4,30 +4,30 @@ "EscrowFactory": { "address": "0x92FD968AcBd521c232f5fB8c33b342923cC72714", "startBlock": 28745625, - "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0x711Fd6ab6d65A98904522d4e3586F492B989c527" }, "Escrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "Staking": { "address": "0xE24e5C08E28331D24758b69A5E9f383D2bDD1c98", "startBlock": 45120420, - "abi": "../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" }, "KVStore": { "address": "0x21A0C4CED7aE447fCf87D9FE3A29FA9B3AB20Ff1", "startBlock": 33941535, - "abi": "../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "LegacyEscrowFactory": { "address": "0xc88bC422cAAb2ac8812de03176402dbcA09533f4", "startBlock": 20689161, - "abi": "../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" }, "LegacyEscrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" } } diff --git a/packages/sdk/typescript/subgraph/config/ethereum.json b/packages/sdk/typescript/subgraph/human-protocol/config/ethereum.json similarity index 56% rename from packages/sdk/typescript/subgraph/config/ethereum.json rename to packages/sdk/typescript/subgraph/human-protocol/config/ethereum.json index c91e0ca8af..8d106ff4df 100644 --- a/packages/sdk/typescript/subgraph/config/ethereum.json +++ b/packages/sdk/typescript/subgraph/human-protocol/config/ethereum.json @@ -4,30 +4,30 @@ "EscrowFactory": { "address": "0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a", "startBlock": 16924057, - "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867" }, "Escrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "KVStore": { "address": "0xB6d36B1CDaD50302BCB3DB43bAb0D349458e1b8D", "startBlock": 18683644, - "abi": "../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "Staking": { "address": "0xEf6Da3aB52c33925Be3F84038193a7e1331F51E6", "startBlock": 21464165, - "abi": "../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" }, "LegacyEscrowFactory": { "address": "0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a", "startBlock": 16924057, - "abi": "../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" }, "LegacyEscrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" } } diff --git a/packages/sdk/typescript/subgraph/config/localhost.json b/packages/sdk/typescript/subgraph/human-protocol/config/localhost.json similarity index 60% rename from packages/sdk/typescript/subgraph/config/localhost.json rename to packages/sdk/typescript/subgraph/human-protocol/config/localhost.json index 15b69817b4..5c53a4e5ae 100644 --- a/packages/sdk/typescript/subgraph/config/localhost.json +++ b/packages/sdk/typescript/subgraph/human-protocol/config/localhost.json @@ -4,22 +4,22 @@ "EscrowFactory": { "address": "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9", "startBlock": 5, - "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3" }, "Escrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "Staking": { "address": "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512", "startBlock": 3, - "abi": "../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" }, "KVStore": { "address": "0xdc64a140aa3e981100a9beca4e685f962f0cf6c9", "startBlock": 6, - "abi": "../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" } } diff --git a/packages/sdk/typescript/subgraph/config/polygon.json b/packages/sdk/typescript/subgraph/human-protocol/config/polygon.json similarity index 56% rename from packages/sdk/typescript/subgraph/config/polygon.json rename to packages/sdk/typescript/subgraph/human-protocol/config/polygon.json index 91bd092cc7..c81064286d 100644 --- a/packages/sdk/typescript/subgraph/config/polygon.json +++ b/packages/sdk/typescript/subgraph/human-protocol/config/polygon.json @@ -4,30 +4,30 @@ "EscrowFactory": { "address": "0xBDBfD2cC708199C5640C6ECdf3B0F4A4C67AdfcB", "startBlock": 38858552, - "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571Bf" }, "Escrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "Staking": { "address": "0x01D115E9E8bF0C58318793624CC662a030D07F1D", "startBlock": 65832028, - "abi": "../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" }, "KVStore": { "address": "0xbcB28672F826a50B03EE91B28145EAbddA73B2eD", "startBlock": 50567977, - "abi": "../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "LegacyEscrowFactory": { "address": "0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794", "startBlock": 25426566, - "abi": "../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" }, "LegacyEscrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" } } diff --git a/packages/sdk/typescript/subgraph/config/sepolia.json b/packages/sdk/typescript/subgraph/human-protocol/config/sepolia.json similarity index 56% rename from packages/sdk/typescript/subgraph/config/sepolia.json rename to packages/sdk/typescript/subgraph/human-protocol/config/sepolia.json index 812bc64390..7ffbc15c7c 100644 --- a/packages/sdk/typescript/subgraph/config/sepolia.json +++ b/packages/sdk/typescript/subgraph/human-protocol/config/sepolia.json @@ -4,25 +4,25 @@ "EscrowFactory": { "address": "0x5987A5558d961ee674efe4A8c8eB7B1b5495D3bf", "startBlock": 7067993, - "abi": "../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33" }, "Escrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "KVStore": { "address": "0xCc0AF0635aa19fE799B6aFDBe28fcFAeA7f00a60", "startBlock": 5716238, - "abi": "../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "Staking": { "address": "0x2163e3A40032Af1C359ac731deaB48258b317890", "startBlock": 7062708, - "abi": "../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" }, "LegacyEscrow": { - "abi": "../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" + "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" } } diff --git a/packages/sdk/typescript/subgraph/eslint.config.mjs b/packages/sdk/typescript/subgraph/human-protocol/eslint.config.mjs similarity index 100% rename from packages/sdk/typescript/subgraph/eslint.config.mjs rename to packages/sdk/typescript/subgraph/human-protocol/eslint.config.mjs diff --git a/packages/sdk/typescript/subgraph/local-graph-status.sh b/packages/sdk/typescript/subgraph/human-protocol/local-graph-status.sh similarity index 100% rename from packages/sdk/typescript/subgraph/local-graph-status.sh rename to packages/sdk/typescript/subgraph/human-protocol/local-graph-status.sh diff --git a/packages/sdk/typescript/subgraph/matchstick.yaml b/packages/sdk/typescript/subgraph/human-protocol/matchstick.yaml similarity index 100% rename from packages/sdk/typescript/subgraph/matchstick.yaml rename to packages/sdk/typescript/subgraph/human-protocol/matchstick.yaml diff --git a/packages/sdk/typescript/subgraph/package.json b/packages/sdk/typescript/subgraph/human-protocol/package.json similarity index 96% rename from packages/sdk/typescript/subgraph/package.json rename to packages/sdk/typescript/subgraph/human-protocol/package.json index 03dfb3d969..b6c59674ca 100644 --- a/packages/sdk/typescript/subgraph/package.json +++ b/packages/sdk/typescript/subgraph/human-protocol/package.json @@ -26,7 +26,7 @@ "repository": { "type": "git", "url": "https://github.com/humanprotocol/human-protocol.git", - "directory": "packages/sdk/typescript/subgraph" + "directory": "packages/sdk/typescript/subgraph/human-protocol" }, "keywords": [ "human-protocol", diff --git a/packages/sdk/typescript/subgraph/schema.graphql b/packages/sdk/typescript/subgraph/human-protocol/schema.graphql similarity index 100% rename from packages/sdk/typescript/subgraph/schema.graphql rename to packages/sdk/typescript/subgraph/human-protocol/schema.graphql diff --git a/packages/sdk/typescript/subgraph/src/mapping/EscrowFactory.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowFactory.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/EscrowFactory.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowFactory.ts diff --git a/packages/sdk/typescript/subgraph/src/mapping/EscrowTemplate.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/EscrowTemplate.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts diff --git a/packages/sdk/typescript/subgraph/src/mapping/KVStore.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/KVStore.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/KVStore.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/KVStore.ts diff --git a/packages/sdk/typescript/subgraph/src/mapping/StakingTemplate.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/StakingTemplate.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/StakingTemplate.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/StakingTemplate.ts diff --git a/packages/sdk/typescript/subgraph/src/mapping/legacy/Escrow.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/legacy/Escrow.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/legacy/Escrow.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/legacy/Escrow.ts diff --git a/packages/sdk/typescript/subgraph/src/mapping/legacy/EscrowFactory.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/legacy/EscrowFactory.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/legacy/EscrowFactory.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/legacy/EscrowFactory.ts diff --git a/packages/sdk/typescript/subgraph/src/mapping/utils/dayUpdates.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/dayUpdates.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/utils/dayUpdates.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/dayUpdates.ts diff --git a/packages/sdk/typescript/subgraph/src/mapping/utils/ethAdrress.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/ethAdrress.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/utils/ethAdrress.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/ethAdrress.ts diff --git a/packages/sdk/typescript/subgraph/src/mapping/utils/event.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/event.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/utils/event.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/event.ts diff --git a/packages/sdk/typescript/subgraph/src/mapping/utils/number.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/number.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/utils/number.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/number.ts diff --git a/packages/sdk/typescript/subgraph/src/mapping/utils/string.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/string.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/utils/string.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/string.ts diff --git a/packages/sdk/typescript/subgraph/src/mapping/utils/transaction.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/transaction.ts similarity index 100% rename from packages/sdk/typescript/subgraph/src/mapping/utils/transaction.ts rename to packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/transaction.ts diff --git a/packages/sdk/typescript/subgraph/template.yaml b/packages/sdk/typescript/subgraph/human-protocol/template.yaml similarity index 100% rename from packages/sdk/typescript/subgraph/template.yaml rename to packages/sdk/typescript/subgraph/human-protocol/template.yaml diff --git a/packages/sdk/typescript/subgraph/tests/escrow-factory/escrow-factory.test.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/escrow-factory/escrow-factory.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/escrow-factory/escrow-factory.test.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/escrow-factory/escrow-factory.test.ts diff --git a/packages/sdk/typescript/subgraph/tests/escrow-factory/fixtures.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/escrow-factory/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/escrow-factory/fixtures.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/escrow-factory/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/tests/escrow/escrow.test.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/escrow.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/escrow/escrow.test.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/escrow/escrow.test.ts diff --git a/packages/sdk/typescript/subgraph/tests/escrow/fixtures.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/escrow/fixtures.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/escrow/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/tests/kvstore/fixtures.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/kvstore/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/kvstore/fixtures.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/kvstore/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/tests/kvstore/kvstore.test.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/kvstore/kvstore.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/kvstore/kvstore.test.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/kvstore/kvstore.test.ts diff --git a/packages/sdk/typescript/subgraph/tests/legacy/escrow-factory/escrow-factory.test.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow-factory/escrow-factory.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/legacy/escrow-factory/escrow-factory.test.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow-factory/escrow-factory.test.ts diff --git a/packages/sdk/typescript/subgraph/tests/legacy/escrow-factory/fixtures.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow-factory/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/legacy/escrow-factory/fixtures.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow-factory/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/tests/legacy/escrow/escrow.test.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow/escrow.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/legacy/escrow/escrow.test.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow/escrow.test.ts diff --git a/packages/sdk/typescript/subgraph/tests/legacy/escrow/fixtures.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/legacy/escrow/fixtures.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/tests/staking/fixtures.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/staking/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/staking/fixtures.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/staking/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/tests/staking/staking.test.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/staking/staking.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/staking/staking.test.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/staking/staking.test.ts diff --git a/packages/sdk/typescript/subgraph/tests/utils.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/utils.ts similarity index 100% rename from packages/sdk/typescript/subgraph/tests/utils.ts rename to packages/sdk/typescript/subgraph/human-protocol/tests/utils.ts diff --git a/packages/sdk/typescript/subgraph/tsconfig.json b/packages/sdk/typescript/subgraph/human-protocol/tsconfig.json similarity index 100% rename from packages/sdk/typescript/subgraph/tsconfig.json rename to packages/sdk/typescript/subgraph/human-protocol/tsconfig.json diff --git a/yarn.lock b/yarn.lock index 4a70e1d6d4..621df8e8d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11162,9 +11162,9 @@ __metadata: languageName: node linkType: hard -"@tools/subgraph-hmt-stats@workspace:packages/sdk/typescript/subgraph-hmt-stats": +"@tools/subgraph-hmt-stats@workspace:packages/sdk/typescript/subgraph/hmt": version: 0.0.0-use.local - resolution: "@tools/subgraph-hmt-stats@workspace:packages/sdk/typescript/subgraph-hmt-stats" + resolution: "@tools/subgraph-hmt-stats@workspace:packages/sdk/typescript/subgraph/hmt" dependencies: "@graphprotocol/graph-cli": "npm:^0.97.1" "@graphprotocol/graph-ts": "npm:^0.38.0" @@ -11179,9 +11179,9 @@ __metadata: languageName: unknown linkType: soft -"@tools/subgraph@workspace:packages/sdk/typescript/subgraph": +"@tools/subgraph@workspace:packages/sdk/typescript/subgraph/human-protocol": version: 0.0.0-use.local - resolution: "@tools/subgraph@workspace:packages/sdk/typescript/subgraph" + resolution: "@tools/subgraph@workspace:packages/sdk/typescript/subgraph/human-protocol" dependencies: "@graphprotocol/graph-cli": "npm:^0.97.1" "@graphprotocol/graph-ts": "npm:^0.38.0" From 0f6d08414fcd755b49cf9d47407c3c81e60461b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Wed, 4 Mar 2026 14:39:25 +0100 Subject: [PATCH 06/10] Update matchstick.yaml libsFolder path and enhance internalTransaction handling in EscrowTemplate --- .../sdk/typescript/subgraph/human-protocol/matchstick.yaml | 2 +- .../subgraph/human-protocol/src/mapping/EscrowTemplate.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/sdk/typescript/subgraph/human-protocol/matchstick.yaml b/packages/sdk/typescript/subgraph/human-protocol/matchstick.yaml index b6dd695aba..e6859bf3f4 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/matchstick.yaml +++ b/packages/sdk/typescript/subgraph/human-protocol/matchstick.yaml @@ -1 +1 @@ -libsFolder: ../../../../node_modules +libsFolder: ../../../../../node_modules diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts index 76c8b13d8b..bca745e5e3 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts +++ b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts @@ -556,6 +556,8 @@ function handleBulkTransferCommon( internalTransaction.transaction = transaction.id; internalTransaction.method = 'transfer'; internalTransaction.escrow = Address.fromBytes(escrowEntity.address); + internalTransaction.token = Address.fromBytes(escrowEntity.token); + internalTransaction.receiver = recipient; internalTransaction.save(); } @@ -689,6 +691,7 @@ export function handleCompleted(event: Completed): void { internalTransaction.method = 'transfer'; internalTransaction.escrow = escrowEntity.address; internalTransaction.token = escrowEntity.token; + internalTransaction.receiver = escrowEntity.launcher; internalTransaction.save(); escrowEntity.balance = ZERO_BI; From 8ada099b7d6cdebdd36cebe664434637cbb085ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Wed, 4 Mar 2026 14:42:31 +0100 Subject: [PATCH 07/10] Update libsFolder path in matchstick.yaml for correct module resolution --- packages/sdk/typescript/subgraph/hmt/matchstick.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk/typescript/subgraph/hmt/matchstick.yaml b/packages/sdk/typescript/subgraph/hmt/matchstick.yaml index b6dd695aba..e6859bf3f4 100644 --- a/packages/sdk/typescript/subgraph/hmt/matchstick.yaml +++ b/packages/sdk/typescript/subgraph/hmt/matchstick.yaml @@ -1 +1 @@ -libsFolder: ../../../../node_modules +libsFolder: ../../../../../node_modules From 6d20998a51c2c5eba2283b8a0f8c50cd3bcea72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Wed, 4 Mar 2026 16:08:47 +0100 Subject: [PATCH 08/10] Add permissions section for subgraph CI workflow --- .github/workflows/ci-test-subgraph.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci-test-subgraph.yaml b/.github/workflows/ci-test-subgraph.yaml index 748ee80230..b12d2792d7 100644 --- a/.github/workflows/ci-test-subgraph.yaml +++ b/.github/workflows/ci-test-subgraph.yaml @@ -7,6 +7,9 @@ on: - "packages/core/**" - "packages/sdk/typescript/subgraph/**" +permissions: + contents: read + jobs: subgraph-test: name: Subgraph Test (${{ matrix.workspace }}) From f83c0a27140eec888f10f2664ebaf961d20adde4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Thu, 5 Mar 2026 15:11:29 +0100 Subject: [PATCH 09/10] Add transaction creation and tests for fund events in Escrow --- .../src/mapping/EscrowTemplate.ts | 11 ++++++++++ .../tests/escrow/escrow.test.ts | 20 +++++++++++++++++++ .../human-protocol/tests/escrow/fixtures.ts | 4 ++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts index bca745e5e3..214da14547 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts +++ b/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts @@ -710,6 +710,17 @@ export function handleFund(event: Fund): void { return; } + createTransaction( + event, + 'fund', + event.transaction.from, + Address.fromBytes(escrowEntity.address), + null, + Address.fromBytes(escrowEntity.address), + event.params.amount, + Address.fromBytes(escrowEntity.token) + ); + // Create FundEvent entity const fundEventEntity = new FundEvent(toEventId(event)); fundEventEntity.block = event.block.number; diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/escrow.test.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/escrow.test.ts index 9fabb437ba..4c1a4da747 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/escrow.test.ts +++ b/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/escrow.test.ts @@ -660,6 +660,26 @@ describe('Escrow', () => { assert.fieldEquals('FundEvent', id, 'sender', operatorAddressString); assert.fieldEquals('FundEvent', id, 'amount', '100'); + // Transaction + assert.fieldEquals( + 'Transaction', + fund.transaction.hash.toHex(), + 'method', + 'fund' + ); + assert.fieldEquals( + 'Transaction', + fund.transaction.hash.toHex(), + 'to', + escrowAddressString + ); + assert.fieldEquals( + 'Transaction', + fund.transaction.hash.toHex(), + 'value', + '100' + ); + // Escrow assert.fieldEquals('Escrow', escrowAddressString, 'balance', '100'); assert.fieldEquals( diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/fixtures.ts b/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/fixtures.ts index 77d0b2020f..2caf119f3b 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/fixtures.ts +++ b/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/fixtures.ts @@ -324,7 +324,7 @@ export function createFundEvent( ): Fund { const newFundEvent = changetype(newMockEvent()); newFundEvent.transaction.hash = generateUniqueHash( - sender.toString(), + sender.toString() + '-fund', timestamp, newFundEvent.transaction.nonce ); @@ -386,7 +386,7 @@ export function createCancellationRequestedEvent( ): CancellationRequested { const event = changetype(newMockEvent()); event.transaction.hash = generateUniqueHash( - sender.toString(), + sender.toString() + '-cancellation-requested', timestamp, event.transaction.nonce ); From e3e2e0cd79ba25eadcd306f3f319cf98e102e8e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Thu, 5 Mar 2026 16:40:18 +0100 Subject: [PATCH 10/10] Moved subgraphs from SDK to their own folder in package level --- packages/sdk/typescript/subgraph/hmt/matchstick.yaml | 1 - .../subgraph/human-protocol/matchstick.yaml | 1 - .../{sdk/typescript => }/subgraph/hmt/.gitignore | 0 .../typescript => }/subgraph/hmt/.prettierignore | 0 .../{sdk/typescript => }/subgraph/hmt/.prettierrc | 0 packages/{sdk/typescript => }/subgraph/hmt/README.md | 0 .../typescript => }/subgraph/hmt/config/amoy.json | 2 +- .../subgraph/hmt/config/bsc-testnet.json | 2 +- .../typescript => }/subgraph/hmt/config/bsc.json | 2 +- .../subgraph/hmt/config/ethereum.json | 2 +- .../subgraph/hmt/config/localhost.json | 2 +- .../typescript => }/subgraph/hmt/config/polygon.json | 2 +- .../typescript => }/subgraph/hmt/config/sepolia.json | 2 +- .../typescript => }/subgraph/hmt/eslint.config.mjs | 0 packages/subgraph/hmt/matchstick.yaml | 1 + .../{sdk/typescript => }/subgraph/hmt/package.json | 0 .../{sdk/typescript => }/subgraph/hmt/schema.graphql | 0 .../subgraph/hmt/src/mapping/HMToken.ts | 0 .../subgraph/hmt/src/mapping/utils/dayUpdates.ts | 0 .../subgraph/hmt/src/mapping/utils/number.ts | 0 .../{sdk/typescript => }/subgraph/hmt/template.yaml | 0 .../subgraph/hmt/tests/hmt/fixtures.ts | 0 .../subgraph/hmt/tests/hmt/hmt.test.ts | 0 .../{sdk/typescript => }/subgraph/hmt/tests/utils.ts | 0 .../human-protocol => subgraph/hmt}/tsconfig.json | 2 +- .../subgraph/human-protocol/.gitignore | 0 .../subgraph/human-protocol/.prettierignore | 0 .../subgraph/human-protocol/.prettierrc | 0 .../subgraph/human-protocol/README.md | 0 .../subgraph/human-protocol/config/amoy.json | 8 ++++---- .../subgraph/human-protocol/config/bsc-testnet.json | 12 ++++++------ .../subgraph/human-protocol/config/bsc.json | 12 ++++++------ .../subgraph/human-protocol/config/ethereum.json | 12 ++++++------ .../subgraph/human-protocol/config/localhost.json | 8 ++++---- .../subgraph/human-protocol/config/polygon.json | 12 ++++++------ .../subgraph/human-protocol/config/sepolia.json | 10 +++++----- .../subgraph/human-protocol/eslint.config.mjs | 0 .../subgraph/human-protocol/local-graph-status.sh | 0 packages/subgraph/human-protocol/matchstick.yaml | 1 + .../subgraph/human-protocol/package.json | 0 .../subgraph/human-protocol/schema.graphql | 0 .../human-protocol/src/mapping/EscrowFactory.ts | 0 .../human-protocol/src/mapping/EscrowTemplate.ts | 0 .../subgraph/human-protocol/src/mapping/KVStore.ts | 0 .../human-protocol/src/mapping/StakingTemplate.ts | 0 .../human-protocol/src/mapping/legacy/Escrow.ts | 0 .../src/mapping/legacy/EscrowFactory.ts | 0 .../human-protocol/src/mapping/utils/dayUpdates.ts | 0 .../human-protocol/src/mapping/utils/ethAdrress.ts | 0 .../human-protocol/src/mapping/utils/event.ts | 0 .../human-protocol/src/mapping/utils/number.ts | 0 .../human-protocol/src/mapping/utils/string.ts | 0 .../human-protocol/src/mapping/utils/transaction.ts | 0 .../subgraph/human-protocol/template.yaml | 0 .../tests/escrow-factory/escrow-factory.test.ts | 0 .../human-protocol/tests/escrow-factory/fixtures.ts | 0 .../human-protocol/tests/escrow/escrow.test.ts | 0 .../subgraph/human-protocol/tests/escrow/fixtures.ts | 0 .../human-protocol/tests/kvstore/fixtures.ts | 0 .../human-protocol/tests/kvstore/kvstore.test.ts | 0 .../legacy/escrow-factory/escrow-factory.test.ts | 0 .../tests/legacy/escrow-factory/fixtures.ts | 0 .../tests/legacy/escrow/escrow.test.ts | 0 .../human-protocol/tests/legacy/escrow/fixtures.ts | 0 .../human-protocol/tests/staking/fixtures.ts | 0 .../human-protocol/tests/staking/staking.test.ts | 0 .../subgraph/human-protocol/tests/utils.ts | 0 .../hmt => subgraph/human-protocol}/tsconfig.json | 2 +- yarn.lock | 8 ++++---- 69 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 packages/sdk/typescript/subgraph/hmt/matchstick.yaml delete mode 100644 packages/sdk/typescript/subgraph/human-protocol/matchstick.yaml rename packages/{sdk/typescript => }/subgraph/hmt/.gitignore (100%) rename packages/{sdk/typescript => }/subgraph/hmt/.prettierignore (100%) rename packages/{sdk/typescript => }/subgraph/hmt/.prettierrc (100%) rename packages/{sdk/typescript => }/subgraph/hmt/README.md (100%) rename packages/{sdk/typescript => }/subgraph/hmt/config/amoy.json (70%) rename packages/{sdk/typescript => }/subgraph/hmt/config/bsc-testnet.json (71%) rename packages/{sdk/typescript => }/subgraph/hmt/config/bsc.json (69%) rename packages/{sdk/typescript => }/subgraph/hmt/config/ethereum.json (70%) rename packages/{sdk/typescript => }/subgraph/hmt/config/localhost.json (69%) rename packages/{sdk/typescript => }/subgraph/hmt/config/polygon.json (70%) rename packages/{sdk/typescript => }/subgraph/hmt/config/sepolia.json (71%) rename packages/{sdk/typescript => }/subgraph/hmt/eslint.config.mjs (100%) create mode 100644 packages/subgraph/hmt/matchstick.yaml rename packages/{sdk/typescript => }/subgraph/hmt/package.json (100%) rename packages/{sdk/typescript => }/subgraph/hmt/schema.graphql (100%) rename packages/{sdk/typescript => }/subgraph/hmt/src/mapping/HMToken.ts (100%) rename packages/{sdk/typescript => }/subgraph/hmt/src/mapping/utils/dayUpdates.ts (100%) rename packages/{sdk/typescript => }/subgraph/hmt/src/mapping/utils/number.ts (100%) rename packages/{sdk/typescript => }/subgraph/hmt/template.yaml (100%) rename packages/{sdk/typescript => }/subgraph/hmt/tests/hmt/fixtures.ts (100%) rename packages/{sdk/typescript => }/subgraph/hmt/tests/hmt/hmt.test.ts (100%) rename packages/{sdk/typescript => }/subgraph/hmt/tests/utils.ts (100%) rename packages/{sdk/typescript/subgraph/human-protocol => subgraph/hmt}/tsconfig.json (73%) rename packages/{sdk/typescript => }/subgraph/human-protocol/.gitignore (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/.prettierignore (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/.prettierrc (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/README.md (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/config/amoy.json (61%) rename packages/{sdk/typescript => }/subgraph/human-protocol/config/bsc-testnet.json (57%) rename packages/{sdk/typescript => }/subgraph/human-protocol/config/bsc.json (56%) rename packages/{sdk/typescript => }/subgraph/human-protocol/config/ethereum.json (56%) rename packages/{sdk/typescript => }/subgraph/human-protocol/config/localhost.json (60%) rename packages/{sdk/typescript => }/subgraph/human-protocol/config/polygon.json (56%) rename packages/{sdk/typescript => }/subgraph/human-protocol/config/sepolia.json (56%) rename packages/{sdk/typescript => }/subgraph/human-protocol/eslint.config.mjs (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/local-graph-status.sh (100%) create mode 100644 packages/subgraph/human-protocol/matchstick.yaml rename packages/{sdk/typescript => }/subgraph/human-protocol/package.json (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/schema.graphql (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/EscrowFactory.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/EscrowTemplate.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/KVStore.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/StakingTemplate.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/legacy/Escrow.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/legacy/EscrowFactory.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/utils/dayUpdates.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/utils/ethAdrress.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/utils/event.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/utils/number.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/utils/string.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/src/mapping/utils/transaction.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/template.yaml (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/escrow-factory/escrow-factory.test.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/escrow-factory/fixtures.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/escrow/escrow.test.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/escrow/fixtures.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/kvstore/fixtures.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/kvstore/kvstore.test.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/legacy/escrow-factory/escrow-factory.test.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/legacy/escrow-factory/fixtures.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/legacy/escrow/escrow.test.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/legacy/escrow/fixtures.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/staking/fixtures.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/staking/staking.test.ts (100%) rename packages/{sdk/typescript => }/subgraph/human-protocol/tests/utils.ts (100%) rename packages/{sdk/typescript/subgraph/hmt => subgraph/human-protocol}/tsconfig.json (73%) diff --git a/packages/sdk/typescript/subgraph/hmt/matchstick.yaml b/packages/sdk/typescript/subgraph/hmt/matchstick.yaml deleted file mode 100644 index e6859bf3f4..0000000000 --- a/packages/sdk/typescript/subgraph/hmt/matchstick.yaml +++ /dev/null @@ -1 +0,0 @@ -libsFolder: ../../../../../node_modules diff --git a/packages/sdk/typescript/subgraph/human-protocol/matchstick.yaml b/packages/sdk/typescript/subgraph/human-protocol/matchstick.yaml deleted file mode 100644 index e6859bf3f4..0000000000 --- a/packages/sdk/typescript/subgraph/human-protocol/matchstick.yaml +++ /dev/null @@ -1 +0,0 @@ -libsFolder: ../../../../../node_modules diff --git a/packages/sdk/typescript/subgraph/hmt/.gitignore b/packages/subgraph/hmt/.gitignore similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/.gitignore rename to packages/subgraph/hmt/.gitignore diff --git a/packages/sdk/typescript/subgraph/hmt/.prettierignore b/packages/subgraph/hmt/.prettierignore similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/.prettierignore rename to packages/subgraph/hmt/.prettierignore diff --git a/packages/sdk/typescript/subgraph/hmt/.prettierrc b/packages/subgraph/hmt/.prettierrc similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/.prettierrc rename to packages/subgraph/hmt/.prettierrc diff --git a/packages/sdk/typescript/subgraph/hmt/README.md b/packages/subgraph/hmt/README.md similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/README.md rename to packages/subgraph/hmt/README.md diff --git a/packages/sdk/typescript/subgraph/hmt/config/amoy.json b/packages/subgraph/hmt/config/amoy.json similarity index 70% rename from packages/sdk/typescript/subgraph/hmt/config/amoy.json rename to packages/subgraph/hmt/config/amoy.json index a3d9f907a9..9e3ff34fee 100644 --- a/packages/sdk/typescript/subgraph/hmt/config/amoy.json +++ b/packages/subgraph/hmt/config/amoy.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33", "startBlock": 5769546, - "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph/hmt/config/bsc-testnet.json b/packages/subgraph/hmt/config/bsc-testnet.json similarity index 71% rename from packages/sdk/typescript/subgraph/hmt/config/bsc-testnet.json rename to packages/subgraph/hmt/config/bsc-testnet.json index ed6d9b491c..bab01016d0 100644 --- a/packages/sdk/typescript/subgraph/hmt/config/bsc-testnet.json +++ b/packages/subgraph/hmt/config/bsc-testnet.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d", "startBlock": 26716354, - "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph/hmt/config/bsc.json b/packages/subgraph/hmt/config/bsc.json similarity index 69% rename from packages/sdk/typescript/subgraph/hmt/config/bsc.json rename to packages/subgraph/hmt/config/bsc.json index e69df3d9f8..eab6ad0b64 100644 --- a/packages/sdk/typescript/subgraph/hmt/config/bsc.json +++ b/packages/subgraph/hmt/config/bsc.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0x711Fd6ab6d65A98904522d4e3586F492B989c527", "startBlock": 25383172, - "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph/hmt/config/ethereum.json b/packages/subgraph/hmt/config/ethereum.json similarity index 70% rename from packages/sdk/typescript/subgraph/hmt/config/ethereum.json rename to packages/subgraph/hmt/config/ethereum.json index 8a520e7319..9004bd2aca 100644 --- a/packages/sdk/typescript/subgraph/hmt/config/ethereum.json +++ b/packages/subgraph/hmt/config/ethereum.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867", "startBlock": 12184475, - "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph/hmt/config/localhost.json b/packages/subgraph/hmt/config/localhost.json similarity index 69% rename from packages/sdk/typescript/subgraph/hmt/config/localhost.json rename to packages/subgraph/hmt/config/localhost.json index 56e613392a..e69584771f 100644 --- a/packages/sdk/typescript/subgraph/hmt/config/localhost.json +++ b/packages/subgraph/hmt/config/localhost.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "startBlock": 1, - "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph/hmt/config/polygon.json b/packages/subgraph/hmt/config/polygon.json similarity index 70% rename from packages/sdk/typescript/subgraph/hmt/config/polygon.json rename to packages/subgraph/hmt/config/polygon.json index 657ebf2e03..ee304360a6 100644 --- a/packages/sdk/typescript/subgraph/hmt/config/polygon.json +++ b/packages/subgraph/hmt/config/polygon.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571Bf", "startBlock": 20181701, - "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph/hmt/config/sepolia.json b/packages/subgraph/hmt/config/sepolia.json similarity index 71% rename from packages/sdk/typescript/subgraph/hmt/config/sepolia.json rename to packages/subgraph/hmt/config/sepolia.json index 70698bd2d9..ebc16b0e25 100644 --- a/packages/sdk/typescript/subgraph/hmt/config/sepolia.json +++ b/packages/subgraph/hmt/config/sepolia.json @@ -4,6 +4,6 @@ "HMToken": { "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33", "startBlock": 5716225, - "abi": "../../../../../node_modules/@human-protocol/core/abis/HMToken.json" + "abi": "../../../node_modules/@human-protocol/core/abis/HMToken.json" } } diff --git a/packages/sdk/typescript/subgraph/hmt/eslint.config.mjs b/packages/subgraph/hmt/eslint.config.mjs similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/eslint.config.mjs rename to packages/subgraph/hmt/eslint.config.mjs diff --git a/packages/subgraph/hmt/matchstick.yaml b/packages/subgraph/hmt/matchstick.yaml new file mode 100644 index 0000000000..be49651fb8 --- /dev/null +++ b/packages/subgraph/hmt/matchstick.yaml @@ -0,0 +1 @@ +libsFolder: ../../../node_modules diff --git a/packages/sdk/typescript/subgraph/hmt/package.json b/packages/subgraph/hmt/package.json similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/package.json rename to packages/subgraph/hmt/package.json diff --git a/packages/sdk/typescript/subgraph/hmt/schema.graphql b/packages/subgraph/hmt/schema.graphql similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/schema.graphql rename to packages/subgraph/hmt/schema.graphql diff --git a/packages/sdk/typescript/subgraph/hmt/src/mapping/HMToken.ts b/packages/subgraph/hmt/src/mapping/HMToken.ts similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/src/mapping/HMToken.ts rename to packages/subgraph/hmt/src/mapping/HMToken.ts diff --git a/packages/sdk/typescript/subgraph/hmt/src/mapping/utils/dayUpdates.ts b/packages/subgraph/hmt/src/mapping/utils/dayUpdates.ts similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/src/mapping/utils/dayUpdates.ts rename to packages/subgraph/hmt/src/mapping/utils/dayUpdates.ts diff --git a/packages/sdk/typescript/subgraph/hmt/src/mapping/utils/number.ts b/packages/subgraph/hmt/src/mapping/utils/number.ts similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/src/mapping/utils/number.ts rename to packages/subgraph/hmt/src/mapping/utils/number.ts diff --git a/packages/sdk/typescript/subgraph/hmt/template.yaml b/packages/subgraph/hmt/template.yaml similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/template.yaml rename to packages/subgraph/hmt/template.yaml diff --git a/packages/sdk/typescript/subgraph/hmt/tests/hmt/fixtures.ts b/packages/subgraph/hmt/tests/hmt/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/tests/hmt/fixtures.ts rename to packages/subgraph/hmt/tests/hmt/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/hmt/tests/hmt/hmt.test.ts b/packages/subgraph/hmt/tests/hmt/hmt.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/tests/hmt/hmt.test.ts rename to packages/subgraph/hmt/tests/hmt/hmt.test.ts diff --git a/packages/sdk/typescript/subgraph/hmt/tests/utils.ts b/packages/subgraph/hmt/tests/utils.ts similarity index 100% rename from packages/sdk/typescript/subgraph/hmt/tests/utils.ts rename to packages/subgraph/hmt/tests/utils.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tsconfig.json b/packages/subgraph/hmt/tsconfig.json similarity index 73% rename from packages/sdk/typescript/subgraph/human-protocol/tsconfig.json rename to packages/subgraph/hmt/tsconfig.json index f9e6cb7174..3c11a89fec 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/tsconfig.json +++ b/packages/subgraph/hmt/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "baseUrl": ".", "types": ["@graphprotocol/graph-ts", "node"] diff --git a/packages/sdk/typescript/subgraph/human-protocol/.gitignore b/packages/subgraph/human-protocol/.gitignore similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/.gitignore rename to packages/subgraph/human-protocol/.gitignore diff --git a/packages/sdk/typescript/subgraph/human-protocol/.prettierignore b/packages/subgraph/human-protocol/.prettierignore similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/.prettierignore rename to packages/subgraph/human-protocol/.prettierignore diff --git a/packages/sdk/typescript/subgraph/human-protocol/.prettierrc b/packages/subgraph/human-protocol/.prettierrc similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/.prettierrc rename to packages/subgraph/human-protocol/.prettierrc diff --git a/packages/sdk/typescript/subgraph/human-protocol/README.md b/packages/subgraph/human-protocol/README.md similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/README.md rename to packages/subgraph/human-protocol/README.md diff --git a/packages/sdk/typescript/subgraph/human-protocol/config/amoy.json b/packages/subgraph/human-protocol/config/amoy.json similarity index 61% rename from packages/sdk/typescript/subgraph/human-protocol/config/amoy.json rename to packages/subgraph/human-protocol/config/amoy.json index 33d2f27c9a..81bb09b1f4 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/config/amoy.json +++ b/packages/subgraph/human-protocol/config/amoy.json @@ -4,22 +4,22 @@ "EscrowFactory": { "address": "0xAFf5a986A530ff839d49325A5dF69F96627E8D29", "startBlock": 5773000, - "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33" }, "Escrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "KVStore": { "address": "0x724AeFC243EdacCA27EAB86D3ec5a76Af4436Fc7", "startBlock": 5773002, - "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "Staking": { "address": "0xffE496683F842a923110415b7278ded3F265f2C5", "startBlock": 14983952, - "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Staking.json" } } diff --git a/packages/sdk/typescript/subgraph/human-protocol/config/bsc-testnet.json b/packages/subgraph/human-protocol/config/bsc-testnet.json similarity index 57% rename from packages/sdk/typescript/subgraph/human-protocol/config/bsc-testnet.json rename to packages/subgraph/human-protocol/config/bsc-testnet.json index 4e40cc0b33..636e82c61d 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/config/bsc-testnet.json +++ b/packages/subgraph/human-protocol/config/bsc-testnet.json @@ -4,30 +4,30 @@ "EscrowFactory": { "address": "0x2bfA592DBDaF434DDcbb893B1916120d181DAD18", "startBlock": 26716359, - "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d" }, "Escrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "Staking": { "address": "0xD6D347ba6987519B4e42EcED43dF98eFf5465a23", "startBlock": 45938762, - "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Staking.json" }, "KVStore": { "address": "0x32e27177BA6Ea91cf28dfd91a0Da9822A4b74EcF", "startBlock": 34883905, - "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "LegacyEscrowFactory": { "address": "0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f", "startBlock": 23632686, - "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" + "abi": "../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" }, "LegacyEscrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" } } diff --git a/packages/sdk/typescript/subgraph/human-protocol/config/bsc.json b/packages/subgraph/human-protocol/config/bsc.json similarity index 56% rename from packages/sdk/typescript/subgraph/human-protocol/config/bsc.json rename to packages/subgraph/human-protocol/config/bsc.json index 1812daf14e..e7144d3720 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/config/bsc.json +++ b/packages/subgraph/human-protocol/config/bsc.json @@ -4,30 +4,30 @@ "EscrowFactory": { "address": "0x92FD968AcBd521c232f5fB8c33b342923cC72714", "startBlock": 28745625, - "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0x711Fd6ab6d65A98904522d4e3586F492B989c527" }, "Escrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "Staking": { "address": "0xE24e5C08E28331D24758b69A5E9f383D2bDD1c98", "startBlock": 45120420, - "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Staking.json" }, "KVStore": { "address": "0x21A0C4CED7aE447fCf87D9FE3A29FA9B3AB20Ff1", "startBlock": 33941535, - "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "LegacyEscrowFactory": { "address": "0xc88bC422cAAb2ac8812de03176402dbcA09533f4", "startBlock": 20689161, - "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" + "abi": "../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" }, "LegacyEscrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" } } diff --git a/packages/sdk/typescript/subgraph/human-protocol/config/ethereum.json b/packages/subgraph/human-protocol/config/ethereum.json similarity index 56% rename from packages/sdk/typescript/subgraph/human-protocol/config/ethereum.json rename to packages/subgraph/human-protocol/config/ethereum.json index 8d106ff4df..5c03c57f35 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/config/ethereum.json +++ b/packages/subgraph/human-protocol/config/ethereum.json @@ -4,30 +4,30 @@ "EscrowFactory": { "address": "0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a", "startBlock": 16924057, - "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867" }, "Escrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "KVStore": { "address": "0xB6d36B1CDaD50302BCB3DB43bAb0D349458e1b8D", "startBlock": 18683644, - "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "Staking": { "address": "0xEf6Da3aB52c33925Be3F84038193a7e1331F51E6", "startBlock": 21464165, - "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Staking.json" }, "LegacyEscrowFactory": { "address": "0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a", "startBlock": 16924057, - "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" + "abi": "../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" }, "LegacyEscrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" } } diff --git a/packages/sdk/typescript/subgraph/human-protocol/config/localhost.json b/packages/subgraph/human-protocol/config/localhost.json similarity index 60% rename from packages/sdk/typescript/subgraph/human-protocol/config/localhost.json rename to packages/subgraph/human-protocol/config/localhost.json index 5c53a4e5ae..9998836d75 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/config/localhost.json +++ b/packages/subgraph/human-protocol/config/localhost.json @@ -4,22 +4,22 @@ "EscrowFactory": { "address": "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9", "startBlock": 5, - "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3" }, "Escrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "Staking": { "address": "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512", "startBlock": 3, - "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Staking.json" }, "KVStore": { "address": "0xdc64a140aa3e981100a9beca4e685f962f0cf6c9", "startBlock": 6, - "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../node_modules/@human-protocol/core/abis/KVStore.json" } } diff --git a/packages/sdk/typescript/subgraph/human-protocol/config/polygon.json b/packages/subgraph/human-protocol/config/polygon.json similarity index 56% rename from packages/sdk/typescript/subgraph/human-protocol/config/polygon.json rename to packages/subgraph/human-protocol/config/polygon.json index c81064286d..c1a584b909 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/config/polygon.json +++ b/packages/subgraph/human-protocol/config/polygon.json @@ -4,30 +4,30 @@ "EscrowFactory": { "address": "0xBDBfD2cC708199C5640C6ECdf3B0F4A4C67AdfcB", "startBlock": 38858552, - "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571Bf" }, "Escrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "Staking": { "address": "0x01D115E9E8bF0C58318793624CC662a030D07F1D", "startBlock": 65832028, - "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Staking.json" }, "KVStore": { "address": "0xbcB28672F826a50B03EE91B28145EAbddA73B2eD", "startBlock": 50567977, - "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "LegacyEscrowFactory": { "address": "0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794", "startBlock": 25426566, - "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" + "abi": "../../../node_modules/@human-protocol/core/abis/legacy/EscrowFactory.json" }, "LegacyEscrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" } } diff --git a/packages/sdk/typescript/subgraph/human-protocol/config/sepolia.json b/packages/subgraph/human-protocol/config/sepolia.json similarity index 56% rename from packages/sdk/typescript/subgraph/human-protocol/config/sepolia.json rename to packages/subgraph/human-protocol/config/sepolia.json index 7ffbc15c7c..eca908cad1 100644 --- a/packages/sdk/typescript/subgraph/human-protocol/config/sepolia.json +++ b/packages/subgraph/human-protocol/config/sepolia.json @@ -4,25 +4,25 @@ "EscrowFactory": { "address": "0x5987A5558d961ee674efe4A8c8eB7B1b5495D3bf", "startBlock": 7067993, - "abi": "../../../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" + "abi": "../../../node_modules/@human-protocol/core/abis/EscrowFactory.json" }, "HMToken": { "address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33" }, "Escrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Escrow.json" }, "KVStore": { "address": "0xCc0AF0635aa19fE799B6aFDBe28fcFAeA7f00a60", "startBlock": 5716238, - "abi": "../../../../../node_modules/@human-protocol/core/abis/KVStore.json" + "abi": "../../../node_modules/@human-protocol/core/abis/KVStore.json" }, "Staking": { "address": "0x2163e3A40032Af1C359ac731deaB48258b317890", "startBlock": 7062708, - "abi": "../../../../../node_modules/@human-protocol/core/abis/Staking.json" + "abi": "../../../node_modules/@human-protocol/core/abis/Staking.json" }, "LegacyEscrow": { - "abi": "../../../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" + "abi": "../../../node_modules/@human-protocol/core/abis/legacy/Escrow.json" } } diff --git a/packages/sdk/typescript/subgraph/human-protocol/eslint.config.mjs b/packages/subgraph/human-protocol/eslint.config.mjs similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/eslint.config.mjs rename to packages/subgraph/human-protocol/eslint.config.mjs diff --git a/packages/sdk/typescript/subgraph/human-protocol/local-graph-status.sh b/packages/subgraph/human-protocol/local-graph-status.sh similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/local-graph-status.sh rename to packages/subgraph/human-protocol/local-graph-status.sh diff --git a/packages/subgraph/human-protocol/matchstick.yaml b/packages/subgraph/human-protocol/matchstick.yaml new file mode 100644 index 0000000000..be49651fb8 --- /dev/null +++ b/packages/subgraph/human-protocol/matchstick.yaml @@ -0,0 +1 @@ +libsFolder: ../../../node_modules diff --git a/packages/sdk/typescript/subgraph/human-protocol/package.json b/packages/subgraph/human-protocol/package.json similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/package.json rename to packages/subgraph/human-protocol/package.json diff --git a/packages/sdk/typescript/subgraph/human-protocol/schema.graphql b/packages/subgraph/human-protocol/schema.graphql similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/schema.graphql rename to packages/subgraph/human-protocol/schema.graphql diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowFactory.ts b/packages/subgraph/human-protocol/src/mapping/EscrowFactory.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowFactory.ts rename to packages/subgraph/human-protocol/src/mapping/EscrowFactory.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts b/packages/subgraph/human-protocol/src/mapping/EscrowTemplate.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/EscrowTemplate.ts rename to packages/subgraph/human-protocol/src/mapping/EscrowTemplate.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/KVStore.ts b/packages/subgraph/human-protocol/src/mapping/KVStore.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/KVStore.ts rename to packages/subgraph/human-protocol/src/mapping/KVStore.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/StakingTemplate.ts b/packages/subgraph/human-protocol/src/mapping/StakingTemplate.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/StakingTemplate.ts rename to packages/subgraph/human-protocol/src/mapping/StakingTemplate.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/legacy/Escrow.ts b/packages/subgraph/human-protocol/src/mapping/legacy/Escrow.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/legacy/Escrow.ts rename to packages/subgraph/human-protocol/src/mapping/legacy/Escrow.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/legacy/EscrowFactory.ts b/packages/subgraph/human-protocol/src/mapping/legacy/EscrowFactory.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/legacy/EscrowFactory.ts rename to packages/subgraph/human-protocol/src/mapping/legacy/EscrowFactory.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/dayUpdates.ts b/packages/subgraph/human-protocol/src/mapping/utils/dayUpdates.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/dayUpdates.ts rename to packages/subgraph/human-protocol/src/mapping/utils/dayUpdates.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/ethAdrress.ts b/packages/subgraph/human-protocol/src/mapping/utils/ethAdrress.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/ethAdrress.ts rename to packages/subgraph/human-protocol/src/mapping/utils/ethAdrress.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/event.ts b/packages/subgraph/human-protocol/src/mapping/utils/event.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/event.ts rename to packages/subgraph/human-protocol/src/mapping/utils/event.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/number.ts b/packages/subgraph/human-protocol/src/mapping/utils/number.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/number.ts rename to packages/subgraph/human-protocol/src/mapping/utils/number.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/string.ts b/packages/subgraph/human-protocol/src/mapping/utils/string.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/string.ts rename to packages/subgraph/human-protocol/src/mapping/utils/string.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/transaction.ts b/packages/subgraph/human-protocol/src/mapping/utils/transaction.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/src/mapping/utils/transaction.ts rename to packages/subgraph/human-protocol/src/mapping/utils/transaction.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/template.yaml b/packages/subgraph/human-protocol/template.yaml similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/template.yaml rename to packages/subgraph/human-protocol/template.yaml diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/escrow-factory/escrow-factory.test.ts b/packages/subgraph/human-protocol/tests/escrow-factory/escrow-factory.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/escrow-factory/escrow-factory.test.ts rename to packages/subgraph/human-protocol/tests/escrow-factory/escrow-factory.test.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/escrow-factory/fixtures.ts b/packages/subgraph/human-protocol/tests/escrow-factory/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/escrow-factory/fixtures.ts rename to packages/subgraph/human-protocol/tests/escrow-factory/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/escrow.test.ts b/packages/subgraph/human-protocol/tests/escrow/escrow.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/escrow/escrow.test.ts rename to packages/subgraph/human-protocol/tests/escrow/escrow.test.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/escrow/fixtures.ts b/packages/subgraph/human-protocol/tests/escrow/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/escrow/fixtures.ts rename to packages/subgraph/human-protocol/tests/escrow/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/kvstore/fixtures.ts b/packages/subgraph/human-protocol/tests/kvstore/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/kvstore/fixtures.ts rename to packages/subgraph/human-protocol/tests/kvstore/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/kvstore/kvstore.test.ts b/packages/subgraph/human-protocol/tests/kvstore/kvstore.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/kvstore/kvstore.test.ts rename to packages/subgraph/human-protocol/tests/kvstore/kvstore.test.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow-factory/escrow-factory.test.ts b/packages/subgraph/human-protocol/tests/legacy/escrow-factory/escrow-factory.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow-factory/escrow-factory.test.ts rename to packages/subgraph/human-protocol/tests/legacy/escrow-factory/escrow-factory.test.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow-factory/fixtures.ts b/packages/subgraph/human-protocol/tests/legacy/escrow-factory/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow-factory/fixtures.ts rename to packages/subgraph/human-protocol/tests/legacy/escrow-factory/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow/escrow.test.ts b/packages/subgraph/human-protocol/tests/legacy/escrow/escrow.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow/escrow.test.ts rename to packages/subgraph/human-protocol/tests/legacy/escrow/escrow.test.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow/fixtures.ts b/packages/subgraph/human-protocol/tests/legacy/escrow/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/legacy/escrow/fixtures.ts rename to packages/subgraph/human-protocol/tests/legacy/escrow/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/staking/fixtures.ts b/packages/subgraph/human-protocol/tests/staking/fixtures.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/staking/fixtures.ts rename to packages/subgraph/human-protocol/tests/staking/fixtures.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/staking/staking.test.ts b/packages/subgraph/human-protocol/tests/staking/staking.test.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/staking/staking.test.ts rename to packages/subgraph/human-protocol/tests/staking/staking.test.ts diff --git a/packages/sdk/typescript/subgraph/human-protocol/tests/utils.ts b/packages/subgraph/human-protocol/tests/utils.ts similarity index 100% rename from packages/sdk/typescript/subgraph/human-protocol/tests/utils.ts rename to packages/subgraph/human-protocol/tests/utils.ts diff --git a/packages/sdk/typescript/subgraph/hmt/tsconfig.json b/packages/subgraph/human-protocol/tsconfig.json similarity index 73% rename from packages/sdk/typescript/subgraph/hmt/tsconfig.json rename to packages/subgraph/human-protocol/tsconfig.json index f9e6cb7174..3c11a89fec 100644 --- a/packages/sdk/typescript/subgraph/hmt/tsconfig.json +++ b/packages/subgraph/human-protocol/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "baseUrl": ".", "types": ["@graphprotocol/graph-ts", "node"] diff --git a/yarn.lock b/yarn.lock index 621df8e8d8..6fe9560902 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11162,9 +11162,9 @@ __metadata: languageName: node linkType: hard -"@tools/subgraph-hmt-stats@workspace:packages/sdk/typescript/subgraph/hmt": +"@tools/subgraph-hmt-stats@workspace:packages/subgraph/hmt": version: 0.0.0-use.local - resolution: "@tools/subgraph-hmt-stats@workspace:packages/sdk/typescript/subgraph/hmt" + resolution: "@tools/subgraph-hmt-stats@workspace:packages/subgraph/hmt" dependencies: "@graphprotocol/graph-cli": "npm:^0.97.1" "@graphprotocol/graph-ts": "npm:^0.38.0" @@ -11179,9 +11179,9 @@ __metadata: languageName: unknown linkType: soft -"@tools/subgraph@workspace:packages/sdk/typescript/subgraph/human-protocol": +"@tools/subgraph@workspace:packages/subgraph/human-protocol": version: 0.0.0-use.local - resolution: "@tools/subgraph@workspace:packages/sdk/typescript/subgraph/human-protocol" + resolution: "@tools/subgraph@workspace:packages/subgraph/human-protocol" dependencies: "@graphprotocol/graph-cli": "npm:^0.97.1" "@graphprotocol/graph-ts": "npm:^0.38.0"