@oceanprotocol/lib 0.20.2 → 1.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 (146) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +1 -1
  3. package/dist/lib.js +2 -0
  4. package/dist/lib.js.map +1 -0
  5. package/dist/lib.modern.js +2 -0
  6. package/dist/lib.modern.js.map +1 -0
  7. package/dist/lib.module.js +2 -0
  8. package/dist/lib.module.js.map +1 -0
  9. package/dist/lib.umd.js +2 -0
  10. package/dist/lib.umd.js.map +1 -0
  11. package/dist/src/@types/Asset.d.ts +36 -0
  12. package/dist/{node/ocean/interfaces → src/@types}/Compute.d.ts +13 -12
  13. package/dist/src/@types/DDO/Credentials.d.ts +8 -0
  14. package/dist/src/@types/DDO/DDO.d.ts +15 -0
  15. package/dist/src/@types/DDO/Event.d.ts +7 -0
  16. package/dist/src/@types/DDO/Metadata.d.ts +38 -0
  17. package/dist/src/@types/DDO/Service.d.ts +28 -0
  18. package/dist/src/@types/FileMetadata.d.ts +8 -0
  19. package/dist/src/@types/Provider.d.ts +15 -0
  20. package/dist/src/@types/index.d.ts +8 -0
  21. package/dist/src/aquarius/Aquarius.d.ts +10 -0
  22. package/dist/src/aquarius/index.d.ts +1 -0
  23. package/dist/src/factories/NFTFactory.d.ts +70 -0
  24. package/dist/src/factories/index.d.ts +1 -0
  25. package/dist/src/index.d.ts +8 -0
  26. package/dist/src/interfaces/DispenserInterface.d.ts +7 -0
  27. package/dist/src/interfaces/Erc20Interface.d.ts +11 -0
  28. package/dist/src/interfaces/FixedRateInterface.d.ts +19 -0
  29. package/dist/src/interfaces/PoolInterface.d.ts +36 -0
  30. package/dist/src/interfaces/RouterInterface.d.ts +12 -0
  31. package/dist/src/interfaces/index.d.ts +5 -0
  32. package/dist/{node → src}/models/Config.d.ts +10 -7
  33. package/dist/src/models/index.d.ts +1 -0
  34. package/dist/src/pools/Router.d.ts +46 -0
  35. package/dist/src/pools/balancer/Pool.d.ts +73 -0
  36. package/dist/src/pools/balancer/index.d.ts +1 -0
  37. package/dist/src/pools/dispenser/Dispenser.d.ts +37 -0
  38. package/dist/src/pools/dispenser/index.d.ts +1 -0
  39. package/dist/src/pools/fixedRate/FixedRateExchange.d.ts +95 -0
  40. package/dist/src/pools/fixedRate/index.d.ts +1 -0
  41. package/dist/src/pools/index.d.ts +3 -0
  42. package/dist/src/pools/ssContracts/SideStaking.d.ts +28 -0
  43. package/dist/src/pools/ssContracts/index.d.ts +1 -0
  44. package/dist/src/provider/Provider.d.ts +31 -0
  45. package/dist/src/provider/index.d.ts +1 -0
  46. package/dist/src/tokens/Datatoken.d.ts +77 -0
  47. package/dist/src/tokens/NFT.d.ts +57 -0
  48. package/dist/src/tokens/index.d.ts +2 -0
  49. package/dist/src/utils/ConfigHelper.d.ts +6 -0
  50. package/dist/src/utils/Constants.d.ts +1 -0
  51. package/dist/src/utils/ContractParams.d.ts +4 -0
  52. package/dist/src/utils/ConversionTypeHelper.d.ts +3 -0
  53. package/dist/{node/utils/Datatokens.d.ts → src/utils/DatatokenName.d.ts} +1 -1
  54. package/dist/src/utils/DdoHelpers.d.ts +2 -0
  55. package/dist/src/utils/FetchHelper.d.ts +5 -0
  56. package/dist/src/utils/GasUtils.d.ts +2 -0
  57. package/dist/{node → src}/utils/Logger.d.ts +0 -0
  58. package/dist/src/utils/SignatureUtils.d.ts +8 -0
  59. package/dist/src/utils/index.d.ts +9 -0
  60. package/dist/test/TestContractHandler.d.ts +44 -0
  61. package/dist/test/integration/ComputeFlow.test.d.ts +1 -0
  62. package/dist/test/integration/Provider.test.d.ts +1 -0
  63. package/dist/test/integration/PublishFlows.test.d.ts +1 -0
  64. package/dist/test/integration/SimplePublishConsumeFlow.test.d.ts +1 -0
  65. package/dist/test/integration/config.d.ts +3 -0
  66. package/dist/test/unit/NftFactory.test.d.ts +1 -0
  67. package/dist/test/unit/config.d.ts +3 -0
  68. package/dist/test/unit/pools/Router.test.d.ts +1 -0
  69. package/dist/test/unit/pools/balancer/Pool.test.d.ts +1 -0
  70. package/dist/test/unit/pools/dispenser/Dispenser.test.d.ts +1 -0
  71. package/dist/test/unit/pools/fixedRate/FixedRateExchange.test.d.ts +1 -0
  72. package/dist/test/unit/pools/ssContracts/SideStaking.test.d.ts +1 -0
  73. package/dist/test/unit/tokens/Datatoken.test.d.ts +1 -0
  74. package/dist/test/unit/tokens/Nft.test.d.ts +1 -0
  75. package/docs/beginners_guide.md +2 -2
  76. package/docs/quickstart_simple.md +2 -2
  77. package/package.json +38 -31
  78. package/dist/node/Instantiable.abstract.d.ts +0 -25
  79. package/dist/node/balancer/OceanPool.d.ts +0 -95
  80. package/dist/node/balancer/Pool.d.ts +0 -56
  81. package/dist/node/balancer/PoolFactory.d.ts +0 -15
  82. package/dist/node/datatokens/ContractEvent.d.ts +0 -19
  83. package/dist/node/datatokens/ContractHandler.d.ts +0 -12
  84. package/dist/node/datatokens/Datatokens.d.ts +0 -44
  85. package/dist/node/datatokens/EventHandler.d.ts +0 -19
  86. package/dist/node/datatokens/Network.d.ts +0 -5
  87. package/dist/node/datatokens/Web3Provider.d.ts +0 -5
  88. package/dist/node/datatokens/contracts/ContractBase.d.ts +0 -27
  89. package/dist/node/ddo/DDO.d.ts +0 -36
  90. package/dist/node/ddo/interfaces/AdditionalInformation.d.ts +0 -16
  91. package/dist/node/ddo/interfaces/Authentication.d.ts +0 -4
  92. package/dist/node/ddo/interfaces/BestPrice.d.ts +0 -10
  93. package/dist/node/ddo/interfaces/Consumable.d.ts +0 -5
  94. package/dist/node/ddo/interfaces/Credentials.d.ts +0 -9
  95. package/dist/node/ddo/interfaces/Curation.d.ts +0 -6
  96. package/dist/node/ddo/interfaces/DataTokenInfo.d.ts +0 -10
  97. package/dist/node/ddo/interfaces/EditableMetadata.d.ts +0 -9
  98. package/dist/node/ddo/interfaces/EditableMetadataLinks.d.ts +0 -5
  99. package/dist/node/ddo/interfaces/Event.d.ts +0 -7
  100. package/dist/node/ddo/interfaces/File.d.ts +0 -13
  101. package/dist/node/ddo/interfaces/Metadata.d.ts +0 -15
  102. package/dist/node/ddo/interfaces/MetadataAlgorithm.d.ts +0 -12
  103. package/dist/node/ddo/interfaces/MetadataMain.d.ts +0 -12
  104. package/dist/node/ddo/interfaces/Proof.d.ts +0 -6
  105. package/dist/node/ddo/interfaces/PublicKey.d.ts +0 -8
  106. package/dist/node/ddo/interfaces/PurgatoryData.d.ts +0 -4
  107. package/dist/node/ddo/interfaces/Service.d.ts +0 -99
  108. package/dist/node/ddo/interfaces/ServicePrices.d.ts +0 -4
  109. package/dist/node/ddo/interfaces/Status.d.ts +0 -5
  110. package/dist/node/ddo/interfaces/index.d.ts +0 -17
  111. package/dist/node/dispenser/Dispenser.d.ts +0 -44
  112. package/dist/node/exchange/FixedRateExchange.d.ts +0 -59
  113. package/dist/node/index.d.ts +0 -1
  114. package/dist/node/lib.d.ts +0 -15
  115. package/dist/node/lib.js +0 -2
  116. package/dist/node/lib.js.map +0 -1
  117. package/dist/node/lib.module.js +0 -2
  118. package/dist/node/lib.module.js.map +0 -1
  119. package/dist/node/lib.umd.js +0 -2
  120. package/dist/node/lib.umd.js.map +0 -1
  121. package/dist/node/metadatacache/MetadataCache.d.ts +0 -41
  122. package/dist/node/metadatacache/OnChainMetaData.d.ts +0 -31
  123. package/dist/node/ocean/Account.d.ts +0 -16
  124. package/dist/node/ocean/Accounts.d.ts +0 -9
  125. package/dist/node/ocean/Assets.d.ts +0 -56
  126. package/dist/node/ocean/AssetsCredential.d.ts +0 -6
  127. package/dist/node/ocean/Compute.d.ts +0 -75
  128. package/dist/node/ocean/DID.d.ts +0 -8
  129. package/dist/node/ocean/EventAccessControl.d.ts +0 -9
  130. package/dist/node/ocean/Ocean.d.ts +0 -34
  131. package/dist/node/ocean/OceanAuth.d.ts +0 -15
  132. package/dist/node/ocean/Versions.d.ts +0 -25
  133. package/dist/node/ocean/utils/SignatureUtils.d.ts +0 -13
  134. package/dist/node/ocean/utils/Utils.d.ts +0 -8
  135. package/dist/node/ocean/utils/WebServiceConnector.d.ts +0 -16
  136. package/dist/node/provider/Provider.d.ts +0 -56
  137. package/dist/node/utils/AssetResolverHelper.d.ts +0 -8
  138. package/dist/node/utils/ConfigHelper.d.ts +0 -17
  139. package/dist/node/utils/ContractUtils.d.ts +0 -5
  140. package/dist/node/utils/ConversionTypeHelpers.d.ts +0 -8
  141. package/dist/node/utils/GeneratorHelpers.d.ts +0 -1
  142. package/dist/node/utils/PromiseResolver.d.ts +0 -3
  143. package/dist/node/utils/SubscribableObserver.d.ts +0 -12
  144. package/dist/node/utils/SubscribablePromise.d.ts +0 -14
  145. package/dist/node/utils/Timeout.d.ts +0 -1
  146. package/dist/node/utils/index.d.ts +0 -9
