The LedgerConnection, EnclaveConnection and Erdstall interfaces currently mix up read-only operations (state reads and event subscriptions) and write operations (sending of transactions). This is problematic because a read-only user like a marketplace only needs the read parts. Also, the implementations need signers, which a read-only actor doesn't have and shouldn't need to provide.
So we split up the interfaces and call the read-only part Client/Reader and the extended write part Session/Writer.
Interface Erdstall from erdstall.ts should become ErdstallSession. It extends ErdstallClient, which only extends the read-only interfaces. The Enclave and Ledger connections are split into Reader and Writer parts.
Full interface extension tree
The following tree shows how interfaces extend (embed) each other, and mentions some methods explicitly.
ErdstallSession
ErdstallClient
LedgerReader
ErdstallWatcher (I'd prefer to rename to LedgerWatcher so that prefix Erdstall stands for combined stuff. Same for LedgerEvent etc.)
erdstall(): Address
EnclaveReader
EnclaveWatcher
getAccount
LedgerWriter
Depositor
Withdrawer
EnclaveWriter
Onboarder (new interface, contains method onboard)
Transactor
Minter
Exiter
Leaver
I'd also add an interface Connector that has the two methods connect and disconnect and extend it in interfaces that need it.
I'd move method subscribe into the watcher interface because on, once, off go together with subscribe, if I understand it correctly.
Implementations
The implementations also need to be split up, so that we can have a read-only Client that implements the ErdstallClient interface and a writing, user-bound ErdstallSession that implements the Session interface.
The
LedgerConnection
,EnclaveConnection
andErdstall
interfaces currently mix up read-only operations (state reads and event subscriptions) and write operations (sending of transactions). This is problematic because a read-only user like a marketplace only needs the read parts. Also, the implementations need signers, which a read-only actor doesn't have and shouldn't need to provide.So we split up the interfaces and call the read-only part
Client
/Reader
and the extended write partSession
/Writer
. InterfaceErdstall
fromerdstall.ts
should becomeErdstallSession
. It extendsErdstallClient
, which only extends the read-only interfaces. TheEnclave
andLedger
connections are split intoReader
andWriter
parts.Full interface extension tree
The following tree shows how interfaces extend (embed) each other, and mentions some methods explicitly.
ErdstallSession
ErdstallClient
LedgerReader
ErdstallWatcher
(I'd prefer to rename toLedgerWatcher
so that prefixErdstall
stands for combined stuff. Same forLedgerEvent
etc.)erdstall(): Address
EnclaveReader
EnclaveWatcher
getAccount
LedgerWriter
Depositor
Withdrawer
EnclaveWriter
Onboarder
(new interface, contains methodonboard
)Transactor
Minter
Exiter
Leaver
I'd also add an interface
Connector
that has the two methodsconnect
anddisconnect
and extend it in interfaces that need it.I'd move method
subscribe
into thewatcher
interface becauseon, once, off
go together withsubscribe
, if I understand it correctly.Implementations
The implementations also need to be split up, so that we can have a read-only
Client
that implements theErdstallClient
interface and a writing, user-boundErdstallSession
that implements theSession
interface.