@oceanprotocol/lib 0.20.1 → 1.0.0-next.10
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 +139 -0
- package/README.md +1 -1
- package/dist/lib.js +2 -0
- package/dist/lib.js.map +1 -0
- package/dist/lib.modern.js +2 -0
- package/dist/lib.modern.js.map +1 -0
- package/dist/lib.module.js +2 -0
- package/dist/lib.module.js.map +1 -0
- package/dist/lib.umd.js +2 -0
- package/dist/lib.umd.js.map +1 -0
- package/dist/src/@types/Asset.d.ts +36 -0
- package/dist/{node/ocean/interfaces → src/@types}/Compute.d.ts +13 -9
- package/dist/src/@types/DDO/Credentials.d.ts +8 -0
- package/dist/src/@types/DDO/DDO.d.ts +15 -0
- package/dist/src/@types/DDO/Event.d.ts +7 -0
- package/dist/src/@types/DDO/Metadata.d.ts +38 -0
- package/dist/src/@types/DDO/Service.d.ts +28 -0
- package/dist/src/@types/DownloadResponse.d.ts +4 -0
- package/dist/src/@types/FileMetadata.d.ts +9 -0
- package/dist/src/@types/Provider.d.ts +16 -0
- package/dist/src/@types/index.d.ts +8 -0
- package/dist/src/aquarius/Aquarius.d.ts +10 -0
- package/dist/src/aquarius/index.d.ts +1 -0
- package/dist/src/factories/NFTFactory.d.ts +66 -0
- package/dist/src/factories/index.d.ts +1 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/interfaces/DispenserInterface.d.ts +7 -0
- package/dist/src/interfaces/Erc20Interface.d.ts +11 -0
- package/dist/src/interfaces/Erc721Interface.d.ts +12 -0
- package/dist/src/interfaces/FixedRateInterface.d.ts +19 -0
- package/dist/src/interfaces/PoolInterface.d.ts +36 -0
- package/dist/src/interfaces/RouterInterface.d.ts +12 -0
- package/dist/src/interfaces/index.d.ts +5 -0
- package/dist/{node → src}/models/Config.d.ts +14 -7
- package/dist/src/models/index.d.ts +1 -0
- package/dist/src/pools/Router.d.ts +47 -0
- package/dist/src/pools/balancer/Pool.d.ts +70 -0
- package/dist/src/pools/balancer/index.d.ts +1 -0
- package/dist/src/pools/dispenser/Dispenser.d.ts +38 -0
- package/dist/src/pools/dispenser/index.d.ts +1 -0
- package/dist/src/pools/fixedRate/FixedRateExchange.d.ts +96 -0
- package/dist/src/pools/fixedRate/index.d.ts +1 -0
- package/dist/src/pools/index.d.ts +3 -0
- package/dist/src/pools/ssContracts/SideStaking.d.ts +30 -0
- package/dist/src/pools/ssContracts/index.d.ts +1 -0
- package/dist/src/provider/Provider.d.ts +35 -0
- package/dist/src/provider/index.d.ts +1 -0
- package/dist/src/tokens/Datatoken.d.ts +73 -0
- package/dist/src/tokens/NFT.d.ts +62 -0
- package/dist/src/tokens/index.d.ts +2 -0
- package/dist/src/utils/ConfigHelper.d.ts +6 -0
- package/dist/src/utils/Constants.d.ts +2 -0
- package/dist/src/utils/ContractUtils.d.ts +11 -0
- package/dist/src/utils/ConversionTypeHelper.d.ts +3 -0
- package/dist/{node/utils/Datatokens.d.ts → src/utils/DatatokenName.d.ts} +1 -1
- package/dist/src/utils/DdoHelpers.d.ts +2 -0
- package/dist/src/utils/FetchHelper.d.ts +6 -0
- package/dist/{node → src}/utils/Logger.d.ts +0 -0
- package/dist/src/utils/SignatureUtils.d.ts +8 -0
- package/dist/src/utils/TokenUtils.d.ts +7 -0
- package/dist/src/utils/index.d.ts +9 -0
- package/dist/src/utils/minAbi.d.ts +2 -0
- package/dist/test/TestContractHandler.d.ts +44 -0
- package/dist/test/integration/ComputeFlow.test.d.ts +1 -0
- package/dist/test/integration/Provider.test.d.ts +1 -0
- package/dist/test/integration/PublishFlows.test.d.ts +1 -0
- package/dist/test/integration/SimplePublishConsumeFlow.test.d.ts +1 -0
- package/dist/test/integration/config.d.ts +3 -0
- package/dist/test/unit/NftFactory.test.d.ts +1 -0
- package/dist/test/unit/config.d.ts +3 -0
- package/dist/test/unit/pools/Router.test.d.ts +1 -0
- package/dist/test/unit/pools/balancer/Pool.test.d.ts +1 -0
- package/dist/test/unit/pools/dispenser/Dispenser.test.d.ts +1 -0
- package/dist/test/unit/pools/fixedRate/FixedRateExchange.test.d.ts +1 -0
- package/dist/test/unit/pools/ssContracts/SideStaking.test.d.ts +1 -0
- package/dist/test/unit/tokens/Datatoken.test.d.ts +1 -0
- package/dist/test/unit/tokens/Nft.test.d.ts +1 -0
- package/docs/beginners_guide.md +4 -4
- package/docs/overview.md +100 -9
- package/docs/quickstart_marketplace.md +34 -33
- package/docs/quickstart_simple.md +18 -16
- package/package.json +37 -29
- package/dist/node/Instantiable.abstract.d.ts +0 -25
- package/dist/node/balancer/OceanPool.d.ts +0 -95
- package/dist/node/balancer/Pool.d.ts +0 -56
- package/dist/node/balancer/PoolFactory.d.ts +0 -15
- package/dist/node/datatokens/ContractEvent.d.ts +0 -19
- package/dist/node/datatokens/ContractHandler.d.ts +0 -12
- package/dist/node/datatokens/Datatokens.d.ts +0 -44
- package/dist/node/datatokens/EventHandler.d.ts +0 -19
- package/dist/node/datatokens/Network.d.ts +0 -5
- package/dist/node/datatokens/Web3Provider.d.ts +0 -5
- package/dist/node/datatokens/contracts/ContractBase.d.ts +0 -27
- package/dist/node/ddo/DDO.d.ts +0 -36
- package/dist/node/ddo/interfaces/AdditionalInformation.d.ts +0 -16
- package/dist/node/ddo/interfaces/Authentication.d.ts +0 -4
- package/dist/node/ddo/interfaces/BestPrice.d.ts +0 -10
- package/dist/node/ddo/interfaces/Consumable.d.ts +0 -5
- package/dist/node/ddo/interfaces/Credentials.d.ts +0 -9
- package/dist/node/ddo/interfaces/Curation.d.ts +0 -6
- package/dist/node/ddo/interfaces/DataTokenInfo.d.ts +0 -10
- package/dist/node/ddo/interfaces/EditableMetadata.d.ts +0 -9
- package/dist/node/ddo/interfaces/EditableMetadataLinks.d.ts +0 -5
- package/dist/node/ddo/interfaces/Event.d.ts +0 -7
- package/dist/node/ddo/interfaces/File.d.ts +0 -13
- package/dist/node/ddo/interfaces/Metadata.d.ts +0 -15
- package/dist/node/ddo/interfaces/MetadataAlgorithm.d.ts +0 -12
- package/dist/node/ddo/interfaces/MetadataMain.d.ts +0 -12
- package/dist/node/ddo/interfaces/Proof.d.ts +0 -6
- package/dist/node/ddo/interfaces/PublicKey.d.ts +0 -8
- package/dist/node/ddo/interfaces/PurgatoryData.d.ts +0 -4
- package/dist/node/ddo/interfaces/Service.d.ts +0 -99
- package/dist/node/ddo/interfaces/ServicePrices.d.ts +0 -4
- package/dist/node/ddo/interfaces/Status.d.ts +0 -5
- package/dist/node/ddo/interfaces/index.d.ts +0 -17
- package/dist/node/dispenser/Dispenser.d.ts +0 -44
- package/dist/node/exchange/FixedRateExchange.d.ts +0 -59
- package/dist/node/index.d.ts +0 -1
- package/dist/node/lib.d.ts +0 -15
- package/dist/node/lib.js +0 -2
- package/dist/node/lib.js.map +0 -1
- package/dist/node/lib.module.js +0 -2
- package/dist/node/lib.module.js.map +0 -1
- package/dist/node/lib.umd.js +0 -2
- package/dist/node/lib.umd.js.map +0 -1
- package/dist/node/metadatacache/MetadataCache.d.ts +0 -41
- package/dist/node/metadatacache/OnChainMetaData.d.ts +0 -31
- package/dist/node/ocean/Account.d.ts +0 -16
- package/dist/node/ocean/Accounts.d.ts +0 -9
- package/dist/node/ocean/Assets.d.ts +0 -56
- package/dist/node/ocean/AssetsCredential.d.ts +0 -6
- package/dist/node/ocean/Compute.d.ts +0 -75
- package/dist/node/ocean/DID.d.ts +0 -8
- package/dist/node/ocean/EventAccessControl.d.ts +0 -9
- package/dist/node/ocean/Ocean.d.ts +0 -34
- package/dist/node/ocean/OceanAuth.d.ts +0 -15
- package/dist/node/ocean/Versions.d.ts +0 -25
- package/dist/node/ocean/utils/SignatureUtils.d.ts +0 -13
- package/dist/node/ocean/utils/Utils.d.ts +0 -8
- package/dist/node/ocean/utils/WebServiceConnector.d.ts +0 -16
- package/dist/node/provider/Provider.d.ts +0 -56
- package/dist/node/utils/AssetResolverHelper.d.ts +0 -8
- package/dist/node/utils/ConfigHelper.d.ts +0 -17
- package/dist/node/utils/ContractUtils.d.ts +0 -5
- package/dist/node/utils/ConversionTypeHelpers.d.ts +0 -8
- package/dist/node/utils/GeneratorHelpers.d.ts +0 -1
- package/dist/node/utils/PromiseResolver.d.ts +0 -3
- package/dist/node/utils/SubscribableObserver.d.ts +0 -12
- package/dist/node/utils/SubscribablePromise.d.ts +0 -14
- package/dist/node/utils/Timeout.d.ts +0 -1
- package/dist/node/utils/index.d.ts +0 -9
package/docs/overview.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Here is an overview of all ot the main functions and submodules:
|
|
4
4
|
|
|
5
5
|
### Ocean instance
|
|
6
|
+
|
|
6
7
|
Create/get datatoken, get dtfactory, user orders (history)
|
|
7
8
|
|
|
8
9
|
```
|
|
@@ -13,277 +14,365 @@ const ocean = await Ocean.getInstance(config)
|
|
|
13
14
|
Then use the following submodules...
|
|
14
15
|
|
|
15
16
|
# Assets
|
|
17
|
+
|
|
16
18
|
Publish, get, list, search, order, consume/download
|
|
19
|
+
|
|
17
20
|
```Typescript
|
|
18
21
|
ocean.asset.getInstance(config: InstantiableConfig): Promise<Assets>;
|
|
19
22
|
```
|
|
23
|
+
|
|
20
24
|
```Typescript
|
|
21
25
|
ocean.asset.create(metadata: Metadata, publisher: Account, services?: Service[], dtAddress?: string, cap?: string, name?: string, symbol?: string, providerUri?: string): SubscribablePromise<CreateProgressStep, DDO>;
|
|
22
26
|
```
|
|
27
|
+
|
|
23
28
|
```Typescript
|
|
24
29
|
ocean.asset.ownerAssets(owner: string): Promise<QueryResult>;
|
|
25
30
|
```
|
|
31
|
+
|
|
26
32
|
```Typescript
|
|
27
33
|
ocean.asset.resolve(did: string): Promise<DDO>;
|
|
28
34
|
```
|
|
35
|
+
|
|
29
36
|
```Typescript
|
|
30
37
|
ocean.asset.resolveByDTAddress(dtAddress: string, offset?: number, page?: number, sort?: number): Promise<DDO[]>;
|
|
31
38
|
```
|
|
39
|
+
|
|
32
40
|
```Typescript
|
|
33
41
|
ocean.asset.editMetadata(ddo: DDO, newMetadata: EditableMetadata): Promise<DDO>;
|
|
34
42
|
```
|
|
43
|
+
|
|
35
44
|
```Typescript
|
|
36
45
|
ocean.asset.updateMetadata(ddo: DDO, consumerAccount: string): Promise<TransactionReceipt>;
|
|
37
46
|
```
|
|
47
|
+
|
|
38
48
|
```Typescript
|
|
39
49
|
ocean.asset.editServiceTimeout(ddo: DDO, serviceIndex: number, timeout: number): Promise<DDO>;
|
|
40
50
|
```
|
|
51
|
+
|
|
41
52
|
```Typescript
|
|
42
53
|
ocean.asset.creator(did: string): Promise<string>;
|
|
43
54
|
```
|
|
55
|
+
|
|
44
56
|
```Typescript
|
|
45
57
|
ocean.asset.query(query: SearchQuery): Promise<QueryResult>;
|
|
46
58
|
```
|
|
59
|
+
|
|
47
60
|
```Typescript
|
|
48
61
|
ocean.asset.search(text: string): Promise<QueryResult>;
|
|
49
62
|
```
|
|
63
|
+
|
|
50
64
|
```Typescript
|
|
51
65
|
ocean.asset.getServiceByType(did: string, serviceType: string): Promise<Service>;
|
|
52
66
|
```
|
|
67
|
+
|
|
53
68
|
```Typescript
|
|
54
69
|
ocean.asset.getServiceByIndex(did: string, serviceIndex: number): Promise<Service>;
|
|
55
70
|
```
|
|
71
|
+
|
|
56
72
|
```Typescript
|
|
57
73
|
ocean.asset.createAccessServiceAttributes(creator: Account, cost: string, datePublished: string, timeout?: number, providerUri?: string): Promise<ServiceAccess>;
|
|
58
74
|
```
|
|
75
|
+
|
|
59
76
|
```Typescript
|
|
60
77
|
ocean.asset.initialize(did: string, serviceType: string, consumerAddress: string, serviceIndex: number, serviceEndpoint: string): Promise<any>;
|
|
61
78
|
```
|
|
79
|
+
|
|
62
80
|
```Typescript
|
|
63
81
|
ocean.asset.order(did: string, serviceType: string, payerAddress: string, serviceIndex?: number, mpAddress?: string, consumerAddress?: string, searchPreviousOrders?: boolean): Promise<string>;
|
|
64
82
|
```
|
|
83
|
+
|
|
65
84
|
```Typescript
|
|
66
85
|
ocean.asset.download(did: string, txId: string, tokenAddress: string, consumerAccount: Account, destination: string): Promise<string | true>;
|
|
67
86
|
```
|
|
87
|
+
|
|
68
88
|
```Typescript
|
|
69
89
|
ocean.asset.simpleDownload(dtAddress: string, serviceEndpoint: string, txId: string, account: string): Promise<string>;
|
|
70
90
|
```
|
|
91
|
+
|
|
71
92
|
```Typescript
|
|
72
93
|
ocean.asset.getOrderHistory(account: Account, serviceType?: string, fromBlock?: number): Promise<Order[]>;
|
|
73
94
|
```
|
|
74
95
|
|
|
75
96
|
# Datatoken Pool
|
|
97
|
+
|
|
76
98
|
Create, add/remove liquidity, check liquidity, price, buy datatokens
|
|
77
99
|
|
|
78
100
|
```Typescript
|
|
79
101
|
ocean.pool.
|
|
80
102
|
```
|
|
103
|
+
|
|
81
104
|
```Typescript
|
|
82
105
|
ocean.pool.createDTPool(account: string, token: string, amount: string, weight: string, fee: string): Promise<string>;
|
|
83
106
|
```
|
|
107
|
+
|
|
84
108
|
```Typescript
|
|
85
109
|
ocean.pool.getDTAddress(poolAddress: string): Promise<string>;
|
|
86
110
|
```
|
|
111
|
+
|
|
87
112
|
```Typescript
|
|
88
113
|
ocean.pool.getOceanReserve(poolAddress: string): Promise<string>;
|
|
89
114
|
```
|
|
115
|
+
|
|
90
116
|
```Typescript
|
|
91
117
|
ocean.pool.getDTReserve(poolAddress: string): Promise<string>;
|
|
92
118
|
```
|
|
119
|
+
|
|
93
120
|
```Typescript
|
|
94
121
|
ocean.pool.getMaxBuyQuantity(poolAddress: string, tokenAddress: string): Promise<string>;
|
|
95
122
|
```
|
|
123
|
+
|
|
96
124
|
```Typescript
|
|
97
125
|
ocean.pool.getOceanMaxBuyQuantity(poolAddress: string): Promise<string>;
|
|
98
126
|
```
|
|
127
|
+
|
|
99
128
|
```Typescript
|
|
100
129
|
ocean.pool.getDTMaxBuyQuantity(poolAddress: string): Promise<string>;
|
|
101
130
|
```
|
|
131
|
+
|
|
102
132
|
```Typescript
|
|
103
133
|
ocean.pool.calcInGivenOut(poolAddress: string, tokenInAddress: string, tokenOutAddress: string, tokenOutAmount: string): Promise<string>;
|
|
104
134
|
```
|
|
135
|
+
|
|
105
136
|
```Typescript
|
|
106
137
|
ocean.pool.calcOutGivenIn(poolAddress: string, tokenInAddress: string, tokenOutAddress: string, tokenInAmount: string): Promise<string>;
|
|
107
138
|
```
|
|
139
|
+
|
|
108
140
|
```Typescript
|
|
109
141
|
ocean.pool.calcPoolOutGivenSingleIn(poolAddress: string, tokenInAddress: string, tokenInAmount: string): Promise<string>;
|
|
110
142
|
```
|
|
143
|
+
|
|
111
144
|
```Typescript
|
|
112
145
|
ocean.pool.calcSingleInGivenPoolOut(poolAddress: string, tokenInAddress: string, poolShares: string): Promise<string>;
|
|
113
146
|
```
|
|
147
|
+
|
|
114
148
|
```Typescript
|
|
115
149
|
ocean.pool.calcSingleOutGivenPoolIn(poolAddress: string, tokenOutAddress: string, poolShares: string): Promise<string>;
|
|
116
150
|
```
|
|
151
|
+
|
|
117
152
|
```Typescript
|
|
118
153
|
ocean.pool.calcPoolInGivenSingleOut(poolAddress: string, tokenOutAddress: string, tokenOutAmount: string): Promise<string>;
|
|
119
154
|
```
|
|
155
|
+
|
|
120
156
|
```Typescript
|
|
121
157
|
ocean.pool.getPoolSharesRequiredToRemoveDT(poolAddress: string, dtAmount: string): Promise<string>;
|
|
122
158
|
```
|
|
159
|
+
|
|
123
160
|
```Typescript
|
|
124
161
|
ocean.pool.getDTRemovedforPoolShares(poolAddress: string, poolShares: string): Promise<string>;
|
|
125
162
|
```
|
|
163
|
+
|
|
126
164
|
```Typescript
|
|
127
165
|
ocean.pool.getPoolSharesRequiredToRemoveOcean(poolAddress: string, oceanAmount: string): Promise<string>;
|
|
128
166
|
```
|
|
167
|
+
|
|
129
168
|
```Typescript
|
|
130
169
|
ocean.pool.getOceanRemovedforPoolShares(poolAddress: string, poolShares: string): Promise<string>;
|
|
131
170
|
```
|
|
171
|
+
|
|
132
172
|
```Typescript
|
|
133
173
|
ocean.pool.getTokensRemovedforPoolShares(poolAddress: string, poolShares: string): Promise<TokensReceived>;
|
|
134
174
|
```
|
|
175
|
+
|
|
135
176
|
```Typescript
|
|
136
177
|
ocean.pool.getDTMaxAddLiquidity(poolAddress: string): Promise<string>;
|
|
137
178
|
```
|
|
179
|
+
|
|
138
180
|
```Typescript
|
|
139
181
|
ocean.pool.getOceanMaxAddLiquidity(poolAddress: string): Promise<string>;
|
|
140
182
|
```
|
|
183
|
+
|
|
141
184
|
```Typescript
|
|
142
185
|
ocean.pool.getMaxAddLiquidity(poolAddress: string, tokenAddress: string): Promise<string>;
|
|
143
186
|
```
|
|
187
|
+
|
|
144
188
|
```Typescript
|
|
145
189
|
ocean.pool.getMaxRemoveLiquidity(poolAddress: string, tokenAddress: string): Promise<string>;
|
|
146
190
|
```
|
|
191
|
+
|
|
147
192
|
```Typescript
|
|
148
193
|
ocean.pool.getDTMaxRemoveLiquidity(poolAddress: string): Promise<string>;
|
|
149
194
|
```
|
|
195
|
+
|
|
150
196
|
```Typescript
|
|
151
197
|
ocean.pool.getOceanMaxRemoveLiquidity(poolAddress: string): Promise<string>;
|
|
152
198
|
```
|
|
199
|
+
|
|
153
200
|
```Typescript
|
|
154
201
|
ocean.pool.buyDT(account: string, poolAddress: string, dtAmountWanted: string, maxOceanAmount: string, maxPrice?: string): Promise<TransactionReceipt>;
|
|
155
202
|
```
|
|
203
|
+
|
|
156
204
|
```Typescript
|
|
157
205
|
ocean.pool.sellDT(account: string, poolAddress: string, dtAmount: string, oceanAmountWanted: string, maxPrice?: string): Promise<TransactionReceipt>;
|
|
158
206
|
```
|
|
207
|
+
|
|
159
208
|
```Typescript
|
|
160
209
|
ocean.pool.addDTLiquidity(account: string, poolAddress: string, amount: string): Promise<TransactionReceipt>;
|
|
161
210
|
```
|
|
211
|
+
|
|
162
212
|
```Typescript
|
|
163
213
|
ocean.pool.removeDTLiquidity(account: string, poolAddress: string, amount: string, maximumPoolShares: string): Promise<TransactionReceipt>;
|
|
164
214
|
```
|
|
215
|
+
|
|
165
216
|
```Typescript
|
|
166
217
|
ocean.pool.addOceanLiquidity(account: string, poolAddress: string, amount: string): Promise<TransactionReceipt>;
|
|
167
218
|
```
|
|
219
|
+
|
|
168
220
|
```Typescript
|
|
169
221
|
ocean.pool.removeOceanLiquidity(account: string, poolAddress: string, amount: string, maximumPoolShares: string): Promise<TransactionReceipt>;
|
|
170
222
|
```
|
|
223
|
+
|
|
171
224
|
```Typescript
|
|
172
225
|
ocean.pool.removePoolLiquidity(account: string, poolAddress: string, poolShares: string, minDT?: string, minOcean?: string): Promise<TransactionReceipt>;
|
|
173
226
|
```
|
|
227
|
+
|
|
174
228
|
```Typescript
|
|
175
229
|
ocean.pool.getDTPrice(poolAddress: string): Promise<string>;
|
|
176
230
|
```
|
|
231
|
+
|
|
177
232
|
```Typescript
|
|
178
233
|
ocean.pool.searchPoolforDT(dtAddress: string): Promise<string[]>;
|
|
179
234
|
```
|
|
235
|
+
|
|
180
236
|
```Typescript
|
|
181
237
|
ocean.pool.getOceanNeeded(poolAddress: string, dtRequired: string): Promise<string>;
|
|
182
238
|
```
|
|
239
|
+
|
|
183
240
|
```Typescript
|
|
184
241
|
ocean.pool.getOceanReceived(poolAddress: string, dtSold: string): Promise<string>;
|
|
185
242
|
```
|
|
243
|
+
|
|
186
244
|
```Typescript
|
|
187
245
|
ocean.pool.getDTNeeded(poolAddress: string, OceanRequired: string): Promise<string>;
|
|
188
246
|
```
|
|
247
|
+
|
|
189
248
|
```Typescript
|
|
190
249
|
ocean.pool.getPoolsbyCreator(account?: string): Promise<PoolDetails[]>;
|
|
191
250
|
```
|
|
251
|
+
|
|
192
252
|
```Typescript
|
|
193
253
|
ocean.pool.getPoolDetails(poolAddress: string): Promise<PoolDetails>;
|
|
194
254
|
```
|
|
255
|
+
|
|
195
256
|
```Typescript
|
|
196
257
|
ocean.pool.getPoolLogs(poolAddress: string, account?: string): Promise<PoolTransaction[]>;
|
|
197
258
|
```
|
|
259
|
+
|
|
198
260
|
```Typescript
|
|
199
261
|
ocean.pool.getAllPoolLogs(account: string): Promise<PoolTransaction[]>;
|
|
200
262
|
```
|
|
201
263
|
|
|
202
264
|
# Fixed rate exchange
|
|
203
|
-
|
|
265
|
+
|
|
266
|
+
Create, price, buy datatokens
|
|
204
267
|
|
|
205
268
|
```Typescript
|
|
206
|
-
ocean.exchange.create(
|
|
269
|
+
ocean.exchange.create(datatoken: string, rate: string, address: string): Promise<string>;
|
|
207
270
|
```
|
|
271
|
+
|
|
208
272
|
```Typescript
|
|
209
|
-
ocean.exchange.generateExchangeId(
|
|
273
|
+
ocean.exchange.generateExchangeId(datatoken: string, owner: string): Promise<string>;
|
|
210
274
|
```
|
|
275
|
+
|
|
211
276
|
```Typescript
|
|
212
|
-
ocean.exchange.buyDT(exchangeId: string,
|
|
277
|
+
ocean.exchange.buyDT(exchangeId: string, datatokenAmount: string, address: string): Promise<TransactionReceipt>;
|
|
213
278
|
```
|
|
279
|
+
|
|
214
280
|
```Typescript
|
|
215
281
|
ocean.exchange.getNumberOfExchanges(): Promise<number>;
|
|
216
282
|
```
|
|
283
|
+
|
|
217
284
|
```Typescript
|
|
218
285
|
ocean.exchange.setRate(exchangeId: string, newRate: number, address: string): Promise<TransactionReceipt>;
|
|
219
286
|
```
|
|
287
|
+
|
|
220
288
|
```Typescript
|
|
221
289
|
ocean.exchange.activate(exchangeId: string, address: string): Promise<TransactionReceipt>;
|
|
222
290
|
```
|
|
291
|
+
|
|
223
292
|
```Typescript
|
|
224
293
|
ocean.exchange.deactivate(exchangeId: string, address: string): Promise<TransactionReceipt>;
|
|
225
294
|
```
|
|
295
|
+
|
|
226
296
|
```Typescript
|
|
227
297
|
ocean.exchange.getRate(exchangeId: string): Promise<string>;
|
|
228
298
|
```
|
|
299
|
+
|
|
229
300
|
```Typescript
|
|
230
301
|
ocean.exchange.getSupply(exchangeId: string): Promise<string>;
|
|
231
302
|
```
|
|
303
|
+
|
|
232
304
|
```Typescript
|
|
233
|
-
ocean.exchange.getOceanNeeded(exchangeId: string,
|
|
305
|
+
ocean.exchange.getOceanNeeded(exchangeId: string, datatokenAmount: string): Promise<string>;
|
|
234
306
|
```
|
|
307
|
+
|
|
235
308
|
```Typescript
|
|
236
309
|
ocean.exchange.getExchange(exchangeId: string): Promise<FixedPriceExchange>;
|
|
237
310
|
```
|
|
311
|
+
|
|
238
312
|
```Typescript
|
|
239
313
|
ocean.exchange.getExchanges(): Promise<string[]>;
|
|
240
314
|
```
|
|
315
|
+
|
|
241
316
|
```Typescript
|
|
242
317
|
ocean.exchange.isActive(exchangeId: string): Promise<boolean>;
|
|
243
318
|
```
|
|
319
|
+
|
|
244
320
|
```Typescript
|
|
245
|
-
ocean.exchange.CalcInGivenOut(exchangeId: string,
|
|
321
|
+
ocean.exchange.CalcInGivenOut(exchangeId: string, datatokenAmount: string): Promise<string>;
|
|
246
322
|
```
|
|
323
|
+
|
|
247
324
|
```Typescript
|
|
248
|
-
ocean.exchange.searchforDT(
|
|
325
|
+
ocean.exchange.searchforDT(datatokenAddress: string, minSupply: string): Promise<FixedPriceExchange[]>;
|
|
249
326
|
```
|
|
327
|
+
|
|
250
328
|
```Typescript
|
|
251
329
|
ocean.exchange.getExchangesbyCreator(account?: string): Promise<FixedPriceExchange[]>;
|
|
252
330
|
```
|
|
331
|
+
|
|
253
332
|
```Typescript
|
|
254
333
|
ocean.exchange.getExchangeSwaps(exchangeId: string, account?: string): Promise<FixedPriceSwap[]>;
|
|
255
334
|
```
|
|
335
|
+
|
|
256
336
|
```Typescript
|
|
257
337
|
ocean.exchange.getAllExchangesSwaps(account: string): Promise<FixedPriceSwap[]>;
|
|
258
338
|
```
|
|
259
339
|
|
|
260
340
|
# Compute-to-data
|
|
341
|
+
|
|
261
342
|
consume/start, stop, results, status, define-service
|
|
262
343
|
|
|
263
344
|
```Typescript
|
|
264
|
-
ocean.compute.start(did: string, txId: string, tokenAddress: string, consumerAccount: Account, algorithmDid?: string, algorithmMeta?: MetadataAlgorithm, output?: Output, serviceIndex?: string, serviceType?: string, algorithmTransferTxId?: string,
|
|
345
|
+
ocean.compute.start(did: string, txId: string, tokenAddress: string, consumerAccount: Account, algorithmDid?: string, algorithmMeta?: MetadataAlgorithm, output?: Output, serviceIndex?: string, serviceType?: string, algorithmTransferTxId?: string, algorithmDatatoken?: string): Promise<ComputeJob>;
|
|
265
346
|
```
|
|
347
|
+
|
|
266
348
|
```Typescript
|
|
267
349
|
ocean.compute.stop(consumerAccount: Account, did: string, jobId: string): Promise<ComputeJob>;
|
|
268
350
|
```
|
|
351
|
+
|
|
269
352
|
```Typescript
|
|
270
353
|
ocean.compute.delete(consumerAccount: Account, did: string, jobId: string): Promise<ComputeJob>;
|
|
271
354
|
```
|
|
355
|
+
|
|
272
356
|
```Typescript
|
|
273
357
|
ocean.compute.status(consumerAccount: Account, did?: string, jobId?: string): Promise<ComputeJob[]>;
|
|
274
358
|
```
|
|
359
|
+
|
|
275
360
|
```Typescript
|
|
276
361
|
ocean.compute.result(consumerAccount: Account, did: string, jobId: string): Promise<ComputeJob>;
|
|
277
362
|
```
|
|
363
|
+
|
|
278
364
|
```Typescript
|
|
279
365
|
ocean.compute.createServerAttributes(serverId: string, serverType: string, cost: string, cpu: string, gpu: string, memory: string, disk: string, maxExecutionTime: number): Server;
|
|
280
366
|
```
|
|
367
|
+
|
|
281
368
|
```Typescript
|
|
282
369
|
ocean.compute.createContainerAttributes(image: string, tag: string, checksum: string): Container;
|
|
283
370
|
```
|
|
371
|
+
|
|
284
372
|
```Typescript
|
|
285
373
|
ocean.compute.createClusterAttributes(type: string, url: string): Cluster;
|
|
286
374
|
```
|
|
375
|
+
|
|
287
376
|
```Typescript
|
|
288
377
|
ocean.compute.createProviderAttributes(type: string, description: string, cluster: Cluster, containers: Container[], servers: Server[]): {
|
|
289
378
|
type: string;
|
|
@@ -295,9 +384,11 @@ ocean.compute.createProviderAttributes(type: string, description: string, cluste
|
|
|
295
384
|
};
|
|
296
385
|
};
|
|
297
386
|
```
|
|
387
|
+
|
|
298
388
|
```Typescript
|
|
299
389
|
ocean.compute.createComputeService(consumerAccount: Account, cost: string, datePublished: string, providerAttributes: any, computePrivacy?: ServiceComputePrivacy, timeout?: number, providerUri?: string): ServiceCompute;
|
|
300
390
|
```
|
|
391
|
+
|
|
301
392
|
```Typescript
|
|
302
393
|
ocean.compute.order(consumerAccount: string, datasetDid: string, serviceIndex: number, algorithmDid?: string, algorithmMeta?: MetadataAlgorithm, mpAddress?: string): SubscribablePromise<OrderProgressStep, string>;
|
|
303
|
-
```
|
|
394
|
+
```
|
|
@@ -10,7 +10,7 @@ Here's the steps.
|
|
|
10
10
|
2. Create a new node.js project
|
|
11
11
|
3. Install dependancies
|
|
12
12
|
4. Create a config file and update contract addresses
|
|
13
|
-
5. Publish a new
|
|
13
|
+
5. Publish a new datatoken
|
|
14
14
|
6. Mint 200 tokens
|
|
15
15
|
7. Publish a dataset
|
|
16
16
|
8. Alice allows marketplace to sell her datatokens
|
|
@@ -20,7 +20,6 @@ Here's the steps.
|
|
|
20
20
|
12. Bob downloads the dataset
|
|
21
21
|
13. Extensions
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
Let's go through each step.
|
|
25
24
|
|
|
26
25
|
## 1. Initialize services
|
|
@@ -35,7 +34,7 @@ cd barge/
|
|
|
35
34
|
|
|
36
35
|
## 2. Create a new node.js project
|
|
37
36
|
|
|
38
|
-
Start by creating a new Node.js project. Open a new terminal and enter the following commands:
|
|
37
|
+
Start by creating a new Node.js project. Open a new terminal and enter the following commands:
|
|
39
38
|
|
|
40
39
|
```bash
|
|
41
40
|
mkdir marketplace-quickstart
|
|
@@ -48,7 +47,7 @@ cat > marketplace.js
|
|
|
48
47
|
|
|
49
48
|
## 3. Install dependancies
|
|
50
49
|
|
|
51
|
-
Open the package.json file in a text editor and update the dependancies to include the following:
|
|
50
|
+
Open the package.json file in a text editor and update the dependancies to include the following:
|
|
52
51
|
|
|
53
52
|
```JSON
|
|
54
53
|
"dependencies": {
|
|
@@ -58,7 +57,7 @@ Open the package.json file in a text editor and update the dependancies to inclu
|
|
|
58
57
|
}
|
|
59
58
|
```
|
|
60
59
|
|
|
61
|
-
Now in your terminal run the following command:
|
|
60
|
+
Now in your terminal run the following command:
|
|
62
61
|
|
|
63
62
|
```bash
|
|
64
63
|
npm install
|
|
@@ -66,7 +65,7 @@ npm install
|
|
|
66
65
|
|
|
67
66
|
## 4. Create a config file and update contract addresses
|
|
68
67
|
|
|
69
|
-
Create a new config.js file:
|
|
68
|
+
Create a new config.js file:
|
|
70
69
|
|
|
71
70
|
```bash
|
|
72
71
|
cat > config.js
|
|
@@ -114,17 +113,18 @@ Now check what your contract addresses are locally. In your terminal run:
|
|
|
114
113
|
cat ~/.ocean/ocean-contracts/artifacts/address.json
|
|
115
114
|
```
|
|
116
115
|
|
|
117
|
-
Next, update the contract addresses in your config.js file. Replace each of the place holders with the actual addresses that were outputted into your terminal.
|
|
116
|
+
Next, update the contract addresses in your config.js file. Replace each of the place holders with the actual addresses that were outputted into your terminal.
|
|
117
|
+
|
|
118
|
+
## 5. Publish a new datatoken
|
|
118
119
|
|
|
119
|
-
## 5. Publish a new data token
|
|
120
120
|
Now open the `marketplace.js` file in your text editor. Enter the following code and save the file:
|
|
121
121
|
|
|
122
122
|
```Javascript
|
|
123
123
|
const Web3 = require("web3");
|
|
124
|
-
const { Ocean,
|
|
124
|
+
const { Ocean, Datatokens } = require("@oceanprotocol/lib");
|
|
125
125
|
|
|
126
|
-
const { factoryABI } = require("@oceanprotocol/contracts/artifacts/DTFactory.json");
|
|
127
|
-
const { datatokensABI } = require("@oceanprotocol/contracts/artifacts/
|
|
126
|
+
const { factoryABI } = require("@oceanprotocol/contracts/artifacts/contracts/DTFactory.json");
|
|
127
|
+
const { datatokensABI } = require("@oceanprotocol/contracts/artifacts/contracts/DatatokenTemplate.json");
|
|
128
128
|
const { config, contracts, urls } = require("./config");
|
|
129
129
|
|
|
130
130
|
|
|
@@ -137,7 +137,7 @@ const init = async () => {
|
|
|
137
137
|
const alice = accounts[0].id;
|
|
138
138
|
console.log('Alice account address:', alice)
|
|
139
139
|
|
|
140
|
-
const datatoken = new
|
|
140
|
+
const datatoken = new Datatokens(
|
|
141
141
|
contracts.DTFactory,
|
|
142
142
|
factoryABI,
|
|
143
143
|
datatokensABI,
|
|
@@ -150,7 +150,7 @@ const init = async () => {
|
|
|
150
150
|
init();
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
Now in your terminal, run the following command:
|
|
153
|
+
Now in your terminal, run the following command:
|
|
154
154
|
|
|
155
155
|
```bash
|
|
156
156
|
node marketplace.js
|
|
@@ -160,7 +160,7 @@ Congratulations, you've created your first Ocean datatoken! 🌊🐋
|
|
|
160
160
|
|
|
161
161
|
## 6. Mint 200 tokens
|
|
162
162
|
|
|
163
|
-
Next, we will edit the code in `marketplace.js` to mint 200 datatokens. These 200
|
|
163
|
+
Next, we will edit the code in `marketplace.js` to mint 200 datatokens. These 200 datatokens are minted and sent to Alice's Address.
|
|
164
164
|
|
|
165
165
|
At the end of the `init() { ... }` function (after `console.log('Deployed datatoken address: ${tokenAddress}')`) add the following line of code:
|
|
166
166
|
|
|
@@ -176,7 +176,7 @@ Now run the `marketplace.js` file again:
|
|
|
176
176
|
node marketplace.js
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
You should now see in the console output that Alice has a token balance of 200.
|
|
179
|
+
You should now see in the console output that Alice has a token balance of 200.
|
|
180
180
|
|
|
181
181
|
## 7. Publish a dataset
|
|
182
182
|
|
|
@@ -243,7 +243,7 @@ Now save and run the `marketplace.js` file:
|
|
|
243
243
|
node marketplace.js
|
|
244
244
|
```
|
|
245
245
|
|
|
246
|
-
In the terminal output you should now see the Data ID (did) outputed.
|
|
246
|
+
In the terminal output you should now see the Data ID (did) outputed.
|
|
247
247
|
|
|
248
248
|
Congratulations, you have published your first dataset! 🌊🐠
|
|
249
249
|
|
|
@@ -275,7 +275,7 @@ await datatoken.approve(
|
|
|
275
275
|
console.log("Marketplace Allowance:", marketplaceAllowance);
|
|
276
276
|
```
|
|
277
277
|
|
|
278
|
-
You should see in the terminal output that the marketplace has a datatoken allowance of 100 tokens.
|
|
278
|
+
You should see in the terminal output that the marketplace has a datatoken allowance of 100 tokens.
|
|
279
279
|
|
|
280
280
|
Now save the file and run it:
|
|
281
281
|
|
|
@@ -308,24 +308,25 @@ You should see in the terminal output that the Markeplace now has a datatoken ba
|
|
|
308
308
|
|
|
309
309
|
## 10. Marketplace posts asset for sale
|
|
310
310
|
|
|
311
|
-
In this section we show how the maketplace can post the dataset for sale.
|
|
311
|
+
In this section we show how the maketplace can post the dataset for sale.
|
|
312
312
|
|
|
313
|
-
First, in the same terminal that you are running your files, enter the following command:
|
|
313
|
+
First, in the same terminal that you are running your files, enter the following command:
|
|
314
314
|
|
|
315
315
|
```bash
|
|
316
316
|
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
|
317
317
|
```
|
|
318
|
-
|
|
318
|
+
|
|
319
|
+
This tells ocean.js the location of the contract addresses.
|
|
319
320
|
|
|
320
321
|
At the end of the `init() { ... }` function (after `console.log("Alice balance:", aliceBalance)`) add the following code:
|
|
321
322
|
|
|
322
323
|
```javascript
|
|
323
324
|
// Wait for datatoken to be published
|
|
324
|
-
await new Promise(r => setTimeout(r, 15000))
|
|
325
|
+
await new Promise((r) => setTimeout(r, 15000))
|
|
325
326
|
|
|
326
327
|
const asset = await ocean.assets.resolve(dataId)
|
|
327
328
|
const accessService = await ocean.assets.getServiceByType(asset.id, 'access')
|
|
328
|
-
console.log(
|
|
329
|
+
console.log('accessService', accessService)
|
|
329
330
|
```
|
|
330
331
|
|
|
331
332
|
Now save and run the file:
|
|
@@ -334,11 +335,11 @@ Now save and run the file:
|
|
|
334
335
|
node marketplace.js
|
|
335
336
|
```
|
|
336
337
|
|
|
337
|
-
In the terminal output you should see the atributes of your dataset, including the cost, creator address and published date.
|
|
338
|
+
In the terminal output you should see the atributes of your dataset, including the cost, creator address and published date.
|
|
338
339
|
|
|
339
340
|
## 11. Bob acquires datatokens (value swap)
|
|
340
341
|
|
|
341
|
-
Now, you're Bob :) In production environment, Bob would visit the marketplace website and purchase datatokends with USD via a payment gateway such as Stripe. In this example we demonstrate Alice sending Bob datatokens so that he is able to consume the dataset.
|
|
342
|
+
Now, you're Bob :) In production environment, Bob would visit the marketplace website and purchase datatokends with USD via a payment gateway such as Stripe. In this example we demonstrate Alice sending Bob datatokens so that he is able to consume the dataset.
|
|
342
343
|
|
|
343
344
|
First we will edit the `init() { ... }` function to create an address for Bob. On the line after `const marketplace = accounts[1].id;` add the following code:
|
|
344
345
|
|
|
@@ -366,17 +367,18 @@ Save the `marketplace.js` file and run it again. In your terminal enter:
|
|
|
366
367
|
```bash
|
|
367
368
|
node marketplace.js
|
|
368
369
|
```
|
|
370
|
+
|
|
369
371
|
You should see in the terminal output that both Bob and Alice have a balance of 50 tokens.
|
|
370
372
|
|
|
371
373
|
## 12. Bob downloads the dataset
|
|
372
374
|
|
|
373
|
-
Finally, Bob downloads the dataset. This is is a two part process where he first orders the dataset and then downloads it.
|
|
375
|
+
Finally, Bob downloads the dataset. This is is a two part process where he first orders the dataset and then downloads it.
|
|
374
376
|
|
|
375
377
|
At the end of the `init() { ... }` function (after `console.log("bobTransaction", bobTransaction)`) add the following code:
|
|
376
378
|
|
|
377
379
|
```javascript
|
|
378
380
|
const bobTransaction = await ocean.assets.order(asset.id, accessService.type, bob)
|
|
379
|
-
console.log(
|
|
381
|
+
console.log('bobTransaction', bobTransaction)
|
|
380
382
|
|
|
381
383
|
const data = await ocean.assets.download(
|
|
382
384
|
asset.id,
|
|
@@ -386,19 +388,19 @@ const data = await ocean.assets.download(
|
|
|
386
388
|
'./datafiles'
|
|
387
389
|
)
|
|
388
390
|
bobBalance = await datatoken.balance(tokenAddress, bob)
|
|
389
|
-
console.log(
|
|
391
|
+
console.log('Bob token balance:', bobBalance)
|
|
390
392
|
```
|
|
391
393
|
|
|
392
394
|
Save the `marketplace.js` file and run it again. In your terminal enter:
|
|
393
395
|
|
|
394
|
-
You should see in the terminal output that Bob's balance has now been reduce to 40 tokens, as he has spent 10 on the dataset. You can confirm in the terminal that the data has been downloaded with the following commands:
|
|
396
|
+
You should see in the terminal output that Bob's balance has now been reduce to 40 tokens, as he has spent 10 on the dataset. You can confirm in the terminal that the data has been downloaded with the following commands:
|
|
395
397
|
|
|
396
398
|
```bash
|
|
397
399
|
cd datafiles
|
|
398
400
|
ls
|
|
399
401
|
```
|
|
400
|
-
In the terminal output you should see a new directory has been created that contains your data.
|
|
401
402
|
|
|
403
|
+
In the terminal output you should see a new directory has been created that contains your data.
|
|
402
404
|
|
|
403
405
|
To view Bob's previous orders you can enter the following code at the end of the `init() { ... }` function (after `console.log("Bob token balance:", bobBalance)`):
|
|
404
406
|
|
|
@@ -407,16 +409,15 @@ const history = await ocean.assets.getOrderHistory(accounts[2])
|
|
|
407
409
|
console.log("Bob's history", history)
|
|
408
410
|
```
|
|
409
411
|
|
|
410
|
-
If you save the file and run it again you should see all of Bob's previous orders.
|
|
412
|
+
If you save the file and run it again you should see all of Bob's previous orders.
|
|
411
413
|
|
|
412
414
|
## 13. Extensions
|
|
413
415
|
|
|
414
|
-
Congratulations on completing the Oceon.js Marketplace tutorial 🌊🐋🐠. This has given you a solid foundation upon which you can start using Ocean.js. There is still a lot more you can do with Ocean.js, here are some suggestions for next steps to continue learning:
|
|
416
|
+
Congratulations on completing the Oceon.js Marketplace tutorial 🌊🐋🐠. This has given you a solid foundation upon which you can start using Ocean.js. There is still a lot more you can do with Ocean.js, here are some suggestions for next steps to continue learning:
|
|
415
417
|
|
|
416
418
|
1. Check Alice's order history using `ocean.assets.getOrderHistory(accounts[0])`
|
|
417
419
|
2. List all of Alice's assets with `ocean.assets.ownerAssets(alice)`
|
|
418
|
-
3. Update metadata for Alice's dataset using `ocean.assets.editMetadata(ddo, newMetaData)`
|
|
420
|
+
3. Update metadata for Alice's dataset using `ocean.assets.editMetadata(ddo, newMetaData)`
|
|
419
421
|
4. Update the new metadata onchain with `ocean.onChainMetadata.update(newDdo.id, newDdo, alice)`
|
|
420
422
|
5. Check the metadata with `ocean.assets.getServiceByType(ddo.id, 'metadata')`
|
|
421
423
|
6. Update the timeout for the dataset with `ocean.assets.editServiceTimeout(ddo, serviceIndex, newTimeout)`
|
|
422
|
-
|