Documentation ¶
Index ¶
- Constants
- Variables
- func DumpKey(key *secp256k1.PrivKey) string
- func GenReadablesTicket(ctx context.Context, session Session, acp *ACPClient, ids []string) (string, error)
- func NewACPQueryClient(addr string) (types.QueryClient, error)
- func NewActor() (string, *secp256k1.PrivKey)
- func NewPromise[T any](txHash string) (Promise[T], Fulfiller[T])
- type ACPClient
- func (c *ACPClient) TxCheckAccess(ctx context.Context, session Session, msg *types.MsgCheckAccess) (*Promise[string], error)
- func (c *ACPClient) TxCreatePolicy(ctx context.Context, session Session, msg *types.MsgCreatePolicy) (*Promise[string], error)
- func (c *ACPClient) TxDeleteRelationship(ctx context.Context, session Session, msg *types.MsgDeleteRelationship) (*Promise[Executed], error)
- func (c *ACPClient) TxRegisterObject(ctx context.Context, session Session, msg *types.MsgRegisterObject) (*Promise[Executed], error)
- func (c *ACPClient) TxSetRelationship(ctx context.Context, session Session, msg *types.MsgSetRelationship) (*Promise[Executed], error)
- type Executed
- type Fulfiller
- type Note
- type NoteCommands
- type NoteQuerier
- type PermissionManager
- func (m *PermissionManager) RegisterNote(ctx context.Context, session Session, note *Note) (*Promise[Executed], error)
- func (m *PermissionManager) ShareNote(ctx context.Context, session Session, noteId string, actorId string) (*Promise[Executed], error)
- func (m *PermissionManager) UnshareNote(ctx context.Context, session Session, noteId string, actorId string) (*Promise[Executed], error)
- type PipeChan
- type Promise
- type Repository
- type SQLite
- type Session
- type TxError
- type TxListener
Constants ¶
const ChainID string = "sourcehub-dev"
const PolicyId string = "73b18a8dab25e613f89a2e65b6cc59502b646d24dc1bcdc049d13c3d358e750b"
const TokenName string = "stake"
Variables ¶
var ErrPromiseCanceled = errors.New("promise canceled")
var RootCmd = cobra.Command{}
Functions ¶
func GenReadablesTicket ¶
func NewACPQueryClient ¶
func NewACPQueryClient(addr string) (types.QueryClient, error)
Types ¶
type ACPClient ¶
type ACPClient struct {
// contains filtered or unexported fields
}
var ACPCl *ACPClient
func NewACPClient ¶
func NewACPClient(nodeGRPCAddr string, listener *TxListener) (ACPClient, error)
func (*ACPClient) TxCheckAccess ¶
func (c *ACPClient) TxCheckAccess(ctx context.Context, session Session, msg *types.MsgCheckAccess) (*Promise[string], error)
TxCheckAccess builds builds a Tx and Broadcats a MsgCheckAccess Return a Promise containing the Decision ID
func (*ACPClient) TxCreatePolicy ¶
func (*ACPClient) TxDeleteRelationship ¶
func (*ACPClient) TxRegisterObject ¶
type Fulfiller ¶
type Fulfiller[T any] struct { // contains filtered or unexported fields }
Fulfiller fullfils a Promise
func NewFulfiller ¶
func (*Fulfiller[T]) Cancel ¶
func (f *Fulfiller[T]) Cancel()
Cancel cancels a promise, meaning it wont produce an error
func (*Fulfiller[T]) Produce ¶
func (f *Fulfiller[T]) Produce(value T)
Produce produces the result value, sends it to the correct channel and marks it as fullfilled
func (*Fulfiller[T]) ProduceErr ¶
ProduceErr produces an error as the Promise result and fulfills it
type NoteCommands ¶
type NoteCommands struct {
// contains filtered or unexported fields
}
var NoteCmds *NoteCommands
func NewNoteCommands ¶
func NewNoteCommands(repo Repository, manager *PermissionManager) NoteCommands
type NoteQuerier ¶
type NoteQuerier struct {
// contains filtered or unexported fields
}
var Querier *NoteQuerier
func NewNoteQuerier ¶
func NewNoteQuerier(acp *ACPClient, repo Repository, querier types.QueryClient) NoteQuerier
func (*NoteQuerier) FetchLocalNodes ¶
func (*NoteQuerier) FetchReadableNotes ¶
Note: this assumes the need for internet, which is lame Local users should be able to check their own notes and sync the remaining notes as it goes. Right now that's kinda lame to do
func (*NoteQuerier) ListReadableNotesID ¶
ListAccessibleNotes lists all notes the user has access to (as a reader or editor)
This is kind of an awkward step because we need to query the ACP module to figure this out.
In Defra there is a challenge because doc syncing is an app level concern. This creates a chicken and egg problem, because the app can't rely on defra to know which docs it has access to but defra can't sync the doc because it doesn't know which docs were shared. Ultimately this info is in the Relation graph, as such we could fetch this directly from it.
Another alternative would require dApp devs to implement ad hoc and custom notification systems between the peers. This would lead to potentially more work for dApp devs and it's something the Relation Graph could solve
type PermissionManager ¶
type PermissionManager struct {
// contains filtered or unexported fields
}
var PermMan *PermissionManager
func NewPermissionManager ¶
func NewPermissionManager(acp *ACPClient) *PermissionManager
func (*PermissionManager) RegisterNote ¶
func (m *PermissionManager) RegisterNote(ctx context.Context, session Session, note *Note) (*Promise[Executed], error)
RegisterNote registers the session user as the owner of the note object
type PipeChan ¶
func (*PipeChan[T, U]) ReceiveEnd ¶
func (c *PipeChan[T, U]) ReceiveEnd() <-chan U
type Promise ¶
type Promise[T any] struct { // contains filtered or unexported fields }
Promise represents a value which will be produced The result will be either an error or a result. Callers should select between either one of the channels.
func (*Promise[T]) GetResult ¶
GetResult returns the stored result from a Promise. If Promise hasn't been fulfilled return err
func (*Promise[T]) Result ¶
func (p *Promise[T]) Result() <-chan T
Result returns a channel which produces the result
func (*Promise[T]) Terminated ¶
type Repository ¶
type SQLite ¶
type SQLite struct {
// contains filtered or unexported fields
}
func (*SQLite) ListLocalNotes ¶
type Session ¶
type Session struct { // SourceHub address of Authenticated user Actor string PrivKey cryptotypes.PrivKey }
func NewSession ¶
type TxListener ¶
type TxListener struct {
// contains filtered or unexported fields
}
TxListener connects to a CometBFT node RPC serv and subscribes as a liestener to Txs Multiplexes Txs to different listeners - only one listener per tx
func NewTxListener ¶
func NewTxListener(addr string) (*TxListener, error)
NewTxListener creates a WebSocket client for CometBFT rpc
func NewTxListenerFromClient ¶
func NewTxListenerFromClient(client *rpcclient.WSClient) (*TxListener, error)
func (*TxListener) DefaultChan ¶
func (l *TxListener) DefaultChan() <-chan rpctypes.ResultEvent
func (*TxListener) ErrChan ¶
func (l *TxListener) ErrChan() <-chan error
func (*TxListener) Listen ¶
func (l *TxListener) Listen(ctx context.Context) error
Listen runs the listener in a thread and returns a default reponse channel which returns responses to unregistered txs If ctx is terminated, the listener stops and cleans up
func (*TxListener) Subscribe ¶
func (l *TxListener) Subscribe(txHash string) Promise[rpctypes.ResultEvent]
Subscribe configures the Listener to return the RPC Response when the response for txHash is received.
Note: The listener does not logs responses. If the response for txHash is received before being registered the response will be sent on the default channel.