mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-10-31 23:35:19 +01:00
Compare commits
137 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2f322ee016 | ||
|
ecc9092f5b | ||
|
ae1a33755f | ||
|
63bc3f8409 | ||
|
b9bfe07a92 | ||
|
d80ba60637 | ||
|
4e939c70c0 | ||
|
ba5e514ddf | ||
|
8930eef827 | ||
|
36ae877984 | ||
|
cf58c9aae4 | ||
|
8bc4dab920 | ||
|
fc07962311 | ||
|
0077cfa69f | ||
|
90ad128bc2 | ||
|
0880f714b0 | ||
|
7ee41bc29b | ||
|
957db42e59 | ||
|
db6c3eeeea | ||
|
329ea980b6 | ||
|
c6004336ae | ||
|
87e42fd6ce | ||
|
f5b5400261 | ||
|
aeef30129a | ||
|
299d196162 | ||
|
fa58272978 | ||
|
bc56752f3c | ||
|
ab62f18c3e | ||
|
a62a4c189d | ||
|
39a1210c82 | ||
|
ae9c371e8f | ||
|
86cc7f0608 | ||
|
b412d2b0b6 | ||
|
207a4ac806 | ||
|
60b8728225 | ||
|
dcaf83775d | ||
|
2ca1280328 | ||
|
e1df119197 | ||
|
c42cd1c283 | ||
|
e30047c430 | ||
|
093b452441 | ||
|
8691538078 | ||
|
5b2ccbc276 | ||
|
9fd0553337 | ||
|
c33868d841 | ||
|
68944f02a5 | ||
|
a77ea45d5f | ||
|
fa071a9cd2 | ||
|
9164897f2c | ||
|
4794dec64e | ||
|
c8541a071e | ||
|
b376cb3942 | ||
|
81b43ecc20 | ||
|
c02b32b47e | ||
|
a6ded85a37 | ||
|
4607c673b4 | ||
|
d888d7d256 | ||
|
420a229a61 | ||
|
0cf40d40ce | ||
|
b803f1eb6b | ||
|
1a44345d05 | ||
|
de5f1aab4b | ||
|
0a3d513262 | ||
|
81eb7ea738 | ||
|
40f09aa6fe | ||
|
1a5b1a500c | ||
|
dd0512e793 | ||
|
140bcc6341 | ||
|
6a9b342c52 | ||
|
ec9d7e733f | ||
|
4c3fd95abc | ||
|
46f88599b4 | ||
|
86c6551f31 | ||
|
1191594196 | ||
|
88a2eecb9b | ||
|
15af2cd609 | ||
|
1a5906b2b3 | ||
|
6925cfdde3 | ||
|
21618b89cf | ||
|
8ad4f4852b | ||
|
4cacee3f45 | ||
|
3de53c5197 | ||
|
7c35711f72 | ||
|
26a53431ea | ||
|
25021ac9ea | ||
|
38a7166041 | ||
|
9c56b00faa | ||
|
957488077b | ||
|
688166e2a0 | ||
|
1e5e461286 | ||
|
e15d69ebf9 | ||
|
a48b376fa5 | ||
|
1bb6c9da78 | ||
|
a923bd943f | ||
|
574b20795b | ||
|
65515d9d91 | ||
|
cb16d01926 | ||
|
1293e6ebd7 | ||
|
004930fd69 | ||
|
2c7ccabe02 | ||
|
a36c2aecce | ||
|
f34e863623 | ||
|
8ef553769a | ||
|
c8a4978bc8 | ||
|
c636ad2680 | ||
|
941dfa28ed | ||
|
d9c5e71d9f | ||
|
20c27cd521 | ||
|
6c4fc1c346 | ||
|
8eb80507c9 | ||
|
5ef15e8845 | ||
|
39ef388831 | ||
|
e6975c60cb | ||
|
5be8f397af | ||
|
bb90457b91 | ||
|
89db52ff41 | ||
|
3a629c7d3e | ||
|
d7e0643c1d | ||
|
a0d3c365bb | ||
|
52ab055c1a | ||
|
0cf93fbc52 | ||
|
5b787d72b5 | ||
|
e9fdbb96d8 | ||
|
c7668c4f1d | ||
|
45ac3c3d96 | ||
|
619571b0c2 | ||
|
29b5efe472 | ||
|
1e2a3b1814 | ||
|
ae78cae608 | ||
|
95fcfe9ba7 | ||
|
7be20246c0 | ||
|
92094086f9 | ||
|
868f991f17 | ||
|
93a05eb767 | ||
|
12ac5cb523 | ||
|
253dc63fa8 | ||
|
24df9f332e |
7
.github/workflows/tests.yml
vendored
7
.github/workflows/tests.yml
vendored
@ -37,8 +37,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
repository: 'oceanprotocol/barge'
|
repository: 'oceanprotocol/barge'
|
||||||
path: 'barge'
|
path: 'barge'
|
||||||
ref: main
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: ${{ env.DOCKERHUB_PASSWORD && env.DOCKERHUB_USERNAME }}
|
if: ${{ env.DOCKERHUB_PASSWORD && env.DOCKERHUB_USERNAME }}
|
||||||
run: |
|
run: |
|
||||||
@ -51,8 +49,6 @@ jobs:
|
|||||||
working-directory: ${{ github.workspace }}/barge
|
working-directory: ${{ github.workspace }}/barge
|
||||||
run: |
|
run: |
|
||||||
bash -x start_ocean.sh --with-thegraph --skip-subgraph-deploy --no-dashboard 2>&1 > start_ocean.log &
|
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
|
- run: npm ci
|
||||||
|
|
||||||
@ -74,3 +70,6 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
ADDRESS_FILE: /home/runner/.ocean/ocean-contracts/artifacts/address.json
|
ADDRESS_FILE: /home/runner/.ocean/ocean-contracts/artifacts/address.json
|
||||||
BARGE_FOLDER: /home/runner/.ocean/
|
BARGE_FOLDER: /home/runner/.ocean/
|
||||||
|
- name: docker logs
|
||||||
|
run: docker logs ocean_graph-node_1
|
||||||
|
if: ${{ failure() }}
|
||||||
|
244
CHANGELOG.md
244
CHANGELOG.md
@ -4,9 +4,253 @@ 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).
|
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)
|
||||||
|
- Fix #628 & #629 & #621: Store event log index for all records [`#630`](https://github.com/oceanprotocol/ocean-subgraph/pull/630)
|
||||||
|
- Bump release-it from 15.10.2 to 15.10.3 [`#673`](https://github.com/oceanprotocol/ocean-subgraph/pull/673)
|
||||||
|
- 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)
|
||||||
|
|
||||||
|
> 28 April 2023
|
||||||
|
|
||||||
|
- switch amount from wei to numeric [`#666`](https://github.com/oceanprotocol/ocean-subgraph/pull/666)
|
||||||
|
- Release 3.0.7 [`8691538`](https://github.com/oceanprotocol/ocean-subgraph/commit/8691538078f0d8aa81a0543de403a4e540adbfbd)
|
||||||
|
|
||||||
|
#### [v3.0.6](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.5...v3.0.6)
|
||||||
|
|
||||||
|
> 28 April 2023
|
||||||
|
|
||||||
|
- proper veDelegation [`#663`](https://github.com/oceanprotocol/ocean-subgraph/pull/663)
|
||||||
|
- Release 3.0.6 [`9fd0553`](https://github.com/oceanprotocol/ocean-subgraph/commit/9fd055333705185b5f507fddcdf0f5502add1f1c)
|
||||||
|
|
||||||
|
#### [v3.0.5](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.4...v3.0.5)
|
||||||
|
|
||||||
|
> 26 April 2023
|
||||||
|
|
||||||
|
- add events handlers [`#662`](https://github.com/oceanprotocol/ocean-subgraph/pull/662)
|
||||||
|
- Bump prettier from 2.8.7 to 2.8.8 [`#660`](https://github.com/oceanprotocol/ocean-subgraph/pull/660)
|
||||||
|
- Bump vm2 from 3.9.16 to 3.9.17 [`#659`](https://github.com/oceanprotocol/ocean-subgraph/pull/659)
|
||||||
|
- Add missing veDelegation.save() [`#658`](https://github.com/oceanprotocol/ocean-subgraph/pull/658)
|
||||||
|
- Release 3.0.5 [`68944f0`](https://github.com/oceanprotocol/ocean-subgraph/commit/68944f02a545ea9c06881dcd8883f7dcecd72063)
|
||||||
|
|
||||||
|
#### [v3.0.4](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.3...v3.0.4)
|
||||||
|
|
||||||
|
> 14 April 2023
|
||||||
|
|
||||||
|
- add more veOcean stats [`#655`](https://github.com/oceanprotocol/ocean-subgraph/pull/655)
|
||||||
|
- Bump vm2 from 3.9.15 to 3.9.16 [`#653`](https://github.com/oceanprotocol/ocean-subgraph/pull/653)
|
||||||
|
- Bump typescript from 5.0.3 to 5.0.4 [`#652`](https://github.com/oceanprotocol/ocean-subgraph/pull/652)
|
||||||
|
- Bump vm2 from 3.9.11 to 3.9.15 [`#649`](https://github.com/oceanprotocol/ocean-subgraph/pull/649)
|
||||||
|
- Bump release-it from 15.10.0 to 15.10.1 [`#651`](https://github.com/oceanprotocol/ocean-subgraph/pull/651)
|
||||||
|
- Release 3.0.4 [`c8541a0`](https://github.com/oceanprotocol/ocean-subgraph/commit/c8541a071ef13d51e2e62822a194710bef660729)
|
||||||
|
|
||||||
|
#### [v3.0.3](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.2...v3.0.3)
|
||||||
|
|
||||||
|
> 6 April 2023
|
||||||
|
|
||||||
|
- Removing amountFraction and adding timestamp [`#647`](https://github.com/oceanprotocol/ocean-subgraph/pull/647)
|
||||||
|
- Fixing decimals issue [`#644`](https://github.com/oceanprotocol/ocean-subgraph/pull/644)
|
||||||
|
- Bump typescript from 5.0.2 to 5.0.3 [`#641`](https://github.com/oceanprotocol/ocean-subgraph/pull/641)
|
||||||
|
- Bump release-it from 15.9.3 to 15.10.0 [`#640`](https://github.com/oceanprotocol/ocean-subgraph/pull/640)
|
||||||
|
- Release 3.0.3 [`d888d7d`](https://github.com/oceanprotocol/ocean-subgraph/commit/d888d7d2566c5fa0fe21903bd16d0b5329815526)
|
||||||
|
|
||||||
|
#### [v3.0.2](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.1...v3.0.2)
|
||||||
|
|
||||||
|
> 31 March 2023
|
||||||
|
|
||||||
|
- Storing the fraction of veOcean [`#623`](https://github.com/oceanprotocol/ocean-subgraph/pull/623)
|
||||||
|
- Bump eslint-config-prettier from 8.7.0 to 8.8.0 [`#637`](https://github.com/oceanprotocol/ocean-subgraph/pull/637)
|
||||||
|
- Bump prettier from 2.8.4 to 2.8.7 [`#636`](https://github.com/oceanprotocol/ocean-subgraph/pull/636)
|
||||||
|
- Bump release-it from 15.9.1 to 15.9.3 [`#638`](https://github.com/oceanprotocol/ocean-subgraph/pull/638)
|
||||||
|
- Bump typescript from 4.9.5 to 5.0.2 [`#632`](https://github.com/oceanprotocol/ocean-subgraph/pull/632)
|
||||||
|
- Bump release-it from 15.8.0 to 15.9.1 [`#634`](https://github.com/oceanprotocol/ocean-subgraph/pull/634)
|
||||||
|
- Update ocean-lib with 2.7.0 version. [`#633`](https://github.com/oceanprotocol/ocean-subgraph/pull/633)
|
||||||
|
- Bump eslint-config-prettier from 8.6.0 to 8.7.0 [`#625`](https://github.com/oceanprotocol/ocean-subgraph/pull/625)
|
||||||
|
- Bump @oceanprotocol/lib from 2.6.1 to 2.6.3 [`#614`](https://github.com/oceanprotocol/ocean-subgraph/pull/614)
|
||||||
|
- Bump release-it from 15.7.0 to 15.8.0 [`#624`](https://github.com/oceanprotocol/ocean-subgraph/pull/624)
|
||||||
|
- Bump @oceanprotocol/contracts from 1.1.8 to 1.1.12 [`#627`](https://github.com/oceanprotocol/ocean-subgraph/pull/627)
|
||||||
|
- Bump release-it from 15.6.0 to 15.7.0 [`#618`](https://github.com/oceanprotocol/ocean-subgraph/pull/618)
|
||||||
|
- Update README.md [`#617`](https://github.com/oceanprotocol/ocean-subgraph/pull/617)
|
||||||
|
- Update copyright year. [`#615`](https://github.com/oceanprotocol/ocean-subgraph/pull/615)
|
||||||
|
- Bump prettier from 2.8.3 to 2.8.4 [`#612`](https://github.com/oceanprotocol/ocean-subgraph/pull/612)
|
||||||
|
- Bump http-cache-semantics from 4.1.0 to 4.1.1 [`#608`](https://github.com/oceanprotocol/ocean-subgraph/pull/608)
|
||||||
|
- Bump @graphprotocol/graph-ts from 0.29.1 to 0.29.3 [`#611`](https://github.com/oceanprotocol/ocean-subgraph/pull/611)
|
||||||
|
- Bump typescript from 4.9.4 to 4.9.5 [`#610`](https://github.com/oceanprotocol/ocean-subgraph/pull/610)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.37.7 to 0.38.0 [`#609`](https://github.com/oceanprotocol/ocean-subgraph/pull/609)
|
||||||
|
- Release 3.0.2 [`de5f1aa`](https://github.com/oceanprotocol/ocean-subgraph/commit/de5f1aab4bc70d6ec831fa0f24099666ef3c46a1)
|
||||||
|
|
||||||
|
#### [v3.0.1](https://github.com/oceanprotocol/ocean-subgraph/compare/v3.0.0...v3.0.1)
|
||||||
|
|
||||||
|
> 27 January 2023
|
||||||
|
|
||||||
|
- fix veDeposit id generation [`#606`](https://github.com/oceanprotocol/ocean-subgraph/pull/606)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.37.2 to 0.37.7 [`#603`](https://github.com/oceanprotocol/ocean-subgraph/pull/603)
|
||||||
|
- Bump eslint-plugin-import from 2.27.4 to 2.27.5 [`#602`](https://github.com/oceanprotocol/ocean-subgraph/pull/602)
|
||||||
|
- Tracking OPC fees [`#593`](https://github.com/oceanprotocol/ocean-subgraph/pull/593)
|
||||||
|
- Bump prettier from 2.8.2 to 2.8.3 [`#600`](https://github.com/oceanprotocol/ocean-subgraph/pull/600)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.37.1 to 0.37.2 [`#599`](https://github.com/oceanprotocol/ocean-subgraph/pull/599)
|
||||||
|
- Bump eslint-plugin-import from 2.26.0 to 2.27.4 [`#601`](https://github.com/oceanprotocol/ocean-subgraph/pull/601)
|
||||||
|
- Bump eslint-config-prettier from 8.5.0 to 8.6.0 [`#596`](https://github.com/oceanprotocol/ocean-subgraph/pull/596)
|
||||||
|
- Bump prettier from 2.8.1 to 2.8.2 [`#597`](https://github.com/oceanprotocol/ocean-subgraph/pull/597)
|
||||||
|
- Bump @oceanprotocol/lib from 2.6.0 to 2.6.1 [`#598`](https://github.com/oceanprotocol/ocean-subgraph/pull/598)
|
||||||
|
- Bump json5 from 1.0.1 to 1.0.2 [`#594`](https://github.com/oceanprotocol/ocean-subgraph/pull/594)
|
||||||
|
- Bump @graphprotocol/graph-ts from 0.29.0 to 0.29.1 [`#590`](https://github.com/oceanprotocol/ocean-subgraph/pull/590)
|
||||||
|
- Bump @oceanprotocol/lib from 2.5.2 to 2.6.0 [`#591`](https://github.com/oceanprotocol/ocean-subgraph/pull/591)
|
||||||
|
- Bump release-it from 15.5.1 to 15.6.0 [`#592`](https://github.com/oceanprotocol/ocean-subgraph/pull/592)
|
||||||
|
- Bump typescript from 4.9.3 to 4.9.4 [`#586`](https://github.com/oceanprotocol/ocean-subgraph/pull/586)
|
||||||
|
- Bump mocha from 10.1.0 to 10.2.0 [`#583`](https://github.com/oceanprotocol/ocean-subgraph/pull/583)
|
||||||
|
- Bump qs from 6.5.2 to 6.5.3 [`#587`](https://github.com/oceanprotocol/ocean-subgraph/pull/587)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.37.0 to 0.37.1 [`#585`](https://github.com/oceanprotocol/ocean-subgraph/pull/585)
|
||||||
|
- Bump prettier from 2.8.0 to 2.8.1 [`#584`](https://github.com/oceanprotocol/ocean-subgraph/pull/584)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.36.1 to 0.37.0 [`#578`](https://github.com/oceanprotocol/ocean-subgraph/pull/578)
|
||||||
|
- Bump decode-uri-component from 0.2.0 to 0.2.2 [`#581`](https://github.com/oceanprotocol/ocean-subgraph/pull/581)
|
||||||
|
- Bump release-it from 15.5.0 to 15.5.1 [`#579`](https://github.com/oceanprotocol/ocean-subgraph/pull/579)
|
||||||
|
- Bump @types/mocha from 10.0.0 to 10.0.1 [`#580`](https://github.com/oceanprotocol/ocean-subgraph/pull/580)
|
||||||
|
- Bump prettier from 2.7.1 to 2.8.0 [`#577`](https://github.com/oceanprotocol/ocean-subgraph/pull/577)
|
||||||
|
- Release 2.1.4 [`7c35711`](https://github.com/oceanprotocol/ocean-subgraph/commit/7c35711f722b7ea487d8b8c9aa3e42d71f2beb56)
|
||||||
|
- Release 3.0.1 [`3de53c5`](https://github.com/oceanprotocol/ocean-subgraph/commit/3de53c519750ca40ec269ed21f7c17773b53b139)
|
||||||
|
|
||||||
|
### [v3.0.0](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.1.4...v3.0.0)
|
||||||
|
|
||||||
|
> 24 November 2022
|
||||||
|
|
||||||
|
#### [v2.1.4](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.1.3...v2.1.4)
|
||||||
|
|
||||||
|
> 27 January 2023
|
||||||
|
|
||||||
|
- fix veDeposit id generation [`#606`](https://github.com/oceanprotocol/ocean-subgraph/pull/606)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.37.2 to 0.37.7 [`#603`](https://github.com/oceanprotocol/ocean-subgraph/pull/603)
|
||||||
|
- Bump eslint-plugin-import from 2.27.4 to 2.27.5 [`#602`](https://github.com/oceanprotocol/ocean-subgraph/pull/602)
|
||||||
|
- Tracking OPC fees [`#593`](https://github.com/oceanprotocol/ocean-subgraph/pull/593)
|
||||||
|
- Bump prettier from 2.8.2 to 2.8.3 [`#600`](https://github.com/oceanprotocol/ocean-subgraph/pull/600)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.37.1 to 0.37.2 [`#599`](https://github.com/oceanprotocol/ocean-subgraph/pull/599)
|
||||||
|
- Bump eslint-plugin-import from 2.26.0 to 2.27.4 [`#601`](https://github.com/oceanprotocol/ocean-subgraph/pull/601)
|
||||||
|
- Bump eslint-config-prettier from 8.5.0 to 8.6.0 [`#596`](https://github.com/oceanprotocol/ocean-subgraph/pull/596)
|
||||||
|
- Bump prettier from 2.8.1 to 2.8.2 [`#597`](https://github.com/oceanprotocol/ocean-subgraph/pull/597)
|
||||||
|
- Bump @oceanprotocol/lib from 2.6.0 to 2.6.1 [`#598`](https://github.com/oceanprotocol/ocean-subgraph/pull/598)
|
||||||
|
- Bump json5 from 1.0.1 to 1.0.2 [`#594`](https://github.com/oceanprotocol/ocean-subgraph/pull/594)
|
||||||
|
- Bump @graphprotocol/graph-ts from 0.29.0 to 0.29.1 [`#590`](https://github.com/oceanprotocol/ocean-subgraph/pull/590)
|
||||||
|
- Bump @oceanprotocol/lib from 2.5.2 to 2.6.0 [`#591`](https://github.com/oceanprotocol/ocean-subgraph/pull/591)
|
||||||
|
- Bump release-it from 15.5.1 to 15.6.0 [`#592`](https://github.com/oceanprotocol/ocean-subgraph/pull/592)
|
||||||
|
- Bump typescript from 4.9.3 to 4.9.4 [`#586`](https://github.com/oceanprotocol/ocean-subgraph/pull/586)
|
||||||
|
- Bump mocha from 10.1.0 to 10.2.0 [`#583`](https://github.com/oceanprotocol/ocean-subgraph/pull/583)
|
||||||
|
- Bump qs from 6.5.2 to 6.5.3 [`#587`](https://github.com/oceanprotocol/ocean-subgraph/pull/587)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.37.0 to 0.37.1 [`#585`](https://github.com/oceanprotocol/ocean-subgraph/pull/585)
|
||||||
|
- Bump prettier from 2.8.0 to 2.8.1 [`#584`](https://github.com/oceanprotocol/ocean-subgraph/pull/584)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.36.1 to 0.37.0 [`#578`](https://github.com/oceanprotocol/ocean-subgraph/pull/578)
|
||||||
|
- Bump decode-uri-component from 0.2.0 to 0.2.2 [`#581`](https://github.com/oceanprotocol/ocean-subgraph/pull/581)
|
||||||
|
- Bump release-it from 15.5.0 to 15.5.1 [`#579`](https://github.com/oceanprotocol/ocean-subgraph/pull/579)
|
||||||
|
- Bump @types/mocha from 10.0.0 to 10.0.1 [`#580`](https://github.com/oceanprotocol/ocean-subgraph/pull/580)
|
||||||
|
- Bump prettier from 2.7.1 to 2.8.0 [`#577`](https://github.com/oceanprotocol/ocean-subgraph/pull/577)
|
||||||
|
- nft transfer event [`#573`](https://github.com/oceanprotocol/ocean-subgraph/pull/573)
|
||||||
|
- add lastPriceToken [`#567`](https://github.com/oceanprotocol/ocean-subgraph/pull/567)
|
||||||
|
- Bump typescript from 4.8.4 to 4.9.3 [`#576`](https://github.com/oceanprotocol/ocean-subgraph/pull/576)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.35.0 to 0.36.1 [`#575`](https://github.com/oceanprotocol/ocean-subgraph/pull/575)
|
||||||
|
- Bump @oceanprotocol/lib from 2.5.1 to 2.5.2 [`#574`](https://github.com/oceanprotocol/ocean-subgraph/pull/574)
|
||||||
|
- Bump @graphprotocol/graph-ts from 0.28.1 to 0.29.0 [`#571`](https://github.com/oceanprotocol/ocean-subgraph/pull/571)
|
||||||
|
- Bump chai and @types/chai [`#572`](https://github.com/oceanprotocol/ocean-subgraph/pull/572)
|
||||||
|
- Bump @oceanprotocol/lib from 2.4.0 to 2.5.1 [`#569`](https://github.com/oceanprotocol/ocean-subgraph/pull/569)
|
||||||
|
- Bump @oceanprotocol/lib from 2.3.0 to 2.4.0 [`#568`](https://github.com/oceanprotocol/ocean-subgraph/pull/568)
|
||||||
|
- Bump @oceanprotocol/contracts from 1.1.7 to 1.1.8 [`#566`](https://github.com/oceanprotocol/ocean-subgraph/pull/566)
|
||||||
|
- Bump @oceanprotocol/lib from 2.2.2 to 2.3.0 [`#565`](https://github.com/oceanprotocol/ocean-subgraph/pull/565)
|
||||||
|
- Bump @graphprotocol/graph-ts from 0.28.0 to 0.28.1 [`#559`](https://github.com/oceanprotocol/ocean-subgraph/pull/559)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.34.0 to 0.35.0 [`#560`](https://github.com/oceanprotocol/ocean-subgraph/pull/560)
|
||||||
|
- Bump mocha from 10.0.0 to 10.1.0 [`#561`](https://github.com/oceanprotocol/ocean-subgraph/pull/561)
|
||||||
|
- Bump @oceanprotocol/lib from 2.2.1 to 2.2.2 [`#562`](https://github.com/oceanprotocol/ocean-subgraph/pull/562)
|
||||||
|
- Bump @oceanprotocol/lib from 2.1.1 to 2.2.1 [`#557`](https://github.com/oceanprotocol/ocean-subgraph/pull/557)
|
||||||
|
- Bump release-it from 15.4.2 to 15.5.0 [`#558`](https://github.com/oceanprotocol/ocean-subgraph/pull/558)
|
||||||
|
- Bump @types/mocha from 9.1.1 to 10.0.0 [`#556`](https://github.com/oceanprotocol/ocean-subgraph/pull/556)
|
||||||
|
- Bump @graphprotocol/graph-cli from 0.33.1 to 0.34.0 [`#555`](https://github.com/oceanprotocol/ocean-subgraph/pull/555)
|
||||||
|
- Bump typescript from 4.8.3 to 4.8.4 [`#554`](https://github.com/oceanprotocol/ocean-subgraph/pull/554)
|
||||||
|
- Bump @graphprotocol/graph-ts from 0.27.0 to 0.28.0 [`#553`](https://github.com/oceanprotocol/ocean-subgraph/pull/553)
|
||||||
|
- Release 2.1.4 [`7c35711`](https://github.com/oceanprotocol/ocean-subgraph/commit/7c35711f722b7ea487d8b8c9aa3e42d71f2beb56)
|
||||||
|
|
||||||
|
#### [v2.1.3](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.1.2...v2.1.3)
|
||||||
|
|
||||||
|
> 30 September 2022
|
||||||
|
|
||||||
|
- add chainId and nftAddress [`#552`](https://github.com/oceanprotocol/ocean-subgraph/pull/552)
|
||||||
|
- Bump vm2 from 3.9.9 to 3.9.11 [`#550`](https://github.com/oceanprotocol/ocean-subgraph/pull/550)
|
||||||
|
- Release 2.1.3 [`ae78cae`](https://github.com/oceanprotocol/ocean-subgraph/commit/ae78cae6083514592756f2549f21a307361d96d8)
|
||||||
|
|
||||||
|
#### [v2.1.2](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.1.1...v2.1.2)
|
||||||
|
|
||||||
|
> 28 September 2022
|
||||||
|
|
||||||
|
- fix tokenRemoved [`#549`](https://github.com/oceanprotocol/ocean-subgraph/pull/549)
|
||||||
|
- Bump @oceanprotocol/lib from 2.0.2 to 2.1.1 [`#545`](https://github.com/oceanprotocol/ocean-subgraph/pull/545)
|
||||||
|
- Bump eslint-config-oceanprotocol from 2.0.3 to 2.0.4 [`#546`](https://github.com/oceanprotocol/ocean-subgraph/pull/546)
|
||||||
|
- Release 2.1.2 [`9209408`](https://github.com/oceanprotocol/ocean-subgraph/commit/92094086f98ebe7470f1fcbeeb297fbb695a431e)
|
||||||
|
|
||||||
|
#### [v2.1.1](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.1.0...v2.1.1)
|
||||||
|
|
||||||
|
> 26 September 2022
|
||||||
|
|
||||||
|
- fix allocation [`#544`](https://github.com/oceanprotocol/ocean-subgraph/pull/544)
|
||||||
|
- Release 2.1.1 [`253dc63`](https://github.com/oceanprotocol/ocean-subgraph/commit/253dc63fa853011ed95f3501cc4cf0eed6d22f73)
|
||||||
|
|
||||||
#### [v2.1.0](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.7...v2.1.0)
|
#### [v2.1.0](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.7...v2.1.0)
|
||||||
|
|
||||||
|
> 23 September 2022
|
||||||
|
|
||||||
- Feature/more ve [`#543`](https://github.com/oceanprotocol/ocean-subgraph/pull/543)
|
- Feature/more ve [`#543`](https://github.com/oceanprotocol/ocean-subgraph/pull/543)
|
||||||
|
- Release 2.1.0 [`6c4b270`](https://github.com/oceanprotocol/ocean-subgraph/commit/6c4b2705645632b23dc90809868f25550238f2e1)
|
||||||
|
|
||||||
#### [v2.0.7](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.6...v2.0.7)
|
#### [v2.0.7](https://github.com/oceanprotocol/ocean-subgraph/compare/v2.0.6...v2.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/
|
COPY package*.json /usr/src/app/
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app/
|
||||||
RUN npm install
|
ENV NODE_ENV=production
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
|
||||||
|
FROM base as runner
|
||||||
|
ENV NODE_ENV=production
|
||||||
COPY . /usr/src/app
|
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
|
ENV DEPLOY_SUBGRAPH=true
|
||||||
ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
|
ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
|
10
README.md
10
README.md
@ -30,10 +30,12 @@
|
|||||||
|
|
||||||
This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/` namespace for all networks the Ocean Protocol contracts are deployed to:
|
This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/` namespace for all networks the Ocean Protocol contracts are deployed to:
|
||||||
|
|
||||||
- [v4.subgraph.ropsten.oceanprotocol.com](https://v4.subgraph.ropsten.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
- [v4.subgraph.mainnet.oceanprotocol.com](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||||
- [v4.subgraph.rinkeby.oceanprotocol.com](https://v4.subgraph.rinkeby.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
- [v4.subgraph.polygon.oceanprotocol.com](https://v4.subgraph.polygon.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
||||||
|
- [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.mumbai.oceanprotocol.com](https://v4.subgraph.mumbai.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)
|
||||||
- [v4.subgraph.moonbase.oceanprotocol.com](https://v4.subgraph.moonbase.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql)
|
|
||||||
|
|
||||||
## ⛵ Example Queries
|
## ⛵ Example Queries
|
||||||
|
|
||||||
@ -258,7 +260,7 @@ You can edit the event handler code and then run `npm run deploy:local`, with so
|
|||||||
## 🏛 License
|
## 🏛 License
|
||||||
|
|
||||||
```
|
```
|
||||||
Copyright ((C)) 2022 Ocean Protocol Foundation
|
Copyright ((C)) 2023 Ocean Protocol Foundation
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -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": {}
|
|
||||||
}
|
|
657
deployment/README.md
Normal file
657
deployment/README.md
Normal file
@ -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" ]
|
if [ "${DEPLOY_SUBGRAPH}" = "true" ]
|
||||||
then
|
then
|
||||||
|
rm -f /ocean-subgraph/ready
|
||||||
echo "Waiting for contracts to be deployed"
|
echo "Waiting for contracts to be deployed"
|
||||||
while [ ! -f "/ocean-contracts/artifacts/ready" ]; do
|
while [ ! -f "/ocean-contracts/artifacts/ready" ]; do
|
||||||
sleep 2
|
sleep 2
|
||||||
@ -13,5 +14,7 @@ then
|
|||||||
export ADDRESS_FILE="/ocean-contracts/artifacts/address.json"
|
export ADDRESS_FILE="/ocean-contracts/artifacts/address.json"
|
||||||
cd /usr/src/app/
|
cd /usr/src/app/
|
||||||
npm run quickstart:barge
|
npm run quickstart:barge
|
||||||
|
sleep 3
|
||||||
|
touch /ocean-subgraph/ready
|
||||||
fi
|
fi
|
||||||
tail -f /dev/null
|
tail -f /dev/null
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
graph-node:
|
graph-node:
|
||||||
image: graphprotocol/graph-node:v0.26.0
|
image: graphprotocol/graph-node:v0.28.2
|
||||||
ports:
|
ports:
|
||||||
- '9000:8000'
|
- '9000:8000'
|
||||||
- '8001:8001'
|
- '8001:8001'
|
||||||
@ -17,8 +17,9 @@ services:
|
|||||||
postgres_pass: let-me-in
|
postgres_pass: let-me-in
|
||||||
postgres_db: graph-node
|
postgres_db: graph-node
|
||||||
ipfs: 'ipfs:5001'
|
ipfs: 'ipfs:5001'
|
||||||
ethereum: 'rinkeby:https://rinkeby.infura.io/v3/${INFURA_PROJECT_ID}'
|
ethereum: 'oasis_saphire_testnet:http://192.168.136.129:8080'
|
||||||
RUST_LOG: info
|
RUST_LOG: warning
|
||||||
|
GRAPH_ETHEREUM_MAX_BLOCK_RANGE_SIZE: 100
|
||||||
ipfs:
|
ipfs:
|
||||||
image: ipfs/go-ipfs:v0.4.23
|
image: ipfs/go-ipfs:v0.4.23
|
||||||
ports:
|
ports:
|
||||||
|
50587
package-lock.json
generated
50587
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
55
package.json
55
package.json
@ -1,12 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "ocean-subgraph",
|
"name": "ocean-subgraph",
|
||||||
"version": "2.1.0",
|
"version": "4.0.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "",
|
"start": "",
|
||||||
"quickstart:development": "node ./scripts/generatenetworkssubgraphs.js development && npm run codegen && npm run create:local && npm run deploy:local",
|
"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: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: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: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: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",
|
"quickstart:moonbase": "node ./scripts/generatenetworkssubgraphs.js moonbase && npm run codegen && npm run create:local && npm run deploy:local",
|
||||||
@ -14,23 +13,33 @@
|
|||||||
"quickstart:mainnet": "node ./scripts/generatenetworkssubgraphs.js mainnet && npm run codegen && npm run create:local && npm run deploy:local",
|
"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: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: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: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: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": "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",
|
"create:local-barge": "graph create oceanprotocol/ocean-subgraph --node http://172.15.0.15:8020",
|
||||||
"codegen": "graph codegen --output-dir src/@types",
|
"codegen": "graph codegen --output-dir src/@types",
|
||||||
"build": "graph build",
|
"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: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": "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 --debug --ipfs http://172.15.0.16:5001 --node http://172.15.0.15: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": "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-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'",
|
"test-dispenser": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/Dispenser.test.ts'",
|
||||||
|
"test-simple": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/SimpleSubgraph.test.ts'",
|
||||||
"test-fixed": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/FixedRateExchange.test.ts'",
|
"test-fixed": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/FixedRateExchange.test.ts'",
|
||||||
"test-users": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/users.test.ts'",
|
"test-users": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/users.test.ts'",
|
||||||
"test-ve": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/VeOcean.test.ts'",
|
"test-ve": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/VeOcean.test.ts'",
|
||||||
"test-df": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/DFRewards.test.ts'",
|
"test-df": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/DFRewards.test.ts'",
|
||||||
|
"test-dt": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/Datatoken.test.ts'",
|
||||||
"test-zend": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/ZEnding.test.ts'",
|
"test-zend": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/ZEnding.test.ts'",
|
||||||
|
"test-publish-consume": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/SimplePublishConsume.test.ts'",
|
||||||
|
"test-nft": "TS_NODE_PROJECT='test/integration/tsconfig.json' mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/Nft.test.ts'",
|
||||||
"lint": "eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx .",
|
"lint": "eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx .",
|
||||||
"lint:fix": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx . --fix",
|
"lint:fix": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx . --fix",
|
||||||
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json,yaml}' --write",
|
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json,yaml}' --write",
|
||||||
@ -40,37 +49,39 @@
|
|||||||
"changelog": "auto-changelog -p"
|
"changelog": "auto-changelog -p"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@graphprotocol/graph-cli": "^0.33.1",
|
"@types/chai": "^4.3.11",
|
||||||
"@graphprotocol/graph-ts": "^0.27.0",
|
|
||||||
"@types/chai": "^4.3.3",
|
|
||||||
"@types/chai-spies": "^1.0.3",
|
"@types/chai-spies": "^1.0.3",
|
||||||
"@types/mocha": "^9.1.1",
|
"@types/mocha": "^10.0.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
"@types/node": "^20.8.2",
|
||||||
"@typescript-eslint/parser": "^4.33.0",
|
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
||||||
|
"@typescript-eslint/parser": "^6.19.0",
|
||||||
"auto-changelog": "^2.4.0",
|
"auto-changelog": "^2.4.0",
|
||||||
"chai": "^4.3.6",
|
"chai": "^4.3.10",
|
||||||
"chai-spies": "^1.0.0",
|
"chai-spies": "^1.0.0",
|
||||||
|
"cross-fetch": "^3.1.6",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-config-oceanprotocol": "^2.0.3",
|
"eslint-config-oceanprotocol": "^2.0.4",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.27.5",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"eslint-plugin-standard": "^5.0.0",
|
"eslint-plugin-standard": "^5.0.0",
|
||||||
"mocha": "^10.0.0",
|
"ethereumjs-util": "^7.1.5",
|
||||||
"mock-local-storage": "^1.1.23",
|
"mocha": "^10.2.0",
|
||||||
"prettier": "^2.7.1",
|
"mock-local-storage": "^1.1.24",
|
||||||
"release-it": "^15.4.2",
|
"prettier": "^2.8.8",
|
||||||
|
"release-it": "^17.0.0",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"ts-node-dev": "^2.0.0",
|
"ts-node-dev": "^2.0.0",
|
||||||
"ts-node-register": "^1.0.0",
|
"ts-node-register": "^1.0.0",
|
||||||
"typescript": "^4.8.3"
|
"typescript": "^5.4.5",
|
||||||
|
"@oceanprotocol/lib": "^2.7.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oceanprotocol/contracts": "^1.1.7",
|
"@oceanprotocol/contracts": "^2.0.3",
|
||||||
"@oceanprotocol/lib": "^2.0.2",
|
"@graphprotocol/graph-cli": "^0.71.0",
|
||||||
"cross-fetch": "^3.1.4"
|
"@graphprotocol/graph-ts": "^0.31.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
232
schema.graphql
232
schema.graphql
@ -30,7 +30,7 @@ type Token @entity {
|
|||||||
publishMarketFeeAmount: BigDecimal
|
publishMarketFeeAmount: BigDecimal
|
||||||
|
|
||||||
"template ID of the datatoken"
|
"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"
|
"number of addresses holding a balance of datatoken , TODO: can we actually calculate this? what happens when users trade the dts"
|
||||||
holderCount: BigInt!
|
holderCount: BigInt!
|
||||||
@ -52,11 +52,11 @@ type Token @entity {
|
|||||||
|
|
||||||
"datatoken creation transaction id"
|
"datatoken creation transaction id"
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
"block number when it was created"
|
"block number when it was created"
|
||||||
block: Int!
|
block: Int!
|
||||||
|
|
||||||
lastPriceToken: String!
|
lastPriceToken: Token
|
||||||
lastPriceValue: BigDecimal!
|
lastPriceValue: BigDecimal!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,9 +76,9 @@ type Nft @entity{
|
|||||||
tokenUri: String
|
tokenUri: String
|
||||||
|
|
||||||
"address of the owner of the nft"
|
"address of the owner of the nft"
|
||||||
owner: String!
|
owner: User!
|
||||||
"address of the creator of the nft"
|
"address of the creator of the nft"
|
||||||
creator: String!
|
creator: User!
|
||||||
|
|
||||||
"same as id, it's just for easy discoverability"
|
"same as id, it's just for easy discoverability"
|
||||||
address: String!
|
address: String!
|
||||||
@ -98,6 +98,9 @@ type Nft @entity{
|
|||||||
"template address"
|
"template address"
|
||||||
template: String!
|
template: String!
|
||||||
|
|
||||||
|
"template ID of the datatoken"
|
||||||
|
templateId: Int
|
||||||
|
|
||||||
"set if NFT is transferable"
|
"set if NFT is transferable"
|
||||||
transferable: Boolean!
|
transferable: Boolean!
|
||||||
|
|
||||||
@ -105,6 +108,7 @@ type Nft @entity{
|
|||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
"nft creation transaction id"
|
"nft creation transaction id"
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
"block number when it was created"
|
"block number when it was created"
|
||||||
block: Int
|
block: Int
|
||||||
|
|
||||||
@ -115,6 +119,7 @@ type Nft @entity{
|
|||||||
hasMetadata: Boolean!
|
hasMetadata: Boolean!
|
||||||
|
|
||||||
nftData: [NftData!] @derivedFrom(field: "nft")
|
nftData: [NftData!] @derivedFrom(field: "nft")
|
||||||
|
transferHistory: [NftTransferHistory!] @derivedFrom(field: "nft")
|
||||||
}
|
}
|
||||||
|
|
||||||
type NftData @entity{
|
type NftData @entity{
|
||||||
@ -131,6 +136,7 @@ type OrderReuse @entity {
|
|||||||
caller: String!
|
caller: String!
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
block: Int!
|
block: Int!
|
||||||
providerFee: String
|
providerFee: String
|
||||||
providerFeeValidUntil: BigInt
|
providerFeeValidUntil: BigInt
|
||||||
@ -140,7 +146,7 @@ type OrderReuse @entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Order @entity {
|
type Order @entity {
|
||||||
"transaction hash - token address - from address"
|
"transaction hash - token address - from address - eventIndex"
|
||||||
id: ID!
|
id: ID!
|
||||||
datatoken: Token!
|
datatoken: Token!
|
||||||
|
|
||||||
@ -148,6 +154,7 @@ type Order @entity {
|
|||||||
payer: User!
|
payer: User!
|
||||||
amount: BigDecimal!
|
amount: BigDecimal!
|
||||||
serviceIndex: Int!
|
serviceIndex: Int!
|
||||||
|
nftOwner: User!
|
||||||
|
|
||||||
|
|
||||||
# the fees will be updated from an event that will be created after (todo)
|
# the fees will be updated from an event that will be created after (todo)
|
||||||
@ -165,9 +172,10 @@ type Order @entity {
|
|||||||
|
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
block: Int!
|
block: Int!
|
||||||
|
|
||||||
lastPriceToken: String!
|
lastPriceToken: Token
|
||||||
lastPriceValue: BigDecimal!
|
lastPriceValue: BigDecimal!
|
||||||
estimatedUSDValue: BigDecimal!
|
estimatedUSDValue: BigDecimal!
|
||||||
gasUsed: BigDecimal
|
gasUsed: BigDecimal
|
||||||
@ -218,6 +226,7 @@ type FixedRateExchange @entity {
|
|||||||
|
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
block: Int!
|
block: Int!
|
||||||
|
|
||||||
"address of the market where the datatoken was created. This address collects market fees."
|
"address of the market where the datatoken was created. This address collects market fees."
|
||||||
@ -244,6 +253,7 @@ type FixedRateExchangeUpdate @entity {
|
|||||||
block: Int!
|
block: Int!
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
type FixedRateExchangeSwap @entity {
|
type FixedRateExchangeSwap @entity {
|
||||||
@ -255,6 +265,10 @@ type FixedRateExchangeSwap @entity {
|
|||||||
block: Int!
|
block: Int!
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
|
oceanFeeAmount: BigDecimal!
|
||||||
|
marketFeeAmount: BigDecimal!
|
||||||
|
consumeMarketFeeAmount: BigDecimal!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -280,6 +294,7 @@ type Dispenser @entity {
|
|||||||
block: Int!
|
block: Int!
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
|
|
||||||
dispenses: [DispenserTransaction!] @derivedFrom(field: "dispenser")
|
dispenses: [DispenserTransaction!] @derivedFrom(field: "dispenser")
|
||||||
}
|
}
|
||||||
@ -293,6 +308,7 @@ type DispenserTransaction @entity {
|
|||||||
block: Int!
|
block: Int!
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
"utility type"
|
"utility type"
|
||||||
@ -333,6 +349,9 @@ type GlobalStatistic @entity {
|
|||||||
"number of dispensers created"
|
"number of dispensers created"
|
||||||
dispenserCount: Int!
|
dispenserCount: Int!
|
||||||
|
|
||||||
|
"total ocean locked in veOcean"
|
||||||
|
totalOceanLocked:BigDecimal!
|
||||||
|
|
||||||
"current version"
|
"current version"
|
||||||
version: String
|
version: String
|
||||||
}
|
}
|
||||||
@ -377,13 +396,13 @@ type NftUpdate @entity {
|
|||||||
block: Int!
|
block: Int!
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
type Template @entity{
|
type Template @entity{
|
||||||
id: ID!
|
id: ID!
|
||||||
fixedRateTemplates: [String!]
|
fixedRateTemplates: [String!]
|
||||||
dispenserTemplates: [String!]
|
dispenserTemplates: [String!]
|
||||||
ssTemplates: [String!]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Not tracking allocationToId or idToAllocation
|
# Not tracking allocationToId or idToAllocation
|
||||||
@ -398,12 +417,15 @@ type VeAllocateUser @entity{
|
|||||||
firstContact: Int!
|
firstContact: Int!
|
||||||
lastContact: Int!
|
lastContact: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
veOcean: VeOCEAN!
|
veOcean: VeOCEAN!
|
||||||
}
|
}
|
||||||
|
|
||||||
type VeAllocateId @entity{
|
type VeAllocateId @entity{
|
||||||
"id = {DataNFT Address}-{chain id}"
|
"id = {DataNFT Address}-{chain id}"
|
||||||
id: ID!
|
id: ID!
|
||||||
|
nftAddress: String!
|
||||||
|
chainId: BigInt!
|
||||||
|
|
||||||
veAllocation: [VeAllocation!] @derivedFrom(field: "allocationId")
|
veAllocation: [VeAllocation!] @derivedFrom(field: "allocationId")
|
||||||
allocatedTotal: BigDecimal!
|
allocatedTotal: BigDecimal!
|
||||||
@ -412,6 +434,7 @@ type VeAllocateId @entity{
|
|||||||
firstContact: Int!
|
firstContact: Int!
|
||||||
lastContact: Int!
|
lastContact: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
# we need to track allocation of user to id
|
# we need to track allocation of user to id
|
||||||
@ -431,6 +454,7 @@ type VeAllocation @entity {
|
|||||||
firstContact: Int!
|
firstContact: Int!
|
||||||
lastContact: Int!
|
lastContact: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
enum veAllocationUpdateType {
|
enum veAllocationUpdateType {
|
||||||
@ -439,7 +463,7 @@ enum veAllocationUpdateType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type VeAllocationUpdate @entity {
|
type VeAllocationUpdate @entity {
|
||||||
"{tx}-{VeAllocation id}"
|
"{tx}-{VeAllocation id}-{eventIndex}"
|
||||||
id: ID!
|
id: ID!
|
||||||
|
|
||||||
veAllocation: VeAllocation!
|
veAllocation: VeAllocation!
|
||||||
@ -449,20 +473,41 @@ type VeAllocationUpdate @entity {
|
|||||||
block: Int!
|
block: Int!
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
type VeDelegation @entity {
|
type VeDelegation @entity {
|
||||||
"id = tokenId"
|
"id = VeDelegation contract + tokenId"
|
||||||
id: ID!
|
id: ID!
|
||||||
delegator: VeOCEAN!
|
delegator: VeOCEAN!
|
||||||
receiver: VeOCEAN!
|
receiver: VeOCEAN!
|
||||||
tokenId: BigInt!
|
tokenId: BigInt!
|
||||||
amount: BigInt!
|
amount: BigDecimal!
|
||||||
|
lockedAmount: BigDecimal!
|
||||||
|
timeLeftUnlock: Int!
|
||||||
cancelTime: BigInt!
|
cancelTime: BigInt!
|
||||||
expireTime: BigInt!
|
expireTime: BigInt!
|
||||||
block: Int!
|
updates: [VeDelegationUpdate!] @derivedFrom(field: "veDelegation")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type VeDelegationUpdate @entity {
|
||||||
|
"id = {tx}-{eventIndex}"
|
||||||
|
id: ID!
|
||||||
|
block: Int!
|
||||||
|
timestamp: Int!
|
||||||
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
|
sender: String!
|
||||||
|
amount: BigDecimal!
|
||||||
|
cancelTime: BigInt!
|
||||||
|
expireTime: BigInt!
|
||||||
|
"type: CREATE_BOOST = 0, EXTEND_BOOST = 1, BURN_BOOST = 2"
|
||||||
|
type:Int!
|
||||||
|
veDelegation:VeDelegation!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
type VeOCEAN @entity {
|
type VeOCEAN @entity {
|
||||||
"id = {user address}"
|
"id = {user address}"
|
||||||
id: ID!
|
id: ID!
|
||||||
@ -474,12 +519,12 @@ type VeOCEAN @entity {
|
|||||||
delegates: [VeDelegation!] @derivedFrom(field: "receiver")
|
delegates: [VeDelegation!] @derivedFrom(field: "receiver")
|
||||||
deposits: [VeDeposit!] @derivedFrom(field: "veOcean")
|
deposits: [VeDeposit!] @derivedFrom(field: "veOcean")
|
||||||
claims: [VeClaim!] @derivedFrom(field: "veOcean")
|
claims: [VeClaim!] @derivedFrom(field: "veOcean")
|
||||||
allocation: VeAllocateUser! @derivedFrom(field: "veOcean")
|
allocation: VeAllocateUser @derivedFrom(field: "veOcean")
|
||||||
block: Int!
|
block: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
type VeDeposit @entity {
|
type VeDeposit @entity {
|
||||||
"id = {user address}-{timestamp}"
|
"id = {user address}-{tx}-{eventIndex}"
|
||||||
id: ID!
|
id: ID!
|
||||||
"veOcean holder"
|
"veOcean holder"
|
||||||
provider:String!
|
provider:String!
|
||||||
@ -494,7 +539,9 @@ type VeDeposit @entity {
|
|||||||
timestamp: BigInt!
|
timestamp: BigInt!
|
||||||
block: Int!
|
block: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
veOcean: VeOCEAN!
|
veOcean: VeOCEAN!
|
||||||
|
totalOceanLocked:BigDecimal!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -518,6 +565,7 @@ type VeFeeDistributorCheckPoint @entity {
|
|||||||
timestamp: BigInt!
|
timestamp: BigInt!
|
||||||
block: Int!
|
block: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
type VeClaim @entity {
|
type VeClaim @entity {
|
||||||
@ -532,6 +580,7 @@ type VeClaim @entity {
|
|||||||
timestamp: BigInt!
|
timestamp: BigInt!
|
||||||
block: Int!
|
block: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
veOcean: VeOCEAN!
|
veOcean: VeOCEAN!
|
||||||
VeFeeDistributor: VeFeeDistributor!
|
VeFeeDistributor: VeFeeDistributor!
|
||||||
}
|
}
|
||||||
@ -560,6 +609,7 @@ type DFHistory @entity {
|
|||||||
timestamp: BigInt!
|
timestamp: BigInt!
|
||||||
block: Int!
|
block: Int!
|
||||||
tx: String!
|
tx: String!
|
||||||
|
eventIndex: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -570,3 +620,157 @@ type DFReward @entity {
|
|||||||
availableClaims: [DFAvailableClaim!] @derivedFrom(field: "receiver")
|
availableClaims: [DFAvailableClaim!] @derivedFrom(field: "receiver")
|
||||||
history: [DFHistory!] @derivedFrom(field: "receiver")
|
history: [DFHistory!] @derivedFrom(field: "receiver")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NftTransferHistory @entity {
|
||||||
|
# ID = hash(nftAddress+txId+eventNumber)
|
||||||
|
id: ID!
|
||||||
|
nft: Nft!
|
||||||
|
oldOwner: User!
|
||||||
|
newOwner: User!
|
||||||
|
txId: String
|
||||||
|
eventIndex: Int!
|
||||||
|
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!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ export function handleAllocated(event: Allocated): void {
|
|||||||
history.type = 'Allocated'
|
history.type = 'Allocated'
|
||||||
history.timestamp = event.block.timestamp
|
history.timestamp = event.block.timestamp
|
||||||
history.tx = event.transaction.hash.toHex()
|
history.tx = event.transaction.hash.toHex()
|
||||||
|
history.eventIndex = event.logIndex.toI32()
|
||||||
history.block = event.block.number.toI32()
|
history.block = event.block.number.toI32()
|
||||||
history.save()
|
history.save()
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ export function handleClaimed(event: Claimed): void {
|
|||||||
history.type = 'Claimed'
|
history.type = 'Claimed'
|
||||||
history.timestamp = event.block.timestamp
|
history.timestamp = event.block.timestamp
|
||||||
history.tx = event.transaction.hash.toHex()
|
history.tx = event.transaction.hash.toHex()
|
||||||
|
history.eventIndex = event.logIndex.toI32()
|
||||||
history.block = event.block.number.toI32()
|
history.block = event.block.number.toI32()
|
||||||
history.save()
|
history.save()
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ export function handleNewDispenser(event: DispenserCreated): void {
|
|||||||
dispenser.allowedSwapper = event.params.allowedSwapper.toHex()
|
dispenser.allowedSwapper = event.params.allowedSwapper.toHex()
|
||||||
dispenser.createdTimestamp = event.block.timestamp.toI32()
|
dispenser.createdTimestamp = event.block.timestamp.toI32()
|
||||||
dispenser.tx = event.transaction.hash.toHex()
|
dispenser.tx = event.transaction.hash.toHex()
|
||||||
|
dispenser.eventIndex = event.logIndex.toI32()
|
||||||
dispenser.block = event.block.number.toI32()
|
dispenser.block = event.block.number.toI32()
|
||||||
dispenser.save()
|
dispenser.save()
|
||||||
|
|
||||||
@ -57,6 +58,7 @@ export function handleActivate(event: DispenserActivated): void {
|
|||||||
)
|
)
|
||||||
const dispenser = getDispenser(dispenserID)
|
const dispenser = getDispenser(dispenserID)
|
||||||
dispenser.active = true
|
dispenser.active = true
|
||||||
|
dispenser.eventIndex = event.logIndex.toI32()
|
||||||
dispenser.save()
|
dispenser.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,6 +69,7 @@ export function handleDeactivate(event: DispenserDeactivated): void {
|
|||||||
)
|
)
|
||||||
const dispenser = getDispenser(dispenserID)
|
const dispenser = getDispenser(dispenserID)
|
||||||
dispenser.active = false
|
dispenser.active = false
|
||||||
|
dispenser.eventIndex = event.logIndex.toI32()
|
||||||
dispenser.save()
|
dispenser.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +79,7 @@ export function handleAllowedSwapperChanged(
|
|||||||
const dispenserID = getDispenserGraphID(event.address, event.params.datatoken)
|
const dispenserID = getDispenserGraphID(event.address, event.params.datatoken)
|
||||||
const dispenser = getDispenser(dispenserID)
|
const dispenser = getDispenser(dispenserID)
|
||||||
dispenser.allowedSwapper = event.params.newAllowedSwapper.toHex()
|
dispenser.allowedSwapper = event.params.newAllowedSwapper.toHex()
|
||||||
|
dispenser.eventIndex = event.logIndex.toI32()
|
||||||
dispenser.save()
|
dispenser.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,10 +88,8 @@ export function handleTokensDispensed(event: TokensDispensed): void {
|
|||||||
event.address,
|
event.address,
|
||||||
event.params.datatokenAddress
|
event.params.datatokenAddress
|
||||||
)
|
)
|
||||||
const id = event.transaction.hash
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
.toHexString()
|
const id = `${event.transaction.hash.toHexString()}-${dispenserID}-${eventIndex}`
|
||||||
.concat('-')
|
|
||||||
.concat(dispenserID)
|
|
||||||
|
|
||||||
const dispenserTransaction = new DispenserTransaction(id)
|
const dispenserTransaction = new DispenserTransaction(id)
|
||||||
const dispenser = getDispenser(dispenserID)
|
const dispenser = getDispenser(dispenserID)
|
||||||
@ -98,6 +100,7 @@ export function handleTokensDispensed(event: TokensDispensed): void {
|
|||||||
|
|
||||||
dispenserTransaction.createdTimestamp = event.block.timestamp.toI32()
|
dispenserTransaction.createdTimestamp = event.block.timestamp.toI32()
|
||||||
dispenserTransaction.tx = event.transaction.hash.toHex()
|
dispenserTransaction.tx = event.transaction.hash.toHex()
|
||||||
|
dispenserTransaction.eventIndex = event.logIndex.toI32()
|
||||||
dispenserTransaction.block = event.block.number.toI32()
|
dispenserTransaction.block = event.block.number.toI32()
|
||||||
const token = getToken(event.params.datatokenAddress, true)
|
const token = getToken(event.params.datatokenAddress, true)
|
||||||
dispenserTransaction.amount = weiToDecimal(
|
dispenserTransaction.amount = weiToDecimal(
|
||||||
@ -111,5 +114,6 @@ export function handleOwnerWinthdraw(event: OwnerWithdrawed): void {
|
|||||||
const dispenserID = getDispenserGraphID(event.address, event.params.datatoken)
|
const dispenserID = getDispenserGraphID(event.address, event.params.datatoken)
|
||||||
const dispenser = getDispenser(dispenserID)
|
const dispenser = getDispenser(dispenserID)
|
||||||
dispenser.balance = decimal.ZERO
|
dispenser.balance = decimal.ZERO
|
||||||
|
dispenser.eventIndex = event.logIndex.toI32()
|
||||||
dispenser.save()
|
dispenser.save()
|
||||||
}
|
}
|
||||||
|
284
src/mappings/erc20Template3.ts
Normal file
284
src/mappings/erc20Template3.ts
Normal file
@ -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,11 +1,12 @@
|
|||||||
import { Order, Nft, OrderReuse } from '../@types/schema'
|
import { Order, Nft, OrderReuse } from '../@types/schema'
|
||||||
import { BigInt, BigDecimal } from '@graphprotocol/graph-ts'
|
import { BigInt, BigDecimal, Address, log } from '@graphprotocol/graph-ts'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NewPaymentCollector,
|
NewPaymentCollector,
|
||||||
OrderStarted,
|
OrderStarted,
|
||||||
PublishMarketFee,
|
PublishMarketFee,
|
||||||
PublishMarketFeeChanged,
|
PublishMarketFeeChanged,
|
||||||
|
ConsumeMarketFee,
|
||||||
AddedMinter,
|
AddedMinter,
|
||||||
AddedPaymentManager,
|
AddedPaymentManager,
|
||||||
RemovedMinter,
|
RemovedMinter,
|
||||||
@ -20,14 +21,19 @@ import { weiToDecimal } from './utils/generic'
|
|||||||
import { addOrder } from './utils/globalUtils'
|
import { addOrder } from './utils/globalUtils'
|
||||||
import { getToken, getUSDValue } from './utils/tokenUtils'
|
import { getToken, getUSDValue } from './utils/tokenUtils'
|
||||||
import { getUser } from './utils/userUtils'
|
import { getUser } from './utils/userUtils'
|
||||||
import { getOrderId } from './utils/orderUtils'
|
import {
|
||||||
|
getOrderId,
|
||||||
|
searchOrderForEvent,
|
||||||
|
searchOrderReusedForEvent
|
||||||
|
} from './utils/orderUtils'
|
||||||
|
|
||||||
export function handleOrderStarted(event: OrderStarted): void {
|
export function handleOrderStarted(event: OrderStarted): void {
|
||||||
const order = new Order(
|
const order = new Order(
|
||||||
getOrderId(
|
getOrderId(
|
||||||
event.transaction.hash.toHex(),
|
event.transaction.hash.toHex(),
|
||||||
event.address.toHex(),
|
event.address.toHex(),
|
||||||
event.transaction.from.toHex()
|
event.transaction.from.toHex(),
|
||||||
|
event.logIndex.toI32()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -38,6 +44,12 @@ export function handleOrderStarted(event: OrderStarted): void {
|
|||||||
const consumer = getUser(event.params.consumer.toHex())
|
const consumer = getUser(event.params.consumer.toHex())
|
||||||
order.consumer = consumer.id
|
order.consumer = consumer.id
|
||||||
|
|
||||||
|
if (token.nft) {
|
||||||
|
const nft = Nft.load(token.nft as string) as Nft
|
||||||
|
const nftOwner = getUser(nft.owner)
|
||||||
|
order.nftOwner = nftOwner.id
|
||||||
|
}
|
||||||
|
|
||||||
const payer = getUser(event.params.payer.toHex())
|
const payer = getUser(event.params.payer.toHex())
|
||||||
payer.totalOrders = payer.totalOrders.plus(integer.ONE)
|
payer.totalOrders = payer.totalOrders.plus(integer.ONE)
|
||||||
payer.save()
|
payer.save()
|
||||||
@ -53,19 +65,22 @@ export function handleOrderStarted(event: OrderStarted): void {
|
|||||||
const publishMarket = getUser(event.params.publishMarketAddress.toHex())
|
const publishMarket = getUser(event.params.publishMarketAddress.toHex())
|
||||||
order.publishingMarket = publishMarket.id
|
order.publishingMarket = publishMarket.id
|
||||||
|
|
||||||
// const consumeMarket = getUser(event.params..toHex())
|
|
||||||
// order.consumerMarket = consumeMarket.id
|
|
||||||
|
|
||||||
order.createdTimestamp = event.block.timestamp.toI32()
|
order.createdTimestamp = event.block.timestamp.toI32()
|
||||||
order.tx = event.transaction.hash.toHex()
|
order.tx = event.transaction.hash.toHex()
|
||||||
|
order.eventIndex = event.logIndex.toI32()
|
||||||
order.block = event.block.number.toI32()
|
order.block = event.block.number.toI32()
|
||||||
order.lastPriceToken = token.lastPriceToken
|
const tokenId = token.lastPriceToken
|
||||||
order.lastPriceValue = token.lastPriceValue
|
if (tokenId) {
|
||||||
order.estimatedUSDValue = getUSDValue(
|
const priceToken = getToken(Address.fromString(tokenId), false)
|
||||||
order.lastPriceToken,
|
order.lastPriceToken = priceToken.id
|
||||||
order.lastPriceValue,
|
order.lastPriceValue = token.lastPriceValue
|
||||||
order.createdTimestamp
|
order.estimatedUSDValue = getUSDValue(
|
||||||
)
|
priceToken.id,
|
||||||
|
order.lastPriceValue,
|
||||||
|
order.createdTimestamp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (event.receipt !== null && event.receipt!.gasUsed) {
|
if (event.receipt !== null && event.receipt!.gasUsed) {
|
||||||
order.gasUsed = event.receipt!.gasUsed.toBigDecimal()
|
order.gasUsed = event.receipt!.gasUsed.toBigDecimal()
|
||||||
} else {
|
} else {
|
||||||
@ -92,32 +107,56 @@ export function handleOrderStarted(event: OrderStarted): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function handlerOrderReused(event: OrderReused): void {
|
export function handlerOrderReused(event: OrderReused): void {
|
||||||
const orderId = getOrderId(
|
const order = searchOrderForEvent(
|
||||||
event.params.orderTxId.toHexString(),
|
event.params.orderTxId.toHexString(),
|
||||||
event.address.toHex(),
|
event.address.toHex(),
|
||||||
event.params.caller.toHex()
|
event.params.caller.toHex(),
|
||||||
|
event.logIndex.toI32()
|
||||||
)
|
)
|
||||||
const order = Order.load(orderId)
|
|
||||||
|
|
||||||
if (!order) return
|
if (!order) return
|
||||||
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
|
|
||||||
const reuseOrder = new OrderReuse(event.transaction.hash.toHex())
|
const reuseOrder = new OrderReuse(
|
||||||
|
`${event.transaction.hash.toHex()}-${eventIndex}`
|
||||||
|
)
|
||||||
if (event.transaction.gasPrice)
|
if (event.transaction.gasPrice)
|
||||||
reuseOrder.gasPrice = event.transaction.gasPrice
|
reuseOrder.gasPrice = event.transaction.gasPrice
|
||||||
else reuseOrder.gasPrice = BigInt.zero()
|
else reuseOrder.gasPrice = BigInt.zero()
|
||||||
if (event.receipt !== null && event.receipt!.gasUsed) {
|
if (event.receipt !== null && event.receipt!.gasUsed) {
|
||||||
reuseOrder.gasUsed = event.receipt!.gasUsed.toBigDecimal()
|
reuseOrder.gasUsed = event.receipt!.gasUsed.toBigDecimal()
|
||||||
} else reuseOrder.gasUsed = BigDecimal.zero()
|
} else reuseOrder.gasUsed = BigDecimal.zero()
|
||||||
reuseOrder.order = orderId
|
reuseOrder.order = order.id
|
||||||
reuseOrder.caller = event.params.caller.toHexString()
|
reuseOrder.caller = event.params.caller.toHexString()
|
||||||
reuseOrder.createdTimestamp = event.params.timestamp.toI32()
|
reuseOrder.createdTimestamp = event.params.timestamp.toI32()
|
||||||
reuseOrder.tx = event.transaction.hash.toHex()
|
reuseOrder.tx = event.transaction.hash.toHex()
|
||||||
|
reuseOrder.eventIndex = event.logIndex.toI32()
|
||||||
reuseOrder.block = event.params.number.toI32()
|
reuseOrder.block = event.params.number.toI32()
|
||||||
|
|
||||||
reuseOrder.save()
|
reuseOrder.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handlePublishMarketFee(event: PublishMarketFee): void {}
|
export function handlePublishMarketFee(event: PublishMarketFee): void {
|
||||||
|
const order = searchOrderForEvent(
|
||||||
|
event.transaction.hash.toHex(),
|
||||||
|
event.address.toHex(),
|
||||||
|
event.transaction.from.toHex(),
|
||||||
|
event.logIndex.toI32()
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!order) return
|
||||||
|
const publishMarket = getUser(event.params.PublishMarketFeeAddress.toHex())
|
||||||
|
order.publishingMarket = publishMarket.id
|
||||||
|
|
||||||
|
const publishMarketToken = getToken(event.params.PublishMarketFeeToken, true)
|
||||||
|
order.publishingMarketToken = publishMarketToken.id
|
||||||
|
order.publishingMarketAmmount = weiToDecimal(
|
||||||
|
event.params.PublishMarketFeeAmount.toBigDecimal(),
|
||||||
|
publishMarketToken.decimals
|
||||||
|
)
|
||||||
|
|
||||||
|
order.save()
|
||||||
|
}
|
||||||
export function handlePublishMarketFeeChanged(
|
export function handlePublishMarketFeeChanged(
|
||||||
event: PublishMarketFeeChanged
|
event: PublishMarketFeeChanged
|
||||||
): void {
|
): void {
|
||||||
@ -138,10 +177,33 @@ export function handlePublishMarketFeeChanged(
|
|||||||
event.params.PublishMarketFeeAmount.toBigDecimal(),
|
event.params.PublishMarketFeeAmount.toBigDecimal(),
|
||||||
decimals
|
decimals
|
||||||
)
|
)
|
||||||
|
token.eventIndex = event.logIndex.toI32()
|
||||||
token.save()
|
token.save()
|
||||||
// TODO - shold we have a history
|
// TODO - shold we have a history
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function handleConsumeMarketFee(event: ConsumeMarketFee): void {
|
||||||
|
const order = searchOrderForEvent(
|
||||||
|
event.transaction.hash.toHex(),
|
||||||
|
event.address.toHex(),
|
||||||
|
event.transaction.from.toHex(),
|
||||||
|
event.logIndex.toI32()
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!order) return
|
||||||
|
const consumeMarket = getUser(event.params.consumeMarketFeeAddress.toHex())
|
||||||
|
order.consumerMarket = consumeMarket.id
|
||||||
|
|
||||||
|
const consumeMarketToken = getToken(event.params.consumeMarketFeeToken, false)
|
||||||
|
order.consumerMarketToken = consumeMarketToken.id
|
||||||
|
order.consumerMarketAmmount = weiToDecimal(
|
||||||
|
event.params.consumeMarketFeeAmount.toBigDecimal(),
|
||||||
|
consumeMarketToken.decimals
|
||||||
|
)
|
||||||
|
|
||||||
|
order.save()
|
||||||
|
}
|
||||||
|
|
||||||
// roles
|
// roles
|
||||||
// roles
|
// roles
|
||||||
export function handleAddedMinter(event: AddedMinter): void {
|
export function handleAddedMinter(event: AddedMinter): void {
|
||||||
@ -152,6 +214,7 @@ export function handleAddedMinter(event: AddedMinter): void {
|
|||||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||||
existingRoles.push(event.params.user.toHexString())
|
existingRoles.push(event.params.user.toHexString())
|
||||||
token.minter = existingRoles
|
token.minter = existingRoles
|
||||||
|
token.eventIndex = event.logIndex.toI32()
|
||||||
token.save()
|
token.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +231,7 @@ export function handleRemovedMinter(event: RemovedMinter): void {
|
|||||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||||
}
|
}
|
||||||
token.minter = newList
|
token.minter = newList
|
||||||
|
token.eventIndex = event.logIndex.toI32()
|
||||||
token.save()
|
token.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,6 +243,7 @@ export function handleAddedPaymentManager(event: AddedPaymentManager): void {
|
|||||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||||
existingRoles.push(event.params.user.toHexString())
|
existingRoles.push(event.params.user.toHexString())
|
||||||
token.paymentManager = existingRoles
|
token.paymentManager = existingRoles
|
||||||
|
token.eventIndex = event.logIndex.toI32()
|
||||||
token.save()
|
token.save()
|
||||||
}
|
}
|
||||||
export function handleRemovedPaymentManager(
|
export function handleRemovedPaymentManager(
|
||||||
@ -196,6 +261,7 @@ export function handleRemovedPaymentManager(
|
|||||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||||
}
|
}
|
||||||
token.paymentManager = newList
|
token.paymentManager = newList
|
||||||
|
token.eventIndex = event.logIndex.toI32()
|
||||||
token.save()
|
token.save()
|
||||||
}
|
}
|
||||||
export function handleCleanedPermissions(event: CleanedPermissions): void {
|
export function handleCleanedPermissions(event: CleanedPermissions): void {
|
||||||
@ -206,12 +272,14 @@ export function handleCleanedPermissions(event: CleanedPermissions): void {
|
|||||||
const nft = Nft.load(token.nft as string)
|
const nft = Nft.load(token.nft as string)
|
||||||
if (nft) token.paymentCollector = nft.owner
|
if (nft) token.paymentCollector = nft.owner
|
||||||
else token.paymentCollector = '0x0000000000000000000000000000000000000000'
|
else token.paymentCollector = '0x0000000000000000000000000000000000000000'
|
||||||
|
token.eventIndex = event.logIndex.toI32()
|
||||||
token.save()
|
token.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleNewPaymentCollector(event: NewPaymentCollector): void {
|
export function handleNewPaymentCollector(event: NewPaymentCollector): void {
|
||||||
const token = getToken(event.address, true)
|
const token = getToken(event.address, true)
|
||||||
token.paymentCollector = event.params._newPaymentCollector.toHexString()
|
token.paymentCollector = event.params._newPaymentCollector.toHexString()
|
||||||
|
token.eventIndex = event.logIndex.toI32()
|
||||||
token.save()
|
token.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,12 +292,12 @@ export function handleProviderFee(event: ProviderFee): void {
|
|||||||
event.params.validUntil
|
event.params.validUntil
|
||||||
}"}`
|
}"}`
|
||||||
|
|
||||||
const orderId = getOrderId(
|
const order = searchOrderForEvent(
|
||||||
event.transaction.hash.toHex(),
|
event.transaction.hash.toHex(),
|
||||||
event.address.toHex(),
|
event.address.toHex(),
|
||||||
event.transaction.from.toHex()
|
event.transaction.from.toHex(),
|
||||||
|
event.logIndex.toI32()
|
||||||
)
|
)
|
||||||
const order = Order.load(orderId)
|
|
||||||
|
|
||||||
if (order) {
|
if (order) {
|
||||||
order.providerFee = providerFee
|
order.providerFee = providerFee
|
||||||
@ -237,27 +305,15 @@ export function handleProviderFee(event: ProviderFee): void {
|
|||||||
order.save()
|
order.save()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const orderReuse = searchOrderReusedForEvent(
|
||||||
let orderReuse = OrderReuse.load(event.transaction.hash.toHex())
|
event.transaction.hash.toHex(),
|
||||||
|
event.address.toHex(),
|
||||||
|
event.logIndex.toI32()
|
||||||
|
)
|
||||||
if (orderReuse) {
|
if (orderReuse) {
|
||||||
|
log.info('order reuse id in provider fee handler: {}', [orderReuse.id])
|
||||||
orderReuse.providerFee = providerFee
|
orderReuse.providerFee = providerFee
|
||||||
orderReuse.providerFeeValidUntil = event.params.validUntil
|
orderReuse.providerFeeValidUntil = event.params.validUntil
|
||||||
orderReuse.save()
|
orderReuse.save()
|
||||||
} else {
|
|
||||||
orderReuse = new OrderReuse(event.transaction.hash.toHex())
|
|
||||||
orderReuse.providerFee = providerFee
|
|
||||||
orderReuse.providerFeeValidUntil = event.params.validUntil
|
|
||||||
orderReuse.order = orderId
|
|
||||||
orderReuse.createdTimestamp = event.block.timestamp.toI32()
|
|
||||||
orderReuse.tx = event.transaction.hash.toHex()
|
|
||||||
orderReuse.block = event.block.number.toI32()
|
|
||||||
orderReuse.caller = event.transaction.from.toHex()
|
|
||||||
if (event.transaction.gasPrice)
|
|
||||||
orderReuse.gasPrice = event.transaction.gasPrice
|
|
||||||
else orderReuse.gasPrice = BigInt.zero()
|
|
||||||
if (event.receipt !== null && event.receipt!.gasUsed) {
|
|
||||||
orderReuse.gasUsed = event.receipt!.gasUsed.toBigDecimal()
|
|
||||||
} else orderReuse.gasUsed = BigDecimal.zero()
|
|
||||||
orderReuse.save()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,24 @@
|
|||||||
import {
|
import {
|
||||||
NFTCreated,
|
NFTCreated,
|
||||||
TokenCreated,
|
TokenCreated,
|
||||||
ERC721Factory
|
Template721Added,
|
||||||
|
Template20Added
|
||||||
} from '../@types/ERC721Factory/ERC721Factory'
|
} from '../@types/ERC721Factory/ERC721Factory'
|
||||||
|
import { Erc721Template, Erc20Template } from '../@types/schema'
|
||||||
import { decimal } from './utils/constants'
|
import { decimal } from './utils/constants'
|
||||||
import { weiToDecimal } from './utils/generic'
|
import { weiToDecimal } from './utils/generic'
|
||||||
|
import {
|
||||||
|
ERC20Template as factoryERC20Template,
|
||||||
|
ERC20Template3 as factoryERC20Template3
|
||||||
|
} from '../@types/templates'
|
||||||
import { getUser } from './utils/userUtils'
|
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 { addDatatoken } from './utils/globalUtils'
|
||||||
import { BigInt } from '@graphprotocol/graph-ts'
|
|
||||||
|
|
||||||
export function handleNftCreated(event: NFTCreated): void {
|
export function handleNftCreated(event: NFTCreated): void {
|
||||||
// const nft = new Nft(event.params.newTokenAddress.toHexString())
|
// const nft = new Nft(event.params.newTokenAddress.toHexString())
|
||||||
@ -25,8 +34,9 @@ export function handleNftCreated(event: NFTCreated): void {
|
|||||||
nft.createdTimestamp = event.block.timestamp.toI32()
|
nft.createdTimestamp = event.block.timestamp.toI32()
|
||||||
nft.tx = event.transaction.hash.toHex()
|
nft.tx = event.transaction.hash.toHex()
|
||||||
nft.block = event.block.number.toI32()
|
nft.block = event.block.number.toI32()
|
||||||
|
nft.eventIndex = event.logIndex.toI32()
|
||||||
nft.transferable = event.params.transferable
|
nft.transferable = event.params.transferable
|
||||||
|
nft.template = event.params.templateAddress.toHexString()
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,6 +49,7 @@ export function handleNewToken(event: TokenCreated): void {
|
|||||||
token.createdTimestamp = event.block.timestamp.toI32()
|
token.createdTimestamp = event.block.timestamp.toI32()
|
||||||
token.tx = event.transaction.hash.toHex()
|
token.tx = event.transaction.hash.toHex()
|
||||||
token.block = event.block.number.toI32()
|
token.block = event.block.number.toI32()
|
||||||
|
token.eventIndex = event.logIndex.toI32()
|
||||||
|
|
||||||
token.nft = event.params.creator.toHexString()
|
token.nft = event.params.creator.toHexString()
|
||||||
|
|
||||||
@ -47,25 +58,37 @@ export function handleNewToken(event: TokenCreated): void {
|
|||||||
token.decimals = 18
|
token.decimals = 18
|
||||||
token.supply = decimal.ZERO
|
token.supply = decimal.ZERO
|
||||||
token.cap = weiToDecimal(event.params.cap.toBigDecimal(), 18)
|
token.cap = weiToDecimal(event.params.cap.toBigDecimal(), 18)
|
||||||
const eventTemplateAddress = event.params.templateAddress
|
token.templateId = getErc20TemplateId(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.save()
|
token.save()
|
||||||
addDatatoken()
|
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,
|
TokenRemoved,
|
||||||
OPCFeeChanged,
|
OPCFeeChanged,
|
||||||
FactoryRouter,
|
FactoryRouter,
|
||||||
SSContractAdded,
|
|
||||||
SSContractRemoved,
|
|
||||||
FixedRateContractAdded,
|
FixedRateContractAdded,
|
||||||
FixedRateContractRemoved,
|
FixedRateContractRemoved,
|
||||||
DispenserContractAdded,
|
DispenserContractAdded,
|
||||||
@ -86,37 +84,11 @@ export function handleTokenRemoved(event: TokenRemoved): void {
|
|||||||
while (existingTokens.length > 0) {
|
while (existingTokens.length > 0) {
|
||||||
const role = existingTokens.shift().toString()
|
const role = existingTokens.shift().toString()
|
||||||
if (!role) break
|
if (!role) break
|
||||||
if (role !== event.params.token.toHexString()) newList.push(role)
|
if (role != event.params.token.toHexString()) newList.push(role)
|
||||||
}
|
}
|
||||||
opc.approvedTokens = newList
|
opc.approvedTokens = newList
|
||||||
opc.save()
|
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(
|
export function handleFixedRateContractAdded(
|
||||||
event: FixedRateContractAdded
|
event: FixedRateContractAdded
|
||||||
@ -144,7 +116,7 @@ export function handleFixedRateContractRemoved(
|
|||||||
while (existingContracts.length > 0) {
|
while (existingContracts.length > 0) {
|
||||||
const role = existingContracts.shift().toString()
|
const role = existingContracts.shift().toString()
|
||||||
if (!role) break
|
if (!role) break
|
||||||
if (role !== event.params.contractAddress.toHexString()) newList.push(role)
|
if (role != event.params.contractAddress.toHexString()) newList.push(role)
|
||||||
}
|
}
|
||||||
templates.fixedRateTemplates = newList
|
templates.fixedRateTemplates = newList
|
||||||
templates.save()
|
templates.save()
|
||||||
@ -175,7 +147,7 @@ export function handleDispenserContractRemoved(
|
|||||||
while (existingContracts.length > 0) {
|
while (existingContracts.length > 0) {
|
||||||
const role = existingContracts.shift().toString()
|
const role = existingContracts.shift().toString()
|
||||||
if (!role) break
|
if (!role) break
|
||||||
if (role !== event.params.contractAddress.toHexString()) newList.push(role)
|
if (role != event.params.contractAddress.toHexString()) newList.push(role)
|
||||||
}
|
}
|
||||||
templates.dispenserTemplates = newList
|
templates.dispenserTemplates = newList
|
||||||
templates.save()
|
templates.save()
|
||||||
|
@ -50,6 +50,7 @@ export function handleExchangeCreated(event: ExchangeCreated): void {
|
|||||||
)
|
)
|
||||||
fixedRateExchange.createdTimestamp = event.block.timestamp.toI32()
|
fixedRateExchange.createdTimestamp = event.block.timestamp.toI32()
|
||||||
fixedRateExchange.tx = event.transaction.hash.toHex()
|
fixedRateExchange.tx = event.transaction.hash.toHex()
|
||||||
|
fixedRateExchange.eventIndex = event.logIndex.toI32()
|
||||||
fixedRateExchange.block = event.block.number.toI32()
|
fixedRateExchange.block = event.block.number.toI32()
|
||||||
fixedRateExchange.save()
|
fixedRateExchange.save()
|
||||||
|
|
||||||
@ -63,12 +64,14 @@ export function handleRateChange(event: ExchangeRateChanged): void {
|
|||||||
event.address
|
event.address
|
||||||
)
|
)
|
||||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||||
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
|
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||||
)
|
)
|
||||||
newExchangeUpdate.oldPrice = fixedRateExchange.price
|
newExchangeUpdate.oldPrice = fixedRateExchange.price
|
||||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
newExchangeUpdate.eventIndex = event.logIndex.toI32()
|
||||||
newExchangeUpdate.block = event.block.number.toI32()
|
newExchangeUpdate.block = event.block.number.toI32()
|
||||||
newExchangeUpdate.exchangeId = fixedRateId
|
newExchangeUpdate.exchangeId = fixedRateId
|
||||||
|
|
||||||
@ -89,6 +92,7 @@ export function handleMintStateChanged(event: ExchangeMintStateChanged): void {
|
|||||||
)
|
)
|
||||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||||
fixedRateExchange.withMint = event.params.withMint
|
fixedRateExchange.withMint = event.params.withMint
|
||||||
|
fixedRateExchange.eventIndex = event.logIndex.toI32()
|
||||||
fixedRateExchange.save()
|
fixedRateExchange.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,14 +102,16 @@ export function handleActivated(event: ExchangeActivated): void {
|
|||||||
event.address
|
event.address
|
||||||
)
|
)
|
||||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||||
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
|
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||||
)
|
)
|
||||||
newExchangeUpdate.exchangeId = fixedRateId
|
newExchangeUpdate.exchangeId = fixedRateId
|
||||||
newExchangeUpdate.oldActive = fixedRateExchange.active
|
newExchangeUpdate.oldActive = fixedRateExchange.active
|
||||||
newExchangeUpdate.newActive = true
|
newExchangeUpdate.newActive = true
|
||||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
newExchangeUpdate.eventIndex = event.logIndex.toI32()
|
||||||
newExchangeUpdate.block = event.block.number.toI32()
|
newExchangeUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
fixedRateExchange.active = true
|
fixedRateExchange.active = true
|
||||||
@ -120,8 +126,9 @@ export function handleDeactivated(event: ExchangeDeactivated): void {
|
|||||||
event.address
|
event.address
|
||||||
)
|
)
|
||||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||||
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
|
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||||
)
|
)
|
||||||
newExchangeUpdate.oldActive = fixedRateExchange.active
|
newExchangeUpdate.oldActive = fixedRateExchange.active
|
||||||
newExchangeUpdate.newActive = false
|
newExchangeUpdate.newActive = false
|
||||||
@ -129,6 +136,7 @@ export function handleDeactivated(event: ExchangeDeactivated): void {
|
|||||||
newExchangeUpdate.exchangeId = fixedRateId
|
newExchangeUpdate.exchangeId = fixedRateId
|
||||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
newExchangeUpdate.eventIndex = event.logIndex.toI32()
|
||||||
newExchangeUpdate.block = event.block.number.toI32()
|
newExchangeUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
fixedRateExchange.active = false
|
fixedRateExchange.active = false
|
||||||
@ -144,11 +152,13 @@ export function handleAllowedSwapperChanged(
|
|||||||
event.address
|
event.address
|
||||||
)
|
)
|
||||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||||
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
const newExchangeUpdate = new FixedRateExchangeUpdate(
|
||||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
|
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||||
)
|
)
|
||||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
newExchangeUpdate.eventIndex = event.logIndex.toI32()
|
||||||
newExchangeUpdate.block = event.block.number.toI32()
|
newExchangeUpdate.block = event.block.number.toI32()
|
||||||
newExchangeUpdate.oldAllowedSwapper = fixedRateExchange.allowedSwapper
|
newExchangeUpdate.oldAllowedSwapper = fixedRateExchange.allowedSwapper
|
||||||
newExchangeUpdate.exchangeId = fixedRateId
|
newExchangeUpdate.exchangeId = fixedRateId
|
||||||
@ -165,12 +175,13 @@ export function handleSwap(event: Swapped): void {
|
|||||||
event.address
|
event.address
|
||||||
)
|
)
|
||||||
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
const fixedRateExchange = getFixedRateExchange(fixedRateId)
|
||||||
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
const swap = new FixedRateExchangeSwap(
|
const swap = new FixedRateExchangeSwap(
|
||||||
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
|
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId, eventIndex)
|
||||||
)
|
)
|
||||||
swap.createdTimestamp = event.block.timestamp.toI32()
|
swap.createdTimestamp = event.block.timestamp.toI32()
|
||||||
swap.tx = event.transaction.hash.toHex()
|
swap.tx = event.transaction.hash.toHex()
|
||||||
|
swap.eventIndex = event.logIndex.toI32()
|
||||||
swap.block = event.block.number.toI32()
|
swap.block = event.block.number.toI32()
|
||||||
|
|
||||||
swap.exchangeId = fixedRateId
|
swap.exchangeId = fixedRateId
|
||||||
@ -191,6 +202,20 @@ export function handleSwap(event: Swapped): void {
|
|||||||
BigInt.fromI32(18).toI32()
|
BigInt.fromI32(18).toI32()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Track fees
|
||||||
|
swap.oceanFeeAmount = weiToDecimal(
|
||||||
|
event.params.oceanFeeAmount.toBigDecimal(),
|
||||||
|
BigInt.fromI32(baseToken.decimals).toI32()
|
||||||
|
)
|
||||||
|
swap.marketFeeAmount = weiToDecimal(
|
||||||
|
event.params.marketFeeAmount.toBigDecimal(),
|
||||||
|
BigInt.fromI32(baseToken.decimals).toI32()
|
||||||
|
)
|
||||||
|
swap.consumeMarketFeeAmount = weiToDecimal(
|
||||||
|
event.params.consumeMarketFeeAmount.toBigDecimal(),
|
||||||
|
BigInt.fromI32(baseToken.decimals).toI32()
|
||||||
|
)
|
||||||
|
|
||||||
swap.save()
|
swap.save()
|
||||||
|
|
||||||
updateFixedRateExchangeSupply(event.params.exchangeId, event.address)
|
updateFixedRateExchangeSupply(event.params.exchangeId, event.address)
|
||||||
@ -206,7 +231,11 @@ export function handleSwap(event: Swapped): void {
|
|||||||
Address.fromString(fixedRateExchange.datatoken),
|
Address.fromString(fixedRateExchange.datatoken),
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
datatoken.lastPriceToken = fixedRateExchange.baseToken
|
const priceToken = getToken(
|
||||||
|
Address.fromString(fixedRateExchange.baseToken),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
datatoken.lastPriceToken = priceToken.id
|
||||||
datatoken.lastPriceValue = fixedRateExchange.price
|
datatoken.lastPriceValue = fixedRateExchange.price
|
||||||
datatoken.save()
|
datatoken.save()
|
||||||
}
|
}
|
||||||
@ -226,6 +255,7 @@ export function handlePublishMarketFeeChanged(
|
|||||||
event.params.swapFee.toBigDecimal(),
|
event.params.swapFee.toBigDecimal(),
|
||||||
BigInt.fromI32(18).toI32()
|
BigInt.fromI32(18).toI32()
|
||||||
)
|
)
|
||||||
|
fixedRateExchange.eventIndex = event.logIndex.toI32()
|
||||||
fixedRateExchange.save()
|
fixedRateExchange.save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,7 +273,7 @@ export function handleTokenCollected(event: TokenCollected): void {
|
|||||||
fixedRateExchange.baseTokenBalance.minus(
|
fixedRateExchange.baseTokenBalance.minus(
|
||||||
weiToDecimal(event.params.amount.toBigDecimal(), baseToken.decimals)
|
weiToDecimal(event.params.amount.toBigDecimal(), baseToken.decimals)
|
||||||
)
|
)
|
||||||
|
fixedRateExchange.eventIndex = event.logIndex.toI32()
|
||||||
fixedRateExchange.save()
|
fixedRateExchange.save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Nft, NftUpdate, NftData } from '../@types/schema'
|
import { Nft, NftUpdate, NftData, NftTransferHistory } from '../@types/schema'
|
||||||
import {
|
import {
|
||||||
MetadataCreated,
|
MetadataCreated,
|
||||||
MetadataState,
|
MetadataState,
|
||||||
@ -20,8 +20,8 @@ import { NftUpdateType } from './utils/constants'
|
|||||||
import { getNftToken, getNftTokenWithID } from './utils/tokenUtils'
|
import { getNftToken, getNftTokenWithID } from './utils/tokenUtils'
|
||||||
import { getUser } from './utils/userUtils'
|
import { getUser } from './utils/userUtils'
|
||||||
|
|
||||||
function getId(tx: string, nftAddress: string): string {
|
function getId(tx: string, nftAddress: string, eventIndex: number): string {
|
||||||
return `${tx}-${nftAddress}`
|
return `${tx}-${nftAddress}-${eventIndex}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleMetadataCreated(event: MetadataCreated): void {
|
export function handleMetadataCreated(event: MetadataCreated): void {
|
||||||
@ -33,8 +33,9 @@ export function handleMetadataCreated(event: MetadataCreated): void {
|
|||||||
nft.providerUrl = event.params.decryptorUrl.toString()
|
nft.providerUrl = event.params.decryptorUrl.toString()
|
||||||
nft.hasMetadata = true
|
nft.hasMetadata = true
|
||||||
|
|
||||||
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
const nftUpdate = new NftUpdate(
|
const nftUpdate = new NftUpdate(
|
||||||
getId(event.transaction.hash.toHex(), nftAddress)
|
getId(event.transaction.hash.toHex(), nftAddress, eventIndex)
|
||||||
)
|
)
|
||||||
|
|
||||||
nftUpdate.type = NftUpdateType.METADATA_CREATED
|
nftUpdate.type = NftUpdateType.METADATA_CREATED
|
||||||
@ -47,6 +48,7 @@ export function handleMetadataCreated(event: MetadataCreated): void {
|
|||||||
|
|
||||||
nftUpdate.timestamp = event.block.timestamp.toI32()
|
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
nftUpdate.tx = event.transaction.hash.toHex()
|
nftUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
nftUpdate.eventIndex = event.logIndex.toI32()
|
||||||
nftUpdate.block = event.block.number.toI32()
|
nftUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
nftUpdate.save()
|
nftUpdate.save()
|
||||||
@ -60,8 +62,9 @@ export function handleMetadataUpdated(event: MetadataUpdated): void {
|
|||||||
|
|
||||||
nft.assetState = event.params.state
|
nft.assetState = event.params.state
|
||||||
nft.hasMetadata = true
|
nft.hasMetadata = true
|
||||||
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
const nftUpdate = new NftUpdate(
|
const nftUpdate = new NftUpdate(
|
||||||
getId(event.transaction.hash.toHex(), nftAddress)
|
getId(event.transaction.hash.toHex(), nftAddress, eventIndex)
|
||||||
)
|
)
|
||||||
|
|
||||||
nftUpdate.nft = nft.id
|
nftUpdate.nft = nft.id
|
||||||
@ -71,6 +74,7 @@ export function handleMetadataUpdated(event: MetadataUpdated): void {
|
|||||||
|
|
||||||
nftUpdate.timestamp = event.block.timestamp.toI32()
|
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
nftUpdate.tx = event.transaction.hash.toHex()
|
nftUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
nftUpdate.eventIndex = event.logIndex.toI32()
|
||||||
nftUpdate.block = event.block.number.toI32()
|
nftUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
nftUpdate.save()
|
nftUpdate.save()
|
||||||
@ -83,9 +87,9 @@ export function handleMetadataState(event: MetadataState): void {
|
|||||||
if (!nft) return
|
if (!nft) return
|
||||||
|
|
||||||
nft.assetState = event.params.state
|
nft.assetState = event.params.state
|
||||||
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
const nftUpdate = new NftUpdate(
|
const nftUpdate = new NftUpdate(
|
||||||
getId(event.transaction.hash.toHex(), nftAddress)
|
getId(event.transaction.hash.toHex(), nftAddress, eventIndex)
|
||||||
)
|
)
|
||||||
|
|
||||||
nftUpdate.nft = nft.id
|
nftUpdate.nft = nft.id
|
||||||
@ -95,6 +99,7 @@ export function handleMetadataState(event: MetadataState): void {
|
|||||||
|
|
||||||
nftUpdate.timestamp = event.block.timestamp.toI32()
|
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
nftUpdate.tx = event.transaction.hash.toHex()
|
nftUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
nftUpdate.eventIndex = event.logIndex.toI32()
|
||||||
nftUpdate.block = event.block.number.toI32()
|
nftUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
nftUpdate.save()
|
nftUpdate.save()
|
||||||
@ -108,9 +113,9 @@ export function handleTokenUriUpdate(event: TokenURIUpdate): void {
|
|||||||
if (!nft) return
|
if (!nft) return
|
||||||
|
|
||||||
nft.tokenUri = event.params.tokenURI.toString()
|
nft.tokenUri = event.params.tokenURI.toString()
|
||||||
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
const nftUpdate = new NftUpdate(
|
const nftUpdate = new NftUpdate(
|
||||||
getId(event.transaction.hash.toHex(), nftAddress)
|
getId(event.transaction.hash.toHex(), nftAddress, eventIndex)
|
||||||
)
|
)
|
||||||
nftUpdate.nft = nft.id
|
nftUpdate.nft = nft.id
|
||||||
nftUpdate.type = NftUpdateType.TOKENURI_UPDATED
|
nftUpdate.type = NftUpdateType.TOKENURI_UPDATED
|
||||||
@ -118,6 +123,7 @@ export function handleTokenUriUpdate(event: TokenURIUpdate): void {
|
|||||||
nftUpdate.tokenUri = nft.tokenUri
|
nftUpdate.tokenUri = nft.tokenUri
|
||||||
nftUpdate.timestamp = event.block.timestamp.toI32()
|
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
nftUpdate.tx = event.transaction.hash.toHex()
|
nftUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
nftUpdate.eventIndex = event.logIndex.toI32()
|
||||||
nftUpdate.block = event.block.number.toI32()
|
nftUpdate.block = event.block.number.toI32()
|
||||||
nftUpdate.assetState = nft.assetState
|
nftUpdate.assetState = nft.assetState
|
||||||
nftUpdate.save()
|
nftUpdate.save()
|
||||||
@ -133,6 +139,7 @@ export function handleAddedManager(event: AddedManager): void {
|
|||||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||||
existingRoles.push(event.params.user.toHexString())
|
existingRoles.push(event.params.user.toHexString())
|
||||||
nft.managerRole = existingRoles
|
nft.managerRole = existingRoles
|
||||||
|
nft.eventIndex = event.logIndex.toI32()
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
export function handleRemovedManager(event: RemovedManager): void {
|
export function handleRemovedManager(event: RemovedManager): void {
|
||||||
@ -148,6 +155,7 @@ export function handleRemovedManager(event: RemovedManager): void {
|
|||||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||||
}
|
}
|
||||||
nft.managerRole = newList
|
nft.managerRole = newList
|
||||||
|
nft.eventIndex = event.logIndex.toI32()
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,6 +168,7 @@ export function handleAddedTo725StoreList(event: AddedTo725StoreList): void {
|
|||||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||||
existingRoles.push(event.params.user.toHexString())
|
existingRoles.push(event.params.user.toHexString())
|
||||||
nft.storeUpdateRole = existingRoles
|
nft.storeUpdateRole = existingRoles
|
||||||
|
nft.eventIndex = event.logIndex.toI32()
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,6 +187,7 @@ export function handleRemovedFrom725StoreList(
|
|||||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||||
}
|
}
|
||||||
nft.storeUpdateRole = newList
|
nft.storeUpdateRole = newList
|
||||||
|
nft.eventIndex = event.logIndex.toI32()
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,6 +202,7 @@ export function handleAddedToCreateERC20List(
|
|||||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||||
existingRoles.push(event.params.user.toHexString())
|
existingRoles.push(event.params.user.toHexString())
|
||||||
nft.erc20DeployerRole = existingRoles
|
nft.erc20DeployerRole = existingRoles
|
||||||
|
nft.eventIndex = event.logIndex.toI32()
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,6 +221,7 @@ export function handleRemovedFromCreateERC20List(
|
|||||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||||
}
|
}
|
||||||
nft.erc20DeployerRole = newList
|
nft.erc20DeployerRole = newList
|
||||||
|
nft.eventIndex = event.logIndex.toI32()
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,6 +234,7 @@ export function handleAddedToMetadataList(event: AddedToMetadataList): void {
|
|||||||
if (!existingRoles.includes(event.params.user.toHexString()))
|
if (!existingRoles.includes(event.params.user.toHexString()))
|
||||||
existingRoles.push(event.params.user.toHexString())
|
existingRoles.push(event.params.user.toHexString())
|
||||||
nft.metadataRole = existingRoles
|
nft.metadataRole = existingRoles
|
||||||
|
nft.eventIndex = event.logIndex.toI32()
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +253,7 @@ export function handleRemovedFromMetadataList(
|
|||||||
if (role !== event.params.user.toHexString()) newList.push(role)
|
if (role !== event.params.user.toHexString()) newList.push(role)
|
||||||
}
|
}
|
||||||
nft.metadataRole = newList
|
nft.metadataRole = newList
|
||||||
|
nft.eventIndex = event.logIndex.toI32()
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,15 +264,30 @@ export function handleCleanedPermissions(event: CleanedPermissions): void {
|
|||||||
nft.erc20DeployerRole = newList
|
nft.erc20DeployerRole = newList
|
||||||
nft.storeUpdateRole = newList
|
nft.storeUpdateRole = newList
|
||||||
nft.managerRole = newList
|
nft.managerRole = newList
|
||||||
|
nft.eventIndex = event.logIndex.toI32()
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleNftTransferred(event: Transfer): void {
|
export function handleNftTransferred(event: Transfer): void {
|
||||||
const id = event.address.toHex()
|
const id = event.address.toHex()
|
||||||
const nft = getNftTokenWithID(id)
|
const nft = getNftTokenWithID(id)
|
||||||
|
const oldOwner = nft.owner
|
||||||
const newOwner = getUser(event.params.to.toHexString())
|
const newOwner = getUser(event.params.to.toHexString())
|
||||||
nft.owner = newOwner.id
|
nft.owner = newOwner.id
|
||||||
nft.save()
|
nft.save()
|
||||||
|
const eventIndex: number = event.logIndex.toI32()
|
||||||
|
const transferId = `${
|
||||||
|
nft.address
|
||||||
|
}-${event.transaction.hash.toHex()}-${eventIndex}`
|
||||||
|
const newTransfer = new NftTransferHistory(transferId)
|
||||||
|
newTransfer.oldOwner = oldOwner
|
||||||
|
newTransfer.nft = nft.id
|
||||||
|
newTransfer.newOwner = newOwner.id
|
||||||
|
newTransfer.txId = event.transaction.hash.toHex()
|
||||||
|
newTransfer.eventIndex = event.logIndex.toI32()
|
||||||
|
newTransfer.timestamp = event.block.timestamp.toI32()
|
||||||
|
newTransfer.block = event.block.number.toI32()
|
||||||
|
newTransfer.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleNftData(event: DataChanged): void {
|
export function handleNftData(event: DataChanged): void {
|
||||||
|
@ -52,12 +52,18 @@ export function updateFixedRateExchangeSupply(
|
|||||||
fixedRateDetails.value.value8.toBigDecimal(),
|
fixedRateDetails.value.value8.toBigDecimal(),
|
||||||
baseToken.decimals
|
baseToken.decimals
|
||||||
)
|
)
|
||||||
|
// update withMint state
|
||||||
|
fixedRateExchange.withMint = fixedRateDetails.value.value11
|
||||||
|
|
||||||
|
// update active state
|
||||||
|
fixedRateExchange.active = fixedRateDetails.value.value6
|
||||||
fixedRateExchange.save()
|
fixedRateExchange.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUpdateOrSwapId(
|
export function getUpdateOrSwapId(
|
||||||
txAddress: string,
|
txAddress: string,
|
||||||
exchangeId: string
|
exchangeId: string,
|
||||||
|
eventIndex: number
|
||||||
): string {
|
): string {
|
||||||
return `${txAddress}-${exchangeId}`
|
return `${txAddress}-${exchangeId}-${eventIndex}`
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,13 @@ export function getGlobalStats(): GlobalStatistic {
|
|||||||
let globalStats = GlobalStatistic.load(GLOBAL_ID)
|
let globalStats = GlobalStatistic.load(GLOBAL_ID)
|
||||||
if (!globalStats) {
|
if (!globalStats) {
|
||||||
globalStats = new GlobalStatistic(GLOBAL_ID)
|
globalStats = new GlobalStatistic(GLOBAL_ID)
|
||||||
globalStats.version = '2.1.0'
|
globalStats.version = '4.0.2'
|
||||||
globalStats.orderCount = 0
|
globalStats.orderCount = 0
|
||||||
globalStats.fixedCount = 0
|
globalStats.fixedCount = 0
|
||||||
globalStats.datatokenCount = 0
|
globalStats.datatokenCount = 0
|
||||||
globalStats.dispenserCount = 0
|
globalStats.dispenserCount = 0
|
||||||
globalStats.nftCount = 0
|
globalStats.nftCount = 0
|
||||||
|
globalStats.totalOceanLocked = BigDecimal.zero()
|
||||||
globalStats.save()
|
globalStats.save()
|
||||||
}
|
}
|
||||||
return globalStats
|
return globalStats
|
||||||
@ -33,6 +34,11 @@ export function getOPC(): OPC {
|
|||||||
return globalStats
|
return globalStats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getTotalOceanLocked(): BigDecimal {
|
||||||
|
const globalStats = getGlobalStats()
|
||||||
|
return globalStats.totalOceanLocked
|
||||||
|
}
|
||||||
|
|
||||||
export function getTemplates(): Template {
|
export function getTemplates(): Template {
|
||||||
let templates = Template.load(GLOBAL_ID)
|
let templates = Template.load(GLOBAL_ID)
|
||||||
if (!templates) {
|
if (!templates) {
|
||||||
@ -42,6 +48,12 @@ export function getTemplates(): Template {
|
|||||||
return templates
|
return templates
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function updateTotalOceanLocked(amount: BigDecimal): void {
|
||||||
|
const globalStats = getGlobalStats()
|
||||||
|
globalStats.totalOceanLocked = amount
|
||||||
|
globalStats.save()
|
||||||
|
}
|
||||||
|
|
||||||
export function addOrder(): void {
|
export function addOrder(): void {
|
||||||
const globalStats = getGlobalStats()
|
const globalStats = getGlobalStats()
|
||||||
globalStats.orderCount = globalStats.orderCount + 1
|
globalStats.orderCount = globalStats.orderCount + 1
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { Order } from '../../@types/schema'
|
import { Order, OrderReuse } from '../../@types/schema'
|
||||||
|
|
||||||
export function getOrderId(
|
export function getOrderId(
|
||||||
tx: string,
|
tx: string,
|
||||||
tokenAddress: string,
|
tokenAddress: string,
|
||||||
fromAddress: string
|
fromAddress: string,
|
||||||
|
eventIndex: number
|
||||||
): string {
|
): string {
|
||||||
return `${tx}-${tokenAddress}-${fromAddress}`
|
return `${tx}-${tokenAddress}-${fromAddress}-${eventIndex}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createOrder(orderId: string): Order {
|
export function createOrder(orderId: string): Order {
|
||||||
@ -16,12 +17,53 @@ export function createOrder(orderId: string): Order {
|
|||||||
export function getOrder(
|
export function getOrder(
|
||||||
transactionHash: string,
|
transactionHash: string,
|
||||||
address: string,
|
address: string,
|
||||||
transactionFrom: string
|
transactionFrom: string,
|
||||||
|
eventIndex: number
|
||||||
): Order {
|
): Order {
|
||||||
const orderId = getOrderId(transactionHash, address, transactionFrom)
|
const orderId = getOrderId(
|
||||||
|
transactionHash,
|
||||||
|
address,
|
||||||
|
transactionFrom,
|
||||||
|
eventIndex
|
||||||
|
)
|
||||||
let newOrder = Order.load(orderId)
|
let newOrder = Order.load(orderId)
|
||||||
if (newOrder === null) {
|
if (newOrder === null) {
|
||||||
newOrder = createOrder(orderId)
|
newOrder = createOrder(orderId)
|
||||||
}
|
}
|
||||||
return newOrder
|
return newOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function searchOrderForEvent(
|
||||||
|
transactionHash: string,
|
||||||
|
address: string,
|
||||||
|
transactionFrom: string,
|
||||||
|
eventIndex: number
|
||||||
|
): Order | null {
|
||||||
|
for (let i = eventIndex; i >= 0; i--) {
|
||||||
|
const orderId = getOrderId(transactionHash, address, transactionFrom, i)
|
||||||
|
const order = Order.load(orderId)
|
||||||
|
if (order && order.datatoken == address) {
|
||||||
|
return order
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
export function searchOrderReusedForEvent(
|
||||||
|
transactionHash: string,
|
||||||
|
eventAddress: string,
|
||||||
|
eventIndex: number
|
||||||
|
): OrderReuse | null {
|
||||||
|
for (let i = eventIndex; i >= 0; i--) {
|
||||||
|
const orderReused = OrderReuse.load(`${transactionHash}-${i}`)
|
||||||
|
if (!orderReused) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const order = Order.load(orderReused.order)
|
||||||
|
|
||||||
|
if (order && order.datatoken == eventAddress) {
|
||||||
|
return orderReused
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
import { Address, log, BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
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 { ERC20 } from '../../@types/templates/ERC20Template/ERC20'
|
||||||
import { ERC20Template, ERC721Template } from '../../@types/templates'
|
import { ERC721Template } from '../../@types/templates'
|
||||||
import { addNft } from './globalUtils'
|
import { addNft } from './globalUtils'
|
||||||
import { ZERO_ADDRESS } from './constants'
|
import { ZERO_ADDRESS } from './constants'
|
||||||
|
|
||||||
export function createToken(address: Address, isDatatoken: boolean): Token {
|
export function createToken(address: Address, isDatatoken: boolean): Token {
|
||||||
log.debug('started creating token with address: {}', [address.toHexString()])
|
log.debug('started creating token with address: {}', [address.toHexString()])
|
||||||
if (isDatatoken) {
|
|
||||||
ERC20Template.create(address)
|
|
||||||
}
|
|
||||||
const token = new Token(address.toHexString())
|
const token = new Token(address.toHexString())
|
||||||
const contract = ERC20.bind(address)
|
const contract = ERC20.bind(address)
|
||||||
const name = contract.try_name()
|
const name = contract.try_name()
|
||||||
@ -30,6 +33,8 @@ export function createToken(address: Address, isDatatoken: boolean): Token {
|
|||||||
token.createdTimestamp = 0
|
token.createdTimestamp = 0
|
||||||
token.block = 0
|
token.block = 0
|
||||||
token.tx = ''
|
token.tx = ''
|
||||||
|
token.eventIndex = 0
|
||||||
|
token.templateId = BigInt.zero()
|
||||||
token.save()
|
token.save()
|
||||||
return token
|
return token
|
||||||
}
|
}
|
||||||
@ -60,6 +65,7 @@ export function createNftToken(address: Address): Nft {
|
|||||||
token.tx = ''
|
token.tx = ''
|
||||||
token.orderCount = BigInt.zero()
|
token.orderCount = BigInt.zero()
|
||||||
token.hasMetadata = false
|
token.hasMetadata = false
|
||||||
|
token.eventIndex = 0
|
||||||
token.save()
|
token.save()
|
||||||
addNft()
|
addNft()
|
||||||
return token
|
return token
|
||||||
@ -93,6 +99,7 @@ export function getNftTokenWithID(tokenId: string): Nft {
|
|||||||
nftToken.tx = ''
|
nftToken.tx = ''
|
||||||
nftToken.orderCount = BigInt.zero()
|
nftToken.orderCount = BigInt.zero()
|
||||||
nftToken.hasMetadata = false
|
nftToken.hasMetadata = false
|
||||||
|
nftToken.eventIndex = 0
|
||||||
nftToken.save()
|
nftToken.save()
|
||||||
addNft()
|
addNft()
|
||||||
}
|
}
|
||||||
@ -106,3 +113,44 @@ export function getUSDValue(
|
|||||||
): BigDecimal {
|
): BigDecimal {
|
||||||
return BigDecimal.zero()
|
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
|
||||||
|
}
|
||||||
|
@ -38,6 +38,7 @@ export function getveAllocateUser(
|
|||||||
|
|
||||||
allocateUser.firstContact = event.block.timestamp.toI32()
|
allocateUser.firstContact = event.block.timestamp.toI32()
|
||||||
allocateUser.tx = event.transaction.hash.toHex()
|
allocateUser.tx = event.transaction.hash.toHex()
|
||||||
|
allocateUser.eventIndex = event.logIndex.toI32()
|
||||||
allocateUser.block = event.block.number.toI32()
|
allocateUser.block = event.block.number.toI32()
|
||||||
allocateUser.lastContact = 0
|
allocateUser.lastContact = 0
|
||||||
const veOcean = getveOCEAN(sender)
|
const veOcean = getveOCEAN(sender)
|
||||||
@ -60,8 +61,11 @@ export function getveAllocateId(
|
|||||||
|
|
||||||
allocateId.firstContact = event.block.timestamp.toI32()
|
allocateId.firstContact = event.block.timestamp.toI32()
|
||||||
allocateId.tx = event.transaction.hash.toHex()
|
allocateId.tx = event.transaction.hash.toHex()
|
||||||
|
allocateId.eventIndex = event.logIndex.toI32()
|
||||||
allocateId.block = event.block.number.toI32()
|
allocateId.block = event.block.number.toI32()
|
||||||
allocateId.lastContact = 0
|
allocateId.lastContact = 0
|
||||||
|
allocateId.chainId = BigInt.zero()
|
||||||
|
allocateId.nftAddress = ''
|
||||||
|
|
||||||
allocateId.save()
|
allocateId.save()
|
||||||
}
|
}
|
||||||
@ -85,6 +89,7 @@ export function getveAllocation(
|
|||||||
|
|
||||||
veAllocation.firstContact = event.block.timestamp.toI32()
|
veAllocation.firstContact = event.block.timestamp.toI32()
|
||||||
veAllocation.tx = event.transaction.hash.toHex()
|
veAllocation.tx = event.transaction.hash.toHex()
|
||||||
|
veAllocation.eventIndex = event.logIndex.toI32()
|
||||||
veAllocation.block = event.block.number.toI32()
|
veAllocation.block = event.block.number.toI32()
|
||||||
veAllocation.lastContact = 0
|
veAllocation.lastContact = 0
|
||||||
|
|
||||||
@ -101,16 +106,17 @@ export function writeveAllocationUpdate(
|
|||||||
allocationType: string,
|
allocationType: string,
|
||||||
amount: BigDecimal
|
amount: BigDecimal
|
||||||
): VeAllocationUpdate {
|
): VeAllocationUpdate {
|
||||||
const tx = event.transaction.hash.toHex()
|
const id = `${event.transaction.hash.toHex()}-${veAllocationId}-${event.logIndex.toString()}`
|
||||||
let allocationUpdate = VeAllocationUpdate.load(tx + '-' + veAllocationId)
|
let allocationUpdate = VeAllocationUpdate.load(id)
|
||||||
if (allocationUpdate === null) {
|
if (allocationUpdate === null) {
|
||||||
allocationUpdate = new VeAllocationUpdate(tx + '-' + veAllocationId)
|
allocationUpdate = new VeAllocationUpdate(id)
|
||||||
allocationUpdate.veAllocation = veAllocationId
|
allocationUpdate.veAllocation = veAllocationId
|
||||||
allocationUpdate.type = allocationType
|
allocationUpdate.type = allocationType
|
||||||
allocationUpdate.allocatedTotal = amount
|
allocationUpdate.allocatedTotal = amount
|
||||||
|
|
||||||
allocationUpdate.timestamp = event.block.timestamp.toI32()
|
allocationUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
allocationUpdate.tx = event.transaction.hash.toHex()
|
allocationUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
allocationUpdate.eventIndex = event.logIndex.toI32()
|
||||||
allocationUpdate.block = event.block.number.toI32()
|
allocationUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
allocationUpdate.save()
|
allocationUpdate.save()
|
||||||
@ -119,7 +125,11 @@ export function writeveAllocationUpdate(
|
|||||||
return allocationUpdate
|
return allocationUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getveDelegation(id: string): VeDelegation {
|
export function getveDelegation(
|
||||||
|
contract: Address,
|
||||||
|
eventid: string
|
||||||
|
): VeDelegation {
|
||||||
|
const id = contract.toHex() + '-' + eventid
|
||||||
let veDelegation = VeDelegation.load(id)
|
let veDelegation = VeDelegation.load(id)
|
||||||
|
|
||||||
if (veDelegation === null) {
|
if (veDelegation === null) {
|
||||||
@ -127,18 +137,17 @@ export function getveDelegation(id: string): VeDelegation {
|
|||||||
veDelegation.cancelTime = BigInt.zero()
|
veDelegation.cancelTime = BigInt.zero()
|
||||||
veDelegation.expireTime = BigInt.zero()
|
veDelegation.expireTime = BigInt.zero()
|
||||||
veDelegation.tokenId = BigInt.zero()
|
veDelegation.tokenId = BigInt.zero()
|
||||||
veDelegation.amount = BigInt.zero()
|
veDelegation.amount = BigDecimal.zero()
|
||||||
veDelegation.receiver = ''
|
veDelegation.receiver = ''
|
||||||
veDelegation.delegator = ''
|
veDelegation.delegator = ''
|
||||||
veDelegation.block = 0
|
veDelegation.lockedAmount = BigDecimal.zero()
|
||||||
|
veDelegation.timeLeftUnlock = 0
|
||||||
veDelegation.save()
|
veDelegation.save()
|
||||||
}
|
}
|
||||||
return veDelegation
|
return veDelegation
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDeposit(id: string): VeDeposit {
|
export function getDeposit(id: string): VeDeposit {
|
||||||
let deposit = VeDeposit.load(id)
|
let deposit = VeDeposit.load(id)
|
||||||
|
|
||||||
if (deposit === null) {
|
if (deposit === null) {
|
||||||
deposit = new VeDeposit(id)
|
deposit = new VeDeposit(id)
|
||||||
deposit.provider = ''
|
deposit.provider = ''
|
||||||
@ -148,6 +157,7 @@ export function getDeposit(id: string): VeDeposit {
|
|||||||
deposit.type = BigInt.zero()
|
deposit.type = BigInt.zero()
|
||||||
deposit.timestamp = BigInt.zero()
|
deposit.timestamp = BigInt.zero()
|
||||||
deposit.tx = ''
|
deposit.tx = ''
|
||||||
|
deposit.eventIndex = 0
|
||||||
deposit.block = 0
|
deposit.block = 0
|
||||||
// do not save it
|
// do not save it
|
||||||
// deposit.save()
|
// deposit.save()
|
||||||
@ -196,6 +206,9 @@ export function handleOneAllocation(
|
|||||||
allocationAmount
|
allocationAmount
|
||||||
)
|
)
|
||||||
|
|
||||||
|
allocateId.chainId = chainId
|
||||||
|
allocateId.nftAddress = nftAddress
|
||||||
|
|
||||||
// save entities
|
// save entities
|
||||||
allocateUser.save()
|
allocateUser.save()
|
||||||
allocateId.save()
|
allocateId.save()
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { BigInt } from '@graphprotocol/graph-ts'
|
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
||||||
|
import { VeDelegationUpdate } from '../@types/schema'
|
||||||
import {
|
import {
|
||||||
BurnBoost,
|
BurnBoost,
|
||||||
DelegateBoost,
|
DelegateBoost,
|
||||||
ExtendBoost,
|
ExtendBoost,
|
||||||
TransferBoost
|
TransferBoost
|
||||||
} from '../@types/veDelegation/veDelegation'
|
} from '../@types/veDelegation/veDelegation'
|
||||||
|
import { weiToDecimal } from './utils/generic'
|
||||||
import { getveDelegation, getveOCEAN } from './utils/veUtils'
|
import { getveDelegation, getveOCEAN } from './utils/veUtils'
|
||||||
|
|
||||||
export function handleDelegation(event: DelegateBoost): void {
|
export function handleDelegation(event: DelegateBoost): void {
|
||||||
@ -14,17 +16,39 @@ export function handleDelegation(event: DelegateBoost): void {
|
|||||||
const _amount = event.params._amount
|
const _amount = event.params._amount
|
||||||
const _cancelTime = event.params._cancel_time
|
const _cancelTime = event.params._cancel_time
|
||||||
const _expireTime = event.params._expire_time
|
const _expireTime = event.params._expire_time
|
||||||
|
// create veOcean if does not exists
|
||||||
const veDelegation = getveDelegation(_tokenId.toHex())
|
|
||||||
veDelegation.delegator = _delegator
|
|
||||||
getveOCEAN(_receiver)
|
getveOCEAN(_receiver)
|
||||||
|
const delegator = getveOCEAN(_delegator)
|
||||||
|
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
|
||||||
|
const ts = event.block.timestamp.toI32()
|
||||||
|
|
||||||
|
veDelegation.delegator = _delegator
|
||||||
veDelegation.receiver = _receiver
|
veDelegation.receiver = _receiver
|
||||||
veDelegation.tokenId = _tokenId
|
veDelegation.tokenId = _tokenId
|
||||||
veDelegation.amount = _amount
|
veDelegation.amount = weiToDecimal(
|
||||||
|
_amount.toBigDecimal(),
|
||||||
|
BigInt.fromI32(18).toI32()
|
||||||
|
)
|
||||||
|
veDelegation.lockedAmount = delegator.lockedAmount
|
||||||
|
veDelegation.timeLeftUnlock = delegator.unlockTime.toI32() - ts
|
||||||
veDelegation.cancelTime = _cancelTime
|
veDelegation.cancelTime = _cancelTime
|
||||||
veDelegation.expireTime = _expireTime
|
veDelegation.expireTime = _expireTime
|
||||||
veDelegation.block = event.block.number.toI32()
|
|
||||||
veDelegation.save()
|
veDelegation.save()
|
||||||
|
|
||||||
|
const veDelegationUpdate = new VeDelegationUpdate(
|
||||||
|
event.transaction.hash.toHex() + '-' + event.logIndex.toString()
|
||||||
|
)
|
||||||
|
veDelegationUpdate.type = 0
|
||||||
|
veDelegationUpdate.veDelegation = veDelegation.id
|
||||||
|
veDelegationUpdate.block = event.block.number.toI32()
|
||||||
|
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
|
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
veDelegationUpdate.eventIndex = event.logIndex.toI32()
|
||||||
|
veDelegationUpdate.amount = veDelegation.amount
|
||||||
|
veDelegationUpdate.cancelTime = _cancelTime
|
||||||
|
veDelegationUpdate.expireTime = _expireTime
|
||||||
|
veDelegationUpdate.sender = event.transaction.from.toHex()
|
||||||
|
veDelegationUpdate.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleExtendBoost(event: ExtendBoost): void {
|
export function handleExtendBoost(event: ExtendBoost): void {
|
||||||
@ -34,15 +58,37 @@ export function handleExtendBoost(event: ExtendBoost): void {
|
|||||||
const _amount = event.params._amount
|
const _amount = event.params._amount
|
||||||
const _cancelTime = event.params._cancel_time
|
const _cancelTime = event.params._cancel_time
|
||||||
const _expireTime = event.params._expire_time
|
const _expireTime = event.params._expire_time
|
||||||
|
// create veOcean if does not exists
|
||||||
const veDelegation = getveDelegation(_tokenId.toHex())
|
getveOCEAN(_receiver)
|
||||||
|
getveOCEAN(_delegator)
|
||||||
|
// it's possible to not have veDelegation object, because we missed handleDelegation
|
||||||
|
// that should not happend, but we create the object anyway
|
||||||
|
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
|
||||||
veDelegation.delegator = _delegator
|
veDelegation.delegator = _delegator
|
||||||
veDelegation.receiver = _receiver
|
veDelegation.receiver = _receiver
|
||||||
veDelegation.tokenId = _tokenId
|
veDelegation.tokenId = _tokenId
|
||||||
veDelegation.amount = _amount
|
veDelegation.amount = weiToDecimal(
|
||||||
|
_amount.toBigDecimal(),
|
||||||
|
BigInt.fromI32(18).toI32()
|
||||||
|
)
|
||||||
veDelegation.cancelTime = _cancelTime
|
veDelegation.cancelTime = _cancelTime
|
||||||
veDelegation.expireTime = _expireTime
|
veDelegation.expireTime = _expireTime
|
||||||
veDelegation.save()
|
veDelegation.save()
|
||||||
|
|
||||||
|
const veDelegationUpdate = new VeDelegationUpdate(
|
||||||
|
event.transaction.hash.toHex() + '-' + event.logIndex.toString()
|
||||||
|
)
|
||||||
|
veDelegationUpdate.veDelegation = veDelegation.id
|
||||||
|
veDelegationUpdate.type = 1
|
||||||
|
veDelegationUpdate.block = event.block.number.toI32()
|
||||||
|
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
|
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
veDelegationUpdate.eventIndex = event.logIndex.toI32()
|
||||||
|
veDelegationUpdate.amount = veDelegation.amount
|
||||||
|
veDelegationUpdate.cancelTime = _cancelTime
|
||||||
|
veDelegationUpdate.expireTime = _expireTime
|
||||||
|
veDelegationUpdate.sender = event.transaction.from.toHex()
|
||||||
|
veDelegationUpdate.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleTransferBoost(event: TransferBoost): void {
|
export function handleTransferBoost(event: TransferBoost): void {
|
||||||
@ -58,6 +104,22 @@ export function handleBurnBoost(event: BurnBoost): void {
|
|||||||
const _tokenId = event.params._token_id
|
const _tokenId = event.params._token_id
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
const veDelegation = getveDelegation(_tokenId.toHex())
|
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
|
||||||
veDelegation.amount = BigInt.zero()
|
veDelegation.amount = BigDecimal.zero()
|
||||||
|
veDelegation.save()
|
||||||
|
|
||||||
|
const veDelegationUpdate = new VeDelegationUpdate(
|
||||||
|
event.transaction.hash.toHex() + '-' + event.logIndex.toString()
|
||||||
|
)
|
||||||
|
veDelegationUpdate.veDelegation = veDelegation.id
|
||||||
|
veDelegationUpdate.type = 2
|
||||||
|
veDelegationUpdate.block = event.block.number.toI32()
|
||||||
|
veDelegationUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
|
veDelegationUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
veDelegationUpdate.eventIndex = event.logIndex.toI32()
|
||||||
|
veDelegationUpdate.amount = veDelegation.amount
|
||||||
|
veDelegationUpdate.cancelTime = veDelegation.cancelTime
|
||||||
|
veDelegationUpdate.expireTime = veDelegation.expireTime
|
||||||
|
veDelegationUpdate.sender = event.transaction.from.toHex()
|
||||||
|
veDelegationUpdate.save()
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ export function handleClaimed(event: Claimed): void {
|
|||||||
|
|
||||||
claim.block = event.block.number.toI32()
|
claim.block = event.block.number.toI32()
|
||||||
claim.tx = event.transaction.hash.toHex()
|
claim.tx = event.transaction.hash.toHex()
|
||||||
|
claim.eventIndex = event.logIndex.toI32()
|
||||||
claim.timestamp = event.block.timestamp
|
claim.timestamp = event.block.timestamp
|
||||||
claim.save()
|
claim.save()
|
||||||
}
|
}
|
||||||
@ -44,6 +45,7 @@ export function handleCheckpoint(event: CheckpointToken): void {
|
|||||||
checkpoint.sender = event.transaction.from.toHexString()
|
checkpoint.sender = event.transaction.from.toHexString()
|
||||||
checkpoint.block = event.block.number.toI32()
|
checkpoint.block = event.block.number.toI32()
|
||||||
checkpoint.tx = event.transaction.hash.toHex()
|
checkpoint.tx = event.transaction.hash.toHex()
|
||||||
|
checkpoint.eventIndex = event.logIndex.toI32()
|
||||||
checkpoint.timestamp = event.params.time
|
checkpoint.timestamp = event.params.time
|
||||||
checkpoint.VeFeeDistributor = distributor.id
|
checkpoint.VeFeeDistributor = distributor.id
|
||||||
checkpoint.save()
|
checkpoint.save()
|
||||||
|
@ -2,6 +2,10 @@ import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
|||||||
import { Deposit, Supply, Withdraw } from '../@types/veOCEAN/veOCEAN'
|
import { Deposit, Supply, Withdraw } from '../@types/veOCEAN/veOCEAN'
|
||||||
import { weiToDecimal } from './utils/generic'
|
import { weiToDecimal } from './utils/generic'
|
||||||
import { getDeposit, getveOCEAN } from './utils/veUtils'
|
import { getDeposit, getveOCEAN } from './utils/veUtils'
|
||||||
|
import {
|
||||||
|
getTotalOceanLocked,
|
||||||
|
updateTotalOceanLocked
|
||||||
|
} from './utils/globalUtils'
|
||||||
|
|
||||||
export function handleDeposit(event: Deposit): void {
|
export function handleDeposit(event: Deposit): void {
|
||||||
const provider = event.params.provider
|
const provider = event.params.provider
|
||||||
@ -9,10 +13,16 @@ export function handleDeposit(event: Deposit): void {
|
|||||||
const locktime = event.params.locktime
|
const locktime = event.params.locktime
|
||||||
const type = event.params.type
|
const type = event.params.type
|
||||||
const ts = event.params.ts
|
const ts = event.params.ts
|
||||||
|
const totalOceanLocked = getTotalOceanLocked()
|
||||||
const veOCEAN = getveOCEAN(provider.toHex())
|
const veOCEAN = getveOCEAN(provider.toHex())
|
||||||
// Create new Deposit entity
|
// Create new Deposit entity
|
||||||
const deposit = getDeposit(provider.toHex() + '-' + locktime.toString())
|
const deposit = getDeposit(
|
||||||
|
provider.toHex() +
|
||||||
|
'-' +
|
||||||
|
event.transaction.hash.toHex() +
|
||||||
|
'-' +
|
||||||
|
event.logIndex.toString()
|
||||||
|
)
|
||||||
deposit.provider = provider.toHex()
|
deposit.provider = provider.toHex()
|
||||||
deposit.value = weiToDecimal(value.toBigDecimal(), 18)
|
deposit.value = weiToDecimal(value.toBigDecimal(), 18)
|
||||||
deposit.unlockTime = locktime
|
deposit.unlockTime = locktime
|
||||||
@ -22,6 +32,10 @@ export function handleDeposit(event: Deposit): void {
|
|||||||
deposit.tx = event.transaction.hash.toHex()
|
deposit.tx = event.transaction.hash.toHex()
|
||||||
deposit.sender = event.transaction.from.toHex()
|
deposit.sender = event.transaction.from.toHex()
|
||||||
deposit.veOcean = veOCEAN.id
|
deposit.veOcean = veOCEAN.id
|
||||||
|
|
||||||
|
deposit.totalOceanLocked = totalOceanLocked.plus(deposit.value)
|
||||||
|
updateTotalOceanLocked(deposit.totalOceanLocked)
|
||||||
|
|
||||||
deposit.save()
|
deposit.save()
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
@ -33,13 +47,20 @@ export function handleDeposit(event: Deposit): void {
|
|||||||
}
|
}
|
||||||
export function handleSupply(event: Supply): void {}
|
export function handleSupply(event: Supply): void {}
|
||||||
export function handleWithdraw(event: Withdraw): void {
|
export function handleWithdraw(event: Withdraw): void {
|
||||||
|
const totalOceanLocked = getTotalOceanLocked()
|
||||||
const provider = event.params.provider
|
const provider = event.params.provider
|
||||||
const value = event.params.value
|
const value = event.params.value
|
||||||
const ts = event.params.ts
|
const ts = event.params.ts
|
||||||
|
|
||||||
const veOCEAN = getveOCEAN(provider.toHex())
|
const veOCEAN = getveOCEAN(provider.toHex())
|
||||||
// Create new Deposit entity
|
// Create new Deposit entity
|
||||||
const deposit = getDeposit(provider.toHex() + '-' + ts.toString())
|
const deposit = getDeposit(
|
||||||
|
provider.toHex() +
|
||||||
|
'-' +
|
||||||
|
event.transaction.hash.toHex() +
|
||||||
|
'-' +
|
||||||
|
event.logIndex.toString()
|
||||||
|
)
|
||||||
deposit.provider = provider.toHex()
|
deposit.provider = provider.toHex()
|
||||||
deposit.value = weiToDecimal(value.toBigDecimal(), 18).neg()
|
deposit.value = weiToDecimal(value.toBigDecimal(), 18).neg()
|
||||||
deposit.unlockTime = BigInt.zero()
|
deposit.unlockTime = BigInt.zero()
|
||||||
@ -47,8 +68,11 @@ export function handleWithdraw(event: Withdraw): void {
|
|||||||
deposit.timestamp = ts
|
deposit.timestamp = ts
|
||||||
deposit.block = event.block.number.toI32()
|
deposit.block = event.block.number.toI32()
|
||||||
deposit.tx = event.transaction.hash.toHex()
|
deposit.tx = event.transaction.hash.toHex()
|
||||||
|
deposit.eventIndex = event.logIndex.toI32()
|
||||||
deposit.sender = event.transaction.from.toHex()
|
deposit.sender = event.transaction.from.toHex()
|
||||||
deposit.veOcean = veOCEAN.id
|
deposit.veOcean = veOCEAN.id
|
||||||
|
deposit.totalOceanLocked = totalOceanLocked.plus(deposit.value) // it's already negated above
|
||||||
|
updateTotalOceanLocked(deposit.totalOceanLocked)
|
||||||
deposit.save()
|
deposit.save()
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ templates:
|
|||||||
handler: handlePublishMarketFee
|
handler: handlePublishMarketFee
|
||||||
- event: PublishMarketFeeChanged(address,address,address,uint256)
|
- event: PublishMarketFeeChanged(address,address,address,uint256)
|
||||||
handler: handlePublishMarketFeeChanged
|
handler: handlePublishMarketFeeChanged
|
||||||
|
- event: ConsumeMarketFee(indexed address,indexed address,uint256)
|
||||||
|
handler: handleConsumeMarketFee
|
||||||
- event: AddedMinter(indexed address,indexed address,uint256,uint256)
|
- event: AddedMinter(indexed address,indexed address,uint256,uint256)
|
||||||
handler: handleAddedMinter
|
handler: handleAddedMinter
|
||||||
- event: AddedPaymentManager(indexed address,indexed address,uint256,uint256)
|
- event: AddedPaymentManager(indexed address,indexed address,uint256,uint256)
|
||||||
@ -52,6 +54,41 @@ templates:
|
|||||||
handler: handleProviderFee
|
handler: handleProviderFee
|
||||||
receipt: true
|
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
|
- name: ERC721Template
|
||||||
kind: ethereum/contract
|
kind: ethereum/contract
|
||||||
network: __NETWORK__
|
network: __NETWORK__
|
||||||
@ -187,6 +224,10 @@ dataSources:
|
|||||||
entities:
|
entities:
|
||||||
- ERC721Factory
|
- ERC721Factory
|
||||||
abis:
|
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
|
- name: ERC721Factory
|
||||||
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json
|
file: ./node_modules/@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json
|
||||||
- name: ERC20
|
- name: ERC20
|
||||||
@ -196,6 +237,10 @@ dataSources:
|
|||||||
handler: handleNftCreated
|
handler: handleNftCreated
|
||||||
- event: TokenCreated(indexed address,indexed address,string,string,uint256,address)
|
- event: TokenCreated(indexed address,indexed address,string,string,uint256,address)
|
||||||
handler: handleNewToken
|
handler: handleNewToken
|
||||||
|
- event: Template721Added(indexed address,indexed uint256)
|
||||||
|
handler: handleNew721Template
|
||||||
|
- event: Template20Added(indexed address,indexed uint256)
|
||||||
|
handler: handleNew20Template
|
||||||
|
|
||||||
- kind: ethereum/contract
|
- kind: ethereum/contract
|
||||||
name: FactoryRouter
|
name: FactoryRouter
|
||||||
@ -223,10 +268,6 @@ dataSources:
|
|||||||
handler: handleTokenRemoved
|
handler: handleTokenRemoved
|
||||||
- event: OPCFeeChanged(indexed address,uint256,uint256,uint256,uint256)
|
- event: OPCFeeChanged(indexed address,uint256,uint256,uint256,uint256)
|
||||||
handler: handleOPCFeeChanged
|
handler: handleOPCFeeChanged
|
||||||
- event: SSContractAdded(indexed address,indexed address)
|
|
||||||
handler: handleSSContractAdded
|
|
||||||
- event: SSContractRemoved(indexed address,indexed address)
|
|
||||||
handler: handleSSContractRemoved
|
|
||||||
- event: FixedRateContractAdded(indexed address,indexed address)
|
- event: FixedRateContractAdded(indexed address,indexed address)
|
||||||
handler: handleFixedRateContractAdded
|
handler: handleFixedRateContractAdded
|
||||||
- event: FixedRateContractRemoved(indexed address,indexed address)
|
- event: FixedRateContractRemoved(indexed address,indexed address)
|
||||||
|
@ -66,6 +66,10 @@
|
|||||||
eventHandlers:
|
eventHandlers:
|
||||||
- event: DelegateBoost(indexed address,indexed address,indexed uint256,uint256,uint256,uint256)
|
- event: DelegateBoost(indexed address,indexed address,indexed uint256,uint256,uint256,uint256)
|
||||||
handler: handleDelegation
|
handler: handleDelegation
|
||||||
|
- event: ExtendBoost(indexed address,indexed address,indexed uint256,uint256,uint256,uint256)
|
||||||
|
handler: handleExtendBoost
|
||||||
|
- event: BurnBoost(indexed address,indexed address,indexed uint256)
|
||||||
|
handler: handleBurnBoost
|
||||||
|
|
||||||
- name: veFeeDistributor
|
- name: veFeeDistributor
|
||||||
kind: ethereum/contract
|
kind: ethereum/contract
|
||||||
|
@ -159,6 +159,7 @@ describe('DFRewards tests', async () => {
|
|||||||
}
|
}
|
||||||
type
|
type
|
||||||
tx
|
tx
|
||||||
|
eventIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
@ -175,6 +176,7 @@ describe('DFRewards tests', async () => {
|
|||||||
)
|
)
|
||||||
assert(info[0].history[0].amount === '100')
|
assert(info[0].history[0].amount === '100')
|
||||||
assert(info[0].history[0].tx === tx.transactionHash.toLowerCase())
|
assert(info[0].history[0].tx === tx.transactionHash.toLowerCase())
|
||||||
|
assert(info[0].history[0].eventIndex === tx.events.Allocated.logIndex)
|
||||||
assert(info[0].history[0].type === 'Allocated')
|
assert(info[0].history[0].type === 'Allocated')
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -183,7 +185,7 @@ describe('DFRewards tests', async () => {
|
|||||||
user2,
|
user2,
|
||||||
datatokenAddress1
|
datatokenAddress1
|
||||||
)
|
)
|
||||||
await dfRewards.claimRewards(user2, user2, datatokenAddress1)
|
const tx = await dfRewards.claimRewards(user2, user2, datatokenAddress1)
|
||||||
|
|
||||||
const user2Balance = await dfRewards.getAvailableRewards(
|
const user2Balance = await dfRewards.getAvailableRewards(
|
||||||
user2,
|
user2,
|
||||||
@ -219,6 +221,7 @@ describe('DFRewards tests', async () => {
|
|||||||
}
|
}
|
||||||
type
|
type
|
||||||
tx
|
tx
|
||||||
|
eventIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
@ -235,5 +238,6 @@ describe('DFRewards tests', async () => {
|
|||||||
)
|
)
|
||||||
assert(info[0].history[0].amount === expectedReward)
|
assert(info[0].history[0].amount === expectedReward)
|
||||||
assert(info[0].history[0].type === 'Claimed')
|
assert(info[0].history[0].type === 'Claimed')
|
||||||
|
assert(info[0].history[0].eventIndex === tx.events.Claimed.logIndex)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'mocha'
|
||||||
import {
|
import {
|
||||||
DatatokenCreateParams,
|
DatatokenCreateParams,
|
||||||
ProviderInstance,
|
ProviderInstance,
|
||||||
@ -135,7 +136,7 @@ describe('Datatoken tests', async () => {
|
|||||||
datatokenAddress = result.events.TokenCreated.returnValues[0].toLowerCase()
|
datatokenAddress = result.events.TokenCreated.returnValues[0].toLowerCase()
|
||||||
|
|
||||||
// Check values before updating metadata
|
// Check values before updating metadata
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const initialQuery = {
|
const initialQuery = {
|
||||||
query: `query {
|
query: `query {
|
||||||
token(id: "${datatokenAddress}"){
|
token(id: "${datatokenAddress}"){
|
||||||
@ -161,8 +162,8 @@ describe('Datatoken tests', async () => {
|
|||||||
dispensers {id},
|
dispensers {id},
|
||||||
createdTimestamp,
|
createdTimestamp,
|
||||||
tx,
|
tx,
|
||||||
|
eventIndex,
|
||||||
block,
|
block,
|
||||||
lastPriceToken,
|
|
||||||
lastPriceValue
|
lastPriceValue
|
||||||
}}`
|
}}`
|
||||||
}
|
}
|
||||||
@ -197,8 +198,10 @@ describe('Datatoken tests', async () => {
|
|||||||
dt.publishMarketFeeAmount === publishMarketFeeAmount,
|
dt.publishMarketFeeAmount === publishMarketFeeAmount,
|
||||||
'incorrect value for: publishMarketFeeAmount'
|
'incorrect value for: publishMarketFeeAmount'
|
||||||
)
|
)
|
||||||
|
assert(
|
||||||
assert(dt.templateId === templateIndex, 'incorrect value for: templateId')
|
parseInt(dt.templateId) === templateIndex,
|
||||||
|
'incorrect value for: templateId'
|
||||||
|
)
|
||||||
assert(dt.holderCount === '0', 'incorrect value for: holderCount')
|
assert(dt.holderCount === '0', 'incorrect value for: holderCount')
|
||||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||||
assert(dt.orders, 'incorrect value for: orders')
|
assert(dt.orders, 'incorrect value for: orders')
|
||||||
@ -214,26 +217,30 @@ describe('Datatoken tests', async () => {
|
|||||||
assert(tx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
assert(tx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||||
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
||||||
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
||||||
assert(
|
|
||||||
dt.lastPriceToken === '0x0000000000000000000000000000000000000000',
|
|
||||||
'incorrect value for: lastPriceToken'
|
|
||||||
)
|
|
||||||
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
||||||
|
assert(
|
||||||
|
dt.eventIndex !== null && dt.eventIndex > 0,
|
||||||
|
'incorrect value for: eventIndex'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Correct Datatoken fields after updating metadata', async () => {
|
it('Correct Datatoken fields after updating metadata', async () => {
|
||||||
// create the files encrypted string
|
// create the files encrypted string
|
||||||
let providerResponse = await ProviderInstance.encrypt(assetUrl, providerUrl)
|
const chain = await web3.eth.getChainId()
|
||||||
|
let providerResponse = await ProviderInstance.encrypt(
|
||||||
|
assetUrl,
|
||||||
|
chain,
|
||||||
|
providerUrl
|
||||||
|
)
|
||||||
ddo.services[0].files = await providerResponse
|
ddo.services[0].files = await providerResponse
|
||||||
ddo.services[0].datatokenAddress = datatokenAddress
|
ddo.services[0].datatokenAddress = datatokenAddress
|
||||||
// update ddo and set the right did
|
// update ddo and set the right did
|
||||||
ddo.nftAddress = erc721Address
|
ddo.nftAddress = erc721Address
|
||||||
const chain = await web3.eth.getChainId()
|
|
||||||
ddo.id =
|
ddo.id =
|
||||||
'did:op:' +
|
'did:op:' +
|
||||||
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
||||||
|
|
||||||
providerResponse = await ProviderInstance.encrypt(ddo, providerUrl)
|
providerResponse = await ProviderInstance.encrypt(ddo, chain, providerUrl)
|
||||||
const encryptedResponse = await providerResponse
|
const encryptedResponse = await providerResponse
|
||||||
const metadataHash = getHash(JSON.stringify(ddo))
|
const metadataHash = getHash(JSON.stringify(ddo))
|
||||||
await nft.setMetadata(
|
await nft.setMetadata(
|
||||||
@ -248,7 +255,7 @@ describe('Datatoken tests', async () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Check values before updating metadata
|
// Check values before updating metadata
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const initialQuery = {
|
const initialQuery = {
|
||||||
query: `query {
|
query: `query {
|
||||||
token(id: "${datatokenAddress}"){
|
token(id: "${datatokenAddress}"){
|
||||||
@ -274,8 +281,8 @@ describe('Datatoken tests', async () => {
|
|||||||
dispensers {id},
|
dispensers {id},
|
||||||
createdTimestamp,
|
createdTimestamp,
|
||||||
tx,
|
tx,
|
||||||
|
eventIndex,
|
||||||
block,
|
block,
|
||||||
lastPriceToken,
|
|
||||||
lastPriceValue
|
lastPriceValue
|
||||||
}}`
|
}}`
|
||||||
}
|
}
|
||||||
@ -283,7 +290,7 @@ describe('Datatoken tests', async () => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(initialQuery)
|
body: JSON.stringify(initialQuery)
|
||||||
})
|
})
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const dt = (await initialResponse.json()).data.token
|
const dt = (await initialResponse.json()).data.token
|
||||||
|
|
||||||
const tx: TransactionReceipt = await web3.eth.getTransactionReceipt(dt.tx)
|
const tx: TransactionReceipt = await web3.eth.getTransactionReceipt(dt.tx)
|
||||||
@ -310,7 +317,10 @@ describe('Datatoken tests', async () => {
|
|||||||
dt.publishMarketFeeAmount === publishMarketFeeAmount,
|
dt.publishMarketFeeAmount === publishMarketFeeAmount,
|
||||||
'incorrect value for: 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.holderCount === '0', 'incorrect value for: holderCount')
|
||||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||||
assert(dt.orders, 'incorrect value for: orders')
|
assert(dt.orders, 'incorrect value for: orders')
|
||||||
@ -326,15 +336,42 @@ describe('Datatoken tests', async () => {
|
|||||||
assert(tx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
assert(tx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||||
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
||||||
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
||||||
assert(
|
|
||||||
dt.lastPriceToken === '0x0000000000000000000000000000000000000000',
|
|
||||||
'incorrect value for: lastPriceToken'
|
|
||||||
)
|
|
||||||
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
||||||
|
assert(
|
||||||
|
dt.eventIndex !== null && dt.eventIndex > 0,
|
||||||
|
'incorrect value for: eventIndex'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Check datatoken orders are updated correctly after publishing & ordering a datatoken', async () => {
|
it('Check datatoken orders are updated correctly after publishing & ordering a datatoken with fees', async () => {
|
||||||
// Start with publishing a new datatoken
|
// Publish a datatoken for publishingMarketFeeToken
|
||||||
|
const nftParams1: NftCreateData = {
|
||||||
|
name: 'newNFT1',
|
||||||
|
symbol: 'newTST1',
|
||||||
|
templateIndex,
|
||||||
|
tokenURI: '',
|
||||||
|
transferable: true,
|
||||||
|
owner: publisher
|
||||||
|
}
|
||||||
|
const erc20Params1: DatatokenCreateParams = {
|
||||||
|
templateIndex,
|
||||||
|
cap: '100000',
|
||||||
|
feeAmount: '0',
|
||||||
|
paymentCollector: ZERO_ADDRESS,
|
||||||
|
feeToken: ZERO_ADDRESS,
|
||||||
|
minter: publisher,
|
||||||
|
mpFeeAddress: ZERO_ADDRESS
|
||||||
|
}
|
||||||
|
const result1 = await Factory.createNftWithDatatoken(
|
||||||
|
publisher,
|
||||||
|
nftParams1,
|
||||||
|
erc20Params1
|
||||||
|
)
|
||||||
|
await sleep(3000)
|
||||||
|
const publishingTokenAddress = result1.events.TokenCreated.returnValues[0]
|
||||||
|
const publishingDatatoken = new Datatoken(web3, 8996)
|
||||||
|
|
||||||
|
// Start with publishing the datatoken used for startOrder
|
||||||
const nftParams: NftCreateData = {
|
const nftParams: NftCreateData = {
|
||||||
name: 'newNFT',
|
name: 'newNFT',
|
||||||
symbol: 'newTST',
|
symbol: 'newTST',
|
||||||
@ -346,42 +383,76 @@ describe('Datatoken tests', async () => {
|
|||||||
const erc20Params: DatatokenCreateParams = {
|
const erc20Params: DatatokenCreateParams = {
|
||||||
templateIndex,
|
templateIndex,
|
||||||
cap: '100000',
|
cap: '100000',
|
||||||
feeAmount: '0',
|
feeAmount: '0.2',
|
||||||
paymentCollector: ZERO_ADDRESS,
|
paymentCollector: ZERO_ADDRESS,
|
||||||
feeToken: ZERO_ADDRESS,
|
feeToken: publishingTokenAddress,
|
||||||
minter: publisher,
|
minter: publisher,
|
||||||
mpFeeAddress: ZERO_ADDRESS
|
mpFeeAddress: publisher
|
||||||
}
|
}
|
||||||
const result = await Factory.createNftWithDatatoken(
|
const result = await Factory.createNftWithDatatoken(
|
||||||
publisher,
|
publisher,
|
||||||
nftParams,
|
nftParams,
|
||||||
erc20Params
|
erc20Params
|
||||||
)
|
)
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const newDtAddress = result.events.TokenCreated.returnValues[0]
|
const newDtAddress = result.events.TokenCreated.returnValues[0]
|
||||||
|
|
||||||
const datatoken = new Datatoken(web3, 8996)
|
const datatoken = new Datatoken(web3, 8996)
|
||||||
|
|
||||||
|
await datatoken.approve(
|
||||||
|
newDtAddress,
|
||||||
|
publishingTokenAddress,
|
||||||
|
'100000000000000000000000000',
|
||||||
|
user1
|
||||||
|
)
|
||||||
|
await publishingDatatoken.approve(
|
||||||
|
publishingTokenAddress,
|
||||||
|
newDtAddress,
|
||||||
|
'100000000000000000000000000',
|
||||||
|
user1
|
||||||
|
)
|
||||||
await datatoken.mint(newDtAddress, publisher, '100', user1)
|
await datatoken.mint(newDtAddress, publisher, '100', user1)
|
||||||
|
await publishingDatatoken.mint(
|
||||||
|
publishingTokenAddress,
|
||||||
|
publisher,
|
||||||
|
'100',
|
||||||
|
user1
|
||||||
|
)
|
||||||
const user1balance = await datatoken.balance(newDtAddress, user1)
|
const user1balance = await datatoken.balance(newDtAddress, user1)
|
||||||
const user2balance = await datatoken.balance(newDtAddress, user2)
|
const user2balance = await datatoken.balance(newDtAddress, user2)
|
||||||
assert(Number(user1balance) === 100, 'Invalid user1 balance')
|
assert(Number(user1balance) === 100, 'Invalid user1 balance')
|
||||||
assert(Number(user2balance) === 0, 'Invalid user2 balance')
|
assert(Number(user2balance) === 0, 'Invalid user2 balance')
|
||||||
|
|
||||||
|
const user1balanceOfPublishing = await datatoken.balance(
|
||||||
|
publishingTokenAddress,
|
||||||
|
user1
|
||||||
|
)
|
||||||
|
const user2balanceOfPublishing = await datatoken.balance(
|
||||||
|
publishingTokenAddress,
|
||||||
|
user2
|
||||||
|
)
|
||||||
|
assert(Number(user1balanceOfPublishing) === 100, 'Invalid user1 balance')
|
||||||
|
assert(Number(user2balanceOfPublishing) === 0, 'Invalid user2 balance')
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
query: `query {token(id: "${newDtAddress.toLowerCase()}"){id,orderCount,orders {id}}}`
|
query: `query {token(id: "${newDtAddress.toLowerCase()}"){id,orderCount,orders {id, nftOwner{id}, lastPriceToken{id}, eventIndex}, eventIndex}}`
|
||||||
}
|
}
|
||||||
|
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
let response = await fetch(subgraphUrl, {
|
let response = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(query)
|
body: JSON.stringify(query)
|
||||||
})
|
})
|
||||||
|
await sleep(3000)
|
||||||
const initialToken = (await response.json()).data.token
|
const initialToken = (await response.json()).data.token
|
||||||
|
|
||||||
assert(initialToken, 'Invalid initialToken')
|
assert(initialToken, 'Invalid initialToken')
|
||||||
assert(initialToken.orderCount === '0', 'Invalid initial orderCount')
|
assert(initialToken.orderCount === '0', 'Invalid initial orderCount')
|
||||||
assert(initialToken.orders.length === 0, 'Invalid initial orders')
|
assert(initialToken.orders.length === 0, 'Invalid initial orders')
|
||||||
|
assert(
|
||||||
|
initialToken.eventIndex !== null && initialToken.eventIndex > 0,
|
||||||
|
'Invalid eventIndex'
|
||||||
|
)
|
||||||
|
|
||||||
const providerData = JSON.stringify({ timeout: 0 })
|
const providerData = JSON.stringify({ timeout: 0 })
|
||||||
const providerFeeToken = ZERO_ADDRESS
|
const providerFeeToken = ZERO_ADDRESS
|
||||||
@ -406,27 +477,81 @@ describe('Datatoken tests', async () => {
|
|||||||
providerData: web3.utils.toHex(web3.utils.asciiToHex(providerData)),
|
providerData: web3.utils.toHex(web3.utils.asciiToHex(providerData)),
|
||||||
validUntil: providerValidUntil
|
validUntil: providerValidUntil
|
||||||
}
|
}
|
||||||
|
const consumeMarketFees = {
|
||||||
|
consumeMarketFeeAddress: publisher,
|
||||||
|
consumeMarketFeeToken: publishingTokenAddress,
|
||||||
|
consumeMarketFeeAmount: '20000'
|
||||||
|
}
|
||||||
assert(setProviderFee, 'Invalid setProviderFee')
|
assert(setProviderFee, 'Invalid setProviderFee')
|
||||||
const orderTx = await datatoken.startOrder(
|
const orderTx = await datatoken.startOrder(
|
||||||
newDtAddress,
|
newDtAddress,
|
||||||
user1,
|
user1,
|
||||||
user2,
|
user2,
|
||||||
1,
|
1,
|
||||||
setProviderFee
|
setProviderFee,
|
||||||
|
consumeMarketFees
|
||||||
)
|
)
|
||||||
assert(orderTx, 'Invalid orderTx')
|
assert(orderTx, 'Invalid orderTx')
|
||||||
const orderId = `${orderTx.transactionHash.toLowerCase()}-${newDtAddress.toLowerCase()}-${user1.toLowerCase()}`
|
const orderId = `${orderTx.transactionHash.toLowerCase()}-${newDtAddress.toLowerCase()}-${user1.toLowerCase()}-${orderTx.events.OrderStarted.logIndex.toFixed(
|
||||||
|
1
|
||||||
|
)}`
|
||||||
|
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
response = await fetch(subgraphUrl, {
|
response = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(query)
|
body: JSON.stringify(query)
|
||||||
})
|
})
|
||||||
|
await sleep(3000)
|
||||||
|
|
||||||
const token = (await response.json()).data.token
|
const token = (await response.json()).data.token
|
||||||
|
|
||||||
assert(token, 'Invalid token')
|
assert(token, 'Invalid token')
|
||||||
assert(token.orderCount === '1', 'Invalid orderCount after order')
|
assert(token.orderCount === '1', 'Invalid orderCount after order')
|
||||||
assert(token.orders[0].id === orderId)
|
assert(token.orders[0].id === orderId)
|
||||||
|
assert(token.orders[0].lastPriceToken.id === ZERO_ADDRESS)
|
||||||
|
assert(token.orders[0].nftOwner.id === publisher, 'invalid nftOwner')
|
||||||
|
assert(token.orders[0].eventIndex === 0, 'invalid order eventIndex')
|
||||||
|
assert(token.eventIndex !== null, 'Invalid eventIndex')
|
||||||
|
assert(
|
||||||
|
token.eventIndex !== token.orders[0].eventIndex,
|
||||||
|
'Invalid log indeces'
|
||||||
|
)
|
||||||
|
const orderQuery = {
|
||||||
|
query: `query {order(id:"${orderId}"){id, publishingMarket{id}, publishingMarketToken{id}, publishingMarketAmmount, consumerMarket{id}, consumerMarketToken{id}, consumerMarketAmmount, eventIndex}}`
|
||||||
|
}
|
||||||
|
await sleep(3000)
|
||||||
|
const orderResponse = await fetch(subgraphUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(orderQuery)
|
||||||
|
})
|
||||||
|
await sleep(3000)
|
||||||
|
const queryResult = await orderResponse.json()
|
||||||
|
const order = queryResult.data.order
|
||||||
|
assert(
|
||||||
|
order.publishingMarket.id === erc20Params.mpFeeAddress.toLowerCase(),
|
||||||
|
'incorrect publish market fee address'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
order.publishingMarketToken.id === erc20Params.feeToken.toLowerCase(),
|
||||||
|
'incorrect publish market fee token'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
order.publishingMarketAmmount === erc20Params.feeAmount,
|
||||||
|
'incorrect publish market fee amount'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
order.consumerMarket.id ===
|
||||||
|
consumeMarketFees.consumeMarketFeeAddress.toLowerCase(),
|
||||||
|
'incorrect consume market fee address'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
order.consumerMarketToken.id ===
|
||||||
|
consumeMarketFees.consumeMarketFeeToken.toLowerCase(),
|
||||||
|
'incorrect consume market fee token'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
order.consumerMarketAmmount === '0.00000000000002',
|
||||||
|
'incorrect consume market fee amount'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -110,6 +110,7 @@ describe('Dispenser tests', async () => {
|
|||||||
nftParams,
|
nftParams,
|
||||||
erc20Params
|
erc20Params
|
||||||
)
|
)
|
||||||
|
const nftTemplate = await Factory.getNFTTemplate(nftParams.templateIndex)
|
||||||
assert(tx.events.NFTCreated.event === 'NFTCreated')
|
assert(tx.events.NFTCreated.event === 'NFTCreated')
|
||||||
assert(tx.events.TokenCreated.event === 'TokenCreated')
|
assert(tx.events.TokenCreated.event === 'TokenCreated')
|
||||||
nftAddress = tx.events.NFTCreated.returnValues.newTokenAddress.toLowerCase()
|
nftAddress = tx.events.NFTCreated.returnValues.newTokenAddress.toLowerCase()
|
||||||
@ -125,8 +126,8 @@ describe('Dispenser tests', async () => {
|
|||||||
symbol,
|
symbol,
|
||||||
name,
|
name,
|
||||||
tokenUri,
|
tokenUri,
|
||||||
owner,
|
owner{id},
|
||||||
creator,
|
creator{id},
|
||||||
address,
|
address,
|
||||||
providerUrl,
|
providerUrl,
|
||||||
assetState,
|
assetState,
|
||||||
@ -138,6 +139,7 @@ describe('Dispenser tests', async () => {
|
|||||||
transferable,
|
transferable,
|
||||||
createdTimestamp,
|
createdTimestamp,
|
||||||
tx,
|
tx,
|
||||||
|
eventIndex,
|
||||||
block,
|
block,
|
||||||
orderCount}}`
|
orderCount}}`
|
||||||
}
|
}
|
||||||
@ -153,8 +155,8 @@ describe('Dispenser tests', async () => {
|
|||||||
assert(nft.symbol === nftSymbol, 'incorrect value for: symbol')
|
assert(nft.symbol === nftSymbol, 'incorrect value for: symbol')
|
||||||
assert(nft.name === nftName, 'incorrect value for: name')
|
assert(nft.name === nftName, 'incorrect value for: name')
|
||||||
assert(nft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
assert(nft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
||||||
assert(nft.owner === publisher, 'incorrect value for: owner')
|
assert(nft.owner.id === publisher, 'incorrect value for: owner')
|
||||||
assert(nft.creator === publisher, 'incorrect value for: creator')
|
assert(nft.creator.id === publisher, 'incorrect value for: creator')
|
||||||
assert(nft.managerRole[0] === publisher, 'incorrect value for: managerRole')
|
assert(nft.managerRole[0] === publisher, 'incorrect value for: managerRole')
|
||||||
assert(
|
assert(
|
||||||
nft.erc20DeployerRole[0] === factoryAddress,
|
nft.erc20DeployerRole[0] === factoryAddress,
|
||||||
@ -162,7 +164,10 @@ describe('Dispenser tests', async () => {
|
|||||||
)
|
)
|
||||||
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
||||||
assert(nft.metadataRole === null, 'incorrect value for: metadataRole')
|
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.transferable === true, 'incorrect value for: transferable')
|
||||||
assert(nft.createdTimestamp >= time, 'incorrect value: createdTimestamp')
|
assert(nft.createdTimestamp >= time, 'incorrect value: createdTimestamp')
|
||||||
assert(nft.createdTimestamp < time + 5, 'incorrect value: createdTimestamp')
|
assert(nft.createdTimestamp < time + 5, 'incorrect value: createdTimestamp')
|
||||||
@ -172,6 +177,10 @@ describe('Dispenser tests', async () => {
|
|||||||
assert(nft.block >= blockNumber, 'incorrect value for: block')
|
assert(nft.block >= blockNumber, 'incorrect value for: block')
|
||||||
assert(nft.block < blockNumber + 50, 'incorrect value for: block')
|
assert(nft.block < blockNumber + 50, 'incorrect value for: block')
|
||||||
assert(nft.orderCount === '0', 'incorrect value for: orderCount')
|
assert(nft.orderCount === '0', 'incorrect value for: orderCount')
|
||||||
|
assert(
|
||||||
|
nft.eventIndex !== null && nft.eventIndex > 0,
|
||||||
|
'Invalid eventIndex for NFT creation'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Test all DT Fields after deploying', async () => {
|
it('Test all DT Fields after deploying', async () => {
|
||||||
@ -201,8 +210,8 @@ describe('Dispenser tests', async () => {
|
|||||||
dispensers {id},
|
dispensers {id},
|
||||||
createdTimestamp,
|
createdTimestamp,
|
||||||
tx,
|
tx,
|
||||||
|
eventIndex,
|
||||||
block,
|
block,
|
||||||
lastPriceToken,
|
|
||||||
lastPriceValue
|
lastPriceValue
|
||||||
}}`
|
}}`
|
||||||
}
|
}
|
||||||
@ -238,7 +247,10 @@ describe('Dispenser tests', async () => {
|
|||||||
'incorrect value for: 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.holderCount === '0', 'incorrect value for: holderCount')
|
||||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||||
assert(dt.orders, 'incorrect value for: orders')
|
assert(dt.orders, 'incorrect value for: orders')
|
||||||
@ -254,11 +266,11 @@ describe('Dispenser tests', async () => {
|
|||||||
assert(dtTx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
assert(dtTx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||||
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
||||||
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
||||||
assert(
|
|
||||||
dt.lastPriceToken === '0x0000000000000000000000000000000000000000',
|
|
||||||
'incorrect value for: lastPriceToken'
|
|
||||||
)
|
|
||||||
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
||||||
|
assert(
|
||||||
|
dt.eventIndex !== null && dt.eventIndex > 0,
|
||||||
|
'incorrect value for: eventIndex'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Make user1 minter', async () => {
|
it('Make user1 minter', async () => {
|
||||||
@ -267,15 +279,16 @@ describe('Dispenser tests', async () => {
|
|||||||
assert((await datatoken.getPermissions(dtAddress, user1)).minter === true)
|
assert((await datatoken.getPermissions(dtAddress, user1)).minter === true)
|
||||||
await sleep(sleepMs)
|
await sleep(sleepMs)
|
||||||
const minterQuery = {
|
const minterQuery = {
|
||||||
query: `query {token(id: "${dtAddress}"){minter{id}}}`
|
query: `query {token(id: "${dtAddress}"){minter{id}, eventIndex}}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const minterResponse = await fetch(subgraphUrl, {
|
const minterResponse = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(minterQuery)
|
body: JSON.stringify(minterQuery)
|
||||||
})
|
})
|
||||||
const minter = (await minterResponse.json()).data.token.minter
|
const dt = (await minterResponse.json()).data.token
|
||||||
assert(minter[1] === user1, 'incorrect value for: minter')
|
assert(dt.minter[1] === user1, 'incorrect value for: minter')
|
||||||
|
assert(dt.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Create dispenser', async () => {
|
it('Create dispenser', async () => {
|
||||||
@ -315,6 +328,7 @@ describe('Dispenser tests', async () => {
|
|||||||
block
|
block
|
||||||
createdTimestamp
|
createdTimestamp
|
||||||
tx
|
tx
|
||||||
|
eventIndex
|
||||||
dispenses {
|
dispenses {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
@ -341,13 +355,17 @@ describe('Dispenser tests', async () => {
|
|||||||
assert(response.createdTimestamp >= time, 'incorrect: createdTimestamp')
|
assert(response.createdTimestamp >= time, 'incorrect: createdTimestamp')
|
||||||
assert(response.createdTimestamp < time + 15, 'incorrect: createdTimestamp')
|
assert(response.createdTimestamp < time + 15, 'incorrect: createdTimestamp')
|
||||||
assert(response.tx === tx.transactionHash, 'incorrect value for: tx')
|
assert(response.tx === tx.transactionHash, 'incorrect value for: tx')
|
||||||
|
assert(
|
||||||
|
response.eventIndex !== null && response.eventIndex > 0,
|
||||||
|
'incorrect value for: eventIndex'
|
||||||
|
)
|
||||||
assert(response.dispenses.length === 0, 'incorrect value for: dispenses')
|
assert(response.dispenses.length === 0, 'incorrect value for: dispenses')
|
||||||
assert(response.__typename === 'Dispenser', 'incorrect value: __typename')
|
assert(response.__typename === 'Dispenser', 'incorrect value: __typename')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Deactivates dispenser', async () => {
|
it('Deactivates dispenser', async () => {
|
||||||
const deactiveQuery = {
|
const deactiveQuery = {
|
||||||
query: `query {dispenser(id: "${dispenserId}"){active}}`
|
query: `query {dispenser(id: "${dispenserId}"){active, eventIndex}}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialResponse = await fetch(subgraphUrl, {
|
const initialResponse = await fetch(subgraphUrl, {
|
||||||
@ -358,7 +376,7 @@ describe('Dispenser tests', async () => {
|
|||||||
assert(initialActive === true, 'incorrect value for: initialActive')
|
assert(initialActive === true, 'incorrect value for: initialActive')
|
||||||
|
|
||||||
// Deactivate exchange
|
// Deactivate exchange
|
||||||
await dispenser.deactivate(dtAddress, publisher)
|
const tx = await dispenser.deactivate(dtAddress, publisher)
|
||||||
const status = await dispenser.status(dtAddress)
|
const status = await dispenser.status(dtAddress)
|
||||||
assert(status.active === false, 'Dispenser is still active')
|
assert(status.active === false, 'Dispenser is still active')
|
||||||
await sleep(sleepMs)
|
await sleep(sleepMs)
|
||||||
@ -367,23 +385,29 @@ describe('Dispenser tests', async () => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(deactiveQuery)
|
body: JSON.stringify(deactiveQuery)
|
||||||
})
|
})
|
||||||
const updatedActive = (await updatedResponse.json()).data.dispenser.active
|
const updatedActive = (await updatedResponse.json()).data.dispenser
|
||||||
assert(updatedActive === false, 'incorrect value for: updatedActive')
|
assert(updatedActive.active === false, 'incorrect value for: updatedActive')
|
||||||
|
assert(updatedActive.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||||
|
assert(
|
||||||
|
updatedActive.eventIndex === tx.events.DispenserDeactivated.logIndex,
|
||||||
|
'incorrect value for: eventIndex'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Activates exchange', async () => {
|
it('Activates dispenser', async () => {
|
||||||
const activeQuery = {
|
const activeQuery = {
|
||||||
query: `query {dispenser(id: "${dispenserId}"){active}}`
|
query: `query {dispenser(id: "${dispenserId}"){active, eventIndex}}`
|
||||||
}
|
}
|
||||||
const initialResponse = await fetch(subgraphUrl, {
|
const initialResponse = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(activeQuery)
|
body: JSON.stringify(activeQuery)
|
||||||
})
|
})
|
||||||
const initialActive = (await initialResponse.json()).data.dispenser.active
|
const initialActive = (await initialResponse.json()).data.dispenser
|
||||||
assert(initialActive === false, 'incorrect value for: initialActive')
|
assert(initialActive.active === false, 'incorrect value for: initialActive')
|
||||||
|
assert(initialActive.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||||
|
|
||||||
// Activate exchange
|
// Activate dispenser
|
||||||
await dispenser.activate(dtAddress, '100', '100', publisher)
|
const tx = await dispenser.activate(dtAddress, '100', '100', publisher)
|
||||||
await sleep(sleepMs)
|
await sleep(sleepMs)
|
||||||
|
|
||||||
// Check the updated value for active
|
// Check the updated value for active
|
||||||
@ -391,8 +415,13 @@ describe('Dispenser tests', async () => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(activeQuery)
|
body: JSON.stringify(activeQuery)
|
||||||
})
|
})
|
||||||
const updatedActive = (await updatedResponse.json()).data.dispenser.active
|
const updatedActive = (await updatedResponse.json()).data.dispenser
|
||||||
assert(updatedActive === true, 'incorrect value for: updatedActive')
|
assert(updatedActive.active === true, 'incorrect value for: updatedActive')
|
||||||
|
assert(updatedActive.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||||
|
assert(
|
||||||
|
updatedActive.eventIndex === tx.events.DispenserActivated.logIndex,
|
||||||
|
'incorrect value for: eventIndex'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('User2 gets datatokens from the dispenser', async () => {
|
it('User2 gets datatokens from the dispenser', async () => {
|
||||||
@ -407,6 +436,7 @@ describe('Dispenser tests', async () => {
|
|||||||
block
|
block
|
||||||
createdTimestamp
|
createdTimestamp
|
||||||
tx
|
tx
|
||||||
|
eventIndex
|
||||||
__typename
|
__typename
|
||||||
}}}`
|
}}}`
|
||||||
}
|
}
|
||||||
@ -415,6 +445,7 @@ describe('Dispenser tests', async () => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(dispenseQuery)
|
body: JSON.stringify(dispenseQuery)
|
||||||
})
|
})
|
||||||
|
await sleep(sleepMs)
|
||||||
const before = (await response1.json()).data.dispenser.dispenses
|
const before = (await response1.json()).data.dispenser.dispenses
|
||||||
assert(before.length === 0, 'incorrect value for: dispenses')
|
assert(before.length === 0, 'incorrect value for: dispenses')
|
||||||
|
|
||||||
@ -428,7 +459,13 @@ describe('Dispenser tests', async () => {
|
|||||||
})
|
})
|
||||||
const dispense = (await response2.json()).data.dispenser.dispenses[0]
|
const dispense = (await response2.json()).data.dispenser.dispenses[0]
|
||||||
|
|
||||||
assert(dispense.id === `${tx.transactionHash}-${dispenserId}`, 'wrong id')
|
assert(
|
||||||
|
dispense.id ===
|
||||||
|
`${
|
||||||
|
tx.transactionHash
|
||||||
|
}-${dispenserId}-${tx.events.TokensDispensed.logIndex.toFixed(1)}`,
|
||||||
|
'wrong id'
|
||||||
|
)
|
||||||
assert(dispense.dispenser.id === dispenserId, 'incorrect value for: user')
|
assert(dispense.dispenser.id === dispenserId, 'incorrect value for: user')
|
||||||
assert(dispense.user.id === user2, 'incorrect value for: user')
|
assert(dispense.user.id === user2, 'incorrect value for: user')
|
||||||
assert(dispense.amount === amount, 'incorrect value for: user')
|
assert(dispense.amount === amount, 'incorrect value for: user')
|
||||||
@ -436,6 +473,7 @@ describe('Dispenser tests', async () => {
|
|||||||
assert(dispense.createdTimestamp >= time, 'incorrect: createdTimestamp')
|
assert(dispense.createdTimestamp >= time, 'incorrect: createdTimestamp')
|
||||||
assert(dispense.createdTimestamp < time + 15, 'incorrect: createdTimestamp')
|
assert(dispense.createdTimestamp < time + 15, 'incorrect: createdTimestamp')
|
||||||
assert(dispense.tx === tx.transactionHash, 'incorrect value for: tx')
|
assert(dispense.tx === tx.transactionHash, 'incorrect value for: tx')
|
||||||
|
assert(dispense.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||||
assert(dispense.__typename === 'DispenserTransaction', 'wrong __typename')
|
assert(dispense.__typename === 'DispenserTransaction', 'wrong __typename')
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -445,21 +483,21 @@ describe('Dispenser tests', async () => {
|
|||||||
|
|
||||||
// Check balance after owner withdraw
|
// Check balance after owner withdraw
|
||||||
const balanceQuery = {
|
const balanceQuery = {
|
||||||
query: `query {dispenser(id: "${dispenserId}"){balance}}`
|
query: `query {dispenser(id: "${dispenserId}"){balance, eventIndex}}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(subgraphUrl, {
|
const response = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(balanceQuery)
|
body: JSON.stringify(balanceQuery)
|
||||||
})
|
})
|
||||||
const balance = (await response.json()).data.dispenser.balance
|
const balance = (await response.json()).data.dispenser
|
||||||
|
assert(balance.balance === '0', 'incorrect value for: balance')
|
||||||
assert(balance === '0', 'incorrect value for: balance')
|
assert(balance.eventIndex !== null, 'incorrect value for: eventIndex')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Updates allowed swapper', async () => {
|
it('Updates allowed swapper', async () => {
|
||||||
const swapperQuery = {
|
const swapperQuery = {
|
||||||
query: `query {dispenser(id: "${dispenserId}"){allowedSwapper}}`
|
query: `query {dispenser(id: "${dispenserId}"){allowedSwapper, eventIndex}}`
|
||||||
}
|
}
|
||||||
// Check initial allowedSwapper
|
// Check initial allowedSwapper
|
||||||
const swapperResponse1 = await fetch(subgraphUrl, {
|
const swapperResponse1 = await fetch(subgraphUrl, {
|
||||||
@ -473,7 +511,7 @@ describe('Dispenser tests', async () => {
|
|||||||
'incorrect value for: allowedSwapper'
|
'incorrect value for: allowedSwapper'
|
||||||
)
|
)
|
||||||
|
|
||||||
await dispenser.setAllowedSwapper(dtAddress, publisher, user1)
|
const tx = await dispenser.setAllowedSwapper(dtAddress, publisher, user1)
|
||||||
await sleep(sleepMs)
|
await sleep(sleepMs)
|
||||||
|
|
||||||
const swapperResponse2 = await fetch(subgraphUrl, {
|
const swapperResponse2 = await fetch(subgraphUrl, {
|
||||||
@ -481,8 +519,16 @@ describe('Dispenser tests', async () => {
|
|||||||
body: JSON.stringify(swapperQuery)
|
body: JSON.stringify(swapperQuery)
|
||||||
})
|
})
|
||||||
const allowedSwapper2 = (await swapperResponse2.json()).data.dispenser
|
const allowedSwapper2 = (await swapperResponse2.json()).data.dispenser
|
||||||
.allowedSwapper
|
|
||||||
|
|
||||||
assert(allowedSwapper2 === user1, 'incorrect value for: allowedSwapper 2')
|
assert(
|
||||||
|
allowedSwapper2.allowedSwapper === user1,
|
||||||
|
'incorrect value for: allowedSwapper 2'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
allowedSwapper2.eventIndex !== null &&
|
||||||
|
allowedSwapper2.eventIndex ===
|
||||||
|
tx.events.DispenserAllowedSwapperChanged.logIndex,
|
||||||
|
'incorrect value for: eventIndex'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
165
test/integration/FactoryRouter.test.ts
Normal file
165
test/integration/FactoryRouter.test.ts
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
import {
|
||||||
|
Router,
|
||||||
|
NftFactory,
|
||||||
|
calculateEstimatedGas,
|
||||||
|
sendTx,
|
||||||
|
sleep
|
||||||
|
} from '@oceanprotocol/lib'
|
||||||
|
import { AbiItem } from 'web3-utils'
|
||||||
|
import { assert } from 'chai'
|
||||||
|
import Web3 from 'web3'
|
||||||
|
import { homedir } from 'os'
|
||||||
|
import fs from 'fs'
|
||||||
|
import { fetch } from 'cross-fetch'
|
||||||
|
|
||||||
|
const data = JSON.parse(
|
||||||
|
fs.readFileSync(
|
||||||
|
process.env.ADDRESS_FILE ||
|
||||||
|
`${homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
||||||
|
'utf8'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
const addresses = data.development
|
||||||
|
const web3 = new Web3('http://127.0.0.1:8545')
|
||||||
|
|
||||||
|
const subgraphUrl =
|
||||||
|
'http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
||||||
|
|
||||||
|
const minAbi = [
|
||||||
|
{
|
||||||
|
constant: false,
|
||||||
|
inputs: [
|
||||||
|
{ name: 'to', type: 'address' },
|
||||||
|
{ name: 'value', type: 'uint256' }
|
||||||
|
],
|
||||||
|
name: 'mint',
|
||||||
|
outputs: [{ name: '', type: 'bool' }],
|
||||||
|
payable: false,
|
||||||
|
stateMutability: 'nonpayable',
|
||||||
|
type: 'function'
|
||||||
|
}
|
||||||
|
] as AbiItem[]
|
||||||
|
|
||||||
|
async function getSubgraphApprovedTokens() {
|
||||||
|
const tokens: string[] = []
|
||||||
|
const initialQuery = {
|
||||||
|
query: `query{
|
||||||
|
opcs{
|
||||||
|
approvedTokens{
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
const initialResponse = await fetch(subgraphUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(initialQuery)
|
||||||
|
})
|
||||||
|
const info = (await initialResponse.json()).data.opcs[0].approvedTokens
|
||||||
|
for (let i = 0; i < info.length; i++) tokens.push(info[i].id)
|
||||||
|
return tokens
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('FactoryRouter tests', async () => {
|
||||||
|
let factory
|
||||||
|
let router: Router
|
||||||
|
let ownerAccount: string
|
||||||
|
let Alice: string
|
||||||
|
let Bob: string
|
||||||
|
let datatokenAddress
|
||||||
|
// let nft1, nft2, nft3
|
||||||
|
// let chainId
|
||||||
|
// const configHelper = new ConfigHelper()
|
||||||
|
// const config = configHelper.getConfig('development')
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
const accounts = await web3.eth.getAccounts()
|
||||||
|
// chainId = await web3.eth.getChainId()
|
||||||
|
ownerAccount = accounts[0]
|
||||||
|
Alice = accounts[1]
|
||||||
|
Bob = accounts[2]
|
||||||
|
|
||||||
|
const tokenContract = new web3.eth.Contract(minAbi, addresses.Ocean)
|
||||||
|
const estGas = await calculateEstimatedGas(
|
||||||
|
ownerAccount,
|
||||||
|
tokenContract.methods.mint,
|
||||||
|
Alice,
|
||||||
|
web3.utils.toWei('100000')
|
||||||
|
)
|
||||||
|
await sendTx(
|
||||||
|
ownerAccount,
|
||||||
|
estGas,
|
||||||
|
web3,
|
||||||
|
1,
|
||||||
|
tokenContract.methods.mint,
|
||||||
|
Alice,
|
||||||
|
web3.utils.toWei('100000')
|
||||||
|
)
|
||||||
|
await sendTx(
|
||||||
|
ownerAccount,
|
||||||
|
estGas,
|
||||||
|
web3,
|
||||||
|
1,
|
||||||
|
tokenContract.methods.mint,
|
||||||
|
Bob,
|
||||||
|
web3.utils.toWei('100000')
|
||||||
|
)
|
||||||
|
router = new Router(addresses.Router, web3)
|
||||||
|
// nftFactory = new NftFactory(addresses.ERC721Factory, web3)
|
||||||
|
factory = new NftFactory(addresses.ERC721Factory, web3)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Ocean token should be in the approve token list', async () => {
|
||||||
|
// since we can only lock once, we test if tx fails or not
|
||||||
|
// so if there is already a lock, skip it
|
||||||
|
const tokens = await getSubgraphApprovedTokens()
|
||||||
|
assert(tokens.includes(addresses.Ocean.toLowerCase()))
|
||||||
|
assert(tokens.length === 1)
|
||||||
|
})
|
||||||
|
it('Owner should add another token in the approved list', async () => {
|
||||||
|
const nftName = 'testNFT'
|
||||||
|
const nftSymbol = 'TST'
|
||||||
|
const marketPlaceFeeAddress = '0x1230000000000000000000000000000000000000'
|
||||||
|
const feeToken = '0x3210000000000000000000000000000000000000'
|
||||||
|
const publishMarketFeeAmount = '0.1'
|
||||||
|
const cap = '10000'
|
||||||
|
const templateIndex = 1
|
||||||
|
const result = await factory.createNftWithDatatoken(
|
||||||
|
Alice,
|
||||||
|
{
|
||||||
|
name: nftName,
|
||||||
|
symbol: nftSymbol,
|
||||||
|
templateIndex,
|
||||||
|
tokenURI: '',
|
||||||
|
transferable: true,
|
||||||
|
owner: Alice
|
||||||
|
},
|
||||||
|
{
|
||||||
|
templateIndex,
|
||||||
|
cap,
|
||||||
|
feeAmount: publishMarketFeeAmount,
|
||||||
|
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||||
|
feeToken,
|
||||||
|
minter: Alice,
|
||||||
|
mpFeeAddress: marketPlaceFeeAddress,
|
||||||
|
name: 'DT1',
|
||||||
|
symbol: 'DT1'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
datatokenAddress = result.events.TokenCreated.returnValues[0].toLowerCase()
|
||||||
|
await router.addApprovedToken(ownerAccount, datatokenAddress)
|
||||||
|
await sleep(2000)
|
||||||
|
const tokens = await getSubgraphApprovedTokens()
|
||||||
|
assert(tokens.includes(datatokenAddress.toLowerCase()))
|
||||||
|
assert(tokens.length === 2)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Owner should remove token from the approved list', async () => {
|
||||||
|
await router.removeApprovedToken(ownerAccount, datatokenAddress)
|
||||||
|
await sleep(2000)
|
||||||
|
const tokens = await getSubgraphApprovedTokens()
|
||||||
|
assert(!tokens.includes(datatokenAddress.toLowerCase()))
|
||||||
|
assert(tokens.length === 1)
|
||||||
|
})
|
||||||
|
})
|
@ -44,7 +44,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
const publishMarketSwapFee = '0.003'
|
const publishMarketSwapFee = '0.003'
|
||||||
const templateIndex = 1
|
const templateIndex = 1
|
||||||
const dtAmount = '10'
|
const dtAmount = '10'
|
||||||
const datatoken = new Datatoken(web3, 8996)
|
// const datatoken = new Datatoken(web3, 8996)
|
||||||
let datatokenAddress: string
|
let datatokenAddress: string
|
||||||
let fixedRateAddress: string
|
let fixedRateAddress: string
|
||||||
let baseTokenAddress: string
|
let baseTokenAddress: string
|
||||||
@ -108,7 +108,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
fixedRate: price,
|
fixedRate: price,
|
||||||
marketFee: publishMarketSwapFee,
|
marketFee: publishMarketSwapFee,
|
||||||
allowedConsumer: ZERO_ADDRESS,
|
allowedConsumer: ZERO_ADDRESS,
|
||||||
withMint: false
|
withMint: true
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await Factory.createNftWithDatatokenWithFixedRate(
|
const result = await Factory.createNftWithDatatokenWithFixedRate(
|
||||||
@ -127,6 +127,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
result.events.NewFixedRate.returnValues.exchangeId.toLowerCase()
|
result.events.NewFixedRate.returnValues.exchangeId.toLowerCase()
|
||||||
|
|
||||||
fixedRateId = `${exchangeContract}-${exchangeId}`
|
fixedRateId = `${exchangeContract}-${exchangeId}`
|
||||||
|
const nftTemplate = await Factory.getNFTTemplate(nftParams.templateIndex)
|
||||||
|
|
||||||
// Check NFT values
|
// Check NFT values
|
||||||
await sleep(sleepMs)
|
await sleep(sleepMs)
|
||||||
@ -138,8 +139,8 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
symbol,
|
symbol,
|
||||||
name,
|
name,
|
||||||
tokenUri,
|
tokenUri,
|
||||||
owner,
|
owner{id},
|
||||||
creator,
|
creator{id},
|
||||||
address,
|
address,
|
||||||
providerUrl,
|
providerUrl,
|
||||||
assetState,
|
assetState,
|
||||||
@ -151,6 +152,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
transferable,
|
transferable,
|
||||||
createdTimestamp,
|
createdTimestamp,
|
||||||
tx,
|
tx,
|
||||||
|
eventIndex,
|
||||||
block,
|
block,
|
||||||
orderCount}}`
|
orderCount}}`
|
||||||
}
|
}
|
||||||
@ -166,8 +168,8 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
assert(nft.symbol === nftSymbol, 'incorrect value for: symbol')
|
assert(nft.symbol === nftSymbol, 'incorrect value for: symbol')
|
||||||
assert(nft.name === nftName, 'incorrect value for: name')
|
assert(nft.name === nftName, 'incorrect value for: name')
|
||||||
assert(nft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
assert(nft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
||||||
assert(nft.owner === publisher, 'incorrect value for: owner')
|
assert(nft.owner.id === publisher, 'incorrect value for: owner')
|
||||||
assert(nft.creator === publisher, 'incorrect value for: creator')
|
assert(nft.creator.id === publisher, 'incorrect value for: creator')
|
||||||
assert(nft.managerRole[0] === publisher, 'incorrect value for: managerRole')
|
assert(nft.managerRole[0] === publisher, 'incorrect value for: managerRole')
|
||||||
assert(
|
assert(
|
||||||
nft.erc20DeployerRole[0] === factoryAddress,
|
nft.erc20DeployerRole[0] === factoryAddress,
|
||||||
@ -175,7 +177,10 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
)
|
)
|
||||||
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
||||||
assert(nft.metadataRole === null, 'incorrect value for: metadataRole')
|
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.transferable === true, 'incorrect value for: transferable')
|
||||||
assert(
|
assert(
|
||||||
nft.createdTimestamp >= time,
|
nft.createdTimestamp >= time,
|
||||||
@ -191,6 +196,10 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
assert(nft.block >= blockNumber, 'incorrect value for: block')
|
assert(nft.block >= blockNumber, 'incorrect value for: block')
|
||||||
assert(nft.block < blockNumber + 50, 'incorrect value for: block')
|
assert(nft.block < blockNumber + 50, 'incorrect value for: block')
|
||||||
assert(nft.orderCount === '0', 'incorrect value for: orderCount')
|
assert(nft.orderCount === '0', 'incorrect value for: orderCount')
|
||||||
|
assert(
|
||||||
|
nft.eventIndex !== null && nft.eventIndex > 0,
|
||||||
|
'incorrect value for: eventIndex'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Test DT Fields after deploying Fixed rate exchange', async () => {
|
it('Test DT Fields after deploying Fixed rate exchange', async () => {
|
||||||
@ -220,6 +229,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
dispensers {id},
|
dispensers {id},
|
||||||
createdTimestamp,
|
createdTimestamp,
|
||||||
tx,
|
tx,
|
||||||
|
eventIndex,
|
||||||
block,
|
block,
|
||||||
lastPriceToken,
|
lastPriceToken,
|
||||||
lastPriceValue
|
lastPriceValue
|
||||||
@ -257,7 +267,10 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
'incorrect value for: 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.holderCount === '0', 'incorrect value for: holderCount')
|
||||||
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
assert(dt.orderCount === '0', 'incorrect value for: orderCount')
|
||||||
assert(dt.orders, 'incorrect value for: orders')
|
assert(dt.orders, 'incorrect value for: orders')
|
||||||
@ -273,11 +286,11 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
assert(dtTx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
assert(dtTx.blockNumber >= blockNumber, 'incorrect value for: tx')
|
||||||
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
assert(dt.block >= blockNumber, 'incorrect value for: block')
|
||||||
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
assert(dt.block < blockNumber + 50, 'incorrect value for: block')
|
||||||
assert(
|
|
||||||
dt.lastPriceToken === '0x0000000000000000000000000000000000000000',
|
|
||||||
'incorrect value for: lastPriceToken'
|
|
||||||
)
|
|
||||||
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
assert(dt.lastPriceValue === '0', 'incorrect value for: lastPriceValue')
|
||||||
|
assert(
|
||||||
|
dt.eventIndex !== null && dt.eventIndex > 0,
|
||||||
|
'incorrect value for: eventIndex'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Test fixedRateExchanges Fields', async () => {
|
it('Test fixedRateExchanges Fields', async () => {
|
||||||
@ -314,6 +327,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
}
|
}
|
||||||
createdTimestamp
|
createdTimestamp
|
||||||
tx
|
tx
|
||||||
|
eventIndex
|
||||||
block
|
block
|
||||||
publishMarketFeeAddress
|
publishMarketFeeAddress
|
||||||
publishMarketSwapFee
|
publishMarketSwapFee
|
||||||
@ -342,7 +356,8 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
'incorrect value for: baseToken.id'
|
'incorrect value for: baseToken.id'
|
||||||
)
|
)
|
||||||
assert(
|
assert(
|
||||||
fixed.datatokenSupply === '0',
|
fixed.datatokenSupply ===
|
||||||
|
'115792089237316195423570985008687900000000000000000000000000',
|
||||||
'incorrect value for: datatokenSupply'
|
'incorrect value for: datatokenSupply'
|
||||||
)
|
)
|
||||||
assert(
|
assert(
|
||||||
@ -364,7 +379,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
fixed.allowedSwapper === ZERO_ADDRESS,
|
fixed.allowedSwapper === ZERO_ADDRESS,
|
||||||
'incorrect value for: allowedSwapper'
|
'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.isMinter === null, 'incorrect value for: isMinter')
|
||||||
assert(fixed.updates, 'incorrect value for: updates.id')
|
assert(fixed.updates, 'incorrect value for: updates.id')
|
||||||
assert(fixed.swaps, 'incorrect value for: swaps')
|
assert(fixed.swaps, 'incorrect value for: swaps')
|
||||||
@ -389,6 +404,10 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
)
|
)
|
||||||
assert(fixedTx.from === publisher, 'incorrect value for: tx')
|
assert(fixedTx.from === publisher, 'incorrect value for: tx')
|
||||||
assert(fixedTx.to === factoryAddress, 'incorrect value for: tx')
|
assert(fixedTx.to === factoryAddress, 'incorrect value for: tx')
|
||||||
|
assert(
|
||||||
|
fixed.eventIndex !== null && fixed.eventIndex > 0,
|
||||||
|
'incorrect value for: eventIndex'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Updates Fixed Rate Price', async () => {
|
it('Updates Fixed Rate Price', async () => {
|
||||||
@ -402,6 +421,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
}
|
}
|
||||||
oldPrice
|
oldPrice
|
||||||
newPrice
|
newPrice
|
||||||
|
eventIndex
|
||||||
}
|
}
|
||||||
}}`
|
}}`
|
||||||
}
|
}
|
||||||
@ -426,7 +446,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
|
|
||||||
// Update price
|
// Update price
|
||||||
const newPrice = '999'
|
const newPrice = '999'
|
||||||
await fixedRate.setRate(publisher, exchangeId, newPrice)
|
const tx = await fixedRate.setRate(publisher, exchangeId, newPrice)
|
||||||
await sleep(sleepMs)
|
await sleep(sleepMs)
|
||||||
|
|
||||||
// Check price after first update
|
// Check price after first update
|
||||||
@ -445,10 +465,14 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
)
|
)
|
||||||
assert(updates2.oldPrice === price1, 'incorrect value: 2nd oldPrice')
|
assert(updates2.oldPrice === price1, 'incorrect value: 2nd oldPrice')
|
||||||
assert(updates2.newPrice === newPrice, 'incorrect value: 2nd newPrice')
|
assert(updates2.newPrice === newPrice, 'incorrect value: 2nd newPrice')
|
||||||
|
assert(
|
||||||
|
updates2.eventIndex === tx.events.ExchangeRateChanged.logIndex,
|
||||||
|
'incorrect value: 2nd eventIndex'
|
||||||
|
)
|
||||||
|
|
||||||
// Update price a 2nd time
|
// Update price a 2nd time
|
||||||
const newPrice2 = '1' // '5.123'
|
const newPrice2 = '1' // '5.123'
|
||||||
await fixedRate.setRate(publisher, exchangeId, newPrice2)
|
const tx2 = await fixedRate.setRate(publisher, exchangeId, newPrice2)
|
||||||
await sleep(sleepMs)
|
await sleep(sleepMs)
|
||||||
|
|
||||||
// Check price after 2nd update
|
// Check price after 2nd update
|
||||||
@ -468,112 +492,10 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
)
|
)
|
||||||
assert(updates3.oldPrice === newPrice, 'incorrect value: 3rd oldPrice')
|
assert(updates3.oldPrice === newPrice, 'incorrect value: 3rd oldPrice')
|
||||||
assert(updates3.newPrice === newPrice2, 'incorrect value: 3rd newPrice')
|
assert(updates3.newPrice === newPrice2, 'incorrect value: 3rd newPrice')
|
||||||
})
|
assert(
|
||||||
it('Deactivates exchange', async () => {
|
updates3.eventIndex === tx2.events.ExchangeRateChanged.logIndex,
|
||||||
const deactiveQuery = {
|
'incorrect value: 3nd eventIndex'
|
||||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){active}}`
|
)
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
.active
|
|
||||||
assert(updatedActive === false, 'incorrect value for: updatedActive')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Activates exchange', async () => {
|
|
||||||
const activeQuery = {
|
|
||||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){active}}`
|
|
||||||
}
|
|
||||||
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
|
|
||||||
.active
|
|
||||||
assert(updatedActive === true, 'incorrect value for: updatedActive')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Activate Minting', async () => {
|
|
||||||
const mintingQuery = {
|
|
||||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){withMint}}`
|
|
||||||
}
|
|
||||||
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
|
|
||||||
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
|
|
||||||
.withMint
|
|
||||||
assert(updatedMint === true, 'incorrect value for: updatedMint')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Deactivate Minting', async () => {
|
|
||||||
const mintingQuery = {
|
|
||||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){withMint}}`
|
|
||||||
}
|
|
||||||
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
|
|
||||||
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
|
|
||||||
.withMint
|
|
||||||
assert(updatedMint === false, 'incorrect value for: updatedMint')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('User1 buys a datatoken', async () => {
|
it('User1 buys a datatoken', async () => {
|
||||||
@ -588,6 +510,10 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
block
|
block
|
||||||
createdTimestamp
|
createdTimestamp
|
||||||
tx
|
tx
|
||||||
|
eventIndex
|
||||||
|
oceanFeeAmount
|
||||||
|
marketFeeAmount
|
||||||
|
consumeMarketFeeAmount
|
||||||
__typename
|
__typename
|
||||||
}
|
}
|
||||||
}}`
|
}}`
|
||||||
@ -630,6 +556,17 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
const tx = (
|
const tx = (
|
||||||
await fixedRate.buyDatatokens(user1, exchangeId, dtAmount, '100')
|
await fixedRate.buyDatatokens(user1, exchangeId, dtAmount, '100')
|
||||||
).events?.Swapped
|
).events?.Swapped
|
||||||
|
|
||||||
|
const oceanFeeAmount = web3.utils.fromWei(
|
||||||
|
new BN(tx.returnValues.oceanFeeAmount)
|
||||||
|
)
|
||||||
|
const marketFeeAmount = web3.utils.fromWei(
|
||||||
|
new BN(tx.returnValues.marketFeeAmount)
|
||||||
|
)
|
||||||
|
const consumeMarketFeeAmount = web3.utils.fromWei(
|
||||||
|
new BN(tx.returnValues.consumeMarketFeeAmount)
|
||||||
|
)
|
||||||
|
|
||||||
await sleep(sleepMs)
|
await sleep(sleepMs)
|
||||||
user1Balance = await datatoken.balance(datatokenAddress, user1)
|
user1Balance = await datatoken.balance(datatokenAddress, user1)
|
||||||
// user1 has 1 datatoken
|
// user1 has 1 datatoken
|
||||||
@ -644,7 +581,11 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
const swappedAmount = web3.utils.fromWei(
|
const swappedAmount = web3.utils.fromWei(
|
||||||
new BN(tx.returnValues.baseTokenSwappedAmount)
|
new BN(tx.returnValues.baseTokenSwappedAmount)
|
||||||
)
|
)
|
||||||
assert(swaps.id === `${tx.transactionHash}-${fixedRateId}`, 'incorrect: id')
|
assert(
|
||||||
|
swaps.id ===
|
||||||
|
`${tx.transactionHash}-${fixedRateId}-${tx.logIndex.toFixed(1)}`,
|
||||||
|
'incorrect: id'
|
||||||
|
)
|
||||||
assert(swaps.exchangeId.id === fixedRateId, 'incorrect: exchangeId')
|
assert(swaps.exchangeId.id === fixedRateId, 'incorrect: exchangeId')
|
||||||
assert(swaps.by.id === user1, 'incorrect value for: id')
|
assert(swaps.by.id === user1, 'incorrect value for: id')
|
||||||
assert(swaps.baseTokenAmount === swappedAmount, 'incorrect baseTokenAmount')
|
assert(swaps.baseTokenAmount === swappedAmount, 'incorrect baseTokenAmount')
|
||||||
@ -652,54 +593,78 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
assert(swaps.block === tx.blockNumber, 'incorrect value for: block')
|
assert(swaps.block === tx.blockNumber, 'incorrect value for: block')
|
||||||
assert(swaps.createdTimestamp >= time, 'incorrect: createdTimestamp')
|
assert(swaps.createdTimestamp >= time, 'incorrect: createdTimestamp')
|
||||||
assert(swaps.createdTimestamp < time + 25, 'incorrect: createdTimestamp 2')
|
assert(swaps.createdTimestamp < time + 25, 'incorrect: createdTimestamp 2')
|
||||||
|
assert(swaps.oceanFeeAmount === oceanFeeAmount, 'incorrect: oceanFeeAmount')
|
||||||
|
assert(swaps.marketFeeAmount === marketFeeAmount, 'wrong marketFeeAmount')
|
||||||
|
assert(
|
||||||
|
swaps.consumeMarketFeeAmount === consumeMarketFeeAmount,
|
||||||
|
'wrong consumeMarketFeeAmount'
|
||||||
|
)
|
||||||
assert(swaps.tx === tx.transactionHash, 'incorrect value for: tx')
|
assert(swaps.tx === tx.transactionHash, 'incorrect value for: tx')
|
||||||
|
assert(swaps.eventIndex === tx.logIndex, 'incorrect value for: eventIndex')
|
||||||
assert(swaps.__typename === 'FixedRateExchangeSwap', 'incorrect __typename')
|
assert(swaps.__typename === 'FixedRateExchangeSwap', 'incorrect __typename')
|
||||||
})
|
})
|
||||||
it('User1 sells a datatoken', async () => {
|
|
||||||
await datatoken.approve(datatokenAddress, fixedRateAddress, dtAmount, user1)
|
it('Deactivate Minting', async () => {
|
||||||
const tx = (await fixedRate.sellDatatokens(user1, exchangeId, '10', '9'))
|
const mintingQuery = {
|
||||||
.events?.Swapped
|
query: `query {fixedRateExchange(id: "${fixedRateId}"){withMint, eventIndex}}`
|
||||||
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
|
|
||||||
__typename
|
|
||||||
}
|
|
||||||
}}`
|
|
||||||
}
|
}
|
||||||
// Check initial swaps
|
const initialResponse = await fetch(subgraphUrl, {
|
||||||
const response = await fetch(subgraphUrl, {
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(swapsQuery)
|
body: JSON.stringify(mintingQuery)
|
||||||
})
|
})
|
||||||
const swaps = (await response.json()).data.fixedRateExchange.swaps[0]
|
const initialMint = (await initialResponse.json()).data.fixedRateExchange
|
||||||
const swappedAmount = web3.utils.fromWei(
|
.withMint
|
||||||
new BN(tx.returnValues.baseTokenSwappedAmount)
|
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('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.id === `${tx.transactionHash}-${fixedRateId}`, 'incorrect: id')
|
|
||||||
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.tx === tx.transactionHash, 'incorrect value for: tx')
|
|
||||||
assert(swaps.__typename === 'FixedRateExchangeSwap', 'incorrect __typename')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Updates allowed swapper', async () => {
|
it('Updates allowed swapper', async () => {
|
||||||
const swapperQuery = {
|
const swapperQuery = {
|
||||||
query: `query {fixedRateExchange(id: "${fixedRateId}"){allowedSwapper}}`
|
query: `query {fixedRateExchange(id: "${fixedRateId}"){allowedSwapper, eventIndex}}`
|
||||||
}
|
}
|
||||||
// Check initial allowedSwapper
|
// Check initial allowedSwapper
|
||||||
const swapperResponse1 = await fetch(subgraphUrl, {
|
const swapperResponse1 = await fetch(subgraphUrl, {
|
||||||
@ -713,7 +678,7 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
'incorrect value for: allowedSwapper'
|
'incorrect value for: allowedSwapper'
|
||||||
)
|
)
|
||||||
|
|
||||||
await fixedRate.setAllowedSwapper(publisher, exchangeId, user1)
|
const tx = await fixedRate.setAllowedSwapper(publisher, exchangeId, user1)
|
||||||
await sleep(sleepMs)
|
await sleep(sleepMs)
|
||||||
|
|
||||||
const swapperResponse2 = await fetch(subgraphUrl, {
|
const swapperResponse2 = await fetch(subgraphUrl, {
|
||||||
@ -721,8 +686,75 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||||||
body: JSON.stringify(swapperQuery)
|
body: JSON.stringify(swapperQuery)
|
||||||
})
|
})
|
||||||
const allowedSwapper2 = (await swapperResponse2.json()).data
|
const allowedSwapper2 = (await swapperResponse2.json()).data
|
||||||
.fixedRateExchange.allowedSwapper
|
.fixedRateExchange
|
||||||
|
|
||||||
assert(allowedSwapper2 === user1, 'incorrect value for: allowedSwapper 2')
|
assert(
|
||||||
|
allowedSwapper2.allowedSwapper === user1,
|
||||||
|
'incorrect value for: allowedSwapper 2'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
allowedSwapper2.eventIndex ===
|
||||||
|
tx.events.ExchangeAllowedSwapperChanged.logIndex,
|
||||||
|
'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 () => {
|
describe('NFT tests', async () => {
|
||||||
const nftName = 'testNFT'
|
const nftName = 'testNFT'
|
||||||
@ -119,9 +120,9 @@ describe('NFT tests', async () => {
|
|||||||
)
|
)
|
||||||
erc721Address = result.events.NFTCreated.returnValues[0]
|
erc721Address = result.events.NFTCreated.returnValues[0]
|
||||||
datatokenAddress = result.events.TokenCreated.returnValues[0]
|
datatokenAddress = result.events.TokenCreated.returnValues[0]
|
||||||
|
nftTemplate = await Factory.getNFTTemplate(nftParams.templateIndex)
|
||||||
// Check values before updating metadata
|
// Check values before updating metadata
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
nftAddress = erc721Address.toLowerCase()
|
nftAddress = erc721Address.toLowerCase()
|
||||||
const initialQuery = {
|
const initialQuery = {
|
||||||
query: `query {
|
query: `query {
|
||||||
@ -130,8 +131,8 @@ describe('NFT tests', async () => {
|
|||||||
symbol,
|
symbol,
|
||||||
name,
|
name,
|
||||||
tokenUri,
|
tokenUri,
|
||||||
owner,
|
owner{id},
|
||||||
creator,
|
creator{id},
|
||||||
address,
|
address,
|
||||||
providerUrl,
|
providerUrl,
|
||||||
assetState,
|
assetState,
|
||||||
@ -143,6 +144,7 @@ describe('NFT tests', async () => {
|
|||||||
transferable,
|
transferable,
|
||||||
createdTimestamp,
|
createdTimestamp,
|
||||||
tx,
|
tx,
|
||||||
|
eventIndex,
|
||||||
block,
|
block,
|
||||||
orderCount}}`
|
orderCount}}`
|
||||||
}
|
}
|
||||||
@ -150,15 +152,15 @@ describe('NFT tests', async () => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(initialQuery)
|
body: JSON.stringify(initialQuery)
|
||||||
})
|
})
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const nft = (await initialResponse.json()).data.nft
|
const nft = (await initialResponse.json()).data.nft
|
||||||
const tx: TransactionReceipt = await web3.eth.getTransactionReceipt(nft.tx)
|
const tx: TransactionReceipt = await web3.eth.getTransactionReceipt(nft.tx)
|
||||||
assert(nft.id === nftAddress, 'incorrect value for: id')
|
assert(nft.id === nftAddress, 'incorrect value for: id')
|
||||||
assert(nft.symbol === nftSymbol, 'incorrect value for: symbol')
|
assert(nft.symbol === nftSymbol, 'incorrect value for: symbol')
|
||||||
assert(nft.name === nftName, 'incorrect value for: name')
|
assert(nft.name === nftName, 'incorrect value for: name')
|
||||||
assert(nft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
assert(nft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
||||||
assert(nft.owner === publisher, 'incorrect value for: owner')
|
assert(nft.owner.id === publisher, 'incorrect value for: owner')
|
||||||
assert(nft.creator === publisher, 'incorrect value for: creator')
|
assert(nft.creator.id === publisher, 'incorrect value for: creator')
|
||||||
assert(nft.managerRole[0] === publisher, 'incorrect value for: managerRole')
|
assert(nft.managerRole[0] === publisher, 'incorrect value for: managerRole')
|
||||||
assert(
|
assert(
|
||||||
nft.erc20DeployerRole[0] === factoryAddress,
|
nft.erc20DeployerRole[0] === factoryAddress,
|
||||||
@ -166,7 +168,10 @@ describe('NFT tests', async () => {
|
|||||||
)
|
)
|
||||||
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
assert(nft.storeUpdateRole === null, 'incorrect value for: storeUpdateRole')
|
||||||
assert(nft.metadataRole === null, 'incorrect value for: metadataRole')
|
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.transferable === true, 'incorrect value for: transferable')
|
||||||
assert(
|
assert(
|
||||||
nft.createdTimestamp >= time,
|
nft.createdTimestamp >= time,
|
||||||
@ -182,21 +187,29 @@ describe('NFT tests', async () => {
|
|||||||
assert(nft.block >= blockNumber, 'incorrect value for: block')
|
assert(nft.block >= blockNumber, 'incorrect value for: block')
|
||||||
assert(nft.block < blockNumber + 50, 'incorrect value for: block')
|
assert(nft.block < blockNumber + 50, 'incorrect value for: block')
|
||||||
assert(nft.orderCount === '0', 'incorrect value for: orderCount')
|
assert(nft.orderCount === '0', 'incorrect value for: orderCount')
|
||||||
|
assert(
|
||||||
|
nft.eventIndex !== null && nft.eventIndex > 0,
|
||||||
|
'Invalid eventIndex for NFT creation'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Update metadata', async () => {
|
it('Update metadata', async () => {
|
||||||
|
const chain = await web3.eth.getChainId()
|
||||||
// create the files encrypted string
|
// create the files encrypted string
|
||||||
let providerResponse = await ProviderInstance.encrypt(assetUrl, providerUrl)
|
let providerResponse = await ProviderInstance.encrypt(
|
||||||
|
assetUrl,
|
||||||
|
chain,
|
||||||
|
providerUrl
|
||||||
|
)
|
||||||
ddo.services[0].files = await providerResponse
|
ddo.services[0].files = await providerResponse
|
||||||
ddo.services[0].datatokenAddress = datatokenAddress
|
ddo.services[0].datatokenAddress = datatokenAddress
|
||||||
// update ddo and set the right did
|
// update ddo and set the right did
|
||||||
ddo.nftAddress = erc721Address
|
ddo.nftAddress = erc721Address
|
||||||
const chain = await web3.eth.getChainId()
|
|
||||||
ddo.id =
|
ddo.id =
|
||||||
'did:op:' +
|
'did:op:' +
|
||||||
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
||||||
|
|
||||||
providerResponse = await ProviderInstance.encrypt(ddo, providerUrl)
|
providerResponse = await ProviderInstance.encrypt(ddo, chain, providerUrl)
|
||||||
const encryptedResponse = await providerResponse
|
const encryptedResponse = await providerResponse
|
||||||
const metadataHash = getHash(JSON.stringify(ddo))
|
const metadataHash = getHash(JSON.stringify(ddo))
|
||||||
await nft.setMetadata(
|
await nft.setMetadata(
|
||||||
@ -211,7 +224,7 @@ describe('NFT tests', async () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// graph tests here
|
// graph tests here
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const query = {
|
const query = {
|
||||||
query: `query {
|
query: `query {
|
||||||
nft(id:"${nftAddress}"){
|
nft(id:"${nftAddress}"){
|
||||||
@ -219,8 +232,8 @@ describe('NFT tests', async () => {
|
|||||||
symbol,
|
symbol,
|
||||||
name,
|
name,
|
||||||
tokenUri,
|
tokenUri,
|
||||||
owner,
|
owner{id},
|
||||||
creator,
|
creator{id},
|
||||||
address,
|
address,
|
||||||
providerUrl,
|
providerUrl,
|
||||||
assetState,
|
assetState,
|
||||||
@ -232,6 +245,7 @@ describe('NFT tests', async () => {
|
|||||||
transferable,
|
transferable,
|
||||||
createdTimestamp,
|
createdTimestamp,
|
||||||
tx,
|
tx,
|
||||||
|
eventIndex,
|
||||||
block,
|
block,
|
||||||
orderCount}}`
|
orderCount}}`
|
||||||
}
|
}
|
||||||
@ -239,6 +253,7 @@ describe('NFT tests', async () => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(query)
|
body: JSON.stringify(query)
|
||||||
})
|
})
|
||||||
|
await sleep(3000)
|
||||||
const updatedNft = (await response.json()).data.nft
|
const updatedNft = (await response.json()).data.nft
|
||||||
const tx: TransactionReceipt = await web3.eth.getTransactionReceipt(
|
const tx: TransactionReceipt = await web3.eth.getTransactionReceipt(
|
||||||
updatedNft.tx
|
updatedNft.tx
|
||||||
@ -247,8 +262,8 @@ describe('NFT tests', async () => {
|
|||||||
assert(updatedNft.symbol === nftSymbol, 'incorrect value for: symbol')
|
assert(updatedNft.symbol === nftSymbol, 'incorrect value for: symbol')
|
||||||
assert(updatedNft.name === nftName, 'incorrect value for: name')
|
assert(updatedNft.name === nftName, 'incorrect value for: name')
|
||||||
assert(updatedNft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
assert(updatedNft.tokenUri === tokenURI, 'incorrect value for: tokenUri')
|
||||||
assert(updatedNft.owner === publisher, 'incorrect value for: owner')
|
assert(updatedNft.owner.id === publisher, 'incorrect value for: owner')
|
||||||
assert(updatedNft.creator === publisher, 'incorrect value for: creator')
|
assert(updatedNft.creator.id === publisher, 'incorrect value for: creator')
|
||||||
assert(
|
assert(
|
||||||
updatedNft.managerRole[0] === publisher,
|
updatedNft.managerRole[0] === publisher,
|
||||||
'incorrect value for: managerRole'
|
'incorrect value for: managerRole'
|
||||||
@ -265,7 +280,10 @@ describe('NFT tests', async () => {
|
|||||||
updatedNft.metadataRole === null,
|
updatedNft.metadataRole === null,
|
||||||
'incorrect value for: metadataRole'
|
'incorrect value for: metadataRole'
|
||||||
)
|
)
|
||||||
assert(updatedNft.template === '', 'incorrect value for: template')
|
assert(
|
||||||
|
updatedNft.template === nftTemplate.templateAddress.toLowerCase(),
|
||||||
|
'incorrect value for: template'
|
||||||
|
)
|
||||||
assert(
|
assert(
|
||||||
updatedNft.transferable === true,
|
updatedNft.transferable === true,
|
||||||
'incorrect value for: transferable'
|
'incorrect value for: transferable'
|
||||||
@ -284,6 +302,10 @@ describe('NFT tests', async () => {
|
|||||||
assert(updatedNft.block >= blockNumber, 'incorrect value for: block')
|
assert(updatedNft.block >= blockNumber, 'incorrect value for: block')
|
||||||
assert(updatedNft.block < blockNumber + 50, 'incorrect value for: block')
|
assert(updatedNft.block < blockNumber + 50, 'incorrect value for: block')
|
||||||
assert(updatedNft.orderCount === '0', 'incorrect value for: orderCount')
|
assert(updatedNft.orderCount === '0', 'incorrect value for: orderCount')
|
||||||
|
assert(
|
||||||
|
updatedNft.eventIndex !== null && updatedNft.eventIndex > 0,
|
||||||
|
'Invalid eventIndex for NFT update'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Set a key/value in erc725 store', async () => {
|
it('Set a key/value in erc725 store', async () => {
|
||||||
@ -297,6 +319,7 @@ describe('NFT tests', async () => {
|
|||||||
key
|
key
|
||||||
value
|
value
|
||||||
}
|
}
|
||||||
|
eventIndex
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
}
|
}
|
||||||
@ -306,5 +329,9 @@ describe('NFT tests', async () => {
|
|||||||
})
|
})
|
||||||
const updatedNft = (await response.json()).data.nft
|
const updatedNft = (await response.json()).data.nft
|
||||||
assert(updatedNft.nftData.key !== null, 'incorrect value for key')
|
assert(updatedNft.nftData.key !== null, 'incorrect value for key')
|
||||||
|
assert(
|
||||||
|
updatedNft.eventIndex !== null && updatedNft.eventIndex > 0,
|
||||||
|
'Invalid eventIndex for NFT update'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -122,18 +122,22 @@ describe('Simple Publish & consume test', async () => {
|
|||||||
const erc721Address = result.events.NFTCreated.returnValues[0]
|
const erc721Address = result.events.NFTCreated.returnValues[0]
|
||||||
datatokenAddress = result.events.TokenCreated.returnValues[0]
|
datatokenAddress = result.events.TokenCreated.returnValues[0]
|
||||||
|
|
||||||
|
const chain = await web3.eth.getChainId()
|
||||||
// create the files encrypted string
|
// create the files encrypted string
|
||||||
let providerResponse = await ProviderInstance.encrypt(assetUrl, providerUrl)
|
let providerResponse = await ProviderInstance.encrypt(
|
||||||
|
assetUrl,
|
||||||
|
chain,
|
||||||
|
providerUrl
|
||||||
|
)
|
||||||
ddo.services[0].files = await providerResponse
|
ddo.services[0].files = await providerResponse
|
||||||
ddo.services[0].datatokenAddress = datatokenAddress
|
ddo.services[0].datatokenAddress = datatokenAddress
|
||||||
// update ddo and set the right did
|
// update ddo and set the right did
|
||||||
ddo.nftAddress = erc721Address
|
ddo.nftAddress = erc721Address
|
||||||
const chain = await web3.eth.getChainId()
|
|
||||||
ddo.id =
|
ddo.id =
|
||||||
'did:op:' +
|
'did:op:' +
|
||||||
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
||||||
|
|
||||||
providerResponse = await ProviderInstance.encrypt(ddo, providerUrl)
|
providerResponse = await ProviderInstance.encrypt(ddo, chain, providerUrl)
|
||||||
const encryptedResponse = await providerResponse
|
const encryptedResponse = await providerResponse
|
||||||
const metadataHash = getHash(JSON.stringify(ddo))
|
const metadataHash = getHash(JSON.stringify(ddo))
|
||||||
await nft.setMetadata(
|
await nft.setMetadata(
|
||||||
@ -148,18 +152,24 @@ describe('Simple Publish & consume test', async () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// graph tests here
|
// graph tests here
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const graphNftToken = erc721Address.toLowerCase()
|
const graphNftToken = erc721Address.toLowerCase()
|
||||||
const query = {
|
const query = {
|
||||||
query: `query {
|
query: `query {
|
||||||
nft(id:"${graphNftToken}"){symbol,id}}`
|
nft(id:"${graphNftToken}"){symbol,id,eventIndex}}`
|
||||||
}
|
}
|
||||||
const response = await fetch(subgraphUrl, {
|
const response = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(query)
|
body: JSON.stringify(query)
|
||||||
})
|
})
|
||||||
|
await sleep(3000)
|
||||||
const queryResult = await response.json()
|
const queryResult = await response.json()
|
||||||
assert(queryResult.data.nft.id === graphNftToken)
|
assert(queryResult.data.nft.id === graphNftToken)
|
||||||
|
assert(
|
||||||
|
queryResult.data.nft.eventIndex !== null &&
|
||||||
|
queryResult.data.nft.eventIndex > 0,
|
||||||
|
'Invalid eventIndex for NFT creation'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
it('should publish and transfer an NFT', async () => {
|
it('should publish and transfer an NFT', async () => {
|
||||||
const nftParams: NftCreateData = {
|
const nftParams: NftCreateData = {
|
||||||
@ -184,38 +194,48 @@ describe('Simple Publish & consume test', async () => {
|
|||||||
nftParams,
|
nftParams,
|
||||||
erc20Params
|
erc20Params
|
||||||
)
|
)
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const erc721Address = result.events.NFTCreated.returnValues[0]
|
const erc721Address = result.events.NFTCreated.returnValues[0]
|
||||||
const datatokenAddress = result.events.TokenCreated.returnValues[0]
|
const datatokenAddress = result.events.TokenCreated.returnValues[0]
|
||||||
const graphNftToken = erc721Address.toLowerCase()
|
const graphNftToken = erc721Address.toLowerCase()
|
||||||
|
|
||||||
const queryOriginalOwner = {
|
const queryOriginalOwner = {
|
||||||
query: `query {
|
query: `query {
|
||||||
nft(id:"${graphNftToken}"){symbol,id,owner}}`
|
nft(id:"${graphNftToken}"){symbol,id,owner{id},eventIndex}}`
|
||||||
}
|
}
|
||||||
const initialResponse = await fetch(subgraphUrl, {
|
const initialResponse = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(queryOriginalOwner)
|
body: JSON.stringify(queryOriginalOwner)
|
||||||
})
|
})
|
||||||
|
await sleep(3000)
|
||||||
const initialResult = await initialResponse.json()
|
const initialResult = await initialResponse.json()
|
||||||
// Checking original owner account has been set correctly
|
// Checking original owner account has been set correctly
|
||||||
assert(
|
assert(
|
||||||
initialResult.data.nft.owner.toLowerCase() ===
|
initialResult.data.nft.owner.id.toLowerCase() ===
|
||||||
publisherAccount.toLowerCase()
|
publisherAccount.toLowerCase()
|
||||||
)
|
)
|
||||||
|
assert(
|
||||||
|
initialResult.data.nft.eventIndex !== null &&
|
||||||
|
initialResult.data.nft.eventIndex > 0,
|
||||||
|
'Invalid eventIndex for NFT creation'
|
||||||
|
)
|
||||||
|
|
||||||
// create the files encrypted string
|
// create the files encrypted string
|
||||||
let providerResponse = await ProviderInstance.encrypt(assetUrl, providerUrl)
|
const chain = await web3.eth.getChainId()
|
||||||
|
let providerResponse = await ProviderInstance.encrypt(
|
||||||
|
assetUrl,
|
||||||
|
chain,
|
||||||
|
providerUrl
|
||||||
|
)
|
||||||
ddo.services[0].files = await providerResponse
|
ddo.services[0].files = await providerResponse
|
||||||
ddo.services[0].datatokenAddress = datatokenAddress
|
ddo.services[0].datatokenAddress = datatokenAddress
|
||||||
// update ddo and set the right did
|
// update ddo and set the right did
|
||||||
ddo.nftAddress = erc721Address
|
ddo.nftAddress = erc721Address
|
||||||
const chain = await web3.eth.getChainId()
|
|
||||||
ddo.id =
|
ddo.id =
|
||||||
'did:op:' +
|
'did:op:' +
|
||||||
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
SHA256(web3.utils.toChecksumAddress(erc721Address) + chain.toString(10))
|
||||||
|
|
||||||
providerResponse = await ProviderInstance.encrypt(ddo, providerUrl)
|
providerResponse = await ProviderInstance.encrypt(ddo, chain, providerUrl)
|
||||||
const encryptedResponse = await providerResponse
|
const encryptedResponse = await providerResponse
|
||||||
const metadataHash = getHash(JSON.stringify(ddo))
|
const metadataHash = getHash(JSON.stringify(ddo))
|
||||||
await nft.setMetadata(
|
await nft.setMetadata(
|
||||||
@ -228,21 +248,27 @@ describe('Simple Publish & consume test', async () => {
|
|||||||
encryptedResponse,
|
encryptedResponse,
|
||||||
'0x' + metadataHash
|
'0x' + metadataHash
|
||||||
)
|
)
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
|
|
||||||
// Transfer the NFT
|
// Transfer the NFT
|
||||||
await nft.transferNft(graphNftToken, publisherAccount, newOwnerAccount)
|
await nft.transferNft(graphNftToken, publisherAccount, newOwnerAccount)
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const query2 = {
|
const query2 = {
|
||||||
query: `query {
|
query: `query {
|
||||||
nft(id:"${graphNftToken}"){symbol,id,owner, transferable}}`
|
nft(id:"${graphNftToken}"){symbol,id,owner{id}, transferable, eventIndex}}`
|
||||||
}
|
}
|
||||||
const response = await fetch(subgraphUrl, {
|
const response = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(query2)
|
body: JSON.stringify(query2)
|
||||||
})
|
})
|
||||||
|
await sleep(3000)
|
||||||
const queryResult = await response.json()
|
const queryResult = await response.json()
|
||||||
assert(queryResult.data.nft.owner === newOwnerAccount)
|
assert(queryResult.data.nft.owner.id === newOwnerAccount)
|
||||||
|
assert(
|
||||||
|
queryResult.data.nft.eventIndex !== null &&
|
||||||
|
queryResult.data.nft.eventIndex > 0,
|
||||||
|
'Invalid eventIndex for NFT creation'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should save provider fees after startOrder is called', async () => {
|
it('should save provider fees after startOrder is called', async () => {
|
||||||
@ -280,19 +306,26 @@ describe('Simple Publish & consume test', async () => {
|
|||||||
1,
|
1,
|
||||||
setProviderFee
|
setProviderFee
|
||||||
)
|
)
|
||||||
const orderId = `${orderTx.transactionHash.toLowerCase()}-${datatokenAddress.toLowerCase()}-${user1.toLowerCase()}`
|
await sleep(3000)
|
||||||
|
const orderId = `${orderTx.transactionHash.toLowerCase()}-${datatokenAddress.toLowerCase()}-${user1.toLowerCase()}-${orderTx.events.OrderStarted.logIndex.toFixed(
|
||||||
|
1
|
||||||
|
)}`
|
||||||
|
const query = {
|
||||||
|
query: `query {order(id:"${orderId}"){id, providerFee, lastPriceToken{id}, eventIndex}}`
|
||||||
|
}
|
||||||
|
|
||||||
const query = { query: `query {order(id:"${orderId}"){id, providerFee}}` }
|
await sleep(3000)
|
||||||
|
|
||||||
await sleep(2000)
|
|
||||||
const response = await fetch(subgraphUrl, {
|
const response = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(query)
|
body: JSON.stringify(query)
|
||||||
})
|
})
|
||||||
|
await sleep(3000)
|
||||||
const queryResult = await response.json()
|
const queryResult = await response.json()
|
||||||
|
|
||||||
const providerFeeJSON = JSON.parse(queryResult.data.order.providerFee)
|
const providerFeeJSON = JSON.parse(queryResult.data.order.providerFee)
|
||||||
|
const lastPriceToken = queryResult.data.order.lastPriceToken.id
|
||||||
|
|
||||||
|
assert(lastPriceToken === ZERO_ADDRESS, 'Wrong lastPriceToken')
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
providerFeeJSON.providerFeeAddress.toLowerCase() ===
|
providerFeeJSON.providerFeeAddress.toLowerCase() ===
|
||||||
@ -309,6 +342,10 @@ describe('Simple Publish & consume test', async () => {
|
|||||||
setProviderFee.providerFeeToken.toLowerCase(),
|
setProviderFee.providerFeeToken.toLowerCase(),
|
||||||
'Wrong providerFeeToken set'
|
'Wrong providerFeeToken set'
|
||||||
)
|
)
|
||||||
|
assert(
|
||||||
|
queryResult.data.order.eventIndex !== null,
|
||||||
|
'Invalid eventIndex for order'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should save provider fees after calling reuseOrder on a using a previous txId', async () => {
|
it('should save provider fees after calling reuseOrder on a using a previous txId', async () => {
|
||||||
@ -349,21 +386,26 @@ describe('Simple Publish & consume test', async () => {
|
|||||||
assert(orderTx.transactionHash, 'Failed to start order')
|
assert(orderTx.transactionHash, 'Failed to start order')
|
||||||
|
|
||||||
// Check initial provider fee has been set correctly
|
// Check initial provider fee has been set correctly
|
||||||
const orderId = `${orderTx.transactionHash.toLowerCase()}-${datatokenAddress.toLowerCase()}-${user4.toLowerCase()}`
|
const orderId = `${orderTx.transactionHash.toLowerCase()}-${datatokenAddress.toLowerCase()}-${user4.toLowerCase()}-${orderTx.events.OrderStarted.logIndex.toFixed(
|
||||||
|
1
|
||||||
|
)}`
|
||||||
|
|
||||||
const initialQuery = {
|
const initialQuery = {
|
||||||
query: `query {order(id:"${orderId}"){id, providerFee}}`
|
query: `query {order(id:"${orderId}"){id, providerFee, lastPriceToken{id}, eventIndex}}`
|
||||||
}
|
}
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const initialResponse = await fetch(subgraphUrl, {
|
const initialResponse = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(initialQuery)
|
body: JSON.stringify(initialQuery)
|
||||||
})
|
})
|
||||||
|
await sleep(3000)
|
||||||
const initialQueryResult = await initialResponse.json()
|
const initialQueryResult = await initialResponse.json()
|
||||||
const initialProviderFeeJSON = JSON.parse(
|
const initialProviderFeeJSON = JSON.parse(
|
||||||
initialQueryResult.data.order.providerFee
|
initialQueryResult.data.order.providerFee
|
||||||
)
|
)
|
||||||
|
const lastPriceToken = initialQueryResult.data.order.lastPriceToken.id
|
||||||
|
|
||||||
|
assert(lastPriceToken === ZERO_ADDRESS, 'Wrong initial lastPriceToken set')
|
||||||
assert(
|
assert(
|
||||||
initialProviderFeeJSON.providerFeeAddress.toLowerCase() ===
|
initialProviderFeeJSON.providerFeeAddress.toLowerCase() ===
|
||||||
setInitialProviderFee.providerFeeAddress.toLowerCase(),
|
setInitialProviderFee.providerFeeAddress.toLowerCase(),
|
||||||
@ -379,6 +421,10 @@ describe('Simple Publish & consume test', async () => {
|
|||||||
setInitialProviderFee.providerFeeToken.toLowerCase(),
|
setInitialProviderFee.providerFeeToken.toLowerCase(),
|
||||||
'Wrong initial providerFeeToken set'
|
'Wrong initial providerFeeToken set'
|
||||||
)
|
)
|
||||||
|
assert(
|
||||||
|
initialQueryResult.data.order.eventIndex !== null,
|
||||||
|
'Invalid eventIndex for order'
|
||||||
|
)
|
||||||
|
|
||||||
providerFeeAmount = '990000'
|
providerFeeAmount = '990000'
|
||||||
providerValidUntil = '10000'
|
providerValidUntil = '10000'
|
||||||
@ -407,7 +453,7 @@ describe('Simple Publish & consume test', async () => {
|
|||||||
|
|
||||||
const reusedOrder = await datatoken.reuseOrder(
|
const reusedOrder = await datatoken.reuseOrder(
|
||||||
datatokenAddress,
|
datatokenAddress,
|
||||||
user2,
|
user4,
|
||||||
orderTx.transactionHash,
|
orderTx.transactionHash,
|
||||||
setNewProviderFee
|
setNewProviderFee
|
||||||
)
|
)
|
||||||
@ -419,7 +465,11 @@ describe('Simple Publish & consume test', async () => {
|
|||||||
// Check the new provider fee has been set in OrderReuse
|
// Check the new provider fee has been set in OrderReuse
|
||||||
|
|
||||||
const reuseQuery = {
|
const reuseQuery = {
|
||||||
query: `query {orderReuse(id:"${reusedOrder.transactionHash}"){id, providerFee}}`
|
query: `query {orderReuse(id:"${
|
||||||
|
reusedOrder.transactionHash
|
||||||
|
}-${reusedOrder.events.OrderReused.logIndex.toFixed(
|
||||||
|
1
|
||||||
|
)}"){id, providerFee, eventIndex}}`
|
||||||
}
|
}
|
||||||
|
|
||||||
await sleep(2000)
|
await sleep(2000)
|
||||||
@ -449,5 +499,17 @@ describe('Simple Publish & consume test', async () => {
|
|||||||
setNewProviderFee.providerFeeToken.toLowerCase(),
|
setNewProviderFee.providerFeeToken.toLowerCase(),
|
||||||
'New providerFeeToken set in reuse order is wrong'
|
'New providerFeeToken set in reuse order is wrong'
|
||||||
)
|
)
|
||||||
|
assert(
|
||||||
|
reuseQueryResult.data.orderReuse.eventIndex !== null,
|
||||||
|
'Invalid eventIndex for reuse order'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
reuseQueryResult.data.orderReuse.eventIndex === 0,
|
||||||
|
'Invalid reuse order event index'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
initialQueryResult.data.order.eventIndex === 0,
|
||||||
|
'Invalid start order event index'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -31,6 +31,7 @@ describe('Tests coverage without provider/aquarius', async () => {
|
|||||||
let accounts: string[]
|
let accounts: string[]
|
||||||
let publisherAccount: string
|
let publisherAccount: string
|
||||||
let newOwnerAccount: string
|
let newOwnerAccount: string
|
||||||
|
let time: number
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
nft = new Nft(web3)
|
nft = new Nft(web3)
|
||||||
@ -38,6 +39,8 @@ describe('Tests coverage without provider/aquarius', async () => {
|
|||||||
accounts = await web3.eth.getAccounts()
|
accounts = await web3.eth.getAccounts()
|
||||||
publisherAccount = accounts[0]
|
publisherAccount = accounts[0]
|
||||||
newOwnerAccount = accounts[1].toLowerCase()
|
newOwnerAccount = accounts[1].toLowerCase()
|
||||||
|
const date = new Date()
|
||||||
|
time = Math.floor(date.getTime() / 1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should publish a dataset (create NFT + ERC20)', async () => {
|
it('should publish a dataset (create NFT + ERC20)', async () => {
|
||||||
@ -66,18 +69,23 @@ describe('Tests coverage without provider/aquarius', async () => {
|
|||||||
const erc721Address = result.events.NFTCreated.returnValues[0]
|
const erc721Address = result.events.NFTCreated.returnValues[0]
|
||||||
|
|
||||||
// graph tests here
|
// graph tests here
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const graphNftToken = erc721Address.toLowerCase()
|
const graphNftToken = erc721Address.toLowerCase()
|
||||||
const query = {
|
const query = {
|
||||||
query: `query {
|
query: `query {
|
||||||
nft(id:"${graphNftToken}"){symbol,id}}`
|
nft(id:"${graphNftToken}"){symbol,id,eventIndex}}`
|
||||||
}
|
}
|
||||||
const response = await fetch(subgraphUrl, {
|
const response = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(query)
|
body: JSON.stringify(query)
|
||||||
})
|
})
|
||||||
|
await sleep(3000)
|
||||||
const queryResult = await response.json()
|
const queryResult = await response.json()
|
||||||
assert(queryResult.data.nft.id === graphNftToken)
|
assert(queryResult.data.nft.id === graphNftToken)
|
||||||
|
assert(
|
||||||
|
queryResult.data.nft.eventIndex !== null &&
|
||||||
|
queryResult.data.nft.eventIndex > 0
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should publish and transfer an NFT', async () => {
|
it('should publish and transfer an NFT', async () => {
|
||||||
@ -103,22 +111,53 @@ describe('Tests coverage without provider/aquarius', async () => {
|
|||||||
nftParams,
|
nftParams,
|
||||||
erc20Params
|
erc20Params
|
||||||
)
|
)
|
||||||
await sleep(2000)
|
await sleep(3000)
|
||||||
const erc721Address = result.events.NFTCreated.returnValues[0]
|
const erc721Address = result.events.NFTCreated.returnValues[0]
|
||||||
const graphNftToken = erc721Address.toLowerCase()
|
const nftAddress = erc721Address.toLowerCase()
|
||||||
|
|
||||||
// Transfer the NFT
|
// Transfer the NFT
|
||||||
await nft.transferNft(graphNftToken, publisherAccount, newOwnerAccount)
|
const tx = await nft.transferNft(
|
||||||
await sleep(2000)
|
nftAddress,
|
||||||
|
publisherAccount,
|
||||||
|
newOwnerAccount
|
||||||
|
)
|
||||||
|
|
||||||
|
await sleep(3000)
|
||||||
const query2 = {
|
const query2 = {
|
||||||
query: `query {
|
query: `query {
|
||||||
nft(id:"${graphNftToken}"){symbol,id,owner, transferable}}`
|
nft(id:"${nftAddress}"){
|
||||||
|
symbol,
|
||||||
|
id,
|
||||||
|
owner{id},
|
||||||
|
transferable,
|
||||||
|
transferHistory(orderBy: timestamp, orderDirection: desc){id,nft,oldOwner,newOwner,txId,eventIndex,timestamp,block}
|
||||||
|
}}`
|
||||||
}
|
}
|
||||||
const response = await fetch(subgraphUrl, {
|
const response = await fetch(subgraphUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(query2)
|
body: JSON.stringify(query2)
|
||||||
})
|
})
|
||||||
|
await sleep(3000)
|
||||||
const queryResult = await response.json()
|
const queryResult = await response.json()
|
||||||
assert(queryResult.data.nft.owner === newOwnerAccount)
|
const transferHistory = queryResult.data.nft.transferHistory[0]
|
||||||
|
|
||||||
|
assert(queryResult.data.nft.owner.id === newOwnerAccount)
|
||||||
|
assert(
|
||||||
|
transferHistory.id ===
|
||||||
|
`${nftAddress}-${
|
||||||
|
tx.transactionHash
|
||||||
|
}-${tx.events.Transfer.logIndex.toFixed(1)}`,
|
||||||
|
'Invalid transferHistory Id'
|
||||||
|
)
|
||||||
|
assert(transferHistory.txId === tx.transactionHash, 'invalid txId')
|
||||||
|
assert(
|
||||||
|
transferHistory.eventIndex === tx.events.Transfer.logIndex,
|
||||||
|
'invalid eventIndex'
|
||||||
|
)
|
||||||
|
assert(transferHistory.timestamp)
|
||||||
|
|
||||||
|
assert(transferHistory.timestamp >= time - 500, 'incorrect value timestamp')
|
||||||
|
assert(transferHistory.timestamp < time + 500, 'incorrect value timestamp')
|
||||||
|
assert(transferHistory.block === tx.blockNumber, 'blockNumber')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -16,6 +16,7 @@ import Web3 from 'web3'
|
|||||||
import { homedir } from 'os'
|
import { homedir } from 'os'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import { fetch } from 'cross-fetch'
|
import { fetch } from 'cross-fetch'
|
||||||
|
import veDelegation from '@oceanprotocol/contracts/artifacts/contracts/ve/veDelegation.vy/veDelegation.json'
|
||||||
|
|
||||||
const data = JSON.parse(
|
const data = JSON.parse(
|
||||||
fs.readFileSync(
|
fs.readFileSync(
|
||||||
@ -69,6 +70,23 @@ function evmIncreaseTime(seconds) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getTotalLockedOcean() {
|
||||||
|
const initialQuery = {
|
||||||
|
query: `query{
|
||||||
|
globalStatistics{
|
||||||
|
totalOceanLocked
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
const initialResponse = await fetch(subgraphUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(initialQuery)
|
||||||
|
})
|
||||||
|
const data = (await initialResponse.json()).data.globalStatistics
|
||||||
|
if (data.length == 0) return 0
|
||||||
|
|
||||||
|
return data[0].totalOceanLocked
|
||||||
|
}
|
||||||
const minAbi = [
|
const minAbi = [
|
||||||
{
|
{
|
||||||
constant: false,
|
constant: false,
|
||||||
@ -87,6 +105,7 @@ const minAbi = [
|
|||||||
describe('veOcean tests', async () => {
|
describe('veOcean tests', async () => {
|
||||||
let nftFactory
|
let nftFactory
|
||||||
let veOcean: VeOcean
|
let veOcean: VeOcean
|
||||||
|
let delegateContract
|
||||||
let veAllocate: VeAllocate
|
let veAllocate: VeAllocate
|
||||||
let veFeeDistributor: VeFeeDistributor
|
let veFeeDistributor: VeFeeDistributor
|
||||||
let ownerAccount: string
|
let ownerAccount: string
|
||||||
@ -103,6 +122,10 @@ describe('veOcean tests', async () => {
|
|||||||
ownerAccount = accounts[0]
|
ownerAccount = accounts[0]
|
||||||
Alice = accounts[1]
|
Alice = accounts[1]
|
||||||
Bob = accounts[2]
|
Bob = accounts[2]
|
||||||
|
delegateContract = new web3.eth.Contract(
|
||||||
|
veDelegation.abi as AbiItem[],
|
||||||
|
addresses.veDelegation
|
||||||
|
)
|
||||||
|
|
||||||
const tokenContract = new web3.eth.Contract(minAbi, addresses.Ocean)
|
const tokenContract = new web3.eth.Contract(minAbi, addresses.Ocean)
|
||||||
const estGas = await calculateEstimatedGas(
|
const estGas = await calculateEstimatedGas(
|
||||||
@ -138,6 +161,7 @@ describe('veOcean tests', async () => {
|
|||||||
it('Alice should lock 100 Ocean', async () => {
|
it('Alice should lock 100 Ocean', async () => {
|
||||||
// since we can only lock once, we test if tx fails or not
|
// since we can only lock once, we test if tx fails or not
|
||||||
// so if there is already a lock, skip it
|
// so if there is already a lock, skip it
|
||||||
|
const totalOceanLockedBefore = await getTotalLockedOcean()
|
||||||
let currentBalance = await veOcean.getLockedAmount(Alice)
|
let currentBalance = await veOcean.getLockedAmount(Alice)
|
||||||
let currentLock = await veOcean.lockEnd(Alice)
|
let currentLock = await veOcean.lockEnd(Alice)
|
||||||
const amount = '100'
|
const amount = '100'
|
||||||
@ -166,6 +190,19 @@ describe('veOcean tests', async () => {
|
|||||||
currentBalance = await veOcean.getLockedAmount(Alice)
|
currentBalance = await veOcean.getLockedAmount(Alice)
|
||||||
currentLock = await veOcean.lockEnd(Alice)
|
currentLock = await veOcean.lockEnd(Alice)
|
||||||
await sleep(2000)
|
await sleep(2000)
|
||||||
|
const totalOceanLockedAfter = await getTotalLockedOcean()
|
||||||
|
assert(
|
||||||
|
parseFloat(totalOceanLockedAfter) > parseFloat(totalOceanLockedBefore),
|
||||||
|
'After (' +
|
||||||
|
totalOceanLockedAfter +
|
||||||
|
') shold be higher then ' +
|
||||||
|
totalOceanLockedBefore
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
parseFloat(totalOceanLockedAfter) ==
|
||||||
|
parseFloat(totalOceanLockedBefore + amount),
|
||||||
|
'Invalid totalOceanLockedAfter (' + totalOceanLockedAfter + ')'
|
||||||
|
)
|
||||||
const initialQuery = {
|
const initialQuery = {
|
||||||
query: `query {
|
query: `query {
|
||||||
veOCEANs(id:"${Alice.toLowerCase()}"){
|
veOCEANs(id:"${Alice.toLowerCase()}"){
|
||||||
@ -287,7 +324,7 @@ describe('veOcean tests', async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('Alice should allocate 10% to NFT1', async () => {
|
it('Alice should allocate 10% to NFT1', async () => {
|
||||||
await veAllocate.setAllocation(Alice, '1000', nft1, chainId)
|
const tx = await veAllocate.setAllocation(Alice, '1000', nft1, chainId)
|
||||||
const newTotalAllocation = await veAllocate.getTotalAllocation(Alice)
|
const newTotalAllocation = await veAllocate.getTotalAllocation(Alice)
|
||||||
await sleep(2000)
|
await sleep(2000)
|
||||||
let initialQuery = {
|
let initialQuery = {
|
||||||
@ -295,6 +332,7 @@ describe('veOcean tests', async () => {
|
|||||||
veAllocateUsers(id:"${Alice.toLowerCase()}"){
|
veAllocateUsers(id:"${Alice.toLowerCase()}"){
|
||||||
id,
|
id,
|
||||||
allocatedTotal
|
allocatedTotal
|
||||||
|
eventIndex
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
}
|
}
|
||||||
@ -310,13 +348,15 @@ describe('veOcean tests', async () => {
|
|||||||
' to equal subgraph value ' +
|
' to equal subgraph value ' +
|
||||||
info[0].allocatedTotal
|
info[0].allocatedTotal
|
||||||
)
|
)
|
||||||
|
assert(info[0].eventIndex === tx.events.AllocationSet.logIndex)
|
||||||
initialQuery = {
|
initialQuery = {
|
||||||
query: `query {
|
query: `query {
|
||||||
veAllocations(
|
veAllocations(
|
||||||
where: {allocationUser:"${Alice.toLowerCase()}", chainId:"${chainId}", nftAddress:"${nft1.toLowerCase()}"}
|
where: {allocationUser:"${Alice.toLowerCase()}", chainId:"${chainId}", nftAddress:"${nft1.toLowerCase()}"}
|
||||||
){
|
){
|
||||||
id,
|
id,
|
||||||
allocated
|
allocated,
|
||||||
|
eventIndex
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
}
|
}
|
||||||
@ -330,10 +370,11 @@ describe('veOcean tests', async () => {
|
|||||||
'Expected totalAllocation 1000 to equal subgraph value ' +
|
'Expected totalAllocation 1000 to equal subgraph value ' +
|
||||||
info[0].allocatedTotal
|
info[0].allocatedTotal
|
||||||
)
|
)
|
||||||
|
assert(info[0].eventIndex === tx.events.AllocationSet.logIndex)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Alice should allocate 10% to NFT2 and 20% to NFT3', async () => {
|
it('Alice should allocate 10% to NFT2 and 20% to NFT3', async () => {
|
||||||
await veAllocate.setBatchAllocation(
|
const tx = await veAllocate.setBatchAllocation(
|
||||||
Alice,
|
Alice,
|
||||||
['1000', '2000'],
|
['1000', '2000'],
|
||||||
[nft2, nft3],
|
[nft2, nft3],
|
||||||
@ -346,7 +387,8 @@ describe('veOcean tests', async () => {
|
|||||||
query: `query {
|
query: `query {
|
||||||
veAllocateUsers(id:"${Alice.toLowerCase()}"){
|
veAllocateUsers(id:"${Alice.toLowerCase()}"){
|
||||||
id,
|
id,
|
||||||
allocatedTotal
|
allocatedTotal,
|
||||||
|
eventIndex
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
}
|
}
|
||||||
@ -362,13 +404,15 @@ describe('veOcean tests', async () => {
|
|||||||
' to equal subgraph value ' +
|
' to equal subgraph value ' +
|
||||||
info[0].allocatedTotal
|
info[0].allocatedTotal
|
||||||
)
|
)
|
||||||
|
assert(info[0].eventIndex === tx.events.AllocationSetMultiple.logIndex)
|
||||||
initialQuery = {
|
initialQuery = {
|
||||||
query: `query {
|
query: `query {
|
||||||
veAllocations(
|
veAllocations(
|
||||||
where: {allocationUser:"${Alice.toLowerCase()}", chainId:"${chainId}", nftAddress:"${nft2.toLowerCase()}"}
|
where: {allocationUser:"${Alice.toLowerCase()}", chainId:"${chainId}", nftAddress:"${nft2.toLowerCase()}"}
|
||||||
){
|
){
|
||||||
id,
|
id,
|
||||||
allocated
|
allocated,
|
||||||
|
eventIndex
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
}
|
}
|
||||||
@ -382,6 +426,7 @@ describe('veOcean tests', async () => {
|
|||||||
'Expected totalAllocation 1000 to equal subgraph value ' +
|
'Expected totalAllocation 1000 to equal subgraph value ' +
|
||||||
info[0].allocatedTotal
|
info[0].allocatedTotal
|
||||||
)
|
)
|
||||||
|
assert(info[0].eventIndex === tx.events.AllocationSetMultiple.logIndex)
|
||||||
initialQuery = {
|
initialQuery = {
|
||||||
query: `query {
|
query: `query {
|
||||||
veAllocations(
|
veAllocations(
|
||||||
@ -544,6 +589,241 @@ describe('veOcean tests', async () => {
|
|||||||
})
|
})
|
||||||
it('Alice should withdraw locked tokens', async () => {
|
it('Alice should withdraw locked tokens', async () => {
|
||||||
await evmIncreaseTime(60 * 60 * 24 * 7)
|
await evmIncreaseTime(60 * 60 * 24 * 7)
|
||||||
|
const totalOceanLockedBefore = await getTotalLockedOcean()
|
||||||
await veOcean.withdraw(Alice)
|
await veOcean.withdraw(Alice)
|
||||||
|
await sleep(2000)
|
||||||
|
const totalOceanLockedAfter = await getTotalLockedOcean()
|
||||||
|
assert(
|
||||||
|
parseFloat(totalOceanLockedAfter) < parseFloat(totalOceanLockedBefore),
|
||||||
|
'After (' +
|
||||||
|
totalOceanLockedAfter +
|
||||||
|
') shold be lower then ' +
|
||||||
|
totalOceanLockedBefore
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Alice should lock 100 Ocean and Delegate them to Bob', async () => {
|
||||||
|
// since we can only lock once, we test if tx fails or not
|
||||||
|
// so if there is already a lock, skip it
|
||||||
|
let currentBalance = await veOcean.getLockedAmount(Alice)
|
||||||
|
let currentLock = await veOcean.lockEnd(Alice)
|
||||||
|
const amount = '100'
|
||||||
|
await approve(
|
||||||
|
web3,
|
||||||
|
config,
|
||||||
|
Alice,
|
||||||
|
addresses.Ocean,
|
||||||
|
addresses.veOCEAN,
|
||||||
|
amount
|
||||||
|
)
|
||||||
|
const timestamp = Math.floor(Date.now() / 1000)
|
||||||
|
const unlockTime = timestamp + 30 * 86400
|
||||||
|
|
||||||
|
if (parseInt(currentBalance) > 0 || currentLock > 0) {
|
||||||
|
// we already have some locked tokens, so our transaction should fail
|
||||||
|
try {
|
||||||
|
await veOcean.lockTokens(Alice, amount, unlockTime)
|
||||||
|
assert(false, 'This should fail!')
|
||||||
|
} catch (e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await veOcean.lockTokens(Alice, amount, unlockTime)
|
||||||
|
}
|
||||||
|
currentBalance = await veOcean.getLockedAmount(Alice)
|
||||||
|
currentLock = await veOcean.lockEnd(Alice)
|
||||||
|
await sleep(2000)
|
||||||
|
const initialQuery = {
|
||||||
|
query: `query {
|
||||||
|
veOCEANs(id:"${Alice.toLowerCase()}"){
|
||||||
|
id,
|
||||||
|
lockedAmount,
|
||||||
|
unlockTime
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
await sleep(2000)
|
||||||
|
|
||||||
|
const initialResponse = await fetch(subgraphUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(initialQuery)
|
||||||
|
})
|
||||||
|
await sleep(2000)
|
||||||
|
const info = (await initialResponse.json()).data.veOCEANs
|
||||||
|
assert(info[0].id === Alice.toLowerCase(), 'ID is incorrect')
|
||||||
|
assert(info[0].lockedAmount === currentBalance, 'LockedAmount is incorrect')
|
||||||
|
assert(info[0].unlockTime === currentLock, 'Unlock time is not correct')
|
||||||
|
|
||||||
|
const lockTime = await veOcean.lockEnd(Alice)
|
||||||
|
const extLockTime = Number(lockTime) + 31556926
|
||||||
|
|
||||||
|
await delegateContract.methods.setApprovalForAll(Alice, true).send({
|
||||||
|
from: Alice
|
||||||
|
})
|
||||||
|
|
||||||
|
await veOcean.increaseUnlockTime(Alice, extLockTime)
|
||||||
|
|
||||||
|
const initalBoostExpiry = extLockTime - 100000
|
||||||
|
let estGas = await calculateEstimatedGas(
|
||||||
|
Alice,
|
||||||
|
delegateContract.methods.create_boost,
|
||||||
|
Alice,
|
||||||
|
Bob,
|
||||||
|
5000,
|
||||||
|
0,
|
||||||
|
initalBoostExpiry,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
|
const tx3 = await sendTx(
|
||||||
|
Alice,
|
||||||
|
estGas,
|
||||||
|
web3,
|
||||||
|
1,
|
||||||
|
delegateContract.methods.create_boost,
|
||||||
|
Alice,
|
||||||
|
Bob,
|
||||||
|
5000,
|
||||||
|
0,
|
||||||
|
initalBoostExpiry,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
|
assert(tx3, 'Transaction failed')
|
||||||
|
assert(tx3.events.DelegateBoost, 'No Delegate boost event')
|
||||||
|
const tokenId = tx3.events.DelegateBoost.returnValues._token_id
|
||||||
|
await evmIncreaseTime(60)
|
||||||
|
// extend boost
|
||||||
|
estGas = await calculateEstimatedGas(
|
||||||
|
Alice,
|
||||||
|
delegateContract.methods.extend_boost,
|
||||||
|
tokenId,
|
||||||
|
10000,
|
||||||
|
extLockTime,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
|
const tx4 = await sendTx(
|
||||||
|
Alice,
|
||||||
|
estGas,
|
||||||
|
web3,
|
||||||
|
1,
|
||||||
|
delegateContract.methods.extend_boost,
|
||||||
|
tokenId,
|
||||||
|
10000,
|
||||||
|
extLockTime,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
|
assert(tx4, 'Transaction failed')
|
||||||
|
assert(tx4.events.ExtendBoost, 'No ExtendBoost event')
|
||||||
|
await evmIncreaseTime(60)
|
||||||
|
// burn it
|
||||||
|
estGas = await calculateEstimatedGas(
|
||||||
|
Alice,
|
||||||
|
delegateContract.methods.cancel_boost,
|
||||||
|
tokenId
|
||||||
|
)
|
||||||
|
|
||||||
|
const tx5 = await sendTx(
|
||||||
|
Alice,
|
||||||
|
estGas,
|
||||||
|
web3,
|
||||||
|
1,
|
||||||
|
delegateContract.methods.cancel_boost,
|
||||||
|
tokenId
|
||||||
|
)
|
||||||
|
|
||||||
|
assert(tx5, 'Transaction failed')
|
||||||
|
assert(tx5.events.BurnBoost, 'No BurnBoost event')
|
||||||
|
|
||||||
|
await sleep(3000)
|
||||||
|
const delegateQuery = {
|
||||||
|
query: `query{
|
||||||
|
veDelegations(where:{delegator:"${Alice.toLowerCase()}"}){
|
||||||
|
id
|
||||||
|
delegator {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
receiver{
|
||||||
|
id
|
||||||
|
}
|
||||||
|
amount
|
||||||
|
tokenId
|
||||||
|
cancelTime
|
||||||
|
expireTime
|
||||||
|
updates(orderBy:timestamp orderDirection:asc){
|
||||||
|
id
|
||||||
|
block
|
||||||
|
timestamp
|
||||||
|
tx
|
||||||
|
eventIndex
|
||||||
|
sender
|
||||||
|
amount
|
||||||
|
cancelTime
|
||||||
|
expireTime
|
||||||
|
type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const delegateResponse = await fetch(subgraphUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(delegateQuery)
|
||||||
|
})
|
||||||
|
const resp = await delegateResponse.json()
|
||||||
|
const delegations = resp.data.veDelegations
|
||||||
|
|
||||||
|
assert(delegations.length > 0, 'No veDelegations')
|
||||||
|
assert(
|
||||||
|
delegations[0].tokenId.toLowerCase() ==
|
||||||
|
tx3.events.DelegateBoost.returnValues._token_id.toLowerCase(),
|
||||||
|
'Invalid tokenID'
|
||||||
|
)
|
||||||
|
assert(delegations[0].amount == '0', 'Invalid amount, should be 0')
|
||||||
|
assert(delegations[0].updates.length > 0, 'No updates')
|
||||||
|
// check updates. first is create boost
|
||||||
|
assert(
|
||||||
|
delegations[0].updates[0].type == 0,
|
||||||
|
'Invalid type. should be createBoost'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
delegations[0].updates[0].cancelTime ==
|
||||||
|
tx3.events.DelegateBoost.returnValues._cancel_time,
|
||||||
|
'Invalid cancelTime'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
delegations[0].updates[0].expireTime ==
|
||||||
|
tx3.events.DelegateBoost.returnValues._expire_time,
|
||||||
|
'Invalid expireTime'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
web3.utils.toWei(delegations[0].updates[0].amount) ==
|
||||||
|
tx3.events.DelegateBoost.returnValues._amount,
|
||||||
|
'Invalid amount'
|
||||||
|
)
|
||||||
|
// check extend boos update
|
||||||
|
assert(
|
||||||
|
delegations[0].updates[1].type == 1,
|
||||||
|
'Invalid type. should be extend Boost'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
delegations[0].updates[1].cancelTime ==
|
||||||
|
tx4.events.ExtendBoost.returnValues._cancel_time,
|
||||||
|
'Invalid cancelTime for extend boost'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
delegations[0].updates[1].expireTime ==
|
||||||
|
tx4.events.ExtendBoost.returnValues._expire_time,
|
||||||
|
'Invalid expireTime for extend boost'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
web3.utils.toWei(delegations[0].updates[1].amount) ==
|
||||||
|
tx4.events.ExtendBoost.returnValues._amount,
|
||||||
|
'Invalid amount for extend boost'
|
||||||
|
)
|
||||||
|
// check burn
|
||||||
|
assert(delegations[0].updates[2].type == 2, 'Invalid type. should be burn')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -33,7 +33,7 @@ async function userQuery(user: string) {
|
|||||||
user(id:"${user}"){
|
user(id:"${user}"){
|
||||||
id
|
id
|
||||||
tokenBalancesOwned {id}
|
tokenBalancesOwned {id}
|
||||||
orders {id}
|
orders {id, lastPriceToken{id}}
|
||||||
freSwaps {id}
|
freSwaps {id}
|
||||||
totalOrders
|
totalOrders
|
||||||
totalSales
|
totalSales
|
||||||
@ -64,7 +64,7 @@ describe('User tests', async () => {
|
|||||||
const publishMarketSwapFee = '0.003'
|
const publishMarketSwapFee = '0.003'
|
||||||
const templateIndex = 1
|
const templateIndex = 1
|
||||||
const dtAmount = '10'
|
const dtAmount = '10'
|
||||||
const datatoken = new Datatoken(web3, 8996)
|
// const datatoken = new Datatoken(web3, 8996)
|
||||||
let datatokenAddress: string
|
let datatokenAddress: string
|
||||||
let fixedRateAddress: string
|
let fixedRateAddress: string
|
||||||
let baseTokenAddress: string
|
let baseTokenAddress: string
|
||||||
@ -123,7 +123,7 @@ describe('User tests', async () => {
|
|||||||
fixedRate: price,
|
fixedRate: price,
|
||||||
marketFee: publishMarketSwapFee,
|
marketFee: publishMarketSwapFee,
|
||||||
allowedConsumer: ZERO_ADDRESS,
|
allowedConsumer: ZERO_ADDRESS,
|
||||||
withMint: false
|
withMint: true
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await Factory.createNftWithDatatokenWithFixedRate(
|
const result = await Factory.createNftWithDatatokenWithFixedRate(
|
||||||
@ -196,27 +196,6 @@ describe('User tests', async () => {
|
|||||||
assert(user.totalSales === '0', 'incorrect value for: totalSales')
|
assert(user.totalSales === '0', 'incorrect value for: totalSales')
|
||||||
assert(user.__typename === 'User', 'incorrect value for: __typename')
|
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 () => {
|
it('Check user fields after publishing & ordering a datatoken', async () => {
|
||||||
// Start with publishing a new datatoken
|
// Start with publishing a new datatoken
|
||||||
const nftParams: NftCreateData = {
|
const nftParams: NftCreateData = {
|
||||||
@ -284,7 +263,6 @@ describe('User tests', async () => {
|
|||||||
await sleep(2000)
|
await sleep(2000)
|
||||||
|
|
||||||
const user = await userQuery(user3)
|
const user = await userQuery(user3)
|
||||||
|
|
||||||
assert(user.id === user3, 'incorrect value for: id')
|
assert(user.id === user3, 'incorrect value for: id')
|
||||||
assert(user.tokenBalancesOwned.length === 0, 'incorrect tokenBalancesOwned')
|
assert(user.tokenBalancesOwned.length === 0, 'incorrect tokenBalancesOwned')
|
||||||
assert(user.orders.length === 1, 'incorrect value for: orders')
|
assert(user.orders.length === 1, 'incorrect value for: orders')
|
||||||
@ -292,5 +270,9 @@ describe('User tests', async () => {
|
|||||||
assert(user.totalOrders === '1', 'incorrect value for: totalOrders')
|
assert(user.totalOrders === '1', 'incorrect value for: totalOrders')
|
||||||
assert(user.totalSales === '0', 'incorrect value for: totalSales')
|
assert(user.totalSales === '0', 'incorrect value for: totalSales')
|
||||||
assert(user.__typename === 'User', 'incorrect value for: __typename')
|
assert(user.__typename === 'User', 'incorrect value for: __typename')
|
||||||
|
assert(
|
||||||
|
user.orders[0].lastPriceToken.id === ZERO_ADDRESS,
|
||||||
|
'incorrect value for: lastPriceToken'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user