Use latest predictoor contracts (#708)

* Update tests.yml

* Update handlers

* Update schema

* Linter

* Update abi and fields

* use latest contracts

* use latest contracts

* expose agg preds in trueval

* fix abi path

* remove unused abis

* fix

---------

Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
This commit is contained in:
Alex Coseru 2023-08-16 17:23:15 +03:00 committed by GitHub
parent 1502ac3963
commit 8ebb202cc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 58 additions and 2526 deletions

View File

@ -52,7 +52,7 @@ jobs:
run: |
bash -x start_ocean.sh --with-thegraph --skip-subgraph-deploy --no-dashboard 2>&1 > start_ocean.log &
env:
CONTRACTS_VERSION: predictoor
CONTRACTS_VERSION: predictoor3
- run: npm ci

File diff suppressed because one or more lines are too long

View File

@ -1,422 +0,0 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "ERC721RolesAddress",
"sourceName": "contracts/utils/ERC721RolesAddress.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "AddedManager",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "AddedTo725StoreList",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "AddedToCreateERC20List",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "AddedToMetadataList",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "CleanedPermissions",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "RemovedFrom725StoreList",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "RemovedFromCreateERC20List",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "RemovedFromMetadataList",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "RemovedManager",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "_allowedAddress",
"type": "address"
}
],
"name": "addTo725StoreList",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_allowedAddress",
"type": "address"
}
],
"name": "addToCreateERC20List",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_allowedAddress",
"type": "address"
}
],
"name": "addToMetadataList",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "auth",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "getPermissions",
"outputs": [
{
"components": [
{
"internalType": "bool",
"name": "manager",
"type": "bool"
},
{
"internalType": "bool",
"name": "deployERC20",
"type": "bool"
},
{
"internalType": "bool",
"name": "updateMetadata",
"type": "bool"
},
{
"internalType": "bool",
"name": "store",
"type": "bool"
}
],
"internalType": "struct ERC721RolesAddress.Roles",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_allowedAddress",
"type": "address"
}
],
"name": "removeFrom725StoreList",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_allowedAddress",
"type": "address"
}
],
"name": "removeFromCreateERC20List",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_allowedAddress",
"type": "address"
}
],
"name": "removeFromMetadataList",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b5061090f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063431053ac1161005b578063431053ac1461019f5780634a63740a146101b2578063b0c41ead146101c5578063fe1ec880146101f057600080fd5b806310c558bf1461008d578063160a7925146100a257806319c186e514610179578063273e06b31461018c575b600080fd5b6100a061009b366004610859565b610203565b005b6101356100b0366004610859565b604080516080810182526000808252602082018190529181018290526060810191909152506001600160a01b0316600090815260208181526040918290208251608081018452905460ff808216151583526101008204811615159383019390935262010000810483161515938201939093526301000000909204161515606082015290565b604051610170919081511515815260208083015115159082015260408083015115159082015260609182015115159181019190915260800190565b60405180910390f35b6100a0610187366004610859565b6102f0565b6100a061019a366004610859565b6103ca565b6100a06101ad366004610859565b6104fc565b6100a06101c0366004610859565b61062d565b6101d86101d3366004610889565b610703565b6040516001600160a01b039091168152602001610170565b6100a06101fe366004610859565b61072d565b3360009081526020819052604090205460ff1615156001146102405760405162461bcd60e51b8152600401610237906108a2565b60405180910390fd5b6001600160a01b038116600081815260208190526040808220805462ff000019166201000017815560018054808201825593527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf690920180546001600160a01b0319168417905551909133917fc2a42571a74ce1442c8c44d375ba9442e7d55d94b37afeace261c83c62128fa4906102e49042904390918252602082015260400190565b60405180910390a35050565b3360009081526020819052604090205460ff1615156001146103245760405162461bcd60e51b8152600401610237906108a2565b6001600160a01b038116600081815260208190526040808220805463ff0000001916630100000017815560018054808201825593527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf690920180546001600160a01b0319168417905551909133917feb09276310ed110a7e565d64966d0ff68a47112d2dd5eeb6cbd7451836ce35ee906102e49042904390918252602082015260400190565b3360009081526020819052604090205460ff1615156001148061041b5750336001600160a01b03821614801561041b5750336000908152602081905260409020546301000000900460ff1615156001145b1561047f576001600160a01b03811660008181526020818152604091829020805463ff000000191681558251428152439281019290925292339290917fc929b18b08ffea86a1f95e29384dbe8968f2fcbd70cfd735df3aba1cc548cbf391016102e4565b60405162461bcd60e51b815260206004820152604660248201527f455243373231526f6c6573416464726573733a204e6f7420656e6f756768207060448201527f65726d697373696f6e7320746f2072656d6f76652066726f6d2037323553746f6064820152651c99531a5cdd60d21b608482015260a401610237565b3360009081526020819052604090205460ff1615156001148061054c5750336001600160a01b03821614801561054c57503360009081526020819052604090205462010000900460ff1615156001145b156105af576001600160a01b03811660008181526020818152604091829020805462ff0000191681558251428152439281019290925292339290917f9b41e1311fa819e825bc77fa2568492112e15ea92d173f3f8ee1c8ec3c1c562b91016102e4565b60405162461bcd60e51b815260206004820152604760248201527f455243373231526f6c6573416464726573733a204e6f7420656e6f756768207060448201527f65726d697373696f6e7320746f2072656d6f76652066726f6d206d65746164616064820152661d18481b1a5cdd60ca1b608482015260a401610237565b3360009081526020819052604090205460ff1615156001146106615760405162461bcd60e51b8152600401610237906108a2565b6001600160a01b038116600081815260208190526040808220805461ff00191661010017815560018054808201825593527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf690920180546001600160a01b0319168417905551909133917f0572d56343be407a66810f01449212e8545e14ff5049c479d34be944cdfd0d4f906102e49042904390918252602082015260400190565b6001818154811061071357600080fd5b6000918252602090912001546001600160a01b0316905081565b3360009081526020819052604090205460ff1615156001148061077d5750336001600160a01b03821614801561077d57503360009081526020819052604090205460ff6101009091041615156001145b156107df576001600160a01b03811660008181526020818152604091829020805461ff00191681558251428152439281019290925292339290917f59bd33f4c27cc16a2d74450e1fa43d7896020be9aecea4bee009db9294de899791016102e4565b60405162461bcd60e51b815260206004820152604360248201527f455243373231526f6c6573416464726573733a204e6f7420656e6f756768207060448201527f65726d697373696f6e7320746f2072656d6f76652066726f6d2045524332304c6064820152621a5cdd60ea1b608482015260a401610237565b60006020828403121561086b57600080fd5b81356001600160a01b038116811461088257600080fd5b9392505050565b60006020828403121561089b57600080fd5b5035919050565b6020808252601f908201527f455243373231526f6c6573416464726573733a204e4f54204d414e414745520060408201526060019056fea2646970667358221220cabd9a0cec3e45ffba59a95bb3ddc1d19aa1c82a0724b54aabff16b67c302d2c64736f6c634300080a0033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063431053ac1161005b578063431053ac1461019f5780634a63740a146101b2578063b0c41ead146101c5578063fe1ec880146101f057600080fd5b806310c558bf1461008d578063160a7925146100a257806319c186e514610179578063273e06b31461018c575b600080fd5b6100a061009b366004610859565b610203565b005b6101356100b0366004610859565b604080516080810182526000808252602082018190529181018290526060810191909152506001600160a01b0316600090815260208181526040918290208251608081018452905460ff808216151583526101008204811615159383019390935262010000810483161515938201939093526301000000909204161515606082015290565b604051610170919081511515815260208083015115159082015260408083015115159082015260609182015115159181019190915260800190565b60405180910390f35b6100a0610187366004610859565b6102f0565b6100a061019a366004610859565b6103ca565b6100a06101ad366004610859565b6104fc565b6100a06101c0366004610859565b61062d565b6101d86101d3366004610889565b610703565b6040516001600160a01b039091168152602001610170565b6100a06101fe366004610859565b61072d565b3360009081526020819052604090205460ff1615156001146102405760405162461bcd60e51b8152600401610237906108a2565b60405180910390fd5b6001600160a01b038116600081815260208190526040808220805462ff000019166201000017815560018054808201825593527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf690920180546001600160a01b0319168417905551909133917fc2a42571a74ce1442c8c44d375ba9442e7d55d94b37afeace261c83c62128fa4906102e49042904390918252602082015260400190565b60405180910390a35050565b3360009081526020819052604090205460ff1615156001146103245760405162461bcd60e51b8152600401610237906108a2565b6001600160a01b038116600081815260208190526040808220805463ff0000001916630100000017815560018054808201825593527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf690920180546001600160a01b0319168417905551909133917feb09276310ed110a7e565d64966d0ff68a47112d2dd5eeb6cbd7451836ce35ee906102e49042904390918252602082015260400190565b3360009081526020819052604090205460ff1615156001148061041b5750336001600160a01b03821614801561041b5750336000908152602081905260409020546301000000900460ff1615156001145b1561047f576001600160a01b03811660008181526020818152604091829020805463ff000000191681558251428152439281019290925292339290917fc929b18b08ffea86a1f95e29384dbe8968f2fcbd70cfd735df3aba1cc548cbf391016102e4565b60405162461bcd60e51b815260206004820152604660248201527f455243373231526f6c6573416464726573733a204e6f7420656e6f756768207060448201527f65726d697373696f6e7320746f2072656d6f76652066726f6d2037323553746f6064820152651c99531a5cdd60d21b608482015260a401610237565b3360009081526020819052604090205460ff1615156001148061054c5750336001600160a01b03821614801561054c57503360009081526020819052604090205462010000900460ff1615156001145b156105af576001600160a01b03811660008181526020818152604091829020805462ff0000191681558251428152439281019290925292339290917f9b41e1311fa819e825bc77fa2568492112e15ea92d173f3f8ee1c8ec3c1c562b91016102e4565b60405162461bcd60e51b815260206004820152604760248201527f455243373231526f6c6573416464726573733a204e6f7420656e6f756768207060448201527f65726d697373696f6e7320746f2072656d6f76652066726f6d206d65746164616064820152661d18481b1a5cdd60ca1b608482015260a401610237565b3360009081526020819052604090205460ff1615156001146106615760405162461bcd60e51b8152600401610237906108a2565b6001600160a01b038116600081815260208190526040808220805461ff00191661010017815560018054808201825593527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf690920180546001600160a01b0319168417905551909133917f0572d56343be407a66810f01449212e8545e14ff5049c479d34be944cdfd0d4f906102e49042904390918252602082015260400190565b6001818154811061071357600080fd5b6000918252602090912001546001600160a01b0316905081565b3360009081526020819052604090205460ff1615156001148061077d5750336001600160a01b03821614801561077d57503360009081526020819052604090205460ff6101009091041615156001145b156107df576001600160a01b03811660008181526020818152604091829020805461ff00191681558251428152439281019290925292339290917f59bd33f4c27cc16a2d74450e1fa43d7896020be9aecea4bee009db9294de899791016102e4565b60405162461bcd60e51b815260206004820152604360248201527f455243373231526f6c6573416464726573733a204e6f7420656e6f756768207060448201527f65726d697373696f6e7320746f2072656d6f76652066726f6d2045524332304c6064820152621a5cdd60ea1b608482015260a401610237565b60006020828403121561086b57600080fd5b81356001600160a01b038116811461088257600080fd5b9392505050565b60006020828403121561089b57600080fd5b5035919050565b6020808252601f908201527f455243373231526f6c6573416464726573733a204e4f54204d414e414745520060408201526060019056fea2646970667358221220cabd9a0cec3e45ffba59a95bb3ddc1d19aa1c82a0724b54aabff16b67c302d2c64736f6c634300080a0033",
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@ -1,7 +1,7 @@
version: '3'
services:
graph-node:
image: graphprotocol/graph-node:v0.27.0
image: graphprotocol/graph-node:v0.28.2
ports:
- '9000:8000'
- '8001:8001'
@ -17,8 +17,9 @@ services:
postgres_pass: let-me-in
postgres_db: graph-node
ipfs: 'ipfs:5001'
ethereum: 'goerli:https://goerli.infura.io/v3/${INFURA_PROJECT_ID}'
RUST_LOG: info
ethereum: 'oasis_saphire_testnet:http://192.168.136.129:8080'
RUST_LOG: warning
GRAPH_ETHEREUM_MAX_BLOCK_RANGE_SIZE: 100
ipfs:
image: ipfs/go-ipfs:v0.4.23
ports:

