@oceanprotocol/lib 4.0.0-next.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/.mocharc.json +8 -0
  2. package/CHANGELOG.md +73 -4
  3. package/CodeExamples.md +7 -6
  4. package/ComputeExamples.md +127 -98
  5. package/README.md +9 -0
  6. package/dist/lib.cjs +2 -0
  7. package/dist/lib.cjs.map +1 -0
  8. package/dist/lib.modern.js +1 -1
  9. package/dist/lib.modern.js.map +1 -1
  10. package/dist/lib.module.mjs +2 -0
  11. package/dist/lib.module.mjs.map +1 -0
  12. package/dist/lib.umd.js +1 -1
  13. package/dist/lib.umd.js.map +1 -1
  14. package/dist/types/@types/Compute.d.ts +76 -13
  15. package/dist/types/@types/DDO/Metadata.d.ts +1 -1
  16. package/dist/types/@types/DDO/Service.d.ts +2 -2
  17. package/dist/types/@types/File.d.ts +1 -1
  18. package/dist/types/@types/index.d.ts +20 -20
  19. package/dist/types/config/index.d.ts +2 -2
  20. package/dist/types/contracts/AccessList.d.ts +3 -3
  21. package/dist/types/contracts/AccessListFactory.d.ts +3 -3
  22. package/dist/types/contracts/Datatoken.d.ts +4 -4
  23. package/dist/types/contracts/Datatoken4.d.ts +4 -4
  24. package/dist/types/contracts/Dispenser.d.ts +3 -3
  25. package/dist/types/contracts/FixedRateExchange.d.ts +2 -2
  26. package/dist/types/contracts/NFT.d.ts +2 -2
  27. package/dist/types/contracts/NFTFactory.d.ts +3 -3
  28. package/dist/types/contracts/Router.d.ts +2 -2
  29. package/dist/types/contracts/SmartContract.d.ts +3 -3
  30. package/dist/types/contracts/SmartContractWithAddress.d.ts +3 -3
  31. package/dist/types/contracts/df/DfRewards.d.ts +1 -1
  32. package/dist/types/contracts/df/DfStrategyV1.d.ts +1 -1
  33. package/dist/types/contracts/index.d.ts +20 -20
  34. package/dist/types/contracts/ve/VeAllocate.d.ts +2 -2
  35. package/dist/types/contracts/ve/VeFeeDistributor.d.ts +2 -2
  36. package/dist/types/contracts/ve/VeFeeEstimate.d.ts +2 -2
  37. package/dist/types/contracts/ve/VeOcean.d.ts +2 -2
  38. package/dist/types/index.d.ts +5 -5
  39. package/dist/types/services/Aquarius.d.ts +7 -4
  40. package/dist/types/services/Provider.d.ts +56 -8
  41. package/dist/types/services/index.d.ts +2 -2
  42. package/dist/types/utils/Addresses.d.ts +23 -0
  43. package/dist/types/utils/Assets.d.ts +1 -23
  44. package/dist/types/utils/ContractUtils.d.ts +1 -1
  45. package/dist/types/utils/FetchHelper.d.ts +1 -1
  46. package/dist/types/utils/General.d.ts +1 -0
  47. package/dist/types/utils/OrderUtils.d.ts +5 -1
  48. package/dist/types/utils/SignatureUtils.d.ts +1 -0
  49. package/dist/types/utils/TokenUtils.d.ts +2 -2
  50. package/dist/types/utils/index.d.ts +13 -13
  51. package/docs/classes/Aquarius.md +9 -5
  52. package/docs/classes/NftFactory.md +1 -1
  53. package/docs/classes/Provider.md +40 -7
  54. package/docs/interfaces/ComputeEnvFees.md +30 -0
  55. package/docs/interfaces/ComputeEnvFeesStructure.md +20 -0
  56. package/docs/interfaces/ComputeEnvironment.md +50 -39
  57. package/docs/interfaces/ComputeResourcesPricingInfo.md +30 -0
  58. package/docs/interfaces/ComputeResourcesRequest.md +30 -0
  59. package/docs/interfaces/Metadata.md +1 -1
  60. package/docs/interfaces/RunningPlatform.md +30 -0
  61. package/package.json +30 -20
  62. package/dist/lib.js +0 -2
  63. package/dist/lib.js.map +0 -1
  64. package/dist/lib.module.js +0 -2
  65. package/dist/lib.module.js.map +0 -1
