2020-06-19 06:57:57 +03:00
|
|
|
const STATIC_ADDRESS_TYPE_MAP = {
|
2020-07-16 05:45:23 +03:00
|
|
|
bls: "BLS",
|
|
|
|
secp256k1: "SECP256K1",
|
|
|
|
multisig: "MULTISIG",
|
2020-06-19 06:57:57 +03:00
|
|
|
};
|
2020-06-04 09:26:20 +03:00
|
|
|
|
|
|
|
const transformAddresses = (addrsList, info) => {
|
|
|
|
const balanceMap = {};
|
|
|
|
info.balancesList.forEach((b) => {
|
|
|
|
balanceMap[b.addr.addr] = b.balance;
|
|
|
|
});
|
|
|
|
|
|
|
|
return addrsList.map((each, index) => {
|
|
|
|
return {
|
2020-06-08 09:45:53 +03:00
|
|
|
id: each.addr,
|
|
|
|
value: each.addr,
|
2020-06-04 09:26:20 +03:00
|
|
|
balance: balanceMap[each.addr],
|
|
|
|
name: each.name,
|
|
|
|
address: each.addr,
|
|
|
|
type: STATIC_ADDRESS_TYPE_MAP[each.type],
|
|
|
|
deals: 0,
|
|
|
|
transactions: [],
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-07-27 04:51:51 +03:00
|
|
|
const transformPeers = (peersList = []) => {
|
2020-06-04 09:26:20 +03:00
|
|
|
return peersList.map((each) => {
|
|
|
|
return {
|
|
|
|
id: each.addrInfo.id,
|
2020-07-16 05:45:23 +03:00
|
|
|
"peer-avatar": null,
|
|
|
|
"chain-head": null,
|
2020-06-04 09:26:20 +03:00
|
|
|
height: null,
|
2020-06-08 09:45:53 +03:00
|
|
|
location: null,
|
2020-06-04 09:26:20 +03:00
|
|
|
upload: null,
|
|
|
|
download: null,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-07-16 05:45:23 +03:00
|
|
|
export const getSelectedState = (props) => {
|
2020-07-21 14:36:50 +03:00
|
|
|
if (!props) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-07-22 10:41:29 +03:00
|
|
|
const { info } = props;
|
2020-07-16 05:45:23 +03:00
|
|
|
|
|
|
|
if (!info || !info.id) {
|
|
|
|
return {
|
|
|
|
address: "",
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2020-07-22 07:11:13 +03:00
|
|
|
address: info.defaultStorageConfig.cold.filecoin.addr,
|
2020-07-16 05:45:23 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-06-04 09:26:20 +03:00
|
|
|
export const getInitialState = (props) => {
|
2020-07-21 14:36:50 +03:00
|
|
|
if (!props) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-07-16 05:45:23 +03:00
|
|
|
const {
|
|
|
|
status,
|
2020-08-04 05:45:59 +03:00
|
|
|
stats,
|
2020-07-16 05:45:23 +03:00
|
|
|
messageList,
|
|
|
|
peersList,
|
|
|
|
addrsList,
|
|
|
|
info,
|
|
|
|
library,
|
2020-07-22 10:41:29 +03:00
|
|
|
data,
|
|
|
|
settings,
|
|
|
|
username,
|
2020-07-23 13:05:13 +03:00
|
|
|
storageList,
|
|
|
|
retrievalList,
|
2020-07-27 04:51:51 +03:00
|
|
|
slates,
|
2020-07-28 09:54:15 +03:00
|
|
|
keys,
|
2020-07-16 05:45:23 +03:00
|
|
|
} = props;
|
2020-06-09 21:00:36 +03:00
|
|
|
|
2020-06-04 09:26:20 +03:00
|
|
|
return {
|
|
|
|
id: info.id,
|
2020-07-22 10:41:29 +03:00
|
|
|
username,
|
|
|
|
data: {
|
|
|
|
photo: data.photo,
|
|
|
|
},
|
2020-06-04 09:26:20 +03:00
|
|
|
|
2020-08-04 05:45:59 +03:00
|
|
|
// NOTE(jim): Local settings
|
2020-07-22 10:41:29 +03:00
|
|
|
settings_deals_auto_approve: settings.deals_auto_approve,
|
2020-06-04 09:26:20 +03:00
|
|
|
|
2020-08-04 05:45:59 +03:00
|
|
|
// NOTE(jim): Powergate Hot Settings
|
2020-07-22 07:11:13 +03:00
|
|
|
settings_hot_enabled: info.defaultStorageConfig.hot.enabled,
|
|
|
|
settings_hot_allow_unfreeze: info.defaultStorageConfig.hot.allowUnfreeze,
|
|
|
|
settings_hot_ipfs_add_timeout:
|
|
|
|
info.defaultStorageConfig.hot.ipfs.addTimeout,
|
2020-06-04 09:26:20 +03:00
|
|
|
|
2020-08-04 05:45:59 +03:00
|
|
|
// NOTE(jim): Powergate Cold Settings
|
2020-07-22 07:11:13 +03:00
|
|
|
settings_cold_enabled: info.defaultStorageConfig.cold.enabled,
|
|
|
|
settings_cold_default_address: info.defaultStorageConfig.cold.filecoin.addr,
|
2020-07-16 05:45:23 +03:00
|
|
|
settings_cold_default_duration:
|
2020-07-22 07:11:13 +03:00
|
|
|
info.defaultStorageConfig.cold.filecoin.dealMinDuration,
|
2020-07-16 05:45:23 +03:00
|
|
|
settings_cold_default_replication_factor:
|
2020-07-22 07:11:13 +03:00
|
|
|
info.defaultStorageConfig.cold.filecoin.repFactor,
|
2020-07-16 05:45:23 +03:00
|
|
|
settings_cold_default_excluded_miners:
|
2020-07-22 07:11:13 +03:00
|
|
|
info.defaultStorageConfig.cold.filecoin.excludedMinersList,
|
2020-07-16 05:45:23 +03:00
|
|
|
settings_cold_default_trusted_miners:
|
2020-07-22 07:11:13 +03:00
|
|
|
info.defaultStorageConfig.cold.filecoin.trustedMinersList,
|
|
|
|
settings_cold_default_max_price:
|
|
|
|
info.defaultStorageConfig.cold.filecoin.maxPrice,
|
2020-07-16 05:45:23 +03:00
|
|
|
settings_cold_default_auto_renew:
|
2020-07-22 07:11:13 +03:00
|
|
|
info.defaultStorageConfig.cold.filecoin.renew.enabled,
|
2020-07-16 05:45:23 +03:00
|
|
|
settings_cold_default_auto_renew_max_price:
|
2020-07-22 07:11:13 +03:00
|
|
|
info.defaultStorageConfig.cold.filecoin.renew.threshold,
|
2020-06-04 09:26:20 +03:00
|
|
|
|
2020-07-23 13:05:13 +03:00
|
|
|
storageList,
|
|
|
|
retrievalList,
|
2020-07-27 04:51:51 +03:00
|
|
|
slates,
|
2020-07-28 09:54:15 +03:00
|
|
|
keys,
|
2020-08-04 05:45:59 +03:00
|
|
|
stats,
|
|
|
|
library,
|
2020-06-04 09:26:20 +03:00
|
|
|
peers: transformPeers(peersList),
|
|
|
|
addresses: transformAddresses(addrsList, info),
|
|
|
|
};
|
|
|
|
};
|