Resolved conflicts.

This commit is contained in:
Maria Carmina 2023-04-05 14:37:13 +03:00
commit ead1bb05ab
10 changed files with 1052 additions and 336 deletions

View File

@ -4,8 +4,32 @@ All notable changes to this project will be documented in this file. Dates are d
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
#### [v3.0.2](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.1...v3.0.2)
- Storing the fraction of veOcean [`#623`](https://github.com/oceanprotocol/ocean-subgraph/pull/623)
- Bump eslint-config-prettier from 8.7.0 to 8.8.0 [`#637`](https://github.com/oceanprotocol/ocean-subgraph/pull/637)
- Bump prettier from 2.8.4 to 2.8.7 [`#636`](https://github.com/oceanprotocol/ocean-subgraph/pull/636)
- Bump release-it from 15.9.1 to 15.9.3 [`#638`](https://github.com/oceanprotocol/ocean-subgraph/pull/638)
- Bump typescript from 4.9.5 to 5.0.2 [`#632`](https://github.com/oceanprotocol/ocean-subgraph/pull/632)
- Bump release-it from 15.8.0 to 15.9.1 [`#634`](https://github.com/oceanprotocol/ocean-subgraph/pull/634)
- Update ocean-lib with 2.7.0 version. [`#633`](https://github.com/oceanprotocol/ocean-subgraph/pull/633)
- Bump eslint-config-prettier from 8.6.0 to 8.7.0 [`#625`](https://github.com/oceanprotocol/ocean-subgraph/pull/625)
- Bump @oceanprotocol/lib from 2.6.1 to 2.6.3 [`#614`](https://github.com/oceanprotocol/ocean-subgraph/pull/614)
- Bump release-it from 15.7.0 to 15.8.0 [`#624`](https://github.com/oceanprotocol/ocean-subgraph/pull/624)
- Bump @oceanprotocol/contracts from 1.1.8 to 1.1.12 [`#627`](https://github.com/oceanprotocol/ocean-subgraph/pull/627)
- Bump release-it from 15.6.0 to 15.7.0 [`#618`](https://github.com/oceanprotocol/ocean-subgraph/pull/618)
- Update README.md [`#617`](https://github.com/oceanprotocol/ocean-subgraph/pull/617)
- Update copyright year. [`#615`](https://github.com/oceanprotocol/ocean-subgraph/pull/615)
- Bump prettier from 2.8.3 to 2.8.4 [`#612`](https://github.com/oceanprotocol/ocean-subgraph/pull/612)
- Bump http-cache-semantics from 4.1.0 to 4.1.1 [`#608`](https://github.com/oceanprotocol/ocean-subgraph/pull/608)
- Bump @graphprotocol/graph-ts from 0.29.1 to 0.29.3 [`#611`](https://github.com/oceanprotocol/ocean-subgraph/pull/611)
- Bump typescript from 4.9.4 to 4.9.5 [`#610`](https://github.com/oceanprotocol/ocean-subgraph/pull/610)
- Bump @graphprotocol/graph-cli from 0.37.7 to 0.38.0 [`#609`](https://github.com/oceanprotocol/ocean-subgraph/pull/609)
#### [v3.0.1](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.0...v3.0.1)
> 27 January 2023
- fix veDeposit id generation [`#606`](https://github.com/oceanprotocol/ocean-subgraph/pull/606)
- Bump @graphprotocol/graph-cli from 0.37.2 to 0.37.7 [`#603`](https://github.com/oceanprotocol/ocean-subgraph/pull/603)
- Bump eslint-plugin-import from 2.27.4 to 2.27.5 [`#602`](https://github.com/oceanprotocol/ocean-subgraph/pull/602)
@ -31,6 +55,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Bump @types/mocha from 10.0.0 to 10.0.1 [`#580`](https://github.com/oceanprotocol/ocean-subgraph/pull/580)
- Bump prettier from 2.7.1 to 2.8.0 [`#577`](https://github.com/oceanprotocol/ocean-subgraph/pull/577)
- Release 2.1.4 [`7c35711`](https://github.com/oceanprotocol/ocean-subgraph/commit/7c35711f722b7ea487d8b8c9aa3e42d71f2beb56)
- Release 3.0.1 [`3de53c5`](https://github.com/oceanprotocol/ocean-subgraph/commit/3de53c519750ca40ec269ed21f7c17773b53b139)
### [v3.0.0](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.1.4...v3.0.0)

1203
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "ocean-subgraph",
"version": "3.0.1",
"version": "3.0.2",
"scripts": {
"start": "",
"quickstart:development": "node ./scripts/generatenetworkssubgraphs.js development && npm run codegen && npm run create:local && npm run deploy:local",
@ -56,20 +56,20 @@
"chai-spies": "^1.0.0",
"eslint": "^7.32.0",
"eslint-config-oceanprotocol": "^2.0.4",
"eslint-config-prettier": "^8.7.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-standard": "^5.0.0",
"mocha": "^10.2.0",
"mock-local-storage": "^1.1.23",
"prettier": "^2.8.4",
"release-it": "^15.8.0",
"prettier": "^2.8.7",
"release-it": "^15.10.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"ts-node-register": "^1.0.0",
"typescript": "^4.9.5"
"typescript": "^5.0.3"
},
"dependencies": {
"@oceanprotocol/contracts": "^1.1.12",

View File

@ -478,6 +478,7 @@ type VeDelegation @entity {
receiver: VeOCEAN!
tokenId: BigInt!
amount: BigInt!
amountFraction: BigDecimal!
cancelTime: BigInt!
expireTime: BigInt!
block: Int!

View File

@ -13,7 +13,7 @@ export function getGlobalStats(): GlobalStatistic {
let globalStats = GlobalStatistic.load(GLOBAL_ID)
if (!globalStats) {
globalStats = new GlobalStatistic(GLOBAL_ID)
globalStats.version = '3.0.1'
globalStats.version = '3.0.2'
globalStats.orderCount = 0
globalStats.fixedCount = 0
globalStats.datatokenCount = 0

View File

@ -133,6 +133,7 @@ export function getveDelegation(id: string): VeDelegation {
veDelegation.cancelTime = BigInt.zero()
veDelegation.expireTime = BigInt.zero()
veDelegation.tokenId = BigInt.zero()
veDelegation.amountFraction = BigDecimal.zero()
veDelegation.amount = BigInt.zero()
veDelegation.receiver = ''
veDelegation.delegator = ''

View File

@ -1,4 +1,4 @@
import { BigInt } from '@graphprotocol/graph-ts'
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
import {
BurnBoost,
DelegateBoost,
@ -6,6 +6,7 @@ import {
TransferBoost
} from '../@types/veDelegation/veDelegation'
import { getveDelegation, getveOCEAN } from './utils/veUtils'
import { weiToDecimal } from './utils/generic'
export function handleDelegation(event: DelegateBoost): void {
const _delegator = event.params._delegator.toHex()
@ -18,6 +19,12 @@ export function handleDelegation(event: DelegateBoost): void {
const veDelegation = getveDelegation(_tokenId.toHex())
veDelegation.delegator = _delegator
getveOCEAN(_receiver)
const delegatorVeOcean = getveOCEAN(_delegator)
if (_amount && delegatorVeOcean.lockedAmount) {
veDelegation.amountFraction = _amount.divDecimal(
delegatorVeOcean.lockedAmount
)
}
veDelegation.receiver = _receiver
veDelegation.tokenId = _tokenId
veDelegation.amount = _amount
@ -36,6 +43,12 @@ export function handleExtendBoost(event: ExtendBoost): void {
const _expireTime = event.params._expire_time
const veDelegation = getveDelegation(_tokenId.toHex())
const delegatorVeOcean = getveOCEAN(_delegator)
if (_amount && delegatorVeOcean.lockedAmount) {
veDelegation.amountFraction = weiToDecimal(_amount.toBigDecimal(), 18).div(
delegatorVeOcean.lockedAmount
)
}
veDelegation.delegator = _delegator
veDelegation.receiver = _receiver
veDelegation.tokenId = _tokenId
@ -59,5 +72,6 @@ export function handleBurnBoost(event: BurnBoost): void {
// delete
const veDelegation = getveDelegation(_tokenId.toHex())
veDelegation.amountFraction = BigDecimal.zero()
veDelegation.amount = BigInt.zero()
}

View File

@ -222,8 +222,8 @@ describe('Datatoken tests', async () => {
})
it('Correct Datatoken fields after updating metadata', async () => {
const chain = await web3.eth.getChainId()
// create the files encrypted string
const chain = await web3.eth.getChainId()
let providerResponse = await ProviderInstance.encrypt(
assetUrl,
chain,

View File

@ -122,8 +122,8 @@ describe('Simple Publish & consume test', async () => {
const erc721Address = result.events.NFTCreated.returnValues[0]
datatokenAddress = result.events.TokenCreated.returnValues[0]
// create the files encrypted string
const chain = await web3.eth.getChainId()
// create the files encrypted string
let providerResponse = await ProviderInstance.encrypt(
assetUrl,
chain,

View File

@ -16,6 +16,7 @@ import Web3 from 'web3'
import { homedir } from 'os'
import fs from 'fs'
import { fetch } from 'cross-fetch'
import veDelegation from '@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json'
const data = JSON.parse(
fs.readFileSync(
@ -87,6 +88,7 @@ const minAbi = [
describe('veOcean tests', async () => {
let nftFactory
let veOcean: VeOcean
let delegateContract
let veAllocate: VeAllocate
let veFeeDistributor: VeFeeDistributor
let ownerAccount: string
@ -103,6 +105,10 @@ describe('veOcean tests', async () => {
ownerAccount = accounts[0]
Alice = accounts[1]
Bob = accounts[2]
delegateContract = new web3.eth.Contract(
veDelegation.abi as AbiItem[],
addresses.veDelegation
)
const tokenContract = new web3.eth.Contract(minAbi, addresses.Ocean)
const estGas = await calculateEstimatedGas(
@ -554,4 +560,124 @@ describe('veOcean tests', async () => {
await evmIncreaseTime(60 * 60 * 24 * 7)
await veOcean.withdraw(Alice)
})
it('Alice should lock 100 Ocean and Delegate them to Bob', async () => {
// since we can only lock once, we test if tx fails or not
// so if there is already a lock, skip it
let currentBalance = await veOcean.getLockedAmount(Alice)
let currentLock = await veOcean.lockEnd(Alice)
const amount = '100'
await approve(
web3,
config,
Alice,
addresses.Ocean,
addresses.veOCEAN,
amount
)
const timestamp = Math.floor(Date.now() / 1000)
const unlockTime = timestamp + 30 * 86400
console.log('unlock time', unlockTime)
if (parseInt(currentBalance) > 0 || currentLock > 0) {
// we already have some locked tokens, so our transaction should fail
try {
await veOcean.lockTokens(Alice, amount, unlockTime)
assert(false, 'This should fail!')
} catch (e) {
// do nothing
}
} else {
await veOcean.lockTokens(Alice, amount, unlockTime)
}
currentBalance = await veOcean.getLockedAmount(Alice)
currentLock = await veOcean.lockEnd(Alice)
await sleep(2000)
const initialQuery = {
query: `query {
veOCEANs(id:"${Alice.toLowerCase()}"){
id,
lockedAmount,
unlockTime
}
}`
}
await sleep(2000)
const initialResponse = await fetch(subgraphUrl, {
method: 'POST',
body: JSON.stringify(initialQuery)
})
await sleep(2000)
const info = (await initialResponse.json()).data.veOCEANs
assert(info[0].id === Alice.toLowerCase(), 'ID is incorrect')
assert(info[0].lockedAmount === currentBalance, 'LockedAmount is incorrect')
assert(info[0].unlockTime === currentLock, 'Unlock time is not correct')
const lockTime = await veOcean.lockEnd(Alice)
const extLockTime = Number(lockTime) + 31556926
await delegateContract.methods.setApprovalForAll(Alice, true).send({
from: Alice
})
await veOcean.increaseUnlockTime(Alice, extLockTime)
const estGas = await calculateEstimatedGas(
Alice,
delegateContract.methods.create_boost,
Alice,
Bob,
10000,
0,
extLockTime,
0
)
const tx3 = await sendTx(
Alice,
estGas,
web3,
1,
delegateContract.methods.create_boost,
Alice,
Bob,
10000,
0,
extLockTime,
0
)
assert(tx3, 'Transaction failed')
assert(tx3.events.DelegateBoost, 'No Delegate boost event')
sleep(4000)
const delegateQuery = {
query: `query {
veDelegations{
id,
delegator {
id
},
receiver {
id
},
tokenId,
amount,
amountFraction,
cancelTime,
expireTime
}
}`
}
const delegateResponse = await fetch(subgraphUrl, {
method: 'POST',
body: JSON.stringify(delegateQuery)
})
const json = await delegateResponse.json()
console.log('json', json)
console.log('json?.data?.veDelegations', json?.data?.veDelegations)
assert(json?.data?.veDelegations, 'No veDelegations')
})
})