@oceanprotocol/lib 0.20.1 → 1.0.0-next.10

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 (151) hide show
  1. package/CHANGELOG.md +139 -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 -9
  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/DownloadResponse.d.ts +4 -0
  19. package/dist/src/@types/FileMetadata.d.ts +9 -0
  20. package/dist/src/@types/Provider.d.ts +16 -0
  21. package/dist/src/@types/index.d.ts +8 -0
  22. package/dist/src/aquarius/Aquarius.d.ts +10 -0
  23. package/dist/src/aquarius/index.d.ts +1 -0
  24. package/dist/src/factories/NFTFactory.d.ts +66 -0
  25. package/dist/src/factories/index.d.ts +1 -0
  26. package/dist/src/index.d.ts +8 -0
  27. package/dist/src/interfaces/DispenserInterface.d.ts +7 -0
  28. package/dist/src/interfaces/Erc20Interface.d.ts +11 -0
  29. package/dist/src/interfaces/Erc721Interface.d.ts +12 -0
  30. package/dist/src/interfaces/FixedRateInterface.d.ts +19 -0
  31. package/dist/src/interfaces/PoolInterface.d.ts +36 -0
  32. package/dist/src/interfaces/RouterInterface.d.ts +12 -0
  33. package/dist/src/interfaces/index.d.ts +5 -0
  34. package/dist/{node → src}/models/Config.d.ts +14 -7
  35. package/dist/src/models/index.d.ts +1 -0
  36. package/dist/src/pools/Router.d.ts +47 -0
  37. package/dist/src/pools/balancer/Pool.d.ts +70 -0
  38. package/dist/src/pools/balancer/index.d.ts +1 -0
  39. package/dist/src/pools/dispenser/Dispenser.d.ts +38 -0
  40. package/dist/src/pools/dispenser/index.d.ts +1 -0
  41. package/dist/src/pools/fixedRate/FixedRateExchange.d.ts +96 -0
  42. package/dist/src/pools/fixedRate/index.d.ts +1 -0
  43. package/dist/src/pools/index.d.ts +3 -0
  44. package/dist/src/pools/ssContracts/SideStaking.d.ts +30 -0
  45. package/dist/src/pools/ssContracts/index.d.ts +1 -0
  46. package/dist/src/provider/Provider.d.ts +35 -0
  47. package/dist/src/provider/index.d.ts +1 -0
  48. package/dist/src/tokens/Datatoken.d.ts +73 -0
  49. package/dist/src/tokens/NFT.d.ts +62 -0
  50. package/dist/src/tokens/index.d.ts +2 -0
  51. package/dist/src/utils/ConfigHelper.d.ts +6 -0
  52. package/dist/src/utils/Constants.d.ts +2 -0
  53. package/dist/src/utils/ContractUtils.d.ts +11 -0
  54. package/dist/src/utils/ConversionTypeHelper.d.ts +3 -0
  55. package/dist/{node/utils/Datatokens.d.ts → src/utils/DatatokenName.d.ts} +1 -1
  56. package/dist/src/utils/DdoHelpers.d.ts +2 -0
  57. package/dist/src/utils/FetchHelper.d.ts +6 -0
  58. package/dist/{node → src}/utils/Logger.d.ts +0 -0
  59. package/dist/src/utils/SignatureUtils.d.ts +8 -0
  60. package/dist/src/utils/TokenUtils.d.ts +7 -0
  61. package/dist/src/utils/index.d.ts +9 -0
  62. package/dist/src/utils/minAbi.d.ts +2 -0
  63. package/dist/test/TestContractHandler.d.ts +44 -0
  64. package/dist/test/integration/ComputeFlow.test.d.ts +1 -0
  65. package/dist/test/integration/Provider.test.d.ts +1 -0
  66. package/dist/test/integration/PublishFlows.test.d.ts +1 -0
  67. package/dist/test/integration/SimplePublishConsumeFlow.test.d.ts +1 -0
  68. package/dist/test/integration/config.d.ts +3 -0
  69. package/dist/test/unit/NftFactory.test.d.ts +1 -0
  70. package/dist/test/unit/config.d.ts +3 -0
  71. package/dist/test/unit/pools/Router.test.d.ts +1 -0
  72. package/dist/test/unit/pools/balancer/Pool.test.d.ts +1 -0
  73. package/dist/test/unit/pools/dispenser/Dispenser.test.d.ts +1 -0
  74. package/dist/test/unit/pools/fixedRate/FixedRateExchange.test.d.ts +1 -0
  75. package/dist/test/unit/pools/ssContracts/SideStaking.test.d.ts +1 -0
  76. package/dist/test/unit/tokens/Datatoken.test.d.ts +1 -0
  77. package/dist/test/unit/tokens/Nft.test.d.ts +1 -0
  78. package/docs/beginners_guide.md +4 -4
  79. package/docs/overview.md +100 -9
  80. package/docs/quickstart_marketplace.md +34 -33
  81. package/docs/quickstart_simple.md +18 -16
  82. package/package.json +37 -29
  83. package/dist/node/Instantiable.abstract.d.ts +0 -25
  84. package/dist/node/balancer/OceanPool.d.ts +0 -95
  85. package/dist/node/balancer/Pool.d.ts +0 -56
  86. package/dist/node/balancer/PoolFactory.d.ts +0 -15
  87. package/dist/node/datatokens/ContractEvent.d.ts +0 -19
  88. package/dist/node/datatokens/ContractHandler.d.ts +0 -12
  89. package/dist/node/datatokens/Datatokens.d.ts +0 -44
  90. package/dist/node/datatokens/EventHandler.d.ts +0 -19
  91. package/dist/node/datatokens/Network.d.ts +0 -5
  92. package/dist/node/datatokens/Web3Provider.d.ts +0 -5
  93. package/dist/node/datatokens/contracts/ContractBase.d.ts +0 -27
  94. package/dist/node/ddo/DDO.d.ts +0 -36
  95. package/dist/node/ddo/interfaces/AdditionalInformation.d.ts +0 -16
  96. package/dist/node/ddo/interfaces/Authentication.d.ts +0 -4
  97. package/dist/node/ddo/interfaces/BestPrice.d.ts +0 -10
  98. package/dist/node/ddo/interfaces/Consumable.d.ts +0 -5
  99. package/dist/node/ddo/interfaces/Credentials.d.ts +0 -9
  100. package/dist/node/ddo/interfaces/Curation.d.ts +0 -6
  101. package/dist/node/ddo/interfaces/DataTokenInfo.d.ts +0 -10
  102. package/dist/node/ddo/interfaces/EditableMetadata.d.ts +0 -9
  103. package/dist/node/ddo/interfaces/EditableMetadataLinks.d.ts +0 -5
  104. package/dist/node/ddo/interfaces/Event.d.ts +0 -7
  105. package/dist/node/ddo/interfaces/File.d.ts +0 -13
  106. package/dist/node/ddo/interfaces/Metadata.d.ts +0 -15
  107. package/dist/node/ddo/interfaces/MetadataAlgorithm.d.ts +0 -12
  108. package/dist/node/ddo/interfaces/MetadataMain.d.ts +0 -12
  109. package/dist/node/ddo/interfaces/Proof.d.ts +0 -6
  110. package/dist/node/ddo/interfaces/PublicKey.d.ts +0 -8
  111. package/dist/node/ddo/interfaces/PurgatoryData.d.ts +0 -4
  112. package/dist/node/ddo/interfaces/Service.d.ts +0 -99
  113. package/dist/node/ddo/interfaces/ServicePrices.d.ts +0 -4
  114. package/dist/node/ddo/interfaces/Status.d.ts +0 -5
  115. package/dist/node/ddo/interfaces/index.d.ts +0 -17
  116. package/dist/node/dispenser/Dispenser.d.ts +0 -44
  117. package/dist/node/exchange/FixedRateExchange.d.ts +0 -59
  118. package/dist/node/index.d.ts +0 -1
  119. package/dist/node/lib.d.ts +0 -15
  120. package/dist/node/lib.js +0 -2
  121. package/dist/node/lib.js.map +0 -1
  122. package/dist/node/lib.module.js +0 -2
  123. package/dist/node/lib.module.js.map +0 -1
  124. package/dist/node/lib.umd.js +0 -2
  125. package/dist/node/lib.umd.js.map +0 -1
  126. package/dist/node/metadatacache/MetadataCache.d.ts +0 -41
  127. package/dist/node/metadatacache/OnChainMetaData.d.ts +0 -31
  128. package/dist/node/ocean/Account.d.ts +0 -16
  129. package/dist/node/ocean/Accounts.d.ts +0 -9
  130. package/dist/node/ocean/Assets.d.ts +0 -56
  131. package/dist/node/ocean/AssetsCredential.d.ts +0 -6
  132. package/dist/node/ocean/Compute.d.ts +0 -75
  133. package/dist/node/ocean/DID.d.ts +0 -8
  134. package/dist/node/ocean/EventAccessControl.d.ts +0 -9
  135. package/dist/node/ocean/Ocean.d.ts +0 -34
  136. package/dist/node/ocean/OceanAuth.d.ts +0 -15
  137. package/dist/node/ocean/Versions.d.ts +0 -25
  138. package/dist/node/ocean/utils/SignatureUtils.d.ts +0 -13
  139. package/dist/node/ocean/utils/Utils.d.ts +0 -8
  140. package/dist/node/ocean/utils/WebServiceConnector.d.ts +0 -16
  141. package/dist/node/provider/Provider.d.ts +0 -56
  142. package/dist/node/utils/AssetResolverHelper.d.ts +0 -8
  143. package/dist/node/utils/ConfigHelper.d.ts +0 -17
  144. package/dist/node/utils/ContractUtils.d.ts +0 -5
  145. package/dist/node/utils/ConversionTypeHelpers.d.ts +0 -8
  146. package/dist/node/utils/GeneratorHelpers.d.ts +0 -1
  147. package/dist/node/utils/PromiseResolver.d.ts +0 -3
  148. package/dist/node/utils/SubscribableObserver.d.ts +0 -12
  149. package/dist/node/utils/SubscribablePromise.d.ts +0 -14
  150. package/dist/node/utils/Timeout.d.ts +0 -1
  151. package/dist/node/utils/index.d.ts +0 -9
