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

Function getcontractinfo

src/rpc/rpctx.cpp:789–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

787}
788
789Value getcontractinfo(const Array& params, bool fHelp) {
790 if (fHelp || params.size() != 1)
791 throw runtime_error(
792 "getcontractinfo \"contract regid\"\n"
793 "\nget contract information.\n"
794 "\nArguments:\n"
795 "1. \"contract regid\" (string, required) the contract regid.\n"
796 "\nReturn an object contains contract information\n"
797 "\nExamples:\n" +
798 HelpExampleCli("getcontractinfo", "1-1") + "\nAs json rpc call\n" +
799 HelpExampleRpc("getcontractinfo", "1-1"));
800
801 CRegID regid(params[0].get_str());
802 if (regid.IsEmpty() || !pCdMan->pContractCache->HasContract(regid)) {
803 throw JSONRPCError(RPC_INVALID_PARAMS, "Invalid contract regid.");
804 }
805
806 CUniversalContractStore contractStore;
807 if (!pCdMan->pContractCache->GetContract(regid, contractStore)) {
808 throw JSONRPCError(RPC_DATABASE_ERROR, "Failed to acquire contract from db.");
809 }
810
811 Object obj = contractStore.ToJson();
812 obj.insert(obj.begin(), Pair("contract_regid", regid.ToString()));
813
814 return obj;
815}
816
817Value listtxcache(const Array& params, bool fHelp) {
818 if (fHelp || params.size() != 0) {

Callers

nothing calls this directly

Calls 12

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
PairClass · 0.85
HasContractMethod · 0.80
GetContractMethod · 0.80
sizeMethod · 0.45
IsEmptyMethod · 0.45
ToJsonMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected