1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Merge branch 'main' into feature/customProvider

This commit is contained in:
Alex Coseru 2020-09-22 12:35:56 +03:00 committed by GitHub
commit 023c258311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 244 additions and 93 deletions

242
package-lock.json generated
View File

@ -1465,9 +1465,9 @@
"dev": true
},
"@types/node": {
"version": "14.11.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.1.tgz",
"integrity": "sha512-oTQgnd0hblfLsJ6BvJzzSL+Inogp3lq9fGgqRkMB/ziKMgEUaFl801OncOzUmalfzt14N0oPHMK47ipl+wbTIw=="
"version": "14.11.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.2.tgz",
"integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA=="
},
"@types/node-fetch": {
"version": "2.5.7",
@ -1535,13 +1535,13 @@
}
},
"@typescript-eslint/eslint-plugin": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.1.1.tgz",
"integrity": "sha512-Hoxyt99EA9LMmqo/5PuWWPeWeB3mKyvibfJ1Hy5SfiUpjE8Nqp+5QNd9fOkzL66+fqvIWSIE+Ett16LGMzCGnQ==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.2.0.tgz",
"integrity": "sha512-zBNRkzvLSwo6y5TG0DVcmshZIYBHKtmzD4N+LYnfTFpzc4bc79o8jNRSb728WV7A4Cegbs+MV5IRAj8BKBgOVQ==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "4.1.1",
"@typescript-eslint/scope-manager": "4.1.1",
"@typescript-eslint/experimental-utils": "4.2.0",
"@typescript-eslint/scope-manager": "4.2.0",
"debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0",
@ -1549,15 +1549,47 @@
"tsutils": "^3.17.1"
},
"dependencies": {
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"@typescript-eslint/scope-manager": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.2.0.tgz",
"integrity": "sha512-Tb402cxxObSxWIVT+PnBp5ruT2V/36yj6gG4C9AjkgRlZpxrLAzWDk3neen6ToMBGeGdxtnfFLoJRUecGz9mYQ==",
"dev": true,
"requires": {
"ms": "^2.1.1"
"@typescript-eslint/types": "4.2.0",
"@typescript-eslint/visitor-keys": "4.2.0"
}
},
"@typescript-eslint/types": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.2.0.tgz",
"integrity": "sha512-xkv5nIsxfI/Di9eVwN+G9reWl7Me9R5jpzmZUch58uQ7g0/hHVuGUbbn4NcxcM5y/R4wuJIIEPKPDb5l4Fdmwg==",
"dev": true
},
"@typescript-eslint/visitor-keys": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.2.0.tgz",
"integrity": "sha512-WIf4BNOlFOH2W+YqGWa6YKLcK/EB3gEj2apCrqLw6mme1RzBy0jtJ9ewJgnrZDB640zfnv8L+/gwGH5sYp/rGw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.2.0",
"eslint-visitor-keys": "^2.0.0"
}
},
"debug": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
"dev": true,
"requires": {
"ms": "2.1.2"
}
},
"eslint-visitor-keys": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz",
"integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==",
"dev": true
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@ -1573,38 +1605,109 @@
}
},
"@typescript-eslint/experimental-utils": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.1.1.tgz",
"integrity": "sha512-jzYsNciHoa4Z3c1URtmeT/bamYm8Dwfw6vuN3WHIE/BXb1iC4KveAnXDErTAZtPVxTYBaYn3n2gbt6F6D2rm1A==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.2.0.tgz",
"integrity": "sha512-5BBj6BjgHEndBaQQpUVzRIPERz03LBc0MCQkHwUaH044FJFL08SwWv/sQftk7gf0ShZ2xZysz0LTwCwNt4Xu3w==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/scope-manager": "4.1.1",
"@typescript-eslint/types": "4.1.1",
"@typescript-eslint/typescript-estree": "4.1.1",
"@typescript-eslint/scope-manager": "4.2.0",
"@typescript-eslint/types": "4.2.0",
"@typescript-eslint/typescript-estree": "4.2.0",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
},
"dependencies": {
"@typescript-eslint/scope-manager": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.2.0.tgz",
"integrity": "sha512-Tb402cxxObSxWIVT+PnBp5ruT2V/36yj6gG4C9AjkgRlZpxrLAzWDk3neen6ToMBGeGdxtnfFLoJRUecGz9mYQ==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.2.0",
"@typescript-eslint/visitor-keys": "4.2.0"
}
},
"@typescript-eslint/types": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.2.0.tgz",
"integrity": "sha512-xkv5nIsxfI/Di9eVwN+G9reWl7Me9R5jpzmZUch58uQ7g0/hHVuGUbbn4NcxcM5y/R4wuJIIEPKPDb5l4Fdmwg==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.2.0.tgz",
"integrity": "sha512-iWDLCB7z4MGkLipduF6EOotdHNtgxuNKnYD54nMS/oitFnsk4S3S/TE/UYXQTra550lHtlv9eGmp+dvN9pUDtA==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.2.0",
"@typescript-eslint/visitor-keys": "4.2.0",
"debug": "^4.1.1",
"globby": "^11.0.1",
"is-glob": "^4.0.1",
"lodash": "^4.17.15",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
}
},
"@typescript-eslint/visitor-keys": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.2.0.tgz",
"integrity": "sha512-WIf4BNOlFOH2W+YqGWa6YKLcK/EB3gEj2apCrqLw6mme1RzBy0jtJ9ewJgnrZDB640zfnv8L+/gwGH5sYp/rGw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.2.0",
"eslint-visitor-keys": "^2.0.0"
}
},
"debug": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
"dev": true,
"requires": {
"ms": "2.1.2"
}
},
"eslint-visitor-keys": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz",
"integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==",
"dev": true
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
}
}
},
"@typescript-eslint/parser": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.1.1.tgz",
"integrity": "sha512-NLIhmicpKGfJbdXyQBz9j48PA6hq6e+SDOoXy7Ak6bq1ebGqbgG+fR1UIDAuay6OjQdot69c/URu2uLlsP8GQQ==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.2.0.tgz",
"integrity": "sha512-54jJ6MwkOtowpE48C0QJF9iTz2/NZxfKVJzv1ha5imigzHbNSLN9yvbxFFH1KdlRPQrlR8qxqyOvLHHxd397VA==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "4.1.1",
"@typescript-eslint/types": "4.1.1",
"@typescript-eslint/typescript-estree": "4.1.1",
"@typescript-eslint/scope-manager": "4.2.0",
"@typescript-eslint/types": "4.2.0",
"@typescript-eslint/typescript-estree": "4.2.0",
"debug": "^4.1.1"
},
"dependencies": {
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
"dev": true,
"requires": {
"ms": "^2.1.1"
"ms": "2.1.2"
}
},
"ms": {
@ -1616,29 +1719,29 @@
}
},
"@typescript-eslint/scope-manager": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.1.1.tgz",
"integrity": "sha512-0W8TTobCvIIQ2FsrYTffyZGAAFUyIbEHq5EYJb1m7Rpd005jrnOvKOo8ywCLhs/Bm17C+KsrUboBvBAARQVvyA==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.2.0.tgz",
"integrity": "sha512-Tb402cxxObSxWIVT+PnBp5ruT2V/36yj6gG4C9AjkgRlZpxrLAzWDk3neen6ToMBGeGdxtnfFLoJRUecGz9mYQ==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.1.1",
"@typescript-eslint/visitor-keys": "4.1.1"
"@typescript-eslint/types": "4.2.0",
"@typescript-eslint/visitor-keys": "4.2.0"
}
},
"@typescript-eslint/types": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.1.1.tgz",
"integrity": "sha512-zrBiqOKYerMTllKcn+BP+i1b7LW/EbMMYytroXMxUTvFPn1smkCu0D7lSAx29fTUO4jnwV0ljSvYQtn2vNrNxA==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.2.0.tgz",
"integrity": "sha512-xkv5nIsxfI/Di9eVwN+G9reWl7Me9R5jpzmZUch58uQ7g0/hHVuGUbbn4NcxcM5y/R4wuJIIEPKPDb5l4Fdmwg==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.1.1.tgz",
"integrity": "sha512-2AUg5v0liVBsqbGxBphbJ0QbGqSRVaF5qPoTPWcxop+66vMdU1h4CCvHxTC47+Qb+Pr4l2RhXDd41JNpwcQEKw==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.2.0.tgz",
"integrity": "sha512-iWDLCB7z4MGkLipduF6EOotdHNtgxuNKnYD54nMS/oitFnsk4S3S/TE/UYXQTra550lHtlv9eGmp+dvN9pUDtA==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.1.1",
"@typescript-eslint/visitor-keys": "4.1.1",
"@typescript-eslint/types": "4.2.0",
"@typescript-eslint/visitor-keys": "4.2.0",
"debug": "^4.1.1",
"globby": "^11.0.1",
"is-glob": "^4.0.1",
@ -1648,12 +1751,12 @@
},
"dependencies": {
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
"dev": true,
"requires": {
"ms": "^2.1.1"
"ms": "2.1.2"
}
},
"ms": {
@ -1671,12 +1774,12 @@
}
},
"@typescript-eslint/visitor-keys": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.1.1.tgz",
"integrity": "sha512-/EOOXbA2ferGLG6RmCHEQ0lTTLkOlXYDgblCmQk3tIU7mTPLm4gKhFMeeUSe+bcchTUsKeCk8xcpbop5Zr/8Rw==",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.2.0.tgz",
"integrity": "sha512-WIf4BNOlFOH2W+YqGWa6YKLcK/EB3gEj2apCrqLw6mme1RzBy0jtJ9ewJgnrZDB640zfnv8L+/gwGH5sYp/rGw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.1.1",
"@typescript-eslint/types": "4.2.0",
"eslint-visitor-keys": "^2.0.0"
},
"dependencies": {
@ -2017,9 +2120,9 @@
"integrity": "sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY="
},
"auto-changelog": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/auto-changelog/-/auto-changelog-2.2.0.tgz",
"integrity": "sha512-RBY0hhVNXstggOQL0SyUaCfSiVD11CVXEHvDwB+mEt9UnhXPqhdpQ7nIVGDEog7JopTdYbydULLLt6v//qrWjw==",
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/auto-changelog/-/auto-changelog-2.2.1.tgz",
"integrity": "sha512-XlykJfZrXlWUAADBqGoN1elmntrRcx7oEymyYB3NRPEZxv0TfYHfivmwzejUMnwAdXKCgbQPo7GV5ULs3jwpfw==",
"dev": true,
"requires": {
"commander": "^5.0.0",
@ -5372,9 +5475,9 @@
"dev": true
},
"highlight.js": {
"version": "10.1.2",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.1.2.tgz",
"integrity": "sha512-Q39v/Mn5mfBlMff9r+zzA+gWxRsCRKwEMvYTiisLr/XUiFI/4puWt0Ojdko3R3JCNWGdOWaA5g/Yxqa23kC5AA==",
"version": "10.2.0",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.2.0.tgz",
"integrity": "sha512-OryzPiqqNCfO/wtFo619W+nPYALM6u7iCQkum4bqRmmlcTikOkmlL06i009QelynBPAlNByTQU6cBB2cOBQtCw==",
"dev": true
},
"hmac-drbg": {
@ -9528,14 +9631,14 @@
}
},
"typedoc": {
"version": "0.19.1",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.19.1.tgz",
"integrity": "sha512-EqZpRJQUnkwHA1yBhaDExEXUZIiWKddkrDXhRcfUzpnu6pizxNmVTw5IZ3mu682Noa4zQCniE0YNjaAwHQodrA==",
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.19.2.tgz",
"integrity": "sha512-oDEg1BLEzi1qvgdQXc658EYgJ5qJLVSeZ0hQ57Eq4JXy6Vj2VX4RVo18qYxRWz75ifAaYuYNBUCnbhjd37TfOg==",
"dev": true,
"requires": {
"fs-extra": "^9.0.1",
"handlebars": "^4.7.6",
"highlight.js": "^10.0.0",
"highlight.js": "^10.2.0",
"lodash": "^4.17.20",
"lunr": "^2.3.9",
"marked": "^1.1.1",
@ -9543,7 +9646,7 @@
"progress": "^2.0.3",
"semver": "^7.3.2",
"shelljs": "^0.8.4",
"typedoc-default-themes": "^0.11.1"
"typedoc-default-themes": "^0.11.4"
},
"dependencies": {
"fs-extra": {
@ -9589,18 +9692,15 @@
}
},
"typedoc-default-themes": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.11.1.tgz",
"integrity": "sha512-1yl8pbhjrLywqGJx9TfT+wzP+ntudPYjgJdpCj+s5ed2etBkqZPOCBMKwpaN9o6pdoFQF195PggqWTLVEkaRQQ==",
"dev": true,
"requires": {
"lunr": "^2.3.9"
}
"version": "0.11.4",
"resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.11.4.tgz",
"integrity": "sha512-Y4Lf+qIb9NTydrexlazAM46SSLrmrQRqWiD52593g53SsmUFioAsMWt8m834J6qsp+7wHRjxCXSZeiiW5cMUdw==",
"dev": true
},
"typescript": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz",
"integrity": "sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==",
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.3.tgz",
"integrity": "sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==",
"dev": true
},
"uglify-js": {

View File

@ -6,10 +6,10 @@ import defaultDatatokensABI from '@oceanprotocol/contracts/artifacts/DataTokenTe
import wordListDefault from '../data/words.json'
import { TransactionReceipt } from 'web3-core'
import { time } from 'console'
import BigNumber from 'bignumber.js'
/**
* Provides a interface to DataTokens
* Provides an interface to DataTokens
*/
export class DataTokens {
public factoryAddress: string

View File

@ -14,9 +14,9 @@ import DID from './DID'
import { SubscribablePromise, didZeroX } from '../utils'
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
import { WebServiceConnector } from './utils/WebServiceConnector'
import { DataTokens } from '../lib'
import BigNumber from 'bignumber.js'
import { Provider } from '../provider/Provider'
import { isAddress } from 'web3-utils'
export enum CreateProgressStep {
CreatingDataToken,
@ -70,6 +70,13 @@ export class Assets extends Instantiable {
symbol?: string,
customProviderURL?: string
): SubscribablePromise<CreateProgressStep, DDO> {
if (!isAddress(dtAddress)) {
this.logger.error(
`Passed Data Token address ${dtAddress} is not valid. Aborting publishing.`
)
return null
}
this.logger.log('Creating asset')
return new SubscribablePromise(async (observer) => {
if (services.length === 0) {
@ -81,6 +88,7 @@ export class Assets extends Instantiable {
const metadataStoreURI = this.ocean.metadatastore.getURI()
const jsonBlob = { t: 1, url: metadataStoreURI }
const { datatokens } = this.ocean
dtAddress = await datatokens.create(
JSON.stringify(jsonBlob),
publisher.getId(),
@ -88,7 +96,15 @@ export class Assets extends Instantiable {
name,
symbol
)
this.logger.log('DataToken creted')
if (!isAddress(dtAddress)) {
this.logger.error(
`Created Data Token address ${dtAddress} is not valid. Aborting publishing.`
)
return null
}
this.logger.log(`DataToken ${dtAddress} created`)
observer.next(CreateProgressStep.DataTokenCreated)
}

View File

@ -4,7 +4,7 @@ import { DataTokens } from '../../src/datatokens/Datatokens'
import { Ocean } from '../../src/ocean/Ocean'
import { ConfigHelper } from '../../src/utils/ConfigHelper'
import { assert } from 'console'
import { assert } from 'chai'
import { ServiceComputePrivacy } from '../../src/ddo/interfaces/Service'
import Web3 from 'web3'
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
@ -393,16 +393,16 @@ describe('Compute flow', () => {
assert(newDdo !== null)
await sleep(6000)
const metaData = await ocean.assets.getServiceByType(ddo.id, 'compute')
assert(
metaData.attributes.main.privacy.allowRawAlgorithm ===
assert.equal(
metaData.attributes.main.privacy.allowRawAlgorithm,
newComputePrivacy.allowRawAlgorithm
)
assert(
metaData.attributes.main.privacy.allowNetworkAccess ===
assert.equal(
metaData.attributes.main.privacy.allowNetworkAccess,
newComputePrivacy.allowNetworkAccess
)
assert(
metaData.attributes.main.privacy.trustedAlgorithms ===
assert.deepEqual(
metaData.attributes.main.privacy.trustedAlgorithms,
newComputePrivacy.trustedAlgorithms
)
})

View File

@ -1,12 +1,11 @@
import { AbiItem } from 'web3-utils/types'
import { assert, spy, use } from 'chai'
import spies from 'chai-spies'
import { TestContractHandler } from '../TestContractHandler'
import { DataTokens } from '../../src/datatokens/Datatokens'
import { Ocean } from '../../src/ocean/Ocean'
import { ConfigHelper } from '../../src/utils/ConfigHelper'
// import config from './config'
import { assert } from 'console'
import Web3 from 'web3'
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
@ -19,6 +18,8 @@ function sleep(ms) {
})
}
use(spies)
describe('Marketplace flow', () => {
let owner
let bob
@ -156,7 +157,7 @@ describe('Marketplace flow', () => {
it('Marketplace posts asset for sale', async () => {
accessService = await ocean.assets.getServiceByType(ddo.id, 'access')
price = 20
assert(accessService.attributes.main.cost * price === datatoken.toWei('200'))
assert.equal(accessService.attributes.main.cost * price, datatoken.toWei('200'))
})
it('Bob gets datatokens', async () => {
@ -197,10 +198,12 @@ describe('Marketplace flow', () => {
const balanceAfter = await datatoken.balance(tokenAddress, bob.getId())
assert(balanceBefore === balanceAfter)
})
it('owner can list there assets', async () => {
const assets = await ocean.assets.ownerAssets(alice.getId())
assert(assets.length > 0)
})
it('Alice updates metadata', async () => {
const newMetaData: EditableMetadata = {
description: 'new description',
@ -211,10 +214,42 @@ describe('Marketplace flow', () => {
assert(newDdo !== null)
await sleep(6000)
const metaData = await ocean.assets.getServiceByType(ddo.id, 'metadata')
assert(metaData.attributes.main.name === newMetaData.title)
assert(
metaData.attributes.additionalInformation.description === newMetaData.description
assert.equal(metaData.attributes.main.name, newMetaData.title)
assert.equal(
metaData.attributes.additionalInformation.description,
newMetaData.description
)
assert(metaData.attributes.additionalInformation.links === newMetaData.links)
assert.deepEqual(metaData.attributes.additionalInformation.links, newMetaData.links)
})
it('Alice publishes a dataset but passed data token is invalid', async () => {
price = datatoken.toWei('10') // in datatoken
const publishedDate = new Date(Date.now()).toISOString().split('.')[0] + 'Z'
const timeout = 0
service1 = await ocean.assets.createAccessServiceAttributes(
alice,
price,
publishedDate,
timeout
)
ddo = await ocean.assets.create(asset, alice, [service1], 'gibberishDataToken')
assert.equal(ddo, null)
})
it('Alice publishes a dataset but created data token is invalid', async () => {
price = datatoken.toWei('10') // in datatoken
const publishedDate = new Date(Date.now()).toISOString().split('.')[0] + 'Z'
const timeout = 0
service1 = await ocean.assets.createAccessServiceAttributes(
alice,
price,
publishedDate,
timeout
)
spy.on(datatoken, 'create', () => null)
ddo = await ocean.assets.create(asset, alice, [service1])
assert.equal(ddo, null)
})
})