fix(api+cmd): fix gateway jsonpb emit nil empty field error

This commit is contained in:
Alexader 2021-04-27 15:17:35 +08:00
parent f7a887856e
commit 5cf9c1ff15
4 changed files with 8 additions and 19 deletions

View File

@ -22,7 +22,7 @@ func Start(config *repo.Config) error {
mux := runtime.NewServeMux(
runtime.WithMarshalerOption(runtime.MIMEWildcard,
&runtime.JSONPb{OrigName: true, EmitDefaults: true, EnumsAsInts: true},
&runtime.JSONPb{OrigName: true, EmitDefaults: false, EnumsAsInts: true},
),
)

View File

@ -361,7 +361,7 @@ func invokeBVMContract(ctx *cli.Context, contractAddr string, method string, arg
fmt.Println("get transaction receipt error: " + err.Error())
}
m := &runtime.JSONPb{OrigName: true, EmitDefaults: true, EnumsAsInts: true}
m := &runtime.JSONPb{OrigName: true, EmitDefaults: false, EnumsAsInts: true}
receipt := &pb.Receipt{}
if err = m.Unmarshal(data, receipt); err != nil {
return nil, fmt.Errorf("jsonpb unmarshal receipt error: %w", err)

2
go.mod
View File

@ -28,7 +28,7 @@ require (
github.com/magiconair/properties v1.8.4
github.com/meshplus/bitxhub-core v1.3.0
github.com/meshplus/bitxhub-kit v1.2.0
github.com/meshplus/bitxhub-model v1.2.0
github.com/meshplus/bitxhub-model v1.2.1-0.20210427070329-44b1020dd703
github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a
github.com/meshplus/did-registry v0.0.0-20210413035015-509c6c3a0bae
github.com/meshplus/go-libp2p-cert v0.0.0-20210125063330-7c25fd5b7a49

21
go.sum
View File

@ -126,6 +126,7 @@ github.com/cbergoon/merkletree v0.2.0 h1:Bttqr3OuoiZEo4ed1L7fTasHka9II+BF9fhBfbN
github.com/cbergoon/merkletree v0.2.0/go.mod h1:5c15eckUgiucMGDOCanvalj/yJnD+KAZj1qyJtRW5aM=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
@ -221,6 +222,7 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc h1:jtW8jbpkO4YirRSyepBOH8E+2HEw6/hKkBvFPwhUN8c=
github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6 h1:u/UEqS66A5ckRmS4yNpjmVH56sVtS/RfclBAYocb4as=
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ=
@ -817,10 +819,6 @@ github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpe
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210318102029-494ee3060b0c/go.mod h1:G19Wrz1u66UmwaES/iLM19jmlv3APAZ5qfYOlNnIIZw=
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210423140028-7c7e2fd80a46 h1:ZX6J+BcLFuxzCmC8yf7DC5ah9MVJ+birGL5xd5SMdgY=
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210423140028-7c7e2fd80a46/go.mod h1:ijf/8xybq2lGz86VKSTghDQGrKhx7GHavDQpCJWcsDs=
github.com/meshplus/bitxhub-core v1.2.0 h1:tSOIN3Fg89UJwu0XhlCIP+oCLwhg/TP4JQehTFp4Las=
github.com/meshplus/bitxhub-core v1.2.0/go.mod h1:2ksSKEiox4B06gSPT6h4+GcdWnh92/FDPUUImX/dI04=
github.com/meshplus/bitxhub-core v1.3.0 h1:bv4iAQMk7tg0Gz6WfoC3q1/ssLhE0czNnUcLglWrltM=
github.com/meshplus/bitxhub-core v1.3.0/go.mod h1:2ksSKEiox4B06gSPT6h4+GcdWnh92/FDPUUImX/dI04=
github.com/meshplus/bitxhub-kit v1.1.1 h1:vkPO88oA3+Kpc0N8lIgfj/U52KBuI+633hPbMYt1xm8=
@ -831,25 +829,15 @@ github.com/meshplus/bitxhub-kit v1.1.2-0.20201203072410-8a0383a6870d h1:J9tzTNf2
github.com/meshplus/bitxhub-kit v1.1.2-0.20201203072410-8a0383a6870d/go.mod h1:KR7ZlXhII9n0Bu8viaZTScvXCYn0MCQnYlsTvHPp0XA=
github.com/meshplus/bitxhub-kit v1.1.2-0.20210112075018-319e668d6359 h1:GdgS14bnCF4b/a5zhQi2wlu92pHc9cfl6A1HcbO7zmE=
github.com/meshplus/bitxhub-kit v1.1.2-0.20210112075018-319e668d6359/go.mod h1:KR7ZlXhII9n0Bu8viaZTScvXCYn0MCQnYlsTvHPp0XA=
github.com/meshplus/bitxhub-kit v1.1.2-0.20210423082909-97edee705d22 h1:4PguI96NAg5IFHTnUi0YGQ9HgSiV3K0b/PkxaWRmUrg=
github.com/meshplus/bitxhub-kit v1.1.2-0.20210423082909-97edee705d22/go.mod h1:ltiaMnupw2mzE1gENiV6LF6C8UYu0bF7w1NrG3QDvFQ=
github.com/meshplus/bitxhub-kit v1.1.2-0.20210425013549-7a642723d279/go.mod h1:ltiaMnupw2mzE1gENiV6LF6C8UYu0bF7w1NrG3QDvFQ=
github.com/meshplus/bitxhub-kit v1.1.2-0.20210425020456-3e87ac09c707 h1:xkeoue4sog72PnVVmPrcGgGiQDjaougHallr4RjDTEk=
github.com/meshplus/bitxhub-kit v1.1.2-0.20210425020456-3e87ac09c707/go.mod h1:Zs4eZnVtI0uX6aIMN7DnqXCJTthQ0WNrjF1/h6KkGRc=
github.com/meshplus/bitxhub-kit v1.2.0 h1:lG6vyRD14bPoQFNU8ygmgzMXAy4xDlEueJyM6vShndo=
github.com/meshplus/bitxhub-kit v1.2.0/go.mod h1:vGTKDkCAU7/IlirT6tlq6BMnCpY9UbfrrwGDy6foQIg=
github.com/meshplus/bitxhub-model v1.1.1/go.mod h1:lUl9vPZXM9tP+B0ABRW/2eOW/6KCmjFTdoiTj5Vut/A=
github.com/meshplus/bitxhub-model v1.1.2-0.20201021152621-0b3c17c54b23/go.mod h1:4qWBZx5wv7WZzUqiuBsbkQqQ2Ju8aOFpsoNpBBNy8Us=
github.com/meshplus/bitxhub-model v1.1.2-0.20210409090411-de23bd385c5f/go.mod h1:x3H+TL24wcByzHegenLfs+5PQkQGNsk8eCm31QJMa+Q=
github.com/meshplus/bitxhub-model v1.1.2-0.20210423135747-9546174eabb0/go.mod h1:rW2Sd4ZFdBoch0h4i1lSuyHNFIOg/3t8loQ+LV5rvNc=
github.com/meshplus/bitxhub-model v1.1.2-0.20210425021723-411f67ad49be h1:SGCgDzpMEu/cpjlewBrotZmGujB9tPOEL614CrJxlLk=
github.com/meshplus/bitxhub-model v1.1.2-0.20210425021723-411f67ad49be/go.mod h1:XIfxB6AAi0D5Qd7jmOykijSvI0GSKQZRR0OG0cp23iU=
github.com/meshplus/bitxhub-model v1.1.2-0.20210426012554-bb170814ec11 h1:rdevlFfnfLNvoSfnJx/pdJkfUHAQGoJfyqxDxWOyhJw=
github.com/meshplus/bitxhub-model v1.1.2-0.20210426012554-bb170814ec11/go.mod h1:XIfxB6AAi0D5Qd7jmOykijSvI0GSKQZRR0OG0cp23iU=
github.com/meshplus/bitxhub-model v1.1.2-0.20210426065438-954f4d830abc h1:Xdr93A4XsYXzI0Sxcmrvsl9aDt0QGnaXfs8i1vbGmhk=
github.com/meshplus/bitxhub-model v1.1.2-0.20210426065438-954f4d830abc/go.mod h1:XIfxB6AAi0D5Qd7jmOykijSvI0GSKQZRR0OG0cp23iU=
github.com/meshplus/bitxhub-model v1.2.0 h1:Ac8ol1HZNLIegyZkU/DZGYkPeeAWp3ZgYsbJGNF2GV0=
github.com/meshplus/bitxhub-model v1.2.0/go.mod h1:QCYJy8fUQex0cvxqAZtGHJn31F5mwuXnE3Lyri15zUc=
github.com/meshplus/bitxhub-model v1.2.1-0.20210427070329-44b1020dd703 h1:ue/MOET/icL9lZEQiGEpcUFH6jzRpTmQ0vBZt9yo3Fk=
github.com/meshplus/bitxhub-model v1.2.1-0.20210427070329-44b1020dd703/go.mod h1:QCYJy8fUQex0cvxqAZtGHJn31F5mwuXnE3Lyri15zUc=
github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a h1:c4ESPDa60Jd4zfzZIGGTyzhfaVM3vKN+xV2G9BwIDGQ=
github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a/go.mod h1:vAldSRfDe2Qo7exsSTbchVmZWXPY7fhWQrRw18QJHho=
github.com/meshplus/did-registry v0.0.0-20210413035015-509c6c3a0bae h1:E4iaFwHAg1ScyiU9Bz3RY0wjfXNZzPH3O43DBTl9iWg=
@ -1543,6 +1531,7 @@ gopkg.in/src-d/go-cli.v0 v0.0.0-20181105080154-d492247bbc0d/go.mod h1:z+K8VcOYVY
gopkg.in/src-d/go-log.v1 v1.0.1/go.mod h1:GN34hKP0g305ysm2/hctJ0Y8nWP3zxXXJ8GFabTyABE=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/urfave/cli.v1 v1.20.0 h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0=
gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=