MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / listcontracts

Function listcontracts

src/rpc/rpctx.cpp:748–787  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

746}
747
748Value listcontracts(const Array& params, bool fHelp) {
749 if (fHelp || params.size() != 1) {
750 throw runtime_error(
751 "listcontracts \"show detail\"\n"
752 "\nget the list of all contracts\n"
753 "\nArguments:\n"
754 "1. show detail (boolean, required) show contract in detail if true.\n"
755 "\nReturn an object contains all contracts\n"
756 "\nResult:\n"
757 "\nExamples:\n" +
758 HelpExampleCli("listcontracts", "true") + "\nAs json rpc call\n" + HelpExampleRpc("listcontracts", "true"));
759 }
760
761 bool showDetail = params[0].get_bool();
762
763 auto dbIt = MakeDbIterator(pCdMan->pContractCache->contractCache);
764 Object obj;
765 Array contractArray;
766 for (dbIt->First(); dbIt->IsValid(); dbIt->Next()) {
767 Object contractObject;
768 const auto &regidKey = dbIt->GetKey();
769 const CUniversalContractStore &contract = dbIt->GetValue();
770 contractObject.push_back(Pair("contract_regid", regidKey.ToString()));
771 contractObject.push_back(Pair("memo", contract.memo));
772
773 if (showDetail) {
774 contractObject.push_back(Pair("vm_type", contract.vm_type));
775 contractObject.push_back(Pair("upgradable", contract.upgradable));
776 contractObject.push_back(Pair("code", HexStr(contract.code)));
777 contractObject.push_back(Pair("abi", contract.abi));
778 }
779
780 contractArray.push_back(contractObject);
781 }
782
783 obj.push_back(Pair("count", contractArray.size()));
784 obj.push_back(Pair("contracts", contractArray));
785
786 return obj;
787}
788
789Value getcontractinfo(const Array& params, bool fHelp) {
790 if (fHelp || params.size() != 1)

Callers

nothing calls this directly

Calls 14

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
MakeDbIteratorFunction · 0.85
PairClass · 0.85
HexStrFunction · 0.85
get_boolMethod · 0.80
push_backMethod · 0.80
sizeMethod · 0.45
FirstMethod · 0.45
IsValidMethod · 0.45
NextMethod · 0.45
GetKeyMethod · 0.45

Tested by

no test coverage detected