@oceanprotocol/lib 7.0.0-next.4 → 7.0.0-next.6

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 (98) hide show
  1. package/dist/lib.cjs +1 -1
  2. package/dist/lib.module.mjs +1 -1
  3. package/dist/lib.umd.js +1 -1
  4. package/package.json +8 -5
  5. package/.mocharc.json +0 -8
  6. package/.nvmrc +0 -1
  7. package/CHANGELOG.md +0 -3256
  8. package/Cheatsheet.md +0 -326
  9. package/CodeExamples.md +0 -881
  10. package/ComputeExamples.md +0 -941
  11. package/dist/lib.cjs.map +0 -1
  12. package/dist/lib.module.mjs.map +0 -1
  13. package/dist/lib.umd.js.map +0 -1
  14. package/docs/.nojekyll +0 -1
  15. package/docs/README.md +0 -195
  16. package/docs/classes/Aquarius.md +0 -175
  17. package/docs/classes/Config.md +0 -481
  18. package/docs/classes/ConfigHelper.md +0 -66
  19. package/docs/classes/Datatoken.md +0 -1123
  20. package/docs/classes/Dispenser.md +0 -502
  21. package/docs/classes/Escrow.md +0 -285
  22. package/docs/classes/FixedRateExchange.md +0 -1068
  23. package/docs/classes/Logger.md +0 -191
  24. package/docs/classes/Nft.md +0 -970
  25. package/docs/classes/NftFactory.md +0 -861
  26. package/docs/classes/Provider.md +0 -727
  27. package/docs/classes/Router.md +0 -645
  28. package/docs/classes/SmartContract.md +0 -193
  29. package/docs/classes/SmartContractWithAddress.md +0 -268
  30. package/docs/enums/LogLevel.md +0 -63
  31. package/docs/interfaces/AbiInput.md +0 -63
  32. package/docs/interfaces/AbiItem.md +0 -107
  33. package/docs/interfaces/AbiOutput.md +0 -52
  34. package/docs/interfaces/Arweave.md +0 -32
  35. package/docs/interfaces/Asset.md +0 -227
  36. package/docs/interfaces/AssetDatatoken.md +0 -60
  37. package/docs/interfaces/AssetLastEvent.md +0 -63
  38. package/docs/interfaces/AssetNft.md +0 -105
  39. package/docs/interfaces/AssetPrice.md +0 -47
  40. package/docs/interfaces/ComputeAlgorithm.md +0 -82
  41. package/docs/interfaces/ComputeAsset.md +0 -56
  42. package/docs/interfaces/ComputeEnvFees.md +0 -30
  43. package/docs/interfaces/ComputeEnvFeesStructure.md +0 -20
  44. package/docs/interfaces/ComputeEnvironment.md +0 -177
  45. package/docs/interfaces/ComputeJob.md +0 -173
  46. package/docs/interfaces/ComputeOutput.md +0 -118
  47. package/docs/interfaces/ComputeResourcesPricingInfo.md +0 -30
  48. package/docs/interfaces/ComputeResourcesRequest.md +0 -34
  49. package/docs/interfaces/ComputeResult.md +0 -52
  50. package/docs/interfaces/ConsumeMarketFee.md +0 -41
  51. package/docs/interfaces/Credential.md +0 -30
  52. package/docs/interfaces/Credentials.md +0 -30
  53. package/docs/interfaces/DDO.md +0 -137
  54. package/docs/interfaces/DatatokenCreateParams.md +0 -107
  55. package/docs/interfaces/DatatokenRoles.md +0 -30
  56. package/docs/interfaces/DispenserCreationParams.md +0 -63
  57. package/docs/interfaces/DispenserParams.md +0 -52
  58. package/docs/interfaces/DispenserToken.md +0 -85
  59. package/docs/interfaces/DownloadResponse.md +0 -30
  60. package/docs/interfaces/Event.md +0 -73
  61. package/docs/interfaces/FeesInfo.md +0 -74
  62. package/docs/interfaces/FileInfo.md +0 -118
  63. package/docs/interfaces/Files.md +0 -41
  64. package/docs/interfaces/FixedPriceExchange.md +0 -162
  65. package/docs/interfaces/FreCreationParams.md +0 -118
  66. package/docs/interfaces/FreOrderParams.md +0 -85
  67. package/docs/interfaces/GraphqlQuery.md +0 -69
  68. package/docs/interfaces/Ipfs.md +0 -32
  69. package/docs/interfaces/Metadata.md +0 -193
  70. package/docs/interfaces/MetadataAlgorithm.md +0 -69
  71. package/docs/interfaces/MetadataAndTokenURI.md +0 -107
  72. package/docs/interfaces/MetadataProof.md +0 -52
  73. package/docs/interfaces/NftCreateData.md +0 -74
  74. package/docs/interfaces/NftRoles.md +0 -52
  75. package/docs/interfaces/Operation.md +0 -145
  76. package/docs/interfaces/OrderParams.md +0 -52
  77. package/docs/interfaces/PriceAndFees.md +0 -52
  78. package/docs/interfaces/ProviderComputeInitialize.md +0 -41
  79. package/docs/interfaces/ProviderComputeInitializeResults.md +0 -43
  80. package/docs/interfaces/ProviderFees.md +0 -96
  81. package/docs/interfaces/ProviderInitialize.md +0 -52
  82. package/docs/interfaces/PublisherTrustedAlgorithm.md +0 -47
  83. package/docs/interfaces/PublishingMarketFee.md +0 -41
  84. package/docs/interfaces/Purgatory.md +0 -34
  85. package/docs/interfaces/RunningPlatform.md +0 -30
  86. package/docs/interfaces/SearchQuery.md +0 -67
  87. package/docs/interfaces/Service.md +0 -138
  88. package/docs/interfaces/ServiceComputeOptions.md +0 -63
  89. package/docs/interfaces/ServiceEndpoint.md +0 -41
  90. package/docs/interfaces/Smartcontract-1.md +0 -58
  91. package/docs/interfaces/Stats.md +0 -47
  92. package/docs/interfaces/Template.md +0 -30
  93. package/docs/interfaces/TokenOrder.md +0 -63
  94. package/docs/interfaces/UrlFile.md +0 -71
  95. package/docs/interfaces/UserCustomParameters.md +0 -7
  96. package/docs/interfaces/ValidateMetadata.md +0 -52
  97. package/docs/modules.md +0 -850
  98. package/typedoc.json +0 -4
