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.
@@ -27,7 +27,7 @@ from Yichus/Service import (
27
27
  )
28
28
  from Yichus/Transaction import (
29
29
  Scope, TxTable, Txn, Outcome,
30
- tx_table, tx_pure, tx_bind, tx_abort, tx_read, tx_write, tx_insert,
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
- def accounts_table[s](scope: Scope[s]) -> TxTable[s, Account]:
163
- tx_table(scope, "accounts")
162
+ accounts_table: TxTable[s, Account] = stored_table("accounts")
164
163
 
165
- def receipts_table[s](scope: Scope[s]) -> TxTable[s, Receipt]:
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(scope), uid))
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(scope), uid, Account(id, owner, next)))
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(scope), key))
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(scope, principal, sub(0, amount)))
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(scope), key, receipt))
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(scope, principal, amount)
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
- scope <- transaction(db)
257
- deposit_plan(scope, principal, input)
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.0",
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.2"
23
+ "@yichus/api-mcp": "0.1.4"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^22.0.0",