@oceanprotocol/lib 4.0.3 → 4.1.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.
@@ -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
+ }
@@ -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;
@@ -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
+ }
@@ -18,3 +18,4 @@ export * from './df/DfStrategyV1.js';
18
18
  export * from './Datatoken4.js';
19
19
  export * from './AccessList.js';
20
20
  export * from './AccessListFactory.js';
21
+ export * from './Escrow.js';
@@ -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, validUntil: number, providerUri: string, accountId: string, signal?: AbortSignal): Promise<ProviderComputeInitializeResults>;
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?: ComputeResourceRequest[], chainId?: number, // network used by payment (only for payed compute jobs)
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.
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.3",
4
+ "version": "4.1.1",
5
5
  "description": "JavaScript client library for Ocean Protocol",
6
6
  "main": "./dist/lib.cjs",
7
7
  "umd:main": "dist/lib.umd.js",
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@oasisprotocol/sapphire-paratime": "^1.3.2",
60
- "@oceanprotocol/contracts": "^2.2.0",
60
+ "@oceanprotocol/contracts": "^2.3.0",
61
61
  "@oceanprotocol/ddo-js": "^0.0.8",
62
62
  "@rdfjs/dataset": "^2.0.2",
63
63
  "@rdfjs/formats-common": "^3.1.0",