|
6 | 6 | :: mainly for orchestration. But, first focus on getting a working TX CRUD
|
7 | 7 | :: agent before optimizing. So, one day :)
|
8 | 8 | ::
|
9 |
| -/+ *account, *transaction, *wallet |
10 |
| -/+ default-agent, dbug, agentio, verb |
| 9 | +/+ a=account, t=transaction, w=wallet |
| 10 | +/+ default-agent, dbug, verb |
11 | 11 | |%
|
12 | 12 | +$ card card:agent:gall
|
13 | 13 | +$ versioned-state
|
|
18 | 18 | :: acts: map of account-id --> account
|
19 | 19 | :: txns: map of transaction-id --> transaction
|
20 | 20 | :: wlts: map of wallet-id --> wallets
|
21 |
| -+$ state-0 [%0 txns=transactions:zero:past] |
22 |
| -+$ state-1 [%1 acts=accounts txns=transactions wlts=wallets] |
| 21 | ++$ state-0 [%0 txns=transactions:zero:past:t] |
| 22 | ++$ state-1 [%1 acts=accounts:a txns=transactions:t wlts=wallets:w] |
23 | 23 | --
|
24 | 24 | =| state-1
|
25 | 25 | =* state -
|
26 | 26 | ::
|
27 | 27 | %- agent:dbug
|
28 | 28 | %+ verb & :: TODO: disable before production
|
29 | 29 | ^- agent:gall
|
| 30 | +:: |
| 31 | +=< :: app core |
30 | 32 | |_ =bowl:gall
|
31 | 33 | +* this .
|
| 34 | + do ~(. +> bowl) |
32 | 35 | def ~(. (default-agent this %.n) bowl)
|
33 |
| - io ~(. agentio bowl) |
34 | 36 | ::
|
35 | 37 | ++ on-init on-init:def
|
36 | 38 | ::
|
|
42 | 44 | |= old-state=vase
|
43 | 45 | ^- (quip card _this)
|
44 | 46 | =/ old !<(versioned-state old-state)
|
| 47 | + |^ |
45 | 48 | ?- -.old
|
46 |
| - %1 |
47 |
| - `this(state old) |
48 |
| - %0 |
49 |
| - `this(state-0-to-1 old) |
| 49 | + %1 `this(state old) |
| 50 | + %0 `this(state (state-0-to-1 old)) |
50 | 51 | ==
|
51 | 52 | ++ state-0-to-1
|
52 | 53 | |= zer=state-0
|
53 | 54 | ^- state-1
|
54 | 55 | :* %1
|
55 |
| - acts *accounts |
| 56 | + acts *accounts:a |
56 | 57 | txns (transactions-0-to-1 txns.zer)
|
57 |
| - wlts *wallets |
| 58 | + wlts *wallets:w |
58 | 59 | ==
|
59 | 60 | ++ transactions-0-to-1
|
60 |
| - |= txns=transactions:zero:past |
61 |
| - ^- transactions |
| 61 | + |= txns=transactions:zero:past:t |
| 62 | + ^- transactions:t |
62 | 63 | %- ~(run by txns)
|
63 |
| - |= [id=@t txn=transaction:zero:past] |
64 |
| - ^- [id=@t txn=transaction] |
| 64 | + |= [id=@t txn=transaction:zero:past:t] |
| 65 | + ^- [id=@t txn=transaction:t] |
65 | 66 | [id (transaction-0-to-1 txn)]
|
66 | 67 | ++ transaction-0-to-1
|
67 |
| - |= txn=transaction:zero:past |
68 |
| - ^- ^transaction :: TODO: which transaction to point to? should use the ket to traverse up the tree? |
| 68 | + |= txn=transaction:zero:past:t |
| 69 | + ^- transaction:t |
69 | 70 | :* id.txn
|
70 | 71 | coin-id.txn
|
71 | 72 | date.txn
|
|
75 | 76 | type.txn
|
76 | 77 | ~
|
77 | 78 | ==
|
| 79 | + -- |
78 | 80 | ::
|
79 |
| -:: TODO: add pokes for accounts and wallets |
80 | 81 | ++ on-poke
|
81 | 82 | |= [=mark =vase]
|
82 | 83 | ^- (quip card _this)
|
83 |
| - |^ |
84 | 84 | ?> (team:title our.bowl src.bowl)
|
85 |
| - ?. ?=(%hodl-action mark) (on-poke:def mark vase) |
86 |
| - =/ act !<(action vase) |
87 |
| - =. state (poke-action act) |
88 |
| - :_ this |
89 |
| - ~[(fact:io hodl-update+!>(`update`[act]) ~[/updates])] |
90 |
| - :: |
91 |
| - ++ poke-action |
92 |
| - |= act=action |
93 |
| - ^- _state |
94 |
| - ?- -.act |
95 |
| - %add |
96 |
| - ?< (~(has by txns) id.act) |
97 |
| - =/ txn=txn |
98 |
| - :* id=id.act |
99 |
| - coin-id=coin-id.act |
100 |
| - date=date.act |
101 |
| - note=note.act |
102 |
| - amount=amount.act |
103 |
| - cost-basis=cost-basis.act |
104 |
| - type=type.act |
105 |
| - account-id=account-id.act |
106 |
| - == |
107 |
| - state(txns (~(put by txns) id.act txn)) |
108 |
| - :: |
109 |
| - %edit |
110 |
| - ?> (~(has by txns) id.act) |
111 |
| - =/ txn=txn |
112 |
| - :* id=id.act |
113 |
| - coin-id=coin-id.act |
114 |
| - date=date.act |
115 |
| - note=note.act |
116 |
| - amount=amount.act |
117 |
| - cost-basis=cost-basis.act |
118 |
| - type=type.act |
119 |
| - account-id=account-id.act |
120 |
| - == |
121 |
| - state(txns (~(put by txns) id.act txn)) :: TODO: should all fields be editable? probably not id |
122 |
| - :: |
123 |
| - %del |
124 |
| - ?> (~(has by txns) id.act) |
125 |
| - state(txns (~(del by txns) id.act)) |
| 85 | + =^ cards state |
| 86 | + ?+ mark (on-poke:def mark vase) |
| 87 | + %account-action (poke-account-action:do !<(action:a vase)) :: TODO do these action need to be namesspaced? |
| 88 | + %transaction-action (poke-transaction-action:do !<(action:t vase)) |
| 89 | + %wallet-action (poke-wallet-action:do !<(action:w vase)) |
126 | 90 | ==
|
127 |
| - -- |
| 91 | + [cards this] |
128 | 92 | ::
|
129 | 93 | ++ on-watch
|
130 | 94 | |= =path
|
131 | 95 | ^- (quip card _this)
|
132 | 96 | ?> (team:title our.bowl src.bowl)
|
133 | 97 | ?+ path (on-watch:def path)
|
134 |
| - [%updates ~] `this |
| 98 | + [%updates ~] `this |
| 99 | + :: TODO: should the updates be scoped to each model? |
| 100 | + :: ?: ?=([%updates ~] path) |
| 101 | + :: :_ this |
| 102 | + :: [%give %fact ~ %hodl-update !>(update)]~ |
| 103 | + :: (on-watch:def path) |
135 | 104 | ==
|
136 | 105 | ::
|
137 |
| -:: TODO: add scries for accounts and wallets |
138 | 106 | ++ on-peek
|
139 | 107 | |= =path
|
140 | 108 | ^- (unit (unit cage))
|
141 | 109 | ?> (team:title our.bowl src.bowl)
|
142 |
| - ?+ path (on-peek:def path) |
143 |
| - [%x %transactions *] |
144 |
| - ?+ t.t.path (on-peek:def path) |
145 |
| - [%all ~] |
146 |
| - :^ ~ ~ %hodl-update |
147 |
| - !> ^- update |
148 |
| - [%txns txns] |
149 |
| - == |
| 110 | + ?+ path (on-peek:def path) |
| 111 | + [%x %accounts @t ~] ``noun+!>((~(get by acts) i.t.t.path)) |
| 112 | + [%x %accounts ~] ``noun+!>(acts) |
| 113 | + [%x %transactions @t ~] ``noun+!>((~(get by txns) i.t.t.path)) |
| 114 | + [%x %transactions ~] ``noun+!>(txns) |
| 115 | + [%x %wallets @t ~] ``noun+!>((~(get by wlts) i.t.t.path)) |
| 116 | + [%x %wallets ~] ``noun+!>(wlts) |
150 | 117 | ==
|
151 | 118 | ::
|
152 | 119 | ++ on-leave on-leave:def
|
153 | 120 | ++ on-agent on-agent:def
|
154 | 121 | ++ on-arvo on-arvo:def
|
155 | 122 | ++ on-fail on-fail:def
|
156 | 123 | --
|
| 124 | +:: helper core |
| 125 | +|_ =bowl:gall |
| 126 | +++ poke-account-action |
| 127 | + |= act=action:a |
| 128 | + ^- _state |
| 129 | + ?- -.act |
| 130 | + %add |
| 131 | + ?< (~(has by acts) id.act) |
| 132 | + =/ =acct:a |
| 133 | + :* id=id.act |
| 134 | + wallet-id=wallet-id.act |
| 135 | + name=name.act |
| 136 | + note=note.act |
| 137 | + == |
| 138 | + state(acts (~(put by acts) id.act acct)) |
| 139 | + :: |
| 140 | + %edit |
| 141 | + ?> (~(has by acts) id.act) |
| 142 | + =/ =acct:a |
| 143 | + :* id=id.act :: TODO: should all fields be editable? probably not id |
| 144 | + wallet-id=wallet-id.act |
| 145 | + name=name.act |
| 146 | + note=note.act |
| 147 | + == |
| 148 | + state(acts (~(put by acts) id.act acct)) |
| 149 | + :: |
| 150 | + %del |
| 151 | + ?> (~(has by acts) id.act) |
| 152 | + state(acts (~(del by acts) id.act)) |
| 153 | + == |
| 154 | +:: |
| 155 | +++ poke-transaction-action |
| 156 | + |= act=action:t |
| 157 | + ^- _state |
| 158 | + ?- -.act |
| 159 | + %add |
| 160 | + ?< (~(has by txns) id.act) |
| 161 | + =/ =txn:t |
| 162 | + :* id=id.act |
| 163 | + coin-id=coin-id.act |
| 164 | + date=date.act |
| 165 | + note=note.act |
| 166 | + amount=amount.act |
| 167 | + cost-basis=cost-basis.act |
| 168 | + type=type.act |
| 169 | + account-id=account-id.act |
| 170 | + == |
| 171 | + state(txns (~(put by txns) id.act txn)) |
| 172 | + :: |
| 173 | + %edit |
| 174 | + ?> (~(has by txns) id.act) |
| 175 | + =/ =txn:t |
| 176 | + :* id=id.act :: TODO: should all fields be editable? probably not id |
| 177 | + coin-id=coin-id.act |
| 178 | + date=date.act |
| 179 | + note=note.act |
| 180 | + amount=amount.act |
| 181 | + cost-basis=cost-basis.act |
| 182 | + type=type.act |
| 183 | + account-id=account-id.act |
| 184 | + == |
| 185 | + state(txns (~(put by txns) id.act txn)) |
| 186 | + :: |
| 187 | + %del |
| 188 | + ?> (~(has by txns) id.act) |
| 189 | + state(txns (~(del by txns) id.act)) |
| 190 | + == |
| 191 | +:: |
| 192 | +++ poke-wallet-action |
| 193 | + |= act=action:w |
| 194 | + ^- _state |
| 195 | + ?- -.act |
| 196 | + %add |
| 197 | + ?< (~(has by wlts) id.act) |
| 198 | + =/ =wllt:w |
| 199 | + :* id=id.act |
| 200 | + name=name.act |
| 201 | + note=note.act |
| 202 | + == |
| 203 | + state(wlts (~(put by wlts) id.act wllt)) |
| 204 | + :: |
| 205 | + %edit |
| 206 | + ?> (~(has by wlts) id.act) |
| 207 | + =/ =wllt:w |
| 208 | + :* id=id.act :: TODO: should all fields be editable? probably not id |
| 209 | + name=name.act |
| 210 | + note=note.act |
| 211 | + == |
| 212 | + state(wlts (~(put by wlts) id.act wllt)) |
| 213 | + :: |
| 214 | + %del |
| 215 | + ?> (~(has by wlts) id.act) |
| 216 | + state(wlts (~(del by wlts) id.act)) |
| 217 | + == |
| 218 | +-- |
0 commit comments