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

WalletAddress -> AccountAddress #325

Merged
merged 1 commit into from
Jan 2, 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/uptrace/bun/driver/pgdriver v1.1.16
github.com/waku-org/go-waku v0.8.0
github.com/xmtp/go-msgio v0.2.1-0.20220510223757-25a701b79cd3
github.com/xmtp/proto/v3 v3.32.1-0.20231026053711-5efc208e3135
github.com/xmtp/proto/v3 v3.36.1-0.20231219054634-2ff03b7d5090
github.com/yoheimuta/protolint v0.39.0
go.uber.org/zap v1.24.0
golang.org/x/sync v0.3.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,8 @@ github.com/xmtp/proto/v3 v3.29.1-0.20231025220423-87413e63f3ab h1:hWBftgxB7QWXDO
github.com/xmtp/proto/v3 v3.29.1-0.20231025220423-87413e63f3ab/go.mod h1:NF2zAjtNpVIhS4tFG19g4L1tJcPZHm81oeDFXltmOiY=
github.com/xmtp/proto/v3 v3.32.1-0.20231026053711-5efc208e3135 h1:MpeptLshF0T8ikwmVQI1mnlp5fXkbyUc+9FpyzFdsbo=
github.com/xmtp/proto/v3 v3.32.1-0.20231026053711-5efc208e3135/go.mod h1:NF2zAjtNpVIhS4tFG19g4L1tJcPZHm81oeDFXltmOiY=
github.com/xmtp/proto/v3 v3.36.1-0.20231219054634-2ff03b7d5090 h1:+0KTgQiUfu5UxgLjP18VL4BtG6hJMJYL0n1mVXtf3Ss=
github.com/xmtp/proto/v3 v3.36.1-0.20231219054634-2ff03b7d5090/go.mod h1:NF2zAjtNpVIhS4tFG19g4L1tJcPZHm81oeDFXltmOiY=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/yoheimuta/go-protoparser/v4 v4.6.0 h1:uvz1e9/5Ihsm4Ku8AJeDImTpirKmIxubZdSn0QJNdnw=
github.com/yoheimuta/go-protoparser/v4 v4.6.0/go.mod h1:AHNNnSWnb0UoL4QgHPiOAg2BniQceFscPI5X/BZNHl8=
Expand Down
16 changes: 8 additions & 8 deletions pkg/api/message/v3/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ func (s *Service) RegisterInstallation(ctx context.Context, req *proto.RegisterI
}

installationId := results[0].InstallationId
walletAddress := results[0].WalletAddress
accountAddress := results[0].AccountAddress
credentialIdentity := results[0].CredentialIdentity

if err = s.mlsStore.CreateInstallation(ctx, installationId, walletAddress, req.LastResortKeyPackage.KeyPackageTlsSerialized, credentialIdentity); err != nil {
if err = s.mlsStore.CreateInstallation(ctx, installationId, accountAddress, req.LastResortKeyPackage.KeyPackageTlsSerialized, credentialIdentity); err != nil {
return nil, err
}

Expand Down Expand Up @@ -203,15 +203,15 @@ func (s *Service) GetIdentityUpdates(ctx context.Context, req *proto.GetIdentity
return nil, err
}

walletAddresses := req.WalletAddresses
updates, err := s.mlsStore.GetIdentityUpdates(ctx, req.WalletAddresses, int64(req.StartTimeNs))
accountAddresses := req.AccountAddresses
updates, err := s.mlsStore.GetIdentityUpdates(ctx, req.AccountAddresses, int64(req.StartTimeNs))
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get identity updates: %s", err)
}

