@@ -9,15 +9,18 @@ import (
99 actiontypes "github.com/LumeraProtocol/lumera/x/action/v1/types"
1010
1111 sntypes "github.com/LumeraProtocol/lumera/x/supernode/v1/types"
12+ authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
1213 lumeraclient "github.com/LumeraProtocol/supernode/pkg/lumera"
1314 "github.com/cosmos/cosmos-sdk/crypto/keyring"
1415 "github.com/golang/protobuf/proto"
1516)
1617
1718//go:generate mockery --name=Client --output=testutil/mocks --outpkg=mocks --filename=lumera_mock.go
1819type Client interface {
20+ AccountInfoByAddress (ctx context.Context , addr string ) (* authtypes.QueryAccountInfoResponse , error )
1921 GetAction (ctx context.Context , actionID string ) (Action , error )
2022 GetSupernodes (ctx context.Context , height int64 ) ([]Supernode , error )
23+ GetSupernodeBySupernodeAddress (ctx context.Context , address string ) (* sntypes.SuperNode , error )
2124 DecodeCascadeMetadata (ctx context.Context , action Action ) (actiontypes.CascadeMetadata , error )
2225 VerifySignature (ctx context.Context , accountAddr string , data []byte , signature []byte ) error
2326}
@@ -62,6 +65,37 @@ func NewAdapter(ctx context.Context, config ConfigParams, logger log.Logger) (Cl
6265 }, nil
6366}
6467
68+ func (a * Adapter ) GetSupernodeBySupernodeAddress (ctx context.Context , address string ) (* sntypes.SuperNode , error ) {
69+ a .logger .Debug (ctx , "Getting supernode by address" , "address" , address )
70+ resp , err := a .client .SuperNode ().GetSupernodeBySupernodeAddress (ctx , address )
71+ if err != nil {
72+ a .logger .Error (ctx , "Failed to get supernode" , "address" , address , "error" , err )
73+ return nil , fmt .Errorf ("failed to get supernode: %w" , err )
74+ }
75+ if resp == nil {
76+ a .logger .Error (ctx , "Received nil response for supernode" , "address" , address )
77+ return nil , fmt .Errorf ("received nil response for supernode %s" , address )
78+ }
79+ a .logger .Debug (ctx , "Successfully retrieved supernode" , "address" , address )
80+ return resp , nil
81+ }
82+
83+ func (a * Adapter ) AccountInfoByAddress (ctx context.Context , addr string ) (* authtypes.QueryAccountInfoResponse , error ) {
84+ a .logger .Debug (ctx , "Getting account info by address" , "address" , addr )
85+ resp , err := a .client .Auth ().AccountInfoByAddress (ctx , addr )
86+ if err != nil {
87+ a .logger .Error (ctx , "Failed to get account info" , "address" , addr , "error" , err )
88+ return nil , fmt .Errorf ("failed to get account info: %w" , err )
89+ }
90+ if resp == nil {
91+ a .logger .Error (ctx , "Received nil response for account info" , "address" , addr )
92+ return nil , fmt .Errorf ("received nil response for account info %s" , addr )
93+ }
94+ a .logger .Debug (ctx , "Successfully retrieved account info" , "address" , addr )
95+
96+ return resp , nil
97+ }
98+
6599func (a * Adapter ) GetAction (ctx context.Context , actionID string ) (Action , error ) {
66100 a .logger .Debug (ctx , "Getting action from blockchain" , "actionID" , actionID )
67101
0 commit comments