@oceanprotocol/lib 1.1.8 → 2.0.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/CHANGELOG.md +47 -16
  2. package/CodeExamples.md +28 -315
  3. package/README.md +4 -7
  4. package/dist/lib.js +1 -1
  5. package/dist/lib.js.map +1 -1
  6. package/dist/lib.modern.js +1 -1
  7. package/dist/lib.modern.js.map +1 -1
  8. package/dist/lib.module.js +1 -1
  9. package/dist/lib.module.js.map +1 -1
  10. package/dist/lib.umd.js +1 -1
  11. package/dist/lib.umd.js.map +1 -1
  12. package/dist/src/@types/Asset.d.ts +4 -4
  13. package/dist/src/@types/Compute.d.ts +1 -1
  14. package/dist/src/@types/DDO/DDO.d.ts +2 -5
  15. package/dist/src/@types/{Erc20.d.ts → Datatoken.d.ts} +18 -1
  16. package/dist/src/@types/Dispenser.d.ts +9 -0
  17. package/dist/src/@types/FixedPrice.d.ts +24 -0
  18. package/dist/src/@types/{Erc721.d.ts → NFT.d.ts} +6 -0
  19. package/dist/src/@types/NFTFactory.d.ts +20 -0
  20. package/dist/src/@types/Provider.d.ts +8 -0
  21. package/dist/src/@types/ReturnTypes.d.ts +2 -0
  22. package/dist/src/@types/Router.d.ts +1 -1
  23. package/dist/src/@types/index.d.ts +11 -8
  24. package/dist/src/{models → config}/Config.d.ts +2 -23
  25. package/dist/src/{utils → config}/ConfigHelper.d.ts +1 -1
  26. package/dist/src/config/index.d.ts +2 -0
  27. package/dist/src/contracts/Datatoken.d.ts +232 -0
  28. package/dist/src/contracts/Dispenser.d.ts +73 -0
  29. package/dist/src/contracts/FixedRateExchange.d.ts +212 -0
  30. package/dist/src/contracts/NFT.d.ts +197 -0
  31. package/dist/src/contracts/NFTFactory.d.ts +144 -0
  32. package/dist/src/contracts/Router.d.ts +92 -0
  33. package/dist/src/contracts/SmartContract.d.ts +22 -0
  34. package/dist/src/contracts/SmartContractWithAddress.d.ts +18 -0
  35. package/dist/src/contracts/df/DfRewards.d.ts +32 -0
  36. package/dist/src/contracts/df/DfStrategyV1.d.ts +23 -0
  37. package/dist/src/contracts/index.d.ts +13 -0
  38. package/dist/src/contracts/ve/VeAllocate.d.ts +41 -0
  39. package/dist/src/contracts/ve/VeFeeDistributor.d.ts +30 -0
  40. package/dist/src/contracts/ve/VeOcean.d.ts +69 -0
  41. package/dist/src/index.d.ts +4 -7
  42. package/dist/src/{aquarius → services}/Aquarius.d.ts +2 -3
  43. package/dist/src/{provider → services}/Provider.d.ts +5 -13
  44. package/dist/src/services/index.d.ts +2 -0
  45. package/dist/src/utils/Constants.d.ts +2 -0
  46. package/dist/src/utils/ContractUtils.d.ts +14 -8
  47. package/dist/src/utils/DdoHelpers.d.ts +1 -1
  48. package/dist/src/utils/FetchHelper.d.ts +1 -4
  49. package/dist/src/utils/Logger.d.ts +0 -1
  50. package/dist/src/utils/TokenUtils.d.ts +17 -39
  51. package/dist/src/utils/index.d.ts +6 -7
  52. package/dist/test/TestContractHandler.d.ts +4 -4
  53. package/dist/test/config.d.ts +1 -1
  54. package/dist/test/unit/{factories/NftFactory.test.d.ts → DFRewards.test.d.ts} +0 -0
  55. package/dist/test/unit/{tokens/Datatoken.test.d.ts → Datatoken.test.d.ts} +0 -0
  56. package/dist/test/unit/{pools/dispenser/Dispenser.test.d.ts → Dispenser.test.d.ts} +0 -0
  57. package/dist/test/unit/{pools/fixedRate/FixedRateExchange.test.d.ts → FixedRateExchange.test.d.ts} +0 -0
  58. package/dist/test/unit/{tokens/Nft.test.d.ts → Nft.test.d.ts} +0 -0
  59. package/dist/test/unit/{pools/Router.test.d.ts → NftFactory.test.d.ts} +0 -0
  60. package/dist/test/unit/{pools/balancer/Pool.test.d.ts → Router.test.d.ts} +0 -0
  61. package/dist/test/unit/{pools/ssContracts/SideStaking.test.d.ts → veOcean.test.d.ts} +0 -0
  62. package/package.json +6 -19
  63. package/dist/src/@types/Pool.d.ts +0 -45
  64. package/dist/src/aquarius/index.d.ts +0 -1
  65. package/dist/src/factories/NFTFactory.d.ts +0 -275
  66. package/dist/src/factories/index.d.ts +0 -1
  67. package/dist/src/models/index.d.ts +0 -1
  68. package/dist/src/pools/Router.d.ts +0 -228
  69. package/dist/src/pools/balancer/Pool.d.ts +0 -395
  70. package/dist/src/pools/balancer/index.d.ts +0 -1
  71. package/dist/src/pools/dispenser/Dispenser.d.ts +0 -145
  72. package/dist/src/pools/dispenser/index.d.ts +0 -1
  73. package/dist/src/pools/fixedRate/FixedRateExchange.d.ts +0 -388
  74. package/dist/src/pools/fixedRate/index.d.ts +0 -1
  75. package/dist/src/pools/index.d.ts +0 -5
  76. package/dist/src/pools/ssContracts/SideStaking.d.ts +0 -133
  77. package/dist/src/pools/ssContracts/index.d.ts +0 -1
  78. package/dist/src/provider/index.d.ts +0 -1
  79. package/dist/src/tokens/Datatoken.d.ts +0 -413
  80. package/dist/src/tokens/NFT.d.ts +0 -364
  81. package/dist/src/tokens/index.d.ts +0 -2
  82. package/dist/src/utils/ConversionTypeHelper.d.ts +0 -3
  83. package/dist/src/utils/PoolHelpers.d.ts +0 -8
