@toruslabs/ethereum-controllers 4.10.0 → 4.11.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 +14 -41
- package/dist/ethereumControllers.cjs.js.map +1 -1
- package/dist/ethereumControllers.esm.js +14 -42
- package/dist/ethereumControllers.esm.js.map +1 -1
- package/dist/ethereumControllers.umd.min.js +1 -1
- package/dist/ethereumControllers.umd.min.js.map +1 -1
- package/dist/types/Preferences/PreferencesController.d.ts +2 -1
- package/package.json +7 -6
- package/src/Preferences/PreferencesController.ts +20 -48
|
@@ -4016,6 +4016,7 @@ class NftsController extends base_controllers_namespaceObject.BaseController {
|
|
|
4016
4016
|
|
|
4017
4017
|
|
|
4018
4018
|
|
|
4019
|
+
|
|
4019
4020
|
class PreferencesController extends base_controllers_namespaceObject.BasePreferencesController {
|
|
4020
4021
|
constructor(_ref) {
|
|
4021
4022
|
let {
|
|
@@ -4077,7 +4078,8 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4077
4078
|
locale = "en-US",
|
|
4078
4079
|
type,
|
|
4079
4080
|
signatures,
|
|
4080
|
-
network
|
|
4081
|
+
network,
|
|
4082
|
+
web3AuthClientId
|
|
4081
4083
|
} = params;
|
|
4082
4084
|
await super.init(address, userInfo, jwtToken, {
|
|
4083
4085
|
type,
|
|
@@ -4109,7 +4111,8 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4109
4111
|
calledFromEmbed,
|
|
4110
4112
|
rehydrate
|
|
4111
4113
|
},
|
|
4112
|
-
address
|
|
4114
|
+
address,
|
|
4115
|
+
web3AuthClientId
|
|
4113
4116
|
});
|
|
4114
4117
|
}
|
|
4115
4118
|
getSelectedAddress() {
|
|
@@ -4151,13 +4154,8 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4151
4154
|
} finally {
|
|
4152
4155
|
Promise.all([this.getWalletOrders(address).catch(error => {
|
|
4153
4156
|
external_loglevel_default().error("unable to fetch wallet orders", error);
|
|
4154
|
-
}), this.getTopUpOrders(address).catch(error => {
|
|
4155
|
-
external_loglevel_default().error("unable to fetch top up orders", error);
|
|
4156
4157
|
})]).then(data => {
|
|
4157
|
-
const [walletTx
|
|
4158
|
-
if (paymentTx) {
|
|
4159
|
-
this.calculatePaymentTx(paymentTx, address);
|
|
4160
|
-
}
|
|
4158
|
+
const [walletTx] = data;
|
|
4161
4159
|
// eslint-disable-next-line promise/always-return
|
|
4162
4160
|
if (walletTx && walletTx.length > 0) {
|
|
4163
4161
|
this.updateState({
|
|
@@ -4252,6 +4250,11 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4252
4250
|
var _this$getAddressState6, _this$getAddressState7;
|
|
4253
4251
|
return (_this$getAddressState6 = (_this$getAddressState7 = this.getAddressState(address)) === null || _this$getAddressState7 === void 0 ? void 0 : _this$getAddressState7.customNfts) !== null && _this$getAddressState6 !== void 0 ? _this$getAddressState6 : [];
|
|
4254
4252
|
}
|
|
4253
|
+
isChainIdSupported(address, chainId) {
|
|
4254
|
+
const approveChainOptions = this.getChainOptions(address);
|
|
4255
|
+
const providerConfig = approveChainOptions.find(x => (0,util_namespaceObject.stripHexPrefix)(x.chainId) === chainId);
|
|
4256
|
+
return !!providerConfig;
|
|
4257
|
+
}
|
|
4255
4258
|
async addChain(network) {
|
|
4256
4259
|
const approveChainOptions = this.getChainOptions();
|
|
4257
4260
|
const providerConfig = approveChainOptions.find(x => x.chainId === network.chainId);
|
|
@@ -4357,43 +4360,13 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4357
4360
|
return false;
|
|
4358
4361
|
}
|
|
4359
4362
|
}
|
|
4360
|
-
calculatePaymentTx(txs, address) {
|
|
4361
|
-
const accumulator = [];
|
|
4362
|
-
for (const x of txs) {
|
|
4363
|
-
let action = "";
|
|
4364
|
-
const lowerCaseAction = x.action.toLowerCase();
|
|
4365
|
-
if (base_controllers_namespaceObject.ACTIVITY_ACTION_TOPUP.includes(lowerCaseAction)) action = base_controllers_namespaceObject.ACTIVITY_ACTION_TOPUP;else if (base_controllers_namespaceObject.ACTIVITY_ACTION_SEND.includes(lowerCaseAction)) action = base_controllers_namespaceObject.ACTIVITY_ACTION_SEND;else if (base_controllers_namespaceObject.ACTIVITY_ACTION_RECEIVE.includes(lowerCaseAction)) action = base_controllers_namespaceObject.ACTIVITY_ACTION_RECEIVE;
|
|
4366
|
-
accumulator.push({
|
|
4367
|
-
id: x.id,
|
|
4368
|
-
date: new Date(x.date).toDateString(),
|
|
4369
|
-
from: x.from,
|
|
4370
|
-
slicedFrom: x.slicedFrom,
|
|
4371
|
-
action,
|
|
4372
|
-
to: x.to,
|
|
4373
|
-
slicedTo: x.slicedTo,
|
|
4374
|
-
totalAmount: x.totalAmount,
|
|
4375
|
-
totalAmountString: x.totalAmountString,
|
|
4376
|
-
currencyAmount: x.currencyAmount,
|
|
4377
|
-
currencyAmountString: x.currencyAmountString,
|
|
4378
|
-
amount: x.amount,
|
|
4379
|
-
ethRate: x.ethRate,
|
|
4380
|
-
status: x.status.toLowerCase(),
|
|
4381
|
-
etherscanLink: x.etherscanLink || "",
|
|
4382
|
-
blockExplorerLink: "",
|
|
4383
|
-
currencyUsed: x.currencyUsed
|
|
4384
|
-
});
|
|
4385
|
-
}
|
|
4386
|
-
this.updateState({
|
|
4387
|
-
paymentTx: accumulator
|
|
4388
|
-
}, address);
|
|
4389
|
-
}
|
|
4390
4363
|
getChainOptions() {
|
|
4391
|
-
var _identities$
|
|
4364
|
+
var _identities$address$c, _identities$address;
|
|
4365
|
+
let address = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state.selectedAddress;
|
|
4392
4366
|
const {
|
|
4393
|
-
selectedAddress,
|
|
4394
4367
|
identities
|
|
4395
4368
|
} = this.state;
|
|
4396
|
-
const customNetworks = (_identities$
|
|
4369
|
+
const customNetworks = (_identities$address$c = (_identities$address = identities[address]) === null || _identities$address === void 0 ? void 0 : _identities$address.customNetworks) !== null && _identities$address$c !== void 0 ? _identities$address$c : [];
|
|
4397
4370
|
const custom = Object.values(customNetworks).reduce((chains, network) => {
|
|
4398
4371
|
const networkItem = {
|
|
4399
4372
|
blockExplorerUrl: network.block_explorer_url,
|