@human-protocol/sdk 6.1.0 → 7.0.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 +21 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +26 -14
- package/dist/encryption/encryption.d.ts +84 -0
- package/dist/encryption/encryption.d.ts.map +1 -0
- package/dist/{encryption.js → encryption/encryption.js} +3 -161
- package/dist/encryption/encryption_utils.d.ts +101 -0
- package/dist/encryption/encryption_utils.d.ts.map +1 -0
- package/dist/encryption/encryption_utils.js +191 -0
- package/dist/encryption/index.d.ts +4 -0
- package/dist/encryption/index.d.ts.map +1 -0
- package/dist/encryption/index.js +7 -0
- package/dist/encryption/types.d.ts +9 -0
- package/dist/encryption/types.d.ts.map +1 -0
- package/dist/encryption/types.js +9 -0
- package/dist/error.d.ts +6 -10
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +12 -14
- package/dist/{escrow.d.ts → escrow/escrow_client.d.ts} +4 -184
- package/dist/{escrow.d.ts.map → escrow/escrow_client.d.ts.map} +1 -1
- package/dist/{escrow.js → escrow/escrow_client.js} +35 -411
- package/dist/escrow/escrow_utils.d.ts +172 -0
- package/dist/escrow/escrow_utils.d.ts.map +1 -0
- package/dist/escrow/escrow_utils.js +388 -0
- package/dist/escrow/index.d.ts +3 -0
- package/dist/escrow/index.d.ts.map +1 -0
- package/dist/escrow/index.js +7 -0
- package/dist/graphql/queries/statistics.d.ts +1 -0
- package/dist/graphql/queries/statistics.d.ts.map +1 -1
- package/dist/graphql/queries/statistics.js +36 -2
- package/dist/graphql/types.d.ts +3 -1
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -22
- package/dist/interfaces.d.ts +0 -5
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore/index.d.ts +3 -0
- package/dist/kvstore/index.d.ts.map +1 -0
- package/dist/kvstore/index.js +7 -0
- package/dist/{kvstore.d.ts → kvstore/kvstore_client.d.ts} +3 -108
- package/dist/kvstore/kvstore_client.d.ts.map +1 -0
- package/dist/{kvstore.js → kvstore/kvstore_client.js} +22 -184
- package/dist/kvstore/kvstore_utils.d.ts +105 -0
- package/dist/kvstore/kvstore_utils.d.ts.map +1 -0
- package/dist/kvstore/kvstore_utils.js +184 -0
- package/dist/operator/index.d.ts +2 -0
- package/dist/operator/index.d.ts.map +1 -0
- package/dist/operator/index.js +5 -0
- package/dist/{operator.d.ts → operator/operator_utils.d.ts} +3 -3
- package/dist/operator/operator_utils.d.ts.map +1 -0
- package/dist/{operator.js → operator/operator_utils.js} +6 -6
- package/dist/staking/index.d.ts +3 -0
- package/dist/staking/index.d.ts.map +1 -0
- package/dist/staking/index.js +7 -0
- package/dist/{staking.d.ts → staking/staking_client.d.ts} +4 -65
- package/dist/staking/staking_client.d.ts.map +1 -0
- package/dist/{staking.js → staking/staking_client.js} +6 -136
- package/dist/staking/staking_utils.d.ts +63 -0
- package/dist/staking/staking_utils.d.ts.map +1 -0
- package/dist/staking/staking_utils.js +137 -0
- package/dist/statistics/index.d.ts +2 -0
- package/dist/statistics/index.d.ts.map +1 -0
- package/dist/statistics/index.js +5 -0
- package/dist/{statistics.d.ts → statistics/statistics_utils.d.ts} +4 -13
- package/dist/statistics/statistics_utils.d.ts.map +1 -0
- package/dist/{statistics.js → statistics/statistics_utils.js} +8 -22
- package/dist/transaction/index.d.ts +2 -0
- package/dist/transaction/index.d.ts.map +1 -0
- package/dist/transaction/index.js +5 -0
- package/dist/{transaction.d.ts → transaction/transaction_utils.d.ts} +3 -3
- package/dist/transaction/transaction_utils.d.ts.map +1 -0
- package/dist/{transaction.js → transaction/transaction_utils.js} +5 -5
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +15 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +71 -4
- package/dist/worker/index.d.ts +2 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +5 -0
- package/dist/{worker.d.ts → worker/worker_utils.d.ts} +3 -3
- package/dist/worker/worker_utils.d.ts.map +1 -0
- package/dist/{worker.js → worker/worker_utils.js} +5 -5
- package/package.json +4 -4
- package/src/constants.ts +38 -14
- package/src/{encryption.ts → encryption/encryption.ts} +1 -193
- package/src/encryption/encryption_utils.ts +179 -0
- package/src/encryption/index.ts +3 -0
- package/src/encryption/types.ts +15 -0
- package/src/error.ts +11 -17
- package/src/{escrow.ts → escrow/escrow_client.ts} +36 -556
- package/src/escrow/escrow_utils.ts +510 -0
- package/src/escrow/index.ts +2 -0
- package/src/graphql/queries/statistics.ts +37 -1
- package/src/graphql/types.ts +4 -1
- package/src/index.ts +11 -25
- package/src/interfaces.ts +0 -5
- package/src/kvstore/index.ts +2 -0
- package/src/{kvstore.ts → kvstore/kvstore_client.ts} +27 -241
- package/src/kvstore/kvstore_utils.ts +244 -0
- package/src/operator/index.ts +1 -0
- package/src/{operator.ts → operator/operator_utils.ts} +8 -8
- package/src/staking/index.ts +2 -0
- package/src/{staking.ts → staking/staking_client.ts} +8 -174
- package/src/staking/staking_utils.ts +170 -0
- package/src/statistics/index.ts +1 -0
- package/src/{statistics.ts → statistics/statistics_utils.ts} +14 -26
- package/src/transaction/index.ts +1 -0
- package/src/{transaction.ts → transaction/transaction_utils.ts} +7 -7
- package/src/types.ts +8 -0
- package/src/utils.ts +80 -3
- package/src/worker/index.ts +1 -0
- package/src/{worker.ts → worker/worker_utils.ts} +7 -7
- package/dist/encryption.d.ts +0 -189
- package/dist/encryption.d.ts.map +0 -1
- package/dist/kvstore.d.ts.map +0 -1
- package/dist/operator.d.ts.map +0 -1
- package/dist/staking.d.ts.map +0 -1
- package/dist/statistics.d.ts.map +0 -1
- package/dist/transaction.d.ts.map +0 -1
- package/dist/worker.d.ts.map +0 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.EncryptionUtils = void 0;
|
|
37
|
+
const openpgp = __importStar(require("openpgp"));
|
|
38
|
+
const types_1 = require("./types");
|
|
39
|
+
/**
|
|
40
|
+
* Utility class for encryption-related operations.
|
|
41
|
+
*/
|
|
42
|
+
class EncryptionUtils {
|
|
43
|
+
/**
|
|
44
|
+
* This function verifies the signature of a signed message using the public key.
|
|
45
|
+
*
|
|
46
|
+
* @param message - Message to verify.
|
|
47
|
+
* @param publicKey - Public key to verify that the message was signed by a specific source.
|
|
48
|
+
* @returns True if verified. False if not verified.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { EncryptionUtils } from '@human-protocol/sdk';
|
|
53
|
+
*
|
|
54
|
+
* const publicKey = '-----BEGIN PGP PUBLIC KEY BLOCK-----...';
|
|
55
|
+
* const result = await EncryptionUtils.verify('message', publicKey);
|
|
56
|
+
* console.log('Verification result:', result);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
static async verify(message, publicKey) {
|
|
60
|
+
const pgpPublicKey = await openpgp.readKey({ armoredKey: publicKey });
|
|
61
|
+
const signedMessage = await openpgp.readCleartextMessage({
|
|
62
|
+
cleartextMessage: message,
|
|
63
|
+
});
|
|
64
|
+
const verificationResult = await signedMessage.verify([pgpPublicKey]);
|
|
65
|
+
const { verified } = verificationResult[0];
|
|
66
|
+
try {
|
|
67
|
+
return await verified;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* This function gets signed data from a signed message.
|
|
75
|
+
*
|
|
76
|
+
* @param message - Message.
|
|
77
|
+
* @returns Signed data.
|
|
78
|
+
* @throws Error If data could not be extracted from the message
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* import { EncryptionUtils } from '@human-protocol/sdk';
|
|
83
|
+
*
|
|
84
|
+
* const signedData = await EncryptionUtils.getSignedData('message');
|
|
85
|
+
* console.log('Signed data:', signedData);
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
static async getSignedData(message) {
|
|
89
|
+
const signedMessage = await openpgp.readCleartextMessage({
|
|
90
|
+
cleartextMessage: message,
|
|
91
|
+
});
|
|
92
|
+
try {
|
|
93
|
+
return signedMessage.getText();
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
throw new Error('Could not get data: ' + e.message);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* This function generates a key pair for encryption and decryption.
|
|
101
|
+
*
|
|
102
|
+
* @param name - Name for the key pair.
|
|
103
|
+
* @param email - Email for the key pair.
|
|
104
|
+
* @param passphrase - Passphrase to encrypt the private key (optional, defaults to empty string).
|
|
105
|
+
* @returns Key pair generated.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* import { EncryptionUtils } from '@human-protocol/sdk';
|
|
110
|
+
*
|
|
111
|
+
* const name = 'YOUR_NAME';
|
|
112
|
+
* const email = 'YOUR_EMAIL';
|
|
113
|
+
* const passphrase = 'YOUR_PASSPHRASE';
|
|
114
|
+
* const keyPair = await EncryptionUtils.generateKeyPair(name, email, passphrase);
|
|
115
|
+
* console.log('Public key:', keyPair.publicKey);
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
static async generateKeyPair(name, email, passphrase = '') {
|
|
119
|
+
const { privateKey, publicKey, revocationCertificate } = await openpgp.generateKey({
|
|
120
|
+
type: 'ecc',
|
|
121
|
+
curve: 'ed25519Legacy',
|
|
122
|
+
userIDs: [{ name: name, email: email }],
|
|
123
|
+
passphrase: passphrase,
|
|
124
|
+
format: 'armored',
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
passphrase: passphrase,
|
|
128
|
+
privateKey,
|
|
129
|
+
publicKey,
|
|
130
|
+
revocationCertificate,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* This function encrypts a message using the specified public keys.
|
|
135
|
+
*
|
|
136
|
+
* @param message - Message to encrypt.
|
|
137
|
+
* @param publicKeys - Array of public keys to use for encryption.
|
|
138
|
+
* @returns Message encrypted.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* import { EncryptionUtils } from '@human-protocol/sdk';
|
|
143
|
+
*
|
|
144
|
+
* const publicKey1 = '-----BEGIN PGP PUBLIC KEY BLOCK-----...';
|
|
145
|
+
* const publicKey2 = '-----BEGIN PGP PUBLIC KEY BLOCK-----...';
|
|
146
|
+
* const publicKeys = [publicKey1, publicKey2];
|
|
147
|
+
* const encryptedMessage = await EncryptionUtils.encrypt('message', publicKeys);
|
|
148
|
+
* console.log('Encrypted message:', encryptedMessage);
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
static async encrypt(message, publicKeys) {
|
|
152
|
+
const pgpPublicKeys = await Promise.all(publicKeys.map((armoredKey) => openpgp.readKey({ armoredKey })));
|
|
153
|
+
const pgpMessage = await openpgp.createMessage({
|
|
154
|
+
binary: (0, types_1.makeMessageDataBinary)(message),
|
|
155
|
+
});
|
|
156
|
+
const encrypted = await openpgp.encrypt({
|
|
157
|
+
message: pgpMessage,
|
|
158
|
+
encryptionKeys: pgpPublicKeys,
|
|
159
|
+
format: 'armored',
|
|
160
|
+
});
|
|
161
|
+
return encrypted;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Verifies if a message appears to be encrypted with OpenPGP.
|
|
165
|
+
*
|
|
166
|
+
* @param message - Message to verify.
|
|
167
|
+
* @returns `true` if the message appears to be encrypted, `false` if not.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* import { EncryptionUtils } from '@human-protocol/sdk';
|
|
172
|
+
*
|
|
173
|
+
* const message = '-----BEGIN PGP MESSAGE-----...';
|
|
174
|
+
* const isEncrypted = EncryptionUtils.isEncrypted(message);
|
|
175
|
+
*
|
|
176
|
+
* if (isEncrypted) {
|
|
177
|
+
* console.log('The message is encrypted with OpenPGP.');
|
|
178
|
+
* } else {
|
|
179
|
+
* console.log('The message is not encrypted with OpenPGP.');
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
static isEncrypted(message) {
|
|
184
|
+
const startMarker = '-----BEGIN PGP MESSAGE-----';
|
|
185
|
+
const endMarker = '-----END PGP MESSAGE-----';
|
|
186
|
+
const hasStartMarker = message.includes(startMarker);
|
|
187
|
+
const hasEndMarker = message.includes(endMarker);
|
|
188
|
+
return hasStartMarker && hasEndMarker;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.EncryptionUtils = EncryptionUtils;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/encryption/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EncryptionUtils = exports.Encryption = void 0;
|
|
4
|
+
var encryption_1 = require("./encryption");
|
|
5
|
+
Object.defineProperty(exports, "Encryption", { enumerable: true, get: function () { return encryption_1.Encryption; } });
|
|
6
|
+
var encryption_utils_1 = require("./encryption_utils");
|
|
7
|
+
Object.defineProperty(exports, "EncryptionUtils", { enumerable: true, get: function () { return encryption_utils_1.EncryptionUtils; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type representing the data type of a message.
|
|
3
|
+
* It can be either a string or a Uint8Array.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export type MessageDataType = string | Uint8Array;
|
|
8
|
+
export declare function makeMessageDataBinary(message: MessageDataType): Uint8Array;
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/encryption/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,UAAU,CAAC;AAElD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,UAAU,CAM1E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeMessageDataBinary = makeMessageDataBinary;
|
|
4
|
+
function makeMessageDataBinary(message) {
|
|
5
|
+
if (typeof message === 'string') {
|
|
6
|
+
return Buffer.from(message);
|
|
7
|
+
}
|
|
8
|
+
return message;
|
|
9
|
+
}
|
package/dist/error.d.ts
CHANGED
|
@@ -118,14 +118,6 @@ export declare const ErrorInvalidManifest: Error;
|
|
|
118
118
|
* @constant {Error} - No URL provided.
|
|
119
119
|
*/
|
|
120
120
|
export declare const ErrorNoURLprovided: Error;
|
|
121
|
-
/**
|
|
122
|
-
* @constant {Error} - Fee must be between 0 and 100.
|
|
123
|
-
*/
|
|
124
|
-
export declare const ErrorFeeMustBeBetweenZeroAndHundred: Error;
|
|
125
|
-
/**
|
|
126
|
-
* @constant {Error} - Total fee must be less than 100.
|
|
127
|
-
*/
|
|
128
|
-
export declare const ErrorTotalFeeMustBeLessThanHundred: Error;
|
|
129
121
|
/**
|
|
130
122
|
* @constant {Error} - Recipient cannot be an empty array.
|
|
131
123
|
*/
|
|
@@ -214,7 +206,11 @@ export declare class ContractExecutionError extends EthereumError {
|
|
|
214
206
|
export declare class InvalidEthereumAddressError extends Error {
|
|
215
207
|
constructor(address: string);
|
|
216
208
|
}
|
|
217
|
-
export declare class
|
|
218
|
-
|
|
209
|
+
export declare class SubgraphRequestError extends Error {
|
|
210
|
+
readonly statusCode?: number;
|
|
211
|
+
readonly url: string;
|
|
212
|
+
constructor(message: string, url: string, statusCode?: number);
|
|
213
|
+
}
|
|
214
|
+
export declare class SubgraphBadIndexerError extends SubgraphRequestError {
|
|
219
215
|
}
|
|
220
216
|
//# sourceMappingURL=error.d.ts.map
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,mBAAmB,OAA2C,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,oBAAoB,OAAmC,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,uBAAuB,OAEnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,OAA+B,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,wBAAwB,OAAqC,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,0CAA0C,OAEtD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2CAA2C,OAEvD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yCAAyC,OAErD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+BAA+B,OAE3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,OAExC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,OAExC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC,OAE9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,OAE7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,OAAqC,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,wCAAwC,OAEpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,OAE7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,OAA0C,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,mDAAmD,OAE/D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,OAEvC,CAAC;AAEF;;GAEG;AACH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hB,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAM9D;AAED,qBAAa,uBAAwB,SAAQ,oBAAoB;CAAG"}
|
package/dist/error.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidArgumentError = exports.EthereumError = exports.WarnSubgraphApiKeyNotProvided = exports.WarnVersionMismatch = exports.ErrorRoutingRequestsToIndexerRequiresApiKey = exports.ErrorRetryParametersMissing = exports.ErrorBulkPayOutVersion = exports.ErrorStoreResultsVersion = exports.ErrorUnsupportedStatus = exports.ErrorInvalidHash = exports.ErrorHashIsEmptyString = exports.ErrorLaunchedEventIsNotEmitted = exports.ErrorRecipientAndAmountsMustBeSameLength = exports.ErrorAmountsCannotBeEmptyArray = exports.ErrorEscrowDoesNotHaveEnoughBalance = exports.ErrorAmountMustBeGreaterThanZero = exports.ErrorTooManyRecipients = exports.ErrorRecipientCannotBeEmptyArray = exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.NumericFault = exports.ReplacementUnderpriced = exports.InvalidArgumentError = exports.EthereumError = exports.WarnSubgraphApiKeyNotProvided = exports.WarnVersionMismatch = exports.ErrorRoutingRequestsToIndexerRequiresApiKey = exports.ErrorRetryParametersMissing = exports.ErrorBulkPayOutVersion = exports.ErrorStoreResultsVersion = exports.ErrorUnsupportedStatus = exports.ErrorInvalidHash = exports.ErrorHashIsEmptyString = exports.ErrorLaunchedEventIsNotEmitted = exports.ErrorRecipientAndAmountsMustBeSameLength = exports.ErrorAmountsCannotBeEmptyArray = exports.ErrorEscrowDoesNotHaveEnoughBalance = exports.ErrorAmountMustBeGreaterThanZero = exports.ErrorTooManyRecipients = exports.ErrorRecipientCannotBeEmptyArray = exports.ErrorNoURLprovided = exports.ErrorInvalidManifest = exports.ErrorInvalidUrl = exports.ErrorManifestFileDoesNotExist = exports.ErrorTransferEventNotFoundInTransactionLogs = exports.ErrorEscrowAddressIsNotProvidedByFactory = exports.ErrorSigner = exports.ErrorStakerNotFound = exports.ErrorUnsupportedChainID = exports.ErrorProviderDoesNotExist = exports.ErrorHMTokenAmountNotApproved = exports.ErrorFailedToCheckAllowance = exports.ErrorFailedToApproveStakingAmountSignerDoesNotExist = exports.ErrorStakingGetStakers = exports.ErrorInvalidEscrowAddressProvided = exports.ErrorCannotUseDateAndBlockSimultaneously = exports.ErrorInvalidHashProvided = exports.ErrorInvalidStakerAddressProvided = exports.ErrorInvalidSlasherAddressProvided = exports.ErrorInvalidStakingValueSign = exports.ErrorInvalidStakingValueType = exports.ErrorStakingValueMustBePositive = exports.ErrorInvalidExchangeOracleAddressProvided = exports.ErrorInvalidReputationOracleAddressProvided = exports.ErrorInvalidRecordingOracleAddressProvided = exports.ErrorInvalidTokenAddress = exports.ErrorInvalidAddress = exports.ErrorKVStoreArrayLength = exports.ErrorKVStoreEmptyKey = exports.ErrorStakingMissing = void 0;
|
|
4
|
+
exports.SubgraphBadIndexerError = exports.SubgraphRequestError = exports.InvalidEthereumAddressError = exports.ContractExecutionError = exports.TransactionReplaced = exports.NonceExpired = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* @constant {Error} - The Staking contract is missing.
|
|
7
7
|
*/
|
|
@@ -122,14 +122,6 @@ exports.ErrorInvalidManifest = new Error('Invalid manifest');
|
|
|
122
122
|
* @constant {Error} - No URL provided.
|
|
123
123
|
*/
|
|
124
124
|
exports.ErrorNoURLprovided = new Error('No URL provided');
|
|
125
|
-
/**
|
|
126
|
-
* @constant {Error} - Fee must be between 0 and 100.
|
|
127
|
-
*/
|
|
128
|
-
exports.ErrorFeeMustBeBetweenZeroAndHundred = new Error('Fee must be between 0 and 100');
|
|
129
|
-
/**
|
|
130
|
-
* @constant {Error} - Total fee must be less than 100.
|
|
131
|
-
*/
|
|
132
|
-
exports.ErrorTotalFeeMustBeLessThanHundred = new Error('Total fee must be less than 100');
|
|
133
125
|
/**
|
|
134
126
|
* @constant {Error} - Recipient cannot be an empty array.
|
|
135
127
|
*/
|
|
@@ -242,9 +234,15 @@ class InvalidEthereumAddressError extends Error {
|
|
|
242
234
|
}
|
|
243
235
|
}
|
|
244
236
|
exports.InvalidEthereumAddressError = InvalidEthereumAddressError;
|
|
245
|
-
class
|
|
246
|
-
constructor(
|
|
247
|
-
super(
|
|
237
|
+
class SubgraphRequestError extends Error {
|
|
238
|
+
constructor(message, url, statusCode) {
|
|
239
|
+
super(message);
|
|
240
|
+
this.name = this.constructor.name;
|
|
241
|
+
this.url = url;
|
|
242
|
+
this.statusCode = statusCode;
|
|
248
243
|
}
|
|
249
244
|
}
|
|
250
|
-
exports.
|
|
245
|
+
exports.SubgraphRequestError = SubgraphRequestError;
|
|
246
|
+
class SubgraphBadIndexerError extends SubgraphRequestError {
|
|
247
|
+
}
|
|
248
|
+
exports.SubgraphBadIndexerError = SubgraphBadIndexerError;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { EscrowFactory } from '@human-protocol/core/typechain-types';
|
|
2
2
|
import { ContractRunner, Overrides } from 'ethers';
|
|
3
|
-
import { BaseEthersClient } from '
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { EscrowStatus, NetworkData, TransactionLikeWithNonce, TransactionOverrides } from './types';
|
|
3
|
+
import { BaseEthersClient } from '../base';
|
|
4
|
+
import { IEscrowConfig, IEscrowWithdraw } from '../interfaces';
|
|
5
|
+
import { EscrowStatus, NetworkData, TransactionLikeWithNonce, TransactionOverrides } from '../types';
|
|
7
6
|
/**
|
|
8
7
|
* Client to perform actions on Escrow contracts and obtain information from the contracts.
|
|
9
8
|
*
|
|
@@ -113,8 +112,6 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
113
112
|
* @throws ErrorInvalidRecordingOracleAddressProvided If the recording oracle address is invalid
|
|
114
113
|
* @throws ErrorInvalidReputationOracleAddressProvided If the reputation oracle address is invalid
|
|
115
114
|
* @throws ErrorInvalidExchangeOracleAddressProvided If the exchange oracle address is invalid
|
|
116
|
-
* @throws ErrorAmountMustBeGreaterThanZero If any oracle fee is less than or equal to zero
|
|
117
|
-
* @throws ErrorTotalFeeMustBeLessThanHundred If the total oracle fees exceed 100
|
|
118
115
|
* @throws ErrorInvalidManifest If the manifest is not a valid URL or JSON string
|
|
119
116
|
* @throws ErrorHashIsEmptyString If the manifest hash is empty
|
|
120
117
|
* @throws ErrorLaunchedEventIsNotEmitted If the LaunchedV2 event is not emitted
|
|
@@ -135,9 +132,6 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
135
132
|
* recordingOracle: '0xRecordingOracleAddress',
|
|
136
133
|
* reputationOracle: '0xReputationOracleAddress',
|
|
137
134
|
* exchangeOracle: '0xExchangeOracleAddress',
|
|
138
|
-
* recordingOracleFee: 5n,
|
|
139
|
-
* reputationOracleFee: 5n,
|
|
140
|
-
* exchangeOracleFee: 5n,
|
|
141
135
|
* manifest: 'https://example.com/manifest.json',
|
|
142
136
|
* manifestHash: 'manifestHash-123',
|
|
143
137
|
* };
|
|
@@ -164,8 +158,6 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
164
158
|
* @throws ErrorInvalidRecordingOracleAddressProvided If the recording oracle address is invalid
|
|
165
159
|
* @throws ErrorInvalidReputationOracleAddressProvided If the reputation oracle address is invalid
|
|
166
160
|
* @throws ErrorInvalidExchangeOracleAddressProvided If the exchange oracle address is invalid
|
|
167
|
-
* @throws ErrorAmountMustBeGreaterThanZero If any oracle fee is less than or equal to zero
|
|
168
|
-
* @throws ErrorTotalFeeMustBeLessThanHundred If the total oracle fees exceed 100
|
|
169
161
|
* @throws ErrorInvalidManifest If the manifest is not a valid URL or JSON string
|
|
170
162
|
* @throws ErrorHashIsEmptyString If the manifest hash is empty
|
|
171
163
|
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
@@ -179,9 +171,6 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
179
171
|
* recordingOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
180
172
|
* reputationOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
181
173
|
* exchangeOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
182
|
-
* recordingOracleFee: 10n,
|
|
183
|
-
* reputationOracleFee: 10n,
|
|
184
|
-
* exchangeOracleFee: 10n,
|
|
185
174
|
* manifest: 'http://localhost/manifest.json',
|
|
186
175
|
* manifestHash: 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079',
|
|
187
176
|
* };
|
|
@@ -700,173 +689,4 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
700
689
|
*/
|
|
701
690
|
getFactoryAddress(escrowAddress: string): Promise<string>;
|
|
702
691
|
}
|
|
703
|
-
|
|
704
|
-
* Utility helpers for escrow-related queries.
|
|
705
|
-
*
|
|
706
|
-
* @example
|
|
707
|
-
* ```ts
|
|
708
|
-
* import { ChainId, EscrowUtils } from '@human-protocol/sdk';
|
|
709
|
-
*
|
|
710
|
-
* const escrows = await EscrowUtils.getEscrows({
|
|
711
|
-
* chainId: ChainId.POLYGON_AMOY
|
|
712
|
-
* });
|
|
713
|
-
* console.log('Escrows:', escrows);
|
|
714
|
-
* ```
|
|
715
|
-
*/
|
|
716
|
-
export declare class EscrowUtils {
|
|
717
|
-
/**
|
|
718
|
-
* This function returns an array of escrows based on the specified filter parameters.
|
|
719
|
-
*
|
|
720
|
-
* @param filter - Filter parameters.
|
|
721
|
-
* @param options - Optional configuration for subgraph requests.
|
|
722
|
-
* @returns List of escrows that match the filter.
|
|
723
|
-
* @throws ErrorInvalidAddress If any filter address is invalid
|
|
724
|
-
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
725
|
-
*
|
|
726
|
-
* @example
|
|
727
|
-
* ```ts
|
|
728
|
-
* import { ChainId, EscrowStatus } from '@human-protocol/sdk';
|
|
729
|
-
*
|
|
730
|
-
* const filters = {
|
|
731
|
-
* status: EscrowStatus.Pending,
|
|
732
|
-
* from: new Date(2023, 4, 8),
|
|
733
|
-
* to: new Date(2023, 5, 8),
|
|
734
|
-
* chainId: ChainId.POLYGON_AMOY
|
|
735
|
-
* };
|
|
736
|
-
* const escrows = await EscrowUtils.getEscrows(filters);
|
|
737
|
-
* console.log('Found escrows:', escrows.length);
|
|
738
|
-
* ```
|
|
739
|
-
*/
|
|
740
|
-
static getEscrows(filter: IEscrowsFilter, options?: SubgraphOptions): Promise<IEscrow[]>;
|
|
741
|
-
/**
|
|
742
|
-
* This function returns the escrow data for a given address.
|
|
743
|
-
*
|
|
744
|
-
* > This uses Subgraph
|
|
745
|
-
*
|
|
746
|
-
* @param chainId - Network in which the escrow has been deployed
|
|
747
|
-
* @param escrowAddress - Address of the escrow
|
|
748
|
-
* @param options - Optional configuration for subgraph requests.
|
|
749
|
-
* @returns Escrow data or null if not found.
|
|
750
|
-
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
751
|
-
* @throws ErrorInvalidAddress If the escrow address is invalid
|
|
752
|
-
*
|
|
753
|
-
* @example
|
|
754
|
-
* ```ts
|
|
755
|
-
* import { ChainId } from '@human-protocol/sdk';
|
|
756
|
-
*
|
|
757
|
-
* const escrow = await EscrowUtils.getEscrow(
|
|
758
|
-
* ChainId.POLYGON_AMOY,
|
|
759
|
-
* "0x1234567890123456789012345678901234567890"
|
|
760
|
-
* );
|
|
761
|
-
* if (escrow) {
|
|
762
|
-
* console.log('Escrow status:', escrow.status);
|
|
763
|
-
* }
|
|
764
|
-
* ```
|
|
765
|
-
*/
|
|
766
|
-
static getEscrow(chainId: ChainId, escrowAddress: string, options?: SubgraphOptions): Promise<IEscrow | null>;
|
|
767
|
-
/**
|
|
768
|
-
* This function returns the status events for a given set of networks within an optional date range.
|
|
769
|
-
*
|
|
770
|
-
* > This uses Subgraph
|
|
771
|
-
*
|
|
772
|
-
* @param filter - Filter parameters.
|
|
773
|
-
* @param options - Optional configuration for subgraph requests.
|
|
774
|
-
* @returns Array of status events with their corresponding statuses.
|
|
775
|
-
* @throws ErrorInvalidAddress If the launcher address is invalid
|
|
776
|
-
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
777
|
-
*
|
|
778
|
-
* @example
|
|
779
|
-
* ```ts
|
|
780
|
-
* import { ChainId, EscrowStatus } from '@human-protocol/sdk';
|
|
781
|
-
*
|
|
782
|
-
* const fromDate = new Date('2023-01-01');
|
|
783
|
-
* const toDate = new Date('2023-12-31');
|
|
784
|
-
* const statusEvents = await EscrowUtils.getStatusEvents({
|
|
785
|
-
* chainId: ChainId.POLYGON,
|
|
786
|
-
* statuses: [EscrowStatus.Pending, EscrowStatus.Complete],
|
|
787
|
-
* from: fromDate,
|
|
788
|
-
* to: toDate
|
|
789
|
-
* });
|
|
790
|
-
* console.log('Status events:', statusEvents.length);
|
|
791
|
-
* ```
|
|
792
|
-
*/
|
|
793
|
-
static getStatusEvents(filter: IStatusEventFilter, options?: SubgraphOptions): Promise<IStatusEvent[]>;
|
|
794
|
-
/**
|
|
795
|
-
* This function returns the payouts for a given set of networks.
|
|
796
|
-
*
|
|
797
|
-
* > This uses Subgraph
|
|
798
|
-
*
|
|
799
|
-
* @param filter - Filter parameters.
|
|
800
|
-
* @param options - Optional configuration for subgraph requests.
|
|
801
|
-
* @returns List of payouts matching the filters.
|
|
802
|
-
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
803
|
-
* @throws ErrorInvalidAddress If any filter address is invalid
|
|
804
|
-
*
|
|
805
|
-
* @example
|
|
806
|
-
* ```ts
|
|
807
|
-
* import { ChainId } from '@human-protocol/sdk';
|
|
808
|
-
*
|
|
809
|
-
* const payouts = await EscrowUtils.getPayouts({
|
|
810
|
-
* chainId: ChainId.POLYGON,
|
|
811
|
-
* escrowAddress: '0x1234567890123456789012345678901234567890',
|
|
812
|
-
* recipient: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef',
|
|
813
|
-
* from: new Date('2023-01-01'),
|
|
814
|
-
* to: new Date('2023-12-31')
|
|
815
|
-
* });
|
|
816
|
-
* console.log('Payouts:', payouts.length);
|
|
817
|
-
* ```
|
|
818
|
-
*/
|
|
819
|
-
static getPayouts(filter: IPayoutFilter, options?: SubgraphOptions): Promise<IPayout[]>;
|
|
820
|
-
/**
|
|
821
|
-
* This function returns the cancellation refunds for a given set of networks.
|
|
822
|
-
*
|
|
823
|
-
* > This uses Subgraph
|
|
824
|
-
*
|
|
825
|
-
* @param filter - Filter parameters.
|
|
826
|
-
* @param options - Optional configuration for subgraph requests.
|
|
827
|
-
* @returns List of cancellation refunds matching the filters.
|
|
828
|
-
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
829
|
-
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
830
|
-
* @throws ErrorInvalidAddress If the receiver address is invalid
|
|
831
|
-
*
|
|
832
|
-
* @example
|
|
833
|
-
* ```ts
|
|
834
|
-
* import { ChainId } from '@human-protocol/sdk';
|
|
835
|
-
*
|
|
836
|
-
* const cancellationRefunds = await EscrowUtils.getCancellationRefunds({
|
|
837
|
-
* chainId: ChainId.POLYGON_AMOY,
|
|
838
|
-
* escrowAddress: '0x1234567890123456789012345678901234567890',
|
|
839
|
-
* });
|
|
840
|
-
* console.log('Cancellation refunds:', cancellationRefunds.length);
|
|
841
|
-
* ```
|
|
842
|
-
*/
|
|
843
|
-
static getCancellationRefunds(filter: ICancellationRefundFilter, options?: SubgraphOptions): Promise<ICancellationRefund[]>;
|
|
844
|
-
/**
|
|
845
|
-
* This function returns the cancellation refund for a given escrow address.
|
|
846
|
-
*
|
|
847
|
-
* > This uses Subgraph
|
|
848
|
-
*
|
|
849
|
-
* @param chainId - Network in which the escrow has been deployed
|
|
850
|
-
* @param escrowAddress - Address of the escrow
|
|
851
|
-
* @param options - Optional configuration for subgraph requests.
|
|
852
|
-
* @returns Cancellation refund data or null if not found.
|
|
853
|
-
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
854
|
-
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
855
|
-
*
|
|
856
|
-
* @example
|
|
857
|
-
* ```ts
|
|
858
|
-
* import { ChainId } from '@human-protocol/sdk';
|
|
859
|
-
*
|
|
860
|
-
*
|
|
861
|
-
* const cancellationRefund = await EscrowUtils.getCancellationRefund(
|
|
862
|
-
* ChainId.POLYGON_AMOY,
|
|
863
|
-
* "0x1234567890123456789012345678901234567890"
|
|
864
|
-
* );
|
|
865
|
-
* if (cancellationRefund) {
|
|
866
|
-
* console.log('Refund amount:', cancellationRefund.amount);
|
|
867
|
-
* }
|
|
868
|
-
* ```
|
|
869
|
-
*/
|
|
870
|
-
static getCancellationRefund(chainId: ChainId, escrowAddress: string, options?: SubgraphOptions): Promise<ICancellationRefund | null>;
|
|
871
|
-
}
|
|
872
|
-
//# sourceMappingURL=escrow.d.ts.map
|
|
692
|
+
//# sourceMappingURL=escrow_client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"escrow_client.d.ts","sourceRoot":"","sources":["../../src/escrow/escrow_client.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,aAAa,EAKd,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAY,SAAS,EAAkB,MAAM,QAAQ,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA6B3C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,WAAW,EACX,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;IACzC,qBAAqB,EAAE,aAAa,CAAC;IAE5C;;;;;;OAMG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,W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