@oceanprotocol/lib 4.0.2 → 4.1.0
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 +55 -4
- package/CodeExamples.md +41 -17
- package/ComputeExamples.md +300 -49
- package/dist/lib.cjs +1 -1
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.modern.js +1 -1
- package/dist/lib.modern.js.map +1 -1
- package/dist/lib.module.mjs +1 -1
- package/dist/lib.module.mjs.map +1 -1
- package/dist/lib.umd.js +1 -1
- package/dist/lib.umd.js.map +1 -1
- package/dist/types/@types/Compute.d.ts +10 -1
- package/dist/types/@types/File.d.ts +1 -42
- package/dist/types/@types/NFT.d.ts +1 -1
- package/dist/types/@types/Provider.d.ts +9 -0
- package/dist/types/@types/index.d.ts +0 -7
- package/dist/types/config/Config.d.ts +2 -12
- package/dist/types/contracts/Datatoken.d.ts +9 -0
- package/dist/types/contracts/Escrow.d.ts +93 -0
- package/dist/types/contracts/NFT.d.ts +2 -1
- package/dist/types/services/Aquarius.d.ts +1 -1
- package/dist/types/services/Provider.d.ts +8 -6
- package/dist/types/utils/Assets.d.ts +2 -1
- package/dist/types/utils/OrderUtils.d.ts +1 -1
- package/package.json +6 -5
- package/dist/types/@types/Asset.d.ts +0 -148
- package/dist/types/@types/DDO/ConsumerParameter.d.ts +0 -37
- package/dist/types/@types/DDO/Credentials.d.ts +0 -8
- package/dist/types/@types/DDO/DDO.d.ts +0 -55
- package/dist/types/@types/DDO/Event.d.ts +0 -27
- package/dist/types/@types/DDO/Metadata.d.ts +0 -141
- package/dist/types/@types/DDO/Service.d.ts +0 -106
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Metadata, MetadataAlgorithm } from '
|
|
1
|
+
import { Metadata, MetadataAlgorithm } from '@oceanprotocol/ddo-js';
|
|
2
2
|
export type ComputeResultType = 'algorithmLog' | 'output' | 'configrationLog' | 'publishLog';
|
|
3
3
|
export interface RunningPlatform {
|
|
4
4
|
architecture: string;
|
|
@@ -132,3 +132,12 @@ export interface ComputeAlgorithm {
|
|
|
132
132
|
[key: string]: any;
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
|
+
export interface ComputePayment {
|
|
136
|
+
chainId: number;
|
|
137
|
+
token: string;
|
|
138
|
+
maxJobDuration: number;
|
|
139
|
+
}
|
|
140
|
+
export interface ValidationResponse {
|
|
141
|
+
isValid: boolean;
|
|
142
|
+
message: string;
|
|
143
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AbiItem } from './Contracts.js';
|
|
2
1
|
interface FileTypeHeaders {
|
|
3
2
|
[key: string]: string;
|
|
4
3
|
}
|
|
@@ -25,28 +24,6 @@ export interface UrlFile {
|
|
|
25
24
|
*/
|
|
26
25
|
headers?: FileTypeHeaders;
|
|
27
26
|
}
|
|
28
|
-
export interface GraphqlQuery {
|
|
29
|
-
type: 'graphql';
|
|
30
|
-
/**
|
|
31
|
-
* @type {number}
|
|
32
|
-
*/
|
|
33
|
-
index?: number;
|
|
34
|
-
/**
|
|
35
|
-
* Endpoint URL
|
|
36
|
-
* @type {string}
|
|
37
|
-
*/
|
|
38
|
-
url: string;
|
|
39
|
-
/**
|
|
40
|
-
* query
|
|
41
|
-
* @type {string}
|
|
42
|
-
*/
|
|
43
|
-
query: string;
|
|
44
|
-
/**
|
|
45
|
-
* Headers key value pairs associated with the asset GET request
|
|
46
|
-
* @type {string}
|
|
47
|
-
*/
|
|
48
|
-
headers?: FileTypeHeaders;
|
|
49
|
-
}
|
|
50
27
|
export interface Arweave {
|
|
51
28
|
type: 'arweave';
|
|
52
29
|
/**
|
|
@@ -63,27 +40,9 @@ export interface Ipfs {
|
|
|
63
40
|
*/
|
|
64
41
|
hash: string;
|
|
65
42
|
}
|
|
66
|
-
export interface Smartcontract {
|
|
67
|
-
type: 'smartcontract';
|
|
68
|
-
/**
|
|
69
|
-
* Smartcontract address
|
|
70
|
-
* @type {string}
|
|
71
|
-
*/
|
|
72
|
-
address: string;
|
|
73
|
-
/**
|
|
74
|
-
* ChainId
|
|
75
|
-
* @type {number}
|
|
76
|
-
*/
|
|
77
|
-
chainId: number;
|
|
78
|
-
/**
|
|
79
|
-
* Function ABI (not the entire smartcontract abi)
|
|
80
|
-
* @type {AbiItem}
|
|
81
|
-
*/
|
|
82
|
-
abi: AbiItem;
|
|
83
|
-
}
|
|
84
43
|
export interface Files {
|
|
85
44
|
nftAddress: string;
|
|
86
45
|
datatokenAddress: string;
|
|
87
|
-
files: UrlFile[] |
|
|
46
|
+
files: UrlFile[] | Arweave[] | Ipfs[];
|
|
88
47
|
}
|
|
89
48
|
export {};
|
|
@@ -19,9 +19,18 @@ export interface ProviderComputeInitialize {
|
|
|
19
19
|
validOrder?: string;
|
|
20
20
|
providerFee?: ProviderFees;
|
|
21
21
|
}
|
|
22
|
+
export interface ProviderComputeInitializePayment {
|
|
23
|
+
escrowAddress: string;
|
|
24
|
+
chainId: number;
|
|
25
|
+
payee: string;
|
|
26
|
+
token: string;
|
|
27
|
+
amount: number;
|
|
28
|
+
minLockSeconds: number;
|
|
29
|
+
}
|
|
22
30
|
export interface ProviderComputeInitializeResults {
|
|
23
31
|
algorithm?: ProviderComputeInitialize;
|
|
24
32
|
datasets?: ProviderComputeInitialize[];
|
|
33
|
+
payment?: ProviderComputeInitializePayment;
|
|
25
34
|
}
|
|
26
35
|
export interface ServiceEndpoint {
|
|
27
36
|
serviceName: string;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export * from './DDO/Credentials.js';
|
|
2
|
-
export * from './DDO/DDO.js';
|
|
3
|
-
export * from './DDO/Event.js';
|
|
4
|
-
export * from './DDO/Metadata.js';
|
|
5
|
-
export * from './DDO/ConsumerParameter.js';
|
|
6
|
-
export * from './DDO/Service.js';
|
|
7
|
-
export * from './Asset.js';
|
|
8
1
|
export * from './Contracts.js';
|
|
9
2
|
export * from './File.js';
|
|
10
3
|
export * from './FileInfo.js';
|
|
@@ -13,15 +13,10 @@ export declare class Config {
|
|
|
13
13
|
*/
|
|
14
14
|
providerAddress?: string;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Ocean Node URL.
|
|
17
17
|
* @type {string}
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Provider URL.
|
|
22
|
-
* @type {string}
|
|
23
|
-
*/
|
|
24
|
-
providerUri?: string;
|
|
19
|
+
oceanNodeUri?: string;
|
|
25
20
|
/**
|
|
26
21
|
* Web3 Provider.
|
|
27
22
|
* @type {any}
|
|
@@ -113,11 +108,6 @@ export declare class Config {
|
|
|
113
108
|
* @type {string}
|
|
114
109
|
*/
|
|
115
110
|
network: string;
|
|
116
|
-
/**
|
|
117
|
-
* Url of the relevant subgraph instance ex: https://subgraph.mainnet.oceanprotocol.com
|
|
118
|
-
* @type {string}
|
|
119
|
-
*/
|
|
120
|
-
subgraphUri: string;
|
|
121
111
|
/**
|
|
122
112
|
* Url of the blockchain exporer ex: https://etherscan.io
|
|
123
113
|
* @type {string}
|
|
@@ -257,6 +257,15 @@ export declare class Datatoken extends SmartContract {
|
|
|
257
257
|
* @return {Promise<String>} balance Number of datatokens. Will be converted from wei
|
|
258
258
|
*/
|
|
259
259
|
balance(datatokenAddress: string, address: string): Promise<string>;
|
|
260
|
+
/**
|
|
261
|
+
* Get Address Allowance for datatoken
|
|
262
|
+
* @param {String} dtAddress Datatoken adress
|
|
263
|
+
* @param {String} owner owner adress
|
|
264
|
+
* @param {String} spender spender adress
|
|
265
|
+
* @param {Number} decimals numer of token decimals, default 18
|
|
266
|
+
* @return {Promise<String>} allowance Number of datatokens. Will be converted from wei
|
|
267
|
+
*/
|
|
268
|
+
allowance(datatokenAddress: string, owner: string, spender: string, decimals?: number): Promise<string>;
|
|
260
269
|
/**
|
|
261
270
|
* Allows to set the fee required by the publisherMarket
|
|
262
271
|
* only publishMarketFeeAddress can call it
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Signer } from 'ethers';
|
|
2
|
+
import { AbiItem, ReceiptOrEstimate, ValidationResponse } from '../@types';
|
|
3
|
+
import { Config } from '../config';
|
|
4
|
+
import { SmartContractWithAddress } from './SmartContractWithAddress';
|
|
5
|
+
export declare class EscrowContract extends SmartContractWithAddress {
|
|
6
|
+
abiEnterprise: AbiItem[];
|
|
7
|
+
getDefaultAbi(): AbiItem[];
|
|
8
|
+
/**
|
|
9
|
+
* Instantiate AccessList class
|
|
10
|
+
* @param {string} address The contract address.
|
|
11
|
+
* @param {Signer} signer The signer object.
|
|
12
|
+
* @param {string | number} [network] Network id or name
|
|
13
|
+
* @param {Config} [config] The configuration object.
|
|
14
|
+
* @param {AbiItem[]} [abi] ABI array of the smart contract
|
|
15
|
+
* @param {AbiItem[]} abiEnterprise Enterprise ABI array of the smart contract
|
|
16
|
+
*/
|
|
17
|
+
constructor(address: string, signer: Signer, network?: string | number, config?: Config, abi?: AbiItem[]);
|
|
18
|
+
/**
|
|
19
|
+
* Get Funds
|
|
20
|
+
* @return {Promise<any>} Funds
|
|
21
|
+
*/
|
|
22
|
+
getFunds(token: string): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Get User Funds
|
|
25
|
+
* @return {Promise<any>} User funds
|
|
26
|
+
*/
|
|
27
|
+
getUserFunds(payer: string, token: string): Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Get Locks
|
|
30
|
+
* @return {Promise<[]>} Locks
|
|
31
|
+
*/
|
|
32
|
+
getLocks(token: string, payer: string, payee: string): Promise<any[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Get Authorizations
|
|
35
|
+
* @return {Promise<[]>} Authorizations
|
|
36
|
+
*/
|
|
37
|
+
getAuthorizations(token: string, payer: string, payee: string): Promise<any[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Checks funds for escrow payment.
|
|
40
|
+
* Does authorization when needed.
|
|
41
|
+
* Does deposit when needed.
|
|
42
|
+
* @param {String} token as payment token for escrow
|
|
43
|
+
* @param {String} consumerAddress as consumerAddress for that environment
|
|
44
|
+
* @param {String} amountToDeposit wanted amount for escrow lock deposit. If this is
|
|
45
|
+
* not provided and funds for escrow are 0 -> fallback to maxLockedAmount, else
|
|
46
|
+
* use balance of payment token.
|
|
47
|
+
* @param {String} maxLockedAmount amount necessary to be paid for starting compute job,
|
|
48
|
+
* returned from initialize compute payment and used for authorize if needed.
|
|
49
|
+
* @param {String} maxLockSeconds max seconds to lock the payment,
|
|
50
|
+
* returned from initialize compute payment and used for authorize if needed.
|
|
51
|
+
* @param {String} maxLockCounts max lock counts,
|
|
52
|
+
* returned from initialize compute payment and used for authorize if needed.
|
|
53
|
+
* @return {Promise<ValidationResponse>} validation response
|
|
54
|
+
*/
|
|
55
|
+
verifyFundsForEscrowPayment(token: string, consumerAddress: string, amountToDeposit?: string, maxLockedAmount?: string, maxLockSeconds?: string, maxLockCounts?: string): Promise<ValidationResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Deposit funds
|
|
58
|
+
* @param {String} token Token address
|
|
59
|
+
* @param {String} amount amount
|
|
60
|
+
* @param {Boolean} estimateGas if True, return gas estimate
|
|
61
|
+
* @return {Promise<ReceiptOrEstimate>} returns the transaction receipt or the estimateGas value
|
|
62
|
+
*/
|
|
63
|
+
deposit<G extends boolean = false>(token: string, amount: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
64
|
+
/**
|
|
65
|
+
* Withdraw funds
|
|
66
|
+
* @param {String[]} tokens Array of token addresses
|
|
67
|
+
* @param {String[]} amounts Array of token amounts
|
|
68
|
+
* @param {Boolean} estimateGas if True, return gas estimate
|
|
69
|
+
* @return {Promise<ReceiptOrEstimate>} returns the transaction receipt or the estimateGas value
|
|
70
|
+
*/
|
|
71
|
+
withdraw<G extends boolean = false>(tokens: string[], amounts: string[], estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
72
|
+
/**
|
|
73
|
+
* Authorize locks
|
|
74
|
+
* @param {String} token Token address
|
|
75
|
+
* @param {String} payee,
|
|
76
|
+
* @param {String} maxLockedAmount,
|
|
77
|
+
* @param {String} maxLockSeconds,
|
|
78
|
+
* @param {String} maxLockCounts,
|
|
79
|
+
* @param {Boolean} estimateGas if True, return gas estimate
|
|
80
|
+
* @return {Promise<ReceiptOrEstimate>} returns the transaction receipt or the estimateGas value
|
|
81
|
+
*/
|
|
82
|
+
authorize<G extends boolean = false>(token: string, payee: string, maxLockedAmount: string, maxLockSeconds: string, maxLockCounts: string, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
83
|
+
/**
|
|
84
|
+
* Cancel expired locks
|
|
85
|
+
* @param {String} jobId Job ID with hash
|
|
86
|
+
* @param {String} token Token address
|
|
87
|
+
* @param {String} payee, Payee address for the compute job,
|
|
88
|
+
* @param {String} payer, Payer address for the compute job
|
|
89
|
+
* @param {Boolean} estimateGas if True, return gas estimate
|
|
90
|
+
* @return {Promise<ReceiptOrEstimate>} returns the transaction receipt or the estimateGas value
|
|
91
|
+
*/
|
|
92
|
+
cancelExpiredLocks<G extends boolean = false>(jobIds: string[], tokens: string[], payers: string[], payees: string[], estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
93
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers';
|
|
2
|
-
import {
|
|
2
|
+
import { MetadataAndTokenURI, NftRoles, ReceiptOrEstimate, AbiItem } from '../@types/index.js';
|
|
3
3
|
import { SmartContract } from './SmartContract.js';
|
|
4
|
+
import { MetadataProof } from '@oceanprotocol/ddo-js';
|
|
4
5
|
export declare class Nft extends SmartContract {
|
|
5
6
|
getDefaultAbi(): AbiItem[];
|
|
6
7
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { Arweave, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, ServiceEndpoint, UrlFile, UserCustomParameters, Ipfs,
|
|
2
|
+
import { Arweave, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, ServiceEndpoint, UrlFile, UserCustomParameters, Ipfs, ComputeResourceRequest } from '../@types';
|
|
3
3
|
export declare class Provider {
|
|
4
4
|
/**
|
|
5
5
|
* Returns the provider endpoints
|
|
@@ -65,7 +65,7 @@ export declare class Provider {
|
|
|
65
65
|
* @param {AbortSignal} [signal] - An optional abort signal.
|
|
66
66
|
* @returns {Promise<FileInfo[]>} A promise that resolves with an array of file info objects.
|
|
67
67
|
*/
|
|
68
|
-
getFileInfo(file: UrlFile | Arweave | Ipfs
|
|
68
|
+
getFileInfo(file: UrlFile | Arweave | Ipfs, providerUri: string, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
|
|
69
69
|
/**
|
|
70
70
|
* Returns compute environments from a provider.
|
|
71
71
|
* @param {string} providerUri - The URI of the provider.
|
|
@@ -97,18 +97,19 @@ export declare class Provider {
|
|
|
97
97
|
* @param {AbortSignal} signal abort signal
|
|
98
98
|
* @return {Promise<ProviderComputeInitialize>} ProviderComputeInitialize data
|
|
99
99
|
*/
|
|
100
|
-
initializeComputeV1(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string,
|
|
100
|
+
initializeComputeV1(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, providerUri: string, accountId: string, chainId: number, token: string, maxJobDuration: number, signal?: AbortSignal): Promise<ProviderComputeInitializeResults>;
|
|
101
101
|
/** Initializes the provider for a compute request.
|
|
102
102
|
* @param {ComputeAsset[]} assets The datasets array to initialize compute request.
|
|
103
103
|
* @param {ComputeAlgorithmber} algorithm The algorithm to use.
|
|
104
104
|
* @param {string} computeEnv The compute environment.
|
|
105
|
+
* @param {string} token The payment token address.
|
|
105
106
|
* @param {number} validUntil The job expiration date.
|
|
106
107
|
* @param {string} providerUri The provider URI.
|
|
107
108
|
* @param {Signer} signer caller address
|
|
108
109
|
* @param {AbortSignal} signal abort signal
|
|
109
110
|
* @return {Promise<ProviderComputeInitialize>} ProviderComputeInitialize data
|
|
110
111
|
*/
|
|
111
|
-
initializeCompute(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, validUntil: number, providerUri: string, signer: Signer, signal?: AbortSignal): Promise<ProviderComputeInitializeResults>;
|
|
112
|
+
initializeCompute(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, token: string, validUntil: number, providerUri: string, signer: Signer, resources: ComputeResourceRequest[], signal?: AbortSignal): Promise<ProviderComputeInitializeResults>;
|
|
112
113
|
/**
|
|
113
114
|
* Gets the download URL.
|
|
114
115
|
* @param {string} did - The DID.
|
|
@@ -141,14 +142,15 @@ export declare class Provider {
|
|
|
141
142
|
* @param {string} computeEnv The compute environment.
|
|
142
143
|
* @param {ComputeAsset} datasets The dataset to start compute on + additionalDatasets (the additional datasets if that is the case)
|
|
143
144
|
* @param {ComputeAlgorithm} algorithm The algorithm to start compute with.
|
|
145
|
+
* @param {number} maxJobDuration The compute job max execution time.
|
|
146
|
+
* @param {string} token The token address for compute payment.
|
|
144
147
|
* @param {ComputeResourceRequest} resources The resources to start compute job with.
|
|
145
148
|
* @param {chainId} chainId The chain used to do payments
|
|
146
149
|
* @param {ComputeOutput} output The compute job output settings.
|
|
147
|
-
* @param {boolean} freeEnvironment is it a free environment? uses different route
|
|
148
150
|
* @param {AbortSignal} signal abort signal
|
|
149
151
|
* @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
|
|
150
152
|
*/
|
|
151
|
-
computeStart(providerUri: string, consumer: Signer, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, resources
|
|
153
|
+
computeStart(providerUri: string, consumer: Signer, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, maxJobDuration: number, token: string, resources: ComputeResourceRequest[], chainId?: number, // network used by payment (only for payed compute jobs)
|
|
152
154
|
output?: ComputeOutput, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
153
155
|
/** Instruct the provider to start a FREE compute job (new C2D V2)
|
|
154
156
|
* @param {string} providerUri The provider URI.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
2
|
import { Aquarius } from '../services/Aquarius.js';
|
|
3
|
+
import { DDO } from '@oceanprotocol/ddo-js';
|
|
3
4
|
export declare const DEVELOPMENT_CHAIN_ID = 8996;
|
|
4
5
|
export declare function useOasisSDK(network: string | number): boolean;
|
|
5
6
|
/**
|
|
@@ -20,7 +21,7 @@ export declare function useOasisSDK(network: string | number): boolean;
|
|
|
20
21
|
*/
|
|
21
22
|
export declare function createAsset(name: string, symbol: string, owner: Signer, assetUrl: any, // files object
|
|
22
23
|
templateIDorAddress: string | number, // If string, it's template address , otherwise, it's templateId
|
|
23
|
-
ddo:
|
|
24
|
+
ddo: DDO, encryptDDO: boolean, // default is true
|
|
24
25
|
providerUrl: string, providerFeeToken: string, aquariusInstance: Aquarius, accessListFactory?: string, // access list factory address
|
|
25
26
|
allowAccessList?: string, // allow list address
|
|
26
27
|
denyAccessList?: string): Promise<string>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { Asset } from '../@types/Asset.js';
|
|
3
2
|
import { Config } from '../config/Config.js';
|
|
4
3
|
import { Datatoken } from '../contracts/Datatoken.js';
|
|
5
4
|
import { ConsumeMarketFee } from '../@types/Datatoken.js';
|
|
6
5
|
import { ProviderFees } from '../@types/Provider.js';
|
|
6
|
+
import { Asset } from '@oceanprotocol/ddo-js';
|
|
7
7
|
/**
|
|
8
8
|
* Orders an asset based on the specified pricing schema and configuration.
|
|
9
9
|
* @param {Asset} asset - The asset to be ordered.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oceanprotocol/lib",
|
|
3
3
|
"source": "./src/index.ts",
|
|
4
|
-
"version": "4.0
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"description": "JavaScript client library for Ocean Protocol",
|
|
6
6
|
"main": "./dist/lib.cjs",
|
|
7
7
|
"umd:main": "dist/lib.umd.js",
|
|
@@ -57,15 +57,16 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@oasisprotocol/sapphire-paratime": "^1.3.2",
|
|
60
|
-
"@oceanprotocol/contracts": "^2.
|
|
61
|
-
"@oceanprotocol/ddo-js": "^0.0.
|
|
60
|
+
"@oceanprotocol/contracts": "^2.3.0",
|
|
61
|
+
"@oceanprotocol/ddo-js": "^0.0.8",
|
|
62
62
|
"@rdfjs/dataset": "^2.0.2",
|
|
63
63
|
"@rdfjs/formats-common": "^3.1.0",
|
|
64
64
|
"@zazuko/env-node": "^2.1.4",
|
|
65
65
|
"cross-fetch": "^4.0.0",
|
|
66
66
|
"crypto-js": "^4.1.1",
|
|
67
67
|
"decimal.js": "^10.4.1",
|
|
68
|
-
"ethers": "^5.7.2"
|
|
68
|
+
"ethers": "^5.7.2",
|
|
69
|
+
"form-data": "^2.3.3"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
72
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
@@ -94,7 +95,7 @@
|
|
|
94
95
|
"nyc": "^17.1.0",
|
|
95
96
|
"ora": "5.4.1",
|
|
96
97
|
"prettier": "^2.7.1",
|
|
97
|
-
"release-it": "^
|
|
98
|
+
"release-it": "^18.1.2",
|
|
98
99
|
"source-map-support": "^0.5.21",
|
|
99
100
|
"ts-node": "^10.9.2",
|
|
100
101
|
"ts-node-register": "^1.0.0",
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { DDO } from '.';
|
|
2
|
-
export interface AssetNft {
|
|
3
|
-
/**
|
|
4
|
-
* Contract address of the deployed ERC721 NFT contract.
|
|
5
|
-
* @type {string}
|
|
6
|
-
*/
|
|
7
|
-
address: string;
|
|
8
|
-
/**
|
|
9
|
-
* Name of NFT set in contract.
|
|
10
|
-
* @type {string}
|
|
11
|
-
*/
|
|
12
|
-
name: string;
|
|
13
|
-
/**
|
|
14
|
-
* Symbol of NFT set in contract.
|
|
15
|
-
* @type {string}
|
|
16
|
-
*/
|
|
17
|
-
symbol: string;
|
|
18
|
-
/**
|
|
19
|
-
* ETH account address of the NFT owner.
|
|
20
|
-
* @type {string}
|
|
21
|
-
*/
|
|
22
|
-
owner: string;
|
|
23
|
-
/**
|
|
24
|
-
* State of the asset reflecting the NFT contract value.
|
|
25
|
-
* 0 Active.
|
|
26
|
-
* 1 End-of-life.
|
|
27
|
-
* 2 Deprecated (by another asset).
|
|
28
|
-
* 3 Revoked by publisher.
|
|
29
|
-
* 4 Ordering is temporary disabled.
|
|
30
|
-
* 5 Unlisted in markets.
|
|
31
|
-
* @type {number}
|
|
32
|
-
*/
|
|
33
|
-
state: 0 | 1 | 2 | 3 | 4 | 5;
|
|
34
|
-
/**
|
|
35
|
-
* Contains the date of NFT creation.
|
|
36
|
-
* @type {string}
|
|
37
|
-
*/
|
|
38
|
-
created: string;
|
|
39
|
-
/**
|
|
40
|
-
* NFT token URI.
|
|
41
|
-
* @type {string}
|
|
42
|
-
*/
|
|
43
|
-
tokenURI: string;
|
|
44
|
-
}
|
|
45
|
-
export interface Purgatory {
|
|
46
|
-
/**
|
|
47
|
-
* If `true`, asset is in purgatory.
|
|
48
|
-
* @type {boolean}
|
|
49
|
-
*/
|
|
50
|
-
state: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* If asset is in purgatory, contains the reason for being there as defined in `list-purgatory`.
|
|
53
|
-
* @type {string}
|
|
54
|
-
*/
|
|
55
|
-
reason: string;
|
|
56
|
-
}
|
|
57
|
-
export interface AssetDatatoken {
|
|
58
|
-
/**
|
|
59
|
-
* Contract address of the deployed Datatoken contract.
|
|
60
|
-
* @type {string}
|
|
61
|
-
*/
|
|
62
|
-
address: string;
|
|
63
|
-
/**
|
|
64
|
-
* Name of NFT set in contract.
|
|
65
|
-
* @type {string}
|
|
66
|
-
*/
|
|
67
|
-
name: string;
|
|
68
|
-
/**
|
|
69
|
-
* Symbol of NFT set in contract.
|
|
70
|
-
* @type {string}
|
|
71
|
-
*/
|
|
72
|
-
symbol: string;
|
|
73
|
-
/**
|
|
74
|
-
* ID of the service the datatoken is attached to.
|
|
75
|
-
* @type {string}
|
|
76
|
-
*/
|
|
77
|
-
serviceId: string;
|
|
78
|
-
}
|
|
79
|
-
export interface AssetPrice {
|
|
80
|
-
/**
|
|
81
|
-
* The price of the asset expressed as a number. If 0 then the price is FREE.
|
|
82
|
-
* @type {number}
|
|
83
|
-
*/
|
|
84
|
-
value: number;
|
|
85
|
-
/**
|
|
86
|
-
* The symbol that the price of the asset is expressed in.
|
|
87
|
-
* @type {string}
|
|
88
|
-
*/
|
|
89
|
-
tokenSymbol?: string;
|
|
90
|
-
/**
|
|
91
|
-
* The address of the token that the price needs to be paid in.
|
|
92
|
-
* @type {string}
|
|
93
|
-
*/
|
|
94
|
-
tokenAddress?: string;
|
|
95
|
-
}
|
|
96
|
-
export interface Stats {
|
|
97
|
-
/**
|
|
98
|
-
* How often an asset was consumed, meaning how often it was either downloaded or used as part of a compute job.
|
|
99
|
-
* @type {number}
|
|
100
|
-
*/
|
|
101
|
-
orders: number;
|
|
102
|
-
/**
|
|
103
|
-
* Contains information about the price of this asset.
|
|
104
|
-
* @type {AssetPrice}
|
|
105
|
-
*/
|
|
106
|
-
price: AssetPrice;
|
|
107
|
-
/**
|
|
108
|
-
* Total amount of veOCEAN allocated on this asset.
|
|
109
|
-
* @type {number}
|
|
110
|
-
*/
|
|
111
|
-
allocated?: number;
|
|
112
|
-
}
|
|
113
|
-
export interface AssetLastEvent {
|
|
114
|
-
tx: string;
|
|
115
|
-
block: number;
|
|
116
|
-
from: string;
|
|
117
|
-
contract: string;
|
|
118
|
-
datetime: string;
|
|
119
|
-
}
|
|
120
|
-
export interface Asset extends DDO {
|
|
121
|
-
/**
|
|
122
|
-
* Contains information about the ERC721 NFT contract which represents the intellectual property of the publisher.
|
|
123
|
-
* @type {string}
|
|
124
|
-
*/
|
|
125
|
-
nft: AssetNft;
|
|
126
|
-
/**
|
|
127
|
-
* Contains information about the ERC20 Datatokens attached to asset services.
|
|
128
|
-
* @type {string}
|
|
129
|
-
*/
|
|
130
|
-
datatokens: AssetDatatoken[];
|
|
131
|
-
/**
|
|
132
|
-
* Contains information about the last transaction that created or updated the DDO.
|
|
133
|
-
* @type {string}
|
|
134
|
-
*/
|
|
135
|
-
event: AssetLastEvent;
|
|
136
|
-
/**
|
|
137
|
-
* The stats section contains different statistics fields. This section is added by Aquarius
|
|
138
|
-
* @type {Stats}
|
|
139
|
-
*/
|
|
140
|
-
stats: Stats;
|
|
141
|
-
/**
|
|
142
|
-
* Contains information about an asset's purgatory status defined in
|
|
143
|
-
* [`list-purgatory`](https://github.com/oceanprotocol/list-purgatory).
|
|
144
|
-
* Marketplace interfaces are encouraged to prevent certain user actions like downloading on assets in purgatory.
|
|
145
|
-
* @type {Purgatory}
|
|
146
|
-
*/
|
|
147
|
-
purgatory: Purgatory;
|
|
148
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export interface ConsumerParameter {
|
|
2
|
-
/**
|
|
3
|
-
* Parameter name.
|
|
4
|
-
* @type {string}
|
|
5
|
-
*/
|
|
6
|
-
name: string;
|
|
7
|
-
/**
|
|
8
|
-
* Field type.
|
|
9
|
-
* @type {'text' | 'number' | 'boolean' | 'select'}
|
|
10
|
-
*/
|
|
11
|
-
type: 'text' | 'number' | 'boolean' | 'select';
|
|
12
|
-
/**
|
|
13
|
-
* Displayed field label.
|
|
14
|
-
* @type {string}
|
|
15
|
-
*/
|
|
16
|
-
label: string;
|
|
17
|
-
/**
|
|
18
|
-
* Defines if customer input for this field is mandatory.
|
|
19
|
-
* @type {boolean}
|
|
20
|
-
*/
|
|
21
|
-
required: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Field description.
|
|
24
|
-
* @type {string}
|
|
25
|
-
*/
|
|
26
|
-
description: string;
|
|
27
|
-
/**
|
|
28
|
-
* Field default value. For select types, string key of default option.
|
|
29
|
-
* @type {string}
|
|
30
|
-
*/
|
|
31
|
-
default: string;
|
|
32
|
-
/**
|
|
33
|
-
* For select types, a list of options.
|
|
34
|
-
* @type {string}
|
|
35
|
-
*/
|
|
36
|
-
options?: string;
|
|
37
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Service, Metadata, Credentials, Event } from '..';
|
|
2
|
-
/**
|
|
3
|
-
* DID Descriptor Object.
|
|
4
|
-
* Contains metadata about the asset, and define access in at least one service.
|
|
5
|
-
*/
|
|
6
|
-
export interface DDO {
|
|
7
|
-
/**
|
|
8
|
-
* Contexts used for validation.
|
|
9
|
-
* @type {string[]}
|
|
10
|
-
*/
|
|
11
|
-
'@context': string[];
|
|
12
|
-
/**
|
|
13
|
-
* DID, descentralized ID.
|
|
14
|
-
* Computed as sha256(address of NFT contract + chainId)
|
|
15
|
-
* @type {string}
|
|
16
|
-
*/
|
|
17
|
-
id: string;
|
|
18
|
-
/**
|
|
19
|
-
* Version information in SemVer notation
|
|
20
|
-
* referring to the DDO spec version
|
|
21
|
-
* @type {string}
|
|
22
|
-
*/
|
|
23
|
-
version: string;
|
|
24
|
-
/**
|
|
25
|
-
* NFT contract address
|
|
26
|
-
* @type {string}
|
|
27
|
-
*/
|
|
28
|
-
nftAddress: string;
|
|
29
|
-
/**
|
|
30
|
-
* ChainId of the network the DDO was published to.
|
|
31
|
-
* @type {number}
|
|
32
|
-
*/
|
|
33
|
-
chainId: number;
|
|
34
|
-
/**
|
|
35
|
-
* Stores an object describing the asset.
|
|
36
|
-
* @type {Metadata}
|
|
37
|
-
*/
|
|
38
|
-
metadata: Metadata;
|
|
39
|
-
/**
|
|
40
|
-
* Stores an array of services defining access to the asset.
|
|
41
|
-
* @type {Service[]}
|
|
42
|
-
*/
|
|
43
|
-
services: Service[];
|
|
44
|
-
/**
|
|
45
|
-
* Describes the credentials needed to access a dataset
|
|
46
|
-
* in addition to the services definition.
|
|
47
|
-
* @type {Credentials}
|
|
48
|
-
*/
|
|
49
|
-
credentials?: Credentials;
|
|
50
|
-
/**
|
|
51
|
-
* Describes the event of last metadata event
|
|
52
|
-
* @type {Event}
|
|
53
|
-
*/
|
|
54
|
-
event?: Event;
|
|
55
|
-
}
|