resUpdates := make([]*proto.GetIdentityUpdatesResponse_WalletUpdates, len(walletAddresses))
for i, walletAddress := range walletAddresses {
walletUpdates := updates[walletAddress]
resUpdates := make([]*proto.GetIdentityUpdatesResponse_WalletUpdates, len(accountAddresses))
for i, accountAddress := range accountAddresses {
walletUpdates := updates[accountAddress]

resUpdates[i] = &proto.GetIdentityUpdatesResponse_WalletUpdates{
Updates: []*proto.GetIdentityUpdatesResponse_Update{},
Expand Down Expand Up @@ -289,7 +289,7 @@ func validateUploadKeyPackagesRequest(req *proto.UploadKeyPackagesRequest) error
}

func validateGetIdentityUpdatesRequest(req *proto.GetIdentityUpdatesRequest) error {
if req == nil || len(req.WalletAddresses) == 0 {
if req == nil || len(req.AccountAddresses) == 0 {
return status.Errorf(codes.InvalidArgument, "no wallet addresses to get updates for")
}
return nil
Expand Down
32 changes: 16 additions & 16 deletions pkg/api/message/v3/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ func newMockedValidationService() *mockedMLSValidationService {
return new(mockedMLSValidationService)
}

func (m *mockedMLSValidationService) mockValidateKeyPackages(installationId []byte, walletAddress string) *mock.Call {
func (m *mockedMLSValidationService) mockValidateKeyPackages(installationId []byte, accountAddress string) *mock.Call {
return m.On("ValidateKeyPackages", mock.Anything, mock.Anything).Return([]mlsvalidate.IdentityValidationResult{
{
InstallationId: installationId,
WalletAddress: walletAddress,
AccountAddress: accountAddress,
CredentialIdentity: []byte("test"),
},
}, nil)
Expand Down Expand Up @@ -97,9 +97,9 @@ func TestRegisterInstallation(t *testing.T) {
defer cleanup()

installationId := test.RandomBytes(32)
walletAddress := test.RandomString(32)
accountAddress := test.RandomString(32)

mlsValidationService.mockValidateKeyPackages(installationId, walletAddress)
mlsValidationService.mockValidateKeyPackages(installationId, accountAddress)

res, err := svc.RegisterInstallation(ctx, &proto.RegisterInstallationRequest{
LastResortKeyPackage: &proto.KeyPackageUpload{
Expand All @@ -115,7 +115,7 @@ func TestRegisterInstallation(t *testing.T) {
require.NoError(t, err)

require.Len(t, installations, 1)
require.Equal(t, walletAddress, installations[0].WalletAddress)
require.Equal(t, accountAddress, installations[0].WalletAddress)
}

func TestRegisterInstallationError(t *testing.T) {
Expand All @@ -140,9 +140,9 @@ func TestUploadKeyPackages(t *testing.T) {
defer cleanup()

installationId := test.RandomBytes(32)
walletAddress := test.RandomString(32)
accountAddress := test.RandomString(32)

mlsValidationService.mockValidateKeyPackages(installationId, walletAddress)
mlsValidationService.mockValidateKeyPackages(installationId, accountAddress)

res, err := svc.RegisterInstallation(ctx, &proto.RegisterInstallationRequest{
LastResortKeyPackage: &proto.KeyPackageUpload{
Expand Down Expand Up @@ -172,9 +172,9 @@ func TestConsumeKeyPackages(t *testing.T) {
defer cleanup()

installationId1 := test.RandomBytes(32)
walletAddress1 := test.RandomString(32)
accountAddress1 := test.RandomString(32)

mockCall := mlsValidationService.mockValidateKeyPackages(installationId1, walletAddress1)
mockCall := mlsValidationService.mockValidateKeyPackages(installationId1, accountAddress1)

res, err := svc.RegisterInstallation(ctx, &proto.RegisterInstallationRequest{
LastResortKeyPackage: &proto.KeyPackageUpload{
Expand All @@ -186,10 +186,10 @@ func TestConsumeKeyPackages(t *testing.T) {

// Add a second key package
installationId2 := test.RandomBytes(32)
walletAddress2 := test.RandomString(32)
accountAddress2 := test.RandomString(32)
// Unset the original mock so we can set a new one
mockCall.Unset()
mlsValidationService.mockValidateKeyPackages(installationId2, walletAddress2)
mlsValidationService.mockValidateKeyPackages(installationId2, accountAddress2)

res, err = svc.RegisterInstallation(ctx, &proto.RegisterInstallationRequest{
LastResortKeyPackage: &proto.KeyPackageUpload{
Expand Down Expand Up @@ -268,9 +268,9 @@ func TestGetIdentityUpdates(t *testing.T) {
defer cleanup()

installationId := test.RandomBytes(32)
walletAddress := test.RandomString(32)
accountAddress := test.RandomString(32)

mockCall := mlsValidationService.mockValidateKeyPackages(installationId, walletAddress)
mockCall := mlsValidationService.mockValidateKeyPackages(installationId, accountAddress)

_, err := svc.RegisterInstallation(ctx, &proto.RegisterInstallationRequest{
LastResortKeyPackage: &proto.KeyPackageUpload{
Expand All @@ -280,7 +280,7 @@ func TestGetIdentityUpdates(t *testing.T) {
require.NoError(t, err)

identityUpdates, err := svc.GetIdentityUpdates(ctx, &proto.GetIdentityUpdatesRequest{
WalletAddresses: []string{walletAddress},
AccountAddresses: []string{accountAddress},
})
require.NoError(t, err)
require.NotNil(t, identityUpdates)
Expand All @@ -295,7 +295,7 @@ func TestGetIdentityUpdates(t *testing.T) {
}

mockCall.Unset()
mlsValidationService.mockValidateKeyPackages(test.RandomBytes(32), walletAddress)
mlsValidationService.mockValidateKeyPackages(test.RandomBytes(32), accountAddress)
_, err = svc.RegisterInstallation(ctx, &proto.RegisterInstallationRequest{
LastResortKeyPackage: &proto.KeyPackageUpload{
KeyPackageTlsSerialized: []byte("test"),
Expand All @@ -304,7 +304,7 @@ func TestGetIdentityUpdates(t *testing.T) {
require.NoError(t, err)

identityUpdates, err = svc.GetIdentityUpdates(ctx, &proto.GetIdentityUpdatesRequest{
WalletAddresses: []string{walletAddress},
AccountAddresses: []string{accountAddress},
})
require.NoError(t, err)
require.Len(t, identityUpdates.Updates, 1)
Expand Down
4 changes: 2 additions & 2 deletions pkg/mlsvalidate/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

type IdentityValidationResult struct {
WalletAddress string
AccountAddress string
InstallationId []byte
CredentialIdentity []byte
}
Expand Down Expand Up @@ -55,7 +55,7 @@ func (s *MLSValidationServiceImpl) ValidateKeyPackages(ctx context.Context, keyP
return nil, fmt.Errorf("validation failed with error %s", response.ErrorMessage)
}
out[i] = IdentityValidationResult{
WalletAddress: response.WalletAddress,
AccountAddress: response.AccountAddress,
InstallationId: response.InstallationId,
CredentialIdentity: response.CredentialIdentityBytes,
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/mlsvalidate/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestValidateKeyPackages(t *testing.T) {

firstResponse := svc.ValidateKeyPackagesResponse_ValidationResponse{
IsOk: true,
WalletAddress: "0x123",
AccountAddress: "0x123",
InstallationId: []byte("123"),
CredentialIdentityBytes: []byte("456"),
ErrorMessage: "",
Expand All @@ -55,7 +55,7 @@ func TestValidateKeyPackages(t *testing.T) {
res, err := service.ValidateKeyPackages(ctx, nil)
assert.NoError(t, err)
assert.Equal(t, 1, len(res))
assert.Equal(t, "0x123", res[0].WalletAddress)
assert.Equal(t, "0x123", res[0].AccountAddress)
assert.Equal(t, []byte("123"), res[0].InstallationId)
assert.Equal(t, []byte("456"), res[0].CredentialIdentity)
}
Expand Down