Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!
Open sidebar
chainweaver
ida
contract-ida
Commits
d364a4cd
Commit
d364a4cd
authored
1 year ago
by
guanghonglu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ApplyForCertification event
parent
4091fb3b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
5 deletions
+14
-5
event/events.go
event/events.go
+2
-2
ida.go
ida.go
+8
-3
test/cmd/mycmc_test.go
test/cmd/mycmc_test.go
+4
-0
No files found.
event/events.go
View file @
d364a4cd
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
ida.go
View file @
d364a4cd
...
...
@@ -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
)
id
a
OwnershipBytes
,
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
(
id
a
OwnershipBytes
,
&
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
()
}
...
...
This diff is collapsed.
Click to expand it.
test/cmd/mycmc_test.go
View file @
d364a4cd
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment