@oceanprotocol/lib 2.7.0 → 3.0.0-next.1

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 (49) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/CodeExamples.md +273 -166
  3. package/ComputeExamples.md +106 -101
  4. package/dist/lib.js +1 -1
  5. package/dist/lib.js.map +1 -1
  6. package/dist/lib.modern.js +1 -1
  7. package/dist/lib.modern.js.map +1 -1
  8. package/dist/lib.module.js +1 -1
  9. package/dist/lib.module.js.map +1 -1
  10. package/dist/lib.umd.js +1 -1
  11. package/dist/lib.umd.js.map +1 -1
  12. package/dist/src/@types/Contracts.d.ts +26 -0
  13. package/dist/src/@types/DDO/Metadata.d.ts +2 -2
  14. package/dist/src/@types/File.d.ts +1 -1
  15. package/dist/src/@types/ReturnTypes.d.ts +3 -2
  16. package/dist/src/@types/index.d.ts +1 -0
  17. package/dist/src/config/Config.d.ts +1 -1
  18. package/dist/src/config/ConfigHelper.d.ts +6 -0
  19. package/dist/src/contracts/Datatoken.d.ts +90 -72
  20. package/dist/src/contracts/Dispenser.d.ts +27 -27
  21. package/dist/src/contracts/FixedRateExchange.d.ts +57 -60
  22. package/dist/src/contracts/NFT.d.ts +57 -34
  23. package/dist/src/contracts/NFTFactory.d.ts +78 -57
  24. package/dist/src/contracts/Router.d.ts +33 -18
  25. package/dist/src/contracts/SmartContract.d.ts +35 -12
  26. package/dist/src/contracts/SmartContractWithAddress.d.ts +7 -8
  27. package/dist/src/contracts/df/DfRewards.d.ts +6 -7
  28. package/dist/src/contracts/df/DfStrategyV1.d.ts +3 -5
  29. package/dist/src/contracts/ve/VeAllocate.d.ts +4 -7
  30. package/dist/src/contracts/ve/VeFeeDistributor.d.ts +6 -7
  31. package/dist/src/contracts/ve/VeFeeEstimate.d.ts +2 -2
  32. package/dist/src/contracts/ve/VeOcean.d.ts +12 -13
  33. package/dist/src/services/Aquarius.d.ts +3 -4
  34. package/dist/src/services/Provider.d.ts +124 -76
  35. package/dist/src/utils/ContractUtils.d.ts +36 -16
  36. package/dist/src/utils/DatatokenName.d.ts +5 -2
  37. package/dist/src/utils/DdoHelpers.d.ts +11 -0
  38. package/dist/src/utils/FetchHelper.d.ts +11 -0
  39. package/dist/src/utils/General.d.ts +1 -0
  40. package/dist/src/utils/ProviderErrors.d.ts +1 -0
  41. package/dist/src/utils/SignatureUtils.d.ts +8 -2
  42. package/dist/src/utils/TokenUtils.d.ts +43 -43
  43. package/dist/src/utils/index.d.ts +1 -0
  44. package/dist/src/utils/minAbi.d.ts +38 -2
  45. package/dist/test/config.d.ts +17 -3
  46. package/dist/test/integration/helpers.d.ts +7 -0
  47. package/package.json +10 -5
  48. package/dist/test/TestContractHandler.d.ts +0 -16
  49. /package/dist/test/integration/{SimplePublishConsumeFlow.test.d.ts → PublishEditConsume.test.d.ts} +0 -0
@@ -1,48 +1,47 @@
1
- import { AbiItem } from 'web3-utils';
2
1
  import { SmartContractWithAddress } from '../SmartContractWithAddress';
3
- import { ReceiptOrEstimate } from '../../@types';
2
+ import { ReceiptOrEstimate, AbiItem } from '../../@types';
4
3
  /**
5
4
  * Provides an interface for veOcean contract
6
5
  */
