@requestnetwork/utils 0.28.1-next.1351 → 0.28.1-next.709
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/README.md +2 -20
- package/dist/amount.d.ts +5 -9
- package/dist/amount.d.ts.map +1 -1
- package/dist/amount.js +19 -23
- package/dist/amount.js.map +1 -1
- package/dist/bignumber.d.ts +7 -0
- package/dist/bignumber.d.ts.map +1 -0
- package/dist/bignumber.js +11 -0
- package/dist/bignumber.js.map +1 -0
- package/dist/cached-throttle.d.ts +2 -2
- package/dist/cached-throttle.d.ts.map +1 -1
- package/dist/cached-throttle.js +5 -3
- package/dist/cached-throttle.js.map +1 -1
- package/dist/crypto/crypto-wrapper.d.ts +1 -8
- package/dist/crypto/crypto-wrapper.d.ts.map +1 -1
- package/dist/crypto/crypto-wrapper.js +19 -31
- package/dist/crypto/crypto-wrapper.js.map +1 -1
- package/dist/crypto/ec-utils.d.ts +6 -14
- package/dist/crypto/ec-utils.d.ts.map +1 -1
- package/dist/crypto/ec-utils.js +77 -41
- package/dist/crypto/ec-utils.js.map +1 -1
- package/dist/crypto.d.ts +14 -26
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +40 -30
- package/dist/crypto.js.map +1 -1
- package/dist/encryption.d.ts +1 -6
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +15 -27
- package/dist/encryption.js.map +1 -1
- package/dist/identity.d.ts +4 -9
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +11 -12
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +12 -69
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -28
- package/dist/index.js.map +1 -1
- package/dist/normalize-gas-fees.d.ts +19 -0
- package/dist/normalize-gas-fees.d.ts.map +1 -0
- package/dist/normalize-gas-fees.js +44 -0
- package/dist/normalize-gas-fees.js.map +1 -0
- package/dist/providers.d.ts +40 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +149 -0
- package/dist/providers.js.map +1 -0
- package/dist/retry.d.ts +10 -6
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +15 -16
- package/dist/retry.js.map +1 -1
- package/dist/signature.d.ts +3 -8
- package/dist/signature.d.ts.map +1 -1
- package/dist/signature.js +13 -19
- package/dist/signature.js.map +1 -1
- package/dist/simple-logger.d.ts +1 -1
- package/dist/simple-logger.d.ts.map +1 -1
- package/dist/simple-logger.js +4 -3
- package/dist/simple-logger.js.map +1 -1
- package/dist/utils.d.ts +11 -20
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +20 -21
- package/dist/utils.js.map +1 -1
- package/package.json +18 -26
- package/CHANGELOG.md +0 -1047
package/dist/retry.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.retry = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
12
5
|
// Default amount of retries
|
|
13
6
|
const DEFAULT_MAX_RETRIES = 5;
|
|
14
7
|
// Default delay between retries
|
|
15
8
|
const DEFAULT_RETRY_DELAY = 100;
|
|
9
|
+
// Default exponential backoff delay increment
|
|
10
|
+
const DEFAULT_EXPONENTIAL_BACKOFF_DELAY = 0;
|
|
11
|
+
// Maximum exponential backoff delay allowed
|
|
12
|
+
const DEFAULT_MAX_EXPONENTIAL_BACKOFF_DELAY = 30000;
|
|
16
13
|
/**
|
|
17
14
|
* A method that retries a function a defined amount of times if it fails.
|
|
18
15
|
*
|
|
@@ -21,19 +18,21 @@ const DEFAULT_RETRY_DELAY = 100;
|
|
|
21
18
|
* @param [options.context] The context to run the function
|
|
22
19
|
* @param [options.maxRetries=DEFAULT_MAX_RETRIES] The maximum amount of retries for the function
|
|
23
20
|
* @param [options.retryDelay=DEFAULT_RETRY_DELAY] The delay between retries
|
|
21
|
+
* @param [options.exponentialBackoffDelay=DEFAULT_EXPONENTIAL_BACKOFF_DELAY] The exponential backoff delay increment
|
|
22
|
+
* @param [options.maxExponentialBackoffDelay=DEFAULT_MAX_EXPONENTIAL_BACKOFF_DELAY] The maximum exponential backoff delay allowed
|
|
24
23
|
*/
|
|
25
|
-
|
|
26
|
-
// If a context was passed in, bind it to
|
|
24
|
+
const retry = (target, { context, maxRetries = DEFAULT_MAX_RETRIES, retryDelay = DEFAULT_RETRY_DELAY, exponentialBackoffDelay = DEFAULT_EXPONENTIAL_BACKOFF_DELAY, maxExponentialBackoffDelay = DEFAULT_MAX_EXPONENTIAL_BACKOFF_DELAY, } = {}) => {
|
|
25
|
+
// If a context was passed in, bind it to the target function
|
|
27
26
|
if (context) {
|
|
28
27
|
target = target.bind(context);
|
|
29
28
|
}
|
|
30
29
|
// Returns an external function that will contain the retry counter
|
|
31
|
-
return (...args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
return (...args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
32
31
|
// The current amount of retries
|
|
33
32
|
let retry = 0;
|
|
34
33
|
// Returns the retrying function that can be called
|
|
35
34
|
return (function retryFunction(...innerArgs) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
36
|
try {
|
|
38
37
|
// Call the target function with the target object as context
|
|
39
38
|
return yield target(...innerArgs);
|
|
@@ -43,9 +42,8 @@ exports.default = (target, { context, maxRetries = DEFAULT_MAX_RETRIES, retryDel
|
|
|
43
42
|
if (retry < maxRetries) {
|
|
44
43
|
retry++;
|
|
45
44
|
// Wait for the delay before retrying
|
|
46
|
-
yield new Promise((resolve) =>
|
|
47
|
-
|
|
48
|
-
});
|
|
45
|
+
yield new Promise((resolve) => setTimeout(resolve, retryDelay +
|
|
46
|
+
Math.min(maxExponentialBackoffDelay, exponentialBackoffDelay * Math.pow(2, retry))));
|
|
49
47
|
return retryFunction(...innerArgs);
|
|
50
48
|
}
|
|
51
49
|
else {
|
|
@@ -57,4 +55,5 @@ exports.default = (target, { context, maxRetries = DEFAULT_MAX_RETRIES, retryDel
|
|
|
57
55
|
})(...args);
|
|
58
56
|
});
|
|
59
57
|
};
|
|
58
|
+
exports.retry = retry;
|
|
60
59
|
//# sourceMappingURL=retry.js.map
|
package/dist/retry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":";;;;AAAA,4BAA4B;AAC5B,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,gCAAgC;AAChC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,8CAA8C;AAC9C,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAE5C,4CAA4C;AAC5C,MAAM,qCAAqC,GAAG,KAAK,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,KAAK,GAAG,CACZ,MAA0D,EAC1D,EACE,OAAO,EACP,UAAU,GAAG,mBAAmB,EAChC,UAAU,GAAG,mBAAmB,EAChC,uBAAuB,GAAG,iCAAiC,EAC3D,0BAA0B,GAAG,qCAAqC,MAOhE,EAAE,EACsC,EAAE;IAC9C,6DAA6D;IAC7D,IAAI,OAAO,EAAE;QACX,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAC/B;IAED,mEAAmE;IACnE,OAAO,CAAO,GAAG,IAAa,EAAoB,EAAE;QAClD,gCAAgC;QAChC,IAAI,KAAK,GAAG,CAAC,CAAC;QAEd,mDAAmD;QACnD,OAAO,CAAC,SAAe,aAAa,CAAC,GAAG,SAAkB;;gBACxD,IAAI;oBACF,6DAA6D;oBAC7D,OAAO,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC;iBACnC;gBAAC,OAAO,CAAC,EAAE;oBACV,4DAA4D;oBAC5D,IAAI,KAAK,GAAG,UAAU,EAAE;wBACtB,KAAK,EAAE,CAAC;wBACR,qCAAqC;wBACrC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5B,UAAU,CACR,OAAO,EACP,UAAU;4BACR,IAAI,CAAC,GAAG,CAAC,0BAA0B,EAAE,uBAAuB,GAAG,SAAA,CAAC,EAAI,KAAK,CAAA,CAAC,CAC7E,CACF,CAAC;wBAEF,OAAO,aAAa,CAAC,GAAG,SAAS,CAAC,CAAC;qBACpC;yBAAM;wBACL,0CAA0C;wBAC1C,MAAM,CAAC,CAAC;qBACT;iBACF;YACH,CAAC;SAAA,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACd,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEO,sBAAK"}
|
package/dist/signature.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { IdentityTypes, SignatureTypes } from '@requestnetwork/types';
|
|
2
|
-
declare const _default: {
|
|
3
|
-
getIdentityFromSignatureParams: typeof getIdentityFromSignatureParams;
|
|
4
|
-
recover: typeof recover;
|
|
5
|
-
sign: typeof sign;
|
|
6
|
-
};
|
|
7
2
|
/**
|
|
8
3
|
* Function to manage Request Logic Signature
|
|
9
4
|
*/
|
|
10
|
-
export
|
|
5
|
+
export { getIdentityFromSignatureParams, recoverSigner, sign };
|
|
11
6
|
/**
|
|
12
7
|
* Function to get the signer identity from the signature parameters
|
|
13
8
|
*
|
|
@@ -25,7 +20,7 @@ declare function getIdentityFromSignatureParams(signatureParams: SignatureTypes.
|
|
|
25
20
|
* @param signatureParams Signature parameters
|
|
26
21
|
* @returns ISignature the signature
|
|
27
22
|
*/
|
|
28
|
-
declare function sign(data:
|
|
23
|
+
declare function sign(data: unknown, signatureParams: SignatureTypes.ISignatureParameters): SignatureTypes.ISignedData;
|
|
29
24
|
/**
|
|
30
25
|
* Function to recover signer identity from a signature
|
|
31
26
|
*
|
|
@@ -34,5 +29,5 @@ declare function sign(data: any, signatureParams: SignatureTypes.ISignatureParam
|
|
|
34
29
|
* @param signedData the data signed
|
|
35
30
|
* @returns identity of the signer
|
|
36
31
|
*/
|
|
37
|
-
declare function
|
|
32
|
+
declare function recoverSigner(signedData: SignatureTypes.ISignedData): IdentityTypes.IIdentity;
|
|
38
33
|
//# sourceMappingURL=signature.d.ts.map
|
package/dist/signature.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../src/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../src/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAUtE;;GAEG;AACH,OAAO,EAAE,8BAA8B,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AAK/D;;;;;;GAMG;AACH,iBAAS,8BAA8B,CACrC,eAAe,EAAE,cAAc,CAAC,oBAAoB,GACnD,aAAa,CAAC,SAAS,CASzB;AAED;;;;;;;;GAQG;AACH,iBAAS,IAAI,CACX,IAAI,EAAE,OAAO,EACb,eAAe,EAAE,cAAc,CAAC,oBAAoB,GACnD,cAAc,CAAC,WAAW,CAe5B;AAED;;;;;;;GAOG;AACH,iBAAS,aAAa,CAAC,UAAU,EAAE,cAAc,CAAC,WAAW,GAAG,aAAa,CAAC,SAAS,CA+BtF"}
|
package/dist/signature.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sign = exports.recoverSigner = exports.getIdentityFromSignatureParams = void 0;
|
|
3
4
|
const types_1 = require("@requestnetwork/types");
|
|
5
|
+
const ethers_1 = require("ethers");
|
|
4
6
|
const crypto_1 = require("./crypto");
|
|
5
|
-
/**
|
|
6
|
-
* Function to manage Request Logic Signature
|
|
7
|
-
*/
|
|
8
|
-
exports.default = {
|
|
9
|
-
getIdentityFromSignatureParams,
|
|
10
|
-
recover,
|
|
11
|
-
sign,
|
|
12
|
-
};
|
|
13
7
|
// Use to localize the parameter V in an ECDSA signature in hex format
|
|
14
8
|
const V_POSITION_FROM_END_IN_ECDSA_HEX = -2;
|
|
15
9
|
/**
|
|
@@ -23,11 +17,12 @@ function getIdentityFromSignatureParams(signatureParams) {
|
|
|
23
17
|
if (signatureParams.method === types_1.SignatureTypes.METHOD.ECDSA) {
|
|
24
18
|
return {
|
|
25
19
|
type: types_1.IdentityTypes.TYPE.ETHEREUM_ADDRESS,
|
|
26
|
-
value: crypto_1.
|
|
20
|
+
value: (0, crypto_1.getAddressFromPrivateKey)(signatureParams.privateKey),
|
|
27
21
|
};
|
|
28
22
|
}
|
|
29
23
|
throw new Error('signatureParams.method not supported');
|
|
30
24
|
}
|
|
25
|
+
exports.getIdentityFromSignatureParams = getIdentityFromSignatureParams;
|
|
31
26
|
/**
|
|
32
27
|
* Function to sign data from signature parameters
|
|
33
28
|
*
|
|
@@ -40,16 +35,17 @@ function getIdentityFromSignatureParams(signatureParams) {
|
|
|
40
35
|
function sign(data, signatureParams) {
|
|
41
36
|
let value;
|
|
42
37
|
if (signatureParams.method === types_1.SignatureTypes.METHOD.ECDSA) {
|
|
43
|
-
value = crypto_1.
|
|
38
|
+
value = (0, crypto_1.ecSign)(signatureParams.privateKey, (0, crypto_1.normalizeKeccak256Hash)(data).value);
|
|
44
39
|
return { data, signature: { method: signatureParams.method, value } };
|
|
45
40
|
}
|
|
46
41
|
if (signatureParams.method === types_1.SignatureTypes.METHOD.ECDSA_ETHEREUM) {
|
|
47
|
-
const normalizedData = crypto_1.
|
|
48
|
-
value = crypto_1.
|
|
42
|
+
const normalizedData = (0, crypto_1.normalize)(data);
|
|
43
|
+
value = (0, crypto_1.ecSign)(signatureParams.privateKey, ethers_1.ethers.utils.hashMessage(normalizedData));
|
|
49
44
|
return { data, signature: { method: signatureParams.method, value } };
|
|
50
45
|
}
|
|
51
46
|
throw new Error('signatureParams.method not supported');
|
|
52
47
|
}
|
|
48
|
+
exports.sign = sign;
|
|
53
49
|
/**
|
|
54
50
|
* Function to recover signer identity from a signature
|
|
55
51
|
*
|
|
@@ -58,10 +54,10 @@ function sign(data, signatureParams) {
|
|
|
58
54
|
* @param signedData the data signed
|
|
59
55
|
* @returns identity of the signer
|
|
60
56
|
*/
|
|
61
|
-
function
|
|
57
|
+
function recoverSigner(signedData) {
|
|
62
58
|
let value;
|
|
63
59
|
if (signedData.signature.method === types_1.SignatureTypes.METHOD.ECDSA) {
|
|
64
|
-
value = crypto_1.
|
|
60
|
+
value = (0, crypto_1.ecRecover)(signedData.signature.value, (0, crypto_1.normalizeKeccak256Hash)(signedData.data).value);
|
|
65
61
|
return {
|
|
66
62
|
type: types_1.IdentityTypes.TYPE.ETHEREUM_ADDRESS,
|
|
67
63
|
value,
|
|
@@ -78,11 +74,8 @@ function recover(signedData) {
|
|
|
78
74
|
else if (v.toLowerCase() === '01') {
|
|
79
75
|
signature = `${signedData.signature.value.slice(0, V_POSITION_FROM_END_IN_ECDSA_HEX)}1b`;
|
|
80
76
|
}
|
|
81
|
-
const normalizedData = crypto_1.
|
|
82
|
-
value = crypto_1.
|
|
83
|
-
// add the ethereum padding (only for ECDSA_ETHEREUM)
|
|
84
|
-
// This is to make the system compatible with the ethereum signatures
|
|
85
|
-
`\x19Ethereum Signed Message:\n${normalizedData.length}${normalizedData}`)).toLowerCase();
|
|
77
|
+
const normalizedData = ethers_1.ethers.utils.hashMessage((0, crypto_1.normalize)(signedData.data));
|
|
78
|
+
value = (0, crypto_1.ecRecover)(signature, normalizedData).toLowerCase();
|
|
86
79
|
return {
|
|
87
80
|
type: types_1.IdentityTypes.TYPE.ETHEREUM_ADDRESS,
|
|
88
81
|
value,
|
|
@@ -90,4 +83,5 @@ function recover(signedData) {
|
|
|
90
83
|
}
|
|
91
84
|
throw new Error('signatureParams.method not supported');
|
|
92
85
|
}
|
|
86
|
+
exports.recoverSigner = recoverSigner;
|
|
93
87
|
//# sourceMappingURL=signature.js.map
|
package/dist/signature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../src/signature.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../src/signature.ts"],"names":[],"mappings":";;;AAAA,iDAAsE;AACtE,mCAAgC;AAChC,qCAMkB;AAOlB,sEAAsE;AACtE,MAAM,gCAAgC,GAAG,CAAC,CAAC,CAAC;AAE5C;;;;;;GAMG;AACH,SAAS,8BAA8B,CACrC,eAAoD;IAEpD,IAAI,eAAe,CAAC,MAAM,KAAK,sBAAc,CAAC,MAAM,CAAC,KAAK,EAAE;QAC1D,OAAO;YACL,IAAI,EAAE,qBAAa,CAAC,IAAI,CAAC,gBAAgB;YACzC,KAAK,EAAE,IAAA,iCAAwB,EAAC,eAAe,CAAC,UAAU,CAAC;SAC5D,CAAC;KACH;IAED,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;AAC1D,CAAC;AAvBQ,wEAA8B;AAyBvC;;;;;;;;GAQG;AACH,SAAS,IAAI,CACX,IAAa,EACb,eAAoD;IAEpD,IAAI,KAAa,C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EAAE;QACxE,uDAAuD;QACvD,+BAA+B;QAC/B,MAAM,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAE7E,IAAI,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC;QAC3C,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE;YAC5B,SAAS,GAAG,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,gCAAgC,CAAC,IAAI,CAAC;SAC1F;aAAM,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE;YACnC,SAAS,GAAG,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,gCAAgC,CAAC,IAAI,CAAC;SAC1F;QACD,MAAM,cAAc,GAAG,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,IAAA,kBAAS,EAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5E,KAAK,GAAG,IAAA,kBAAS,EAAC,SAAS,EAAE,cAAc,CAAC,CAAC,WAAW,EAAE,CAAC;QAE3D,OAAO;YACL,IAAI,EAAE,qBAAa,CAAC,IAAI,CAAC,gBAAgB;YACzC,KAAK;SACN,CAAC;KACH;IAED,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;AAC1D,CAAC;AA7FwC,sCAAa"}
|
package/dist/simple-logger.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LogTypes } from '@requestnetwork/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Simple logger that outputs content to the console.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export declare class SimpleLogger implements LogTypes.ILogger {
|
|
6
6
|
/**
|
|
7
7
|
* maxLogLevel, the maximum log level to display
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-logger.d.ts","sourceRoot":"","sources":["../src/simple-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAKjD;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"simple-logger.d.ts","sourceRoot":"","sources":["../src/simple-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAKjD;;GAEG;AACH,qBAAa,YAAa,YAAW,QAAQ,CAAC,OAAO;IACnD;;OAEG;IACI,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAEtC;;OAEG;IACI,MAAM,UAAW;IAExB;;;;OAIG;gBACS,WAAW,GAAE,QAAQ,CAAC,QAA4B;IAI9D;;;;;OAKG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI;IAMpD;;;;;OAKG;IACI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI;IAMnD;;;;;OAKG;IACI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI;IAMnD;;;;;OAKG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI;IAMpD;;;;;;;;OAQG;IACH,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM;IAYvF;;;;;OAKG;IACH,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAKrE"}
|
package/dist/simple-logger.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.SimpleLogger = void 0;
|
|
4
|
+
/* eslint-disable no-console */
|
|
4
5
|
const types_1 = require("@requestnetwork/types");
|
|
5
6
|
// The default log level to use if none is used at the constructor.
|
|
6
7
|
const DEFAULT_LOG_LEVEL = types_1.LogTypes.LogLevel.QUIET;
|
|
@@ -90,10 +91,10 @@ class SimpleLogger {
|
|
|
90
91
|
* @param separator The log separator character
|
|
91
92
|
*/
|
|
92
93
|
checkForSeparator(tags, separator) {
|
|
93
|
-
if (tags.some(tag => tag.includes(separator))) {
|
|
94
|
+
if (tags.some((tag) => tag.includes(separator))) {
|
|
94
95
|
throw new Error(`Log tags can't can't contain ${separator} character`);
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
|
-
exports.
|
|
99
|
+
exports.SimpleLogger = SimpleLogger;
|
|
99
100
|
//# sourceMappingURL=simple-logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-logger.js","sourceRoot":"","sources":["../src/simple-logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"simple-logger.js","sourceRoot":"","sources":["../src/simple-logger.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,iDAAiD;AAEjD,mEAAmE;AACnE,MAAM,iBAAiB,GAAG,gBAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;AAElD;;GAEG;AACH,MAAa,YAAY;IAWvB;;;;OAIG;IACH,YAAY,cAAiC,iBAAiB;QAV9D;;WAEG;QACI,WAAM,GAAG,OAAO,CAAC;QAQtB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,OAAe,EAAE,IAAe;QAC3C,IAAI,IAAI,CAAC,WAAW,IAAI,gBAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE;YAC/C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,gBA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AAM,EAAE;YACvB,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAClC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC/B,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC;SACtB;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACO,iBAAiB,CAAC,IAAc,EAAE,SAAiB;QAC3D,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE;YAC/C,MAAM,IAAI,KAAK,CAAC,gCAAgC,SAAS,YAAY,CAAC,CAAC;SACxE;IACH,CAAC;CACF;AApGD,oCAoGC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
deepCopy: typeof deepCopy;
|
|
3
|
-
deepSort: typeof deepSort;
|
|
4
|
-
flatten2DimensionsArray: typeof flatten2DimensionsArray;
|
|
5
|
-
getCurrentTimestampInSecond: typeof getCurrentTimestampInSecond;
|
|
6
|
-
isString: typeof isString;
|
|
7
|
-
timeoutPromise: typeof timeoutPromise;
|
|
8
|
-
unique: typeof unique;
|
|
9
|
-
uniqueByProperty: typeof uniqueByProperty;
|
|
10
|
-
};
|
|
11
1
|
/**
|
|
12
2
|
* Collection of general purpose utility function
|
|
13
3
|
*/
|
|
14
|
-
export
|
|
4
|
+
export { deepCopy, deepSort, flatten2DimensionsArray, getCurrentTimestampInSecond, isString, timeoutPromise, unique, uniqueByProperty, notNull, };
|
|
15
5
|
/**
|
|
16
6
|
* Function to check if a variable is a string
|
|
17
7
|
*
|
|
@@ -27,7 +17,7 @@ declare function isString(variable: any): boolean;
|
|
|
27
17
|
*
|
|
28
18
|
* @returns any the deep copy
|
|
29
19
|
*/
|
|
30
|
-
declare function deepCopy(variable:
|
|
20
|
+
declare function deepCopy<T>(variable: T): T;
|
|
31
21
|
/**
|
|
32
22
|
* Function return the object with keys deeply sorted
|
|
33
23
|
*
|
|
@@ -44,9 +34,9 @@ declare function deepSort(nestedObject: any): any;
|
|
|
44
34
|
* @param array the array to curate
|
|
45
35
|
* @returns an object containing the array with only unique element and an object with the duplication
|
|
46
36
|
*/
|
|
47
|
-
declare function unique(array:
|
|
48
|
-
uniqueItems:
|
|
49
|
-
duplicates:
|
|
37
|
+
declare function unique<T>(array: T[]): {
|
|
38
|
+
uniqueItems: T[];
|
|
39
|
+
duplicates: T[];
|
|
50
40
|
};
|
|
51
41
|
/**
|
|
52
42
|
* Separates the duplicated object from an array from a property
|
|
@@ -56,9 +46,9 @@ declare function unique(array: any[]): {
|
|
|
56
46
|
* @param array the array to curate
|
|
57
47
|
* @returns an object containing the array with only unique element and an object with the duplication
|
|
58
48
|
*/
|
|
59
|
-
declare function uniqueByProperty(array:
|
|
60
|
-
uniqueItems:
|
|
61
|
-
duplicates:
|
|
49
|
+
declare function uniqueByProperty<T>(array: T[], property: keyof T): {
|
|
50
|
+
uniqueItems: T[];
|
|
51
|
+
duplicates: T[];
|
|
62
52
|
};
|
|
63
53
|
/**
|
|
64
54
|
* Function return the timestamp in second
|
|
@@ -71,11 +61,12 @@ declare function getCurrentTimestampInSecond(): number;
|
|
|
71
61
|
*
|
|
72
62
|
* @returns any[] the flat array
|
|
73
63
|
*/
|
|
74
|
-
declare function flatten2DimensionsArray(twoDimensionsArray:
|
|
64
|
+
declare function flatten2DimensionsArray<T>(twoDimensionsArray: T[][]): T[];
|
|
75
65
|
/**
|
|
76
66
|
* Function that returns a promise that rejects when the specified timeout is reached
|
|
77
67
|
* @param timeout Timeout threshold to throw the error
|
|
78
68
|
* @param message Timeout error message
|
|
79
69
|
*/
|
|
80
|
-
declare function timeoutPromise(timeout: number, message: string): Promise<
|
|
70
|
+
declare function timeoutPromise<T>(promise: Promise<T>, timeout: number, message: string): Promise<T>;
|
|
71
|
+
declare function notNull<T>(x: T | null | undefined): x is T;
|
|
81
72
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,uBAAuB,EACvB,2BAA2B,EAC3B,QAAQ,EACR,cAAc,EACd,MAAM,EACN,gBAAgB,EAChB,OAAO,GACR,CAAC;AAIF;;;;;;GAMG;AACH,iBAAS,QAAQ,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAExC;AAED;;;;;;GAMG;AACH,iBAAS,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAEnC;AAED;;;;;;GAMG;AACH,iBAAS,QAAQ,CAAC,YAAY,EAAE,GAAG,GAAG,GAAG,CAexC;AAED;;;;;;;GAOG;AACH,iBAAS,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG;IAAE,WAAW,EAAE,CAAC,EAAE,CAAC;IAAC,UAAU,EAAE,CAAC,EAAE,CAAA;CAAE,CAsBpE;AAED;;;;;;;GAOG;AACH,iBAAS,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG;IAAE,WAAW,EAAE,CAAC,EAAE,CAAC;IAAC,UAAU,EAAE,CAAC,EAAE,CAAA;CAAE,CAsBjG;AAED;;;;GAIG;AACH,iBAAS,2BAA2B,IAAI,MAAM,CAE7C;AAED;;;;GAIG;AACH,iBAAS,uBAAuB,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAElE;AAED;;;;GAIG;AACH,iBAAS,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAK5F;AAED,iBAAS,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,IAAI,CAAC,CAEnD"}
|
package/dist/utils.js
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.notNull = exports.uniqueByProperty = exports.unique = exports.timeoutPromise = exports.isString = exports.getCurrentTimestampInSecond = exports.flatten2DimensionsArray = exports.deepSort = exports.deepCopy = void 0;
|
|
3
4
|
const crypto_1 = require("./crypto");
|
|
4
|
-
/**
|
|
5
|
-
* Collection of general purpose utility function
|
|
6
|
-
*/
|
|
7
|
-
exports.default = {
|
|
8
|
-
deepCopy,
|
|
9
|
-
deepSort,
|
|
10
|
-
flatten2DimensionsArray,
|
|
11
|
-
getCurrentTimestampInSecond,
|
|
12
|
-
isString,
|
|
13
|
-
timeoutPromise,
|
|
14
|
-
unique,
|
|
15
|
-
uniqueByProperty,
|
|
16
|
-
};
|
|
17
5
|
const MILLISECOND_IN_SECOND = 1000;
|
|
18
6
|
/**
|
|
19
7
|
* Function to check if a variable is a string
|
|
@@ -25,6 +13,7 @@ const MILLISECOND_IN_SECOND = 1000;
|
|
|
25
13
|
function isString(variable) {
|
|
26
14
|
return typeof variable === 'string' || variable instanceof String;
|
|
27
15
|
}
|
|
16
|
+
exports.isString = isString;
|
|
28
17
|
/**
|
|
29
18
|
* Function return a deep copy of the parameter
|
|
30
19
|
*
|
|
@@ -35,6 +24,7 @@ function isString(variable) {
|
|
|
35
24
|
function deepCopy(variable) {
|
|
36
25
|
return JSON.parse(JSON.stringify(variable));
|
|
37
26
|
}
|
|
27
|
+
exports.deepCopy = deepCopy;
|
|
38
28
|
/**
|
|
39
29
|
* Function return the object with keys deeply sorted
|
|
40
30
|
*
|
|
@@ -45,7 +35,7 @@ function deepCopy(variable) {
|
|
|
45
35
|
function deepSort(nestedObject) {
|
|
46
36
|
// sort objects in arrays
|
|
47
37
|
if (nestedObject instanceof Array) {
|
|
48
|
-
return nestedObject.map(i => deepSort(i));
|
|
38
|
+
return nestedObject.map((i) => deepSort(i));
|
|
49
39
|
}
|
|
50
40
|
// sort data keys
|
|
51
41
|
if (nestedObject instanceof Object) {
|
|
@@ -58,6 +48,7 @@ function deepSort(nestedObject) {
|
|
|
58
48
|
}
|
|
59
49
|
return nestedObject;
|
|
60
50
|
}
|
|
51
|
+
exports.deepSort = deepSort;
|
|
61
52
|
/**
|
|
62
53
|
* Separates the duplicated object from an array
|
|
63
54
|
* Two object are assumed identical if their normalized Keccak256 hashes are equal
|
|
@@ -68,7 +59,7 @@ function deepSort(nestedObject) {
|
|
|
68
59
|
*/
|
|
69
60
|
function unique(array) {
|
|
70
61
|
const result = array.reduce((accumulator, element) => {
|
|
71
|
-
const hash = crypto_1.
|
|
62
|
+
const hash = (0, crypto_1.normalizeKeccak256Hash)(element);
|
|
72
63
|
if (accumulator.uniqueItemsHashes.includes(hash.value)) {
|
|
73
64
|
// if already included, adds it to the array of duplicates
|
|
74
65
|
accumulator.duplicates.push(element);
|
|
@@ -82,6 +73,7 @@ function unique(array) {
|
|
|
82
73
|
}, { uniqueItems: [], duplicates: [], uniqueItemsHashes: [] });
|
|
83
74
|
return { uniqueItems: result.uniqueItems, duplicates: result.duplicates };
|
|
84
75
|
}
|
|
76
|
+
exports.unique = unique;
|
|
85
77
|
/**
|
|
86
78
|
* Separates the duplicated object from an array from a property
|
|
87
79
|
* Two object are assumed identical if the value of the properties whose name is given in parameter have their normalized Keccak256 hashes equals
|
|
@@ -92,7 +84,7 @@ function unique(array) {
|
|
|
92
84
|
*/
|
|
93
85
|
function uniqueByProperty(array, property) {
|
|
94
86
|
const result = array.reduce((accumulator, element) => {
|
|
95
|
-
const hash = crypto_1.
|
|
87
|
+
const hash = (0, crypto_1.normalizeKeccak256Hash)(element[property]);
|
|
96
88
|
if (accumulator.uniqueItemsHashes.includes(hash.value)) {
|
|
97
89
|
// if already included, adds it to the array of duplicates
|
|
98
90
|
accumulator.duplicates.push(element);
|
|
@@ -106,6 +98,7 @@ function uniqueByProperty(array, property) {
|
|
|
106
98
|
}, { uniqueItems: [], duplicates: [], uniqueItemsHashes: [] });
|
|
107
99
|
return { uniqueItems: result.uniqueItems, duplicates: result.duplicates };
|
|
108
100
|
}
|
|
101
|
+
exports.uniqueByProperty = uniqueByProperty;
|
|
109
102
|
/**
|
|
110
103
|
* Function return the timestamp in second
|
|
111
104
|
*
|
|
@@ -114,6 +107,7 @@ function uniqueByProperty(array, property) {
|
|
|
114
107
|
function getCurrentTimestampInSecond() {
|
|
115
108
|
return Math.floor(Date.now() / MILLISECOND_IN_SECOND);
|
|
116
109
|
}
|
|
110
|
+
exports.getCurrentTimestampInSecond = getCurrentTimestampInSecond;
|
|
117
111
|
/** Function return a two dimensions array flatten
|
|
118
112
|
* @param any[] twoDimensionsArray the array to flatten
|
|
119
113
|
*
|
|
@@ -122,16 +116,21 @@ function getCurrentTimestampInSecond() {
|
|
|
122
116
|
function flatten2DimensionsArray(twoDimensionsArray) {
|
|
123
117
|
return twoDimensionsArray.reduce((accumulator, current) => accumulator.concat(current), []);
|
|
124
118
|
}
|
|
119
|
+
exports.flatten2DimensionsArray = flatten2DimensionsArray;
|
|
125
120
|
/**
|
|
126
121
|
* Function that returns a promise that rejects when the specified timeout is reached
|
|
127
122
|
* @param timeout Timeout threshold to throw the error
|
|
128
123
|
* @param message Timeout error message
|
|
129
124
|
*/
|
|
130
|
-
function timeoutPromise(timeout, message) {
|
|
131
|
-
|
|
132
|
-
setTimeout(() =>
|
|
133
|
-
reject(new Error(message));
|
|
134
|
-
}, timeout);
|
|
125
|
+
function timeoutPromise(promise, timeout, message) {
|
|
126
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
127
|
+
setTimeout(() => reject(new Error(message)), timeout);
|
|
135
128
|
});
|
|
129
|
+
return Promise.race([timeoutPromise, promise]);
|
|
130
|
+
}
|
|
131
|
+
exports.timeoutPromise = timeoutPromise;
|
|
132
|
+
function notNull(x) {
|
|
133
|
+
return x !== null && x !== undefined;
|
|
136
134
|
}
|
|
135
|
+
exports.notNull = notNull;
|
|
137
136
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,qCAAkD;AAiBlD,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC;;;;;;GAMG;AACH,SAAS,QAAQ,CAAC,QAAa;IAC7B,OAAO,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,YAAY,MAAM,CAAC;AACpE,CAAC;AAlBC,4BAAQ;AAoBV;;;;;;GAMG;AACH,SAAS,QAAQ,CAAI,QAAW;IAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9C,CAAC;AAjCC,4BAAQ;AAmCV;;;;;;GAMG;AACH,SAAS,QAAQ,CAAC,YAAiB;IACjC,yBAAyB;IACzB,IAAI,YAAY,YAAY,KAAK,EAAE;QACjC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7C;IACD,iBAAiB;IACjB,IAAI,YAAY,YAAY,MAAM,EAAE;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;aAC7B,IAAI,EAAE;aACN,MAAM,CAAC,CAAC,MAAW,EAAE,GAAQ,EAAE,EAAE;YAChC,MAAM,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AAC,IAAI,CAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;AACpD,CAAC;AAlJC,wCAAc;AAoJhB,SAAS,OAAO,CAAI,CAAuB;IACzC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC;AACvC,CAAC;AAnJC,0BAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@requestnetwork/utils",
|
|
3
|
-
"version": "0.28.1-next.
|
|
3
|
+
"version": "0.28.1-next.709+44946236",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=18.0.0"
|
|
23
23
|
},
|
|
24
24
|
"main": "dist/index.js",
|
|
25
25
|
"types": "dist/index.d.ts",
|
|
@@ -31,37 +31,29 @@
|
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "tsc -b",
|
|
35
|
-
"clean": "
|
|
36
|
-
"lint": "
|
|
37
|
-
"lint
|
|
34
|
+
"build": "tsc -b tsconfig.build.json",
|
|
35
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
|
|
36
|
+
"lint": "eslint . --fix",
|
|
37
|
+
"lint:check": "eslint .",
|
|
38
38
|
"prepare": "yarn run build",
|
|
39
39
|
"test": "jest",
|
|
40
40
|
"test:watch": "yarn test --watch"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@requestnetwork/types": "0.29.1-next.
|
|
44
|
-
"
|
|
45
|
-
"
|
|
43
|
+
"@requestnetwork/types": "0.29.1-next.709+44946236",
|
|
44
|
+
"@toruslabs/eccrypto": "4.0.0",
|
|
45
|
+
"ethers": "5.5.1",
|
|
46
|
+
"secp256k1": "4.0.2",
|
|
47
|
+
"tslib": "2.5.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
|
-
"@types/
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"eslint": "7.9.0",
|
|
52
|
-
"eslint-plugin-spellcheck": "0.0.17",
|
|
53
|
-
"eslint-plugin-typescript": "0.14.0",
|
|
54
|
-
"jest": "26.4.2",
|
|
55
|
-
"lint-staged": "10.3.0",
|
|
56
|
-
"mocha": "8.1.3",
|
|
57
|
-
"nyc": "15.1.0",
|
|
58
|
-
"prettier": "2.1.1",
|
|
59
|
-
"shx": "0.3.2",
|
|
50
|
+
"@types/jest": "29.5.6",
|
|
51
|
+
"jest": "29.5.0",
|
|
52
|
+
"jest-junit": "16.0.0",
|
|
60
53
|
"source-map-support": "0.5.19",
|
|
61
|
-
"ts-jest": "
|
|
62
|
-
"ts-node": "9.
|
|
63
|
-
"
|
|
64
|
-
"typescript": "4.0.2"
|
|
54
|
+
"ts-jest": "29.1.0",
|
|
55
|
+
"ts-node": "10.9.1",
|
|
56
|
+
"typescript": "5.1.3"
|
|
65
57
|
},
|
|
66
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "449462366df9f74a825fef46339012111816f0c3"
|
|
67
59
|
}
|