0.2.0 powergate: prework, updates settings, decorates issue

This commit is contained in:
@wwwjim 2020-07-21 21:11:13 -07:00
parent 392dc7c1ee
commit cfb7f1a54d
8 changed files with 57 additions and 62 deletions

View File

@ -8,20 +8,6 @@ const REQUEST_HEADERS = {
"Content-Type": "application/json",
};
export const setDefaultConfig = async (data) => {
const options = {
method: "POST",
headers: REQUEST_HEADERS,
credentials: "include",
body: JSON.stringify(data),
};
const response = await fetch(`/_/settings`, options);
const json = await response.json();
return json;
};
export const createWalletAddress = async (data) => {
if (Strings.isEmpty(data.name)) {
return null;
@ -68,6 +54,19 @@ export const sendWalletAddressFilecoin = async (data) => {
// NOTE(jim):
// New WWW Requests.
export const updateViewer = async (data) => {
const options = {
method: "POST",
headers: REQUEST_HEADERS,
credentials: "include",
body: JSON.stringify(data),
};
const response = await fetch(`/api/users/update`, options);
const json = await response.json();
return json;
};
export const signIn = async (data) => {
const options = {

View File

@ -294,36 +294,3 @@ export const SELECT_COUNTRY_OPTIONS = [
{ value: "Zimbabwe", name: "Zimbabwe" },
{ value: "Åland Islands", name: "Åland Islands" },
];
//POWERGATE FIXTURES
// const FFS = await PowerGate.ffs.create();
// output:
// "id":"d094238b-97ac-436b-9060-986dae80d295",
// "token":"fd9159b0-1ec7-46f1-8999-c9208a7e9cd7"
// const { cid } = await PowerGate.ffs.addToHot(buffer);
// output:
// "id":
// "token":
// const { jobId } = await PowerGate.ffs.pushConfig(cid);
// output:
// "id":
// "token":
// const data = await PowerGate.ffs.setDefaultConfig(req.body.config);
// output:
// "id":
// "token":
// const data = await PowerGate.ffs.newAddr();
// output:
// "id":
// "token":
// const data = await PowerGate.ffs.sendFil();
// output:
// "id":
// "token":

View File

@ -60,7 +60,7 @@ export const getSelectedState = (props) => {
}
return {
address: info.defaultConfig.cold.filecoin.addr,
address: info.defaultStorageConfig.cold.filecoin.addr,
};
};
@ -102,25 +102,27 @@ export const getInitialState = (props) => {
settings_deals_auto_approve: local.settings_deals_auto_approve,
settings_hot_enabled: info.defaultConfig.hot.enabled,
settings_hot_allow_unfreeze: info.defaultConfig.hot.allowUnfreeze,
settings_hot_ipfs_add_timeout: info.defaultConfig.hot.ipfs.addTimeout,
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,
settings_cold_enabled: info.defaultConfig.cold.enabled,
settings_cold_default_address: info.defaultConfig.cold.filecoin.addr,
settings_cold_enabled: info.defaultStorageConfig.cold.enabled,
settings_cold_default_address: info.defaultStorageConfig.cold.filecoin.addr,
settings_cold_default_duration:
info.defaultConfig.cold.filecoin.dealMinDuration,
info.defaultStorageConfig.cold.filecoin.dealMinDuration,
settings_cold_default_replication_factor:
info.defaultConfig.cold.filecoin.repFactor,
info.defaultStorageConfig.cold.filecoin.repFactor,
settings_cold_default_excluded_miners:
info.defaultConfig.cold.filecoin.excludedMinersList,
info.defaultStorageConfig.cold.filecoin.excludedMinersList,
settings_cold_default_trusted_miners:
info.defaultConfig.cold.filecoin.trustedMinersList,
settings_cold_default_max_price: info.defaultConfig.cold.filecoin.maxPrice,
info.defaultStorageConfig.cold.filecoin.trustedMinersList,
settings_cold_default_max_price:
info.defaultStorageConfig.cold.filecoin.maxPrice,
settings_cold_default_auto_renew:
info.defaultConfig.cold.filecoin.renew.enabled,
info.defaultStorageConfig.cold.filecoin.renew.enabled,
settings_cold_default_auto_renew_max_price:
info.defaultConfig.cold.filecoin.renew.threshold,
info.defaultStorageConfig.cold.filecoin.renew.threshold,
notifications: [],
payment_channels_active: [],

View File

@ -57,6 +57,10 @@ export const refresh = async ({ PG }) => {
const Peers = await PG.net.peers();
const peersList = Peers.peersList ? Peers.peersList : null;
console.log({ status });
console.log({ messageList });
console.log({ peersList });
return { peersList, messageList, status };
};
@ -68,6 +72,9 @@ export const refreshWithToken = async ({ PG }) => {
const NetworkInfo = await PG.ffs.info();
const info = NetworkInfo.info ? NetworkInfo.info : null;
console.log({ addrsList });
console.log({ info });
return { addrsList, info };
};

View File

@ -40,7 +40,7 @@
"@emotion/react": "11.0.0-next.12",
"@emotion/server": "11.0.0-next.12",
"@textile/hub": "^0.4.1",
"@textile/powergate-client": "0.1.0",
"@textile/powergate-client": "0.2.0",
"@textile/threads-core": "^0.1.33",
"babel-plugin-module-resolver": "^4.0.0",
"bcrypt": "^5.0.0",

View File

@ -6,6 +6,7 @@ import { Buckets } from "@textile/hub";
import { Libp2pCryptoIdentity } from "@textile/threads-core";
const initCORS = MW.init(MW.CORS);
const initAuth = MW.init(MW.RequireCookieAuthentication);
const TEXTILE_KEY_INFO = {
key: Environment.TEXTILE_HUB_KEY,
@ -14,6 +15,7 @@ const TEXTILE_KEY_INFO = {
export default async (req, res) => {
initCORS(req, res);
initAuth(req, res);
const user = await Data.getUserByUsername({
username: req.body.data.username,

View File

@ -1,11 +1,28 @@
import * as MW from "~/node_common/middleware";
import DB from "~/node_common/database";
import PG from "~/node_common/powergate";
const initCORS = MW.init(MW.CORS);
const initAuth = MW.init(MW.RequireCookieAuthentication);
export default async (req, res) => {
initCORS(req, res);
initAuth(req, res);
// TODO(jim): POWERGATE_ISSUE
// Should work when our hosted Powergate works.
if (req.body.type === "SET_DEFAULT_STORAGE_CONFIG") {
let data;
try {
data = await PG.ffs.setDefaultStorageConfig(req.body.config);
} catch (e) {
console.log(e);
return res
.status(500)
.send({ decorator: "SERVER_USER_UPDATE_SETTINGS_CONFIG", error: true });
}
}
return res.status(200).json({ decorator: "SERVER_USER_UPDATE" });
};

View File

@ -42,7 +42,8 @@ export default class SceneSettings extends React.Component {
_deferredSave = null;
_handleSave = async () => {
await Actions.setDefaultConfig({
await Actions.updateViewer({
type: "SET_DEFAULT_STORAGE_CONFIG",
config: {
hot: {
enabled: this.state.settings_cold_enabled,