@huma-finance/shared 0.0.30 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abis/BaseCreditPool.json +1179 -1179
- package/dist/abis/BaseFeeManager.json +480 -480
- package/dist/abis/BasePoolConfig.json +1364 -1364
- package/dist/abis/ERC20TransferableReceivable.json +648 -648
- package/dist/abis/HDT.json +512 -512
- package/dist/abis/IConstantFlowAgreementV1.json +890 -890
- package/dist/abis/ISuperfluid.json +1122 -1122
- package/dist/abis/InvoiceNFT.json +625 -625
- package/dist/abis/Multisend.json +26 -26
- package/dist/abis/RealWorldReceivable.json +823 -823
- package/dist/abis/ReceivableFactoringPool.json +1529 -1529
- package/dist/abis/StreamFactoringPool.json +1523 -1523
- package/dist/abis/StreamFeeManager.json +522 -522
- package/dist/abis/SuperfluidPoolProcessor.json +692 -692
- package/dist/abis/TestERC20.json +358 -358
- package/dist/abis/TradableStream.json +850 -850
- package/dist/abis/Transfer.json +24 -24
- package/dist/abis/TransferNFT.json +27 -27
- package/dist/abis/erc20.json +117 -117
- package/dist/abis/erc2612.json +132 -132
- package/dist/abis/erc721.json +673 -673
- package/dist/abis/index.d.ts +3 -3
- package/dist/abis/index.js +3 -3
- package/dist/abis/types/BaseCreditPool.d.ts +803 -803
- package/dist/abis/types/BaseCreditPool.js +1 -1
- package/dist/abis/types/BaseFeeManager.d.ts +408 -408
- package/dist/abis/types/BaseFeeManager.js +1 -1
- package/dist/abis/types/BasePoolConfig.d.ts +1097 -1097
- package/dist/abis/types/BasePoolConfig.js +1 -1
- package/dist/abis/types/ERC20TransferableReceivable.d.ts +407 -407
- package/dist/abis/types/ERC20TransferableReceivable.js +1 -1
- package/dist/abis/types/Erc20.d.ts +168 -168
- package/dist/abis/types/Erc20.js +1 -1
- package/dist/abis/types/Erc2612.d.ts +192 -192
- package/dist/abis/types/Erc2612.js +1 -1
- package/dist/abis/types/Erc721.d.ts +474 -474
- package/dist/abis/types/Erc721.js +1 -1
- package/dist/abis/types/HDT.d.ts +369 -369
- package/dist/abis/types/HDT.js +1 -1
- package/dist/abis/types/IConstantFlowAgreementV1.d.ts +573 -573
- package/dist/abis/types/IConstantFlowAgreementV1.js +1 -1
- package/dist/abis/types/ISuperfluid.d.ts +728 -728
- package/dist/abis/types/ISuperfluid.js +1 -1
- package/dist/abis/types/InvoiceNFT.d.ts +425 -425
- package/dist/abis/types/InvoiceNFT.js +1 -1
- package/dist/abis/types/Multisend.d.ts +50 -50
- package/dist/abis/types/Multisend.js +1 -1
- package/dist/abis/types/RealWorldReceivable.d.ts +564 -564
- package/dist/abis/types/RealWorldReceivable.js +1 -1
- package/dist/abis/types/ReceivableFactoringPool.d.ts +999 -999
- package/dist/abis/types/ReceivableFactoringPool.js +1 -1
- package/dist/abis/types/StreamFactoringPool.d.ts +985 -985
- package/dist/abis/types/StreamFactoringPool.js +1 -1
- package/dist/abis/types/StreamFeeManager.d.ts +440 -440
- package/dist/abis/types/StreamFeeManager.js +1 -1
- package/dist/abis/types/SuperfluidPoolProcessor.d.ts +398 -398
- package/dist/abis/types/SuperfluidPoolProcessor.js +1 -1
- package/dist/abis/types/TestERC20.d.ts +270 -270
- package/dist/abis/types/TestERC20.js +1 -1
- package/dist/abis/types/TradableStream.d.ts +607 -607
- package/dist/abis/types/TradableStream.js +1 -1
- package/dist/abis/types/Transfer.d.ts +45 -45
- package/dist/abis/types/Transfer.js +1 -1
- package/dist/abis/types/TransferNFT.d.ts +45 -45
- package/dist/abis/types/TransferNFT.js +1 -1
- package/dist/abis/types/common.d.ts +22 -22
- package/dist/abis/types/common.js +1 -1
- package/dist/abis/types/factories/BaseCreditPool__factory.d.ts +931 -931
- package/dist/abis/types/factories/BaseCreditPool__factory.js +1193 -1192
- package/dist/abis/types/factories/BaseCreditPool__factory.js.map +1 -1
- package/dist/abis/types/factories/BaseFeeManager__factory.d.ts +379 -379
- package/dist/abis/types/factories/BaseFeeManager__factory.js +494 -493
- package/dist/abis/types/factories/BaseFeeManager__factory.js.map +1 -1
- package/dist/abis/types/factories/BasePoolConfig__factory.d.ts +1074 -1074
- package/dist/abis/types/factories/BasePoolConfig__factory.js +1378 -1377
- package/dist/abis/types/factories/BasePoolConfig__factory.js.map +1 -1
- package/dist/abis/types/factories/ERC20TransferableReceivable__factory.d.ts +508 -508
- package/dist/abis/types/factories/ERC20TransferableReceivable__factory.js +662 -661
- package/dist/abis/types/factories/ERC20TransferableReceivable__factory.js.map +1 -1
- package/dist/abis/types/factories/Erc20__factory.d.ts +175 -175
- package/dist/abis/types/factories/Erc20__factory.js +236 -235
- package/dist/abis/types/factories/Erc20__factory.js.map +1 -1
- package/dist/abis/types/factories/Erc2612__factory.d.ts +209 -209
- package/dist/abis/types/factories/Erc2612__factory.js +279 -278
- package/dist/abis/types/factories/Erc2612__factory.js.map +1 -1
- package/dist/abis/types/factories/Erc721__factory.d.ts +539 -539
- package/dist/abis/types/factories/Erc721__factory.js +687 -686
- package/dist/abis/types/factories/Erc721__factory.js.map +1 -1
- package/dist/abis/types/factories/HDT__factory.d.ts +399 -399
- package/dist/abis/types/factories/HDT__factory.js +526 -525
- package/dist/abis/types/factories/HDT__factory.js.map +1 -1
- package/dist/abis/types/factories/IConstantFlowAgreementV1__factory.d.ts +695 -695
- package/dist/abis/types/factories/IConstantFlowAgreementV1__factory.js +904 -903
- package/dist/abis/types/factories/IConstantFlowAgreementV1__factory.js.map +1 -1
- package/dist/abis/types/factories/ISuperfluid__factory.d.ts +866 -866
- package/dist/abis/types/factories/ISuperfluid__factory.js +1136 -1135
- package/dist/abis/types/factories/ISuperfluid__factory.js.map +1 -1
- package/dist/abis/types/factories/InvoiceNFT__factory.d.ts +489 -489
- package/dist/abis/types/factories/InvoiceNFT__factory.js +639 -638
- package/dist/abis/types/factories/InvoiceNFT__factory.js.map +1 -1
- package/dist/abis/types/factories/Multisend__factory.d.ts +26 -26
- package/dist/abis/types/factories/Multisend__factory.js +40 -39
- package/dist/abis/types/factories/Multisend__factory.js.map +1 -1
- package/dist/abis/types/factories/RealWorldReceivable__factory.d.ts +645 -645
- package/dist/abis/types/factories/RealWorldReceivable__factory.js +837 -836
- package/dist/abis/types/factories/RealWorldReceivable__factory.js.map +1 -1
- package/dist/abis/types/factories/ReceivableFactoringPool__factory.d.ts +1204 -1204
- package/dist/abis/types/factories/ReceivableFactoringPool__factory.js +1543 -1542
- package/dist/abis/types/factories/ReceivableFactoringPool__factory.js.map +1 -1
- package/dist/abis/types/factories/StreamFactoringPool__factory.d.ts +1200 -1200
- package/dist/abis/types/factories/StreamFactoringPool__factory.js +1537 -1536
- package/dist/abis/types/factories/StreamFactoringPool__factory.js.map +1 -1
- package/dist/abis/types/factories/StreamFeeManager__factory.d.ts +412 -412
- package/dist/abis/types/factories/StreamFeeManager__factory.js +536 -535
- package/dist/abis/types/factories/StreamFeeManager__factory.js.map +1 -1
- package/dist/abis/types/factories/SuperfluidPoolProcessor__factory.d.ts +546 -546
- package/dist/abis/types/factories/SuperfluidPoolProcessor__factory.js +706 -705
- package/dist/abis/types/factories/SuperfluidPoolProcessor__factory.js.map +1 -1
- package/dist/abis/types/factories/TestERC20__factory.d.ts +280 -280
- package/dist/abis/types/factories/TestERC20__factory.js +372 -371
- package/dist/abis/types/factories/TestERC20__factory.js.map +1 -1
- package/dist/abis/types/factories/TradableStream__factory.d.ts +663 -663
- package/dist/abis/types/factories/TradableStream__factory.js +864 -863
- package/dist/abis/types/factories/TradableStream__factory.js.map +1 -1
- package/dist/abis/types/factories/TransferNFT__factory.d.ts +28 -28
- package/dist/abis/types/factories/TransferNFT__factory.js +41 -40
- package/dist/abis/types/factories/TransferNFT__factory.js.map +1 -1
- package/dist/abis/types/factories/Transfer__factory.d.ts +25 -25
- package/dist/abis/types/factories/Transfer__factory.js +38 -37
- package/dist/abis/types/factories/Transfer__factory.js.map +1 -1
- package/dist/abis/types/factories/index.d.ts +21 -21
- package/dist/abis/types/factories/index.js +24 -24
- package/dist/abis/types/index.d.ts +43 -43
- package/dist/abis/types/index.js +22 -22
- package/dist/cjs/hooks/web3/index.js +2 -2
- package/dist/cjs/hooks/web3/index.js.map +1 -1
- package/dist/cjs/services/IdentityService.d.ts +17 -0
- package/dist/cjs/services/IdentityService.js +31 -4
- package/dist/cjs/services/IdentityService.js.map +1 -1
- package/dist/cjs/utils/chain.d.ts +3 -1
- package/dist/cjs/utils/chain.js +9 -1
- package/dist/cjs/utils/chain.js.map +1 -1
- package/dist/cjs/utils/config.d.ts +1 -0
- package/dist/cjs/utils/config.js +10 -1
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +2 -0
- package/dist/cjs/utils/index.js +2 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/notifi.d.ts +3 -0
- package/dist/cjs/utils/notifi.js +40 -0
- package/dist/cjs/utils/notifi.js.map +1 -0
- package/dist/cjs/utils/number.js +7 -1
- package/dist/cjs/utils/number.js.map +1 -1
- package/dist/cjs/utils/pool.d.ts +1 -0
- package/dist/cjs/utils/pool.js +9 -6
- package/dist/cjs/utils/pool.js.map +1 -1
- package/dist/cjs/utils/realWorldReceivable.d.ts +12 -0
- package/dist/cjs/utils/realWorldReceivable.js +3 -0
- package/dist/cjs/utils/realWorldReceivable.js.map +1 -0
- package/dist/hooks/index.d.ts +18 -18
- package/dist/hooks/index.js +18 -18
- package/dist/hooks/useActiveRoute.d.ts +8 -8
- package/dist/hooks/useActiveRoute.js +7 -7
- package/dist/hooks/useAsyncError.d.ts +14 -14
- package/dist/hooks/useAsyncError.js +22 -22
- package/dist/hooks/useCLPoolContract.d.ts +27 -27
- package/dist/hooks/useContract.d.ts +7 -7
- package/dist/hooks/useContractFunction.d.ts +18 -18
- package/dist/hooks/useContractFunction.js +54 -54
- package/dist/hooks/useERC2612Permit/ethPermit/index.d.ts +35 -35
- package/dist/hooks/useERC2612Permit/ethPermit/index.js +139 -139
- package/dist/hooks/useERC2612Permit/ethPermit/lib.d.ts +1 -1
- package/dist/hooks/useERC2612Permit/ethPermit/lib.js +21 -21
- package/dist/hooks/useERC2612Permit/ethPermit/rpc.d.ts +10 -10
- package/dist/hooks/useERC2612Permit/ethPermit/rpc.js +96 -96
- package/dist/hooks/useERC2612Permit/index.d.ts +6 -6
- package/dist/hooks/useERC2612Permit/index.js +31 -31
- package/dist/hooks/useFactoring.d.ts +19 -19
- package/dist/hooks/useForceRefresh.d.ts +1 -1
- package/dist/hooks/useForceRefresh.js +8 -8
- package/dist/hooks/useGetSizes.d.ts +12 -12
- package/dist/hooks/useGetSizes.js +19 -19
- package/dist/hooks/useInvoiceNFTContract.d.ts +11 -11
- package/dist/hooks/useMQ.d.ts +6 -6
- package/dist/hooks/useMQ.js +14 -14
- package/dist/hooks/useMount.d.ts +2 -2
- package/dist/hooks/useMount.js +8 -8
- package/dist/hooks/useParamsSearch.d.ts +2 -2
- package/dist/hooks/useParamsSearch.js +6 -6
- package/dist/hooks/usePool.d.ts +4 -4
- package/dist/hooks/usePoolContract.d.ts +73 -73
- package/dist/hooks/useRFPoolContract.d.ts +22 -22
- package/dist/hooks/useRefresh.d.ts +1 -1
- package/dist/hooks/useRefresh.js +47 -47
- package/dist/hooks/web3/index.d.ts +15 -15
- package/dist/hooks/web3/index.js +2 -2
- package/dist/hooks/web3/index.js.map +1 -1
- package/dist/hooks/web3/useConnectors.d.ts +17 -17
- package/dist/hooks/web3/useConnectors.js +24 -24
- package/dist/hooks/web3/useJsonRpcUrlsMap.d.ts +13 -13
- package/dist/index.d.ts +5 -5
- package/dist/services/EAService.d.ts +153 -153
- package/dist/services/IdentityService.d.ts +17 -0
- package/dist/services/IdentityService.js +32 -5
- package/dist/services/IdentityService.js.map +1 -1
- package/dist/services/RNService.d.ts +14 -14
- package/dist/services/index.d.ts +3 -3
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils/JsonRpcConnector.d.ts +11 -11
- package/dist/utils/JsonRpcConnector.js +38 -38
- package/dist/utils/WalletConnect.d.ts +10 -10
- package/dist/utils/WalletConnect.js +50 -49
- package/dist/utils/WalletConnect.js.map +1 -1
- package/dist/utils/chain.d.ts +3 -1
- package/dist/utils/chain.js +7 -0
- package/dist/utils/chain.js.map +1 -1
- package/dist/utils/common.d.ts +4 -4
- package/dist/utils/common.js +10 -10
- package/dist/utils/config.d.ts +1 -0
- package/dist/utils/config.js +10 -1
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/const.d.ts +2 -2
- package/dist/utils/const.js +2 -2
- package/dist/utils/contractError.json +73 -73
- package/dist/utils/credit.d.ts +21 -21
- package/dist/utils/credit.js +35 -35
- package/dist/utils/errors.d.ts +26 -26
- package/dist/utils/errors.js +39 -39
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/jsonRpcEndpoints.d.ts +12 -12
- package/dist/utils/notifi.d.ts +3 -0
- package/dist/utils/notifi.js +35 -0
- package/dist/utils/notifi.js.map +1 -0
- package/dist/utils/number.d.ts +5 -5
- package/dist/utils/number.js +7 -1
- package/dist/utils/number.js.map +1 -1
- package/dist/utils/pool.d.ts +1 -0
- package/dist/utils/pool.js +9 -6
- package/dist/utils/pool.js.map +1 -1
- package/dist/utils/realWorldReceivable.d.ts +12 -0
- package/dist/utils/realWorldReceivable.js +2 -0
- package/dist/utils/realWorldReceivable.js.map +1 -0
- package/dist/utils/request.d.ts +3 -3
- package/dist/utils/request.js +38 -38
- package/dist/utils/scientificToDecimal.d.ts +1 -1
- package/dist/utils/scientificToDecimal.js +57 -57
- package/dist/utils/string.d.ts +1 -1
- package/dist/utils/string.js +1 -1
- package/dist/utils/style.d.ts +1 -1
- package/dist/utils/style.js +12 -12
- package/dist/utils/time.d.ts +26 -26
- package/dist/utils/time.js +50 -50
- package/dist/utils/transaction.d.ts +32 -32
- package/dist/utils/transaction.js +87 -87
- package/dist/utils/web3.d.ts +4 -4
- package/dist/utils/web3.js +34 -34
- package/package.json +3 -3
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
/* eslint-disable no-plusplus */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
3
|
-
/* eslint-disable radix */
|
|
4
|
-
/* eslint-disable prefer-destructuring */
|
|
5
|
-
// @ts-nocheck
|
|
6
|
-
// github.com/jam3/scientific-to-decimal
|
|
7
|
-
export const scientificToDecimal = (value) => {
|
|
8
|
-
value = parseFloat(value);
|
|
9
|
-
const REGEX_SCIENTIFIC = /(\d+\.?\d*)e\d*(\+|-)(\d+)/;
|
|
10
|
-
const valueString = value.toString();
|
|
11
|
-
let result = REGEX_SCIENTIFIC.exec(valueString);
|
|
12
|
-
let base;
|
|
13
|
-
let positiveNegative;
|
|
14
|
-
let exponents;
|
|
15
|
-
let precision;
|
|
16
|
-
let rVal;
|
|
17
|
-
// is scientific
|
|
18
|
-
if (result) {
|
|
19
|
-
// [ '1e+32', '1', '+', '2', index: 0, input: '1e+32' ]
|
|
20
|
-
base = result[1];
|
|
21
|
-
positiveNegative = result[2];
|
|
22
|
-
exponents = result[3];
|
|
23
|
-
if (positiveNegative === '+') {
|
|
24
|
-
precision = parseInt(exponents);
|
|
25
|
-
// base is a decimal
|
|
26
|
-
if (base.indexOf('.') !== -1) {
|
|
27
|
-
result = /(\d+\.)(\d)/.exec(base);
|
|
28
|
-
// [ 2 ] == right side after decimal
|
|
29
|
-
// [ 1 ] == left side before decimal
|
|
30
|
-
precision -= result[2].length + result[1].length;
|
|
31
|
-
rVal = base.split('.').join('') + getZeros(precision);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
rVal = base + getZeros(precision);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
precision = base.length + parseInt(exponents) - 1;
|
|
39
|
-
// if it contains a period we want to drop precision by one
|
|
40
|
-
if (base.indexOf('.') !== -1) {
|
|
41
|
-
precision--;
|
|
42
|
-
}
|
|
43
|
-
rVal = value.toFixed(precision);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
rVal = value.toString();
|
|
48
|
-
}
|
|
49
|
-
return rVal;
|
|
50
|
-
};
|
|
51
|
-
function getZeros(count) {
|
|
52
|
-
let rVal = '';
|
|
53
|
-
for (let i = 0; i < count; i++) {
|
|
54
|
-
rVal += '0';
|
|
55
|
-
}
|
|
56
|
-
return rVal;
|
|
57
|
-
}
|
|
1
|
+
/* eslint-disable no-plusplus */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
3
|
+
/* eslint-disable radix */
|
|
4
|
+
/* eslint-disable prefer-destructuring */
|
|
5
|
+
// @ts-nocheck
|
|
6
|
+
// github.com/jam3/scientific-to-decimal
|
|
7
|
+
export const scientificToDecimal = (value) => {
|
|
8
|
+
value = parseFloat(value);
|
|
9
|
+
const REGEX_SCIENTIFIC = /(\d+\.?\d*)e\d*(\+|-)(\d+)/;
|
|
10
|
+
const valueString = value.toString();
|
|
11
|
+
let result = REGEX_SCIENTIFIC.exec(valueString);
|
|
12
|
+
let base;
|
|
13
|
+
let positiveNegative;
|
|
14
|
+
let exponents;
|
|
15
|
+
let precision;
|
|
16
|
+
let rVal;
|
|
17
|
+
// is scientific
|
|
18
|
+
if (result) {
|
|
19
|
+
// [ '1e+32', '1', '+', '2', index: 0, input: '1e+32' ]
|
|
20
|
+
base = result[1];
|
|
21
|
+
positiveNegative = result[2];
|
|
22
|
+
exponents = result[3];
|
|
23
|
+
if (positiveNegative === '+') {
|
|
24
|
+
precision = parseInt(exponents);
|
|
25
|
+
// base is a decimal
|
|
26
|
+
if (base.indexOf('.') !== -1) {
|
|
27
|
+
result = /(\d+\.)(\d)/.exec(base);
|
|
28
|
+
// [ 2 ] == right side after decimal
|
|
29
|
+
// [ 1 ] == left side before decimal
|
|
30
|
+
precision -= result[2].length + result[1].length;
|
|
31
|
+
rVal = base.split('.').join('') + getZeros(precision);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
rVal = base + getZeros(precision);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
precision = base.length + parseInt(exponents) - 1;
|
|
39
|
+
// if it contains a period we want to drop precision by one
|
|
40
|
+
if (base.indexOf('.') !== -1) {
|
|
41
|
+
precision--;
|
|
42
|
+
}
|
|
43
|
+
rVal = value.toFixed(precision);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
rVal = value.toString();
|
|
48
|
+
}
|
|
49
|
+
return rVal;
|
|
50
|
+
};
|
|
51
|
+
function getZeros(count) {
|
|
52
|
+
let rVal = '';
|
|
53
|
+
for (let i = 0; i < count; i++) {
|
|
54
|
+
rVal += '0';
|
|
55
|
+
}
|
|
56
|
+
return rVal;
|
|
57
|
+
}
|
|
58
58
|
//# sourceMappingURL=scientificToDecimal.js.map
|
package/dist/utils/string.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const capitalizeFirstLetter: (str: string) => string;
|
|
1
|
+
export declare const capitalizeFirstLetter: (str: string) => string;
|
package/dist/utils/string.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
1
|
+
export const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
2
2
|
//# sourceMappingURL=string.js.map
|
package/dist/utils/style.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const combineStyles: (...styles: any[]) => (theme: any) => any;
|
|
1
|
+
export declare const combineStyles: (...styles: any[]) => (theme: any) => any;
|
package/dist/utils/style.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
export const combineStyles = (...styles) => function CombineStyles(theme) {
|
|
3
|
-
const outStyles = styles.map((arg) => {
|
|
4
|
-
// Apply the "theme" object for style functions.
|
|
5
|
-
if (typeof arg === 'function') {
|
|
6
|
-
return arg(theme);
|
|
7
|
-
}
|
|
8
|
-
// Objects need no change.
|
|
9
|
-
return arg;
|
|
10
|
-
});
|
|
11
|
-
return outStyles.reduce((acc, val) => Object.assign(acc, val));
|
|
12
|
-
};
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
export const combineStyles = (...styles) => function CombineStyles(theme) {
|
|
3
|
+
const outStyles = styles.map((arg) => {
|
|
4
|
+
// Apply the "theme" object for style functions.
|
|
5
|
+
if (typeof arg === 'function') {
|
|
6
|
+
return arg(theme);
|
|
7
|
+
}
|
|
8
|
+
// Objects need no change.
|
|
9
|
+
return arg;
|
|
10
|
+
});
|
|
11
|
+
return outStyles.reduce((acc, val) => Object.assign(acc, val));
|
|
12
|
+
};
|
|
13
13
|
//# sourceMappingURL=style.js.map
|
package/dist/utils/time.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
|
-
export declare const MILLISECONDS = 1000;
|
|
3
|
-
export declare const DAY_SECONDS: number;
|
|
4
|
-
export declare const TIME_FORMAT_LL = "ll";
|
|
5
|
-
export declare const timestampToStr: (timestamp: number, format: string) => string;
|
|
6
|
-
/**
|
|
7
|
-
* Convert timestamp to format ll: Nov 12, 2022
|
|
8
|
-
*
|
|
9
|
-
* @param timestamp
|
|
10
|
-
* @returns format ll: Nov 12, 2022
|
|
11
|
-
*/
|
|
12
|
-
export declare const timestampToLL: (timestamp?: number) => string;
|
|
13
|
-
/**
|
|
14
|
-
* get unix time in seconds
|
|
15
|
-
*
|
|
16
|
-
* @returns timestamp
|
|
17
|
-
*/
|
|
18
|
-
export declare const getUnixTimestamp: (date?: moment.Moment) => number;
|
|
19
|
-
export declare const secondsToDays: (seconds: number | undefined) => number;
|
|
20
|
-
export declare const timeUtil: {
|
|
21
|
-
timestampToStr: (timestamp: number, format: string) => string;
|
|
22
|
-
timestampToLL: (timestamp?: number) => string;
|
|
23
|
-
getUnixTimestamp: (date?: moment.Moment) => number;
|
|
24
|
-
secondsToDays: (seconds: number | undefined) => number;
|
|
25
|
-
sleep: (ms: number) => Promise<unknown>;
|
|
26
|
-
};
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
export declare const MILLISECONDS = 1000;
|
|
3
|
+
export declare const DAY_SECONDS: number;
|
|
4
|
+
export declare const TIME_FORMAT_LL = "ll";
|
|
5
|
+
export declare const timestampToStr: (timestamp: number, format: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Convert timestamp to format ll: Nov 12, 2022
|
|
8
|
+
*
|
|
9
|
+
* @param timestamp
|
|
10
|
+
* @returns format ll: Nov 12, 2022
|
|
11
|
+
*/
|
|
12
|
+
export declare const timestampToLL: (timestamp?: number) => string;
|
|
13
|
+
/**
|
|
14
|
+
* get unix time in seconds
|
|
15
|
+
*
|
|
16
|
+
* @returns timestamp
|
|
17
|
+
*/
|
|
18
|
+
export declare const getUnixTimestamp: (date?: moment.Moment) => number;
|
|
19
|
+
export declare const secondsToDays: (seconds: number | undefined) => number;
|
|
20
|
+
export declare const timeUtil: {
|
|
21
|
+
timestampToStr: (timestamp: number, format: string) => string;
|
|
22
|
+
timestampToLL: (timestamp?: number) => string;
|
|
23
|
+
getUnixTimestamp: (date?: moment.Moment) => number;
|
|
24
|
+
secondsToDays: (seconds: number | undefined) => number;
|
|
25
|
+
sleep: (ms: number) => Promise<unknown>;
|
|
26
|
+
};
|
package/dist/utils/time.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
|
-
import { isEmpty } from './common';
|
|
3
|
-
export const MILLISECONDS = 1000;
|
|
4
|
-
export const DAY_SECONDS = 24 * 60 * 60;
|
|
5
|
-
export const TIME_FORMAT_LL = 'll';
|
|
6
|
-
export const timestampToStr = (timestamp, format) => moment.unix(timestamp).format(format);
|
|
7
|
-
/**
|
|
8
|
-
* Convert timestamp to format ll: Nov 12, 2022
|
|
9
|
-
*
|
|
10
|
-
* @param timestamp
|
|
11
|
-
* @returns format ll: Nov 12, 2022
|
|
12
|
-
*/
|
|
13
|
-
export const timestampToLL = (timestamp) => {
|
|
14
|
-
if (!timestamp) {
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
return timestampToStr(timestamp, TIME_FORMAT_LL);
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* get unix time in seconds
|
|
21
|
-
*
|
|
22
|
-
* @returns timestamp
|
|
23
|
-
*/
|
|
24
|
-
export const getUnixTimestamp = (date) => {
|
|
25
|
-
if (date) {
|
|
26
|
-
return date.unix();
|
|
27
|
-
}
|
|
28
|
-
return Math.floor(Date.now() / MILLISECONDS);
|
|
29
|
-
};
|
|
30
|
-
export const secondsToDays = (seconds) => {
|
|
31
|
-
if (isEmpty(seconds)) {
|
|
32
|
-
return 0;
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
return seconds / DAY_SECONDS;
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
return 0;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
// eslint-disable-next-line no-promise-executor-return
|
|
43
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
44
|
-
export const timeUtil = {
|
|
45
|
-
timestampToStr,
|
|
46
|
-
timestampToLL,
|
|
47
|
-
getUnixTimestamp,
|
|
48
|
-
secondsToDays,
|
|
49
|
-
sleep,
|
|
50
|
-
};
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { isEmpty } from './common';
|
|
3
|
+
export const MILLISECONDS = 1000;
|
|
4
|
+
export const DAY_SECONDS = 24 * 60 * 60;
|
|
5
|
+
export const TIME_FORMAT_LL = 'll';
|
|
6
|
+
export const timestampToStr = (timestamp, format) => moment.unix(timestamp).format(format);
|
|
7
|
+
/**
|
|
8
|
+
* Convert timestamp to format ll: Nov 12, 2022
|
|
9
|
+
*
|
|
10
|
+
* @param timestamp
|
|
11
|
+
* @returns format ll: Nov 12, 2022
|
|
12
|
+
*/
|
|
13
|
+
export const timestampToLL = (timestamp) => {
|
|
14
|
+
if (!timestamp) {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
return timestampToStr(timestamp, TIME_FORMAT_LL);
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* get unix time in seconds
|
|
21
|
+
*
|
|
22
|
+
* @returns timestamp
|
|
23
|
+
*/
|
|
24
|
+
export const getUnixTimestamp = (date) => {
|
|
25
|
+
if (date) {
|
|
26
|
+
return date.unix();
|
|
27
|
+
}
|
|
28
|
+
return Math.floor(Date.now() / MILLISECONDS);
|
|
29
|
+
};
|
|
30
|
+
export const secondsToDays = (seconds) => {
|
|
31
|
+
if (isEmpty(seconds)) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
return seconds / DAY_SECONDS;
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
// eslint-disable-next-line no-promise-executor-return
|
|
43
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
44
|
+
export const timeUtil = {
|
|
45
|
+
timestampToStr,
|
|
46
|
+
timestampToLL,
|
|
47
|
+
getUnixTimestamp,
|
|
48
|
+
secondsToDays,
|
|
49
|
+
sleep,
|
|
50
|
+
};
|
|
51
51
|
//# sourceMappingURL=time.js.map
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
-
import { ContractReceipt } from '@ethersproject/contracts';
|
|
3
|
-
import { Web3Provider } from '@ethersproject/providers';
|
|
4
|
-
import { ethers } from 'ethers';
|
|
5
|
-
export declare enum TxStateType {
|
|
6
|
-
Success = "Success",
|
|
7
|
-
Denied = "Denied",
|
|
8
|
-
Invalid = "Invalid",
|
|
9
|
-
Failed = "Failed",
|
|
10
|
-
New = "New",
|
|
11
|
-
GasEstimating = "GasEstimating",
|
|
12
|
-
Signing = "Signing",
|
|
13
|
-
Confirming = "Confirming"
|
|
14
|
-
}
|
|
15
|
-
export interface TxResponse {
|
|
16
|
-
txReceipt: ContractReceipt;
|
|
17
|
-
}
|
|
18
|
-
export interface Event {
|
|
19
|
-
name: string;
|
|
20
|
-
type: string;
|
|
21
|
-
value: string;
|
|
22
|
-
}
|
|
23
|
-
export interface EventLog {
|
|
24
|
-
name: string;
|
|
25
|
-
events: Event[];
|
|
26
|
-
address: string;
|
|
27
|
-
}
|
|
28
|
-
export declare const isTxFailed: (txState: TxStateType) => boolean;
|
|
29
|
-
export declare const increaseGasLimit: (estimatedGasLimit: BigNumber) => BigNumber;
|
|
30
|
-
export declare const getTransactionErrorFromHash: (provider: Web3Provider, txHash: string) => Promise<string>;
|
|
31
|
-
export declare const getTransactionErrorFromError: (e: any) => string | null;
|
|
32
|
-
export declare const decodeLogs: (txlogs: any[], abi: any) => ethers.utils.LogDescription[];
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
+
import { ContractReceipt } from '@ethersproject/contracts';
|
|
3
|
+
import { Web3Provider } from '@ethersproject/providers';
|
|
4
|
+
import { ethers } from 'ethers';
|
|
5
|
+
export declare enum TxStateType {
|
|
6
|
+
Success = "Success",
|
|
7
|
+
Denied = "Denied",
|
|
8
|
+
Invalid = "Invalid",
|
|
9
|
+
Failed = "Failed",
|
|
10
|
+
New = "New",
|
|
11
|
+
GasEstimating = "GasEstimating",
|
|
12
|
+
Signing = "Signing",
|
|
13
|
+
Confirming = "Confirming"
|
|
14
|
+
}
|
|
15
|
+
export interface TxResponse {
|
|
16
|
+
txReceipt: ContractReceipt;
|
|
17
|
+
}
|
|
18
|
+
export interface Event {
|
|
19
|
+
name: string;
|
|
20
|
+
type: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
export interface EventLog {
|
|
24
|
+
name: string;
|
|
25
|
+
events: Event[];
|
|
26
|
+
address: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const isTxFailed: (txState: TxStateType) => boolean;
|
|
29
|
+
export declare const increaseGasLimit: (estimatedGasLimit: BigNumber) => BigNumber;
|
|
30
|
+
export declare const getTransactionErrorFromHash: (provider: Web3Provider, txHash: string) => Promise<string>;
|
|
31
|
+
export declare const getTransactionErrorFromError: (e: any) => string | null;
|
|
32
|
+
export declare const decodeLogs: (txlogs: any[], abi: any) => ethers.utils.LogDescription[];
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
|
-
import TxErrors from './contractError.json';
|
|
3
|
-
import { capitalizeFirstLetter } from './string';
|
|
4
|
-
export var TxStateType;
|
|
5
|
-
(function (TxStateType) {
|
|
6
|
-
TxStateType["Success"] = "Success";
|
|
7
|
-
TxStateType["Denied"] = "Denied";
|
|
8
|
-
TxStateType["Invalid"] = "Invalid";
|
|
9
|
-
TxStateType["Failed"] = "Failed";
|
|
10
|
-
TxStateType["New"] = "New";
|
|
11
|
-
TxStateType["GasEstimating"] = "GasEstimating";
|
|
12
|
-
TxStateType["Signing"] = "Signing";
|
|
13
|
-
TxStateType["Confirming"] = "Confirming";
|
|
14
|
-
})(TxStateType || (TxStateType = {}));
|
|
15
|
-
export const isTxFailed = (txState) => [TxStateType.Denied, TxStateType.Invalid, TxStateType.Failed].includes(txState);
|
|
16
|
-
export const increaseGasLimit = (estimatedGasLimit) => {
|
|
17
|
-
if (!estimatedGasLimit || Number.isNaN(estimatedGasLimit.toNumber())) {
|
|
18
|
-
console.log('estimatedGasLimit', estimatedGasLimit);
|
|
19
|
-
throw new Error('Estimated gas limited error.');
|
|
20
|
-
}
|
|
21
|
-
return estimatedGasLimit.mul(150).div(100);
|
|
22
|
-
};
|
|
23
|
-
const parseErrorMessageToUserFriendlyMessage = (message) => capitalizeFirstLetter(message
|
|
24
|
-
.replace('()', '')
|
|
25
|
-
.split(/(?=[A-Z])/)
|
|
26
|
-
.join(' ')
|
|
27
|
-
.toLowerCase());
|
|
28
|
-
const findContractErrorMessage = (code) => {
|
|
29
|
-
let reason = null;
|
|
30
|
-
Object.keys(TxErrors).forEach((key) => {
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
if (code.toLowerCase() === TxErrors[key].toLowerCase()) {
|
|
33
|
-
reason = parseErrorMessageToUserFriendlyMessage(key);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
return reason;
|
|
37
|
-
};
|
|
38
|
-
export const getTransactionErrorFromHash = async (provider, txHash) => {
|
|
39
|
-
const commonErrorMessage = 'Send transaction failed';
|
|
40
|
-
try {
|
|
41
|
-
const originTx = await provider.getTransaction(txHash);
|
|
42
|
-
const { from, to, data, gasLimit, blockNumber } = originTx;
|
|
43
|
-
// Only provide necessary params to get the tx return which can avoid unexpected error
|
|
44
|
-
const tx = { from, to, data, gasLimit };
|
|
45
|
-
const code = await provider.call(tx, blockNumber);
|
|
46
|
-
const reason = findContractErrorMessage(code);
|
|
47
|
-
return reason !== null && reason !== void 0 ? reason : commonErrorMessage;
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
if (!error.data) {
|
|
52
|
-
console.error(error);
|
|
53
|
-
return commonErrorMessage;
|
|
54
|
-
}
|
|
55
|
-
const code = error.data.replace('Reverted ', '');
|
|
56
|
-
const reason = ethers.utils.toUtf8String(`0x${code.substr(138)}`);
|
|
57
|
-
return reason;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
-
export const getTransactionErrorFromError = (e) => {
|
|
62
|
-
var _a, _b, _c, _d, _e;
|
|
63
|
-
const errorCode = ((_c = (_b = (_a = e.error) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.originalError) === null || _c === void 0 ? void 0 : _c.data) || ((_e = (_d = e.error) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.data);
|
|
64
|
-
if (errorCode) {
|
|
65
|
-
const contractErrorMessage = findContractErrorMessage(errorCode);
|
|
66
|
-
if (contractErrorMessage) {
|
|
67
|
-
return contractErrorMessage;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return null;
|
|
71
|
-
};
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
-
export const decodeLogs = (txlogs, abi) => {
|
|
74
|
-
const result = [];
|
|
75
|
-
const iface = new ethers.utils.Interface(abi);
|
|
76
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
77
|
-
for (const log of txlogs) {
|
|
78
|
-
try {
|
|
79
|
-
result.push(iface.parseLog(log));
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
console.error(error);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return result;
|
|
87
|
-
};
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import TxErrors from './contractError.json';
|
|
3
|
+
import { capitalizeFirstLetter } from './string';
|
|
4
|
+
export var TxStateType;
|
|
5
|
+
(function (TxStateType) {
|
|
6
|
+
TxStateType["Success"] = "Success";
|
|
7
|
+
TxStateType["Denied"] = "Denied";
|
|
8
|
+
TxStateType["Invalid"] = "Invalid";
|
|
9
|
+
TxStateType["Failed"] = "Failed";
|
|
10
|
+
TxStateType["New"] = "New";
|
|
11
|
+
TxStateType["GasEstimating"] = "GasEstimating";
|
|
12
|
+
TxStateType["Signing"] = "Signing";
|
|
13
|
+
TxStateType["Confirming"] = "Confirming";
|
|
14
|
+
})(TxStateType || (TxStateType = {}));
|
|
15
|
+
export const isTxFailed = (txState) => [TxStateType.Denied, TxStateType.Invalid, TxStateType.Failed].includes(txState);
|
|
16
|
+
export const increaseGasLimit = (estimatedGasLimit) => {
|
|
17
|
+
if (!estimatedGasLimit || Number.isNaN(estimatedGasLimit.toNumber())) {
|
|
18
|
+
console.log('estimatedGasLimit', estimatedGasLimit);
|
|
19
|
+
throw new Error('Estimated gas limited error.');
|
|
20
|
+
}
|
|
21
|
+
return estimatedGasLimit.mul(150).div(100);
|
|
22
|
+
};
|
|
23
|
+
const parseErrorMessageToUserFriendlyMessage = (message) => capitalizeFirstLetter(message
|
|
24
|
+
.replace('()', '')
|
|
25
|
+
.split(/(?=[A-Z])/)
|
|
26
|
+
.join(' ')
|
|
27
|
+
.toLowerCase());
|
|
28
|
+
const findContractErrorMessage = (code) => {
|
|
29
|
+
let reason = null;
|
|
30
|
+
Object.keys(TxErrors).forEach((key) => {
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
if (code.toLowerCase() === TxErrors[key].toLowerCase()) {
|
|
33
|
+
reason = parseErrorMessageToUserFriendlyMessage(key);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return reason;
|
|
37
|
+
};
|
|
38
|
+
export const getTransactionErrorFromHash = async (provider, txHash) => {
|
|
39
|
+
const commonErrorMessage = 'Send transaction failed';
|
|
40
|
+
try {
|
|
41
|
+
const originTx = await provider.getTransaction(txHash);
|
|
42
|
+
const { from, to, data, gasLimit, blockNumber } = originTx;
|
|
43
|
+
// Only provide necessary params to get the tx return which can avoid unexpected error
|
|
44
|
+
const tx = { from, to, data, gasLimit };
|
|
45
|
+
const code = await provider.call(tx, blockNumber);
|
|
46
|
+
const reason = findContractErrorMessage(code);
|
|
47
|
+
return reason !== null && reason !== void 0 ? reason : commonErrorMessage;
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (!error.data) {
|
|
52
|
+
console.error(error);
|
|
53
|
+
return commonErrorMessage;
|
|
54
|
+
}
|
|
55
|
+
const code = error.data.replace('Reverted ', '');
|
|
56
|
+
const reason = ethers.utils.toUtf8String(`0x${code.substr(138)}`);
|
|
57
|
+
return reason;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
export const getTransactionErrorFromError = (e) => {
|
|
62
|
+
var _a, _b, _c, _d, _e;
|
|
63
|
+
const errorCode = ((_c = (_b = (_a = e.error) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.originalError) === null || _c === void 0 ? void 0 : _c.data) || ((_e = (_d = e.error) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.data);
|
|
64
|
+
if (errorCode) {
|
|
65
|
+
const contractErrorMessage = findContractErrorMessage(errorCode);
|
|
66
|
+
if (contractErrorMessage) {
|
|
67
|
+
return contractErrorMessage;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
};
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
+
export const decodeLogs = (txlogs, abi) => {
|
|
74
|
+
const result = [];
|
|
75
|
+
const iface = new ethers.utils.Interface(abi);
|
|
76
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
77
|
+
for (const log of txlogs) {
|
|
78
|
+
try {
|
|
79
|
+
result.push(iface.parseLog(log));
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error(error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
};
|
|
88
88
|
//# sourceMappingURL=transaction.js.map
|
package/dist/utils/web3.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Contract } from '@ethersproject/contracts';
|
|
2
|
-
import { JsonRpcProvider } from '@ethersproject/providers';
|
|
3
|
-
export declare function isAddress(value: any): string | false;
|
|
4
|
-
export declare function getContract(address: string, ABI: any, provider: JsonRpcProvider, account?: string): Contract;
|
|
1
|
+
import { Contract } from '@ethersproject/contracts';
|
|
2
|
+
import { JsonRpcProvider } from '@ethersproject/providers';
|
|
3
|
+
export declare function isAddress(value: any): string | false;
|
|
4
|
+
export declare function getContract(address: string, ABI: any, provider: JsonRpcProvider, account?: string): Contract;
|
package/dist/utils/web3.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { Contract } from '@ethersproject/contracts';
|
|
2
|
-
import { AddressZero } from '@ethersproject/constants';
|
|
3
|
-
import { getAddress } from '@ethersproject/address';
|
|
4
|
-
// returns the checksummed address if the address is valid, otherwise returns false
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
export function isAddress(value) {
|
|
7
|
-
try {
|
|
8
|
-
// Alphabetical letters must be made lowercase for getAddress to work.
|
|
9
|
-
// See documentation here: https://docs.ethers.io/v5/api/utils/address/
|
|
10
|
-
return getAddress(value.toLowerCase());
|
|
11
|
-
}
|
|
12
|
-
catch (_a) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// account is not optional
|
|
17
|
-
function getSigner(provider, account) {
|
|
18
|
-
return provider.getSigner(account).connectUnchecked();
|
|
19
|
-
}
|
|
20
|
-
// account is optional
|
|
21
|
-
function getProviderOrSigner(provider, account) {
|
|
22
|
-
return account ? getSigner(provider, account) : provider;
|
|
23
|
-
}
|
|
24
|
-
// account is optional
|
|
25
|
-
export function getContract(address,
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
-
ABI, provider, account) {
|
|
28
|
-
if (!isAddress(address) || address === AddressZero) {
|
|
29
|
-
throw Error(`Invalid 'address' parameter '${address}'.`);
|
|
30
|
-
}
|
|
31
|
-
return new Contract(address, ABI,
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
-
getProviderOrSigner(provider, account));
|
|
34
|
-
}
|
|
1
|
+
import { Contract } from '@ethersproject/contracts';
|
|
2
|
+
import { AddressZero } from '@ethersproject/constants';
|
|
3
|
+
import { getAddress } from '@ethersproject/address';
|
|
4
|
+
// returns the checksummed address if the address is valid, otherwise returns false
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
export function isAddress(value) {
|
|
7
|
+
try {
|
|
8
|
+
// Alphabetical letters must be made lowercase for getAddress to work.
|
|
9
|
+
// See documentation here: https://docs.ethers.io/v5/api/utils/address/
|
|
10
|
+
return getAddress(value.toLowerCase());
|
|
11
|
+
}
|
|
12
|
+
catch (_a) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// account is not optional
|
|
17
|
+
function getSigner(provider, account) {
|
|
18
|
+
return provider.getSigner(account).connectUnchecked();
|
|
19
|
+
}
|
|
20
|
+
// account is optional
|
|
21
|
+
function getProviderOrSigner(provider, account) {
|
|
22
|
+
return account ? getSigner(provider, account) : provider;
|
|
23
|
+
}
|
|
24
|
+
// account is optional
|
|
25
|
+
export function getContract(address,
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
ABI, provider, account) {
|
|
28
|
+
if (!isAddress(address) || address === AddressZero) {
|
|
29
|
+
throw Error(`Invalid 'address' parameter '${address}'.`);
|
|
30
|
+
}
|
|
31
|
+
return new Contract(address, ABI,
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
getProviderOrSigner(provider, account));
|
|
34
|
+
}
|
|
35
35
|
//# sourceMappingURL=web3.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"start": "tsc -w",
|
|
11
|
+
"start": "tsc -w --project ./tsconfig.build.json",
|
|
12
12
|
"postbuild": "copyfiles -u 1 ./src/components/icons/*.svg dist",
|
|
13
13
|
"build": "tsc --project ./tsconfig.build.json && tsc --project ./tsconfig.cjs.json",
|
|
14
14
|
"contracts:compile:abi": "typechain --target ethers-v5 --out-dir src/abis/types \"./src/abis/**/*.json\"",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"optionalDependencies": {
|
|
150
150
|
"encoding": "^0.1.13"
|
|
151
151
|
},
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "d58baeee71cc6d50a8dab3ce91411bf88c846f00"
|
|
153
153
|
}
|