From c74460e77e82e6e43d744ec0baa4d2be679198bc Mon Sep 17 00:00:00 2001 From: defi101 <170788970+defi101@users.noreply.github.com> Date: Fri, 8 May 2026 16:25:24 +0700 Subject: [PATCH 1/3] Add private credit score demo dapp --- main.cpp | 37 ++- static/index.html | 4 +- static/private-credit-score.css | 331 +++++++++++++++++++ static/private-credit-score.html | 114 +++++++ static/private-credit-score.js | 391 +++++++++++++++++++++++ static/templates/index.json | 4 + static/templates/private_credit/main.aml | 115 +++++++ 7 files changed, 993 insertions(+), 3 deletions(-) create mode 100644 static/private-credit-score.css create mode 100644 static/private-credit-score.html create mode 100644 static/private-credit-score.js create mode 100644 static/templates/private_credit/main.aml diff --git a/main.cpp b/main.cpp index 972bfe0..3508fa7 100644 --- a/main.cpp +++ b/main.cpp @@ -1880,7 +1880,7 @@ int main(int argc, char** argv) { tx.to_ = contract_addr; tx.amount = "0"; tx.nonce = nonce + 1; - tx.ou = parse_ou(body, "50000000"); + tx.ou = parse_ou(body, "200000"); tx.timestamp = now_ts(); tx.op_type = "deploy"; tx.encrypted_data = bytecode; @@ -2036,6 +2036,39 @@ int main(int argc, char** argv) { res.set_content(r.result.dump(), "application/json"); }); + svr.Post("/api/contract/view", [](const httplib::Request& req, httplib::Response& res) { + WALLET_GUARD + json body; + try { body = json::parse(req.body); } catch (...) { + res.status = 400; + res.set_content(err_json("invalid json").dump(), "application/json"); + return; + } + std::string addr = body.value("address", ""); + std::string method = body.value("method", ""); + if (addr.empty() || method.empty()) { + res.status = 400; + res.set_content(err_json("address and method required").dump(), "application/json"); + return; + } + json params = json::array(); + if (body.contains("params")) { + params = body["params"]; + if (!params.is_array()) { + res.status = 400; + res.set_content(err_json("params must be an array").dump(), "application/json"); + return; + } + } + auto r = g_rpc.contract_call_view(addr, method, params, g_wallet.addr); + if (!r.ok) { + res.status = 400; + res.set_content(err_json(r.error).dump(), "application/json"); + return; + } + res.set_content(r.result.dump(), "application/json"); + }); + svr.Post("/api/fhe/encrypt", [](const httplib::Request& req, httplib::Response& res) { WALLET_GUARD if (!g_pvac_ok) { @@ -2374,4 +2407,4 @@ int main(int argc, char** argv) { printf("octra_wallet listening on http://127.0.0.1:%d\n", port); svr.listen("127.0.0.1", port); return 0; -} \ No newline at end of file +} diff --git a/static/index.html b/static/index.html index abbed67..96b6869 100644 --- a/static/index.html +++ b/static/index.html @@ -285,6 +285,7 @@