mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-05 22:10:10 +00:00
Fix robot recovery (#945)
* Fix Robot recovery * Change testralia onion
This commit is contained in:
parent
b973afe13e
commit
8d8e3a5688
@ -9,7 +9,7 @@ interface RecoveryProps {
|
|||||||
inputToken: string;
|
inputToken: string;
|
||||||
badToken: string;
|
badToken: string;
|
||||||
setInputToken: (state: string) => void;
|
setInputToken: (state: string) => void;
|
||||||
getGenerateRobot: (token: string) => void;
|
getRecoverRobot: (token: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Recovery = ({
|
const Recovery = ({
|
||||||
@ -17,12 +17,12 @@ const Recovery = ({
|
|||||||
badToken,
|
badToken,
|
||||||
setView,
|
setView,
|
||||||
setInputToken,
|
setInputToken,
|
||||||
getGenerateRobot,
|
getRecoverRobot,
|
||||||
}: RecoveryProps): JSX.Element => {
|
}: RecoveryProps): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const onClickRecover = (): void => {
|
const onClickRecover = (): void => {
|
||||||
getGenerateRobot(inputToken);
|
getRecoverRobot(inputToken);
|
||||||
setView('profile');
|
setView('profile');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ const RobotProfile = ({
|
|||||||
if (garage.getRobot().nickname != null && garage.getRobot().avatarLoaded) {
|
if (garage.getRobot().nickname != null && garage.getRobot().avatarLoaded) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [robotUpdatedAt]);
|
}, [robotUpdatedAt, loading]);
|
||||||
|
|
||||||
const handleAddRobot = (): void => {
|
const handleAddRobot = (): void => {
|
||||||
getGenerateRobot(genBase62Token(36));
|
getGenerateRobot(genBase62Token(36));
|
||||||
|
@ -48,10 +48,8 @@ const RobotPage = ({ avatarBaseUrl }: RobotPageProps): JSX.Element => {
|
|||||||
const token = urlToken ?? garage.getRobot().token;
|
const token = urlToken ?? garage.getRobot().token;
|
||||||
if (token !== undefined) {
|
if (token !== undefined) {
|
||||||
setInputToken(token);
|
setInputToken(token);
|
||||||
}
|
|
||||||
if (garage.getRobot().nickname !== undefined && token !== undefined) {
|
|
||||||
if (window.NativeRobosats === undefined || torStatus === '"Done"') {
|
if (window.NativeRobosats === undefined || torStatus === '"Done"') {
|
||||||
getGenerateRobot(token);
|
getRecoverRobot(token);
|
||||||
setView('profile');
|
setView('profile');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,16 +65,32 @@ const RobotPage = ({ avatarBaseUrl }: RobotPageProps): JSX.Element => {
|
|||||||
}
|
}
|
||||||
}, [inputToken]);
|
}, [inputToken]);
|
||||||
|
|
||||||
const getGenerateRobot = (token: string): void => {
|
const getRecoverRobot = (token: string): void => {
|
||||||
setInputToken(token);
|
setInputToken(token);
|
||||||
genKey(token)
|
genKey(token)
|
||||||
.then((key) => {
|
.then((key) => {
|
||||||
const slot = garage.createRobot({
|
garage.updateRobot({
|
||||||
token,
|
token,
|
||||||
pubKey: key.publicKeyArmored,
|
pubKey: key.publicKeyArmored,
|
||||||
encPrivKey: key.encryptedPrivateKeyArmored,
|
encPrivKey: key.encryptedPrivateKeyArmored,
|
||||||
});
|
});
|
||||||
void federation.fetchRobot(garage, slot);
|
void federation.fetchRobot(garage, garage.currentSlot);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const getGenerateRobot = (token: string): void => {
|
||||||
|
setInputToken(token);
|
||||||
|
genKey(token)
|
||||||
|
.then((key) => {
|
||||||
|
garage.createRobot({
|
||||||
|
token,
|
||||||
|
pubKey: key.publicKeyArmored,
|
||||||
|
encPrivKey: key.encryptedPrivateKeyArmored,
|
||||||
|
});
|
||||||
|
void federation.fetchRobot(garage, garage.currentSlot);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
@ -180,7 +194,7 @@ const RobotPage = ({ avatarBaseUrl }: RobotPageProps): JSX.Element => {
|
|||||||
badToken={badToken}
|
badToken={badToken}
|
||||||
inputToken={inputToken}
|
inputToken={inputToken}
|
||||||
setInputToken={setInputToken}
|
setInputToken={setInputToken}
|
||||||
getGenerateRobot={getGenerateRobot}
|
getRecoverRobot={getRecoverRobot}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</Paper>
|
</Paper>
|
||||||
|
@ -297,16 +297,21 @@ export class Coordinator {
|
|||||||
console.log(e);
|
console.log(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
garage.updateRobot(
|
if (
|
||||||
{
|
newAttributes?.activeOrderId !== null ||
|
||||||
...newAttributes,
|
(garage.getRobot(index).activeOrderId === null && newAttributes?.lastOrderId !== null)
|
||||||
tokenSHA256: authHeaders.tokenSHA256,
|
) {
|
||||||
loading: false,
|
garage.updateRobot(
|
||||||
bitsEntropy,
|
{
|
||||||
shannonEntropy,
|
...newAttributes,
|
||||||
},
|
tokenSHA256: authHeaders.tokenSHA256,
|
||||||
index,
|
loading: false,
|
||||||
);
|
bitsEntropy,
|
||||||
|
shannonEntropy,
|
||||||
|
},
|
||||||
|
index,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return garage.getRobot(index);
|
return garage.getRobot(index);
|
||||||
};
|
};
|
||||||
|
@ -102,11 +102,12 @@ export class Federation {
|
|||||||
const coordinator = this.coordinators[currentOrder.shortAlias];
|
const coordinator = this.coordinators[currentOrder.shortAlias];
|
||||||
if (coordinator != null && currentOrder.id !== null) {
|
if (coordinator != null && currentOrder.id !== null) {
|
||||||
const newOrder = await coordinator.fetchOrder(currentOrder.id, robot);
|
const newOrder = await coordinator.fetchOrder(currentOrder.id, robot);
|
||||||
|
if (newOrder) {
|
||||||
return {
|
return {
|
||||||
...currentOrder,
|
...currentOrder,
|
||||||
order: newOrder,
|
order: newOrder,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return currentOrder;
|
return currentOrder;
|
||||||
|
@ -17,10 +17,9 @@ class Garage {
|
|||||||
this.slots = rawSlots
|
this.slots = rawSlots
|
||||||
.filter((raw: any) => raw !== null)
|
.filter((raw: any) => raw !== null)
|
||||||
.map((raw: any) => {
|
.map((raw: any) => {
|
||||||
const newSlot: Slot = { robot: new Robot(), order: null };
|
const robot = new Robot(raw.robot);
|
||||||
newSlot.order = raw.order as Order;
|
robot.update(raw.robot);
|
||||||
newSlot.robot.update(raw.robot);
|
return { robot, order: raw.order as Order };
|
||||||
return newSlot;
|
|
||||||
});
|
});
|
||||||
console.log('Robot Garage was loaded from local storage');
|
console.log('Robot Garage was loaded from local storage');
|
||||||
}
|
}
|
||||||
@ -29,7 +28,8 @@ class Garage {
|
|||||||
this.slots = [{ robot: new Robot(), order: null }];
|
this.slots = [{ robot: new Robot(), order: null }];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentSlot = this.slots.length - 1;
|
this.currentSlot = 0;
|
||||||
|
|
||||||
this.hooks = {
|
this.hooks = {
|
||||||
onRobotUpdate: [],
|
onRobotUpdate: [],
|
||||||
onOrderUpdate: [],
|
onOrderUpdate: [],
|
||||||
@ -73,7 +73,7 @@ class Garage {
|
|||||||
deleteSlot: (index?: number) => void = (index) => {
|
deleteSlot: (index?: number) => void = (index) => {
|
||||||
const targetSlot = index ?? this.slots.length - 1;
|
const targetSlot = index ?? this.slots.length - 1;
|
||||||
this.slots.splice(targetSlot, 1);
|
this.slots.splice(targetSlot, 1);
|
||||||
this.currentSlot = this.slots.length - 1;
|
this.currentSlot = 0;
|
||||||
this.triggerHook('onRobotUpdate');
|
this.triggerHook('onRobotUpdate');
|
||||||
this.triggerHook('onOrderUpdate');
|
this.triggerHook('onOrderUpdate');
|
||||||
this.save();
|
this.save();
|
||||||
@ -104,12 +104,12 @@ class Garage {
|
|||||||
return this.getSlot(slot).robot;
|
return this.getSlot(slot).robot;
|
||||||
};
|
};
|
||||||
|
|
||||||
createRobot = (attributes: Record<any, any>): number => {
|
createRobot = (attributes: Record<any, any>): void => {
|
||||||
const newSlot = { robot: new Robot(), order: null };
|
const newSlot = { robot: new Robot(), order: null };
|
||||||
newSlot.robot.update(attributes);
|
newSlot.robot.update(attributes);
|
||||||
this.slots.push(newSlot);
|
this.slots.push(newSlot);
|
||||||
|
this.currentSlot = this.slots.length - 1;
|
||||||
return this.slots.length - 1;
|
this.save();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Orders
|
// Orders
|
||||||
|
@ -119,7 +119,7 @@
|
|||||||
"i2p": ""
|
"i2p": ""
|
||||||
},
|
},
|
||||||
"testnet": {
|
"testnet": {
|
||||||
"onion": "https://qu6xztmzhlve6nxbb77jldek53pvhkaltz6seni7wq6g6yyj233qp4yd.onion",
|
"onion": "https://testraliar7xkhos2gipv2k65obykofb4jqzl5l4danfryacifi4t7qd.onion",
|
||||||
"clearnet": "https://test.unsafe.satstralia.com",
|
"clearnet": "https://test.unsafe.satstralia.com",
|
||||||
"i2p": ""
|
"i2p": ""
|
||||||
},
|
},
|
||||||
@ -134,14 +134,14 @@
|
|||||||
"color": "#000000",
|
"color": "#000000",
|
||||||
"testnet": {
|
"testnet": {
|
||||||
"onion": "http://none.onion",
|
"onion": "http://none.onion",
|
||||||
"clearnet": "http://127.0.0.1:12596"
|
"clearnet": "http://localhost:12596"
|
||||||
},
|
},
|
||||||
"badges": {
|
"badges": {
|
||||||
"donatesToDevFund": 0
|
"donatesToDevFund": 0
|
||||||
},
|
},
|
||||||
"mainnet": {
|
"mainnet": {
|
||||||
"onion": "http://none.onion",
|
"onion": "http://none.onion",
|
||||||
"clearnet": "http://127.0.0.1:12596"
|
"clearnet": "http://localhost:12596"
|
||||||
},
|
},
|
||||||
"policies": {
|
"policies": {
|
||||||
"Development Policy": "Don't look around, just buidl"
|
"Development Policy": "Don't look around, just buidl"
|
||||||
|
@ -39,7 +39,7 @@ testnet_temple_socat="socat tcp4-LISTEN:${testnet_temple_port},reuseaddr,fork,ke
|
|||||||
mainnet_satstralia_onion=satstraoq35jffvkgpfoqld32nzw2siuvowanruindbfojowpwsjdgad.onion
|
mainnet_satstralia_onion=satstraoq35jffvkgpfoqld32nzw2siuvowanruindbfojowpwsjdgad.onion
|
||||||
mainnet_satstralia_port=103
|
mainnet_satstralia_port=103
|
||||||
# Testnet
|
# Testnet
|
||||||
testnet_satstralia_onion=qu6xztmzhlve6nxbb77jldek53pvhkaltz6seni7wq6g6yyj233qp4yd.onion
|
testnet_satstralia_onion=testraliar7xkhos2gipv2k65obykofb4jqzl5l4danfryacifi4t7qd.onion
|
||||||
testnet_satstralia_port=1003
|
testnet_satstralia_port=1003
|
||||||
# socat cmd
|
# socat cmd
|
||||||
mainnet_satstralia_socat="socat tcp4-LISTEN:${mainnet_satstralia_port},reuseaddr,fork,keepalive,bind=127.0.0.1 SOCKS4A:${TOR_PROXY_IP:-127.0.0.1}:${mainnet_satstralia_onion}:80,socksport=${TOR_PROXY_PORT:-9050}"
|
mainnet_satstralia_socat="socat tcp4-LISTEN:${mainnet_satstralia_port},reuseaddr,fork,keepalive,bind=127.0.0.1 SOCKS4A:${TOR_PROXY_IP:-127.0.0.1}:${mainnet_satstralia_onion}:80,socksport=${TOR_PROXY_PORT:-9050}"
|
||||||
|
Loading…
Reference in New Issue
Block a user