@oceanprotocol/lib 9.3.0-next.3 → 9.3.0-next.5
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/dist/lib.modern.mjs +2 -2
- package/dist/lib.module.mjs +2 -2
- package/dist/types/@types/EscrowEvents.d.ts +68 -0
- package/dist/types/@types/OneTimeSubsidyProvider.d.ts +5 -4
- package/dist/types/@types/Provider.d.ts +1 -0
- package/dist/types/@types/index.d.ts +1 -0
- package/dist/types/services/providers/BaseProvider.d.ts +22 -1
- package/dist/types/services/providers/HttpProvider.d.ts +12 -1
- package/dist/types/services/providers/P2pProvider.d.ts +11 -1
- package/package.json +3 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export type EscrowEventType = 'Auth' | 'Lock' | 'ReLock' | 'Claimed' | 'Canceled' | 'Deposit' | 'Withdraw' | 'Subsidized' | 'LockSponsored' | 'SponsorRefunded';
|
|
2
|
+
/**
|
|
3
|
+
* Numeric range bound for a range filter. `min`/`max` are inclusive, `gt`/`lt` exclusive.
|
|
4
|
+
* uint256 bounds must be passed as strings (the node compares them with BigInt).
|
|
5
|
+
* Note: `gt`/`lt` only take effect over the P2P transport — the HTTP REST route reads only
|
|
6
|
+
* `min`/`max`, so `gt`/`lt` are dropped (with a warning) when querying an HTTP node.
|
|
7
|
+
*/
|
|
8
|
+
export interface RangeFilter {
|
|
9
|
+
min?: string | number;
|
|
10
|
+
max?: string | number;
|
|
11
|
+
gt?: string | number;
|
|
12
|
+
lt?: string | number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* One indexed escrow event row, keyed by `${txHash}-${logIndex}`. The base fields are always
|
|
16
|
+
* present; the rest depend on `eventType`. All uint256 fields are decimal strings.
|
|
17
|
+
*/
|
|
18
|
+
export interface EscrowEventRecord {
|
|
19
|
+
id: string;
|
|
20
|
+
eventType: EscrowEventType;
|
|
21
|
+
chainId: number;
|
|
22
|
+
contract: string;
|
|
23
|
+
block: number;
|
|
24
|
+
txHash: string;
|
|
25
|
+
payer?: string;
|
|
26
|
+
payee?: string;
|
|
27
|
+
token?: string;
|
|
28
|
+
jobId?: string;
|
|
29
|
+
provider?: string;
|
|
30
|
+
proof?: string;
|
|
31
|
+
amount?: string;
|
|
32
|
+
expiry?: string;
|
|
33
|
+
oldAmount?: string;
|
|
34
|
+
newAmount?: string;
|
|
35
|
+
newExpiry?: string;
|
|
36
|
+
maxLockedAmount?: string;
|
|
37
|
+
maxLockSeconds?: string;
|
|
38
|
+
maxLockCounts?: string;
|
|
39
|
+
expiryTimestamp?: string;
|
|
40
|
+
subsidyAmount?: string;
|
|
41
|
+
bonusAmount?: string;
|
|
42
|
+
reclaimable?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Filters for `getEscrowEvents`. All fields are optional. Equality filters match exactly
|
|
46
|
+
* (addresses are case-insensitive on input, returned lowercased). `ranges` holds numeric
|
|
47
|
+
* range filters keyed by record field, e.g. `{ block: { min: 100, max: 200 } }`.
|
|
48
|
+
*
|
|
49
|
+
* Range-filterable fields: `block`, `chainId` (store-side), and the uint256 fields `amount`,
|
|
50
|
+
* `subsidyAmount`, `bonusAmount`, `oldAmount`, `newAmount`, `maxLockedAmount`, `maxLockSeconds`,
|
|
51
|
+
* `maxLockCounts`, `expiry`, `newExpiry`, `expiryTimestamp` (node-side BigInt). A range on any
|
|
52
|
+
* other field is rejected by the node.
|
|
53
|
+
*/
|
|
54
|
+
export interface EscrowEventsFilter {
|
|
55
|
+
chainId?: number;
|
|
56
|
+
eventType?: EscrowEventType;
|
|
57
|
+
payer?: string;
|
|
58
|
+
payee?: string;
|
|
59
|
+
token?: string;
|
|
60
|
+
provider?: string;
|
|
61
|
+
contract?: string;
|
|
62
|
+
reclaimable?: boolean;
|
|
63
|
+
jobId?: string;
|
|
64
|
+
txId?: string;
|
|
65
|
+
ranges?: Record<string, RangeFilter>;
|
|
66
|
+
offset?: number;
|
|
67
|
+
size?: number;
|
|
68
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-token configuration of a `OneTimeSubsidyProvider`, as returned by `getTokenConfig`.
|
|
3
|
-
* `defaultCredit` is expressed in human-readable token units; `pctBps` is the
|
|
4
|
-
* per-job percentage ceiling in basis points (here `0` means "
|
|
5
|
-
*
|
|
3
|
+
* `defaultCredit` is expressed in human-readable token units; `pctBps` is the REQUIRED
|
|
4
|
+
* per-job percentage ceiling in basis points (here `0` means "grant nothing" and `10000`
|
|
5
|
+
* (= `BPS`) means up to 100% of the job may be sponsored — same meaning as
|
|
6
|
+
* `OPFSubsidyProvider`). A token must have a non-zero `pctBps` to sponsor anything.
|
|
6
7
|
*/
|
|
7
8
|
export interface OneTimeTokenConfig {
|
|
8
|
-
/**
|
|
9
|
+
/** Per-job ceiling in basis points (1% = 100 bps); `'0'` = grant nothing, `'10000'` = 100% of job. */
|
|
9
10
|
pctBps: string;
|
|
10
11
|
/** Global one-time credit granted per user for this token, in human-readable token units. */
|
|
11
12
|
defaultCredit: string;
|
|
@@ -15,6 +15,7 @@ export * from './Provider.js';
|
|
|
15
15
|
export * from './Router.js';
|
|
16
16
|
export * from './ReturnTypes.js';
|
|
17
17
|
export * from './Escrow.js';
|
|
18
|
+
export * from './EscrowEvents.js';
|
|
18
19
|
export * from './OPFSubsidyProvider.js';
|
|
19
20
|
export * from './OneTimeSubsidyProvider.js';
|
|
20
21
|
export * from './SubsidyView.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ComputeResultStream, FindComputeProvidersRequest, FindComputeProvidersResult, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, NodeStatus, NodeComputeJob, NodeMetricsSnapshot, NodeMetricsHistoryResult, NodeLogEntry, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, CompleteSignature, SignerOrAuthTokenOrSignature } from '../../@types/index.js';
|
|
2
|
+
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ComputeResultStream, FindComputeProvidersRequest, FindComputeProvidersResult, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, NodeStatus, NodeComputeJob, NodeMetricsSnapshot, NodeMetricsHistoryResult, NodeLogEntry, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, CompleteSignature, SignerOrAuthTokenOrSignature, EscrowEventRecord, EscrowEventsFilter } from '../../@types/index.js';
|
|
3
3
|
import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
|
|
4
4
|
import { type P2pProvider, type P2PConfig, type P2PRequestBodyStream } from './P2pProvider.js';
|
|
5
5
|
export { OCEAN_P2P_PROTOCOL, type P2PConfig, type P2pProviderRecord, type Multiaddr, P2pError, type P2pErrorType, classifyP2pError, isRetryableP2pError } from './P2pProvider.js';
|
|
@@ -126,6 +126,27 @@ export declare class BaseProvider {
|
|
|
126
126
|
downloadNodeLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, startTime: string, endTime: string, maxLogs?: number, moduleName?: string, level?: string, page?: number, signal?: AbortSignal): Promise<NodeLogEntry[]>;
|
|
127
127
|
getNodeStatus(nodeUri: OceanNode, signal?: AbortSignal): Promise<NodeStatus>;
|
|
128
128
|
getNodeJobs(nodeUri: OceanNode, fromTimestamp?: number, signal?: AbortSignal): Promise<NodeComputeJob[]>;
|
|
129
|
+
/**
|
|
130
|
+
* Queries indexed escrow events from a node. A public read — no auth is sent. Routes to HTTP
|
|
131
|
+
* (`GET /api/services/escrow/events`) or P2P (GET_ESCROW_EVENTS) depending on the node target.
|
|
132
|
+
* Returns a single page (default size 100, max 250 server-side); use `getAllEscrowEvents` to
|
|
133
|
+
* walk every page.
|
|
134
|
+
* @param {OceanNode} nodeUri - node HTTP endpoint, peerId or multiaddr
|
|
135
|
+
* @param {EscrowEventsFilter} [filter] - optional equality / range filters and pagination
|
|
136
|
+
* @param {AbortSignal} [signal] - optional abort signal to cancel the request
|
|
137
|
+
* @return {Promise<EscrowEventRecord[]>} the matching event rows, or [] on failure
|
|
138
|
+
*/
|
|
139
|
+
getEscrowEvents(nodeUri: OceanNode, filter?: EscrowEventsFilter, signal?: AbortSignal): Promise<EscrowEventRecord[]>;
|
|
140
|
+
/**
|
|
141
|
+
* Like `getEscrowEvents` but transparently walks every page until a short page is returned.
|
|
142
|
+
* Exact for `block`/`chainId` ranges (store-side); a very selective uint256 amount range can
|
|
143
|
+
* still be incomplete, since the node applies a bounded scan per page.
|
|
144
|
+
* @param {OceanNode} nodeUri - node HTTP endpoint, peerId or multiaddr
|
|
145
|
+
* @param {EscrowEventsFilter} [filter] - optional equality / range filters and starting offset
|
|
146
|
+
* @param {AbortSignal} [signal] - optional abort signal to cancel the request
|
|
147
|
+
* @return {Promise<EscrowEventRecord[]>} all matching event rows, or [] on failure
|
|
148
|
+
*/
|
|
149
|
+
getAllEscrowEvents(nodeUri: OceanNode, filter?: EscrowEventsFilter, signal?: AbortSignal): Promise<EscrowEventRecord[]>;
|
|
129
150
|
/**
|
|
130
151
|
* Returns the live per-node resource metrics snapshot. Routes to HTTP (`GET /nodeMetrics`)
|
|
131
152
|
* or P2P (GET_NODE_METRICS command) depending on the node target.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, ComputeResultStream, NodeStatus, NodeComputeJob, NodeLogEntry, NodeMetricsSnapshot, NodeMetricsHistoryResult, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, SignerOrAuthTokenOrSignature } from '../../@types/index.js';
|
|
2
|
+
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, ComputeResultStream, NodeStatus, NodeComputeJob, NodeLogEntry, NodeMetricsSnapshot, NodeMetricsHistoryResult, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, SignerOrAuthTokenOrSignature, EscrowEventRecord, EscrowEventsFilter } from '../../@types/index.js';
|
|
3
3
|
import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
|
|
4
4
|
import { type P2PRequestBodyStream } from './P2pProvider.js';
|
|
5
5
|
export declare class HttpProvider {
|
|
@@ -30,6 +30,17 @@ export declare class HttpProvider {
|
|
|
30
30
|
* @return {Promise<NodeMetricsHistoryResult | null>} the history, or null if unavailable
|
|
31
31
|
*/
|
|
32
32
|
getNodeMetricsHistory(nodeUri: string, startTime?: number | string, stopTime?: number | string, signal?: AbortSignal): Promise<NodeMetricsHistoryResult | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Queries indexed escrow events via the REST route `GET /api/services/escrow/events`.
|
|
35
|
+
* Equality filters go on the query string; `ranges` are flattened to `<field>Min`/`<field>Max`.
|
|
36
|
+
* The REST route reads only `min`/`max`, so any `gt`/`lt` bound is dropped (with a warning) —
|
|
37
|
+
* use the P2P transport for exclusive bounds. A public read: no auth is sent.
|
|
38
|
+
* @param {string} nodeUri - node HTTP endpoint
|
|
39
|
+
* @param {EscrowEventsFilter} [filter] - optional equality / range filters and pagination
|
|
40
|
+
* @param {AbortSignal} [signal] - optional abort signal to cancel the request
|
|
41
|
+
* @return {Promise<EscrowEventRecord[]>} the matching event rows, or [] on failure
|
|
42
|
+
*/
|
|
43
|
+
getEscrowEvents(nodeUri: string, filter?: EscrowEventsFilter, signal?: AbortSignal): Promise<EscrowEventRecord[]>;
|
|
33
44
|
/**
|
|
34
45
|
* Returns the node public key
|
|
35
46
|
* @return {string} The node public key
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Libp2p, type Libp2pOptions } from 'libp2p';
|
|
2
2
|
import { type Multiaddr } from '@multiformats/multiaddr';
|
|
3
3
|
import { Signer } from 'ethers';
|
|
4
|
-
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, ComputeResultStream, NodeStatus, NodeComputeJob, NodeMetricsSnapshot, NodeMetricsHistoryResult, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, SignerOrAuthTokenOrSignature } from '../../@types/index.js';
|
|
4
|
+
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, ComputeResultStream, NodeStatus, NodeComputeJob, NodeMetricsSnapshot, NodeMetricsHistoryResult, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, SignerOrAuthTokenOrSignature, EscrowEventRecord, EscrowEventsFilter } from '../../@types/index.js';
|
|
5
5
|
import { NodeLogEntry } from '../../@types/Provider.js';
|
|
6
6
|
import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
|
|
7
7
|
import { CID } from 'multiformats/cid';
|
|
@@ -502,6 +502,16 @@ export declare class P2pProvider {
|
|
|
502
502
|
*/
|
|
503
503
|
getNodeStatus(nodeUri: OceanNode, signal?: AbortSignal): Promise<NodeStatus>;
|
|
504
504
|
getNodeJobs(nodeUri: OceanNode, fromTimestamp?: number, signal?: AbortSignal): Promise<NodeComputeJob[]>;
|
|
505
|
+
/**
|
|
506
|
+
* Queries indexed escrow events via the P2P GET_ESCROW_EVENTS command. The `ranges` object
|
|
507
|
+
* (including exclusive `gt`/`lt` bounds) is passed through verbatim; the node compares uint256
|
|
508
|
+
* bounds with BigInt. A public read: no signer / auth token is sent.
|
|
509
|
+
* @param {OceanNode} nodeUri - peerId/multiaddr of the node
|
|
510
|
+
* @param {EscrowEventsFilter} [filter] - optional equality / range filters and pagination
|
|
511
|
+
* @param {AbortSignal} [signal] - optional abort signal to cancel the request
|
|
512
|
+
* @return {Promise<EscrowEventRecord[]>} the matching event rows, or [] on failure
|
|
513
|
+
*/
|
|
514
|
+
getEscrowEvents(nodeUri: OceanNode, filter?: EscrowEventsFilter, signal?: AbortSignal): Promise<EscrowEventRecord[]>;
|
|
505
515
|
/**
|
|
506
516
|
* Returns the live per-node resource metrics snapshot via the P2P GET_NODE_METRICS command.
|
|
507
517
|
* @param {OceanNode} nodeUri - peerId/multiaddr of the node
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oceanprotocol/lib",
|
|
3
3
|
"source": "./src/index.ts",
|
|
4
|
-
"version": "9.3.0-next.
|
|
4
|
+
"version": "9.3.0-next.5",
|
|
5
5
|
"description": "JavaScript client library for Ocean Protocol",
|
|
6
6
|
"module": "./dist/lib.module.mjs",
|
|
7
7
|
"type": "module",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@libp2p/websockets": "^10.1.21",
|
|
84
84
|
"@multiformats/multiaddr": "^13.0.3",
|
|
85
85
|
"@oasisprotocol/sapphire-ethers-v6": "^6.0.1",
|
|
86
|
-
"@oceanprotocol/ddo-js": "^0.
|
|
86
|
+
"@oceanprotocol/ddo-js": "^1.0.0",
|
|
87
87
|
"bignumber.js": "^11.1.5",
|
|
88
88
|
"cross-fetch": "^4.1.0",
|
|
89
89
|
"crypto-js": "^4.2.0",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@eslint/js": "^10.0.1",
|
|
100
100
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
101
|
-
"@oceanprotocol/contracts": "^3.2.0-rc.
|
|
101
|
+
"@oceanprotocol/contracts": "^3.2.0-rc.1",
|
|
102
102
|
"@types/chai": "^5.2.3",
|
|
103
103
|
"@types/crypto-js": "^4.2.2",
|
|
104
104
|
"@types/jsonwebtoken": "^9.0.10",
|