Prathamesh Musale
9fab3f8326
All checks were successful
Integration Tests / test-integration (push) Successful in 2m32s
Unit Tests / test-unit (push) Successful in 2m34s
SDK Tests / sdk_tests_nameservice_expiry (push) Successful in 8m34s
SDK Tests / sdk_tests_auctions (push) Successful in 14m15s
E2E Tests / test-e2e (push) Successful in 2m47s
SDK Tests / sdk_tests (push) Successful in 7m54s
Part of [Sumsub KYC integration in onboarding app](https://www.notion.so/Sumsub-KYC-integration-in-onboarding-app-607b598c9c1d4d12adc71725e2ab5e7e) Reviewed-on: #43 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package onboarding
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
errorsmod "cosmossdk.io/errors"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
)
|
|
|
|
var PERMITTED_ROLES = []string{"participant", "validator"}
|
|
|
|
var _ sdk.Msg = &MsgOnboardParticipant{}
|
|
|
|
func (msg MsgOnboardParticipant) ValidateBasic() error {
|
|
if len(msg.Participant) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrorInvalidSigner, msg.Participant)
|
|
}
|
|
|
|
if len(msg.EthPayload.Address) != 42 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Participant)
|
|
}
|
|
|
|
if len(msg.EthSignature) != 132 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid signature.")
|
|
}
|
|
|
|
if len(msg.KycId) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Empty KYC ID.")
|
|
}
|
|
|
|
isRoleValid := false
|
|
for _, v := range PERMITTED_ROLES {
|
|
if msg.Role == v {
|
|
isRoleValid = true
|
|
break
|
|
}
|
|
}
|
|
|
|
if !isRoleValid {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("Participant role has to be one of: %v", PERMITTED_ROLES))
|
|
}
|
|
|
|
return nil
|
|
}
|