mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-30 10:27:11 +03:00
naive: move json [en/de]code functions to common core
This commit is contained in:
parent
6cdc3a1cae
commit
93c2e3b0b5
@ -29,13 +29,13 @@
|
|||||||
+$ pend-tx [force=? =raw-tx:naive]
|
+$ pend-tx [force=? =raw-tx:naive]
|
||||||
::
|
::
|
||||||
++ from-json
|
++ from-json
|
||||||
|
=, dejs-soft:format
|
||||||
|%
|
|%
|
||||||
++ keys
|
++ keys
|
||||||
|= params=(map @t json)
|
|= params=(map @t json)
|
||||||
^- (unit [encrypt=@ auth=@ crypto-suite=@ breach=?])
|
^- (unit [encrypt=@ auth=@ crypto-suite=@ breach=?])
|
||||||
?~ data=(~(get by params) 'data') ~
|
?~ data=(~(get by params) 'data') ~
|
||||||
%. u.data
|
%. u.data
|
||||||
=, dejs-soft:format
|
|
||||||
%- ot
|
%- ot
|
||||||
:~ ['encrypt' so]
|
:~ ['encrypt' so]
|
||||||
['auth' so]
|
['auth' so]
|
||||||
@ -54,7 +54,6 @@
|
|||||||
?~ add.u.ans ~
|
?~ add.u.ans ~
|
||||||
(some [u.add.u.ans r.u.ans])
|
(some [u.add.u.ans r.u.ans])
|
||||||
%. u.data
|
%. u.data
|
||||||
=, dejs-soft:format
|
|
||||||
%- ot
|
%- ot
|
||||||
~[['address' (cu to-hex so)] ['reset' bo]]
|
~[['address' (cu to-hex so)] ['reset' bo]]
|
||||||
::
|
::
|
||||||
@ -67,9 +66,8 @@
|
|||||||
?~ add.u.ans ~
|
?~ add.u.ans ~
|
||||||
(some [ship.u.ans u.add.u.ans])
|
(some [ship.u.ans u.add.u.ans])
|
||||||
%. u.data
|
%. u.data
|
||||||
=, dejs-soft:format
|
|
||||||
%- ot
|
%- ot
|
||||||
:~ ['ship' (su ;~(pfix sig fed:ag))]
|
:~ ['ship' (su ;~(pfix ^sig fed:ag))]
|
||||||
['address' (cu to-hex so)]
|
['address' (cu to-hex so)]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
@ -79,7 +77,6 @@
|
|||||||
?~ data=(~(get by params) 'data') ~
|
?~ data=(~(get by params) 'data') ~
|
||||||
=; ans=(unit (unit @ux))
|
=; ans=(unit (unit @ux))
|
||||||
?~(ans ~ u.ans)
|
?~(ans ~ u.ans)
|
||||||
=, dejs-soft:format
|
|
||||||
%. u.data
|
%. u.data
|
||||||
(ot ['address' (cu to-hex so)]~)
|
(ot ['address' (cu to-hex so)]~)
|
||||||
::
|
::
|
||||||
@ -87,18 +84,16 @@
|
|||||||
|= params=(map @t json)
|
|= params=(map @t json)
|
||||||
^- (unit @p)
|
^- (unit @p)
|
||||||
?~ data=(~(get by params) 'data') ~
|
?~ data=(~(get by params) 'data') ~
|
||||||
=, dejs-soft:format
|
|
||||||
%. u.data
|
%. u.data
|
||||||
(ot ['ship' (su ;~(pfix sig fed:ag))]~)
|
(ot ['ship' (su ;~(pfix ^sig fed:ag))]~)
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
++ ship
|
++ ship
|
||||||
|= params=(map @t json)
|
|= params=(map @t json)
|
||||||
^- (unit @p)
|
^- (unit @p)
|
||||||
?~ data=(~(get by params) 'ship') ~
|
?~ data=(~(get by params) 'ship') ~
|
||||||
=, dejs-soft:format
|
|
||||||
%. u.data
|
%. u.data
|
||||||
(su ;~(pfix sig fed:ag))
|
(su ;~(pfix ^sig fed:ag))
|
||||||
::
|
::
|
||||||
++ address
|
++ address
|
||||||
|= params=(map @t json)
|
|= params=(map @t json)
|
||||||
@ -106,7 +101,6 @@
|
|||||||
?~ data=(~(get by params) 'address') ~
|
?~ data=(~(get by params) 'address') ~
|
||||||
=; ans=(unit (unit @ux))
|
=; ans=(unit (unit @ux))
|
||||||
?~(ans ~ u.ans)
|
?~(ans ~ u.ans)
|
||||||
=, dejs-soft:format
|
|
||||||
((cu to-hex so) u.data)
|
((cu to-hex so) u.data)
|
||||||
::
|
::
|
||||||
++ sig
|
++ sig
|
||||||
@ -116,17 +110,15 @@
|
|||||||
=; ans=(unit (unit @ux))
|
=; ans=(unit (unit @ux))
|
||||||
?~(ans ~ u.ans)
|
?~(ans ~ u.ans)
|
||||||
%. u.sig
|
%. u.sig
|
||||||
=, dejs-soft:format
|
|
||||||
(cu to-hex so)
|
(cu to-hex so)
|
||||||
::
|
::
|
||||||
++ from
|
++ from
|
||||||
|= params=(map @t json)
|
|= params=(map @t json)
|
||||||
^- (unit [@p proxy:naive])
|
^- (unit [@p proxy:naive])
|
||||||
?~ from=(~(get by params) 'from') ~
|
?~ from=(~(get by params) 'from') ~
|
||||||
=, dejs-soft:format
|
|
||||||
%. u.from
|
%. u.from
|
||||||
%- ot
|
%- ot
|
||||||
:~ ['ship' (su ;~(pfix sig fed:ag))]
|
:~ ['ship' (su ;~(pfix ^sig fed:ag))]
|
||||||
['proxy' (cu proxy:naive so)]
|
['proxy' (cu proxy:naive so)]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
@ -136,7 +128,6 @@
|
|||||||
?~ keccak=(~(get by params) 'keccak') ~
|
?~ keccak=(~(get by params) 'keccak') ~
|
||||||
=; ans=(unit (unit @ux))
|
=; ans=(unit (unit @ux))
|
||||||
?~(ans ~ u.ans)
|
?~(ans ~ u.ans)
|
||||||
=, dejs-soft:format
|
|
||||||
((cu to-hex so) u.keccak)
|
((cu to-hex so) u.keccak)
|
||||||
::
|
::
|
||||||
++ raw
|
++ raw
|
||||||
@ -147,21 +138,19 @@
|
|||||||
?~ ans ~
|
?~ ans ~
|
||||||
?~ u.ans ~
|
?~ u.ans ~
|
||||||
(some (as-octs:mimes:html u.u.ans))
|
(some (as-octs:mimes:html u.u.ans))
|
||||||
=, dejs-soft:format
|
|
||||||
((cu to-hex so) u.raw)
|
((cu to-hex so) u.raw)
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
++ to-json
|
++ to-json
|
||||||
|
=, enjs:format
|
||||||
|%
|
|%
|
||||||
++ pending
|
++ pending
|
||||||
|= pending=(list pend-tx)
|
|= pending=(list pend-tx)
|
||||||
^- json
|
^- json
|
||||||
=, enjs:format
|
|
||||||
:- %a
|
:- %a
|
||||||
%+ turn pending
|
%+ turn pending
|
||||||
|= pend-tx
|
|= pend-tx
|
||||||
^- json
|
^- json
|
||||||
=, enjs:format
|
|
||||||
%- pairs
|
%- pairs
|
||||||
:~ ['force' b+force]
|
:~ ['force' b+force]
|
||||||
::
|
::
|
||||||
@ -174,7 +163,6 @@
|
|||||||
++ tx
|
++ tx
|
||||||
|= =tx:naive
|
|= =tx:naive
|
||||||
^- json
|
^- json
|
||||||
=, enjs:format
|
|
||||||
|^
|
|^
|
||||||
%- pairs
|
%- pairs
|
||||||
:~ ['tx' (parse-tx +.tx)]
|
:~ ['tx' (parse-tx +.tx)]
|
||||||
@ -228,7 +216,6 @@
|
|||||||
++ point
|
++ point
|
||||||
|= =point:naive
|
|= =point:naive
|
||||||
^- json
|
^- json
|
||||||
=, enjs:format
|
|
||||||
%- pairs
|
%- pairs
|
||||||
:~ ['dominion' s+dominion.point]
|
:~ ['dominion' s+dominion.point]
|
||||||
::
|
::
|
||||||
@ -268,7 +255,6 @@
|
|||||||
++ ownership
|
++ ownership
|
||||||
|= [=address:naive =nonce:naive]
|
|= [=address:naive =nonce:naive]
|
||||||
^- json
|
^- json
|
||||||
=, enjs:format
|
|
||||||
%- pairs
|
%- pairs
|
||||||
:~ ['address' s+(crip "0x{((x-co:co 20) address)}")]
|
:~ ['address' s+(crip "0x{((x-co:co 20) address)}")]
|
||||||
['nonce' (numb nonce)]
|
['nonce' (numb nonce)]
|
||||||
@ -277,7 +263,6 @@
|
|||||||
++ tx-status
|
++ tx-status
|
||||||
|= =^tx-status
|
|= =^tx-status
|
||||||
^- json
|
^- json
|
||||||
=, enjs:format
|
|
||||||
%- pairs
|
%- pairs
|
||||||
:~ ['status' s+status.tx-status]
|
:~ ['status' s+status.tx-status]
|
||||||
::
|
::
|
||||||
|
Loading…
Reference in New Issue
Block a user