Updated Ve with eventIndex.
This commit is contained in:
parent
0f7026ab6e
commit
00e804c683
|
@ -412,6 +412,7 @@ type VeAllocateUser @entity{
|
|||
firstContact: Int!
|
||||
lastContact: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
veOcean: VeOCEAN!
|
||||
}
|
||||
|
||||
|
@ -428,6 +429,7 @@ type VeAllocateId @entity{
|
|||
firstContact: Int!
|
||||
lastContact: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
# we need to track allocation of user to id
|
||||
|
@ -447,6 +449,7 @@ type VeAllocation @entity {
|
|||
firstContact: Int!
|
||||
lastContact: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
enum veAllocationUpdateType {
|
||||
|
@ -465,6 +468,7 @@ type VeAllocationUpdate @entity {
|
|||
block: Int!
|
||||
timestamp: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
type VeDelegation @entity {
|
||||
|
@ -510,6 +514,7 @@ type VeDeposit @entity {
|
|||
timestamp: BigInt!
|
||||
block: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
veOcean: VeOCEAN!
|
||||
}
|
||||
|
||||
|
@ -534,6 +539,7 @@ type VeFeeDistributorCheckPoint @entity {
|
|||
timestamp: BigInt!
|
||||
block: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
type VeClaim @entity {
|
||||
|
@ -548,6 +554,7 @@ type VeClaim @entity {
|
|||
timestamp: BigInt!
|
||||
block: Int!
|
||||
tx: String!
|
||||
eventIndex: Int!
|
||||
veOcean: VeOCEAN!
|
||||
VeFeeDistributor: VeFeeDistributor!
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ export function getveAllocateUser(
|
|||
|
||||
allocateUser.firstContact = event.block.timestamp.toI32()
|
||||
allocateUser.tx = event.transaction.hash.toHex()
|
||||
allocateUser.eventIndex = event.logIndex.toI32()
|
||||
allocateUser.block = event.block.number.toI32()
|
||||
allocateUser.lastContact = 0
|
||||
const veOcean = getveOCEAN(sender)
|
||||
|
@ -60,6 +61,7 @@ export function getveAllocateId(
|
|||
|
||||
allocateId.firstContact = event.block.timestamp.toI32()
|
||||
allocateId.tx = event.transaction.hash.toHex()
|
||||
allocateId.eventIndex = event.logIndex.toI32()
|
||||
allocateId.block = event.block.number.toI32()
|
||||
allocateId.lastContact = 0
|
||||
allocateId.chainId = BigInt.zero()
|
||||
|
@ -87,6 +89,7 @@ export function getveAllocation(
|
|||
|
||||
veAllocation.firstContact = event.block.timestamp.toI32()
|
||||
veAllocation.tx = event.transaction.hash.toHex()
|
||||
veAllocation.eventIndex = event.logIndex.toI32()
|
||||
veAllocation.block = event.block.number.toI32()
|
||||
veAllocation.lastContact = 0
|
||||
|
||||
|
@ -113,6 +116,7 @@ export function writeveAllocationUpdate(
|
|||
|
||||
allocationUpdate.timestamp = event.block.timestamp.toI32()
|
||||
allocationUpdate.tx = event.transaction.hash.toHex()
|
||||
allocationUpdate.eventIndex = event.logIndex.toI32()
|
||||
allocationUpdate.block = event.block.number.toI32()
|
||||
|
||||
allocationUpdate.save()
|
||||
|
@ -150,6 +154,7 @@ export function getDeposit(id: string): VeDeposit {
|
|||
deposit.type = BigInt.zero()
|
||||
deposit.timestamp = BigInt.zero()
|
||||
deposit.tx = ''
|
||||
deposit.eventIndex = 0
|
||||
deposit.block = 0
|
||||
// do not save it
|
||||
// deposit.save()
|
||||
|
|
|
@ -44,6 +44,7 @@ export function handleCheckpoint(event: CheckpointToken): void {
|
|||
checkpoint.sender = event.transaction.from.toHexString()
|
||||
checkpoint.block = event.block.number.toI32()
|
||||
checkpoint.tx = event.transaction.hash.toHex()
|
||||
checkpoint.eventIndex = event.logIndex.toI32()
|
||||
checkpoint.timestamp = event.params.time
|
||||
checkpoint.VeFeeDistributor = distributor.id
|
||||
checkpoint.save()
|
||||
|
|
|
@ -26,6 +26,7 @@ export function handleDeposit(event: Deposit): void {
|
|||
deposit.timestamp = ts
|
||||
deposit.block = event.block.number.toI32()
|
||||
deposit.tx = event.transaction.hash.toHex()
|
||||
deposit.eventIndex = event.logIndex.toI32()
|
||||
deposit.sender = event.transaction.from.toHex()
|
||||
deposit.veOcean = veOCEAN.id
|
||||
deposit.save()
|
||||
|
@ -59,6 +60,7 @@ export function handleWithdraw(event: Withdraw): void {
|
|||
deposit.timestamp = ts
|
||||
deposit.block = event.block.number.toI32()
|
||||
deposit.tx = event.transaction.hash.toHex()
|
||||
deposit.eventIndex = event.logIndex.toI32()
|
||||
deposit.sender = event.transaction.from.toHex()
|
||||
deposit.veOcean = veOCEAN.id
|
||||
deposit.save()
|
||||
|
|
|
@ -287,7 +287,7 @@ describe('veOcean tests', async () => {
|
|||
})
|
||||
|
||||
it('Alice should allocate 10% to NFT1', async () => {
|
||||
await veAllocate.setAllocation(Alice, '1000', nft1, chainId)
|
||||
const tx = await veAllocate.setAllocation(Alice, '1000', nft1, chainId)
|
||||
const newTotalAllocation = await veAllocate.getTotalAllocation(Alice)
|
||||
await sleep(2000)
|
||||
let initialQuery = {
|
||||
|
@ -295,6 +295,7 @@ describe('veOcean tests', async () => {
|
|||
veAllocateUsers(id:"${Alice.toLowerCase()}"){
|
||||
id,
|
||||
allocatedTotal
|
||||
eventIndex
|
||||
}
|
||||
}`
|
||||
}
|
||||
|
@ -310,13 +311,15 @@ describe('veOcean tests', async () => {
|
|||
' to equal subgraph value ' +
|
||||
info[0].allocatedTotal
|
||||
)
|
||||
assert(info[0].eventIndex === tx.events.AllocationSet.logIndex)
|
||||
initialQuery = {
|
||||
query: `query {
|
||||
veAllocations(
|
||||
where: {allocationUser:"${Alice.toLowerCase()}", chainId:"${chainId}", nftAddress:"${nft1.toLowerCase()}"}
|
||||
){
|
||||
id,
|
||||
allocated
|
||||
allocated,
|
||||
eventIndex
|
||||
}
|
||||
}`
|
||||
}
|
||||
|
@ -330,10 +333,11 @@ describe('veOcean tests', async () => {
|
|||
'Expected totalAllocation 1000 to equal subgraph value ' +
|
||||
info[0].allocatedTotal
|
||||
)
|
||||
assert(info[0].eventIndex === tx.events.AllocationSet.logIndex)
|
||||
})
|
||||
|
||||
it('Alice should allocate 10% to NFT2 and 20% to NFT3', async () => {
|
||||
await veAllocate.setBatchAllocation(
|
||||
const tx = await veAllocate.setBatchAllocation(
|
||||
Alice,
|
||||
['1000', '2000'],
|
||||
[nft2, nft3],
|
||||
|
@ -346,7 +350,8 @@ describe('veOcean tests', async () => {
|
|||
query: `query {
|
||||
veAllocateUsers(id:"${Alice.toLowerCase()}"){
|
||||
id,
|
||||
allocatedTotal
|
||||
allocatedTotal,
|
||||
eventIndex
|
||||
}
|
||||
}`
|
||||
}
|
||||
|
@ -362,13 +367,15 @@ describe('veOcean tests', async () => {
|
|||
' to equal subgraph value ' +
|
||||
info[0].allocatedTotal
|
||||
)
|
||||
assert(info[0].eventIndex === tx.events.AllocationSetMultiple.logIndex)
|
||||
initialQuery = {
|
||||
query: `query {
|
||||
veAllocations(
|
||||
where: {allocationUser:"${Alice.toLowerCase()}", chainId:"${chainId}", nftAddress:"${nft2.toLowerCase()}"}
|
||||
){
|
||||
id,
|
||||
allocated
|
||||
allocated,
|
||||
eventIndex
|
||||
}
|
||||
}`
|
||||
}
|
||||
|
@ -382,6 +389,7 @@ describe('veOcean tests', async () => {
|
|||
'Expected totalAllocation 1000 to equal subgraph value ' +
|
||||
info[0].allocatedTotal
|
||||
)
|
||||
assert(info[0].eventIndex === tx.events.AllocationSetMultiple.logIndex)
|
||||
initialQuery = {
|
||||
query: `query {
|
||||
veAllocations(
|
||||
|
|
Loading…
Reference in New Issue