package/.mocharc.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "require": ["source-map-support/register", "mock-local-storage"],
3
+ "extension": ["ts"],
4
+ "timeout": 200000,
5
+ "bail": true,
6
+ "exit": true,
7
+ "fullTrace": true
8
+ }
package/CHANGELOG.md CHANGED
@@ -4,7 +4,76 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
- #### [v4.0.0-next.0](https://github.com/oceanprotocol/ocean.js/compare/v3.4.3...v4.0.0-next.0)
7
+ #### [v4.0.0](https://github.com/oceanprotocol/ocean.js/compare/v4.0.0-next.1...v4.0.0)
8
+
9
+ - Release 4.0 [`#1922`](https://github.com/oceanprotocol/ocean.js/pull/1922)
10
+ - add policy server option to getDownloadUrl [`#1917`](https://github.com/oceanprotocol/ocean.js/pull/1917)
11
+ - add missing exports, refactor addresses file [`#1904`](https://github.com/oceanprotocol/ocean.js/pull/1904)
12
+ - Use serviceIndex instead of hardcoded indexes. [`#1905`](https://github.com/oceanprotocol/ocean.js/pull/1905)
13
+ - Bump path-to-regexp and express [`#1893`](https://github.com/oceanprotocol/ocean.js/pull/1893)
14
+ - make retries and interval bigger & configurable on waitForAqua [`#1895`](https://github.com/oceanprotocol/ocean.js/pull/1895)
15
+ - Bump eslint-config-prettier from 9.0.0 to 9.1.0 [`#1884`](https://github.com/oceanprotocol/ocean.js/pull/1884)
16
+ - Add back check for access list factory. [`#1889`](https://github.com/oceanprotocol/ocean.js/pull/1889)
17
+ - Remove circular dependencies, fix imports and improve build [`#1881`](https://github.com/oceanprotocol/ocean.js/pull/1881)
18
+ - chore: remove redundant words in comment [`#1890`](https://github.com/oceanprotocol/ocean.js/pull/1890)
19
+ - Bump @truffle/hdwallet-provider from 2.1.10 to 2.1.15 [`#1886`](https://github.com/oceanprotocol/ocean.js/pull/1886)
20
+ - Bump nyc from 15.1.0 to 17.1.0 [`#1883`](https://github.com/oceanprotocol/ocean.js/pull/1883)
21
+ - Bump @types/crypto-js from 4.1.2 to 4.2.2 [`#1882`](https://github.com/oceanprotocol/ocean.js/pull/1882)
22
+ - Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows [`#1844`](https://github.com/oceanprotocol/ocean.js/pull/1844)
23
+ - Remove node:16 docker image from workflow. [`#1879`](https://github.com/oceanprotocol/ocean.js/pull/1879)
24
+ - Bump rollup from 2.61.1 to 2.79.2 [`#1866`](https://github.com/oceanprotocol/ocean.js/pull/1866)
25
+ - Remove checks from publishing. ADded chain ID check for ordering. [`#1875`](https://github.com/oceanprotocol/ocean.js/pull/1875)
26
+ - done [`60d0272`](https://github.com/oceanprotocol/ocean.js/commit/60d027294a2893410860f1180ff47177e12e45de)
27
+ - rename waitForAqua as waitForIndexer [`6381795`](https://github.com/oceanprotocol/ocean.js/commit/6381795c957f301b93461d84a14ff59991b58738)
28
+ - 4th pass [`bf94e10`](https://github.com/oceanprotocol/ocean.js/commit/bf94e102e53dd07eac6c671ef222b96e34ffca7f)
29
+
30
+ #### [v4.0.0-next.1](https://github.com/oceanprotocol/ocean.js/compare/v4.0.0-next.0...v4.0.0-next.1)
31
+
32
+ > 12 November 2024
33
+
34
+ - add datasets on ComputeAsset, new start compute fn [`8563429`](https://github.com/oceanprotocol/ocean.js/commit/85634293306fca9aaa3ab5ae06a114149ccc8911)
35
+ - support for consumer signature on initialize compute [`71c5923`](https://github.com/oceanprotocol/ocean.js/commit/71c59230db99a08a6c28df66c26e32ca61c71089)
36
+ - add file object types [`cd936c2`](https://github.com/oceanprotocol/ocean.js/commit/cd936c24a989633d3d8e71b908a375802d2e2970)
37
+
38
+ #### [v4.0.0-next.0](https://github.com/oceanprotocol/ocean.js/compare/v3.4.6...v4.0.0-next.0)
39
+
40
+ > 12 November 2024
41
+
42
+ - Release 4.0.0-next.0 [`658cfe8`](https://github.com/oceanprotocol/ocean.js/commit/658cfe83ff855a83eb97e3cbf1276bed6022a1a6)
43
+
44
+ #### [v3.4.6](https://github.com/oceanprotocol/ocean.js/compare/v3.4.5...v3.4.6)
45
+
46
+ > 8 January 2025
47
+
48
+ - make retries and interval bigger & configurable on waitForAqua [`#1895`](https://github.com/oceanprotocol/ocean.js/pull/1895)
49
+ - Bump eslint-config-prettier from 9.0.0 to 9.1.0 [`#1884`](https://github.com/oceanprotocol/ocean.js/pull/1884)
50
+ - rename waitForAqua as waitForIndexer [`6381795`](https://github.com/oceanprotocol/ocean.js/commit/6381795c957f301b93461d84a14ff59991b58738)
51
+ - Release 3.4.6 [`edd3581`](https://github.com/oceanprotocol/ocean.js/commit/edd3581df80e59f7f6ce64c9e1ae5e4553835f92)
52
+ - make retries and interval bigger & configurable [`2b6e537`](https://github.com/oceanprotocol/ocean.js/commit/2b6e537f4e2a06603cfb62c61a2af5f471b4a699)
53
+
54
+ #### [v3.4.5](https://github.com/oceanprotocol/ocean.js/compare/v3.4.4...v3.4.5)
55
+
56
+ > 19 December 2024
57
+
58
+ - Add back check for access list factory. [`#1889`](https://github.com/oceanprotocol/ocean.js/pull/1889)
59
+ - Remove circular dependencies, fix imports and improve build [`#1881`](https://github.com/oceanprotocol/ocean.js/pull/1881)
60
+ - chore: remove redundant words in comment [`#1890`](https://github.com/oceanprotocol/ocean.js/pull/1890)
61
+ - Bump @truffle/hdwallet-provider from 2.1.10 to 2.1.15 [`#1886`](https://github.com/oceanprotocol/ocean.js/pull/1886)
62
+ - Bump nyc from 15.1.0 to 17.1.0 [`#1883`](https://github.com/oceanprotocol/ocean.js/pull/1883)
63
+ - Bump @types/crypto-js from 4.1.2 to 4.2.2 [`#1882`](https://github.com/oceanprotocol/ocean.js/pull/1882)
64
+ - Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows [`#1844`](https://github.com/oceanprotocol/ocean.js/pull/1844)
65
+ - Remove node:16 docker image from workflow. [`#1879`](https://github.com/oceanprotocol/ocean.js/pull/1879)
66
+ - Bump rollup from 2.61.1 to 2.79.2 [`#1866`](https://github.com/oceanprotocol/ocean.js/pull/1866)
67
+ - done [`60d0272`](https://github.com/oceanprotocol/ocean.js/commit/60d027294a2893410860f1180ff47177e12e45de)
68
+ - 4th pass [`bf94e10`](https://github.com/oceanprotocol/ocean.js/commit/bf94e102e53dd07eac6c671ef222b96e34ffca7f)
69
+ - Release 3.4.5 [`a1ee835`](https://github.com/oceanprotocol/ocean.js/commit/a1ee835294b6a51721c3c215dd3c16f741b0573b)
70
+
71
+ #### [v3.4.4](https://github.com/oceanprotocol/ocean.js/compare/v3.4.3...v3.4.4)
72
+
73
+ > 20 November 2024
74
+
75
+ - Remove checks from publishing. ADded chain ID check for ordering. [`#1875`](https://github.com/oceanprotocol/ocean.js/pull/1875)
76
+ - Release 3.4.4 [`fa242a5`](https://github.com/oceanprotocol/ocean.js/commit/fa242a5095d16327adf2d53830a643350fcdfa84)
8
77
 
9
78
  #### [v3.4.3](https://github.com/oceanprotocol/ocean.js/compare/v3.4.2...v3.4.3)
10
79
 
@@ -257,7 +326,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
257
326
  - Merge 04deabccd3ffbc8d3620e42a8b1bc4a2d5019e54 into 543f71f7cda1b3d0099cc26975d34b89bead7452 [`c33663c`](https://github.com/oceanprotocol/ocean.js/commit/c33663cfdbf501c407d3e1e17f56b17761f9e556)
258
327
  - set min gas fee 30 gwei on priority fees for polygon and mumbai as well [`04deabc`](https://github.com/oceanprotocol/ocean.js/commit/04deabccd3ffbc8d3620e42a8b1bc4a2d5019e54)
259
328
 
260
- #### [v3.0.0](https://github.com/oceanprotocol/ocean.js/compare/v3.0.0-next.5...v3.0.0)
329
+ ### [v3.0.0](https://github.com/oceanprotocol/ocean.js/compare/v3.0.0-next.5...v3.0.0)
261
330
 
262
331
  > 29 May 2023
263
332
 
@@ -533,7 +602,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
533
602
  - put back paid env test [`219d4b4`](https://github.com/oceanprotocol/ocean.js/commit/219d4b4a1e1a2bba04cfaa2e26808b0f4a1fa717)
534
603
  - update asset timeouts [`9fc8a8e`](https://github.com/oceanprotocol/ocean.js/commit/9fc8a8ebb316d0aefcce6d38f83aeb6f4fc5734d)
535
604
 
536
- #### [v2.0.0](https://github.com/oceanprotocol/ocean.js/compare/v2.0.0-next.3...v2.0.0)
605
+ ### [v2.0.0](https://github.com/oceanprotocol/ocean.js/compare/v2.0.0-next.3...v2.0.0)
537
606
 
538
607
  > 7 September 2022
539
608
 
@@ -685,7 +754,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
685
754
  - update to new schema & compute fixes [`#1510`](https://github.com/oceanprotocol/ocean.js/pull/1510)
686
755
  - Release 1.1.0 [`112c27e`](https://github.com/oceanprotocol/ocean.js/commit/112c27edab58ef0681ea3e87fb09978411924753)
687
756
 
688
- #### [v1.0.0](https://github.com/oceanprotocol/ocean.js/compare/v1.0.0-next.45...v1.0.0)
757
+ ### [v1.0.0](https://github.com/oceanprotocol/ocean.js/compare/v1.0.0-next.45...v1.0.0)
689
758
 
690
759
  > 8 June 2022
691
760
 
package/CodeExamples.md CHANGED
@@ -79,7 +79,7 @@ Start by importing all of the necessary dependencies
79
79
  import fs from 'fs'
80
80
 
81
81
  import { ethers, providers, Signer } from 'ethers'
82
- import { SHA256 } from 'crypto-js'
82
+ import crypto from 'crypto-js'
83
83
  import { homedir } from 'os'
84
84
  import {
85
85
  approve,
@@ -109,8 +109,9 @@ import {
109
109
  getEventFromTx,
110
110
  DDO,
111
111
  LoggerInstance
112
- } from '@oceanprotocol/lib'
112
+ } from '../../src/index.js'
113
113
  ```
114
+ const { SHA256 } = crypto
114
115
 
115
116
  <!--
116
117
  describe('Marketplace flow tests
@@ -165,7 +166,7 @@ Next, we define the metadata that will describe our data asset. This is what we
165
166
  ```Typescript
166
167
  const genericAsset: DDO = {
167
168
  '@context': ['https://w3id.org/did/v1'],
168
- id: '',
169
+ id: 'did:op',
169
170
  version: '4.1.0',
170
171
  chainId: 8996,
171
172
  nftAddress: '0x0',
@@ -504,7 +505,7 @@ Now we can make the contract call
504
505
  )
505
506
  console.log(`Consumer ${FRE_NFT_SYMBOL} balance after swap: ${consumerDTBalance}`)
506
507
 
507
- const resolvedDDO = await aquarius.waitForAqua(fixedDDO.id)
508
+ const resolvedDDO = await aquarius.waitForIndexer(fixedDDO.id)
508
509
  assert(resolvedDDO, 'Cannot fetch DDO from Aquarius')
509
510
 
510
511
  ```
@@ -726,7 +727,7 @@ Now we need to encrypt file(s) using provider
726
727
  `Consumer ${DISP_NFT_SYMBOL} balance after dispense: ${consumerDTBalance}`
727
728
  )
728
729
 
729
- const resolvedDDO = await aquarius.waitForAqua(fixedDDO.id)
730
+ const resolvedDDO = await aquarius.waitForIndexer(fixedDDO.id)
730
731
  assert(resolvedDDO, 'Cannot fetch DDO from Aquarius')
731
732
 
732
733
  datatoken = new Datatoken(consumerAccount, await consumerAccount.getChainId())
@@ -821,7 +822,7 @@ Let's start by using the `setData` method to update the nft key value store with
821
822
  data
822
823
  )
823
824
  } catch (e) {
824
- console.log('e = ', e)
825
+ console.log('error = ', e)
825
826
  assert.fail('Failed to set data in NFT ERC725 key value store', e)
826
827
  }
827
828
  ```
@@ -119,7 +119,6 @@ Start by importing all of the necessary dependencies
119
119
  import fs from 'fs'
120
120
  import { homedir } from 'os'
121
121
 
122
- import { SHA256 } from 'crypto-js'
123
122
  import { ethers, providers, Signer } from 'ethers'
124
123
  import {
125
124
  ProviderInstance,
@@ -144,9 +143,12 @@ import {
144
143
  configHelperNetworks,
145
144
  ConfigHelper,
146
145
  getEventFromTx,
147
- amountToUnits
148
- } from '@oceanprotocol/lib'
146
+ amountToUnits,
147
+ isDefined
148
+ } from '../../src/index.js'
149
149
  ```
150
+ import crypto from 'crypto-js'
151
+ const { SHA256 } = crypto
150
152
 
151
153
  ### 4.2. Constants and variables
152
154
 
@@ -275,15 +277,18 @@ let resolvedAlgorithmDdo: DDO
275
277
 
276
278
  let computeJobId: string
277
279
  let agreementId: string
280
+
281
+ let computeRoutePath: string
282
+ let hasFreeComputeSupport: boolean
278
283
  ```
279
284
 
280
285
  ### 4.3 Helper methods
281
286
 
282
287
  Now we define the helper methods which we will use later to publish the dataset and algorithm, and also order them
283
288
 
284
- Add a `createAsset()`function.
289
+ Add a `createAssetHelper()`function.
285
290
  ```Typescript
286
- async function createAsset(
291
+ async function createAssetHelper(
287
292
  name: string,
288
293
  symbol: string,
289
294
  owner: Signer,
@@ -503,7 +508,7 @@ you need to mint oceans to mentioned accounts only if you are using barge to tes
503
508
 
504
509
  ### 6.1 Publish a dataset (create NFT + Datatoken) and set dataset metadata
505
510
  ```Typescript
506
- datasetId = await createAsset(
511
+ datasetId = await createAssetHelper(
507
512
  'D1Min',
508
513
  'D1M',
509
514
  publisherAccount,
@@ -520,7 +525,7 @@ Now, let's check that we successfully published a dataset (create NFT + Datatoke
520
525
 
521
526
  ### 6.2 Publish an algorithm (create NFT + Datatoken) and set algorithm metadata
522
527
  ```Typescript
523
- algorithmId = await createAsset(
528
+ algorithmId = await createAssetHelper(
524
529
  'D1Min',
525
530
  'D1M',
526
531
  publisherAccount,
@@ -539,8 +544,8 @@ Now, let's check that we successfully published a algorithm (create NFT + Datato
539
544
 
540
545
  ### 7.1 Resolve published datasets and algorithms
541
546
  ```Typescript
542
- resolvedDatasetDdo = await aquariusInstance.waitForAqua(datasetId)
543
- resolvedAlgorithmDdo = await aquariusInstance.waitForAqua(algorithmId)
547
+ resolvedDatasetDdo = await aquariusInstance.waitForIndexer(datasetId)
548
+ resolvedAlgorithmDdo = await aquariusInstance.waitForIndexer(algorithmId)
544
549
  ```
545
550
  <!--
546
551
  assert(resolvedDatasetDdo, 'Cannot fetch DDO from Aquarius')
@@ -594,7 +599,7 @@ Now, let's check that we successfully published a algorithm (create NFT + Datato
594
599
  let's check the free compute environment
595
600
  ```Typescript
596
601
  const computeEnv = computeEnvs[resolvedDatasetDdo.chainId].find(
597
- (ce) => ce.priceMin === 0
602
+ (ce) => ce.priceMin === 0 || isDefined(ce.free)
598
603
  )
599
604
  console.log('Free compute environment = ', computeEnv)
600
605
  ```
@@ -602,111 +607,135 @@ let's check the free compute environment
602
607
  assert(computeEnv, 'Cannot find the free compute env')
603
608
  -->
604
609
 
605
- Let's have 5 minute of compute access
606
- ```Typescript
607
- const mytime = new Date()
608
- const computeMinutes = 5
609
- mytime.setMinutes(mytime.getMinutes() + computeMinutes)
610
- const computeValidUntil = Math.floor(mytime.getTime() / 1000)
611
-
612
- const assets: ComputeAsset[] = [
613
- {
614
- documentId: resolvedDatasetDdo.id,
615
- serviceId: resolvedDatasetDdo.services[0].id
610
+ computeRoutePath = await ProviderInstance.getComputeStartRoutes(providerUrl, true)
611
+ if (isDefined(computeRoutePath)) {
612
+ hasFreeComputeSupport = true
613
+ Let's have 5 minute of compute access
614
+ ```Typescript
615
+ const mytime = new Date()
616
+ const computeMinutes = 5
617
+ mytime.setMinutes(mytime.getMinutes() + computeMinutes)
618
+ const computeValidUntil = Math.floor(mytime.getTime() / 1000)
619
+
620
+ const assets: ComputeAsset[] = [
621
+ {
622
+ documentId: resolvedDatasetDdo.id,
623
+ serviceId: resolvedDatasetDdo.services[0].id
624
+ }
625
+ ]
626
+ const dtAddressArray = [resolvedDatasetDdo.services[0].datatokenAddress]
627
+ const algo: ComputeAlgorithm = {
628
+ documentId: resolvedAlgorithmDdo.id,
629
+ serviceId: resolvedAlgorithmDdo.services[0].id
616
630
  }
617
- ]
618
- const dtAddressArray = [resolvedDatasetDdo.services[0].datatokenAddress]
619
- const algo: ComputeAlgorithm = {
620
- documentId: resolvedAlgorithmDdo.id,
621
- serviceId: resolvedAlgorithmDdo.services[0].id
622
- }
623
631
 
624
- const providerInitializeComputeResults = await ProviderInstance.initializeCompute(
625
- assets,
626
- algo,
627
- computeEnv.id,
628
- computeValidUntil,
629
- providerUrl,
630
- await consumerAccount.getAddress()
631
- )
632
- ```
633
- <!--
634
- assert(!('error' in providerInitializeComputeResults), 'Cannot order algorithm')
635
- -->
636
- ```Typescript
637
- algo.transferTxId = await handleOrder(
638
- providerInitializeComputeResults.algorithm,
639
- resolvedAlgorithmDdo.services[0].datatokenAddress,
640
- consumerAccount,
641
- computeEnv.consumerAddress,
642
- 0
643
- )
644
- for (let i = 0; i < providerInitializeComputeResults.datasets.length; i++) {
645
- assets[i].transferTxId = await handleOrder(
646
- providerInitializeComputeResults.datasets[i],
647
- dtAddressArray[i],
632
+ const providerInitializeComputeResults = await ProviderInstance.initializeCompute(
633
+ assets,
634
+ algo,
635
+ computeEnv.id,
636
+ computeValidUntil,
637
+ providerUrl,
638
+ consumerAccount
639
+ )
640
+ ```
641
+ <!--
642
+ assert(!('error' in providerInitializeComputeResults), 'Cannot order algorithm')
643
+ -->
644
+ ```Typescript
645
+ algo.transferTxId = await handleOrder(
646
+ providerInitializeComputeResults.algorithm,
647
+ resolvedAlgorithmDdo.services[0].datatokenAddress,
648
648
  consumerAccount,
649
649
  computeEnv.consumerAddress,
650
650
  0
651
651
  )
652
- }
652
+ for (let i = 0; i < providerInitializeComputeResults.datasets.length; i++) {
653
+ assets[i].transferTxId = await handleOrder(
654
+ providerInitializeComputeResults.datasets[i],
655
+ dtAddressArray[i],
656
+ consumerAccount,
657
+ computeEnv.consumerAddress,
658
+ 0
659
+ )
660
+ }
653
661
 
654
- const computeJobs = await ProviderInstance.computeStart(
655
- providerUrl,
656
- consumerAccount,
657
- computeEnv.id,
658
- assets[0],
659
- algo
660
- )
662
+ const computeJobs = await ProviderInstance.freeComputeStart(
663
+ providerUrl,
664
+ consumerAccount,
665
+ computeEnv.id,
666
+ assets,
667
+ algo
668
+ )
661
669
 
662
- ```
663
- <!--
664
- assert(computeJobs, 'Cannot start compute job')
665
- -->
666
- Let's save the compute job it, we re going to use later
667
- ```Typescript
668
- computeJobId = computeJobs[0].jobId
669
- // eslint-disable-next-line prefer-destructuring
670
- agreementId = computeJobs[0].agreementId
670
+ ```
671
+ <!--
672
+ assert(computeJobs, 'Cannot start compute job')
673
+ -->
674
+ Let's save the compute job it, we re going to use later
675
+ ```Typescript
676
+ computeJobId = computeJobs[0].jobId
677
+ // eslint-disable-next-line prefer-destructuring
678
+ agreementId = computeJobs[0].agreementId
679
+ } else {
680
+ assert(
681
+ computeRoutePath === null,
682
+ 'Route path for free compute is not defined (perhaps because provider does not support it yet?)'
683
+ )
684
+ hasFreeComputeSupport = false
685
+ }
671
686
 
672
687
  ```
673
688
 
674
689
  ## 11. Check compute status and get download compute results URL
675
690
  ### 11.1 Check compute status
676
- You can also add various delays so you see the various states of the compute job
677
- ```Typescript
678
- const jobStatus = await ProviderInstance.computeStatus(
679
- providerUrl,
680
- await consumerAccount.getAddress(),
681
- computeJobId,
682
- agreementId
683
- )
684
- ```
685
- <!--
686
- assert(jobStatus, 'Cannot retrieve compute status!')
687
- -->
688
- Now, let's see the current status of the previously started computer job
689
- ```Typescript
690
- console.log('Current status of the compute job: ', jobStatus)
691
+ if (!hasFreeComputeSupport) {
692
+ assert(
693
+ computeRoutePath === null,
694
+ 'Compute route path for free compute is not defined (perhaps because provider does not support it yet?)'
695
+ )
696
+ } else {
697
+ You can also add various delays so you see the various states of the compute job
698
+ ```Typescript
699
+ const jobStatus = await ProviderInstance.computeStatus(
700
+ providerUrl,
701
+ await consumerAccount.getAddress(),
702
+ computeJobId,
703
+ agreementId
704
+ )
705
+ ```
706
+ <!--
707
+ assert(jobStatus, 'Cannot retrieve compute status!')
708
+ -->
709
+ Now, let's see the current status of the previously started computer job
710
+ ```Typescript
711
+ console.log('Current status of the compute job: ', jobStatus)
712
+ }
691
713
 
692
714
  ```
693
715
 
694
716
  ### 11.2 Get download compute results URL
695
- ```Typescript
696
- await sleep(10000)
697
- const downloadURL = await ProviderInstance.getComputeResultUrl(
698
- providerUrl,
699
- consumerAccount,
700
- computeJobId,
701
- 0
702
- )
703
- ```
704
- <!--
705
- assert(downloadURL, 'Provider getComputeResultUrl failed!')
706
- -->
707
- Let's check the compute results url for the specified index
708
- ```Typescript
709
- console.log(`Compute results URL: ${downloadURL}`)
717
+ if (!hasFreeComputeSupport) {
718
+ assert(
719
+ computeRoutePath === null,
720
+ 'Compute route path for free compute is not defined (perhaps because provider does not support it yet?)'
721
+ )
722
+ } else {
723
+ ```Typescript
724
+ await sleep(10000)
725
+ const downloadURL = await ProviderInstance.getComputeResultUrl(
726
+ providerUrl,
727
+ consumerAccount,
728
+ computeJobId,
729
+ 0
730
+ )
731
+ ```
732
+ <!--
733
+ assert(downloadURL, 'Provider getComputeResultUrl failed!')
734
+ -->
735
+ Let's check the compute results url for the specified index
736
+ ```Typescript
737
+ console.log(`Compute results URL: ${downloadURL}`)
738
+ }
710
739
 
711
740
  ```
712
741
 
package/README.md CHANGED
@@ -51,6 +51,15 @@ npm install @oceanprotocol/lib
51
51
  - Visit the [Ocean Protocol website](https://docs.oceanprotocol.com/) for general information about Ocean Protocol.
52
52
  - If you have any difficulties or if you have further questions about how to use ocean.js please reach out to us on [Discord](https://discord.gg/TnXjkR5).
53
53
  - If you notice any bugs or issues with ocean.js please [open an issue on github](https://github.com/oceanprotocol/ocean.js/issues/new?assignees=&labels=bug&template=bug_report.md&title=).
54
+ - Developers using this library should ensure their tsconfig.json includes the necessary options:
55
+ ```
56
+ {
57
+ "moduleResolution": "node",
58
+ "esModuleInterop": true,
59
+ "allowSyntheticDefaultImports": true
60
+ }
61
+ ```
62
+ - If using Next.js, they may need "moduleResolution": "bundler" for better compatibility.
54
63
 
55
64
  ## 🦑 Development
56
65