Merge branch 'main' into feature/dependabot

This commit is contained in:
Matthias Kretschmann 2021-01-26 13:59:37 +01:00 committed by GitHub
commit 7a9c78ddfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 273 additions and 19 deletions

View File

@ -5,11 +5,15 @@
"start": "",
"create": "graph create oceanprotocol/ocean-subgraph --node https://api.thegraph.com/deploy/",
"create:local": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
"create:local-rinkeby": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
"create:local-ropsten": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
"codegen": "graph codegen --output-dir src/@types",
"build": "graph build",
"deploy": "graph deploy oceanprotocol/ocean-subgraph --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:beta": "graph deploy oceanprotocol/ocean-subgraph-beta --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:local": "graph deploy oceanprotocol/ocean-subgraph subgraph.yaml --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020",
"deploy:local": "graph deploy oceanprotocol/ocean-subgraph subgraph.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
"deploy:local-rinkeby": "graph deploy oceanprotocol/ocean-subgraph subgraph.rinkeby.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
"deploy:local-ropsten": "graph deploy oceanprotocol/ocean-subgraph subgraph.ropsten.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
"test": "npm run codegen && npm run lint && npm run type-check",
"lint": "eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx .",
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json,yaml}' --write",

View File

@ -34,10 +34,17 @@ export const ENABLE_DEBUG = true
const network = dataSource.network()
export const OCEAN: string =
network === 'mainnet'
? '0x967da4048cd07ab37855c090aaf366e4ce1b9f48'
: '0x8967BCF84170c91B0d24D4302C2376283b0B3a07'
export const OCEAN: string = getOceanAddress()
function getOceanAddress(): string {
if (network == 'ropsten') {
return '0x5e8dcb2afa23844bcc311b00ad1a0c30025aade9'
} else if (network == 'rinkeby') {
return '0x8967bcf84170c91b0d24d4302c2376283b0b3a07'
}
// network == 'mainnet'
return '0x967da4048cd07ab37855c090aaf366e4ce1b9f48'
}
export function _debuglog(
message: string,
@ -175,7 +182,7 @@ export function updatePoolTransactionToken(
ptxTokenValues.save()
if (ptxTokenValues.tokenAddress === OCEAN) {
if (ptxTokenValues.tokenAddress == OCEAN) {
ptx.oceanReserve = ptxTokenValues.tokenReserve
pool.oceanReserve = ptxTokenValues.tokenReserve
} else {

View File

@ -29,8 +29,8 @@ export function handleTransfer(event: Transfer): void {
let oldBalanceFrom = BigDecimal.fromString('0.0')
let oldBalanceTo = BigDecimal.fromString('0.0')
const isMint = tokenShareFrom === ZERO_ADDRESS
const isBurn = tokenShareTo === ZERO_ADDRESS
const isMint = tokenShareFrom == ZERO_ADDRESS
const isBurn = tokenShareTo == ZERO_ADDRESS
const datatoken = Datatoken.load(tokenId)
@ -69,7 +69,7 @@ export function handleTransfer(event: Transfer): void {
}
if (
tokenBalanceTo !== null &&
tokenBalanceTo != null &&
tokenBalanceTo.balance.notEqual(ZERO_BD) &&
oldBalanceTo.equals(ZERO_BD)
) {
@ -77,7 +77,7 @@ export function handleTransfer(event: Transfer): void {
}
if (
tokenBalanceFrom !== null &&
tokenBalanceFrom != null &&
tokenBalanceFrom.balance.equals(ZERO_BD) &&
oldBalanceFrom.notEqual(ZERO_BD)
) {
@ -115,7 +115,7 @@ export function handleOrderStarted(event: OrderStarted): void {
order.timestamp = event.params.timestamp.toI32()
if (
event.params.mrktFeeCollector != null &&
event.params.mrktFeeCollector.toHex() !== ZERO_ADDRESS
event.params.mrktFeeCollector.toHex() != ZERO_ADDRESS
) {
order.marketFeeCollector = event.params.mrktFeeCollector.toHexString()
}

View File

@ -7,7 +7,7 @@ import { ZERO_BD } from '../helpers'
export function handleNewPool(event: BPoolRegistered): void {
let factory = PoolFactory.load('1')
if (factory === null) {
if (factory == null) {
factory = new PoolFactory('1')
factory.totalLiquidity = ZERO_BD
factory.totalSwapVolume = ZERO_BD

View File

@ -59,7 +59,7 @@ export function handleSetController(event: LOG_CALL): void {
export function handleSetPublicSwap(event: LOG_CALL): void {
const poolId = event.address.toHex()
const pool = Pool.load(poolId)
pool.publicSwap = event.params.data.toHexString().slice(-1) === '1'
pool.publicSwap = event.params.data.toHexString().slice(-1) == '1'
pool.save()
}
@ -86,7 +86,7 @@ export function _handleRebind(
const pool = Pool.load(poolId)
const decimals = BigInt.fromI32(18).toI32()
if (tokenAddress !== OCEAN) {
if (tokenAddress != OCEAN) {
pool.datatokenAddress = tokenAddress
}
pool.tokenCount += BigInt.fromI32(1)
@ -131,6 +131,10 @@ export function handleRebind(event: LOG_CALL): void {
}
export function handleSetup(event: LOG_CALL): void {
if (PoolTransaction.load(event.transaction.hash.toHexString()) != null) {
return
}
const poolId = event.address.toHex()
debuglog('handleSetup: ', event, [])
const data = event.params.data.toHexString()
@ -204,7 +208,7 @@ export function handleJoinPool(event: LOG_JOIN): void {
const poolId = event.address.toHex()
const pool = Pool.load(poolId)
if (pool.finalized === false) {
if (pool.finalized == false) {
return
}
@ -406,8 +410,8 @@ export function handleTransfer(event: Transfer): void {
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
const isMint = event.params.from.toHex() === ZERO_ADDRESS
const isBurn = event.params.to.toHex() === ZERO_ADDRESS
const isMint = event.params.from.toHex() == ZERO_ADDRESS
const isBurn = event.params.to.toHex() == ZERO_ADDRESS
const poolShareFromId = poolId.concat('-').concat(event.params.from.toHex())
let poolShareFrom = PoolShare.load(poolShareFromId)
@ -434,6 +438,8 @@ export function handleTransfer(event: Transfer): void {
poolTx.sharesTransferAmount = value
poolTx.sharesBalance = poolShareTo.balance
}
debuglog('pool shares mint: (id, value, totalShares)', event, [poolId, value.toString(), pool.totalShares.toString()])
} else if (isBurn) {
if (poolShareFrom == null) {
createPoolShareEntity(poolShareFromId, poolId, event.params.from.toHex())
@ -446,6 +452,7 @@ export function handleTransfer(event: Transfer): void {
poolTx.sharesTransferAmount = -value
poolTx.sharesBalance = poolShareFrom.balance
}
debuglog('pool shares burn: (id, value, totalShares)', event, [poolId, value.toString(), pool.totalShares.toString()])
} else {
if (poolShareTo == null) {
createPoolShareEntity(poolShareToId, poolId, event.params.to.toHex())
@ -463,7 +470,7 @@ export function handleTransfer(event: Transfer): void {
}
if (
poolShareTo !== null &&
poolShareTo != null &&
poolShareTo.balance.notEqual(ZERO_BD) &&
poolShareToBalance.equals(ZERO_BD)
) {
@ -471,7 +478,7 @@ export function handleTransfer(event: Transfer): void {
}
if (
poolShareFrom !== null &&
poolShareFrom != null &&
poolShareFrom.balance.equals(ZERO_BD) &&
poolShareFromBalance.notEqual(ZERO_BD)
) {

118
subgraph.rinkeby.yaml Normal file
View File

@ -0,0 +1,118 @@
specVersion: 0.0.2
description: Ocean provides data sharing through IDOs
repository: https://github.com/oceanprotocol/ocean-subgraph
schema:
file: ./schema.graphql
dataSources:
- kind: ethereum/contract
name: Factory
network: rinkeby
source:
address: '0x53eDF9289B0898e1652Ce009AACf8D25fA9A42F8'
abi: Factory
startBlock: 7298806
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
file: ./src/mappings/factory.ts
entities:
- PoolFactory
abis:
- name: Factory
file: ./abis/BFactory.json
eventHandlers:
- event: BPoolRegistered(address,indexed address)
handler: handleNewPool
- kind: ethereum/contract
name: DTFactory
network: rinkeby
source:
address: '0x3fd7A00106038Fb5c802c6d63fa7147Fe429E83a'
abi: DTFactory
startBlock: 7298804
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
file: ./src/mappings/dtfactory.ts
entities:
- DatatokenFactory
abis:
- name: DTFactory
file: ./abis/DTFactory.json
eventHandlers:
- event: TokenRegistered(indexed address,string,string,uint256,indexed address,indexed string)
handler: handleNewToken
templates:
- kind: ethereum/contract
name: Pool
network: rinkeby
source:
abi: Pool
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
file: ./src/mappings/pool.ts
entities:
- Pool
- PoolFactory
- Swap
abis:
- name: Pool
file: ./abis/BPool.json
- name: BToken
file: ./abis/BToken.json
eventHandlers:
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x34e1990700000000000000000000000000000000000000000000000000000000'
handler: handleSetSwapFee
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x92eefe9b00000000000000000000000000000000000000000000000000000000'
handler: handleSetController
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x49b5955200000000000000000000000000000000000000000000000000000000'
handler: handleSetPublicSwap
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x4bb278f300000000000000000000000000000000000000000000000000000000'
handler: handleFinalize
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0xd1d7bc9100000000000000000000000000000000000000000000000000000000'
handler: handleSetup
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x3fdddaa200000000000000000000000000000000000000000000000000000000'
handler: handleRebind
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0xe4e1e53800000000000000000000000000000000000000000000000000000000'
handler: handleRebind
- event: LOG_JOIN(indexed address,indexed address,uint256)
handler: handleJoinPool
- event: LOG_EXIT(indexed address,indexed address,uint256)
handler: handleExitPool
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256)
handler: handleSwap
- event: Transfer(indexed address,indexed address,uint256)
handler: handleTransfer
- kind: ethereum/contract
name: DataToken
network: rinkeby
source:
abi: DataToken
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
file: ./src/mappings/datatoken.ts
entities:
- DataToken
- DatatokenFactory
abis:
- name: DataToken
file: ./abis/DataTokenTemplate.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleTransfer
- event: OrderStarted(indexed address,indexed address,uint256,uint256,uint256,indexed address,uint256)
handler: handleOrderStarted

118
subgraph.ropsten.yaml Normal file
View File

@ -0,0 +1,118 @@
specVersion: 0.0.2
description: Ocean provides data sharing through IDOs
repository: https://github.com/oceanprotocol/ocean-subgraph
schema:
file: ./schema.graphql
dataSources:
- kind: ethereum/contract
name: Factory
network: ropsten
source:
address: '0x75be6e18c80A487C8b49663bf14f80A6495045B2'
abi: Factory
startBlock: 9227587
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
file: ./src/mappings/factory.ts
entities:
- PoolFactory
abis:
- name: Factory
file: ./abis/BFactory.json
eventHandlers:
- event: BPoolRegistered(address,indexed address)
handler: handleNewPool
- kind: ethereum/contract
name: DTFactory
network: ropsten
source:
address: '0x6ebcCa6df2CAba986FCF44E64Ee82251c1455Dcc'
abi: DTFactory
startBlock: 9227578
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
file: ./src/mappings/dtfactory.ts
entities:
- DatatokenFactory
abis:
- name: DTFactory
file: ./abis/DTFactory.json
eventHandlers:
- event: TokenRegistered(indexed address,string,string,uint256,indexed address,indexed string)
handler: handleNewToken
templates:
- kind: ethereum/contract
name: Pool
network: ropsten
source:
abi: Pool
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
file: ./src/mappings/pool.ts
entities:
- Pool
- PoolFactory
- Swap
abis:
- name: Pool
file: ./abis/BPool.json
- name: BToken
file: ./abis/BToken.json
eventHandlers:
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x34e1990700000000000000000000000000000000000000000000000000000000'
handler: handleSetSwapFee
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x92eefe9b00000000000000000000000000000000000000000000000000000000'
handler: handleSetController
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x49b5955200000000000000000000000000000000000000000000000000000000'
handler: handleSetPublicSwap
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x4bb278f300000000000000000000000000000000000000000000000000000000'
handler: handleFinalize
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0xd1d7bc9100000000000000000000000000000000000000000000000000000000'
handler: handleSetup
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x3fdddaa200000000000000000000000000000000000000000000000000000000'
handler: handleRebind
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0xe4e1e53800000000000000000000000000000000000000000000000000000000'
handler: handleRebind
- event: LOG_JOIN(indexed address,indexed address,uint256)
handler: handleJoinPool
- event: LOG_EXIT(indexed address,indexed address,uint256)
handler: handleExitPool
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256)
handler: handleSwap
- event: Transfer(indexed address,indexed address,uint256)
handler: handleTransfer
- kind: ethereum/contract
name: DataToken
network: ropsten
source:
abi: DataToken
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
file: ./src/mappings/datatoken.ts
entities:
- DataToken
- DatatokenFactory
abis:
- name: DataToken
file: ./abis/DataTokenTemplate.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleTransfer
- event: OrderStarted(indexed address,indexed address,uint256,uint256,uint256,indexed address,uint256)
handler: handleOrderStarted