@oceanprotocol/lib 4.3.1 → 5.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/CodeExamples.md +31 -43
- package/ComputeExamples.md +32 -38
- 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/PolicyServer.d.ts +9 -0
- package/dist/types/@types/ReturnTypes.d.ts +3 -3
- package/dist/types/@types/index.d.ts +1 -0
- package/dist/types/contracts/AccessListFactory.d.ts +2 -2
- package/dist/types/contracts/Datatoken4.d.ts +5 -5
- package/dist/types/contracts/NFT.d.ts +1 -2
- package/dist/types/contracts/NFTFactory.d.ts +1 -2
- package/dist/types/contracts/ve/VeAllocate.d.ts +1 -1
- package/dist/types/services/Provider.d.ts +17 -6
- package/dist/types/utils/ContractUtils.d.ts +3 -3
- package/dist/types/utils/General.d.ts +1 -1
- package/dist/types/utils/OrderUtils.d.ts +1 -1
- package/docs/classes/Aquarius.md +1 -1
- package/docs/classes/VeAllocate.md +1 -1
- package/docs/modules.md +1 -1
- package/package.json +8 -7
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type ReceiptOrEstimate<G extends boolean = false> = G extends false ?
|
|
3
|
-
export type ReceiptOrDecimal<G extends boolean = false> = G extends false ?
|
|
1
|
+
import { BigNumberish, TransactionResponse } from 'ethers';
|
|
2
|
+
export type ReceiptOrEstimate<G extends boolean = false> = G extends false ? TransactionResponse : BigNumberish;
|
|
3
|
+
export type ReceiptOrDecimal<G extends boolean = false> = G extends false ? TransactionResponse : number;
|
|
@@ -8,6 +8,7 @@ export * from './DownloadResponse.js';
|
|
|
8
8
|
export * from './FixedPrice.js';
|
|
9
9
|
export * from './NFT.js';
|
|
10
10
|
export * from './NFTFactory.js';
|
|
11
|
+
export * from './PolicyServer.js';
|
|
11
12
|
export * from './Provider.js';
|
|
12
13
|
export * from './Router.js';
|
|
13
14
|
export * from './ReturnTypes.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BigNumberish, Signer } from 'ethers';
|
|
2
2
|
import { Config } from '../config/index.js';
|
|
3
3
|
import { AbiItem, ReceiptOrEstimate } from '../@types/index.js';
|
|
4
4
|
import { SmartContractWithAddress } from './SmartContractWithAddress.js';
|
|
@@ -27,7 +27,7 @@ export declare class AccesslistFactory extends SmartContractWithAddress {
|
|
|
27
27
|
* @param {Boolean} [estimateGas] if True, return gas estimate
|
|
28
28
|
* @return {Promise<string|BigNumber>} The transaction hash or the gas estimate.
|
|
29
29
|
*/
|
|
30
|
-
deployAccessListContract<G extends boolean = false>(nameAccessList: string, symbolAccessList: string, tokenURI: string[], transferable: boolean, owner: string, user: string[], estimateGas?: G): Promise<G extends false ? string :
|
|
30
|
+
deployAccessListContract<G extends boolean = false>(nameAccessList: string, symbolAccessList: string, tokenURI: string[], transferable: boolean, owner: string, user: string[], estimateGas?: G): Promise<G extends false ? string : BigNumberish>;
|
|
31
31
|
/**
|
|
32
32
|
* Get Factory Owner
|
|
33
33
|
* @return {Promise<string>} Factory Owner address
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Datatoken } from './Datatoken.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Signer } from 'ethers';
|
|
3
3
|
import { AbiItem, ReceiptOrEstimate } from '../@types/index.js';
|
|
4
4
|
import { AccessListContract } from './AccessList.js';
|
|
5
5
|
import { Config } from '../config/index.js';
|
|
6
6
|
export declare class Datatoken4 extends Datatoken {
|
|
7
7
|
accessList: AccessListContract;
|
|
8
|
-
fileObject:
|
|
8
|
+
fileObject: Uint8Array;
|
|
9
9
|
getDefaultAbi(): AbiItem[];
|
|
10
10
|
/**
|
|
11
11
|
* Instantiate Datatoken class
|
|
@@ -14,8 +14,8 @@ export declare class Datatoken4 extends Datatoken {
|
|
|
14
14
|
* @param {Config} [config] The configuration object.
|
|
15
15
|
* @param {AbiItem[]} [abi] ABI array of the smart contract
|
|
16
16
|
*/
|
|
17
|
-
constructor(signer: Signer, fileObject:
|
|
18
|
-
setFileObj(fileObj:
|
|
17
|
+
constructor(signer: Signer, fileObject: Uint8Array, network?: string | number, config?: Config, abi?: AbiItem[]);
|
|
18
|
+
setFileObj(fileObj: Uint8Array): void;
|
|
19
19
|
/**
|
|
20
20
|
* getAllowListContract - It returns the current allowList contract address
|
|
21
21
|
* @param dtAddress datatoken address
|
|
@@ -68,5 +68,5 @@ export declare class Datatoken4 extends Datatoken {
|
|
|
68
68
|
* @param {String} consumerAddress
|
|
69
69
|
* @return {Promise<Bytes>} returns file object
|
|
70
70
|
*/
|
|
71
|
-
getFileObject(dtAddress: string, serviceIndex: number, providerAddress: string, providerSignature:
|
|
71
|
+
getFileObject(dtAddress: string, serviceIndex: number, providerAddress: string, providerSignature: Uint8Array, consumerData: Uint8Array, consumerSignature: Uint8Array, consumerAddress: string): Promise<Uint8Array>;
|
|
72
72
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BigNumber } from 'ethers';
|
|
2
1
|
import { MetadataAndTokenURI, NftRoles, ReceiptOrEstimate, AbiItem } from '../@types/index.js';
|
|
3
2
|
import { SmartContract } from './SmartContract.js';
|
|
4
3
|
import { MetadataProof } from '@oceanprotocol/ddo-js';
|
|
@@ -20,7 +19,7 @@ export declare class Nft extends SmartContract {
|
|
|
20
19
|
* @param {Boolean} estimateGas if True, return gas estimate
|
|
21
20
|
* @return {Promise<string>} ERC20 Datatoken address
|
|
22
21
|
*/
|
|
23
|
-
createDatatoken<G extends boolean = false>(nftAddress: string, address: string, minter: string, paymentCollector: string, mpFeeAddress: string, feeToken: string, feeAmount: string, cap: string, name?: string, symbol?: string, templateIndex?: number, filesObject?: string, accessListContract?: string, allowAccessList?: string, denyAccessList?: string, estimateGas?: G): Promise<G extends false ? string :
|
|
22
|
+
createDatatoken<G extends boolean = false>(nftAddress: string, address: string, minter: string, paymentCollector: string, mpFeeAddress: string, feeToken: string, feeAmount: string, cap: string, name?: string, symbol?: string, templateIndex?: number, filesObject?: string, accessListContract?: string, allowAccessList?: string, denyAccessList?: string, estimateGas?: G): Promise<G extends false ? string : BigInt>;
|
|
24
23
|
/**
|
|
25
24
|
* Add Manager for NFT Contract (only NFT Owner can succeed)
|
|
26
25
|
* @param {String} nftAddress NFT contract address
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BigNumber } from 'ethers';
|
|
2
1
|
import { AbiItem, FreCreationParams, DatatokenCreateParams, DispenserCreationParams, NftCreateData, Template, TokenOrder, ReceiptOrEstimate } from '../@types/index.js';
|
|
3
2
|
import { SmartContractWithAddress } from './SmartContractWithAddress.js';
|
|
4
3
|
/**
|
|
@@ -12,7 +11,7 @@ export declare class NftFactory extends SmartContractWithAddress {
|
|
|
12
11
|
* @param {Boolean} [estimateGas] if True, return gas estimate
|
|
13
12
|
* @return {Promise<string|BigNumber>} The transaction hash or the gas estimate.
|
|
14
13
|
*/
|
|
15
|
-
createNFT<G extends boolean = false>(nftData: NftCreateData, estimateGas?: G): Promise<G extends false ? string :
|
|
14
|
+
createNFT<G extends boolean = false>(nftData: NftCreateData, estimateGas?: G): Promise<G extends false ? string : bigint>;
|
|
16
15
|
/**
|
|
17
16
|
* Get Current NFT Count (NFT created)
|
|
18
17
|
* @return {Promise<number>} Number of NFT created from this factory
|
|
@@ -15,7 +15,7 @@ export declare class VeAllocate extends SmartContractWithAddress {
|
|
|
15
15
|
*/
|
|
16
16
|
setAllocation<G extends boolean = false>(amount: string, nft: string, chainId: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
|
|
17
17
|
/**
|
|
18
|
-
* set specific
|
|
18
|
+
* set specific percentage of veOcean to multiple nfts
|
|
19
19
|
* Maximum allocated percentage is 10000, so 1% is specified as 100
|
|
20
20
|
* @param {String[]} amount Array of percentages used
|
|
21
21
|
* @param {String[]} nft Array of NFT addresses
|
|
@@ -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, ComputeResourceRequest, ComputeJobMetadata } from '../@types';
|
|
2
|
+
import { Arweave, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, ServiceEndpoint, UrlFile, UserCustomParameters, Ipfs, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand } from '../@types';
|
|
3
3
|
export declare class Provider {
|
|
4
4
|
private getConsumerAddress;
|
|
5
5
|
private getSignature;
|
|
@@ -159,7 +159,7 @@ export declare class Provider {
|
|
|
159
159
|
* @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
|
|
160
160
|
*/
|
|
161
161
|
computeStart(providerUri: string, signerOrAuthToken: Signer | string, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, maxJobDuration: number, token: string, resources: ComputeResourceRequest[], chainId: number, // network used by payment (only for payed compute jobs)
|
|
162
|
-
metadata?: ComputeJobMetadata, output?: ComputeOutput, policyServer?: any, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
162
|
+
metadata?: ComputeJobMetadata, additionalViewers?: string[], output?: ComputeOutput, policyServer?: any, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
163
163
|
/** Instruct the provider to start a FREE compute job (new C2D V2)
|
|
164
164
|
* @param {string} providerUri The provider URI.
|
|
165
165
|
* @param {SignerOrAuthToken} signerOrAuthToken The consumer signer object or auth token.
|
|
@@ -173,7 +173,7 @@ export declare class Provider {
|
|
|
173
173
|
* @param {AbortSignal} signal abort signal
|
|
174
174
|
* @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
|
|
175
175
|
*/
|
|
176
|
-
freeComputeStart(providerUri: string, signerOrAuthToken: Signer | string, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, resources?: ComputeResourceRequest[], metadata?: ComputeJobMetadata, output?: ComputeOutput, policyServer?: any, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
176
|
+
freeComputeStart(providerUri: string, signerOrAuthToken: Signer | string, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, resources?: ComputeResourceRequest[], metadata?: ComputeJobMetadata, additionalViewers?: string[], output?: ComputeOutput, policyServer?: any, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
177
177
|
/**
|
|
178
178
|
*
|
|
179
179
|
* @param providerUri provider URL
|
|
@@ -185,15 +185,14 @@ export declare class Provider {
|
|
|
185
185
|
computeStreamableLogs(providerUri: string, signerOrAuthToken: Signer | string, jobId: string, signal?: AbortSignal): Promise<any>;
|
|
186
186
|
getComputeStartRoutes(providerUri: string, isFreeCompute?: boolean): Promise<string | null>;
|
|
187
187
|
/** Instruct the provider to Stop the execution of a to stop a compute job.
|
|
188
|
-
* @param {string} did the asset did
|
|
189
|
-
* @param {string} consumerAddress The consumer address.
|
|
190
188
|
* @param {string} jobId the compute job id
|
|
191
189
|
* @param {string} providerUri The provider URI.
|
|
192
190
|
* @param {SignerOrAuthToken} signerOrAuthToken The consumer signer or auth token.
|
|
191
|
+
* @param {string} agreementId The agreement id.
|
|
193
192
|
* @param {AbortSignal} signal abort signal
|
|
194
193
|
* @return {Promise<ComputeJob | ComputeJob[]>}
|
|
195
194
|
*/
|
|
196
|
-
computeStop(
|
|
195
|
+
computeStop(jobId: string, providerUri: string, signerOrAuthToken: Signer | string, agreementId?: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
197
196
|
/** Get compute status for a specific jobId/documentId/owner.
|
|
198
197
|
* @param {string} providerUri The URI of the provider we want to query
|
|
199
198
|
* @param {string} consumerAddress The consumer ethereum address
|
|
@@ -243,6 +242,18 @@ export declare class Provider {
|
|
|
243
242
|
* @return {Promise<boolean>} valid or not
|
|
244
243
|
*/
|
|
245
244
|
isValidProvider(url: string, signal?: AbortSignal): Promise<boolean>;
|
|
245
|
+
/** Sends a PolicyServer request to node to be passthrough to PS
|
|
246
|
+
* @param {string} providerUri The provider URI.
|
|
247
|
+
* @param {PolicyServerPassthroughCommand} request The request to be passed through to the Policy Server.
|
|
248
|
+
* @param {AbortSignal} signal abort signal
|
|
249
|
+
*/
|
|
250
|
+
PolicyServerPassthrough(providerUri: string, request: PolicyServerPassthroughCommand, signal?: AbortSignal): Promise<any>;
|
|
251
|
+
/** Initialize Policy Server verification
|
|
252
|
+
* @param {string} providerUri The provider URI.
|
|
253
|
+
* @param {PolicyServerInitializeCommand} request The request to be sent to the Policy Server.
|
|
254
|
+
* @param {AbortSignal} signal abort signal
|
|
255
|
+
*/
|
|
256
|
+
initializePSVerification(providerUri: string, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
|
|
246
257
|
/**
|
|
247
258
|
* Private method that removes the leading 0x from a string.
|
|
248
259
|
* @param {string} input - The input string.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Signer,
|
|
1
|
+
import { Signer, Contract, TransactionResponse, BaseContractMethod, EventLog, TransactionReceipt } from 'ethers';
|
|
2
2
|
import { Config } from '../config/index.js';
|
|
3
3
|
export declare function setContractDefaults(contract: Contract, config: Config): Contract;
|
|
4
4
|
/**
|
|
@@ -33,7 +33,7 @@ export declare function unitsToAmount(signer: Signer, token: string, amount: str
|
|
|
33
33
|
* @returns {Promise<string>} - The converted amount in units
|
|
34
34
|
*/
|
|
35
35
|
export declare function amountToUnits(signer: Signer, token: string, amount: string, tokenDecimals?: number): Promise<string>;
|
|
36
|
-
export declare function getEventFromTx(txReceipt:
|
|
36
|
+
export declare function getEventFromTx(txReceipt: TransactionReceipt, eventName: string): EventLog | undefined;
|
|
37
37
|
/**
|
|
38
38
|
* Send the transation on chain
|
|
39
39
|
* @param {BigNumber} estGas estimated gas for the transaction
|
|
@@ -43,4 +43,4 @@ export declare function getEventFromTx(txReceipt: any, eventName: any): any;
|
|
|
43
43
|
* @param {...any[]} args arguments of the function
|
|
44
44
|
* @return {Promise<any>} transaction receipt
|
|
45
45
|
*/
|
|
46
|
-
export declare function sendTx(estGas:
|
|
46
|
+
export declare function sendTx(estGas: bigint, signer: Signer, gasFeeMultiplier: number, functionToSend: BaseContractMethod, ...args: any[]): Promise<TransactionResponse>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Simple blocking sleep function
|
|
3
|
-
* @param {number} ms - Number of
|
|
3
|
+
* @param {number} ms - Number of milliseconds to wait
|
|
4
4
|
*/
|
|
5
5
|
export declare function sleep(ms: number): Promise<unknown>;
|
|
6
6
|
export declare function isDefined(something: any): boolean;
|
|
@@ -21,4 +21,4 @@ import { Asset } from '@oceanprotocol/ddo-js';
|
|
|
21
21
|
* @returns {Promise<void>} - A promise that resolves when the asset order process is completed.
|
|
22
22
|
* @throws {Error} If the pricing schema is not supported or if required indexes are invalid.
|
|
23
23
|
*/
|
|
24
|
-
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("
|
|
24
|
+
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("ethers").TransactionResponse>;
|
package/docs/classes/Aquarius.md
CHANGED
|
@@ -161,7 +161,7 @@ Blocks until Indexer will cache the did (or the update for that did) or timeouts
|
|
|
161
161
|
| `did` | `string` | DID of the asset. |
|
|
162
162
|
| `txid?` | `string` | used when the did exists and we expect an update with that txid. |
|
|
163
163
|
| `signal?` | `AbortSignal` | abort signal |
|
|
164
|
-
| `interval` | `number` | retry interval in
|
|
164
|
+
| `interval` | `number` | retry interval in milliseconds. Default is 3000 |
|
|
165
165
|
| `maxRetries` | `number` | max number of retries. Default is 100 |
|
|
166
166
|
|
|
167
167
|
#### Returns
|
|
@@ -315,7 +315,7 @@ ___
|
|
|
315
315
|
|
|
316
316
|
▸ **setBatchAllocation**<`G`\>(`amount`, `nft`, `chainId`, `estimateGas?`): `Promise`<[`ReceiptOrEstimate`](../modules.md#receiptorestimate)<`G`\>\>
|
|
317
317
|
|
|
318
|
-
set specific
|
|
318
|
+
set specific percentage of veOcean to multiple nfts
|
|
319
319
|
Maximum allocated percentage is 10000, so 1% is specified as 100
|
|
320
320
|
|
|
321
321
|
#### Type parameters
|
package/docs/modules.md
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oceanprotocol/lib",
|
|
3
3
|
"source": "./src/index.ts",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0-next.1",
|
|
5
5
|
"description": "JavaScript client library for Ocean Protocol",
|
|
6
6
|
"main": "./dist/lib.cjs",
|
|
7
7
|
"umd:main": "dist/lib.umd.js",
|
|
@@ -62,28 +62,29 @@
|
|
|
62
62
|
"@rdfjs/dataset": "^2.0.2",
|
|
63
63
|
"@rdfjs/formats-common": "^3.1.0",
|
|
64
64
|
"@zazuko/env-node": "^2.1.4",
|
|
65
|
+
"bignumber.js": "^9.3.1",
|
|
65
66
|
"cross-fetch": "^4.0.0",
|
|
66
67
|
"crypto-js": "^4.1.1",
|
|
67
68
|
"decimal.js": "^10.4.1",
|
|
68
|
-
"ethers": "^
|
|
69
|
+
"ethers": "^6.15.0",
|
|
69
70
|
"form-data": "^2.3.3",
|
|
70
71
|
"jsonwebtoken": "^9.0.2"
|
|
71
72
|
},
|
|
72
73
|
"devDependencies": {
|
|
73
74
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
74
75
|
"@truffle/hdwallet-provider": "^2.0.14",
|
|
75
|
-
"@types/chai": "^
|
|
76
|
+
"@types/chai": "^5.2.2",
|
|
76
77
|
"@types/chai-spies": "^1.0.3",
|
|
77
78
|
"@types/crypto-js": "^4.1.1",
|
|
78
79
|
"@types/jsonwebtoken": "^9.0.10",
|
|
79
80
|
"@types/mocha": "^10.0.10",
|
|
80
|
-
"@types/node": "^
|
|
81
|
+
"@types/node": "^22.15.29",
|
|
81
82
|
"@types/node-fetch": "^3.0.3",
|
|
82
83
|
"@typescript-eslint/eslint-plugin": "^6.4.1",
|
|
83
84
|
"@typescript-eslint/parser": "^6.4.1",
|
|
84
85
|
"auto-changelog": "^2.4.0",
|
|
85
86
|
"c8": "^10.1.3",
|
|
86
|
-
"chai": "^
|
|
87
|
+
"chai": "^5.2.1",
|
|
87
88
|
"chai-spies": "^1.0.0",
|
|
88
89
|
"cross-env": "^7.0.3",
|
|
89
90
|
"eslint": "^8.23.1",
|
|
@@ -91,8 +92,8 @@
|
|
|
91
92
|
"eslint-config-prettier": "^10.1.5",
|
|
92
93
|
"eslint-plugin-prettier": "^4.2.1",
|
|
93
94
|
"fs": "0.0.1-security",
|
|
94
|
-
"microbundle": "0.
|
|
95
|
-
"mocha": "^
|
|
95
|
+
"microbundle": "^0.15.1",
|
|
96
|
+
"mocha": "^11.7.1",
|
|
96
97
|
"mock-local-storage": "^1.1.24",
|
|
97
98
|
"nyc": "^17.1.0",
|
|
98
99
|
"ora": "5.4.1",
|