package/Cheatsheet.md DELETED
@@ -1,326 +0,0 @@
1
- # Ocean.js Cheatsheet
2
-
3
- ## Prerequisites
4
- - Git, Node.js, Docker
5
- - Install Git: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
6
- - Node.js: https://nodejs.org/en/download/
7
- - Docker: https://docs.docker.com/get-docker/
8
-
9
- ### Installation & Usage
10
-
11
- ```bash
12
- npm init
13
- npm install @oceanprotocol/lib crypto-js ethers typescript @types/node ts-node
14
- ```
15
-
16
- ### Configuration
17
-
18
- ```bash
19
- export NODE_URL='https://compute1.oceanprotocol.com'
20
- export PRIVATE_KEY=<replace_me>
21
- export RPC=<replace_me>
22
- ```
23
-
24
- ### Publish Flow
25
-
26
- 1. Define DDO object
27
- ```javascript
28
-
29
- const genericAsset: DDO = {
30
- '@context': ['https://w3id.org/did/v1'],
31
- id: 'did:op',
32
- version: '4.1.0',
33
- chainId: 8996,
34
- nftAddress: '0x0',
35
- metadata: {
36
- created: '2021-12-20T14:35:20Z',
37
- updated: '2021-12-20T14:35:20Z',
38
- type: 'dataset',
39
- name: 'dataset-name',
40
- description: 'Ocean protocol test dataset description',
41
- author: 'oceanprotocol-team',
42
- license: 'MIT',
43
- tags: ['white-papers'],
44
- additionalInformation: { 'test-key': 'test-value' },
45
- links: ['http://data.ceda.ac.uk/badc/ukcp09/']
46
- },
47
- services: [
48
- {
49
- id: 'db164c1b981e4d2974e90e61bda121512e6909c1035c908d68933ae4cfaba6b0',
50
- type: 'access',
51
- files: '',
52
- datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3',
53
- serviceEndpoint: 'http://127.0.0.1:8001',
54
- timeout: 0
55
- }
56
- ]
57
- }
58
- ```
59
- 2. Create NFT + datatoken + dispenser/FRE:
60
-
61
- ```javascript
62
-
63
- const { chainId } = await publisherAccount.provider.getNetwork()
64
- const factory = new NftFactory(
65
- addresses.ERC721Factory,
66
- publisherAccount,
67
- Number(chainId)
68
- )
69
-
70
- const nftParams: NftCreateData = {
71
- name: FRE_NFT_NAME,
72
- symbol: FRE_NFT_SYMBOL,
73
- templateIndex: 1,
74
- tokenURI: '',
75
- transferable: true,
76
- owner: await publisherAccount.getAddress()
77
- }
78
-
79
- const datatokenParams: DatatokenCreateParams = {
80
- templateIndex: 1,
81
- cap: '100000',
82
- feeAmount: '0',
83
- paymentCollector: ZERO_ADDRESS,
84
- feeToken: ZERO_ADDRESS,
85
- minter: await publisherAccount.getAddress(),
86
- mpFeeAddress: ZERO_ADDRESS
87
- }
88
-
89
- const freParams: FreCreationParams = {
90
- fixedRateAddress: addresses.FixedPrice,
91
- baseTokenAddress: addresses.Ocean,
92
- owner: await publisherAccount.getAddress(),
93
- marketFeeCollector: await publisherAccount.getAddress(),
94
- baseTokenDecimals: 18,
95
- datatokenDecimals: 18,
96
- fixedRate: '1',
97
- marketFee: '0.001',
98
- allowedConsumer: ZERO_ADDRESS,
99
- withMint: true
100
- }
101
-
102
- const bundleNFT = await factory.createNftWithDatatokenWithFixedRate(
103
- nftParams,
104
- datatokenParams,
105
- freParams
106
- )
107
-
108
- ```
109
- ### Consume Flow
110
- As a prerequisite for this flow, publish flow needs to be executed before.
111
- ```javascript
112
- const fixedRate = new FixedRateExchange(freAddress, consumerAccount, Number(chainId))
113
- await fixedRate.buyDatatokens(freId, '1', '2')
114
-
115
- const resolvedDDO = await aquarius.waitForIndexer(fixedDDO.id)
116
- assert(resolvedDDO, 'Cannot fetch DDO from Aquarius')
117
-
118
- // Initialize - obtain proof for ordering assets
119
-
120
- const initializeData = await ProviderInstance.initialize(
121
- resolvedDDO.id,
122
- resolvedDDO.services[0].id,
123
- 0,
124
- await consumerAccount.getAddress(),
125
- providerUrl
126
- )
127
-
128
- const providerFees: ProviderFees = {
129
- providerFeeAddress: initializeData.providerFee.providerFeeAddress,
130
- providerFeeToken: initializeData.providerFee.providerFeeToken,
131
- providerFeeAmount: initializeData.providerFee.providerFeeAmount,
132
- v: initializeData.providerFee.v,
133
- r: initializeData.providerFee.r,
134
- s: initializeData.providerFee.s,
135
- providerData: initializeData.providerFee.providerData,
136
- validUntil: initializeData.providerFee.validUntil
137
- }
138
- // Starting order after retriving provider fees
139
- const tx = await datatoken.startOrder(
140
- freDatatokenAddress,
141
- await consumerAccount.getAddress(),
142
- 0,
143
- providerFees
144
- )
145
- const orderTx = await tx.wait()
146
- const orderStartedTx = getEventFromTx(orderTx, 'OrderStarted')
147
- console.log(`Order started, tx: ${orderStartedTx.transactionHash}`)
148
-
149
- const downloadURL = await ProviderInstance.getDownloadUrl(
150
- fixedDDO.id,
151
- fixedDDO.services[0].id,
152
- 0,
153
- orderStartedTx.transactionHash,
154
- providerUrl,
155
- consumerAccount
156
- )
157
-
158
- // Lets check that the download URL was successfully received
159
- console.log(`Download URL: ${downloadURL}`)
160
-
161
- ```
162
- For better UX, it is recommended to have installed VSCode extension.
163
- ### Get compute environments
164
-
165
- ```javascript
166
-
167
-
168
- // Fetch compute envrionments first
169
- const computeEnvs = await ProviderInstance.getComputeEnvironments(providerUrl)
170
-
171
- ```
172
- For `free start compute` it is not necessary publish flow.
173
-
174
-
175
- ### Free Start Compute
176
-
177
- ```javascript
178
-
179
- // Let's have 5 minute of compute access
180
- const mytime = new Date()
181
- const computeMinutes = 5
182
- mytime.setMinutes(mytime.getMinutes() + computeMinutes)
183
-
184
- // Let's prepare the dataset and algorithm assets to be used in the compute job
185
- const assets: ComputeAsset[] = [
186
- {
187
- documentId: resolvedDatasetDdo.id,
188
- serviceId: resolvedDatasetDdo.services[0].id
189
- }
190
- ]
191
-
192
- const algo: ComputeAlgorithm = {
193
- documentId: resolvedAlgorithmDdo.id,
194
- serviceId: resolvedAlgorithmDdo.services[0].id,
195
- meta: resolvedAlgorithmDdo.metadata.algorithm
196
- }
197
-
198
- // Let's start the free compute job
199
- const computeJobs = await ProviderInstance.freeComputeStart(
200
- providerUrl,
201
- consumerAccount,
202
- computeEnv.id,
203
- assets,
204
- algo
205
- )
206
-
207
- ```
208
-
209
- ### Paid Start Compute
210
-
211
-
212
- ```javascript
213
-
214
-
215
- const mytime = new Date()
216
- const computeMinutes = 5
217
- mytime.setMinutes(mytime.getMinutes() + computeMinutes)
218
- const computeValidUntil = Math.floor(mytime.getTime() / 1000)
219
-
220
- const resources: ComputeResourceRequest[] = [
221
- {
222
- id: 'cpu',
223
- amount: 2
224
- },
225
- {
226
- id: 'ram',
227
- amount: 2
228
- },
229
- {
230
- id: 'disk',
231
- amount: 0
232
- }
233
- ]
234
- const assets: ComputeAsset[] = [
235
- {
236
- documentId: resolvedDatasetDdo.id,
237
- serviceId: resolvedDatasetDdo.services[0].id
238
- }
239
- ]
240
- const dtAddressArray = [resolvedDatasetDdo.services[0].datatokenAddress]
241
- const algo: ComputeAlgorithm = {
242
- documentId: resolvedAlgorithmDdo.id,
243
- serviceId: resolvedAlgorithmDdo.services[0].id,
244
- meta: resolvedAlgorithmDdo.metadata.algorithm
245
- }
246
-
247
- const providerInitializeComputeResults = await ProviderInstance.initializeCompute(
248
- assets,
249
- algo,
250
- computeEnv.id,
251
- paymentToken,
252
- computeValidUntil,
253
- providerUrl,
254
- consumerAccount,
255
- resources,
256
- Number(chainId)
257
- )
258
- // Initialize payment contract
259
- const escrow = new EscrowContract(
260
- getAddress(providerInitializeComputeResults.payment.escrowAddress),
261
- consumerAccount
262
- )
263
- const amountToDeposit = (providerInitializeComputeResults.payment.amount * 2).toString()
264
- await escrow.verifyFundsForEscrowPayment(
265
- paymentToken,
266
- computeEnv.consumerAddress,
267
- await unitsToAmount(consumerAccount, paymentToken, amountToDeposit),
268
- providerInitializeComputeResults.payment.amount.toString(),
269
- providerInitializeComputeResults.payment.minLockSeconds.toString(),
270
- '10'
271
- )
272
-
273
- algo.transferTxId = await handleOrder(
274
- providerInitializeComputeResults.algorithm,
275
- resolvedAlgorithmDdo.services[0].datatokenAddress,
276
- consumerAccount,
277
- computeEnv.consumerAddress,
278
- 0
279
- )
280
- for (let i = 0; i < providerInitializeComputeResults.datasets.length; i++) {
281
- assets[i].transferTxId = await handleOrder(
282
- providerInitializeComputeResults.datasets[i],
283
- dtAddressArray[i],
284
- consumerAccount,
285
- computeEnv.consumerAddress,
286
- 0
287
- )
288
- }
289
-
290
- const computeJobs = await ProviderInstance.computeStart(
291
- providerUrl,
292
- consumerAccount,
293
- computeEnv.id,
294
- assets,
295
- algo,
296
- computeValidUntil,
297
- paymentToken,
298
- resources,
299
- Number(chainId)
300
- )
301
- ```
302
-
303
- ### Get compute job status
304
-
305
- ```javascript
306
-
307
- const jobStatus = await ProviderInstance.computeStatus(
308
- providerUrl,
309
- await consumerAccount.getAddress(),
310
- computeJobId
311
- )
312
- ```
313
-
314
- ### Get download compute results URL
315
-
316
- ```javascript
317
-
318
- const downloadURL = await ProviderInstance.getComputeResultUrl(
319
- providerUrl,
320
- consumerAccount,
321
- computeJobId,
322
- 0
323
- )
324
-
325
-
326
- ```