Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy SCW validation requests to our MLS service #407

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions pkg/authn/authn.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/identity/api/v1/identity_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
mlsstore "github.com/xmtp/xmtp-node-go/pkg/mls/store"
"github.com/xmtp/xmtp-node-go/pkg/mlsvalidate"
api "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1"
identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -97,3 +98,7 @@ func (s *Service) GetInboxIds(ctx context.Context, req *api.GetInboxIdsRequest)
*/
return s.store.GetInboxIds(ctx, req)
}

func (s *Service) VerifySmartContractWalletSignatures(ctx context.Context, req *identity.VerifySmartContractWalletSignaturesRequest) (*identity.VerifySmartContractWalletSignaturesResponse, error) {
return s.validationService.VerifySmartContractWalletSignatures(ctx, req)
}
6 changes: 6 additions & 0 deletions pkg/identity/api/v1/identity_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ func (m *mockedMLSValidationService) ValidateInboxIdKeyPackages(ctx context.Cont
return nil, nil
}

func (m *mockedMLSValidationService) VerifySmartContractWalletSignatures(ctx context.Context, req *identity.VerifySmartContractWalletSignaturesRequest) (*identity.VerifySmartContractWalletSignaturesResponse, error) {
args := m.Called(ctx, req)

return args.Get(0).(*identity.VerifySmartContractWalletSignaturesResponse), args.Error(1)
}

func newMockedValidationService() *mockedMLSValidationService {
return new(mockedMLSValidationService)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/mlsvalidate/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type MLSValidationService interface {
ValidateV3KeyPackages(ctx context.Context, keyPackages [][]byte) ([]IdentityValidationResult, error)
ValidateGroupMessages(ctx context.Context, groupMessages []*mlsv1.GroupMessageInput) ([]GroupMessageValidationResult, error)
GetAssociationState(ctx context.Context, oldUpdates []*associations.IdentityUpdate, newUpdates []*associations.IdentityUpdate) (*AssociationStateResult, error)
VerifySmartContractWalletSignatures(ctx context.Context, req *identity.VerifySmartContractWalletSignaturesRequest) (*identity.VerifySmartContractWalletSignaturesResponse, error)
}

type IdentityStore interface {
Expand Down Expand Up @@ -178,3 +179,7 @@ func makeValidateGroupMessagesRequest(groupMessages []*mlsv1.GroupMessageInput)
GroupMessages: groupMessageRequests,
}
}

func (s *MLSValidationServiceImpl) VerifySmartContractWalletSignatures(ctx context.Context, req *identity.VerifySmartContractWalletSignaturesRequest) (*identity.VerifySmartContractWalletSignaturesResponse, error) {
return s.grpcClient.VerifySmartContractWalletSignatures(ctx, req)
}
7 changes: 7 additions & 0 deletions pkg/mlsvalidate/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
identity "github.com/xmtp/xmtp-node-go/pkg/proto/identity/api/v1"
svc "github.com/xmtp/xmtp-node-go/pkg/proto/mls_validation/v1"
"google.golang.org/grpc"
)
Expand Down Expand Up @@ -42,6 +43,12 @@ func (m *MockedGRPCService) ValidateInboxIds(ctx context.Context, req *svc.Valid
return args.Get(0).(*svc.ValidateInboxIdsResponse), args.Error(1)
}

func (m *MockedGRPCService) VerifySmartContractWalletSignatures(ctx context.Context, req *identity.VerifySmartContractWalletSignaturesRequest, opts ...grpc.CallOption) (*identity.VerifySmartContractWalletSignaturesResponse, error) {
args := m.Called(ctx, req)

return args.Get(0).(*identity.VerifySmartContractWalletSignaturesResponse), args.Error(1)
}

func getMockedService() (*MockedGRPCService, MLSValidationService) {
mockService := new(MockedGRPCService)
service := &MLSValidationServiceImpl{
Expand Down
63 changes: 62 additions & 1 deletion pkg/mocks/mock_MLSValidationService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/mocks/mock_MlsApi_SubscribeGroupMessagesServer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/mocks/mock_MlsApi_SubscribeWelcomeMessagesServer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading