From 83b233afceec00f947e642c74a0970a1e86949e4 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Mon, 6 Nov 2023 14:28:54 +0800 Subject: [PATCH 1/6] support friendly cmd --- src/dfi/rpc_accounts.cpp | 56 ++++++++++++++++++- src/rpc/client.cpp | 4 ++ test/functional/feature_evm_transferdomain.py | 17 ++++++ 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/src/dfi/rpc_accounts.cpp b/src/dfi/rpc_accounts.cpp index e366613a12..9a28102861 100644 --- a/src/dfi/rpc_accounts.cpp +++ b/src/dfi/rpc_accounts.cpp @@ -2198,11 +2198,61 @@ UniValue transferdomain(const JSONRPCRequest &request) { EnsureWalletIsUnlocked(pwallet); - RPCTypeCheck(request.params, {UniValue::VARR}, false); - UniValue srcDstArray(UniValue::VARR); - srcDstArray = request.params[0].get_array(); + if (!request.params[0].isArray()) { + auto defineDomain = [](CTxDestination &dest) { + if (dest.index() == WitV0KeyHashType || dest.index() == PKHashType) { + return VMDomain::DVM; + } else if (dest.index() == WitV16KeyEthHashType) { + return VMDomain::EVM; + } else { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Unsupport domain provided"); + } + }; + + if (request.params[0].isNull()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "\"src\" is required"); + } + if (request.params[1].isNull()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "\"dst\" is required"); + } + if (request.params[2].isNull()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "\"amount\" is required"); + } + + std::string src = request.params[0].get_str(); + std::string dst = request.params[1].get_str(); + std::string amount = request.params[2].get_str(); + + CTxDestination srcDest = DecodeDestination(src); + CTxDestination dstDest = DecodeDestination(dst); + + VMDomain srcDomainType = defineDomain(srcDest); + VMDomain dstDomainType = defineDomain(dstDest); + + UniValue srcObj(UniValue::VOBJ); + srcObj.pushKV("address", src); + srcObj.pushKV("amount", amount); + srcObj.pushKV("domain", static_cast(srcDomainType)); + + UniValue dstObj(UniValue::VOBJ); + dstObj.pushKV("address", dst); + dstObj.pushKV("amount", amount); + dstObj.pushKV("domain", static_cast(dstDomainType)); + + UniValue elem(UniValue::VOBJ); + elem.pushKV("src", srcObj); + elem.pushKV("dst", dstObj); + + if (!request.params[3].isNull()) { + elem.pushKV("nonce", request.params[3].get_int()); + } + srcDstArray.push_back(elem); + } else { + RPCTypeCheck(request.params, {UniValue::VARR}, false); + srcDstArray = request.params[0].get_array(); + } CrossBoundaryResult result; CTransferDomainMessage msg; diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 5da3a3fd4e..4cea53ee1d 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -334,6 +334,10 @@ static const CRPCConvertParam vRPCConvertParams[] = { "sendtokenstoaddress", 0, "from" }, { "sendtokenstoaddress", 1, "to" }, { "transferdomain", 0, "array" }, + { "transferdomain", 0, "from" }, + { "transferdomain", 1, "to" }, + { "transferdomain", 2, "tokenAmount" }, + { "transferdomain", 3, "nonce" }, { "getanchorteams", 0, "blockHeight" }, { "getactivemasternodecount", 0, "blockCount" }, { "appointoracle", 1, "pricefeeds" }, diff --git a/test/functional/feature_evm_transferdomain.py b/test/functional/feature_evm_transferdomain.py index c74a426582..688fa5adb4 100755 --- a/test/functional/feature_evm_transferdomain.py +++ b/test/functional/feature_evm_transferdomain.py @@ -1256,6 +1256,21 @@ def test_contract_methods(self): assert_equal(contract.functions.totalSupply().call(), 0) assert_equal(contract.functions.balanceOf(self.address_erc55).call(), 0) + def test_new_transfer_domain(self): + self.rollback_to(self.start_height) + + self.nodes[0].utxostoaccount({self.address: "200@DFI"}) + transfer_domain( + self.nodes[0], self.address, self.address_erc55, "100@DFI", 2, 3 + ) + self.nodes[0].generate(1) + + self.nodes[0].transferdomain(self.address, self.address_erc55, "100@DFI") + balance_before = self.nodes[0].w3.eth.get_balance(self.address_erc55) + self.nodes[0].generate(1) + balance_after = self.nodes[0].w3.eth.get_balance(self.address_erc55) + assert_equal(balance_before + 100000000000000000000, balance_after) + def run_test(self): self.setup() self.invalid_before_fork_and_disabled() @@ -1292,6 +1307,8 @@ def run_test(self): self.test_contract_methods() + self.test_new_transfer_domain() + if __name__ == "__main__": EVMTest().main() From 71595ddd28082e6421871e5b4e1bb58738b3e33e Mon Sep 17 00:00:00 2001 From: canonbrother Date: Mon, 6 Nov 2023 16:15:27 +0800 Subject: [PATCH 2/6] conditional RPCHelpMan --- src/dfi/rpc_accounts.cpp | 126 ++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 54 deletions(-) diff --git a/src/dfi/rpc_accounts.cpp b/src/dfi/rpc_accounts.cpp index 9a28102861..06f5695e40 100644 --- a/src/dfi/rpc_accounts.cpp +++ b/src/dfi/rpc_accounts.cpp @@ -2117,77 +2117,95 @@ UniValue sendtokenstoaddress(const JSONRPCRequest &request) { UniValue transferdomain(const JSONRPCRequest &request) { auto pwallet = GetWallet(request); - // TODO: Add support for non-JSON parameteric input that's human friendly and intuitive - RPCHelpMan{ + + if (!request.params[0].isArray()) { + RPCHelpMan{ "transferdomain", "Creates (and submits to local node and network) a tx to transfer assets across domains. DVM to EVM/EVM to " "DVM, etc.\n" + HelpRequiringPassphrase(pwallet) + "\n", - { - { - "array", - RPCArg::Type::ARR, - RPCArg::Optional::NO, - "A json array of src and dst json objects", + { + { "from", RPCArg::Type::STR, RPCArg::Optional::NO, "the source address of sender"}, + { "to", RPCArg::Type::STR, RPCArg::Optional::NO, "the destination address of sender"}, + { "tokenAmount", RPCArg::Type::STR, RPCArg::Optional::NO, "in amount@token format"}, + { "nonce", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "specified nonce if needed"}, + }, + RPCResult{"\"hash\" (string) The hex-encoded hash of broadcasted transaction\n"}, + RPCExamples{HelpExampleCli("transferdomain", R"("from" "to" "100@DFI")") + + HelpExampleRpc("transferdomain", R"("from", "to", 100@BTC 2")")}, + }.Check(request); + } else { + RPCHelpMan{ + "transferdomain", + "Creates (and submits to local node and network) a tx to transfer assets across domains. DVM to EVM/EVM to " + "DVM, etc.\n" + + HelpRequiringPassphrase(pwallet) + "\n", + { { + "array", + RPCArg::Type::ARR, + RPCArg::Optional::NO, + "A json array of src and dst json objects", { - "", - RPCArg::Type::OBJ, - RPCArg::Optional::OMITTED, - "", { + "", + RPCArg::Type::OBJ, + RPCArg::Optional::OMITTED, + "", { - "src", - RPCArg::Type::OBJ, - RPCArg::Optional::OMITTED, - "Source arguments", { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "Source address"}, - {"amount", - RPCArg::Type::STR, - RPCArg::Optional::NO, - "Amount transfered, the value is amount in amount@token format"}, - {"domain", - RPCArg::Type::NUM, - RPCArg::Optional::NO, - "Domain of source: 2 - DVM, 3 - EVM"}, - // {"data", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Optional data"}, + "src", + RPCArg::Type::OBJ, + RPCArg::Optional::OMITTED, + "Source arguments", + { + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "Source address"}, + {"amount", + RPCArg::Type::STR, + RPCArg::Optional::NO, + "Amount transfered, the value is amount in amount@token format"}, + {"domain", + RPCArg::Type::NUM, + RPCArg::Optional::NO, + "Domain of source: 2 - DVM, 3 - EVM"}, + // {"data", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Optional data"}, + }, }, - }, - { - "dst", - RPCArg::Type::OBJ, - RPCArg::Optional::OMITTED, - "Destination arguments", { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "Destination address"}, - {"amount", - RPCArg::Type::STR, - RPCArg::Optional::NO, - "Amount transfered, the value is amount in amount@token format"}, - {"domain", - RPCArg::Type::NUM, - RPCArg::Optional::NO, - "Domain of source: 2 - DVM, 3 - EVM"}, - // {"data", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Optional data"}, + "dst", + RPCArg::Type::OBJ, + RPCArg::Optional::OMITTED, + "Destination arguments", + { + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "Destination address"}, + {"amount", + RPCArg::Type::STR, + RPCArg::Optional::NO, + "Amount transfered, the value is amount in amount@token format"}, + {"domain", + RPCArg::Type::NUM, + RPCArg::Optional::NO, + "Domain of source: 2 - DVM, 3 - EVM"}, + // {"data", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Optional data"}, + }, }, + {"nonce", + RPCArg::Type::NUM, + RPCArg::Optional::OMITTED, + "Optional parameter to specify the transaction nonce"}, }, - {"nonce", - RPCArg::Type::NUM, - RPCArg::Optional::OMITTED, - "Optional parameter to specify the transaction nonce"}, }, }, }, - }, }, - RPCResult{"\"hash\" (string) The hex-encoded hash of broadcasted transaction\n"}, - RPCExamples{ - HelpExampleCli( - "transferdomain", R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 2}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 3}}]')") + - HelpExampleCli( - "transferdomain", R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 3}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 2}}]')")}, + }, + RPCResult{"\"hash\" (string) The hex-encoded hash of broadcasted transaction\n"}, + RPCExamples{ + HelpExampleCli( + "transferdomain", R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 2}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 3}}]')") + + HelpExampleCli( + "transferdomain", R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 3}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 2}}]')")}, + }.Check(request); } - .Check(request); if (pwallet->chain().isInitialBlockDownload()) { throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, From fa4c456c6078f8575ca500f57a56a41040745536 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Thu, 9 Nov 2023 10:18:01 +0800 Subject: [PATCH 3/6] refine test --- test/functional/feature_evm_transferdomain.py | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/test/functional/feature_evm_transferdomain.py b/test/functional/feature_evm_transferdomain.py index 688fa5adb4..c48489ca4b 100755 --- a/test/functional/feature_evm_transferdomain.py +++ b/test/functional/feature_evm_transferdomain.py @@ -1259,17 +1259,38 @@ def test_contract_methods(self): def test_new_transfer_domain(self): self.rollback_to(self.start_height) - self.nodes[0].utxostoaccount({self.address: "200@DFI"}) - transfer_domain( - self.nodes[0], self.address, self.address_erc55, "100@DFI", 2, 3 + dfi_id = "0" + # dvm -> evm + self.nodes[0].transferdomain( + self.address, self.address_erc55, "123.45678901@DFI" + ) + balance_dvm_before = float( + self.nodes[0].getaccount(self.address, {}, True)[dfi_id] ) + balance_evm_before = self.nodes[0].w3.eth.get_balance(self.address_erc55) self.nodes[0].generate(1) + balance_dvm_after = float( + self.nodes[0].getaccount(self.address, {}, True)[dfi_id] + ) + balance_evm_after = self.nodes[0].w3.eth.get_balance(self.address_erc55) + assert_equal(balance_dvm_before - 123.45678901000000000, balance_dvm_after) + assert_equal(balance_evm_before + 123456789010000000000, balance_evm_after) - self.nodes[0].transferdomain(self.address, self.address_erc55, "100@DFI") - balance_before = self.nodes[0].w3.eth.get_balance(self.address_erc55) + # evm -> dvm + self.nodes[0].transferdomain( + self.address_erc55, self.address, "9.87654321@DFI" + ) + balance_dvm_before = float( + self.nodes[0].getaccount(self.address, {}, True)[dfi_id] + ) + balance_evm_before = self.nodes[0].w3.eth.get_balance(self.address_erc55) self.nodes[0].generate(1) - balance_after = self.nodes[0].w3.eth.get_balance(self.address_erc55) - assert_equal(balance_before + 100000000000000000000, balance_after) + balance_dvm_after = float( + self.nodes[0].getaccount(self.address, {}, True)[dfi_id] + ) + balance_evm_after = self.nodes[0].w3.eth.get_balance(self.address_erc55) + assert_equal(balance_dvm_before + 9.87654321000000000, balance_dvm_after) + assert_equal(balance_evm_before - 9876543210000000000, balance_evm_after) def run_test(self): self.setup() From bdcb15adfcbf76bd5c83a6dfb0a6324d5f6aa186 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Thu, 9 Nov 2023 10:24:19 +0800 Subject: [PATCH 4/6] fix test --- test/functional/feature_evm_transferdomain.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/functional/feature_evm_transferdomain.py b/test/functional/feature_evm_transferdomain.py index c48489ca4b..d6b25f94c7 100755 --- a/test/functional/feature_evm_transferdomain.py +++ b/test/functional/feature_evm_transferdomain.py @@ -1259,6 +1259,12 @@ def test_contract_methods(self): def test_new_transfer_domain(self): self.rollback_to(self.start_height) + self.nodes[0].utxostoaccount({self.address: "200@DFI"}) + transfer_domain( + self.nodes[0], self.address, self.address_erc55, "100@DFI", 2, 3 + ) + self.nodes[0].generate(1) + dfi_id = "0" # dvm -> evm self.nodes[0].transferdomain( From 480b0806b7c27105a32ee0f0418c04efcabf8728 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Thu, 9 Nov 2023 11:35:23 +0800 Subject: [PATCH 5/6] custom made RPCHelpMan --- src/dfi/rpc_accounts.cpp | 125 ++++++++++++--------------------------- 1 file changed, 37 insertions(+), 88 deletions(-) diff --git a/src/dfi/rpc_accounts.cpp b/src/dfi/rpc_accounts.cpp index 06f5695e40..f988eb4d96 100644 --- a/src/dfi/rpc_accounts.cpp +++ b/src/dfi/rpc_accounts.cpp @@ -2118,94 +2118,41 @@ UniValue sendtokenstoaddress(const JSONRPCRequest &request) { UniValue transferdomain(const JSONRPCRequest &request) { auto pwallet = GetWallet(request); - if (!request.params[0].isArray()) { - RPCHelpMan{ - "transferdomain", - "Creates (and submits to local node and network) a tx to transfer assets across domains. DVM to EVM/EVM to " - "DVM, etc.\n" + - HelpRequiringPassphrase(pwallet) + "\n", - { - { "from", RPCArg::Type::STR, RPCArg::Optional::NO, "the source address of sender"}, - { "to", RPCArg::Type::STR, RPCArg::Optional::NO, "the destination address of sender"}, - { "tokenAmount", RPCArg::Type::STR, RPCArg::Optional::NO, "in amount@token format"}, - { "nonce", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "specified nonce if needed"}, - }, - RPCResult{"\"hash\" (string) The hex-encoded hash of broadcasted transaction\n"}, - RPCExamples{HelpExampleCli("transferdomain", R"("from" "to" "100@DFI")") + - HelpExampleRpc("transferdomain", R"("from", "to", 100@BTC 2")")}, - }.Check(request); - } else { - RPCHelpMan{ - "transferdomain", - "Creates (and submits to local node and network) a tx to transfer assets across domains. DVM to EVM/EVM to " - "DVM, etc.\n" + - HelpRequiringPassphrase(pwallet) + "\n", - { - { - "array", - RPCArg::Type::ARR, - RPCArg::Optional::NO, - "A json array of src and dst json objects", - { - { - "", - RPCArg::Type::OBJ, - RPCArg::Optional::OMITTED, - "", - { - { - "src", - RPCArg::Type::OBJ, - RPCArg::Optional::OMITTED, - "Source arguments", - { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "Source address"}, - {"amount", - RPCArg::Type::STR, - RPCArg::Optional::NO, - "Amount transfered, the value is amount in amount@token format"}, - {"domain", - RPCArg::Type::NUM, - RPCArg::Optional::NO, - "Domain of source: 2 - DVM, 3 - EVM"}, - // {"data", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Optional data"}, - }, - }, - { - "dst", - RPCArg::Type::OBJ, - RPCArg::Optional::OMITTED, - "Destination arguments", - { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "Destination address"}, - {"amount", - RPCArg::Type::STR, - RPCArg::Optional::NO, - "Amount transfered, the value is amount in amount@token format"}, - {"domain", - RPCArg::Type::NUM, - RPCArg::Optional::NO, - "Domain of source: 2 - DVM, 3 - EVM"}, - // {"data", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Optional data"}, - }, - }, - {"nonce", - RPCArg::Type::NUM, - RPCArg::Optional::OMITTED, - "Optional parameter to specify the transaction nonce"}, - }, - }, - }, - }, - }, - RPCResult{"\"hash\" (string) The hex-encoded hash of broadcasted transaction\n"}, - RPCExamples{ - HelpExampleCli( - "transferdomain", R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 2}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 3}}]')") + - HelpExampleCli( - "transferdomain", R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 3}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 2}}]')")}, - }.Check(request); - } + RPCHelpMan{ + "transferdomain", + "Creates (and submits to local node and network) a tx to transfer assets across domains. DVM to EVM/EVM to " + "DVM, etc.\n" + HelpRequiringPassphrase(pwallet) + "\n" + + "Arguments:\n" + "1. array | string (json array | string, required) A json array of src and dst json objects\n" + " [\n" + " { (json object)\n" + " \"src\": { (json object) Source arguments\n" + " \"address\": \"str\", (string, required) Source address\n" + " \"amount\": \"str\", (string, required) Amount transfered, the value is amount in amount@token format\n" + " \"domain\": n, (numeric, required) Domain of source: 2 - DVM, 3 - EVM\n" + " },\n" + " \"dst\": { (json object) Destination arguments\n" + " \"address\": \"str\", (string, required) Destination address\n" + " \"amount\": \"str\", (string, required) Amount transfered, the value is amount in amount@token format\n" + " \"domain\": n, (numeric, required) Domain of source: 2 - DVM, 3 - EVM\n" + " },\n" + " \"nonce\": n, (numeric) Optional parameter to specify the transaction nonce\n" + " },\n" + " ...\n" + " ]\n" + " from (string, required) the source address of sender\n" + "2. to (string, required) the destination address of sender\n" + "3. tokenAmount (string, required) in amount@token format\n" + "4. nonce\n" + , + {}, + RPCResult{"\"hash\" (string) The hex-encoded hash of broadcasted transaction\n"}, + RPCExamples{ + HelpExampleCli("transferdomain", R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 2}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 3}}]')") + + HelpExampleCli("transferdomain", R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 3}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 2}}]')") + + HelpExampleCli("transferdomain", R"("from" "to" "100@DFI")") + + HelpExampleCli("transferdomain", R"("from", "to", 100@BTC 2")")}, + }; if (pwallet->chain().isInitialBlockDownload()) { throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, @@ -2219,6 +2166,8 @@ UniValue transferdomain(const JSONRPCRequest &request) { UniValue srcDstArray(UniValue::VARR); if (!request.params[0].isArray()) { + RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VSTR, UniValue::VSTR}, false); + auto defineDomain = [](CTxDestination &dest) { if (dest.index() == WitV0KeyHashType || dest.index() == PKHashType) { return VMDomain::DVM; From 9e0c55773fe160ef31a1bbd782a63a790b1b3e0e Mon Sep 17 00:00:00 2001 From: canonbrother Date: Thu, 9 Nov 2023 11:36:02 +0800 Subject: [PATCH 6/6] fmt --- src/dfi/rpc_accounts.cpp | 63 ++++++++++--------- test/functional/feature_evm_transferdomain.py | 4 +- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/dfi/rpc_accounts.cpp b/src/dfi/rpc_accounts.cpp index f988eb4d96..bd4323eafe 100644 --- a/src/dfi/rpc_accounts.cpp +++ b/src/dfi/rpc_accounts.cpp @@ -2119,37 +2119,44 @@ UniValue transferdomain(const JSONRPCRequest &request) { auto pwallet = GetWallet(request); RPCHelpMan{ - "transferdomain", - "Creates (and submits to local node and network) a tx to transfer assets across domains. DVM to EVM/EVM to " - "DVM, etc.\n" + HelpRequiringPassphrase(pwallet) + "\n" + - "Arguments:\n" - "1. array | string (json array | string, required) A json array of src and dst json objects\n" - " [\n" - " { (json object)\n" - " \"src\": { (json object) Source arguments\n" - " \"address\": \"str\", (string, required) Source address\n" - " \"amount\": \"str\", (string, required) Amount transfered, the value is amount in amount@token format\n" - " \"domain\": n, (numeric, required) Domain of source: 2 - DVM, 3 - EVM\n" - " },\n" - " \"dst\": { (json object) Destination arguments\n" - " \"address\": \"str\", (string, required) Destination address\n" - " \"amount\": \"str\", (string, required) Amount transfered, the value is amount in amount@token format\n" - " \"domain\": n, (numeric, required) Domain of source: 2 - DVM, 3 - EVM\n" - " },\n" - " \"nonce\": n, (numeric) Optional parameter to specify the transaction nonce\n" - " },\n" - " ...\n" - " ]\n" - " from (string, required) the source address of sender\n" - "2. to (string, required) the destination address of sender\n" - "3. tokenAmount (string, required) in amount@token format\n" - "4. nonce\n" - , + "transferdomain", + "Creates (and submits to local node and network) a tx to transfer assets across domains. DVM to EVM/EVM to " + "DVM, etc.\n" + + HelpRequiringPassphrase(pwallet) + "\n" + + "Arguments:\n" + "1. array | string (json array | string, required) A json array of src and dst json " + "objects\n" + " [\n" + " { (json object)\n" + " \"src\": { (json object) Source arguments\n" + " \"address\": \"str\", (string, required) Source address\n" + " \"amount\": \"str\", (string, required) Amount transfered, the value is amount in " + "amount@token format\n" + " \"domain\": n, (numeric, required) Domain of source: 2 - DVM, 3 - EVM\n" + " },\n" + " \"dst\": { (json object) Destination arguments\n" + " \"address\": \"str\", (string, required) Destination address\n" + " \"amount\": \"str\", (string, required) Amount transfered, the value is amount in " + "amount@token format\n" + " \"domain\": n, (numeric, required) Domain of source: 2 - DVM, 3 - EVM\n" + " },\n" + " \"nonce\": n, (numeric) Optional parameter to specify the transaction nonce\n" + " },\n" + " ...\n" + " ]\n" + " from (string, required) the source address of sender\n" + "2. to (string, required) the destination address of sender\n" + "3. tokenAmount (string, required) in amount@token format\n" + "4. nonce\n", {}, RPCResult{"\"hash\" (string) The hex-encoded hash of broadcasted transaction\n"}, RPCExamples{ - HelpExampleCli("transferdomain", R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 2}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 3}}]')") + - HelpExampleCli("transferdomain", R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 3}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 2}}]')") + + HelpExampleCli( + "transferdomain", + R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 2}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 3}}]')") + + HelpExampleCli( + "transferdomain", + R"('[{"src":{"address":"", "amount":"1.0@DFI", "domain": 3}, "dst":{"address":"", "amount":"1.0@DFI", "domain": 2}}]')") + HelpExampleCli("transferdomain", R"("from" "to" "100@DFI")") + HelpExampleCli("transferdomain", R"("from", "to", 100@BTC 2")")}, }; diff --git a/test/functional/feature_evm_transferdomain.py b/test/functional/feature_evm_transferdomain.py index d6b25f94c7..bfe23dd86a 100755 --- a/test/functional/feature_evm_transferdomain.py +++ b/test/functional/feature_evm_transferdomain.py @@ -1283,9 +1283,7 @@ def test_new_transfer_domain(self): assert_equal(balance_evm_before + 123456789010000000000, balance_evm_after) # evm -> dvm - self.nodes[0].transferdomain( - self.address_erc55, self.address, "9.87654321@DFI" - ) + self.nodes[0].transferdomain(self.address_erc55, self.address, "9.87654321@DFI") balance_dvm_before = float( self.nodes[0].getaccount(self.address, {}, True)[dfi_id] )