@oceanprotocol/lib 6.1.1 → 7.0.0-next.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.
package/CHANGELOG.md CHANGED
@@ -4,9 +4,25 @@ 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
+ #### [v7.0.0-next.0](https://github.com/oceanprotocol/ocean.js/compare/v6.1.2...v7.0.0-next.0)
8
+
9
+ - p2p impl [`68db01f`](https://github.com/oceanprotocol/ocean.js/commit/68db01fbf8f28854e6e0abe43aba85fbf6834c28)
10
+ - p2p warmup [`8c2bb5a`](https://github.com/oceanprotocol/ocean.js/commit/8c2bb5ae2b17b5f2c9530800c1f3143b1b318b0e)
11
+ - push,fetch config and no tls [`9cda783`](https://github.com/oceanprotocol/ocean.js/commit/9cda78366ddcfe97a93ecb79dc3a8aa3264ccecc)
12
+
13
+ #### [v6.1.2](https://github.com/oceanprotocol/ocean.js/compare/v6.1.1...v6.1.2)
14
+
15
+ > 24 March 2026
16
+
17
+ - Feature/output_in_initializeCompute [`#2056`](https://github.com/oceanprotocol/ocean.js/pull/2056)
18
+ - Release 6.1.2 [`3b3cdeb`](https://github.com/oceanprotocol/ocean.js/commit/3b3cdebdb5ce7b89ebbbd2d49e44d5f6fa65e0d1)
19
+
7
20
  #### [v6.1.1](https://github.com/oceanprotocol/ocean.js/compare/v6.1.0...v6.1.1)
8
21
 
22
+ > 19 March 2026
23
+
9
24
  - Refactor eciesencrypt to support multiple public key formats and improve normalization [`#2054`](https://github.com/oceanprotocol/ocean.js/pull/2054)
25
+ - Release 6.1.1 [`e784f0e`](https://github.com/oceanprotocol/ocean.js/commit/e784f0ef917f2cc6224b3413f6acc2412b6dd9ac)
10
26
 
11
27
  #### [v6.1.0](https://github.com/oceanprotocol/ocean.js/compare/v6.0.0...v6.1.0)
12
28
 
package/CodeExamples.md CHANGED
@@ -104,6 +104,7 @@ import {
104
104
  sendTx,
105
105
  ConfigHelper,
106
106
  configHelperNetworks,
107
+ getNodeEndpointConfig,
107
108
  amountToUnits,
108
109
  getEventFromTx,
109
110
  LoggerInstance
@@ -206,9 +207,7 @@ Next, we define the metadata that will describe our data asset. This is what we
206
207
  const config = new ConfigHelper().getConfig(
207
208
  parseInt(String((await publisherAccount.provider.getNetwork()).chainId))
208
209
  )
209
- if (process.env.NODE_URL) {
210
- config.oceanNodeUri = process.env.NODE_URL
211
- }
210
+ Object.assign(config, getNodeEndpointConfig())
212
211
  aquarius = new Aquarius(config?.oceanNodeUri)
213
212
  providerUrl = config?.oceanNodeUri
214
213
  addresses = JSON.parse(
@@ -143,6 +143,7 @@ import {
143
143
  sendTx,
144
144
  configHelperNetworks,
145
145
  ConfigHelper,
146
+ getNodeEndpointConfig,
146
147
  getEventFromTx,
147
148
  amountToUnits,
148
149
  isDefined,
@@ -280,8 +281,6 @@ let resolvedAlgorithmDdo: DDO
280
281
  let computeJobId: string
281
282
  let agreementId: string
282
283
 
283
- let computeRoutePath: string
284
- let hasFreeComputeSupport: boolean
285
284
  ```
286
285
 
287
286
  ### 4.3 Helper methods
@@ -438,9 +437,7 @@ We need to load the configuration. Add the following code into your `run(){ }` f
438
437
  const config = new ConfigHelper().getConfig(
439
438
  parseInt(String((await publisherAccount.provider.getNetwork()).chainId))
440
439
  )
441
- if (process.env.NODE_URL) {
442
- config.oceanNodeUri = process.env.NODE_URL
443
- }
440
+ Object.assign(config, getNodeEndpointConfig())
444
441
  aquariusInstance = new Aquarius(config?.oceanNodeUri)
445
442
  providerUrl = config?.oceanNodeUri
446
443
  addresses = JSON.parse(
@@ -622,126 +619,99 @@ let's check the free compute environment
622
619
  assert(computeEnv, 'Cannot find the free compute env')
623
620
  -->
624
621
 
625
- <!--
626
- computeRoutePath = await ProviderInstance.getComputeStartRoutes(providerUrl, true)
627
- if (isDefined(computeRoutePath)) {
628
- hasFreeComputeSupport = true
629
- -->
630
-
631
- Let's have 5 minute of compute access
632
- ```Typescript
633
- const mytime = new Date()
634
- const computeMinutes = 5
635
- mytime.setMinutes(mytime.getMinutes() + computeMinutes)
636
-
637
- ```
638
- Let's prepare the dataset and algorithm assets to be used in the compute job
639
- ```Typescript
640
- const assets: ComputeAsset[] = [
641
- {
642
- documentId: resolvedDatasetDdo.id,
643
- serviceId: resolvedDatasetDdo.services[0].id
644
- }
645
- ]
646
-
647
- const algo: ComputeAlgorithm = {
648
- documentId: resolvedAlgorithmDdo.id,
649
- serviceId: resolvedAlgorithmDdo.services[0].id,
650
- meta: resolvedAlgorithmDdo.metadata.algorithm
622
+ Let's have 5 minute of compute access
623
+ ```Typescript
624
+ const mytime = new Date()
625
+ const computeMinutes = 5
626
+ mytime.setMinutes(mytime.getMinutes() + computeMinutes)
627
+
628
+ ```
629
+ Let's prepare the dataset and algorithm assets to be used in the compute job
630
+ ```Typescript
631
+ const assets: ComputeAsset[] = [
632
+ {
633
+ documentId: resolvedDatasetDdo.id,
634
+ serviceId: resolvedDatasetDdo.services[0].id
651
635
  }
652
- ```
636
+ ]
653
637
 
654
- Let's start the free compute job
655
- ```Typescript
656
- const computeJobs = await ProviderInstance.freeComputeStart(
657
- providerUrl,
658
- consumerAccount,
659
- computeEnv.id,
660
- assets,
661
- algo
662
- )
663
- ```
664
-
665
- <!--
666
- assert(computeJobs, 'Cannot start compute job')
667
- -->
668
-
669
- Let's save the compute job it, we re going to use later
670
- ```Typescript
671
- computeJobId = computeJobs[0].jobId
672
- // eslint-disable-next-line prefer-destructuring
673
- agreementId = computeJobs[0].agreementId
674
- ```
675
- <!--
676
- } else {
677
- assert(
678
- computeRoutePath === null,
679
- 'Route path for free compute is not defined (perhaps because provider does not support it yet?)'
680
- )
681
- hasFreeComputeSupport = false
638
+ const algo: ComputeAlgorithm = {
639
+ documentId: resolvedAlgorithmDdo.id,
640
+ serviceId: resolvedAlgorithmDdo.services[0].id,
641
+ meta: resolvedAlgorithmDdo.metadata.algorithm
682
642
  }
643
+ ```
644
+
645
+ Let's start the free compute job
646
+ ```Typescript
647
+ const computeJobs = await ProviderInstance.freeComputeStart(
648
+ providerUrl,
649
+ consumerAccount,
650
+ computeEnv.id,
651
+ assets,
652
+ algo
653
+ )
654
+ ```
655
+
656
+ <!--
657
+ assert(computeJobs, 'Cannot start compute job')
658
+ -->
659
+
660
+ Let's save the compute job it, we re going to use later
661
+ ```Typescript
662
+ computeJobId = computeJobs[0].jobId
663
+ // eslint-disable-next-line prefer-destructuring
664
+ agreementId = computeJobs[0].agreementId
665
+ ```
666
+ <!--
683
667
  }).timeout(40000)
684
668
  -->
685
669
 
686
670
  ## 11. Check compute status and get download compute results URL
687
671
  ### 11.1 Check compute status
688
672
  <!--
689
- if (!hasFreeComputeSupport) {
690
- assert(
691
- computeRoutePath === null,
692
- 'Compute route path for free compute is not defined (perhaps because provider does not support it yet?)'
693
- )
694
- } else {
695
- -->
696
- You can also add various delays so you see the various states of the compute job
697
- ```Typescript
698
- const jobStatus = await ProviderInstance.computeStatus(
699
- providerUrl,
700
- await consumerAccount.getAddress(),
701
- computeJobId,
702
- agreementId
703
- )
704
- ```
705
- <!--
706
- assert(jobStatus, 'Cannot retrieve compute status!')
707
- -->
708
- Now, let's see the current status of the previously started computer job
709
- ```Typescript
710
- console.log('Current status of the compute job: ', jobStatus)
711
- ```
712
- <!--
713
- }
673
+
674
+ -->
675
+ You can also add various delays so you see the various states of the compute job
676
+ ```Typescript
677
+ const jobStatus = await ProviderInstance.computeStatus(
678
+ providerUrl,
679
+ consumerAccount,
680
+ computeJobId,
681
+ agreementId
682
+ )
683
+ ```
684
+ <!--
685
+ assert(jobStatus, 'Cannot retrieve compute status!')
686
+ -->
687
+ Now, let's see the current status of the previously started computer job
688
+ ```Typescript
689
+ console.log('Current status of the compute job: ', jobStatus)
690
+ ```
691
+ <!--
714
692
  }).timeout(40000)
715
693
  -->
716
694
 
717
695
  ### 11.2 Get download compute results URL
718
696
  <!--
719
- if (!hasFreeComputeSupport) {
720
- assert(
721
- computeRoutePath === null,
722
- 'Compute route path for free compute is not defined (perhaps because provider does not support it yet?)'
723
- )
724
- } else {
725
- -->
726
-
727
- ```Typescript
728
- await sleep(10000)
729
- const downloadURL = await ProviderInstance.getComputeResultUrl(
730
- providerUrl,
731
- consumerAccount,
732
- computeJobId,
733
- 0
734
- )
735
- ```
736
- <!--
737
- assert(downloadURL, 'Provider getComputeResultUrl failed!')
738
- -->
739
- Let's check the compute results url for the specified index
740
- ```Typescript
741
- console.log(`Compute results URL: ${downloadURL}`)
742
- ```
743
- <!--
744
- }
697
+ -->
698
+ ```Typescript
699
+ await sleep(10000)
700
+ const downloadURL = await ProviderInstance.getComputeResultUrl(
701
+ providerUrl,
702
+ consumerAccount,
703
+ computeJobId,
704
+ 0
705
+ )
706
+ ```
707
+ <!--
708
+ assert(downloadURL, 'Provider getComputeResultUrl failed!')
709
+ -->
710
+ Let's check the compute results url for the specified index
711
+ ```Typescript
712
+ console.log(`Compute results URL: ${downloadURL}`)
713
+ ```
714
+ <!--
745
715
  }).timeout(40000)
746
716
  -->
747
717
 
@@ -764,227 +734,203 @@ let's select compute environment which have free and paid resources
764
734
 
765
735
  <!--
766
736
  const paymentToken = addresses.Ocean
767
- computeRoutePath = await ProviderInstance.getComputeStartRoutes(providerUrl, false)
768
- if (isDefined(computeRoutePath)) {
769
- -->
770
-
771
- Let's have 5 minute of compute access
772
- ```Typescript
773
-
774
- const mytime = new Date()
775
- const computeMinutes = 5
776
- mytime.setMinutes(mytime.getMinutes() + computeMinutes)
777
- const computeValidUntil = Math.floor(mytime.getTime() / 1000)
778
-
779
- ```
780
-
781
- Let's prepare the dataset and algorithm assets to be used in the compute job
782
- ```Typescript
783
- const resources: ComputeResourceRequest[] = [
784
- {
785
- id: 'cpu',
786
- amount: 2
787
- },
788
- {
789
- id: 'ram',
790
- amount: 2
791
- },
792
- {
793
- id: 'disk',
794
- amount: 0
795
- }
796
- ]
797
- const assets: ComputeAsset[] = [
798
- {
799
- documentId: resolvedDatasetDdo.id,
800
- serviceId: resolvedDatasetDdo.services[0].id
801
- }
802
- ]
803
- const dtAddressArray = [resolvedDatasetDdo.services[0].datatokenAddress]
804
- const algo: ComputeAlgorithm = {
805
- documentId: resolvedAlgorithmDdo.id,
806
- serviceId: resolvedAlgorithmDdo.services[0].id,
807
- meta: resolvedAlgorithmDdo.metadata.algorithm
737
+
738
+ Let's have 5 minute of compute access
739
+ ```Typescript
740
+
741
+ const mytime = new Date()
742
+ const computeMinutes = 5
743
+ mytime.setMinutes(mytime.getMinutes() + computeMinutes)
744
+ const computeValidUntil = Math.floor(mytime.getTime() / 1000)
745
+
746
+ ```
747
+
748
+ Let's prepare the dataset and algorithm assets to be used in the compute job
749
+ ```Typescript
750
+ const resources: ComputeResourceRequest[] = [
751
+ {
752
+ id: 'cpu',
753
+ amount: 2
754
+ },
755
+ {
756
+ id: 'ram',
757
+ amount: 2
758
+ },
759
+ {
760
+ id: 'disk',
761
+ amount: 0
808
762
  }
809
- ```
810
-
811
- Triggering initialize compute to see payment options
812
- ```Typescript
813
- const providerInitializeComputeResults = await ProviderInstance.initializeCompute(
814
- assets,
815
- algo,
816
- computeEnv.id,
817
- paymentToken,
818
- computeValidUntil,
819
- providerUrl,
820
- consumerAccount,
821
- resources,
822
- Number(chainId)
823
- )
763
+ ]
764
+ const assets: ComputeAsset[] = [
765
+ {
766
+ documentId: resolvedDatasetDdo.id,
767
+ serviceId: resolvedDatasetDdo.services[0].id
768
+ }
769
+ ]
770
+ const dtAddressArray = [resolvedDatasetDdo.services[0].datatokenAddress]
771
+ const algo: ComputeAlgorithm = {
772
+ documentId: resolvedAlgorithmDdo.id,
773
+ serviceId: resolvedAlgorithmDdo.services[0].id,
774
+ meta: resolvedAlgorithmDdo.metadata.algorithm
775
+ }
776
+ ```
824
777
 
825
- console.log(
826
- 'providerInitializeComputeResults = ',
827
- JSON.stringify(providerInitializeComputeResults)
828
- )
778
+ Triggering initialize compute to see payment options
779
+ ```Typescript
780
+ const providerInitializeComputeResults = await ProviderInstance.initializeCompute(
781
+ assets,
782
+ algo,
783
+ computeEnv.id,
784
+ paymentToken,
785
+ computeValidUntil,
786
+ providerUrl,
787
+ consumerAccount,
788
+ resources,
789
+ Number(chainId)
790
+ )
829
791
 
830
- ```
792
+ console.log(
793
+ 'providerInitializeComputeResults = ',
794
+ JSON.stringify(providerInitializeComputeResults)
795
+ )
831
796
 
832
- <!--
833
- assert(!('error' in providerInitializeComputeResults), 'Cannot order algorithm')
834
- -->
797
+ ```
835
798
 
836
- Let's check funds for escrow payment
837
- ```Typescript
838
- const escrow = new EscrowContract(
839
- getAddress(providerInitializeComputeResults.payment.escrowAddress),
840
- consumerAccount
841
- )
842
- const paymentTokenPublisher = new Datatoken(publisherAccount)
843
- const balancePublisherPaymentToken = await paymentTokenPublisher.balance(
844
- paymentToken,
845
- await publisherAccount.getAddress()
846
- )
847
- assert(
848
- new BigNumber(parseEther(balancePublisherPaymentToken)).isGreaterThan(0),
849
- 'Balance should be higher than 0'
850
- )
851
- const tx = await publisherAccount.sendTransaction({
852
- to: computeEnv.consumerAddress,
853
- value: parseEther('1.5')
854
- })
855
- await tx.wait()
856
-
857
- await paymentTokenPublisher.transfer(
858
- paymentToken,
859
- getAddress(computeEnv.consumerAddress),
860
- (Number(balancePublisherPaymentToken) / 2).toString()
861
- )
862
- const amountToDeposit = (
863
- providerInitializeComputeResults.payment.amount * 2
864
- ).toString()
865
- await escrow.verifyFundsForEscrowPayment(
866
- paymentToken,
867
- computeEnv.consumerAddress,
868
- await unitsToAmount(consumerAccount, paymentToken, amountToDeposit),
869
- providerInitializeComputeResults.payment.amount.toString(),
870
- providerInitializeComputeResults.payment.minLockSeconds.toString(),
871
- '10'
872
- )
873
- ```
799
+ <!--
800
+ assert(!('error' in providerInitializeComputeResults), 'Cannot order algorithm')
801
+ -->
802
+
803
+ Let's check funds for escrow payment
804
+ ```Typescript
805
+ const escrow = new EscrowContract(
806
+ getAddress(providerInitializeComputeResults.payment.escrowAddress),
807
+ consumerAccount
808
+ )
809
+ const paymentTokenPublisher = new Datatoken(publisherAccount)
810
+ const balancePublisherPaymentToken = await paymentTokenPublisher.balance(
811
+ paymentToken,
812
+ await publisherAccount.getAddress()
813
+ )
814
+ assert(
815
+ new BigNumber(parseEther(balancePublisherPaymentToken)).isGreaterThan(0),
816
+ 'Balance should be higher than 0'
817
+ )
818
+ const tx = await publisherAccount.sendTransaction({
819
+ to: computeEnv.consumerAddress,
820
+ value: parseEther('1.5')
821
+ })
822
+ await tx.wait()
823
+
824
+ await paymentTokenPublisher.transfer(
825
+ paymentToken,
826
+ getAddress(computeEnv.consumerAddress),
827
+ (Number(balancePublisherPaymentToken) / 2).toString()
828
+ )
829
+ const amountToDeposit = (
830
+ providerInitializeComputeResults.payment.amount * 2
831
+ ).toString()
832
+ await escrow.verifyFundsForEscrowPayment(
833
+ paymentToken,
834
+ computeEnv.consumerAddress,
835
+ await unitsToAmount(consumerAccount, paymentToken, amountToDeposit),
836
+ providerInitializeComputeResults.payment.amount.toString(),
837
+ providerInitializeComputeResults.payment.minLockSeconds.toString(),
838
+ '10'
839
+ )
840
+ ```
874
841
 
875
- Let's order assets
876
- ```Typescript
842
+ Let's order assets
843
+ ```Typescript
877
844
 
878
- algo.transferTxId = await handleOrder(
879
- providerInitializeComputeResults.algorithm,
880
- resolvedAlgorithmDdo.services[0].datatokenAddress,
845
+ algo.transferTxId = await handleOrder(
846
+ providerInitializeComputeResults.algorithm,
847
+ resolvedAlgorithmDdo.services[0].datatokenAddress,
848
+ consumerAccount,
849
+ computeEnv.consumerAddress,
850
+ 0
851
+ )
852
+ for (let i = 0; i < providerInitializeComputeResults.datasets.length; i++) {
853
+ assets[i].transferTxId = await handleOrder(
854
+ providerInitializeComputeResults.datasets[i],
855
+ dtAddressArray[i],
881
856
  consumerAccount,
882
857
  computeEnv.consumerAddress,
883
858
  0
884
859
  )
885
- for (let i = 0; i < providerInitializeComputeResults.datasets.length; i++) {
886
- assets[i].transferTxId = await handleOrder(
887
- providerInitializeComputeResults.datasets[i],
888
- dtAddressArray[i],
889
- consumerAccount,
890
- computeEnv.consumerAddress,
891
- 0
892
- )
893
- }
894
- ```
895
-
896
- Let's start compute job
897
- ```Typescript
898
- const computeJobs = await ProviderInstance.computeStart(
899
- providerUrl,
900
- consumerAccount,
901
- computeEnv.id,
902
- assets,
903
- algo,
904
- computeValidUntil,
905
- paymentToken,
906
- resources,
907
- Number(chainId)
908
- )
909
- ```
910
-
911
- <!--
912
- assert(computeJobs, 'Cannot start compute job')
913
- -->
914
-
915
- Let's save the compute job it, we re going to use later
916
- ```Typescript
917
- computeJobId = computeJobs[0].jobId
918
- ```
919
- <!--
920
- } else {
921
- assert(
922
- computeRoutePath === null,
923
- 'Route path for free compute is not defined (perhaps because provider does not support it yet?)'
924
- )
925
- hasFreeComputeSupport = false
926
860
  }
861
+ ```
862
+
863
+ Let's start compute job
864
+ ```Typescript
865
+ const computeJobs = await ProviderInstance.computeStart(
866
+ providerUrl,
867
+ consumerAccount,
868
+ computeEnv.id,
869
+ assets,
870
+ algo,
871
+ computeValidUntil,
872
+ paymentToken,
873
+ resources,
874
+ Number(chainId)
875
+ )
876
+ ```
877
+
878
+ <!--
879
+ assert(computeJobs, 'Cannot start compute job')
880
+ -->
881
+
882
+ Let's save the compute job it, we re going to use later
883
+ ```Typescript
884
+ computeJobId = computeJobs[0].jobId
885
+ ```
886
+ <!--
927
887
  }).timeout(40000)
928
888
  -->
929
889
 
930
890
  ## 13. Check paid compute job status and get download compute results URL
931
891
  ### 13.1 Check compute status for paid compute job
932
892
  <!--
933
- if (!hasFreeComputeSupport) {
934
- assert(
935
- computeRoutePath === null,
936
- 'Compute route path for free compute is not defined (perhaps because provider does not support it yet?)'
937
- )
938
- } else {
939
- -->
940
- You can also add various delays so you see the various states of the compute job
941
- ```Typescript
942
- const jobStatus = await ProviderInstance.computeStatus(
943
- providerUrl,
944
- await consumerAccount.getAddress(),
945
- computeJobId
946
- )
947
- ```
948
- <!--
949
- assert(jobStatus, 'Cannot retrieve compute status!')
950
- -->
951
- Now, let's see the current status of the previously started computer job
952
- ```Typescript
953
- console.log('Current status of the compute job: ', jobStatus)
954
- ```
955
- <!--
956
- }
893
+ -->
894
+ You can also add various delays so you see the various states of the compute job
895
+ ```Typescript
896
+ const jobStatus = await ProviderInstance.computeStatus(
897
+ providerUrl,
898
+ consumerAccount,
899
+ computeJobId
900
+ )
901
+ ```
902
+ <!--
903
+ assert(jobStatus, 'Cannot retrieve compute status!')
904
+ -->
905
+ Now, let's see the current status of the previously started computer job
906
+ ```Typescript
907
+ console.log('Current status of the compute job: ', jobStatus)
908
+ ```
909
+ <!--
957
910
  }).timeout(40000)
958
911
  -->
959
912
 
960
913
  ### 13.2 Get download compute results URL
961
914
  <!--
962
- if (!hasFreeComputeSupport) {
963
- assert(
964
- computeRoutePath === null,
965
- 'Compute route path for paid compute is not defined (perhaps because provider does not support it yet?)'
966
- )
967
- } else {
968
- -->
915
+ -->
969
916
 
970
- ```Typescript
971
- await sleep(10000)
972
- const downloadURL = await ProviderInstance.getComputeResultUrl(
973
- providerUrl,
974
- consumerAccount,
975
- computeJobId,
976
- 0
977
- )
978
- ```
979
- <!--
980
- assert(downloadURL, 'Provider getComputeResultUrl failed!')
981
- -->
982
- Let's check the compute results url for the specified index
983
- ```Typescript
984
- console.log(`Compute results URL: ${downloadURL}`)
985
- ```
986
- <!--
987
- }
917
+ ```Typescript
918
+ await sleep(10000)
919
+ const downloadURL = await ProviderInstance.getComputeResultUrl(
920
+ providerUrl,
921
+ consumerAccount,
922
+ computeJobId,
923
+ 0
924
+ )
925
+ ```
926
+ <!--
927
+ assert(downloadURL, 'Provider getComputeResultUrl failed!')
928
+ -->
929
+ Let's check the compute results url for the specified index
930
+ ```Typescript
931
+ console.log(`Compute results URL: ${downloadURL}`)
932
+ ```
933
+ <!--
988
934
  }).timeout(40000)
989
935
  })
990
936
  -->