14
package-lock.json generated
View File

@ -9,7 +9,7 @@
"version": "3.0.9",
"license": "Apache-2.0",
"dependencies": {
"@oceanprotocol/contracts": "^2.0.0-next.2",
"@oceanprotocol/contracts": "^2.0.0-next.6",
"@oceanprotocol/lib": "^2.7.0",
"cross-fetch": "^3.1.6",
"ethereumjs-util": "^7.1.5"
@ -964,9 +964,9 @@
}
},
"node_modules/@oceanprotocol/contracts": {
"version": "2.0.0-next.2",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-2.0.0-next.2.tgz",
"integrity": "sha512-VVIUtfiJbojKOP+YsWmGZw8s8R0TLO3OCyqn6MKrBN+ukdwkimLmg7/0LPtCQQjOSv8MrIyQb1dN7o+3hchNZg=="
"version": "2.0.0-next.6",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-2.0.0-next.6.tgz",
"integrity": "sha512-eQ+P1uWudprH0PDWLjSF2teys10MD3vb2W7U610KZTHphkZ52sgoFwLLMu0TeO+s5elr0OdnUilu78/EaFHEbg=="
},
"node_modules/@oceanprotocol/lib": {
"version": "2.7.0",
@ -15341,9 +15341,9 @@
}
},
"@oceanprotocol/contracts": {
"version": "2.0.0-next.2",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-2.0.0-next.2.tgz",
"integrity": "sha512-VVIUtfiJbojKOP+YsWmGZw8s8R0TLO3OCyqn6MKrBN+ukdwkimLmg7/0LPtCQQjOSv8MrIyQb1dN7o+3hchNZg=="
"version": "2.0.0-next.6",
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-2.0.0-next.6.tgz",
"integrity": "sha512-eQ+P1uWudprH0PDWLjSF2teys10MD3vb2W7U610KZTHphkZ52sgoFwLLMu0TeO+s5elr0OdnUilu78/EaFHEbg=="
},
"@oceanprotocol/lib": {
"version": "2.7.0",

View File

@ -75,7 +75,7 @@
"typescript": "^5.0.4"
},
"dependencies": {
"@oceanprotocol/contracts": "^2.0.0-next.2",
"@oceanprotocol/contracts": "^2.0.0-next.6",
"@oceanprotocol/lib": "^2.7.0",
"cross-fetch": "^3.1.6",
"ethereumjs-util": "^7.1.5"

View File

@ -733,6 +733,8 @@ type PredictSlot @entity{
revenue: BigDecimal!
revenues: [PredictionRevenue!] @derivedFrom(field: "slot")
status: PredictSlotStatus!
roundSumStakesUp: BigDecimal!
roundSumStakes: BigDecimal!
}
@ -740,9 +742,9 @@ type PredictSettingUpdate @entity{
"id = {contract address}-{txId}-{eventIndex}"
id: ID!
predictContract: PredictContract!
blocksPerEpoch: BigInt!
blocksPerSubscription: BigInt!
truevalSubmitTimeoutBlock: BigInt!
secondsPerEpoch: BigInt!
secondsPerSubscription: BigInt!
truevalSubmitTimeout: BigInt!
stakeToken: Token
"txId"
txId: String
@ -757,9 +759,9 @@ type PredictContract @entity{
slots: [PredictSlot!] @derivedFrom(field: "predictContract")
settingUpdates: [PredictSettingUpdate!] @derivedFrom(field: "predictContract")
subscriptions: [PredictSubscription!] @derivedFrom(field: "predictContract")
blocksPerEpoch: BigInt!
blocksPerSubscription: BigInt!
truevalSubmitTimeoutBlock: BigInt!
secondsPerEpoch: BigInt!
secondsPerSubscription: BigInt!
truevalSubmitTimeout: BigInt!
stakeToken: Token
"creation txId"
txId: String

View File

@ -33,6 +33,8 @@ function getPredictSlot(
newPredictSlot.predictContract = predictContractAddress
newPredictSlot.slot = slot
newPredictSlot.revenue = BigDecimal.zero()
newPredictSlot.roundSumStakesUp = BigDecimal.zero()
newPredictSlot.roundSumStakes = BigDecimal.zero()
newPredictSlot.status = 'Pending'
newPredictSlot.save()
}
@ -155,14 +157,31 @@ export function handleTruevalSubmitted(event: TruevalSubmitted): void {
18
)
newPredictTrueVals.save()
let decimals = 18
const predictContract = getPredictContract(event.address)
if (predictContract.stakeToken) {
const stakeToken = getToken(
Address.fromString(predictContract.stakeToken!),
false
)
decimals = stakeToken.decimals
}
predictSlot.roundSumStakesUp = weiToDecimal(
event.params.roundSumStakesUp.toBigDecimal(),
BigInt.fromI32(decimals).toI32()
)
predictSlot.roundSumStakes = weiToDecimal(
event.params.roundSumStakes.toBigDecimal(),
BigInt.fromI32(decimals).toI32()
)
predictSlot.save()
}
export function handleSettingChanged(event: SettingChanged): void {
const predictContract = getPredictContract(event.address)
predictContract.blocksPerEpoch = event.params.blocksPerEpoch
predictContract.blocksPerSubscription = event.params.blocksPerSubscription
predictContract.truevalSubmitTimeoutBlock =
event.params.trueValueSubmitTimeoutBlock
predictContract.secondsPerEpoch = event.params.secondsPerEpoch
predictContract.secondsPerSubscription = event.params.secondsPerSubscription
predictContract.truevalSubmitTimeout = event.params.trueValueSubmitTimeout
const stakeToken = getToken(event.params.stakeToken, false)
predictContract.stakeToken = stakeToken.id
predictContract.save()
@ -178,11 +197,11 @@ export function handleSettingChanged(event: SettingChanged): void {
predictSettingsUpdate.eventIndex = event.logIndex.toI32()
predictSettingsUpdate.timestamp = event.block.timestamp.toI32()
predictSettingsUpdate.predictContract = predictContract.id
predictSettingsUpdate.blocksPerEpoch = event.params.blocksPerEpoch
predictSettingsUpdate.blocksPerSubscription =
event.params.blocksPerSubscription
predictSettingsUpdate.truevalSubmitTimeoutBlock =
event.params.trueValueSubmitTimeoutBlock
predictSettingsUpdate.secondsPerEpoch = event.params.secondsPerEpoch
predictSettingsUpdate.secondsPerSubscription =
event.params.secondsPerSubscription
predictSettingsUpdate.truevalSubmitTimeout =
event.params.trueValueSubmitTimeout
predictSettingsUpdate.stakeToken = stakeToken.id
predictSettingsUpdate.save()
}
@ -190,15 +209,14 @@ export function handleSettingChanged(event: SettingChanged): void {
export function handleRevenueAdded(event: RevenueAdded): void {
/*
for (uint256 i = 0; i < num_epochs; i++) {
// TODO FIND A WAY TO ACHIEVE THIS WITHOUT A LOOP
subscriptionRevenueAtBlock[
slot + blocksPerEpoch * (i)
slot + secondsPerEpoch * (i)
] += amt_per_epoch;
}
emit RevenueAdded(amount,slot,amt_per_epoch,num_epochs,blocksPerEpoch);
emit RevenueAdded(amount,slot,amt_per_epoch,num_epochs,secondsPerEpoch);
*/
const numEpochs = event.params.numEpochs
const blocksPerEpoch = event.params.blocksPerEpoch
const secondsPerEpoch = event.params.secondsPerEpoch
let decimals = 18
const predictContract = getPredictContract(event.address)
if (predictContract.stakeToken) {
@ -214,7 +232,7 @@ export function handleRevenueAdded(event: RevenueAdded): void {
)
const slot = event.params.slot
for (let i = BigInt.zero(); i.lt(numEpochs); i = i.plus(BigInt.fromI32(1))) {
const targetSlot = slot.plus(blocksPerEpoch.times(i))
const targetSlot = slot.plus(secondsPerEpoch.times(i))
const predictSlot = getPredictSlot(event.address.toHexString(), targetSlot)
predictSlot.revenue = predictSlot.revenue.plus(amountPerEpoch)
predictSlot.save()

View File

@ -134,9 +134,9 @@ export function createPredictContract(address: Address): PredictContract {
const predictContract = new PredictContract(address.toHexString())
const token = getToken(address, true)
predictContract.token = token.id
predictContract.blocksPerEpoch = BigInt.zero()
predictContract.blocksPerSubscription = BigInt.zero()
predictContract.truevalSubmitTimeoutBlock = BigInt.zero()
predictContract.secondsPerEpoch = BigInt.zero()
predictContract.secondsPerSubscription = BigInt.zero()
predictContract.truevalSubmitTimeout = BigInt.zero()
predictContract.stakeToken = null
predictContract.txId = ''
predictContract.timestamp = 0

View File

@ -68,7 +68,7 @@ templates:
- ERC20Template3
abis:
- name: ERC20Template3
file: ./abis/ERC20Template3.json
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template3.sol/ERC20Template3.json
- name: ERC20
file: ./abis/ERC20.json
- name: ERC20Roles
@ -80,7 +80,7 @@ templates:
handler: handlePredictionPayout
- event: NewSubscription(indexed address,uint256,uint256)
handler: handleNewSubscription
- event: TruevalSubmitted(indexed uint256,bool,uint256,uint8)
- event: TruevalSubmitted(indexed uint256,bool,uint256,uint8,uint256,uint256)
handler: handleTruevalSubmitted
- event: SettingChanged(uint256,uint256,uint256,address)
handler: handleSettingChanged