yichus 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli.js +17 -3192
- package/dist/cli.js.map +1 -1
- package/dist/main.js +3762 -0
- package/dist/main.js.map +1 -0
- package/dist/studio-page/system-map-record.js +3 -3
- package/dist/studio-page/system-map.js +41 -9
- package/dist/studio-page/what-happens-record.js +11 -4
- package/dist/studio-page/what-happens.js +48 -29
- package/dist/studio-reference/balance-listed-laws.bosatsu +29 -0
- package/dist/studio-reference/balance.bosatsu +7 -0
- package/dist/studio-reference/calculator.md +20 -0
- package/dist/studio-reference/consent-laws.bosatsu +37 -0
- package/dist/studio-reference/consent.bosatsu +15 -0
- package/dist/studio-reference/deploy-platforms.md +6 -6
- package/dist/studio-reference/laws.md +62 -0
- package/dist/studio-reference/porting.md +3 -1
- package/dist/studio-reference/protocol-cases.md +11 -0
- package/dist/studio-reference/{protocol-specification.txt → protocol-specification.md} +16 -18
- package/dist/studio-reference/refund-desk-one-round.bosatsu +21 -18
- package/dist/studio-reference/refund-desk.bosatsu +21 -18
- package/dist/studio-reference/render.yaml +42 -0
- package/dist/studio-reference/server.mjs +33 -0
- package/dist/studio-reference/store.mjs +16 -0
- package/dist/studio-reference/the-page.md +34 -11
- package/dist/studio-reference/withdrawal.bosatsu +11 -15
- package/package.json +2 -2
|
@@ -27,7 +27,7 @@ from Yichus/Service import (
|
|
|
27
27
|
)
|
|
28
28
|
from Yichus/Transaction import (
|
|
29
29
|
Scope, TxTable, Txn, Outcome,
|
|
30
|
-
|
|
30
|
+
stored_table, tx_pure, tx_bind, tx_abort, tx_read, tx_write, tx_insert,
|
|
31
31
|
tx_database_time_millis, transaction
|
|
32
32
|
)
|
|
33
33
|
|
|
@@ -159,11 +159,9 @@ access_rules = AccessSpec([
|
|
|
159
159
|
AccessRule("withdrawal_receipts", OwnerScoped),
|
|
160
160
|
])
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
tx_table(scope, "accounts")
|
|
162
|
+
accounts_table: TxTable[s, Account] = stored_table("accounts")
|
|
164
163
|
|
|
165
|
-
|
|
166
|
-
tx_table(scope, "withdrawal_receipts")
|
|
164
|
+
receipts_table: TxTable[s, Receipt] = stored_table("withdrawal_receipts")
|
|
167
165
|
|
|
168
166
|
def account_rows(db: Db) -> Table[Account]:
|
|
169
167
|
table(db, "accounts")
|
|
@@ -178,12 +176,11 @@ def receipt_rows(db: Db) -> Table[Receipt]:
|
|
|
178
176
|
# ---------------------------------------------------------------------------
|
|
179
177
|
|
|
180
178
|
def move_balance[s](
|
|
181
|
-
scope: Scope[s],
|
|
182
179
|
principal: Principal,
|
|
183
180
|
delta: Int
|
|
184
181
|
) -> Txn[s, LedgerError, Movement]:
|
|
185
182
|
Principal(uid, _) = principal
|
|
186
|
-
row <- tx_bind(tx_read(accounts_table
|
|
183
|
+
row <- tx_bind(tx_read(accounts_table, uid))
|
|
187
184
|
match row:
|
|
188
185
|
case None: tx_abort(UnknownAccount(uid))
|
|
189
186
|
case Some(Account(id, owner, balance)):
|
|
@@ -191,7 +188,7 @@ def move_balance[s](
|
|
|
191
188
|
if int_lt(next, 0):
|
|
192
189
|
tx_abort(InsufficientFunds(balance, sub(0, delta)))
|
|
193
190
|
else:
|
|
194
|
-
_ <- tx_bind(tx_write(accounts_table
|
|
191
|
+
_ <- tx_bind(tx_write(accounts_table, uid, Account(id, owner, next)))
|
|
195
192
|
tx_pure(Movement(balance, next))
|
|
196
193
|
|
|
197
194
|
# ---------------------------------------------------------------------------
|
|
@@ -207,7 +204,7 @@ def withdraw_plan[s](
|
|
|
207
204
|
case Some(error): tx_abort(error)
|
|
208
205
|
case None:
|
|
209
206
|
key = owner_key(principal, command_local_key(input))
|
|
210
|
-
previous <- tx_bind(tx_read(receipts_table
|
|
207
|
+
previous <- tx_bind(tx_read(receipts_table, key))
|
|
211
208
|
match previous:
|
|
212
209
|
case Some(receipt): tx_pure(receipt)
|
|
213
210
|
case None:
|
|
@@ -215,17 +212,16 @@ def withdraw_plan[s](
|
|
|
215
212
|
if int_lt(now, 0): tx_abort(InvalidDatabaseTime(now))
|
|
216
213
|
else:
|
|
217
214
|
WithdrawInput(_, amount) = input
|
|
218
|
-
moved <- tx_bind(move_balance(
|
|
215
|
+
moved <- tx_bind(move_balance(principal, sub(0, amount)))
|
|
219
216
|
Movement(_, after) = moved
|
|
220
217
|
receipt = Receipt(input, after, now)
|
|
221
|
-
_ <- tx_bind(tx_insert(receipts_table
|
|
218
|
+
_ <- tx_bind(tx_insert(receipts_table, key, receipt))
|
|
222
219
|
# The receipt filed in the ledger and the receipt in the
|
|
223
220
|
# response are one value, so the customer's copy and the
|
|
224
221
|
# bank's copy cannot say different things.
|
|
225
222
|
tx_pure(receipt)
|
|
226
223
|
|
|
227
224
|
def deposit_plan[s](
|
|
228
|
-
scope: Scope[s],
|
|
229
225
|
principal: Principal,
|
|
230
226
|
input: DepositInput
|
|
231
227
|
) -> Txn[s, LedgerError, Movement]:
|
|
@@ -233,7 +229,7 @@ def deposit_plan[s](
|
|
|
233
229
|
case Some(error): tx_abort(error)
|
|
234
230
|
case None:
|
|
235
231
|
DepositInput(_, amount) = input
|
|
236
|
-
move_balance(
|
|
232
|
+
move_balance(principal, amount)
|
|
237
233
|
|
|
238
234
|
# ---------------------------------------------------------------------------
|
|
239
235
|
# Handlers. The engine injects Db and Principal; nothing here
|
|
@@ -253,8 +249,8 @@ def deposit(
|
|
|
253
249
|
principal: Principal,
|
|
254
250
|
input: DepositInput
|
|
255
251
|
) -> IO[Outcome[LedgerError, Movement]]:
|
|
256
|
-
|
|
257
|
-
deposit_plan(
|
|
252
|
+
_ <- transaction(db)
|
|
253
|
+
deposit_plan(principal, input)
|
|
258
254
|
|
|
259
255
|
def withdrawal_status(
|
|
260
256
|
db: Db,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yichus",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Local Bosatsu compilation, Yichus analysis, and generated apps using the WebMCP engine",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://yich.us",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"zod": "^4.3.6",
|
|
22
22
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
23
|
-
"@yichus/api-mcp": "0.1.
|
|
23
|
+
"@yichus/api-mcp": "0.1.4"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^22.0.0",
|