11 #include <validation.h> 21 #include <QRegularExpressionValidator> 26 static const QString PRC_COMMAND =
"createcontract";
27 static const QString PARAM_BYTECODE =
"bytecode";
28 static const QString PARAM_GASLIMIT =
"gaslimit";
29 static const QString PARAM_GASPRICE =
"gasprice";
30 static const QString PARAM_SENDER =
"sender";
32 static const CAmount SINGLE_STEP = 0.00000001*COIN;
33 static const CAmount HIGH_GASPRICE = 0.001*COIN;
43 m_ABIFunctionField(0),
49 Q_UNUSED(platformStyle);
59 ui->
labelSenderAddress->setToolTip(tr(
"The quantum address that will be used to create the contract."));
73 QStringList lstMandatory;
74 lstMandatory.append(PARAM_BYTECODE);
75 QStringList lstOptional;
76 lstOptional.append(PARAM_GASLIMIT);
77 lstOptional.append(PARAM_GASPRICE);
78 lstOptional.append(PARAM_SENDER);
79 QMap<QString, QString> lstTranslations;
95 QRegularExpression regEx;
97 QRegularExpressionValidator *bytecodeValidator =
new QRegularExpressionValidator(
ui->
textEditBytecode);
98 bytecodeValidator->setRegularExpression(regEx);
111 ui->
labelSolidity->setText(
"<a href=\"https://ethereum.github.io/browser-solidity/\">Solidity compiler</a>");
114 ui->
labelToken->setText(
"<a href=\"https://ethereum.org/token#the-code\">Token template</a>");
136 bool dataValid =
true;
182 QMap<QString, QString> lstParams;
184 QString errorMessage;
192 if(gasPrice > HIGH_GASPRICE)
194 QString message = tr(
"The Gas Price is too high, are you sure you want to possibly spend a max of %1 for this transaction?");
195 if(QMessageBox::question(
this, tr(
"High Gas price"), message.arg(
FabcoinUnits::formatWithUnit(unit, gasLimit * gasPrice))) == QMessageBox::No)
206 QString questionString = tr(
"Are you sure you want to create contract? <br />");
209 confirmationDialog.
exec();
210 QMessageBox::StandardButton retval = (QMessageBox::StandardButton)confirmationDialog.result();
211 if(retval == QMessageBox::Yes)
214 if(errorMessage.isEmpty() &&
m_execRPCCommand->
exec(lstParams, result, resultJson, errorMessage))
227 QMessageBox::warning(
this, tr(
"Create contract"), errorMessage);
237 uint64_t blockGasLimit = 0;
238 uint64_t minGasPrice = 0;
239 uint64_t nGasPrice = 0;
242 ui->
labelGasLimit->setToolTip(tr(
"Gas limit. Default = %1, Max = %2").arg(DEFAULT_GAS_LIMIT_OP_CREATE).arg(blockGasLimit));
243 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))));
290 std::vector<ParameterABI::ErrorType> errors;
291 if(
function.
abiIn(values, strData, errors))
293 return QString::fromStdString(strData);
297 errorMessage =
function.errorMessage(errors,
true);
#define SetObjectStyleSheet(object, name)
void on_createContractClicked()
ABIFunctionField * m_ABIFunctionField
UnlockContext requestUnlock()
QPushButton * pushButtonCreateContract
void setSingleStep(const CAmount &step)
Set single step in satoshis.
void setResultData(QVariant result, FunctionABI function, QList< QStringList > paramValues, ContractTxType type)
void setupUi(QWidget *CreateContract)
QString toDataHex(int func, QString &errorMessage)
void setIsValidManually(bool value)
ExecRPCCommand * m_execRPCCommand
std::vector< FunctionABI > functions
void on_refresh()
on_refresh Refresh the list of addresses
std::vector< std::vector< std::string > > getValuesVector()
getValuesVector Get params values vector List of all parameters that can be sent to a function...
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)
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)
QStackedWidget * stackedWidget
QScrollArea * scrollAreaConstructor
void setCurrent(int index)
setCurrent Set current index
QLabel * labelSenderAddress
void on_clearAllClicked()
QValidatedTextEdit * textEditInterface
static QString format(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string.
CreateContract(const PlatformStyle *platformStyle, QWidget *parent=0)
int getSelectedFunction() const
getSelectedFunction Get the ABI for the selected function from the contract
void setClientModel(ClientModel *clientModel)
QPushButton * pushButtonClearAll
void on_updateCreateButton()
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.
QSpinBox * lineEditGasLimit
The ABIFunctionField class ABI functions widget.
void on_numBlocksChanged()
void setCheckValidator(const QValidator *v)
void setValue(const CAmount &value)
QValidatedTextEdit * textEditBytecode
ClientModel * m_clientModel
The ExecRPCCommand class Execution of RPC command line.
ContractABI * m_contractABI
Interface to Fabcoin wallet from Qt view code.
virtual QString currentText() const
currentText Get the current text
bool isValidInterfaceABI()
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
bool loads(const std::string &json_data)
void setModel(WalletModel *model)
AddressField * lineEditSenderAddress
void setMinimum(const CAmount &min)
FabcoinAmountField * lineEditGasPrice
OptionsModel * getOptionsModel()
void getGasInfo(uint64_t &blockGasLimit, uint64_t &minGasPrice, uint64_t &nGasPrice) const
Get the information about the needed gas.