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

DEV-1079: Split validation into basic and dynamic #285

Merged
merged 94 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
a5265f3
Minor improvements
askolesov Feb 18, 2022
0c11010
Implementation checkpoint
askolesov Feb 24, 2022
61fc7b6
Implementation
askolesov Feb 25, 2022
7f1d302
Types validation poc
askolesov Feb 25, 2022
bdf0300
Update basic validation for messages
askolesov Feb 25, 2022
41f8883
Validation implemetation
askolesov Feb 28, 2022
e90eeb5
Add `unique` helper
askolesov Feb 28, 2022
661b60d
Dynamic validaton implementation
askolesov Mar 1, 2022
7ee98ae
Add DID static validation without tests
Mar 2, 2022
00e222a
Merge pull request #291 from cheqd/DEV-705-did-validation
askolesov Mar 3, 2022
d868c87
Improve did validation primitives
askolesov Mar 3, 2022
bca70df
[DEV-705] Add DID and DIDURL validation with tests
Mar 5, 2022
4efacab
Switch to ozzo validation vramework
askolesov Mar 5, 2022
eb198b7
[DEV-705] make each test as independent
Mar 5, 2022
2208f67
[DEV-705] Add validation for VerificationDethod and Controller
Mar 5, 2022
acd0f39
[DEV-705] Add check that DID list is set
Mar 6, 2022
7b6b302
Verification method validation
askolesov Mar 7, 2022
9ba85d7
Finished static validation
askolesov Mar 8, 2022
4069187
Further improvements
askolesov Mar 8, 2022
14ed669
[DEV-705] Add JWK key verification
Mar 9, 2022
3cb95d8
Add todos
askolesov Mar 10, 2022
cfcfbab
Add ED25519 validation and tests
Mar 10, 2022
20bd72f
Implementation
askolesov Mar 11, 2022
826b00d
Minor edits
askolesov Mar 11, 2022
e05c3bc
For the previous commit
askolesov Mar 11, 2022
119d3db
Merge pull request #292 from cheqd/DEV-705-did-validation
askolesov Mar 11, 2022
c405c73
Fix did creation positive test
askolesov Mar 11, 2022
8496b8f
Add support for JWKs
askolesov Mar 11, 2022
56a5a4e
[DEV-705] change AlsoKnowAs field validation to just URI
Mar 11, 2022
9edb9f5
Tests for jwk signature verification
askolesov Mar 11, 2022
1d3f441
[DEV-705] Fix tests for MsgCreateDid
Mar 14, 2022
2cd08a0
UpdateDID implementation
askolesov Mar 14, 2022
b551fa9
Finish did update
askolesov Mar 15, 2022
ab5e6c0
Minor fixes
askolesov Mar 15, 2022
88a641d
Merge branch 'DEV-705-did-validation' into DEV-705
askolesov Mar 15, 2022
1af8f2d
Fix positive update test
askolesov Mar 15, 2022
a8b5c98
Improve comments
askolesov Mar 15, 2022
d48511f
Merge branch 'main' into DEV-705
askolesov Mar 15, 2022
ff054ae
Tidy go mods
askolesov Mar 15, 2022
ed1aa61
Merge branch 'main' into DEV-705
askolesov Mar 15, 2022
2fdc200
Fix go lint issues
askolesov Mar 15, 2022
1cee542
Merge branch 'DEV-705' of https://github.com/cheqd/cheqd-node into DE…
askolesov Mar 15, 2022
326ee65
Fix test workflow
askolesov Mar 15, 2022
dded348
Fix go lint issues
askolesov Mar 15, 2022
d14149f
Merge branch 'main' into DEV-705
askolesov Mar 15, 2022
2d00036
Revert unnecessary changes
askolesov Mar 15, 2022
467cad4
Improve eror messages on did update
askolesov Mar 16, 2022
7e70134
Rollback unnecessary change
askolesov Mar 16, 2022
1cd3e1d
Remove unused errors
askolesov Mar 16, 2022
90def38
Revert unnecessary chanes, add eof new lines
askolesov Mar 16, 2022
51be1c3
Make signature verification during creation similar to the verificati…
askolesov Mar 16, 2022
abb2d80
Revert "Make signature verification during creation similar to the ve…
askolesov Mar 16, 2022
9f65acf
[DEV-705] The latest changes around UpdateDid functionality
Mar 16, 2022
fdab46d
Make validation rules naming consistent
askolesov Mar 17, 2022
1c7df44
For the previous commit
askolesov Mar 17, 2022
74bbf1e
Bump module consensus version
askolesov Mar 17, 2022
9022554
Fix update logix where extra signatures were required
askolesov Mar 17, 2022
301c3ad
[DEV-705] Tests refactoring
Mar 17, 2022
452e8cb
Add fopport for multiple signaturess to cli
askolesov Mar 17, 2022
86b3bf7
Fix bash tests
askolesov Mar 17, 2022
c46af97
Fix go linter issues
askolesov Mar 17, 2022
76932bf
Pin go version in docker
askolesov Mar 17, 2022
1039d5a
Merge remote-tracking branch 'origin/DEV-705' into DEV-705-did-valida…
Mar 17, 2022
985349b
[DEV-705] Fix verification method tests
Mar 17, 2022
1aab462
Fix upgrade test
askolesov Mar 17, 2022
77d9c3e
Merge remote-tracking branch 'origin/DEV-705' into DEV-705-did-valida…
Mar 17, 2022
dfad749
[DEV-705] fix python-based tests
Mar 17, 2022
ede86b0
[DEV-705] Fix debian test
Mar 17, 2022
3166ec9
fix upgrade tests
Toktar Mar 17, 2022
adba304
fix upgrade tests
Toktar Mar 17, 2022
6383bf9
fix upgrade tests
Toktar Mar 17, 2022
b046ff1
Bump IBC version
askolesov Mar 17, 2022
2699959
Get rid of the odd library
askolesov Mar 17, 2022
d0d3c4e
[DEV-705] fix upgrade tests
Toktar Mar 17, 2022
25767c6
[DEV-705] fix upgrade tests
Toktar Mar 17, 2022
dabd9b1
[DEV-705] Add --home for new_docker
Mar 17, 2022
693eb13
Simplify grpc gateway path
askolesov Mar 17, 2022
194b6d7
Fix error message
askolesov Mar 17, 2022
c91ca1e
[DEV-705] fix upgrade tests
Mar 18, 2022
e06c6ff
[DEV-705] fix upgrade test
Mar 18, 2022
6784128
[DEV-705] Fix upgrade test
Mar 18, 2022
afea105
[DEV-705] fix upgrade test
Mar 18, 2022
60af20c
[DEV-705] Fix upgrade test
Mar 18, 2022
e85ae31
[DEV-705] Fix upgrade test again
Mar 18, 2022
4af599c
[DEV-705] get -d back
Mar 18, 2022
4916717
[DEV-705] Get rid of --ver-key
Mar 18, 2022
e41afb1
[DEV-705] Get local_tx_send back
Mar 18, 2022
b094a0b
Merge pull request #300 from cheqd/DEV-705-did-validation
askolesov Mar 18, 2022
3fc4544
Fix linter issues
askolesov Mar 18, 2022
33cf211
Merge branch 'DEV-705-did-validation' into DEV-705
askolesov Mar 18, 2022
6389eab
Changed user to cheqd
ankurdotb Mar 18, 2022
ab50855
Change user back to root
askolesov Mar 18, 2022
3e21a23
Revert "Change user back to root"
askolesov Mar 18, 2022
8d0d6f0
Revert "Changed user to cheqd"
askolesov Mar 18, 2022
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
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ go 1.17

