mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge branch 'v4main' into issue-1346-rewrite-datatoken-test
This commit is contained in:
commit
eea1c374b3
11
CHANGELOG.md
11
CHANGELOG.md
@ -4,8 +4,19 @@ 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).
|
||||
|
||||
#### [v1.0.0-next.44](https://github.com/oceanprotocol/ocean.js/compare/v1.0.0-next.43...v1.0.0-next.44)
|
||||
|
||||
- bump to contracts 34 [`#1476`](https://github.com/oceanprotocol/ocean.js/pull/1476)
|
||||
- update max out [`#1475`](https://github.com/oceanprotocol/ocean.js/pull/1475)
|
||||
- Issue-#1343: Rewrite simple publish consume flow test [`#1454`](https://github.com/oceanprotocol/ocean.js/pull/1454)
|
||||
- refactor SimplePublishConsumeFlow.test.ts file [`c97f750`](https://github.com/oceanprotocol/ocean.js/commit/c97f7503133986c4a6165c4ddcb7f54e5afdc2fe)
|
||||
- don't deploy smart contracts [`a75ca34`](https://github.com/oceanprotocol/ocean.js/commit/a75ca34e9e5245cfdbb670f1c23c91d96c57ec30)
|
||||
- add DDO type [`11508b7`](https://github.com/oceanprotocol/ocean.js/commit/11508b7794048dc5f81fc4aba4c3a5b551c9e18c)
|
||||
|
||||
#### [v1.0.0-next.43](https://github.com/oceanprotocol/ocean.js/compare/v1.0.0-next.42...v1.0.0-next.43)
|
||||
|
||||
> 17 May 2022
|
||||
|
||||
- bump contracts to alpha.33 [`#1472`](https://github.com/oceanprotocol/ocean.js/pull/1472)
|
||||
- Bump @types/node from 17.0.32 to 17.0.34 [`#1471`](https://github.com/oceanprotocol/ocean.js/pull/1471)
|
||||
- Add transfer() function to TokenUtils [`#1387`](https://github.com/oceanprotocol/ocean.js/pull/1387)
|
||||
|
144
package-lock.json
generated
144
package-lock.json
generated
@ -1,15 +1,15 @@
|
||||
{
|
||||
"name": "@oceanprotocol/lib",
|
||||
"version": "1.0.0-next.43",
|
||||
"version": "1.0.0-next.44",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@oceanprotocol/lib",
|
||||
"version": "1.0.0-next.43",
|
||||
"version": "1.0.0-next.44",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@oceanprotocol/contracts": "^1.0.0-alpha.33",
|
||||
"@oceanprotocol/contracts": "^1.0.0-alpha.34",
|
||||
"bignumber.js": "^9.0.2",
|
||||
"cross-fetch": "^3.1.5",
|
||||
"crypto-js": "^4.1.1",
|
||||
@ -24,7 +24,7 @@
|
||||
"@types/chai-spies": "^1.0.3",
|
||||
"@types/crypto-js": "^4.1.1",
|
||||
"@types/mocha": "^9.1.1",
|
||||
"@types/node": "^17.0.34",
|
||||
"@types/node": "^17.0.35",
|
||||
"@types/node-fetch": "^3.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||
"@typescript-eslint/parser": "^4.33.0",
|
||||
@ -45,7 +45,7 @@
|
||||
"prettier": "^2.6.2",
|
||||
"release-it": "^15.0.0",
|
||||
"source-map-support": "^0.5.19",
|
||||
"ts-node": "^10.7.0",
|
||||
"ts-node": "^10.8.0",
|
||||
"ts-node-register": "^1.0.0",
|
||||
"typedoc": "0.22.15",
|
||||
"typescript": "^4.6.4"
|
||||
@ -1911,22 +1911,13 @@
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@cspotcode/source-map-consumer": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz",
|
||||
"integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 12"
|
||||
}
|
||||
},
|
||||
"node_modules/@cspotcode/source-map-support": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz",
|
||||
"integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==",
|
||||
"version": "0.8.1",
|
||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
|
||||
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cspotcode/source-map-consumer": "0.8.0"
|
||||
"@jridgewell/trace-mapping": "0.3.9"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
@ -2411,6 +2402,31 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/resolve-uri": {
|
||||
"version": "3.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.7.tgz",
|
||||
"integrity": "sha512-8cXDaBBHOr2pQ7j77Y6Vp5VDT2sIqWyWQ56TjEq4ih/a4iST3dItRe8Q9fp0rrIl9DoKhWQtUQz/YpOxLkXbNA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/sourcemap-codec": {
|
||||
"version": "1.4.13",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz",
|
||||
"integrity": "sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@jridgewell/trace-mapping": {
|
||||
"version": "0.3.9",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
|
||||
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/resolve-uri": "^3.0.3",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@metamask/safe-event-emitter": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@metamask/safe-event-emitter/-/safe-event-emitter-2.0.0.tgz",
|
||||
@ -2471,9 +2487,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oceanprotocol/contracts": {
|
||||
"version": "1.0.0-alpha.33",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.33.tgz",
|
||||
"integrity": "sha512-jx8fg9src7fjeqMXB2ZYLdp0BoJA0G5vau6pa48YOjasDuPekJtPdT0oRy0PVkyJ2HtkYjAwKVyiFfAbZcug6A=="
|
||||
"version": "1.0.0-alpha.34",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.34.tgz",
|
||||
"integrity": "sha512-ZhNCakYbUpXrffpS98Hj0r5K70IzzTXNoYKBX4Ks3Qqc2T7mhXIxtakzygkM0lEk038ImWuzS2PAZKTATz+X2w=="
|
||||
},
|
||||
"node_modules/@octokit/auth-token": {
|
||||
"version": "2.5.0",
|
||||
@ -3021,9 +3037,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "17.0.34",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.34.tgz",
|
||||
"integrity": "sha512-XImEz7XwTvDBtzlTnm8YvMqGW/ErMWBsKZ+hMTvnDIjGCKxwK5Xpc+c/oQjOauwq8M4OS11hEkpjX8rrI/eEgA=="
|
||||
"version": "17.0.35",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.35.tgz",
|
||||
"integrity": "sha512-vu1SrqBjbbZ3J6vwY17jBs8Sr/BKA+/a/WtjRG+whKg1iuLFOosq872EXS0eXWILdO36DHQQeku/ZcL6hz2fpg=="
|
||||
},
|
||||
"node_modules/@types/node-fetch": {
|
||||
"version": "3.0.3",
|
||||
@ -16285,12 +16301,12 @@
|
||||
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
|
||||
},
|
||||
"node_modules/ts-node": {
|
||||
"version": "10.7.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz",
|
||||
"integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==",
|
||||
"version": "10.8.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.8.0.tgz",
|
||||
"integrity": "sha512-/fNd5Qh+zTt8Vt1KbYZjRHCE9sI5i7nqfD/dzBBRDeVXZXS6kToW6R7tTU6Nd4XavFs0mAVCg29Q//ML7WsZYA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cspotcode/source-map-support": "0.7.0",
|
||||
"@cspotcode/source-map-support": "^0.8.0",
|
||||
"@tsconfig/node10": "^1.0.7",
|
||||
"@tsconfig/node12": "^1.0.7",
|
||||
"@tsconfig/node14": "^1.0.0",
|
||||
@ -16301,7 +16317,7 @@
|
||||
"create-require": "^1.1.0",
|
||||
"diff": "^4.0.1",
|
||||
"make-error": "^1.1.1",
|
||||
"v8-compile-cache-lib": "^3.0.0",
|
||||
"v8-compile-cache-lib": "^3.0.1",
|
||||
"yn": "3.1.1"
|
||||
},
|
||||
"bin": {
|
||||
@ -16885,9 +16901,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/v8-compile-cache-lib": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz",
|
||||
"integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==",
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
||||
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/varint": {
|
||||
@ -19258,19 +19274,13 @@
|
||||
"to-fast-properties": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"@cspotcode/source-map-consumer": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz",
|
||||
"integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==",
|
||||
"dev": true
|
||||
},
|
||||
"@cspotcode/source-map-support": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz",
|
||||
"integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==",
|
||||
"version": "0.8.1",
|
||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
|
||||
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cspotcode/source-map-consumer": "0.8.0"
|
||||
"@jridgewell/trace-mapping": "0.3.9"
|
||||
}
|
||||
},
|
||||
"@eslint/eslintrc": {
|
||||
@ -19565,6 +19575,28 @@
|
||||
"integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==",
|
||||
"dev": true
|
||||
},
|
||||
"@jridgewell/resolve-uri": {
|
||||
"version": "3.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.7.tgz",
|
||||
"integrity": "sha512-8cXDaBBHOr2pQ7j77Y6Vp5VDT2sIqWyWQ56TjEq4ih/a4iST3dItRe8Q9fp0rrIl9DoKhWQtUQz/YpOxLkXbNA==",
|
||||
"dev": true
|
||||
},
|
||||
"@jridgewell/sourcemap-codec": {
|
||||
"version": "1.4.13",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz",
|
||||
"integrity": "sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w==",
|
||||
"dev": true
|
||||
},
|
||||
"@jridgewell/trace-mapping": {
|
||||
"version": "0.3.9",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
|
||||
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@jridgewell/resolve-uri": "^3.0.3",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||
}
|
||||
},
|
||||
"@metamask/safe-event-emitter": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@metamask/safe-event-emitter/-/safe-event-emitter-2.0.0.tgz",
|
||||
@ -19610,9 +19642,9 @@
|
||||
}
|
||||
},
|
||||
"@oceanprotocol/contracts": {
|
||||
"version": "1.0.0-alpha.33",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.33.tgz",
|
||||
"integrity": "sha512-jx8fg9src7fjeqMXB2ZYLdp0BoJA0G5vau6pa48YOjasDuPekJtPdT0oRy0PVkyJ2HtkYjAwKVyiFfAbZcug6A=="
|
||||
"version": "1.0.0-alpha.34",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.34.tgz",
|
||||
"integrity": "sha512-ZhNCakYbUpXrffpS98Hj0r5K70IzzTXNoYKBX4Ks3Qqc2T7mhXIxtakzygkM0lEk038ImWuzS2PAZKTATz+X2w=="
|
||||
},
|
||||
"@octokit/auth-token": {
|
||||
"version": "2.5.0",
|
||||
@ -20079,9 +20111,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "17.0.34",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.34.tgz",
|
||||
"integrity": "sha512-XImEz7XwTvDBtzlTnm8YvMqGW/ErMWBsKZ+hMTvnDIjGCKxwK5Xpc+c/oQjOauwq8M4OS11hEkpjX8rrI/eEgA=="
|
||||
"version": "17.0.35",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.35.tgz",
|
||||
"integrity": "sha512-vu1SrqBjbbZ3J6vwY17jBs8Sr/BKA+/a/WtjRG+whKg1iuLFOosq872EXS0eXWILdO36DHQQeku/ZcL6hz2fpg=="
|
||||
},
|
||||
"@types/node-fetch": {
|
||||
"version": "3.0.3",
|
||||
@ -30239,12 +30271,12 @@
|
||||
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
|
||||
},
|
||||
"ts-node": {
|
||||
"version": "10.7.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz",
|
||||
"integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==",
|
||||
"version": "10.8.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.8.0.tgz",
|
||||
"integrity": "sha512-/fNd5Qh+zTt8Vt1KbYZjRHCE9sI5i7nqfD/dzBBRDeVXZXS6kToW6R7tTU6Nd4XavFs0mAVCg29Q//ML7WsZYA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cspotcode/source-map-support": "0.7.0",
|
||||
"@cspotcode/source-map-support": "^0.8.0",
|
||||
"@tsconfig/node10": "^1.0.7",
|
||||
"@tsconfig/node12": "^1.0.7",
|
||||
"@tsconfig/node14": "^1.0.0",
|
||||
@ -30255,7 +30287,7 @@
|
||||
"create-require": "^1.1.0",
|
||||
"diff": "^4.0.1",
|
||||
"make-error": "^1.1.1",
|
||||
"v8-compile-cache-lib": "^3.0.0",
|
||||
"v8-compile-cache-lib": "^3.0.1",
|
||||
"yn": "3.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -30684,9 +30716,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"v8-compile-cache-lib": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz",
|
||||
"integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==",
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
||||
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
|
||||
"dev": true
|
||||
},
|
||||
"varint": {
|
||||
|
20
package.json
20
package.json
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@oceanprotocol/lib",
|
||||
"source": "./src/index.ts",
|
||||
"version": "1.0.0-next.43",
|
||||
"version": "1.0.0-next.44",
|
||||
"description": "JavaScript client library for Ocean Protocol",
|
||||
"main": "./dist/lib.js",
|
||||
"umd:main": "dist/lib.umd.js",
|
||||
@ -27,19 +27,19 @@
|
||||
"changelog": "auto-changelog -p",
|
||||
"prepublishOnly": "npm run build",
|
||||
"mocha": "TS_NODE_PROJECT='./test/tsconfig.json' mocha --config=test/.mocharc.json --node-env=test --exit",
|
||||
"test:ss": "npm run mocha -- 'test/unit/pools/ssContracts/SideStaking.test.ts'",
|
||||
"test:nftfactory": "npm run mocha -- 'test/unit/factories/NftFactory.test.ts'",
|
||||
"test:nft": "npm run mocha -- 'test/unit/tokens/Nft.test.ts'",
|
||||
"test:datatoken": "npm run mocha -- 'test/unit/tokens/Datatoken.test.ts'",
|
||||
"test:router": "npm run mocha -- 'test/unit/pools/Router.test.ts'",
|
||||
"test:fixed": "npm run mocha -- 'test/unit/pools/fixedRate/FixedRateExchange.test.ts'",
|
||||
"test:ss": "npm run mocha -- 'test/unit/pools/ssContracts/SideStaking.test.ts'",
|
||||
"test:pool": "npm run mocha -- 'test/unit/pools/balancer/Pool.test.ts'",
|
||||
"test:dispenser": "npm run mocha -- 'test/unit/pools/dispenser/Dispenser.test.ts'",
|
||||
"test:dt": "npm run mocha -- 'test/unit/tokens/Datatoken.test.ts'",
|
||||
"test:nftDt": "npm run mocha -- 'test/unit/tokens/Nft.test.ts'",
|
||||
"test:factory": "npm run mocha -- 'test/unit/NftFactory.test.ts'",
|
||||
"test:router": "npm run mocha -- 'test/unit/pools/Router.test.ts'",
|
||||
"test:publishAll": "npm run mocha -- 'test/integration/PublishFlows.test.ts'",
|
||||
"test:provider": "npm run mocha -- 'test/integration/Provider.test.ts'",
|
||||
"test:unit": "npm run mocha -- 'test/unit/**/*.test.ts'",
|
||||
"test:unit:cover": "nyc --report-dir coverage/unit npm run test:unit",
|
||||
"test:integration": "npm run mocha -- 'test/integration/**/*.test.ts'",
|
||||
"test:provider": "npm run mocha -- 'test/integration/Provider.test.ts'",
|
||||
"test:compute": "npm run mocha -- 'test/integration/ComputeFlow.test.ts'",
|
||||
"test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration"
|
||||
},
|
||||
@ -58,7 +58,7 @@
|
||||
"web3": "^1.7.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@oceanprotocol/contracts": "^1.0.0-alpha.33",
|
||||
"@oceanprotocol/contracts": "^1.0.0-alpha.34",
|
||||
"bignumber.js": "^9.0.2",
|
||||
"cross-fetch": "^3.1.5",
|
||||
"crypto-js": "^4.1.1",
|
||||
@ -73,7 +73,7 @@
|
||||
"@types/chai-spies": "^1.0.3",
|
||||
"@types/crypto-js": "^4.1.1",
|
||||
"@types/mocha": "^9.1.1",
|
||||
"@types/node": "^17.0.34",
|
||||
"@types/node": "^17.0.35",
|
||||
"@types/node-fetch": "^3.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||
"@typescript-eslint/parser": "^4.33.0",
|
||||
@ -94,7 +94,7 @@
|
||||
"prettier": "^2.6.2",
|
||||
"release-it": "^15.0.0",
|
||||
"source-map-support": "^0.5.19",
|
||||
"ts-node": "^10.7.0",
|
||||
"ts-node": "^10.8.0",
|
||||
"ts-node-register": "^1.0.0",
|
||||
"typedoc": "0.22.15",
|
||||
"typescript": "^4.6.4"
|
||||
|
@ -15,3 +15,9 @@ export interface ConsumeMarketFee {
|
||||
consumeMarketFeeToken: string // address of the token marketplace wants to add fee on top
|
||||
consumeMarketFeeAmount: string
|
||||
}
|
||||
|
||||
export interface PublishingMarketFee {
|
||||
publishMarketFeeAddress: string
|
||||
publishMarketFeeToken: string
|
||||
publishMarketFeeAmount: string
|
||||
}
|
||||
|
@ -60,9 +60,8 @@ export class FixedRateExchange {
|
||||
public oceanAddress: string = null
|
||||
public fixedRateAddress: string
|
||||
public fixedRateExchangeAbi: AbiItem | AbiItem[]
|
||||
public fixedRateContract: Contract
|
||||
public web3: Web3
|
||||
public contract: Contract = null
|
||||
public fixedRateContract: Contract = null
|
||||
|
||||
public config: Config
|
||||
public ssAbi: AbiItem | AbiItem[]
|
||||
@ -86,7 +85,7 @@ export class FixedRateExchange {
|
||||
fixedRateExchangeAbi || (defaultFixedRateExchangeAbi.abi as AbiItem[])
|
||||
this.oceanAddress = oceanAddress
|
||||
this.fixedRateAddress = fixedRateAddress
|
||||
this.contract = setContractDefaults(
|
||||
this.fixedRateContract = setContractDefaults(
|
||||
new this.web3.eth.Contract(this.fixedRateExchangeAbi, this.fixedRateAddress),
|
||||
this.config
|
||||
)
|
||||
@ -115,7 +114,7 @@ export class FixedRateExchange {
|
||||
* @return {Promise<string>} exchangeId
|
||||
*/
|
||||
public async generateExchangeId(baseToken: string, datatoken: string): Promise<string> {
|
||||
const exchangeId = await this.contract.methods
|
||||
const exchangeId = await this.fixedRateContract.methods
|
||||
.generateExchangeId(baseToken, datatoken)
|
||||
.call()
|
||||
return exchangeId
|
||||
@ -186,7 +185,7 @@ export class FixedRateExchange {
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.buyDT,
|
||||
this.fixedRateContract.methods.buyDT,
|
||||
exchangeId,
|
||||
dtAmountFormatted,
|
||||
maxBtFormatted,
|
||||
@ -194,7 +193,7 @@ export class FixedRateExchange {
|
||||
consumeMarketFeeFormatted
|
||||
)
|
||||
try {
|
||||
const trxReceipt = await this.contract.methods
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.buyDT(
|
||||
exchangeId,
|
||||
dtAmountFormatted,
|
||||
@ -278,7 +277,7 @@ export class FixedRateExchange {
|
||||
)
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.sellDT,
|
||||
this.fixedRateContract.methods.sellDT,
|
||||
exchangeId,
|
||||
dtAmountFormatted,
|
||||
minBtFormatted,
|
||||
@ -286,7 +285,7 @@ export class FixedRateExchange {
|
||||
consumeMarketFeeFormatted
|
||||
)
|
||||
try {
|
||||
const trxReceipt = await this.contract.methods
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.sellDT(
|
||||
exchangeId,
|
||||
dtAmountFormatted,
|
||||
@ -313,7 +312,9 @@ export class FixedRateExchange {
|
||||
* @return {Promise<Number>} no of available exchanges
|
||||
*/
|
||||
public async getNumberOfExchanges(): Promise<number> {
|
||||
const numExchanges = await this.contract.methods.getNumberOfExchanges().call()
|
||||
const numExchanges = await this.fixedRateContract.methods
|
||||
.getNumberOfExchanges()
|
||||
.call()
|
||||
return numExchanges
|
||||
}
|
||||
|
||||
@ -355,11 +356,11 @@ export class FixedRateExchange {
|
||||
): Promise<TransactionReceipt> {
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.setRate,
|
||||
this.fixedRateContract.methods.setRate,
|
||||
exchangeId,
|
||||
this.web3.utils.toWei(newRate)
|
||||
)
|
||||
const trxReceipt = await this.contract.methods
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.setRate(exchangeId, this.web3.utils.toWei(newRate))
|
||||
.send({
|
||||
from: address,
|
||||
@ -385,7 +386,12 @@ export class FixedRateExchange {
|
||||
): Promise<number> {
|
||||
const fixedRate = contractInstance || this.fixedRateContract
|
||||
|
||||
return estimateGas(account, fixedRate.methods.setRate, exchangeId, newAllowedSwapper)
|
||||
return estimateGas(
|
||||
account,
|
||||
fixedRate.methods.setAllowedSwapper,
|
||||
exchangeId,
|
||||
newAllowedSwapper
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -402,11 +408,11 @@ export class FixedRateExchange {
|
||||
): Promise<TransactionReceipt> {
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.setAllowedSwapper,
|
||||
this.fixedRateContract.methods.setAllowedSwapper,
|
||||
exchangeId,
|
||||
newAllowedSwapper
|
||||
)
|
||||
const trxReceipt = await this.contract.methods
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.setAllowedSwapper(exchangeId, newAllowedSwapper)
|
||||
.send({
|
||||
from: address,
|
||||
@ -446,17 +452,18 @@ export class FixedRateExchange {
|
||||
const exchange = await this.getExchange(exchangeId)
|
||||
if (!exchange) return null
|
||||
if (exchange.active === true) return null
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.toggleExchangeState,
|
||||
this.fixedRateContract.methods.toggleExchangeState,
|
||||
exchangeId
|
||||
)
|
||||
const trxReceipt = await this.contract.methods.toggleExchangeState(exchangeId).send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.toggleExchangeState(exchangeId)
|
||||
.send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
@ -493,15 +500,17 @@ export class FixedRateExchange {
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.toggleExchangeState,
|
||||
this.fixedRateContract.methods.toggleExchangeState,
|
||||
exchangeId
|
||||
)
|
||||
|
||||
const trxReceipt = await this.contract.methods.toggleExchangeState(exchangeId).send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.toggleExchangeState(exchangeId)
|
||||
.send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
|
||||
return trxReceipt
|
||||
}
|
||||
@ -512,7 +521,7 @@ export class FixedRateExchange {
|
||||
* @return {Promise<string>} Rate (converted from wei)
|
||||
*/
|
||||
public async getRate(exchangeId: string): Promise<string> {
|
||||
const weiRate = await this.contract.methods.getRate(exchangeId).call()
|
||||
const weiRate = await this.fixedRateContract.methods.getRate(exchangeId).call()
|
||||
const rate = await this.web3.utils.fromWei(weiRate)
|
||||
return rate
|
||||
}
|
||||
@ -523,7 +532,7 @@ export class FixedRateExchange {
|
||||
* @return {Promise<string>} dt supply formatted
|
||||
*/
|
||||
public async getDTSupply(exchangeId: string): Promise<string> {
|
||||
const dtSupply = await this.contract.methods.getDTSupply(exchangeId).call()
|
||||
const dtSupply = await this.fixedRateContract.methods.getDTSupply(exchangeId).call()
|
||||
const exchange = await this.getExchange(exchangeId)
|
||||
return await this.unitsToAmount(exchange.datatoken, dtSupply, +exchange.dtDecimals)
|
||||
}
|
||||
@ -534,7 +543,7 @@ export class FixedRateExchange {
|
||||
* @return {Promise<string>} dt supply formatted
|
||||
*/
|
||||
public async getBTSupply(exchangeId: string): Promise<string> {
|
||||
const btSupply = await this.contract.methods.getBTSupply(exchangeId).call()
|
||||
const btSupply = await this.fixedRateContract.methods.getBTSupply(exchangeId).call()
|
||||
const exchange = await this.getExchange(exchangeId)
|
||||
return await this.unitsToAmount(exchange.baseToken, btSupply, +exchange.btDecimals)
|
||||
}
|
||||
@ -545,7 +554,7 @@ export class FixedRateExchange {
|
||||
* @return {Promise<string>} address of allowedSwapper
|
||||
*/
|
||||
public async getAllowedSwapper(exchangeId: string): Promise<string> {
|
||||
return await this.contract.methods.getAllowedSwapper(exchangeId).call()
|
||||
return await this.fixedRateContract.methods.getAllowedSwapper(exchangeId).call()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -561,7 +570,7 @@ export class FixedRateExchange {
|
||||
consumeMarketFee: string = '0'
|
||||
): Promise<PriceAndFees> {
|
||||
const fixedRateExchange = await this.getExchange(exchangeId)
|
||||
const result = await this.contract.methods
|
||||
const result = await this.fixedRateContract.methods
|
||||
.calcBaseInGivenOutDT(
|
||||
exchangeId,
|
||||
await this.amountToUnits(
|
||||
@ -611,7 +620,7 @@ export class FixedRateExchange {
|
||||
consumeMarketFee: string = '0'
|
||||
): Promise<string> {
|
||||
const exchange = await this.getExchange(exchangeId)
|
||||
const result = await this.contract.methods
|
||||
const result = await this.fixedRateContract.methods
|
||||
.calcBaseOutGivenInDT(
|
||||
exchangeId,
|
||||
await this.amountToUnits(
|
||||
@ -632,7 +641,7 @@ export class FixedRateExchange {
|
||||
* @return {Promise<FixedPricedExchange>} Exchange details
|
||||
*/
|
||||
public async getExchange(exchangeId: string): Promise<FixedPriceExchange> {
|
||||
const result: FixedPriceExchange = await this.contract.methods
|
||||
const result: FixedPriceExchange = await this.fixedRateContract.methods
|
||||
.getExchange(exchangeId)
|
||||
.call()
|
||||
result.dtDecimals = result.dtDecimals.toString()
|
||||
@ -668,7 +677,9 @@ export class FixedRateExchange {
|
||||
* @return {Promise<FixedPricedExchange>} Exchange details
|
||||
*/
|
||||
public async getFeesInfo(exchangeId: string): Promise<FeesInfo> {
|
||||
const result: FeesInfo = await this.contract.methods.getFeesInfo(exchangeId).call()
|
||||
const result: FeesInfo = await this.fixedRateContract.methods
|
||||
.getFeesInfo(exchangeId)
|
||||
.call()
|
||||
result.opcFee = this.web3.utils.fromWei(result.opcFee.toString())
|
||||
result.marketFee = this.web3.utils.fromWei(result.marketFee.toString())
|
||||
|
||||
@ -694,7 +705,7 @@ export class FixedRateExchange {
|
||||
* @return {Promise<String[]>} Exchanges list
|
||||
*/
|
||||
public async getExchanges(): Promise<string[]> {
|
||||
return await this.contract.methods.getExchanges().call()
|
||||
return await this.fixedRateContract.methods.getExchanges().call()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -703,7 +714,7 @@ export class FixedRateExchange {
|
||||
* @return {Promise<Boolean>} Result
|
||||
*/
|
||||
public async isActive(exchangeId: string): Promise<boolean> {
|
||||
const result = await this.contract.methods.isActive(exchangeId).call()
|
||||
const result = await this.fixedRateContract.methods.isActive(exchangeId).call()
|
||||
return result
|
||||
}
|
||||
|
||||
@ -740,11 +751,11 @@ export class FixedRateExchange {
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.toggleMintState,
|
||||
this.fixedRateContract.methods.toggleMintState,
|
||||
exchangeId,
|
||||
true
|
||||
)
|
||||
const trxReceipt = await this.contract.methods
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.toggleMintState(exchangeId, true)
|
||||
.send({
|
||||
from: address,
|
||||
@ -768,7 +779,12 @@ export class FixedRateExchange {
|
||||
): Promise<number> {
|
||||
const fixedRate = contractInstance || this.fixedRateContract
|
||||
|
||||
return estimateGas(account, fixedRate.methods.toggleMintState, exchangeId)
|
||||
return estimateGas(
|
||||
account,
|
||||
fixedRate.methods.toggleMintState(exchangeId, false),
|
||||
exchangeId,
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -787,12 +803,12 @@ export class FixedRateExchange {
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.toggleMintState,
|
||||
this.fixedRateContract.methods.toggleMintState,
|
||||
exchangeId,
|
||||
false
|
||||
)
|
||||
|
||||
const trxReceipt = await this.contract.methods
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.toggleMintState(exchangeId, false)
|
||||
.send({
|
||||
from: address,
|
||||
@ -818,7 +834,7 @@ export class FixedRateExchange {
|
||||
contractInstance?: Contract
|
||||
): Promise<number> {
|
||||
const fixedRate = contractInstance || this.fixedRateContract
|
||||
const fixedrate: FixedPriceExchange = await this.contract.methods
|
||||
const fixedrate: FixedPriceExchange = await this.fixedRateContract.methods
|
||||
.getExchange(exchangeId)
|
||||
.call()
|
||||
const amountWei = await this.amountToUnits(
|
||||
@ -844,7 +860,7 @@ export class FixedRateExchange {
|
||||
const exchange = await this.getExchange(exchangeId)
|
||||
if (!exchange) return null
|
||||
|
||||
const fixedrate: FixedPriceExchange = await this.contract.methods
|
||||
const fixedrate: FixedPriceExchange = await this.fixedRateContract.methods
|
||||
.getExchange(exchangeId)
|
||||
.call()
|
||||
const amountWei = await this.amountToUnits(
|
||||
@ -855,16 +871,18 @@ export class FixedRateExchange {
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.collectBT,
|
||||
this.fixedRateContract.methods.collectBT,
|
||||
exchangeId,
|
||||
amountWei
|
||||
)
|
||||
|
||||
const trxReceipt = await this.contract.methods.collectBT(exchangeId, amountWei).send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.collectBT(exchangeId, amountWei)
|
||||
.send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
@ -883,7 +901,7 @@ export class FixedRateExchange {
|
||||
contractInstance?: Contract
|
||||
): Promise<number> {
|
||||
const fixedRate = contractInstance || this.fixedRateContract
|
||||
const fixedrate: FixedPriceExchange = await this.contract.methods
|
||||
const fixedrate: FixedPriceExchange = await this.fixedRateContract.methods
|
||||
.getExchange(exchangeId)
|
||||
.call()
|
||||
|
||||
@ -910,7 +928,7 @@ export class FixedRateExchange {
|
||||
const exchange = await this.getExchange(exchangeId)
|
||||
if (!exchange) return null
|
||||
|
||||
const fixedrate: FixedPriceExchange = await this.contract.methods
|
||||
const fixedrate: FixedPriceExchange = await this.fixedRateContract.methods
|
||||
.getExchange(exchangeId)
|
||||
.call()
|
||||
const amountWei = await this.amountToUnits(
|
||||
@ -921,16 +939,18 @@ export class FixedRateExchange {
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.collectDT,
|
||||
this.fixedRateContract.methods.collectDT,
|
||||
exchangeId,
|
||||
amountWei
|
||||
)
|
||||
|
||||
const trxReceipt = await this.contract.methods.collectDT(exchangeId, amountWei).send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.collectDT(exchangeId, amountWei)
|
||||
.send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
@ -966,14 +986,16 @@ export class FixedRateExchange {
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.collectMarketFee,
|
||||
this.fixedRateContract.methods.collectMarketFee,
|
||||
exchangeId
|
||||
)
|
||||
const trxReceipt = await this.contract.methods.collectMarketFee(exchangeId).send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.collectMarketFee(exchangeId)
|
||||
.send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
@ -1009,17 +1031,33 @@ export class FixedRateExchange {
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.collectOceanFee,
|
||||
this.fixedRateContract.methods.collectOceanFee,
|
||||
exchangeId
|
||||
)
|
||||
const trxReceipt = await this.contract.methods.collectOceanFee(exchangeId).send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.collectOceanFee(exchangeId)
|
||||
.send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OPF Collector of fixed rate contract
|
||||
* @return {String}
|
||||
*/
|
||||
async getOPCCollector(): Promise<string> {
|
||||
let result = null
|
||||
try {
|
||||
result = await this.fixedRateContract.methods.opcCollector().call()
|
||||
} catch (e) {
|
||||
LoggerInstance.error(`ERROR: Failed to get OPC Collector address: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Router address set in fixed rate contract
|
||||
* @return {String}
|
||||
@ -1027,7 +1065,7 @@ export class FixedRateExchange {
|
||||
async getRouter(): Promise<string> {
|
||||
let result = null
|
||||
try {
|
||||
result = await this.contract.methods.router().call()
|
||||
result = await this.fixedRateContract.methods.router().call()
|
||||
} catch (e) {
|
||||
LoggerInstance.error(`ERROR: Failed to get Router address: ${e.message}`)
|
||||
}
|
||||
@ -1087,11 +1125,11 @@ export class FixedRateExchange {
|
||||
): Promise<TransactionReceipt> {
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.updateMarketFee,
|
||||
this.fixedRateContract.methods.updateMarketFee,
|
||||
exchangeId,
|
||||
this.web3.utils.toWei(newMarketFee)
|
||||
)
|
||||
const trxReceipt = await this.contract.methods
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.updateMarketFee(exchangeId, this.web3.utils.toWei(newMarketFee))
|
||||
.send({
|
||||
from: address,
|
||||
@ -1139,11 +1177,11 @@ export class FixedRateExchange {
|
||||
): Promise<TransactionReceipt> {
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
this.contract.methods.updateMarketFeeCollector,
|
||||
this.fixedRateContract.methods.updateMarketFeeCollector,
|
||||
exchangeId,
|
||||
newMarketFeeCollector
|
||||
)
|
||||
const trxReceipt = await this.contract.methods
|
||||
const trxReceipt = await this.fixedRateContract.methods
|
||||
.updateMarketFeeCollector(exchangeId, newMarketFeeCollector)
|
||||
.send({
|
||||
from: address,
|
||||
|
@ -18,7 +18,8 @@ import {
|
||||
ConsumeMarketFee,
|
||||
FreOrderParams,
|
||||
FreCreationParams,
|
||||
ProviderFees
|
||||
ProviderFees,
|
||||
PublishingMarketFee
|
||||
} from '../@types'
|
||||
import { Nft } from './NFT'
|
||||
import { Config } from '../models/index.js'
|
||||
@ -1311,4 +1312,102 @@ export class Datatoken {
|
||||
const balance = await dtContract.methods.balanceOf(address).call()
|
||||
return this.web3.utils.fromWei(balance)
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev estGasSetPublishingMarketFee
|
||||
* Estimating gas for publishMarketFeeAddress method
|
||||
* @param {string} datatokenAddress Datatoken adress
|
||||
* @param {string} publishMarketFeeAddress new publish Market Fee Address
|
||||
* @param {string} publishMarketFeeToken new publish Market Fee Token
|
||||
* @param {string} publishMarketFeeAmount new fee amount
|
||||
* @param {String} address user adress
|
||||
*/
|
||||
public async estGasSetPublishingMarketFee(
|
||||
datatokenAddress: string,
|
||||
publishMarketFeeAddress: string,
|
||||
publishMarketFeeToken: string,
|
||||
publishMarketFeeAmount: string,
|
||||
address: string
|
||||
): Promise<number> {
|
||||
// Estimate gas cost for publishMarketFeeAddress method
|
||||
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, datatokenAddress, {
|
||||
from: address
|
||||
})
|
||||
return estimateGas(
|
||||
address,
|
||||
dtContract.methods.setPublishingMarketFee,
|
||||
publishMarketFeeAddress,
|
||||
publishMarketFeeToken,
|
||||
publishMarketFeeAmount
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev setPublishingMarketFee
|
||||
* Only publishMarketFeeAddress can call it
|
||||
* This function allows to set the fee required by the publisherMarket
|
||||
* @param {string} datatokenAddress Datatoken adress
|
||||
* @param {string} publishMarketFeeAddress new publish Market Fee Address
|
||||
* @param {string} publishMarketFeeToken new publish Market Fee Token
|
||||
* @param {string} publishMarketFeeAmount new fee amount
|
||||
* @param {String} address user adress
|
||||
*/
|
||||
public async setPublishingMarketFee(
|
||||
datatokenAddress: string,
|
||||
publishMarketFeeAddress: string,
|
||||
publishMarketFeeToken: string,
|
||||
publishMarketFeeAmount: string,
|
||||
address: string
|
||||
) {
|
||||
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, datatokenAddress, {
|
||||
from: address
|
||||
})
|
||||
const mktFeeAddress = (await dtContract.methods.getPublishingMarketFee().call())[0]
|
||||
if (mktFeeAddress !== address) {
|
||||
throw new Error(`Caller is not the Publishing Market Fee Address`)
|
||||
}
|
||||
const estGas = await this.estGasSetPublishingMarketFee(
|
||||
datatokenAddress,
|
||||
publishMarketFeeAddress,
|
||||
publishMarketFeeToken,
|
||||
publishMarketFeeAmount,
|
||||
address
|
||||
)
|
||||
await dtContract.methods
|
||||
.setPublishingMarketFee(
|
||||
publishMarketFeeAddress,
|
||||
publishMarketFeeToken,
|
||||
publishMarketFeeAmount
|
||||
)
|
||||
.send({
|
||||
from: address,
|
||||
gas: estGas + 1,
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev getPublishingMarketFee
|
||||
* Get publishingMarket Fee
|
||||
* This function allows to get the current fee set by the publishing market
|
||||
* @param {String} datatokenAddress Datatoken adress
|
||||
* @param {String} address user adress
|
||||
* @return {Promise<PublishingMarketFee>} Current fee set by the publishing market
|
||||
*/
|
||||
public async getPublishingMarketFee(
|
||||
datatokenAddress: string,
|
||||
address: string
|
||||
): Promise<PublishingMarketFee> {
|
||||
const dtContract = new this.web3.eth.Contract(this.datatokensAbi, datatokenAddress, {
|
||||
from: address
|
||||
})
|
||||
|
||||
const publishingMarketFee = await dtContract.methods.getPublishingMarketFee().call()
|
||||
const returnValues = {
|
||||
publishMarketFeeAddress: publishingMarketFee[0],
|
||||
publishMarketFeeToken: publishingMarketFee[1],
|
||||
publishMarketFeeAmount: publishingMarketFee[2]
|
||||
}
|
||||
return returnValues
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ import Decimal from 'decimal.js'
|
||||
import { Pool } from '..'
|
||||
|
||||
export function calcMaxExactOut(balance: string): Decimal {
|
||||
return new Decimal(balance).div(3.01)
|
||||
return new Decimal(balance).div(2)
|
||||
}
|
||||
|
||||
export function calcMaxExactIn(balance: string): Decimal {
|
||||
return new Decimal(balance).div(2.01)
|
||||
return new Decimal(balance).div(2)
|
||||
}
|
||||
export async function getMaxSwapExactOut(
|
||||
poolInstance: Pool,
|
||||
|
@ -10,92 +10,95 @@ import {
|
||||
Datatoken,
|
||||
getHash,
|
||||
Nft,
|
||||
downloadFile
|
||||
downloadFile,
|
||||
ZERO_ADDRESS
|
||||
} from '../../src'
|
||||
import { ProviderFees, Erc20CreateParams } from '../../src/@types'
|
||||
|
||||
const assetUrl = [
|
||||
{
|
||||
type: 'url',
|
||||
url: 'https://raw.githubusercontent.com/oceanprotocol/testdatasets/main/shs_dataset_test.txt',
|
||||
method: 'GET'
|
||||
}
|
||||
]
|
||||
const ddo = {
|
||||
'@context': ['https://w3id.org/did/v1'],
|
||||
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
|
||||
version: '4.0.0',
|
||||
chainId: 4,
|
||||
nftAddress: '0x0',
|
||||
metadata: {
|
||||
created: '2021-12-20T14:35:20Z',
|
||||
updated: '2021-12-20T14:35:20Z',
|
||||
type: 'dataset',
|
||||
name: 'dfgdfgdg',
|
||||
description: 'd dfgd fgd dfg dfgdfgd dfgdf',
|
||||
tags: [''],
|
||||
author: 'dd',
|
||||
license: 'https://market.oceanprotocol.com/terms',
|
||||
additionalInformation: {
|
||||
termsAndConditions: true
|
||||
}
|
||||
},
|
||||
services: [
|
||||
{
|
||||
id: 'notAnId',
|
||||
type: 'access',
|
||||
files: '',
|
||||
datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3',
|
||||
serviceEndpoint: 'https://providerv4.rinkeby.oceanprotocol.com',
|
||||
timeout: 0
|
||||
}
|
||||
]
|
||||
}
|
||||
import { ProviderFees, Erc20CreateParams, DDO } from '../../src/@types'
|
||||
|
||||
describe('Simple Publish & consume test', async () => {
|
||||
let config: Config
|
||||
let addresses: any
|
||||
let aquarius: Aquarius
|
||||
let providerUrl: any
|
||||
let publisherAccount: string
|
||||
let consumerAccount: string
|
||||
|
||||
const assetUrl = [
|
||||
{
|
||||
type: 'url',
|
||||
url: 'https://raw.githubusercontent.com/oceanprotocol/testdatasets/main/shs_dataset_test.txt',
|
||||
method: 'GET'
|
||||
}
|
||||
]
|
||||
|
||||
const ddo: DDO = {
|
||||
'@context': ['https://w3id.org/did/v1'],
|
||||
id: '',
|
||||
version: '4.0.0',
|
||||
chainId: 4,
|
||||
nftAddress: '0x0',
|
||||
metadata: {
|
||||
created: '2021-12-20T14:35:20Z',
|
||||
updated: '2021-12-20T14:35:20Z',
|
||||
type: 'dataset',
|
||||
name: 'dataset-name',
|
||||
description: 'Ocean protocol test dataset description',
|
||||
author: 'oceanprotocol-team',
|
||||
license: 'MIT'
|
||||
},
|
||||
services: [
|
||||
{
|
||||
id: 'testFakeId',
|
||||
type: 'access',
|
||||
files: '',
|
||||
datatokenAddress: '0x0',
|
||||
serviceEndpoint: 'https://providerv4.rinkeby.oceanprotocol.com',
|
||||
timeout: 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
before(async () => {
|
||||
config = await getTestConfig(web3)
|
||||
addresses = getAddresses()
|
||||
aquarius = new Aquarius(config.metadataCacheUri)
|
||||
providerUrl = config.providerUri
|
||||
|
||||
addresses = getAddresses()
|
||||
})
|
||||
|
||||
it('Initialize accounts', async () => {
|
||||
const accounts = await web3.eth.getAccounts()
|
||||
publisherAccount = accounts[0]
|
||||
consumerAccount = accounts[1]
|
||||
})
|
||||
|
||||
it('should publish a dataset (create NFT + ERC20)', async () => {
|
||||
const nft = new Nft(web3)
|
||||
const datatoken = new Datatoken(web3)
|
||||
const Factory = new NftFactory(addresses.ERC721Factory, web3)
|
||||
const accounts = await web3.eth.getAccounts()
|
||||
const publisherAccount = accounts[0]
|
||||
const consumerAccount = accounts[1]
|
||||
|
||||
const nftParams: NftCreateData = {
|
||||
name: 'testNFT',
|
||||
symbol: 'TST',
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
tokenURI: '',
|
||||
tokenURI: 'https://oceanprotocol.com/nft/',
|
||||
transferable: true,
|
||||
owner: publisherAccount
|
||||
}
|
||||
|
||||
const erc20Params: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
cap: '100000',
|
||||
feeAmount: '0',
|
||||
paymentCollector: '0x0000000000000000000000000000000000000000',
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
paymentCollector: ZERO_ADDRESS,
|
||||
feeToken: ZERO_ADDRESS,
|
||||
minter: publisherAccount,
|
||||
mpFeeAddress: '0x0000000000000000000000000000000000000000'
|
||||
mpFeeAddress: ZERO_ADDRESS
|
||||
}
|
||||
const result = await Factory.createNftWithErc20(
|
||||
publisherAccount,
|
||||
nftParams,
|
||||
erc20Params
|
||||
)
|
||||
const erc721Address = result.events.NFTCreated.returnValues[0]
|
||||
const datatokenAddress = result.events.TokenCreated.returnValues[0]
|
||||
|
||||
const tx = await Factory.createNftWithErc20(publisherAccount, nftParams, erc20Params)
|
||||
const erc721Address = tx.events.NFTCreated.returnValues[0]
|
||||
const datatokenAddress = tx.events.TokenCreated.returnValues[0]
|
||||
|
||||
// create the files encrypted string
|
||||
let providerResponse = await ProviderInstance.encrypt(assetUrl, providerUrl)
|
||||
@ -110,7 +113,7 @@ describe('Simple Publish & consume test', async () => {
|
||||
providerResponse = await ProviderInstance.encrypt(ddo, providerUrl)
|
||||
const encryptedResponse = await providerResponse
|
||||
const metadataHash = getHash(JSON.stringify(ddo))
|
||||
const res = await nft.setMetadata(
|
||||
await nft.setMetadata(
|
||||
erc721Address,
|
||||
publisherAccount,
|
||||
0,
|
||||
@ -120,10 +123,13 @@ describe('Simple Publish & consume test', async () => {
|
||||
encryptedResponse,
|
||||
'0x' + metadataHash
|
||||
)
|
||||
|
||||
const resolvedDDO = await aquarius.waitForAqua(ddo.id)
|
||||
assert(resolvedDDO, 'Cannot fetch DDO from Aquarius')
|
||||
|
||||
// mint 1 ERC20 and send it to the consumer
|
||||
await datatoken.mint(datatokenAddress, publisherAccount, '1', consumerAccount)
|
||||
|
||||
// initialize provider
|
||||
const initializeData = await ProviderInstance.initialize(
|
||||
resolvedDDO.id,
|
||||
@ -132,6 +138,7 @@ describe('Simple Publish & consume test', async () => {
|
||||
consumerAccount,
|
||||
providerUrl
|
||||
)
|
||||
|
||||
const providerFees: ProviderFees = {
|
||||
providerFeeAddress: initializeData.providerFee.providerFeeAddress,
|
||||
providerFeeToken: initializeData.providerFee.providerFeeToken,
|
||||
@ -142,6 +149,7 @@ describe('Simple Publish & consume test', async () => {
|
||||
providerData: initializeData.providerFee.providerData,
|
||||
validUntil: initializeData.providerFee.validUntil
|
||||
}
|
||||
|
||||
// make the payment
|
||||
const txid = await datatoken.startOrder(
|
||||
datatokenAddress,
|
||||
@ -150,6 +158,7 @@ describe('Simple Publish & consume test', async () => {
|
||||
0,
|
||||
providerFees
|
||||
)
|
||||
|
||||
// get the url
|
||||
const downloadURL = await ProviderInstance.getDownloadUrl(
|
||||
ddo.id,
|
||||
@ -160,9 +169,10 @@ describe('Simple Publish & consume test', async () => {
|
||||
providerUrl,
|
||||
web3
|
||||
)
|
||||
|
||||
assert(downloadURL, 'Provider getDownloadUrl failed')
|
||||
try {
|
||||
const fileData = await downloadFile(downloadURL)
|
||||
await downloadFile(downloadURL)
|
||||
} catch (e) {
|
||||
assert.fail('Download failed')
|
||||
}
|
||||
|
@ -1,48 +1,75 @@
|
||||
import { assert, expect } from 'chai'
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
import { deployContracts, Addresses } from '../TestContractHandler'
|
||||
import { deployContracts, Addresses } from '../../TestContractHandler'
|
||||
import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json'
|
||||
import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/MockERC20Decimals.sol/MockERC20Decimals.json'
|
||||
import { web3 } from '../config'
|
||||
import { NftFactory, NftCreateData, TokenOrder, ZERO_ADDRESS, signHash } from '../../src'
|
||||
import { web3 } from '../../config'
|
||||
import {
|
||||
NftFactory,
|
||||
NftCreateData,
|
||||
TokenOrder,
|
||||
ZERO_ADDRESS,
|
||||
signHash,
|
||||
Nft,
|
||||
transfer,
|
||||
approve
|
||||
} from '../../../src'
|
||||
import {
|
||||
ProviderFees,
|
||||
FreCreationParams,
|
||||
Erc20CreateParams,
|
||||
PoolCreationParams
|
||||
} from '../../src/@types'
|
||||
} from '../../../src/@types'
|
||||
|
||||
describe('Nft Factory test', () => {
|
||||
let factoryOwner: string
|
||||
let nftOwner: string
|
||||
let user1: string
|
||||
let user2: string
|
||||
let user3: string
|
||||
let contracts: Addresses
|
||||
let nftFactory: NftFactory
|
||||
let dtAddress: string
|
||||
let dtAddress2: string
|
||||
let nftAddress: string
|
||||
|
||||
const DATA_TOKEN_AMOUNT = web3.utils.toWei('1')
|
||||
const FEE = '0.001'
|
||||
|
||||
const nftData: NftCreateData = {
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
tokenURI: 'https://oceanprotocol.com/nft/',
|
||||
transferable: true,
|
||||
owner: factoryOwner
|
||||
}
|
||||
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: nftOwner,
|
||||
paymentCollector: user2,
|
||||
mpFeeAddress: user1,
|
||||
feeToken: ZERO_ADDRESS,
|
||||
cap: '1000000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B1',
|
||||
symbol: 'ERC20DT1Symbol'
|
||||
}
|
||||
|
||||
before(async () => {
|
||||
const accounts = await web3.eth.getAccounts()
|
||||
factoryOwner = accounts[0]
|
||||
nftOwner = accounts[1]
|
||||
user1 = accounts[2]
|
||||
user2 = accounts[3]
|
||||
user3 = accounts[4]
|
||||
|
||||
nftData.owner = factoryOwner
|
||||
ercParams.minter = nftOwner
|
||||
ercParams.paymentCollector = user2
|
||||
ercParams.mpFeeAddress = user1
|
||||
})
|
||||
|
||||
it('should deploy contracts', async () => {
|
||||
contracts = await deployContracts(web3, factoryOwner)
|
||||
|
||||
const daiContract = new web3.eth.Contract(
|
||||
MockERC20.abi as AbiItem[],
|
||||
contracts.daiAddress
|
||||
)
|
||||
await daiContract.methods
|
||||
.approve(contracts.erc721FactoryAddress, web3.utils.toWei('10000'))
|
||||
.send({ from: factoryOwner })
|
||||
})
|
||||
|
||||
it('should initiate NFTFactory instance', async () => {
|
||||
@ -59,42 +86,28 @@ describe('Nft Factory test', () => {
|
||||
assert(nftTemplate.isActive === true)
|
||||
assert(nftTemplate.templateAddress === contracts.erc721TemplateAddress)
|
||||
})
|
||||
|
||||
it('#getTokenTemplate - should return Token template struct', async () => {
|
||||
const tokenTemplate = await nftFactory.getTokenTemplate(1)
|
||||
assert(tokenTemplate.isActive === true)
|
||||
assert(tokenTemplate.templateAddress === contracts.erc20TemplateAddress)
|
||||
})
|
||||
|
||||
it('#createNftwithErc - should create an NFT and a Datatoken ', async () => {
|
||||
it('#createNft - should create an NFT', async () => {
|
||||
// we prepare transaction parameters objects
|
||||
const nftData: NftCreateData = {
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
tokenURI: 'https://oceanprotocol.com/nft/',
|
||||
transferable: true,
|
||||
owner: factoryOwner
|
||||
}
|
||||
const nftAddress = await nftFactory.createNFT(nftOwner, nftData)
|
||||
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '10000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B1',
|
||||
symbol: 'ERC20DT1Symbol'
|
||||
}
|
||||
// we check the created nft
|
||||
const nftDatatoken = new Nft(web3)
|
||||
const tokenURI = await nftDatatoken.getTokenURI(nftAddress, 1)
|
||||
assert(tokenURI === nftData.tokenURI)
|
||||
})
|
||||
|
||||
const txReceipt = await nftFactory.createNftWithErc20(
|
||||
factoryOwner,
|
||||
nftData,
|
||||
ercParams
|
||||
)
|
||||
it('#createNftwithErc - should create an NFT and a Datatoken', async () => {
|
||||
// we prepare transaction parameters objects
|
||||
const txReceipt = await nftFactory.createNftWithErc20(nftOwner, nftData, ercParams)
|
||||
|
||||
// EVENTS HAVE BEEN EMITTED
|
||||
// events have been emitted
|
||||
expect(txReceipt.events.NFTCreated.event === 'NFTCreated')
|
||||
expect(txReceipt.events.TokenCreated.event === 'TokenCreated')
|
||||
|
||||
@ -103,53 +116,58 @@ describe('Nft Factory test', () => {
|
||||
dtAddress = txReceipt.events.TokenCreated.returnValues.newTokenAddress
|
||||
})
|
||||
|
||||
it('#createNftwithErc - should increment nft and token count', async () => {
|
||||
const currentNFTCount = await nftFactory.getCurrentNFTCount()
|
||||
const currentTokenCount = await nftFactory.getCurrentTokenCount()
|
||||
|
||||
await nftFactory.createNftWithErc20(nftOwner, nftData, ercParams)
|
||||
|
||||
expect((await nftFactory.getCurrentNFTCount()) === currentNFTCount + 1)
|
||||
expect((await nftFactory.getCurrentTokenCount()) === currentTokenCount + 1)
|
||||
})
|
||||
|
||||
it('#createNftErcWithPool- should create an NFT, a Datatoken and a pool DT/DAI', async () => {
|
||||
// we prepare transaction parameters objects
|
||||
const nftData: NftCreateData = {
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
tokenURI: 'https://oceanprotocol.com/nft/',
|
||||
transferable: true,
|
||||
owner: factoryOwner
|
||||
}
|
||||
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: user2,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B1',
|
||||
symbol: 'ERC20DT1Symbol'
|
||||
}
|
||||
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: contracts.sideStakingAddress,
|
||||
baseTokenAddress: contracts.daiAddress,
|
||||
baseTokenSender: contracts.erc721FactoryAddress,
|
||||
publisherAddress: factoryOwner,
|
||||
marketFeeCollector: factoryOwner,
|
||||
publisherAddress: nftOwner,
|
||||
marketFeeCollector: nftOwner,
|
||||
poolTemplateAddress: contracts.poolTemplateAddress,
|
||||
rate: '1',
|
||||
baseTokenDecimals: 18,
|
||||
vestingAmount: '10000',
|
||||
vestedBlocks: 2500000,
|
||||
initialBaseTokenLiquidity: '2000',
|
||||
swapFeeLiquidityProvider: '0.001',
|
||||
swapFeeMarketRunner: '0.001'
|
||||
swapFeeLiquidityProvider: FEE,
|
||||
swapFeeMarketRunner: FEE
|
||||
}
|
||||
|
||||
const txReceipt = await nftFactory.createNftErc20WithPool(
|
||||
await transfer(
|
||||
web3,
|
||||
factoryOwner,
|
||||
contracts.daiAddress,
|
||||
nftOwner,
|
||||
poolParams.vestingAmount
|
||||
)
|
||||
|
||||
await approve(
|
||||
web3,
|
||||
nftOwner,
|
||||
contracts.daiAddress,
|
||||
contracts.erc721FactoryAddress,
|
||||
poolParams.vestingAmount
|
||||
)
|
||||
|
||||
const txReceipt = await nftFactory.createNftErc20WithPool(
|
||||
nftOwner,
|
||||
nftData,
|
||||
ercParams,
|
||||
poolParams
|
||||
)
|
||||
|
||||
// EVENTS HAVE BEEN EMITTED
|
||||
// events have been emitted
|
||||
expect(txReceipt.events.NFTCreated.event === 'NFTCreated')
|
||||
expect(txReceipt.events.TokenCreated.event === 'TokenCreated')
|
||||
expect(txReceipt.events.NewPool.event === 'NewPool')
|
||||
@ -157,48 +175,27 @@ describe('Nft Factory test', () => {
|
||||
|
||||
it('#createNftErcWithFixedRate- should create an NFT, a datatoken and create a Fixed Rate Exchange', async () => {
|
||||
// we prepare transaction parameters objects
|
||||
const nftData: NftCreateData = {
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
tokenURI: 'https://oceanprotocol.com/nft/',
|
||||
transferable: true,
|
||||
owner: factoryOwner
|
||||
}
|
||||
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B1',
|
||||
symbol: 'ERC20DT1Symbol'
|
||||
}
|
||||
|
||||
const freParams: FreCreationParams = {
|
||||
fixedRateAddress: contracts.fixedRateAddress,
|
||||
baseTokenAddress: contracts.daiAddress,
|
||||
owner: factoryOwner,
|
||||
marketFeeCollector: factoryOwner,
|
||||
owner: nftOwner,
|
||||
marketFeeCollector: nftOwner,
|
||||
baseTokenDecimals: 18,
|
||||
datatokenDecimals: 18,
|
||||
fixedRate: '1',
|
||||
marketFee: '0.001',
|
||||
allowedConsumer: factoryOwner,
|
||||
marketFee: FEE,
|
||||
allowedConsumer: user1,
|
||||
withMint: false
|
||||
}
|
||||
|
||||
const txReceipt = await nftFactory.createNftErc20WithFixedRate(
|
||||
factoryOwner,
|
||||
nftOwner,
|
||||
nftData,
|
||||
ercParams,
|
||||
freParams
|
||||
)
|
||||
|
||||
// EVENTS HAVE BEEN EMITTED
|
||||
// events have been emitted
|
||||
expect(txReceipt.events.NFTCreated.event === 'NFTCreated')
|
||||
expect(txReceipt.events.TokenCreated.event === 'TokenCreated')
|
||||
expect(txReceipt.events.NewFixedRate.event === 'NewFixedRate')
|
||||
@ -209,27 +206,6 @@ describe('Nft Factory test', () => {
|
||||
|
||||
it('#createNftErcWithDispenser- should create an NFT, a datatoken and create a Dispenser', async () => {
|
||||
// we prepare transaction parameters objects
|
||||
const nftData: NftCreateData = {
|
||||
name: '72120Bundle',
|
||||
symbol: '72Bundle',
|
||||
templateIndex: 1,
|
||||
tokenURI: 'https://oceanprotocol.com/nft/',
|
||||
transferable: true,
|
||||
owner: factoryOwner
|
||||
}
|
||||
|
||||
const ercParams: Erc20CreateParams = {
|
||||
templateIndex: 1,
|
||||
minter: factoryOwner,
|
||||
paymentCollector: user3,
|
||||
mpFeeAddress: user2,
|
||||
feeToken: '0x0000000000000000000000000000000000000000',
|
||||
cap: '1000000',
|
||||
feeAmount: '0',
|
||||
name: 'ERC20B1',
|
||||
symbol: 'ERC20DT1Symbol'
|
||||
}
|
||||
|
||||
const dispenserParams = {
|
||||
dispenserAddress: contracts.dispenserAddress,
|
||||
maxTokens: '1',
|
||||
@ -239,13 +215,13 @@ describe('Nft Factory test', () => {
|
||||
}
|
||||
|
||||
const txReceipt = await nftFactory.createNftErc20WithDispenser(
|
||||
factoryOwner,
|
||||
nftOwner,
|
||||
nftData,
|
||||
ercParams,
|
||||
dispenserParams
|
||||
)
|
||||
|
||||
// EVENTS HAVE BEEN EMITTED
|
||||
// events have been emitted
|
||||
expect(txReceipt.events.NFTCreated.event === 'NFTCreated')
|
||||
expect(txReceipt.events.TokenCreated.event === 'TokenCreated')
|
||||
expect(txReceipt.events.DispenserCreated.event === 'DispenserCreated')
|
||||
@ -255,39 +231,38 @@ describe('Nft Factory test', () => {
|
||||
})
|
||||
|
||||
it('#startMultipleTokenOrder- should succed to start multiple orders', async () => {
|
||||
const consumer = user2 // could be different user
|
||||
const dtAmount = web3.utils.toWei('1')
|
||||
const consumer = user1 // could be different user
|
||||
const serviceIndex = 1 // dummy index
|
||||
const consumeFeeAddress = user3 // marketplace fee Collector
|
||||
const consumeFeeAddress = user2 // marketplace fee Collector
|
||||
const consumeFeeAmount = '0' // fee to be collected on top, requires approval
|
||||
const consumeFeeToken = contracts.daiAddress // token address for the feeAmount, in this case DAI
|
||||
|
||||
// we reuse a DT created in a previous test
|
||||
const dtContract = new web3.eth.Contract(ERC20Template.abi as AbiItem[], dtAddress)
|
||||
expect(await dtContract.methods.balanceOf(user2).call()).to.equal('0')
|
||||
expect(await dtContract.methods.balanceOf(user1).call()).to.equal('0')
|
||||
|
||||
// dt owner mint dtAmount to user2
|
||||
await dtContract.methods.mint(user2, dtAmount).send({ from: factoryOwner })
|
||||
// dt owner mint DATA_TOKEN_AMOUNT to user1
|
||||
await dtContract.methods.mint(user1, DATA_TOKEN_AMOUNT).send({ from: nftOwner })
|
||||
|
||||
// user2 approves NFTFactory to move his dtAmount
|
||||
// user1 approves NFTFactory to move his DATA_TOKEN_AMOUNT
|
||||
await dtContract.methods
|
||||
.approve(contracts.erc721FactoryAddress, dtAmount)
|
||||
.send({ from: user2 })
|
||||
.approve(contracts.erc721FactoryAddress, DATA_TOKEN_AMOUNT)
|
||||
.send({ from: user1 })
|
||||
|
||||
// we reuse another DT created in a previous test
|
||||
const dtContract2 = new web3.eth.Contract(ERC20Template.abi as AbiItem[], dtAddress2)
|
||||
expect(await dtContract2.methods.balanceOf(user2).call()).to.equal('0')
|
||||
expect(await dtContract2.methods.balanceOf(user1).call()).to.equal('0')
|
||||
|
||||
// dt owner mint dtAmount to user2
|
||||
await dtContract2.methods.mint(user2, dtAmount).send({ from: factoryOwner })
|
||||
// user2 approves NFTFactory to move his dtAmount
|
||||
// dt owner mint DATA_TOKEN_AMOUNT to user1
|
||||
await dtContract2.methods.mint(user1, DATA_TOKEN_AMOUNT).send({ from: nftOwner })
|
||||
// user1 approves NFTFactory to move his DATA_TOKEN_AMOUNT
|
||||
await dtContract2.methods
|
||||
.approve(contracts.erc721FactoryAddress, dtAmount)
|
||||
.send({ from: user2 })
|
||||
.approve(contracts.erc721FactoryAddress, DATA_TOKEN_AMOUNT)
|
||||
.send({ from: user1 })
|
||||
|
||||
// we check user2 has enought DTs
|
||||
expect(await dtContract.methods.balanceOf(user2).call()).to.equal(dtAmount)
|
||||
expect(await dtContract2.methods.balanceOf(user2).call()).to.equal(dtAmount)
|
||||
// we check user1 has enought DTs
|
||||
expect(await dtContract.methods.balanceOf(user1).call()).to.equal(DATA_TOKEN_AMOUNT)
|
||||
expect(await dtContract2.methods.balanceOf(user1).call()).to.equal(DATA_TOKEN_AMOUNT)
|
||||
|
||||
const providerData = JSON.stringify({ timeout: 0 })
|
||||
const providerValidUntil = '0'
|
||||
@ -312,8 +287,8 @@ describe('Nft Factory test', () => {
|
||||
validUntil: providerValidUntil
|
||||
}
|
||||
const consumeMarketFee = {
|
||||
consumeMarketFeeAddress: '0x0000000000000000000000000000000000000000',
|
||||
consumeMarketFeeToken: '0x0000000000000000000000000000000000000000',
|
||||
consumeMarketFeeAddress: ZERO_ADDRESS,
|
||||
consumeMarketFeeToken: ZERO_ADDRESS,
|
||||
consumeMarketFeeAmount: '0'
|
||||
}
|
||||
const orders: TokenOrder[] = [
|
||||
@ -332,24 +307,21 @@ describe('Nft Factory test', () => {
|
||||
_consumeMarketFee: consumeMarketFee
|
||||
}
|
||||
]
|
||||
await nftFactory.startMultipleTokenOrder(user2, orders)
|
||||
// we check user2 has no more DTs
|
||||
expect(await dtContract.methods.balanceOf(user2).call()).to.equal('0')
|
||||
expect(await dtContract2.methods.balanceOf(user2).call()).to.equal('0')
|
||||
await nftFactory.startMultipleTokenOrder(user1, orders)
|
||||
// we check user1 has no more DTs
|
||||
expect(await dtContract.methods.balanceOf(user1).call()).to.equal('0')
|
||||
expect(await dtContract2.methods.balanceOf(user1).call()).to.equal('0')
|
||||
})
|
||||
|
||||
it('#checkDatatoken - should confirm if DT is from the factory', async () => {
|
||||
assert((await nftFactory.checkDatatoken(dtAddress)) === true)
|
||||
assert((await nftFactory.checkDatatoken(dtAddress2)) === true)
|
||||
assert((await nftFactory.checkDatatoken(user2)) === false)
|
||||
assert((await nftFactory.checkDatatoken(user1)) === false)
|
||||
assert((await nftFactory.checkDatatoken(nftAddress)) === false)
|
||||
})
|
||||
|
||||
it('#checkNFT - should return nftAddress if from the factory, or address(0) if not', async () => {
|
||||
assert(
|
||||
(await nftFactory.checkNFT(dtAddress)) ===
|
||||
'0x0000000000000000000000000000000000000000'
|
||||
)
|
||||
assert((await nftFactory.checkNFT(dtAddress)) === ZERO_ADDRESS)
|
||||
assert((await nftFactory.checkNFT(nftAddress)) === nftAddress)
|
||||
})
|
||||
|
@ -589,4 +589,66 @@ describe('Datatoken', () => {
|
||||
assert(+balance1after === +balance1before - 1)
|
||||
assert(+balance2after === +balance2before + 1)
|
||||
})
|
||||
|
||||
it('#setPublishingMarketFee - User should not be able to set the Publishing Market Fee', async () => {
|
||||
const originalPublishingMarketFee = await datatoken.getPublishingMarketFee(
|
||||
datatokenAddress,
|
||||
user1
|
||||
)
|
||||
try {
|
||||
await datatoken.setPublishingMarketFee(
|
||||
datatokenAddress,
|
||||
user1,
|
||||
contracts.daiAddress,
|
||||
web3.utils.toWei('10'),
|
||||
user1
|
||||
)
|
||||
} catch (e) {
|
||||
console.log('Message:', e.message)
|
||||
assert(e.message === 'Caller is not the Publishing Market Fee Address')
|
||||
}
|
||||
const newPublishingMarketFee = await datatoken.getPublishingMarketFee(
|
||||
datatokenAddress,
|
||||
user3
|
||||
)
|
||||
|
||||
assert(
|
||||
newPublishingMarketFee.publishMarketFeeAddress ===
|
||||
originalPublishingMarketFee.publishMarketFeeAddress
|
||||
)
|
||||
assert(
|
||||
newPublishingMarketFee.publishMarketFeeAmount ===
|
||||
originalPublishingMarketFee.publishMarketFeeAmount
|
||||
)
|
||||
assert(
|
||||
newPublishingMarketFee.publishMarketFeeToken ===
|
||||
originalPublishingMarketFee.publishMarketFeeToken
|
||||
)
|
||||
})
|
||||
it('#setPublishingMarketFee - Marketplace fee address should be able to set the Publishing Market Fee', async () => {
|
||||
const originalPublishingMarketFee = await datatoken.getPublishingMarketFee(
|
||||
datatokenAddress,
|
||||
user2
|
||||
)
|
||||
try {
|
||||
await datatoken.setPublishingMarketFee(
|
||||
datatokenAddress,
|
||||
user2,
|
||||
contracts.daiAddress,
|
||||
web3.utils.toWei('10'),
|
||||
user2
|
||||
)
|
||||
} catch (e) {
|
||||
console.log('Error:', e)
|
||||
}
|
||||
const newPublishingMarketFee = await datatoken.getPublishingMarketFee(
|
||||
datatokenAddress,
|
||||
user2
|
||||
)
|
||||
|
||||
assert(newPublishingMarketFee !== originalPublishingMarketFee)
|
||||
assert(newPublishingMarketFee.publishMarketFeeAddress === user2)
|
||||
assert(newPublishingMarketFee.publishMarketFeeAmount === web3.utils.toWei('10'))
|
||||
assert(newPublishingMarketFee.publishMarketFeeToken === contracts.daiAddress)
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user