7
6
  export declare class VeOcean extends SmartContractWithAddress {
8
- getDefaultAbi(): AbiItem | AbiItem[];
7
+ getDefaultAbi(): AbiItem[];
9
8
  /**
10
9
  * Deposit `amount` tokens for `userAddress` and lock until `unlockTime`
11
- * @param {String} userAddress user address
12
10
  * @param {String} amount Amount of tokens to be locked
13
11
  * @param {Number} unlockTime Timestamp for unlock
12
+ * @param {Boolean} estimateGas if True, return gas estimate
14
13
  * @return {Promise<ReceiptOrEstimate>}
15
14
  */
16
- lockTokens<G extends boolean = false>(userAddress: string, amount: string, unlockTime: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
15
+ lockTokens<G extends boolean = false>(amount: string, unlockTime: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
17
16
  /**
18
17
  * Deposit `amount` tokens for `toAddress` and add to the existing lock
19
18
  * 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
19
  * @param {String} toAddress user address to deposit for
22
20
  * @param {String} amount Amount of tokens to be locked
21
+ * @param {Boolean} estimateGas if True, return gas estimate
23
22
  * @return {Promise<ReceiptOrEstimate>}
24
23
  */
25
- depositFor<G extends boolean = false>(fromUserAddress: string, toAddress: string, amount: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
24
+ depositFor<G extends boolean = false>(toAddress: string, amount: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
26
25
  /**
27
26
  * Deposit `amount` additional tokens for `userAddress` without modifying the unlock time
28
- * @param {String} userAddress user address that sends the tx
29
27
  * @param {String} amount Amount of tokens to be locked
28
+ * @param {Boolean} estimateGas if True, return gas estimate
30
29
  * @return {Promise<ReceiptOrEstimate>}
31
30
  */
32
- increaseAmount<G extends boolean = false>(userAddress: string, amount: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
31
+ increaseAmount<G extends boolean = false>(amount: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
33
32
  /**
34
33
  * Extend the unlock time for `userAddress` to `unlockTime`
35
- * @param {String} userAddress user address that sends the tx
36
34
  * @param {Number} unlockTime Timestamp for new unlock time
35
+ * @param {Boolean} estimateGas if True, return gas estimate
37
36
  * @return {Promise<ReceiptOrEstimate>}
38
37
  */
39
- increaseUnlockTime<G extends boolean = false>(userAddress: string, unlockTime: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
38
+ increaseUnlockTime<G extends boolean = false>(unlockTime: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
40
39
  /**
41
40
  * Withdraw all tokens for `userAddress`
42
- * @param {String} userAddress user address that sends the tx
41
+ * @param {Boolean} estimateGas if True, return gas estimate
43
42
  * @return {Promise<ReceiptOrEstimate>}
44
43
  */
45
- withdraw<G extends boolean = false>(userAddress: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
44
+ withdraw<G extends boolean = false>(estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
46
45
  /** Get voting power for address
47
46
  * @param {String} userAddress user address
48
47
  * @return {Promise<number>}
@@ -16,18 +16,17 @@ export declare class Aquarius {
16
16
  */
17
17
  constructor(aquariusURL: string);
18
18
  /** Resolves a DID
19
- * @param {string} did
19
+ * @param {string} did DID of the asset.
20
20
  * @param {AbortSignal} signal abort signal
21
21
  * @return {Promise<Asset>} Asset
22
22
  */
23
23
  resolve(did: string, signal?: AbortSignal): Promise<Asset>;
24
24
  /**
25
25
  * Blocks until Aqua will cache the did (or the update for that did) or timeouts
26
-
27
26
  * @param {string} did DID of the asset.
28
27
  * @param {string} txid used when the did exists and we expect an update with that txid.
29
- * @param {AbortSignal} signal abort signal
30
- * @return {Promise<DDO>} DDO of the asset.
28
+ * @param {AbortSignal} signal abort signal
29
+ * @return {Promise<Asset>} DDO of the asset.
31
30
  */
32
31
  waitForAqua(did: string, txid?: string, signal?: AbortSignal): Promise<Asset>;
33
32
  /**
@@ -1,19 +1,28 @@
1
- import Web3 from 'web3';
1
+ import { Signer } from 'ethers';
2
2
  import { Arweave, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, ServiceEndpoint, UrlFile, UserCustomParameters, Ipfs, Smartcontract, GraphqlQuery } from '../@types';
3
3
  export declare class Provider {
4
4
  /**
5
5
  * Returns the provider endpoints
6
- * @return {Promise<ServiceEndpoint[]>}
6
+ * @param {string} providerUri - the provider url
7
+ * @return {Promise<any>}
7
8
  */
8
9
  getEndpoints(providerUri: string): Promise<any>;
10
+ /**
11
+ * This function returns the endpoint URL for a given service name.
12
+ * @param {ServiceEndpoint[]} servicesEndpoints - The array of service endpoints
13
+ * @param {string} serviceName - The name of the service
14
+ * @returns {ServiceEndpoint} The endpoint URL for the given service name
15
+ */
9
16
  getEndpointURL(servicesEndpoints: ServiceEndpoint[], serviceName: string): ServiceEndpoint;
10
17
  /**
11
- * Returns the service endpoints that exist in provider.
12
- * @param {any} endpoints
13
- * @return {Promise<ServiceEndpoint[]>}
18
+ * This function returns an array of service endpoints for a given provider endpoint.
19
+ * @param {string} providerEndpoint - The provider endpoint
20
+ * @param {any} endpoints - The endpoints object
21
+ * @returns {ServiceEndpoint[]} An array of service endpoints
14
22
  */
15
23
  getServiceEndpoints(providerEndpoint: string, endpoints: any): Promise<ServiceEndpoint[]>;
16
- /** Gets current nonce
24
+ /**
25
+ * Get current nonce from the provider.
17
26
  * @param {string} providerUri provider uri address
18
27
  * @param {string} consumerAddress Publisher address
19
28
  * @param {AbortSignal} signal abort signal
@@ -22,91 +31,109 @@ export declare class Provider {
22
31
  * @return {Promise<string>} urlDetails
23
32
  */
24
33
  getNonce(providerUri: string, consumerAddress: string, signal?: AbortSignal, providerEndpoints?: any, serviceEndpoints?: ServiceEndpoint[]): Promise<string>;
25
- signProviderRequest(web3: Web3, accountId: string, message: string, password?: string): Promise<string>;
26
- /** Encrypt data using the Provider's own symmetric key
34
+ /**
35
+ * Sign a provider request with a signer.
36
+ * @param {Signer} signer - The signer to use.
37
+ * @param {string} message - The message to sign.
38
+ * @returns {Promise<string>} A promise that resolves with the signature.
39
+ */
40
+ signProviderRequest(signer: Signer, message: string): Promise<string>;
41
+ /**
42
+ * Encrypt data using the Provider's own symmetric key
27
43
  * @param {string} data data in json format that needs to be sent , it can either be a DDO or a File array
28
- * @param {number} chainId network's id so provider can choose the corresponding web3 object
44
+ * @param {number} chainId network's id so provider can choose the corresponding Signer object
29
45
  * @param {string} providerUri provider uri address
30
46
  * @param {AbortSignal} signal abort signal
31
47
  * @return {Promise<string>} urlDetails
32
48
  */
33
49
  encrypt(data: any, chainId: number, providerUri: string, signal?: AbortSignal): Promise<string>;
34
- /** Get DDO File details (if possible)
35
- * @param {UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract} file one of the supported file structures
36
- * @param {string} serviceId the id of the service for which to check the files
37
- * @param {string} providerUri uri of the provider that will be used to check the file
38
- * @param {boolean} withChecksum if true, will return checksum of files content
39
- * @param {AbortSignal} signal abort signal
40
- * @return {Promise<FileInfo[]>} urlDetails
50
+ /**
51
+ * Get file details for a given DID and service ID.
52
+ * @param {string} did - The DID to check.
53
+ * @param {string} serviceId - The service ID to check.
54
+ * @param {string} providerUri - The URI of the provider.
55
+ * @param {boolean} [withChecksum=false] - Whether or not to include a checksum.
56
+ * @param {AbortSignal} [signal] - An optional abort signal.
57
+ * @returns {Promise<FileInfo[]>} A promise that resolves with an array of file info objects.
41
58
  */
42
59
  checkDidFiles(did: string, serviceId: string, providerUri: string, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
43
- /** Get URL details (if possible)
60
+ /**
61
+ * Get File details (if possible)
44
62
  * @param {UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract} file one of the supported file structures
45
63
  * @param {string} providerUri uri of the provider that will be used to check the file
46
- * @param {boolean} withChecksum if true, will return checksum of files content
47
- * @param {AbortSignal} signal abort signal
48
- * @return {Promise<FileInfo[]>} urlDetails
64
+ * @param {boolean} [withChecksum=false] - Whether or not to include a checksum.
65
+ * @param {AbortSignal} [signal] - An optional abort signal.
66
+ * @returns {Promise<FileInfo[]>} A promise that resolves with an array of file info objects.
49
67
  */
50
68
  getFileInfo(file: UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract, providerUri: string, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
51
- /** Get Compute Environments
52
- * @return {Promise<ComputeEnvironment[]>} urlDetails
53
- */
54
- getComputeEnvironments(providerUri: string, signal?: AbortSignal): Promise<ComputeEnvironment[]>;
55
- /** Initialize a service request.
56
- * @param {DDO | string} asset
57
- * @param {number} serviceIndex
58
- * @param {string} serviceType
59
- * @param {string} consumerAddress
60
- * @param {UserCustomParameters} userCustomParameters
61
- * @param {string} providerUri Identifier of the asset to be registered in ocean
62
- * @param {AbortSignal} signal abort signal
63
- * @return {Promise<ProviderInitialize>} ProviderInitialize data
69
+ /**
70
+ * Returns compute environments from a provider.
71
+ * @param {string} providerUri - The URI of the provider.
72
+ * @param {AbortSignal} [signal] - An optional abort signal.
73
+ * @returns {Promise<{[chainId: number]: ComputeEnvironment[]}>} A promise that resolves with an object containing compute environments for each chain ID.
74
+ */
75
+ getComputeEnvironments(providerUri: string, signal?: AbortSignal): Promise<{
76
+ [chainId: number]: ComputeEnvironment[];
77
+ }>;
78
+ /**
79
+ * Initializes the provider for a service request.
80
+ * @param {string} did - The asset DID .
81
+ * @param {string} serviceId - The asset service ID.
82
+ * @param {number} fileIndex - The file index.
83
+ * @param {string} consumerAddress - The consumer address.
84
+ * @param {string} providerUri - The URI of the provider.
85
+ * @param {AbortSignal} [signal] - The abort signal if any.
86
+ * @param {UserCustomParameters} [userCustomParameters] - The custom parameters if any.
87
+ * @param {string} [computeEnv] - The compute environment if any.
88
+ * @param {number} [validUntil] - The validity time if any.
89
+ * @returns {Promise<ProviderInitialize>} A promise that resolves with ProviderInitialize response.
64
90
  */
65
91
  initialize(did: string, serviceId: string, fileIndex: number, consumerAddress: string, providerUri: string, signal?: AbortSignal, userCustomParameters?: UserCustomParameters, computeEnv?: string, validUntil?: number): Promise<ProviderInitialize>;
66
- /** Initialize a compute request.
67
- * @param {ComputeAsset} assets
68
- * @param {ComputeAlgorithmber} algorithm
69
- * @param {string} computeEnv
70
- * @param {number} validUntil
71
- * @param {string} providerUri Identifier of the asset to be registered in ocean
72
- * @param {string} accountId
92
+ /** Initializes the provider for a compute request.
93
+ * @param {ComputeAsset[]} assets The datasets array to initialize compute request.
94
+ * @param {ComputeAlgorithmber} algorithm The algorithm to use.
95
+ * @param {string} computeEnv The compute environment.
96
+ * @param {number} validUntil The job expiration date.
97
+ * @param {string} providerUri The provider URI.
98
+ * @param {string} accountId caller address
73
99
  * @param {AbortSignal} signal abort signal
74
100
  * @return {Promise<ProviderComputeInitialize>} ProviderComputeInitialize data
75
101
  */
76
102
  initializeCompute(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, validUntil: number, providerUri: string, accountId: string, signal?: AbortSignal): Promise<ProviderComputeInitializeResults>;
77
- /** Gets fully signed URL for download
78
- * @param {string} did
79
- * @param {string} accountId
80
- * @param {string} serviceId
81
- * @param {number} fileIndex
82
- * @param {string} providerUri
83
- * @param {Web3} web3
84
- * @param {UserCustomParameters} userCustomParameters
85
- * @return {Promise<string>}
86
- */
87
- getDownloadUrl(did: string, accountId: string, serviceId: string, fileIndex: number, transferTxId: string, providerUri: string, web3: Web3, userCustomParameters?: UserCustomParameters): Promise<any>;
103
+ /**
104
+ * Gets the download URL.
105
+ * @param {string} did - The DID.
106
+ * @param {string} serviceId - The service ID.
107
+ * @param {number} fileIndex - The file index.
108
+ * @param {string} transferTxId - The transfer transaction ID.
109
+ * @param {string} providerUri - The provider URI.
110
+ * @param {Signer} signer - The signer.
111
+ * @param {UserCustomParameters} userCustomParameters - The user custom parameters.
112
+ * @returns {Promise<any>} The download URL.
113
+ */
114
+ getDownloadUrl(did: string, serviceId: string, fileIndex: number, transferTxId: string, providerUri: string, signer: Signer, userCustomParameters?: UserCustomParameters): Promise<any>;
88
115
  /** Instruct the provider to start a compute job
89
- * @param {string} did
90
- * @param {string} consumerAddress
91
- * @param {string} computeEnv
92
- * @param {ComputeAlgorithm} algorithm
93
- * @param {string} providerUri
94
- * @param {Web3} web3
116
+ * @param {string} providerUri The provider URI.
117
+ * @param {Signer} signer The consumer signer object.
118
+ * @param {string} computeEnv The compute environment.
119
+ * @param {ComputeAsset} dataset The dataset to start compute on
120
+ * @param {ComputeAlgorithm} algorithm The algorithm to start compute with.
95
121
  * @param {AbortSignal} signal abort signal
96
- * @param {ComputeOutput} output
97
- * @return {Promise<ComputeJob | ComputeJob[]>}
122
+ * @param {ComputeAsset[]} additionalDatasets The additional datasets if that is the case.
123
+ * @param {ComputeOutput} output The compute job output settings.
124
+ * @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
98
125
  */
99
- computeStart(providerUri: string, web3: Web3, consumerAddress: string, computeEnv: string, dataset: ComputeAsset, algorithm: ComputeAlgorithm, signal?: AbortSignal, additionalDatasets?: ComputeAsset[], output?: ComputeOutput): Promise<ComputeJob | ComputeJob[]>;
126
+ computeStart(providerUri: string, consumer: Signer, computeEnv: string, dataset: ComputeAsset, algorithm: ComputeAlgorithm, signal?: AbortSignal, additionalDatasets?: ComputeAsset[], output?: ComputeOutput): Promise<ComputeJob | ComputeJob[]>;
100
127
  /** Instruct the provider to Stop the execution of a to stop a compute job.
101
- * @param {string} did
102
- * @param {string} consumerAddress
103
- * @param {string} jobId
104
- * @param {string} providerUri
105
- * @param {Web3} web3
128
+ * @param {string} did the asset did
129
+ * @param {string} consumerAddress The consumer address.
130
+ * @param {string} jobId the compute job id
131
+ * @param {string} providerUri The provider URI.
132
+ * @param {Signer} signer The consumer signer object.
106
133
  * @param {AbortSignal} signal abort signal
107
134
  * @return {Promise<ComputeJob | ComputeJob[]>}
108
135
  */
109
- computeStop(did: string, consumerAddress: string, jobId: string, providerUri: string, web3: Web3, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
136
+ computeStop(did: string, consumerAddress: string, jobId: string, providerUri: string, signer: Signer, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
110
137
  /** Get compute status for a specific jobId/documentId/owner.
111
138
  * @param {string} providerUri The URI of the provider we want to query
112
139
  * @param {string} consumerAddress The consumer ethereum address
@@ -118,32 +145,53 @@ export declare class Provider {
118
145
  computeStatus(providerUri: string, consumerAddress: string, jobId?: string, did?: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
119
146
  /** Get compute result url
120
147
  * @param {string} providerUri The URI of the provider we want to query
121
- * @param {Web3} web3 Web3 instance
122
- * @param {string} consumerAddress The consumer ethereum address
148
+ * @param {Signer} consumer consumer Signer wallet object
123
149
  * @param {string} jobId The ID of a compute job.
124
150
  * @param {number} index Result index
125
151
  * @return {Promise<string>}
126
152
  */
127
- getComputeResultUrl(providerUri: string, web3: Web3, consumerAddress: string, jobId: string, index: number): Promise<string>;
153
+ getComputeResultUrl(providerUri: string, consumer: Signer, jobId: string, index: number): Promise<string>;
128
154
  /** Deletes a compute job.
129
- * @param {string} did
130
- * @param {string} consumerAddress
131
- * @param {string} jobId
132
- * @param {string} providerUri
133
- * @param {Web3} web3
155
+ * @param {string} did asset did
156
+ * @param {Signer} consumer consumer Signer wallet object
157
+ * @param {string} jobId the compute job ID
158
+ * @param {string} providerUri The URI of the provider we want to query
134
159
  * @param {AbortSignal} signal abort signal
135
160
  * @return {Promise<ComputeJob | ComputeJob[]>}
136
161
  */
137
- computeDelete(did: string, consumerAddress: string, jobId: string, providerUri: string, web3: Web3, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
162
+ computeDelete(did: string, consumer: Signer, jobId: string, providerUri: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
138
163
  /** Check for a valid provider at URL
139
164
  * @param {String} url provider uri address
140
165
  * @param {AbortSignal} signal abort signal
141
- * @return {Promise<boolean>} string
166
+ * @return {Promise<boolean>} valid or not
142
167
  */
143
168
  isValidProvider(url: string, signal?: AbortSignal): Promise<boolean>;
169
+ /**
170
+ * Private method that removes the leading 0x from a string.
171
+ * @param {string} input - The input string.
172
+ * @returns The transformed string.
173
+ */
144
174
  private noZeroX;
175
+ /**
176
+ * Private method that removes the leading 0x from a string.
177
+ * @param {string} input - The input string.
178
+ * @param {boolean} zeroOutput - Whether to include 0x in the output if the input is valid and zeroOutput is true.
179
+ * @returns The transformed string.
180
+ */
145
181
  private zeroXTransformer;
182
+ /**
183
+ * Private method that matches an input string against a regular expression and returns the first capture group.
184
+ * @param {string} input - The input string to match.
185
+ * @param {RegExp} regexp - The regular expression to match against.
186
+ * @param {string} conversorName - The name of the method calling this function.
187
+ * @returns An object with two properties: `valid` (a boolean indicating whether the input matched the regular expression) and `output` (the first capture group of the match, or the original input if there was no match).
188
+ */
146
189
  private inputMatch;
190
+ /**
191
+ * Private method that fetches data from a URL using the GET method.
192
+ * @param {string} url - The URL to fetch data from.
193
+ * @returns A Promise that resolves to a Response object.
194
+ */
147
195
  private getData;
148
196
  }
149
197
  export declare const ProviderInstance: Provider;
@@ -1,26 +1,46 @@
1
- import Web3 from 'web3';
2
- import { Contract } from 'web3-eth-contract';
1
+ import { Signer, providers, Contract, ContractFunction, BigNumber } from 'ethers';
3
2
  import { Config } from '../config';
4
- import { TransactionReceipt } from 'web3-core';
5
3
  export declare function setContractDefaults(contract: Contract, config: Config): Contract;
6
- export declare function getFairGasPrice(web3: Web3, gasFeeMultiplier: number): Promise<string>;
7
- export declare function unitsToAmount(web3: Web3, token: string, amount: string, tokenDecimals?: number): Promise<string>;
8
- export declare function amountToUnits(web3: Web3, token: string, amount: string, tokenDecimals?: number): Promise<string>;
9
4
  /**
10
- * Estimates the gas used when a function would be executed on chain
11
- * @param {string} from account that calls the function
12
- * @param {Function} functionToEstimateGas function that we need to estimate the gas
13
- * @param {...any[]} args arguments of the function
14
- * @return {Promise<number>} gas cost of the function
5
+ * Asynchronous function that returns a fair gas price based on the current gas price and a multiplier.
6
+ * @param {Signer} signer - The signer object to use for fetching the current gas price.
7
+ * @param {number} gasFeeMultiplier - The multiplier to apply to the current gas price. If not provided, the current gas price is returned as a string.
8
+ * @returns A Promise that resolves to a string representation of the fair gas price.
9
+ */
10
+ export declare function getFairGasPrice(signer: Signer, gasFeeMultiplier: number): Promise<string>;
11
+ /**
12
+ * Asynchronous function that returns the number of decimal places for a given token.
13
+ * @param {Signer} signer - The signer object to use for fetching the token decimals.
14
+ * @param {string} token - The address of the token contract.
15
+ * @returns A Promise that resolves to the number of decimal places for the token.
16
+ */
17
+ export declare function getTokenDecimals(signer: Signer, token: string): Promise<any>;
18
+ /**
19
+ * Converts an amount of units to tokens
20
+ * @param {Signer} signer - The signer object to use.
21
+ * @param {string} token - The token to convert
22
+ * @param {string} amount - The amount of units to convert
23
+ * @param {number} [tokenDecimals] - The number of decimals in the token
24
+ * @returns {Promise<string>} - The converted amount in tokens
25
+ */
26
+ export declare function unitsToAmount(signer: Signer, token: string, amount: string, tokenDecimals?: number): Promise<string>;
27
+ /**
28
+ * Converts an amount of tokens to units
29
+ * @param {Signer} signer - The signer object to use.
30
+ * @param {string} token - The token to convert
31
+ * @param {string} amount - The amount of tokens to convert
32
+ * @param {number} [tokenDecimals] - The number of decimals of the token
33
+ * @returns {Promise<string>} - The converted amount in units
15
34
  */
16
- export declare function calculateEstimatedGas(from: string, functionToEstimateGas: Function, ...args: any[]): Promise<number>;
35
+ export declare function amountToUnits(signer: Signer, token: string, amount: string, tokenDecimals?: number): Promise<string>;
36
+ export declare function getEventFromTx(txReceipt: any, eventName: any): any;
17
37
  /**
18
38
  * 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
39
+ * @param {BigNumber} estGas estimated gas for the transaction
40
+ * @param {Signer} signer signer object
41
+ * @param {number} gasFeeMultiplier number represinting the multiplier we apply to gas fees
22
42
  * @param {Function} functionToSend function that we need to send
23
43
  * @param {...any[]} args arguments of the function
24
44
  * @return {Promise<any>} transaction receipt
25
45
  */
26
- export declare function sendTx(from: string, estGas: number, web3: Web3, gasFeeMultiplier: number, functionToSend: Function, ...args: any[]): Promise<TransactionReceipt>;
46
+ export declare function sendTx(estGas: BigNumber, signer: Signer, gasFeeMultiplier: number, functionToSend: ContractFunction, ...args: any[]): Promise<providers.TransactionResponse>;
@@ -1,6 +1,9 @@
1
1
  /**
2
- * Generate new datatoken name & symbol from a word list
3
- * @return {<{ name: String; symbol: String }>} datatoken name & symbol. Produces e.g. "Endemic Jellyfish Token" & "ENDJEL-45"
2
+ * This function generates a datatoken name and symbol from a given word list.
3
+ * @param {Object} [wordList] - An object containing an array of nouns and adjectives.
4
+ * @param {string[]} [wordList.nouns] - An array of nouns.
5
+ * @param {string[]} [wordList.adjectives] - An array of adjectives.
6
+ * @returns {Object} Returns an object containing the generated name and symbol. Produces e.g. "Endemic Jellyfish Token" & "ENDJEL-45"
4
7
  */
5
8
  export declare function generateDtName(wordList?: {
6
9
  nouns: string[];
@@ -1,2 +1,13 @@
1
+ /**
2
+ * Generates a valid DID
3
+ * @param {string} nftAddress - The NFT address
4
+ * @param {number} chainId - The chain ID
5
+ * @returns {string} - The DID
6
+ */
1
7
  export declare function generateDid(nftAddress: string, chainId: number): string;
8
+ /**
9
+ * Returns the SHA256 hash of the input data
10
+ * @param {any} data - The input data
11
+ * @returns {string} - The SHA256 hash of the input data
12
+ */
2
13
  export declare function getHash(data: any): string;
@@ -1,3 +1,14 @@
1
1
  import { DownloadResponse } from '../@types';
2
+ /**
3
+ * Triggers a file download from the specified URL when called from a browser context.
4
+ * @param {string} url - The URL of the file to download
5
+ * @returns {Promise<void>} - A Promise that resolves when the file has been downloaded
6
+ */
2
7
  export declare function downloadFileBrowser(url: string): Promise<void>;
8
+ /**
9
+ * Triggers a file download from the specified URL when called from a browser context.
10
+ * @param {string} url - The URL of the file to download
11
+ * @param {number} [index] - The file index
12
+ * @returns {Promise<void>} - A Promise that resolves when the file has been downloaded
13
+ */
3
14
  export declare function downloadFile(url: string, index?: number): Promise<DownloadResponse>;
@@ -1,4 +1,5 @@
1
1
  /**
2
2
  * Simple blocking sleep function
3
+ * @param {number} ms - Number of miliseconds to wait
3
4
  */
4
5
  export declare function sleep(ms: number): Promise<unknown>;
@@ -0,0 +1 @@
1
+ export declare function getErrorMessage(error: Object): string;
@@ -1,5 +1,11 @@
1
- import Web3 from 'web3';
2
- export declare function signHash(web3: Web3, message: string, address: string): Promise<{
1
+ import { Signer } from 'ethers';
2
+ /**
3
+ * Signs the hash of a message using the provided signer.
4
+ * @param {Signer} signer - The signer to use for signing the hash.
5
+ * @param {string} message - The message to sign.
6
+ * @returns {Promise<string>} - A Promise that resolves to the signature of the hash of the message.
7
+ */
8
+ export declare function signHash(signer: Signer, message: string): Promise<{
3
9
  v: string;
4
10
  r: string;
5
11
  s: string;
@@ -1,70 +1,70 @@
1
- import Web3 from 'web3';
1
+ import { Signer } from 'ethers';
2
2
  import { Config } from '../config';
3
- import { ReceiptOrEstimate } from '../@types';
3
+ import { ReceiptOrEstimate, ReceiptOrDecimal } from '../@types';
4
4
  /**
5
5
  * Approve spender to spent amount tokens
6
- * @param {Web3} web3
7
- * @param {Config} config
8
- * @param {String} account
9
- * @param {String} tokenAddress
10
- * @param {String} spender
6
+ * @param {Signer} signer - The signer object
7
+ * @param {Config} config - The config object
8
+ * @param {string} account - The address of the caller
9
+ * @param {string} tokenAddress - The address of the token
10
+ * @param {string} spender - The address of the spender
11
11
  * @param {String} amount amount of ERC20 Datatokens (always expressed as wei)
12
12
  * @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
13
- * @param {number} tokenDecimals optional number of decimals of the token
14
- * @param {boolean} estimateGas if true, returns the estimate gas cost for calling the method
13
+ * @param {number} [tokenDecimals] optional number of decimals of the token
14
+ * @param {boolean} [estimateGas] if true, returns the estimate gas cost for calling the method
15
15
  */
16
- 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>>;
16
+ export declare function approve<G extends boolean = false>(signer: Signer, config: Config, account: string, tokenAddress: string, spender: string, amount: string, force?: boolean, tokenDecimals?: number, estimateGas?: G): Promise<ReceiptOrDecimal<G> | number>;
17
17
  /**
18
18
  * Approve spender to spent amount tokens
19
- * @param {Web3} web3
20
- * @param {Config} config
21
- * @param {String} account
22
- * @param {String} tokenAddress
23
- * @param {String} spender
24
- * @param {String} amount amount of ERC20 tokens (always expressed as wei)
19
+ * @param {Signer} signer - The signer object
20
+ * @param {Config} config - The config object
21
+ * @param {string} account - The address of the caller
22
+ * @param {string} tokenAddress - The address of the token
23
+ * @param {string} spender - The address of the spender
24
+ * @param {string} amount amount of ERC20 tokens (always expressed as wei)
25
25
  * @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
26
- * @param {boolean} estimateGas if true, returns the estimate gas cost for calling the method
26
+ * @param {boolean} [estimateGas] if true, returns the estimate gas cost for calling the method
27
27
  */
28
- 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>>;
28
+ export declare function approveWei<G extends boolean = false>(signer: Signer, config: Config, account: string, tokenAddress: string, spender: string, amount: string, force?: boolean, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
29
29
  /**
30
30
  * Moves amount tokens from the caller’s account to recipient.
31
- * @param {String} account
32
- * @param {String} tokenAddress
33
- * @param {String} recipient
31
+ * @param {Signer} signer - The signer object
32
+ * @param {Config} config - The config object
33
+ * @param {string} tokenAddress - The address of the token
34
+ * @param {string} recipient - The address of the tokens receiver
34
35
  * @param {String} amount amount of ERC20 Datatokens (not as wei)
35
- * @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
36
+ * @param {String} estimateGas if true returns the gas estimate
36
37
  */
37
- 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>>;
38
+ export declare function transfer<G extends boolean = false>(signer: Signer, config: Config, tokenAddress: string, recipient: string, amount: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
38
39
  /**
39
40
  * Get Allowance for any Datatoken
40
- * @param {Web3} web3
41
- * @param {String } tokenAdress
42
- * @param {String} account
43
- * @param {String} spender
41
+ * @param {Signer} signer - The signer object
42
+ * @param {string} tokenAddress - The address of the token
43
+ * @param {string} account - The address of the caller
44
+ * @param {string} spender - The address of the spender
44
45
  * @param {number} tokenDecimals optional number of decimals of the token
45
46
  */
46
- export declare function allowance(web3: Web3, tokenAddress: string, account: string, spender: string, tokenDecimals?: number): Promise<string>;
47
+ export declare function allowance(signer: Signer, tokenAddress: string, account: string, spender: string, tokenDecimals?: number): Promise<string>;
47
48
  /**
48
49
  * Get balance for any Datatoken
49
- * @param {Web3} web3
50
- * @param {String} tokenAdress
51
- * @param {String} owner
52
- * @param {String} spender
53
- * @param {number} tokenDecimals optional number of decimals of the token
50
+ * @param {Signer} signer - The signer object
51
+ * @param {string} tokenAddress - The address of the token
52
+ * @param {string} account - The address of the caller
53
+ * @param {number} [tokenDecimals] optional number of decimals of the token
54
54
  */
55
- export declare function balance(web3: Web3, tokenAddress: string, account: string, tokenDecimals?: number): Promise<string>;
55
+ export declare function balance(signer: Signer, tokenAddress: string, account: string, tokenDecimals?: number): Promise<string>;
56
56
  /**
57
- * Get Allowance for any erc20
58
- * @param {Web3} web3
59
- * @param {String} tokenAdress
60
- * @param {String} account
61
- * @param {String} spender
57
+ * Get Allowance in wei for any erc20
58
+ * @param {Signer} signer - The signer object
59
+ * @param {string} tokenAddress - The address of the token
60
+ * @param {string} account - The address of the caller
61
+ * @param {string} spender - The address of the spneder
62
62
  */
63
- export declare function allowanceWei(web3: Web3, tokenAddress: string, account: string, spender: string): Promise<string>;
63
+ export declare function allowanceWei(signer: Signer, tokenAddress: string, account: string, spender: string): Promise<string>;
64
64
  /**
65
65
  * Get decimals for any Datatoken
66
- * @param {Web3} web3
67
- * @param {String} tokenAdress
66
+ * @param {Signer} signer - The signer object
67
+ * @param {String} tokenAddress - The address of the token
68
68
  * @return {Promise<number>} Number of decimals of the token
69
69
  */
70
- export declare function decimals(web3: Web3, tokenAddress: string): Promise<number>;
70
+ export declare function decimals(signer: Signer, tokenAddress: string): Promise<number>;
@@ -8,3 +8,4 @@ export * from './Logger';
8
8
  export * from './minAbi';
9
9
  export * from './SignatureUtils';
10
10
  export * from './TokenUtils';
11
+ export * from './ProviderErrors';