@@ -0,0 +1,95 @@
1
+ import { TransactionReceipt } from 'web3-core';
2
+ import { Contract } from 'web3-eth-contract';
3
+ import { AbiItem } from 'web3-utils/types';
4
+ import Web3 from 'web3';
5
+ export interface FixedPriceExchange {
6
+ active: boolean;
7
+ exchangeOwner: string;
8
+ dataToken: string;
9
+ baseToken: string;
10
+ fixedRate: string;
11
+ dtDecimals: string;
12
+ btDecimals: string;
13
+ dtBalance: string;
14
+ btBalance: string;
15
+ dtSupply: string;
16
+ btSupply: string;
17
+ withMint: boolean;
18
+ allowedSwapper: string;
19
+ exchangeId?: string;
20
+ }
21
+ export interface FeesInfo {
22
+ opfFee: string;
23
+ marketFee: string;
24
+ marketFeeCollector: string;
25
+ marketFeeAvailable: string;
26
+ oceanFeeAvailable: string;
27
+ exchangeId: string;
28
+ }
29
+ export interface FixedPriceSwap {
30
+ exchangeId: string;
31
+ caller: string;
32
+ baseTokenAmount: string;
33
+ dataTokenAmount: string;
34
+ }
35
+ export declare enum FixedRateCreateProgressStep {
36
+ CreatingExchange = 0,
37
+ ApprovingDatatoken = 1
38
+ }
39
+ export declare class FixedRateExchange {
40
+ GASLIMIT_DEFAULT: number;
41
+ oceanAddress: string;
42
+ fixedRateAddress: string;
43
+ fixedRateExchangeAbi: AbiItem | AbiItem[];
44
+ fixedRateContract: Contract;
45
+ web3: Web3;
46
+ contract: Contract;
47
+ startBlock: number;
48
+ ssAbi: AbiItem | AbiItem[];
49
+ constructor(web3: Web3, fixedRateAddress: string, fixedRateExchangeAbi?: AbiItem | AbiItem[], oceanAddress?: string, startBlock?: number);
50
+ amountToUnits(token: string, amount: string): Promise<string>;
51
+ unitsToAmount(token: string, amount: string): Promise<string>;
52
+ generateExchangeId(basetoken: string, dataToken: string, owner: string): Promise<string>;
53
+ estBuyDT(account: string, datatokenAddress: string, dtAmount: string, maxBasetokenAmount: string, contractInstance?: Contract): Promise<number>;
54
+ buyDT(address: string, exchangeId: string, datatokenAmount: string, maxBasetokenAmount: string): Promise<TransactionReceipt>;
55
+ estSellDT(account: string, datatokenAddress: string, dtAmount: string, maxBasetokenAmount: string, contractInstance?: Contract): Promise<number>;
56
+ sellDT(address: string, exchangeId: string, datatokenAmount: string, minBasetokenAmount: string): Promise<TransactionReceipt>;
57
+ getNumberOfExchanges(): Promise<number>;
58
+ estSetRate(account: string, exchangeId: string, newRate: string, contractInstance?: Contract): Promise<number>;
59
+ setRate(address: string, exchangeId: string, newRate: string): Promise<TransactionReceipt>;
60
+ estSetAllowedSwapper(account: string, exchangeId: string, newAllowedSwapper: string, contractInstance?: Contract): Promise<number>;
61
+ setAllowedSwapper(address: string, exchangeId: string, newAllowedSwapper: string): Promise<TransactionReceipt>;
62
+ estActivate(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
63
+ activate(address: string, exchangeId: string): Promise<TransactionReceipt>;
64
+ estDeactivate(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
65
+ deactivate(address: string, exchangeId: string): Promise<TransactionReceipt>;
66
+ getRate(exchangeId: string): Promise<string>;
67
+ getDTSupply(exchangeId: string): Promise<string>;
68
+ getBTSupply(exchangeId: string): Promise<string>;
69
+ getAllowedSwapper(exchangeId: string): Promise<string>;
70
+ getAmountBTIn(exchangeId: string, dataTokenAmount: string): Promise<string>;
71
+ getAmountBTOut(exchangeId: string, dataTokenAmount: string): Promise<string>;
72
+ getExchange(exchangeId: string): Promise<FixedPriceExchange>;
73
+ getFeesInfo(exchangeId: string): Promise<FeesInfo>;
74
+ getExchanges(): Promise<string[]>;
75
+ isActive(exchangeId: string): Promise<boolean>;
76
+ estActivateMint(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
77
+ activateMint(address: string, exchangeId: string): Promise<TransactionReceipt>;
78
+ estDeactivateMint(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
79
+ deactivateMint(address: string, exchangeId: string): Promise<TransactionReceipt>;
80
+ estCollectBT(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
81
+ collectBT(address: string, exchangeId: string): Promise<TransactionReceipt>;
82
+ estCollectDT(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
83
+ collectDT(address: string, exchangeId: string): Promise<TransactionReceipt>;
84
+ estCollectMarketFee(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
85
+ collectMarketFee(address: string, exchangeId: string): Promise<TransactionReceipt>;
86
+ estCollectOceanFee(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
87
+ collectOceanFee(address: string, exchangeId: string): Promise<TransactionReceipt>;
88
+ getOPFCollector(): Promise<string>;
89
+ getRouter(): Promise<string>;
90
+ getExchangeOwner(exchangeId: string): Promise<string>;
91
+ estUpdateMarketFee(account: string, exchangeId: string, newMarketFee: string, contractInstance?: Contract): Promise<number>;
92
+ updateMarketFee(address: string, exchangeId: string, newMarketFee: string): Promise<TransactionReceipt>;
93
+ estUpdateMarketFeeCollector(account: string, exchangeId: string, newMarketFeeCollector: string, contractInstance?: Contract): Promise<number>;
94
+ updateMarketFeeCollector(address: string, exchangeId: string, newMarketFeeCollector: string): Promise<TransactionReceipt>;
95
+ }
@@ -0,0 +1 @@
1
+ export * from './FixedRateExchange';
@@ -0,0 +1,3 @@
1
+ export * from './balancer';
2
+ export * from './dispenser';
3
+ export * from './fixedRate';
@@ -0,0 +1,28 @@
1
+ import Web3 from 'web3';
2
+ import { AbiItem } from 'web3-utils/types';
3
+ import { TransactionReceipt } from 'web3-core';
4
+ import { Contract } from 'web3-eth-contract';
5
+ export declare class SideStaking {
6
+ ssAbi: AbiItem | AbiItem[];
7
+ web3: Web3;
8
+ GASLIMIT_DEFAULT: number;
9
+ constructor(web3: Web3, ssAbi?: AbiItem | AbiItem[]);
10
+ amountToUnits(token: string, amount: string): Promise<string>;
11
+ unitsToAmount(token: string, amount: string): Promise<string>;
12
+ getDataTokenCirculatingSupply(ssAddress: string, datatokenAddress: string): Promise<string>;
13
+ getDataTokenCurrentCirculatingSupply(ssAddress: string, datatokenAddress: string): Promise<string>;
14
+ getPublisherAddress(ssAddress: string, datatokenAddress: string): Promise<string>;
15
+ getBasetoken(ssAddress: string, datatokenAddress: string): Promise<string>;
16
+ getPoolAddress(ssAddress: string, datatokenAddress: string): Promise<string>;
17
+ getBasetokenBalance(ssAddress: string, datatokenAddress: string): Promise<string>;
18
+ getDatatokenBalance(ssAddress: string, datatokenAddress: string): Promise<string>;
19
+ getvestingEndBlock(ssAddress: string, datatokenAddress: string): Promise<string>;
20
+ getvestingAmount(ssAddress: string, datatokenAddress: string): Promise<string>;
21
+ getvestingLastBlock(ssAddress: string, datatokenAddress: string): Promise<string>;
22
+ getvestingAmountSoFar(ssAddress: string, datatokenAddress: string): Promise<string>;
23
+ estGetVesting(account: string, ssAddress: string, datatokenAddress: string, contractInstance?: Contract): Promise<number>;
24
+ getVesting(account: string, ssAddress: string, datatokenAddress: string): Promise<TransactionReceipt>;
25
+ estSetPoolSwapFee(account: string, ssAddress: string, datatokenAddress: string, poolAddress: string, swapFee: number, contractInstance?: Contract): Promise<number>;
26
+ setPoolSwapFee(account: string, ssAddress: string, datatokenAddress: string, poolAddress: string, swapFee: number): Promise<TransactionReceipt>;
27
+ getRouter(ssAddress: string): Promise<string>;
28
+ }
@@ -0,0 +1 @@
1
+ export * from './SideStaking';
@@ -0,0 +1,31 @@
1
+ import Web3 from 'web3';
2
+ import { FileMetadata, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ProviderInitialize } from '../@types/';
3
+ export interface ServiceEndpoint {
4
+ serviceName: string;
5
+ method: string;
6
+ urlPath: string;
7
+ }
8
+ export interface UserCustomParameters {
9
+ [key: string]: any;
10
+ }
11
+ export declare class Provider {
12
+ getEndpoints(providerUri: string): Promise<any>;
13
+ getEndpointURL(servicesEndpoints: ServiceEndpoint[], serviceName: string): ServiceEndpoint;
14
+ getServiceEndpoints(providerEndpoint: string, endpoints: any): Promise<ServiceEndpoint[]>;
15
+ getNonce(providerUri: string, consumerAddress: string, fetchMethod: any, providerEndpoints?: any, serviceEndpoints?: ServiceEndpoint[]): Promise<string>;
16
+ createSignature(web3: Web3, accountId: string, agreementId: string): Promise<string>;
17
+ createHashSignature(web3: Web3, accountId: string, message: string): Promise<string>;
18
+ encrypt(data: any, providerUri: string, postMethod: any): Promise<any>;
19
+ checkDidFiles(did: string, serviceId: number, providerUri: string, fetchMethod: any): Promise<FileMetadata[]>;
20
+ checkFileUrl(url: string, providerUri: string, fetchMethod: any): Promise<FileMetadata[]>;
21
+ initialize(did: string, serviceId: string, fileIndex: number, consumerAddress: string, providerUri: string, getMethod: any, userCustomParameters?: UserCustomParameters, computeEnv?: string): Promise<ProviderInitialize>;
22
+ getDownloadUrl(did: string, accountId: string, serviceId: string, fileIndex: number, transferTxId: string, providerUri: string, web3: Web3, userCustomParameters?: UserCustomParameters): Promise<any>;
23
+ computeStart(providerUri: string, web3: Web3, fetchMethod: any, consumerAddress: string, computeEnv: string, dataset: ComputeAsset, algorithm: ComputeAlgorithm, additionalDatasets?: ComputeAsset[], output?: ComputeOutput): Promise<ComputeJob | ComputeJob[]>;
24
+ computeStop(did: string, consumerAddress: string, jobId: string, providerUri: string, web3: Web3, fetchMethod: any): Promise<ComputeJob | ComputeJob[]>;
25
+ computeStatus(providerUri: string, fetchMethod: any, jobId?: string, did?: string, consumerAddress?: string): Promise<ComputeJob | ComputeJob[]>;
26
+ computeResult(jobId: string, index: number, destination: string, accountId: string, providerUri: string, web3: Web3, fetchMethod: any): Promise<any>;
27
+ computeDelete(did: string, consumerAddress: string, jobId: string, providerUri: string, web3: Web3, fetchMethod: any): Promise<ComputeJob | ComputeJob[]>;
28
+ isValidProvider(url: string, fetchMethod: any): Promise<boolean>;
29
+ }
30
+ export declare const ProviderInstance: Provider;
31
+ export default ProviderInstance;
@@ -0,0 +1 @@
1
+ export * from './Provider';
@@ -0,0 +1,77 @@
1
+ import Web3 from 'web3';
2
+ import { AbiItem } from 'web3-utils';
3
+ import { TransactionReceipt } from 'web3-eth';
4
+ import { Contract } from 'web3-eth-contract';
5
+ import { FreOrderParams, FreCreationParams } from '../interfaces';
6
+ import { Nft } from './NFT';
7
+ interface Roles {
8
+ minter: boolean;
9
+ paymentManager: boolean;
10
+ }
11
+ export interface OrderParams {
12
+ consumer: string;
13
+ serviceIndex: number;
14
+ providerFeeAddress: string;
15
+ providerFeeToken: string;
16
+ providerFeeAmount: string;
17
+ v: string;
18
+ r: string;
19
+ s: string;
20
+ providerData: string;
21
+ }
22
+ export interface DispenserParams {
23
+ maxTokens: string;
24
+ maxBalance: string;
25
+ withMint?: boolean;
26
+ allowedSwapper?: string;
27
+ }
28
+ export declare class Datatoken {
29
+ GASLIMIT_DEFAULT: number;
30
+ factoryAddress: string;
31
+ factoryABI: AbiItem | AbiItem[];
32
+ datatokensAbi: AbiItem | AbiItem[];
33
+ datatokensEnterpriseAbi: AbiItem | AbiItem[];
34
+ web3: Web3;
35
+ startBlock: number;
36
+ nft: Nft;
37
+ constructor(web3: Web3, datatokensAbi?: AbiItem | AbiItem[], datatokensEnterpriseAbi?: AbiItem | AbiItem[], startBlock?: number);
38
+ estGasApprove(dtAddress: string, spender: string, amount: string, address: string, contractInstance?: Contract): Promise<any>;
39
+ approve(dtAddress: string, spender: string, amount: string, address: string): Promise<TransactionReceipt>;
40
+ estGasMint(dtAddress: string, address: string, amount: string, toAddress?: string, contractInstance?: Contract): Promise<any>;
41
+ estGasCreateFixedRate(dtAddress: string, address: string, fixedRateParams: FreCreationParams, contractInstance?: Contract): Promise<any>;
42
+ createFixedRate(dtAddress: string, address: string, fixedRateParams: FreCreationParams): Promise<TransactionReceipt>;
43
+ estGasCreateDispenser(dtAddress: string, address: string, dispenserAddress: string, dispenserParams: DispenserParams, contractInstance?: Contract): Promise<any>;
44
+ createDispenser(dtAddress: string, address: string, dispenserAddress: string, dispenserParams: DispenserParams): Promise<TransactionReceipt>;
45
+ mint(dtAddress: string, address: string, amount: string, toAddress?: string): Promise<TransactionReceipt>;
46
+ estGasAddMinter(dtAddress: string, address: string, minter: string, contractInstance?: Contract): Promise<any>;
47
+ addMinter(dtAddress: string, address: string, minter: string): Promise<TransactionReceipt>;
48
+ estGasRemoveMinter(dtAddress: string, address: string, minter: string, contractInstance?: Contract): Promise<any>;
49
+ removeMinter(dtAddress: string, address: string, minter: string): Promise<TransactionReceipt>;
50
+ estGasAddPaymentManager(dtAddress: string, address: string, paymentManager: string, contractInstance?: Contract): Promise<any>;
51
+ addPaymentManager(dtAddress: string, address: string, paymentManager: string): Promise<TransactionReceipt>;
52
+ estGasRemovePaymentManager(dtAddress: string, address: string, paymentManager: string, contractInstance?: Contract): Promise<any>;
53
+ removePaymentManager(dtAddress: string, address: string, paymentManager: string): Promise<TransactionReceipt>;
54
+ estGasSetPaymentCollector(dtAddress: string, address: string, paymentCollector: string, contractInstance?: Contract): Promise<any>;
55
+ setPaymentCollector(dtAddress: string, address: string, paymentCollector: string): Promise<TransactionReceipt>;
56
+ getPaymentCollector(dtAddress: string): Promise<string>;
57
+ transfer(dtAddress: string, toAddress: string, amount: string, address: string): Promise<TransactionReceipt>;
58
+ estGasTransfer(dtAddress: string, toAddress: string, amount: string, address: string, contractInstance?: Contract): Promise<any>;
59
+ transferWei(dtAddress: string, toAddress: string, amount: string, address: string): Promise<TransactionReceipt>;
60
+ estGasStartOrder(dtAddress: string, address: string, consumer: string, serviceIndex: number, providerFeeAddress: string, providerFeeToken: string, providerFeeAmount: string, v: string, r: string, s: string, providerDatas: string, contractInstance?: Contract): Promise<any>;
61
+ startOrder(dtAddress: string, address: string, consumer: string, serviceIndex: number, providerFeeAddress: string, providerFeeToken: string, providerFeeAmount: string, v: string, r: string, s: string, providerDatas: string): Promise<TransactionReceipt>;
62
+ estGasBuyFromFreAndOrder(dtAddress: string, address: string, orderParams: OrderParams, freParams: FreOrderParams, contractInstance?: Contract): Promise<any>;
63
+ buyFromFreAndOrder(dtAddress: string, address: string, orderParams: OrderParams, freParams: FreOrderParams): Promise<TransactionReceipt>;
64
+ estGasBuyFromDispenserAndOrder(dtAddress: string, address: string, orderParams: OrderParams, dispenserContract: string, contractInstance?: Contract): Promise<any>;
65
+ buyFromDispenserAndOrder(dtAddress: string, address: string, orderParams: OrderParams, dispenserContract: string): Promise<TransactionReceipt>;
66
+ estGasSetData(dtAddress: string, address: string, value: string, contractInstance?: Contract): Promise<any>;
67
+ setData(dtAddress: string, address: string, value: string): Promise<TransactionReceipt>;
68
+ estGasCleanPermissions(dtAddress: string, address: string, contractInstance?: Contract): Promise<any>;
69
+ cleanPermissions(dtAddress: string, address: string): Promise<TransactionReceipt>;
70
+ getDTPermissions(dtAddress: string, address: string): Promise<Roles>;
71
+ getCap(dtAddress: string): Promise<string>;
72
+ getDecimals(dtAddress: string): Promise<string>;
73
+ getNFTAddress(dtAddress: string): Promise<string>;
74
+ isERC20Deployer(dtAddress: string, address: string): Promise<boolean>;
75
+ balance(dataTokenAddress: string, address: string): Promise<string>;
76
+ }
77
+ export {};
@@ -0,0 +1,57 @@
1
+ import Web3 from 'web3';
2
+ import { AbiItem } from 'web3-utils';
3
+ import { TransactionReceipt } from 'web3-eth';
4
+ import { Contract } from 'web3-eth-contract';
5
+ import { MetadataProof } from '../../src/@types';
6
+ interface Roles {
7
+ manager: boolean;
8
+ deployERC20: boolean;
9
+ updateMetadata: boolean;
10
+ store: boolean;
11
+ }
12
+ export declare class Nft {
13
+ GASLIMIT_DEFAULT: number;
14
+ factory721Address: string;
15
+ factory721Abi: AbiItem | AbiItem[];
16
+ nftAbi: AbiItem | AbiItem[];
17
+ web3: Web3;
18
+ startBlock: number;
19
+ constructor(web3: Web3, nftAbi?: AbiItem | AbiItem[], startBlock?: number);
20
+ estGasCreateErc20(nftAddress: string, address: string, minter: string, feeManager: string, mpFeeAddress: string, feeToken: string, feeAmount: string, cap: string, name?: string, symbol?: string, templateIndex?: number, contractInstance?: Contract): Promise<any>;
21
+ createErc20(nftAddress: string, address: string, minter: string, feeManager: string, mpFeeAddress: string, feeToken: string, feeAmount: string, cap: string, name?: string, symbol?: string, templateIndex?: number): Promise<string>;
22
+ estGasAddManager(nftAddress: string, address: string, manager: string, contractInstance?: Contract): Promise<any>;
23
+ addManager(nftAddress: string, address: string, manager: string): Promise<any>;
24
+ estGasRemoveManager(nftAddress: string, address: string, manager: string, contractInstance?: Contract): Promise<any>;
25
+ removeManager(nftAddress: string, address: string, manager: string): Promise<any>;
26
+ estGasAddErc20Deployer(nftAddress: string, address: string, erc20Deployer: string, contractInstance?: Contract): Promise<any>;
27
+ addErc20Deployer(nftAddress: string, address: string, erc20Deployer: string): Promise<TransactionReceipt>;
28
+ estGasRemoveErc20Deployer(nftAddress: string, address: string, erc20Deployer: string, contractInstance?: Contract): Promise<any>;
29
+ removeErc20Deployer(nftAddress: string, address: string, erc20Deployer: string): Promise<TransactionReceipt>;
30
+ estGasAddMetadataUpdater(nftAddress: string, address: string, metadataUpdater: string, contractInstance?: Contract): Promise<any>;
31
+ addMetadataUpdater(nftAddress: string, address: string, metadataUpdater: string): Promise<TransactionReceipt>;
32
+ esGasRemoveMetadataUpdater(nftAddress: string, address: string, metadataUpdater: string, contractInstance?: Contract): Promise<any>;
33
+ removeMetadataUpdater(nftAddress: string, address: string, metadataUpdater: string): Promise<TransactionReceipt>;
34
+ estGasAddStoreUpdater(nftAddress: string, address: string, storeUpdater: string, contractInstance?: Contract): Promise<any>;
35
+ addStoreUpdater(nftAddress: string, address: string, storeUpdater: string): Promise<TransactionReceipt>;
36
+ estGasRemoveStoreUpdater(nftAddress: string, address: string, storeUpdater: string, contractInstance?: Contract): Promise<any>;
37
+ removeStoreUpdater(nftAddress: string, address: string, storeUpdater: string): Promise<TransactionReceipt>;
38
+ estGasCleanPermissions(nftAddress: string, address: string, contractInstance?: Contract): Promise<any>;
39
+ cleanPermissions(nftAddress: string, address: string): Promise<TransactionReceipt>;
40
+ estGasTransferNft(nftAddress: string, nftOwner: string, nftReceiver: string, tokenId: number, contractInstance?: Contract): Promise<any>;
41
+ transferNft(nftAddress: string, nftOwner: string, nftReceiver: string, tokenId?: number): Promise<TransactionReceipt>;
42
+ estGasSafeTransferNft(nftAddress: string, nftOwner: string, nftReceiver: string, tokenId: number, contractInstance?: Contract): Promise<any>;
43
+ safeTransferNft(nftAddress: string, nftOwner: string, nftReceiver: string, tokenId?: number): Promise<TransactionReceipt>;
44
+ estGasSetMetadata(nftAddress: string, metadataUpdater: string, metadataState: number, metaDataDecryptorUrl: string, metaDataDecryptorAddress: string, flags: string, data: string, metadataHash: string, metadataProofs?: MetadataProof[], contractInstance?: Contract): Promise<any>;
45
+ setMetadata(nftAddress: string, address: string, metadataState: number, metaDataDecryptorUrl: string, metaDataDecryptorAddress: string, flags: string, data: string, metadataHash: string, metadataProofs?: MetadataProof[]): Promise<TransactionReceipt>;
46
+ estGasSetMetadataState(nftAddress: string, metadataUpdater: string, metadataState: number, contractInstance?: Contract): Promise<any>;
47
+ setMetadataState(nftAddress: string, address: string, metadataState: number): Promise<TransactionReceipt>;
48
+ estSetTokenURI(nftAddress: string, address: string, data: string): Promise<any>;
49
+ setTokenURI(nftAddress: string, address: string, data: string): Promise<any>;
50
+ getNftOwner(nftAddress: string): Promise<string>;
51
+ getNftPermissions(nftAddress: string, address: string): Promise<Roles>;
52
+ getMetadata(nftAddress: string): Promise<Object>;
53
+ isErc20Deployer(nftAddress: string, address: string): Promise<boolean>;
54
+ getData(nftAddress: string, key: string): Promise<string>;
55
+ getTokenURI(nftAddress: string, id: number): Promise<string>;
56
+ }
57
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './Datatoken';
2
+ export * from './NFT';
@@ -0,0 +1,6 @@
1
+ import Config from '../models/Config';
2
+ export declare const configHelperNetworks: Config[];
3
+ export declare class ConfigHelper {
4
+ getAddressesFromEnv(network: string): Partial<Config>;
5
+ getConfig(network: string | number, infuraProjectId?: string): Config;
6
+ }
@@ -0,0 +1 @@
1
+ export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
@@ -0,0 +1,4 @@
1
+ import { Erc20CreateParams, FreCreationParams, PoolCreationParams } from '../interfaces';
2
+ export declare function getErcCreationParams(ercParams: Erc20CreateParams): any;
3
+ export declare function getFreCreationParams(freParams: FreCreationParams): any;
4
+ export declare function getPoolCreationParams(poolParams: PoolCreationParams): any;
@@ -0,0 +1,3 @@
1
+ export declare const zeroX: (input: string) => string;
2
+ export declare const noZeroX: (input: string) => string;
3
+ export declare function zeroXTransformer(input: string, zeroOutput: boolean): string;
@@ -1,4 +1,4 @@
1
- export declare function generateDatatokenName(wordList?: {
1
+ export declare function generateDtName(wordList?: {
2
2
  nouns: string[];
3
3
  adjectives: string[];
4
4
  }): {
@@ -0,0 +1,2 @@
1
+ export declare function generateDid(erc721Address: string, chainId: number): string;
2
+ export declare function getHash(data: any): string;
@@ -0,0 +1,5 @@
1
+ export declare function fetchData(url: string, opts: RequestInit): Promise<Response>;
2
+ export declare function downloadFile(url: string, destination?: string, index?: number): Promise<string>;
3
+ export declare function getData(url: string): Promise<Response>;
4
+ export declare function postData(url: string, payload: BodyInit): Promise<Response>;
5
+ export declare function crossFetchGeneric(method: string, url: string, body: string, headers: any): Promise<Response>;
@@ -0,0 +1,2 @@
1
+ import Web3 from 'web3';
2
+ export declare function getFairGasPrice(web3: Web3): Promise<string>;
File without changes
@@ -0,0 +1,8 @@
1
+ import Web3 from 'web3';
2
+ export declare function signText(web3: Web3, text: string, publicKey: string, password?: string): Promise<string>;
3
+ export declare function signHash(web3: Web3, message: string, address: string): Promise<{
4
+ v: string;
5
+ r: string;
6
+ s: string;
7
+ }>;
8
+ export declare function signWithHash(web3: Web3, text: string, publicKey: string, password?: string): Promise<string>;
@@ -0,0 +1,9 @@
1
+ export * from './Logger';
2
+ export * from './GasUtils';
3
+ export * from './DatatokenName';
4
+ export * from './ContractParams';
5
+ export * from './FetchHelper';
6
+ export * from './ConfigHelper';
7
+ export * from './DdoHelpers';
8
+ export * from './Constants';
9
+ export * from './SignatureUtils';
@@ -0,0 +1,44 @@
1
+ import Web3 from 'web3';
2
+ import { Contract } from 'web3-eth-contract';
3
+ import { AbiItem } from 'web3-utils/types';
4
+ export declare class TestContractHandler {
5
+ accounts: string[];
6
+ ERC721Factory: Contract;
7
+ ERC20Template: Contract;
8
+ ERC721Template: Contract;
9
+ Router: Contract;
10
+ SideStaking: Contract;
11
+ FixedRate: Contract;
12
+ Dispenser: Contract;
13
+ OPFCollector: Contract;
14
+ PoolTemplate: Contract;
15
+ MockERC20: Contract;
16
+ MockOcean: Contract;
17
+ ERC721FactoryBytecode: string;
18
+ ERC20TemplateBytecode: string;
19
+ ERC721TemplateBytecode: string;
20
+ RouterBytecode: string;
21
+ SideStakingBytecode: string;
22
+ FixedRateBytecode: string;
23
+ DispenserBytecode: string;
24
+ PoolTemplateBytecode: string;
25
+ OPFCollectorBytecode: string;
26
+ MockERC20Bytecode: string;
27
+ OPFBytecode: string;
28
+ factory721Address: string;
29
+ template721Address: string;
30
+ template20Address: string;
31
+ routerAddress: string;
32
+ sideStakingAddress: string;
33
+ fixedRateAddress: string;
34
+ dispenserAddress: string;
35
+ poolTemplateAddress: string;
36
+ opfCollectorAddress: string;
37
+ oceanAddress: string;
38
+ daiAddress: string;
39
+ usdcAddress: string;
40
+ web3: Web3;
41
+ constructor(web3: Web3, ERC721TemplateABI: AbiItem | AbiItem[], ERC20TemplateABI: AbiItem | AbiItem[], PoolTemplateABI?: AbiItem | AbiItem[], ERC721FactoryABI?: AbiItem | AbiItem[], RouterABI?: AbiItem | AbiItem[], SideStakingABI?: AbiItem | AbiItem[], FixedRateABI?: AbiItem | AbiItem[], DispenserABI?: AbiItem | AbiItem[], OPFABI?: AbiItem | AbiItem[], template721Bytecode?: string, template20Bytecode?: string, poolTemplateBytecode?: string, factory721Bytecode?: string, routerBytecode?: string, sideStakingBytecode?: string, fixedRateBytecode?: string, dispenserBytecode?: string, opfBytecode?: string);
42
+ getAccounts(): Promise<string[]>;
43
+ deployContracts(owner: string, routerABI?: AbiItem | AbiItem[]): Promise<void>;
44
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { Config } from '../../src/models/Config';
2
+ declare const _default: Config;
3
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { Config } from '../../src/models/Config';
2
+ declare const _default: Config;
3
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -168,8 +168,8 @@ The process of creating and deploying the ERC20 datatokens has been automated by
168
168
  const Web3 = require("web3");
169
169
  const { Ocean, DataTokens } = require("@oceanprotocol/lib");
170
170
 
171
- const factoryABI = require("@oceanprotocol/contracts/artifacts/DTFactory.json").abi;
172
- const datatokensABI = require("@oceanprotocol/contracts/artifacts/DataTokenTemplate.json").abi;
171
+ const { factoryABI } = require("@oceanprotocol/contracts/artifacts/DTFactory.json");
172
+ const { datatokensABI } = require("@oceanprotocol/contracts/artifacts/DataTokenTemplate.json");
173
173
  const { config, contracts, urls } = require("./config");
174
174
 
175
175
  const init = async () => {
@@ -114,8 +114,8 @@ Now open the `index.js` file in your text editor. Enter the following code and s
114
114
  const Web3 = require("web3");
115
115
  const { Ocean, DataTokens } = require("@oceanprotocol/lib");
116
116
 
117
- const factoryABI = require("@oceanprotocol/contracts/artifacts/DTFactory.json").abi;
118
- const datatokensABI = require("@oceanprotocol/contracts/artifacts/DataTokenTemplate.json").abi;
117
+ const { factoryABI } = require("@oceanprotocol/contracts/artifacts/DTFactory.json");
118
+ const { datatokensABI } = require("@oceanprotocol/contracts/artifacts/DataTokenTemplate.json");
119
119
  const { config, contracts, urls } = require("./config");
120
120
 
121
121
 
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "@oceanprotocol/lib",
3
3
  "source": "./src/index.ts",
4
- "version": "0.20.2",
4
+ "version": "1.0.0-next.3",
5
5
  "description": "JavaScript client library for Ocean Protocol",
6
- "main": "./dist/node/lib.js",
7
- "exports": "./dist/node/lib.js",
8
- "module": "./dist/node/lib.module.js",
9
- "typings": "./dist/node/lib.d.ts",
10
- "umd:main": "dist/node/lib.umd.js",
11
- "unpkg": "./dist/node/lib.cjs2.min.js",
6
+ "main": "./dist/lib.js",
7
+ "umd:main": "dist/lib.umd.js",
8
+ "module": "./dist/lib.module.js",
9
+ "exports": {
10
+ "require": "./dist/lib.js",
11
+ "default": "./dist/lib.modern.js"
12
+ },
13
+ "types": "./dist/src/index.d.ts",
12
14
  "scripts": {
13
15
  "start": "npm run clean && npm run build:metadata && tsc -w",
14
- "build": "npm run clean && npm run build:metadata && microbundle build --format umd,cjs,es --compress --target node --tsconfig tsconfig.json",
16
+ "build": "npm run clean && npm run build:metadata && microbundle build --format modern,esm,cjs,umd --compress --tsconfig tsconfig.json",
15
17
  "build:tsc": "tsc --sourceMap",
16
18
  "build:metadata": "node ./scripts/get-metadata.js > src/metadata.json",
17
19
  "clean": "rm -rf ./dist/ ./doc/ ./.nyc_output",
@@ -24,10 +26,19 @@
24
26
  "release": "release-it --non-interactive",
25
27
  "changelog": "auto-changelog -p",
26
28
  "prepublishOnly": "npm run build",
27
- "test": "npm run lint && npm run test:unit:cover && npm run test:integration:cover",
28
- "test:unit": "mocha --config=test/unit/.mocharc.json --node-env=test --exit 'test/unit/**/*.test.ts'",
29
+ "mocha": "TS_NODE_PROJECT='./test/tsconfig.json' mocha --config=test/.mocharc.json --node-env=test --exit",
30
+ "test:ss": "npm run mocha -- 'test/unit/pools/ssContracts/SideStaking.test.ts'",
31
+ "test:fixed": "npm run mocha -- 'test/unit/pools/fixedRate/FixedRateExchange.test.ts'",
32
+ "test:pool": "npm run mocha -- 'test/unit/pools/balancer/Pool.test.ts'",
33
+ "test:dispenser": "npm run mocha -- 'test/unit/pools/dispenser/Dispenser.test.ts'",
34
+ "test:dt": "npm run mocha -- 'test/unit/tokens/Datatoken.test.ts'",
35
+ "test:nftDt": "npm run mocha -- 'test/unit/Nft.test.ts'",
36
+ "test:factory": "npm run mocha -- 'test/unit/NftFactory.test.ts'",
37
+ "test:router": "npm run mocha -- 'test/unit/pools/Router.test.ts'",
38
+ "test:publishAll": "npm run mocha -- 'test/integration/PublishFlows.test.ts'",
39
+ "test:unit": "npm run mocha -- 'test/unit/**/*.test.ts'",
29
40
  "test:unit:cover": "nyc --report-dir coverage/unit npm run test:unit",
30
- "test:integration": "mocha --config=test/integration/.mocharc.json --node-env=test --exit 'test/integration/**/*.test.ts'",
41
+ "test:integration": "npm run mocha -- 'test/integration/**/*.test.ts'",
31
42
  "test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration"
32
43
  },
33
44
  "repository": {
@@ -45,27 +56,23 @@
45
56
  "web3": ">=1.3.5"
46
57
  },
47
58
  "dependencies": {
48
- "@ethereum-navigator/navigator": "^0.5.3",
49
- "@oceanprotocol/contracts": "^0.6.9",
59
+ "bignumber.js": "^9.0.2",
50
60
  "cross-fetch": "^3.1.4",
51
61
  "crypto-js": "^4.0.0",
52
62
  "decimal.js": "^10.2.1",
53
63
  "fs": "0.0.1-security",
54
- "lzma": "^2.3.2",
55
- "node-abort-controller": "^2.0.0",
56
64
  "save-file": "^2.3.1",
57
- "uuid": "^8.3.2",
58
- "web3": "^1.6.1",
59
- "web3-core": "^1.5.3",
60
- "web3-eth-contract": "^1.5.2"
65
+ "web3": ">=1.3.5",
66
+ "web3-core": "^1.6.1",
67
+ "web3-eth-contract": "^1.6.1"
61
68
  },
62
69
  "devDependencies": {
63
- "@truffle/hdwallet-provider": "^2.0.0",
64
- "@types/chai": "^4.3.0",
70
+ "@truffle/hdwallet-provider": "^1.5.1",
71
+ "@types/chai": "^4.2.19",
65
72
  "@types/chai-spies": "^1.0.3",
66
- "@types/crypto-js": "^4.1.0",
73
+ "@types/crypto-js": "^4.0.1",
67
74
  "@types/mocha": "^9.0.0",
68
- "@types/node": "^17.0.7",
75
+ "@types/node": "^16.10.3",
69
76
  "@types/node-fetch": "^3.0.3",
70
77
  "@typescript-eslint/eslint-plugin": "^4.33.0",
71
78
  "@typescript-eslint/parser": "^4.33.0",
@@ -78,17 +85,17 @@
78
85
  "eslint-config-prettier": "^8.3.0",
79
86
  "eslint-plugin-prettier": "^4.0.0",
80
87
  "microbundle": "^0.14.2",
81
- "mocha": "^9.1.3",
82
- "mock-local-storage": "^1.1.19",
88
+ "mocha": "^9.1.2",
89
+ "mock-local-storage": "^1.1.17",
83
90
  "nyc": "^15.1.0",
84
91
  "ora": "5.4.1",
85
- "prettier": "^2.5.1",
86
- "release-it": "^14.11.8",
87
- "source-map-support": "^0.5.21",
88
- "ts-node": "^10.4.0",
92
+ "prettier": "^2.3.1",
93
+ "release-it": "^14.12.1",
94
+ "source-map-support": "^0.5.19",
95
+ "ts-node": "^10.0.0",
89
96
  "ts-node-register": "^1.0.0",
90
- "typedoc": "0.22.10",
91
- "typescript": "^4.5.4"
97
+ "typedoc": "0.22.5",
98
+ "typescript": "^4.3.4"
92
99
  },
93
100
  "nyc": {
94
101
  "include": [