@@ -0,0 +1,96 @@
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
+ import { Config } from '../../models/index.js';
6
+ export interface FixedPriceExchange {
7
+ active: boolean;
8
+ exchangeOwner: string;
9
+ datatoken: string;
10
+ baseToken: string;
11
+ fixedRate: string;
12
+ dtDecimals: string;
13
+ btDecimals: string;
14
+ dtBalance: string;
15
+ btBalance: string;
16
+ dtSupply: string;
17
+ btSupply: string;
18
+ withMint: boolean;
19
+ allowedSwapper: string;
20
+ exchangeId?: string;
21
+ }
22
+ export interface FeesInfo {
23
+ opcFee: string;
24
+ marketFee: string;
25
+ marketFeeCollector: string;
26
+ marketFeeAvailable: string;
27
+ oceanFeeAvailable: string;
28
+ exchangeId: string;
29
+ }
30
+ export interface FixedPriceSwap {
31
+ exchangeId: string;
32
+ caller: string;
33
+ baseTokenAmount: string;
34
+ datatokenAmount: string;
35
+ }
36
+ export declare enum FixedRateCreateProgressStep {
37
+ CreatingExchange = 0,
38
+ ApprovingDatatoken = 1
39
+ }
40
+ export declare class FixedRateExchange {
41
+ GASLIMIT_DEFAULT: number;
42
+ oceanAddress: string;
43
+ fixedRateAddress: string;
44
+ fixedRateExchangeAbi: AbiItem | AbiItem[];
45
+ fixedRateContract: Contract;
46
+ web3: Web3;
47
+ contract: Contract;
48
+ config: Config;
49
+ ssAbi: AbiItem | AbiItem[];
50
+ constructor(web3: Web3, fixedRateAddress: string, fixedRateExchangeAbi?: AbiItem | AbiItem[], oceanAddress?: string, config?: Config);
51
+ amountToUnits(token: string, amount: string): Promise<string>;
52
+ unitsToAmount(token: string, amount: string): Promise<string>;
53
+ generateExchangeId(baseToken: string, datatoken: string, owner: string): Promise<string>;
54
+ estBuyDT(account: string, datatokenAddress: string, dtAmount: string, maxBaseTokenAmount: string, contractInstance?: Contract): Promise<number>;
55
+ buyDT(address: string, exchangeId: string, datatokenAmount: string, maxBaseTokenAmount: string): Promise<TransactionReceipt>;
56
+ estSellDT(account: string, datatokenAddress: string, dtAmount: string, maxBaseTokenAmount: string, contractInstance?: Contract): Promise<number>;
57
+ sellDT(address: string, exchangeId: string, datatokenAmount: string, minBaseTokenAmount: string): Promise<TransactionReceipt>;
58
+ getNumberOfExchanges(): Promise<number>;
59
+ estSetRate(account: string, exchangeId: string, newRate: string, contractInstance?: Contract): Promise<number>;
60
+ setRate(address: string, exchangeId: string, newRate: string): Promise<TransactionReceipt>;
61
+ estSetAllowedSwapper(account: string, exchangeId: string, newAllowedSwapper: string, contractInstance?: Contract): Promise<number>;
62
+ setAllowedSwapper(address: string, exchangeId: string, newAllowedSwapper: string): Promise<TransactionReceipt>;
63
+ estActivate(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
64
+ activate(address: string, exchangeId: string): Promise<TransactionReceipt>;
65
+ estDeactivate(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
66
+ deactivate(address: string, exchangeId: string): Promise<TransactionReceipt>;
67
+ getRate(exchangeId: string): Promise<string>;
68
+ getDTSupply(exchangeId: string): Promise<string>;
69
+ getBTSupply(exchangeId: string): Promise<string>;
70
+ getAllowedSwapper(exchangeId: string): Promise<string>;
71
+ getAmountBTIn(exchangeId: string, datatokenAmount: string): Promise<string>;
72
+ getAmountBTOut(exchangeId: string, datatokenAmount: string): Promise<string>;
73
+ getExchange(exchangeId: string): Promise<FixedPriceExchange>;
74
+ getFeesInfo(exchangeId: string): Promise<FeesInfo>;
75
+ getExchanges(): Promise<string[]>;
76
+ isActive(exchangeId: string): Promise<boolean>;
77
+ estActivateMint(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
78
+ activateMint(address: string, exchangeId: string): Promise<TransactionReceipt>;
79
+ estDeactivateMint(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
80
+ deactivateMint(address: string, exchangeId: string): Promise<TransactionReceipt>;
81
+ estCollectBT(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
82
+ collectBT(address: string, exchangeId: string): Promise<TransactionReceipt>;
83
+ estCollectDT(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
84
+ collectDT(address: string, exchangeId: string): Promise<TransactionReceipt>;
85
+ estCollectMarketFee(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
86
+ collectMarketFee(address: string, exchangeId: string): Promise<TransactionReceipt>;
87
+ estCollectOceanFee(account: string, exchangeId: string, contractInstance?: Contract): Promise<number>;
88
+ collectOceanFee(address: string, exchangeId: string): Promise<TransactionReceipt>;
89
+ getOPCCollector(): Promise<string>;
90
+ getRouter(): Promise<string>;
91
+ getExchangeOwner(exchangeId: string): Promise<string>;
92
+ estUpdateMarketFee(account: string, exchangeId: string, newMarketFee: string, contractInstance?: Contract): Promise<number>;
93
+ updateMarketFee(address: string, exchangeId: string, newMarketFee: string): Promise<TransactionReceipt>;
94
+ estUpdateMarketFeeCollector(account: string, exchangeId: string, newMarketFeeCollector: string, contractInstance?: Contract): Promise<number>;
95
+ updateMarketFeeCollector(address: string, exchangeId: string, newMarketFeeCollector: string): Promise<TransactionReceipt>;
96
+ }
@@ -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,30 @@
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
+ import { Config } from '../../models';
6
+ export declare class SideStaking {
7
+ ssAbi: AbiItem | AbiItem[];
8
+ web3: Web3;
9
+ GASLIMIT_DEFAULT: number;
10
+ config: Config;
11
+ constructor(web3: Web3, ssAbi?: AbiItem | AbiItem[], config?: Config);
12
+ amountToUnits(token: string, amount: string): Promise<string>;
13
+ unitsToAmount(token: string, amount: string): Promise<string>;
14
+ getDatatokenCirculatingSupply(ssAddress: string, datatokenAddress: string): Promise<string>;
15
+ getDatatokenCurrentCirculatingSupply(ssAddress: string, datatokenAddress: string): Promise<string>;
16
+ getPublisherAddress(ssAddress: string, datatokenAddress: string): Promise<string>;
17
+ getBaseToken(ssAddress: string, datatokenAddress: string): Promise<string>;
18
+ getPoolAddress(ssAddress: string, datatokenAddress: string): Promise<string>;
19
+ getBaseTokenBalance(ssAddress: string, datatokenAddress: string): Promise<string>;
20
+ getDatatokenBalance(ssAddress: string, datatokenAddress: string): Promise<string>;
21
+ getvestingEndBlock(ssAddress: string, datatokenAddress: string): Promise<string>;
22
+ getvestingAmount(ssAddress: string, datatokenAddress: string): Promise<string>;
23
+ getvestingLastBlock(ssAddress: string, datatokenAddress: string): Promise<string>;
24
+ getvestingAmountSoFar(ssAddress: string, datatokenAddress: string): Promise<string>;
25
+ estGetVesting(account: string, ssAddress: string, datatokenAddress: string, contractInstance?: Contract): Promise<number>;
26
+ getVesting(account: string, ssAddress: string, datatokenAddress: string): Promise<TransactionReceipt>;
27
+ estSetPoolSwapFee(account: string, ssAddress: string, datatokenAddress: string, poolAddress: string, swapFee: number, contractInstance?: Contract): Promise<number>;
28
+ setPoolSwapFee(account: string, ssAddress: string, datatokenAddress: string, poolAddress: string, swapFee: number): Promise<TransactionReceipt>;
29
+ getRouter(ssAddress: string): Promise<string>;
30
+ }
@@ -0,0 +1 @@
1
+ export * from './SideStaking';
@@ -0,0 +1,35 @@
1
+ import Web3 from 'web3';
2
+ import { FileMetadata, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ProviderInitialize } from '../@types/';
3
+ import { DownloadResponse } from '../@types/DownloadResponse';
4
+ export interface HttpCallback {
5
+ (httpMethod: string, url: string, body: string, header: any): Promise<any>;
6
+ }
7
+ export interface ServiceEndpoint {
8
+ serviceName: string;
9
+ method: string;
10
+ urlPath: string;
11
+ }
12
+ export interface UserCustomParameters {
13
+ [key: string]: any;
14
+ }
15
+ export declare class Provider {
16
+ getEndpoints(providerUri: string): Promise<any>;
17
+ getEndpointURL(servicesEndpoints: ServiceEndpoint[], serviceName: string): ServiceEndpoint;
18
+ getServiceEndpoints(providerEndpoint: string, endpoints: any): Promise<ServiceEndpoint[]>;
19
+ getNonce(providerUri: string, consumerAddress: string, signal?: AbortSignal, providerEndpoints?: any, serviceEndpoints?: ServiceEndpoint[]): Promise<string>;
20
+ createSignature(web3: Web3, accountId: string, agreementId: string): Promise<string>;
21
+ createHashSignature(web3: Web3, accountId: string, message: string): Promise<string>;
22
+ encrypt(data: any, providerUri: string, signal?: AbortSignal): Promise<string>;
23
+ checkDidFiles(did: string, serviceId: number, providerUri: string, signal?: AbortSignal): Promise<FileMetadata[]>;
24
+ checkFileUrl(url: string, providerUri: string, signal?: AbortSignal): Promise<FileMetadata[]>;
25
+ initialize(did: string, serviceId: string, fileIndex: number, consumerAddress: string, providerUri: string, signal?: AbortSignal, userCustomParameters?: UserCustomParameters, computeEnv?: string, validUntil?: number): Promise<ProviderInitialize>;
26
+ getDownloadUrl(did: string, accountId: string, serviceId: string, fileIndex: number, transferTxId: string, providerUri: string, web3: Web3, userCustomParameters?: UserCustomParameters): Promise<any>;
27
+ computeStart(providerUri: string, web3: Web3, consumerAddress: string, computeEnv: string, dataset: ComputeAsset, algorithm: ComputeAlgorithm, signal?: AbortSignal, additionalDatasets?: ComputeAsset[], output?: ComputeOutput): Promise<ComputeJob | ComputeJob[]>;
28
+ computeStop(did: string, consumerAddress: string, jobId: string, providerUri: string, web3: Web3, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
29
+ computeStatus(providerUri: string, signal?: AbortSignal, jobId?: string, did?: string, consumerAddress?: string): Promise<ComputeJob | ComputeJob[]>;
30
+ computeResult(jobId: string, index: number, accountId: string, providerUri: string, web3: Web3, signal?: AbortSignal): Promise<DownloadResponse | void>;
31
+ computeDelete(did: string, consumerAddress: string, jobId: string, providerUri: string, web3: Web3, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
32
+ isValidProvider(url: string, signal?: AbortSignal): Promise<boolean>;
33
+ }
34
+ export declare const ProviderInstance: Provider;
35
+ export default ProviderInstance;
@@ -0,0 +1 @@
1
+ export * from './Provider';
@@ -0,0 +1,73 @@
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
+ import { Config } from '../models/index.js';
8
+ import { ProviderFees } from '../@types/Provider.js';
9
+ interface Roles {
10
+ minter: boolean;
11
+ paymentManager: boolean;
12
+ }
13
+ export interface OrderParams {
14
+ consumer: string;
15
+ serviceIndex: number;
16
+ _providerFees: ProviderFees;
17
+ }
18
+ export interface DispenserParams {
19
+ maxTokens: string;
20
+ maxBalance: string;
21
+ withMint?: boolean;
22
+ allowedSwapper?: string;
23
+ }
24
+ export declare class Datatoken {
25
+ GASLIMIT_DEFAULT: number;
26
+ factoryAddress: string;
27
+ factoryABI: AbiItem | AbiItem[];
28
+ datatokensAbi: AbiItem | AbiItem[];
29
+ datatokensEnterpriseAbi: AbiItem | AbiItem[];
30
+ web3: Web3;
31
+ config: Config;
32
+ nft: Nft;
33
+ constructor(web3: Web3, datatokensAbi?: AbiItem | AbiItem[], datatokensEnterpriseAbi?: AbiItem | AbiItem[], config?: Config);
34
+ estGasApprove(dtAddress: string, spender: string, amount: string, address: string, contractInstance?: Contract): Promise<any>;
35
+ approve(dtAddress: string, spender: string, amount: string, address: string): Promise<TransactionReceipt>;
36
+ estGasMint(dtAddress: string, address: string, amount: string, toAddress?: string, contractInstance?: Contract): Promise<any>;
37
+ estGasCreateFixedRate(dtAddress: string, address: string, fixedRateParams: FreCreationParams, contractInstance?: Contract): Promise<any>;
38
+ createFixedRate(dtAddress: string, address: string, fixedRateParams: FreCreationParams): Promise<TransactionReceipt>;
39
+ estGasCreateDispenser(dtAddress: string, address: string, dispenserAddress: string, dispenserParams: DispenserParams, contractInstance?: Contract): Promise<any>;
40
+ createDispenser(dtAddress: string, address: string, dispenserAddress: string, dispenserParams: DispenserParams): Promise<TransactionReceipt>;
41
+ mint(dtAddress: string, address: string, amount: string, toAddress?: string): Promise<TransactionReceipt>;
42
+ estGasAddMinter(dtAddress: string, address: string, minter: string, contractInstance?: Contract): Promise<any>;
43
+ addMinter(dtAddress: string, address: string, minter: string): Promise<TransactionReceipt>;
44
+ estGasRemoveMinter(dtAddress: string, address: string, minter: string, contractInstance?: Contract): Promise<any>;
45
+ removeMinter(dtAddress: string, address: string, minter: string): Promise<TransactionReceipt>;
46
+ estGasAddPaymentManager(dtAddress: string, address: string, paymentManager: string, contractInstance?: Contract): Promise<any>;
47
+ addPaymentManager(dtAddress: string, address: string, paymentManager: string): Promise<TransactionReceipt>;
48
+ estGasRemovePaymentManager(dtAddress: string, address: string, paymentManager: string, contractInstance?: Contract): Promise<any>;
49
+ removePaymentManager(dtAddress: string, address: string, paymentManager: string): Promise<TransactionReceipt>;
50
+ estGasSetPaymentCollector(dtAddress: string, address: string, paymentCollector: string, contractInstance?: Contract): Promise<any>;
51
+ setPaymentCollector(dtAddress: string, address: string, paymentCollector: string): Promise<TransactionReceipt>;
52
+ getPaymentCollector(dtAddress: string): Promise<string>;
53
+ transfer(dtAddress: string, toAddress: string, amount: string, address: string): Promise<TransactionReceipt>;
54
+ estGasTransfer(dtAddress: string, toAddress: string, amount: string, address: string, contractInstance?: Contract): Promise<any>;
55
+ transferWei(dtAddress: string, toAddress: string, amount: string, address: string): Promise<TransactionReceipt>;
56
+ estGasStartOrder(dtAddress: string, address: string, consumer: string, serviceIndex: number, providerFees: ProviderFees, contractInstance?: Contract): Promise<any>;
57
+ startOrder(dtAddress: string, address: string, consumer: string, serviceIndex: number, providerFees: ProviderFees): Promise<TransactionReceipt>;
58
+ estGasBuyFromFreAndOrder(dtAddress: string, address: string, orderParams: OrderParams, freParams: FreOrderParams, contractInstance?: Contract): Promise<any>;
59
+ buyFromFreAndOrder(dtAddress: string, address: string, orderParams: OrderParams, freParams: FreOrderParams): Promise<TransactionReceipt>;
60
+ estGasBuyFromDispenserAndOrder(dtAddress: string, address: string, orderParams: OrderParams, dispenserContract: string, contractInstance?: Contract): Promise<any>;
61
+ buyFromDispenserAndOrder(dtAddress: string, address: string, orderParams: OrderParams, dispenserContract: string): Promise<TransactionReceipt>;
62
+ estGasSetData(dtAddress: string, address: string, value: string, contractInstance?: Contract): Promise<any>;
63
+ setData(dtAddress: string, address: string, value: string): Promise<TransactionReceipt>;
64
+ estGasCleanPermissions(dtAddress: string, address: string, contractInstance?: Contract): Promise<any>;
65
+ cleanPermissions(dtAddress: string, address: string): Promise<TransactionReceipt>;
66
+ getDTPermissions(dtAddress: string, address: string): Promise<Roles>;
67
+ getCap(dtAddress: string): Promise<string>;
68
+ getDecimals(dtAddress: string): Promise<string>;
69
+ getNFTAddress(dtAddress: string): Promise<string>;
70
+ isERC20Deployer(dtAddress: string, address: string): Promise<boolean>;
71
+ balance(datatokenAddress: string, address: string): Promise<string>;
72
+ }
73
+ export {};
@@ -0,0 +1,62 @@
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
+ import { Config } from '../models/index.js';
7
+ import { MetadataAndTokenURI } from '../interfaces/Erc721Interface';
8
+ interface Roles {
9
+ manager: boolean;
10
+ deployERC20: boolean;
11
+ updateMetadata: boolean;
12
+ store: boolean;
13
+ }
14
+ export declare class Nft {
15
+ GASLIMIT_DEFAULT: number;
16
+ factory721Address: string;
17
+ factory721Abi: AbiItem | AbiItem[];
18
+ nftAbi: AbiItem | AbiItem[];
19
+ web3: Web3;
20
+ startBlock: number;
21
+ config: Config;
22
+ constructor(web3: Web3, nftAbi?: AbiItem | AbiItem[], config?: Config);
23
+ 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>;
24
+ 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>;
25
+ estGasAddManager(nftAddress: string, address: string, manager: string, contractInstance?: Contract): Promise<any>;
26
+ addManager(nftAddress: string, address: string, manager: string): Promise<any>;
27
+ estGasRemoveManager(nftAddress: string, address: string, manager: string, contractInstance?: Contract): Promise<any>;
28
+ removeManager(nftAddress: string, address: string, manager: string): Promise<any>;
29
+ estGasAddErc20Deployer(nftAddress: string, address: string, erc20Deployer: string, contractInstance?: Contract): Promise<any>;
30
+ addErc20Deployer(nftAddress: string, address: string, erc20Deployer: string): Promise<TransactionReceipt>;
31
+ estGasRemoveErc20Deployer(nftAddress: string, address: string, erc20Deployer: string, contractInstance?: Contract): Promise<any>;
32
+ removeErc20Deployer(nftAddress: string, address: string, erc20Deployer: string): Promise<TransactionReceipt>;
33
+ estGasAddMetadataUpdater(nftAddress: string, address: string, metadataUpdater: string, contractInstance?: Contract): Promise<any>;
34
+ addMetadataUpdater(nftAddress: string, address: string, metadataUpdater: string): Promise<TransactionReceipt>;
35
+ esGasRemoveMetadataUpdater(nftAddress: string, address: string, metadataUpdater: string, contractInstance?: Contract): Promise<any>;
36
+ removeMetadataUpdater(nftAddress: string, address: string, metadataUpdater: string): Promise<TransactionReceipt>;
37
+ estGasAddStoreUpdater(nftAddress: string, address: string, storeUpdater: string, contractInstance?: Contract): Promise<any>;
38
+ addStoreUpdater(nftAddress: string, address: string, storeUpdater: string): Promise<TransactionReceipt>;
39
+ estGasRemoveStoreUpdater(nftAddress: string, address: string, storeUpdater: string, contractInstance?: Contract): Promise<any>;
40
+ removeStoreUpdater(nftAddress: string, address: string, storeUpdater: string): Promise<TransactionReceipt>;
41
+ estGasCleanPermissions(nftAddress: string, address: string, contractInstance?: Contract): Promise<any>;
42
+ cleanPermissions(nftAddress: string, address: string): Promise<TransactionReceipt>;
43
+ estGasTransferNft(nftAddress: string, nftOwner: string, nftReceiver: string, tokenId: number, contractInstance?: Contract): Promise<any>;
44
+ transferNft(nftAddress: string, nftOwner: string, nftReceiver: string, tokenId?: number): Promise<TransactionReceipt>;
45
+ estGasSafeTransferNft(nftAddress: string, nftOwner: string, nftReceiver: string, tokenId: number, contractInstance?: Contract): Promise<any>;
46
+ safeTransferNft(nftAddress: string, nftOwner: string, nftReceiver: string, tokenId?: number): Promise<TransactionReceipt>;
47
+ estGasSetMetadata(nftAddress: string, metadataUpdater: string, metadataState: number, metadataDecryptorUrl: string, metadataDecryptorAddress: string, flags: string, data: string, metadataHash: string, metadataProofs?: MetadataProof[], contractInstance?: Contract): Promise<any>;
48
+ setMetadata(nftAddress: string, address: string, metadataState: number, metadataDecryptorUrl: string, metadataDecryptorAddress: string, flags: string, data: string, metadataHash: string, metadataProofs?: MetadataProof[]): Promise<TransactionReceipt>;
49
+ estGasSetMetadataAndTokenURI(nftAddress: string, metadataUpdater: string, metadataAndTokenURI: MetadataAndTokenURI, contractInstance?: Contract): Promise<any>;
50
+ setMetadataAndTokenURI(nftAddress: string, metadataUpdater: string, metadataAndTokenURI: MetadataAndTokenURI): Promise<TransactionReceipt>;
51
+ estGasSetMetadataState(nftAddress: string, metadataUpdater: string, metadataState: number, contractInstance?: Contract): Promise<any>;
52
+ setMetadataState(nftAddress: string, address: string, metadataState: number): Promise<TransactionReceipt>;
53
+ estSetTokenURI(nftAddress: string, address: string, data: string): Promise<any>;
54
+ setTokenURI(nftAddress: string, address: string, data: string): Promise<any>;
55
+ getNftOwner(nftAddress: string): Promise<string>;
56
+ getNftPermissions(nftAddress: string, address: string): Promise<Roles>;
57
+ getMetadata(nftAddress: string): Promise<Object>;
58
+ isErc20Deployer(nftAddress: string, address: string): Promise<boolean>;
59
+ getData(nftAddress: string, key: string): Promise<string>;
60
+ getTokenURI(nftAddress: string, id: number): Promise<string>;
61
+ }
62
+ 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, customAddresses?: any): Partial<Config>;
5
+ getConfig(network: string | number, infuraProjectId?: string): Config;
6
+ }
@@ -0,0 +1,2 @@
1
+ export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
2
+ export declare const GASLIMIT_DEFAULT = 1000000;
@@ -0,0 +1,11 @@
1
+ import Web3 from 'web3';
2
+ import { Contract } from 'web3-eth-contract';
3
+ import { Erc20CreateParams, FreCreationParams, PoolCreationParams } from '../interfaces';
4
+ import { Config } from '../models';
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 getFreCreationParams(freParams: FreCreationParams): any;
9
+ export declare function getPoolCreationParams(poolParams: PoolCreationParams): any;
10
+ export declare function unitsToAmount(web3: Web3, token: string, amount: string): Promise<string>;
11
+ export declare function amountToUnits(web3: Web3, token: string, amount: string): Promise<string>;
@@ -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,6 @@
1
+ import { DownloadResponse } from '../@types/DownloadResponse';
2
+ export declare function fetchData(url: string, opts: RequestInit): Promise<Response>;
3
+ export declare function downloadFileBrowser(url: string): Promise<void>;
4
+ 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>;
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,7 @@
1
+ import { Contract } from 'web3-eth-contract';
2
+ import { TransactionReceipt } from 'web3-core';
3
+ import Web3 from 'web3';
4
+ export declare function estApprove(web3: Web3, account: string, tokenAddress: string, spender: string, amount: string, contractInstance?: Contract): Promise<number>;
5
+ export declare function approve(web3: Web3, account: string, tokenAddress: string, spender: string, amount: string, force?: boolean): Promise<TransactionReceipt | string>;
6
+ export declare function allowance(web3: Web3, tokenAddress: string, account: string, spender: string): Promise<string>;
7
+ export declare function balance(web3: Web3, tokenAddress: string, account: string): Promise<string>;
@@ -0,0 +1,9 @@
1
+ export * from './Logger';
2
+ export * from './DatatokenName';
3
+ export * from './ContractUtils';
4
+ export * from './FetchHelper';
5
+ export * from './ConfigHelper';
6
+ export * from './DdoHelpers';
7
+ export * from './Constants';
8
+ export * from './SignatureUtils';
9
+ export * from './TokenUtils';
@@ -0,0 +1,2 @@
1
+ import { AbiItem } from 'web3-utils/types';
2
+ export declare const minAbi: AbiItem[];
@@ -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 {};
@@ -166,10 +166,10 @@ The process of creating and deploying the ERC20 datatokens has been automated by
166
166
 
167
167
  ```Javascript
168
168
  const Web3 = require("web3");
169
- const { Ocean, DataTokens } = require("@oceanprotocol/lib");
169
+ const { Ocean, Datatokens } = require("@oceanprotocol/lib");
170
170
 
171
- const { factoryABI } = require("@oceanprotocol/contracts/artifacts/DTFactory.json");
172
- const { datatokensABI } = require("@oceanprotocol/contracts/artifacts/DataTokenTemplate.json");
171
+ const { factoryABI } = require("@oceanprotocol/contracts/artifacts/contracts/DTFactory.json");
172
+ const { datatokensABI } = require("@oceanprotocol/contracts/artifacts/contracts/DatatokenTemplate.json");
173
173
  const { config, contracts, urls } = require("./config");
174
174
 
175
175
  const init = async () => {
@@ -180,7 +180,7 @@ const init = async () => {
180
180
  const alice = accounts[0].id;
181
181
  console.log('Alice account address:', alice)
182
182
 
183
- const datatoken = new DataTokens(
183
+ const datatoken = new Datatokens(
184
184
  contracts.DTFactory,
185
185
  factoryABI,
186
186
  datatokensABI,