Skip to content

Commit

Permalink
Proxy SCW validation requests to our MLS service (#407)
Browse files Browse the repository at this point in the history
* wip

* finish proxying
  • Loading branch information
codabrink authored Oct 9, 2024
1 parent 9dd808c commit 6744976
Show file tree
Hide file tree
Showing 22 changed files with 3,116 additions and 1,744 deletions.
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

0 comments on commit 6744976

Please sign in to comment.