@@ -0,0 +1,18 @@
1
+ import Web3 from 'web3';
2
+ import { Contract } from 'web3-eth-contract';
3
+ import { AbiItem } from 'web3-utils';
4
+ import { Config } from '../config';
5
+ import { SmartContract } from './SmartContract';
6
+ export declare abstract class SmartContractWithAddress extends SmartContract {
7
+ address: string;
8
+ contract: Contract;
9
+ /**
10
+ * Instantiate the smart contract.
11
+ * @param {string} address Address of the smart contract
12
+ * @param {Web3} web3
13
+ * @param {string | number} network Network id or name
14
+ * @param {Config} config Configutation of the smart contract
15
+ * @param {AbiItem | AbiItem[]} abi ABI of the smart contract
16
+ */
17
+ constructor(address: string, web3: Web3, network?: string | number, config?: Config, abi?: AbiItem | AbiItem[]);
18
+ }
@@ -0,0 +1,32 @@
1
+ import { AbiItem } from 'web3-utils';
2
+ import { SmartContractWithAddress } from '../SmartContractWithAddress';
3
+ import { ReceiptOrEstimate } from '../../@types';
4
+ /**
5
+ * Provides an interface for DFRewards contract
6
+ */
7
+ export declare class DfRewards extends SmartContractWithAddress {
8
+ getDefaultAbi(): AbiItem | AbiItem[];
9
+ /** Get available DF Rewards for a token
10
+ * @param {String} userAddress user address
11
+ * @param {String} tokenAddress token address
12
+ * @return {Promise<string>}
13
+ */
14
+ getAvailableRewards(userAddress: string, tokenAddress: string): Promise<string>;
15
+ /**
16
+ * claim rewards for any address
17
+ * @param {String} fromUserAddress user that generates the tx
18
+ * @param {String} userAddress user address to claim
19
+ * @param {String} tokenAddress token address
20
+ * @return {Promise<ReceiptOrEstimate>}
21
+ */
22
+ claimRewards<G extends boolean = false>(fromUserAddress: string, userAddress: string, tokenAddress: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
23
+ /**
24
+ * allocate rewards to address. An approve must exist before calling this function.
25
+ * @param {String} fromUserAddress user that generates the tx
26
+ * @param {String[]} userAddresses array of users that will receive rewards
27
+ * @param {String[]} amounts array of amounts
28
+ * @param {String} tokenAddress token address
29
+ * @return {Promise<ReceiptOrEstimate>}
30
+ */
31
+ allocateRewards<G extends boolean = false>(fromUserAddress: string, userAddresses: string[], amounts: string[], tokenAddress: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
32
+ }
@@ -0,0 +1,23 @@
1
+ import { AbiItem } from 'web3-utils';
2
+ import { SmartContractWithAddress } from '../SmartContractWithAddress';
3
+ import { ReceiptOrEstimate } from '../../@types';
4
+ /**
5
+ * Provides an interface for dfStrategyV1 contract
6
+ */
7
+ export declare class DfStrategyV1 extends SmartContractWithAddress {
8
+ getDefaultAbi(): AbiItem | AbiItem[];
9
+ /** Get available DF Rewards for multiple tokens
10
+ * @param {String} userAddress user address
11
+ * @param {String} tokenAddresses array of tokens
12
+ * @return {Promise<string[]>}
13
+ */
14
+ getMultipleAvailableRewards(userAddress: string, tokenAddresses: string[]): Promise<string[]>;
15
+ /**
16
+ * claim multiple token rewards for any address
17
+ * @param {String} fromUserAddress user that generates the tx
18
+ * @param {String} userAddress user address to claim
19
+ * @param {String} tokenAddresses array of tokens
20
+ * @return {Promise<ReceiptOrEstimate>}
21
+ */
22
+ claimMultipleRewards<G extends boolean = false>(fromUserAddress: string, userAddress: string, tokenAddresses: string[], estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
23
+ }
@@ -0,0 +1,13 @@
1
+ export * from './SmartContract';
2
+ export * from './SmartContractWithAddress';
3
+ export * from './Dispenser';
4
+ export * from './FixedRateExchange';
5
+ export * from './Router';
6
+ export * from './Datatoken';
7
+ export * from './NFT';
8
+ export * from './NFTFactory';
9
+ export * from './ve/VeOcean';
10
+ export * from './ve/VeFeeDistributor';
11
+ export * from './ve/VeAllocate';
12
+ export * from './df/DfRewards';
13
+ export * from './df/DfStrategyV1';
@@ -0,0 +1,41 @@
1
+ import { AbiItem } from 'web3-utils';
2
+ import { SmartContractWithAddress } from '../SmartContractWithAddress';
3
+ import { ReceiptOrEstimate } from '../../@types';
4
+ /**
5
+ * Provides an interface for veOcean contract
6
+ */
7
+ export declare class VeAllocate extends SmartContractWithAddress {
8
+ getDefaultAbi(): AbiItem | AbiItem[];
9
+ /**
10
+ * set a specific percentage of veOcean to a specific nft
11
+ * Maximum allocated percentage is 10000, so 1% is specified as 100
12
+ * @param {String} userAddress user address
13
+ * @param {String} amount Percentage used
14
+ * @param {String} nft NFT address to allocate to
15
+ * @param {String} chainId chainId of NFT
16
+ * @return {Promise<ReceiptOrEstimate>}
17
+ */
18
+ setAllocation<G extends boolean = false>(userAddress: string, amount: string, nft: string, chainId: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
19
+ /**
20
+ * set specific percetage of veOcean to multiple nfts
21
+ * Maximum allocated percentage is 10000, so 1% is specified as 100
22
+ * @param {String} userAddress user address
23
+ * @param {String[]} amount Array of percentages used
24
+ * @param {String[]} nft Array of NFT addresses
25
+ * @param {String[]} chainId Array of chainIds
26
+ * @return {Promise<ReceiptOrEstimate>}
27
+ */
28
+ setBatchAllocation<G extends boolean = false>(userAddress: string, amount: string[], nft: string[], chainId: number[], estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
29
+ /** Get totalAllocation for address
30
+ * @param {String} userAddress user address
31
+ * @return {Promise<number>}
32
+ */
33
+ getTotalAllocation(userAddress: string): Promise<number>;
34
+ /** Get getveAllocation for address, nft, chainId
35
+ * @param {String} userAddress user address
36
+ * @param {String} nft NFT address to allocate to
37
+ * @param {String} chainId chainId of NFT
38
+ * @return {Promise<number>}
39
+ */
40
+ getVeAllocation(userAddress: string, nft: string, chainId: string): Promise<number>;
41
+ }
@@ -0,0 +1,30 @@
1
+ import { AbiItem } from 'web3-utils';
2
+ import { SmartContractWithAddress } from '../SmartContractWithAddress';
3
+ import { ReceiptOrEstimate } from '../../@types';
4
+ /**
5
+ * Provides an interface for veOcean contract
6
+ */
7
+ export declare class VeFeeDistributor extends SmartContractWithAddress {
8
+ getDefaultAbi(): AbiItem | AbiItem[];
9
+ /**
10
+ * Claim fees for `userAddress`
11
+ * Each call to claim look at a maximum of 50 user veOCEAN points.
12
+ For accounts with many veOCEAN related actions, this function
13
+ may need to be called more than once to claim all available
14
+ fees. In the `Claimed` event that fires, if `claim_epoch` is
15
+ less than `max_epoch`, the account may claim again
16
+ * @param {String} userAddress user address
17
+ * @return {Promise<ReceiptOrEstimate>}
18
+ */
19
+ claim<G extends boolean = false>(userAddress: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
20
+ /**
21
+ * Make multiple fee claims in a single call
22
+ Used to claim for many accounts at once, or to make
23
+ multiple claims for the same address when that address
24
+ has significant veOCEAN history
25
+ * @param {String} fromUserAddress user address that sends the tx
26
+ * @param {String} addresses array of addresses to claim
27
+ * @return {Promise<ReceiptOrEstimate>}
28
+ */
29
+ claimMany<G extends boolean = false>(fromUserAddress: string, addresses: string[], estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
30
+ }
@@ -0,0 +1,69 @@
1
+ import { AbiItem } from 'web3-utils';
2
+ import { SmartContractWithAddress } from '../SmartContractWithAddress';
3
+ import { ReceiptOrEstimate } from '../../@types';
4
+ /**
5
+ * Provides an interface for veOcean contract
6
+ */
7
+ export declare class VeOcean extends SmartContractWithAddress {
8
+ getDefaultAbi(): AbiItem | AbiItem[];
9
+ /**
10
+ * Deposit `amount` tokens for `userAddress` and lock until `unlockTime`
11
+ * @param {String} userAddress user address
12
+ * @param {String} amount Amount of tokens to be locked
13
+ * @param {Number} unlockTime Timestamp for unlock
14
+ * @return {Promise<ReceiptOrEstimate>}
15
+ */
16
+ lockTokens<G extends boolean = false>(userAddress: string, amount: string, unlockTime: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
17
+ /**
18
+ * Deposit `amount` tokens for `toAddress` and add to the existing lock
19
+ * Anyone (even a smart contract) can deposit for someone else, but cannot extend their locktime and deposit for a brand new user
20
+ * @param {String} fromUserAddress user address that sends the tx
21
+ * @param {String} toAddress user address to deposit for
22
+ * @param {String} amount Amount of tokens to be locked
23
+ * @return {Promise<ReceiptOrEstimate>}
24
+ */
25
+ depositFor<G extends boolean = false>(fromUserAddress: string, toAddress: string, amount: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
26
+ /**
27
+ * Deposit `amount` additional tokens for `userAddress` without modifying the unlock time
28
+ * @param {String} userAddress user address that sends the tx
29
+ * @param {String} amount Amount of tokens to be locked
30
+ * @return {Promise<ReceiptOrEstimate>}
31
+ */
32
+ increaseAmount<G extends boolean = false>(userAddress: string, amount: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
33
+ /**
34
+ * Extend the unlock time for `userAddress` to `unlockTime`
35
+ * @param {String} userAddress user address that sends the tx
36
+ * @param {Number} unlockTime Timestamp for new unlock time
37
+ * @return {Promise<ReceiptOrEstimate>}
38
+ */
39
+ increaseUnlockTime<G extends boolean = false>(userAddress: string, unlockTime: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
40
+ /**
41
+ * Withdraw all tokens for `userAddress`
42
+ * @param {String} userAddress user address that sends the tx
43
+ * @return {Promise<ReceiptOrEstimate>}
44
+ */
45
+ withdraw<G extends boolean = false>(userAddress: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
46
+ /** Get voting power for address
47
+ * @param {String} userAddress user address
48
+ * @return {Promise<number>}
49
+ */
50
+ getVotingPower(userAddress: string): Promise<number>;
51
+ /** Get locked balance
52
+ * @param {String} userAddress user address
53
+ * @return {Promise<string>}
54
+ */
55
+ getLockedAmount(userAddress: string): Promise<string>;
56
+ /** Get untilLock for address
57
+ * @param {String} userAddress user address
58
+ * @return {Promise<number>}
59
+ */
60
+ lockEnd(userAddress: string): Promise<number>;
61
+ /** Get total supply
62
+ * @return {Promise<number>}
63
+ */
64
+ totalSupply(): Promise<string>;
65
+ /** Get token
66
+ * @return {Promise<string>}
67
+ */
68
+ getToken(): Promise<string>;
69
+ }
@@ -1,8 +1,5 @@
1
- export * from './aquarius';
2
- export * from './pools';
3
- export * from './tokens';
4
- export * from './factories';
5
- export * from './models';
6
- export * from './utils';
7
1
  export * from './@types';
8
- export * from './provider';
2
+ export * from './config';
3
+ export * from './contracts';
4
+ export * from './services';
5
+ export * from './utils';
@@ -1,4 +1,4 @@
1
- import { Asset, DDO, ValidateMetadata } from '../@types/';
1
+ import { Asset, DDO, ValidateMetadata } from '../@types';
2
2
  export interface SearchQuery {
3
3
  from?: number;
4
4
  size?: number;
@@ -9,7 +9,7 @@ export interface SearchQuery {
9
9
  aggs?: any;
10
10
  }
11
11
  export declare class Aquarius {
12
- aquariusURL: any;
12
+ aquariusURL: string;
13
13
  /**
14
14
  * Instantiate Aquarius
15
15
  * @param {String} aquariusURL
@@ -52,4 +52,3 @@ export declare class Aquarius {
52
52
  */
53
53
  querySearch(query: SearchQuery, signal?: AbortSignal): Promise<any>;
54
54
  }
55
- export default Aquarius;
@@ -1,16 +1,5 @@
1
1
  import Web3 from 'web3';
2
- import { FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults } from '../@types/';
3
- export interface HttpCallback {
4
- (httpMethod: string, url: string, body: string, header: any): Promise<any>;
5
- }
6
- export interface ServiceEndpoint {
7
- serviceName: string;
8
- method: string;
9
- urlPath: string;
10
- }
11
- export interface UserCustomParameters {
12
- [key: string]: any;
13
- }
2
+ import { FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, ServiceEndpoint, UserCustomParameters } from '../@types';
14
3
  export declare class Provider {
15
4
  /**
16
5
  * Returns the provider endpoints
@@ -149,6 +138,9 @@ export declare class Provider {
149
138
  * @return {Promise<boolean>} string
150
139
  */
151
140
  isValidProvider(url: string, signal?: AbortSignal): Promise<boolean>;
141
+ private noZeroX;
142
+ private zeroXTransformer;
143
+ private inputMatch;
144
+ private getData;
152
145
  }
153
146
  export declare const ProviderInstance: Provider;
154
- export default ProviderInstance;
@@ -0,0 +1,2 @@
1
+ export * from './Aquarius';
2
+ export * from './Provider';
@@ -1,2 +1,4 @@
1
1
  export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
2
2
  export declare const GASLIMIT_DEFAULT = 1000000;
3
+ export declare const MAX_UINT_256 = "115792089237316195423570985008687907853269984665640564039457584007913129639934";
4
+ export declare const FEE_HISTORY_NOT_SUPPORTED = "Returned error: Method eth_feeHistory not supported.";
@@ -1,13 +1,9 @@
1
1
  import Web3 from 'web3';
2
2
  import { Contract } from 'web3-eth-contract';
3
- import { Erc20CreateParams, FreCreationParams, FreOrderParams, PoolCreationParams } from '../@types';
4
- import { Config } from '../models';
3
+ import { Config } from '../config';
4
+ import { TransactionReceipt } from 'web3-core';
5
5
  export declare function setContractDefaults(contract: Contract, config: Config): Contract;
6
- export declare function getFairGasPrice(web3: Web3, config: Config): Promise<string>;
7
- export declare function getErcCreationParams(ercParams: Erc20CreateParams): any;
8
- export declare function getFreOrderParams(web3: Web3, freParams: FreOrderParams): Promise<any>;
9
- export declare function getFreCreationParams(freParams: FreCreationParams): any;
10
- export declare function getPoolCreationParams(web3: Web3, poolParams: PoolCreationParams): Promise<any>;
6
+ export declare function getFairGasPrice(web3: Web3, gasFeeMultiplier: number): Promise<string>;
11
7
  export declare function unitsToAmount(web3: Web3, token: string, amount: string, tokenDecimals?: number): Promise<string>;
12
8
  export declare function amountToUnits(web3: Web3, token: string, amount: string, tokenDecimals?: number): Promise<string>;
13
9
  /**
@@ -17,4 +13,14 @@ export declare function amountToUnits(web3: Web3, token: string, amount: string,
17
13
  * @param {...any[]} args arguments of the function
18
14
  * @return {Promise<number>} gas cost of the function
19
15
  */
20
- export declare function estimateGas(from: string, functionToEstimateGas: Function, ...args: any[]): Promise<any>;
16
+ export declare function calculateEstimatedGas(from: string, functionToEstimateGas: Function, ...args: any[]): Promise<number>;
17
+ /**
18
+ * Send the transation on chain
19
+ * @param {string} from account that calls the function
20
+ * @param {any} estGas estimated gas for the transaction
21
+ * @param {Web3} web3 web3 objcet
22
+ * @param {Function} functionToSend function that we need to send
23
+ * @param {...any[]} args arguments of the function
24
+ * @return {Promise<any>} transaction receipt
25
+ */
26
+ export declare function sendTx(from: string, estGas: number, web3: Web3, gasFeeMultiplier: number, functionToSend: Function, ...args: any[]): Promise<TransactionReceipt>;
@@ -1,2 +1,2 @@
1
- export declare function generateDid(erc721Address: string, chainId: number): string;
1
+ export declare function generateDid(nftAddress: string, chainId: number): string;
2
2
  export declare function getHash(data: any): string;
@@ -1,6 +1,3 @@
1
- import { DownloadResponse } from '../@types/DownloadResponse';
2
- export declare function fetchData(url: string, opts: RequestInit): Promise<Response>;
1
+ import { DownloadResponse } from '../@types';
3
2
  export declare function downloadFileBrowser(url: string): Promise<void>;
4
3
  export declare function downloadFile(url: string, index?: number): Promise<DownloadResponse>;
5
- export declare function getData(url: string): Promise<Response>;
6
- export declare function postData(url: string, payload: BodyInit): Promise<Response>;
@@ -17,4 +17,3 @@ export declare class Logger {
17
17
  private dispatch;
18
18
  }
19
19
  export declare const LoggerInstance: Logger;
20
- export default LoggerInstance;
@@ -1,27 +1,16 @@
1
- import { Contract } from 'web3-eth-contract';
2
- import { TransactionReceipt } from 'web3-core';
3
1
  import Web3 from 'web3';
4
- /**
5
- * Estimate gas cost for approval function
6
- * @param {String} account
7
- * @param {String} tokenAddress
8
- * @param {String} spender
9
- * @param {String} amount
10
- * @param {String} force
11
- * @param {Contract} contractInstance optional contract instance
12
- * @return {Promise<number>}
13
- */
14
- export declare function estApprove(web3: Web3, account: string, tokenAddress: string, spender: string, amount: string, contractInstance?: Contract): Promise<number>;
2
+ import { Config } from '../config';
3
+ import { ReceiptOrEstimate } from '../@types';
15
4
  /**
16
5
  * Approve spender to spent amount tokens
17
6
  * @param {String} account
18
7
  * @param {String} tokenAddress
19
8
  * @param {String} spender
20
- * @param {String} amount amount of ERC20 tokens (always expressed as wei)
9
+ * @param {String} amount amount of ERC20 Datatokens (always expressed as wei)
21
10
  * @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
11
  * @param {number} tokenDecimals optional number of decimals of the token
23
12
  */
24
- export declare function approve(web3: Web3, account: string, tokenAddress: string, spender: string, amount: string, force?: boolean, tokenDecimals?: number): Promise<TransactionReceipt | string>;
13
+ export declare function approve<G extends boolean = false>(web3: Web3, config: Config, account: string, tokenAddress: string, spender: string, amount: string, force?: boolean, tokenDecimals?: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
25
14
  /**
26
15
  * Approve spender to spent amount tokens
27
16
  * @param {String} account
@@ -30,29 +19,18 @@ export declare function approve(web3: Web3, account: string, tokenAddress: strin
30
19
  * @param {String} amount amount of ERC20 tokens (always expressed as wei)
31
20
  * @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
32
21
  */
33
- export declare function approveWei(web3: Web3, account: string, tokenAddress: string, spender: string, amount: string, force?: boolean): Promise<TransactionReceipt | string>;
34
- /**
35
- * Estimate gas cost for transfer function
36
- * @param {String} account
37
- * @param {String} tokenAddress
38
- * @param {String} recipient
39
- * @param {String} amount
40
- * @param {String} force
41
- * @param {Contract} contractInstance optional contract instance
42
- * @return {Promise<number>}
43
- */
44
- export declare function estTransfer(web3: Web3, account: string, tokenAddress: string, recipient: string, amount: string, contractInstance?: Contract): Promise<number>;
22
+ export declare function approveWei<G extends boolean = false>(web3: Web3, config: Config, account: string, tokenAddress: string, spender: string, amount: string, force?: boolean, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
45
23
  /**
46
24
  * Moves amount tokens from the caller’s account to recipient.
47
25
  * @param {String} account
48
26
  * @param {String} tokenAddress
49
27
  * @param {String} recipient
50
- * @param {String} amount amount of ERC20 tokens (not as wei)
28
+ * @param {String} amount amount of ERC20 Datatokens (not as wei)
51
29
  * @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
52
30
  */
53
- export declare function transfer(web3: Web3, account: string, tokenAddress: string, recipient: string, amount: string): Promise<TransactionReceipt | string>;
31
+ export declare function transfer<G extends boolean = false>(web3: Web3, config: Config, account: string, tokenAddress: string, recipient: string, amount: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
54
32
  /**
55
- * Get Allowance for any erc20
33
+ * Get Allowance for any Datatoken
56
34
  * @param {Web3} web3
57
35
  * @param {String } tokenAdress
58
36
  * @param {String} account
@@ -61,24 +39,24 @@ export declare function transfer(web3: Web3, account: string, tokenAddress: stri
61
39
  */
62
40
  export declare function allowance(web3: Web3, tokenAddress: string, account: string, spender: string, tokenDecimals?: number): Promise<string>;
63
41
  /**
64
- * Get Allowance for any erc20
42
+ * Get balance for any Datatoken
65
43
  * @param {Web3} web3
66
- * @param {String } tokenAdress
67
- * @param {String} account
44
+ * @param {String} tokenAdress
45
+ * @param {String} owner
68
46
  * @param {String} spender
47
+ * @param {number} tokenDecimals optional number of decimals of the token
69
48
  */
70
- export declare function allowanceWei(web3: Web3, tokenAddress: string, account: string, spender: string, tokenDecimals?: number): Promise<string>;
49
+ export declare function balance(web3: Web3, tokenAddress: string, account: string, tokenDecimals?: number): Promise<string>;
71
50
  /**
72
- * Get balance for any erc20
51
+ * Get Allowance for any erc20
73
52
  * @param {Web3} web3
74
53
  * @param {String} tokenAdress
75
- * @param {String} owner
54
+ * @param {String} account
76
55
  * @param {String} spender
77
- * @param {number} tokenDecimals optional number of decimals of the token
78
56
  */
79
- export declare function balance(web3: Web3, tokenAddress: string, account: string, tokenDecimals?: number): Promise<string>;
57
+ export declare function allowanceWei(web3: Web3, tokenAddress: string, account: string, spender: string, tokenDecimals?: number): Promise<string>;
80
58
  /**
81
- * Get decimals for any erc20
59
+ * Get decimals for any Datatoken
82
60
  * @param {Web3} web3
83
61
  * @param {String} tokenAdress
84
62
  * @return {Promise<number>} Number of decimals of the token
@@ -1,11 +1,10 @@
1
- export * from './Logger';
2
- export * from './DatatokenName';
1
+ export * from './Constants';
3
2
  export * from './ContractUtils';
4
- export * from './FetchHelper';
5
- export * from './ConfigHelper';
3
+ export * from './DatatokenName';
6
4
  export * from './DdoHelpers';
7
- export * from './Constants';
5
+ export * from './FetchHelper';
6
+ export * from './General';
7
+ export * from './Logger';
8
+ export * from './minAbi';
8
9
  export * from './SignatureUtils';
9
10
  export * from './TokenUtils';
10
- export * from './General';
11
- export * from './PoolHelpers';
@@ -1,16 +1,16 @@
1
1
  import Web3 from 'web3';
2
2
  export interface Addresses {
3
3
  opfCommunityFeeCollectorAddress: string;
4
- poolTemplateAddress: string;
5
- erc20TemplateAddress: string;
6
- erc721TemplateAddress: string;
4
+ datatokenTemplateAddress: string;
5
+ nftTemplateAddress: string;
7
6
  oceanAddress: string;
8
7
  routerAddress: string;
9
8
  sideStakingAddress: string;
10
9
  fixedRateAddress: string;
11
10
  dispenserAddress: string;
12
- erc721FactoryAddress: string;
11
+ nftFactoryAddress: string;
13
12
  daiAddress: string;
14
13
  usdcAddress: string;
14
+ poolTemplateAddress: string;
15
15
  }
16
16
  export declare const deployContracts: (web3: Web3, owner: string) => Promise<Addresses>;
@@ -1,5 +1,5 @@
1
1
  import Web3 from 'web3';
2
2
  export declare const GAS_PRICE = "3000000000";
3
3
  export declare const web3: Web3;
4
- export declare const getTestConfig: (web3: Web3) => Promise<import("../src").Config>;
4
+ export declare const getTestConfig: (web3: Web3) => Promise<import("../src/config").Config>;
5
5
  export declare const getAddresses: () => any;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oceanprotocol/lib",
3
3
  "source": "./src/index.ts",
4
- "version": "1.1.8",
4
+ "version": "2.0.0-next.3",
5
5
  "description": "JavaScript client library for Ocean Protocol",
6
6
  "main": "./dist/lib.js",
7
7
  "umd:main": "dist/lib.umd.js",
@@ -27,25 +27,12 @@
27
27
  "changelog": "auto-changelog -p",
28
28
  "prepublishOnly": "npm run build",
29
29
  "mocha": "TS_NODE_PROJECT='./test/tsconfig.json' mocha --config=test/.mocharc.json --node-env=test --exit",
30
- "test:nftfactory": "npm run mocha -- 'test/unit/factories/NftFactory.test.ts'",
31
- "test:nft": "npm run mocha -- 'test/unit/tokens/Nft.test.ts'",
32
- "test:datatoken": "npm run mocha -- 'test/unit/tokens/Datatoken.test.ts'",
33
- "test:router": "npm run mocha -- 'test/unit/pools/Router.test.ts'",
34
- "test:fixed": "npm run mocha -- 'test/unit/pools/fixedRate/FixedRateExchange.test.ts'",
35
- "test:ss": "npm run mocha -- 'test/unit/pools/ssContracts/SideStaking.test.ts'",
36
- "test:pool": "npm run mocha -- 'test/unit/pools/balancer/Pool.test.ts'",
37
- "test:dispenser": "npm run mocha -- 'test/unit/pools/dispenser/Dispenser.test.ts'",
38
- "test:publishAll": "npm run mocha -- 'test/integration/PublishFlows.test.ts'",
39
- "test:examples": "npm run mocha -- 'test/integration/CodeExamples.test.ts'",
40
- "test:provider": "npm run mocha -- 'test/integration/Provider.test.ts'",
41
30
  "test:unit": "npm run mocha -- 'test/unit/**/*.test.ts'",
42
31
  "test:unit:cover": "nyc --report-dir coverage/unit --exclude 'src/@types/**/*' npm run test:unit",
43
32
  "test:integration": "npm run mocha -- 'test/integration/**/*.test.ts'",
44
- "test:compute": "npm run mocha -- 'test/integration/ComputeFlow.test.ts'",
45
- "test:integration:cover": "nyc --report-dir coverage/integration --exclude 'src/@types/**/*' --no-clean npm run test:integration",
46
- "create:guide": "chmod +x ./scripts/createCodeExamples.sh && ./scripts/createCodeExamples.sh",
47
- "create:guide:mac": "chmod +x ./scripts/createCodeExamples-mac.sh && ./scripts/createCodeExamples-mac.sh",
48
- "commit:guide": "chmod +x scripts/commitChanges.sh && scripts/commitChanges.sh"
33
+ "test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration",
34
+ "create:guide": "./scripts/createCodeExamples.sh",
35
+ "commit:guide": "./scripts/commitChanges.sh"
49
36
  },
50
37
  "repository": {
51
38
  "type": "git",
@@ -62,7 +49,7 @@
62
49
  "web3": "^1.7.4"
63
50
  },
64
51
  "dependencies": {
65
- "@oceanprotocol/contracts": "^1.0.0",
52
+ "@oceanprotocol/contracts": "^1.1.3",
66
53
  "bignumber.js": "^9.0.2",
67
54
  "cross-fetch": "^3.1.5",
68
55
  "crypto-js": "^4.1.1",
@@ -96,7 +83,7 @@
96
83
  "nyc": "^15.1.0",
97
84
  "ora": "5.4.1",
98
85
  "prettier": "^2.7.1",
99
- "release-it": "^15.1.1",
86
+ "release-it": "^15.4.0",
100
87
  "source-map-support": "^0.5.19",
101
88
  "ts-node": "^10.8.2",
102
89
  "ts-node-register": "^1.0.0",
@@ -1,45 +0,0 @@
1
- export interface PoolCreationParams {
2
- ssContract: string;
3
- baseTokenAddress: string;
4
- baseTokenSender: string;
5
- publisherAddress: string;
6
- marketFeeCollector: string;
7
- poolTemplateAddress: string;
8
- rate: string;
9
- baseTokenDecimals: number;
10
- vestingAmount: string;
11
- vestedBlocks: number;
12
- initialBaseTokenLiquidity: string;
13
- swapFeeLiquidityProvider: string;
14
- swapFeeMarketRunner: string;
15
- }
16
- export interface CurrentFees {
17
- tokens: string[];
18
- amounts: string[];
19
- }
20
- export interface TokenInOutMarket {
21
- tokenIn: string;
22
- tokenOut: string;
23
- marketFeeAddress: string;
24
- tokenInDecimals?: number;
25
- tokenOutDecimals?: number;
26
- }
27
- export interface AmountsInMaxFee {
28
- tokenAmountIn: string;
29
- minAmountOut: string;
30
- swapMarketFee: string;
31
- maxPrice?: string;
32
- }
33
- export interface AmountsOutMaxFee {
34
- tokenAmountOut: string;
35
- maxAmountIn: string;
36
- swapMarketFee: string;
37
- maxPrice?: string;
38
- }
39
- export interface PoolPriceAndFees {
40
- tokenAmount: string;
41
- liquidityProviderSwapFeeAmount: string;
42
- oceanFeeAmount: string;
43
- publishMarketSwapFeeAmount: string;
44
- consumeMarketSwapFeeAmount: string;
45
- }
@@ -1 +0,0 @@
1
- export * from './Aquarius';