From 8d90e9625154eb7ae3a63dbbe219e8ed967b003d Mon Sep 17 00:00:00 2001 From: timlucmiptev Date: Sun, 22 Nov 2020 16:49:55 +0200 Subject: [PATCH] skeleton view --- app/btc-wallet-hook.hoon | 9 ++++-- app/btc-wallet-view.hoon | 65 +++++++++++++++++++++++++++++++++++++++ lib/btc-wallet-store.hoon | 10 ++++++ lib/btc-wallet-view.hoon | 20 ++++++++++++ sur/btc-wallet-view.hoon | 5 +++ 5 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 app/btc-wallet-view.hoon create mode 100644 lib/btc-wallet-view.hoon create mode 100644 sur/btc-wallet-view.hoon diff --git a/app/btc-wallet-hook.hoon b/app/btc-wallet-hook.hoon index 74595bc33..744b18be8 100644 --- a/app/btc-wallet-hook.hoon +++ b/app/btc-wallet-hook.hoon @@ -76,8 +76,13 @@ == [cards this] :: -:: TODO: handle /sign-me path -++ on-watch on-watch:def +++ on-watch + |= pax=path + ^- (quip card _this) + ?+ pax (on-watch:def pax) + [%sign-me ~] + `this + == ++ on-leave on-leave:def ++ on-peek on-peek:def ++ on-agent diff --git a/app/btc-wallet-view.hoon b/app/btc-wallet-view.hoon new file mode 100644 index 000000000..598f464bf --- /dev/null +++ b/app/btc-wallet-view.hoon @@ -0,0 +1,65 @@ +:: btc-wallet-view.hoon +:: receive signing requests from btc-wallet-hook +:: +/- *btc-wallet-view +/+ dbug, default-agent +|% ++$ versioned-state + $% state-0 + == +:: ++$ state-0 [%0 counter=@] +:: ++$ card card:agent:gall +:: +-- +%- agent:dbug +=| state-0 +=* state - +^- agent:gall +|_ =bowl:gall ++* this . + def ~(. (default-agent this %|) bowl) +:: +++ on-init + ^- (quip card _this) + ~& > '%btc-wallet-view initialized successfully' + =/ filea [%file-server-action !>([%serve-dir /'~btc-wallet' /app/btc-wallet %.n %.y])] + :_ this + :~ [%pass /srv %agent [our.bowl %file-server] %poke filea] + [%pass /u/[(scot %da now.bowl)] %agent [our.bowl %btc-wallet-hook] %watch /sign-me] + == +++ on-save + ^- vase + !>(state) +++ on-load + |= old-state=vase + ^- (quip card _this) + ~& > '%btc-wallet-view recompiled successfully' + `this(state !<(versioned-state old-state)) +++ on-poke + |= [=mark =vase] + |^ ^- (quip card _this) + ?+ mark (on-poke:def mark vase) + %btc-wallet-view-action + (handle-action !<(action vase)) + == + ++ handle-action + |= =action + ~& >>> action + `this + -- +:: +++ on-watch + |= =path + ^- (quip card _this) + ?+ path (on-watch:def path) + [%primary ~] + `this + == +++ on-leave on-leave:def +++ on-peek on-peek:def +++ on-agent on-agent:def +++ on-arvo on-arvo:def +++ on-fail on-fail:def +-- diff --git a/lib/btc-wallet-store.hoon b/lib/btc-wallet-store.hoon index 363431ec1..a2ec92b88 100644 --- a/lib/btc-wallet-store.hoon +++ b/lib/btc-wallet-store.hoon @@ -5,6 +5,16 @@ =, secp:crypto =+ ecc=secp256k1 |% +++ enjs + =, enjs:format + |% + :: + ++ txbu + |= =^txbu + ^- json + [%s 'txbu placeholder'] + -- +:: ++ defaults |% ++ max-gap 20 diff --git a/lib/btc-wallet-view.hoon b/lib/btc-wallet-view.hoon new file mode 100644 index 000000000..693631670 --- /dev/null +++ b/lib/btc-wallet-view.hoon @@ -0,0 +1,20 @@ +/- sur=btc-wallet-view +^? +=< [sur .] +=, sur +|% +++ dejs + =, dejs:format + |% + ++ action + |= jon=json + ^- ^action + =< (parse-json jon) + |% + ++ parse-json + %- of + :~ [%blank so] + == + -- + -- +-- diff --git a/sur/btc-wallet-view.hoon b/sur/btc-wallet-view.hoon new file mode 100644 index 000000000..2b1a3996b --- /dev/null +++ b/sur/btc-wallet-view.hoon @@ -0,0 +1,5 @@ +|% ++$ action + $% [%blank ~] + == +--