{this.props.data.is_maker
? t('Your maker bond was unlocked')
: t('Your taker bond was unlocked')}
);
};
showEscrowQRInvoice = () => {
const { t } = this.props;
return (
{/* Make sound for Taker found or HTLC received. */}
{this.props.data.is_maker ? this.Sound('taker-found') : this.Sound('locked-invoice')}
{t('Lock {{amountSats}} Sats as collateral', {
amountSats: pn(this.props.data.escrow_satoshis),
})}
{' ' + this.stepXofY()}
{t(
'You risk losing your bond if you do not lock the collateral. Total time available is {{deposit_timer_hours}}h {{deposit_timer_minutes}}m.',
this.depositHoursMinutes(),
)}
{this.showBondIsLocked()}
);
};
showTakerFound = () => {
const { t } = this.props;
return (
{/* Make bell sound when taker is found. SUPRESSED: It's annoying, not the right moment! Play only after taker locks bon */}
{/* {this.Sound("taker-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()}
);
};
depositHoursMinutes = () => {
const hours = parseInt(this.props.data.escrow_duration / 3600);
const minutes = parseInt((this.props.data.escrow_duration - hours * 3600) / 60);
const dict = { deposit_timer_hours: hours, deposit_timer_minutes: minutes };
return dict;
};
handleClickPauseOrder = () => {
this.props.completeSetState({ pauseLoading: true });
apiClient
.post('/api/order/?order_id=' + this.props.data.id, {
action: 'pause',
})
.then((data) => this.props.getOrderDetails(data.id));
};
showMakerWait = () => {
const { t } = this.props;
return (
{/* Make confirmation sound for HTLC received. */}
{this.Sound('locked-invoice')}
{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 {{deposit_timer_hours}}h {{deposit_timer_minutes}}m to reply. If you do not reply, you risk losing your bond.',
this.depositHoursMinutes(),
)}
{t(
'If the order expires untaken, your bond will return to you (no action needed).',
)}
{this.props.pauseLoading ? (
) : (
)}
{this.showBondIsLocked()}
);
};
showPausedOrder = () => {
const { t } = this.props;
return (
{t('Your order is paused')} {' ' + this.stepXofY()}
{t(
'Your public order has been paused. At the moment it cannot be seen or taken by other robots. You can choose to unpause it at any time.',
)}
{this.props.pauseLoading ? (
) : (
)}
{this.showBondIsLocked()}
);
};
handleInputInvoiceChanged = (e) => {
this.setState({
invoice: e.target.value,
badInvoice: false,
});
};
handleClickSubmitInvoiceButton = () => {
this.setState({ badInvoice: false, loadingSubmitInvoice: true });
apiClient
.post('/api/order/?order_id=' + this.props.data.id, {
action: 'update_invoice',
invoice: this.state.invoice,
})
.then(
(data) =>
this.setState({ badInvoice: data.bad_invoice, loadingSubmitInvoice: false }) &
this.props.completeSetState(data),
);
};
handleInputAddressChanged = (e) => {
this.setState({
address: e.target.value,
badAddress: false,
});
};
handleMiningFeeChanged = (e) => {
let fee = e.target.value;
if (fee > 50) {
fee = 50;
}
this.setState({
miningFee: fee,
});
};
handleClickSubmitAddressButton = () => {
this.setState({ badInvoice: false, loadingSubmitAddress: true });
apiClient
.post('/api/order/?order_id=' + this.props.data.id, {
action: 'update_address',
address: this.state.address,
mining_fee_rate: Math.max(1, this.state.miningFee),
})
.then(
(data) =>
this.setState({ badAddress: data.bad_address, loadingSubmitAddress: false }) &
this.props.completeSetState(data),
);
};
handleInputDisputeChanged = (e) => {
this.setState({
statement: e.target.value,
badStatement: false,
});
};
handleClickSubmitStatementButton = () => {
this.setState({ badInvoice: false });
apiClient
.post('/api/order/?order_id=' + this.props.data.id, {
action: 'submit_statement',
statement: this.state.statement,
})
.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);
};
compatibleWalletsButton = () => {
const { t } = this.props;
return (
);
};
showInputInvoice() {
const { t } = this.props;
return (
{/* Make sound for Taker found or HTLC received. */}
{this.props.data.is_maker ? this.Sound('taker-found') : this.Sound('locked-invoice')}
{' '}
{t('Submit payout info for {{amountSats}} Sats', {
amountSats: pn(this.props.data.invoice_amount),
})}
{' '}
{' ' + this.stepXofY()}
{t(
'Before letting you send {{amountFiat}} {{currencyCode}}, we want to make sure you are able to receive the BTC.',
{
amountFiat: pn(
parseFloat(
parseFloat(this.props.data.amount).toFixed(
this.props.data.currency == 1000 ? 8 : 4,
),
),
),
currencyCode: this.props.data.currencyCode,
},
)}
this.setState({ receiveTab: 0 })}
>
{t('Submit a valid invoice for {{amountSats}} Satoshis.', {
amountSats: pn(this.props.data.invoice_amount),
})}
{this.compatibleWalletsButton()}
{t('Submit')}
{/* ONCHAIN PAYOUT TAB */}
{t('EXPERIMENTAL: ')}
{t('RoboSats will do a swap and send the Sats to your onchain address.')}
{pn(
parseInt(
this.props.data.invoice_amount -
Math.max(1, this.state.miningFee) * 141 -
(this.props.data.invoice_amount * this.props.data.swap_fee_rate) / 100,
),
) + ' Sats'}
}
secondary={t('Final amount you will receive')}
/>
50}
helperText={this.state.miningFee < 1 || this.state.miningFee > 50 ? 'Invalid' : ''}
label={t('Mining Fee')}
required
sx={{ width: 110 }}
value={this.state.miningFee}
type='number'
inputProps={{
max: 50,
min: 1,
style: { textAlign: 'center' },
}}
onChange={this.handleMiningFeeChanged}
/>
{t('Submit')}
{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 info looks good!')} {' ' + this.stepXofY()}
{t('We are waiting for the seller to 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. */}
{this.Sound('locked-invoice')}
{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 = () => {
apiClient
.post('/api/order/?order_id=' + this.props.data.id, {
action: 'confirm',
})
.then((data) => {
this.props.completeSetState(data),
this.setState({ loadingButtonFiatSent: false, loadingButtonFiatReceived: false });
});
};
handleRatingUserChange = (e) => {
apiClient
.post('/api/order/?order_id=' + this.props.data.id, {
action: 'rate_user',
rating: e.target.value,
})
.then((data) => this.props.completeSetState(data));
};
handleRatingRobosatsChange = (e) => {
if (this.state.rating_platform != null) {
return null;
}
this.setState({ rating_platform: e.target.value });
apiClient
.post('/api/order/?order_id=' + this.props.data.id, {
action: 'rate_platform',
rating: e.target.value,
})
.then((data) => this.props.completeSetState(data));
};
showFiatSentButton() {
const { t } = this.props;
return (
);
}
showFiatReceivedButton() {
const { t } = this.props;
return (
{t('Confirm {{amount}} {{currencyCode}} received', {
currencyCode: this.props.data.currencyCode,
amount: pn(
parseFloat(
parseFloat(this.props.data.amount).toFixed(
this.props.data.currency == 1000 ? 8 : 4,
),
),
),
})}
);
}
disputeCountdownRenderer = ({ hours, minutes }) => {
return (
{hours}h {zeroPad(minutes)}m{' '}
);
};
showOpenDisputeButton() {
const { t } = this.props;
const now = Date.now();
const expires_at = new Date(this.props.data.expires_at);
// open dispute button enables 12h before expiry
expires_at.setHours(expires_at.getHours() - 12);
return (
expires_at}
disableTouchListener={now > expires_at}
enterTouchDelay={0}
title={
To open a dispute you need to wait
}
>
);
}
handleRenewOrderButtonPressed = () => {
this.setState({ renewLoading: true });
const body = {
type: this.props.data.type,
currency: this.props.data.currency,
amount: this.props.data.has_range ? null : this.props.data.amount,
has_range: this.props.data.has_range,
min_amount: this.props.data.min_amount,
max_amount: this.props.data.max_amount,
payment_method: this.props.data.payment_method,
is_explicit: this.props.data.is_explicit,
premium: this.props.data.is_explicit ? null : this.props.data.premium,
satoshis: this.props.data.is_explicit ? this.props.data.satoshis : null,
public_duration: this.props.data.public_duration,
escrow_duration: this.props.data.escrow_duration,
bond_size: this.props.data.bond_size,
bondless_taker: this.props.data.bondless_taker,
};
apiClient
.post('/api/make/', body)
.then(
(data) =>
this.setState({ badRequest: data.bad_request }) &
(data.id
? this.props.push('/order/' + data.id) & this.props.getOrderDetails(data.id)
: ''),
);
};
showOrderExpired = () => {
const { t } = this.props;
const show_renew = this.props.data.is_maker;
return (
{t('The order has expired')}{t(this.props.data.expiry_message)}
{show_renew ? (
{this.state.renewLoading ? (
) : (
)}
) : null}
);
};
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.Sound('locked-invoice')}
{' '}
{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 {{amount}} {{currencyCode}}.',
{
currencyCode: this.props.data.currencyCode,
amount: pn(
parseFloat(
parseFloat(this.props.data.amount).toFixed(
this.props.data.currency == 1000 ? 8 : 4,
),
),
),
},
)
: 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;
const show_renew = this.props.data.is_maker;
return (
{/* Make confirmation sound for Chat Open. */}
{this.Sound('successful')}
{t('Trade finished!')}
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!',
)}
) : null}
{(this.state.rating_platform != 5) & (this.state.rating_platform != null) ? (
{t('Thank you for using Robosats!')}
Let us know how the platform could improve (
Telegram
{' '}
/{' '}
Github
)
) : null}
{/* SHOW TXID IF USER RECEIVES ONCHAIN */}
{this.props.data.txid ? (
{t('Your TXID')}
{
systemClient.copyToClipboard(this.props.data.txid);
}}
>
{this.props.data.txid}
) : null}
{show_renew ? (
{this.state.renewLoading ? (
) : (
)}
) : null}
);
}
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{' '}
);
}
};
failureReason = () => {
const { t } = this.props;
return (
{t('Failure reason:')}
{t(this.props.data.failure_reason)}
);
};
showRoutingFailed = () => {
const { t } = this.props;
if (this.props.data.invoice_expired) {
return (
{t('Lightning Routing Failed')}
{this.props.data.failure_reason ? this.failureReason() : null}
{t(
'Your invoice has expired or more than 3 payment attempts have been made. Submit a new invoice.',
)}
{this.compatibleWalletsButton()}
{' '}
{t('Submit an invoice for {{amountSats}} Sats', {
amountSats: pn(this.props.data.invoice_amount),
})}
{t('Submit')}
{this.showBondIsReturned()}
);
} else {
return (
{t('Lightning Routing Failed')}
{this.props.data.failure_reason ? this.failureReason() : null}
{t(
'RoboSats will try to pay your invoice 3 times with a one minute pause in between. 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 (
{this.ConfirmDisputeDialog()}
{this.ConfirmFiatReceivedDialog()}
{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 == 2) ? this.showPausedOrder() : ''}
{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);