新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!

Commit d364a4cd authored by guanghonglu's avatar guanghonglu

add ApplyForCertification event

parent 4091fb3b
......@@ -81,8 +81,8 @@ func EmitIDADeletedEvent(idaIDs []string) {
}
// EmitIDACertificationAppliedEvent converts EventIDACertificationApplied to a string array and emits the event
func EmitIDACertificationAppliedEvent(idaID string, certifierAddress string) {
sdk.Instance.EmitEvent(_const.EventIDACertificationApplied, []string{idaID, certifierAddress})
func EmitIDACertificationAppliedEvent(idaID, certifierAddress, basicStr, ownershipStr string) {
sdk.Instance.EmitEvent(_const.EventIDACertificationApplied, []string{idaID, certifierAddress, basicStr, ownershipStr})
}
// EmitIDACertifiedEvent converts EventIDACertified to a string array and emits the event
......
......@@ -948,12 +948,12 @@ func (a *IDA) DeleteIDAs(keys []string) protogo.Response {
func (a *IDA) ApplyForCertification(key string, authenticatorAddress string) protogo.Response {
idaInfo := &types.IDAInfo{}
idOwnershipBytes, err := sdk.Instance.GetStateByte(_const.KeyIDAOwnership, key)
idaOwnershipBytes, err := sdk.Instance.GetStateByte(_const.KeyIDAOwnership, key)
if err != nil {
return code.ErrorResp(code.ErrInternalDataReadFailed, fmt.Sprintf("failed to getstate[%s %s],err: %v", _const.KeyIDAOwnership, key, err))
}
err = json.Unmarshal(idOwnershipBytes, &idaInfo.Ownership)
err = json.Unmarshal(idaOwnershipBytes, &idaInfo.Ownership)
if err != nil {
return code.ErrorResp(code.ErrInternalJsonUnmarshalFailed, fmt.Sprintf(code.ErrInternalJsonUnmarshalFailed.String()+" [%s - %s],err: %v", _const.KeyIDAOwnership, key, err))
}
......@@ -964,7 +964,12 @@ func (a *IDA) ApplyForCertification(key string, authenticatorAddress string) pro
return *errResp
}
event.EmitIDACertificationAppliedEvent(key, authenticatorAddress)
idaBasicBytes, err := sdk.Instance.GetStateByte(_const.KeyIDABasic, key)
if err != nil {
return code.ErrorResp(code.ErrInternalDataReadFailed, fmt.Sprintf("failed to getstate[%s %s],err: %v", _const.KeyIDABasic, key, err))
}
event.EmitIDACertificationAppliedEvent(key, authenticatorAddress, string(idaBasicBytes), string(idaOwnershipBytes))
return util.SuccessNormal()
}
......
......@@ -304,6 +304,10 @@ func TestAll(t *testing.T) {
require.Nil(t, err)
require.Equal(t, _const.EventIDACertificationApplied, resp.ContractResult.ContractEvent[0].Topic)
require.Equal(t, adminInfo.Address, resp.ContractResult.ContractEvent[0].EventData[1])
tempIDABasic = types.Basic{}
err = json.Unmarshal([]byte(resp.ContractResult.ContractEvent[0].EventData[2]), &tempIDABasic)
require.Nil(t, err)
require.Equal(t, "enname0", tempIDABasic.EnName)
// certify
certificationInfo := types.CertificationInfo{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment