Compare commits
33 Commits
Author | SHA1 | Date |
---|---|---|
dependabot[bot] | 2f322ee016 | |
dependabot[bot] | ecc9092f5b | |
dependabot[bot] | ae1a33755f | |
dependabot[bot] | 63bc3f8409 | |
dependabot[bot] | b9bfe07a92 | |
Alex Coseru | d80ba60637 | |
dependabot[bot] | 4e939c70c0 | |
Alex Coseru | ba5e514ddf | |
alexcos20 | 8930eef827 | |
Alex Coseru | 36ae877984 | |
alexcos20 | cf58c9aae4 | |
Alex Coseru | 8bc4dab920 | |
dependabot[bot] | fc07962311 | |
dependabot[bot] | 0077cfa69f | |
dependabot[bot] | 90ad128bc2 | |
dependabot[bot] | 0880f714b0 | |
dependabot[bot] | 7ee41bc29b | |
dependabot[bot] | 957db42e59 | |
dependabot[bot] | db6c3eeeea | |
alexcos20 | 329ea980b6 | |
Alex Coseru | c6004336ae | |
Alex Coseru | 87e42fd6ce | |
alexcos20 | f5b5400261 | |
Alex Coseru | aeef30129a | |
Alex Coseru | 299d196162 | |
Alex Coseru | fa58272978 | |
Alex Coseru | bc56752f3c | |
dependabot[bot] | ab62f18c3e | |
alexcos20 | a62a4c189d | |
Alex Coseru | 39a1210c82 | |
dependabot[bot] | ae9c371e8f | |
dependabot[bot] | 86cc7f0608 | |
dependabot[bot] | b412d2b0b6 |
|
@ -37,8 +37,6 @@ jobs:
|
|||
with:
|
||||
repository: 'oceanprotocol/barge'
|
||||
path: 'barge'
|
||||
ref: main
|
||||
|
||||
- name: Login to Docker Hub
|
||||
if: ${{ env.DOCKERHUB_PASSWORD && env.DOCKERHUB_USERNAME }}
|
||||
run: |
|
||||
|
@ -51,8 +49,6 @@ jobs:
|
|||
working-directory: ${{ github.workspace }}/barge
|
||||
run: |
|
||||
bash -x start_ocean.sh --with-thegraph --skip-subgraph-deploy --no-dashboard 2>&1 > start_ocean.log &
|
||||
env:
|
||||
CONTRACTS_VERSION: v1.1.7
|
||||
|
||||
- run: npm ci
|
||||
|
||||
|
@ -74,6 +70,6 @@ jobs:
|
|||
env:
|
||||
ADDRESS_FILE: /home/runner/.ocean/ocean-contracts/artifacts/address.json
|
||||
BARGE_FOLDER: /home/runner/.ocean/
|
||||
- name: docker logs
|
||||
- name: docker logs
|
||||
run: docker logs ocean_graph-node_1
|
||||
if: ${{ failure() }}
|
||||
|
|
50
CHANGELOG.md
50
CHANGELOG.md
|
@ -4,8 +4,57 @@ 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).
|
||||
|
||||
#### [v4.0.2](https://github.com/oceanprotocol/ocean-subgraph/compare/v4.0.1...v4.0.2)
|
||||
|
||||
- fix deps [`#744`](https://github.com/oceanprotocol/ocean-subgraph/pull/744)
|
||||
|
||||
#### [v4.0.1](https://github.com/oceanprotocol/ocean-subgraph/compare/v4.0.0...v4.0.1)
|
||||
|
||||
> 22 November 2023
|
||||
|
||||
- Feature/add_optimism & use graph-node 0.33.0 [`#742`](https://github.com/oceanprotocol/ocean-subgraph/pull/742)
|
||||
- Bump chai and @types/chai [`#729`](https://github.com/oceanprotocol/ocean-subgraph/pull/729)
|
||||
- Bump @graphprotocol/graph-cli from 0.56.0 to 0.61.0 [`#738`](https://github.com/oceanprotocol/ocean-subgraph/pull/738)
|
||||
- Bump crypto-js from 4.1.1 to 4.2.0 [`#733`](https://github.com/oceanprotocol/ocean-subgraph/pull/733)
|
||||
- Bump release-it from 15.11.0 to 17.0.0 [`#737`](https://github.com/oceanprotocol/ocean-subgraph/pull/737)
|
||||
- Bump minimist from 1.2.5 to 1.2.6 [`#740`](https://github.com/oceanprotocol/ocean-subgraph/pull/740)
|
||||
- Bump tar from 4.4.13 to 4.4.19 [`#741`](https://github.com/oceanprotocol/ocean-subgraph/pull/741)
|
||||
- Bump @graphprotocol/graph-ts from 0.30.0 to 0.31.0 [`#730`](https://github.com/oceanprotocol/ocean-subgraph/pull/730)
|
||||
- Release 4.0.1 [`cf58c9a`](https://github.com/oceanprotocol/ocean-subgraph/commit/cf58c9aae4aa16f7a30b4c93de72786b1d4b3b3f)
|
||||
|
||||
### [v4.0.0](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.10...v4.0.0)
|
||||
|
||||
> 21 November 2023
|
||||
|
||||
- Predictoor support [`#678`](https://github.com/oceanprotocol/ocean-subgraph/pull/678)
|
||||
- bump deps [`#725`](https://github.com/oceanprotocol/ocean-subgraph/pull/725)
|
||||
- Release 4.0.0 [`329ea98`](https://github.com/oceanprotocol/ocean-subgraph/commit/329ea980b628417652de8a444808ba7f470515c8)
|
||||
|
||||
#### [v3.0.10](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.9...v3.0.10)
|
||||
|
||||
> 15 August 2023
|
||||
|
||||
- Bump to graphnode 0.28.2 [`#702`](https://github.com/oceanprotocol/ocean-subgraph/pull/702)
|
||||
- Template id detection [`#705`](https://github.com/oceanprotocol/ocean-subgraph/pull/705)
|
||||
- reduce docker siz [`#709`](https://github.com/oceanprotocol/ocean-subgraph/pull/709)
|
||||
- Create README.md [`#698`](https://github.com/oceanprotocol/ocean-subgraph/pull/698)
|
||||
- Bump word-wrap from 1.2.3 to 1.2.4 [`#701`](https://github.com/oceanprotocol/ocean-subgraph/pull/701)
|
||||
- Release 3.0.10 [`f5b5400`](https://github.com/oceanprotocol/ocean-subgraph/commit/f5b540026106cdaddfdfb1ba1edce0cc1eb333fc)
|
||||
|
||||
#### [v3.0.9](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.8...v3.0.9)
|
||||
|
||||
> 4 July 2023
|
||||
|
||||
- bump to latest contracts [`#695`](https://github.com/oceanprotocol/ocean-subgraph/pull/695)
|
||||
- Bump release-it from 15.10.3 to 15.11.0 [`#688`](https://github.com/oceanprotocol/ocean-subgraph/pull/688)
|
||||
- Bump mock-local-storage from 1.1.23 to 1.1.24 [`#683`](https://github.com/oceanprotocol/ocean-subgraph/pull/683)
|
||||
- Bump vm2 from 3.9.17 to 3.9.18 [`#681`](https://github.com/oceanprotocol/ocean-subgraph/pull/681)
|
||||
- Release 3.0.9 [`a62a4c1`](https://github.com/oceanprotocol/ocean-subgraph/commit/a62a4c189ddd5f712acb62a683dec1c9c8e067b9)
|
||||
|
||||
#### [v3.0.8](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.7...v3.0.8)
|
||||
|
||||
> 16 May 2023
|
||||
|
||||
- Bump @graphprotocol/graph-ts from 0.29.3 to 0.30.0 [`#680`](https://github.com/oceanprotocol/ocean-subgraph/pull/680)
|
||||
- Bump cross-fetch from 3.1.5 to 3.1.6 [`#679`](https://github.com/oceanprotocol/ocean-subgraph/pull/679)
|
||||
- Add lockedAmount to veDelegation [`#672`](https://github.com/oceanprotocol/ocean-subgraph/pull/672)
|
||||
|
@ -14,6 +63,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|||
- Bump @types/chai from 4.3.4 to 4.3.5 [`#669`](https://github.com/oceanprotocol/ocean-subgraph/pull/669)
|
||||
- Bump release-it from 15.10.1 to 15.10.2 [`#668`](https://github.com/oceanprotocol/ocean-subgraph/pull/668)
|
||||
- Fix #628 & #629 & #621: Store event log index for all records (#630) [`#628`](https://github.com/oceanprotocol/ocean-subgraph/issues/628)
|
||||
- Release 3.0.8 [`207a4ac`](https://github.com/oceanprotocol/ocean-subgraph/commit/207a4ac806d0f7817ac7f2f4ace5d3c2160ad64c)
|
||||
|
||||
#### [v3.0.7](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.6...v3.0.7)
|
||||
|
||||
|
|
21
Dockerfile
21
Dockerfile
|
@ -1,9 +1,24 @@
|
|||
FROM node:16
|
||||
|
||||
FROM ubuntu:20.04 as base
|
||||
RUN apt-get update && apt-get -y install bash curl
|
||||
RUN curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh
|
||||
RUN bash /tmp/nodesource_setup.sh
|
||||
RUN apt install nodejs
|
||||
|
||||
|
||||
|
||||
FROM base as builder
|
||||
RUN apt-get update && apt-get -y install wget
|
||||
COPY package*.json /usr/src/app/
|
||||
WORKDIR /usr/src/app
|
||||
RUN npm install
|
||||
WORKDIR /usr/src/app/
|
||||
ENV NODE_ENV=production
|
||||
RUN npm ci
|
||||
|
||||
|
||||
FROM base as runner
|
||||
ENV NODE_ENV=production
|
||||
COPY . /usr/src/app
|
||||
WORKDIR /usr/src/app/
|
||||
COPY --from=builder /usr/src/app/node_modules/ /usr/src/app/node_modules/
|
||||
ENV DEPLOY_SUBGRAPH=true
|
||||
ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
|
|
@ -35,7 +35,6 @@ This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/`
|
|||
- [v4.subgraph.bsc.oceanprotocol.com](https://v4.subgraph.bsc.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [v4.subgraph.moonriver.oceanprotocol.com](https://v4.subgraph.moonriver.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [v4.subgraph.energyweb.oceanprotocol.com](https://v4.subgraph.energyweb.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [v4.subgraph.goerli.oceanprotocol.com](https://v4.subgraph.goerli.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
- [v4.subgraph.mumbai.oceanprotocol.com](https://v4.subgraph.mumbai.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||
|
||||
## ⛵ Example Queries
|
||||
|
|
|
@ -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": {}
|
||||
}
|
|
@ -0,0 +1,657 @@
|
|||
<!--
|
||||
Copyright 2023 Ocean Protocol Foundation
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
-->
|
||||
|
||||
- [Kubernetes deployment](#kubernetes-deployment)
|
||||
- [Postgresql](#postgresql)
|
||||
- [IPFS](#ipfs)
|
||||
- [Graph-node](#graph-node)
|
||||
- [Docker Compose deployment](#docker-compose-deployment)
|
||||
- [Single systemd service (Graph-node+Postgresql+IPFS)](#single-systemd-service-graph-nodepostgresqlipfs)
|
||||
- [Ocean-subgraph deployment](#ocean-subgraph-deployment)
|
||||
|
||||
#### Kubernetes deployment
|
||||
|
||||
[ocean-subgraph](https://github.com/oceanprotocol/ocean-subgraph) must be deployed on top of [graph-node](https://github.com/graphprotocol/graph-node) which has the following dependencies:
|
||||
|
||||
- PostgreSQL
|
||||
|
||||
- IPFS
|
||||
|
||||
Templates (yaml files) provided and could be customized based on the environment's specifics.
|
||||
|
||||
##### Postgresql
|
||||
|
||||
It is recommended to deploy PostgreSQL as helm chart
|
||||
|
||||
References: https://github.com/bitnami/charts/tree/main/bitnami/postgresql/#installing-the-chart
|
||||
|
||||
Once PostgreSQL pods are running, a database must be created: eg. `mumbai`
|
||||
|
||||
##### IPFS
|
||||
|
||||
The following template can be customized to deploy IPFS statefulset and service:
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
labels:
|
||||
app: ipfs
|
||||
name: ipfs
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: ipfs
|
||||
serviceName: ipfs
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app: ipfs
|
||||
spec:
|
||||
containers:
|
||||
- image: ipfs/go-ipfs:v0.4.22
|
||||
imagePullPolicy: IfNotPresent
|
||||
livenessProbe:
|
||||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /debug/metrics/prometheus
|
||||
port: api
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 3
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
name: s1-ipfs
|
||||
ports:
|
||||
- containerPort: 5001
|
||||
name: api
|
||||
protocol: TCP
|
||||
- containerPort: 8080
|
||||
name: gateway
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /debug/metrics/prometheus
|
||||
port: api
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 3
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
volumeMounts:
|
||||
- mountPath: /data/ipfs
|
||||
name: ipfs-storage
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext:
|
||||
fsGroup: 1000
|
||||
runAsUser: 1000
|
||||
terminationGracePeriodSeconds: 30
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
type: RollingUpdate
|
||||
volumeClaimTemplates:
|
||||
- apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: ipfs-storage
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1G
|
||||
volumeMode: Filesystem
|
||||
status:
|
||||
phase: Pending
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: ipfs
|
||||
name: ipfs
|
||||
spec:
|
||||
clusterIP:
|
||||
clusterIPs:
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
ipFamilyPolicy: SingleStack
|
||||
ports:
|
||||
- name: api
|
||||
port: 5001
|
||||
- name: gateway
|
||||
port: 8080
|
||||
selector:
|
||||
app: ipfs
|
||||
```
|
||||
|
||||
##### Graph-node
|
||||
|
||||
The following annotated templated can be customized to deploy graph-node deployment and service:
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
labels:
|
||||
app: mumbai-graph-node
|
||||
name: mumbai-graph-node
|
||||
spec:
|
||||
progressDeadlineSeconds: 600
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mumbai-graph-node
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 25%
|
||||
maxUnavailable: 25%
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app: mumbai-graph-node
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- name: ipfs
|
||||
value: ipfs.<namespace>.svc.cluster.local:5001
|
||||
- name: postgres_host
|
||||
value: postgresql.<namespace>.svc.cluster.local
|
||||
- name: postgres_user
|
||||
value: < postgresql user >
|
||||
- name: postgres_pass
|
||||
value: < postgresql database password >
|
||||
- name: postgres_db
|
||||
value: < postgresql database >
|
||||
- name: ethereum
|
||||
value: mumbai:https://polygon-mumbai.infura.io/v3/< INFURA ID>
|
||||
- name: GRAPH_KILL_IF_UNRESPONSIVE
|
||||
value: 'true'
|
||||
image: graphprotocol/graph-node:v0.28.2
|
||||
imagePullPolicy: IfNotPresent
|
||||
livenessProbe:
|
||||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8000
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
name: mumbai-graph-node
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
name: graphql
|
||||
protocol: TCP
|
||||
- containerPort: 8020
|
||||
name: jsonrpc
|
||||
protocol: TCP
|
||||
- containerPort: 8030
|
||||
name: indexnode
|
||||
protocol: TCP
|
||||
- containerPort: 8040
|
||||
name: metrics
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8000
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
resources:
|
||||
limits:
|
||||
cpu: '2'
|
||||
memory: 1536Mi
|
||||
requests:
|
||||
cpu: 1500m
|
||||
memory: 1536Mi
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
terminationGracePeriodSeconds: 30
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: mumbai-graph-node
|
||||
name: mumbai-graph-node
|
||||
spec:
|
||||
clusterIP:
|
||||
clusterIPs:
|
||||
internalTrafficPolicy: Cluster
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
ipFamilyPolicy: SingleStack
|
||||
ports:
|
||||
- name: graphql
|
||||
port: 8000
|
||||
- name: jsonrpc
|
||||
port: 8020
|
||||
- name: indexnode
|
||||
port: 8030
|
||||
- name: metrics
|
||||
port: 8040
|
||||
selector:
|
||||
app: mumbai-graph-node
|
||||
```
|
||||
|
||||
#### Docker Compose deployment
|
||||
|
||||
##### Single systemd service (Graph-node+Postgresql+IPFS)
|
||||
|
||||
a) create _/etc/docker/compose/graph-node/docker-compose.yml_ file
|
||||
|
||||
_/etc/docker/compose/graph-node/docker-compose.yml_ (annotated - example for `mumbai` network)
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
services:
|
||||
graph-node:
|
||||
image: graphprotocol/graph-node:v0.28.2
|
||||
container_name: graph-node
|
||||
restart: on-failure
|
||||
ports:
|
||||
- '8000:8000'
|
||||
- '8020:8020'
|
||||
- '8030:8030'
|
||||
- '8040:8040'
|
||||
depends_on:
|
||||
- ipfs
|
||||
- postgres-graph
|
||||
environment:
|
||||
postgres_host: postgres-graph
|
||||
postgres_user: graph-node
|
||||
postgres_pass: < password >
|
||||
postgres_db: mumbai
|
||||
ipfs: 'ipfs:5001'
|
||||
ethereum: 'mumbai:https://polygon-mumbai.infura.io/v3/< INFURA ID >'
|
||||
GRAPH_LOG: info
|
||||
ipfs:
|
||||
image: ipfs/go-ipfs:v0.4.23
|
||||
container_name: ipfs
|
||||
restart: on-failure
|
||||
ports:
|
||||
- '5001:5001'
|
||||
volumes:
|
||||
- ipfs-graph-node:/data/ipfs
|
||||
postgres-graph:
|
||||
image: postgres:15.3
|
||||
container_name: postgres
|
||||
restart: on-failure
|
||||
ports:
|
||||
- '5432:5432'
|
||||
command: ['postgres', '-cshared_preload_libraries=pg_stat_statements']
|
||||
environment:
|
||||
POSTGRES_USER: graph-node
|
||||
POSTGRES_PASSWORD: < password >
|
||||
POSTGRES_DB: mumbai
|
||||
volumes:
|
||||
- pgdata-graph-node:/var/lib/postgresql/data
|
||||
volumes:
|
||||
pgdata-graph-node:
|
||||
driver: local
|
||||
ipfs-graph-node:
|
||||
driver: local
|
||||
```
|
||||
|
||||
b) create _/etc/systemd/system/docker-compose@graph-node.service_ file
|
||||
|
||||
```shell
|
||||
[Unit]
|
||||
Description=%i service with docker compose
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
Environment="PROJECT=ocean"
|
||||
WorkingDirectory=/etc/docker/compose/%i
|
||||
ExecStartPre=/usr/bin/env docker-compose -p $PROJECT pull
|
||||
ExecStart=/usr/bin/env docker-compose -p $PROJECT up -d
|
||||
ExecStop=/usr/bin/env docker-compose -p $PROJECT stop
|
||||
ExecStopPost=/usr/bin/env docker-compose -p $PROJECT down
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
c) run:
|
||||
|
||||
```shell
|
||||
$ sudo systemctl daemon-reload
|
||||
```
|
||||
|
||||
optional - enable service to start at boot:
|
||||
|
||||
```shell
|
||||
$ sudo systemctl enable docker-compose@graph-node.service
|
||||
```
|
||||
|
||||
d) start aquarius service:
|
||||
|
||||
```shell
|
||||
$ sudo systemctl start docker-compose@graph-node.service
|
||||
```
|
||||
|
||||
check status:
|
||||
|
||||
```shell
|
||||
$ sudo systemctl status docker-compose@graph-node.service
|
||||
● docker-compose@graph-node.service - graph-node service with docker compose
|
||||
Loaded: loaded (/etc/systemd/system/docker-compose@graph-node.service; disabled; vendor preset: enabled)
|
||||
Active: active (exited) since Sun 2023-06-25 17:05:25 UTC; 6s ago
|
||||
Process: 4878 ExecStartPre=/usr/bin/env docker-compose -p $PROJECT pull (code=exited, status=0/SUCCESS)
|
||||
Process: 4887 ExecStart=/usr/bin/env docker-compose -p $PROJECT up -d (code=exited, status=0/SUCCESS)
|
||||
Main PID: 4887 (code=exited, status=0/SUCCESS)
|
||||
CPU: 123ms
|
||||
|
||||
Jun 25 17:05:24 testvm env[4887]: Container ipfs Created
|
||||
Jun 25 17:05:24 testvm env[4887]: Container graph-node Creating
|
||||
Jun 25 17:05:24 testvm env[4887]: Container graph-node Created
|
||||
Jun 25 17:05:24 testvm env[4887]: Container ipfs Starting
|
||||
Jun 25 17:05:24 testvm env[4887]: Container postgres Starting
|
||||
Jun 25 17:05:24 testvm env[4887]: Container ipfs Started
|
||||
Jun 25 17:05:25 testvm env[4887]: Container postgres Started
|
||||
Jun 25 17:05:25 testvm env[4887]: Container graph-node Starting
|
||||
Jun 25 17:05:25 testvm env[4887]: Container graph-node Started
|
||||
Jun 25 17:05:25 testvm systemd[1]: Finished graph-node service with docker compose.
|
||||
|
||||
```
|
||||
|
||||
- check containers status
|
||||
|
||||
```shell
|
||||
$ docker ps --format "table {{.Image}}\t{{.Ports}}\t{{.Names}}\t{{.Status}}"
|
||||
IMAGE PORTS NAMES STATUS
|
||||
graphprotocol/graph-node:v0.28.2 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:8020->8020/tcp, :::8020->8020/tcp, 0.0.0.0:8030->8030/tcp, :::8030->8030/tcp, 0.0.0.0:8040->8040/tcp, :::8040->8040/tcp, 8001/tcp graph-node Up 55 minutes
|
||||
ipfs/go-ipfs:v0.4.23 4001/tcp, 8080-8081/tcp, 0.0.0.0:5001->5001/tcp, :::5001->5001/tcp ipfs Up 55 minutes
|
||||
postgres:15.3 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp postgres Up 55 minutes
|
||||
```
|
||||
|
||||
- check logs for graph-node container
|
||||
|
||||
```shell
|
||||
$ docker logs graph-node [--follow]
|
||||
```
|
||||
|
||||
#### Ocean-subgraph deployment
|
||||
|
||||
- install Node.js locally
|
||||
|
||||
- download and extract [Ocean-subgraph](https://github.com/oceanprotocol/ocean-subgraph) (check [here](https://github.com/oceanprotocol/ocean-subgraph/releases) the available releases)
|
||||
- run inside the extracted directory:
|
||||
|
||||
```shell
|
||||
$ npm i
|
||||
```
|
||||
|
||||
then
|
||||
|
||||
(Note: in this example we are deploying on graph-node running for `mumbai` testnet )
|
||||
|
||||
Note: for `ocean-subgraph` deployment in kubernetes environment, both `graph-node` and `ipfs` services must be locally forwarded using `kubectl port-forward` command.
|
||||
|
||||
```shell
|
||||
$ npm run quickstart:mumbai
|
||||
|
||||
> ocean-subgraph@3.0.8 quickstart:mumbai
|
||||
> node ./scripts/generatenetworkssubgraphs.js mumbai && npm run codegen && npm run create:local && npm run deploy:local
|
||||
|
||||
Creating subgraph.yaml for mumbai
|
||||
Adding veOCEAN
|
||||
Skipping polygon
|
||||
Skipping bsc
|
||||
Skipping energyweb
|
||||
Skipping moonriver
|
||||
Skipping mainnet
|
||||
Skipping polygonedge
|
||||
Skipping gaiaxtestnet
|
||||
Skipping alfajores
|
||||
Skipping gen-x-testnet
|
||||
Skipping filecointestnet
|
||||
|
||||
> ocean-subgraph@3.0.8 codegen
|
||||
> graph codegen --output-dir src/@types
|
||||
|
||||
Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
|
||||
Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
|
||||
Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
|
||||
Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
|
||||
Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
|
||||
Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
|
||||
Apply migration: Bump manifest specVersion from 0.0.2 to 0.0.4
|
||||
✔ Apply migrations
|
||||
✔ Load subgraph from subgraph.yaml
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json
|
||||
Load contract ABI from abis/ERC20.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json
|
||||
Load contract ABI from abis/ERC20.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json
|
||||
Load contract ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json
|
||||
✔ Load contract ABIs
|
||||
Generate types for contract ABI: ERC721Factory (node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json)
|
||||
Write types to src/@types/ERC721Factory/ERC721Factory.ts
|
||||
Generate types for contract ABI: ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/ERC721Factory/ERC20.ts
|
||||
Generate types for contract ABI: FactoryRouter (node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json)
|
||||
Write types to src/@types/FactoryRouter/FactoryRouter.ts
|
||||
Generate types for contract ABI: ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/FactoryRouter/ERC20.ts
|
||||
Generate types for contract ABI: veAllocate (node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json)
|
||||
Write types to src/@types/veAllocate/veAllocate.ts
|
||||
Generate types for contract ABI: veOCEAN (node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json)
|
||||
Write types to src/@types/veOCEAN/veOCEAN.ts
|
||||
Generate types for contract ABI: veDelegation (node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json)
|
||||
Write types to src/@types/veDelegation/veDelegation.ts
|
||||
Generate types for contract ABI: veFeeDistributor (node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json)
|
||||
Write types to src/@types/veFeeDistributor/veFeeDistributor.ts
|
||||
Generate types for contract ABI: DFRewards (node_modules/@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json)
|
||||
Write types to src/@types/DFRewards/DFRewards.ts
|
||||
✔ Generate types for contract ABIs
|
||||
Generate types for data source template ERC20Template
|
||||
Generate types for data source template ERC721Template
|
||||
Generate types for data source template Dispenser
|
||||
Generate types for data source template FixedRateExchange
|
||||
Write types for templates to src/@types/templates.ts
|
||||
✔ Generate types for data source templates
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json
|
||||
Load data source template ABI from abis/ERC20.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC20Roles.sol/ERC20Roles.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC721RolesAddress.sol/ERC721RolesAddress.json
|
||||
Load data source template ABI from abis/ERC20.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json
|
||||
Load data source template ABI from abis/ERC20.json
|
||||
Load data source template ABI from node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json
|
||||
Load data source template ABI from abis/ERC20.json
|
||||
✔ Load data source template ABIs
|
||||
Generate types for data source template ABI: ERC20Template > ERC20Template (node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json)
|
||||
Write types to src/@types/templates/ERC20Template/ERC20Template.ts
|
||||
Generate types for data source template ABI: ERC20Template > ERC20TemplateEnterprise (node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json)
|
||||
Write types to src/@types/templates/ERC20Template/ERC20TemplateEnterprise.ts
|
||||
Generate types for data source template ABI: ERC20Template > ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/templates/ERC20Template/ERC20.ts
|
||||
Generate types for data source template ABI: ERC20Template > ERC20Roles (node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC20Roles.sol/ERC20Roles.json)
|
||||
Write types to src/@types/templates/ERC20Template/ERC20Roles.ts
|
||||
Generate types for data source template ABI: ERC721Template > ERC721Template (node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json)
|
||||
Write types to src/@types/templates/ERC721Template/ERC721Template.ts
|
||||
Generate types for data source template ABI: ERC721Template > ERC721RolesAddress (node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC721RolesAddress.sol/ERC721RolesAddress.json)
|
||||
Write types to src/@types/templates/ERC721Template/ERC721RolesAddress.ts
|
||||
Generate types for data source template ABI: ERC721Template > ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/templates/ERC721Template/ERC20.ts
|
||||
Generate types for data source template ABI: Dispenser > Dispenser (node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json)
|
||||
Write types to src/@types/templates/Dispenser/Dispenser.ts
|
||||
Generate types for data source template ABI: Dispenser > ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/templates/Dispenser/ERC20.ts
|
||||
Generate types for data source template ABI: FixedRateExchange > FixedRateExchange (node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json)
|
||||
Write types to src/@types/templates/FixedRateExchange/FixedRateExchange.ts
|
||||
Generate types for data source template ABI: FixedRateExchange > ERC20 (abis/ERC20.json)
|
||||
Write types to src/@types/templates/FixedRateExchange/ERC20.ts
|
||||
✔ Generate types for data source template ABIs
|
||||
✔ Load GraphQL schema from schema.graphql
|
||||
Write types to src/@types/schema.ts
|
||||
✔ Generate types for GraphQL schema
|
||||
|
||||
Types generated successfully
|
||||
|
||||
|
||||
> ocean-subgraph@3.0.8 create:local
|
||||
> graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020
|
||||
|
||||
Created subgraph: oceanprotocol/ocean-subgraph
|
||||
|
||||
> ocean-subgraph@3.0.8 deploy:local
|
||||
> graph deploy oceanprotocol/ocean-subgraph subgraph.yaml -l $npm_package_version --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020
|
||||
|
||||
Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
|
||||
Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
|
||||
Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
|
||||
Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
|
||||
Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
|
||||
Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
|
||||
Skip migration: Bump manifest specVersion from 0.0.2 to 0.0.4
|
||||
✔ Apply migrations
|
||||
✔ Load subgraph from subgraph.yaml
|
||||
Compile data source: ERC721Factory => build/ERC721Factory/ERC721Factory.wasm
|
||||
Compile data source: FactoryRouter => build/FactoryRouter/FactoryRouter.wasm
|
||||
Compile data source: veAllocate => build/veAllocate/veAllocate.wasm
|
||||
Compile data source: veOCEAN => build/veOCEAN/veOCEAN.wasm
|
||||
Compile data source: veDelegation => build/veDelegation/veDelegation.wasm
|
||||
Compile data source: veFeeDistributor => build/veFeeDistributor/veFeeDistributor.wasm
|
||||
Compile data source: DFRewards => build/DFRewards/DFRewards.wasm
|
||||
Compile data source template: ERC20Template => build/templates/ERC20Template/ERC20Template.wasm
|
||||
Compile data source template: ERC721Template => build/templates/ERC721Template/ERC721Template.wasm
|
||||
Compile data source template: Dispenser => build/templates/Dispenser/Dispenser.wasm
|
||||
Compile data source template: FixedRateExchange => build/templates/FixedRateExchange/FixedRateExchange.wasm
|
||||
✔ Compile subgraph
|
||||
Copy schema file build/schema.graphql
|
||||
Write subgraph file build/ERC721Factory/node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json
|
||||
Write subgraph file build/ERC721Factory/abis/ERC20.json
|
||||
Write subgraph file build/FactoryRouter/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json
|
||||
Write subgraph file build/FactoryRouter/abis/ERC20.json
|
||||
Write subgraph file build/veAllocate/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json
|
||||
Write subgraph file build/veOCEAN/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json
|
||||
Write subgraph file build/veDelegation/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json
|
||||
Write subgraph file build/veFeeDistributor/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json
|
||||
Write subgraph file build/DFRewards/node_modules/@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json
|
||||
Write subgraph file build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json
|
||||
Write subgraph file build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json
|
||||
Write subgraph file build/ERC20Template/abis/ERC20.json
|
||||
Write subgraph file build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC20Roles.sol/ERC20Roles.json
|
||||
Write subgraph file build/ERC721Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json
|
||||
Write subgraph file build/ERC721Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC721RolesAddress.sol/ERC721RolesAddress.json
|
||||
Write subgraph file build/ERC721Template/abis/ERC20.json
|
||||
Write subgraph file build/Dispenser/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json
|
||||
Write subgraph file build/Dispenser/abis/ERC20.json
|
||||
Write subgraph file build/FixedRateExchange/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json
|
||||
Write subgraph file build/FixedRateExchange/abis/ERC20.json
|
||||
Write subgraph manifest build/subgraph.yaml
|
||||
✔ Write compiled subgraph to build/
|
||||
Add file to IPFS build/schema.graphql
|
||||
.. QmQa3a9ypCLC84prHGQdhbcGG4DHJceqADGxmZMmAAXuTz
|
||||
Add file to IPFS build/ERC721Factory/node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json
|
||||
.. QmSoG3r5vyWXqjEfKAQYjwtQcQkZCsZEcJXVFWVq1tT1dD
|
||||
Add file to IPFS build/ERC721Factory/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2
|
||||
Add file to IPFS build/FactoryRouter/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json
|
||||
.. QmcBVA1R3yi2167UZMvV4LvG4cMHjL8ZZXmPMriCjn8DEe
|
||||
Add file to IPFS build/FactoryRouter/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2 (already uploaded)
|
||||
Add file to IPFS build/veAllocate/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json
|
||||
.. Qmc3iwQkQAhqe1PjzTt6KZLh9rsWQvyxkFt7doj2iXv8C3
|
||||
Add file to IPFS build/veOCEAN/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json
|
||||
.. QmahFjirJqiwKpytFZ9CdE92LdPGBUDZs6AWpsrH2wn1VP
|
||||
Add file to IPFS build/veDelegation/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json
|
||||
.. QmfU6kZ5sksLdj3q88n7SUP63C1cnhQjU8vuMmRYwf2v5r
|
||||
Add file to IPFS build/veFeeDistributor/node_modules/@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json
|
||||
.. QmVU51oBr62D4UFXTwnMcbzuBBAAeQssqmqM9jic7A6L3v
|
||||
Add file to IPFS build/DFRewards/node_modules/@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json
|
||||
.. QmcckRMahzpL7foEFGpWfkDBsyoWbNRfLC32uFq8ceUV3a
|
||||
Add file to IPFS build/ERC721Factory/ERC721Factory.wasm
|
||||
.. QmVfDAgZdKWxMuNfT7kso1LbFre2xhYbEeHBGm3gH3R9oE
|
||||
Add file to IPFS build/FactoryRouter/FactoryRouter.wasm
|
||||
.. QmYCC9AcaYw3nGSqNXNFHVsuB67FQEyZ8twRjRXrprcgyp
|
||||
Add file to IPFS build/veAllocate/veAllocate.wasm
|
||||
.. QmUFaYDxChi5nKEJLvHQZP1cRoqqP5k3fYSwk2JjuSceiJ
|
||||
Add file to IPFS build/veOCEAN/veOCEAN.wasm
|
||||
.. QmRYCyYKwHdSeM55vuvL1mdCooDkFQm6d2TQ7iK2N1qgur
|
||||
Add file to IPFS build/veDelegation/veDelegation.wasm
|
||||
.. QmaTjRLirzfidtQTYgzxqVVD9AX9e69TN1Y8fEsNQ9AEZq
|
||||
Add file to IPFS build/veFeeDistributor/veFeeDistributor.wasm
|
||||
.. QmZCEp4yxiDyuksEjSaceogJwLMto2UGfV1KxVuJTJLTqg
|
||||
Add file to IPFS build/DFRewards/DFRewards.wasm
|
||||
.. QmRSxe52B836bdfoJbuDY4tUCawzqgkHRNxe9ucU1JdYm5
|
||||
Add file to IPFS build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json
|
||||
.. QmPkhFvnBbqA3You7NsK5Zsyh8kkizXUHF9pcC5V6qDJQu
|
||||
Add file to IPFS build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json
|
||||
.. QmZnogwnfr4TeBPykvmCL2oaX63AKQP1F1uBAbbfnyPAzB
|
||||
Add file to IPFS build/ERC20Template/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2 (already uploaded)
|
||||
Add file to IPFS build/ERC20Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC20Roles.sol/ERC20Roles.json
|
||||
.. QmTWTzg4jTx4GxGApVyxirNRTxB7QovS4bHGuWnnW8Ciz2
|
||||
Add file to IPFS build/templates/ERC20Template/ERC20Template.wasm
|
||||
.. QmUcxes5La7n9481Vf9AoQ2Mjt1CrbS7T6tDhpnfF77Uh5
|
||||
Add file to IPFS build/ERC721Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json
|
||||
.. QmPE82CiACicgu1WxEjeFrLmskiJADroQRnxH7owpK6jaP
|
||||
Add file to IPFS build/ERC721Template/node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC721RolesAddress.sol/ERC721RolesAddress.json
|
||||
.. Qmdhi7UK6Ww8vXH9YC3JxVUEFjTyx3XycF53rRZapVK5c3
|
||||
Add file to IPFS build/ERC721Template/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2 (already uploaded)
|
||||
Add file to IPFS build/templates/ERC721Template/ERC721Template.wasm
|
||||
.. QmNhLws24szwpz8LM2sL6HHKc6KK4vtJwzfeZWkghuqn7Q
|
||||
Add file to IPFS build/Dispenser/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json
|
||||
.. QmdiN7Fhw9sjoVVJgHtTtzxv5fwtFMHLNH1x1yqbswsThW
|
||||
Add file to IPFS build/Dispenser/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2 (already uploaded)
|
||||
Add file to IPFS build/templates/Dispenser/Dispenser.wasm
|
||||
.. QmTpn9wagpmH6byjjdCBZdgypFgcw2mva3bC52nC4z3eLW
|
||||
Add file to IPFS build/FixedRateExchange/node_modules/@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json
|
||||
.. Qmd2ToAptK74j8pGxe8mZXfAvY3AxstgmYH8JDMAfLtAGd
|
||||
Add file to IPFS build/FixedRateExchange/abis/ERC20.json
|
||||
.. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2 (already uploaded)
|
||||
Add file to IPFS build/templates/FixedRateExchange/FixedRateExchange.wasm
|
||||
.. QmRrwwoFF33LvPhnGCGgLBLyuLizrFgD44kW9io81tPZzX
|
||||
✔ Upload subgraph to IPFS
|
||||
|
||||
Build completed: QmVUKpgwuyDh9KgUxTzZvVNFJbdevc56YrZpZjQvu8Yp7q
|
||||
|
||||
Deployed to http://127.0.0.1:8000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql
|
||||
|
||||
Subgraph endpoints:
|
||||
Queries (HTTP): http://127.0.0.1:8000/subgraphs/name/oceanprotocol/ocean-subgraph
|
||||
```
|
||||
|
||||
- This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/`
|
||||
|
||||
http://127.0.0.1:8000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql
|
|
@ -6,6 +6,7 @@ echo "deploy subgraph is ${DEPLOY_SUBGRAPH}"
|
|||
|
||||
if [ "${DEPLOY_SUBGRAPH}" = "true" ]
|
||||
then
|
||||
rm -f /ocean-subgraph/ready
|
||||
echo "Waiting for contracts to be deployed"
|
||||
while [ ! -f "/ocean-contracts/artifacts/ready" ]; do
|
||||
sleep 2
|
||||
|
@ -13,5 +14,7 @@ then
|
|||
export ADDRESS_FILE="/ocean-contracts/artifacts/address.json"
|
||||
cd /usr/src/app/
|
||||
npm run quickstart:barge
|
||||
sleep 3
|
||||
touch /ocean-subgraph/ready
|
||||
fi
|
||||
tail -f /dev/null
|
||||
|
|
|
@ -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:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
42
package.json
42
package.json
|
@ -1,12 +1,11 @@
|
|||
{
|
||||
"name": "ocean-subgraph",
|
||||
"version": "3.0.8",
|
||||
"version": "4.0.2",
|
||||
"scripts": {
|
||||
"start": "",
|
||||
"quickstart:development": "node ./scripts/generatenetworkssubgraphs.js development && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:barge": "node ./scripts/generatenetworkssubgraphs.js development && npm run codegen && npm run create:local-barge && npm run deploy:local-barge",
|
||||
"quickstart:rinkeby": "node ./scripts/generatenetworkssubgraphs.js rinkeby && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:goerli": "node ./scripts/generatenetworkssubgraphs.js goerli && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:ropsten": "node ./scripts/generatenetworkssubgraphs.js ropsten && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:mumbai": "node ./scripts/generatenetworkssubgraphs.js mumbai && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:moonbase": "node ./scripts/generatenetworkssubgraphs.js moonbase && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
|
@ -14,15 +13,21 @@
|
|||
"quickstart:mainnet": "node ./scripts/generatenetworkssubgraphs.js mainnet && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:moonriver": "node ./scripts/generatenetworkssubgraphs.js moonriver && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:energyweb": "node ./scripts/generatenetworkssubgraphs.js energyweb && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:sepolia": "node ./scripts/generatenetworkssubgraphs.js sepolia && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:gen-x-testnet": "node ./scripts/generatenetworkssubgraphs.js gen-x-testnet && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:bsc": "node ./scripts/generatenetworkssubgraphs.js bsc && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:oasis_saphire_testnet": "node ./scripts/generatenetworkssubgraphs.js oasis_saphire_testnet && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:oasis_saphire": "node ./scripts/generatenetworkssubgraphs.js oasis_saphire && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:optimism": "node ./scripts/generatenetworkssubgraphs.js optimism && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"quickstart:optimism_sepolia": "node ./scripts/generatenetworkssubgraphs.js optimism_sepolia && npm run codegen && npm run create:local && npm run deploy:local",
|
||||
"create:thegraph": "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-barge": "graph create oceanprotocol/ocean-subgraph --node http://172.15.0.15:8020",
|
||||
"codegen": "graph codegen --output-dir src/@types",
|
||||
"build": "graph build",
|
||||
"deploy:thegraph": "graph deploy oceanprotocol/ocean-subgraph -l $npm_package_version --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
|
||||
"deploy:local": "graph deploy oceanprotocol/ocean-subgraph subgraph.yaml -l $npm_package_version --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
|
||||
"deploy:local-barge": "graph deploy oceanprotocol/ocean-subgraph subgraph.yaml -l $npm_package_version --debug --ipfs http://172.15.0.16:5001 --node http://172.15.0.15:8020",
|
||||
"deploy:local": "graph deploy oceanprotocol/ocean-subgraph subgraph.yaml -l $npm_package_version --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
|
||||
"deploy:local-barge": "graph deploy oceanprotocol/ocean-subgraph subgraph.yaml -l $npm_package_version --ipfs http://172.15.0.16:5001 --node http://172.15.0.15:8020",
|
||||
"test": "npm run codegen && npm run lint && npm run type-check",
|
||||
"test-integration": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/**/*.test.ts'",
|
||||
"test-dispenser": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/Dispenser.test.ts'",
|
||||
|
@ -44,16 +49,16 @@
|
|||
"changelog": "auto-changelog -p"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@graphprotocol/graph-cli": "^0.38.0",
|
||||
"@graphprotocol/graph-ts": "^0.30.0",
|
||||
"@types/chai": "^4.3.5",
|
||||
"@types/chai": "^4.3.11",
|
||||
"@types/chai-spies": "^1.0.3",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||
"@typescript-eslint/parser": "^4.33.0",
|
||||
"@types/mocha": "^10.0.2",
|
||||
"@types/node": "^20.8.2",
|
||||
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
||||
"@typescript-eslint/parser": "^6.19.0",
|
||||
"auto-changelog": "^2.4.0",
|
||||
"chai": "^4.3.7",
|
||||
"chai": "^4.3.10",
|
||||
"chai-spies": "^1.0.0",
|
||||
"cross-fetch": "^3.1.6",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-oceanprotocol": "^2.0.4",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
|
@ -61,21 +66,22 @@
|
|||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"eslint-plugin-standard": "^5.0.0",
|
||||
"ethereumjs-util": "^7.1.5",
|
||||
"mocha": "^10.2.0",
|
||||
"mock-local-storage": "^1.1.23",
|
||||
"mock-local-storage": "^1.1.24",
|
||||
"prettier": "^2.8.8",
|
||||
"release-it": "^15.10.3",
|
||||
"release-it": "^17.0.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": "^5.0.4"
|
||||
"typescript": "^5.4.5",
|
||||
"@oceanprotocol/lib": "^2.7.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@oceanprotocol/contracts": "^1.1.12",
|
||||
"@oceanprotocol/lib": "^2.7.0",
|
||||
"cross-fetch": "^3.1.6",
|
||||
"ethereumjs-util": "^7.1.5"
|
||||
"@oceanprotocol/contracts": "^2.0.3",
|
||||
"@graphprotocol/graph-cli": "^0.71.0",
|
||||
"@graphprotocol/graph-ts": "^0.31.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
148
schema.graphql
148
schema.graphql
|
@ -30,7 +30,7 @@ type Token @entity {
|
|||
publishMarketFeeAmount: BigDecimal
|
||||
|
||||
"template ID of the datatoken"
|
||||
templateId: Int
|
||||
templateId: BigInt!
|
||||
|
||||
"number of addresses holding a balance of datatoken , TODO: can we actually calculate this? what happens when users trade the dts"
|
||||
holderCount: BigInt!
|
||||
|
@ -98,6 +98,9 @@ type Nft @entity{
|
|||
"template address"
|
||||
template: String!
|
||||
|
||||
"template ID of the datatoken"
|
||||
templateId: Int
|
||||
|
||||
"set if NFT is transferable"
|
||||
transferable: Boolean!
|
||||
|
||||
|
@ -400,7 +403,6 @@ type Template @entity{
|
|||
id: ID!
|
||||
fixedRateTemplates: [String!]
|
||||
dispenserTemplates: [String!]
|
||||
ssTemplates: [String!]
|
||||
}
|
||||
|
||||
# Not tracking allocationToId or idToAllocation
|
||||
|
@ -630,3 +632,145 @@ type NftTransferHistory @entity {
|
|||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
type Erc721Template @entity {
|
||||
#ID = template address
|
||||
id: ID!
|
||||
templateId: BigInt!
|
||||
}
|
||||
|
||||
type Erc20Template @entity {
|
||||
#ID = template address
|
||||
id: ID!
|
||||
templateId: BigInt!
|
||||
}
|
||||
|
||||
|
||||
|
||||
type PredictSubscription @entity{
|
||||
"id = {contract address}-{txid}-{eventIndex}"
|
||||
id: ID!
|
||||
predictContract: PredictContract!
|
||||
user: User!
|
||||
expireTime: BigInt!
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
enum PredictSlotStatus {
|
||||
Pending,
|
||||
Paying,
|
||||
Canceled
|
||||
}
|
||||
|
||||
|
||||
type PredictPayout @entity{
|
||||
"id = {contract address}-{slot}-{user}"
|
||||
id: ID!
|
||||
prediction: PredictPrediction!
|
||||
payout: BigDecimal!
|
||||
predictedValue: Boolean!
|
||||
trueValue: Boolean!
|
||||
aggregatedPredictedValue: BigDecimal!
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
type PredictPrediction @entity{
|
||||
"id = {contract address}-{slot}-{user}"
|
||||
id: ID!
|
||||
slot: PredictSlot!
|
||||
user: User!
|
||||
stake: BigDecimal!
|
||||
payout: PredictPayout
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
|
||||
type PredictTrueVal @entity{
|
||||
"id = {contract address}-{slot}"
|
||||
id: ID!
|
||||
slot: PredictSlot!
|
||||
trueValue: Boolean!
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
type PredictionRevenue @entity{
|
||||
"id = {contract address}-{slot}-{txid}-{eventIndex}"
|
||||
id: ID!
|
||||
slot: PredictSlot!
|
||||
amount: BigDecimal!
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
type PredictSlot @entity{
|
||||
"id = {contract address}-{slot}"
|
||||
id: ID!
|
||||
predictContract: PredictContract!
|
||||
slot: Int!
|
||||
predictions:[PredictPrediction!] @derivedFrom(field: "slot")
|
||||
trueValues: [PredictTrueVal!] @derivedFrom(field: "slot")
|
||||
revenue: BigDecimal!
|
||||
revenues: [PredictionRevenue!] @derivedFrom(field: "slot")
|
||||
status: PredictSlotStatus!
|
||||
roundSumStakesUp: BigDecimal!
|
||||
roundSumStakes: BigDecimal!
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
type PredictSettingUpdate @entity{
|
||||
"id = {contract address}-{txId}-{eventIndex}"
|
||||
id: ID!
|
||||
predictContract: PredictContract!
|
||||
secondsPerEpoch: BigInt!
|
||||
secondsPerSubscription: BigInt!
|
||||
truevalSubmitTimeout: BigInt!
|
||||
stakeToken: Token
|
||||
"txId"
|
||||
txId: String
|
||||
eventIndex:Int!
|
||||
timestamp: Int!
|
||||
block: Int!
|
||||
}
|
||||
type PredictContract @entity{
|
||||
"id = {contract address}"
|
||||
id: ID!
|
||||
token: Token!
|
||||
paused: Boolean!
|
||||
slots: [PredictSlot!] @derivedFrom(field: "predictContract")
|
||||
settingUpdates: [PredictSettingUpdate!] @derivedFrom(field: "predictContract")
|
||||
subscriptions: [PredictSubscription!] @derivedFrom(field: "predictContract")
|
||||
secondsPerEpoch: BigInt!
|
||||
secondsPerSubscription: BigInt!
|
||||
truevalSubmitTimeout: BigInt!
|
||||
stakeToken: Token
|
||||
"creation txId"
|
||||
txId: String
|
||||
"timestamp of creation tx"
|
||||
timestamp: Int!
|
||||
"block of creation tx"
|
||||
block: Int!
|
||||
eventIndex: Int!
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,284 @@
|
|||
import {
|
||||
PredictSubscription,
|
||||
PredictPayout,
|
||||
PredictPrediction,
|
||||
PredictTrueVal,
|
||||
PredictSlot,
|
||||
PredictSettingUpdate,
|
||||
PredictionRevenue
|
||||
} from '../@types/schema'
|
||||
import { BigInt, BigDecimal, Address } from '@graphprotocol/graph-ts'
|
||||
|
||||
import {
|
||||
PredictionSubmitted,
|
||||
PredictionPayout,
|
||||
NewSubscription,
|
||||
TruevalSubmitted,
|
||||
SettingChanged,
|
||||
RevenueAdded,
|
||||
Paused
|
||||
} from '../@types/templates/ERC20Template3/ERC20Template3'
|
||||
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
import { getPredictContract, getToken } from './utils/tokenUtils'
|
||||
import { getUser } from './utils/userUtils'
|
||||
|
||||
function getPredictSlot(
|
||||
predictContractAddress: string,
|
||||
slot: i32
|
||||
): PredictSlot {
|
||||
const id = predictContractAddress + '-' + slot.toString()
|
||||
let newPredictSlot = PredictSlot.load(id)
|
||||
if (newPredictSlot === null) {
|
||||
newPredictSlot = new PredictSlot(id)
|
||||
newPredictSlot.predictContract = predictContractAddress
|
||||
newPredictSlot.slot = slot
|
||||
newPredictSlot.revenue = BigDecimal.zero()
|
||||
newPredictSlot.roundSumStakesUp = BigDecimal.zero()
|
||||
newPredictSlot.roundSumStakes = BigDecimal.zero()
|
||||
newPredictSlot.status = 'Pending'
|
||||
newPredictSlot.save()
|
||||
}
|
||||
return newPredictSlot
|
||||
}
|
||||
|
||||
export function handlePredictionSubmitted(event: PredictionSubmitted): void {
|
||||
const predictSlot = getPredictSlot(
|
||||
event.address.toHexString(),
|
||||
event.params.slot.toI32()
|
||||
)
|
||||
const user = getUser(event.params.predictoor.toHex())
|
||||
const id =
|
||||
event.address.toHexString() +
|
||||
'-' +
|
||||
event.params.slot.toString() +
|
||||
'-' +
|
||||
user.id
|
||||
const predictPrediction = new PredictPrediction(id)
|
||||
predictPrediction.slot = predictSlot.id
|
||||
predictPrediction.user = user.id
|
||||
const predictContract = getPredictContract(event.address)
|
||||
let decimals = 18
|
||||
if (predictContract.stakeToken) {
|
||||
const stakeToken = getToken(
|
||||
Address.fromString(predictContract.stakeToken!),
|
||||
false
|
||||
)
|
||||
decimals = stakeToken.decimals
|
||||
}
|
||||
predictPrediction.stake = weiToDecimal(
|
||||
event.params.stake.toBigDecimal(),
|
||||
BigInt.fromI32(decimals).toI32()
|
||||
)
|
||||
predictPrediction.payout = null
|
||||
predictPrediction.block = event.block.number.toI32()
|
||||
predictPrediction.txId = event.transaction.hash.toHexString()
|
||||
predictPrediction.eventIndex = event.logIndex.toI32()
|
||||
predictPrediction.timestamp = event.block.timestamp.toI32()
|
||||
predictPrediction.save()
|
||||
}
|
||||
|
||||
export function handlePredictionPayout(event: PredictionPayout): void {
|
||||
const user = getUser(event.params.predictoor.toHex())
|
||||
const predictionId =
|
||||
event.address.toHexString() +
|
||||
'-' +
|
||||
event.params.slot.toString() +
|
||||
'-' +
|
||||
user.id
|
||||
const predictPrediction = PredictPrediction.load(predictionId)
|
||||
if (!predictPrediction) return
|
||||
const predictionPayout = new PredictPayout(predictionId)
|
||||
predictionPayout.prediction = predictPrediction.id
|
||||
|
||||
let decimals = 18
|
||||
const predictContract = getPredictContract(event.address)
|
||||
if (predictContract.stakeToken) {
|
||||
const stakeToken = getToken(
|
||||
Address.fromString(predictContract.stakeToken!),
|
||||
false
|
||||
)
|
||||
decimals = stakeToken.decimals
|
||||
}
|
||||
predictionPayout.payout = weiToDecimal(
|
||||
event.params.payout.toBigDecimal(),
|
||||
BigInt.fromI32(decimals).toI32()
|
||||
)
|
||||
predictionPayout.predictedValue = event.params.predictedValue
|
||||
predictionPayout.trueValue = event.params.trueValue
|
||||
predictionPayout.aggregatedPredictedValue = weiToDecimal(
|
||||
event.params.aggregatedPredictedValue.toBigDecimal(),
|
||||
18
|
||||
)
|
||||
predictionPayout.block = event.block.number.toI32()
|
||||
predictionPayout.txId = event.transaction.hash.toHexString()
|
||||
predictionPayout.eventIndex = event.logIndex.toI32()
|
||||
predictionPayout.timestamp = event.block.timestamp.toI32()
|
||||
predictionPayout.save()
|
||||
|
||||
predictPrediction.payout = predictionPayout.id
|
||||
predictPrediction.save()
|
||||
|
||||
let shouldUpdateSlot = false
|
||||
const predictSlot = getPredictSlot(
|
||||
event.address.toHexString(),
|
||||
event.params.slot.toI32()
|
||||
)
|
||||
if (event.params.status == 1 && predictSlot.status !== 'Paying') {
|
||||
predictSlot.status = 'Paying'
|
||||
shouldUpdateSlot = true
|
||||
}
|
||||
if (event.params.status == 2 && predictSlot.status !== 'Canceled') {
|
||||
predictSlot.status = 'Canceled'
|
||||
shouldUpdateSlot = true
|
||||
}
|
||||
if (shouldUpdateSlot == true) predictSlot.save()
|
||||
}
|
||||
|
||||
export function handleNewSubscription(event: NewSubscription): void {
|
||||
const id =
|
||||
event.address.toHexString() +
|
||||
'-' +
|
||||
event.transaction.hash.toHexString() +
|
||||
'-' +
|
||||
event.logIndex.toString()
|
||||
const newSubscription = new PredictSubscription(id)
|
||||
const predictContract = getPredictContract(event.address)
|
||||
newSubscription.predictContract = predictContract.id
|
||||
const user = getUser(event.params.user.toHex())
|
||||
newSubscription.user = user.id
|
||||
newSubscription.expireTime = event.params.expires
|
||||
newSubscription.block = event.block.number.toI32()
|
||||
newSubscription.txId = event.transaction.hash.toHexString()
|
||||
newSubscription.eventIndex = event.logIndex.toI32()
|
||||
newSubscription.timestamp = event.block.timestamp.toI32()
|
||||
newSubscription.save()
|
||||
}
|
||||
|
||||
export function handleTruevalSubmitted(event: TruevalSubmitted): void {
|
||||
const predictSlot = getPredictSlot(
|
||||
event.address.toHexString(),
|
||||
event.params.slot.toI32()
|
||||
)
|
||||
const id = event.address.toHexString() + '-' + event.params.slot.toString()
|
||||
const newPredictTrueVals = new PredictTrueVal(id) // they share the same id
|
||||
newPredictTrueVals.slot = predictSlot.id
|
||||
newPredictTrueVals.trueValue = event.params.trueValue
|
||||
newPredictTrueVals.block = event.block.number.toI32()
|
||||
newPredictTrueVals.txId = event.transaction.hash.toHexString()
|
||||
newPredictTrueVals.eventIndex = event.logIndex.toI32()
|
||||
newPredictTrueVals.timestamp = event.block.timestamp.toI32()
|
||||
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()
|
||||
)
|
||||
|
||||
if (event.params.status == 1) {
|
||||
predictSlot.status = 'Paying'
|
||||
}
|
||||
if (event.params.status == 2) {
|
||||
predictSlot.status = 'Canceled'
|
||||
}
|
||||
predictSlot.save()
|
||||
}
|
||||
|
||||
export function handleSettingChanged(event: SettingChanged): void {
|
||||
const predictContract = getPredictContract(event.address)
|
||||
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()
|
||||
const predictSettingsUpdate = new PredictSettingUpdate(
|
||||
event.address.toHexString() +
|
||||
'- ' +
|
||||
event.transaction.hash.toHexString() +
|
||||
'-' +
|
||||
event.logIndex.toHexString()
|
||||
)
|
||||
predictSettingsUpdate.block = event.block.number.toI32()
|
||||
predictSettingsUpdate.txId = event.transaction.hash.toHexString()
|
||||
predictSettingsUpdate.eventIndex = event.logIndex.toI32()
|
||||
predictSettingsUpdate.timestamp = event.block.timestamp.toI32()
|
||||
predictSettingsUpdate.predictContract = predictContract.id
|
||||
predictSettingsUpdate.secondsPerEpoch = event.params.secondsPerEpoch
|
||||
predictSettingsUpdate.secondsPerSubscription =
|
||||
event.params.secondsPerSubscription
|
||||
predictSettingsUpdate.truevalSubmitTimeout =
|
||||
event.params.trueValueSubmitTimeout
|
||||
predictSettingsUpdate.stakeToken = stakeToken.id
|
||||
predictSettingsUpdate.save()
|
||||
}
|
||||
|
||||
export function handlePaused(event: Paused): void {
|
||||
const predictContract = getPredictContract(event.address)
|
||||
predictContract.paused = event.params.paused
|
||||
predictContract.save()
|
||||
}
|
||||
|
||||
export function handleRevenueAdded(event: RevenueAdded): void {
|
||||
/*
|
||||
for (uint256 i = 0; i < num_epochs; i++) {
|
||||
subscriptionRevenueAtBlock[
|
||||
slot + secondsPerEpoch * (i)
|
||||
] += amt_per_epoch;
|
||||
}
|
||||
emit RevenueAdded(amount,slot,amt_per_epoch,num_epochs,secondsPerEpoch);
|
||||
*/
|
||||
const numEpochs = event.params.numEpochs
|
||||
const secondsPerEpoch = event.params.secondsPerEpoch
|
||||
let decimals = 18
|
||||
const predictContract = getPredictContract(event.address)
|
||||
if (predictContract.stakeToken) {
|
||||
const stakeToken = getToken(
|
||||
Address.fromString(predictContract.stakeToken!),
|
||||
false
|
||||
)
|
||||
decimals = stakeToken.decimals
|
||||
}
|
||||
const amountPerEpoch = weiToDecimal(
|
||||
event.params.amountPerEpoch.toBigDecimal(),
|
||||
BigInt.fromI32(decimals).toI32()
|
||||
)
|
||||
const slot = event.params.slot
|
||||
for (let i = BigInt.zero(); i.lt(numEpochs); i = i.plus(BigInt.fromI32(1))) {
|
||||
const targetSlot = slot.plus(secondsPerEpoch.times(i))
|
||||
const predictSlot = getPredictSlot(
|
||||
event.address.toHexString(),
|
||||
targetSlot.toI32()
|
||||
)
|
||||
predictSlot.revenue = predictSlot.revenue.plus(amountPerEpoch)
|
||||
predictSlot.save()
|
||||
const revenueId =
|
||||
event.address.toHexString() +
|
||||
'-' +
|
||||
targetSlot.toString() +
|
||||
'-' +
|
||||
event.transaction.hash.toHexString() +
|
||||
'-' +
|
||||
event.logIndex.toHexString()
|
||||
const predictRevenue = new PredictionRevenue(revenueId)
|
||||
predictRevenue.slot = predictSlot.id
|
||||
predictRevenue.amount = amountPerEpoch
|
||||
predictRevenue.block = event.block.number.toI32()
|
||||
predictRevenue.txId = event.transaction.hash.toHexString()
|
||||
predictRevenue.eventIndex = event.logIndex.toI32()
|
||||
predictRevenue.timestamp = event.block.timestamp.toI32()
|
||||
predictRevenue.save()
|
||||
}
|
||||
}
|
|
@ -1,15 +1,24 @@
|
|||
import {
|
||||
NFTCreated,
|
||||
TokenCreated,
|
||||
ERC721Factory
|
||||
Template721Added,
|
||||
Template20Added
|
||||
} from '../@types/ERC721Factory/ERC721Factory'
|
||||
import { Erc721Template, Erc20Template } from '../@types/schema'
|
||||
import { decimal } from './utils/constants'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
|
||||
import {
|
||||
ERC20Template as factoryERC20Template,
|
||||
ERC20Template3 as factoryERC20Template3
|
||||
} from '../@types/templates'
|
||||
import { getUser } from './utils/userUtils'
|
||||
import { getToken, getNftToken } from './utils/tokenUtils'
|
||||
import {
|
||||
getToken,
|
||||
getNftToken,
|
||||
getErc20TemplateId,
|
||||
getPredictContract
|
||||
} from './utils/tokenUtils'
|
||||
import { addDatatoken } from './utils/globalUtils'
|
||||
import { BigInt } from '@graphprotocol/graph-ts'
|
||||
|
||||
export function handleNftCreated(event: NFTCreated): void {
|
||||
// const nft = new Nft(event.params.newTokenAddress.toHexString())
|
||||
|
@ -27,7 +36,7 @@ export function handleNftCreated(event: NFTCreated): void {
|
|||
nft.block = event.block.number.toI32()
|
||||
nft.eventIndex = event.logIndex.toI32()
|
||||
nft.transferable = event.params.transferable
|
||||
|
||||
nft.template = event.params.templateAddress.toHexString()
|
||||
nft.save()
|
||||
}
|
||||
|
||||
|
@ -49,25 +58,37 @@ export function handleNewToken(event: TokenCreated): void {
|
|||
token.decimals = 18
|
||||
token.supply = decimal.ZERO
|
||||
token.cap = weiToDecimal(event.params.cap.toBigDecimal(), 18)
|
||||
const eventTemplateAddress = event.params.templateAddress
|
||||
.toHexString()
|
||||
.toLowerCase()
|
||||
const contract = ERC721Factory.bind(event.address)
|
||||
const templateCount = contract.try_getCurrentTemplateCount()
|
||||
if (templateCount.reverted) return
|
||||
const templateCountNum = templateCount.value.toI32()
|
||||
|
||||
for (let i = 0; i < templateCountNum; i++) {
|
||||
const template = contract.try_getTokenTemplate(BigInt.fromI32(1 + i))
|
||||
if (template.reverted) return
|
||||
const templateAddress = template.value.templateAddress
|
||||
.toHexString()
|
||||
.toLowerCase()
|
||||
if (templateAddress == eventTemplateAddress) {
|
||||
token.templateId = 1 + i
|
||||
}
|
||||
}
|
||||
|
||||
token.templateId = getErc20TemplateId(event.params.templateAddress)
|
||||
token.save()
|
||||
addDatatoken()
|
||||
if (token.templateId.toString() == '3') {
|
||||
factoryERC20Template3.create(event.params.newTokenAddress)
|
||||
const predictContract = getPredictContract(event.params.newTokenAddress)
|
||||
predictContract.timestamp = event.block.timestamp.toI32()
|
||||
predictContract.txId = event.transaction.hash.toHex()
|
||||
predictContract.block = event.block.number.toI32()
|
||||
predictContract.eventIndex = event.logIndex.toI32()
|
||||
predictContract.save()
|
||||
}
|
||||
factoryERC20Template.create(event.params.newTokenAddress)
|
||||
}
|
||||
|
||||
export function handleNew721Template(event: Template721Added): void {
|
||||
let template = Erc721Template.load(
|
||||
event.params._templateAddress.toHexString()
|
||||
)
|
||||
if (template === null) {
|
||||
template = new Erc721Template(event.params._templateAddress.toHexString())
|
||||
template.templateId = event.params.nftTemplateCount
|
||||
template.save()
|
||||
}
|
||||
}
|
||||
|
||||
export function handleNew20Template(event: Template20Added): void {
|
||||
let template = Erc20Template.load(event.params._templateAddress.toHexString())
|
||||
if (template === null) {
|
||||
template = new Erc20Template(event.params._templateAddress.toHexString())
|
||||
template.templateId = event.params.nftTemplateCount
|
||||
template.save()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ import {
|
|||
TokenRemoved,
|
||||
OPCFeeChanged,
|
||||
FactoryRouter,
|
||||
SSContractAdded,
|
||||
SSContractRemoved,
|
||||
FixedRateContractAdded,
|
||||
FixedRateContractRemoved,
|
||||
DispenserContractAdded,
|
||||
|
@ -91,32 +89,6 @@ export function handleTokenRemoved(event: TokenRemoved): void {
|
|||
opc.approvedTokens = newList
|
||||
opc.save()
|
||||
}
|
||||
export function handleSSContractAdded(event: SSContractAdded): void {
|
||||
// add token to approvedTokens
|
||||
const templates = getTemplates()
|
||||
let existingContracts: string[]
|
||||
if (!templates.ssTemplates) existingContracts = []
|
||||
else existingContracts = templates.ssTemplates as string[]
|
||||
if (!existingContracts.includes(event.params.contractAddress.toHexString()))
|
||||
existingContracts.push(event.params.contractAddress.toHexString())
|
||||
templates.ssTemplates = existingContracts
|
||||
templates.save()
|
||||
}
|
||||
export function handleSSContractRemoved(event: SSContractRemoved): void {
|
||||
const templates = getTemplates()
|
||||
const newList: string[] = []
|
||||
let existingContracts: string[]
|
||||
if (!templates.ssTemplates) existingContracts = []
|
||||
else existingContracts = templates.ssTemplates as string[]
|
||||
if (!existingContracts || existingContracts.length < 1) return
|
||||
while (existingContracts.length > 0) {
|
||||
const role = existingContracts.shift().toString()
|
||||
if (!role) break
|
||||
if (role != event.params.contractAddress.toHexString()) newList.push(role)
|
||||
}
|
||||
templates.ssTemplates = newList
|
||||
templates.save()
|
||||
}
|
||||
|
||||
export function handleFixedRateContractAdded(
|
||||
event: FixedRateContractAdded
|
||||
|
|
|
@ -52,6 +52,11 @@ export function updateFixedRateExchangeSupply(
|
|||
fixedRateDetails.value.value8.toBigDecimal(),
|
||||
baseToken.decimals
|
||||
)
|
||||
// update withMint state
|
||||
fixedRateExchange.withMint = fixedRateDetails.value.value11
|
||||
|
||||
// update active state
|
||||
fixedRateExchange.active = fixedRateDetails.value.value6
|
||||
fixedRateExchange.save()
|
||||
}
|
||||
|
||||
|
|
|
@ -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.8'
|
||||
globalStats.version = '4.0.2'
|
||||
globalStats.orderCount = 0
|
||||
globalStats.fixedCount = 0
|
||||
globalStats.datatokenCount = 0
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
import { Address, log, BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
||||
import { Nft, Token } from '../../@types/schema'
|
||||
import {
|
||||
Nft,
|
||||
Token,
|
||||
PredictContract,
|
||||
Erc721Template,
|
||||
Erc20Template
|
||||
} from '../../@types/schema'
|
||||
import { ERC20 } from '../../@types/templates/ERC20Template/ERC20'
|
||||
import { ERC20Template, ERC721Template } from '../../@types/templates'
|
||||
import { ERC721Template } from '../../@types/templates'
|
||||
import { addNft } from './globalUtils'
|
||||
import { ZERO_ADDRESS } from './constants'
|
||||
|
||||
export function createToken(address: Address, isDatatoken: boolean): Token {
|
||||
log.debug('started creating token with address: {}', [address.toHexString()])
|
||||
if (isDatatoken) {
|
||||
ERC20Template.create(address)
|
||||
}
|
||||
const token = new Token(address.toHexString())
|
||||
const contract = ERC20.bind(address)
|
||||
const name = contract.try_name()
|
||||
|
@ -31,6 +34,7 @@ export function createToken(address: Address, isDatatoken: boolean): Token {
|
|||
token.block = 0
|
||||
token.tx = ''
|
||||
token.eventIndex = 0
|
||||
token.templateId = BigInt.zero()
|
||||
token.save()
|
||||
return token
|
||||
}
|
||||
|
@ -109,3 +113,44 @@ export function getUSDValue(
|
|||
): BigDecimal {
|
||||
return BigDecimal.zero()
|
||||
}
|
||||
|
||||
export function getErc721TemplateId(address: Address): BigInt {
|
||||
const template = Erc721Template.load(address.toHexString())
|
||||
if (template) {
|
||||
return template.templateId
|
||||
}
|
||||
return BigInt.zero()
|
||||
}
|
||||
|
||||
export function getErc20TemplateId(address: Address): BigInt {
|
||||
const template = Erc20Template.load(address.toHexString())
|
||||
if (template) {
|
||||
return template.templateId
|
||||
}
|
||||
return BigInt.zero()
|
||||
}
|
||||
|
||||
export function createPredictContract(address: Address): PredictContract {
|
||||
const predictContract = new PredictContract(address.toHexString())
|
||||
const token = getToken(address, true)
|
||||
predictContract.token = token.id
|
||||
predictContract.secondsPerEpoch = BigInt.zero()
|
||||
predictContract.secondsPerSubscription = BigInt.zero()
|
||||
predictContract.truevalSubmitTimeout = BigInt.zero()
|
||||
predictContract.stakeToken = null
|
||||
predictContract.txId = ''
|
||||
predictContract.timestamp = 0
|
||||
predictContract.block = 0
|
||||
predictContract.eventIndex = 0
|
||||
predictContract.paused = false
|
||||
predictContract.save()
|
||||
return predictContract
|
||||
}
|
||||
|
||||
export function getPredictContract(address: Address): PredictContract {
|
||||
let newPredictContract = PredictContract.load(address.toHexString())
|
||||
if (newPredictContract === null) {
|
||||
newPredictContract = createPredictContract(address)
|
||||
}
|
||||
return newPredictContract
|
||||
}
|
||||
|
|
|
@ -54,6 +54,41 @@ templates:
|
|||
handler: handleProviderFee
|
||||
receipt: true
|
||||
|
||||
- name: ERC20Template3
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
source:
|
||||
abi: ERC20Template3
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/erc20Template3.ts
|
||||
entities:
|
||||
- ERC20Template3
|
||||
abis:
|
||||
- name: ERC20Template3
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template3.sol/ERC20Template3.json
|
||||
- name: ERC20
|
||||
file: ./abis/ERC20.json
|
||||
- name: ERC20Roles
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/utils/ERC20Roles.sol/ERC20Roles.json
|
||||
eventHandlers:
|
||||
- event: PredictionSubmitted(indexed address,indexed uint256,uint256)
|
||||
handler: handlePredictionSubmitted
|
||||
- event: PredictionPayout(indexed address,indexed uint256,uint256,uint256,bool,bool,uint256,uint8)
|
||||
handler: handlePredictionPayout
|
||||
- event: NewSubscription(indexed address,uint256,uint256)
|
||||
handler: handleNewSubscription
|
||||
- event: TruevalSubmitted(indexed uint256,bool,uint8,uint256,uint256)
|
||||
handler: handleTruevalSubmitted
|
||||
- event: SettingChanged(uint256,uint256,uint256,address)
|
||||
handler: handleSettingChanged
|
||||
- event: RevenueAdded(uint256,uint256,uint256,uint256,uint256)
|
||||
handler: handleRevenueAdded
|
||||
- event: Paused(bool)
|
||||
handler: handlePaused
|
||||
|
||||
- name: ERC721Template
|
||||
kind: ethereum/contract
|
||||
network: __NETWORK__
|
||||
|
@ -189,6 +224,10 @@ dataSources:
|
|||
entities:
|
||||
- ERC721Factory
|
||||
abis:
|
||||
- name: ERC721Template
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json
|
||||
- name: ERC20Template
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json
|
||||
- name: ERC721Factory
|
||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json
|
||||
- name: ERC20
|
||||
|
@ -198,6 +237,10 @@ dataSources:
|
|||
handler: handleNftCreated
|
||||
- event: TokenCreated(indexed address,indexed address,string,string,uint256,address)
|
||||
handler: handleNewToken
|
||||
- event: Template721Added(indexed address,indexed uint256)
|
||||
handler: handleNew721Template
|
||||
- event: Template20Added(indexed address,indexed uint256)
|
||||
handler: handleNew20Template
|
||||
|
||||
- kind: ethereum/contract
|
||||
name: FactoryRouter
|
||||
|
@ -225,10 +268,6 @@ dataSources:
|
|||
handler: handleTokenRemoved
|
||||
- event: OPCFeeChanged(indexed address,uint256,uint256,uint256,uint256)
|
||||
handler: handleOPCFeeChanged
|
||||
- event: SSContractAdded(indexed address,indexed address)
|
||||
handler: handleSSContractAdded
|
||||
- event: SSContractRemoved(indexed address,indexed address)
|
||||
handler: handleSSContractRemoved
|
||||
- event: FixedRateContractAdded(indexed address,indexed address)
|
||||
handler: handleFixedRateContractAdded
|
||||
- event: FixedRateContractRemoved(indexed address,indexed address)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'mocha'
|
||||
import {
|
||||
DatatokenCreateParams,
|
||||
ProviderInstance,
|
||||
|
@ -197,8 +198,10 @@ describe('Datatoken tests', async () => {
|
|||
dt.publishMarketFeeAmount === publishMarketFeeAmount,
|
||||
'incorrect value for: publishMarketFeeAmount'
|
||||
)
|
||||
|
||||
assert(dt.templateId === templateIndex, 'incorrect value for: templateId')
|
||||
assert(
|
||||
parseInt(dt.templateId) === templateIndex,
|
||||
'incorrect value for: templateId'
|
||||
)
|
||||
assert(dt.holderCount === '0', 'incorrect value for: holderCount')
|
||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(dt.orders, 'incorrect value for: orders')
|
||||
|
@ -314,7 +317,10 @@ describe('Datatoken tests', async () => {
|
|||
dt.publishMarketFeeAmount === publishMarketFeeAmount,
|
||||
'incorrect value for: publishMarketFeeAmount'
|
||||
)
|
||||
assert(dt.templateId === templateIndex, 'incorrect value for: templateId')
|
||||
assert(
|
||||
parseInt(dt.templateId) === templateIndex,
|
||||
'incorrect value for: templateId'
|
||||
)
|
||||
assert(dt.holderCount === '0', 'incorrect value for: holderCount')
|
||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(dt.orders, 'incorrect value for: orders')
|
||||
|
|
|
@ -110,6 +110,7 @@ describe('Dispenser tests', async () => {
|
|||
nftParams,
|
||||
erc20Params
|
||||
)
|
||||
const nftTemplate = await Factory.getNFTTemplate(nftParams.templateIndex)
|
||||
assert(tx.events.NFTCreated.event === 'NFTCreated')
|
||||
assert(tx.events.TokenCreated.event === 'TokenCreated')
|
||||
nftAddress = tx.events.NFTCreated.returnValues.newTokenAddress.toLowerCase()
|
||||
|
@ -163,7 +164,10 @@ describe('Dispenser tests', async () => {
|
|||
)
|
||||
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
||||
assert(nft.metadataRole === null, 'incorrect value for: metadataRole')
|
||||
assert(nft.template === '', 'incorrect value for: template')
|
||||
assert(
|
||||
nft.template === nftTemplate.templateAddress.toLowerCase(),
|
||||
'incorrect value for: template'
|
||||
)
|
||||
assert(nft.transferable === true, 'incorrect value for: transferable')
|
||||
assert(nft.createdTimestamp >= time, 'incorrect value: createdTimestamp')
|
||||
assert(nft.createdTimestamp < time + 5, 'incorrect value: createdTimestamp')
|
||||
|
@ -243,7 +247,10 @@ describe('Dispenser tests', async () => {
|
|||
'incorrect value for: publishMarketFeeAmount'
|
||||
)
|
||||
|
||||
assert(dt.templateId === templateIndex, 'incorrect value for: templateId')
|
||||
assert(
|
||||
parseInt(dt.templateId) === templateIndex,
|
||||
'incorrect value for: templateId'
|
||||
)
|
||||
assert(dt.holderCount === '0', 'incorrect value for: holderCount')
|
||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(dt.orders, 'incorrect value for: orders')
|
||||
|
|
|
@ -44,7 +44,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
const publishMarketSwapFee = '0.003'
|
||||
const templateIndex = 1
|
||||
const dtAmount = '10'
|
||||
const datatoken = new Datatoken(web3, 8996)
|
||||
// const datatoken = new Datatoken(web3, 8996)
|
||||
let datatokenAddress: string
|
||||
let fixedRateAddress: string
|
||||
let baseTokenAddress: string
|
||||
|
@ -108,7 +108,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
fixedRate: price,
|
||||
marketFee: publishMarketSwapFee,
|
||||
allowedConsumer: ZERO_ADDRESS,
|
||||
withMint: false
|
||||
withMint: true
|
||||
}
|
||||
|
||||
const result = await Factory.createNftWithDatatokenWithFixedRate(
|
||||
|
@ -127,6 +127,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
result.events.NewFixedRate.returnValues.exchangeId.toLowerCase()
|
||||
|
||||
fixedRateId = `${exchangeContract}-${exchangeId}`
|
||||
const nftTemplate = await Factory.getNFTTemplate(nftParams.templateIndex)
|
||||
|
||||
// Check NFT values
|
||||
await sleep(sleepMs)
|
||||
|
@ -176,7 +177,10 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
)
|
||||
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
||||
assert(nft.metadataRole === null, 'incorrect value for: metadataRole')
|
||||
assert(nft.template === '', 'incorrect value for: template')
|
||||
assert(
|
||||
nft.template === nftTemplate.templateAddress.toLowerCase(),
|
||||
'incorrect value for: template'
|
||||
)
|
||||
assert(nft.transferable === true, 'incorrect value for: transferable')
|
||||
assert(
|
||||
nft.createdTimestamp >= time,
|
||||
|
@ -263,7 +267,10 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
'incorrect value for: publishMarketFeeAmount'
|
||||
)
|
||||
|
||||
assert(dt.templateId === templateIndex, 'incorrect value for: templateId')
|
||||
assert(
|
||||
parseInt(dt.templateId) === templateIndex,
|
||||
'incorrect value for: templateId'
|
||||
)
|
||||
assert(dt.holderCount === '0', 'incorrect value for: holderCount')
|
||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||
assert(dt.orders, 'incorrect value for: orders')
|
||||
|
@ -349,7 +356,8 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
'incorrect value for: baseToken.id'
|
||||
)
|
||||
assert(
|
||||
fixed.datatokenSupply === '0',
|
||||
fixed.datatokenSupply ===
|
||||
'115792089237316195423570985008687900000000000000000000000000',
|
||||
'incorrect value for: datatokenSupply'
|
||||
)
|
||||
assert(
|
||||
|
@ -371,7 +379,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
fixed.allowedSwapper === ZERO_ADDRESS,
|
||||
'incorrect value for: allowedSwapper'
|
||||
)
|
||||
assert(fixed.withMint === null, 'incorrect value for: withMint')
|
||||
assert(fixed.withMint === true, 'incorrect value for: withMint')
|
||||
assert(fixed.isMinter === null, 'incorrect value for: isMinter')
|
||||
assert(fixed.updates, 'incorrect value for: updates.id')
|
||||
assert(fixed.swaps, 'incorrect value for: swaps')
|
||||
|
@ -489,125 +497,6 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
'incorrect value: 3nd eventIndex'
|
||||
)
|
||||
})
|
||||
it('Deactivates exchange', async () => {
|
||||
const deactiveQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){active, eventIndex}}`
|
||||
}
|
||||
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(deactiveQuery)
|
||||
})
|
||||
const initialActive = (await initialResponse.json()).data.fixedRateExchange
|
||||
.active
|
||||
assert(initialActive === true, 'incorrect value for: initialActive')
|
||||
|
||||
// Deactivate exchange
|
||||
await fixedRate.deactivate(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(deactiveQuery)
|
||||
})
|
||||
const updatedActive = (await updatedResponse.json()).data.fixedRateExchange
|
||||
|
||||
assert(updatedActive.active === false, 'incorrect value for: updatedActive')
|
||||
assert(
|
||||
updatedActive.eventIndex !== null && updatedActive.eventIndex > 0,
|
||||
'incorrect value: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Activates exchange', async () => {
|
||||
const activeQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){active, eventIndex}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(activeQuery)
|
||||
})
|
||||
const initialActive = (await initialResponse.json()).data.fixedRateExchange
|
||||
.active
|
||||
assert(initialActive === false, 'incorrect value for: initialActive')
|
||||
|
||||
// Activate exchange
|
||||
await fixedRate.activate(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(activeQuery)
|
||||
})
|
||||
const updatedActive = (await updatedResponse.json()).data.fixedRateExchange
|
||||
assert(updatedActive.active === true, 'incorrect value for: updatedActive')
|
||||
assert(
|
||||
updatedActive.eventIndex !== null && updatedActive.eventIndex > 0,
|
||||
'incorrect value: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Activate Minting', async () => {
|
||||
const mintingQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){withMint, eventIndex}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
const initialMint = (await initialResponse.json()).data.fixedRateExchange
|
||||
.withMint
|
||||
assert(initialMint === null, 'incorrect value for: initialMint')
|
||||
|
||||
// Activate minting
|
||||
const tx = await fixedRate.activateMint(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
|
||||
const updatedMint = (await updatedResponse.json()).data.fixedRateExchange
|
||||
assert(updatedMint.withMint === true, 'incorrect value for: updatedMint')
|
||||
assert(
|
||||
updatedMint.eventIndex === tx.events.ExchangeMintStateChanged.logIndex,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Deactivate Minting', async () => {
|
||||
const mintingQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){withMint, eventIndex}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
const initialMint = (await initialResponse.json()).data.fixedRateExchange
|
||||
.withMint
|
||||
assert(initialMint === true, 'incorrect value for: initialMint')
|
||||
|
||||
// Activate minting
|
||||
const tx = await fixedRate.deactivateMint(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
|
||||
const updatedMint = (await updatedResponse.json()).data.fixedRateExchange
|
||||
assert(updatedMint.withMint === false, 'incorrect value for: updatedMint')
|
||||
assert(
|
||||
updatedMint.eventIndex === tx.events.ExchangeMintStateChanged.logIndex,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('User1 buys a datatoken', async () => {
|
||||
const swapsQuery = {
|
||||
|
@ -714,57 +603,63 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
assert(swaps.eventIndex === tx.logIndex, 'incorrect value for: eventIndex')
|
||||
assert(swaps.__typename === 'FixedRateExchangeSwap', 'incorrect __typename')
|
||||
})
|
||||
it('User1 sells a datatoken', async () => {
|
||||
await datatoken.approve(datatokenAddress, fixedRateAddress, dtAmount, user1)
|
||||
const tx = (await fixedRate.sellDatatokens(user1, exchangeId, '10', '9'))
|
||||
.events?.Swapped
|
||||
const oceanFeeAmount = web3.utils.fromWei(
|
||||
new BN(tx.returnValues.oceanFeeAmount)
|
||||
)
|
||||
assert(tx != null)
|
||||
await sleep(sleepMs)
|
||||
const swapsQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){
|
||||
swaps(orderBy: createdTimestamp, orderDirection: desc){
|
||||
id
|
||||
exchangeId{id}
|
||||
by{id}
|
||||
baseTokenAmount
|
||||
dataTokenAmount
|
||||
block
|
||||
createdTimestamp
|
||||
tx
|
||||
eventIndex
|
||||
oceanFeeAmount
|
||||
__typename
|
||||
}
|
||||
}}`
|
||||
|
||||
it('Deactivate Minting', async () => {
|
||||
const mintingQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){withMint, eventIndex}}`
|
||||
}
|
||||
// Check initial swaps
|
||||
const response = await fetch(subgraphUrl, {
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(swapsQuery)
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
const swaps = (await response.json()).data.fixedRateExchange.swaps[0]
|
||||
const swappedAmount = web3.utils.fromWei(
|
||||
new BN(tx.returnValues.baseTokenSwappedAmount)
|
||||
)
|
||||
const initialMint = (await initialResponse.json()).data.fixedRateExchange
|
||||
.withMint
|
||||
assert(initialMint === true, 'incorrect value for: initialMint')
|
||||
|
||||
// Activate minting
|
||||
const tx = await fixedRate.deactivateMint(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
|
||||
const updatedMint = (await updatedResponse.json()).data.fixedRateExchange
|
||||
assert(updatedMint.withMint === false, 'incorrect value for: updatedMint')
|
||||
assert(
|
||||
swaps.id ===
|
||||
`${tx.transactionHash}-${fixedRateId}-${tx.logIndex.toFixed(1)}`,
|
||||
'incorrect: id'
|
||||
updatedMint.eventIndex === tx.events.ExchangeMintStateChanged.logIndex,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
it('Activate Minting', async () => {
|
||||
const mintingQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){withMint, eventIndex}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
const initialMint = (await initialResponse.json()).data.fixedRateExchange
|
||||
.withMint
|
||||
assert(initialMint === false, 'incorrect value for: initialMint')
|
||||
|
||||
// Activate minting
|
||||
const tx = await fixedRate.activateMint(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mintingQuery)
|
||||
})
|
||||
const updatedMint = (await updatedResponse.json()).data.fixedRateExchange
|
||||
assert(updatedMint.withMint === true, 'incorrect value for: updatedMint')
|
||||
assert(
|
||||
updatedMint.eventIndex === tx.events.ExchangeMintStateChanged.logIndex,
|
||||
'incorrect value for: eventIndex'
|
||||
)
|
||||
assert(swaps.exchangeId.id === fixedRateId, 'incorrect: exchangeId')
|
||||
assert(swaps.by.id === user1, 'incorrect value for: id')
|
||||
assert(swaps.baseTokenAmount === swappedAmount, 'incorrect baseTokenAmount')
|
||||
assert(swaps.dataTokenAmount === dtAmount, 'incorrect: dataTokenAmount')
|
||||
assert(swaps.block === tx.blockNumber, 'incorrect value for: block')
|
||||
assert(swaps.createdTimestamp >= time, 'incorrect: createdTimestamp')
|
||||
assert(swaps.createdTimestamp < time + 25, 'incorrect: createdTimestamp 2')
|
||||
assert(swaps.oceanFeeAmount === oceanFeeAmount, 'incorrect: oceanFeeAmount')
|
||||
assert(swaps.tx === tx.transactionHash, 'incorrect value for: tx')
|
||||
assert(swaps.eventIndex === tx.logIndex, 'incorrect value for: eventIndex')
|
||||
assert(swaps.__typename === 'FixedRateExchangeSwap', 'incorrect __typename')
|
||||
})
|
||||
|
||||
it('Updates allowed swapper', async () => {
|
||||
|
@ -803,4 +698,63 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
'incorrect value for: eventIndex'
|
||||
)
|
||||
})
|
||||
it('Deactivates exchange', async () => {
|
||||
const deactiveQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){active, eventIndex}}`
|
||||
}
|
||||
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(deactiveQuery)
|
||||
})
|
||||
const initialActive = (await initialResponse.json()).data.fixedRateExchange
|
||||
.active
|
||||
assert(initialActive === true, 'incorrect value for: initialActive')
|
||||
|
||||
// Deactivate exchange
|
||||
await fixedRate.deactivate(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(deactiveQuery)
|
||||
})
|
||||
const updatedActive = (await updatedResponse.json()).data.fixedRateExchange
|
||||
|
||||
assert(updatedActive.active === false, 'incorrect value for: updatedActive')
|
||||
assert(
|
||||
updatedActive.eventIndex !== null && updatedActive.eventIndex >= 0,
|
||||
'incorrect value: eventIndex'
|
||||
)
|
||||
})
|
||||
|
||||
it('Activates exchange', async () => {
|
||||
const activeQuery = {
|
||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){active, eventIndex}}`
|
||||
}
|
||||
const initialResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(activeQuery)
|
||||
})
|
||||
const initialActive = (await initialResponse.json()).data.fixedRateExchange
|
||||
.active
|
||||
assert(initialActive === false, 'incorrect value for: initialActive')
|
||||
|
||||
// Activate exchange
|
||||
await fixedRate.activate(publisher, exchangeId)
|
||||
await sleep(sleepMs)
|
||||
|
||||
// Check the updated value for active
|
||||
const updatedResponse = await fetch(subgraphUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(activeQuery)
|
||||
})
|
||||
const updatedActive = (await updatedResponse.json()).data.fixedRateExchange
|
||||
assert(updatedActive.active === true, 'incorrect value for: updatedActive')
|
||||
assert(
|
||||
updatedActive.eventIndex !== null && updatedActive.eventIndex >= 0,
|
||||
'incorrect value: eventIndex'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -66,6 +66,7 @@ const ddo = {
|
|||
}
|
||||
]
|
||||
}
|
||||
let nftTemplate
|
||||
|
||||
describe('NFT tests', async () => {
|
||||
const nftName = 'testNFT'
|
||||
|
@ -119,7 +120,7 @@ describe('NFT tests', async () => {
|
|||
)
|
||||
erc721Address = result.events.NFTCreated.returnValues[0]
|
||||
datatokenAddress = result.events.TokenCreated.returnValues[0]
|
||||
|
||||
nftTemplate = await Factory.getNFTTemplate(nftParams.templateIndex)
|
||||
// Check values before updating metadata
|
||||
await sleep(3000)
|
||||
nftAddress = erc721Address.toLowerCase()
|
||||
|
@ -167,7 +168,10 @@ describe('NFT tests', async () => {
|
|||
)
|
||||
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
||||
assert(nft.metadataRole === null, 'incorrect value for: metadataRole')
|
||||
assert(nft.template === '', 'incorrect value for: template')
|
||||
assert(
|
||||
nft.template === nftTemplate.templateAddress.toLowerCase(),
|
||||
'incorrect value for: template'
|
||||
)
|
||||
assert(nft.transferable === true, 'incorrect value for: transferable')
|
||||
assert(
|
||||
nft.createdTimestamp >= time,
|
||||
|
@ -276,7 +280,10 @@ describe('NFT tests', async () => {
|
|||
updatedNft.metadataRole === null,
|
||||
'incorrect value for: metadataRole'
|
||||
)
|
||||
assert(updatedNft.template === '', 'incorrect value for: template')
|
||||
assert(
|
||||
updatedNft.template === nftTemplate.templateAddress.toLowerCase(),
|
||||
'incorrect value for: template'
|
||||
)
|
||||
assert(
|
||||
updatedNft.transferable === true,
|
||||
'incorrect value for: transferable'
|
||||
|
|
|
@ -64,7 +64,7 @@ describe('User tests', async () => {
|
|||
const publishMarketSwapFee = '0.003'
|
||||
const templateIndex = 1
|
||||
const dtAmount = '10'
|
||||
const datatoken = new Datatoken(web3, 8996)
|
||||
// const datatoken = new Datatoken(web3, 8996)
|
||||
let datatokenAddress: string
|
||||
let fixedRateAddress: string
|
||||
let baseTokenAddress: string
|
||||
|
@ -123,7 +123,7 @@ describe('User tests', async () => {
|
|||
fixedRate: price,
|
||||
marketFee: publishMarketSwapFee,
|
||||
allowedConsumer: ZERO_ADDRESS,
|
||||
withMint: false
|
||||
withMint: true
|
||||
}
|
||||
|
||||
const result = await Factory.createNftWithDatatokenWithFixedRate(
|
||||
|
@ -196,27 +196,6 @@ describe('User tests', async () => {
|
|||
assert(user.totalSales === '0', 'incorrect value for: totalSales')
|
||||
assert(user.__typename === 'User', 'incorrect value for: __typename')
|
||||
})
|
||||
it('User1 sells a datatoken', async () => {
|
||||
const initialUser = await userQuery(user1)
|
||||
await datatoken.approve(datatokenAddress, fixedRateAddress, dtAmount, user1)
|
||||
const tx = (await fixedRate.sellDatatokens(user1, exchangeId, '10', '9'))
|
||||
.events?.Swapped
|
||||
|
||||
assert(tx != null)
|
||||
const user = await userQuery(user1)
|
||||
|
||||
assert(user.id === user1, 'incorrect value for: id')
|
||||
assert(user.tokenBalancesOwned.length === 0, 'incorrect tokenBalancesOwned')
|
||||
assert(user.orders.length === 0, 'incorrect value for: orders')
|
||||
assert(
|
||||
user.freSwaps.length === initialUser.freSwaps.length,
|
||||
'incorrect value for: freSwaps'
|
||||
)
|
||||
assert(user.totalOrders === '0', 'incorrect value for: totalOrders')
|
||||
assert(user.totalSales === '0', 'incorrect value for: totalSales')
|
||||
assert(user.__typename === 'User', 'incorrect value for: __typename')
|
||||
})
|
||||
|
||||
it('Check user fields after publishing & ordering a datatoken', async () => {
|
||||
// Start with publishing a new datatoken
|
||||
const nftParams: NftCreateData = {
|
||||
|
|
Loading…
Reference in New Issue