ocean-subgraph/src/mappings/veDelegation.ts

126 lines
4.8 KiB
TypeScript
Raw Permalink Normal View History

import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
2023-04-28 08:36:56 +02:00
import { VeDelegationUpdate } from '../@types/schema'
Implementing first pass of veAllocate schema, handlers, and test cove… (#490) * Implementing first pass of veAllocate schema, handlers, and test coverage. * Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come. * Created documentation. Moving tests away from subgraph and into df-py. * Expanding documentation to be thorough and cover more of the work involved. * use barge artifacts * use proper contracts in ci * use barge artifacts folder * fix replace * use npm contracts dep * use latest contracts for barge * fix some lint * Fix linter errors * Update schema * Finished basic integration of setAllocation event and verified queries/schema is working as intended. * Fixing amount getter. * Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors. * Fixing import. * Use .zero() * Improve readability * Add allocated to schema * Update abi * Update event handlers in the template * Update veREADME * Remove `AllocationRemoved` handler * Hooking data for tx, firstContact, lastUpdate, block * Update event abi * Add chainId and nftAddress to schema * Update `handleAllocationSet` * Update abi * Update readme * Set initial values * Fix math * Missing event param * set initial value of `lastContact` * veOcean template * VeOcean entity * Handler functions - wip * rename file * Delegation schema * veDelegate mapping file * Rename * Update template * Update schema * Update replaces * Add handler for delegation * Update schema * getveDelegation * Update naming * Add deposit entity * Update template * Make delegation an array * Add `handleDelegation` * Add `handleDeposit` for veOCEAN * Add `getveOCEAN` util function * Add `getDeposit` util function * Add `handleBurnBoost` * Add `handleExtendBoost` * Add `handleTransferBoost` * Set default veOCEAN * Remove unused import * Rename Deposit to VeDeposit * Include block number * Remove `allocatedTotal` * Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not.. * bump contracts to v1.1.1 * bump contracts * bump to contracts 1.1.2 * fix script for networks without ve * add veAllocation.sol's AllocationSetMultiple * copy artfacts from barge for npm quickstart:barge * fix using barge artifacts * temp debug * use barge artifacts * use contracts 1.1.3 * use same approach for 'development' * bump ocean-contracts Co-authored-by: alexcos20 <alex.coseru@gmail.com> Co-authored-by: mihaisc <mihai@oceanprotocol.com> Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
import {
BurnBoost,
DelegateBoost,
ExtendBoost,
TransferBoost
} from '../@types/veDelegation/veDelegation'
import { weiToDecimal } from './utils/generic'
Implementing first pass of veAllocate schema, handlers, and test cove… (#490) * Implementing first pass of veAllocate schema, handlers, and test coverage. * Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come. * Created documentation. Moving tests away from subgraph and into df-py. * Expanding documentation to be thorough and cover more of the work involved. * use barge artifacts * use proper contracts in ci * use barge artifacts folder * fix replace * use npm contracts dep * use latest contracts for barge * fix some lint * Fix linter errors * Update schema * Finished basic integration of setAllocation event and verified queries/schema is working as intended. * Fixing amount getter. * Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors. * Fixing import. * Use .zero() * Improve readability * Add allocated to schema * Update abi * Update event handlers in the template * Update veREADME * Remove `AllocationRemoved` handler * Hooking data for tx, firstContact, lastUpdate, block * Update event abi * Add chainId and nftAddress to schema * Update `handleAllocationSet` * Update abi * Update readme * Set initial values * Fix math * Missing event param * set initial value of `lastContact` * veOcean template * VeOcean entity * Handler functions - wip * rename file * Delegation schema * veDelegate mapping file * Rename * Update template * Update schema * Update replaces * Add handler for delegation * Update schema * getveDelegation * Update naming * Add deposit entity * Update template * Make delegation an array * Add `handleDelegation` * Add `handleDeposit` for veOCEAN * Add `getveOCEAN` util function * Add `getDeposit` util function * Add `handleBurnBoost` * Add `handleExtendBoost` * Add `handleTransferBoost` * Set default veOCEAN * Remove unused import * Rename Deposit to VeDeposit * Include block number * Remove `allocatedTotal` * Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not.. * bump contracts to v1.1.1 * bump contracts * bump to contracts 1.1.2 * fix script for networks without ve * add veAllocation.sol's AllocationSetMultiple * copy artfacts from barge for npm quickstart:barge * fix using barge artifacts * temp debug * use barge artifacts * use contracts 1.1.3 * use same approach for 'development' * bump ocean-contracts Co-authored-by: alexcos20 <alex.coseru@gmail.com> Co-authored-by: mihaisc <mihai@oceanprotocol.com> Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
import { getveDelegation, getveOCEAN } from './utils/veUtils'
export function handleDelegation(event: DelegateBoost): void {
const _delegator = event.params._delegator.toHex()
const _receiver = event.params._receiver.toHex()
const _tokenId = event.params._token_id
const _amount = event.params._amount
const _cancelTime = event.params._cancel_time
const _expireTime = event.params._expire_time
2023-04-28 08:36:56 +02:00
// create veOcean if does not exists
getveOCEAN(_receiver)
const delegator = getveOCEAN(_delegator)
2023-04-28 08:36:56 +02:00
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
const ts = event.block.timestamp.toI32()
Implementing first pass of veAllocate schema, handlers, and test cove… (#490) * Implementing first pass of veAllocate schema, handlers, and test coverage. * Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come. * Created documentation. Moving tests away from subgraph and into df-py. * Expanding documentation to be thorough and cover more of the work involved. * use barge artifacts * use proper contracts in ci * use barge artifacts folder * fix replace * use npm contracts dep * use latest contracts for barge * fix some lint * Fix linter errors * Update schema * Finished basic integration of setAllocation event and verified queries/schema is working as intended. * Fixing amount getter. * Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors. * Fixing import. * Use .zero() * Improve readability * Add allocated to schema * Update abi * Update event handlers in the template * Update veREADME * Remove `AllocationRemoved` handler * Hooking data for tx, firstContact, lastUpdate, block * Update event abi * Add chainId and nftAddress to schema * Update `handleAllocationSet` * Update abi * Update readme * Set initial values * Fix math * Missing event param * set initial value of `lastContact` * veOcean template * VeOcean entity * Handler functions - wip * rename file * Delegation schema * veDelegate mapping file * Rename * Update template * Update schema * Update replaces * Add handler for delegation * Update schema * getveDelegation * Update naming * Add deposit entity * Update template * Make delegation an array * Add `handleDelegation` * Add `handleDeposit` for veOCEAN * Add `getveOCEAN` util function * Add `getDeposit` util function * Add `handleBurnBoost` * Add `handleExtendBoost` * Add `handleTransferBoost` * Set default veOCEAN * Remove unused import * Rename Deposit to VeDeposit * Include block number * Remove `allocatedTotal` * Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not.. * bump contracts to v1.1.1 * bump contracts * bump to contracts 1.1.2 * fix script for networks without ve * add veAllocation.sol's AllocationSetMultiple * copy artfacts from barge for npm quickstart:barge * fix using barge artifacts * temp debug * use barge artifacts * use contracts 1.1.3 * use same approach for 'development' * bump ocean-contracts Co-authored-by: alexcos20 <alex.coseru@gmail.com> Co-authored-by: mihaisc <mihai@oceanprotocol.com> Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
veDelegation.delegator = _delegator
veDelegation.receiver = _receiver
veDelegation.tokenId = _tokenId
veDelegation.amount = weiToDecimal(
_amount.toBigDecimal(),
BigInt.fromI32(18).toI32()
)
veDelegation.lockedAmount = delegator.lockedAmount
veDelegation.timeLeftUnlock = delegator.unlockTime.toI32() - ts
Implementing first pass of veAllocate schema, handlers, and test cove… (#490) * Implementing first pass of veAllocate schema, handlers, and test coverage. * Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come. * Created documentation. Moving tests away from subgraph and into df-py. * Expanding documentation to be thorough and cover more of the work involved. * use barge artifacts * use proper contracts in ci * use barge artifacts folder * fix replace * use npm contracts dep * use latest contracts for barge * fix some lint * Fix linter errors * Update schema * Finished basic integration of setAllocation event and verified queries/schema is working as intended. * Fixing amount getter. * Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors. * Fixing import. * Use .zero() * Improve readability * Add allocated to schema * Update abi * Update event handlers in the template * Update veREADME * Remove `AllocationRemoved` handler * Hooking data for tx, firstContact, lastUpdate, block * Update event abi * Add chainId and nftAddress to schema * Update `handleAllocationSet` * Update abi * Update readme * Set initial values * Fix math * Missing event param * set initial value of `lastContact` * veOcean template * VeOcean entity * Handler functions - wip * rename file * Delegation schema * veDelegate mapping file * Rename * Update template * Update schema * Update replaces * Add handler for delegation * Update schema * getveDelegation * Update naming * Add deposit entity * Update template * Make delegation an array * Add `handleDelegation` * Add `handleDeposit` for veOCEAN * Add `getveOCEAN` util function * Add `getDeposit` util function * Add `handleBurnBoost` * Add `handleExtendBoost` * Add `handleTransferBoost` * Set default veOCEAN * Remove unused import * Rename Deposit to VeDeposit * Include block number * Remove `allocatedTotal` * Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not.. * bump contracts to v1.1.1 * bump contracts * bump to contracts 1.1.2 * fix script for networks without ve * add veAllocation.sol's AllocationSetMultiple * copy artfacts from barge for npm quickstart:barge * fix using barge artifacts * temp debug * use barge artifacts * use contracts 1.1.3 * use same approach for 'development' * bump ocean-contracts Co-authored-by: alexcos20 <alex.coseru@gmail.com> Co-authored-by: mihaisc <mihai@oceanprotocol.com> Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
veDelegation.cancelTime = _cancelTime
veDelegation.expireTime = _expireTime
veDelegation.save()
2023-04-28 08:36:56 +02:00
const veDelegationUpdate = new VeDelegationUpdate(
event.transaction.hash.toHex() + '-' + event.logIndex.toString()
)
veDelegationUpdate.type = 0
veDelegationUpdate.veDelegation = veDelegation.id
veDelegationUpdate.block = event.block.number.toI32()
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
veDelegationUpdate.tx = event.transaction.hash.toHex()
Fix #628 & #629 & #621: Store event log index for all records (#630) * Store eventIndex. * Changed in veDelegation. Removed import of String. * linter. * Removed tx hash. * Revert some tweaks. * added logIndex. * converted to big int. * 0 -> BigInt.zero(). * Added eventIndex to template and OPC. * updated tweak * updated tweak2 * Added eventIndex in tests. * revert. * Added eventIndex for TokenCreated and NFTCreated events. Increase time sleep for graphql request. * Changed position of eventIndex in entity. * Added eventIndex for order events and for dt events. Added new test commands in package.json. * Added eventIndex for NFT Update events. * Added eventIndex for dispenser. * Modified dispenser tests. * Reverted sleep secs. Updated tests. * Updated dispenser tests. Added eventIndex for FRE. * Added eventIndex in df rewards. * Updated Ve with eventIndex. * Updating order id with event index. * Updated @ocean/lib with multichain version. * Updated to number type. * Updated tests for order. * some changes. * Fix dt tests. Added logs for provider fee. Need fix for Simple publish and consume tests. * Problem raised by retrieving order event index in provider fee event handler. * Added function for searching the right order. * Debug order with provider fee. * Removed console logs. * Added debug logs. * Hardcoded eventIndex just for testing. * Paste logs from graph node. * added extra sleep in test. * fixed command. * Added comments. Modified util function for Order Reuse. * Added more logs and other tweaks. * fixed command for docker logs. * Added more logs. * Converted to lowercase. * Removed condition just for test. * Added more logs. Order is not null. * Call getOrder. * Added verification back. * converted to hex and add toString. * Pass toString as param. * Added ethereumjs util. * replaced with ==. * Refactored logic. * Print event index. * added more logs of event index. * Modified tweaks and asserts. * Added log for reuse order. * updates. * Reverted changes. * Added check for eventIndex == 0. * Enhanced the code. Replaced while with for. * Added more logs for reuse test. * added another condition. * Added logs in tests. Removed redundant condition. * Added more logs to test. * Fixed typo. * still debugging * Refactored code. * Getting closer. * Fix tests for orders part. Removed logs. * Removed more logs. * Fix DT tests related to order. * Implemented Publishing Market Fee event handler. Added test. * Added consume market fee handler. Test consume market fee handler. * Fixed tests for fees. Added TODOs. * Generated ID with eventIndex in ficed rate. Added assert errors messages. * Added FRE tests to workflow. * Generated dispenser transaction with event index. * Fixed dispenser tests. * Add event index for NftUpdate entity ID. * Changed IDs for VeDelegation and VeAllocationUpdate. * Added full test suite to workflow. * Fixed nft transfer ID. * print blocks. * test just dt and ending test to see the last block. * Added df test. * Added dispenser test. * Added FRE test. * Added NFT test. * Added simple publish consume test. * Added simple subgraph test. * Added users test. * Added ve test. * Increased sleep time. * commented delegation test. * respect lint * Fixed ending tests. Removed commented code. Brought back test suite. * Print values from failing tests. Updated mappings. * Rollback changes in veDelegation and veUtils. Added more prints for debug in tests. * Removed veDelegation creation record. * Rollback to the approach for veDelegation like it is in main. * Removed prints. Match changes with main. * Removed -1 from last block. * Added prints for eventIndex. Fixed some suggestions. * Fixed veDelegation. * Removed prints.
2023-05-13 14:00:52 +02:00
veDelegationUpdate.eventIndex = event.logIndex.toI32()
veDelegationUpdate.amount = veDelegation.amount
2023-04-28 08:36:56 +02:00
veDelegationUpdate.cancelTime = _cancelTime
veDelegationUpdate.expireTime = _expireTime
veDelegationUpdate.sender = event.transaction.from.toHex()
veDelegationUpdate.save()
Implementing first pass of veAllocate schema, handlers, and test cove… (#490) * Implementing first pass of veAllocate schema, handlers, and test coverage. * Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come. * Created documentation. Moving tests away from subgraph and into df-py. * Expanding documentation to be thorough and cover more of the work involved. * use barge artifacts * use proper contracts in ci * use barge artifacts folder * fix replace * use npm contracts dep * use latest contracts for barge * fix some lint * Fix linter errors * Update schema * Finished basic integration of setAllocation event and verified queries/schema is working as intended. * Fixing amount getter. * Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors. * Fixing import. * Use .zero() * Improve readability * Add allocated to schema * Update abi * Update event handlers in the template * Update veREADME * Remove `AllocationRemoved` handler * Hooking data for tx, firstContact, lastUpdate, block * Update event abi * Add chainId and nftAddress to schema * Update `handleAllocationSet` * Update abi * Update readme * Set initial values * Fix math * Missing event param * set initial value of `lastContact` * veOcean template * VeOcean entity * Handler functions - wip * rename file * Delegation schema * veDelegate mapping file * Rename * Update template * Update schema * Update replaces * Add handler for delegation * Update schema * getveDelegation * Update naming * Add deposit entity * Update template * Make delegation an array * Add `handleDelegation` * Add `handleDeposit` for veOCEAN * Add `getveOCEAN` util function * Add `getDeposit` util function * Add `handleBurnBoost` * Add `handleExtendBoost` * Add `handleTransferBoost` * Set default veOCEAN * Remove unused import * Rename Deposit to VeDeposit * Include block number * Remove `allocatedTotal` * Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not.. * bump contracts to v1.1.1 * bump contracts * bump to contracts 1.1.2 * fix script for networks without ve * add veAllocation.sol's AllocationSetMultiple * copy artfacts from barge for npm quickstart:barge * fix using barge artifacts * temp debug * use barge artifacts * use contracts 1.1.3 * use same approach for 'development' * bump ocean-contracts Co-authored-by: alexcos20 <alex.coseru@gmail.com> Co-authored-by: mihaisc <mihai@oceanprotocol.com> Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
}
export function handleExtendBoost(event: ExtendBoost): void {
const _delegator = event.params._delegator.toHex()
const _receiver = event.params._receiver.toHex()
const _tokenId = event.params._token_id
const _amount = event.params._amount
const _cancelTime = event.params._cancel_time
const _expireTime = event.params._expire_time
2023-04-28 08:36:56 +02:00
// create veOcean if does not exists
getveOCEAN(_receiver)
getveOCEAN(_delegator)
// it's possible to not have veDelegation object, because we missed handleDelegation
// that should not happend, but we create the object anyway
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
Implementing first pass of veAllocate schema, handlers, and test cove… (#490) * Implementing first pass of veAllocate schema, handlers, and test coverage. * Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come. * Created documentation. Moving tests away from subgraph and into df-py. * Expanding documentation to be thorough and cover more of the work involved. * use barge artifacts * use proper contracts in ci * use barge artifacts folder * fix replace * use npm contracts dep * use latest contracts for barge * fix some lint * Fix linter errors * Update schema * Finished basic integration of setAllocation event and verified queries/schema is working as intended. * Fixing amount getter. * Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors. * Fixing import. * Use .zero() * Improve readability * Add allocated to schema * Update abi * Update event handlers in the template * Update veREADME * Remove `AllocationRemoved` handler * Hooking data for tx, firstContact, lastUpdate, block * Update event abi * Add chainId and nftAddress to schema * Update `handleAllocationSet` * Update abi * Update readme * Set initial values * Fix math * Missing event param * set initial value of `lastContact` * veOcean template * VeOcean entity * Handler functions - wip * rename file * Delegation schema * veDelegate mapping file * Rename * Update template * Update schema * Update replaces * Add handler for delegation * Update schema * getveDelegation * Update naming * Add deposit entity * Update template * Make delegation an array * Add `handleDelegation` * Add `handleDeposit` for veOCEAN * Add `getveOCEAN` util function * Add `getDeposit` util function * Add `handleBurnBoost` * Add `handleExtendBoost` * Add `handleTransferBoost` * Set default veOCEAN * Remove unused import * Rename Deposit to VeDeposit * Include block number * Remove `allocatedTotal` * Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not.. * bump contracts to v1.1.1 * bump contracts * bump to contracts 1.1.2 * fix script for networks without ve * add veAllocation.sol's AllocationSetMultiple * copy artfacts from barge for npm quickstart:barge * fix using barge artifacts * temp debug * use barge artifacts * use contracts 1.1.3 * use same approach for 'development' * bump ocean-contracts Co-authored-by: alexcos20 <alex.coseru@gmail.com> Co-authored-by: mihaisc <mihai@oceanprotocol.com> Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
veDelegation.delegator = _delegator
veDelegation.receiver = _receiver
veDelegation.tokenId = _tokenId
veDelegation.amount = weiToDecimal(
_amount.toBigDecimal(),
BigInt.fromI32(18).toI32()
)
Implementing first pass of veAllocate schema, handlers, and test cove… (#490) * Implementing first pass of veAllocate schema, handlers, and test coverage. * Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come. * Created documentation. Moving tests away from subgraph and into df-py. * Expanding documentation to be thorough and cover more of the work involved. * use barge artifacts * use proper contracts in ci * use barge artifacts folder * fix replace * use npm contracts dep * use latest contracts for barge * fix some lint * Fix linter errors * Update schema * Finished basic integration of setAllocation event and verified queries/schema is working as intended. * Fixing amount getter. * Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors. * Fixing import. * Use .zero() * Improve readability * Add allocated to schema * Update abi * Update event handlers in the template * Update veREADME * Remove `AllocationRemoved` handler * Hooking data for tx, firstContact, lastUpdate, block * Update event abi * Add chainId and nftAddress to schema * Update `handleAllocationSet` * Update abi * Update readme * Set initial values * Fix math * Missing event param * set initial value of `lastContact` * veOcean template * VeOcean entity * Handler functions - wip * rename file * Delegation schema * veDelegate mapping file * Rename * Update template * Update schema * Update replaces * Add handler for delegation * Update schema * getveDelegation * Update naming * Add deposit entity * Update template * Make delegation an array * Add `handleDelegation` * Add `handleDeposit` for veOCEAN * Add `getveOCEAN` util function * Add `getDeposit` util function * Add `handleBurnBoost` * Add `handleExtendBoost` * Add `handleTransferBoost` * Set default veOCEAN * Remove unused import * Rename Deposit to VeDeposit * Include block number * Remove `allocatedTotal` * Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not.. * bump contracts to v1.1.1 * bump contracts * bump to contracts 1.1.2 * fix script for networks without ve * add veAllocation.sol's AllocationSetMultiple * copy artfacts from barge for npm quickstart:barge * fix using barge artifacts * temp debug * use barge artifacts * use contracts 1.1.3 * use same approach for 'development' * bump ocean-contracts Co-authored-by: alexcos20 <alex.coseru@gmail.com> Co-authored-by: mihaisc <mihai@oceanprotocol.com> Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
veDelegation.cancelTime = _cancelTime
veDelegation.expireTime = _expireTime
veDelegation.save()
2023-04-28 08:36:56 +02:00
const veDelegationUpdate = new VeDelegationUpdate(
event.transaction.hash.toHex() + '-' + event.logIndex.toString()
)
veDelegationUpdate.veDelegation = veDelegation.id
veDelegationUpdate.type = 1
veDelegationUpdate.block = event.block.number.toI32()
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
veDelegationUpdate.tx = event.transaction.hash.toHex()
Fix #628 & #629 & #621: Store event log index for all records (#630) * Store eventIndex. * Changed in veDelegation. Removed import of String. * linter. * Removed tx hash. * Revert some tweaks. * added logIndex. * converted to big int. * 0 -> BigInt.zero(). * Added eventIndex to template and OPC. * updated tweak * updated tweak2 * Added eventIndex in tests. * revert. * Added eventIndex for TokenCreated and NFTCreated events. Increase time sleep for graphql request. * Changed position of eventIndex in entity. * Added eventIndex for order events and for dt events. Added new test commands in package.json. * Added eventIndex for NFT Update events. * Added eventIndex for dispenser. * Modified dispenser tests. * Reverted sleep secs. Updated tests. * Updated dispenser tests. Added eventIndex for FRE. * Added eventIndex in df rewards. * Updated Ve with eventIndex. * Updating order id with event index. * Updated @ocean/lib with multichain version. * Updated to number type. * Updated tests for order. * some changes. * Fix dt tests. Added logs for provider fee. Need fix for Simple publish and consume tests. * Problem raised by retrieving order event index in provider fee event handler. * Added function for searching the right order. * Debug order with provider fee. * Removed console logs. * Added debug logs. * Hardcoded eventIndex just for testing. * Paste logs from graph node. * added extra sleep in test. * fixed command. * Added comments. Modified util function for Order Reuse. * Added more logs and other tweaks. * fixed command for docker logs. * Added more logs. * Converted to lowercase. * Removed condition just for test. * Added more logs. Order is not null. * Call getOrder. * Added verification back. * converted to hex and add toString. * Pass toString as param. * Added ethereumjs util. * replaced with ==. * Refactored logic. * Print event index. * added more logs of event index. * Modified tweaks and asserts. * Added log for reuse order. * updates. * Reverted changes. * Added check for eventIndex == 0. * Enhanced the code. Replaced while with for. * Added more logs for reuse test. * added another condition. * Added logs in tests. Removed redundant condition. * Added more logs to test. * Fixed typo. * still debugging * Refactored code. * Getting closer. * Fix tests for orders part. Removed logs. * Removed more logs. * Fix DT tests related to order. * Implemented Publishing Market Fee event handler. Added test. * Added consume market fee handler. Test consume market fee handler. * Fixed tests for fees. Added TODOs. * Generated ID with eventIndex in ficed rate. Added assert errors messages. * Added FRE tests to workflow. * Generated dispenser transaction with event index. * Fixed dispenser tests. * Add event index for NftUpdate entity ID. * Changed IDs for VeDelegation and VeAllocationUpdate. * Added full test suite to workflow. * Fixed nft transfer ID. * print blocks. * test just dt and ending test to see the last block. * Added df test. * Added dispenser test. * Added FRE test. * Added NFT test. * Added simple publish consume test. * Added simple subgraph test. * Added users test. * Added ve test. * Increased sleep time. * commented delegation test. * respect lint * Fixed ending tests. Removed commented code. Brought back test suite. * Print values from failing tests. Updated mappings. * Rollback changes in veDelegation and veUtils. Added more prints for debug in tests. * Removed veDelegation creation record. * Rollback to the approach for veDelegation like it is in main. * Removed prints. Match changes with main. * Removed -1 from last block. * Added prints for eventIndex. Fixed some suggestions. * Fixed veDelegation. * Removed prints.
2023-05-13 14:00:52 +02:00
veDelegationUpdate.eventIndex = event.logIndex.toI32()
veDelegationUpdate.amount = veDelegation.amount
2023-04-28 08:36:56 +02:00
veDelegationUpdate.cancelTime = _cancelTime
veDelegationUpdate.expireTime = _expireTime
veDelegationUpdate.sender = event.transaction.from.toHex()
veDelegationUpdate.save()
Implementing first pass of veAllocate schema, handlers, and test cove… (#490) * Implementing first pass of veAllocate schema, handlers, and test coverage. * Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come. * Created documentation. Moving tests away from subgraph and into df-py. * Expanding documentation to be thorough and cover more of the work involved. * use barge artifacts * use proper contracts in ci * use barge artifacts folder * fix replace * use npm contracts dep * use latest contracts for barge * fix some lint * Fix linter errors * Update schema * Finished basic integration of setAllocation event and verified queries/schema is working as intended. * Fixing amount getter. * Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors. * Fixing import. * Use .zero() * Improve readability * Add allocated to schema * Update abi * Update event handlers in the template * Update veREADME * Remove `AllocationRemoved` handler * Hooking data for tx, firstContact, lastUpdate, block * Update event abi * Add chainId and nftAddress to schema * Update `handleAllocationSet` * Update abi * Update readme * Set initial values * Fix math * Missing event param * set initial value of `lastContact` * veOcean template * VeOcean entity * Handler functions - wip * rename file * Delegation schema * veDelegate mapping file * Rename * Update template * Update schema * Update replaces * Add handler for delegation * Update schema * getveDelegation * Update naming * Add deposit entity * Update template * Make delegation an array * Add `handleDelegation` * Add `handleDeposit` for veOCEAN * Add `getveOCEAN` util function * Add `getDeposit` util function * Add `handleBurnBoost` * Add `handleExtendBoost` * Add `handleTransferBoost` * Set default veOCEAN * Remove unused import * Rename Deposit to VeDeposit * Include block number * Remove `allocatedTotal` * Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not.. * bump contracts to v1.1.1 * bump contracts * bump to contracts 1.1.2 * fix script for networks without ve * add veAllocation.sol's AllocationSetMultiple * copy artfacts from barge for npm quickstart:barge * fix using barge artifacts * temp debug * use barge artifacts * use contracts 1.1.3 * use same approach for 'development' * bump ocean-contracts Co-authored-by: alexcos20 <alex.coseru@gmail.com> Co-authored-by: mihaisc <mihai@oceanprotocol.com> Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
}
export function handleTransferBoost(event: TransferBoost): void {
// TODO not sure if we need this
// --------------------------------
// const _from = event.params._from
// const _to = event.params._to
// const _tokenId = event.params._token_id
// const _amount = event.params._amount
// const _expireTime = event.params._expire_time
}
export function handleBurnBoost(event: BurnBoost): void {
const _tokenId = event.params._token_id
// delete
2023-04-28 08:36:56 +02:00
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
veDelegation.amount = BigDecimal.zero()
2023-04-20 14:18:57 +02:00
veDelegation.save()
2023-04-28 08:36:56 +02:00
const veDelegationUpdate = new VeDelegationUpdate(
event.transaction.hash.toHex() + '-' + event.logIndex.toString()
)
veDelegationUpdate.veDelegation = veDelegation.id
veDelegationUpdate.type = 2
veDelegationUpdate.block = event.block.number.toI32()
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
veDelegationUpdate.tx = event.transaction.hash.toHex()
Fix #628 & #629 & #621: Store event log index for all records (#630) * Store eventIndex. * Changed in veDelegation. Removed import of String. * linter. * Removed tx hash. * Revert some tweaks. * added logIndex. * converted to big int. * 0 -> BigInt.zero(). * Added eventIndex to template and OPC. * updated tweak * updated tweak2 * Added eventIndex in tests. * revert. * Added eventIndex for TokenCreated and NFTCreated events. Increase time sleep for graphql request. * Changed position of eventIndex in entity. * Added eventIndex for order events and for dt events. Added new test commands in package.json. * Added eventIndex for NFT Update events. * Added eventIndex for dispenser. * Modified dispenser tests. * Reverted sleep secs. Updated tests. * Updated dispenser tests. Added eventIndex for FRE. * Added eventIndex in df rewards. * Updated Ve with eventIndex. * Updating order id with event index. * Updated @ocean/lib with multichain version. * Updated to number type. * Updated tests for order. * some changes. * Fix dt tests. Added logs for provider fee. Need fix for Simple publish and consume tests. * Problem raised by retrieving order event index in provider fee event handler. * Added function for searching the right order. * Debug order with provider fee. * Removed console logs. * Added debug logs. * Hardcoded eventIndex just for testing. * Paste logs from graph node. * added extra sleep in test. * fixed command. * Added comments. Modified util function for Order Reuse. * Added more logs and other tweaks. * fixed command for docker logs. * Added more logs. * Converted to lowercase. * Removed condition just for test. * Added more logs. Order is not null. * Call getOrder. * Added verification back. * converted to hex and add toString. * Pass toString as param. * Added ethereumjs util. * replaced with ==. * Refactored logic. * Print event index. * added more logs of event index. * Modified tweaks and asserts. * Added log for reuse order. * updates. * Reverted changes. * Added check for eventIndex == 0. * Enhanced the code. Replaced while with for. * Added more logs for reuse test. * added another condition. * Added logs in tests. Removed redundant condition. * Added more logs to test. * Fixed typo. * still debugging * Refactored code. * Getting closer. * Fix tests for orders part. Removed logs. * Removed more logs. * Fix DT tests related to order. * Implemented Publishing Market Fee event handler. Added test. * Added consume market fee handler. Test consume market fee handler. * Fixed tests for fees. Added TODOs. * Generated ID with eventIndex in ficed rate. Added assert errors messages. * Added FRE tests to workflow. * Generated dispenser transaction with event index. * Fixed dispenser tests. * Add event index for NftUpdate entity ID. * Changed IDs for VeDelegation and VeAllocationUpdate. * Added full test suite to workflow. * Fixed nft transfer ID. * print blocks. * test just dt and ending test to see the last block. * Added df test. * Added dispenser test. * Added FRE test. * Added NFT test. * Added simple publish consume test. * Added simple subgraph test. * Added users test. * Added ve test. * Increased sleep time. * commented delegation test. * respect lint * Fixed ending tests. Removed commented code. Brought back test suite. * Print values from failing tests. Updated mappings. * Rollback changes in veDelegation and veUtils. Added more prints for debug in tests. * Removed veDelegation creation record. * Rollback to the approach for veDelegation like it is in main. * Removed prints. Match changes with main. * Removed -1 from last block. * Added prints for eventIndex. Fixed some suggestions. * Fixed veDelegation. * Removed prints.
2023-05-13 14:00:52 +02:00
veDelegationUpdate.eventIndex = event.logIndex.toI32()
2023-04-28 08:36:56 +02:00
veDelegationUpdate.amount = veDelegation.amount
veDelegationUpdate.cancelTime = veDelegation.cancelTime
veDelegationUpdate.expireTime = veDelegation.expireTime
veDelegationUpdate.sender = event.transaction.from.toHex()
veDelegationUpdate.save()
Implementing first pass of veAllocate schema, handlers, and test cove… (#490) * Implementing first pass of veAllocate schema, handlers, and test coverage. * Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come. * Created documentation. Moving tests away from subgraph and into df-py. * Expanding documentation to be thorough and cover more of the work involved. * use barge artifacts * use proper contracts in ci * use barge artifacts folder * fix replace * use npm contracts dep * use latest contracts for barge * fix some lint * Fix linter errors * Update schema * Finished basic integration of setAllocation event and verified queries/schema is working as intended. * Fixing amount getter. * Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors. * Fixing import. * Use .zero() * Improve readability * Add allocated to schema * Update abi * Update event handlers in the template * Update veREADME * Remove `AllocationRemoved` handler * Hooking data for tx, firstContact, lastUpdate, block * Update event abi * Add chainId and nftAddress to schema * Update `handleAllocationSet` * Update abi * Update readme * Set initial values * Fix math * Missing event param * set initial value of `lastContact` * veOcean template * VeOcean entity * Handler functions - wip * rename file * Delegation schema * veDelegate mapping file * Rename * Update template * Update schema * Update replaces * Add handler for delegation * Update schema * getveDelegation * Update naming * Add deposit entity * Update template * Make delegation an array * Add `handleDelegation` * Add `handleDeposit` for veOCEAN * Add `getveOCEAN` util function * Add `getDeposit` util function * Add `handleBurnBoost` * Add `handleExtendBoost` * Add `handleTransferBoost` * Set default veOCEAN * Remove unused import * Rename Deposit to VeDeposit * Include block number * Remove `allocatedTotal` * Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not.. * bump contracts to v1.1.1 * bump contracts * bump to contracts 1.1.2 * fix script for networks without ve * add veAllocation.sol's AllocationSetMultiple * copy artfacts from barge for npm quickstart:barge * fix using barge artifacts * temp debug * use barge artifacts * use contracts 1.1.3 * use same approach for 'development' * bump ocean-contracts Co-authored-by: alexcos20 <alex.coseru@gmail.com> Co-authored-by: mihaisc <mihai@oceanprotocol.com> Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
}