require (
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
github.com/cosmos/cosmos-sdk v0.44.5
github.com/cosmos/cosmos-sdk v0.45.1
ankurdotb marked this conversation as resolved.
Show resolved Hide resolved
github.com/cosmos/ibc-go v1.2.3
github.com/go-playground/validator/v10 v10.10.0
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
Expand Down Expand Up @@ -54,6 +55,8 @@ require (
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-kit/kit v0.10.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/gateway v1.1.0 // indirect
github.com/golang/snappy v0.0.3 // indirect
Expand All @@ -74,6 +77,7 @@ require (
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.11.7 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lib/pq v1.10.2 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/magiconair/properties v1.8.5 // indirect
Expand Down
24 changes: 18 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,17 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0=
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
Expand Down Expand Up @@ -522,13 +526,16 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
Expand Down Expand Up @@ -614,7 +621,6 @@ github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/neilotoole/errgroup v0.1.5/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down Expand Up @@ -681,6 +687,7 @@ github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -745,6 +752,9 @@ github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRr
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
Expand Down Expand Up @@ -917,6 +927,7 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -1325,8 +1336,9 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
Expand Down
9 changes: 4 additions & 5 deletions proto/cheqd/v1/did.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cheqdid.cheqdnode.cheqd.v1;

option go_package = "github.com/cheqd/cheqd-node/x/cheqd/types";

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cheqd/v1/common.proto";

Expand All @@ -21,17 +22,15 @@ message Did {
}

message VerificationMethod {
string id = 1;
string id = 1 [(gogoproto.moretags) = "validate:\"required,did-url,did-url-no-path,did-url-no-query,did-url-fragment\""];
string type = 2;
string controller = 3;
repeated KeyValuePair public_key_jwk = 4; // optional
string public_key_multibase = 5; // optional
repeated KeyValuePair public_key_jwk = 4 [(gogoproto.moretags) = "validate:\"required_without_all=PublicKeyMultibase\""];
string public_key_multibase = 5 [(gogoproto.moretags) = "validate:\"required_without_all=PublicKeyJwk\""];
}

message Service {
string id = 1;
string type = 2;
string service_endpoint = 3;
}


3 changes: 2 additions & 1 deletion proto/cheqd/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cheqdid.cheqdnode.cheqd.v1;

option go_package = "github.com/cheqd/cheqd-node/x/cheqd/types";

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cheqd/v1/did.proto";

Expand Down Expand Up @@ -30,7 +31,7 @@ message SignInfo {

message MsgCreateDidPayload {
repeated string context = 1;
string id = 2;
string id = 2 [(gogoproto.moretags) = "validate:\"required\""];
repeated string controller = 3;
repeated VerificationMethod verification_method = 4;
repeated string authentication = 5;
Expand Down
37 changes: 37 additions & 0 deletions x/cheqd/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"github.com/cheqd/cheqd-node/x/cheqd/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type msgServer struct {
Expand All @@ -14,3 +15,39 @@ func NewMsgServer(keeper Keeper) types.MsgServer {
}

var _ types.MsgServer = msgServer{}


func AppendSignerIfNeed(signers []types.Signer, controller string, msg *types.MsgUpdateDidPayload) []types.Signer {
for _, signer := range signers {
if signer.Signer == controller {
return signers
}
}

signer := types.Signer{
Signer: controller,
}

if controller == msg.Id {
signer.VerificationMethod = msg.VerificationMethod
signer.Authentication = msg.Authentication
}

return append(signers, signer)
}

func (k msgServer) ValidateDidControllers(ctx *sdk.Context, id string, controllers []string, verMethods []*types.VerificationMethod) error {

for _, verificationMethod := range verMethods {
if err := k.ValidateController(ctx, id, verificationMethod.Controller); err != nil {
return err
}
}

for _, didController := range controllers {
if err := k.ValidateController(ctx, id, didController); err != nil {
return err
}
}
return nil
}
59 changes: 59 additions & 0 deletions x/cheqd/keeper/msg_server_create_did.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package keeper

import (
"context"
"fmt"
"reflect"

"github.com/cheqd/cheqd-node/x/cheqd/types"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

func (k msgServer) CreateDid(goCtx context.Context, msg *types.MsgCreateDid) (*types.MsgCreateDidResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
prefix := k.GetDidPrefix(ctx)

payload := msg.GetPayload()
if err := payload.Validate(prefix); err != nil {
return nil, err
}

if err := k.ValidateDidControllers(&ctx, payload.Id, payload.Controller, payload.VerificationMethod); err != nil {
return nil, err
}

if err := k.VerifySignature(&ctx, payload, payload.GetSigners(), msg.GetSignatures()); err != nil {
return nil, err
}

// Checks that the did doesn't exist
if k.HasDid(ctx, payload.Id) {
return nil, sdkerrors.Wrap(types.ErrDidDocExists, fmt.Sprintf("DID is already used by DIDDoc %s", payload.Id))
}

var did = types.Did{
Context: payload.Context,
Id: payload.Id,
Controller: payload.Controller,
VerificationMethod: payload.VerificationMethod,
Authentication: payload.Authentication,
AssertionMethod: payload.AssertionMethod,
CapabilityInvocation: payload.CapabilityInvocation,
CapabilityDelegation: payload.CapabilityDelegation,
KeyAgreement: payload.KeyAgreement,
AlsoKnownAs: payload.AlsoKnownAs,
Service: payload.Service,
}

metadata := types.NewMetadataFromContext(ctx)
id, err := k.AppendDid(ctx, did, &metadata)
if err != nil {
return nil, err
}

return &types.MsgCreateDidResponse{
Id: *id,
}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,12 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

func (k msgServer) CreateDid(goCtx context.Context, msg *types.MsgCreateDid) (*types.MsgCreateDidResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
prefix := k.GetDidPrefix(ctx)

didMsg := msg.GetPayload()
if err := didMsg.Validate(prefix); err != nil {
return nil, err
}

if err := k.ValidateDidControllers(&ctx, didMsg.Id, didMsg.Controller, didMsg.VerificationMethod); err != nil {
return nil, err
}

if err := k.VerifySignature(&ctx, didMsg, didMsg.GetSigners(), msg.GetSignatures()); err != nil {
return nil, err
}

// Checks that the did doesn't exist
if k.HasDid(ctx, didMsg.Id) {
return nil, sdkerrors.Wrap(types.ErrDidDocExists, fmt.Sprintf("DID is already used by DIDDoc %s", didMsg.Id))
}

var did = types.Did{
Context: didMsg.Context,
Id: didMsg.Id,
Controller: didMsg.Controller,
VerificationMethod: didMsg.VerificationMethod,
Authentication: didMsg.Authentication,
AssertionMethod: didMsg.AssertionMethod,
CapabilityInvocation: didMsg.CapabilityInvocation,
CapabilityDelegation: didMsg.CapabilityDelegation,
KeyAgreement: didMsg.KeyAgreement,
AlsoKnownAs: didMsg.AlsoKnownAs,
Service: didMsg.Service,
}

metadata := types.NewMetadata(ctx)
id, err := k.AppendDid(ctx, did, &metadata)
if err != nil {
return nil, err
}

return &types.MsgCreateDidResponse{
Id: *id,
}, nil
}

func (k msgServer) UpdateDid(goCtx context.Context, msg *types.MsgUpdateDid) (*types.MsgUpdateDidResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
prefix := k.GetDidPrefix(ctx)

didMsg := msg.GetPayload()
if err := didMsg.Validate(prefix); err != nil {
if err := didMsg.ValidateDynamic(prefix); err != nil {
return nil, err
}

Expand Down Expand Up @@ -110,7 +63,7 @@ func (k msgServer) UpdateDid(goCtx context.Context, msg *types.MsgUpdateDid) (*t
Service: didMsg.Service,
}

metadata := types.NewMetadata(ctx)
metadata := types.NewMetadataFromContext(ctx)
metadata.Created = oldStateValue.Metadata.Created
metadata.Deactivated = oldStateValue.Metadata.Deactivated

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils
package validate

import "github.com/cheqd/cheqd-node/x/cheqd/utils/strings"

Expand Down
Loading