@oceanprotocol/lib 1.0.0 → 1.1.2
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 +25 -0
- package/CodeExamples.md +19 -8
- 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/src/@types/File.d.ts +23 -0
- package/dist/src/@types/{FileMetadata.d.ts → FileInfo.d.ts} +1 -1
- package/dist/src/@types/index.d.ts +2 -1
- package/dist/src/provider/Provider.d.ts +5 -5
- package/dist/src/utils/TokenUtils.d.ts +17 -0
- package/package.json +8 -8
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface UrlFile {
|
|
2
|
+
type: 'url';
|
|
3
|
+
/**
|
|
4
|
+
* File index.
|
|
5
|
+
* @type {number}
|
|
6
|
+
*/
|
|
7
|
+
index?: number;
|
|
8
|
+
/**
|
|
9
|
+
* File URL.
|
|
10
|
+
* @type {string}
|
|
11
|
+
*/
|
|
12
|
+
url: string;
|
|
13
|
+
/**
|
|
14
|
+
* HTTP method used
|
|
15
|
+
* @type {string}
|
|
16
|
+
*/
|
|
17
|
+
method: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Files {
|
|
20
|
+
nftAddress: string;
|
|
21
|
+
datatokenAddress: string;
|
|
22
|
+
files: UrlFile[];
|
|
23
|
+
}
|
|
@@ -3,7 +3,8 @@ export * from './Asset';
|
|
|
3
3
|
export * from './DDO/Service';
|
|
4
4
|
export * from './DDO/Credentials';
|
|
5
5
|
export * from './DDO/Metadata';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './File';
|
|
7
|
+
export * from './FileInfo';
|
|
7
8
|
export * from './Compute';
|
|
8
9
|
export * from './Provider';
|
|
9
10
|
export * from './FixedPrice';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Web3 from 'web3';
|
|
2
|
-
import {
|
|
2
|
+
import { FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults } from '../@types/';
|
|
3
3
|
export interface HttpCallback {
|
|
4
4
|
(httpMethod: string, url: string, body: string, header: any): Promise<any>;
|
|
5
5
|
}
|
|
@@ -46,16 +46,16 @@ export declare class Provider {
|
|
|
46
46
|
* @param {number} serviceId the id of the service for which to check the files
|
|
47
47
|
* @param {string} providerUri uri of the provider that will be used to check the file
|
|
48
48
|
* @param {AbortSignal} signal abort signal
|
|
49
|
-
* @return {Promise<
|
|
49
|
+
* @return {Promise<FileInfo[]>} urlDetails
|
|
50
50
|
*/
|
|
51
|
-
checkDidFiles(did: string, serviceId: number, providerUri: string, signal?: AbortSignal): Promise<
|
|
51
|
+
checkDidFiles(did: string, serviceId: number, providerUri: string, signal?: AbortSignal): Promise<FileInfo[]>;
|
|
52
52
|
/** Get URL details (if possible)
|
|
53
53
|
* @param {string} url or did
|
|
54
54
|
* @param {string} providerUri uri of the provider that will be used to check the file
|
|
55
55
|
* @param {AbortSignal} signal abort signal
|
|
56
|
-
* @return {Promise<
|
|
56
|
+
* @return {Promise<FileInfo[]>} urlDetails
|
|
57
57
|
*/
|
|
58
|
-
checkFileUrl(url: string, providerUri: string, signal?: AbortSignal): Promise<
|
|
58
|
+
checkFileUrl(url: string, providerUri: string, signal?: AbortSignal): Promise<FileInfo[]>;
|
|
59
59
|
/** Get Compute Environments
|
|
60
60
|
* @return {Promise<ComputeEnvironment[]>} urlDetails
|
|
61
61
|
*/
|
|
@@ -22,6 +22,15 @@ export declare function estApprove(web3: Web3, account: string, tokenAddress: st
|
|
|
22
22
|
* @param {number} tokenDecimals optional number of decimals of the token
|
|
23
23
|
*/
|
|
24
24
|
export declare function approve(web3: Web3, account: string, tokenAddress: string, spender: string, amount: string, force?: boolean, tokenDecimals?: number): Promise<TransactionReceipt | string>;
|
|
25
|
+
/**
|
|
26
|
+
* Approve spender to spent amount tokens
|
|
27
|
+
* @param {String} account
|
|
28
|
+
* @param {String} tokenAddress
|
|
29
|
+
* @param {String} spender
|
|
30
|
+
* @param {String} amount amount of ERC20 tokens (always expressed as wei)
|
|
31
|
+
* @param {boolean} force if true, will overwrite any previous allowence. Else, will check if allowence is enough and will not send a transaction if it's not needed
|
|
32
|
+
*/
|
|
33
|
+
export declare function approveWei(web3: Web3, account: string, tokenAddress: string, spender: string, amount: string, force?: boolean): Promise<TransactionReceipt | string>;
|
|
25
34
|
/**
|
|
26
35
|
* Estimate gas cost for transfer function
|
|
27
36
|
* @param {String} account
|
|
@@ -51,6 +60,14 @@ export declare function transfer(web3: Web3, account: string, tokenAddress: stri
|
|
|
51
60
|
* @param {number} tokenDecimals optional number of decimals of the token
|
|
52
61
|
*/
|
|
53
62
|
export declare function allowance(web3: Web3, tokenAddress: string, account: string, spender: string, tokenDecimals?: number): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Get Allowance for any erc20
|
|
65
|
+
* @param {Web3} web3
|
|
66
|
+
* @param {String } tokenAdress
|
|
67
|
+
* @param {String} account
|
|
68
|
+
* @param {String} spender
|
|
69
|
+
*/
|
|
70
|
+
export declare function allowanceWei(web3: Web3, tokenAddress: string, account: string, spender: string, tokenDecimals?: number): Promise<string>;
|
|
54
71
|
/**
|
|
55
72
|
* Get balance for any erc20
|
|
56
73
|
* @param {Web3} web3
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oceanprotocol/lib",
|
|
3
3
|
"source": "./src/index.ts",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"description": "JavaScript client library for Ocean Protocol",
|
|
6
6
|
"main": "./dist/lib.js",
|
|
7
7
|
"umd:main": "dist/lib.umd.js",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"test:examples": "npm run mocha -- 'test/integration/CodeExamples.test.ts'",
|
|
40
40
|
"test:provider": "npm run mocha -- 'test/integration/Provider.test.ts'",
|
|
41
41
|
"test:unit": "npm run mocha -- 'test/unit/**/*.test.ts'",
|
|
42
|
-
"test:unit:cover": "nyc --report-dir coverage/unit npm run test:unit",
|
|
42
|
+
"test:unit:cover": "nyc --report-dir coverage/unit --exclude 'src/@types/**/*' npm run test:unit",
|
|
43
43
|
"test:integration": "npm run mocha -- 'test/integration/**/*.test.ts'",
|
|
44
44
|
"test:compute": "npm run mocha -- 'test/integration/ComputeFlow.test.ts'",
|
|
45
|
-
"test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration",
|
|
45
|
+
"test:integration:cover": "nyc --report-dir coverage/integration --exclude 'src/@types/**/*' --no-clean npm run test:integration",
|
|
46
46
|
"create:guide": "chmod +x ./scripts/createCodeExamples.sh && ./scripts/createCodeExamples.sh",
|
|
47
47
|
"create:guide:mac": "chmod +x ./scripts/createCodeExamples-mac.sh && ./scripts/createCodeExamples-mac.sh",
|
|
48
48
|
"commit:guide": "chmod +x scripts/commitChanges.sh && scripts/commitChanges.sh"
|
|
@@ -77,16 +77,16 @@
|
|
|
77
77
|
"@types/chai-spies": "^1.0.3",
|
|
78
78
|
"@types/crypto-js": "^4.1.1",
|
|
79
79
|
"@types/mocha": "^9.1.1",
|
|
80
|
-
"@types/node": "^17.0.
|
|
80
|
+
"@types/node": "^17.0.44",
|
|
81
81
|
"@types/node-fetch": "^3.0.3",
|
|
82
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
83
|
-
"@typescript-eslint/parser": "^
|
|
82
|
+
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
83
|
+
"@typescript-eslint/parser": "^5.28.0",
|
|
84
84
|
"auto-changelog": "^2.4.0",
|
|
85
85
|
"chai": "^4.3.6",
|
|
86
86
|
"chai-spies": "^1.0.0",
|
|
87
87
|
"cross-env": "^7.0.3",
|
|
88
|
-
"eslint": "^
|
|
89
|
-
"eslint-config-oceanprotocol": "^
|
|
88
|
+
"eslint": "^8.17.0",
|
|
89
|
+
"eslint-config-oceanprotocol": "^2.0.1",
|
|
90
90
|
"eslint-config-prettier": "^8.5.0",
|
|
91
91
|
"eslint-plugin-prettier": "^4.0.0",
|
|
92
92
|
"fs": "0.0.1-security",
|