@oceanprotocol/lib 3.4.1 → 3.4.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.
- package/CHANGELOG.md +81 -8
- package/CodeExamples.md +31 -11
- package/ComputeExamples.md +7 -3
- package/dist/lib.js +1 -1
- package/dist/lib.js.map +1 -1
- package/dist/lib.modern.js +1 -1
- package/dist/lib.modern.js.map +1 -1
- package/dist/lib.module.js +1 -1
- package/dist/lib.module.js.map +1 -1
- package/dist/lib.umd.js +1 -1
- package/dist/lib.umd.js.map +1 -1
- package/dist/types/@types/Asset.d.ts +148 -0
- package/dist/types/@types/Compute.d.ts +71 -0
- package/dist/types/@types/Contracts.d.ts +26 -0
- package/dist/types/@types/DDO/ConsumerParameter.d.ts +37 -0
- package/dist/types/@types/DDO/Credentials.d.ts +8 -0
- package/dist/types/@types/DDO/DDO.d.ts +55 -0
- package/dist/types/@types/DDO/Event.d.ts +27 -0
- package/dist/types/@types/DDO/Metadata.d.ts +141 -0
- package/dist/types/@types/DDO/Service.d.ts +106 -0
- package/dist/types/@types/Datatoken.d.ts +42 -0
- package/dist/types/@types/Dispenser.d.ts +16 -0
- package/dist/types/@types/DownloadResponse.d.ts +4 -0
- package/dist/types/@types/File.d.ts +89 -0
- package/dist/types/@types/FileInfo.d.ts +43 -0
- package/dist/types/@types/FixedPrice.d.ts +51 -0
- package/dist/types/@types/NFT.d.ts +18 -0
- package/dist/types/@types/NFTFactory.d.ts +20 -0
- package/dist/types/@types/Provider.d.ts +33 -0
- package/dist/types/@types/ReturnTypes.d.ts +3 -0
- package/dist/types/@types/Router.d.ts +59 -0
- package/dist/types/@types/index.d.ts +20 -0
- package/dist/types/config/Config.d.ts +162 -0
- package/dist/types/config/ConfigHelper.d.ts +13 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/contracts/AccessList.d.ts +85 -0
- package/dist/types/contracts/AccessListFactory.d.ts +56 -0
- package/dist/types/contracts/Datatoken.d.ts +278 -0
- package/dist/types/contracts/Datatoken4.d.ts +72 -0
- package/dist/types/contracts/Dispenser.d.ts +73 -0
- package/dist/types/contracts/FixedRateExchange.d.ts +209 -0
- package/dist/types/contracts/NFT.d.ts +227 -0
- package/dist/types/contracts/NFTFactory.d.ts +165 -0
- package/dist/types/contracts/Router.d.ts +107 -0
- package/dist/types/contracts/SmartContract.d.ts +46 -0
- package/dist/types/contracts/SmartContractWithAddress.d.ts +17 -0
- package/dist/types/contracts/df/DfRewards.d.ts +31 -0
- package/dist/types/contracts/df/DfStrategyV1.d.ts +21 -0
- package/dist/types/contracts/index.d.ts +20 -0
- package/dist/types/contracts/ve/VeAllocate.d.ts +38 -0
- package/dist/types/contracts/ve/VeFeeDistributor.d.ts +29 -0
- package/dist/types/contracts/ve/VeFeeEstimate.d.ts +14 -0
- package/dist/types/contracts/ve/VeOcean.d.ts +68 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/services/Aquarius.d.ts +53 -0
- package/dist/types/services/Provider.d.ts +197 -0
- package/dist/types/services/index.d.ts +2 -0
- package/dist/types/utils/Assets.d.ts +56 -0
- package/dist/types/utils/Constants.d.ts +4 -0
- package/dist/types/utils/ContractUtils.d.ts +46 -0
- package/dist/types/utils/DatatokenName.d.ts +14 -0
- package/dist/types/utils/DdoHelpers.d.ts +13 -0
- package/dist/types/utils/FetchHelper.d.ts +14 -0
- package/dist/types/utils/General.d.ts +5 -0
- package/dist/types/utils/Logger.d.ts +19 -0
- package/dist/types/utils/OrderUtils.d.ts +20 -0
- package/dist/types/utils/ProviderErrors.d.ts +1 -0
- package/dist/types/utils/SignatureUtils.d.ts +12 -0
- package/dist/types/utils/TokenUtils.d.ts +70 -0
- package/dist/types/utils/index.d.ts +13 -0
- package/dist/types/utils/minAbi.d.ts +38 -0
- package/package.json +2 -2
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SmartContractWithAddress } from '../SmartContractWithAddress';
|
|
2
|
+
import { ReceiptOrEstimate, AbiItem } from '../../@types';
|
|
3
|
+
/**
|
|
4
|
+
* Provides an interface for veOcean contract
|
|
5
|
+
*/
|
|
6
|
+
export declare class VeAllocate extends SmartContractWithAddress {
|
|
7
|
+
getDefaultAbi(): AbiItem[];
|
|
8
|
+
/**
|
|
9
|
+
* set a specific percentage of veOcean to a specific nft
|
|
10
|
+
* Maximum allocated percentage is 10000, so 1% is specified as 100
|
|
11
|
+
* @param {String} amount Percentage used
|
|
12
|
+
* @param {String} nft NFT address to allocate to
|
|
13
|
+
* @param {String} chainId chainId of NFT
|
|
14
|
+
* @return {Promise<ReceiptOrEstimate>}
|
|
15
|
+
*/
|
|
16
|
+
setAllocation<G extends boolean = false>(amount: string, nft: string, chainId: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
17
|
+
/**
|
|
18
|
+
* set specific percetage of veOcean to multiple nfts
|
|
19
|
+
* Maximum allocated percentage is 10000, so 1% is specified as 100
|
|
20
|
+
* @param {String[]} amount Array of percentages used
|
|
21
|
+
* @param {String[]} nft Array of NFT addresses
|
|
22
|
+
* @param {String[]} chainId Array of chainIds
|
|
23
|
+
* @return {Promise<ReceiptOrEstimate>}
|
|
24
|
+
*/
|
|
25
|
+
setBatchAllocation<G extends boolean = false>(amount: string[], nft: string[], chainId: number[], estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
26
|
+
/** Get totalAllocation for address
|
|
27
|
+
* @param {String} userAddress user address
|
|
28
|
+
* @return {Promise<number>}
|
|
29
|
+
*/
|
|
30
|
+
getTotalAllocation(userAddress: string): Promise<number>;
|
|
31
|
+
/** Get getveAllocation for address, nft, chainId
|
|
32
|
+
* @param {String} userAddress user address
|
|
33
|
+
* @param {String} nft NFT address to allocate to
|
|
34
|
+
* @param {String} chainId chainId of NFT
|
|
35
|
+
* @return {Promise<number>}
|
|
36
|
+
*/
|
|
37
|
+
getVeAllocation(userAddress: string, nft: string, chainId: string): Promise<number>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SmartContractWithAddress } from '../SmartContractWithAddress';
|
|
2
|
+
import { ReceiptOrEstimate, AbiItem } from '../../@types';
|
|
3
|
+
/**
|
|
4
|
+
* Provides an interface for veOcean contract
|
|
5
|
+
*/
|
|
6
|
+
export declare class VeFeeDistributor extends SmartContractWithAddress {
|
|
7
|
+
getDefaultAbi(): AbiItem[];
|
|
8
|
+
/**
|
|
9
|
+
* Claim fees for `userAddress`
|
|
10
|
+
* Each call to claim look at a maximum of 50 user veOCEAN points.
|
|
11
|
+
For accounts with many veOCEAN related actions, this function
|
|
12
|
+
may need to be called more than once to claim all available
|
|
13
|
+
fees. In the `Claimed` event that fires, if `claim_epoch` is
|
|
14
|
+
less than `max_epoch`, the account may claim again
|
|
15
|
+
* @param {Boolean} estimateGas if True, return gas estimate
|
|
16
|
+
* @return {Promise<ReceiptOrEstimate>}
|
|
17
|
+
*/
|
|
18
|
+
claim<G extends boolean = false>(estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
19
|
+
/**
|
|
20
|
+
* Make multiple fee claims in a single call
|
|
21
|
+
Used to claim for many accounts at once, or to make
|
|
22
|
+
multiple claims for the same address when that address
|
|
23
|
+
has significant veOCEAN history
|
|
24
|
+
* @param {String} addresses array of addresses to claim
|
|
25
|
+
* @param {Boolean} estimateGas if True, return gas estimate
|
|
26
|
+
* @return {Promise<ReceiptOrEstimate>}
|
|
27
|
+
*/
|
|
28
|
+
claimMany<G extends boolean = false>(addresses: string[], estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SmartContractWithAddress } from '../SmartContractWithAddress';
|
|
2
|
+
import { AbiItem } from '../../@types';
|
|
3
|
+
/**
|
|
4
|
+
* Provides an interface for veOcean contract
|
|
5
|
+
*/
|
|
6
|
+
export declare class VeFeeEstimate extends SmartContractWithAddress {
|
|
7
|
+
getDefaultAbi(): AbiItem[];
|
|
8
|
+
/**
|
|
9
|
+
* estimateClaim
|
|
10
|
+
* @param {String} userAddress user address
|
|
11
|
+
* @return {Promise<string>}
|
|
12
|
+
*/
|
|
13
|
+
estimateClaim(userAddress: string): Promise<string>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { SmartContractWithAddress } from '../SmartContractWithAddress';
|
|
2
|
+
import { ReceiptOrEstimate, AbiItem } from '../../@types';
|
|
3
|
+
/**
|
|
4
|
+
* Provides an interface for veOcean contract
|
|
5
|
+
*/
|
|
6
|
+
export declare class VeOcean extends SmartContractWithAddress {
|
|
7
|
+
getDefaultAbi(): AbiItem[];
|
|
8
|
+
/**
|
|
9
|
+
* Deposit `amount` tokens for `userAddress` and lock until `unlockTime`
|
|
10
|
+
* @param {String} amount Amount of tokens to be locked
|
|
11
|
+
* @param {Number} unlockTime Timestamp for unlock
|
|
12
|
+
* @param {Boolean} estimateGas if True, return gas estimate
|
|
13
|
+
* @return {Promise<ReceiptOrEstimate>}
|
|
14
|
+
*/
|
|
15
|
+
lockTokens<G extends boolean = false>(amount: string, unlockTime: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
16
|
+
/**
|
|
17
|
+
* Deposit `amount` tokens for `toAddress` and add to the existing lock
|
|
18
|
+
* Anyone (even a smart contract) can deposit for someone else, but cannot extend their locktime and deposit for a brand new user
|
|
19
|
+
* @param {String} toAddress user address to deposit for
|
|
20
|
+
* @param {String} amount Amount of tokens to be locked
|
|
21
|
+
* @param {Boolean} estimateGas if True, return gas estimate
|
|
22
|
+
* @return {Promise<ReceiptOrEstimate>}
|
|
23
|
+
*/
|
|
24
|
+
depositFor<G extends boolean = false>(toAddress: string, amount: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
25
|
+
/**
|
|
26
|
+
* Deposit `amount` additional tokens for `userAddress` without modifying the unlock time
|
|
27
|
+
* @param {String} amount Amount of tokens to be locked
|
|
28
|
+
* @param {Boolean} estimateGas if True, return gas estimate
|
|
29
|
+
* @return {Promise<ReceiptOrEstimate>}
|
|
30
|
+
*/
|
|
31
|
+
increaseAmount<G extends boolean = false>(amount: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
32
|
+
/**
|
|
33
|
+
* Extend the unlock time for `userAddress` to `unlockTime`
|
|
34
|
+
* @param {Number} unlockTime Timestamp for new unlock time
|
|
35
|
+
* @param {Boolean} estimateGas if True, return gas estimate
|
|
36
|
+
* @return {Promise<ReceiptOrEstimate>}
|
|
37
|
+
*/
|
|
38
|
+
increaseUnlockTime<G extends boolean = false>(unlockTime: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
39
|
+
/**
|
|
40
|
+
* Withdraw all tokens for `userAddress`
|
|
41
|
+
* @param {Boolean} estimateGas if True, return gas estimate
|
|
42
|
+
* @return {Promise<ReceiptOrEstimate>}
|
|
43
|
+
*/
|
|
44
|
+
withdraw<G extends boolean = false>(estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
45
|
+
/** Get voting power for address
|
|
46
|
+
* @param {String} userAddress user address
|
|
47
|
+
* @return {Promise<number>}
|
|
48
|
+
*/
|
|
49
|
+
getVotingPower(userAddress: string): Promise<number>;
|
|
50
|
+
/** Get locked balance
|
|
51
|
+
* @param {String} userAddress user address
|
|
52
|
+
* @return {Promise<string>}
|
|
53
|
+
*/
|
|
54
|
+
getLockedAmount(userAddress: string): Promise<string>;
|
|
55
|
+
/** Get untilLock for address
|
|
56
|
+
* @param {String} userAddress user address
|
|
57
|
+
* @return {Promise<number>}
|
|
58
|
+
*/
|
|
59
|
+
lockEnd(userAddress: string): Promise<number>;
|
|
60
|
+
/** Get total supply
|
|
61
|
+
* @return {Promise<number>}
|
|
62
|
+
*/
|
|
63
|
+
totalSupply(): Promise<string>;
|
|
64
|
+
/** Get token
|
|
65
|
+
* @return {Promise<string>}
|
|
66
|
+
*/
|
|
67
|
+
getToken(): Promise<string>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Asset, DDO, ValidateMetadata } from '../@types';
|
|
2
|
+
export interface SearchQuery {
|
|
3
|
+
from?: number;
|
|
4
|
+
size?: number;
|
|
5
|
+
query: any;
|
|
6
|
+
sort?: {
|
|
7
|
+
[jsonPath: string]: string;
|
|
8
|
+
};
|
|
9
|
+
aggs?: any;
|
|
10
|
+
}
|
|
11
|
+
export declare class Aquarius {
|
|
12
|
+
aquariusURL: string;
|
|
13
|
+
/**
|
|
14
|
+
* Instantiate Aquarius
|
|
15
|
+
* @param {String} aquariusURL
|
|
16
|
+
*/
|
|
17
|
+
constructor(aquariusURL: string);
|
|
18
|
+
/** Resolves a DID
|
|
19
|
+
* @param {string} did DID of the asset.
|
|
20
|
+
* @param {AbortSignal} signal abort signal
|
|
21
|
+
* @return {Promise<Asset>} Asset
|
|
22
|
+
*/
|
|
23
|
+
resolve(did: string, signal?: AbortSignal): Promise<Asset>;
|
|
24
|
+
/**
|
|
25
|
+
* Blocks until Aqua will cache the did (or the update for that did) or timeouts
|
|
26
|
+
* @param {string} did DID of the asset.
|
|
27
|
+
* @param {string} txid used when the did exists and we expect an update with that txid.
|
|
28
|
+
* @param {AbortSignal} signal abort signal
|
|
29
|
+
* @return {Promise<Asset>} DDO of the asset.
|
|
30
|
+
*/
|
|
31
|
+
waitForAqua(did: string, txid?: string, signal?: AbortSignal): Promise<Asset>;
|
|
32
|
+
/**
|
|
33
|
+
* Validate DDO content
|
|
34
|
+
* @param {DDO} ddo DID Descriptor Object content.
|
|
35
|
+
* @param {AbortSignal} signal abort signal
|
|
36
|
+
* @return {Promise<ValidateMetadata>}.
|
|
37
|
+
*/
|
|
38
|
+
validate(ddo: DDO, signal?: AbortSignal): Promise<ValidateMetadata>;
|
|
39
|
+
/**
|
|
40
|
+
* Search over the DDOs using a query.
|
|
41
|
+
* @param {string} did DID of the asset
|
|
42
|
+
* @param {AbortSignal} signal abort signal
|
|
43
|
+
* @return {Promise<QueryResult>}
|
|
44
|
+
*/
|
|
45
|
+
getAssetMetadata(did: string, signal?: AbortSignal): Promise<any>;
|
|
46
|
+
/**
|
|
47
|
+
* Search over the DDOs using a query.
|
|
48
|
+
* @param {SearchQuery} query Query to filter the DDOs.
|
|
49
|
+
* @param {AbortSignal} signal abort signal
|
|
50
|
+
* @return {Promise<QueryResult>}
|
|
51
|
+
*/
|
|
52
|
+
querySearch(query: SearchQuery, signal?: AbortSignal): Promise<any>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { Signer } from 'ethers';
|
|
2
|
+
import { Arweave, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, ServiceEndpoint, UrlFile, UserCustomParameters, Ipfs, Smartcontract, GraphqlQuery } from '../@types';
|
|
3
|
+
export declare class Provider {
|
|
4
|
+
/**
|
|
5
|
+
* Returns the provider endpoints
|
|
6
|
+
* @param {string} providerUri - the provider url
|
|
7
|
+
* @return {Promise<any>}
|
|
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
|
+
*/
|
|
16
|
+
getEndpointURL(servicesEndpoints: ServiceEndpoint[], serviceName: string): ServiceEndpoint;
|
|
17
|
+
/**
|
|
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
|
|
22
|
+
*/
|
|
23
|
+
getServiceEndpoints(providerEndpoint: string, endpoints: any): Promise<ServiceEndpoint[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Get current nonce from the provider.
|
|
26
|
+
* @param {string} providerUri provider uri address
|
|
27
|
+
* @param {string} consumerAddress Publisher address
|
|
28
|
+
* @param {AbortSignal} signal abort signal
|
|
29
|
+
* @param {string} providerEndpoints Identifier of the asset to be registered in ocean
|
|
30
|
+
* @param {string} serviceEndpoints document description object (DDO)=
|
|
31
|
+
* @return {Promise<string>} urlDetails
|
|
32
|
+
*/
|
|
33
|
+
getNonce(providerUri: string, consumerAddress: string, signal?: AbortSignal, providerEndpoints?: any, serviceEndpoints?: ServiceEndpoint[]): Promise<number>;
|
|
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
|
|
43
|
+
* @param {string} data data in json format that needs to be sent , it can either be a DDO or a File array
|
|
44
|
+
* @param {number} chainId network's id so provider can choose the corresponding Signer object
|
|
45
|
+
* @param {string} providerUri provider uri address
|
|
46
|
+
* @param {AbortSignal} signal abort signal
|
|
47
|
+
* @return {Promise<string>} urlDetails
|
|
48
|
+
*/
|
|
49
|
+
encrypt(data: any, chainId: number, providerUri: string, signal?: AbortSignal): Promise<string>;
|
|
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.
|
|
58
|
+
*/
|
|
59
|
+
checkDidFiles(did: string, serviceId: string, providerUri: string, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Get File details (if possible)
|
|
62
|
+
* @param {UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract} file one of the supported file structures
|
|
63
|
+
* @param {string} providerUri uri of the provider that will be used to check the file
|
|
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.
|
|
67
|
+
*/
|
|
68
|
+
getFileInfo(file: UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract, providerUri: string, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
|
|
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.
|
|
90
|
+
*/
|
|
91
|
+
initialize(did: string, serviceId: string, fileIndex: number, consumerAddress: string, providerUri: string, signal?: AbortSignal, userCustomParameters?: UserCustomParameters, computeEnv?: string, validUntil?: number): Promise<ProviderInitialize>;
|
|
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
|
|
99
|
+
* @param {AbortSignal} signal abort signal
|
|
100
|
+
* @return {Promise<ProviderComputeInitialize>} ProviderComputeInitialize data
|
|
101
|
+
*/
|
|
102
|
+
initializeCompute(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, validUntil: number, providerUri: string, accountId: string, signal?: AbortSignal): Promise<ProviderComputeInitializeResults>;
|
|
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>;
|
|
115
|
+
/** Instruct the provider to start a compute job
|
|
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.
|
|
121
|
+
* @param {AbortSignal} signal abort signal
|
|
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.
|
|
125
|
+
*/
|
|
126
|
+
computeStart(providerUri: string, consumer: Signer, computeEnv: string, dataset: ComputeAsset, algorithm: ComputeAlgorithm, signal?: AbortSignal, additionalDatasets?: ComputeAsset[], output?: ComputeOutput): Promise<ComputeJob | ComputeJob[]>;
|
|
127
|
+
/** Instruct the provider to Stop the execution of a to stop a compute job.
|
|
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.
|
|
133
|
+
* @param {AbortSignal} signal abort signal
|
|
134
|
+
* @return {Promise<ComputeJob | ComputeJob[]>}
|
|
135
|
+
*/
|
|
136
|
+
computeStop(did: string, consumerAddress: string, jobId: string, providerUri: string, signer: Signer, agreementId?: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
137
|
+
/** Get compute status for a specific jobId/documentId/owner.
|
|
138
|
+
* @param {string} providerUri The URI of the provider we want to query
|
|
139
|
+
* @param {string} consumerAddress The consumer ethereum address
|
|
140
|
+
* @param {string} jobId The ID of a compute job.
|
|
141
|
+
* @param {string} agreementId The ID of the service agreement (tx id)
|
|
142
|
+
* @param {AbortSignal} signal abort signal
|
|
143
|
+
* @return {Promise<ComputeJob | ComputeJob[]>}
|
|
144
|
+
*/
|
|
145
|
+
computeStatus(providerUri: string, consumerAddress: string, jobId?: string, agreementId?: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
146
|
+
/** Get compute result url
|
|
147
|
+
* @param {string} providerUri The URI of the provider we want to query
|
|
148
|
+
* @param {Signer} consumer consumer Signer wallet object
|
|
149
|
+
* @param {string} jobId The ID of a compute job.
|
|
150
|
+
* @param {number} index Result index
|
|
151
|
+
* @return {Promise<string>}
|
|
152
|
+
*/
|
|
153
|
+
getComputeResultUrl(providerUri: string, consumer: Signer, jobId: string, index: number): Promise<string>;
|
|
154
|
+
/** Deletes a compute job.
|
|
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
|
|
159
|
+
* @param {AbortSignal} signal abort signal
|
|
160
|
+
* @return {Promise<ComputeJob | ComputeJob[]>}
|
|
161
|
+
*/
|
|
162
|
+
computeDelete(did: string, consumer: Signer, jobId: string, providerUri: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
163
|
+
/** Check for a valid provider at URL
|
|
164
|
+
* @param {String} url provider uri address
|
|
165
|
+
* @param {AbortSignal} signal abort signal
|
|
166
|
+
* @return {Promise<boolean>} valid or not
|
|
167
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
195
|
+
private getData;
|
|
196
|
+
}
|
|
197
|
+
export declare const ProviderInstance: Provider;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Signer } from 'ethers';
|
|
2
|
+
import { Aquarius } from '../services/Aquarius';
|
|
3
|
+
export declare const DEVELOPMENT_CHAIN_ID = 8996;
|
|
4
|
+
export declare function useOasisSDK(network: string | number): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Get the artifacts address from the address.json file
|
|
7
|
+
* either from the env or from the ocean-contracts dir
|
|
8
|
+
* @returns data or null
|
|
9
|
+
*/
|
|
10
|
+
export declare function getOceanArtifactsAdresses(): any;
|
|
11
|
+
/**
|
|
12
|
+
* Get the artifacts address from the address.json file, for the given chain
|
|
13
|
+
* either from the env or from the ocean-contracts dir, safer than above, because sometimes the network name
|
|
14
|
+
* is mispeled, best example "optimism_sepolia" vs "optimism-sepolia"
|
|
15
|
+
* @returns data or null
|
|
16
|
+
*/
|
|
17
|
+
export declare function getOceanArtifactsAdressesByChainId(chain: number): any;
|
|
18
|
+
/**
|
|
19
|
+
* Use this function to accurately calculate the template index, and also checking if the template is active
|
|
20
|
+
* @param owner the signer account
|
|
21
|
+
* @param nftContractAddress the nft contract address, usually artifactsAddresses.ERC721Factory
|
|
22
|
+
* @param template the template ID or template address (from smart contract getId() function)
|
|
23
|
+
* @returns index of the template on the list
|
|
24
|
+
*/
|
|
25
|
+
export declare function calculateActiveTemplateIndex(owner: Signer, nftContractAddress: string, // addresses.ERC721Factory,
|
|
26
|
+
template: string | number): Promise<number>;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param name asset name
|
|
30
|
+
* @param symbol asse symbol
|
|
31
|
+
* @param owner owner address
|
|
32
|
+
* @param assetUrl asset url, if present and confidential evm, add it to token create params
|
|
33
|
+
* @param templateIDorAddress either template address or id
|
|
34
|
+
* @param ddo ddo
|
|
35
|
+
* @param encryptDDO encrypt or not?
|
|
36
|
+
* @param providerUrl the provider URL
|
|
37
|
+
* @param providerFeeToken the provider fee token
|
|
38
|
+
* @param aquariusInstance aquarius, could be node instance url
|
|
39
|
+
* @param allowAccessList?: string,
|
|
40
|
+
* @param denyAccessList?: string
|
|
41
|
+
* @returns ddo id as string
|
|
42
|
+
*/
|
|
43
|
+
export declare function createAsset(name: string, symbol: string, owner: Signer, assetUrl: any, // files object
|
|
44
|
+
templateIDorAddress: string | number, // If string, it's template address , otherwise, it's templateId
|
|
45
|
+
ddo: any, encryptDDO: boolean, // default is true
|
|
46
|
+
providerUrl: string, providerFeeToken: string, aquariusInstance: Aquarius, accessListFactory?: string, // access list factory address
|
|
47
|
+
allowAccessList?: string, // allow list address
|
|
48
|
+
denyAccessList?: string): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* deploy new access list factory if needed
|
|
51
|
+
* @param accessListFactory accessListFactory address
|
|
52
|
+
* @param owner owner account
|
|
53
|
+
* @param addressesList list of addresses to deploy
|
|
54
|
+
* @returns accessListFactory address
|
|
55
|
+
*/
|
|
56
|
+
export declare function createAccessListFactory(accessListFactory: string, owner: Signer, addressesList?: string[]): Promise<any>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
2
|
+
export declare const GASLIMIT_DEFAULT = 1000000;
|
|
3
|
+
export declare const MAX_UINT_256 = "115792089237316195423570985008687907853269984665640564039457584007913129639934";
|
|
4
|
+
export declare const FEE_HISTORY_NOT_SUPPORTED = "Returned error: Method eth_feeHistory not supported.";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Signer, providers, Contract, ContractFunction, BigNumber } from 'ethers';
|
|
2
|
+
import { Config } from '../config';
|
|
3
|
+
export declare function setContractDefaults(contract: Contract, config: Config): Contract;
|
|
4
|
+
/**
|
|
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
|
|
34
|
+
*/
|
|
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;
|
|
37
|
+
/**
|
|
38
|
+
* Send the transation on chain
|
|
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
|
|
42
|
+
* @param {Function} functionToSend function that we need to send
|
|
43
|
+
* @param {...any[]} args arguments of the function
|
|
44
|
+
* @return {Promise<any>} transaction receipt
|
|
45
|
+
*/
|
|
46
|
+
export declare function sendTx(estGas: BigNumber, signer: Signer, gasFeeMultiplier: number, functionToSend: ContractFunction, ...args: any[]): Promise<providers.TransactionResponse>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
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"
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateDtName(wordList?: {
|
|
9
|
+
nouns: string[];
|
|
10
|
+
adjectives: string[];
|
|
11
|
+
}): {
|
|
12
|
+
name: string;
|
|
13
|
+
symbol: string;
|
|
14
|
+
};
|
|
@@ -0,0 +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
|
+
*/
|
|
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
|
+
*/
|
|
13
|
+
export declare function getHash(data: any): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
*/
|
|
7
|
+
export declare function downloadFileBrowser(url: string): 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
|
+
*/
|
|
14
|
+
export declare function downloadFile(url: string, index?: number): Promise<DownloadResponse>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
None = -1,
|
|
3
|
+
Error = 0,
|
|
4
|
+
Warn = 1,
|
|
5
|
+
Log = 2,
|
|
6
|
+
Verbose = 3
|
|
7
|
+
}
|
|
8
|
+
export declare class Logger {
|
|
9
|
+
private logLevel?;
|
|
10
|
+
constructor(logLevel?: LogLevel);
|
|
11
|
+
setLevel(logLevel: LogLevel): void;
|
|
12
|
+
bypass(...args: any[]): void;
|
|
13
|
+
debug(...args: any[]): void;
|
|
14
|
+
log(...args: any[]): void;
|
|
15
|
+
warn(...args: any[]): void;
|
|
16
|
+
error(...args: any[]): void;
|
|
17
|
+
private dispatch;
|
|
18
|
+
}
|
|
19
|
+
export declare const LoggerInstance: Logger;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Signer } from 'ethers';
|
|
2
|
+
import { Datatoken, Config, Asset, ConsumeMarketFee, ProviderFees } from '../index';
|
|
3
|
+
/**
|
|
4
|
+
* Orders an asset based on the specified pricing schema and configuration.
|
|
5
|
+
* @param {Asset} asset - The asset to be ordered.
|
|
6
|
+
* @param {Signer} consumerAccount - The signer account of the consumer.
|
|
7
|
+
* @param {Config} config - The configuration settings.
|
|
8
|
+
* @param {Datatoken} datatoken - The Datatoken instance.
|
|
9
|
+
* @param {string} [providerUrl] - Optional the consumer address
|
|
10
|
+
* @param {string} [consumerAccount] - Optional the consumer address
|
|
11
|
+
* @param {ConsumeMarketFee} [consumeMarketOrderFee] - Optional consume market fee.
|
|
12
|
+
* @param {ProviderFees} [providerFees] - Optional provider fees
|
|
13
|
+
* @param {string} [consumeMarketFixedSwapFee='0'] - Fixed swap fee for consuming the market.
|
|
14
|
+
* @param {number} [datatokenIndex=0] - Index of the datatoken within the asset.
|
|
15
|
+
* @param {number} [serviceIndex=0] - Index of the service within the asset.
|
|
16
|
+
* @param {number} [fixedRateIndex=0] - Index of the fixed rate within the pricing schema.
|
|
17
|
+
* @returns {Promise<void>} - A promise that resolves when the asset order process is completed.
|
|
18
|
+
* @throws {Error} If the pricing schema is not supported or if required indexes are invalid.
|
|
19
|
+
*/
|
|
20
|
+
export declare function orderAsset(asset: Asset, consumerAccount: Signer, config: Config, datatoken: Datatoken, providerUrl?: string, consumerAddress?: string, consumeMarketOrderFee?: ConsumeMarketFee, providerFees?: ProviderFees, consumeMarketFixedSwapFee?: string, datatokenIndex?: number, serviceIndex?: number, fixedRateIndex?: number): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getErrorMessage(err: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
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<{
|
|
9
|
+
v: string;
|
|
10
|
+
r: string;
|
|
11
|
+
s: string;
|
|
12
|
+
}>;
|