Documentation ¶
Index ¶
- type DefaultHandler
- func (DefaultHandler) AttachHandler(ctx context.Context, db *gorm.DB, preparationID string, wallet string) (*model.Preparation, error)
- func (DefaultHandler) DetachHandler(ctx context.Context, db *gorm.DB, preparationID string, wallet string) (*model.Preparation, error)
- func (DefaultHandler) ImportHandler(ctx context.Context, db *gorm.DB, lotusClient jsonrpc.RPCClient, ...) (*model.Wallet, error)
- func (DefaultHandler) ListAttachedHandler(ctx context.Context, db *gorm.DB, preparationID string) ([]model.Wallet, error)
- func (DefaultHandler) ListHandler(ctx context.Context, db *gorm.DB) ([]model.Wallet, error)
- func (DefaultHandler) RemoveHandler(ctx context.Context, db *gorm.DB, address string) error
- type Handler
- type ImportRequest
- type MockWallet
- func (m *MockWallet) AttachHandler(ctx context.Context, db *gorm.DB, preparation string, wallet string) (*model.Preparation, error)
- func (m *MockWallet) DetachHandler(ctx context.Context, db *gorm.DB, preparation string, wallet string) (*model.Preparation, error)
- func (m *MockWallet) ImportHandler(ctx context.Context, db *gorm.DB, lotusClient jsonrpc.RPCClient, ...) (*model.Wallet, error)
- func (m *MockWallet) ListAttachedHandler(ctx context.Context, db *gorm.DB, preparation string) ([]model.Wallet, error)
- func (m *MockWallet) ListHandler(ctx context.Context, db *gorm.DB) ([]model.Wallet, error)
- func (m *MockWallet) RemoveHandler(ctx context.Context, db *gorm.DB, address string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultHandler ¶ added in v0.4.0
type DefaultHandler struct{}
func (DefaultHandler) AttachHandler ¶ added in v0.4.0
func (DefaultHandler) AttachHandler( ctx context.Context, db *gorm.DB, preparationID string, wallet string, ) (*model.Preparation, error)
AttachHandler associates a wallet with a specific preparation based on given preparationID and wallet address or ID.
Parameters:
- ctx: The context for database transactions and other operations.
- db: A pointer to the gorm.DB instance representing the database connection.
- preparationID: The ID or name of the preparation to which the wallet will be attached.
- wallet: The address or ID of the wallet to be attached to the preparation.
Returns:
- A pointer to the updated Preparation instance.
- An error, if any occurred during the association operation.
func (DefaultHandler) DetachHandler ¶ added in v0.4.0
func (DefaultHandler) DetachHandler( ctx context.Context, db *gorm.DB, preparationID string, wallet string, ) (*model.Preparation, error)
DetachHandler removes the association of a wallet from a specific preparation based on the given preparationID and wallet address or ID.
Parameters:
- ctx: The context for database transactions and other operations.
- db: A pointer to the gorm.DB instance representing the database connection.
- preparationID: The ID or name of the preparation from which the wallet will be removed.
- wallet: The address or ID of the wallet to be removed from the preparation.
Returns:
- A pointer to the updated Preparation instance.
- An error, if any occurred during the removal operation.
func (DefaultHandler) ImportHandler ¶ added in v0.4.0
func (DefaultHandler) ImportHandler( ctx context.Context, db *gorm.DB, lotusClient jsonrpc.RPCClient, request ImportRequest, ) (*model.Wallet, error)
ImportHandler imports a wallet into the system using a given private key. It first verifies the private key's validity by generating its associated public address. It then checks for the existence of this address in the Lotus system using the provided RPC client. After confirming the actor ID from the Lotus system, it creates a new wallet record in the local database.
Parameters:
- ctx: The context for database transactions and other operations.
- db: A pointer to the gorm.DB instance representing the database connection.
- lotusClient: The RPC client used to interact with a Lotus node for actor lookup.
- request: The request containing the private key for the wallet import operation.
Returns:
- A pointer to the created Wallet model if successful.
- An error, if any occurred during the operation.
func (DefaultHandler) ListAttachedHandler ¶ added in v0.4.0
func (DefaultHandler) ListAttachedHandler( ctx context.Context, db *gorm.DB, preparationID string, ) ([]model.Wallet, error)
ListAttachedHandler fetches and returns a list of wallets associated with a given preparation, identified by either its ID or name.
The function looks for the preparation with the specified ID or name in the database. If found, it retrieves all wallets associated with that preparation. If no such preparation is found, an error is returned.
Parameters:
- ctx: The context in which the handler function is executed, used for controlling cancellation.
- db: A pointer to a gorm.DB object, which provides database access.
- preparationID: The ID or name of the preparation whose attached wallets need to be fetched.
Returns:
- A slice of model.Wallet objects that are attached to the specified preparation.
- An error if any issues arise during the process or if the preparation is not found, otherwise nil.
func (DefaultHandler) ListHandler ¶ added in v0.4.0
ListHandler retrieves a list of all the wallets stored in the database.
Parameters:
- ctx: The context for database transactions and other operations.
- db: A pointer to the gorm.DB instance representing the database connection.
Returns:
- A slice containing all Wallet models from the database.
- An error, if any occurred during the database fetch operation.
func (DefaultHandler) RemoveHandler ¶ added in v0.4.0
RemoveHandler deletes a wallet from the database based on its address or ID.
Parameters:
- ctx: The context for database transactions and other operations.
- db: A pointer to the gorm.DB instance representing the database connection.
- address: The address or ID of the wallet to be deleted.
Returns:
- An error, if any occurred during the database deletion operation.
type Handler ¶ added in v0.4.0
type Handler interface { AttachHandler( ctx context.Context, db *gorm.DB, preparation string, wallet string, ) (*model.Preparation, error) DetachHandler( ctx context.Context, db *gorm.DB, preparation string, wallet string, ) (*model.Preparation, error) ImportHandler( ctx context.Context, db *gorm.DB, lotusClient jsonrpc.RPCClient, request ImportRequest, ) (*model.Wallet, error) ListHandler( ctx context.Context, db *gorm.DB, ) ([]model.Wallet, error) ListAttachedHandler( ctx context.Context, db *gorm.DB, preparation string, ) ([]model.Wallet, error) RemoveHandler( ctx context.Context, db *gorm.DB, address string, ) error }
var Default Handler = &DefaultHandler{}
type ImportRequest ¶
type ImportRequest struct {
PrivateKey string `json:"privateKey"` // This is the exported private key from lotus wallet export
}
type MockWallet ¶ added in v0.5.0
func (*MockWallet) AttachHandler ¶ added in v0.5.0
func (m *MockWallet) AttachHandler(ctx context.Context, db *gorm.DB, preparation string, wallet string) (*model.Preparation, error)
func (*MockWallet) DetachHandler ¶ added in v0.5.0
func (m *MockWallet) DetachHandler(ctx context.Context, db *gorm.DB, preparation string, wallet string) (*model.Preparation, error)
func (*MockWallet) ImportHandler ¶ added in v0.5.0
func (m *MockWallet) ImportHandler(ctx context.Context, db *gorm.DB, lotusClient jsonrpc.RPCClient, request ImportRequest) (*model.Wallet, error)