@oceanprotocol/lib 4.0.1 → 4.0.3
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 +88 -8
- package/CodeExamples.md +38 -13
- package/ComputeExamples.md +92 -54
- package/dist/lib.cjs +1 -1
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.modern.js +1 -1
- package/dist/lib.modern.js.map +1 -1
- package/dist/lib.module.mjs +1 -1
- package/dist/lib.module.mjs.map +1 -1
- package/dist/lib.umd.js +1 -1
- package/dist/lib.umd.js.map +1 -1
- package/dist/types/@types/Compute.d.ts +1 -1
- package/dist/types/@types/File.d.ts +1 -42
- package/dist/types/@types/NFT.d.ts +1 -1
- package/dist/types/@types/index.d.ts +0 -7
- package/dist/types/config/Config.d.ts +2 -12
- package/dist/types/contracts/NFT.d.ts +2 -1
- package/dist/types/services/Aquarius.d.ts +1 -1
- package/dist/types/services/Provider.d.ts +2 -2
- package/dist/types/utils/Assets.d.ts +2 -1
- package/dist/types/utils/OrderUtils.d.ts +1 -1
- package/package.json +5 -4
- package/dist/types/@types/Asset.d.ts +0 -148
- package/dist/types/@types/DDO/ConsumerParameter.d.ts +0 -37
- package/dist/types/@types/DDO/Credentials.d.ts +0 -8
- package/dist/types/@types/DDO/DDO.d.ts +0 -55
- package/dist/types/@types/DDO/Event.d.ts +0 -27
- package/dist/types/@types/DDO/Metadata.d.ts +0 -141
- package/dist/types/@types/DDO/Service.d.ts +0 -106
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,32 @@ 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.3](https://github.com/oceanprotocol/ocean.js/compare/v4.0.2...v4.0.3)
|
|
8
|
+
|
|
9
|
+
- Dependencies update [`#1938`](https://github.com/oceanprotocol/ocean.js/pull/1938)
|
|
10
|
+
- use main branch for node checkout [`#1936`](https://github.com/oceanprotocol/ocean.js/pull/1936)
|
|
11
|
+
- Further integrate ddo-js [`#1935`](https://github.com/oceanprotocol/ocean.js/pull/1935)
|
|
12
|
+
- Make integration tests use Ocean Node not Provider or Aquarius [`#1932`](https://github.com/oceanprotocol/ocean.js/pull/1932)
|
|
13
|
+
- update CODEOWNERS [`#1933`](https://github.com/oceanprotocol/ocean.js/pull/1933)
|
|
14
|
+
- Bump release-it from 15.6.1 to 18.1.2 [`#1921`](https://github.com/oceanprotocol/ocean.js/pull/1921)
|
|
15
|
+
- Bump esbuild and tsx [`#1925`](https://github.com/oceanprotocol/ocean.js/pull/1925)
|
|
16
|
+
- Bump serialize-javascript and mocha [`#1915`](https://github.com/oceanprotocol/ocean.js/pull/1915)
|
|
17
|
+
|
|
18
|
+
#### [v4.0.2](https://github.com/oceanprotocol/ocean.js/compare/v4.0.1...v4.0.2)
|
|
19
|
+
|
|
20
|
+
> 27 March 2025
|
|
21
|
+
|
|
22
|
+
- Bump axios from 1.7.9 to 1.8.3 [`#1926`](https://github.com/oceanprotocol/ocean.js/pull/1926)
|
|
23
|
+
- update to ddo.js v0.0.2 [`#1931`](https://github.com/oceanprotocol/ocean.js/pull/1931)
|
|
24
|
+
- Updating codeowners [`#1929`](https://github.com/oceanprotocol/ocean.js/pull/1929)
|
|
25
|
+
- Release 4.0.2 [`b6a78b6`](https://github.com/oceanprotocol/ocean.js/commit/b6a78b64c684af7c9f360e22ecb7a0fa839e8907)
|
|
26
|
+
|
|
7
27
|
#### [v4.0.1](https://github.com/oceanprotocol/ocean.js/compare/v4.0.0...v4.0.1)
|
|
8
28
|
|
|
29
|
+
> 21 March 2025
|
|
30
|
+
|
|
9
31
|
- moving the getChainId call [`#1928`](https://github.com/oceanprotocol/ocean.js/pull/1928)
|
|
32
|
+
- Release 4.0.1 [`519e378`](https://github.com/oceanprotocol/ocean.js/commit/519e378c3cfd6df0ece6e503c89c796a0c76027d)
|
|
10
33
|
|
|
11
34
|
### [v4.0.0](https://github.com/oceanprotocol/ocean.js/compare/v4.0.0-next.1...v4.0.0)
|
|
12
35
|
|
|
@@ -236,15 +259,29 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
236
259
|
- make sure we increment a number when working with nonces [`#1781`](https://github.com/oceanprotocol/ocean.js/pull/1781)
|
|
237
260
|
- Release 3.1.4 [`b2e2cf2`](https://github.com/oceanprotocol/ocean.js/commit/b2e2cf24293af07f597c25e3a3e392db9caa381a)
|
|
238
261
|
|
|
239
|
-
#### [v3.1.3](https://github.com/oceanprotocol/ocean.js/compare/v3.1.
|
|
262
|
+
#### [v3.1.3](https://github.com/oceanprotocol/ocean.js/compare/v3.1.3-next.1...v3.1.3)
|
|
240
263
|
|
|
241
264
|
> 16 October 2023
|
|
242
265
|
|
|
243
266
|
- fix fs use & error handling [`#1777`](https://github.com/oceanprotocol/ocean.js/pull/1777)
|
|
244
267
|
- Bump postcss from 8.4.5 to 8.4.31 [`#1778`](https://github.com/oceanprotocol/ocean.js/pull/1778)
|
|
268
|
+
- Release 3.1.3 [`1bc5a39`](https://github.com/oceanprotocol/ocean.js/commit/1bc5a39fda217c91cf5c44f41c6275acd20740de)
|
|
269
|
+
|
|
270
|
+
#### [v3.1.3-next.1](https://github.com/oceanprotocol/ocean.js/compare/v3.1.3-next.0...v3.1.3-next.1)
|
|
271
|
+
|
|
272
|
+
> 11 October 2023
|
|
273
|
+
|
|
274
|
+
- update error handling [`aada8e9`](https://github.com/oceanprotocol/ocean.js/commit/aada8e92af9273ccc20e86dc00ea73bcb7e8dfdf)
|
|
275
|
+
- Release 3.1.3-next.1 [`40c22b9`](https://github.com/oceanprotocol/ocean.js/commit/40c22b9b1fa147fd4295da1bdd6248d7714a2b30)
|
|
276
|
+
|
|
277
|
+
#### [v3.1.3-next.0](https://github.com/oceanprotocol/ocean.js/compare/v3.1.2...v3.1.3-next.0)
|
|
278
|
+
|
|
279
|
+
> 6 October 2023
|
|
280
|
+
|
|
245
281
|
- Bump @types/crypto-js from 4.1.1 to 4.1.2 [`#1774`](https://github.com/oceanprotocol/ocean.js/pull/1774)
|
|
246
282
|
- Bump @types/chai-spies from 1.0.3 to 1.0.4 [`#1776`](https://github.com/oceanprotocol/ocean.js/pull/1776)
|
|
247
|
-
-
|
|
283
|
+
- fix fs use [`735dc2f`](https://github.com/oceanprotocol/ocean.js/commit/735dc2f62b976be683bc9fcd7f8940e715b18519)
|
|
284
|
+
- Release 3.1.3-next.0 [`5ac5d1f`](https://github.com/oceanprotocol/ocean.js/commit/5ac5d1f44a637b5d8d285757941b0393bb3a7983)
|
|
248
285
|
|
|
249
286
|
#### [v3.1.2](https://github.com/oceanprotocol/ocean.js/compare/v3.1.1...v3.1.2)
|
|
250
287
|
|
|
@@ -303,13 +340,21 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
303
340
|
- Merge 8699e4a8bb30b3ecb7ee894412ebe85267fddd67 into ae2ff1ccde53ace9841844c316a855de271f9a3f [`9da0268`](https://github.com/oceanprotocol/ocean.js/commit/9da0268be6ddfb1e4f110ee48725e8c9a492f6fb)
|
|
304
341
|
- Adding tests to check if the number of decimals is correct for the publishMarketFee [`8699e4a`](https://github.com/oceanprotocol/ocean.js/commit/8699e4a8bb30b3ecb7ee894412ebe85267fddd67)
|
|
305
342
|
|
|
306
|
-
#### [v3.0.1](https://github.com/oceanprotocol/ocean.js/compare/v3.0.0...v3.0.1)
|
|
343
|
+
#### [v3.0.1](https://github.com/oceanprotocol/ocean.js/compare/v3.0.1-next.0...v3.0.1)
|
|
307
344
|
|
|
308
345
|
> 6 June 2023
|
|
309
346
|
|
|
310
347
|
- set min gas fee 30 gwei on priority fees for polygon and mumbai as well [`#1736`](https://github.com/oceanprotocol/ocean.js/pull/1736)
|
|
311
348
|
- Release 3.0.1 [`ae2ff1c`](https://github.com/oceanprotocol/ocean.js/commit/ae2ff1ccde53ace9841844c316a855de271f9a3f)
|
|
312
349
|
|
|
350
|
+
#### [v3.0.1-next.0](https://github.com/oceanprotocol/ocean.js/compare/v3.0.0...v3.0.1-next.0)
|
|
351
|
+
|
|
352
|
+
> 31 May 2023
|
|
353
|
+
|
|
354
|
+
- Release 3.0.1-next.0 [`b670073`](https://github.com/oceanprotocol/ocean.js/commit/b67007363a8e2a3b640411c3b6471edeacdf5d19)
|
|
355
|
+
- Merge 04deabccd3ffbc8d3620e42a8b1bc4a2d5019e54 into 543f71f7cda1b3d0099cc26975d34b89bead7452 [`c33663c`](https://github.com/oceanprotocol/ocean.js/commit/c33663cfdbf501c407d3e1e17f56b17761f9e556)
|
|
356
|
+
- set min gas fee 30 gwei on priority fees for polygon and mumbai as well [`04deabc`](https://github.com/oceanprotocol/ocean.js/commit/04deabccd3ffbc8d3620e42a8b1bc4a2d5019e54)
|
|
357
|
+
|
|
313
358
|
### [v3.0.0](https://github.com/oceanprotocol/ocean.js/compare/v3.0.0-next.5...v3.0.0)
|
|
314
359
|
|
|
315
360
|
> 29 May 2023
|
|
@@ -379,7 +424,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
379
424
|
- more cleanup and jsdoc updates [`967f664`](https://github.com/oceanprotocol/ocean.js/commit/967f6642fb1a0cf9c20d4f4fa28d36527d8e43ba)
|
|
380
425
|
- Updating CodeExamples.md [`815ee37`](https://github.com/oceanprotocol/ocean.js/commit/815ee37c52f9aa64f2cac4948fb137f447d1c6b4)
|
|
381
426
|
|
|
382
|
-
#### [v2.7.0](https://github.com/oceanprotocol/ocean.js/compare/v2.
|
|
427
|
+
#### [v2.7.0](https://github.com/oceanprotocol/ocean.js/compare/v2.7.0-next.2...v2.7.0)
|
|
383
428
|
|
|
384
429
|
> 20 March 2023
|
|
385
430
|
|
|
@@ -390,6 +435,29 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
390
435
|
- Updated copyright year. [`#1700`](https://github.com/oceanprotocol/ocean.js/pull/1700)
|
|
391
436
|
- Release 2.7.0 [`a2e9901`](https://github.com/oceanprotocol/ocean.js/commit/a2e9901697b32c6aaaa489c3bec1a19fcfa185ab)
|
|
392
437
|
|
|
438
|
+
#### [v2.7.0-next.2](https://github.com/oceanprotocol/ocean.js/compare/v2.7.0-next.1...v2.7.0-next.2)
|
|
439
|
+
|
|
440
|
+
> 22 February 2023
|
|
441
|
+
|
|
442
|
+
- Release 2.7.0-next.2 [`2687751`](https://github.com/oceanprotocol/ocean.js/commit/26877517ff8a7537729e37cf6c68260ca3b3bcf4)
|
|
443
|
+
- fix isValid provider method [`010306c`](https://github.com/oceanprotocol/ocean.js/commit/010306c92e003021b08df0b8b8ad6743ae6b240c)
|
|
444
|
+
|
|
445
|
+
#### [v2.7.0-next.1](https://github.com/oceanprotocol/ocean.js/compare/v2.7.0-next.0...v2.7.0-next.1)
|
|
446
|
+
|
|
447
|
+
> 22 February 2023
|
|
448
|
+
|
|
449
|
+
- Release 2.7.0-next.0 [`500062b`](https://github.com/oceanprotocol/ocean.js/commit/500062beb575b21ab7210a675bdf5174d11842c8)
|
|
450
|
+
- Updating CodeExamples.md [`6cc891a`](https://github.com/oceanprotocol/ocean.js/commit/6cc891a5da9e4042e3eee243b651e8a7188d1786)
|
|
451
|
+
- Release 2.7.0-next.1 [`ba27412`](https://github.com/oceanprotocol/ocean.js/commit/ba2741296167de4c112560f2807b1a45e86eba94)
|
|
452
|
+
|
|
453
|
+
#### [v2.7.0-next.0](https://github.com/oceanprotocol/ocean.js/compare/v2.6.3...v2.7.0-next.0)
|
|
454
|
+
|
|
455
|
+
> 21 February 2023
|
|
456
|
+
|
|
457
|
+
- add needed multichain provider changes [`95551ee`](https://github.com/oceanprotocol/ocean.js/commit/95551eeb669395357149dd923ecec304955add14)
|
|
458
|
+
- Release 2.7.0-next.0 [`95886a1`](https://github.com/oceanprotocol/ocean.js/commit/95886a184faadd4a13e857e285e016ef4c20966f)
|
|
459
|
+
- fix code example [`c4a00e4`](https://github.com/oceanprotocol/ocean.js/commit/c4a00e45848ace6a4fe3d4fa1a2aeac518aa44ce)
|
|
460
|
+
|
|
393
461
|
#### [v2.6.3](https://github.com/oceanprotocol/ocean.js/compare/v2.6.2...v2.6.3)
|
|
394
462
|
|
|
395
463
|
> 13 February 2023
|
|
@@ -691,7 +759,21 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
691
759
|
- Bump typedoc from 0.22.15 to 0.22.17 [`#1514`](https://github.com/oceanprotocol/ocean.js/pull/1514)
|
|
692
760
|
- Release 1.1.3 [`7772e93`](https://github.com/oceanprotocol/ocean.js/commit/7772e9387ef9d63f98ea80cfd4eefbea963dd0ad)
|
|
693
761
|
|
|
694
|
-
#### [v1.1.2](https://github.com/oceanprotocol/ocean.js/compare/v1.
|
|
762
|
+
#### [v1.1.2](https://github.com/oceanprotocol/ocean.js/compare/v1.1.1...v1.1.2)
|
|
763
|
+
|
|
764
|
+
> 15 June 2022
|
|
765
|
+
|
|
766
|
+
- Release 1.1.2 [`85bf271`](https://github.com/oceanprotocol/ocean.js/commit/85bf2716e26d8691aeb9d5504e563d557419dc2e)
|
|
767
|
+
- manual bump fix [`5674a54`](https://github.com/oceanprotocol/ocean.js/commit/5674a547d1d367ce88b3595f0be8ebbf12274266)
|
|
768
|
+
|
|
769
|
+
#### [v1.1.1](https://github.com/oceanprotocol/ocean.js/compare/v1.1.0...v1.1.1)
|
|
770
|
+
|
|
771
|
+
> 15 June 2022
|
|
772
|
+
|
|
773
|
+
- Release 1.1.1 [`ea48e01`](https://github.com/oceanprotocol/ocean.js/commit/ea48e015ac8299f71d57a929f8f30c5d1a8446e7)
|
|
774
|
+
- manual bump fix [`a362410`](https://github.com/oceanprotocol/ocean.js/commit/a36241004b1d9578ec5c02d9d6e64d9750c53a7b)
|
|
775
|
+
|
|
776
|
+
#### [v1.1.0](https://github.com/oceanprotocol/ocean.js/compare/v1.0.0...v1.1.0)
|
|
695
777
|
|
|
696
778
|
> 15 June 2022
|
|
697
779
|
|
|
@@ -699,9 +781,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
699
781
|
- Bump @types/node from 17.0.35 to 17.0.44 [`#1513`](https://github.com/oceanprotocol/ocean.js/pull/1513)
|
|
700
782
|
- Bump eslint-config-oceanprotocol from 1.5.0 to 2.0.1 [`#1466`](https://github.com/oceanprotocol/ocean.js/pull/1466)
|
|
701
783
|
- update to new schema & compute fixes [`#1510`](https://github.com/oceanprotocol/ocean.js/pull/1510)
|
|
702
|
-
- Release 1.1.
|
|
703
|
-
- manual bump fix [`5674a54`](https://github.com/oceanprotocol/ocean.js/commit/5674a547d1d367ce88b3595f0be8ebbf12274266)
|
|
704
|
-
- manual bump fix [`a362410`](https://github.com/oceanprotocol/ocean.js/commit/a36241004b1d9578ec5c02d9d6e64d9750c53a7b)
|
|
784
|
+
- Release 1.1.0 [`112c27e`](https://github.com/oceanprotocol/ocean.js/commit/112c27edab58ef0681ea3e87fb09978411924753)
|
|
705
785
|
|
|
706
786
|
### [v1.0.0](https://github.com/oceanprotocol/ocean.js/compare/v1.0.0-next.45...v1.0.0)
|
|
707
787
|
|
package/CodeExamples.md
CHANGED
|
@@ -105,11 +105,10 @@ import {
|
|
|
105
105
|
ConfigHelper,
|
|
106
106
|
configHelperNetworks,
|
|
107
107
|
amountToUnits,
|
|
108
|
-
ValidateMetadata,
|
|
109
108
|
getEventFromTx,
|
|
110
|
-
DDO,
|
|
111
109
|
LoggerInstance
|
|
112
110
|
} from '../../src/index.js'
|
|
111
|
+
import { DDO, ValidateMetadata } from '@oceanprotocol/ddo-js'
|
|
113
112
|
```
|
|
114
113
|
const { SHA256 } = crypto
|
|
115
114
|
|
|
@@ -136,7 +135,7 @@ Now we define the variables which we will need later
|
|
|
136
135
|
let dispenserNftAddress: string
|
|
137
136
|
let dispenserDatatokenAddress: string
|
|
138
137
|
let dispenserAddress: string
|
|
139
|
-
let fixedDDO
|
|
138
|
+
let fixedDDO: DDO
|
|
140
139
|
```
|
|
141
140
|
|
|
142
141
|
We also define some constants that we will use:
|
|
@@ -208,9 +207,11 @@ Next, we define the metadata that will describe our data asset. This is what we
|
|
|
208
207
|
const config = new ConfigHelper().getConfig(
|
|
209
208
|
parseInt(String((await publisherAccount.provider.getNetwork()).chainId))
|
|
210
209
|
)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
if (process.env.OCEAN_NODE_URL) {
|
|
211
|
+
config.oceanNodeUri = process.env.OCEAN_NODE_URL
|
|
212
|
+
}
|
|
213
|
+
aquarius = new Aquarius(config?.oceanNodeUri)
|
|
214
|
+
providerUrl = config?.oceanNodeUri
|
|
214
215
|
addresses = JSON.parse(
|
|
215
216
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
216
217
|
fs.readFileSync(
|
|
@@ -222,7 +223,7 @@ Next, we define the metadata that will describe our data asset. This is what we
|
|
|
222
223
|
```
|
|
223
224
|
As we go along it's a good idea to console log the values so that you check they are right
|
|
224
225
|
```Typescript
|
|
225
|
-
console.log(`
|
|
226
|
+
console.log(`Indexer URL: ${config.oceanNodeUri}`)
|
|
226
227
|
console.log(`Provider URL: ${providerUrl}`)
|
|
227
228
|
console.log(`Deployed contracts address: ${addresses}`)
|
|
228
229
|
console.log(`Publisher account address: ${await publisherAccount.getAddress()}`)
|
|
@@ -487,9 +488,11 @@ Before we call the contract we have to call `approve` so that the contract can m
|
|
|
487
488
|
consumerAccount,
|
|
488
489
|
await consumerAccount.getChainId()
|
|
489
490
|
)
|
|
491
|
+
|
|
490
492
|
```
|
|
491
493
|
Now we can make the contract call
|
|
492
494
|
```Typescript
|
|
495
|
+
|
|
493
496
|
await fixedRate.buyDatatokens(freId, '1', '2')
|
|
494
497
|
|
|
495
498
|
consumerOCEANBalance = await balance(
|
|
@@ -530,6 +533,17 @@ Next, we need to initialize the provider
|
|
|
530
533
|
validUntil: initializeData.providerFee.validUntil
|
|
531
534
|
}
|
|
532
535
|
|
|
536
|
+
console.log(`Provider fee amount: ${providerFees.providerFeeAmount}`)
|
|
537
|
+
|
|
538
|
+
const approveTx = await approve(
|
|
539
|
+
consumerAccount,
|
|
540
|
+
config,
|
|
541
|
+
await consumerAccount.getAddress(),
|
|
542
|
+
freDatatokenAddress,
|
|
543
|
+
providerFees.providerFeeAddress,
|
|
544
|
+
providerFees.providerFeeAmount
|
|
545
|
+
)
|
|
546
|
+
|
|
533
547
|
datatoken = new Datatoken(consumerAccount, await consumerAccount.getChainId())
|
|
534
548
|
|
|
535
549
|
```
|
|
@@ -543,6 +557,8 @@ Lets now make the payment
|
|
|
543
557
|
)
|
|
544
558
|
const orderTx = await tx.wait()
|
|
545
559
|
const orderStartedTx = getEventFromTx(orderTx, 'OrderStarted')
|
|
560
|
+
console.log(`Order started, tx: ${orderStartedTx.transactionHash}`)
|
|
561
|
+
|
|
546
562
|
```
|
|
547
563
|
Now we can get the url
|
|
548
564
|
```Typescript
|
|
@@ -580,8 +596,10 @@ Lets check that the download URL was successfully received
|
|
|
580
596
|
LoggerInstance.error('Download failed', e)
|
|
581
597
|
assert.fail('Download failed')
|
|
582
598
|
}
|
|
583
|
-
|
|
584
599
|
```
|
|
600
|
+
<!--
|
|
601
|
+
}).timeout(40000)
|
|
602
|
+
-->
|
|
585
603
|
|
|
586
604
|
## 8. Publish Data NFT and a Datatoken with a dispenser
|
|
587
605
|
|
|
@@ -639,9 +657,10 @@ Lets check that we managed to received all of those values without any problems
|
|
|
639
657
|
console.log(`Dispenser NFT address: ${dispenserNftAddress}`)
|
|
640
658
|
console.log(`Dispenser Datatoken address: ${dispenserDatatokenAddress}`)
|
|
641
659
|
console.log(`Dispenser address: ${dispenserAddress}`)
|
|
642
|
-
|
|
643
660
|
```
|
|
644
|
-
|
|
661
|
+
<!--
|
|
662
|
+
}).timeout(40000)
|
|
663
|
+
-->
|
|
645
664
|
### 8.2 Set metadata in the dispenser NFT
|
|
646
665
|
```Typescript
|
|
647
666
|
const nft = new Nft(
|
|
@@ -689,8 +708,10 @@ Now we need to encrypt file(s) using provider
|
|
|
689
708
|
encryptedDDO,
|
|
690
709
|
isAssetValid.hash
|
|
691
710
|
)
|
|
692
|
-
|
|
693
711
|
```
|
|
712
|
+
<!--
|
|
713
|
+
}).timeout(40000)
|
|
714
|
+
-->
|
|
694
715
|
|
|
695
716
|
## 9. Consume a dispenser data asset
|
|
696
717
|
|
|
@@ -793,8 +814,10 @@ Let's check we received the download URL ok
|
|
|
793
814
|
} catch (e) {
|
|
794
815
|
assert.fail('Download failed')
|
|
795
816
|
}
|
|
796
|
-
|
|
797
817
|
```
|
|
818
|
+
<!--
|
|
819
|
+
}).timeout(40000)
|
|
820
|
+
-->
|
|
798
821
|
|
|
799
822
|
## 10. Using ERC725 Key-Value Store
|
|
800
823
|
|
|
@@ -848,7 +871,9 @@ Use the `getData` method to get the data stored in the nft key value store
|
|
|
848
871
|
```
|
|
849
872
|
|
|
850
873
|
That's it! Note the simplicity. All data was stored and retrieved from on-chain. We don't need Ocean Provider or Ocean Aquarius for these use cases (though the latter can help for fast querying & retrieval).
|
|
851
|
-
|
|
874
|
+
<!--
|
|
875
|
+
}).timeout(40000)
|
|
876
|
+
-->
|
|
852
877
|
|
|
853
878
|
|
|
854
879
|
## Editing this file
|
package/ComputeExamples.md
CHANGED
|
@@ -12,7 +12,7 @@ Here are the steps:
|
|
|
12
12
|
7. [Resolve published datasets and algorithms](#7-resolve-assets)
|
|
13
13
|
8. [Send datatokens to consumer](#8-send-datatokens-to-consumer)
|
|
14
14
|
9. [Consumer fetches compute environment](#9-get-compute-environments)
|
|
15
|
-
10. [Consumer starts a compute job using a free C2D environment](#10-consumer-starts-a-compute-job)
|
|
15
|
+
10. [Consumer starts a free compute job using a free C2D environment](#10-consumer-starts-a-compute-job)
|
|
16
16
|
11. [Check compute status and get download compute results url](#11-check-compute-status-and-get-download-compute-results-url)
|
|
17
17
|
|
|
18
18
|
Let's go through each step.
|
|
@@ -136,7 +136,6 @@ import {
|
|
|
136
136
|
ComputeAsset,
|
|
137
137
|
Config,
|
|
138
138
|
Files,
|
|
139
|
-
DDO,
|
|
140
139
|
NftCreateData,
|
|
141
140
|
DatatokenCreateParams,
|
|
142
141
|
sendTx,
|
|
@@ -148,6 +147,7 @@ import {
|
|
|
148
147
|
} from '../../src/index.js'
|
|
149
148
|
```
|
|
150
149
|
import crypto from 'crypto-js'
|
|
150
|
+
import { DDO } from '@oceanprotocol/ddo-js'
|
|
151
151
|
const { SHA256 } = crypto
|
|
152
152
|
|
|
153
153
|
### 4.2. Constants and variables
|
|
@@ -342,7 +342,7 @@ async function createAssetHelper(
|
|
|
342
342
|
assetUrl.nftAddress = nftAddress
|
|
343
343
|
ddo.services[0].files = await ProviderInstance.encrypt(assetUrl, chain, providerUrl)
|
|
344
344
|
ddo.services[0].datatokenAddress = datatokenAddressAsset
|
|
345
|
-
ddo.services[0].serviceEndpoint =
|
|
345
|
+
ddo.services[0].serviceEndpoint = providerUrl
|
|
346
346
|
|
|
347
347
|
ddo.nftAddress = nftAddress
|
|
348
348
|
ddo.id = 'did:op:' + SHA256(ethers.utils.getAddress(nftAddress) + chain.toString(10))
|
|
@@ -353,7 +353,7 @@ async function createAssetHelper(
|
|
|
353
353
|
nftAddress,
|
|
354
354
|
await owner.getAddress(),
|
|
355
355
|
0,
|
|
356
|
-
|
|
356
|
+
providerUrl,
|
|
357
357
|
'',
|
|
358
358
|
ethers.utils.hexlify(2),
|
|
359
359
|
encryptedResponse,
|
|
@@ -428,9 +428,11 @@ We need to load the configuration. Add the following code into your `run(){ }` f
|
|
|
428
428
|
const config = new ConfigHelper().getConfig(
|
|
429
429
|
parseInt(String((await publisherAccount.provider.getNetwork()).chainId))
|
|
430
430
|
)
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
431
|
+
if (process.env.OCEAN_NODE_URL) {
|
|
432
|
+
config.oceanNodeUri = process.env.OCEAN_NODE_URL
|
|
433
|
+
}
|
|
434
|
+
aquariusInstance = new Aquarius(config?.oceanNodeUri)
|
|
435
|
+
providerUrl = config?.oceanNodeUri
|
|
434
436
|
addresses = JSON.parse(
|
|
435
437
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
436
438
|
fs.readFileSync(
|
|
@@ -443,7 +445,7 @@ We need to load the configuration. Add the following code into your `run(){ }` f
|
|
|
443
445
|
```
|
|
444
446
|
As we go along it's a good idea to console log the values so that you check they are right. At the end of your `run(){ ... }` function add the following logs:
|
|
445
447
|
```Typescript
|
|
446
|
-
console.log(`
|
|
448
|
+
console.log(`Indexer URL: ${config.oceanNodeUri}`)
|
|
447
449
|
console.log(`Provider URL: ${providerUrl}`)
|
|
448
450
|
console.log(`Deployed contracts address: ${addresses}`)
|
|
449
451
|
console.log(`Publisher account address: ${publisherAccount}`)
|
|
@@ -489,8 +491,10 @@ you need to mint oceans to mentioned accounts only if you are using barge to tes
|
|
|
489
491
|
await publisherAccount.getAddress(),
|
|
490
492
|
amountToUnits(null, null, '1000', 18)
|
|
491
493
|
)
|
|
492
|
-
|
|
493
494
|
```
|
|
495
|
+
<!--
|
|
496
|
+
}).timeout(40000) ///
|
|
497
|
+
--->
|
|
494
498
|
|
|
495
499
|
### 5.2 Send some OCEAN to consumer account
|
|
496
500
|
```Typescript
|
|
@@ -520,8 +524,10 @@ you need to mint oceans to mentioned accounts only if you are using barge to tes
|
|
|
520
524
|
Now, let's check that we successfully published a dataset (create NFT + Datatoken)
|
|
521
525
|
```Typescript
|
|
522
526
|
console.log(`dataset id: ${datasetId}`)
|
|
523
|
-
|
|
524
527
|
```
|
|
528
|
+
<!--
|
|
529
|
+
}).timeout(40000)
|
|
530
|
+
-->
|
|
525
531
|
|
|
526
532
|
### 6.2 Publish an algorithm (create NFT + Datatoken) and set algorithm metadata
|
|
527
533
|
```Typescript
|
|
@@ -537,9 +543,10 @@ Now, let's check that we successfully published a dataset (create NFT + Datatoke
|
|
|
537
543
|
Now, let's check that we successfully published a algorithm (create NFT + Datatoken)
|
|
538
544
|
```Typescript
|
|
539
545
|
console.log(`algorithm id: ${algorithmId}`)
|
|
540
|
-
|
|
541
546
|
```
|
|
542
|
-
|
|
547
|
+
<!--
|
|
548
|
+
}).timeout(40000)
|
|
549
|
+
-->
|
|
543
550
|
## 7. Resolve assets
|
|
544
551
|
|
|
545
552
|
### 7.1 Resolve published datasets and algorithms
|
|
@@ -550,8 +557,8 @@ Now, let's check that we successfully published a algorithm (create NFT + Datato
|
|
|
550
557
|
<!--
|
|
551
558
|
assert(resolvedDatasetDdo, 'Cannot fetch DDO from Aquarius')
|
|
552
559
|
assert(resolvedAlgorithmDdo, 'Cannot fetch DDO from Aquarius')
|
|
560
|
+
}).timeout(80000)
|
|
553
561
|
-->
|
|
554
|
-
|
|
555
562
|
|
|
556
563
|
## 8. Send datatokens to consumer
|
|
557
564
|
|
|
@@ -574,8 +581,10 @@ Now, let's check that we successfully published a algorithm (create NFT + Datato
|
|
|
574
581
|
'10',
|
|
575
582
|
await consumerAccount.getAddress()
|
|
576
583
|
)
|
|
577
|
-
|
|
578
584
|
```
|
|
585
|
+
<!--
|
|
586
|
+
}).timeout(40000)
|
|
587
|
+
-->
|
|
579
588
|
|
|
580
589
|
## 9. Get compute environments
|
|
581
590
|
|
|
@@ -585,21 +594,24 @@ Now, let's check that we successfully published a algorithm (create NFT + Datato
|
|
|
585
594
|
```
|
|
586
595
|
<!--
|
|
587
596
|
assert(computeEnvs, 'No Compute environments found')
|
|
597
|
+
}).timeout(40000)
|
|
588
598
|
-->
|
|
589
|
-
|
|
590
599
|
|
|
591
|
-
## 10. Consumer starts a compute job
|
|
600
|
+
## 10. Consumer starts a free compute job
|
|
592
601
|
|
|
593
602
|
### 10.1 Start a compute job using a free C2D environment
|
|
603
|
+
<!--
|
|
594
604
|
datatoken = new Datatoken(
|
|
595
605
|
consumerAccount,
|
|
596
606
|
(await consumerAccount.provider.getNetwork()).chainId
|
|
597
607
|
)
|
|
608
|
+
-->
|
|
598
609
|
|
|
599
610
|
let's check the free compute environment
|
|
600
611
|
```Typescript
|
|
601
|
-
const computeEnv = computeEnvs
|
|
602
|
-
(ce) =>
|
|
612
|
+
const computeEnv = computeEnvs.find(
|
|
613
|
+
(ce) =>
|
|
614
|
+
!ce?.fees || ce.fees.find((fee) => fee.symbol === 'OCEAN' && fee.amount === '0')
|
|
603
615
|
)
|
|
604
616
|
console.log('Free compute environment = ', computeEnv)
|
|
605
617
|
```
|
|
@@ -607,9 +619,12 @@ let's check the free compute environment
|
|
|
607
619
|
assert(computeEnv, 'Cannot find the free compute env')
|
|
608
620
|
-->
|
|
609
621
|
|
|
622
|
+
<!--
|
|
610
623
|
computeRoutePath = await ProviderInstance.getComputeStartRoutes(providerUrl, true)
|
|
611
624
|
if (isDefined(computeRoutePath)) {
|
|
612
625
|
hasFreeComputeSupport = true
|
|
626
|
+
-->
|
|
627
|
+
|
|
613
628
|
Let's have 5 minute of compute access
|
|
614
629
|
```Typescript
|
|
615
630
|
const mytime = new Date()
|
|
@@ -617,6 +632,9 @@ let's check the free compute environment
|
|
|
617
632
|
mytime.setMinutes(mytime.getMinutes() + computeMinutes)
|
|
618
633
|
const computeValidUntil = Math.floor(mytime.getTime() / 1000)
|
|
619
634
|
|
|
635
|
+
```
|
|
636
|
+
Let's prepare the dataset and algorithm assets to be used in the compute job
|
|
637
|
+
```Typescript
|
|
620
638
|
const assets: ComputeAsset[] = [
|
|
621
639
|
{
|
|
622
640
|
documentId: resolvedDatasetDdo.id,
|
|
@@ -624,41 +642,49 @@ let's check the free compute environment
|
|
|
624
642
|
}
|
|
625
643
|
]
|
|
626
644
|
const dtAddressArray = [resolvedDatasetDdo.services[0].datatokenAddress]
|
|
645
|
+
|
|
627
646
|
const algo: ComputeAlgorithm = {
|
|
628
647
|
documentId: resolvedAlgorithmDdo.id,
|
|
629
|
-
serviceId: resolvedAlgorithmDdo.services[0].id
|
|
648
|
+
serviceId: resolvedAlgorithmDdo.services[0].id,
|
|
649
|
+
meta: resolvedAlgorithmDdo.metadata.algorithm
|
|
630
650
|
}
|
|
631
|
-
|
|
632
|
-
const providerInitializeComputeResults = await ProviderInstance.initializeCompute(
|
|
633
|
-
assets,
|
|
634
|
-
algo,
|
|
635
|
-
computeEnv.id,
|
|
636
|
-
computeValidUntil,
|
|
637
|
-
providerUrl,
|
|
638
|
-
consumerAccount
|
|
639
|
-
)
|
|
640
651
|
```
|
|
652
|
+
|
|
641
653
|
<!--
|
|
642
|
-
|
|
654
|
+
// const providerInitializeComputeResults = await ProviderInstance.initializeCompute(
|
|
655
|
+
// assets,
|
|
656
|
+
// algo,
|
|
657
|
+
// computeEnv.id,
|
|
658
|
+
// computeValidUntil,
|
|
659
|
+
// providerUrl,
|
|
660
|
+
// consumerAccount
|
|
661
|
+
// )
|
|
662
|
+
// console.log('providerInitializeComputeResults = ', providerInitializeComputeResults)
|
|
663
|
+
//
|
|
664
|
+
//
|
|
665
|
+
// assert(!('error' in providerInitializeComputeResults), 'Cannot order algorithm')
|
|
666
|
+
//
|
|
667
|
+
//
|
|
668
|
+
// algo.transferTxId = await handleOrder(
|
|
669
|
+
// providerInitializeComputeResults.algorithm,
|
|
670
|
+
// resolvedAlgorithmDdo.services[0].datatokenAddress,
|
|
671
|
+
// consumerAccount,
|
|
672
|
+
// computeEnv.consumerAddress,
|
|
673
|
+
// 0
|
|
674
|
+
// )
|
|
675
|
+
// for (let i = 0; i < providerInitializeComputeResults.datasets.length; i++) {
|
|
676
|
+
// assets[i].transferTxId = await handleOrder(
|
|
677
|
+
// providerInitializeComputeResults.datasets[i],
|
|
678
|
+
// dtAddressArray[i],
|
|
679
|
+
// consumerAccount,
|
|
680
|
+
// computeEnv.consumerAddress,
|
|
681
|
+
// 0
|
|
682
|
+
// )
|
|
683
|
+
// }
|
|
643
684
|
-->
|
|
644
|
-
```Typescript
|
|
645
|
-
algo.transferTxId = await handleOrder(
|
|
646
|
-
providerInitializeComputeResults.algorithm,
|
|
647
|
-
resolvedAlgorithmDdo.services[0].datatokenAddress,
|
|
648
|
-
consumerAccount,
|
|
649
|
-
computeEnv.consumerAddress,
|
|
650
|
-
0
|
|
651
|
-
)
|
|
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
|
-
}
|
|
661
685
|
|
|
686
|
+
Let's start the free compute job
|
|
687
|
+
```Typescript
|
|
662
688
|
const computeJobs = await ProviderInstance.freeComputeStart(
|
|
663
689
|
providerUrl,
|
|
664
690
|
consumerAccount,
|
|
@@ -666,16 +692,19 @@ let's check the free compute environment
|
|
|
666
692
|
assets,
|
|
667
693
|
algo
|
|
668
694
|
)
|
|
669
|
-
|
|
670
695
|
```
|
|
696
|
+
|
|
671
697
|
<!--
|
|
672
698
|
assert(computeJobs, 'Cannot start compute job')
|
|
673
699
|
-->
|
|
700
|
+
|
|
674
701
|
Let's save the compute job it, we re going to use later
|
|
675
702
|
```Typescript
|
|
676
703
|
computeJobId = computeJobs[0].jobId
|
|
677
704
|
// eslint-disable-next-line prefer-destructuring
|
|
678
705
|
agreementId = computeJobs[0].agreementId
|
|
706
|
+
```
|
|
707
|
+
<!--
|
|
679
708
|
} else {
|
|
680
709
|
assert(
|
|
681
710
|
computeRoutePath === null,
|
|
@@ -683,17 +712,19 @@ let's check the free compute environment
|
|
|
683
712
|
)
|
|
684
713
|
hasFreeComputeSupport = false
|
|
685
714
|
}
|
|
686
|
-
|
|
687
|
-
|
|
715
|
+
}).timeout(40000)
|
|
716
|
+
-->
|
|
688
717
|
|
|
689
718
|
## 11. Check compute status and get download compute results URL
|
|
690
719
|
### 11.1 Check compute status
|
|
720
|
+
<!--
|
|
691
721
|
if (!hasFreeComputeSupport) {
|
|
692
722
|
assert(
|
|
693
723
|
computeRoutePath === null,
|
|
694
724
|
'Compute route path for free compute is not defined (perhaps because provider does not support it yet?)'
|
|
695
725
|
)
|
|
696
726
|
} else {
|
|
727
|
+
-->
|
|
697
728
|
You can also add various delays so you see the various states of the compute job
|
|
698
729
|
```Typescript
|
|
699
730
|
const jobStatus = await ProviderInstance.computeStatus(
|
|
@@ -709,17 +740,22 @@ let's check the free compute environment
|
|
|
709
740
|
Now, let's see the current status of the previously started computer job
|
|
710
741
|
```Typescript
|
|
711
742
|
console.log('Current status of the compute job: ', jobStatus)
|
|
743
|
+
```
|
|
744
|
+
<!--
|
|
712
745
|
}
|
|
713
|
-
|
|
714
|
-
|
|
746
|
+
}).timeout(40000)
|
|
747
|
+
-->
|
|
715
748
|
|
|
716
749
|
### 11.2 Get download compute results URL
|
|
750
|
+
<!--
|
|
717
751
|
if (!hasFreeComputeSupport) {
|
|
718
752
|
assert(
|
|
719
753
|
computeRoutePath === null,
|
|
720
754
|
'Compute route path for free compute is not defined (perhaps because provider does not support it yet?)'
|
|
721
755
|
)
|
|
722
756
|
} else {
|
|
757
|
+
-->
|
|
758
|
+
|
|
723
759
|
```Typescript
|
|
724
760
|
await sleep(10000)
|
|
725
761
|
const downloadURL = await ProviderInstance.getComputeResultUrl(
|
|
@@ -735,10 +771,12 @@ let's check the free compute environment
|
|
|
735
771
|
Let's check the compute results url for the specified index
|
|
736
772
|
```Typescript
|
|
737
773
|
console.log(`Compute results URL: ${downloadURL}`)
|
|
774
|
+
```
|
|
775
|
+
<!--
|
|
738
776
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
777
|
+
}).timeout(40000)
|
|
778
|
+
})
|
|
779
|
+
-->
|
|
742
780
|
|
|
743
781
|
## Editing this file
|
|
744
782
|
Please note that ComputeExamples.md is an autogenerated file, you should not edit it directly.
|