onsonr/sonr

Implement Abstracted `ConnectedWallet` operations to DWN API

prnk28 opened this issue · 2 comments

Description

All ConnectedWallet methods are abstracted over API Methods. DWN Service Worker is responsible for sending Server Side Events which are interpreted by HTMX.

New Methods

  • getAuthInfo()
  • estimateFee()
  • broadcastTx()
  • pollTx()
  • broadcastTxSync()
  • signArbitrary()
  • signAndBroadcastTx()

Associated Files

These files will be modified by this task.

References

Related Issues

Tech Documents

Use these documents to help you complete the task.

Golang SSE Emitter

// NewSSE creates a new sse manager with the specified worker pool size.
func (h *HTMX) NewSSE(workerPoolSize int) error {
	if sseManager != nil {
		return errors.New("sse manager already exists")
	}

	sseManager = sse.NewManager(workerPoolSize)
	return nil
}

// SSEHandler handles the server-sent events. this is a shortcut and is not the preferred way to handle sse.
func (h *HTMX) SSEHandler(w http.ResponseWriter, r *http.Request, cl sse.Listener) {
	if sseManager == nil {
		sseManager = sse.NewManager(DefaultSSEWorkerPoolSize)
	}

	sseManager.Handle(w, r, cl)
}

// SSESend sends a message to all connected clients.
func (h *HTMX) SSESend(message sse.Envelope) {
	if sseManager == nil {
		sseManager = sse.NewManager(DefaultSSEWorkerPoolSize)
	}

	sseManager.Send(message)
}
  • Wallet Interface spawned by Controller on as needed basis
  • proto.Actor spawned for signing operations using GetSignFunc()
  • controller/accstd and controller/wallet for Smart Account implementation