{this.props.data.is_maker ? t("Your maker bond was unlocked") : t("Your taker bond was unlocked")}
);
}
showEscrowQRInvoice=()=>{
const { t } = this.props;
return (
{/* Make confirmation sound for HTLC received. */}
{t("Lock {{amountSats}} Sats as collateral", {amountSats:pn(this.props.data.escrow_satoshis)})}
{" " + this.stepXofY()}
{this.showBondIsLocked()}
);
}
showTakerFound=()=>{
const { t } = this.props;
return (
{/* Make bell sound when taker is found */}
{t("A taker has been found!")} {" " + this.stepXofY()}
{t("Please wait for the taker to lock a bond. If the taker does not lock a bond in time, the order will be made public again.")}
{this.showBondIsLocked()}
);
}
handleClickOpenTelegramDialog = () => {
this.setState({openEnableTelegram: true});
};
handleClickCloseEnableTelegramDialog = () => {
this.setState({openEnableTelegram: false});
};
handleClickEnableTelegram = () =>{
window.open("https://t.me/"+this.props.data.tg_bot_name+'?start='+this.props.data.tg_token, '_blank').focus()
this.handleClickCloseEnableTelegramDialog();
};
EnableTelegramDialog =() =>{
const { t } = this.props;
return(
)
}
showMakerWait=()=>{
const { t } = this.props;
return (
{/* Make confirmation sound for HTLC received. */}
{t("Your order is public")} {" " + this.stepXofY()}
{t("Be patient while robots check the book. This box will ring 🔊 once a robot takes your order, then you will have {{invoice_escrow_duration}} hours to reply. If you do not reply, you risk losing your bond.", {invoice_escrow_duration: pn(this.invoice_escrow_duration)})}
{t("If the order expires untaken, your bond will return to you (no action needed).")}
{this.props.data.tg_enabled ?
{t("Telegram enabled")}
:
}
{this.showBondIsLocked()}
)
}
handleInputInvoiceChanged=(e)=>{
this.setState({
invoice: e.target.value,
badInvoice: false,
});
}
handleClickSubmitInvoiceButton=()=>{
this.setState({badInvoice:false});
const requestOptions = {
method: 'POST',
headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken'),},
body: JSON.stringify({
'action':'update_invoice',
'invoice': this.state.invoice,
}),
};
fetch('/api/order/' + '?order_id=' + this.props.data.id, requestOptions)
.then((response) => response.json())
.then((data) => this.setState({badInvoice:data.bad_invoice})
& this.props.completeSetState(data));
}
handleInputDisputeChanged=(e)=>{
this.setState({
statement: e.target.value,
badStatement: false,
});
}
handleClickSubmitStatementButton=()=>{
this.setState({badInvoice:false});
const requestOptions = {
method: 'POST',
headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken'),},
body: JSON.stringify({
'action':'submit_statement',
'statement': this.state.statement,
}),
};
fetch('/api/order/' + '?order_id=' + this.props.data.id, requestOptions)
.then((response) => response.json())
.then((data) => this.setState({badStatement:data.bad_statement})
& this.props.completeSetState(data));
}
handleScan = data => {
if (data) {
this.setState({
invoice: data
})
}
}
handleError = err => {
console.error(err)
}
handleQRbutton = () => {
this.setState({qrscanner: !this.state.qrscanner});
}
showInputInvoice(){
const { t } = this.props;
return (
{/* Make confirmation sound for HTLC received. */}
{t("Submit an invoice for {{amountSats}} Sats",{amountSats: pn(this.props.data.invoice_amount)})}
{" " + this.stepXofY()}
{t("The taker is committed! Before letting you send {{amountFiat}} {{currencyCode}}, we want to make sure you are able to receive the BTC. Please provide a valid invoice for {{amountSats}} Satoshis.",
{amountFiat: parseFloat(parseFloat(this.props.data.amount).toFixed(4)),
currencyCode: this.props.data.currencyCode,
amountSats: pn(this.props.data.invoice_amount)}
)
}
{this.state.qrscanner ?
: null }
{this.showBondIsLocked()}
)
}
// Asks the user for a dispute statement.
showInDisputeStatement=()=>{
const { t } = this.props;
if(this.props.data.statement_submitted){
return (
{t("We have received your statement")}
{t("We are waiting for your trade counterpart statement. If you are hesitant about the state of the dispute or want to add more information, contact robosats@protonmail.com.")}
{t("Please, save the information needed to identify your order and your payments: order ID; payment hashes of the bonds or escrow (check on your lightning wallet); exact amount of satoshis; and robot nickname. You will have to identify yourself as the user involved in this trade via email (or other contact methods).")}
{this.showBondIsSettled()}
)
}else{
return (
// TODO Option to upload files
{t("A dispute has been opened")}
{t("Please, submit your statement. Be clear and specific about what happened and provide the necessary evidence. You MUST provide a contact method: burner email, XMPP or telegram username to follow up with the staff. Disputes are solved at the discretion of real robots (aka humans), so be as helpful as possible to ensure a fair outcome. Max 5000 chars.")}
{this.showBondIsSettled()}
)}
}
showWaitForDisputeResolution=()=>{
const { t } = this.props;
return (
{t("We have the statements")}
{t("Both statements have been received, wait for the staff to resolve the dispute. If you are hesitant about the state of the dispute or want to add more information, contact robosats@protonmail.com. If you did not provide a contact method, or are unsure whether you wrote it right, write us immediately.")}
{t("Please, save the information needed to identify your order and your payments: order ID; payment hashes of the bonds or escrow (check on your lightning wallet); exact amount of satoshis; and robot nickname. You will have to identify yourself as the user involved in this trade via email (or other contact methods).")}
{this.showBondIsSettled()}
)
}
showDisputeWinner=()=>{
const { t } = this.props;
return (
{t("You have won the dispute")}
{t("You can claim the dispute resolution amount (escrow and fidelity bond) from your profile rewards. If there is anything the staff can help with, do not hesitate to contact to robosats@protonmail.com (or via your provided burner contact method).")}
{this.showBondIsSettled()}
)
}
showDisputeLoser=()=>{
const { t } = this.props;
return (
{t("You have lost the dispute")}
{t("Unfortunately you have lost the dispute. If you think this is a mistake you can ask to re-open the case via email to robosats@protonmail.com. However, chances of it being investigated again are low.")}
{this.showBondIsSettled()}
)
}
showWaitingForEscrow(){
const { t } = this.props;
return(
{t("Your invoice looks good!")} {" " + this.stepXofY()}
{t("We are waiting for the seller lock the trade amount.")}
{t("Just hang on for a moment. If the seller does not deposit, you will get your bond back automatically. In addition, you will receive a compensation (check the rewards in your profile).")}
{this.showBondIsLocked()}
)
}
showWaitingForBuyerInvoice(){
const { t } = this.props;
return(
{/* Make confirmation sound for HTLC received. */}
{t("The trade collateral is locked!")} {" " + this.stepXofY()}
{t("We are waiting for the buyer to post a lightning invoice. Once he does, you will be able to directly communicate the fiat payment details.")}
{t("Just hang on for a moment. If the buyer does not cooperate, you will get back the trade collateral and your bond automatically. In addition, you will receive a compensation (check the rewards in your profile).")}
{this.showBondIsLocked()}
)
}
handleClickConfirmButton=()=>{
const requestOptions = {
method: 'POST',
headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken'),},
body: JSON.stringify({
'action': "confirm",
}),
};
fetch('/api/order/' + '?order_id=' + this.props.data.id, requestOptions)
.then((response) => response.json())
.then((data) => this.props.completeSetState(data));
}
handleRatingUserChange=(e)=>{
const requestOptions = {
method: 'POST',
headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken'),},
body: JSON.stringify({
'action': "rate_user",
'rating': e.target.value,
}),
};
fetch('/api/order/' + '?order_id=' + this.props.data.id, requestOptions)
.then((response) => response.json())
.then((data) => this.props.completeSetState(data));
}
handleRatingRobosatsChange=(e)=>{
if (this.state.rating_platform != null){
return null
}
this.setState({rating_platform:e.target.value});
const requestOptions = {
method: 'POST',
headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken'),},
body: JSON.stringify({
'action': "rate_platform",
'rating': e.target.value,
}),
};
fetch('/api/order/' + '?order_id=' + this.props.data.id, requestOptions)
.then((response) => response.json())
.then((data) => this.props.completeSetState(data));
}
showFiatSentButton(){
const { t } = this.props;
return(
)
}
showFiatReceivedButton(){
const { t } = this.props;
return(
)
}
showOpenDisputeButton(){
const { t } = this.props;
return(
)
}
showOrderExpired(){
const { t } = this.props;
return(
{t("The order has expired")}
)
}
showChat=()=>{
const { t } = this.props;
//In Chatroom - No fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton)
if(this.props.data.is_buyer & this.props.data.status == 9){
var showSendButton=true;
var showReveiceButton=false;
var showDisputeButton=true;
}
if(this.props.data.is_seller & this.props.data.status == 9){
var showSendButton=false;
var showReveiceButton=false;
var showDisputeButton=true;
}
//In Chatroom - Fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton)
if(this.props.data.is_buyer & this.props.data.status == 10){
var showSendButton=false;
var showReveiceButton=false;
var showDisputeButton=true;
}
if(this.props.data.is_seller & this.props.data.status == 10){
var showSendButton=false;
var showReveiceButton=true;
var showDisputeButton=true;
}
return(
{/* Make confirmation sound for Chat Open. */}
{this.props.data.is_seller ? t("Chat with the buyer"): t("Chat with the seller")} {" " + this.stepXofY()}
{this.props.data.is_seller ?
{this.props.data.status == 9?
t("Say hi! Be helpful and concise. Let them know how to send you {{currencyCode}}.",{currencyCode: this.props.data.currencyCode})
:
t("The buyer has sent the fiat. Click 'Confirm Received' once you receive it.")
}
:
{this.props.data.status == 9?
t("Say hi! Ask for payment details and click 'Confirm Sent' as soon as the payment is sent.")
:
t("Wait for the seller to confirm he has received the payment.")
}
}
{showDisputeButton ? this.showOpenDisputeButton() : ""}
{showSendButton ? this.showFiatSentButton() : ""}
{showReveiceButton ? this.showFiatReceivedButton() : ""}
{this.showBondIsLocked()}
)
}
showRateSelect(){
const { t } = this.props;
return(
{/* Make confirmation sound for Chat Open. */}
{t("🎉Trade finished!🥳")}
{/*
What do you think of ⚡{this.props.data.is_maker ? this.props.data.taker_nick : this.props.data.maker_nick}⚡?
*/}
What do you think of 🤖RoboSats⚡?
{this.state.rating_platform==5 ?
{t("Thank you! RoboSats loves you too ❤️")}
{t("RoboSats gets better with more liquidity and users. Tell a bitcoiner friend about Robosats!")}
Let us know how the platform could improve (Telegram / Github)
: null}
{this.showBondIsReturned()}
)
}
showSendingPayment(){
const { t } = this.props;
return(
{t("Attempting Lightning Payment")}
{t("RoboSats is trying to pay your lightning invoice. Remember that lightning nodes must be online in order to receive payments.")}
)
}
// Countdown Renderer callback with condition
countdownRenderer = ({ minutes, seconds, completed }) => {
const { t } = this.props;
if (completed) {
// Render a completed state
return (
{t("Retrying!")}
);
} else {
return (
{zeroPad(minutes)}m {zeroPad(seconds)}s
);
}
};
showRoutingFailed=()=>{
const { t } = this.props;
if(this.props.data.invoice_expired){
return(
{t("Lightning Routing Failed")}
{t("Your invoice has expired or more than 3 payment attempts have been made. Muun wallet is not recommended. ")}
{t("Check the list of compatible wallets")}
{t("Submit an invoice for {{amountSats}} Sats",{amountSats: pn(this.props.data.invoice_amount)})}
{this.showBondIsReturned()}
)
}else{
return(
{t("Lightning Routing Failed")}
{t("RoboSats will try to pay your invoice 3 times every 5 minutes. If it keeps failing, you will be able to submit a new invoice. Check whether you have enough inbound liquidity. Remember that lightning nodes must be online in order to receive payments.")}
{this.showBondIsReturned()}
)}
}
render() {
const { t } = this.props;
return (
{t("Contract Box")}
{/* Maker and taker Bond request */}
{this.props.data.is_maker & this.props.data.status == 0 ? this.showQRInvoice() : ""}
{this.props.data.is_taker & this.props.data.status == 3 ? this.showQRInvoice() : ""}
{/* Waiting for taker and taker bond request */}
{this.props.data.is_maker & this.props.data.status == 1 ? this.showMakerWait() : ""}
{this.props.data.is_maker & this.props.data.status == 3 ? this.showTakerFound() : ""}
{/* Send Invoice (buyer) and deposit collateral (seller) */}
{this.props.data.is_seller & (this.props.data.status == 6 || this.props.data.status == 7 ) ? this.showEscrowQRInvoice() : ""}
{this.props.data.is_buyer & (this.props.data.status == 6 || this.props.data.status == 8 )? this.showInputInvoice() : ""}
{this.props.data.is_buyer & this.props.data.status == 7 ? this.showWaitingForEscrow() : ""}
{this.props.data.is_seller & this.props.data.status == 8 ? this.showWaitingForBuyerInvoice() : ""}
{/* In Chatroom */}
{this.props.data.status == 9 || this.props.data.status == 10 ? this.showChat(): ""}
{/* Trade Finished */}
{(this.props.data.is_seller & [13,14,15].includes(this.props.data.status)) ? this.showRateSelect() : ""}
{(this.props.data.is_buyer & this.props.data.status == 14) ? this.showRateSelect() : ""}
{/* Trade Finished - Payment Routing Failed */}
{this.props.data.is_buyer & this.props.data.status == 13 ? this.showSendingPayment() : ""}
{/* Trade Finished - Payment Routing Failed */}
{this.props.data.is_buyer & this.props.data.status == 15 ? this.showRoutingFailed() : ""}
{/* Trade Finished - TODO Needs more planning */}
{this.props.data.status == 11 ? this.showInDisputeStatement() : ""}
{this.props.data.status == 16 ? this.showWaitForDisputeResolution() : ""}
{(this.props.data.status == 17 & this.props.data.is_taker) || (this.props.data.status == 18 & this.props.data.is_maker) ? this.showDisputeWinner() : ""}
{(this.props.data.status == 18 & this.props.data.is_taker) || (this.props.data.status == 17 & this.props.data.is_maker) ? this.showDisputeLoser() : ""}
{/* Order has expired */}
{this.props.data.status == 5 ? this.showOrderExpired() : ""}
{/* TODO */}
{/* */}
{/* */}
);
}
}
export default withTranslation()(TradeBox);