Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix updateloantoken arguments parsing and description #895

Merged
merged 3 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/masternodes/rpc_loan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,14 @@ UniValue updateloantoken(const JSONRPCRequest& request) {
auto pwallet = GetWallet(request);

RPCHelpMan{"updateloantoken",
"Creates (and submits to local node and network) a token for a price feed set in collateral token.\n" +
"Creates (and submits to local node and network) a transaction to update loan token metadata.\n" +
HelpRequiringPassphrase(pwallet) + "\n",
{
{"token", RPCArg::Type::STR, RPCArg::Optional::NO, "The tokens's symbol, id or creation tx"},
{"metadata", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
{"metadata", RPCArg::Type::OBJ, RPCArg::Optional::NO, "",
{
{"symbol", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Token's symbol (unique), not longer than " + std::to_string(CToken::MAX_TOKEN_SYMBOL_LENGTH)},
{"name", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Token's name (optional), not longer than " + std::to_string(CToken::MAX_TOKEN_NAME_LENGTH)},
{"symbol", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "New token's symbol (unique), not longer than " + std::to_string(CToken::MAX_TOKEN_SYMBOL_LENGTH)},
{"name", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Newoken's name (optional), not longer than " + std::to_string(CToken::MAX_TOKEN_NAME_LENGTH)},
{"fixedIntervalPriceId", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "token/currency pair to use for price of token"},
{"mintable", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, "Token's 'Mintable' property (bool, optional), default is 'True'"},
{"interest", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "Interest rate (optional)."},
Expand All @@ -430,7 +430,8 @@ UniValue updateloantoken(const JSONRPCRequest& request) {
"\"hash\" (string) The hex-encoded hash of broadcasted transaction\n"
},
RPCExamples{
HelpExampleCli("updateloantoken", R"('"token":"TSLAAA", {"symbol":"TSLA","fixedIntervalPriceId":"TSLA/USD", "mintable": true, "interest": 0.03}')")
HelpExampleCli("updateloantoken", R"("TSLAAA", {"symbol":"TSLA","fixedIntervalPriceId":"TSLA/USD", "mintable": true, "interest": 0.03}')") +
HelpExampleRpc("updateloantoken", R"("TSLAAA", {"symbol":"TSLA","fixedIntervalPriceId":"TSLA/USD", "mintable": true, "interest": 0.03})")
},
}.Check(request);

Expand All @@ -439,10 +440,7 @@ UniValue updateloantoken(const JSONRPCRequest& request) {

pwallet->BlockUntilSyncedToCurrentChain();

RPCTypeCheck(request.params, {UniValueType(), UniValue::VOBJ, UniValue::VARR}, false);
if (request.params[0].isNull())
throw JSONRPCError(RPC_INVALID_PARAMETER,
"Invalid parameters, arguments 0 must be non-null and expected as string with token symbol, id or creation txid");
RPCTypeCheck(request.params, {UniValueType(), UniValue::VOBJ, UniValue::VARR}, true);

std::string const tokenStr = trim_ws(request.params[0].getValStr());
UniValue metaObj = request.params[1].get_obj();
Expand Down Expand Up @@ -1376,7 +1374,7 @@ static const CRPCCommand commands[] =
{"loan", "getcollateraltoken", &getcollateraltoken, {"by"}},
{"loan", "listcollateraltokens", &listcollateraltokens, {"by"}},
{"loan", "setloantoken", &setloantoken, {"metadata", "inputs"}},
{"loan", "updateloantoken", &updateloantoken, {"metadata", "inputs"}},
{"loan", "updateloantoken", &updateloantoken, {"token", "metadata", "inputs"}},
{"loan", "listloantokens", &listloantokens, {}},
{"loan", "getloantoken", &getloantoken, {"by"}},
{"loan", "createloanscheme", &createloanscheme, {"mincolratio", "interestrate", "id", "inputs"}},
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "listcollateraltokens", 0, "by" },
{ "setloantoken", 0, "metadata" },
{ "setloantoken", 1, "inputs" },
{ "updateloantoken", 0, "metadata" },
{ "updateloantoken", 1, "inputs" },
{ "updateloantoken", 1, "metadata" },
{ "updateloantoken", 2, "inputs" },
{ "takeloan", 0, "metadata" },
{ "takeloan", 1, "inputs" },
{ "paybackloan", 0, "metadata" },
Expand Down