@toruslabs/ethereum-controllers 7.1.2 → 7.2.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/dist/ethereumControllers.cjs.js +76 -46
- package/dist/ethereumControllers.esm.js +36 -7
- package/dist/ethereumControllers.umd.min.js +1 -1
- package/dist/lib.cjs/Gas/gasUtil.js +15 -15
- package/dist/lib.cjs/Message/utils.js +11 -4
- package/dist/lib.cjs/Network/createEthereumMiddleware.js +23 -0
- package/dist/lib.cjs/Preferences/PreferencesController.js +1 -0
- package/dist/lib.cjs/Tokens/TokensController.js +1 -2
- package/dist/lib.cjs/Transaction/TransactionController.js +5 -5
- package/dist/lib.cjs/index.js +1 -0
- package/dist/lib.cjs/utils/conversionUtils.js +17 -17
- package/dist/lib.cjs/utils/helpers.js +6 -6
- package/dist/lib.esm/Gas/gasUtil.js +1 -1
- package/dist/lib.esm/Message/utils.js +11 -4
- package/dist/lib.esm/Network/createEthereumMiddleware.js +23 -1
- package/dist/lib.esm/Preferences/PreferencesController.js +2 -1
- package/dist/lib.esm/Tokens/TokensController.js +1 -2
- package/dist/lib.esm/Transaction/TransactionController.js +1 -1
- package/dist/lib.esm/index.js +1 -1
- package/dist/lib.esm/utils/conversionUtils.js +1 -1
- package/dist/lib.esm/utils/helpers.js +1 -1
- package/dist/types/Account/AccountTrackerController.d.ts +2 -1
- package/dist/types/Gas/gasUtil.d.ts +1 -1
- package/dist/types/Message/SwitchChainController.d.ts +1 -2
- package/dist/types/Message/utils.d.ts +2 -2
- package/dist/types/Network/createEthereumMiddleware.d.ts +6 -2
- package/dist/types/Nfts/INftsController.d.ts +8 -8
- package/dist/types/Nfts/NftHandler.d.ts +2 -1
- package/dist/types/Nfts/NftsController.d.ts +6 -5
- package/dist/types/Preferences/IPreferencesController.d.ts +10 -0
- package/dist/types/Preferences/PreferencesController.d.ts +4 -1
- package/dist/types/Tokens/TokenRatesController.d.ts +2 -1
- package/dist/types/Tokens/TokensController.d.ts +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utils/conversionUtils.d.ts +1 -1
- package/dist/types/utils/helpers.d.ts +1 -1
- package/dist/types/utils/interfaces.d.ts +11 -74
- package/package.json +4 -4
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
4
|
var httpHelpers = require('@toruslabs/http-helpers');
|
|
5
|
-
var
|
|
5
|
+
var bignumber_js = require('bignumber.js');
|
|
6
6
|
var constants = require('../utils/constants.js');
|
|
7
7
|
var conversionUtils = require('../utils/conversionUtils.js');
|
|
8
8
|
|
|
9
9
|
function normalizeGWEIDecimalNumbers(n) {
|
|
10
|
-
const numberAsWEIHex = conversionUtils.decGWEIToHexWEI(new BigNumber(n));
|
|
10
|
+
const numberAsWEIHex = conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(n));
|
|
11
11
|
const numberAsGWEI = conversionUtils.hexWEIToDecGWEI(numberAsWEIHex);
|
|
12
12
|
return numberAsGWEI;
|
|
13
13
|
}
|
|
@@ -46,14 +46,14 @@ async function fetchGasEstimatesViaEthFeeHistory(provider) {
|
|
|
46
46
|
const numberOfRewards = rewardList.length || 1;
|
|
47
47
|
const priorityFeeCalcs = rewardList.reduce((acc, curr) => {
|
|
48
48
|
return {
|
|
49
|
-
slow: acc.slow.plus(new BigNumber(curr[0], 16)),
|
|
50
|
-
average: acc.average.plus(new BigNumber(curr[1], 16)),
|
|
51
|
-
fast: acc.fast.plus(new BigNumber(curr[2], 16))
|
|
49
|
+
slow: acc.slow.plus(new bignumber_js.BigNumber(curr[0], 16)),
|
|
50
|
+
average: acc.average.plus(new bignumber_js.BigNumber(curr[1], 16)),
|
|
51
|
+
fast: acc.fast.plus(new bignumber_js.BigNumber(curr[2], 16))
|
|
52
52
|
};
|
|
53
53
|
}, {
|
|
54
|
-
slow: new BigNumber(0),
|
|
55
|
-
average: new BigNumber(0),
|
|
56
|
-
fast: new BigNumber(0)
|
|
54
|
+
slow: new bignumber_js.BigNumber(0),
|
|
55
|
+
average: new bignumber_js.BigNumber(0),
|
|
56
|
+
fast: new bignumber_js.BigNumber(0)
|
|
57
57
|
});
|
|
58
58
|
return {
|
|
59
59
|
estimatedBaseFee: conversionUtils.hexWEIToDecGWEI(finalBaseFeePerGas).toString(10),
|
|
@@ -111,13 +111,13 @@ function calculateTimeEstimate(maxPriorityFeePerGas, maxFeePerGas, gasFeeEstimat
|
|
|
111
111
|
high,
|
|
112
112
|
estimatedBaseFee
|
|
113
113
|
} = gasFeeEstimates;
|
|
114
|
-
const maxPriorityFeePerGasInWEI = new BigNumber(conversionUtils.decGWEIToHexWEI(new BigNumber(maxPriorityFeePerGas)), 16);
|
|
115
|
-
const maxFeePerGasInWEI = new BigNumber(conversionUtils.decGWEIToHexWEI(new BigNumber(maxFeePerGas)), 16);
|
|
116
|
-
const estimatedBaseFeeInWEI = new BigNumber(conversionUtils.decGWEIToHexWEI(new BigNumber(estimatedBaseFee)), 16);
|
|
117
|
-
const effectiveMaxPriorityFee = BigNumber.min(maxPriorityFeePerGasInWEI, maxFeePerGasInWEI.minus(estimatedBaseFeeInWEI));
|
|
118
|
-
const lowMaxPriorityFeeInWEI = new BigNumber(conversionUtils.decGWEIToHexWEI(new BigNumber(low.suggestedMaxPriorityFeePerGas)), 16);
|
|
119
|
-
const mediumMaxPriorityFeeInWEI = new BigNumber(conversionUtils.decGWEIToHexWEI(new BigNumber(medium.suggestedMaxPriorityFeePerGas)), 16);
|
|
120
|
-
const highMaxPriorityFeeInWEI = new BigNumber(conversionUtils.decGWEIToHexWEI(new BigNumber(high.suggestedMaxPriorityFeePerGas)), 16);
|
|
114
|
+
const maxPriorityFeePerGasInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(maxPriorityFeePerGas)), 16);
|
|
115
|
+
const maxFeePerGasInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(maxFeePerGas)), 16);
|
|
116
|
+
const estimatedBaseFeeInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(estimatedBaseFee)), 16);
|
|
117
|
+
const effectiveMaxPriorityFee = bignumber_js.BigNumber.min(maxPriorityFeePerGasInWEI, maxFeePerGasInWEI.minus(estimatedBaseFeeInWEI));
|
|
118
|
+
const lowMaxPriorityFeeInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(low.suggestedMaxPriorityFeePerGas)), 16);
|
|
119
|
+
const mediumMaxPriorityFeeInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(medium.suggestedMaxPriorityFeePerGas)), 16);
|
|
120
|
+
const highMaxPriorityFeeInWEI = new bignumber_js.BigNumber(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(high.suggestedMaxPriorityFeePerGas)), 16);
|
|
121
121
|
let lowerTimeBound;
|
|
122
122
|
let upperTimeBound;
|
|
123
123
|
if (effectiveMaxPriorityFee.lt(lowMaxPriorityFeeInWEI)) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var util = require('@ethereumjs/util');
|
|
4
|
+
var baseControllers = require('@toruslabs/base-controllers');
|
|
4
5
|
var ethers = require('ethers');
|
|
5
6
|
|
|
6
7
|
const hexRe = /^[0-9A-Fa-f]+$/gu;
|
|
@@ -94,13 +95,19 @@ async function validateAddChainData(data) {
|
|
|
94
95
|
}
|
|
95
96
|
function validateSwitchChainData(data) {
|
|
96
97
|
const {
|
|
97
|
-
chainId
|
|
98
|
+
chainId: fullChainId
|
|
98
99
|
} = data || {};
|
|
99
|
-
if (!
|
|
100
|
+
if (!fullChainId) {
|
|
100
101
|
throw new Error("Invalid switch chain params: please pass chainId in params");
|
|
101
102
|
}
|
|
102
|
-
if (!ethers.isHexString(
|
|
103
|
-
|
|
103
|
+
if (!ethers.isHexString(fullChainId)) {
|
|
104
|
+
const [namespace, chainId] = fullChainId.split(":");
|
|
105
|
+
if (namespace !== baseControllers.CHAIN_NAMESPACES.SOLANA && namespace !== baseControllers.CHAIN_NAMESPACES.EIP155) {
|
|
106
|
+
throw new Error("Invalid switch chain params: invalid namespace");
|
|
107
|
+
}
|
|
108
|
+
if (!chainId || isNaN(Number(chainId))) {
|
|
109
|
+
throw new Error("Invalid switch chain params: invalid chainId");
|
|
110
|
+
}
|
|
104
111
|
}
|
|
105
112
|
}
|
|
106
113
|
|
|
@@ -225,6 +225,25 @@ function createProcessSwitchEthereumChain({
|
|
|
225
225
|
response.result = await processSwitchEthereumChain(msgParams, request);
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
|
+
function createProcessWalletSwitchChain({
|
|
229
|
+
processWalletSwitchChain
|
|
230
|
+
}) {
|
|
231
|
+
return auth.createAsyncMiddleware(async (request, response, next) => {
|
|
232
|
+
const {
|
|
233
|
+
method
|
|
234
|
+
} = request;
|
|
235
|
+
if (method !== baseControllers.PROVIDER_JRPC_METHODS.WALLET_SWITCH_CHAIN) return next();
|
|
236
|
+
if (!processWalletSwitchChain) throw new Error("WalletMiddleware - opts.processWalletSwitchChain not provided");
|
|
237
|
+
if (!(request !== null && request !== void 0 && request.params)) throw new Error("WalletMiddleware - missing params");
|
|
238
|
+
let msgParams = request.params;
|
|
239
|
+
if (Array.isArray(request.params)) {
|
|
240
|
+
if (!(request.params.length === 1)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [data]`);
|
|
241
|
+
const [message] = request.params;
|
|
242
|
+
msgParams = message;
|
|
243
|
+
}
|
|
244
|
+
response.result = await processWalletSwitchChain(msgParams, request);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
228
247
|
function createProcessAddEthereumChain({
|
|
229
248
|
processAddEthereumChain
|
|
230
249
|
}) {
|
|
@@ -271,6 +290,7 @@ function createEthereumMiddleware(providerHandlers) {
|
|
|
271
290
|
getPendingNonce,
|
|
272
291
|
getPendingTransactionByHash,
|
|
273
292
|
processSwitchEthereumChain,
|
|
293
|
+
processWalletSwitchChain,
|
|
274
294
|
processAddEthereumChain,
|
|
275
295
|
getProviderState,
|
|
276
296
|
version
|
|
@@ -298,6 +318,8 @@ function createEthereumMiddleware(providerHandlers) {
|
|
|
298
318
|
getPendingTransactionByHash
|
|
299
319
|
}), createProcessSwitchEthereumChain({
|
|
300
320
|
processSwitchEthereumChain
|
|
321
|
+
}), createProcessWalletSwitchChain({
|
|
322
|
+
processWalletSwitchChain
|
|
301
323
|
}), createProcessAddEthereumChain({
|
|
302
324
|
processAddEthereumChain
|
|
303
325
|
})]);
|
|
@@ -314,5 +336,6 @@ exports.createProcessPersonalMessage = createProcessPersonalMessage;
|
|
|
314
336
|
exports.createProcessSwitchEthereumChain = createProcessSwitchEthereumChain;
|
|
315
337
|
exports.createProcessTransactionMiddleware = createProcessTransactionMiddleware;
|
|
316
338
|
exports.createProcessTypedMessageV4 = createProcessTypedMessageV4;
|
|
339
|
+
exports.createProcessWalletSwitchChain = createProcessWalletSwitchChain;
|
|
317
340
|
exports.createRequestAccountsMiddleware = createRequestAccountsMiddleware;
|
|
318
341
|
exports.formatTxMetaForRpcResult = formatTxMetaForRpcResult;
|
|
@@ -30,6 +30,7 @@ class PreferencesController extends baseControllers.BasePreferencesController {
|
|
|
30
30
|
signAuthMessage,
|
|
31
31
|
validateSignMessage
|
|
32
32
|
});
|
|
33
|
+
_defineProperty(this, "chainNamespace", baseControllers.CHAIN_NAMESPACES.EIP155);
|
|
33
34
|
_defineProperty(this, "_handle", void 0);
|
|
34
35
|
_defineProperty(this, "_mutex", new asyncMutex.Mutex());
|
|
35
36
|
_defineProperty(this, "getProviderConfig", void 0);
|
|
@@ -8,7 +8,6 @@ var log = require('loglevel');
|
|
|
8
8
|
var abis = require('../utils/abis.js');
|
|
9
9
|
var constants = require('../utils/constants.js');
|
|
10
10
|
var contractAddresses = require('../utils/contractAddresses.js');
|
|
11
|
-
var helpers = require('../utils/helpers.js');
|
|
12
11
|
var TokenHandler = require('./TokenHandler.js');
|
|
13
12
|
|
|
14
13
|
function getObjectFromArrayBasedonKey(oldArray, key) {
|
|
@@ -236,7 +235,7 @@ class TokensController extends baseControllers.BaseController {
|
|
|
236
235
|
logo: x.logo || "eth.svg",
|
|
237
236
|
name: tokenInstance.name,
|
|
238
237
|
symbol: tokenInstance.symbol,
|
|
239
|
-
tokenAddress:
|
|
238
|
+
tokenAddress: tokenInstance.address,
|
|
240
239
|
balance: `0x${balance}`,
|
|
241
240
|
customTokenId: x.customTokenId,
|
|
242
241
|
network: x.chainId,
|
|
@@ -5,7 +5,7 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
|
5
5
|
var util = require('@ethereumjs/util');
|
|
6
6
|
var baseControllers = require('@toruslabs/base-controllers');
|
|
7
7
|
var auth = require('@web3auth/auth');
|
|
8
|
-
var
|
|
8
|
+
var bignumber_js = require('bignumber.js');
|
|
9
9
|
var ethers = require('ethers');
|
|
10
10
|
var log = require('loglevel');
|
|
11
11
|
var constants = require('../utils/constants.js');
|
|
@@ -336,8 +336,8 @@ class TransactionController extends TransactionStateManager.TransactionStateMana
|
|
|
336
336
|
if (suggestedMaxPriorityFeePerGas && suggestedMaxFeePerGas) {
|
|
337
337
|
return {
|
|
338
338
|
// send to controller in hex wei
|
|
339
|
-
maxFeePerGas: util.addHexPrefix(conversionUtils.decGWEIToHexWEI(new BigNumber(suggestedMaxFeePerGas)).toString(16)),
|
|
340
|
-
maxPriorityFeePerGas: util.addHexPrefix(conversionUtils.decGWEIToHexWEI(new BigNumber(suggestedMaxPriorityFeePerGas)).toString(16))
|
|
339
|
+
maxFeePerGas: util.addHexPrefix(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(suggestedMaxFeePerGas)).toString(16)),
|
|
340
|
+
maxPriorityFeePerGas: util.addHexPrefix(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(suggestedMaxPriorityFeePerGas)).toString(16))
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
343
|
} else if (gasEstimateType === constants.GAS_ESTIMATE_TYPES.LEGACY) {
|
|
@@ -347,7 +347,7 @@ class TransactionController extends TransactionStateManager.TransactionStateMana
|
|
|
347
347
|
// The LEGACY type includes low, medium and high estimates of
|
|
348
348
|
// gas price values.
|
|
349
349
|
return {
|
|
350
|
-
gasPrice: util.addHexPrefix(conversionUtils.decGWEIToHexWEI(new BigNumber(medium)).toString(16))
|
|
350
|
+
gasPrice: util.addHexPrefix(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(medium)).toString(16))
|
|
351
351
|
};
|
|
352
352
|
} else if (gasEstimateType === constants.GAS_ESTIMATE_TYPES.ETH_GASPRICE) {
|
|
353
353
|
const {
|
|
@@ -356,7 +356,7 @@ class TransactionController extends TransactionStateManager.TransactionStateMana
|
|
|
356
356
|
// The ETH_GASPRICE type just includes a single gas price property,
|
|
357
357
|
// which we can assume was retrieved from eth_gasPrice
|
|
358
358
|
return {
|
|
359
|
-
gasPrice: util.addHexPrefix(conversionUtils.decGWEIToHexWEI(new BigNumber(gasPrice)).toString(16))
|
|
359
|
+
gasPrice: util.addHexPrefix(conversionUtils.decGWEIToHexWEI(new bignumber_js.BigNumber(gasPrice)).toString(16))
|
|
360
360
|
};
|
|
361
361
|
}
|
|
362
362
|
} catch (error) {
|
package/dist/lib.cjs/index.js
CHANGED
|
@@ -70,6 +70,7 @@ exports.createProcessPersonalMessage = createEthereumMiddleware.createProcessPer
|
|
|
70
70
|
exports.createProcessSwitchEthereumChain = createEthereumMiddleware.createProcessSwitchEthereumChain;
|
|
71
71
|
exports.createProcessTransactionMiddleware = createEthereumMiddleware.createProcessTransactionMiddleware;
|
|
72
72
|
exports.createProcessTypedMessageV4 = createEthereumMiddleware.createProcessTypedMessageV4;
|
|
73
|
+
exports.createProcessWalletSwitchChain = createEthereumMiddleware.createProcessWalletSwitchChain;
|
|
73
74
|
exports.createRequestAccountsMiddleware = createEthereumMiddleware.createRequestAccountsMiddleware;
|
|
74
75
|
exports.formatTxMetaForRpcResult = createEthereumMiddleware.formatTxMetaForRpcResult;
|
|
75
76
|
exports.createChainIdMiddleware = createJsonRpcClient.createChainIdMiddleware;
|
|
@@ -4,7 +4,7 @@ var _objectDestructuringEmpty = require('@babel/runtime/helpers/objectDestructur
|
|
|
4
4
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
5
5
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
6
6
|
var util = require('@ethereumjs/util');
|
|
7
|
-
var
|
|
7
|
+
var bignumber_js = require('bignumber.js');
|
|
8
8
|
var BN = require('bn.js');
|
|
9
9
|
|
|
10
10
|
const _excluded = ["aBase", "bBase"],
|
|
@@ -12,14 +12,14 @@ const _excluded = ["aBase", "bBase"],
|
|
|
12
12
|
_excluded3 = ["multiplicandBase", "multiplierBase"];
|
|
13
13
|
|
|
14
14
|
// Big Number Constants
|
|
15
|
-
const BIG_NUMBER_WEI_MULTIPLIER = new BigNumber("1000000000000000000");
|
|
16
|
-
const BIG_NUMBER_GWEI_MULTIPLIER = new BigNumber("1000000000");
|
|
17
|
-
const BIG_NUMBER_ETH_MULTIPLIER = new BigNumber("1");
|
|
15
|
+
const BIG_NUMBER_WEI_MULTIPLIER = new bignumber_js.BigNumber("1000000000000000000");
|
|
16
|
+
const BIG_NUMBER_GWEI_MULTIPLIER = new bignumber_js.BigNumber("1000000000");
|
|
17
|
+
const BIG_NUMBER_ETH_MULTIPLIER = new bignumber_js.BigNumber("1");
|
|
18
18
|
// Setter Maps
|
|
19
19
|
const toBigNumber = {
|
|
20
|
-
hex: n => new BigNumber(util.stripHexPrefix(n), 16),
|
|
21
|
-
dec: n => new BigNumber(String(n), 10),
|
|
22
|
-
BN: n => new BigNumber(n.toString(16), 16)
|
|
20
|
+
hex: n => new bignumber_js.BigNumber(util.stripHexPrefix(n), 16),
|
|
21
|
+
dec: n => new bignumber_js.BigNumber(String(n), 10),
|
|
22
|
+
BN: n => new bignumber_js.BigNumber(n.toString(16), 16)
|
|
23
23
|
};
|
|
24
24
|
const toNormalizedDenomination = {
|
|
25
25
|
WEI: bigNumber => bigNumber.div(BIG_NUMBER_WEI_MULTIPLIER),
|
|
@@ -27,13 +27,13 @@ const toNormalizedDenomination = {
|
|
|
27
27
|
ETH: bigNumber => bigNumber.div(BIG_NUMBER_ETH_MULTIPLIER)
|
|
28
28
|
};
|
|
29
29
|
const toSpecifiedDenomination = {
|
|
30
|
-
WEI: bigNumber => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER).dp(0, BigNumber.ROUND_HALF_UP),
|
|
31
|
-
GWEI: bigNumber => bigNumber.times(BIG_NUMBER_GWEI_MULTIPLIER).dp(9, BigNumber.ROUND_HALF_UP),
|
|
32
|
-
ETH: bigNumber => bigNumber.times(BIG_NUMBER_ETH_MULTIPLIER).dp(9, BigNumber.ROUND_HALF_UP)
|
|
30
|
+
WEI: bigNumber => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER).dp(0, bignumber_js.BigNumber.ROUND_HALF_UP),
|
|
31
|
+
GWEI: bigNumber => bigNumber.times(BIG_NUMBER_GWEI_MULTIPLIER).dp(9, bignumber_js.BigNumber.ROUND_HALF_UP),
|
|
32
|
+
ETH: bigNumber => bigNumber.times(BIG_NUMBER_ETH_MULTIPLIER).dp(9, bignumber_js.BigNumber.ROUND_HALF_UP)
|
|
33
33
|
};
|
|
34
34
|
const baseChange = {
|
|
35
35
|
hex: n => n.toString(16),
|
|
36
|
-
dec: n => new BigNumber(n).toString(10),
|
|
36
|
+
dec: n => new bignumber_js.BigNumber(n).toString(10),
|
|
37
37
|
BN: n => new BN(n.toString(16))
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -66,7 +66,7 @@ const converter = ({
|
|
|
66
66
|
}
|
|
67
67
|
let rate = toBigNumber.dec(conversionRate);
|
|
68
68
|
if (invertConversionRate) {
|
|
69
|
-
rate = new BigNumber(1).div(conversionRate);
|
|
69
|
+
rate = new bignumber_js.BigNumber(1).div(conversionRate);
|
|
70
70
|
}
|
|
71
71
|
convertedValue = convertedValue.times(rate);
|
|
72
72
|
}
|
|
@@ -74,10 +74,10 @@ const converter = ({
|
|
|
74
74
|
convertedValue = toSpecifiedDenomination[toDenomination](convertedValue);
|
|
75
75
|
}
|
|
76
76
|
if (numberOfDecimals) {
|
|
77
|
-
convertedValue = convertedValue.dp(numberOfDecimals, BigNumber.ROUND_HALF_DOWN);
|
|
77
|
+
convertedValue = convertedValue.dp(numberOfDecimals, bignumber_js.BigNumber.ROUND_HALF_DOWN);
|
|
78
78
|
}
|
|
79
79
|
if (roundDown) {
|
|
80
|
-
convertedValue = convertedValue.dp(roundDown, BigNumber.ROUND_DOWN);
|
|
80
|
+
convertedValue = convertedValue.dp(roundDown, bignumber_js.BigNumber.ROUND_DOWN);
|
|
81
81
|
}
|
|
82
82
|
if (toNumericBase) {
|
|
83
83
|
convertedValue = baseChange[toNumericBase](convertedValue);
|
|
@@ -118,10 +118,10 @@ const getBigNumber = (value, base) => {
|
|
|
118
118
|
|
|
119
119
|
// We don't include 'number' here, because BigNumber will throw if passed
|
|
120
120
|
// a number primitive it considers unsafe.
|
|
121
|
-
if (typeof value === "string" || value instanceof BigNumber) {
|
|
122
|
-
return new BigNumber(value, base);
|
|
121
|
+
if (typeof value === "string" || value instanceof bignumber_js.BigNumber) {
|
|
122
|
+
return new bignumber_js.BigNumber(value, base);
|
|
123
123
|
}
|
|
124
|
-
return new BigNumber(String(value), base);
|
|
124
|
+
return new bignumber_js.BigNumber(String(value), base);
|
|
125
125
|
};
|
|
126
126
|
const addCurrencies = (a, b, options = {}) => {
|
|
127
127
|
const {
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
4
|
var util = require('@ethereumjs/util');
|
|
5
5
|
var baseControllers = require('@toruslabs/base-controllers');
|
|
6
|
-
var
|
|
6
|
+
var bignumber_js = require('bignumber.js');
|
|
7
7
|
var log = require('loglevel');
|
|
8
8
|
var TransactionUtils = require('../Transaction/TransactionUtils.js');
|
|
9
9
|
var constants = require('./constants.js');
|
|
10
10
|
|
|
11
11
|
function hexToBn(hex) {
|
|
12
|
-
return new BigNumber(util.stripHexPrefix(hex), 16);
|
|
12
|
+
return new bignumber_js.BigNumber(util.stripHexPrefix(hex), 16);
|
|
13
13
|
}
|
|
14
14
|
function BNToHex(bn) {
|
|
15
15
|
return util.addHexPrefix(bn.toString(16));
|
|
@@ -112,7 +112,7 @@ function bnLessThan(a, b) {
|
|
|
112
112
|
if (a === null || a === undefined || b === null || b === undefined) {
|
|
113
113
|
return null;
|
|
114
114
|
}
|
|
115
|
-
return new BigNumber(a, 10).lt(b, 10);
|
|
115
|
+
return new bignumber_js.BigNumber(a, 10).lt(b, 10);
|
|
116
116
|
}
|
|
117
117
|
const getIpfsEndpoint = path => `https://infura-ipfs.io/${path}`;
|
|
118
118
|
function sanitizeNftMetdataUrl(url) {
|
|
@@ -155,7 +155,7 @@ const addEtherscanTransactions = async params => {
|
|
|
155
155
|
}));
|
|
156
156
|
const finalTxs = transactionPromises.reduce((accumulator, x) => {
|
|
157
157
|
var _SUPPORTED_NETWORKS$c3, _SUPPORTED_NETWORKS$c4;
|
|
158
|
-
let totalAmountString = x.value ? new BigNumber(x.value).div(new BigNumber(10).pow(new BigNumber(x.tokenDecimal || 18))).toString() : "";
|
|
158
|
+
let totalAmountString = x.value ? new bignumber_js.BigNumber(x.value).div(new bignumber_js.BigNumber(10).pow(new bignumber_js.BigNumber(x.tokenDecimal || 18))).toString() : "";
|
|
159
159
|
let type = constants.CONTRACT_TYPE_ETH;
|
|
160
160
|
if (x.contractAddress !== "") {
|
|
161
161
|
if (x.tokenID) {
|
|
@@ -183,8 +183,8 @@ const addEtherscanTransactions = async params => {
|
|
|
183
183
|
input: x.input,
|
|
184
184
|
contract_address: x.contractAddress,
|
|
185
185
|
transaction_category: x.transaction_category,
|
|
186
|
-
gas: `0x${new BigNumber(x.gasUsed || 0, 10).toString(16)}`,
|
|
187
|
-
gasPrice: `0x${new BigNumber(x.gasPrice || 0, 10).toString(16)}`,
|
|
186
|
+
gas: `0x${new bignumber_js.BigNumber(x.gasUsed || 0, 10).toString(16)}`,
|
|
187
|
+
gasPrice: `0x${new bignumber_js.BigNumber(x.gasPrice || 0, 10).toString(16)}`,
|
|
188
188
|
chain_id: chainId,
|
|
189
189
|
currency_amount: "",
|
|
190
190
|
nonce: x.nonce,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import { get } from '@toruslabs/http-helpers';
|
|
3
|
-
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { BigNumber } from 'bignumber.js';
|
|
4
4
|
import { METHOD_TYPES } from '../utils/constants.js';
|
|
5
5
|
import { hexWEIToDecGWEI, decGWEIToHexWEI } from '../utils/conversionUtils.js';
|
|
6
6
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isValidAddress, stripHexPrefix, addHexPrefix, bytesToHex } from '@ethereumjs/util';
|
|
2
|
+
import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
|
|
2
3
|
import { isHexString, JsonRpcProvider, toQuantity } from 'ethers';
|
|
3
4
|
|
|
4
5
|
const hexRe = /^[0-9A-Fa-f]+$/gu;
|
|
@@ -92,13 +93,19 @@ async function validateAddChainData(data) {
|
|
|
92
93
|
}
|
|
93
94
|
function validateSwitchChainData(data) {
|
|
94
95
|
const {
|
|
95
|
-
chainId
|
|
96
|
+
chainId: fullChainId
|
|
96
97
|
} = data || {};
|
|
97
|
-
if (!
|
|
98
|
+
if (!fullChainId) {
|
|
98
99
|
throw new Error("Invalid switch chain params: please pass chainId in params");
|
|
99
100
|
}
|
|
100
|
-
if (!isHexString(
|
|
101
|
-
|
|
101
|
+
if (!isHexString(fullChainId)) {
|
|
102
|
+
const [namespace, chainId] = fullChainId.split(":");
|
|
103
|
+
if (namespace !== CHAIN_NAMESPACES.SOLANA && namespace !== CHAIN_NAMESPACES.EIP155) {
|
|
104
|
+
throw new Error("Invalid switch chain params: invalid namespace");
|
|
105
|
+
}
|
|
106
|
+
if (!chainId || isNaN(Number(chainId))) {
|
|
107
|
+
throw new Error("Invalid switch chain params: invalid chainId");
|
|
108
|
+
}
|
|
102
109
|
}
|
|
103
110
|
}
|
|
104
111
|
|
|
@@ -223,6 +223,25 @@ function createProcessSwitchEthereumChain({
|
|
|
223
223
|
response.result = await processSwitchEthereumChain(msgParams, request);
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
|
+
function createProcessWalletSwitchChain({
|
|
227
|
+
processWalletSwitchChain
|
|
228
|
+
}) {
|
|
229
|
+
return createAsyncMiddleware(async (request, response, next) => {
|
|
230
|
+
const {
|
|
231
|
+
method
|
|
232
|
+
} = request;
|
|
233
|
+
if (method !== PROVIDER_JRPC_METHODS.WALLET_SWITCH_CHAIN) return next();
|
|
234
|
+
if (!processWalletSwitchChain) throw new Error("WalletMiddleware - opts.processWalletSwitchChain not provided");
|
|
235
|
+
if (!(request !== null && request !== void 0 && request.params)) throw new Error("WalletMiddleware - missing params");
|
|
236
|
+
let msgParams = request.params;
|
|
237
|
+
if (Array.isArray(request.params)) {
|
|
238
|
+
if (!(request.params.length === 1)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [data]`);
|
|
239
|
+
const [message] = request.params;
|
|
240
|
+
msgParams = message;
|
|
241
|
+
}
|
|
242
|
+
response.result = await processWalletSwitchChain(msgParams, request);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
226
245
|
function createProcessAddEthereumChain({
|
|
227
246
|
processAddEthereumChain
|
|
228
247
|
}) {
|
|
@@ -269,6 +288,7 @@ function createEthereumMiddleware(providerHandlers) {
|
|
|
269
288
|
getPendingNonce,
|
|
270
289
|
getPendingTransactionByHash,
|
|
271
290
|
processSwitchEthereumChain,
|
|
291
|
+
processWalletSwitchChain,
|
|
272
292
|
processAddEthereumChain,
|
|
273
293
|
getProviderState,
|
|
274
294
|
version
|
|
@@ -296,9 +316,11 @@ function createEthereumMiddleware(providerHandlers) {
|
|
|
296
316
|
getPendingTransactionByHash
|
|
297
317
|
}), createProcessSwitchEthereumChain({
|
|
298
318
|
processSwitchEthereumChain
|
|
319
|
+
}), createProcessWalletSwitchChain({
|
|
320
|
+
processWalletSwitchChain
|
|
299
321
|
}), createProcessAddEthereumChain({
|
|
300
322
|
processAddEthereumChain
|
|
301
323
|
})]);
|
|
302
324
|
}
|
|
303
325
|
|
|
304
|
-
export { createEthereumMiddleware, createGetAccountsMiddleware, createPendingNonceMiddleware, createPendingTxMiddleware, createProcessAddEthereumChain, createProcessEstimateUserOperationGasMiddleware, createProcessEthSignMessage, createProcessPersonalMessage, createProcessSwitchEthereumChain, createProcessTransactionMiddleware, createProcessTypedMessageV4, createRequestAccountsMiddleware, formatTxMetaForRpcResult };
|
|
326
|
+
export { createEthereumMiddleware, createGetAccountsMiddleware, createPendingNonceMiddleware, createPendingTxMiddleware, createProcessAddEthereumChain, createProcessEstimateUserOperationGasMiddleware, createProcessEthSignMessage, createProcessPersonalMessage, createProcessSwitchEthereumChain, createProcessTransactionMiddleware, createProcessTypedMessageV4, createProcessWalletSwitchChain, createRequestAccountsMiddleware, formatTxMetaForRpcResult };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import { stripHexPrefix } from '@ethereumjs/util';
|
|
3
|
-
import { BasePreferencesController, isUnauthorizedError, TransactionStatus } from '@toruslabs/base-controllers';
|
|
3
|
+
import { BasePreferencesController, CHAIN_NAMESPACES, isUnauthorizedError, TransactionStatus } from '@toruslabs/base-controllers';
|
|
4
4
|
import { Mutex } from 'async-mutex';
|
|
5
5
|
import log from 'loglevel';
|
|
6
6
|
import { ETHERSCAN_SUPPORTED_CHAINS, SUPPORTED_NETWORKS } from '../utils/constants.js';
|
|
@@ -28,6 +28,7 @@ class PreferencesController extends BasePreferencesController {
|
|
|
28
28
|
signAuthMessage,
|
|
29
29
|
validateSignMessage
|
|
30
30
|
});
|
|
31
|
+
_defineProperty(this, "chainNamespace", CHAIN_NAMESPACES.EIP155);
|
|
31
32
|
_defineProperty(this, "_handle", void 0);
|
|
32
33
|
_defineProperty(this, "_mutex", new Mutex());
|
|
33
34
|
_defineProperty(this, "getProviderConfig", void 0);
|
|
@@ -6,7 +6,6 @@ import log from 'loglevel';
|
|
|
6
6
|
import { singleBalanceCheckerAbi } from '../utils/abis.js';
|
|
7
7
|
import { ETHERSCAN_SUPPORTED_CHAINS } from '../utils/constants.js';
|
|
8
8
|
import { SINGLE_CALL_BALANCES_ADDRESSES } from '../utils/contractAddresses.js';
|
|
9
|
-
import { toChecksumAddressByChainId } from '../utils/helpers.js';
|
|
10
9
|
import { TokenHandler } from './TokenHandler.js';
|
|
11
10
|
|
|
12
11
|
function getObjectFromArrayBasedonKey(oldArray, key) {
|
|
@@ -234,7 +233,7 @@ class TokensController extends BaseController {
|
|
|
234
233
|
logo: x.logo || "eth.svg",
|
|
235
234
|
name: tokenInstance.name,
|
|
236
235
|
symbol: tokenInstance.symbol,
|
|
237
|
-
tokenAddress:
|
|
236
|
+
tokenAddress: tokenInstance.address,
|
|
238
237
|
balance: `0x${balance}`,
|
|
239
238
|
customTokenId: x.customTokenId,
|
|
240
239
|
network: x.chainId,
|
|
@@ -3,7 +3,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
3
3
|
import { addHexPrefix, stripHexPrefix } from '@ethereumjs/util';
|
|
4
4
|
import { TRANSACTION_TYPES, TX_EVENTS, TransactionStatus } from '@toruslabs/base-controllers';
|
|
5
5
|
import { providerErrors, rpcErrors } from '@web3auth/auth';
|
|
6
|
-
import BigNumber from 'bignumber.js';
|
|
6
|
+
import { BigNumber } from 'bignumber.js';
|
|
7
7
|
import { Transaction, keccak256 } from 'ethers';
|
|
8
8
|
import log from 'loglevel';
|
|
9
9
|
import { METHOD_TYPES, TRANSACTION_ENVELOPE_TYPES, GAS_ESTIMATE_TYPES, CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP } from '../utils/constants.js';
|
package/dist/lib.esm/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export { PersonalMessageController } from './Message/PersonalMessageController.j
|
|
|
10
10
|
export { SwitchChainController } from './Message/SwitchChainController.js';
|
|
11
11
|
export { TypedMessageController } from './Message/TypedMessageController.js';
|
|
12
12
|
export { normalizeMessageData, validateAddChainData, validateAddress, validateSignMessageData, validateSwitchChainData, validateTypedSignMessageDataV4 } from './Message/utils.js';
|
|
13
|
-
export { createEthereumMiddleware, createGetAccountsMiddleware, createPendingNonceMiddleware, createPendingTxMiddleware, createProcessAddEthereumChain, createProcessEstimateUserOperationGasMiddleware, createProcessEthSignMessage, createProcessPersonalMessage, createProcessSwitchEthereumChain, createProcessTransactionMiddleware, createProcessTypedMessageV4, createRequestAccountsMiddleware, formatTxMetaForRpcResult } from './Network/createEthereumMiddleware.js';
|
|
13
|
+
export { createEthereumMiddleware, createGetAccountsMiddleware, createPendingNonceMiddleware, createPendingTxMiddleware, createProcessAddEthereumChain, createProcessEstimateUserOperationGasMiddleware, createProcessEthSignMessage, createProcessPersonalMessage, createProcessSwitchEthereumChain, createProcessTransactionMiddleware, createProcessTypedMessageV4, createProcessWalletSwitchChain, createRequestAccountsMiddleware, formatTxMetaForRpcResult } from './Network/createEthereumMiddleware.js';
|
|
14
14
|
export { createChainIdMiddleware, createJsonRpcClient, createProviderConfigMiddleware } from './Network/createJsonRpcClient.js';
|
|
15
15
|
export { NetworkController } from './Network/NetworkController.js';
|
|
16
16
|
export { NftHandler } from './Nfts/NftHandler.js';
|
|
@@ -2,7 +2,7 @@ import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructurin
|
|
|
2
2
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
4
|
import { stripHexPrefix } from '@ethereumjs/util';
|
|
5
|
-
import BigNumber from 'bignumber.js';
|
|
5
|
+
import { BigNumber } from 'bignumber.js';
|
|
6
6
|
import BN from 'bn.js';
|
|
7
7
|
|
|
8
8
|
const _excluded = ["aBase", "bBase"],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import { stripHexPrefix, addHexPrefix, isValidAddress, toChecksumAddress } from '@ethereumjs/util';
|
|
3
3
|
import { formatSmallNumbers, addressSlicer, ACTIVITY_ACTION_RECEIVE, ACTIVITY_ACTION_SEND, significantDigits, TransactionStatus } from '@toruslabs/base-controllers';
|
|
4
|
-
import BigNumber from 'bignumber.js';
|
|
4
|
+
import { BigNumber } from 'bignumber.js';
|
|
5
5
|
import log from 'loglevel';
|
|
6
6
|
import { determineTransactionType } from '../Transaction/TransactionUtils.js';
|
|
7
7
|
import { SUPPORTED_NETWORKS, CONTRACT_TYPE_ERC721, CONTRACT_TYPE_ERC1155, CONTRACT_TYPE_ERC20, METHOD_TYPES, MAINNET_CHAIN_ID, TEST_CHAINS, CONTRACT_TYPE_ETH } from './constants.js';
|
|
@@ -2,7 +2,8 @@ import { AccountTrackerConfig, AccountTrackerState, BaseController, IAccountTrac
|
|
|
2
2
|
import { SafeEventEmitterProvider } from "@web3auth/auth";
|
|
3
3
|
import { PollingBlockTracker } from "../Block/PollingBlockTracker";
|
|
4
4
|
import { NetworkController } from "../Network/NetworkController";
|
|
5
|
-
import {
|
|
5
|
+
import { ExtendedAddressPreferences } from "../Preferences/IPreferencesController";
|
|
6
|
+
import { EthereumBlock } from "../utils/interfaces";
|
|
6
7
|
interface AccountTrackerControllerOptions {
|
|
7
8
|
config: AccountTrackerConfig<EthereumBlock>;
|
|
8
9
|
state: Partial<AccountTrackerState>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SafeEventEmitterProvider } from "@web3auth/auth";
|
|
2
|
-
import BigNumber from "bignumber.js";
|
|
2
|
+
import { BigNumber } from "bignumber.js";
|
|
3
3
|
import { EthereumGasFeeEstimates, EthereumLegacyGasFeeEstimates, GasFeeTimeBounds } from "./IGasFeeController";
|
|
4
4
|
export declare function normalizeGWEIDecimalNumbers(n: string | number): number | BigNumber;
|
|
5
5
|
export declare function fetchGasEstimates(url: string): Promise<EthereumGasFeeEstimates>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { AbstractMessageController, BaseConfig, MessageControllerState, UserRequestApprovalParams } from "@toruslabs/base-controllers";
|
|
1
|
+
import { AbstractMessageController, BaseConfig, MessageControllerState, SwitchChainMessage, SwitchChainMessageParams, UserRequestApprovalParams } from "@toruslabs/base-controllers";
|
|
2
2
|
import { JRPCRequest } from "@web3auth/auth";
|
|
3
3
|
import { PreferencesController } from "../Preferences/PreferencesController";
|
|
4
|
-
import { SwitchChainMessage, SwitchChainMessageParams } from "../utils/interfaces";
|
|
5
4
|
export declare class SwitchChainController extends AbstractMessageController<SwitchChainMessage, SwitchChainMessageParams> {
|
|
6
5
|
name: string;
|
|
7
6
|
protected switchChain: PreferencesController["switchChain"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MessageParams } from "@toruslabs/base-controllers";
|
|
2
|
-
import { AddChainMessageParams,
|
|
1
|
+
import { MessageParams, SwitchChainMessageParams } from "@toruslabs/base-controllers";
|
|
2
|
+
import { AddChainMessageParams, TypedMessageParams } from "../utils/interfaces";
|
|
3
3
|
export declare function validateAddress(address: string, propertyName: string): void;
|
|
4
4
|
export declare function validateSignMessageData(messageData: MessageParams): void;
|
|
5
5
|
export declare function normalizeMessageData(data: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InPageWalletProviderState, MessageParams, UserRequestApprovalParams } from "@toruslabs/base-controllers";
|
|
1
|
+
import { InPageWalletProviderState, MessageParams, SwitchChainMessageParams, UserRequestApprovalParams } from "@toruslabs/base-controllers";
|
|
2
2
|
import { JRPCEngineEndCallback, JRPCEngineNextCallback, JRPCMiddleware, JRPCRequest, JRPCResponse } from "@web3auth/auth";
|
|
3
|
-
import { AddChainMessageParams, BlockParams, EthereumTransactionMeta,
|
|
3
|
+
import { AddChainMessageParams, BlockParams, EthereumTransactionMeta, TransactionParams, TransactionRPCMeta, TypedMessageParams, UserOperationGas } from "../utils/interfaces";
|
|
4
4
|
export interface IProviderHandlers {
|
|
5
5
|
version: string;
|
|
6
6
|
requestAccounts?: (req: JRPCRequest<string[]>) => Promise<string[]>;
|
|
@@ -10,6 +10,7 @@ export interface IProviderHandlers {
|
|
|
10
10
|
processTypedMessageV4?: (msgParams: TypedMessageParams, req: JRPCRequest<unknown> & UserRequestApprovalParams) => Promise<string>;
|
|
11
11
|
processPersonalMessage?: (msgParams: MessageParams, req: JRPCRequest<unknown> & UserRequestApprovalParams) => Promise<string>;
|
|
12
12
|
processSwitchEthereumChain?: (msgParams: SwitchChainMessageParams, req: JRPCRequest<unknown> & UserRequestApprovalParams) => Promise<string>;
|
|
13
|
+
processWalletSwitchChain?: (msgParams: SwitchChainMessageParams, req: JRPCRequest<unknown> & UserRequestApprovalParams) => Promise<string>;
|
|
13
14
|
processAddEthereumChain?: (msgParams: AddChainMessageParams, req: JRPCRequest<unknown> & UserRequestApprovalParams) => Promise<string>;
|
|
14
15
|
processEstimateUserOperationGas?: (txParams: TransactionParams, req: JRPCRequest<TransactionParams>) => Promise<UserOperationGas>;
|
|
15
16
|
getPendingNonce?: (nonceParams: {
|
|
@@ -53,6 +54,9 @@ export declare function createPendingTxMiddleware({ getPendingTransactionByHash,
|
|
|
53
54
|
export declare function createProcessSwitchEthereumChain({ processSwitchEthereumChain, }: {
|
|
54
55
|
processSwitchEthereumChain: IProviderHandlers["processSwitchEthereumChain"];
|
|
55
56
|
}): JRPCMiddleware<unknown, string>;
|
|
57
|
+
export declare function createProcessWalletSwitchChain({ processWalletSwitchChain, }: {
|
|
58
|
+
processWalletSwitchChain: IProviderHandlers["processWalletSwitchChain"];
|
|
59
|
+
}): JRPCMiddleware<unknown, string>;
|
|
56
60
|
export declare function createProcessAddEthereumChain({ processAddEthereumChain, }: {
|
|
57
61
|
processAddEthereumChain: IProviderHandlers["processAddEthereumChain"];
|
|
58
62
|
}): JRPCMiddleware<unknown, string>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
selectedAddress: string;
|
|
6
|
-
chainId: string;
|
|
1
|
+
import { CustomNftInfo, NftsControllerConfig, NftsControllerState } from "@toruslabs/base-controllers";
|
|
2
|
+
export type NftStandardType = "erc721" | "erc1155";
|
|
3
|
+
export interface EthereumNftInfo extends CustomNftInfo {
|
|
4
|
+
nftStandard: NftStandardType;
|
|
7
5
|
}
|
|
8
|
-
export interface
|
|
9
|
-
|
|
6
|
+
export interface EthereumNftsControllerConfig extends NftsControllerConfig {
|
|
7
|
+
}
|
|
8
|
+
export interface EthereumNftsControllerState extends NftsControllerState {
|
|
9
|
+
nfts: Record<string, EthereumNftInfo[]>;
|
|
10
10
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { CustomNftItemInfo } from "@toruslabs/base-controllers";
|
|
1
2
|
import { Provider } from "ethers";
|
|
2
|
-
import { CustomNftInfo
|
|
3
|
+
import { EthereumNftInfo as CustomNftInfo } from "../Nfts/INftsController";
|
|
3
4
|
export interface INftOptions {
|
|
4
5
|
contractAddress: string;
|
|
5
6
|
contractName?: string;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { BaseController, INftsController, PreferencesState } from "@toruslabs/base-controllers";
|
|
2
2
|
import { SafeEventEmitterProvider } from "@web3auth/auth";
|
|
3
|
+
import { ExtendedAddressPreferences } from "../Preferences/IPreferencesController";
|
|
3
4
|
import { PreferencesController } from "../Preferences/PreferencesController";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { EthereumNetworkState } from "../utils/interfaces";
|
|
6
|
+
import { EthereumNftInfo as CustomNftInfo, EthereumNftsControllerConfig, EthereumNftsControllerState } from "./INftsController";
|
|
6
7
|
export interface INftsControllerOptions {
|
|
7
|
-
config?: Partial<
|
|
8
|
-
state?: Partial<
|
|
8
|
+
config?: Partial<EthereumNftsControllerConfig>;
|
|
9
|
+
state?: Partial<EthereumNftsControllerState>;
|
|
9
10
|
provider: SafeEventEmitterProvider;
|
|
10
11
|
getCustomNfts?: PreferencesController["getCustomNfts"];
|
|
11
12
|
getSimpleHashNfts: PreferencesController["getSimpleHashNfts"];
|
|
12
13
|
onPreferencesStateChange: (listener: (preferencesState: PreferencesState<ExtendedAddressPreferences>) => void) => void;
|
|
13
14
|
onNetworkStateChange: (listener: (networkState: EthereumNetworkState) => void) => void;
|
|
14
15
|
}
|
|
15
|
-
export declare class NftsController extends BaseController<
|
|
16
|
+
export declare class NftsController extends BaseController<EthereumNftsControllerConfig, EthereumNftsControllerState> implements INftsController<EthereumNftsControllerConfig, EthereumNftsControllerState> {
|
|
16
17
|
name: string;
|
|
17
18
|
private provider;
|
|
18
19
|
private ethersProvider;
|