From a2bc63178cb92d40f815802fb59e4c17859c90c3 Mon Sep 17 00:00:00 2001 From: ssallam Date: Wed, 20 Jan 2021 09:35:53 +0100 Subject: [PATCH] add subgraph config for rinkeby and ropsten testnets, set ocean address based on detected network name --- package.json | 4 ++ src/helpers.ts | 15 ++++-- subgraph.rinkeby.yaml | 118 ++++++++++++++++++++++++++++++++++++++++++ subgraph.ropsten.yaml | 118 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 251 insertions(+), 4 deletions(-) create mode 100644 subgraph.rinkeby.yaml create mode 100644 subgraph.ropsten.yaml diff --git a/package.json b/package.json index 7b1d45b..5a3416b 100644 --- a/package.json +++ b/package.json @@ -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/subgraph-rinkeby --node http://127.0.0.1:8020", + "create:local-ropsten": "graph create oceanprotocol/subgraph-ropsten --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-rinkeby": "graph deploy oceanprotocol/subgraph-rinkeby subgraph.rinkeby.yaml --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020", + "deploy:local-ropsten": "graph deploy oceanprotocol/subgraph-ropsten subgraph.ropsten.yaml --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020", "test": "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", diff --git a/src/helpers.ts b/src/helpers.ts index c0065cc..7039b91 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -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, diff --git a/subgraph.rinkeby.yaml b/subgraph.rinkeby.yaml new file mode 100644 index 0000000..7f07332 --- /dev/null +++ b/subgraph.rinkeby.yaml @@ -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 diff --git a/subgraph.ropsten.yaml b/subgraph.ropsten.yaml new file mode 100644 index 0000000..7ec2f56 --- /dev/null +++ b/subgraph.ropsten.yaml @@ -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