From 230a3171330787e861c1bc5287aa173aceee8aef Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 11 Jan 2022 18:26:35 +0000 Subject: [PATCH 1/2] bump ocean.js to v1.0.0-next.2 --- package-lock.json | 274 ++++++++++++++++++++++++++++++++++++---------- package.json | 2 +- 2 files changed, 216 insertions(+), 60 deletions(-) diff --git a/package-lock.json b/package-lock.json index f13d3e5e4..402f8b899 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@coingecko/cryptoformat": "^0.4.4", "@loadable/component": "^5.15.2", "@oceanprotocol/art": "^3.2.0", - "@oceanprotocol/lib": "file:../ocean.js", + "@oceanprotocol/lib": "1.0.0-next.2", "@oceanprotocol/typographies": "^0.1.0", "@portis/web3": "^4.0.6", "@tippyjs/react": "^4.2.6", @@ -108,21 +108,16 @@ }, "../ocean.js": { "name": "@oceanprotocol/lib", - "version": "1.0.0-alpha", + "version": "1.0.0-next.2", + "extraneous": true, "license": "Apache-2.0", "dependencies": { - "@ethereum-navigator/navigator": "^0.5.3", - "@oceanprotocol/contracts": "github:oceanprotocol/contracts#v4main_postaudit", + "bignumber.js": "^9.0.2", "cross-fetch": "^3.1.4", "crypto-js": "^4.0.0", "decimal.js": "^10.2.1", - "ethereumjs-util": "^7.1.3", "fs": "0.0.1-security", - "lzma": "^2.3.2", - "node-abort-controller": "^2.0.0", "save-file": "^2.3.1", - "underscore": "^1.13.1", - "uuid": "^8.3.2", "web3": ">=1.3.5", "web3-core": "^1.6.1", "web3-eth-contract": "^1.6.1" @@ -145,13 +140,13 @@ "eslint-config-oceanprotocol": "^1.5.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", - "microbundle": "^0.14.0", + "microbundle": "^0.14.2", "mocha": "^9.1.2", "mock-local-storage": "^1.1.17", "nyc": "^15.1.0", "ora": "5.4.1", "prettier": "^2.3.1", - "release-it": "^14.10.0", + "release-it": "^14.12.1", "source-map-support": "^0.5.19", "ts-node": "^10.0.0", "ts-node-register": "^1.0.0", @@ -3913,8 +3908,23 @@ "integrity": "sha512-aUQtg4m5hJlQ0u8C29O9TXJWcAenO3G9vP+vf6LNFkpTDOCMycN/F0SzHS89VNrvGUha8oTDEg7FAkfZBPv2WA==" }, "node_modules/@oceanprotocol/lib": { - "resolved": "../ocean.js", - "link": true + "version": "1.0.0-next.2", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-1.0.0-next.2.tgz", + "integrity": "sha512-P6StKsEu3iCb/s/VVlz411ROSp5BykEYbPOPSzE9Z6JbAdvJ36e7QCSE3FFFexvwMSuG9QRCoLZHA5NZUa3WLw==", + "dependencies": { + "bignumber.js": "^9.0.2", + "cross-fetch": "^3.1.4", + "crypto-js": "^4.0.0", + "decimal.js": "^10.2.1", + "fs": "0.0.1-security", + "save-file": "^2.3.1", + "web3": ">=1.3.5", + "web3-core": "^1.6.1", + "web3-eth-contract": "^1.6.1" + }, + "peerDependencies": { + "web3": ">=1.3.5" + } }, "node_modules/@oceanprotocol/typographies": { "version": "0.1.0", @@ -8458,6 +8468,11 @@ "node": ">= 4.5.0" } }, + "node_modules/atob-lite": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/atob-lite/-/atob-lite-2.0.0.tgz", + "integrity": "sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=" + }, "node_modules/auto-bind": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/auto-bind/-/auto-bind-4.0.0.tgz", @@ -11034,7 +11049,6 @@ "version": "3.1.4", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz", "integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==", - "dev": true, "dependencies": { "node-fetch": "2.6.1" } @@ -11043,7 +11057,6 @@ "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", - "dev": true, "engines": { "node": "4.x || >=6.0.0" } @@ -11083,6 +11096,11 @@ "node": "*" } }, + "node_modules/crypto-js": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz", + "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==" + }, "node_modules/css-color-keywords": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz", @@ -11974,6 +11992,14 @@ "node": ">=4" } }, + "node_modules/dtype": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dtype/-/dtype-2.0.0.tgz", + "integrity": "sha1-zQUjI84GFETs0uj1dI9popvihDQ=", + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", @@ -14369,6 +14395,11 @@ "webpack": "^4.0.0 || ^5.0.0" } }, + "node_modules/file-saver": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz", + "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==" + }, "node_modules/file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -14545,6 +14576,14 @@ "integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==", "dev": true }, + "node_modules/flatten-vertex-data": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/flatten-vertex-data/-/flatten-vertex-data-1.0.2.tgz", + "integrity": "sha512-BvCBFK2NZqerFTdMDgqfHBwxYWnxeCkwONsw6PvBMcUXqo8U/KDWwmXhqx1x2kLIg7DqIsJfOaJFOmlua3Lxuw==", + "dependencies": { + "dtype": "^2.0.0" + } + }, "node_modules/flow-parser": { "version": "0.121.0", "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.121.0.tgz", @@ -14704,6 +14743,11 @@ "readable-stream": "^2.0.0" } }, + "node_modules/fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" + }, "node_modules/fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -16155,6 +16199,11 @@ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" }, + "node_modules/is-base64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-base64/-/is-base64-0.1.0.tgz", + "integrity": "sha512-WRRyllsGXJM7ZN7gPTCCQ/6wNPTRDwiWdPK66l5sJzcU/oOzcIcRRf0Rux8bkpox/1yjt0F6VJRsQOIG2qz5sg==" + }, "node_modules/is-bigint": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", @@ -16177,6 +16226,14 @@ "node": ">=8" } }, + "node_modules/is-blob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-blob/-/is-blob-1.0.0.tgz", + "integrity": "sha1-o9fZb+HD/wZex84nwsIea6ksGDI=", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-boolean-object": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", @@ -25022,6 +25079,19 @@ "which": "bin/which" } }, + "node_modules/save-file": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/save-file/-/save-file-2.3.1.tgz", + "integrity": "sha512-VOD2Ojb1/kuj0XbvSXzZ5xr4rRSZD8f+HzKWGztXNp93gBQDj3njFt9HMhmLtnwd7q0BjJkzLXqd8M2+PFS1qg==", + "dependencies": { + "file-saver": "^2.0.0-rc.4", + "is-blob": "^1.0.0", + "is-buffer": "^2.0.0", + "simple-mime": "^0.1.0", + "to-array-buffer": "^3.2.0", + "write": "^1.0.0" + } + }, "node_modules/sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", @@ -25526,6 +25596,14 @@ "simple-concat": "^1.0.0" } }, + "node_modules/simple-mime": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/simple-mime/-/simple-mime-0.1.0.tgz", + "integrity": "sha1-lfUXxPRm18/1YacfydqyWW6p7y4=", + "engines": [ + "node >= 0.2.0" + ] + }, "node_modules/simple-plist": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.3.0.tgz", @@ -26028,6 +26106,15 @@ "resolved": "https://registry.npmjs.org/string-hash/-/string-hash-1.1.3.tgz", "integrity": "sha1-6Kr8CsGFW0Zmkp7X3RJ1311sgRs=" }, + "node_modules/string-to-arraybuffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-to-arraybuffer/-/string-to-arraybuffer-1.0.2.tgz", + "integrity": "sha512-DaGZidzi93dwjQen5I2osxR9ERS/R7B1PFyufNMnzhj+fmlDQAc1DSDIJVJhgI8Oq221efIMbABUBdPHDRt43Q==", + "dependencies": { + "atob-lite": "^2.0.0", + "is-base64": "^0.1.0" + } + }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -27201,6 +27288,27 @@ "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", "peer": true }, + "node_modules/to-array-buffer": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/to-array-buffer/-/to-array-buffer-3.2.0.tgz", + "integrity": "sha512-zN33mwi0gpL+7xW1ITLfJ48CEj6ZQW0ZAP0MU+2W3kEY0PAIncyuxmD4OqkUVhPAbTP7amq9j/iwvZKYS+lzSQ==", + "dependencies": { + "flatten-vertex-data": "^1.0.2", + "is-blob": "^2.0.1", + "string-to-arraybuffer": "^1.0.0" + } + }, + "node_modules/to-array-buffer/node_modules/is-blob": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-blob/-/is-blob-2.1.0.tgz", + "integrity": "sha512-SZ/fTft5eUhQM6oF/ZaASFDEdbFVe89Imltn9uZr03wdKMcWNVYSMjQPFtg05QuNkt5l5c135ElvXEQG0rk4tw==", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/to-arraybuffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", @@ -29840,7 +29948,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", - "dev": true, "dependencies": { "mkdirp": "^0.5.1" }, @@ -29863,7 +29970,6 @@ "version": "0.5.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, "dependencies": { "minimist": "^1.2.5" }, @@ -32791,49 +32897,16 @@ "integrity": "sha512-aUQtg4m5hJlQ0u8C29O9TXJWcAenO3G9vP+vf6LNFkpTDOCMycN/F0SzHS89VNrvGUha8oTDEg7FAkfZBPv2WA==" }, "@oceanprotocol/lib": { - "version": "file:../ocean.js", + "version": "1.0.0-next.2", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-1.0.0-next.2.tgz", + "integrity": "sha512-P6StKsEu3iCb/s/VVlz411ROSp5BykEYbPOPSzE9Z6JbAdvJ36e7QCSE3FFFexvwMSuG9QRCoLZHA5NZUa3WLw==", "requires": { - "@ethereum-navigator/navigator": "^0.5.3", - "@oceanprotocol/contracts": "github:oceanprotocol/contracts#v4main_postaudit", - "@truffle/hdwallet-provider": "^1.5.1", - "@types/chai": "^4.2.19", - "@types/chai-spies": "^1.0.3", - "@types/crypto-js": "^4.0.1", - "@types/mocha": "^9.0.0", - "@types/node": "^16.10.3", - "@types/node-fetch": "^3.0.3", - "@typescript-eslint/eslint-plugin": "^4.33.0", - "@typescript-eslint/parser": "^4.33.0", - "auto-changelog": "^2.3.0", - "chai": "^4.3.4", - "chai-spies": "^1.0.0", - "cross-env": "^7.0.3", + "bignumber.js": "^9.0.2", "cross-fetch": "^3.1.4", "crypto-js": "^4.0.0", "decimal.js": "^10.2.1", - "eslint": "^7.17.0", - "eslint-config-oceanprotocol": "^1.5.0", - "eslint-config-prettier": "^8.3.0", - "eslint-plugin-prettier": "^4.0.0", - "ethereumjs-util": "^7.1.3", "fs": "0.0.1-security", - "lzma": "^2.3.2", - "microbundle": "^0.14.0", - "mocha": "^9.1.2", - "mock-local-storage": "^1.1.17", - "node-abort-controller": "^2.0.0", - "nyc": "^15.1.0", - "ora": "5.4.1", - "prettier": "^2.3.1", - "release-it": "^14.10.0", "save-file": "^2.3.1", - "source-map-support": "^0.5.19", - "ts-node": "^10.0.0", - "ts-node-register": "^1.0.0", - "typedoc": "0.22.5", - "typescript": "^4.3.4", - "underscore": "^1.13.1", - "uuid": "^8.3.2", "web3": ">=1.3.5", "web3-core": "^1.6.1", "web3-eth-contract": "^1.6.1" @@ -36689,6 +36762,11 @@ "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "peer": true }, + "atob-lite": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/atob-lite/-/atob-lite-2.0.0.tgz", + "integrity": "sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=" + }, "auto-bind": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/auto-bind/-/auto-bind-4.0.0.tgz", @@ -38830,7 +38908,6 @@ "version": "3.1.4", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz", "integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==", - "dev": true, "requires": { "node-fetch": "2.6.1" }, @@ -38838,8 +38915,7 @@ "node-fetch": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", - "dev": true + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" } } }, @@ -38872,6 +38948,11 @@ "randomfill": "^1.0.3" } }, + "crypto-js": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz", + "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==" + }, "css-color-keywords": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz", @@ -39542,6 +39623,11 @@ "integrity": "sha512-7xTQ5DzyE59Nn+7ZgXDXjKAGSGmXZHqttMVVz1r4QNfmGpyj+cm2YtI3II0c/+4zS4a9yq2mBhgdeq2QnpcYlw==", "dev": true }, + "dtype": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dtype/-/dtype-2.0.0.tgz", + "integrity": "sha1-zQUjI84GFETs0uj1dI9popvihDQ=" + }, "duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", @@ -41519,6 +41605,11 @@ "schema-utils": "^3.0.0" } }, + "file-saver": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz", + "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==" + }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -41654,6 +41745,14 @@ "integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==", "dev": true }, + "flatten-vertex-data": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/flatten-vertex-data/-/flatten-vertex-data-1.0.2.tgz", + "integrity": "sha512-BvCBFK2NZqerFTdMDgqfHBwxYWnxeCkwONsw6PvBMcUXqo8U/KDWwmXhqx1x2kLIg7DqIsJfOaJFOmlua3Lxuw==", + "requires": { + "dtype": "^2.0.0" + } + }, "flow-parser": { "version": "0.121.0", "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.121.0.tgz", @@ -41768,6 +41867,11 @@ "readable-stream": "^2.0.0" } }, + "fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" + }, "fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -42880,6 +42984,11 @@ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" }, + "is-base64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-base64/-/is-base64-0.1.0.tgz", + "integrity": "sha512-WRRyllsGXJM7ZN7gPTCCQ/6wNPTRDwiWdPK66l5sJzcU/oOzcIcRRf0Rux8bkpox/1yjt0F6VJRsQOIG2qz5sg==" + }, "is-bigint": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", @@ -42896,6 +43005,11 @@ "binary-extensions": "^2.0.0" } }, + "is-blob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-blob/-/is-blob-1.0.0.tgz", + "integrity": "sha1-o9fZb+HD/wZex84nwsIea6ksGDI=" + }, "is-boolean-object": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", @@ -49884,6 +49998,19 @@ } } }, + "save-file": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/save-file/-/save-file-2.3.1.tgz", + "integrity": "sha512-VOD2Ojb1/kuj0XbvSXzZ5xr4rRSZD8f+HzKWGztXNp93gBQDj3njFt9HMhmLtnwd7q0BjJkzLXqd8M2+PFS1qg==", + "requires": { + "file-saver": "^2.0.0-rc.4", + "is-blob": "^1.0.0", + "is-buffer": "^2.0.0", + "simple-mime": "^0.1.0", + "to-array-buffer": "^3.2.0", + "write": "^1.0.0" + } + }, "sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", @@ -50291,6 +50418,11 @@ "simple-concat": "^1.0.0" } }, + "simple-mime": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/simple-mime/-/simple-mime-0.1.0.tgz", + "integrity": "sha1-lfUXxPRm18/1YacfydqyWW6p7y4=" + }, "simple-plist": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.3.0.tgz", @@ -50726,6 +50858,15 @@ "resolved": "https://registry.npmjs.org/string-hash/-/string-hash-1.1.3.tgz", "integrity": "sha1-6Kr8CsGFW0Zmkp7X3RJ1311sgRs=" }, + "string-to-arraybuffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-to-arraybuffer/-/string-to-arraybuffer-1.0.2.tgz", + "integrity": "sha512-DaGZidzi93dwjQen5I2osxR9ERS/R7B1PFyufNMnzhj+fmlDQAc1DSDIJVJhgI8Oq221efIMbABUBdPHDRt43Q==", + "requires": { + "atob-lite": "^2.0.0", + "is-base64": "^0.1.0" + } + }, "string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -51638,6 +51779,23 @@ "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", "peer": true }, + "to-array-buffer": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/to-array-buffer/-/to-array-buffer-3.2.0.tgz", + "integrity": "sha512-zN33mwi0gpL+7xW1ITLfJ48CEj6ZQW0ZAP0MU+2W3kEY0PAIncyuxmD4OqkUVhPAbTP7amq9j/iwvZKYS+lzSQ==", + "requires": { + "flatten-vertex-data": "^1.0.2", + "is-blob": "^2.0.1", + "string-to-arraybuffer": "^1.0.0" + }, + "dependencies": { + "is-blob": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-blob/-/is-blob-2.1.0.tgz", + "integrity": "sha512-SZ/fTft5eUhQM6oF/ZaASFDEdbFVe89Imltn9uZr03wdKMcWNVYSMjQPFtg05QuNkt5l5c135ElvXEQG0rk4tw==" + } + } + }, "to-arraybuffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", @@ -53808,7 +53966,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", - "dev": true, "requires": { "mkdirp": "^0.5.1" }, @@ -53817,7 +53974,6 @@ "version": "0.5.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, "requires": { "minimist": "^1.2.5" } diff --git a/package.json b/package.json index 67f630c06..ff21f54e8 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@coingecko/cryptoformat": "^0.4.4", "@loadable/component": "^5.15.2", "@oceanprotocol/art": "^3.2.0", - "@oceanprotocol/lib": "file:../ocean.js", + "@oceanprotocol/lib": "1.0.0-next.2", "@oceanprotocol/typographies": "^0.1.0", "@portis/web3": "^4.0.6", "@tippyjs/react": "^4.2.6", From b5b0297ae4e6fd21bbea922ac663156434f92e6e Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 11 Jan 2022 19:05:07 +0000 Subject: [PATCH 2/2] refactor for new ocean.js, make the build work --- src/@context/Asset.tsx | 14 +- src/@context/Web3.tsx | 6 +- src/@hooks/useNetworkMetadata/constants.ts | 1 - src/@types/Compute.d.ts | 2 +- src/@utils/purgatory.ts | 8 +- src/components/@shared/ExplorerLink/index.tsx | 8 +- .../@shared/TokenApproval/index.tsx | 31 ++-- .../Compute/FormComputeDataset.tsx | 11 +- .../Asset/AssetActions/Compute/index.tsx | 32 ++-- .../Asset/AssetActions/Pool/Actions.tsx | 6 +- .../Asset/AssetActions/Pool/Add/FormAdd.tsx | 66 +++---- .../Asset/AssetActions/Pool/Add/index.tsx | 71 ++++---- .../Asset/AssetActions/Pool/Remove.tsx | 83 +++++---- .../Asset/AssetActions/Pool/utils.ts | 43 +++-- .../Asset/AssetActions/Trade/FormTrade.tsx | 44 +++-- .../Asset/AssetActions/Trade/Output.tsx | 20 +-- .../Asset/AssetActions/Trade/Swap.tsx | 167 +++++++++--------- .../Asset/AssetActions/Trade/TradeInput.tsx | 5 +- .../Asset/AssetActions/Trade/index.tsx | 61 +++---- src/components/Asset/AssetActions/index.tsx | 19 +- .../Asset/Edit/DebugEditCompute.tsx | 25 +-- .../Asset/Edit/EditComputeDataset.tsx | 6 +- src/components/Asset/Edit/FormActions.tsx | 6 +- .../Asset/Edit/FormEditComputeDataset.tsx | 2 +- src/components/Asset/Edit/_constants.ts | 4 +- src/components/Asset/Edit/_types.ts | 4 +- src/components/Asset/Edit/index.tsx | 20 +-- .../Profile/History/ComputeJobs/Details.tsx | 4 +- .../Profile/History/ComputeJobs/Results.tsx | 36 ++-- .../Profile/History/ComputeJobs/index.tsx | 30 ++-- 30 files changed, 387 insertions(+), 448 deletions(-) diff --git a/src/@context/Asset.tsx b/src/@context/Asset.tsx index 68deea2b7..18f694660 100644 --- a/src/@context/Asset.tsx +++ b/src/@context/Asset.tsx @@ -7,7 +7,7 @@ import React, { useCallback, ReactNode } from 'react' -import { LoggerInstance } from '@oceanprotocol/lib' +import { LoggerInstance, Purgatory } from '@oceanprotocol/lib' import getAssetPurgatoryData from '@utils/purgatory' import { CancelToken } from 'axios' import { retrieveDDO } from '@utils/aquarius' @@ -18,7 +18,7 @@ import { useCancelToken } from '@hooks/useCancelToken' interface AssetProviderValue { isInPurgatory: boolean - purgatoryData: PurgatoryData + purgatoryData: Purgatory ddo: Asset title: string owner: string @@ -30,12 +30,6 @@ interface AssetProviderValue { refreshDdo: (token?: CancelToken) => Promise } -// temp, just to get rid of the error -export interface PurgatoryData { - did: string - reason: string -} - const AssetContext = createContext({} as AssetProviderValue) const refreshInterval = 10000 // 10 sec. @@ -51,7 +45,7 @@ function AssetProvider({ const { networkId } = useWeb3() const [isInPurgatory, setIsInPurgatory] = useState(false) - const [purgatoryData, setPurgatoryData] = useState() + const [purgatoryData, setPurgatoryData] = useState() const [ddo, setDDO] = useState() const [did, setDID] = useState() const [title, setTitle] = useState() @@ -92,7 +86,7 @@ function AssetProvider({ try { const result = await getAssetPurgatoryData(did) - const isInPurgatory = result?.did !== undefined + const isInPurgatory = result?.state === true setIsInPurgatory(isInPurgatory) isInPurgatory && setPurgatoryData(result) } catch (error) { diff --git a/src/@context/Web3.tsx b/src/@context/Web3.tsx index 45be584a1..e1d432315 100644 --- a/src/@context/Web3.tsx +++ b/src/@context/Web3.tsx @@ -261,9 +261,9 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement { setNetworkDisplayName(networkDisplayName) // Figure out if we're on a chain's testnet, or not - setIsTestnet( - networkData?.network !== 'mainnet' && networkData.network !== 'moonriver' - ) + // setIsTestnet( + // networkData?.network !== 'mainnet' && networkData.network !== 'moonriver' + // ) LoggerInstance.log( `[web3] Network display name set to: ${networkDisplayName}` diff --git a/src/@hooks/useNetworkMetadata/constants.ts b/src/@hooks/useNetworkMetadata/constants.ts index 02b663fc0..db6a0b8f6 100644 --- a/src/@hooks/useNetworkMetadata/constants.ts +++ b/src/@hooks/useNetworkMetadata/constants.ts @@ -7,7 +7,6 @@ export const networkDataGaiaX: EthereumListsChain = { chainId: 2021000, shortName: 'GAIA-X', chain: 'GAIA-X', - network: 'testnet', networkId: 2021000, nativeCurrency: { name: 'Gaia-X', symbol: 'GX', decimals: 18 }, rpc: [configGaiaX.nodeUri], diff --git a/src/@types/Compute.d.ts b/src/@types/Compute.d.ts index 80110bec7..93df8670f 100644 --- a/src/@types/Compute.d.ts +++ b/src/@types/Compute.d.ts @@ -1,4 +1,4 @@ -import { ComputeJob } from '@oceanprotocol/lib/dist/node/ocean/interfaces/Compute' +import { ComputeJob } from '@oceanprotocol/lib' import { OrdersData_tokenOrders_datatokenId as OrdersDatatoken } from './apollo/OrdersData' // declaring into global scope to be able to use this as diff --git a/src/@utils/purgatory.ts b/src/@utils/purgatory.ts index ae4a5fe68..c54ace6fb 100644 --- a/src/@utils/purgatory.ts +++ b/src/@utils/purgatory.ts @@ -1,4 +1,4 @@ -import { PurgatoryData as PurgatoryDataAsset } from '@oceanprotocol/lib' +import { Purgatory } from '@oceanprotocol/lib' import { fetchData } from './fetch' const purgatoryUrl = 'https://market-purgatory.oceanprotocol.com/api/' @@ -10,12 +10,12 @@ export interface PurgatoryDataAccount { export default async function getAssetPurgatoryData( did: string -): Promise { +): Promise { const data = (await fetchData( `${purgatoryUrl}asset?did=${did}` - )) as PurgatoryDataAsset[] + )) as Purgatory[] - return { did: data[0]?.did, reason: data[0]?.reason } + return { state: data[0]?.state, reason: data[0]?.reason } } export async function getAccountPurgatoryData( diff --git a/src/components/@shared/ExplorerLink/index.tsx b/src/components/@shared/ExplorerLink/index.tsx index 8baf1321c..5852485f9 100644 --- a/src/components/@shared/ExplorerLink/index.tsx +++ b/src/components/@shared/ExplorerLink/index.tsx @@ -1,7 +1,7 @@ import React, { ReactElement, ReactNode, useEffect, useState } from 'react' import External from '@images/external.svg' import classNames from 'classnames/bind' -import { ConfigHelperConfig } from '@oceanprotocol/lib' +import { Config } from '@oceanprotocol/lib' import { useOcean } from '@context/Ocean' import styles from './index.module.css' import { getOceanConfig } from '@utils/ocean' @@ -19,9 +19,9 @@ export default function ExplorerLink({ children: ReactNode className?: string }): ReactElement { - const { config, ocean } = useOcean() + const { config } = useOcean() const [url, setUrl] = useState() - const [oceanConfig, setOceanConfig] = useState() + const [oceanConfig, setOceanConfig] = useState() const styleClasses = cx({ link: true, [className]: className @@ -38,7 +38,7 @@ export default function ExplorerLink({ if (oceanConfig === undefined) { initOcean() } - }, [config, oceanConfig, networkId, ocean]) + }, [config, oceanConfig, networkId]) return ( { - if (!ocean || !tokenAddress || !spender || !isAssetNetwork || !amount) - return - - const allowance = await ocean.datatokens.allowance( - tokenAddress, - accountId, - spender - ) - - amount && - new Decimal(amount).greaterThan(new Decimal('0')) && - setTokenApproved( - new Decimal(allowance).greaterThanOrEqualTo(new Decimal(amount)) - ) - }, [ocean, tokenAddress, spender, accountId, amount, isAssetNetwork]) + // if (!tokenAddress || !spender || !isAssetNetwork || !amount) return + // const allowance = await ocean.datatokens.allowance( + // tokenAddress, + // accountId, + // spender + // ) + // amount && + // new Decimal(amount).greaterThan(new Decimal('0')) && + // setTokenApproved( + // new Decimal(allowance).greaterThanOrEqualTo(new Decimal(amount)) + // ) + }, [tokenAddress, spender, accountId, amount, isAssetNetwork]) useEffect(() => { checkTokenApproval() @@ -56,7 +51,7 @@ export default function TokenApproval({ setLoading(true) try { - await ocean.datatokens.approve(tokenAddress, spender, amount, accountId) + // await ocean.datatokens.approve(tokenAddress, spender, amount, accountId) } catch (error) { setLoading(false) } diff --git a/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx b/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx index fa03c013d..c1ce14849 100644 --- a/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx +++ b/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx @@ -66,7 +66,6 @@ export default function FormStartCompute({ const [totalPrice, setTotalPrice] = useState(price?.value) const [isBalanceSufficient, setIsBalanceSufficient] = useState(false) const { accountId, balance } = useWeb3() - const { ocean } = useOcean() const [algorithmConsumableStatus, setAlgorithmConsumableStatus] = useState() @@ -85,11 +84,11 @@ export default function FormStartCompute({ if (!accountId || !isConsumable) return async function checkIsConsumable() { - const consumable = await ocean.assets.isConsumable( - algorithmDDO as any, - accountId.toLowerCase() - ) - if (consumable) setAlgorithmConsumableStatus(consumable.status) + // const consumable = await ocean.assets.isConsumable( + // algorithmDDO as any, + // accountId.toLowerCase() + // ) + // if (consumable) setAlgorithmConsumableStatus(consumable.status) } checkIsConsumable() }, [values.algorithm, accountId, isConsumable]) diff --git a/src/components/Asset/AssetActions/Compute/index.tsx b/src/components/Asset/AssetActions/Compute/index.tsx index aabcf9528..9efcc5161 100644 --- a/src/components/Asset/AssetActions/Compute/index.tsx +++ b/src/components/Asset/AssetActions/Compute/index.tsx @@ -1,5 +1,9 @@ import React, { useState, ReactElement, useEffect, useCallback } from 'react' -import { LoggerInstance } from '@oceanprotocol/lib' +import { + LoggerInstance, + ComputeAlgorithm, + ComputeOutput +} from '@oceanprotocol/lib' import { toast } from 'react-toastify' import Price from '@shared/Price' import FileIcon from '@shared/FileIcon' @@ -17,10 +21,6 @@ import { } from '@utils/aquarius' import { Formik } from 'formik' import { getInitialValues, validationSchema } from './_constants' -import { - ComputeAlgorithm, - ComputeOutput -} from '@oceanprotocol/lib/dist/node/ocean/interfaces/Compute' import axios from 'axios' import FormStartComputeDataset from './FormComputeDataset' import styles from './index.module.css' @@ -55,7 +55,6 @@ export default function Compute({ }): ReactElement { const { appConfig } = useSiteMetadata() const { accountId } = useWeb3() - const { ocean } = useOcean() const { buyDT, pricingError, pricingStepText } = usePricing() const [isJobStarting, setIsJobStarting] = useState(false) const [error, setError] = useState() @@ -83,7 +82,6 @@ export default function Compute({ const isComputeButtonDisabled = isJobStarting === true || file === null || - !ocean || (!hasPreviousDatasetOrder && !hasDatatoken && !isConsumablePrice) || (!hasPreviousAlgorithmOrder && !hasAlgoAssetDatatoken && @@ -111,12 +109,12 @@ export default function Compute({ } async function checkAssetDTBalance(asset: DDO) { - const AssetDtBalance = await ocean.datatokens.balance( - asset.services[0].datatokenAddress, - accountId - ) - setalgorithmDTBalance(AssetDtBalance) - setHasAlgoAssetDatatoken(Number(AssetDtBalance) >= 1) + // const AssetDtBalance = await ocean.datatokens.balance( + // asset.services[0].datatokenAddress, + // accountId + // ) + // setalgorithmDTBalance(AssetDtBalance) + // setHasAlgoAssetDatatoken(Number(AssetDtBalance) >= 1) } function getQuerryString( @@ -204,9 +202,9 @@ export default function Compute({ }, [ddo]) useEffect(() => { - if (!ocean || !accountId) return + if (!accountId) return checkPreviousOrders(ddo) - }, [ocean, ddo, accountId]) + }, [ddo, accountId]) useEffect(() => { if (!selectedAlgorithmAsset) return @@ -231,8 +229,8 @@ export default function Compute({ checkPreviousOrders(selectedAlgorithmAsset) } } - ocean && checkAssetDTBalance(selectedAlgorithmAsset) - }, [ddo, selectedAlgorithmAsset, ocean, accountId, hasPreviousAlgorithmOrder]) + // ocean && checkAssetDTBalance(selectedAlgorithmAsset) + }, [ddo, selectedAlgorithmAsset, accountId, hasPreviousAlgorithmOrder]) // Output errors in toast UI useEffect(() => { diff --git a/src/components/Asset/AssetActions/Pool/Actions.tsx b/src/components/Asset/AssetActions/Pool/Actions.tsx index 700dbbf27..50c8b549b 100644 --- a/src/components/Asset/AssetActions/Pool/Actions.tsx +++ b/src/components/Asset/AssetActions/Pool/Actions.tsx @@ -4,7 +4,6 @@ import Button from '@shared/atoms/Button' import styles from './Actions.module.css' import ExplorerLink from '@shared/ExplorerLink' import SuccessConfetti from '@shared/SuccessConfetti' -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import TokenApproval from '@shared/TokenApproval' @@ -30,14 +29,13 @@ export default function Actions({ isDisabled?: boolean }): ReactElement { const { networkId } = useWeb3() - const { ocean } = useOcean() const actionButton = ( @@ -53,7 +51,7 @@ export default function Actions({ actionButton={actionButton} amount={amount} coin={coin} - disabled={!ocean || isDisabled} + disabled={isDisabled} /> ) : ( actionButton diff --git a/src/components/Asset/AssetActions/Pool/Add/FormAdd.tsx b/src/components/Asset/AssetActions/Pool/Add/FormAdd.tsx index 550b628d2..a6fa4df35 100644 --- a/src/components/Asset/AssetActions/Pool/Add/FormAdd.tsx +++ b/src/components/Asset/AssetActions/Pool/Add/FormAdd.tsx @@ -11,7 +11,6 @@ import Button from '@shared/atoms/Button' import CoinSelect from '../CoinSelect' import { FormAddLiquidity } from '.' import UserLiquidity from '../../UserLiquidity' -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import { isValidNumber } from '@utils/numbers' @@ -43,8 +42,7 @@ export default function FormAdd({ setNewPoolTokens: (value: string) => void setNewPoolShare: (value: string) => void }): ReactElement { - const { balance } = useWeb3() - const { ocean } = useOcean() + const { balance, web3 } = useWeb3() const { isAssetNetwork } = useAsset() // Connect with form @@ -69,36 +67,31 @@ export default function FormAdd({ useEffect(() => { async function calculatePoolShares() { - if (!ocean) return - const tokenInAddress = - coin === 'OCEAN' ? ocean.pool.oceanAddress : ocean.pool.dtAddress - if (!values.amount || !tokenInAddress) { - setNewPoolTokens('0') - setNewPoolShare('0') - return - } - - if (Number(values.amount) > Number(amountMax)) return - - const poolTokens = await ocean.pool.calcPoolOutGivenSingleIn( - poolAddress, - tokenInAddress, - `${values.amount}` - ) - - setNewPoolTokens(poolTokens) - - const newPoolShareDecimal = - isValidNumber(poolTokens) && isValidNumber(totalPoolTokens) - ? new Decimal(poolTokens) - .dividedBy( - new Decimal(totalPoolTokens).plus(new Decimal(poolTokens)) - ) - .mul(100) - .toString() - : '0' - - totalBalance && setNewPoolShare(newPoolShareDecimal) + // if (!web3) return + // const tokenInAddress = + // coin === 'OCEAN' ? ocean.pool.oceanAddress : ocean.pool.dtAddress + // if (!values.amount || !tokenInAddress) { + // setNewPoolTokens('0') + // setNewPoolShare('0') + // return + // } + // if (Number(values.amount) > Number(amountMax)) return + // const poolTokens = await ocean.pool.calcPoolOutGivenSingleIn( + // poolAddress, + // tokenInAddress, + // `${values.amount}` + // ) + // setNewPoolTokens(poolTokens) + // const newPoolShareDecimal = + // isValidNumber(poolTokens) && isValidNumber(totalPoolTokens) + // ? new Decimal(poolTokens) + // .dividedBy( + // new Decimal(totalPoolTokens).plus(new Decimal(poolTokens)) + // ) + // .mul(100) + // .toString() + // : '0' + // totalBalance && setNewPoolShare(newPoolShareDecimal) } calculatePoolShares() }, [ @@ -108,7 +101,6 @@ export default function FormAdd({ amountMax, coin, poolAddress, - ocean?.pool, setNewPoolTokens, setNewPoolShare ]) @@ -144,14 +136,14 @@ export default function FormAdd({ } placeholder="0" field={field} form={form} onChange={handleFieldChange} - disabled={!ocean || !isAssetNetwork} + disabled={!isAssetNetwork} /> )} @@ -161,7 +153,7 @@ export default function FormAdd({ className={styles.buttonMax} style="text" size="small" - disabled={!ocean} + disabled={!web3} onClick={() => { setAmount(amountMax) setFieldValue('amount', amountMax) diff --git a/src/components/Asset/AssetActions/Pool/Add/index.tsx b/src/components/Asset/AssetActions/Pool/Add/index.tsx index 275cfa99b..e54eccad2 100644 --- a/src/components/Asset/AssetActions/Pool/Add/index.tsx +++ b/src/components/Asset/AssetActions/Pool/Add/index.tsx @@ -10,7 +10,6 @@ import Alert from '@shared/atoms/Alert' import { useUserPreferences } from '@context/UserPreferences' import Output from './Output' import DebugOutput from '@shared/DebugOutput' -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import { useAsset } from '@context/Asset' import content from '../../../../../../content/price.json' @@ -43,7 +42,6 @@ export default function Add({ dtAddress: string }): ReactElement { const { accountId, balance } = useWeb3() - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const { debug } = useUserPreferences() const [txId, setTxId] = useState() @@ -69,53 +67,50 @@ export default function Add({ // Get datatoken balance when datatoken selected useEffect(() => { - if (!ocean || !isAssetNetwork || coin === 'OCEAN') return - - async function getDtBalance() { - const dtBalance = await ocean.datatokens.balance(dtAddress, accountId) - setDtBalance(dtBalance) - } - getDtBalance() - }, [ocean, accountId, dtAddress, coin]) + // if (!accountId || !isAssetNetwork || coin === 'OCEAN') return + // async function getDtBalance() { + // const dtBalance = await ocean.datatokens.balance(dtAddress, accountId) + // setDtBalance(dtBalance) + // } + // getDtBalance() + }, [accountId, dtAddress, coin]) // Get maximum amount for either OCEAN or datatoken useEffect(() => { - if (!ocean || !isAssetNetwork || !poolAddress) return + if (!accountId || !isAssetNetwork || !poolAddress) return async function getMaximum() { - const amountMaxPool = - coin === 'OCEAN' - ? await ocean.pool.getOceanMaxAddLiquidity(poolAddress) - : await ocean.pool.getDTMaxAddLiquidity(poolAddress) - - const amountMax = - coin === 'OCEAN' - ? Number(balance.ocean) > Number(amountMaxPool) - ? amountMaxPool - : balance.ocean - : Number(dtBalance) > Number(amountMaxPool) - ? amountMaxPool - : dtBalance - setAmountMax(Number(amountMax).toFixed(3)) + // const amountMaxPool = + // coin === 'OCEAN' + // ? await ocean.pool.getOceanMaxAddLiquidity(poolAddress) + // : await ocean.pool.getDTMaxAddLiquidity(poolAddress) + // const amountMax = + // coin === 'OCEAN' + // ? Number(balance.ocean) > Number(amountMaxPool) + // ? amountMaxPool + // : balance.ocean + // : Number(dtBalance) > Number(amountMaxPool) + // ? amountMaxPool + // : dtBalance + // setAmountMax(Number(amountMax).toFixed(3)) } getMaximum() - }, [ocean, poolAddress, coin, dtBalance, balance.ocean]) + }, [accountId, isAssetNetwork, poolAddress, coin, dtBalance, balance.ocean]) // Submit async function handleAddLiquidity(amount: number, resetForm: () => void) { try { - const result = - coin === 'OCEAN' - ? await ocean.pool.addOceanLiquidity( - accountId, - poolAddress, - `${amount}` - ) - : await ocean.pool.addDTLiquidity(accountId, poolAddress, `${amount}`) - - setTxId(result?.transactionHash) - resetForm() - refreshInfo() + // const result = + // coin === 'OCEAN' + // ? await ocean.pool.addOceanLiquidity( + // accountId, + // poolAddress, + // `${amount}` + // ) + // : await ocean.pool.addDTLiquidity(accountId, poolAddress, `${amount}`) + // setTxId(result?.transactionHash) + // resetForm() + // refreshInfo() } catch (error) { console.error(error.message) toast.error(error.message) diff --git a/src/components/Asset/AssetActions/Pool/Remove.tsx b/src/components/Asset/AssetActions/Pool/Remove.tsx index ac42d66ea..1c7fb0d2c 100644 --- a/src/components/Asset/AssetActions/Pool/Remove.tsx +++ b/src/components/Asset/AssetActions/Pool/Remove.tsx @@ -41,7 +41,6 @@ export default function Remove({ }): ReactElement { const slippagePresets = ['5', '10', '15', '25', '50'] const { accountId } = useWeb3() - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const [amountPercent, setAmountPercent] = useState('0') const [amountMaxPercent, setAmountMaxPercent] = useState('100') @@ -60,24 +59,23 @@ export default function Remove({ async function handleRemoveLiquidity() { setIsLoading(true) try { - const result = - isAdvanced === true - ? await ocean.pool.removePoolLiquidity( - accountId, - poolAddress, - amountPoolShares, - minDatatokenAmount, - minOceanAmount - ) - : await ocean.pool.removeOceanLiquidityWithMinimum( - accountId, - poolAddress, - amountPoolShares, - minOceanAmount - ) - - setTxId(result?.transactionHash) - refreshInfo() + // const result = + // isAdvanced === true + // ? await ocean.pool.removePoolLiquidity( + // accountId, + // poolAddress, + // amountPoolShares, + // minDatatokenAmount, + // minOceanAmount + // ) + // : await ocean.pool.removeOceanLiquidityWithMinimum( + // accountId, + // poolAddress, + // amountPoolShares, + // minOceanAmount + // ) + // setTxId(result?.transactionHash) + // refreshInfo() } catch (error) { LoggerInstance.error(error.message) toast.error(error.message) @@ -88,45 +86,44 @@ export default function Remove({ // Get and set max percentage useEffect(() => { - if (!ocean || !poolTokens) return + if (!accountId || !poolTokens) return async function getMax() { - const amountMaxPercent = - isAdvanced === true - ? '100' - : await getMaxPercentRemove(ocean, poolAddress, poolTokens) - setAmountMaxPercent(amountMaxPercent) + // const amountMaxPercent = + // isAdvanced === true + // ? '100' + // : await getMaxPercentRemove(poolAddress, poolTokens) + // setAmountMaxPercent(amountMaxPercent) } getMax() - }, [ocean, isAdvanced, poolAddress, poolTokens]) + }, [accountId, isAdvanced, poolAddress, poolTokens]) const getValues = useRef( debounce(async (newAmountPoolShares, isAdvanced) => { - if (isAdvanced === true) { - const tokens = await ocean.pool.getTokensRemovedforPoolShares( - poolAddress, - `${newAmountPoolShares}` - ) - setAmountOcean(tokens?.oceanAmount) - setAmountDatatoken(tokens?.dtAmount) - return - } - - const amountOcean = await ocean.pool.getOceanRemovedforPoolShares( - poolAddress, - newAmountPoolShares - ) - setAmountOcean(amountOcean) + // if (isAdvanced === true) { + // const tokens = await ocean.pool.getTokensRemovedforPoolShares( + // poolAddress, + // `${newAmountPoolShares}` + // ) + // setAmountOcean(tokens?.oceanAmount) + // setAmountDatatoken(tokens?.dtAmount) + // return + // } + // const amountOcean = await ocean.pool.getOceanRemovedforPoolShares( + // poolAddress, + // newAmountPoolShares + // ) + // setAmountOcean(amountOcean) }, 150) ) // Check and set outputs when amountPoolShares changes useEffect(() => { - if (!ocean || !poolTokens) return + if (!accountId || !poolTokens) return getValues.current(amountPoolShares, isAdvanced) }, [ amountPoolShares, isAdvanced, - ocean, + accountId, poolTokens, poolAddress, totalPoolTokens diff --git a/src/components/Asset/AssetActions/Pool/utils.ts b/src/components/Asset/AssetActions/Pool/utils.ts index 2d9ed813b..e3fe55d77 100644 --- a/src/components/Asset/AssetActions/Pool/utils.ts +++ b/src/components/Asset/AssetActions/Pool/utils.ts @@ -1,36 +1,35 @@ -import { Ocean } from '@oceanprotocol/lib' import { isValidNumber } from '@utils/numbers' import Decimal from 'decimal.js' Decimal.set({ toExpNeg: -18, precision: 18, rounding: 1 }) export async function getMaxPercentRemove( - ocean: Ocean, poolAddress: string, poolTokens: string ): Promise { - const amountMaxOcean = await ocean.pool.getOceanMaxRemoveLiquidity( - poolAddress - ) + // const amountMaxOcean = await ocean.pool.getOceanMaxRemoveLiquidity( + // poolAddress + // ) - const amountMaxPoolShares = - await ocean.pool.getPoolSharesRequiredToRemoveOcean( - poolAddress, - amountMaxOcean - ) + // const amountMaxPoolShares = + // await ocean.pool.getPoolSharesRequiredToRemoveOcean( + // poolAddress, + // amountMaxOcean + // ) - let amountMaxPercent = - isValidNumber(amountMaxPoolShares) && isValidNumber(poolTokens) - ? new Decimal(amountMaxPoolShares) - .dividedBy(new Decimal(poolTokens)) - .mul(100) - .floor() - .toString() - : '0' + // let amountMaxPercent = + // isValidNumber(amountMaxPoolShares) && isValidNumber(poolTokens) + // ? new Decimal(amountMaxPoolShares) + // .dividedBy(new Decimal(poolTokens)) + // .mul(100) + // .floor() + // .toString() + // : '0' - if (Number(amountMaxPercent) > 100) { - amountMaxPercent = '100' - } + // if (Number(amountMaxPercent) > 100) { + // amountMaxPercent = '100' + // } - return amountMaxPercent + // return amountMaxPercent + return '0' } diff --git a/src/components/Asset/AssetActions/Trade/FormTrade.tsx b/src/components/Asset/AssetActions/Trade/FormTrade.tsx index 0f23d71e8..127fc6e38 100644 --- a/src/components/Asset/AssetActions/Trade/FormTrade.tsx +++ b/src/components/Asset/AssetActions/Trade/FormTrade.tsx @@ -9,7 +9,6 @@ import Swap from './Swap' import Alert from '@shared/atoms/Alert' import styles from './FormTrade.module.css' import Decimal from 'decimal.js' -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import { useAsset } from '@context/Asset' import { FormTradeData } from './_types' @@ -30,7 +29,6 @@ export default function FormTrade({ price: BestPrice }): ReactElement { const { accountId } = useWeb3() - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const { debug } = useUserPreferences() const [txId, setTxId] = useState() @@ -69,27 +67,27 @@ export default function FormTrade({ new Decimal(100).sub(new Decimal(values.slippage)) ).div(100) const precision = 15 - const tx = - values.type === 'buy' - ? await ocean.pool.buyDTWithExactOcean( - accountId, - price.address, - new Decimal(values.datatoken) - .mul(impact) - .toFixed(precision) - .toString(), - new Decimal(values.ocean).toFixed(precision).toString() - ) - : await ocean.pool.sellDT( - accountId, - price.address, - new Decimal(values.datatoken).toFixed(precision).toString(), - new Decimal(values.ocean) - .mul(impact) - .toFixed(precision) - .toString() - ) - setTxId(tx?.transactionHash) + // const tx = + // values.type === 'buy' + // ? await ocean.pool.buyDTWithExactOcean( + // accountId, + // price.address, + // new Decimal(values.datatoken) + // .mul(impact) + // .toFixed(precision) + // .toString(), + // new Decimal(values.ocean).toFixed(precision).toString() + // ) + // : await ocean.pool.sellDT( + // accountId, + // price.address, + // new Decimal(values.datatoken).toFixed(precision).toString(), + // new Decimal(values.ocean) + // .mul(impact) + // .toFixed(precision) + // .toString() + // ) + // setTxId(tx?.transactionHash) } catch (error) { LoggerInstance.error(error.message) toast.error(error.message) diff --git a/src/components/Asset/AssetActions/Trade/Output.tsx b/src/components/Asset/AssetActions/Trade/Output.tsx index 6d1a4dee5..006c3d8a2 100644 --- a/src/components/Asset/AssetActions/Trade/Output.tsx +++ b/src/components/Asset/AssetActions/Trade/Output.tsx @@ -1,7 +1,6 @@ import { FormikContextType, useFormikContext } from 'formik' import React, { ReactElement, useEffect, useState } from 'react' import { useAsset } from '@context/Asset' -import { useOcean } from '@context/Ocean' import Token from '../Pool/Token' import styles from './Output.module.css' @@ -21,7 +20,6 @@ export default function Output({ poolAddress: string }): ReactElement { const { isAssetNetwork } = useAsset() - const { ocean } = useOcean() const [maxOutput, setMaxOutput] = useState() const [swapFee, setSwapFee] = useState() const [swapFeeValue, setSwapFeeValue] = useState() @@ -30,15 +28,15 @@ export default function Output({ // Get swap fee useEffect(() => { - if (!ocean || !poolAddress || !isAssetNetwork) return + if (!poolAddress || !isAssetNetwork) return async function getSwapFee() { - const swapFee = await ocean.pool.getSwapFee(poolAddress) + // const swapFee = await ocean.pool.getSwapFee(poolAddress) - // swapFee is tricky: to get 0.1% you need to convert from 0.001 - setSwapFee( - isValidNumber(swapFee) ? new Decimal(swapFee).mul(100).toString() : '0' - ) + // // swapFee is tricky: to get 0.1% you need to convert from 0.001 + // setSwapFee( + // isValidNumber(swapFee) ? new Decimal(swapFee).mul(100).toString() : '0' + // ) const value = values.type === 'buy' @@ -51,11 +49,11 @@ export default function Output({ setSwapFeeValue(value.toString()) } getSwapFee() - }, [ocean, poolAddress, values, isAssetNetwork]) + }, [poolAddress, values, isAssetNetwork]) // Get output values useEffect(() => { - if (!ocean || !poolAddress || !isAssetNetwork) return + if (!poolAddress || !isAssetNetwork) return async function getOutput() { // Minimum received @@ -75,7 +73,7 @@ export default function Output({ setMaxOutput(maxPrice) } getOutput() - }, [ocean, poolAddress, values, isAssetNetwork]) + }, [poolAddress, values, isAssetNetwork]) return (
diff --git a/src/components/Asset/AssetActions/Trade/Swap.tsx b/src/components/Asset/AssetActions/Trade/Swap.tsx index a28f44927..221123df5 100644 --- a/src/components/Asset/AssetActions/Trade/Swap.tsx +++ b/src/components/Asset/AssetActions/Trade/Swap.tsx @@ -4,7 +4,6 @@ import TradeInput from './TradeInput' import Button from '@shared/atoms/Button' import Arrow from '@images/arrow.svg' import { FormikContextType, useFormikContext } from 'formik' -import { useOcean } from '@context/Ocean' import Output from './Output' import Slippage from './Slippage' import PriceImpact from './PriceImpact' @@ -34,7 +33,6 @@ export default function Swap({ setMaximumOcean: (value: string) => void setCoin: (value: string) => void }): ReactElement { - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const [oceanItem, setOceanItem] = useState({ amount: '0', @@ -72,47 +70,47 @@ export default function Swap({ ? new Decimal(balance.ocean) : new Decimal(maxOcean) - const maxBuyOcean = await ocean.pool.getOceanReceived( - price.address, - `${amountDataToken.toString()}` - ) - const maxBuyDt = await ocean.pool.getDTReceived( - price.address, - `${amountOcean.toString()}` - ) + // const maxBuyOcean = await ocean.pool.getOceanReceived( + // price.address, + // `${amountDataToken.toString()}` + // ) + // const maxBuyDt = await ocean.pool.getDTReceived( + // price.address, + // `${amountOcean.toString()}` + // ) - const maximumDt = - values.type === 'buy' - ? amountDataToken.greaterThan(new Decimal(maxBuyDt)) - ? maxBuyDt - : amountDataToken - : amountDataToken.greaterThan(new Decimal(balance.datatoken)) - ? balance.datatoken - : amountDataToken + // const maximumDt = + // values.type === 'buy' + // ? amountDataToken.greaterThan(new Decimal(maxBuyDt)) + // ? maxBuyDt + // : amountDataToken + // : amountDataToken.greaterThan(new Decimal(balance.datatoken)) + // ? balance.datatoken + // : amountDataToken - const maximumOcean = - values.type === 'sell' - ? amountOcean.greaterThan(new Decimal(maxBuyOcean)) - ? maxBuyOcean - : amountOcean - : amountOcean.greaterThan(new Decimal(balance.ocean)) - ? balance.ocean - : amountOcean + // const maximumOcean = + // values.type === 'sell' + // ? amountOcean.greaterThan(new Decimal(maxBuyOcean)) + // ? maxBuyOcean + // : amountOcean + // : amountOcean.greaterThan(new Decimal(balance.ocean)) + // ? balance.ocean + // : amountOcean - setMaximumDt(maximumDt.toString()) - setMaximumOcean(maximumOcean.toString()) + // setMaximumDt(maximumDt.toString()) + // setMaximumOcean(maximumOcean.toString()) - setOceanItem((prevState) => ({ - ...prevState, - amount: amountOcean.toString(), - maxAmount: maximumOcean.toString() - })) + // setOceanItem((prevState) => ({ + // ...prevState, + // amount: amountOcean.toString(), + // maxAmount: maximumOcean.toString() + // })) - setDtItem((prevState) => ({ - ...prevState, - amount: amountDataToken.toString(), - maxAmount: maximumDt.toString() - })) + // setDtItem((prevState) => ({ + // ...prevState, + // amount: amountDataToken.toString(), + // maxAmount: maximumDt.toString() + // })) } calculateMaximum() }, [ @@ -122,7 +120,6 @@ export default function Swap({ balance, price, values?.type, - ocean, setMaximumDt, setMaximumOcean ]) @@ -137,63 +134,63 @@ export default function Swap({ } const handleValueChange = async (name: string, value: number) => { - let tokenIn = '' - let tokenOut = '' + const tokenIn = '' + const tokenOut = '' let newValue - if (name === 'ocean') { - if (values.type === 'sell') { - newValue = await ocean.pool.getDTNeeded(price.address, value.toString()) + // if (name === 'ocean') { + // if (values.type === 'sell') { + // newValue = await ocean.pool.getDTNeeded(price.address, value.toString()) - setTotalValue(newValue) - setTokenAmount(value.toString()) + // setTotalValue(newValue) + // setTokenAmount(value.toString()) - tokenIn = ddo.services[0].datatokenAddress - tokenOut = ocean.pool.oceanAddress - } else { - newValue = await ocean.pool.getDTReceived( - price.address, - value.toString() - ) + // tokenIn = ddo.services[0].datatokenAddress + // tokenOut = ocean.pool.oceanAddress + // } else { + // newValue = await ocean.pool.getDTReceived( + // price.address, + // value.toString() + // ) - setTotalValue(value.toString()) - setTokenAmount(newValue) - tokenIn = ocean.pool.oceanAddress - tokenOut = ddo.services[0].datatokenAddress - } - } else { - if (values.type === 'sell') { - newValue = await ocean.pool.getOceanReceived( - price.address, - value.toString() - ) + // setTotalValue(value.toString()) + // setTokenAmount(newValue) + // tokenIn = ocean.pool.oceanAddress + // tokenOut = ddo.services[0].datatokenAddress + // } + // } else { + // if (values.type === 'sell') { + // newValue = await ocean.pool.getOceanReceived( + // price.address, + // value.toString() + // ) - setTotalValue(value.toString()) - setTokenAmount(newValue) - tokenIn = ddo.services[0].datatokenAddress - tokenOut = ocean.pool.oceanAddress - } else { - newValue = await ocean.pool.getOceanNeeded( - price.address, - value.toString() - ) + // setTotalValue(value.toString()) + // setTokenAmount(newValue) + // tokenIn = ddo.services[0].datatokenAddress + // tokenOut = ocean.pool.oceanAddress + // } else { + // newValue = await ocean.pool.getOceanNeeded( + // price.address, + // value.toString() + // ) - setTotalValue(newValue) - setTokenAmount(value.toString()) - tokenIn = ocean.pool.oceanAddress - tokenOut = ddo.services[0].datatokenAddress - } - } + // setTotalValue(newValue) + // setTokenAmount(value.toString()) + // tokenIn = ocean.pool.oceanAddress + // tokenOut = ddo.services[0].datatokenAddress + // } + // } await setFieldValue(name === 'ocean' ? 'datatoken' : 'ocean', newValue) - const spotPrice = await ocean.pool.getSpotPrice( - price.address, - tokenIn, - tokenOut - ) + // const spotPrice = await ocean.pool.getSpotPrice( + // price.address, + // tokenIn, + // tokenOut + // ) - setSpotPrice(spotPrice) + // setSpotPrice(spotPrice) validateForm() } diff --git a/src/components/Asset/AssetActions/Trade/TradeInput.tsx b/src/components/Asset/AssetActions/Trade/TradeInput.tsx index 81cad1dfd..c5a04a41a 100644 --- a/src/components/Asset/AssetActions/Trade/TradeInput.tsx +++ b/src/components/Asset/AssetActions/Trade/TradeInput.tsx @@ -11,6 +11,7 @@ import Button from '@shared/atoms/Button' import { useOcean } from '@context/Ocean' import { FormTradeData, TradeItem } from './_types' import UserLiquidity from '../UserLiquidity' +import { useWeb3 } from '@context/Web3' export default function TradeInput({ name, @@ -23,7 +24,7 @@ export default function TradeInput({ disabled: boolean handleValueChange: (name: string, value: number) => void }): ReactElement { - const { ocean } = useOcean() + const { accountId } = useWeb3() // Connect with form const { @@ -64,7 +65,7 @@ export default function TradeInput({ validateForm() handleChange(e) }} - disabled={!ocean || disabled} + disabled={!accountId || disabled} /> )} diff --git a/src/components/Asset/AssetActions/Trade/index.tsx b/src/components/Asset/AssetActions/Trade/index.tsx index bd7ac32a7..7403c5716 100644 --- a/src/components/Asset/AssetActions/Trade/index.tsx +++ b/src/components/Asset/AssetActions/Trade/index.tsx @@ -1,7 +1,6 @@ import React, { ReactElement, useEffect, useState } from 'react' import FormTrade from './FormTrade' import { useAsset } from '@context/Asset' -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import { isValidNumber } from '@utils/numbers' @@ -11,7 +10,6 @@ Decimal.set({ toExpNeg: -18, precision: 18, rounding: 1 }) export default function Trade(): ReactElement { const { accountId, balance } = useWeb3() - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const [tokenBalance, setTokenBalance] = useState() const { price, ddo } = useAsset() @@ -21,7 +19,7 @@ export default function Trade(): ReactElement { // Get datatoken balance, and combine with OCEAN balance from hooks into one object useEffect(() => { if ( - !ocean || + !accountId || !isAssetNetwork || !balance?.ocean || !accountId || @@ -30,45 +28,42 @@ export default function Trade(): ReactElement { return async function getTokenBalance() { - const dtBalance = await ocean.datatokens.balance( - ddo.services[0].datatokenAddress, - accountId - ) - setTokenBalance({ - ocean: new Decimal(balance.ocean).toString(), - datatoken: new Decimal(dtBalance).toString() - }) + // const dtBalance = await ocean.datatokens.balance( + // ddo.services[0].datatokenAddress, + // accountId + // ) + // setTokenBalance({ + // ocean: new Decimal(balance.ocean).toString(), + // datatoken: new Decimal(dtBalance).toString() + // }) } getTokenBalance() - }, [balance.ocean, ocean, accountId, ddo, isAssetNetwork]) + }, [balance.ocean, accountId, ddo, isAssetNetwork]) // Get maximum amount for either OCEAN or datatoken useEffect(() => { - if (!ocean || !isAssetNetwork || !price || price.value === 0) return + if (!isAssetNetwork || !price || price.value === 0) return async function getMaximum() { - const maxTokensInPool = await ocean.pool.getDTMaxBuyQuantity( - price.address - ) - - setMaxDt( - isValidNumber(maxTokensInPool) - ? new Decimal(maxTokensInPool).toString() - : '0' - ) - - const maxOceanInPool = await ocean.pool.getOceanMaxBuyQuantity( - price.address - ) - - setMaxOcean( - isValidNumber(maxOceanInPool) - ? new Decimal(maxOceanInPool).toString() - : '0' - ) + // const maxTokensInPool = await ocean.pool.getDTMaxBuyQuantity( + // price.address + // ) + // setMaxDt( + // isValidNumber(maxTokensInPool) + // ? new Decimal(maxTokensInPool).toString() + // : '0' + // ) + // const maxOceanInPool = await ocean.pool.getOceanMaxBuyQuantity( + // price.address + // ) + // setMaxOcean( + // isValidNumber(maxOceanInPool) + // ? new Decimal(maxOceanInPool).toString() + // : '0' + // ) } getMaximum() - }, [ocean, balance.ocean, price]) + }, [isAssetNetwork, balance.ocean, price]) return ( () @@ -87,25 +86,25 @@ export default function AssetActions({ // Get and set user DT balance useEffect(() => { - if (!ocean || !accountId || !isAssetNetwork) return + if (!accountId || !isAssetNetwork) return async function init() { try { - const dtBalance = await ocean.datatokens.balance( - ddo.services[0].datatokenAddress, - accountId - ) - setDtBalance(dtBalance) + // const dtBalance = await ocean.datatokens.balance( + // ddo.services[0].datatokenAddress, + // accountId + // ) + // setDtBalance(dtBalance) } catch (e) { LoggerInstance.error(e.message) } } init() - }, [ocean, accountId, ddo, isAssetNetwork]) + }, [accountId, ddo, isAssetNetwork]) // Check user balance against price useEffect(() => { if (price?.type === 'free') setIsBalanceSufficient(true) - if (!price?.value || !account || !balance?.ocean || !dtBalance) return + if (!price?.value || !accountId || !balance?.ocean || !dtBalance) return setIsBalanceSufficient( compareAsBN(balance.ocean, `${price.value}`) || Number(dtBalance) >= 1 @@ -114,7 +113,7 @@ export default function AssetActions({ return () => { setIsBalanceSufficient(false) } - }, [balance, account, price, dtBalance]) + }, [balance, accountId, price, dtBalance]) const UseContent = isCompute ? ( () + useState() useEffect(() => { - if (!ocean) return - - async function transformValues() { - const privacy = await transformComputeFormToServiceComputePrivacy( - values, - ocean - ) - setFormTransformed(privacy) - } - transformValues() - }, [values, ddo, ocean]) + // async function transformValues() { + // const privacy = await transformComputeFormToServiceComputePrivacy(values) + // setFormTransformed(privacy) + // } + // transformValues() + }, [values, ddo]) return ( <> diff --git a/src/components/Asset/Edit/EditComputeDataset.tsx b/src/components/Asset/Edit/EditComputeDataset.tsx index 2560f205b..d75c8791c 100644 --- a/src/components/Asset/Edit/EditComputeDataset.tsx +++ b/src/components/Asset/Edit/EditComputeDataset.tsx @@ -1,14 +1,13 @@ -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import { Formik } from 'formik' import React, { ReactElement, useState } from 'react' import { useAsset } from '@context/Asset' import FormEditComputeDataset from './FormEditComputeDataset' -import { LoggerInstance, ServiceComputePrivacy } from '@oceanprotocol/lib' +import { LoggerInstance, ServiceComputeOptions } from '@oceanprotocol/lib' import { useUserPreferences } from '@context/UserPreferences' import DebugEditCompute from './DebugEditCompute' import styles from './index.module.css' -import { transformComputeFormToServiceComputePrivacy } from '@utils/compute' +// import { transformComputeFormToServiceComputePrivacy } from '@utils/compute' import { setMinterToDispenser, setMinterToPublisher } from '@utils/freePrice' import Web3Feedback from '@shared/Web3Feedback' import { getInitialValues, validationSchema } from './_constants' @@ -20,7 +19,6 @@ export default function EditComputeDataset({ setShowEdit: (show: boolean) => void }): ReactElement { const { debug } = useUserPreferences() - const { ocean } = useOcean() const { accountId } = useWeb3() const { ddo, price, isAssetNetwork, refreshDdo } = useAsset() const [success, setSuccess] = useState() diff --git a/src/components/Asset/Edit/FormActions.tsx b/src/components/Asset/Edit/FormActions.tsx index 61173634d..c08a7a0e8 100644 --- a/src/components/Asset/Edit/FormActions.tsx +++ b/src/components/Asset/Edit/FormActions.tsx @@ -1,8 +1,6 @@ import { FormikContextType, useFormikContext } from 'formik' import React, { ReactElement } from 'react' import { useAsset } from '@context/Asset' -import { useOcean } from '@context/Ocean' -import { useWeb3 } from '@context/Web3' import Button from '@shared/atoms/Button' import styles from './FormActions.module.css' @@ -13,8 +11,6 @@ export default function FormActions({ setShowEdit: (show: boolean) => void handleClick?: () => void }): ReactElement { - const { accountId } = useWeb3() - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const { isValid }: FormikContextType> = useFormikContext() @@ -22,7 +18,7 @@ export default function FormActions({
diff --git a/src/components/Profile/History/ComputeJobs/Results.tsx b/src/components/Profile/History/ComputeJobs/Results.tsx index 2a07e6554..6231aae48 100644 --- a/src/components/Profile/History/ComputeJobs/Results.tsx +++ b/src/components/Profile/History/ComputeJobs/Results.tsx @@ -3,37 +3,37 @@ import React, { ReactElement, useState } from 'react' import Loader from '@shared/atoms/Loader' import { ListItem } from '@shared/atoms/Lists' import Button from '@shared/atoms/Button' -import { useOcean } from '@context/Ocean' import styles from './Results.module.css' import FormHelp from '@shared/FormInput/Help' import content from '../../../../../content/pages/history.json' +import { useWeb3 } from '@context/Web3' export default function Results({ job }: { job: ComputeJobMetaData }): ReactElement { - const { ocean, account } = useOcean() + const { accountId } = useWeb3() const [isLoading, setIsLoading] = useState(false) const [hasFetched, setHasFetched] = useState(false) const isFinished = job.dateFinished !== null async function getResults() { - if (!account || !ocean || !job) return + if (!accountId || !job) return try { setIsLoading(true) - const jobStatus = await ocean.compute.status( - account, - job.did, - undefined, - undefined, - job.jobId - ) - if (jobStatus?.length > 0) { - job.algorithmLogUrl = jobStatus[0].algorithmLogUrl - job.resultsUrl = jobStatus[0].resultsUrl - } + // const jobStatus = await ocean.compute.status( + // account, + // job.did, + // undefined, + // undefined, + // job.jobId + // ) + // if (jobStatus?.length > 0) { + // job.algorithmLogUrl = jobStatus[0].algorithmLogUrl + // job.resultsUrl = jobStatus[0].resultsUrl + // } } catch (error) { LoggerInstance.error(error.message) } finally { @@ -47,16 +47,16 @@ export default function Results({ {hasFetched ? (
) : (