roller-rpc: add %get-remaining-quota

This commit is contained in:
yosoyubik 2021-11-22 14:02:31 +01:00
parent 28cc660998
commit 144065c4fc
3 changed files with 33 additions and 9 deletions

View File

@ -151,12 +151,14 @@
?: ?=(l2-tx method)
(process-rpc id +.params method over-quota:scry)
?+ method [~ ~(method error:json-rpc id)]
%cancel-transaction (cancel-tx id +.params)
%when-next-batch `(next-batch id +.params next-batch:scry)
%spawns-remaining `(spawns-remaining id +.params unspawned:scry)
%get-remaining-quota `(quota-remaining id +.params ship-quota:scry)
%get-point `(get-point id +.params point:scry)
%get-ships `(get-ships id +.params ships:scry)
%cancel-transaction (cancel-tx id +.params)
%get-spawned `(get-spawned id +.params spawned:scry)
%get-unspawned `(get-spawned id +.params unspawned:scry)
%spawns-remaining `(spawns-remaining id +.params unspawned:scry)
%get-sponsored-points `(sponsored-points id +.params sponsored:scry)
%get-owned-points `(get-ships id +.params owned:scry)
%get-transferring-for `(get-ships id +.params transfers:scry)
@ -168,18 +170,13 @@
%get-pending-by-address `(addr:pending id +.params addr:pending:scry)
%get-pending-tx `(hash:pending id +.params hash:pending:scry)
%get-transaction-status `(status id +.params tx-status:scry)
%when-next-batch `(next-batch id +.params next-batch:scry)
%get-predicted-state `(get-naive id +.params predicted:scry)
%get-nonce `(nonce id +.params nonce:scry)
%get-history `(history id +.params addr:history:scry)
%get-roller-config `(get-config id +.params config:scry)
%prepare-for-signing `(hash-transaction id +.params chain:scry | &)
%get-unsigned-tx `(hash-transaction id +.params chain:scry & |)
%get-predicted-state `(get-naive id +.params predicted:scry)
%prepare-for-signing `(hash-transaction id +.params chain:scry | &)
%hash-raw-transaction `(hash-raw-transaction id +.params)
:: TODO: deprecated, remove (used together with personal_sign)
::
%hash-transaction ::`(hash-transaction id +.params chain:scry | &)
`(hash-transaction id +.params chain:scry & |)
==
--
::
@ -356,6 +353,13 @@
(~(scry agentio bowl) %roller /over-quota/(scot %p ship)/atom)
==
::
++ ship-quota
|= =ship
.^ @ud
%gx
(~(scry agentio bowl) %roller /ship-quota/(scot %p ship)/atom)
==
::
++ ready
.^ ?
%gx

View File

@ -279,6 +279,7 @@
[%x %quota ~] ``atom+!>(quota)
[%x %slice ~] ``atom+!>(slice)
[%x %over-quota @ ~] (over-quota i.t.t.path)
[%x %ship-quota @ ~] (ship-quota i.t.t.path)
[%x %ready ~] ``atom+!>(?=(^ points.pre))
==
::
@ -451,6 +452,16 @@
=/ [exceeded=? *] (quota-exceeded u.who)
``atom+!>(exceeded)
::
++ ship-quota
|= wat=@t
?~ who=(slaw %p wat) [~ ~]
=/ [exceeded=? next-quota=@ud] (quota-exceeded u.who)
:+ ~ ~
:- %atom
!> ^- @ud
?: exceeded 0
(sub quota.state (dec next-quota))
::
--
::
++ on-arvo

View File

@ -680,4 +680,13 @@
?. =((lent ~(tap by params)) 0)
~(params error:json-rpc id)
[%result id (azimuth-config:to-json azimuth-config)]
::
++ quota-remaining
|= [id=@t params=(map @t json) quota-left=$-(@p @ud)]
^- response:rpc
?. =((lent ~(tap by params)) 1)
~(params error:json-rpc id)
?~ ship=(ship:from-json params)
~(params error:json-rpc id)
[%result id (numb:enjs:format (quota-left u.ship))]
--