11 #include <validation.h> 28 static const QString PRC_COMMAND =
"sendtocontract";
29 static const QString PARAM_ADDRESS =
"address";
30 static const QString PARAM_DATAHEX =
"datahex";
31 static const QString PARAM_AMOUNT =
"amount";
32 static const QString PARAM_GASLIMIT =
"gaslimit";
33 static const QString PARAM_GASPRICE =
"gasprice";
34 static const QString PARAM_SENDER =
"sender";
36 static const CAmount SINGLE_STEP = 0.00000001*COIN;
37 static const CAmount HIGH_GASPRICE = 0.001*COIN;
48 m_ABIFunctionField(0),
56 Q_UNUSED(platformStyle);
71 ui->
labelAmount->setToolTip(tr(
"The amount in FABCOIN to send. Default = 0."));
87 QStringList lstMandatory;
88 lstMandatory.append(PARAM_ADDRESS);
89 lstMandatory.append(PARAM_DATAHEX);
90 QStringList lstOptional;
91 lstOptional.append(PARAM_AMOUNT);
92 lstOptional.append(PARAM_GASLIMIT);
93 lstOptional.append(PARAM_GASPRICE);
94 lstOptional.append(PARAM_SENDER);
95 QMap<QString, QString> lstTranslations;
117 QRegularExpression regEx;
120 addressValidatr->setRegularExpression(regEx);
150 bool dataValid =
true;
202 QMap<QString, QString> lstParams;
204 QString errorMessage;
212 if(gasPrice > HIGH_GASPRICE)
214 QString message = tr(
"The Gas Price is too high, are you sure you want to possibly spend a max of %1 for this transaction?");
215 if(QMessageBox::question(
this, tr(
"High Gas price"), message.arg(
FabcoinUnits::formatWithUnit(unit, gasLimit * gasPrice))) == QMessageBox::No)
228 QString questionString = tr(
"Are you sure you want to send to the contract: <br /><br />");
229 questionString.append(tr(
"<b>%1</b>?")
233 confirmationDialog.
exec();
234 QMessageBox::StandardButton retval = (QMessageBox::StandardButton)confirmationDialog.result();
235 if(retval == QMessageBox::Yes)
238 if(errorMessage.isEmpty() &&
m_execRPCCommand->
exec(lstParams, result, resultJson, errorMessage))
251 QMessageBox::warning(
this, tr(
"Send to contract"), errorMessage);
261 uint64_t blockGasLimit = 0;
262 uint64_t minGasPrice = 0;
263 uint64_t nGasPrice = 0;
266 ui->
labelGasLimit->setToolTip(tr(
"Gas limit: Default = %1, Max = %2.").arg(DEFAULT_GAS_LIMIT_OP_SEND).arg(blockGasLimit));
267 ui->
labelGasPrice->setToolTip(tr(
"Gas price: FABCOIN price per gas unit. Default = %1, Min = %2.").arg(QString::fromStdString(
FormatMoney(DEFAULT_GAS_PRICE))).arg(QString::fromStdString(
FormatMoney(minGasPrice))));
278 bool enabled = func >= -1;
387 return QString::fromStdString(defSelector);
393 std::vector<ParameterABI::ErrorType> errors;
394 if(
function.
abiIn(values, strData, errors))
396 return QString::fromStdString(strData);
400 errorMessage =
function.errorMessage(errors,
true);
408 if(func < 0)
return true;
410 return function.payable;
QPushButton * pushButtonSendToContract
#define SetObjectStyleSheet(object, name)
const QString & getAddressValue() const
QLabel * labelContractAddress
int lookupAddress(const QString &address) const
void setModel(WalletModel *model)
Dialog for editing a contract information.
void setABI(const QString &ABI)
ContractABI * m_contractABI
UnlockContext requestUnlock()
void on_contractAddressChanged()
void on_updateSendToContractButton()
void setupUi(QWidget *SendToContract)
void setSingleStep(const CAmount &step)
Set single step in satoshis.
void setResultData(QVariant result, FunctionABI function, QList< QStringList > paramValues, ContractTxType type)
void on_numBlocksChanged()
ContractTableModel * getContractTableModel()
QLabel * labelSenderAddress
bool isValidContractAddress()
void setIsValidManually(bool value)
std::vector< FunctionABI > functions
QToolButton * pasteAddressButton
void on_refresh()
on_refresh Refresh the list of addresses
ExecRPCCommand * m_execRPCCommand
std::vector< std::vector< std::string > > getValuesVector()
getValuesVector Get params values vector List of all parameters that can be sent to a function...
QString getAddress() const
bool exec(const QMap< QString, QString > ¶ms, QVariant &result, QString &resultJson, QString &errorMessage)
exec Execute the RPC command
bool addTab(int index, const QString &name)
addTab Add new tab
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
QString abiForAddress(const QString &address) const
bytes abiIn(std::string _id, T const &..._t)
void setContractABI(ContractABI *contractABI)
setContractABI Set the contract ABI (list of functions from the contract)
int64_t CAmount
Amount in lius (Can be negative)
void setCurrent(int index)
setCurrent Set current index
void on_loadInfoClicked()
void setContractAddress(const QString &address)
void on_sendToContractClicked()
FabcoinAmountField * lineEditAmount
static QString format(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string.
void on_functionChanged()
int getSelectedFunction() const
getSelectedFunction Get the ABI for the selected function from the contract
void on_saveInfoClicked()
void setModel(ContractTableModel *model)
AddressField * lineEditSenderAddress
void clear()
clear Remove all tabs except the first one which is not closable
Model for Fabcoin network client.
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
void setModel(ContractTableModel *model)
The ABIFunctionField class ABI functions widget.
FabcoinAmountField * lineEditGasPrice
QPushButton * pushButtonClearAll
void setEnabled(bool fEnabled)
Enable/Disable.
void on_pasteAddressClicked()
void setValue(const CAmount &value)
const PlatformStyle * m_platformStyle
bool isValidInterfaceABI()
QString toDataHex(int func, QString &errorMessage)
QValidatedLineEdit * lineEditContractAddress
The ExecRPCCommand class Execution of RPC command line.
QList< QStringList > getParamsValues()
getParamsValues Get the values of the whole list of input parameters for the selected function ...
Interface to Fabcoin wallet from Qt view code.
virtual QString currentText() const
currentText Get the current text
QStackedWidget * stackedWidget
void setCheckValidator(const QValidator *v)
The TabBarInfo class Class for informations about tabs.
static void appendParam(QMap< QString, QString > ¶ms, const QString ¶mName, const QString ¶mValue)
appendParam Append paramether to the list
QToolButton * loadInfoButton
bool loads(const std::string &json_data)
struct evm_uint160be address(struct evm_env *env)
static std::string defaultSelector()
void formatToolButtons(QToolButton *btn1, QToolButton *btn2, QToolButton *btn3)
ContractTableModel * m_contractModel
QSpinBox * lineEditGasLimit
SendToContract(const PlatformStyle *platformStyle, QWidget *parent=0)
void setMinimum(const CAmount &min)
QToolButton * saveInfoButton
ABIFunctionField * m_ABIFunctionField
QValidatedTextEdit * textEditInterface
void on_clearAllClicked()
ClientModel * m_clientModel
void clear()
Make field empty and ready for new input.
QScrollArea * scrollAreaFunction
void setAddress(const QString &address)
OptionsModel * getOptionsModel()
void setClientModel(ClientModel *clientModel)
void getGasInfo(uint64_t &blockGasLimit, uint64_t &minGasPrice, uint64_t &nGasPrice) const
Get the information about the needed gas.