@oceanprotocol/lib 1.0.0-next.36 → 1.0.0-next.39

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.
@@ -21,6 +21,8 @@ export interface TokenInOutMarket {
21
21
  tokenIn: string;
22
22
  tokenOut: string;
23
23
  marketFeeAddress: string;
24
+ tokenInDecimals?: number;
25
+ tokenOutDecimals?: number;
24
26
  }
25
27
  export interface AmountsInMaxFee {
26
28
  tokenAmountIn: string;
@@ -39,7 +39,7 @@ export declare class NftFactory {
39
39
  * @param {AbiItem | AbiItem[]} factory721ABI
40
40
  * @param {Web3} web3
41
41
  */
42
- constructor(factory721Address: string, web3: Web3, factory721Abi?: AbiItem | AbiItem[], config?: Config);
42
+ constructor(factory721Address: string, web3: Web3, network?: string | number, factory721Abi?: AbiItem | AbiItem[], config?: Config);
43
43
  /**
44
44
  * Get estimated gas cost for deployERC721Contract value
45
45
  * @param {String} address
@@ -20,7 +20,7 @@ export declare class Router {
20
20
  * @param {AbiItem | AbiItem[]} Router
21
21
  * @param {Web3} web3
22
22
  */
23
- constructor(routerAddress: string, web3: Web3, RouterAbi?: AbiItem | AbiItem[], config?: Config);
23
+ constructor(routerAddress: string, web3: Web3, network?: string | number, RouterAbi?: AbiItem | AbiItem[], config?: Config);
24
24
  /**
25
25
  * Estimate gas cost for buyDTBatch method
26
26
  * @param {String} address
@@ -12,7 +12,9 @@ export declare class Pool {
12
12
  web3: Web3;
13
13
  GASLIMIT_DEFAULT: number;
14
14
  private config;
15
- constructor(web3: Web3, poolAbi?: AbiItem | AbiItem[], config?: Config);
15
+ constructor(web3: Web3, network?: string | number, poolAbi?: AbiItem | AbiItem[], config?: Config);
16
+ amountToUnits(token: string, amount: string, tokenDecimals?: number): Promise<string>;
17
+ unitsToAmount(token: string, amount: string, tokenDecimals?: number): Promise<string>;
16
18
  /**
17
19
  * Get user shares of pool tokens
18
20
  * @param {String} account
@@ -112,9 +114,10 @@ export declare class Pool {
112
114
  * Returns the current token reserve amount
113
115
  * @param {String} poolAddress
114
116
  * @param {String} token Address of the token to be checked
117
+ * @param {number} tokenDecimals optional number of decimals of the token
115
118
  * @return {String}
116
119
  */
117
- getReserve(poolAddress: string, token: string): Promise<string>;
120
+ getReserve(poolAddress: string, token: string, tokenDecimals?: number): Promise<string>;
118
121
  /**
119
122
  * Get if a pool is finalized
120
123
  * Returns true if pool is finalized
@@ -156,9 +159,10 @@ export declare class Pool {
156
159
  * Get Market Fees available to be collected for a specific token
157
160
  * @param {String} poolAddress
158
161
  * @param {String} token token we want to check fees
162
+ * @param {number} tokenDecimals optional number of decimals of the token
159
163
  * @return {String}
160
164
  */
161
- getMarketFees(poolAddress: string, token: string): Promise<string>;
165
+ getMarketFees(poolAddress: string, token: string, tokenDecimals?: number): Promise<string>;
162
166
  /**
163
167
  * Get Community Get the current amount of fees which can be withdrawned by the Market
164
168
  * @return {CurrentFees}
@@ -173,9 +177,10 @@ export declare class Pool {
173
177
  * Get Community Fees available to be collected for a specific token
174
178
  * @param {String} poolAddress
175
179
  * @param {String} token token we want to check fees
180
+ * @param {number} tokenDecimals optional number of decimals of the token
176
181
  * @return {String}
177
182
  */
178
- getCommunityFees(poolAddress: string, token: string): Promise<string>;
183
+ getCommunityFees(poolAddress: string, token: string, tokenDecimals?: number): Promise<string>;
179
184
  /**
180
185
  * Estimate gas cost for collectOPF
181
186
  * @param {String} address
@@ -270,49 +275,6 @@ export declare class Pool {
270
275
  * @return {TransactionReceipt}
271
276
  */
272
277
  swapExactAmountOut(account: string, poolAddress: string, tokenInOutMarket: TokenInOutMarket, amountsInOutMaxFee: AmountsOutMaxFee): Promise<TransactionReceipt>;
273
- /**
274
- * Estimate gas cost for joinPool method
275
- * @param {String} address
276
- * @param {String} poolAddress
277
- * @param {String} poolAmountOut expected number of pool shares that you will get
278
- * @param {String[]} maxAmountsIn array with maxium amounts spent
279
- * @param {Contract} contractInstance optional contract instance
280
- * @return {Promise<number>}
281
- */
282
- estJoinPool(address: string, poolAddress: string, poolAmountOut: string, maxAmountsIn: string[], contractInstance?: Contract): Promise<number>;
283
- /**
284
- * Adds dual side liquidity to the pool (both datatoken and basetoken)
285
- * This will pull some of each of the currently trading tokens in the pool,
286
- * meaning you must have called approve for each token for this pool.
287
- * These values are limited by the array of maxAmountsIn in the order of the pool tokens.
288
- * @param {String} address
289
- * @param {String} poolAddress
290
- * @param {String} poolAmountOut expected number of pool shares that you will get
291
- * @param {String[]} maxAmountsIn array with maxium amounts spent
292
- * @return {TransactionReceipt}
293
- */
294
- joinPool(address: string, poolAddress: string, poolAmountOut: string, maxAmountsIn: string[]): Promise<TransactionReceipt>;
295
- /**
296
- * Estimate gas cost for exitPool
297
- * @param {String} address
298
- * @param {String} poolAddress
299
- ``* @param {String} poolAmountIn amount of pool shares spent
300
- * @param {String[]} minAmountsOut aarray with minimum amount of tokens expected
301
- * @param {Contract} contractInstance optional contract instance
302
- * @return {Promise<number>}
303
- */
304
- estExitPool(address: string, poolAddress: string, poolAmountIn: string, minAmountsOut: string[], contractInstance?: Contract): Promise<number>;
305
- /**
306
- * Removes dual side liquidity from the pool (both datatoken and basetoken)
307
- * Exit the pool, paying poolAmountIn pool tokens and getting some of each of the currently trading tokens in return.
308
- * These values are limited by the array of minAmountsOut in the order of the pool tokens.
309
- * @param {String} account
310
- * @param {String} poolAddress
311
- * @param {String} poolAmountIn amount of pool shares spent
312
- * @param {String[]} minAmountsOut array with minimum amount of tokens expected
313
- * @return {TransactionReceipt}
314
- */
315
- exitPool(account: string, poolAddress: string, poolAmountIn: string, minAmountsOut: string[]): Promise<TransactionReceipt>;
316
278
  /**
317
279
  * Estimate gas cost for joinswapExternAmountIn
318
280
  * @param {String} address
@@ -373,41 +335,53 @@ export declare class Pool {
373
335
  * @param tokenOut token to get
374
336
  * @param tokenAmountOut exact amount of tokenOut
375
337
  * @param swapMarketFee consume market swap fee
338
+ * @param {number} tokenInDecimals optional number of decimals of the token to be swaped
339
+ * @param {number} tokenOutDecimals optional number of decimals of the token to get
376
340
  */
377
- getAmountInExactOut(poolAddress: string, tokenIn: string, tokenOut: string, tokenAmountOut: string, swapMarketFee: string): Promise<PoolPriceAndFees>;
341
+ getAmountInExactOut(poolAddress: string, tokenIn: string, tokenOut: string, tokenAmountOut: string, swapMarketFee: string, tokenInDecimals?: number, tokenOutDecimals?: number): Promise<PoolPriceAndFees>;
378
342
  /**
379
343
  * How many tokensOut you will get for a exact tokenAmountIn
380
344
  * Returns: tokenAmountOut, LPFee, opcFee , publishMarketSwapFee, consumeMarketSwapFee
381
345
  * @param tokenIn token to be swaped
382
346
  * @param tokenOut token to get
383
- * @param tokenAmountOut exact amount of tokenOut
384
- * @param _consumeMarketSwapFee consume market swap fee
347
+ * @param tokenAmountIn exact amount of tokenIn
348
+ * @param swapMarketFee
349
+ * @param {number} tokenInDecimals optional number of decimals of the token to be swaped
350
+ * @param {number} tokenOutDecimals optional number of decimals of the token to get
385
351
  */
386
- getAmountOutExactIn(poolAddress: string, tokenIn: string, tokenOut: string, tokenAmountIn: string, swapMarketFee: string): Promise<PoolPriceAndFees>;
352
+ getAmountOutExactIn(poolAddress: string, tokenIn: string, tokenOut: string, tokenAmountIn: string, swapMarketFee: string, tokenInDecimals?: number, tokenOutDecimals?: number): Promise<PoolPriceAndFees>;
387
353
  /**
388
354
  * Returns number of poolshares obtain by staking exact tokenAmountIn tokens
389
355
  * @param tokenIn tokenIn
390
356
  * @param tokenAmountIn exact number of tokens staked
357
+ * @param {number} poolDecimals optional number of decimals of the poool
358
+ * @param {number} tokenInDecimals optional number of decimals of the token
391
359
  */
392
- calcPoolOutGivenSingleIn(poolAddress: string, tokenIn: string, tokenAmountIn: string): Promise<string>;
360
+ calcPoolOutGivenSingleIn(poolAddress: string, tokenIn: string, tokenAmountIn: string, poolDecimals?: number, tokenInDecimals?: number): Promise<string>;
393
361
  /**
394
362
  * Returns number of tokens to be staked to the pool in order to get an exact number of poolshares
395
363
  * @param tokenIn tokenIn
396
364
  * @param poolAmountOut expected amount of pool shares
365
+ * @param {number} poolDecimals optional number of decimals of the pool
366
+ * @param {number} tokenInDecimals optional number of decimals of the token
397
367
  */
398
- calcSingleInGivenPoolOut(poolAddress: string, tokenIn: string, poolAmountOut: string): Promise<string>;
368
+ calcSingleInGivenPoolOut(poolAddress: string, tokenIn: string, poolAmountOut: string, poolDecimals?: number, tokenInDecimals?: number): Promise<string>;
399
369
  /**
400
370
  * Returns expected amount of tokenOut for removing exact poolAmountIn pool shares from the pool
401
371
  * @param tokenOut tokenOut
402
372
  * @param poolAmountIn amount of shares spent
373
+ * @param {number} poolDecimals optional number of decimals of the pool
374
+ * @param {number} tokenOutDecimals optional number of decimals of the token
403
375
  */
404
- calcSingleOutGivenPoolIn(poolAddress: string, tokenOut: string, poolAmountIn: string): Promise<string>;
376
+ calcSingleOutGivenPoolIn(poolAddress: string, tokenOut: string, poolAmountIn: string, poolDecimals?: number, tokenOutDecimals?: number): Promise<string>;
405
377
  /**
406
378
  * Returns number of poolshares needed to withdraw exact tokenAmountOut tokens
407
379
  * @param tokenOut tokenOut
408
380
  * @param tokenAmountOut expected amount of tokensOut
381
+ * @param {number} poolDecimals optional number of decimals of the pool
382
+ * @param {number} tokenOutDecimals optional number of decimals of the token
409
383
  */
410
- calcPoolInGivenSingleOut(poolAddress: string, tokenOut: string, tokenAmountOut: string): Promise<string>;
384
+ calcPoolInGivenSingleOut(poolAddress: string, tokenOut: string, tokenAmountOut: string, poolDecimals?: number, tokenOutDecimals?: number): Promise<string>;
411
385
  /**
412
386
  * Get LOG_SWAP encoded topic
413
387
  * @return {String}
@@ -26,7 +26,7 @@ export declare class Dispenser {
26
26
  * @param {String} dispenserAddress
27
27
  * @param {any} dispenserABI
28
28
  */
29
- constructor(web3: Web3, dispenserAddress?: string, dispenserAbi?: AbiItem | AbiItem[], config?: Config);
29
+ constructor(web3: Web3, network?: string | number, dispenserAddress?: string, dispenserAbi?: AbiItem | AbiItem[], config?: Config);
30
30
  /**
31
31
  * Get information about a datatoken dispenser
32
32
  * @param {String} dtAddress
@@ -54,9 +54,9 @@ export declare class FixedRateExchange {
54
54
  * @param {any} web3
55
55
  * @param {any} fixedRateExchangeAbi
56
56
  */
57
- constructor(web3: Web3, fixedRateAddress: string, fixedRateExchangeAbi?: AbiItem | AbiItem[], oceanAddress?: string, config?: Config);
58
- amountToUnits(token: string, amount: string): Promise<string>;
59
- unitsToAmount(token: string, amount: string): Promise<string>;
57
+ constructor(web3: Web3, fixedRateAddress: string, network?: string | number, fixedRateExchangeAbi?: AbiItem | AbiItem[], oceanAddress?: string, config?: Config);
58
+ amountToUnits(token: string, amount: string, tokenDecimals: number): Promise<string>;
59
+ unitsToAmount(token: string, amount: string, tokenDecimals: number): Promise<string>;
60
60
  /**
61
61
  * Creates unique exchange identifier.
62
62
  * @param {String} baseToken baseToken contract address
@@ -8,9 +8,8 @@ export declare class SideStaking {
8
8
  web3: Web3;
9
9
  GASLIMIT_DEFAULT: number;
10
10
  config: Config;
11
- constructor(web3: Web3, ssAbi?: AbiItem | AbiItem[], config?: Config);
12
- amountToUnits(token: string, amount: string): Promise<string>;
13
- unitsToAmount(token: string, amount: string): Promise<string>;
11
+ constructor(web3: Web3, network?: string | number, ssAbi?: AbiItem | AbiItem[], config?: Config);
12
+ unitsToAmount(token: string, amount: string, tokenDecimals?: number): Promise<string>;
14
13
  /**
15
14
  * Get (total vesting amount + token released from the contract when adding liquidity)
16
15
  * @param {String} ssAddress side staking contract address
@@ -58,9 +57,10 @@ export declare class SideStaking {
58
57
  * Get dt balance in the staking contract available for being added as liquidity
59
58
  * @param {String} ssAddress side staking contract address
60
59
  * @param {String} datatokenAddress datatokenAddress
60
+ * @param {number} tokenDecimals optional number of decimals of the token
61
61
  * @return {String}
62
62
  */
63
- getDatatokenBalance(ssAddress: string, datatokenAddress: string): Promise<string>;
63
+ getDatatokenBalance(ssAddress: string, datatokenAddress: string, tokenDecimals?: number): Promise<string>;
64
64
  /**
65
65
  * Get block when vesting ends
66
66
  * @param {String} ssAddress side staking contract address
@@ -72,9 +72,10 @@ export declare class SideStaking {
72
72
  * Get total amount vesting
73
73
  * @param {String} ssAddress side staking contract address
74
74
  * @param {String} datatokenAddress datatokenAddress
75
+ * @param {number} tokenDecimals optional number of decimals of the token
75
76
  * @return {String}
76
77
  */
77
- getvestingAmount(ssAddress: string, datatokenAddress: string): Promise<string>;
78
+ getvestingAmount(ssAddress: string, datatokenAddress: string, tokenDecimals?: number): Promise<string>;
78
79
  /**
79
80
  * Get last block publisher got some vested tokens
80
81
  * @param {String} ssAddress side staking contract address
@@ -86,9 +87,10 @@ export declare class SideStaking {
86
87
  * Get how much has been taken from the vesting amount
87
88
  * @param {String} ssAddress side staking contract address
88
89
  * @param {String} datatokenAddress datatokenAddress
90
+ * @param {number} tokenDecimals optional number of decimals of the token
89
91
  * @return {String}
90
92
  */
91
- getvestingAmountSoFar(ssAddress: string, datatokenAddress: string): Promise<string>;
93
+ getvestingAmountSoFar(ssAddress: string, datatokenAddress: string, tokenDecimals?: number): Promise<string>;
92
94
  /**
93
95
  * Estimate gas cost for getVesting
94
96
  * @param {String} account
@@ -38,7 +38,7 @@ export declare class Datatoken {
38
38
  * @param {AbiItem | AbiItem[]} datatokensAbi
39
39
  * @param {Web3} web3
40
40
  */
41
- constructor(web3: Web3, datatokensAbi?: AbiItem | AbiItem[], datatokensEnterpriseAbi?: AbiItem | AbiItem[], config?: Config);
41
+ constructor(web3: Web3, network?: string | number, datatokensAbi?: AbiItem | AbiItem[], datatokensEnterpriseAbi?: AbiItem | AbiItem[], config?: Config);
42
42
  /**
43
43
  * Estimate gas cost for mint method
44
44
  * @param {String} dtAddress Datatoken address
@@ -261,6 +261,25 @@ export declare class Datatoken {
261
261
  * @return {Promise<TransactionReceipt>} string
262
262
  */
263
263
  startOrder(dtAddress: string, address: string, consumer: string, serviceIndex: number, providerFees: ProviderFees, consumeMarketFee?: ConsumeMarketFee): Promise<TransactionReceipt>;
264
+ /** Estimate gas cost for reuseOrder method
265
+ * @param {String} dtAddress Datatoken address
266
+ * @param {String} address User address which calls
267
+ * @param {String} orderTxId previous valid order
268
+ * @param {providerFees} providerFees provider fees
269
+ * @param {Contract} contractInstance optional contract instance
270
+ * @return {Promise<any>}
271
+ */
272
+ estGasReuseOrder(dtAddress: string, address: string, orderTxId: string, providerFees: ProviderFees, contractInstance?: Contract): Promise<any>;
273
+ /** Reuse Order: called by payer or consumer having a valid order, but with expired provider access.
274
+ * Pays the provider fee again, but it will not require a new datatoken payment
275
+ * Requires previous approval of provider fee.
276
+ * @param {String} dtAddress Datatoken address
277
+ * @param {String} address User address which calls
278
+ * @param {String} orderTxId previous valid order
279
+ * @param {providerFees} providerFees provider fees
280
+ * @return {Promise<TransactionReceipt>} string
281
+ */
282
+ reuseOrder(dtAddress: string, address: string, orderTxId: string, providerFees: ProviderFees): Promise<TransactionReceipt>;
264
283
  /** Estimate gas cost for buyFromFreAndOrder method
265
284
  * @param {String} dtAddress Datatoken address
266
285
  * @param {String} address User address which calls
@@ -22,7 +22,7 @@ export declare class Nft {
22
22
  web3: Web3;
23
23
  startBlock: number;
24
24
  config: Config;
25
- constructor(web3: Web3, nftAbi?: AbiItem | AbiItem[], config?: Config);
25
+ constructor(web3: Web3, network?: string | number, nftAbi?: AbiItem | AbiItem[], config?: Config);
26
26
  /**
27
27
  * Estimate gas cost for createERC20 token creation
28
28
  * @param {String} nftAddress ERC721 addreess
@@ -8,5 +8,5 @@ export declare function getErcCreationParams(ercParams: Erc20CreateParams): any;
8
8
  export declare function getFreOrderParams(freParams: FreOrderParams): any;
9
9
  export declare function getFreCreationParams(freParams: FreCreationParams): any;
10
10
  export declare function getPoolCreationParams(web3: Web3, poolParams: PoolCreationParams): Promise<any>;
11
- export declare function unitsToAmount(web3: Web3, token: string, amount: string): Promise<string>;
12
- export declare function amountToUnits(web3: Web3, token: string, amount: string): Promise<string>;
11
+ export declare function unitsToAmount(web3: Web3, token: string, amount: string, tokenDecimals?: number): Promise<string>;
12
+ export declare function amountToUnits(web3: Web3, token: string, amount: string, tokenDecimals?: number): Promise<string>;
@@ -18,22 +18,25 @@ export declare function estApprove(web3: Web3, account: string, tokenAddress: st
18
18
  * @param {String} tokenAddress
19
19
  * @param {String} spender
20
20
  * @param {String} amount (always expressed as wei)
21
- * @param {String} force if true, will overwrite any previous allowence. Else, will check if allowence is enough and will not send a transaction if it's not needed
21
+ * @param {boolean} force if true, will overwrite any previous allowence. Else, will check if allowence is enough and will not send a transaction if it's not needed
22
+ * @param {number} tokenDecimals optional number of decimals of the token
22
23
  */
23
- export declare function approve(web3: Web3, account: string, tokenAddress: string, spender: string, amount: string, force?: boolean): Promise<TransactionReceipt | string>;
24
+ export declare function approve(web3: Web3, account: string, tokenAddress: string, spender: string, amount: string, force?: boolean, tokenDecimals?: number): Promise<TransactionReceipt | string>;
24
25
  /**
25
26
  * Get Allowance for any erc20
26
27
  * @param {Web3} web3
27
28
  * @param {String } tokenAdress
28
29
  * @param {String} account
29
30
  * @param {String} spender
31
+ * @param {number} tokenDecimals optional number of decimals of the token
30
32
  */
31
- export declare function allowance(web3: Web3, tokenAddress: string, account: string, spender: string): Promise<string>;
33
+ export declare function allowance(web3: Web3, tokenAddress: string, account: string, spender: string, tokenDecimals?: number): Promise<string>;
32
34
  /**
33
35
  * Get balance for any erc20
34
36
  * @param {Web3} web3
35
37
  * @param {String} tokenAdress
36
38
  * @param {String} owner
37
39
  * @param {String} spender
40
+ * @param {number} tokenDecimals optional number of decimals of the token
38
41
  */
39
- export declare function balance(web3: Web3, tokenAddress: string, account: string): Promise<string>;
42
+ export declare function balance(web3: Web3, tokenAddress: string, account: string, tokenDecimals?: number): Promise<string>;
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.36",
4
+ "version": "1.0.0-next.39",
5
5
  "description": "JavaScript client library for Ocean Protocol",
6
6
  "main": "./dist/lib.js",
7
7
  "umd:main": "dist/lib.umd.js",
@@ -58,7 +58,7 @@
58
58
  "web3": "^1.7.3"
59
59
  },
60
60
  "dependencies": {
61
- "@oceanprotocol/contracts": "1.0.0-alpha.28",
61
+ "@oceanprotocol/contracts": "^1.0.0-alpha.31",
62
62
  "bignumber.js": "^9.0.2",
63
63
  "cross-fetch": "^3.1.5",
64
64
  "crypto-js": "^4.1.1",
@@ -68,12 +68,12 @@
68
68
  "web3-eth-contract": "^1.7.1"
69
69
  },
70
70
  "devDependencies": {
71
- "@truffle/hdwallet-provider": "^2.0.6",
71
+ "@truffle/hdwallet-provider": "^2.0.8",
72
72
  "@types/chai": "^4.3.1",
73
73
  "@types/chai-spies": "^1.0.3",
74
74
  "@types/crypto-js": "^4.1.1",
75
- "@types/mocha": "^9.1.0",
76
- "@types/node": "^17.0.23",
75
+ "@types/mocha": "^9.1.1",
76
+ "@types/node": "^17.0.31",
77
77
  "@types/node-fetch": "^3.0.3",
78
78
  "@typescript-eslint/eslint-plugin": "^4.33.0",
79
79
  "@typescript-eslint/parser": "^4.33.0",
@@ -86,18 +86,18 @@
86
86
  "eslint-config-prettier": "^8.5.0",
87
87
  "eslint-plugin-prettier": "^4.0.0",
88
88
  "fs": "0.0.1-security",
89
- "microbundle": "^0.14.2",
90
- "mocha": "^9.2.2",
89
+ "microbundle": "^0.15.0",
90
+ "mocha": "^10.0.0",
91
91
  "mock-local-storage": "^1.1.21",
92
92
  "nyc": "^15.1.0",
93
93
  "ora": "5.4.1",
94
94
  "prettier": "^2.6.2",
95
- "release-it": "^14.14.2",
95
+ "release-it": "^15.0.0",
96
96
  "source-map-support": "^0.5.19",
97
97
  "ts-node": "^10.7.0",
98
98
  "ts-node-register": "^1.0.0",
99
99
  "typedoc": "0.22.15",
100
- "typescript": "^4.6.3"
100
+ "typescript": "^4.6.4"
101
101
  },
102
102
  "nyc": {
103
103
  "include": [