@oceanprotocol/lib 1.0.0-next.11 → 1.0.0-next.15

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.
@@ -1,5 +1,22 @@
1
1
  import { Metadata, MetadataAlgorithm } from './DDO/Metadata';
2
2
  export declare type ComputeResultType = 'algorithmLog' | 'output';
3
+ export interface ComputeEnvironment {
4
+ id: string;
5
+ cpuNumber: number;
6
+ cpuType: string;
7
+ gpuNumber: number;
8
+ gpuType: string;
9
+ ramGB: number;
10
+ diskGB: number;
11
+ priceMin: number;
12
+ desc: string;
13
+ currentJobs: number;
14
+ maxJobs: number;
15
+ consumerAddress: string;
16
+ storageExpiry: number;
17
+ maxJobDuration: number;
18
+ lastSeen: number;
19
+ }
3
20
  export interface ComputeResult {
4
21
  filename: string;
5
22
  filesize: number;
@@ -6,7 +6,7 @@ export interface FreCreationParams {
6
6
  baseTokenDecimals: number;
7
7
  datatokenDecimals: number;
8
8
  fixedRate: string;
9
- marketFee: number;
9
+ marketFee: string;
10
10
  withMint?: boolean;
11
11
  allowedConsumer?: string;
12
12
  }
@@ -17,3 +17,9 @@ export interface FreOrderParams {
17
17
  swapMarketFee: string;
18
18
  marketFeeAddress: string;
19
19
  }
20
+ export interface PriceAndFees {
21
+ baseTokenAmount: string;
22
+ baseTokenAmountBeforeFee: string;
23
+ oceanFeeAmount: string;
24
+ marketFeeAmount: string;
25
+ }
@@ -10,8 +10,8 @@ export interface PoolCreationParams {
10
10
  vestingAmount: string;
11
11
  vestedBlocks: number;
12
12
  initialBaseTokenLiquidity: string;
13
- swapFeeLiquidityProvider: number;
14
- swapFeeMarketRunner: number;
13
+ swapFeeLiquidityProvider: string;
14
+ swapFeeMarketRunner: string;
15
15
  }
16
16
  export interface CurrentFees {
17
17
  tokens: string[];
@@ -12,10 +12,6 @@ export declare class Aquarius {
12
12
  * @return {Promise<Asset>} Asset
13
13
  */
14
14
  resolve(did: string, signal?: AbortSignal): Promise<Asset>;
15
- /**
16
- * Simple blocking sleep function
17
- */
18
- sleep(ms: number): Promise<unknown>;
19
15
  /**
20
16
  * Blocks until Aqua will cache the did (or the update for that did) or timeouts
21
17
 
@@ -195,33 +195,33 @@ export declare class NftFactory {
195
195
  */
196
196
  startMultipleTokenOrder(address: string, orders: TokenOrder[]): Promise<TransactionReceipt>;
197
197
  /**
198
- * Estimate gas cost for createNftWithErc method
198
+ * Estimate gas cost for createNftWithErc20 method
199
199
  * @param address Caller address
200
200
  * @param _NftCreateData input data for nft creation
201
201
  * @param _ErcCreateData input data for erc20 creation
202
202
  * @return {Promise<TransactionReceipt>} transaction receipt
203
203
  */
204
- estGasCreateNftWithErc(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams): Promise<any>;
204
+ estGasCreateNftWithErc20(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams): Promise<any>;
205
205
  /**
206
- * @dev createNftWithErc
206
+ * @dev createNftWithErc20
207
207
  * Creates a new NFT, then a ERC20,all in one call
208
208
  * @param address Caller address
209
209
  * @param _NftCreateData input data for nft creation
210
210
  * @param _ErcCreateData input data for erc20 creation
211
211
  * @return {Promise<TransactionReceipt>} transaction receipt
212
212
  */
213
- createNftWithErc(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams): Promise<TransactionReceipt>;
213
+ createNftWithErc20(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams): Promise<TransactionReceipt>;
214
214
  /**
215
- * Estimate gas cost for createNftErcWithPool method
215
+ * Estimate gas cost for createNftErc20WithPool method
216
216
  * @param address Caller address
217
217
  * @param nftCreateData input data for NFT Creation
218
218
  * @param ercParams input data for ERC20 Creation
219
219
  * @param poolParams input data for Pool Creation
220
220
  * @return {Promise<TransactionReceipt>} transaction receipt
221
221
  */
222
- estGasCreateNftErcWithPool(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, poolParams: PoolCreationParams): Promise<any>;
222
+ estGasCreateNftErc20WithPool(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, poolParams: PoolCreationParams): Promise<any>;
223
223
  /**
224
- * @dev createNftErcWithPool
224
+ * @dev createNftErc20WithPool
225
225
  * Creates a new NFT, then a ERC20, then a Pool, all in one call
226
226
  * Use this carefully, because if Pool creation fails, you are still going to pay a lot of gas
227
227
  * @param address Caller address
@@ -230,17 +230,17 @@ export declare class NftFactory {
230
230
  * @param poolParams input data for Pool Creation
231
231
  * @return {Promise<TransactionReceipt>} transaction receipt
232
232
  */
233
- createNftErcWithPool(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, poolParams: PoolCreationParams): Promise<TransactionReceipt>;
234
- /** Estimate gas cost for createNftErcWithFixedRate method
233
+ createNftErc20WithPool(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, poolParams: PoolCreationParams): Promise<TransactionReceipt>;
234
+ /** Estimate gas cost for createNftErc20WithFixedRate method
235
235
  * @param address Caller address
236
236
  * @param nftCreateData input data for NFT Creation
237
237
  * @param ercParams input data for ERC20 Creation
238
238
  * @param freParams input data for FixedRate Creation
239
239
  * @return {Promise<TransactionReceipt>} transaction receipt
240
240
  */
241
- estGasCreateNftErcWithFixedRate(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, freParams: FreCreationParams): Promise<any>;
241
+ estGasCreateNftErc20WithFixedRate(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, freParams: FreCreationParams): Promise<any>;
242
242
  /**
243
- * @dev createNftErcWithFixedRate
243
+ * @dev createNftErc20WithFixedRate
244
244
  * Creates a new NFT, then a ERC20, then a FixedRateExchange, all in one call
245
245
  * Use this carefully, because if Fixed Rate creation fails, you are still going to pay a lot of gas
246
246
  * @param address Caller address
@@ -249,17 +249,17 @@ export declare class NftFactory {
249
249
  * @param freParams input data for FixedRate Creation
250
250
  * @return {Promise<TransactionReceipt>} transaction receipt
251
251
  */
252
- createNftErcWithFixedRate(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, freParams: FreCreationParams): Promise<TransactionReceipt>;
253
- /** Estimate gas cost for createNftErcWithFixedRate method
252
+ createNftErc20WithFixedRate(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, freParams: FreCreationParams): Promise<TransactionReceipt>;
253
+ /** Estimate gas cost for createNftErc20WithFixedRate method
254
254
  * @param address Caller address
255
255
  * @param nftCreateData input data for NFT Creation
256
256
  * @param ercParams input data for ERC20 Creation
257
257
  * @param dispenserParams input data for Dispenser Creation
258
258
  * @return {Promise<TransactionReceipt>} transaction receipt
259
259
  */
260
- estGasCreateNftErcWithDispenser(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, dispenserParams: DispenserCreationParams): Promise<any>;
260
+ estGasCreateNftErc20WithDispenser(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, dispenserParams: DispenserCreationParams): Promise<any>;
261
261
  /**
262
- * @dev createNftErcWithDispenser
262
+ * @dev createNftErc20WithDispenser
263
263
  * Creates a new NFT, then a ERC20, then a Dispenser, all in one call
264
264
  * Use this carefully, because if Dispenser creation fails, you are still going to pay a lot of gas
265
265
  * @param address Caller address
@@ -268,6 +268,6 @@ export declare class NftFactory {
268
268
  * @param dispenserParams input data for Dispenser Creation
269
269
  * @return {Promise<TransactionReceipt>} transaction receipt
270
270
  */
271
- createNftErcWithDispenser(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, dispenserParams: DispenserCreationParams): Promise<TransactionReceipt>;
271
+ createNftErc20WithDispenser(address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, dispenserParams: DispenserCreationParams): Promise<TransactionReceipt>;
272
272
  }
273
273
  export {};
@@ -301,9 +301,9 @@ export declare class Pool {
301
301
  * @param {Contract} contractInstance optional contract instance
302
302
  * @return {Promise<number>}
303
303
  */
304
- estJoinswapExternAmountIn(address: string, poolAddress: string, tokenIn: string, tokenAmountIn: string, minPoolAmountOut: string, contractInstance?: Contract): Promise<number>;
304
+ estJoinswapExternAmountIn(address: string, poolAddress: string, tokenAmountIn: string, minPoolAmountOut: string, contractInstance?: Contract): Promise<number>;
305
305
  /**
306
- * Pay tokenAmountIn of token tokenIn to join the pool, getting poolAmountOut of the pool shares.
306
+ * Pay tokenAmountIn of baseToken to join the pool, getting poolAmountOut of the pool shares.
307
307
  * @param {String} account
308
308
  * @param {String} poolAddress
309
309
  * @param {String} tokenIn
@@ -311,41 +311,19 @@ export declare class Pool {
311
311
  * @param {String} minPoolAmountOut will be converted to wei
312
312
  * @return {TransactionReceipt}
313
313
  */
314
- joinswapExternAmountIn(account: string, poolAddress: string, tokenIn: string, tokenAmountIn: string, minPoolAmountOut: string): Promise<TransactionReceipt>;
315
- /**
316
- * Estimate gas cost for joinswapPoolAmountOut
317
- * @param {String} address
318
- * @param {String} poolAddress
319
- * @param {String} tokenIn
320
- * @param {String} poolAmountOut will be converted to wei
321
- * @param {String} maxAmountIn will be converted to wei
322
- * @param {Contract} contractInstance optional contract instance
323
- * @return {Promise<number>}
324
- */
325
- estJoinswapPoolAmountOut(address: string, poolAddress: string, tokenIn: string, poolAmountOut: string, maxAmountIn: string, contractInstance?: Contract): Promise<number>;
326
- /**
327
- * Specify poolAmountOut pool shares that you want to get, and a token tokenIn to pay with. This costs tokenAmountIn tokens (these went into the pool).
328
- * @param {String} account
329
- * @param {String} poolAddress
330
- * @param {String} tokenIn
331
- * @param {String} poolAmountOut will be converted to wei
332
- * @param {String} maxAmountIn will be converted to wei
333
- * @return {TransactionReceipt}
334
- */
335
- joinswapPoolAmountOut(account: string, poolAddress: string, tokenIn: string, poolAmountOut: string, maxAmountIn: string): Promise<TransactionReceipt>;
314
+ joinswapExternAmountIn(account: string, poolAddress: string, tokenAmountIn: string, minPoolAmountOut: string): Promise<TransactionReceipt>;
336
315
  /**
337
316
  * Estimate gas cost for joinswapExternAmountIn
338
317
  * @param {String} address
339
318
  @param {String} poolAddress
340
- * @param {String} tokenOut
341
319
  * @param {String} poolAmountIn will be converted to wei
342
320
  * @param {String} minTokenAmountOut will be converted to wei
343
321
  * @param {Contract} contractInstance optional contract instance
344
322
  * @return {Promise<number>}
345
323
  */
346
- estExitswapPoolAmountIn(address: string, poolAddress: string, tokenOut: string, poolAmountIn: string, minTokenAmountOut: string, contractInstance?: Contract): Promise<number>;
324
+ estExitswapPoolAmountIn(address: string, poolAddress: string, poolAmountIn: string, minTokenAmountOut: string, contractInstance?: Contract): Promise<number>;
347
325
  /**
348
- * Pay poolAmountIn pool shares into the pool, getting minTokenAmountOut of the given token tokenOut out of the pool.
326
+ * Pay poolAmountIn pool shares into the pool, getting minTokenAmountOut of the baseToken
349
327
  * @param {String} account
350
328
  * @param {String} poolAddress
351
329
  * @param {String} tokenOut
@@ -353,28 +331,7 @@ export declare class Pool {
353
331
  * @param {String} minTokenAmountOut will be converted to wei
354
332
  * @return {TransactionReceipt}
355
333
  */
356
- exitswapPoolAmountIn(account: string, poolAddress: string, tokenOut: string, poolAmountIn: string, minTokenAmountOut: string): Promise<TransactionReceipt>;
357
- /**
358
- * Estimate gas cost for joinswapExternAmountIn
359
- * @param {String} address
360
- * @param {String} poolAddress
361
- * @param {String} tokenOut
362
- * @param {String} tokenAmountOut will be converted to wei
363
- * @param {String} maxPoolAmountIn will be converted to wei
364
- * @param {Contract} contractInstance optional contract instance
365
- * @return {Promise<number>}
366
- */
367
- estExitswapExternAmountOut(address: string, poolAddress: string, tokenOut: string, tokenAmountOut: string, maxPoolAmountIn: string, contractInstance?: Contract): Promise<number>;
368
- /**
369
- * Specify tokenAmountOut of token tokenOut that you want to get out of the pool. This costs poolAmountIn pool shares (these went into the pool).
370
- * @param {String} account
371
- * @param {String} poolAddress
372
- * @param {String} tokenOut
373
- * @param {String} tokenAmountOut will be converted to wei
374
- * @param {String} maxPoolAmountIn will be converted to wei
375
- * @return {TransactionReceipt}
376
- */
377
- exitswapExternAmountOut(account: string, poolAddress: string, tokenOut: string, tokenAmountOut: string, maxPoolAmountIn: string): Promise<TransactionReceipt>;
334
+ exitswapPoolAmountIn(account: string, poolAddress: string, poolAmountIn: string, minTokenAmountOut: string): Promise<TransactionReceipt>;
378
335
  /**
379
336
  * Get Spot Price of swaping tokenIn to tokenOut
380
337
  * @param {String} poolAddress
@@ -3,6 +3,7 @@ import { Contract } from 'web3-eth-contract';
3
3
  import { AbiItem } from 'web3-utils/types';
4
4
  import Web3 from 'web3';
5
5
  import { Config } from '../../models/index.js';
6
+ import { PriceAndFees } from '../..';
6
7
  export interface FixedPriceExchange {
7
8
  active: boolean;
8
9
  exchangeOwner: string;
@@ -195,12 +196,12 @@ export declare class FixedRateExchange {
195
196
  */
196
197
  getAllowedSwapper(exchangeId: string): Promise<string>;
197
198
  /**
198
- * getBTNeeded - returns amount in baseToken that user will pay for datatokenAmount
199
+ * calcBaseInGivenOutDT - Calculates how many base tokens are needed to get specified amount of datatokens
199
200
  * @param {String} exchangeId ExchangeId
200
- * @param {Number} datatokenAmount Amount of datatokens user wants to buy
201
- * @return {Promise<string>} Amount of baseToken needed for buying
201
+ * @param {string} datatokenAmount Amount of datatokens user wants to buy
202
+ * @return {Promise<PriceAndFees>} how many base tokens are needed and fees
202
203
  */
203
- getAmountBTIn(exchangeId: string, datatokenAmount: string): Promise<string>;
204
+ calcBaseInGivenOutDT(exchangeId: string, datatokenAmount: string): Promise<PriceAndFees>;
204
205
  /**
205
206
  * getBTOut - returns amount in baseToken that user will receive for datatokenAmount sold
206
207
  * @param {String} exchangeId ExchangeId
@@ -1,5 +1,5 @@
1
1
  import Web3 from 'web3';
2
- import { FileMetadata, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ProviderInitialize } from '../@types/';
2
+ import { FileMetadata, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize } from '../@types/';
3
3
  import { DownloadResponse } from '../@types/DownloadResponse';
4
4
  export interface HttpCallback {
5
5
  (httpMethod: string, url: string, body: string, header: any): Promise<any>;
@@ -58,6 +58,10 @@ export declare class Provider {
58
58
  * @return {Promise<FileMetadata[]>} urlDetails
59
59
  */
60
60
  checkFileUrl(url: string, providerUri: string, signal?: AbortSignal): Promise<FileMetadata[]>;
61
+ /** Get Compute Environments
62
+ * @return {Promise<ComputeEnvironment[]>} urlDetails
63
+ */
64
+ getComputeEnvironments(providerUri: string, signal?: AbortSignal): Promise<ComputeEnvironment[]>;
61
65
  /** Initialize a service request.
62
66
  * @param {DDO | string} asset
63
67
  * @param {number} serviceIndex
@@ -83,6 +87,7 @@ export declare class Provider {
83
87
  /** Instruct the provider to start a compute job
84
88
  * @param {string} did
85
89
  * @param {string} consumerAddress
90
+ * @param {string} computeEnv
86
91
  * @param {ComputeAlgorithm} algorithm
87
92
  * @param {string} providerUri
88
93
  * @param {Web3} web3
@@ -1,10 +1,11 @@
1
1
  import Web3 from 'web3';
2
2
  import { Contract } from 'web3-eth-contract';
3
- import { Erc20CreateParams, FreCreationParams, PoolCreationParams } from '../@types';
3
+ import { Erc20CreateParams, FreCreationParams, FreOrderParams, PoolCreationParams } from '../@types';
4
4
  import { Config } from '../models';
5
5
  export declare function setContractDefaults(contract: Contract, config: Config): Contract;
6
6
  export declare function getFairGasPrice(web3: Web3, config: Config): Promise<string>;
7
7
  export declare function getErcCreationParams(ercParams: Erc20CreateParams): any;
8
+ export declare function getFreOrderParams(freParams: FreOrderParams): any;
8
9
  export declare function getFreCreationParams(freParams: FreCreationParams): any;
9
10
  export declare function getPoolCreationParams(poolParams: PoolCreationParams): any;
10
11
  export declare function unitsToAmount(web3: Web3, token: string, amount: string): Promise<string>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Simple blocking sleep function
3
+ */
4
+ export declare function sleep(ms: number): Promise<unknown>;
@@ -7,3 +7,4 @@ export * from './DdoHelpers';
7
7
  export * from './Constants';
8
8
  export * from './SignatureUtils';
9
9
  export * from './TokenUtils';
10
+ export * from './General';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oceanprotocol/lib",
3
3
  "source": "./src/index.ts",
4
- "version": "1.0.0-next.11",
4
+ "version": "1.0.0-next.15",
5
5
  "description": "JavaScript client library for Ocean Protocol",
6
6
  "main": "./dist/lib.js",
7
7
  "umd:main": "dist/lib.umd.js",
@@ -54,30 +54,30 @@
54
54
  },
55
55
  "homepage": "https://github.com/oceanprotocol/ocean.js#readme",
56
56
  "peerDependencies": {
57
- "web3": ">=1.3.5"
57
+ "web3": "^1.7.0"
58
58
  },
59
59
  "dependencies": {
60
- "@oceanprotocol/contracts": "^1.0.0-alpha.17",
60
+ "@oceanprotocol/contracts": "1.0.0-alpha.18",
61
61
  "bignumber.js": "^9.0.2",
62
- "cross-fetch": "^3.1.4",
63
- "crypto-js": "^4.0.0",
64
- "decimal.js": "^10.2.1",
65
- "web3": ">=1.3.5",
66
- "web3-core": "^1.6.1",
67
- "web3-eth-contract": "^1.6.1"
62
+ "cross-fetch": "^3.1.5",
63
+ "crypto-js": "^4.1.1",
64
+ "decimal.js": "^10.3.1",
65
+ "web3": "^1.7.0",
66
+ "web3-core": "^1.7.0",
67
+ "web3-eth-contract": "^1.7.0"
68
68
  },
69
69
  "devDependencies": {
70
- "@truffle/hdwallet-provider": "^1.5.1",
70
+ "@truffle/hdwallet-provider": "^2.0.3",
71
71
  "@types/chai": "^4.2.19",
72
72
  "@types/chai-spies": "^1.0.3",
73
- "@types/crypto-js": "^4.0.1",
74
- "@types/mocha": "^9.0.0",
75
- "@types/node": "^16.10.3",
73
+ "@types/crypto-js": "^4.1.0",
74
+ "@types/mocha": "^9.1.0",
75
+ "@types/node": "^17.0.17",
76
76
  "@types/node-fetch": "^3.0.3",
77
77
  "@typescript-eslint/eslint-plugin": "^4.33.0",
78
78
  "@typescript-eslint/parser": "^4.33.0",
79
- "auto-changelog": "^2.3.0",
80
- "chai": "^4.3.4",
79
+ "auto-changelog": "^2.4.0",
80
+ "chai": "^4.3.6",
81
81
  "chai-spies": "^1.0.0",
82
82
  "cross-env": "^7.0.3",
83
83
  "eslint": "^7.17.0",
@@ -86,17 +86,17 @@
86
86
  "eslint-plugin-prettier": "^4.0.0",
87
87
  "fs": "0.0.1-security",
88
88
  "microbundle": "^0.14.2",
89
- "mocha": "^9.1.2",
90
- "mock-local-storage": "^1.1.17",
89
+ "mocha": "^9.2.0",
90
+ "mock-local-storage": "^1.1.20",
91
91
  "nyc": "^15.1.0",
92
92
  "ora": "5.4.1",
93
93
  "prettier": "^2.3.1",
94
- "release-it": "^14.12.1",
94
+ "release-it": "^14.12.4",
95
95
  "source-map-support": "^0.5.19",
96
- "ts-node": "^10.0.0",
96
+ "ts-node": "^10.5.0",
97
97
  "ts-node-register": "^1.0.0",
98
- "typedoc": "0.22.5",
99
- "typescript": "^4.3.4"
98
+ "typedoc": "0.22.11",
99
+ "typescript": "^4.5.5"
100
100
  },
101
101
  "nyc": {
102
102
  "include": [