From 796bff70e7647f15d2b0bc3d962776d684278016 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Thu, 12 May 2022 20:31:12 +0300 Subject: [PATCH] removing Vesting and opcFee (#432) * removing opcFee * Removing OPCFeeChanged from subgraph.template.yaml * Adding OPCFeeChanged event back into subgraph.template.yml * Adding SSContractAdded and SSContractRemoved back in * Formatting --- .github/workflows/tests.yml | 4 +- abis/ERC20.json | 446 ++++++++++++++++----------------- abis/ERC721RolesAddress.json | 2 +- schema.graphql | 14 -- src/mappings/factoryRouter.ts | 10 +- src/mappings/sscontract.ts | 47 ---- subgraph.template.yaml | 21 -- subgraph.yaml | 43 +--- test/integration/tsconfig.json | 34 +-- 9 files changed, 256 insertions(+), 365 deletions(-) delete mode 100644 src/mappings/sscontract.ts diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6adeb98..9aafb93 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ on: jobs: test: runs-on: ubuntu-latest - strategy: + strategy: max-parallel: 1 steps: - uses: actions/checkout@v2 @@ -53,7 +53,7 @@ jobs: bash -x start_ocean.sh --with-thegraph --skip-subgraph-deploy --no-dashboard 2>&1 > start_ocean.log & env: CONTRACTS_VERSION: v1.0.0-alpha.28 - + - run: npm ci - name: Wait for contracts deployment diff --git a/abis/ERC20.json b/abis/ERC20.json index 7d3e3e9..b576c2c 100644 --- a/abis/ERC20.json +++ b/abis/ERC20.json @@ -1,225 +1,225 @@ { - "contractName": "ERC20", - "abi": [ - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_spender", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_from", - "type": "address" - }, - { - "name": "_to", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [ - { - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "_owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "balance", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_to", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "_owner", - "type": "address" - }, - { - "name": "_spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - } + "contractName": "ERC20", + "abi": [ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_from", + "type": "address" + }, + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "balance", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + }, + { + "name": "_spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + } ] - } \ No newline at end of file +} diff --git a/abis/ERC721RolesAddress.json b/abis/ERC721RolesAddress.json index b3b462b..c288d5f 100644 --- a/abis/ERC721RolesAddress.json +++ b/abis/ERC721RolesAddress.json @@ -419,4 +419,4 @@ "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063431053ac1161005b578063431053ac1461019f5780634a63740a146101b2578063b0c41ead146101c5578063fe1ec880146101f057600080fd5b806310c558bf1461008d578063160a7925146100a257806319c186e514610179578063273e06b31461018c575b600080fd5b6100a061009b366004610859565b610203565b005b6101356100b0366004610859565b604080516080810182526000808252602082018190529181018290526060810191909152506001600160a01b0316600090815260208181526040918290208251608081018452905460ff808216151583526101008204811615159383019390935262010000810483161515938201939093526301000000909204161515606082015290565b604051610170919081511515815260208083015115159082015260408083015115159082015260609182015115159181019190915260800190565b60405180910390f35b6100a0610187366004610859565b6102f0565b6100a061019a366004610859565b6103ca565b6100a06101ad366004610859565b6104fc565b6100a06101c0366004610859565b61062d565b6101d86101d3366004610889565b610703565b6040516001600160a01b039091168152602001610170565b6100a06101fe366004610859565b61072d565b3360009081526020819052604090205460ff1615156001146102405760405162461bcd60e51b8152600401610237906108a2565b60405180910390fd5b6001600160a01b038116600081815260208190526040808220805462ff000019166201000017815560018054808201825593527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf690920180546001600160a01b0319168417905551909133917fc2a42571a74ce1442c8c44d375ba9442e7d55d94b37afeace261c83c62128fa4906102e49042904390918252602082015260400190565b60405180910390a35050565b3360009081526020819052604090205460ff1615156001146103245760405162461bcd60e51b8152600401610237906108a2565b6001600160a01b038116600081815260208190526040808220805463ff0000001916630100000017815560018054808201825593527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf690920180546001600160a01b0319168417905551909133917feb09276310ed110a7e565d64966d0ff68a47112d2dd5eeb6cbd7451836ce35ee906102e49042904390918252602082015260400190565b3360009081526020819052604090205460ff1615156001148061041b5750336001600160a01b03821614801561041b5750336000908152602081905260409020546301000000900460ff1615156001145b1561047f576001600160a01b03811660008181526020818152604091829020805463ff000000191681558251428152439281019290925292339290917fc929b18b08ffea86a1f95e29384dbe8968f2fcbd70cfd735df3aba1cc548cbf391016102e4565b60405162461bcd60e51b815260206004820152604660248201527f455243373231526f6c6573416464726573733a204e6f7420656e6f756768207060448201527f65726d697373696f6e7320746f2072656d6f76652066726f6d2037323553746f6064820152651c99531a5cdd60d21b608482015260a401610237565b3360009081526020819052604090205460ff1615156001148061054c5750336001600160a01b03821614801561054c57503360009081526020819052604090205462010000900460ff1615156001145b156105af576001600160a01b03811660008181526020818152604091829020805462ff0000191681558251428152439281019290925292339290917f9b41e1311fa819e825bc77fa2568492112e15ea92d173f3f8ee1c8ec3c1c562b91016102e4565b60405162461bcd60e51b815260206004820152604760248201527f455243373231526f6c6573416464726573733a204e6f7420656e6f756768207060448201527f65726d697373696f6e7320746f2072656d6f76652066726f6d206d65746164616064820152661d18481b1a5cdd60ca1b608482015260a401610237565b3360009081526020819052604090205460ff1615156001146106615760405162461bcd60e51b8152600401610237906108a2565b6001600160a01b038116600081815260208190526040808220805461ff00191661010017815560018054808201825593527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf690920180546001600160a01b0319168417905551909133917f0572d56343be407a66810f01449212e8545e14ff5049c479d34be944cdfd0d4f906102e49042904390918252602082015260400190565b6001818154811061071357600080fd5b6000918252602090912001546001600160a01b0316905081565b3360009081526020819052604090205460ff1615156001148061077d5750336001600160a01b03821614801561077d57503360009081526020819052604090205460ff6101009091041615156001145b156107df576001600160a01b03811660008181526020818152604091829020805461ff00191681558251428152439281019290925292339290917f59bd33f4c27cc16a2d74450e1fa43d7896020be9aecea4bee009db9294de899791016102e4565b60405162461bcd60e51b815260206004820152604360248201527f455243373231526f6c6573416464726573733a204e6f7420656e6f756768207060448201527f65726d697373696f6e7320746f2072656d6f76652066726f6d2045524332304c6064820152621a5cdd60ea1b608482015260a401610237565b60006020828403121561086b57600080fd5b81356001600160a01b038116811461088257600080fd5b9392505050565b60006020828403121561089b57600080fd5b5035919050565b6020808252601f908201527f455243373231526f6c6573416464726573733a204e4f54204d414e414745520060408201526060019056fea2646970667358221220cabd9a0cec3e45ffba59a95bb3ddc1d19aa1c82a0724b54aabff16b67c302d2c64736f6c634300080a0033", "linkReferences": {}, "deployedLinkReferences": {} -} \ No newline at end of file +} diff --git a/schema.graphql b/schema.graphql index da6d991..87277e0 100644 --- a/schema.graphql +++ b/schema.graphql @@ -534,18 +534,4 @@ type Template @entity{ ssTemplates: [String!] } -type Vested @entity { - id: ID! - amount: BigDecimal! - block: BigInt! - vesting: Vesting! -} -type Vesting @entity { - id: ID! - user: User! - token: Token! - endBlock: BigInt! - amount: BigDecimal! - vestingHistory: [Vested!]! @derivedFrom(field: "vesting") -} diff --git a/src/mappings/factoryRouter.ts b/src/mappings/factoryRouter.ts index 0bf1a10..e99db7e 100644 --- a/src/mappings/factoryRouter.ts +++ b/src/mappings/factoryRouter.ts @@ -13,12 +13,7 @@ import { } from '../@types/FactoryRouter/FactoryRouter' import { BigInt } from '@graphprotocol/graph-ts' import { Pool } from '../@types/schema' -import { - BPool, - FixedRateExchange, - Dispenser, - SSContract -} from '../@types/templates' +import { BPool, FixedRateExchange, Dispenser } from '../@types/templates' import { addPool, getOPC, getTemplates } from './utils/globalUtils' import { weiToDecimal } from './utils/generic' @@ -101,10 +96,8 @@ export function handleTokenRemoved(event: TokenRemoved): void { opc.approvedTokens = newList opc.save() } - export function handleSSContractAdded(event: SSContractAdded): void { // add token to approvedTokens - SSContract.create(event.params.contractAddress) const templates = getTemplates() let existingContracts: string[] if (!templates.ssTemplates) existingContracts = [] @@ -129,6 +122,7 @@ export function handleSSContractRemoved(event: SSContractRemoved): void { templates.ssTemplates = newList templates.save() } + export function handleFixedRateContractAdded( event: FixedRateContractAdded ): void { diff --git a/src/mappings/sscontract.ts b/src/mappings/sscontract.ts deleted file mode 100644 index 5f0598e..0000000 --- a/src/mappings/sscontract.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { - VestingCreated, - Vesting as VestingEvent -} from '../@types/templates/SSContract/SSContract' -import { Vested, Vesting } from '../@types/schema' -import { getUser } from './utils/userUtils' -import { getToken } from './utils/tokenUtils' -import { weiToDecimal } from './utils/generic' - -export function handleVestingCreated(event: VestingCreated): void { - const vesting = new Vesting( - event.address - .toHexString() - .concat('-') - .concat(event.params.datatokenAddress.toHexString()) - ) - const user = getUser(event.params.publisherAddress.toHexString()) - vesting.user = user.id - const token = getToken(event.params.datatokenAddress, true) - vesting.token = token.id - vesting.endBlock = event.params.vestingEndBlock - vesting.amount = weiToDecimal( - event.params.totalVestingAmount.toBigDecimal(), - token.decimals - ) - vesting.save() -} - -export function handleVesting(event: VestingEvent): void { - const vesting = new Vesting( - event.address - .toHexString() - .concat('-') - .concat(event.params.datatokenAddress.toHexString()) - ) - const vestingHistory = new Vested( - event.transaction.hash.toHex().concat('-').concat(event.logIndex.toString()) - ) - vestingHistory.block = event.block.number - const token = getToken(event.params.datatokenAddress, true) - vestingHistory.amount = weiToDecimal( - event.params.amountVested.toBigDecimal(), - token.decimals - ) - vestingHistory.vesting = vesting.id - vestingHistory.save() -} diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 4e763f6..04dba00 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -263,24 +263,3 @@ templates: handler: handlePublishMarketFeeChanged - event: TokenCollected(indexed bytes32,indexed address,indexed address,uint256) handler: handleTokenCollected - - - name: SSContract - kind: ethereum/contract - network: __NETWORK__ - source: - abi: SSContract - mapping: - kind: ethereum/events - apiVersion: 0.0.6 - language: wasm/assemblyscript - file: ./src/mappings/sscontract.ts - entities: - - SSContract - abis: - - name: SSContract - file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/ssContracts/SideStaking.sol/SideStaking.json - eventHandlers: - - event: VestingCreated(indexed address,indexed address,uint256,uint256) - handler: handleVestingCreated - - event: Vesting(indexed address,indexed address,indexed address,uint256) - handler: handleVesting diff --git a/subgraph.yaml b/subgraph.yaml index a110c87..b05fd58 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -6,11 +6,11 @@ schema: dataSources: - kind: ethereum/contract name: ERC721Factory - network: rinkeby + network: development source: - address: '0x6eb0184B64f22fB5e1316221E1eC84988F9E6b12' + address: '0x2f7a30F120f0B7799C8900144eC6d8E4fBbc90ec' abi: ERC721Factory - startBlock: 10422197 + startBlock: 1119 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -31,11 +31,11 @@ dataSources: - kind: ethereum/contract name: FactoryRouter - network: rinkeby + network: development source: - address: '0xF1Ef3C2332E44bdA219D9155E9a97201a1b5eC1C' + address: '0x375B009326A0938B8c325Bc2d402a16fe0fBB402' abi: FactoryRouter - startBlock: 10422197 + startBlock: 1119 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -73,7 +73,7 @@ dataSources: templates: - name: ERC20Template kind: ethereum/contract - network: rinkeby + network: development source: abi: ERC20Template mapping: @@ -114,7 +114,7 @@ templates: - name: BPool kind: ethereum/contract - network: rinkeby + network: development source: abi: BPool mapping: @@ -151,7 +151,7 @@ templates: - name: ERC721Template kind: ethereum/contract - network: rinkeby + network: development source: abi: ERC721Template mapping: @@ -198,7 +198,7 @@ templates: - name: Dispenser kind: ethereum/contract - network: rinkeby + network: development source: abi: Dispenser mapping: @@ -229,7 +229,7 @@ templates: - name: FixedRateExchange kind: ethereum/contract - network: rinkeby + network: development source: abi: FixedRateExchange mapping: @@ -263,24 +263,3 @@ templates: handler: handlePublishMarketFeeChanged - event: TokenCollected(indexed bytes32,indexed address,indexed address,uint256) handler: handleTokenCollected - - - name: SSContract - kind: ethereum/contract - network: rinkeby - source: - abi: SSContract - mapping: - kind: ethereum/events - apiVersion: 0.0.6 - language: wasm/assemblyscript - file: ./src/mappings/sscontract.ts - entities: - - SSContract - abis: - - name: SSContract - file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/ssContracts/SideStaking.sol/SideStaking.json - eventHandlers: - - event: VestingCreated(indexed address,indexed address,uint256,uint256) - handler: handleVestingCreated - - event: Vesting(indexed address,indexed address,indexed address,uint256) - handler: handleVesting diff --git a/test/integration/tsconfig.json b/test/integration/tsconfig.json index 8eaefd4..cd2873c 100644 --- a/test/integration/tsconfig.json +++ b/test/integration/tsconfig.json @@ -1,18 +1,18 @@ { - "compilerOptions": { - "resolveJsonModule": true, - "moduleResolution": "node", - "lib": ["es2017", "es6", "es7", "dom"], - "noUnusedLocals": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "declaration": true, - "module": "commonjs", - "target": "es5", - "removeComments": true, - "experimentalDecorators": true, - "preserveConstEnums": true, - "typeRoots": ["../node_modules/@types"], - "types": ["...", "@types/mocha"], - } - } \ No newline at end of file + "compilerOptions": { + "resolveJsonModule": true, + "moduleResolution": "node", + "lib": ["es2017", "es6", "es7", "dom"], + "noUnusedLocals": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "declaration": true, + "module": "commonjs", + "target": "es5", + "removeComments": true, + "experimentalDecorators": true, + "preserveConstEnums": true, + "typeRoots": ["../node_modules/@types"], + "types": ["...", "@types/mocha"] + } +}