@oceanprotocol/lib 1.1.7 → 2.0.0-next.2
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 +47 -16
- package/CodeExamples.md +28 -315
- package/README.md +4 -7
- package/dist/lib.js +1 -1
- package/dist/lib.js.map +1 -1
- package/dist/lib.modern.js +1 -1
- package/dist/lib.modern.js.map +1 -1
- package/dist/lib.module.js +1 -1
- package/dist/lib.module.js.map +1 -1
- package/dist/lib.umd.js +1 -1
- package/dist/lib.umd.js.map +1 -1
- package/dist/src/@types/Asset.d.ts +4 -4
- package/dist/src/@types/Compute.d.ts +1 -1
- package/dist/src/@types/DDO/DDO.d.ts +2 -5
- package/dist/src/@types/{Erc20.d.ts → Datatoken.d.ts} +18 -1
- package/dist/src/@types/Dispenser.d.ts +9 -0
- package/dist/src/@types/FixedPrice.d.ts +24 -0
- package/dist/src/@types/{Erc721.d.ts → NFT.d.ts} +6 -0
- package/dist/src/@types/NFTFactory.d.ts +20 -0
- package/dist/src/@types/Provider.d.ts +8 -0
- package/dist/src/@types/ReturnTypes.d.ts +2 -0
- package/dist/src/@types/Router.d.ts +1 -1
- package/dist/src/@types/index.d.ts +11 -8
- package/dist/src/{models → config}/Config.d.ts +2 -23
- package/dist/src/{utils → config}/ConfigHelper.d.ts +1 -1
- package/dist/src/config/index.d.ts +2 -0
- package/dist/src/contracts/Datatoken.d.ts +232 -0
- package/dist/src/contracts/Dispenser.d.ts +73 -0
- package/dist/src/contracts/FixedRateExchange.d.ts +212 -0
- package/dist/src/contracts/NFT.d.ts +197 -0
- package/dist/src/contracts/NFTFactory.d.ts +144 -0
- package/dist/src/contracts/Router.d.ts +92 -0
- package/dist/src/contracts/SmartContract.d.ts +22 -0
- package/dist/src/contracts/SmartContractWithAddress.d.ts +18 -0
- package/dist/src/contracts/index.d.ts +11 -0
- package/dist/src/contracts/ve/VeAllocate.d.ts +41 -0
- package/dist/src/contracts/ve/VeFeeDistributor.d.ts +30 -0
- package/dist/src/contracts/ve/VeOcean.d.ts +69 -0
- package/dist/src/index.d.ts +4 -7
- package/dist/src/{aquarius → services}/Aquarius.d.ts +4 -14
- package/dist/src/{provider → services}/Provider.d.ts +5 -13
- package/dist/src/services/index.d.ts +2 -0
- package/dist/src/utils/Constants.d.ts +2 -0
- package/dist/src/utils/ContractUtils.d.ts +14 -8
- package/dist/src/utils/DdoHelpers.d.ts +1 -1
- package/dist/src/utils/FetchHelper.d.ts +1 -4
- package/dist/src/utils/Logger.d.ts +0 -1
- package/dist/src/utils/TokenUtils.d.ts +17 -39
- package/dist/src/utils/index.d.ts +6 -7
- package/dist/test/TestContractHandler.d.ts +4 -4
- package/dist/test/config.d.ts +1 -1
- package/dist/test/unit/{tokens/Datatoken.test.d.ts → Datatoken.test.d.ts} +0 -0
- package/dist/test/unit/{pools/dispenser/Dispenser.test.d.ts → Dispenser.test.d.ts} +0 -0
- package/dist/test/unit/{pools/fixedRate/FixedRateExchange.test.d.ts → FixedRateExchange.test.d.ts} +0 -0
- package/dist/test/unit/{tokens/Nft.test.d.ts → Nft.test.d.ts} +0 -0
- package/dist/test/unit/{factories/NftFactory.test.d.ts → NftFactory.test.d.ts} +0 -0
- package/dist/test/unit/{pools/Router.test.d.ts → Router.test.d.ts} +0 -0
- package/dist/test/unit/{pools/balancer/Pool.test.d.ts → veOcean.test.d.ts} +0 -0
- package/package.json +6 -19
- package/dist/src/@types/Pool.d.ts +0 -45
- package/dist/src/aquarius/index.d.ts +0 -1
- package/dist/src/factories/NFTFactory.d.ts +0 -275
- package/dist/src/factories/index.d.ts +0 -1
- package/dist/src/models/index.d.ts +0 -1
- package/dist/src/pools/Router.d.ts +0 -228
- package/dist/src/pools/balancer/Pool.d.ts +0 -395
- package/dist/src/pools/balancer/index.d.ts +0 -1
- package/dist/src/pools/dispenser/Dispenser.d.ts +0 -145
- package/dist/src/pools/dispenser/index.d.ts +0 -1
- package/dist/src/pools/fixedRate/FixedRateExchange.d.ts +0 -388
- package/dist/src/pools/fixedRate/index.d.ts +0 -1
- package/dist/src/pools/index.d.ts +0 -5
- package/dist/src/pools/ssContracts/SideStaking.d.ts +0 -133
- package/dist/src/pools/ssContracts/index.d.ts +0 -1
- package/dist/src/provider/index.d.ts +0 -1
- package/dist/src/tokens/Datatoken.d.ts +0 -413
- package/dist/src/tokens/NFT.d.ts +0 -364
- package/dist/src/tokens/index.d.ts +0 -2
- package/dist/src/utils/ConversionTypeHelper.d.ts +0 -3
- package/dist/src/utils/PoolHelpers.d.ts +0 -8
- package/dist/test/unit/pools/ssContracts/SideStaking.test.d.ts +0 -1
|
@@ -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,11 @@
|
|
|
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';
|
|
@@ -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
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -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 './
|
|
2
|
+
export * from './config';
|
|
3
|
+
export * from './contracts';
|
|
4
|
+
export * from './services';
|
|
5
|
+
export * from './utils';
|
|
@@ -1,24 +1,15 @@
|
|
|
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;
|
|
5
|
-
query:
|
|
6
|
-
match?: {
|
|
7
|
-
[property: string]: string | number | boolean | Record<string, string | number | boolean>;
|
|
8
|
-
};
|
|
9
|
-
query_string?: {
|
|
10
|
-
[property: string]: string | number | string[] | number[] | boolean;
|
|
11
|
-
};
|
|
12
|
-
simple_query_string?: {
|
|
13
|
-
[property: string]: string | number | string[] | number[] | boolean;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
5
|
+
query: any;
|
|
16
6
|
sort?: {
|
|
17
7
|
[jsonPath: string]: string;
|
|
18
8
|
};
|
|
9
|
+
aggs?: any;
|
|
19
10
|
}
|
|
20
11
|
export declare class Aquarius {
|
|
21
|
-
aquariusURL:
|
|
12
|
+
aquariusURL: string;
|
|
22
13
|
/**
|
|
23
14
|
* Instantiate Aquarius
|
|
24
15
|
* @param {String} aquariusURL
|
|
@@ -61,4 +52,3 @@ export declare class Aquarius {
|
|
|
61
52
|
*/
|
|
62
53
|
querySearch(query: SearchQuery, signal?: AbortSignal): Promise<any>;
|
|
63
54
|
}
|
|
64
|
-
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;
|
|
@@ -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 {
|
|
4
|
-
import {
|
|
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,
|
|
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
|
|
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(
|
|
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
|
|
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>;
|
|
@@ -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
|
-
|
|
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
|
|
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<
|
|
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<
|
|
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
|
|
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<
|
|
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
|
|
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
|
|
42
|
+
* Get balance for any Datatoken
|
|
65
43
|
* @param {Web3} web3
|
|
66
|
-
* @param {String
|
|
67
|
-
* @param {String}
|
|
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
|
|
49
|
+
export declare function balance(web3: Web3, tokenAddress: string, account: string, tokenDecimals?: number): Promise<string>;
|
|
71
50
|
/**
|
|
72
|
-
* Get
|
|
51
|
+
* Get Allowance for any erc20
|
|
73
52
|
* @param {Web3} web3
|
|
74
53
|
* @param {String} tokenAdress
|
|
75
|
-
* @param {String}
|
|
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
|
|
57
|
+
export declare function allowanceWei(web3: Web3, tokenAddress: string, account: string, spender: string, tokenDecimals?: number): Promise<string>;
|
|
80
58
|
/**
|
|
81
|
-
* Get decimals for any
|
|
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 './
|
|
2
|
-
export * from './DatatokenName';
|
|
1
|
+
export * from './Constants';
|
|
3
2
|
export * from './ContractUtils';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './ConfigHelper';
|
|
3
|
+
export * from './DatatokenName';
|
|
6
4
|
export * from './DdoHelpers';
|
|
7
|
-
export * from './
|
|
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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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>;
|
package/dist/test/config.d.ts
CHANGED
|
@@ -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;
|
|
File without changes
|
|
File without changes
|
package/dist/test/unit/{pools/fixedRate/FixedRateExchange.test.d.ts → FixedRateExchange.test.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oceanprotocol/lib",
|
|
3
3
|
"source": "./src/index.ts",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0-next.2",
|
|
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:
|
|
45
|
-
"
|
|
46
|
-
"
|
|
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.
|
|
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.
|
|
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';
|