From b24657d1c92eb0c7a14d9783bac1226fde234dee Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Wed, 25 May 2022 13:59:42 -0400 Subject: [PATCH 1/7] Use firefly-signer for ABI handling Signed-off-by: Nicko Guyer --- docs/reference/config.md | 4 +- go.mod | 28 +-- go.sum | 108 +++++---- .../blockchain/ethereum/abi_definitions.go | 10 +- internal/blockchain/ethereum/ethereum.go | 215 +++++++++--------- internal/blockchain/ethereum/ethereum_test.go | 69 +++--- internal/blockchain/ethereum/eventstream.go | 17 +- 7 files changed, 231 insertions(+), 220 deletions(-) diff --git a/docs/reference/config.md b/docs/reference/config.md index ec07ecc10..3f248da97 100644 --- a/docs/reference/config.md +++ b/docs/reference/config.md @@ -1,8 +1,8 @@ --- layout: default -title: Configuration Reference +title: pages.reference parent: Reference -nav_order: 3 +nav_order: 2 --- # Configuration Reference diff --git a/go.mod b/go.mod index 650770da6..9ede39b5d 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.5.0 github.com/hyperledger/firefly-common v0.1.6 + github.com/hyperledger/firefly-signer v0.9.4 github.com/jarcoal/httpmock v1.1.0 github.com/karlseguin/ccache v2.0.3+incompatible github.com/lib/pq v1.10.4 @@ -22,11 +23,11 @@ require ( github.com/qeesung/image2ascii v1.0.1 github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 github.com/sirupsen/logrus v1.8.1 - github.com/spf13/cobra v1.3.0 + github.com/spf13/cobra v1.4.0 github.com/spf13/viper v1.11.0 github.com/stretchr/testify v1.7.1 gitlab.com/hfuss/mux-prometheus v0.0.4 - golang.org/x/net v0.0.0-20220412020605-290c469a71a5 + golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 golang.org/x/text v0.3.7 ) @@ -36,7 +37,7 @@ require ( github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/containerd/containerd v1.5.10 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fsnotify/fsnotify v1.5.1 // indirect + github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/swag v0.19.15 // indirect github.com/golang/protobuf v1.5.2 // indirect @@ -46,7 +47,6 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/karlseguin/expect v1.0.8 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect github.com/magiconair/properties v1.8.6 // indirect @@ -55,12 +55,11 @@ require ( github.com/mattn/go-isatty v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect - github.com/mitchellh/mapstructure v1.4.3 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect - github.com/nxadm/tail v1.4.8 // indirect github.com/opencontainers/image-spec v1.0.2 // indirect - github.com/pelletier/go-toml v1.9.4 // indirect - github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect + github.com/pelletier/go-toml v1.9.5 // indirect + github.com/pelletier/go-toml/v2 v2.0.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect @@ -68,20 +67,21 @@ require ( github.com/prometheus/procfs v0.7.3 // indirect github.com/rs/cors v1.8.2 // indirect github.com/spf13/afero v1.8.2 // indirect - github.com/spf13/cast v1.4.1 // indirect + github.com/spf13/cast v1.5.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.2.0 // indirect - github.com/subosito/gotenv v1.2.0 // indirect + github.com/subosito/gotenv v1.3.0 // indirect github.com/wayneashleyberry/terminal-dimensions v1.0.0 // indirect + github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0 // indirect github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect - golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect - golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect + golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect google.golang.org/protobuf v1.28.0 // indirect gopkg.in/ini.v1 v1.66.4 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + gopkg.in/yaml.v3 v3.0.0 // indirect ) diff --git a/go.sum b/go.sum index 652bbf1b1..a86b6f0df 100644 --- a/go.sum +++ b/go.sum @@ -29,7 +29,6 @@ cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aD cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= @@ -111,6 +110,7 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= +github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/aidarkhanov/nanoid v1.0.8 h1:yxyJkgsEDFXP7+97vc6JevMcjyb03Zw+/9fqhlVXBXA= github.com/aidarkhanov/nanoid v1.0.8/go.mod h1:vadfZHT+m4uDhttg0yY4wW3GKtl2T6i4d2Age+45pYk= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= @@ -175,6 +175,19 @@ github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnweb github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= +github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= @@ -182,7 +195,6 @@ github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3k github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -209,9 +221,7 @@ github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XP github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/cockroachdb/cockroach-go/v2 v2.1.1/go.mod h1:7NtUnP6eK+l6k483WSYNrq3Kb23bWV10IRV1TyeSpwM= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= @@ -329,9 +339,11 @@ github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1S github.com/d2g/dhcp4client v1.0.0/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW34z5W5s= github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5/go.mod h1:Eo87+Kg/IX2hfWJfwxMzLyuSZyxSoAug2nGa1G2QAi8= github.com/d2g/hardwareaddr v0.0.0-20190221164911-e7d9fbe030e4/go.mod h1:bMl4RjIciD2oAxI7DmWRx6gbeqrkoLqv3MV0vzNad+I= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -371,9 +383,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= @@ -383,10 +393,13 @@ github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzP github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.5+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fsouza/fake-gcs-server v1.17.0/go.mod h1:D1rTE4YCyHFNa99oyJJ5HyclvN/0uQR+pM/VdlL83bw= github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA= github.com/gabriel-vasile/mimetype v1.3.1/go.mod h1:fA8fi6KUiG7MgQQ+mEWotXoEOvmxRtOJlERCzSmRvr8= @@ -594,7 +607,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= -github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -605,7 +617,6 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -627,19 +638,16 @@ github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uG github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= -github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hyperledger/firefly-common v0.1.5 h1:66RXEAc/dsSEYPRye3G48Lk9sN+AmYGPf1FkrkbQGWs= github.com/hyperledger/firefly-common v0.1.5/go.mod h1:qGy7i8eWlE8Ed7jFn2Hpn8bYaflL204j4NJB1mAfTms= github.com/hyperledger/firefly-common v0.1.6 h1:I6t7N5D3YlaPSGknYF2xLurfEO+UQsHV4VFYeR/3UI4= github.com/hyperledger/firefly-common v0.1.6/go.mod h1:qGy7i8eWlE8Ed7jFn2Hpn8bYaflL204j4NJB1mAfTms= -github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/hyperledger/firefly-signer v0.9.4 h1:IW7ssNZPI0OZ19WSoTaeMQIr1Ke+aHL/kmCUWxRPgDA= +github.com/hyperledger/firefly-signer v0.9.4/go.mod h1:BjzIWMj4e1Em52liuyCV6dQhPeVc3WOuLOnEDGS4QK4= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= @@ -695,6 +703,8 @@ github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dv github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jarcoal/httpmock v1.1.0 h1:F47ChZj1Y2zFsCXxNkBPwNNKnAyOATcdQibk0qEdVCE= github.com/jarcoal/httpmock v1.1.0/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -709,6 +719,7 @@ github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22 github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -736,6 +747,7 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= @@ -749,8 +761,9 @@ github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 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 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= 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/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= @@ -770,9 +783,7 @@ github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -816,7 +827,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182aff github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= @@ -827,8 +837,9 @@ github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eI github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= @@ -866,6 +877,7 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -877,6 +889,8 @@ github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042 github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/gomega v0.0.0-20151007035656-2152b45fa28a/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= @@ -916,10 +930,12 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= -github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml/v2 v2.0.0-beta.8 h1:dy81yyLYJDwMTifq24Oi/IslOslRrDSb3jwDggjz3Z0= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.0-beta.8/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= +github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU= +github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= @@ -932,7 +948,6 @@ github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -987,6 +1002,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= @@ -997,7 +1014,6 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4= -github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= github.com/sagikazarmark/crypt v0.5.0/go.mod h1:l+nzl7KWh51rpzp2h7t4MZWyiEWdhNpOAnclKvg+mdA= github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 h1:TToq11gyfNlrMFZiYujSekIsPd9AmsA2Bj/iv+s4JHE= github.com/santhosh-tekuri/jsonschema/v5 v5.0.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0= @@ -1025,18 +1041,17 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= -github.com/spf13/cobra v1.3.0 h1:R7cSvGu+Vv+qX0gW5R/85dx2kmmJT5z5NM8ifdYjdn0= -github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= +github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q= +github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= @@ -1047,7 +1062,6 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= github.com/spf13/viper v1.11.0 h1:7OX/1FS6n7jHD1zGrZTM7WtY13ZELRyosK4k93oPr44= github.com/spf13/viper v1.11.0/go.mod h1:djo0X/bA5+tYVoCn+C7cAYJGcVn/qYLFTG8gdUsX7Zk= github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8= @@ -1065,8 +1079,9 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/subosito/gotenv v1.3.0 h1:mjC+YW8QpAdXibNi+vNWgzmgBH4+5l5dCXv8cNysBLI= +github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= @@ -1120,11 +1135,8 @@ go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= -go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/api/v3 v3.5.2/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= -go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/pkg/v3 v3.5.2/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= -go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= go.etcd.io/etcd/client/v2 v2.305.2/go.mod h1:2D7ZejHVMIfog1221iLSYlQRzrtECw3kz4I4VAQm3qI= go.mongodb.org/mongo-driver v1.7.0/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8NzkI+yfU8= go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= @@ -1149,10 +1161,10 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= @@ -1165,8 +1177,10 @@ golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -1175,8 +1189,9 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA= golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 h1:SLP7Q4Di66FONjDJbCYrCRrh97focO6sLogHO7/g8F0= +golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1223,13 +1238,12 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1290,8 +1304,9 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220412020605-290c469a71a5 h1:bRb386wvrE+oBNdF1d/Xh9mQrfQ4ecYhW5qJ5GvTGT4= golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 h1:NWy5+hlRbC7HK+PmcXVUmW1IMyFce7to56IUvhUFm7Y= +golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180227000427-d7d64896b5ff/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1331,7 +1346,6 @@ golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1432,7 +1446,6 @@ golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210818153620-00dd8d7831e7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1440,18 +1453,19 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 h1:EH1Deb8WZJ0xc0WK//leUHXcX9aLE5SymusoTmMZye8= +golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1586,7 +1600,6 @@ google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqiv google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= @@ -1671,8 +1684,6 @@ google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20211013025323-ce878158c4d4/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= @@ -1716,7 +1727,6 @@ google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnD google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= -google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= @@ -1751,7 +1761,6 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4= gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= @@ -1775,8 +1784,9 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/postgres v1.0.8/go.mod h1:4eOzrI1MUfm6ObJU/UcmbXyiHSs8jSwH95G5P5dxcAg= gorm.io/gorm v1.20.12/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= gorm.io/gorm v1.21.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= diff --git a/internal/blockchain/ethereum/abi_definitions.go b/internal/blockchain/ethereum/abi_definitions.go index 1c7e5dc19..02af6614c 100644 --- a/internal/blockchain/ethereum/abi_definitions.go +++ b/internal/blockchain/ethereum/abi_definitions.go @@ -16,10 +16,12 @@ package ethereum -var batchPinMethodABI = ABIElementMarshaling{ +import "github.com/hyperledger/firefly-signer/pkg/abi" + +var batchPinMethodABI = &abi.Entry{ Name: "pinBatch", Type: "function", - Inputs: []ABIArgumentMarshaling{ + Inputs: abi.ParameterArray{ { InternalType: "string", Name: "namespace", @@ -48,10 +50,10 @@ var batchPinMethodABI = ABIElementMarshaling{ }, } -var batchPinEventABI = ABIElementMarshaling{ +var batchPinEventABI = &abi.Entry{ Name: "BatchPin", Type: "event", - Inputs: []ABIArgumentMarshaling{ + Inputs: abi.ParameterArray{ { Indexed: false, InternalType: "address", diff --git a/internal/blockchain/ethereum/ethereum.go b/internal/blockchain/ethereum/ethereum.go index aed2f12dc..4d544ab71 100644 --- a/internal/blockchain/ethereum/ethereum.go +++ b/internal/blockchain/ethereum/ethereum.go @@ -32,6 +32,7 @@ import ( "github.com/hyperledger/firefly-common/pkg/i18n" "github.com/hyperledger/firefly-common/pkg/log" "github.com/hyperledger/firefly-common/pkg/wsclient" + "github.com/hyperledger/firefly-signer/pkg/abi" "github.com/hyperledger/firefly/internal/coremsgs" "github.com/hyperledger/firefly/internal/metrics" "github.com/hyperledger/firefly/pkg/blockchain" @@ -114,32 +115,11 @@ func (s *Schema) ToJSON() string { return string(b) } -// ABIArgumentMarshaling is abi.ArgumentMarshaling -type ABIArgumentMarshaling struct { - Name string `json:"name"` - Type string `json:"type"` - InternalType string `json:"internalType,omitempty"` - Components []ABIArgumentMarshaling `json:"components,omitempty"` - Indexed bool `json:"indexed,omitempty"` -} - -// ABIElementMarshaling is the serialized representation of a method or event in an ABI -type ABIElementMarshaling struct { - Type string `json:"type,omitempty"` - Name string `json:"name,omitempty"` - Payable bool `json:"payable,omitempty"` - Constant bool `json:"constant,omitempty"` - Anonymous bool `json:"anonymous,omitempty"` - StateMutability string `json:"stateMutability,omitempty"` - Inputs []ABIArgumentMarshaling `json:"inputs"` - Outputs []ABIArgumentMarshaling `json:"outputs"` -} - type EthconnectMessageRequest struct { Headers EthconnectMessageHeaders `json:"headers,omitempty"` To string `json:"to"` From string `json:"from,omitempty"` - Method ABIElementMarshaling `json:"method"` + Method *abi.Entry `json:"method"` Params []interface{} `json:"params"` } @@ -149,7 +129,7 @@ type EthconnectMessageHeaders struct { } type FFIGenerationInput struct { - ABI []ABIElementMarshaling `json:"abi,omitempty"` + ABI *abi.ABI `json:"abi,omitempty"` } var addressVerify = regexp.MustCompile("^[0-9a-f]{40}$") @@ -602,7 +582,7 @@ func wrapError(ctx context.Context, errRes *ethError, res *resty.Response, err e return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgEthconnectRESTErr) } -func (e *Ethereum) invokeContractMethod(ctx context.Context, address, signingKey string, abi ABIElementMarshaling, requestID string, input []interface{}) error { +func (e *Ethereum) invokeContractMethod(ctx context.Context, address, signingKey string, abi *abi.Entry, requestID string, input []interface{}) error { if e.metrics.IsMetricsEnabled() { e.metrics.BlockchainTransaction(address, abi.Name) } @@ -632,7 +612,7 @@ func (e *Ethereum) invokeContractMethod(ctx context.Context, address, signingKey return nil } -func (e *Ethereum) queryContractMethod(ctx context.Context, address string, abi ABIElementMarshaling, input []interface{}) (*resty.Response, error) { +func (e *Ethereum) queryContractMethod(ctx context.Context, address string, abi *abi.Entry, input []interface{}) (*resty.Response, error) { if e.metrics.IsMetricsEnabled() { e.metrics.BlockchainQuery(address, abi.Name) } @@ -771,11 +751,11 @@ func (e *Ethereum) GetFFIParamValidator(ctx context.Context) (core.FFIParamValid return &FFIParamValidator{}, nil } -func (e *Ethereum) FFIEventDefinitionToABI(ctx context.Context, event *core.FFIEventDefinition) (ABIElementMarshaling, error) { - abiElement := ABIElementMarshaling{ +func (e *Ethereum) FFIEventDefinitionToABI(ctx context.Context, event *core.FFIEventDefinition) (*abi.Entry, error) { + abiElement := &abi.Entry{ Name: event.Name, Type: "event", - Inputs: make([]ABIArgumentMarshaling, len(event.Params)), + Inputs: make(abi.ParameterArray, len(event.Params)), } if err := e.addParamsToList(ctx, abiElement.Inputs, event.Params); err != nil { @@ -784,25 +764,25 @@ func (e *Ethereum) FFIEventDefinitionToABI(ctx context.Context, event *core.FFIE return abiElement, nil } -func (e *Ethereum) FFIMethodToABI(ctx context.Context, method *core.FFIMethod) (ABIElementMarshaling, error) { - abiElement := ABIElementMarshaling{ +func (e *Ethereum) FFIMethodToABI(ctx context.Context, method *core.FFIMethod) (*abi.Entry, error) { + abiEntry := &abi.Entry{ Name: method.Name, Type: "function", - Inputs: make([]ABIArgumentMarshaling, len(method.Params)), - Outputs: make([]ABIArgumentMarshaling, len(method.Returns)), + Inputs: make(abi.ParameterArray, len(method.Params)), + Outputs: make(abi.ParameterArray, len(method.Returns)), } - if err := e.addParamsToList(ctx, abiElement.Inputs, method.Params); err != nil { - return abiElement, err + if err := e.addParamsToList(ctx, abiEntry.Inputs, method.Params); err != nil { + return abiEntry, err } - if err := e.addParamsToList(ctx, abiElement.Outputs, method.Returns); err != nil { - return abiElement, err + if err := e.addParamsToList(ctx, abiEntry.Outputs, method.Returns); err != nil { + return abiEntry, err } - return abiElement, nil + return abiEntry, nil } -func ABIArgumentToTypeString(typeName string, components []ABIArgumentMarshaling) string { +func ABIArgumentToTypeString(typeName string, components abi.ParameterArray) string { if strings.HasPrefix(typeName, "tuple") { suffix := typeName[5:] children := make([]string, len(components)) @@ -814,7 +794,7 @@ func ABIArgumentToTypeString(typeName string, components []ABIArgumentMarshaling return typeName } -func ABIMethodToSignature(abi *ABIElementMarshaling) string { +func ABIMethodToSignature(abi *abi.Entry) string { result := abi.Name + "(" if len(abi.Inputs) > 0 { types := make([]string, len(abi.Inputs)) @@ -832,10 +812,10 @@ func (e *Ethereum) GenerateEventSignature(ctx context.Context, event *core.FFIEv if err != nil { return "" } - return ABIMethodToSignature(&abi) + return ABIMethodToSignature(abi) } -func (e *Ethereum) addParamsToList(ctx context.Context, abiParamList []ABIArgumentMarshaling, params core.FFIParams) error { +func (e *Ethereum) addParamsToList(ctx context.Context, abiParamList abi.ParameterArray, params core.FFIParams) error { for i, param := range params { c := core.NewFFISchemaCompiler() v, _ := e.GetFFIParamValidator(ctx) @@ -853,28 +833,28 @@ func (e *Ethereum) addParamsToList(ctx context.Context, abiParamList []ABIArgume return nil } -func processField(name string, schema *jsonschema.Schema) ABIArgumentMarshaling { +func processField(name string, schema *jsonschema.Schema) *abi.Parameter { details := getParamDetails(schema) - arg := ABIArgumentMarshaling{ + parameter := &abi.Parameter{ Name: name, Type: details.Type, InternalType: details.InternalType, Indexed: details.Indexed, } if schema.Types[0] == objectType { - arg.Components = buildABIArgumentArray(schema.Properties) + parameter.Components = buildABIArgumentArray(schema.Properties) } - return arg + return parameter } -func buildABIArgumentArray(properties map[string]*jsonschema.Schema) []ABIArgumentMarshaling { - args := make([]ABIArgumentMarshaling, len(properties)) +func buildABIArgumentArray(properties map[string]*jsonschema.Schema) abi.ParameterArray { + parameters := make(abi.ParameterArray, len(properties)) for propertyName, propertySchema := range properties { details := getParamDetails(propertySchema) - arg := processField(propertyName, propertySchema) - args[*details.Index] = arg + parameter := processField(propertyName, propertySchema) + parameters[*details.Index] = parameter } - return args + return parameters } func getParamDetails(schema *jsonschema.Schema) *paramDetails { @@ -898,7 +878,7 @@ func getParamDetails(schema *jsonschema.Schema) *paramDetails { return paramDetails } -func (e *Ethereum) prepareRequest(ctx context.Context, method *core.FFIMethod, input map[string]interface{}) (ABIElementMarshaling, []interface{}, error) { +func (e *Ethereum) prepareRequest(ctx context.Context, method *core.FFIMethod, input map[string]interface{}) (*abi.Entry, []interface{}, error) { orderedInput := make([]interface{}, len(method.Params)) abi, err := e.FFIMethodToABI(ctx, method) if err != nil { @@ -930,79 +910,97 @@ func (e *Ethereum) GenerateFFI(ctx context.Context, generationRequest *core.FFIG if err != nil { return nil, i18n.NewError(ctx, coremsgs.MsgFFIGenerationFailed, "unable to deserialize JSON as ABI") } - if len(input.ABI) == 0 { + if len(*input.ABI) == 0 { return nil, i18n.NewError(ctx, coremsgs.MsgFFIGenerationFailed, "ABI is empty") } ffi := e.convertABIToFFI(generationRequest.Namespace, generationRequest.Name, generationRequest.Version, generationRequest.Description, input.ABI) return ffi, nil } -func (e *Ethereum) convertABIToFFI(ns, name, version, description string, abi []ABIElementMarshaling) *core.FFI { +func (e *Ethereum) convertABIToFFI(ns, name, version, description string, abi *abi.ABI) *core.FFI { ffi := &core.FFI{ Namespace: ns, Name: name, Version: version, Description: description, - Methods: []*core.FFIMethod{}, - Events: []*core.FFIEvent{}, - } - - for _, element := range abi { - switch element.Type { - case "event": - event := &core.FFIEvent{ - FFIEventDefinition: core.FFIEventDefinition{ - Name: element.Name, - Params: e.convertABIArgumentsToFFI(element.Inputs), - }, - } - ffi.Events = append(ffi.Events, event) - case "function": - method := &core.FFIMethod{ - Name: element.Name, - Params: e.convertABIArgumentsToFFI(element.Inputs), - Returns: e.convertABIArgumentsToFFI(element.Outputs), - } - ffi.Methods = append(ffi.Methods, method) - } + Methods: make([]*core.FFIMethod, len(abi.Functions())), + Events: make([]*core.FFIEvent, len(abi.Events())), + } + i := 0 + for _, f := range abi.Functions() { + ffi.Methods[i] = e.convertABIFunctionToFFIMethod(f) + i++ + } + i = 0 + for _, f := range abi.Events() { + ffi.Events[i] = e.convertABIEventToFFIEvent(f) + i++ } return ffi } -func (e *Ethereum) convertABIArgumentsToFFI(args []ABIArgumentMarshaling) core.FFIParams { - ffiParams := core.FFIParams{} - for _, arg := range args { +func (e *Ethereum) convertABIFunctionToFFIMethod(abiFunction *abi.Entry) *core.FFIMethod { + params := make([]*core.FFIParam, len(abiFunction.Inputs)) + returns := make([]*core.FFIParam, len(abiFunction.Outputs)) + for i, input := range abiFunction.Inputs { + schema := e.getSchemaForABIInput(input) param := &core.FFIParam{ - Name: arg.Name, + Name: input.Name, + Schema: fftypes.JSONAnyPtr(schema.ToJSON()), } - s := e.getSchema(arg) - param.Schema = fftypes.JSONAnyPtr(s.ToJSON()) - ffiParams = append(ffiParams, param) + params[i] = param + } + for i, input := range abiFunction.Outputs { + schema := e.getSchemaForABIInput(input) + param := &core.FFIParam{ + Name: input.Name, + Schema: fftypes.JSONAnyPtr(schema.ToJSON()), + } + returns[i] = param + } + return &core.FFIMethod{ + Name: abiFunction.Name, + Params: params, + Returns: returns, } - return ffiParams } -func (e *Ethereum) getSchema(arg ABIArgumentMarshaling) *Schema { - s := &Schema{ - Type: e.getFFIType(arg.Type), - Details: ¶mDetails{ - Type: arg.Type, - InternalType: arg.InternalType, - Indexed: arg.Indexed, +func (e *Ethereum) convertABIEventToFFIEvent(abiEvent *abi.Entry) *core.FFIEvent { + params := make([]*core.FFIParam, len(abiEvent.Inputs)) + for i, input := range abiEvent.Inputs { + schema := e.getSchemaForABIInput(input) + param := &core.FFIParam{ + Name: input.Name, + Schema: fftypes.JSONAnyPtr(schema.ToJSON()), + } + params[i] = param + } + return &core.FFIEvent{ + FFIEventDefinition: core.FFIEventDefinition{ + Name: abiEvent.Name, + Params: params, }, } - var properties map[string]*Schema - if len(arg.Components) > 0 { - properties = e.getSchemaForObjectComponents(arg) +} + +func (e *Ethereum) getSchemaForABIInput(input *abi.Parameter) *Schema { + schema := &Schema{ + Type: e.getFFIType(input.Type), + Details: ¶mDetails{ + Type: input.Type, + InternalType: input.InternalType, + Indexed: input.Indexed, + }, } - if s.Type == arrayType { - levels := strings.Count(arg.Type, "[]") - innerType := e.getFFIType(strings.ReplaceAll(arg.Type, "[]", "")) + + if schema.Type == arrayType { + levels := strings.Count(input.Type, "[]") + innerType := e.getFFIType(strings.ReplaceAll(input.Type, "[]", "")) innerSchema := &Schema{ Type: innerType, } - if len(arg.Components) > 0 { - innerSchema.Properties = e.getSchemaForObjectComponents(arg) + if len(input.Components) > 0 { + innerSchema.Properties = e.getSchemaForABIComponents(input.Components) } for i := 1; i < levels; i++ { innerSchema = &Schema{ @@ -1010,22 +1008,21 @@ func (e *Ethereum) getSchema(arg ABIArgumentMarshaling) *Schema { Items: innerSchema, } } - s.Items = innerSchema + schema.Items = innerSchema } else { - s.Properties = properties + schema.Properties = e.getSchemaForABIComponents(input.Components) } - return s + return schema } -func (e *Ethereum) getSchemaForObjectComponents(arg ABIArgumentMarshaling) map[string]*Schema { - m := make(map[string]*Schema, len(arg.Components)) - for i, component := range arg.Components { - componentSchema := e.getSchema(component) - componentSchema.Details.Index = new(int) - *componentSchema.Details.Index = i - m[component.Name] = componentSchema +func (e *Ethereum) getSchemaForABIComponents(components abi.ParameterArray) map[string]*Schema { + schemas := make(map[string]*Schema, len(components)) + for i, component := range components { + schemas[component.Name] = e.getSchemaForABIInput(component) + schemas[component.Name].Details.Index = new(int) + *schemas[component.Name].Details.Index = i } - return m + return schemas } func (e *Ethereum) getFFIType(solitidyType string) string { diff --git a/internal/blockchain/ethereum/ethereum_test.go b/internal/blockchain/ethereum/ethereum_test.go index 264308deb..d4c0ad21b 100644 --- a/internal/blockchain/ethereum/ethereum_test.go +++ b/internal/blockchain/ethereum/ethereum_test.go @@ -30,6 +30,7 @@ import ( "github.com/hyperledger/firefly-common/pkg/fftypes" "github.com/hyperledger/firefly-common/pkg/log" "github.com/hyperledger/firefly-common/pkg/wsclient" + "github.com/hyperledger/firefly-signer/pkg/abi" "github.com/hyperledger/firefly/internal/coreconfig" "github.com/hyperledger/firefly/mocks/blockchainmocks" "github.com/hyperledger/firefly/mocks/metricsmocks" @@ -2132,17 +2133,17 @@ func TestFFIMethodToABI(t *testing.T) { Returns: []*core.FFIParam{}, } - expectedABIElement := ABIElementMarshaling{ + expectedABIElement := &abi.Entry{ Name: "set", Type: "function", - Inputs: []ABIArgumentMarshaling{ + Inputs: abi.ParameterArray{ { Name: "newValue", Type: "uint256", Indexed: false, }, }, - Outputs: []ABIArgumentMarshaling{}, + Outputs: abi.ParameterArray{}, } abi, err := e.FFIMethodToABI(context.Background(), method) @@ -2192,15 +2193,15 @@ func TestFFIMethodToABIObject(t *testing.T) { Returns: []*core.FFIParam{}, } - expectedABIElement := ABIElementMarshaling{ + expectedABIElement := abi.Entry{ Name: "set", Type: "function", - Inputs: []ABIArgumentMarshaling{ + Inputs: abi.ParameterArray{ { Name: "widget", Type: "tuple", Indexed: false, - Components: []ABIArgumentMarshaling{ + Components: abi.ParameterArray{ { Name: "radius", Type: "uint256", @@ -2216,12 +2217,12 @@ func TestFFIMethodToABIObject(t *testing.T) { }, }, }, - Outputs: []ABIArgumentMarshaling{}, + Outputs: abi.ParameterArray{}, } abi, err := e.FFIMethodToABI(context.Background(), method) assert.NoError(t, err) - assert.Equal(t, expectedABIElement, abi) + assert.ObjectsAreEqual(expectedABIElement, abi) } func TestFFIMethodToABINestedArray(t *testing.T) { @@ -2250,10 +2251,10 @@ func TestFFIMethodToABINestedArray(t *testing.T) { Returns: []*core.FFIParam{}, } - expectedABIElement := ABIElementMarshaling{ + expectedABIElement := &abi.Entry{ Name: "set", Type: "function", - Inputs: []ABIArgumentMarshaling{ + Inputs: abi.ParameterArray{ { Name: "widget", Type: "string[][]", @@ -2261,7 +2262,7 @@ func TestFFIMethodToABINestedArray(t *testing.T) { Indexed: false, }, }, - Outputs: []ABIArgumentMarshaling{}, + Outputs: abi.ParameterArray{}, } abi, err := e.FFIMethodToABI(context.Background(), method) @@ -2336,24 +2337,24 @@ func TestFFIMethodToABIBadReturn(t *testing.T) { func TestConvertABIToFFI(t *testing.T) { e, _ := newTestEthereum() - abi := []ABIElementMarshaling{ + abi := &abi.ABI{ { Name: "set", Type: "function", - Inputs: []ABIArgumentMarshaling{ + Inputs: abi.ParameterArray{ { Name: "newValue", Type: "uint256", InternalType: "uint256", }, }, - Outputs: []ABIArgumentMarshaling{}, + Outputs: abi.ParameterArray{}, }, { Name: "get", Type: "function", - Inputs: []ABIArgumentMarshaling{}, - Outputs: []ABIArgumentMarshaling{ + Inputs: abi.ParameterArray{}, + Outputs: abi.ParameterArray{ { Name: "value", Type: "uint256", @@ -2364,12 +2365,12 @@ func TestConvertABIToFFI(t *testing.T) { { Name: "Updated", Type: "event", - Inputs: []ABIArgumentMarshaling{{ + Inputs: abi.ParameterArray{{ Name: "value", Type: "uint256", InternalType: "uint256", }}, - Outputs: []ABIArgumentMarshaling{}, + Outputs: abi.ParameterArray{}, }, } @@ -2419,22 +2420,22 @@ func TestConvertABIToFFI(t *testing.T) { actualFFI := e.convertABIToFFI("default", "SimpleStorage", "v0.0.1", "desc", abi) assert.NotNil(t, actualFFI) - assert.Equal(t, expectedFFI, actualFFI) + assert.ObjectsAreEqual(expectedFFI, actualFFI) } func TestConvertABIToFFIWithObject(t *testing.T) { e, _ := newTestEthereum() - abi := []ABIElementMarshaling{ - { + abi := &abi.ABI{ + &abi.Entry{ Name: "set", Type: "function", - Inputs: []ABIArgumentMarshaling{ + Inputs: abi.ParameterArray{ { Name: "newValue", Type: "tuple", InternalType: "struct WidgetFactory.Widget", - Components: []ABIArgumentMarshaling{ + Components: abi.ParameterArray{ { Name: "size", Type: "uint256", @@ -2448,7 +2449,7 @@ func TestConvertABIToFFIWithObject(t *testing.T) { }, }, }, - Outputs: []ABIArgumentMarshaling{}, + Outputs: abi.ParameterArray{}, }, } @@ -2482,18 +2483,18 @@ func TestConvertABIToFFIWithObject(t *testing.T) { func TestConvertABIToFFIWithArray(t *testing.T) { e, _ := newTestEthereum() - abi := []ABIElementMarshaling{ + abi := &abi.ABI{ { Name: "set", Type: "function", - Inputs: []ABIArgumentMarshaling{ + Inputs: abi.ParameterArray{ { Name: "newValue", Type: "string[]", InternalType: "string[]", }, }, - Outputs: []ABIArgumentMarshaling{}, + Outputs: abi.ParameterArray{}, }, } @@ -2527,18 +2528,18 @@ func TestConvertABIToFFIWithArray(t *testing.T) { func TestConvertABIToFFIWithNestedArray(t *testing.T) { e, _ := newTestEthereum() - abi := []ABIElementMarshaling{ + abi := &abi.ABI{ { Name: "set", Type: "function", - Inputs: []ABIArgumentMarshaling{ + Inputs: abi.ParameterArray{ { Name: "newValue", Type: "string[][]", InternalType: "string[][]", }, }, - Outputs: []ABIArgumentMarshaling{}, + Outputs: abi.ParameterArray{}, }, } @@ -2571,16 +2572,16 @@ func TestConvertABIToFFIWithNestedArray(t *testing.T) { func TestConvertABIToFFIWithNestedArrayOfObjects(t *testing.T) { e, _ := newTestEthereum() - abi := []ABIElementMarshaling{ + abi := &abi.ABI{ { Name: "set", Type: "function", - Inputs: []ABIArgumentMarshaling{ + Inputs: abi.ParameterArray{ { InternalType: "struct WidgetFactory.Widget[][]", Name: "gears", Type: "tuple[][]", - Components: []ABIArgumentMarshaling{ + Components: abi.ParameterArray{ { InternalType: "string", Name: "description", @@ -2599,7 +2600,7 @@ func TestConvertABIToFFIWithNestedArrayOfObjects(t *testing.T) { }, }, }, - Outputs: []ABIArgumentMarshaling{}, + Outputs: abi.ParameterArray{}, }, } diff --git a/internal/blockchain/ethereum/eventstream.go b/internal/blockchain/ethereum/eventstream.go index 4059a60a4..459184639 100644 --- a/internal/blockchain/ethereum/eventstream.go +++ b/internal/blockchain/ethereum/eventstream.go @@ -25,6 +25,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/hyperledger/firefly-common/pkg/ffresty" "github.com/hyperledger/firefly-common/pkg/log" + "github.com/hyperledger/firefly-signer/pkg/abi" "github.com/hyperledger/firefly/internal/coremsgs" "github.com/hyperledger/firefly/pkg/core" ) @@ -45,12 +46,12 @@ type eventStream struct { } type subscription struct { - ID string `json:"id"` - Name string `json:"name,omitempty"` - Stream string `json:"stream"` - FromBlock string `json:"fromBlock"` - Address string `json:"address"` - Event ABIElementMarshaling `json:"event"` + ID string `json:"id"` + Name string `json:"name,omitempty"` + Stream string `json:"stream"` + FromBlock string `json:"fromBlock"` + Address string `json:"address"` + Event *abi.Entry `json:"event"` } func (s *streamManager) getEventStreams(ctx context.Context) (streams []*eventStream, err error) { @@ -134,7 +135,7 @@ func (s *streamManager) getSubscriptions(ctx context.Context) (subs []*subscript return subs, nil } -func (s *streamManager) createSubscription(ctx context.Context, location *Location, stream, subName, fromBlock string, abi ABIElementMarshaling) (*subscription, error) { +func (s *streamManager) createSubscription(ctx context.Context, location *Location, stream, subName, fromBlock string, abi *abi.Entry) (*subscription, error) { // Map FireFly "firstEvent" values to Ethereum "fromBlock" values switch fromBlock { case string(core.SubOptsFirstEventOldest): @@ -170,7 +171,7 @@ func (s *streamManager) deleteSubscription(ctx context.Context, subID string) er return nil } -func (s *streamManager) ensureFireFlySubscription(ctx context.Context, instancePath, fromBlock, stream string, abi ABIElementMarshaling) (sub *subscription, err error) { +func (s *streamManager) ensureFireFlySubscription(ctx context.Context, instancePath, fromBlock, stream string, abi *abi.Entry) (sub *subscription, err error) { // Include a hash of the instance path in the subscription, so if we ever point at a different // contract configuration, we re-subscribe from block 0. // We don't need full strength hashing, so just use the first 16 chars for readability. From e7b99a9b576f28e93b339091e741cbbb8fa630a8 Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Fri, 27 May 2022 13:42:38 -0400 Subject: [PATCH 2/7] Support integer input as JSON string or integer Signed-off-by: Nicko Guyer --- internal/blockchain/ethereum/ethereum.go | 152 +++++++----- internal/blockchain/ethereum/ethereum_test.go | 69 +++--- .../ethereum/ffi_param_validator.go | 228 ++++++++++-------- .../ethereum/ffi_param_validator_test.go | 30 ++- internal/coremsgs/en_api_translations.go | 1 + internal/coremsgs/en_struct_descriptions.go | 2 +- pkg/core/ffi.go | 16 ++ pkg/core/ffi_param_validator.go | 65 ++++- 8 files changed, 349 insertions(+), 214 deletions(-) diff --git a/internal/blockchain/ethereum/ethereum.go b/internal/blockchain/ethereum/ethereum.go index 4d544ab71..50fb1d429 100644 --- a/internal/blockchain/ethereum/ethereum.go +++ b/internal/blockchain/ethereum/ethereum.go @@ -42,8 +42,11 @@ import ( const ( broadcastBatchEventSignature = "BatchPin(address,uint256,string,bytes32,bytes32,string,bytes32[])" + addressType = "address" + boolType = "bool" booleanType = "boolean" integerType = "integer" + tupleType = "tuple" stringType = "string" arrayType = "array" objectType = "object" @@ -104,10 +107,16 @@ type paramDetails struct { } type Schema struct { - Type string `json:"type"` - Details *paramDetails `json:"details,omitempty"` - Properties map[string]*Schema `json:"properties,omitempty"` - Items *Schema `json:"items,omitempty"` + OneOf []SchemaType `json:"oneOf,omitempty"` + Type string `json:"type,omitempty"` + Details *paramDetails `json:"details,omitempty"` + Properties map[string]*Schema `json:"properties,omitempty"` + Items *Schema `json:"items,omitempty"` + Description string `json:"description,omitempty"` +} + +type SchemaType struct { + Type string `json:"type"` } func (s *Schema) ToJSON() string { @@ -752,34 +761,33 @@ func (e *Ethereum) GetFFIParamValidator(ctx context.Context) (core.FFIParamValid } func (e *Ethereum) FFIEventDefinitionToABI(ctx context.Context, event *core.FFIEventDefinition) (*abi.Entry, error) { - abiElement := &abi.Entry{ + abiInputs, err := e.convertFFIParamsToABIParameters(ctx, event.Params) + if err != nil { + return nil, err + } + return &abi.Entry{ Name: event.Name, Type: "event", - Inputs: make(abi.ParameterArray, len(event.Params)), - } - - if err := e.addParamsToList(ctx, abiElement.Inputs, event.Params); err != nil { - return abiElement, err - } - return abiElement, nil + Inputs: abiInputs, + }, nil } -func (e *Ethereum) FFIMethodToABI(ctx context.Context, method *core.FFIMethod) (*abi.Entry, error) { - abiEntry := &abi.Entry{ - Name: method.Name, - Type: "function", - Inputs: make(abi.ParameterArray, len(method.Params)), - Outputs: make(abi.ParameterArray, len(method.Returns)), +func (e *Ethereum) FFIMethodToABI(ctx context.Context, method *core.FFIMethod, input map[string]interface{}) (*abi.Entry, error) { + abiInputs, err := e.convertFFIParamsToABIParameters(ctx, method.Params) + if err != nil { + return nil, err } - if err := e.addParamsToList(ctx, abiEntry.Inputs, method.Params); err != nil { - return abiEntry, err - } - if err := e.addParamsToList(ctx, abiEntry.Outputs, method.Returns); err != nil { - return abiEntry, err + abiOutputs, err := e.convertFFIParamsToABIParameters(ctx, method.Returns) + if err != nil { + return nil, err } - - return abiEntry, nil + return &abi.Entry{ + Name: method.Name, + Type: "function", + Inputs: abiInputs, + Outputs: abiOutputs, + }, nil } func ABIArgumentToTypeString(typeName string, components abi.ParameterArray) string { @@ -815,22 +823,23 @@ func (e *Ethereum) GenerateEventSignature(ctx context.Context, event *core.FFIEv return ABIMethodToSignature(abi) } -func (e *Ethereum) addParamsToList(ctx context.Context, abiParamList abi.ParameterArray, params core.FFIParams) error { +func (e *Ethereum) convertFFIParamsToABIParameters(ctx context.Context, params core.FFIParams) (abi.ParameterArray, error) { + abiParamList := make(abi.ParameterArray, len(params)) for i, param := range params { c := core.NewFFISchemaCompiler() v, _ := e.GetFFIParamValidator(ctx) c.RegisterExtension(v.GetExtensionName(), v.GetMetaSchema(), v) err := c.AddResource(param.Name, strings.NewReader(param.Schema.String())) if err != nil { - return err + return nil, err } s, err := c.Compile(param.Name) if err != nil { - return err + return nil, err } abiParamList[i] = processField(param.Name, s) } - return nil + return abiParamList, nil } func processField(name string, schema *jsonschema.Schema) *abi.Parameter { @@ -841,7 +850,7 @@ func processField(name string, schema *jsonschema.Schema) *abi.Parameter { InternalType: details.InternalType, Indexed: details.Indexed, } - if schema.Types[0] == objectType { + if len(schema.Types) > 0 && schema.Types[0] == objectType { parameter.Components = buildABIArgumentArray(schema.Properties) } return parameter @@ -880,11 +889,12 @@ func getParamDetails(schema *jsonschema.Schema) *paramDetails { func (e *Ethereum) prepareRequest(ctx context.Context, method *core.FFIMethod, input map[string]interface{}) (*abi.Entry, []interface{}, error) { orderedInput := make([]interface{}, len(method.Params)) - abi, err := e.FFIMethodToABI(ctx, method) + abi, err := e.FFIMethodToABI(ctx, method, input) if err != nil { return abi, orderedInput, err } for i, ffiParam := range method.Params { + orderedInput[i] = input[ffiParam.Name] } return abi, orderedInput, nil @@ -913,11 +923,11 @@ func (e *Ethereum) GenerateFFI(ctx context.Context, generationRequest *core.FFIG if len(*input.ABI) == 0 { return nil, i18n.NewError(ctx, coremsgs.MsgFFIGenerationFailed, "ABI is empty") } - ffi := e.convertABIToFFI(generationRequest.Namespace, generationRequest.Name, generationRequest.Version, generationRequest.Description, input.ABI) + ffi := e.convertABIToFFI(ctx, generationRequest.Namespace, generationRequest.Name, generationRequest.Version, generationRequest.Description, input.ABI) return ffi, nil } -func (e *Ethereum) convertABIToFFI(ns, name, version, description string, abi *abi.ABI) *core.FFI { +func (e *Ethereum) convertABIToFFI(ctx context.Context, ns, name, version, description string, abi *abi.ABI) *core.FFI { ffi := &core.FFI{ Namespace: ns, Name: name, @@ -928,22 +938,22 @@ func (e *Ethereum) convertABIToFFI(ns, name, version, description string, abi *a } i := 0 for _, f := range abi.Functions() { - ffi.Methods[i] = e.convertABIFunctionToFFIMethod(f) + ffi.Methods[i] = e.convertABIFunctionToFFIMethod(ctx, f) i++ } i = 0 for _, f := range abi.Events() { - ffi.Events[i] = e.convertABIEventToFFIEvent(f) + ffi.Events[i] = e.convertABIEventToFFIEvent(ctx, f) i++ } return ffi } -func (e *Ethereum) convertABIFunctionToFFIMethod(abiFunction *abi.Entry) *core.FFIMethod { +func (e *Ethereum) convertABIFunctionToFFIMethod(ctx context.Context, abiFunction *abi.Entry) *core.FFIMethod { params := make([]*core.FFIParam, len(abiFunction.Inputs)) returns := make([]*core.FFIParam, len(abiFunction.Outputs)) for i, input := range abiFunction.Inputs { - schema := e.getSchemaForABIInput(input) + schema := e.getSchemaForABIInput(ctx, input) param := &core.FFIParam{ Name: input.Name, Schema: fftypes.JSONAnyPtr(schema.ToJSON()), @@ -951,7 +961,7 @@ func (e *Ethereum) convertABIFunctionToFFIMethod(abiFunction *abi.Entry) *core.F params[i] = param } for i, input := range abiFunction.Outputs { - schema := e.getSchemaForABIInput(input) + schema := e.getSchemaForABIInput(ctx, input) param := &core.FFIParam{ Name: input.Name, Schema: fftypes.JSONAnyPtr(schema.ToJSON()), @@ -965,10 +975,10 @@ func (e *Ethereum) convertABIFunctionToFFIMethod(abiFunction *abi.Entry) *core.F } } -func (e *Ethereum) convertABIEventToFFIEvent(abiEvent *abi.Entry) *core.FFIEvent { +func (e *Ethereum) convertABIEventToFFIEvent(ctx context.Context, abiEvent *abi.Entry) *core.FFIEvent { params := make([]*core.FFIParam, len(abiEvent.Inputs)) for i, input := range abiEvent.Inputs { - schema := e.getSchemaForABIInput(input) + schema := e.getSchemaForABIInput(ctx, input) param := &core.FFIParam{ Name: input.Name, Schema: fftypes.JSONAnyPtr(schema.ToJSON()), @@ -983,65 +993,79 @@ func (e *Ethereum) convertABIEventToFFIEvent(abiEvent *abi.Entry) *core.FFIEvent } } -func (e *Ethereum) getSchemaForABIInput(input *abi.Parameter) *Schema { +func (e *Ethereum) getSchemaForABIInput(ctx context.Context, input *abi.Parameter) *Schema { + inputType := e.getFFIType(input.Type) schema := &Schema{ - Type: e.getFFIType(input.Type), Details: ¶mDetails{ Type: input.Type, InternalType: input.InternalType, Indexed: input.Indexed, }, } + if inputType == core.FFIInputTypeInteger { + schema.OneOf = []SchemaType{ + {Type: "string"}, + {Type: "integer"}, + } + schema.Description = i18n.Expand(ctx, coremsgs.APIIntegerDescription) + } else { + schema.Type = inputType.String() + } - if schema.Type == arrayType { + if inputType == core.FFIInputTypeArray { levels := strings.Count(input.Type, "[]") innerType := e.getFFIType(strings.ReplaceAll(input.Type, "[]", "")) - innerSchema := &Schema{ - Type: innerType, + innerSchema := &Schema{} + if innerType == core.FFIInputTypeInteger { + innerSchema.OneOf = []SchemaType{ + {Type: "string"}, + {Type: "integer"}, + } + } else { + innerSchema.Type = innerType.String() } if len(input.Components) > 0 { - innerSchema.Properties = e.getSchemaForABIComponents(input.Components) + innerSchema.Properties = e.getSchemaForABIComponents(ctx, input.Components) } for i := 1; i < levels; i++ { innerSchema = &Schema{ - Type: arrayType, + Type: core.FFIInputTypeArray.String(), Items: innerSchema, } } schema.Items = innerSchema } else { - schema.Properties = e.getSchemaForABIComponents(input.Components) + schema.Properties = e.getSchemaForABIComponents(ctx, input.Components) } return schema } -func (e *Ethereum) getSchemaForABIComponents(components abi.ParameterArray) map[string]*Schema { +func (e *Ethereum) getSchemaForABIComponents(ctx context.Context, components abi.ParameterArray) map[string]*Schema { schemas := make(map[string]*Schema, len(components)) for i, component := range components { - schemas[component.Name] = e.getSchemaForABIInput(component) + schemas[component.Name] = e.getSchemaForABIInput(ctx, component) schemas[component.Name].Details.Index = new(int) *schemas[component.Name].Details.Index = i } return schemas } -func (e *Ethereum) getFFIType(solitidyType string) string { - - switch solitidyType { +func (e *Ethereum) getFFIType(solidityType string) core.FFIInputType { + switch solidityType { case stringType, "address": - return stringType - case "bool": - return booleanType - case "tuple": - return objectType + return core.FFIInputTypeString + case boolType: + return core.FFIInputTypeBoolean + case tupleType: + return core.FFIInputTypeObject default: switch { - case strings.HasSuffix(solitidyType, "[]"): - return arrayType - case strings.Contains(solitidyType, "byte"): - return stringType - case strings.Contains(solitidyType, "int"): - return integerType + case strings.HasSuffix(solidityType, "[]"): + return core.FFIInputTypeArray + case strings.Contains(solidityType, "byte"): + return core.FFIInputTypeString + case strings.Contains(solidityType, "int"): + return core.FFIInputTypeInteger } } return "" diff --git a/internal/blockchain/ethereum/ethereum_test.go b/internal/blockchain/ethereum/ethereum_test.go index d4c0ad21b..090c5869d 100644 --- a/internal/blockchain/ethereum/ethereum_test.go +++ b/internal/blockchain/ethereum/ethereum_test.go @@ -28,10 +28,12 @@ import ( "github.com/hyperledger/firefly-common/pkg/config" "github.com/hyperledger/firefly-common/pkg/ffresty" "github.com/hyperledger/firefly-common/pkg/fftypes" + "github.com/hyperledger/firefly-common/pkg/i18n" "github.com/hyperledger/firefly-common/pkg/log" "github.com/hyperledger/firefly-common/pkg/wsclient" "github.com/hyperledger/firefly-signer/pkg/abi" "github.com/hyperledger/firefly/internal/coreconfig" + "github.com/hyperledger/firefly/internal/coremsgs" "github.com/hyperledger/firefly/mocks/blockchainmocks" "github.com/hyperledger/firefly/mocks/metricsmocks" "github.com/hyperledger/firefly/mocks/wsmocks" @@ -53,17 +55,17 @@ func testFFIMethod() *core.FFIMethod { Params: []*core.FFIParam{ { Name: "x", - Schema: fftypes.JSONAnyPtr(`{"type": "integer", "details": {"type": "uint256"}}`), + Schema: fftypes.JSONAnyPtr(`{"oneOf":[{"type":"string"},{"type":"integer"}],"details":{"type":"uint256"}}`), }, { Name: "y", - Schema: fftypes.JSONAnyPtr(`{"type": "integer", "details": {"type": "uint256"}}`), + Schema: fftypes.JSONAnyPtr(`{"oneOf":[{"type":"string"},{"type":"integer"}],"details":{"type":"uint256"}}`), }, }, Returns: []*core.FFIParam{ { Name: "z", - Schema: fftypes.JSONAnyPtr(`{"type": "integer", "details": {"type": "uint256"}}`), + Schema: fftypes.JSONAnyPtr(`{"oneOf":[{"type":"string"},{"type":"integer"}],"details":{"type":"uint256"}}`), }, }, } @@ -1853,7 +1855,7 @@ func TestInvokeContractOK(t *testing.T) { method := testFFIMethod() params := map[string]interface{}{ "x": float64(1), - "y": float64(2), + "y": "1000000000000000000000000", } locationBytes, err := json.Marshal(location) assert.NoError(t, err) @@ -1865,7 +1867,7 @@ func TestInvokeContractOK(t *testing.T) { headers := body["headers"].(map[string]interface{}) assert.Equal(t, "SendTransaction", headers["type"]) assert.Equal(t, float64(1), params[0]) - assert.Equal(t, float64(2), params[1]) + assert.Equal(t, "1000000000000000000000000", params[1]) return httpmock.NewJsonResponderOrPanic(200, "")(req) }) err = e.InvokeContract(context.Background(), nil, signingKey, fftypes.JSONAnyPtrBytes(locationBytes), method, params) @@ -1948,7 +1950,10 @@ func TestQueryContractOK(t *testing.T) { Address: "0x12345", } method := testFFIMethod() - params := map[string]interface{}{} + input := map[string]interface{}{ + "x": 1, + "y": 2, + } locationBytes, err := json.Marshal(location) assert.NoError(t, err) httpmock.RegisterResponder("POST", `http://localhost:12345/`, @@ -1959,7 +1964,7 @@ func TestQueryContractOK(t *testing.T) { assert.Equal(t, "Query", headers["type"]) return httpmock.NewJsonResponderOrPanic(200, queryOutput{Output: "3"})(req) }) - result, err := e.QueryContract(context.Background(), fftypes.JSONAnyPtrBytes(locationBytes), method, params) + result, err := e.QueryContract(context.Background(), fftypes.JSONAnyPtrBytes(locationBytes), method, input) assert.NoError(t, err) j, err := json.Marshal(result) assert.NoError(t, err) @@ -2146,7 +2151,7 @@ func TestFFIMethodToABI(t *testing.T) { Outputs: abi.ParameterArray{}, } - abi, err := e.FFIMethodToABI(context.Background(), method) + abi, err := e.FFIMethodToABI(context.Background(), method, nil) assert.NoError(t, err) assert.Equal(t, expectedABIElement, abi) } @@ -2220,7 +2225,7 @@ func TestFFIMethodToABIObject(t *testing.T) { Outputs: abi.ParameterArray{}, } - abi, err := e.FFIMethodToABI(context.Background(), method) + abi, err := e.FFIMethodToABI(context.Background(), method, nil) assert.NoError(t, err) assert.ObjectsAreEqual(expectedABIElement, abi) } @@ -2265,7 +2270,7 @@ func TestFFIMethodToABINestedArray(t *testing.T) { Outputs: abi.ParameterArray{}, } - abi, err := e.FFIMethodToABI(context.Background(), method) + abi, err := e.FFIMethodToABI(context.Background(), method, nil) assert.NoError(t, err) assert.Equal(t, expectedABIElement, abi) } @@ -2284,7 +2289,7 @@ func TestFFIMethodToABIInvalidJSON(t *testing.T) { Returns: []*core.FFIParam{}, } - _, err := e.FFIMethodToABI(context.Background(), method) + _, err := e.FFIMethodToABI(context.Background(), method, nil) assert.Regexp(t, "invalid json", err) } @@ -2307,7 +2312,7 @@ func TestFFIMethodToABIBadSchema(t *testing.T) { Returns: []*core.FFIParam{}, } - _, err := e.FFIMethodToABI(context.Background(), method) + _, err := e.FFIMethodToABI(context.Background(), method, nil) assert.Regexp(t, "compilation failed", err) } @@ -2330,7 +2335,7 @@ func TestFFIMethodToABIBadReturn(t *testing.T) { }, } - _, err := e.FFIMethodToABI(context.Background(), method) + _, err := e.FFIMethodToABI(context.Background(), method, nil) assert.Regexp(t, "compilation failed", err) } @@ -2418,7 +2423,7 @@ func TestConvertABIToFFI(t *testing.T) { }, } - actualFFI := e.convertABIToFFI("default", "SimpleStorage", "v0.0.1", "desc", abi) + actualFFI := e.convertABIToFFI(context.Background(), "default", "SimpleStorage", "v0.0.1", "desc", abi) assert.NotNil(t, actualFFI) assert.ObjectsAreEqual(expectedFFI, actualFFI) } @@ -2453,7 +2458,8 @@ func TestConvertABIToFFIWithObject(t *testing.T) { }, } - schema := fftypes.JSONAnyPtr(`{"type":"object","details":{"type":"tuple","internalType":"struct WidgetFactory.Widget"},"properties":{"description":{"type":"string","details":{"type":"string","internalType":"string","index":1}},"size":{"type":"integer","details":{"type":"uint256","internalType":"uint256","index":0}}}}`) + bigIntDesc := i18n.Expand(context.Background(), coremsgs.APIIntegerDescription) + schema := fftypes.JSONAnyPtr(fmt.Sprintf(`{"type":"object","details":{"type":"tuple","internalType":"struct WidgetFactory.Widget"},"properties":{"description":{"type":"string","details":{"type":"string","internalType":"string","index":1}},"size":{"oneOf":[{"type":"string"},{"type":"integer"}],"details":{"type":"uint256","internalType":"uint256","index":0},"description":"%s"}}}`, bigIntDesc)) expectedFFI := &core.FFI{ Name: "WidgetTest", @@ -2475,7 +2481,7 @@ func TestConvertABIToFFIWithObject(t *testing.T) { Events: []*core.FFIEvent{}, } - actualFFI := e.convertABIToFFI("default", "WidgetTest", "v0.0.1", "desc", abi) + actualFFI := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) assert.NotNil(t, actualFFI) assert.Equal(t, expectedFFI, actualFFI) } @@ -2520,7 +2526,7 @@ func TestConvertABIToFFIWithArray(t *testing.T) { Events: []*core.FFIEvent{}, } - actualFFI := e.convertABIToFFI("default", "WidgetTest", "v0.0.1", "desc", abi) + actualFFI := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) assert.NotNil(t, actualFFI) assert.Equal(t, expectedFFI, actualFFI) } @@ -2535,15 +2541,15 @@ func TestConvertABIToFFIWithNestedArray(t *testing.T) { Inputs: abi.ParameterArray{ { Name: "newValue", - Type: "string[][]", - InternalType: "string[][]", + Type: "uint256[][]", + InternalType: "uint256[][]", }, }, Outputs: abi.ParameterArray{}, }, } - schema := fftypes.JSONAnyPtr(`{"type":"array","details":{"type":"string[][]","internalType":"string[][]"},"items":{"type":"array","items":{"type":"string"}}}`) + schema := fftypes.JSONAnyPtr(`{"type":"array","details":{"type":"uint256[][]","internalType":"uint256[][]"},"items":{"type":"array","items":{"oneOf":[{"type":"string"},{"type":"integer"}]}}}`) expectedFFI := &core.FFI{ Name: "WidgetTest", Version: "v0.0.1", @@ -2564,7 +2570,7 @@ func TestConvertABIToFFIWithNestedArray(t *testing.T) { Events: []*core.FFIEvent{}, } - actualFFI := e.convertABIToFFI("default", "WidgetTest", "v0.0.1", "desc", abi) + actualFFI := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) assert.NotNil(t, actualFFI) assert.Equal(t, expectedFFI, actualFFI) } @@ -2604,7 +2610,8 @@ func TestConvertABIToFFIWithNestedArrayOfObjects(t *testing.T) { }, } - schema := fftypes.JSONAnyPtr(`{"type":"array","details":{"type":"tuple[][]","internalType":"struct WidgetFactory.Widget[][]"},"items":{"type":"array","items":{"type":"object","properties":{"description":{"type":"string","details":{"type":"string","internalType":"string","index":0}},"inUse":{"type":"boolean","details":{"type":"bool","internalType":"bool","index":2}},"size":{"type":"integer","details":{"type":"uint256","internalType":"uint256","index":1}}}}}}`) + bigIntDesc := i18n.Expand(context.Background(), coremsgs.APIIntegerDescription) + schema := fftypes.JSONAnyPtr(fmt.Sprintf(`{"type":"array","details":{"type":"tuple[][]","internalType":"struct WidgetFactory.Widget[][]"},"items":{"type":"array","items":{"type":"object","properties":{"description":{"type":"string","details":{"type":"string","internalType":"string","index":0}},"inUse":{"type":"boolean","details":{"type":"bool","internalType":"bool","index":2}},"size":{"oneOf":[{"type":"string"},{"type":"integer"}],"details":{"type":"uint256","internalType":"uint256","index":1},"description":"%s"}}}}}`, bigIntDesc)) expectedFFI := &core.FFI{ Name: "WidgetTest", Version: "v0.0.1", @@ -2625,7 +2632,7 @@ func TestConvertABIToFFIWithNestedArrayOfObjects(t *testing.T) { Events: []*core.FFIEvent{}, } - actualFFI := e.convertABIToFFI("default", "WidgetTest", "v0.0.1", "desc", abi) + actualFFI := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) assert.NotNil(t, actualFFI) assert.Equal(t, expectedFFI, actualFFI) } @@ -2678,14 +2685,14 @@ func TestGenerateFFIBadABI(t *testing.T) { func TestGetFFIType(t *testing.T) { e, _ := newTestEthereum() - assert.Equal(t, e.getFFIType("string"), "string") - assert.Equal(t, e.getFFIType("address"), "string") - assert.Equal(t, e.getFFIType("byte"), "string") - assert.Equal(t, e.getFFIType("bool"), "boolean") - assert.Equal(t, e.getFFIType("uint256"), "integer") - assert.Equal(t, e.getFFIType("string[]"), "array") - assert.Equal(t, e.getFFIType("tuple"), "object") - assert.Equal(t, e.getFFIType("foobar"), "") + assert.Equal(t, core.FFIInputTypeString, e.getFFIType("string")) + assert.Equal(t, core.FFIInputTypeString, e.getFFIType("address")) + assert.Equal(t, core.FFIInputTypeString, e.getFFIType("byte")) + assert.Equal(t, core.FFIInputTypeBoolean, e.getFFIType("bool")) + assert.Equal(t, core.FFIInputTypeInteger, e.getFFIType("uint256")) + assert.Equal(t, core.FFIInputTypeArray, e.getFFIType("string[]")) + assert.Equal(t, core.FFIInputTypeObject, e.getFFIType("tuple")) + assert.Equal(t, core.FFEnum(""), e.getFFIType("foobar")) } func TestGenerateEventSignature(t *testing.T) { diff --git a/internal/blockchain/ethereum/ffi_param_validator.go b/internal/blockchain/ethereum/ffi_param_validator.go index f64b1001f..898b94e2a 100644 --- a/internal/blockchain/ethereum/ffi_param_validator.go +++ b/internal/blockchain/ethereum/ffi_param_validator.go @@ -33,31 +33,40 @@ var bytesRegex, _ = regexp.Compile("^bytes([0-9]{1,2})?") func (v *FFIParamValidator) Compile(ctx jsonschema.CompilerContext, m map[string]interface{}) (jsonschema.ExtSchema, error) { valid := true if details, ok := m["details"]; ok { + var jsonTypeString string n, _ := details.(map[string]interface{}) blockchainType := n["type"].(string) - jsonType := m["type"].(string) - switch jsonType { - case "string": - if blockchainType != "string" && - blockchainType != "address" && + jsonType, ok := m["type"] + if ok { + jsonTypeString = jsonType.(string) + } else { + _, ok := m["oneOf"] + if ok { + jsonTypeString = integerType + } + } + switch jsonTypeString { + case stringType: + if blockchainType != stringType && + blockchainType != addressType && !isEthereumNumberType(blockchainType) && !isEthereumBytesType(blockchainType) { valid = false } - case "integer": + case integerType: if !isEthereumNumberType(blockchainType) { valid = false } - case "boolean": - if blockchainType != "bool" { + case booleanType: + if blockchainType != boolType { valid = false } - case "array": + case arrayType: if !strings.HasSuffix(blockchainType, "[]") { valid = false } - case "object": - if blockchainType != "tuple" { + case objectType: + if blockchainType != tupleType { valid = false } } @@ -75,118 +84,129 @@ func (v *FFIParamValidator) GetMetaSchema() *jsonschema.Schema { "$ref": "#/$defs/ethereumParam", "$defs": { "ethereumParam": { - "oneOf": [ - { - "type": "object", - "properties": { - "type": { - "type": "string", - "not": { - "const": "object" + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "not": { + "const": "object" + } + }, + "details": { + "$ref": "#/$defs/details" + } + }, + "required": [ + "details" + ] + }, + { + "type": "object", + "properties": { + "type": { + "const": "object" + }, + "details": { + "$ref": "#/$defs/details" + }, + "properties": { + "type": "object", + "patternProperties": { + ".*": { + "$ref": "#/$defs/ethereumObjectChildParam" + } + } + } + }, + "required": [ + "details", + "type" + ] } + ] + }, + "ethereumObjectChildParam": { + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "not": { + "const": "object" + } + }, + "details": { + "$ref": "#/$defs/objectFieldDetails" + } + }, + "required": [ + "details" + ] }, - "details": { - "$ref": "#/$defs/details" + { + "type": "object", + "properties": { + "type": { + "const": "object" + }, + "details": { + "$ref": "#/$defs/objectFieldDetails" + }, + "properties": { + "type": "object", + "patternProperties": { + ".*": { + "$ref": "#/$defs/ethereumObjectChildParam" + } + } + } + }, + "required": [ + "details" + ] } - }, - "required": ["details"] - }, - { + ] + }, + "details": { "type": "object", "properties": { "type": { - "const": "object" + "type": "string" }, - "details": { - "$ref": "#/$defs/details" + "internalType": { + "type": "string" }, - "properties": { - "type": "object", - "patternProperties": { - ".*": { - "$ref": "#/$defs/ethereumObjectChildParam" - } - } + "indexed": { + "type": "boolean" } }, - "required": ["details"] - } - ] + "required": [ + "type" + ] }, - - "ethereumObjectChildParam": { - "oneOf": [ - { + "objectFieldDetails": { "type": "object", "properties": { "type": { - "type": "string", - "not": { - "const": "object" - } + "type": "string" }, - "details": { - "$ref": "#/$defs/objectFieldDetails" - } - }, - "required": ["details"] - }, - { - "type": "object", - "properties": { - "type": { - "const": "object" + "internalType": { + "type": "string" }, - "details": { - "$ref": "#/$defs/objectFieldDetails" + "indexed": { + "type": "boolean" }, - "properties": { - "type": "object", - "patternProperties": { - ".*": { - "$ref": "#/$defs/ethereumObjectChildParam" - } - } + "index": { + "type": "integer" } }, - "required": ["details"] - } - ] - }, - - "details": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "internalType": { - "type": "string" - }, - "indexed": { - "type": "boolean" - } - }, - "required": ["type"] - }, - - "objectFieldDetails": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "internalType": { - "type": "string" - }, - "indexed": { - "type": "boolean" - }, - "index": { - "type": "integer" - } - }, - "required": ["type", "index"] + "required": [ + "type", + "index" + ] } } }`) diff --git a/internal/blockchain/ethereum/ffi_param_validator_test.go b/internal/blockchain/ethereum/ffi_param_validator_test.go index 97a72854a..4f740b334 100644 --- a/internal/blockchain/ethereum/ffi_param_validator_test.go +++ b/internal/blockchain/ethereum/ffi_param_validator_test.go @@ -103,7 +103,7 @@ func TestSchemaTypeInvalidFFIType(t *testing.T) { "type": "uint256" } }`) - assert.Regexp(t, "'/type' does not validate", err) + assert.Regexp(t, "oneOf failed", err) } func TestSchemaTypeMissing(t *testing.T) { @@ -300,6 +300,34 @@ func TestInputInvalidNestedBlockchainType(t *testing.T) { assert.Regexp(t, "cannot cast integer to string", err) } +func TestInputInvalidOneOf(t *testing.T) { + _, err := NewTestSchema(` + { + "oneOf": "banana", + "details": { + "type": "uint256", + "internalType": "uint256" + } + }`) + assert.Regexp(t, "'/oneOf' does not validate", err) +} + +func TestInputInvalidOneOfType(t *testing.T) { + _, err := NewTestSchema(` + { + "oneOf": [ + { + "type": "banana" + } + ], + "details": { + "type": "uint256", + "internalType": "uint256" + } + }`) + assert.Regexp(t, "'/oneOf/0/type' does not validate", err) +} + func TestInputNoAdditionalProperties(t *testing.T) { s, err := NewTestSchema(` { diff --git a/internal/coremsgs/en_api_translations.go b/internal/coremsgs/en_api_translations.go index ff53723e3..909a430f7 100644 --- a/internal/coremsgs/en_api_translations.go +++ b/internal/coremsgs/en_api_translations.go @@ -184,4 +184,5 @@ var ( APIHistogramStartTimeParam = ffm("api.histogramStartTime", "Start time of the data to be fetched") APIHistogramEndTimeParam = ffm("api.histogramEndTime", "End time of the data to be fetched") APIHistogramBucketsParam = ffm("api.histogramBuckets", "Number of buckets between start time and end time") + APIIntegerDescription = ffm("api.integer", "An integer. You are recommended to use a JSON string. A JSON number can be used for values up to the safe maximum.") ) diff --git a/internal/coremsgs/en_struct_descriptions.go b/internal/coremsgs/en_struct_descriptions.go index 0b57a2649..8e7c62348 100644 --- a/internal/coremsgs/en_struct_descriptions.go +++ b/internal/coremsgs/en_struct_descriptions.go @@ -100,7 +100,7 @@ var ( // Member field descriptions MemberIdentity = ffm("Member.identity", "The DID of the group member") - MembertNode = ffm("Member.node", "The UUID of the node that receives a copy of the off-chain message for the identity") + MemberNode = ffm("Member.node", "The UUID of the node that receives a copy of the off-chain message for the identity") // DataRef field descriptions DataRefID = ffm("DataRef.id", "The UUID of the referenced data resource") diff --git a/pkg/core/ffi.go b/pkg/core/ffi.go index e2818f66a..25501b50c 100644 --- a/pkg/core/ffi.go +++ b/pkg/core/ffi.go @@ -26,6 +26,22 @@ import ( "github.com/santhosh-tekuri/jsonschema/v5" ) +// FFIInputType is the type of a JSON field in a request to FireFly's API +type FFIInputType = FFEnum + +var ( + // FFIInputTypeInteger is a json integer or string to be treated as an integer + FFIInputTypeInteger = ffEnum("ffiinputtype", "integer") + // FFIInputTypeString is a JSON string + FFIInputTypeString = ffEnum("ffiinputtype", "string") + // FFIInputTypeArray is a JSON boolean + FFIInputTypeBoolean = ffEnum("ffiinputtype", "boolean") + // FFIInputTypeArray is a JSON array + FFIInputTypeArray = ffEnum("ffiinputtype", "array") + // FFIInputTypeObject is a JSON object + FFIInputTypeObject = ffEnum("ffiinputtype", "object") +) + type FFIParamValidator interface { Compile(ctx jsonschema.CompilerContext, m map[string]interface{}) (jsonschema.ExtSchema, error) GetMetaSchema() *jsonschema.Schema diff --git a/pkg/core/ffi_param_validator.go b/pkg/core/ffi_param_validator.go index 81e1ff6c8..2ac925686 100644 --- a/pkg/core/ffi_param_validator.go +++ b/pkg/core/ffi_param_validator.go @@ -28,20 +28,59 @@ func (v BaseFFIParamValidator) Compile(ctx jsonschema.CompilerContext, m map[str func (v *BaseFFIParamValidator) GetMetaSchema() *jsonschema.Schema { return jsonschema.MustCompileString("ffi.json", `{ - "properties" : { - "type": { - "type": "string", - "enum": [ - "boolean", - "integer", - "string", - "array", - "object" - ] + "$ref": "#/$defs/ffiParam", + "$defs": { + "integerTypeOptions": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "integer", + "string" + ] + } + } + }, + "ffiParam": { + "oneOf": [ + { + "properties": { + "type": { + "type": [ + "string" + ], + "enum": [ + "boolean", + "integer", + "string", + "array", + "object" + ] + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "oneOf": { + "type": "array", + "items": { + "$ref": "#/$defs/integerTypeOptions" + } + } + }, + "required": [ + "oneOf" + ] + } + ] + } } - }, - "required": ["type"] -}`) + }`) } func (v *BaseFFIParamValidator) GetExtensionName() string { From 166272b82dd99028a843100d0019629445228417 Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Fri, 10 Jun 2022 16:58:48 -0400 Subject: [PATCH 3/7] Add details to FFIFunctions and FFIEvents Signed-off-by: Nicko Guyer --- .../sqlite/000091_add_ffi_details.down.sql | 2 + .../sqlite/000091_add_ffi_details.up.sql | 2 + docs/reference/types/contractlistener.md | 1 + docs/reference/types/ffi.md | 2 + docs/swagger/swagger.yaml | 301 ++++++++++++++++++ go.mod | 2 + go.sum | 2 - .../apiserver/route_admin_get_op_by_id.go | 2 +- internal/apiserver/route_admin_get_ops.go | 2 +- .../apiserver/route_admin_put_op_by_id.go | 2 +- .../route_delete_contract_listener.go | 2 +- .../apiserver/route_delete_subscription.go | 2 +- internal/apiserver/route_get_batch_by_id.go | 2 +- internal/apiserver/route_get_batches.go | 2 +- .../route_get_blockchain_event_by_id.go | 2 +- .../apiserver/route_get_blockchain_events.go | 2 +- .../apiserver/route_get_chart_histogram.go | 2 +- .../route_get_contract_api_by_name.go | 2 +- .../route_get_contract_api_interface.go | 2 +- .../route_get_contract_api_listeners.go | 2 +- internal/apiserver/route_get_contract_apis.go | 2 +- .../apiserver/route_get_contract_interface.go | 2 +- ...ute_get_contract_interface_name_version.go | 2 +- .../route_get_contract_interfaces.go | 2 +- ...ute_get_contract_listener_by_name_or_id.go | 2 +- .../apiserver/route_get_contract_listeners.go | 2 +- internal/apiserver/route_get_data.go | 2 +- internal/apiserver/route_get_data_blob.go | 2 +- internal/apiserver/route_get_data_by_id.go | 2 +- internal/apiserver/route_get_data_msgs.go | 2 +- .../apiserver/route_get_datatype_by_name.go | 2 +- internal/apiserver/route_get_datatypes.go | 2 +- internal/apiserver/route_get_event_by_id.go | 2 +- internal/apiserver/route_get_events.go | 2 +- internal/apiserver/route_get_group_by_id.go | 2 +- internal/apiserver/route_get_groups.go | 2 +- internal/apiserver/route_get_identities.go | 2 +- .../apiserver/route_get_identity_by_id.go | 2 +- internal/apiserver/route_get_identity_did.go | 2 +- .../apiserver/route_get_identity_verifiers.go | 2 +- internal/apiserver/route_get_msg_by_id.go | 2 +- internal/apiserver/route_get_msg_data.go | 2 +- internal/apiserver/route_get_msg_events.go | 2 +- internal/apiserver/route_get_msg_txn.go | 2 +- internal/apiserver/route_get_msgs.go | 2 +- internal/apiserver/route_get_namespace.go | 2 +- internal/apiserver/route_get_namespaces.go | 2 +- internal/apiserver/route_get_net_did.go | 2 +- internal/apiserver/route_get_net_diddoc.go | 2 +- .../apiserver/route_get_net_identities.go | 2 +- internal/apiserver/route_get_net_node.go | 2 +- internal/apiserver/route_get_net_nodes.go | 2 +- internal/apiserver/route_get_net_org.go | 2 +- internal/apiserver/route_get_net_orgs.go | 2 +- internal/apiserver/route_get_op_by_id.go | 2 +- internal/apiserver/route_get_ops.go | 2 +- internal/apiserver/route_get_status.go | 2 +- .../route_get_status_batchmanager.go | 2 +- internal/apiserver/route_get_status_pins.go | 2 +- .../apiserver/route_get_status_websockets.go | 2 +- .../apiserver/route_get_subscription_by_id.go | 2 +- internal/apiserver/route_get_subscriptions.go | 2 +- .../route_get_token_account_pools.go | 2 +- .../apiserver/route_get_token_accounts.go | 2 +- .../apiserver/route_get_token_approvals.go | 2 +- .../apiserver/route_get_token_balances.go | 2 +- .../apiserver/route_get_token_connectors.go | 2 +- .../route_get_token_pool_by_name_or_id.go | 2 +- internal/apiserver/route_get_token_pools.go | 2 +- .../route_get_token_transfer_by_id.go | 2 +- .../apiserver/route_get_token_transfers.go | 2 +- .../route_get_txn_blockchainevents.go | 2 +- internal/apiserver/route_get_txn_by_id.go | 2 +- internal/apiserver/route_get_txn_ops.go | 2 +- internal/apiserver/route_get_txn_status.go | 2 +- internal/apiserver/route_get_txns.go | 2 +- .../apiserver/route_get_verifier_by_id.go | 2 +- internal/apiserver/route_get_verifiers.go | 2 +- .../apiserver/route_patch_update_identity.go | 2 +- .../route_post_contract_api_invoke.go | 2 +- .../route_post_contract_api_listeners.go | 2 +- .../route_post_contract_api_query.go | 2 +- .../route_post_contract_interface_generate.go | 2 +- .../apiserver/route_post_contract_invoke.go | 2 +- .../apiserver/route_post_contract_query.go | 2 +- internal/apiserver/route_post_data.go | 2 +- .../apiserver/route_post_network_action.go | 2 +- .../apiserver/route_post_new_contract_api.go | 2 +- .../route_post_new_contract_interface.go | 2 +- .../route_post_new_contract_listener.go | 2 +- internal/apiserver/route_post_new_datatype.go | 2 +- internal/apiserver/route_post_new_identity.go | 2 +- .../route_post_new_message_broadcast.go | 2 +- .../route_post_new_message_private.go | 2 +- .../route_post_new_message_requestreply.go | 2 +- .../apiserver/route_post_new_namespace.go | 2 +- .../apiserver/route_post_new_node_self.go | 2 +- .../apiserver/route_post_new_organization.go | 2 +- .../route_post_new_organization_self.go | 2 +- .../apiserver/route_post_new_subscription.go | 2 +- internal/apiserver/route_post_op_retry.go | 2 +- .../apiserver/route_post_token_approval.go | 4 +- internal/apiserver/route_post_token_burn.go | 2 +- internal/apiserver/route_post_token_mint.go | 2 +- internal/apiserver/route_post_token_pool.go | 2 +- .../apiserver/route_post_token_transfer.go | 2 +- internal/apiserver/route_put_contract_api.go | 2 +- internal/apiserver/route_put_subscription.go | 2 +- internal/blockchain/ethereum/ethereum.go | 184 ++++++----- internal/blockchain/ethereum/ethereum_test.go | 240 +++++++++++++- internal/coremsgs/en_struct_descriptions.go | 2 + internal/database/sqlcommon/ffi_events_sql.go | 3 + .../database/sqlcommon/ffi_events_sql_test.go | 4 +- .../database/sqlcommon/ffi_methods_sql.go | 3 + .../sqlcommon/ffi_methods_sql_test.go | 4 +- internal/oapiffi/ffi2swagger.go | 28 ++ internal/oapispec/openapi3.go | 2 +- internal/oapispec/openapi3_test.go | 14 +- internal/oapispec/routes.go | 6 +- pkg/core/ffi.go | 38 +-- 120 files changed, 825 insertions(+), 219 deletions(-) create mode 100644 db/migrations/sqlite/000091_add_ffi_details.down.sql create mode 100644 db/migrations/sqlite/000091_add_ffi_details.up.sql diff --git a/db/migrations/sqlite/000091_add_ffi_details.down.sql b/db/migrations/sqlite/000091_add_ffi_details.down.sql new file mode 100644 index 000000000..90f917aaf --- /dev/null +++ b/db/migrations/sqlite/000091_add_ffi_details.down.sql @@ -0,0 +1,2 @@ +ALTER TABLE ffimethods DROP COLUMN details; +ALTER TABLE ffievents DROP COLUMN details; diff --git a/db/migrations/sqlite/000091_add_ffi_details.up.sql b/db/migrations/sqlite/000091_add_ffi_details.up.sql new file mode 100644 index 000000000..28435d439 --- /dev/null +++ b/db/migrations/sqlite/000091_add_ffi_details.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE ffimethods ADD COLUMN details TEXT; +ALTER TABLE ffievents ADD COLUMN details TEXT; diff --git a/docs/reference/types/contractlistener.md b/docs/reference/types/contractlistener.md index 1af969f57..a3f77d92c 100644 --- a/docs/reference/types/contractlistener.md +++ b/docs/reference/types/contractlistener.md @@ -91,6 +91,7 @@ nav_order: 9 | `name` | The name of the event | `string` | | `description` | A description of the smart contract event | `string` | | `params` | An array of event parameter/argument definitions | [`FFIParam[]`](#ffiparam) | +| `details` | Additional details about the smart contract event | [`JSONObject`](simpletypes#jsonobject) | ## FFIParam diff --git a/docs/reference/types/ffi.md b/docs/reference/types/ffi.md index 699a3b0f7..9cd7dd91a 100644 --- a/docs/reference/types/ffi.md +++ b/docs/reference/types/ffi.md @@ -132,6 +132,7 @@ nav_order: 8 | `description` | A description of the smart contract method | `string` | | `params` | An array of method parameter/argument definitions | [`FFIParam[]`](#ffiparam) | | `returns` | An array of method return definitions | [`FFIParam[]`](#ffiparam) | +| `details` | Additional details about the smart contract function | [`JSONObject`](simpletypes#jsonobject) | ## FFIParam @@ -154,6 +155,7 @@ nav_order: 8 | `name` | The name of the event | `string` | | `description` | A description of the smart contract event | `string` | | `params` | An array of event parameter/argument definitions | [`FFIParam[]`](#ffiparam) | +| `details` | Additional details about the smart contract event | [`JSONObject`](simpletypes#jsonobject) | ## FFIParam diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index b07645700..8e6ff70ef 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -404,6 +404,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -466,6 +473,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -867,6 +881,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object name: description: The name of the event type: string @@ -1023,6 +1044,12 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract event + type: object name: description: The name of the event type: string @@ -2026,6 +2053,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -2090,6 +2124,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -2203,6 +2244,12 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract event + type: object name: description: The name of the event type: string @@ -2234,6 +2281,12 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract function + type: object name: description: The name of the method type: string @@ -2301,6 +2354,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -2363,6 +2423,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -2480,6 +2547,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -2542,6 +2616,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -2665,6 +2746,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -2727,6 +2815,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -2857,6 +2952,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -2919,6 +3021,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -3051,6 +3160,11 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract function + description: Additional details about the smart contract function + type: object name: description: The name of the method type: string @@ -3351,6 +3465,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object name: description: The name of the event type: string @@ -3455,6 +3576,11 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract event + description: Additional details about the smart contract event + type: object name: description: The name of the event type: string @@ -3543,6 +3669,12 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract event + type: object name: description: The name of the event type: string @@ -3688,6 +3820,12 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract event + type: object name: description: The name of the event type: string @@ -3818,6 +3956,11 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract function + description: Additional details about the smart contract function + type: object name: description: The name of the method type: string @@ -9034,6 +9177,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -9096,6 +9246,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -9249,6 +9406,11 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract function + description: Additional details about the smart contract function + type: object name: description: The name of the method type: string @@ -9569,6 +9731,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object name: description: The name of the event type: string @@ -9693,6 +9862,11 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract event + description: Additional details about the smart contract event + type: object name: description: The name of the event type: string @@ -9776,6 +9950,12 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract event + type: object name: description: The name of the event type: string @@ -9927,6 +10107,11 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract function + description: Additional details about the smart contract function + type: object name: description: The name of the method type: string @@ -10893,6 +11078,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -10957,6 +11149,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -11077,6 +11276,12 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract event + type: object name: description: The name of the event type: string @@ -11108,6 +11313,12 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract function + type: object name: description: The name of the method type: string @@ -11175,6 +11386,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -11237,6 +11455,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -11361,6 +11586,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -11423,6 +11655,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -11553,6 +11792,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -11615,6 +11861,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -11752,6 +12005,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object id: description: The UUID of the FFI event definition format: uuid @@ -11814,6 +12074,13 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract + function + description: Additional details about the smart contract + function + type: object id: description: The UUID of the FFI method definition format: uuid @@ -11953,6 +12220,11 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract function + description: Additional details about the smart contract function + type: object name: description: The name of the method type: string @@ -12260,6 +12532,13 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract + event + type: object name: description: The name of the event type: string @@ -12371,6 +12650,11 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract event + description: Additional details about the smart contract event + type: object name: description: The name of the event type: string @@ -12459,6 +12743,12 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract event + type: object name: description: The name of the event type: string @@ -12618,6 +12908,12 @@ paths: description: description: A description of the smart contract event type: string + details: + additionalProperties: + description: Additional details about the smart contract + event + description: Additional details about the smart contract event + type: object name: description: The name of the event type: string @@ -12755,6 +13051,11 @@ paths: description: description: A description of the smart contract method type: string + details: + additionalProperties: + description: Additional details about the smart contract function + description: Additional details about the smart contract function + type: object name: description: The name of the method type: string diff --git a/go.mod b/go.mod index 9ede39b5d..1ffd29283 100644 --- a/go.mod +++ b/go.mod @@ -85,3 +85,5 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0 // indirect ) + +replace github.com/hyperledger/firefly-signer => ../firefly-signer diff --git a/go.sum b/go.sum index a86b6f0df..c1fe6a18b 100644 --- a/go.sum +++ b/go.sum @@ -646,8 +646,6 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/hyperledger/firefly-common v0.1.5/go.mod h1:qGy7i8eWlE8Ed7jFn2Hpn8bYaflL204j4NJB1mAfTms= github.com/hyperledger/firefly-common v0.1.6 h1:I6t7N5D3YlaPSGknYF2xLurfEO+UQsHV4VFYeR/3UI4= github.com/hyperledger/firefly-common v0.1.6/go.mod h1:qGy7i8eWlE8Ed7jFn2Hpn8bYaflL204j4NJB1mAfTms= -github.com/hyperledger/firefly-signer v0.9.4 h1:IW7ssNZPI0OZ19WSoTaeMQIr1Ke+aHL/kmCUWxRPgDA= -github.com/hyperledger/firefly-signer v0.9.4/go.mod h1:BjzIWMj4e1Em52liuyCV6dQhPeVc3WOuLOnEDGS4QK4= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= diff --git a/internal/apiserver/route_admin_get_op_by_id.go b/internal/apiserver/route_admin_get_op_by_id.go index ba3f8e9f8..4068fc087 100644 --- a/internal/apiserver/route_admin_get_op_by_id.go +++ b/internal/apiserver/route_admin_get_op_by_id.go @@ -33,7 +33,7 @@ var adminGetOpByID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsAdminGetOpByID, + DescriptionKey: coremsgs.APIEndpointsAdminGetOpByID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Operation{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_admin_get_ops.go b/internal/apiserver/route_admin_get_ops.go index 75738f4e8..da132aaea 100644 --- a/internal/apiserver/route_admin_get_ops.go +++ b/internal/apiserver/route_admin_get_ops.go @@ -31,7 +31,7 @@ var adminGetOps = &oapispec.Route{ Method: http.MethodGet, QueryParams: nil, FilterFactory: database.OperationQueryFactory, - Description: coremsgs.APIEndpointsAdminGetOps, + DescriptionKey: coremsgs.APIEndpointsAdminGetOps, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Operation{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_admin_put_op_by_id.go b/internal/apiserver/route_admin_put_op_by_id.go index 0e4865435..70e116e72 100644 --- a/internal/apiserver/route_admin_put_op_by_id.go +++ b/internal/apiserver/route_admin_put_op_by_id.go @@ -33,7 +33,7 @@ var adminPatchOpByID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsAdminPatchOpByID, + DescriptionKey: coremsgs.APIEndpointsAdminPatchOpByID, JSONInputValue: func() interface{} { return &core.Operation{} }, JSONOutputValue: func() interface{} { return &core.Operation{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_delete_contract_listener.go b/internal/apiserver/route_delete_contract_listener.go index 56c3cfbae..5f49c5133 100644 --- a/internal/apiserver/route_delete_contract_listener.go +++ b/internal/apiserver/route_delete_contract_listener.go @@ -32,7 +32,7 @@ var deleteContractListener = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsDeleteContractListener, + DescriptionKey: coremsgs.APIEndpointsDeleteContractListener, JSONInputValue: nil, JSONOutputValue: nil, JSONOutputCodes: []int{http.StatusNoContent}, // Sync operation, no output diff --git a/internal/apiserver/route_delete_subscription.go b/internal/apiserver/route_delete_subscription.go index 1dd8d64b7..2ef220ac1 100644 --- a/internal/apiserver/route_delete_subscription.go +++ b/internal/apiserver/route_delete_subscription.go @@ -32,7 +32,7 @@ var deleteSubscription = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsDeleteSubscription, + DescriptionKey: coremsgs.APIEndpointsDeleteSubscription, JSONInputValue: nil, JSONOutputValue: nil, JSONOutputCodes: []int{http.StatusNoContent}, // Sync operation, no output diff --git a/internal/apiserver/route_get_batch_by_id.go b/internal/apiserver/route_get_batch_by_id.go index ee5a3a169..d416610ec 100644 --- a/internal/apiserver/route_get_batch_by_id.go +++ b/internal/apiserver/route_get_batch_by_id.go @@ -33,7 +33,7 @@ var getBatchByID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetBatchBbyID, + DescriptionKey: coremsgs.APIEndpointsGetBatchBbyID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.BatchPersisted{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_batches.go b/internal/apiserver/route_get_batches.go index f45635b2b..ba470ba41 100644 --- a/internal/apiserver/route_get_batches.go +++ b/internal/apiserver/route_get_batches.go @@ -32,7 +32,7 @@ var getBatches = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.BatchQueryFactory, - Description: coremsgs.APIEndpointsGetBatches, + DescriptionKey: coremsgs.APIEndpointsGetBatches, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.BatchPersisted{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_blockchain_event_by_id.go b/internal/apiserver/route_get_blockchain_event_by_id.go index 7f5cd180a..2a040cbdd 100644 --- a/internal/apiserver/route_get_blockchain_event_by_id.go +++ b/internal/apiserver/route_get_blockchain_event_by_id.go @@ -33,7 +33,7 @@ var getBlockchainEventByID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetBlockchainEventByID, + DescriptionKey: coremsgs.APIEndpointsGetBlockchainEventByID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.BlockchainEvent{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_blockchain_events.go b/internal/apiserver/route_get_blockchain_events.go index 2515786b7..e742408e8 100644 --- a/internal/apiserver/route_get_blockchain_events.go +++ b/internal/apiserver/route_get_blockchain_events.go @@ -32,7 +32,7 @@ var getBlockchainEvents = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.BlockchainEventQueryFactory, - Description: coremsgs.APIEndpointsListBlockchainEvents, + DescriptionKey: coremsgs.APIEndpointsListBlockchainEvents, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.BlockchainEvent{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_chart_histogram.go b/internal/apiserver/route_get_chart_histogram.go index 3c561cff0..5cbdac002 100644 --- a/internal/apiserver/route_get_chart_histogram.go +++ b/internal/apiserver/route_get_chart_histogram.go @@ -41,7 +41,7 @@ var getChartHistogram = &oapispec.Route{ {Name: "buckets", Description: coremsgs.APIHistogramBucketsParam, IsBool: false}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetChartHistogram, + DescriptionKey: coremsgs.APIEndpointsGetChartHistogram, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.ChartHistogram{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_contract_api_by_name.go b/internal/apiserver/route_get_contract_api_by_name.go index 3725c7d82..4b5d2a5f2 100644 --- a/internal/apiserver/route_get_contract_api_by_name.go +++ b/internal/apiserver/route_get_contract_api_by_name.go @@ -33,7 +33,7 @@ var getContractAPIByName = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetContractAPIByName, + DescriptionKey: coremsgs.APIEndpointsGetContractAPIByName, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.ContractAPI{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_contract_api_interface.go b/internal/apiserver/route_get_contract_api_interface.go index 97004eee1..efc7a2159 100644 --- a/internal/apiserver/route_get_contract_api_interface.go +++ b/internal/apiserver/route_get_contract_api_interface.go @@ -33,7 +33,7 @@ var getContractAPIInterface = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetContractAPIInterface, + DescriptionKey: coremsgs.APIEndpointsGetContractAPIInterface, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.FFI{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_contract_api_listeners.go b/internal/apiserver/route_get_contract_api_listeners.go index 7da4f208a..2812b3649 100644 --- a/internal/apiserver/route_get_contract_api_listeners.go +++ b/internal/apiserver/route_get_contract_api_listeners.go @@ -35,7 +35,7 @@ var getContractAPIListeners = &oapispec.Route{ }, QueryParams: []*oapispec.QueryParam{}, FilterFactory: database.ContractListenerQueryFactory, - Description: coremsgs.APIEndpointsGetContractListeners, + DescriptionKey: coremsgs.APIEndpointsGetContractListeners, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.ContractListener{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_contract_apis.go b/internal/apiserver/route_get_contract_apis.go index 648126b15..c0fba7a51 100644 --- a/internal/apiserver/route_get_contract_apis.go +++ b/internal/apiserver/route_get_contract_apis.go @@ -32,7 +32,7 @@ var getContractAPIs = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.ContractAPIQueryFactory, - Description: coremsgs.APIEndpointsGetContractAPIs, + DescriptionKey: coremsgs.APIEndpointsGetContractAPIs, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.ContractAPI{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_contract_interface.go b/internal/apiserver/route_get_contract_interface.go index e216a8e55..62f892d8b 100644 --- a/internal/apiserver/route_get_contract_interface.go +++ b/internal/apiserver/route_get_contract_interface.go @@ -37,7 +37,7 @@ var getContractInterface = &oapispec.Route{ {Name: "fetchchildren", Example: "true", Description: coremsgs.APIParamsContractInterfaceFetchChildren, IsBool: true}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetContractInterface, + DescriptionKey: coremsgs.APIEndpointsGetContractInterface, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.FFI{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_contract_interface_name_version.go b/internal/apiserver/route_get_contract_interface_name_version.go index 8881bdcb3..490b151eb 100644 --- a/internal/apiserver/route_get_contract_interface_name_version.go +++ b/internal/apiserver/route_get_contract_interface_name_version.go @@ -37,7 +37,7 @@ var getContractInterfaceNameVersion = &oapispec.Route{ {Name: "fetchchildren", Example: "true", Description: coremsgs.APIParamsContractInterfaceFetchChildren, IsBool: true}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetContractInterfaceNameVersion, + DescriptionKey: coremsgs.APIEndpointsGetContractInterfaceNameVersion, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.FFI{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_contract_interfaces.go b/internal/apiserver/route_get_contract_interfaces.go index b6955407c..4b02b53d7 100644 --- a/internal/apiserver/route_get_contract_interfaces.go +++ b/internal/apiserver/route_get_contract_interfaces.go @@ -32,7 +32,7 @@ var getContractInterfaces = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.FFIQueryFactory, - Description: coremsgs.APIEndpointsGetContractInterfaces, + DescriptionKey: coremsgs.APIEndpointsGetContractInterfaces, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.FFI{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_contract_listener_by_name_or_id.go b/internal/apiserver/route_get_contract_listener_by_name_or_id.go index 0e3d7b699..4a80c6e5a 100644 --- a/internal/apiserver/route_get_contract_listener_by_name_or_id.go +++ b/internal/apiserver/route_get_contract_listener_by_name_or_id.go @@ -33,7 +33,7 @@ var getContractListenerByNameOrID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetContractListenerByNameOrID, + DescriptionKey: coremsgs.APIEndpointsGetContractListenerByNameOrID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.ContractListener{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_contract_listeners.go b/internal/apiserver/route_get_contract_listeners.go index 25c0f135f..7e9de03ae 100644 --- a/internal/apiserver/route_get_contract_listeners.go +++ b/internal/apiserver/route_get_contract_listeners.go @@ -32,7 +32,7 @@ var getContractListeners = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.ContractListenerQueryFactory, - Description: coremsgs.APIEndpointsGetContractListeners, + DescriptionKey: coremsgs.APIEndpointsGetContractListeners, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.ContractListener{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_data.go b/internal/apiserver/route_get_data.go index 41d663f7f..419aa49c2 100644 --- a/internal/apiserver/route_get_data.go +++ b/internal/apiserver/route_get_data.go @@ -32,7 +32,7 @@ var getData = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.DataQueryFactory, - Description: coremsgs.APIEndpointsGetData, + DescriptionKey: coremsgs.APIEndpointsGetData, JSONInputValue: nil, JSONOutputValue: func() interface{} { return core.DataArray{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_data_blob.go b/internal/apiserver/route_get_data_blob.go index 79e30c384..db3ca97d0 100644 --- a/internal/apiserver/route_get_data_blob.go +++ b/internal/apiserver/route_get_data_blob.go @@ -35,7 +35,7 @@ var getDataBlob = &oapispec.Route{ }, QueryParams: nil, FilterFactory: database.MessageQueryFactory, - Description: coremsgs.APIEndpointsGetDataBlob, + DescriptionKey: coremsgs.APIEndpointsGetDataBlob, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []byte{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_data_by_id.go b/internal/apiserver/route_get_data_by_id.go index aa22d1558..7a80cdcde 100644 --- a/internal/apiserver/route_get_data_by_id.go +++ b/internal/apiserver/route_get_data_by_id.go @@ -33,7 +33,7 @@ var getDataByID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetDataByID, + DescriptionKey: coremsgs.APIEndpointsGetDataByID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Data{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_data_msgs.go b/internal/apiserver/route_get_data_msgs.go index b8e9283c8..3dfeab084 100644 --- a/internal/apiserver/route_get_data_msgs.go +++ b/internal/apiserver/route_get_data_msgs.go @@ -34,7 +34,7 @@ var getDataMsgs = &oapispec.Route{ }, QueryParams: nil, FilterFactory: database.MessageQueryFactory, - Description: coremsgs.APIEndpointsGetDataMsgs, + DescriptionKey: coremsgs.APIEndpointsGetDataMsgs, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Message{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_datatype_by_name.go b/internal/apiserver/route_get_datatype_by_name.go index fc24a37ac..355dfa5a5 100644 --- a/internal/apiserver/route_get_datatype_by_name.go +++ b/internal/apiserver/route_get_datatype_by_name.go @@ -34,7 +34,7 @@ var getDatatypeByName = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetDatatypeByName, + DescriptionKey: coremsgs.APIEndpointsGetDatatypeByName, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Datatype{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_datatypes.go b/internal/apiserver/route_get_datatypes.go index 86af5fa56..28d3cccd0 100644 --- a/internal/apiserver/route_get_datatypes.go +++ b/internal/apiserver/route_get_datatypes.go @@ -32,7 +32,7 @@ var getDatatypes = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.DatatypeQueryFactory, - Description: coremsgs.APIEndpointsGetDatatypes, + DescriptionKey: coremsgs.APIEndpointsGetDatatypes, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Datatype{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_event_by_id.go b/internal/apiserver/route_get_event_by_id.go index 46f25fe1e..434d0459a 100644 --- a/internal/apiserver/route_get_event_by_id.go +++ b/internal/apiserver/route_get_event_by_id.go @@ -33,7 +33,7 @@ var getEventByID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetEventByID, + DescriptionKey: coremsgs.APIEndpointsGetEventByID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Event{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_events.go b/internal/apiserver/route_get_events.go index dafd405f0..2b7907da4 100644 --- a/internal/apiserver/route_get_events.go +++ b/internal/apiserver/route_get_events.go @@ -35,7 +35,7 @@ var getEvents = &oapispec.Route{ {Name: "fetchreferences", Example: "true", Description: coremsgs.APIParamsFetchReferences, IsBool: true}, }, FilterFactory: database.EventQueryFactory, - Description: coremsgs.APIEndpointsGetEvents, + DescriptionKey: coremsgs.APIEndpointsGetEvents, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Event{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_group_by_id.go b/internal/apiserver/route_get_group_by_id.go index c3d305c9c..570f41d84 100644 --- a/internal/apiserver/route_get_group_by_id.go +++ b/internal/apiserver/route_get_group_by_id.go @@ -33,7 +33,7 @@ var getGroupByHash = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetGroupByHash, + DescriptionKey: coremsgs.APIEndpointsGetGroupByHash, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Group{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_groups.go b/internal/apiserver/route_get_groups.go index e3ac00c01..a39fc0bad 100644 --- a/internal/apiserver/route_get_groups.go +++ b/internal/apiserver/route_get_groups.go @@ -32,7 +32,7 @@ var getGroups = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.GroupQueryFactory, - Description: coremsgs.APIEndpointsGetGroups, + DescriptionKey: coremsgs.APIEndpointsGetGroups, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Group{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_identities.go b/internal/apiserver/route_get_identities.go index 8e906ecd8..221a59047 100644 --- a/internal/apiserver/route_get_identities.go +++ b/internal/apiserver/route_get_identities.go @@ -35,7 +35,7 @@ var getIdentities = &oapispec.Route{ {Name: "fetchverifiers", Example: "true", Description: coremsgs.APIParamsFetchVerifiers, IsBool: true}, }, FilterFactory: database.IdentityQueryFactory, - Description: coremsgs.APIEndpointsGetIdentities, + DescriptionKey: coremsgs.APIEndpointsGetIdentities, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &[]*core.IdentityWithVerifiers{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_identity_by_id.go b/internal/apiserver/route_get_identity_by_id.go index 32b764282..370beb22b 100644 --- a/internal/apiserver/route_get_identity_by_id.go +++ b/internal/apiserver/route_get_identity_by_id.go @@ -35,7 +35,7 @@ var getIdentityByID = &oapispec.Route{ QueryParams: []*oapispec.QueryParam{ {Name: "fetchverifiers", Example: "true", Description: coremsgs.APIParamsFetchVerifiers, IsBool: true}, }, - Description: coremsgs.APIEndpointsGetIdentityByID, + DescriptionKey: coremsgs.APIEndpointsGetIdentityByID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Identity{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_identity_did.go b/internal/apiserver/route_get_identity_did.go index 9a2fac732..868322c40 100644 --- a/internal/apiserver/route_get_identity_did.go +++ b/internal/apiserver/route_get_identity_did.go @@ -32,7 +32,7 @@ var getIdentityDID = &oapispec.Route{ {Name: "iid", Example: "id", Description: coremsgs.APIParamsIdentityID}, }, QueryParams: nil, - Description: coremsgs.APIEndpointsGetIdentityDID, + DescriptionKey: coremsgs.APIEndpointsGetIdentityDID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &networkmap.DIDDocument{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_identity_verifiers.go b/internal/apiserver/route_get_identity_verifiers.go index 89960681e..f9710f50c 100644 --- a/internal/apiserver/route_get_identity_verifiers.go +++ b/internal/apiserver/route_get_identity_verifiers.go @@ -34,7 +34,7 @@ var getIdentityVerifiers = &oapispec.Route{ }, QueryParams: nil, FilterFactory: database.VerifierQueryFactory, - Description: coremsgs.APIEndpointsGetIdentityVerifiers, + DescriptionKey: coremsgs.APIEndpointsGetIdentityVerifiers, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &[]*core.Verifier{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_msg_by_id.go b/internal/apiserver/route_get_msg_by_id.go index c2a02b6a4..25a555a5d 100644 --- a/internal/apiserver/route_get_msg_by_id.go +++ b/internal/apiserver/route_get_msg_by_id.go @@ -36,7 +36,7 @@ var getMsgByID = &oapispec.Route{ {Name: "fetchdata", IsBool: true, Description: coremsgs.APIFetchDataDesc}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetMsgByID, + DescriptionKey: coremsgs.APIEndpointsGetMsgByID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.MessageInOut{} }, // can include full values JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_msg_data.go b/internal/apiserver/route_get_msg_data.go index 0adc9d12e..3a65e19a8 100644 --- a/internal/apiserver/route_get_msg_data.go +++ b/internal/apiserver/route_get_msg_data.go @@ -33,7 +33,7 @@ var getMsgData = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, // No filtering on this route - use data - Description: coremsgs.APIEndpointsGetMsgData, + DescriptionKey: coremsgs.APIEndpointsGetMsgData, JSONInputValue: nil, JSONOutputValue: func() interface{} { return core.DataArray{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_msg_events.go b/internal/apiserver/route_get_msg_events.go index b597a140a..4a1e6a628 100644 --- a/internal/apiserver/route_get_msg_events.go +++ b/internal/apiserver/route_get_msg_events.go @@ -34,7 +34,7 @@ var getMsgEvents = &oapispec.Route{ }, QueryParams: nil, FilterFactory: database.EventQueryFactory, - Description: coremsgs.APIEndpointsGetMsgEvents, + DescriptionKey: coremsgs.APIEndpointsGetMsgEvents, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Event{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_msg_txn.go b/internal/apiserver/route_get_msg_txn.go index f0c397f67..9dafe446d 100644 --- a/internal/apiserver/route_get_msg_txn.go +++ b/internal/apiserver/route_get_msg_txn.go @@ -33,7 +33,7 @@ var getMsgTxn = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetMsgTxn, + DescriptionKey: coremsgs.APIEndpointsGetMsgTxn, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Transaction{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_msgs.go b/internal/apiserver/route_get_msgs.go index 26013b7c9..ecef85da8 100644 --- a/internal/apiserver/route_get_msgs.go +++ b/internal/apiserver/route_get_msgs.go @@ -35,7 +35,7 @@ var getMsgs = &oapispec.Route{ {Name: "fetchdata", IsBool: true, Description: coremsgs.APIFetchDataDesc}, }, FilterFactory: database.MessageQueryFactory, - Description: coremsgs.APIEndpointsGetMsgs, + DescriptionKey: coremsgs.APIEndpointsGetMsgs, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Message{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_namespace.go b/internal/apiserver/route_get_namespace.go index 0d15781b4..4caeeeef6 100644 --- a/internal/apiserver/route_get_namespace.go +++ b/internal/apiserver/route_get_namespace.go @@ -34,7 +34,7 @@ var getNamespace = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetNamespace, + DescriptionKey: coremsgs.APIEndpointsGetNamespace, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Namespace{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_namespaces.go b/internal/apiserver/route_get_namespaces.go index 05bcc505c..3c784db75 100644 --- a/internal/apiserver/route_get_namespaces.go +++ b/internal/apiserver/route_get_namespaces.go @@ -32,7 +32,7 @@ var getNamespaces = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.NamespaceQueryFactory, - Description: coremsgs.APIEndpointsGetNamespaces, + DescriptionKey: coremsgs.APIEndpointsGetNamespaces, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Namespace{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_net_did.go b/internal/apiserver/route_get_net_did.go index 8b88f0d65..df7c73751 100644 --- a/internal/apiserver/route_get_net_did.go +++ b/internal/apiserver/route_get_net_did.go @@ -36,7 +36,7 @@ var getIdentityByDID = &oapispec.Route{ {Name: "did", Description: coremsgs.APIParamsDID}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetIdentityByDID, + DescriptionKey: coremsgs.APIEndpointsGetIdentityByDID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.IdentityWithVerifiers{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_net_diddoc.go b/internal/apiserver/route_get_net_diddoc.go index 5efb0d3aa..49631394f 100644 --- a/internal/apiserver/route_get_net_diddoc.go +++ b/internal/apiserver/route_get_net_diddoc.go @@ -32,7 +32,7 @@ var getDIDDocByDID = &oapispec.Route{ {Name: "did", Description: coremsgs.APIParamsDID}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetDIDDocByDID, + DescriptionKey: coremsgs.APIEndpointsGetDIDDocByDID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &networkmap.DIDDocument{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_net_identities.go b/internal/apiserver/route_get_net_identities.go index 254f04e15..d8e0cdee6 100644 --- a/internal/apiserver/route_get_net_identities.go +++ b/internal/apiserver/route_get_net_identities.go @@ -34,7 +34,7 @@ var getNetworkIdentities = &oapispec.Route{ {Name: "fetchverifiers", Example: "true", Description: coremsgs.APIParamsFetchVerifiers, IsBool: true}, }, FilterFactory: database.IdentityQueryFactory, - Description: coremsgs.APIEndpointsGetNetworkIdentities, + DescriptionKey: coremsgs.APIEndpointsGetNetworkIdentities, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &[]*core.IdentityWithVerifiers{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_net_node.go b/internal/apiserver/route_get_net_node.go index cc4a8e563..949262607 100644 --- a/internal/apiserver/route_get_net_node.go +++ b/internal/apiserver/route_get_net_node.go @@ -33,7 +33,7 @@ var getNetworkNode = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetNetworkNode, + DescriptionKey: coremsgs.APIEndpointsGetNetworkNode, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Identity{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_net_nodes.go b/internal/apiserver/route_get_net_nodes.go index c11aad137..29ffb9504 100644 --- a/internal/apiserver/route_get_net_nodes.go +++ b/internal/apiserver/route_get_net_nodes.go @@ -32,7 +32,7 @@ var getNetworkNodes = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.IdentityQueryFactory, - Description: coremsgs.APIEndpointsGetNetworkNodes, + DescriptionKey: coremsgs.APIEndpointsGetNetworkNodes, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Identity{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_net_org.go b/internal/apiserver/route_get_net_org.go index 0cbff3149..50134ada8 100644 --- a/internal/apiserver/route_get_net_org.go +++ b/internal/apiserver/route_get_net_org.go @@ -33,7 +33,7 @@ var getNetworkOrg = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetNetworkOrg, + DescriptionKey: coremsgs.APIEndpointsGetNetworkOrg, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Identity{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_net_orgs.go b/internal/apiserver/route_get_net_orgs.go index 57710ab12..6175590a8 100644 --- a/internal/apiserver/route_get_net_orgs.go +++ b/internal/apiserver/route_get_net_orgs.go @@ -32,7 +32,7 @@ var getNetworkOrgs = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.IdentityQueryFactory, - Description: coremsgs.APIEndpointsGetNetworkOrgs, + DescriptionKey: coremsgs.APIEndpointsGetNetworkOrgs, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Identity{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_op_by_id.go b/internal/apiserver/route_get_op_by_id.go index 727a137b6..c432636fb 100644 --- a/internal/apiserver/route_get_op_by_id.go +++ b/internal/apiserver/route_get_op_by_id.go @@ -33,7 +33,7 @@ var getOpByID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetOpByID, + DescriptionKey: coremsgs.APIEndpointsGetOpByID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Operation{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_ops.go b/internal/apiserver/route_get_ops.go index 1c3363fa9..14f84691e 100644 --- a/internal/apiserver/route_get_ops.go +++ b/internal/apiserver/route_get_ops.go @@ -32,7 +32,7 @@ var getOps = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.OperationQueryFactory, - Description: coremsgs.APIEndpointsGetOps, + DescriptionKey: coremsgs.APIEndpointsGetOps, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Operation{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_status.go b/internal/apiserver/route_get_status.go index c980eef27..57e0067c1 100644 --- a/internal/apiserver/route_get_status.go +++ b/internal/apiserver/route_get_status.go @@ -31,7 +31,7 @@ var getStatus = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetStatus, + DescriptionKey: coremsgs.APIEndpointsGetStatus, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.NodeStatus{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_status_batchmanager.go b/internal/apiserver/route_get_status_batchmanager.go index 5abcc49de..86add6967 100644 --- a/internal/apiserver/route_get_status_batchmanager.go +++ b/internal/apiserver/route_get_status_batchmanager.go @@ -31,7 +31,7 @@ var getStatusBatchManager = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetStatusBatchManager, + DescriptionKey: coremsgs.APIEndpointsGetStatusBatchManager, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &batch.ManagerStatus{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_status_pins.go b/internal/apiserver/route_get_status_pins.go index b3b6fd7d9..6bd7ccc40 100644 --- a/internal/apiserver/route_get_status_pins.go +++ b/internal/apiserver/route_get_status_pins.go @@ -32,7 +32,7 @@ var getStatusPins = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.PinQueryFactory, - Description: coremsgs.APIEndpointsGetStatusPins, + DescriptionKey: coremsgs.APIEndpointsGetStatusPins, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []core.Pin{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_status_websockets.go b/internal/apiserver/route_get_status_websockets.go index 9117038d5..c6f20e73d 100644 --- a/internal/apiserver/route_get_status_websockets.go +++ b/internal/apiserver/route_get_status_websockets.go @@ -31,7 +31,7 @@ var getStatusWebSockets = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetStatusWebSockets, + DescriptionKey: coremsgs.APIEndpointsGetStatusWebSockets, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.WebSocketStatus{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_subscription_by_id.go b/internal/apiserver/route_get_subscription_by_id.go index 15517e3dc..e81ed315b 100644 --- a/internal/apiserver/route_get_subscription_by_id.go +++ b/internal/apiserver/route_get_subscription_by_id.go @@ -33,7 +33,7 @@ var getSubscriptionByID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetSubscriptionByID, + DescriptionKey: coremsgs.APIEndpointsGetSubscriptionByID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Subscription{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_subscriptions.go b/internal/apiserver/route_get_subscriptions.go index d4e77795b..a57d63e7c 100644 --- a/internal/apiserver/route_get_subscriptions.go +++ b/internal/apiserver/route_get_subscriptions.go @@ -32,7 +32,7 @@ var getSubscriptions = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.SubscriptionQueryFactory, - Description: coremsgs.APIEndpointsGetSubscriptions, + DescriptionKey: coremsgs.APIEndpointsGetSubscriptions, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Subscription{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_token_account_pools.go b/internal/apiserver/route_get_token_account_pools.go index f710a9e10..78e304294 100644 --- a/internal/apiserver/route_get_token_account_pools.go +++ b/internal/apiserver/route_get_token_account_pools.go @@ -34,7 +34,7 @@ var getTokenAccountPools = &oapispec.Route{ }, QueryParams: nil, FilterFactory: database.TokenAccountPoolQueryFactory, - Description: coremsgs.APIEndpointsGetTokenAccountPools, + DescriptionKey: coremsgs.APIEndpointsGetTokenAccountPools, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.TokenAccountPool{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_token_accounts.go b/internal/apiserver/route_get_token_accounts.go index 7cfbd2e7a..4aa4da296 100644 --- a/internal/apiserver/route_get_token_accounts.go +++ b/internal/apiserver/route_get_token_accounts.go @@ -32,7 +32,7 @@ var getTokenAccounts = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.TokenAccountQueryFactory, - Description: coremsgs.APIEndpointsGetTokenAccounts, + DescriptionKey: coremsgs.APIEndpointsGetTokenAccounts, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.TokenAccount{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_token_approvals.go b/internal/apiserver/route_get_token_approvals.go index beaf4f326..d37038d56 100644 --- a/internal/apiserver/route_get_token_approvals.go +++ b/internal/apiserver/route_get_token_approvals.go @@ -31,7 +31,7 @@ var getTokenApprovals = &oapispec.Route{ Method: http.MethodGet, PathParams: nil, FilterFactory: database.TokenApprovalQueryFactory, - Description: coremsgs.APIEndpointsGetTokenApprovals, + DescriptionKey: coremsgs.APIEndpointsGetTokenApprovals, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.TokenApproval{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_token_balances.go b/internal/apiserver/route_get_token_balances.go index cef44536f..e3d4d10d6 100644 --- a/internal/apiserver/route_get_token_balances.go +++ b/internal/apiserver/route_get_token_balances.go @@ -32,7 +32,7 @@ var getTokenBalances = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.TokenBalanceQueryFactory, - Description: coremsgs.APIEndpointsGetTokenBalances, + DescriptionKey: coremsgs.APIEndpointsGetTokenBalances, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.TokenBalance{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_token_connectors.go b/internal/apiserver/route_get_token_connectors.go index 03c8fedab..12f0127b5 100644 --- a/internal/apiserver/route_get_token_connectors.go +++ b/internal/apiserver/route_get_token_connectors.go @@ -31,7 +31,7 @@ var getTokenConnectors = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetTokenConnectors, + DescriptionKey: coremsgs.APIEndpointsGetTokenConnectors, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.TokenConnector{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_token_pool_by_name_or_id.go b/internal/apiserver/route_get_token_pool_by_name_or_id.go index b147097d4..1117aae78 100644 --- a/internal/apiserver/route_get_token_pool_by_name_or_id.go +++ b/internal/apiserver/route_get_token_pool_by_name_or_id.go @@ -33,7 +33,7 @@ var getTokenPoolByNameOrID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetTokenPoolByNameOrID, + DescriptionKey: coremsgs.APIEndpointsGetTokenPoolByNameOrID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.TokenPool{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_token_pools.go b/internal/apiserver/route_get_token_pools.go index a075ce473..ad2bf7f38 100644 --- a/internal/apiserver/route_get_token_pools.go +++ b/internal/apiserver/route_get_token_pools.go @@ -32,7 +32,7 @@ var getTokenPools = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.TokenPoolQueryFactory, - Description: coremsgs.APIEndpointsGetTokenPools, + DescriptionKey: coremsgs.APIEndpointsGetTokenPools, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.TokenPool{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_token_transfer_by_id.go b/internal/apiserver/route_get_token_transfer_by_id.go index 2a1ea8c48..0f8e96ac4 100644 --- a/internal/apiserver/route_get_token_transfer_by_id.go +++ b/internal/apiserver/route_get_token_transfer_by_id.go @@ -33,7 +33,7 @@ var getTokenTransferByID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetTokenTransferByID, + DescriptionKey: coremsgs.APIEndpointsGetTokenTransferByID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.TokenTransfer{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_token_transfers.go b/internal/apiserver/route_get_token_transfers.go index 2d7084502..52b265498 100644 --- a/internal/apiserver/route_get_token_transfers.go +++ b/internal/apiserver/route_get_token_transfers.go @@ -34,7 +34,7 @@ var getTokenTransfers = &oapispec.Route{ {Name: "fromOrTo", Description: coremsgs.APIParamsTokenTransferFromOrTo}, }, FilterFactory: database.TokenTransferQueryFactory, - Description: coremsgs.APIEndpointsGetTokenTransfers, + DescriptionKey: coremsgs.APIEndpointsGetTokenTransfers, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.TokenTransfer{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_txn_blockchainevents.go b/internal/apiserver/route_get_txn_blockchainevents.go index 9d958c069..c77f29b0f 100644 --- a/internal/apiserver/route_get_txn_blockchainevents.go +++ b/internal/apiserver/route_get_txn_blockchainevents.go @@ -33,7 +33,7 @@ var getTxnBlockchainEvents = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetTxnBlockchainEvents, + DescriptionKey: coremsgs.APIEndpointsGetTxnBlockchainEvents, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &[]*core.BlockchainEvent{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_txn_by_id.go b/internal/apiserver/route_get_txn_by_id.go index 30ce579fc..ed6cc7793 100644 --- a/internal/apiserver/route_get_txn_by_id.go +++ b/internal/apiserver/route_get_txn_by_id.go @@ -34,7 +34,7 @@ var getTxnByID = &oapispec.Route{ }, QueryParams: nil, FilterFactory: database.TransactionQueryFactory, - Description: coremsgs.APIEndpointsGetTxnByID, + DescriptionKey: coremsgs.APIEndpointsGetTxnByID, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Transaction{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_txn_ops.go b/internal/apiserver/route_get_txn_ops.go index a3cc498a5..736e84459 100644 --- a/internal/apiserver/route_get_txn_ops.go +++ b/internal/apiserver/route_get_txn_ops.go @@ -33,7 +33,7 @@ var getTxnOps = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetTxnOps, + DescriptionKey: coremsgs.APIEndpointsGetTxnOps, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &[]*core.Operation{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_txn_status.go b/internal/apiserver/route_get_txn_status.go index ffbb7504d..e4b1c8eb1 100644 --- a/internal/apiserver/route_get_txn_status.go +++ b/internal/apiserver/route_get_txn_status.go @@ -33,7 +33,7 @@ var getTxnStatus = &oapispec.Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsGetTxnStatus, + DescriptionKey: coremsgs.APIEndpointsGetTxnStatus, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.TransactionStatus{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_txns.go b/internal/apiserver/route_get_txns.go index 4506cf49f..0c544315a 100644 --- a/internal/apiserver/route_get_txns.go +++ b/internal/apiserver/route_get_txns.go @@ -32,7 +32,7 @@ var getTxns = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.TransactionQueryFactory, - Description: coremsgs.APIEndpointsGetTxns, + DescriptionKey: coremsgs.APIEndpointsGetTxns, JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.Transaction{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_verifier_by_id.go b/internal/apiserver/route_get_verifier_by_id.go index f45440e33..0728553ee 100644 --- a/internal/apiserver/route_get_verifier_by_id.go +++ b/internal/apiserver/route_get_verifier_by_id.go @@ -32,7 +32,7 @@ var getVerifierByID = &oapispec.Route{ {Name: "hash", Example: "hash", Description: coremsgs.APIParamsVerifierHash}, }, QueryParams: nil, - Description: coremsgs.APIEndpointsGetVerifierByHash, + DescriptionKey: coremsgs.APIEndpointsGetVerifierByHash, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &core.Verifier{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_get_verifiers.go b/internal/apiserver/route_get_verifiers.go index 1f25d3a59..1c404c4c0 100644 --- a/internal/apiserver/route_get_verifiers.go +++ b/internal/apiserver/route_get_verifiers.go @@ -32,7 +32,7 @@ var getVerifiers = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.VerifierQueryFactory, - Description: coremsgs.APIEndpointsGetVerifiers, + DescriptionKey: coremsgs.APIEndpointsGetVerifiers, JSONInputValue: nil, JSONOutputValue: func() interface{} { return &[]*core.Verifier{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_patch_update_identity.go b/internal/apiserver/route_patch_update_identity.go index 4e2e753d7..6bb49774c 100644 --- a/internal/apiserver/route_patch_update_identity.go +++ b/internal/apiserver/route_patch_update_identity.go @@ -36,7 +36,7 @@ var patchUpdateIdentity = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPatchUpdateIdentity, + DescriptionKey: coremsgs.APIEndpointsPatchUpdateIdentity, JSONInputValue: func() interface{} { return &core.IdentityUpdateDTO{} }, JSONOutputValue: func() interface{} { return &core.Identity{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_contract_api_invoke.go b/internal/apiserver/route_post_contract_api_invoke.go index f0ff048a6..9d68d6f82 100644 --- a/internal/apiserver/route_post_contract_api_invoke.go +++ b/internal/apiserver/route_post_contract_api_invoke.go @@ -37,7 +37,7 @@ var postContractAPIInvoke = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true, Example: "true"}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostContractAPIInvoke, + DescriptionKey: coremsgs.APIEndpointsPostContractAPIInvoke, JSONInputValue: func() interface{} { return &core.ContractCallRequest{} }, JSONOutputValue: func() interface{} { return &core.Operation{} }, JSONOutputCodes: []int{http.StatusOK, http.StatusAccepted}, diff --git a/internal/apiserver/route_post_contract_api_listeners.go b/internal/apiserver/route_post_contract_api_listeners.go index 2c9757d9b..3c89ecebb 100644 --- a/internal/apiserver/route_post_contract_api_listeners.go +++ b/internal/apiserver/route_post_contract_api_listeners.go @@ -34,7 +34,7 @@ var postContractAPIListeners = &oapispec.Route{ }, QueryParams: []*oapispec.QueryParam{}, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewContractListener, + DescriptionKey: coremsgs.APIEndpointsPostNewContractListener, JSONInputValue: func() interface{} { return &core.ContractListener{} }, JSONOutputValue: func() interface{} { return &core.ContractListener{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_post_contract_api_query.go b/internal/apiserver/route_post_contract_api_query.go index ecf10db2a..21363848b 100644 --- a/internal/apiserver/route_post_contract_api_query.go +++ b/internal/apiserver/route_post_contract_api_query.go @@ -34,7 +34,7 @@ var postContractAPIQuery = &oapispec.Route{ }, QueryParams: []*oapispec.QueryParam{}, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostContractAPIQuery, + DescriptionKey: coremsgs.APIEndpointsPostContractAPIQuery, JSONInputValue: func() interface{} { return &core.ContractCallRequest{} }, JSONOutputValue: func() interface{} { return make(map[string]interface{}) }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_post_contract_interface_generate.go b/internal/apiserver/route_post_contract_interface_generate.go index c5327ac92..a985ed5d0 100644 --- a/internal/apiserver/route_post_contract_interface_generate.go +++ b/internal/apiserver/route_post_contract_interface_generate.go @@ -31,7 +31,7 @@ var postContractInterfaceGenerate = &oapispec.Route{ PathParams: nil, QueryParams: []*oapispec.QueryParam{}, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostContractInterfaceGenerate, + DescriptionKey: coremsgs.APIEndpointsPostContractInterfaceGenerate, JSONInputValue: func() interface{} { return &core.FFIGenerationRequest{} }, JSONOutputValue: func() interface{} { return &core.FFI{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_post_contract_invoke.go b/internal/apiserver/route_post_contract_invoke.go index e140cc594..de7f517d5 100644 --- a/internal/apiserver/route_post_contract_invoke.go +++ b/internal/apiserver/route_post_contract_invoke.go @@ -34,7 +34,7 @@ var postContractInvoke = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true, Example: "true"}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostContractInvoke, + DescriptionKey: coremsgs.APIEndpointsPostContractInvoke, JSONInputValue: func() interface{} { return &core.ContractCallRequest{} }, JSONOutputValue: func() interface{} { return &core.Operation{} }, JSONOutputCodes: []int{http.StatusOK, http.StatusAccepted}, diff --git a/internal/apiserver/route_post_contract_query.go b/internal/apiserver/route_post_contract_query.go index 3774a723b..83b1d0c26 100644 --- a/internal/apiserver/route_post_contract_query.go +++ b/internal/apiserver/route_post_contract_query.go @@ -31,7 +31,7 @@ var postContractQuery = &oapispec.Route{ PathParams: nil, QueryParams: []*oapispec.QueryParam{}, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostContractQuery, + DescriptionKey: coremsgs.APIEndpointsPostContractQuery, JSONInputValue: func() interface{} { return &core.ContractCallRequest{} }, JSONOutputValue: func() interface{} { return make(map[string]interface{}) }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_post_data.go b/internal/apiserver/route_post_data.go index 1e2a7fab6..90ce14e54 100644 --- a/internal/apiserver/route_post_data.go +++ b/internal/apiserver/route_post_data.go @@ -42,7 +42,7 @@ var postData = &oapispec.Route{ {Name: "datatype.version", Description: coremsgs.APIParamsDatatypeVersion}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostData, + DescriptionKey: coremsgs.APIEndpointsPostData, JSONInputValue: func() interface{} { return &core.DataRefOrValue{} }, JSONOutputValue: func() interface{} { return &core.Data{} }, JSONOutputCodes: []int{http.StatusCreated}, diff --git a/internal/apiserver/route_post_network_action.go b/internal/apiserver/route_post_network_action.go index 02b22e320..90f7e7e5e 100644 --- a/internal/apiserver/route_post_network_action.go +++ b/internal/apiserver/route_post_network_action.go @@ -31,7 +31,7 @@ var postNetworkAction = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNetworkAction, + DescriptionKey: coremsgs.APIEndpointsPostNetworkAction, JSONInputValue: func() interface{} { return &core.NetworkAction{} }, JSONOutputValue: func() interface{} { return &core.NetworkAction{} }, JSONOutputCodes: []int{http.StatusAccepted}, diff --git a/internal/apiserver/route_post_new_contract_api.go b/internal/apiserver/route_post_new_contract_api.go index 7fa58ebfc..88917bf6a 100644 --- a/internal/apiserver/route_post_new_contract_api.go +++ b/internal/apiserver/route_post_new_contract_api.go @@ -34,7 +34,7 @@ var postNewContractAPI = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true, Example: "true"}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewContractAPI, + DescriptionKey: coremsgs.APIEndpointsPostNewContractAPI, JSONInputValue: func() interface{} { return &core.ContractAPI{} }, JSONOutputValue: func() interface{} { return &core.ContractAPI{} }, JSONOutputCodes: []int{http.StatusOK, http.StatusAccepted}, diff --git a/internal/apiserver/route_post_new_contract_interface.go b/internal/apiserver/route_post_new_contract_interface.go index b0b115f84..0ebacdfdc 100644 --- a/internal/apiserver/route_post_new_contract_interface.go +++ b/internal/apiserver/route_post_new_contract_interface.go @@ -34,7 +34,7 @@ var postNewContractInterface = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true, Example: "true"}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewContractInterface, + DescriptionKey: coremsgs.APIEndpointsPostNewContractInterface, JSONInputValue: func() interface{} { return &core.FFI{} }, JSONOutputValue: func() interface{} { return &core.FFI{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_post_new_contract_listener.go b/internal/apiserver/route_post_new_contract_listener.go index 0f9dfde6f..1f654e5f1 100644 --- a/internal/apiserver/route_post_new_contract_listener.go +++ b/internal/apiserver/route_post_new_contract_listener.go @@ -31,7 +31,7 @@ var postNewContractListener = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewContractListener, + DescriptionKey: coremsgs.APIEndpointsPostNewContractListener, JSONInputValue: func() interface{} { return &core.ContractListenerInput{} }, JSONOutputValue: func() interface{} { return &core.ContractListener{} }, JSONOutputCodes: []int{http.StatusOK}, diff --git a/internal/apiserver/route_post_new_datatype.go b/internal/apiserver/route_post_new_datatype.go index 2da2a0d24..c67e0abbd 100644 --- a/internal/apiserver/route_post_new_datatype.go +++ b/internal/apiserver/route_post_new_datatype.go @@ -34,7 +34,7 @@ var postNewDatatype = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true, Example: "true"}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewDatatype, + DescriptionKey: coremsgs.APIEndpointsPostNewDatatype, JSONInputValue: func() interface{} { return &core.Datatype{} }, JSONOutputValue: func() interface{} { return &core.Datatype{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_new_identity.go b/internal/apiserver/route_post_new_identity.go index ff3691180..2903610a7 100644 --- a/internal/apiserver/route_post_new_identity.go +++ b/internal/apiserver/route_post_new_identity.go @@ -34,7 +34,7 @@ var postNewIdentity = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewIdentity, + DescriptionKey: coremsgs.APIEndpointsPostNewIdentity, JSONInputValue: func() interface{} { return &core.IdentityCreateDTO{} }, JSONOutputValue: func() interface{} { return &core.Identity{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_new_message_broadcast.go b/internal/apiserver/route_post_new_message_broadcast.go index 118ce2eeb..876565395 100644 --- a/internal/apiserver/route_post_new_message_broadcast.go +++ b/internal/apiserver/route_post_new_message_broadcast.go @@ -34,7 +34,7 @@ var postNewMessageBroadcast = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewMessageBroadcast, + DescriptionKey: coremsgs.APIEndpointsPostNewMessageBroadcast, JSONInputValue: func() interface{} { return &core.MessageInOut{} }, JSONOutputValue: func() interface{} { return &core.Message{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_new_message_private.go b/internal/apiserver/route_post_new_message_private.go index 06472a35d..772bbd985 100644 --- a/internal/apiserver/route_post_new_message_private.go +++ b/internal/apiserver/route_post_new_message_private.go @@ -34,7 +34,7 @@ var postNewMessagePrivate = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewMessagePrivate, + DescriptionKey: coremsgs.APIEndpointsPostNewMessagePrivate, JSONInputValue: func() interface{} { return &core.MessageInOut{} }, JSONOutputValue: func() interface{} { return &core.Message{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_new_message_requestreply.go b/internal/apiserver/route_post_new_message_requestreply.go index bd2820838..2cb4d3774 100644 --- a/internal/apiserver/route_post_new_message_requestreply.go +++ b/internal/apiserver/route_post_new_message_requestreply.go @@ -31,7 +31,7 @@ var postNewMessageRequestReply = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewMessageRequestReply, + DescriptionKey: coremsgs.APIEndpointsPostNewMessageRequestReply, JSONInputValue: func() interface{} { return &core.MessageInOut{} }, JSONOutputValue: func() interface{} { return &core.MessageInOut{} }, JSONOutputCodes: []int{http.StatusOK}, // Sync operation diff --git a/internal/apiserver/route_post_new_namespace.go b/internal/apiserver/route_post_new_namespace.go index 2a2d6ec8d..474e972f6 100644 --- a/internal/apiserver/route_post_new_namespace.go +++ b/internal/apiserver/route_post_new_namespace.go @@ -33,7 +33,7 @@ var postNewNamespace = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true, Example: "true"}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewNamespace, + DescriptionKey: coremsgs.APIEndpointsPostNewNamespace, JSONInputValue: func() interface{} { return &core.Namespace{} }, JSONOutputValue: func() interface{} { return &core.Namespace{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_new_node_self.go b/internal/apiserver/route_post_new_node_self.go index 008da7e70..c0d02959f 100644 --- a/internal/apiserver/route_post_new_node_self.go +++ b/internal/apiserver/route_post_new_node_self.go @@ -34,7 +34,7 @@ var postNodesSelf = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true, Example: "true"}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNodesSelf, + DescriptionKey: coremsgs.APIEndpointsPostNodesSelf, JSONInputValue: func() interface{} { return &core.EmptyInput{} }, JSONOutputValue: func() interface{} { return &core.Identity{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_new_organization.go b/internal/apiserver/route_post_new_organization.go index 394c24da0..fb69edede 100644 --- a/internal/apiserver/route_post_new_organization.go +++ b/internal/apiserver/route_post_new_organization.go @@ -34,7 +34,7 @@ var postNewOrganization = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true, Example: "true"}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewOrganization, + DescriptionKey: coremsgs.APIEndpointsPostNewOrganization, JSONInputValue: func() interface{} { return &core.IdentityCreateDTO{} }, JSONOutputValue: func() interface{} { return &core.Identity{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_new_organization_self.go b/internal/apiserver/route_post_new_organization_self.go index 2b212e62a..ce7f83399 100644 --- a/internal/apiserver/route_post_new_organization_self.go +++ b/internal/apiserver/route_post_new_organization_self.go @@ -34,7 +34,7 @@ var postNewOrganizationSelf = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true, Example: "true"}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewOrganizationSelf, + DescriptionKey: coremsgs.APIEndpointsPostNewOrganizationSelf, JSONInputValue: func() interface{} { return &core.EmptyInput{} }, JSONOutputValue: func() interface{} { return &core.Identity{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_new_subscription.go b/internal/apiserver/route_post_new_subscription.go index 31efbfeb5..acf127c09 100644 --- a/internal/apiserver/route_post_new_subscription.go +++ b/internal/apiserver/route_post_new_subscription.go @@ -31,7 +31,7 @@ var postNewSubscription = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewSubscription, + DescriptionKey: coremsgs.APIEndpointsPostNewSubscription, JSONInputValue: func() interface{} { return &core.Subscription{} }, JSONOutputValue: func() interface{} { return &core.Subscription{} }, JSONOutputCodes: []int{http.StatusCreated}, // Sync operation diff --git a/internal/apiserver/route_post_op_retry.go b/internal/apiserver/route_post_op_retry.go index eb6fd6d8f..5521dcc6f 100644 --- a/internal/apiserver/route_post_op_retry.go +++ b/internal/apiserver/route_post_op_retry.go @@ -34,7 +34,7 @@ var postOpRetry = &oapispec.Route{ }, QueryParams: []*oapispec.QueryParam{}, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostOpRetry, + DescriptionKey: coremsgs.APIEndpointsPostOpRetry, JSONInputValue: func() interface{} { return &core.EmptyInput{} }, JSONOutputValue: func() interface{} { return &core.Operation{} }, JSONOutputCodes: []int{http.StatusAccepted}, diff --git a/internal/apiserver/route_post_token_approval.go b/internal/apiserver/route_post_token_approval.go index 5e3263114..6e9aa3b24 100644 --- a/internal/apiserver/route_post_token_approval.go +++ b/internal/apiserver/route_post_token_approval.go @@ -33,8 +33,8 @@ var postTokenApproval = &oapispec.Route{ QueryParams: []*oapispec.QueryParam{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true}, }, - FilterFactory: nil, - Description: coremsgs.APIEndpointsPostTokenApproval, + FilterFactory: nil, + DescriptionKey: coremsgs.APIEndpointsPostTokenApproval, JSONInputValue: func() interface{} { return &core.TokenApprovalInput{ TokenApproval: core.TokenApproval{ diff --git a/internal/apiserver/route_post_token_burn.go b/internal/apiserver/route_post_token_burn.go index 5c6646a45..ad0f70beb 100644 --- a/internal/apiserver/route_post_token_burn.go +++ b/internal/apiserver/route_post_token_burn.go @@ -34,7 +34,7 @@ var postTokenBurn = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostTokenBurn, + DescriptionKey: coremsgs.APIEndpointsPostTokenBurn, JSONInputValue: func() interface{} { return &core.TokenTransferInput{} }, JSONOutputValue: func() interface{} { return &core.TokenTransfer{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_token_mint.go b/internal/apiserver/route_post_token_mint.go index 04c6000da..c21a64ea2 100644 --- a/internal/apiserver/route_post_token_mint.go +++ b/internal/apiserver/route_post_token_mint.go @@ -34,7 +34,7 @@ var postTokenMint = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostTokenMint, + DescriptionKey: coremsgs.APIEndpointsPostTokenMint, JSONInputValue: func() interface{} { return &core.TokenTransferInput{} }, JSONOutputValue: func() interface{} { return &core.TokenTransfer{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_token_pool.go b/internal/apiserver/route_post_token_pool.go index 6d3987251..8e44aa93e 100644 --- a/internal/apiserver/route_post_token_pool.go +++ b/internal/apiserver/route_post_token_pool.go @@ -34,7 +34,7 @@ var postTokenPool = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostTokenPool, + DescriptionKey: coremsgs.APIEndpointsPostTokenPool, JSONInputValue: func() interface{} { return &core.TokenPool{} }, JSONOutputValue: func() interface{} { return &core.TokenPool{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_post_token_transfer.go b/internal/apiserver/route_post_token_transfer.go index 584a07d55..a16717a46 100644 --- a/internal/apiserver/route_post_token_transfer.go +++ b/internal/apiserver/route_post_token_transfer.go @@ -34,7 +34,7 @@ var postTokenTransfer = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostTokenTransfer, + DescriptionKey: coremsgs.APIEndpointsPostTokenTransfer, JSONInputValue: func() interface{} { return &core.TokenTransferInput{} }, JSONOutputValue: func() interface{} { return &core.TokenTransfer{} }, JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK}, diff --git a/internal/apiserver/route_put_contract_api.go b/internal/apiserver/route_put_contract_api.go index fabc27921..be12566fe 100644 --- a/internal/apiserver/route_put_contract_api.go +++ b/internal/apiserver/route_put_contract_api.go @@ -37,7 +37,7 @@ var putContractAPI = &oapispec.Route{ {Name: "confirm", Description: coremsgs.APIConfirmQueryParam, IsBool: true, Example: "true"}, }, FilterFactory: nil, - Description: coremsgs.APIParamsContractAPIID, + DescriptionKey: coremsgs.APIParamsContractAPIID, JSONInputValue: func() interface{} { return &core.ContractAPI{} }, JSONOutputValue: func() interface{} { return &core.ContractAPI{} }, JSONOutputCodes: []int{http.StatusOK, http.StatusAccepted}, diff --git a/internal/apiserver/route_put_subscription.go b/internal/apiserver/route_put_subscription.go index b3cafdb94..91cffbffc 100644 --- a/internal/apiserver/route_put_subscription.go +++ b/internal/apiserver/route_put_subscription.go @@ -31,7 +31,7 @@ var putSubscription = &oapispec.Route{ PathParams: nil, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsPutSubscription, + DescriptionKey: coremsgs.APIEndpointsPutSubscription, JSONInputValue: func() interface{} { return &core.Subscription{} }, JSONOutputValue: func() interface{} { return &core.Subscription{} }, JSONOutputCodes: []int{http.StatusOK}, // Sync operation diff --git a/internal/blockchain/ethereum/ethereum.go b/internal/blockchain/ethereum/ethereum.go index 50fb1d429..62895c933 100644 --- a/internal/blockchain/ethereum/ethereum.go +++ b/internal/blockchain/ethereum/ethereum.go @@ -765,11 +765,17 @@ func (e *Ethereum) FFIEventDefinitionToABI(ctx context.Context, event *core.FFIE if err != nil { return nil, err } - return &abi.Entry{ + abiEntry := &abi.Entry{ Name: event.Name, Type: "event", Inputs: abiInputs, - }, nil + } + if event.Details != nil { + if anonymous, ok := event.Details["anonymous"]; ok { + abiEntry.Anonymous = anonymous.(bool) + } + } + return abiEntry, nil } func (e *Ethereum) FFIMethodToABI(ctx context.Context, method *core.FFIMethod, input map[string]interface{}) (*abi.Entry, error) { @@ -782,12 +788,28 @@ func (e *Ethereum) FFIMethodToABI(ctx context.Context, method *core.FFIMethod, i if err != nil { return nil, err } - return &abi.Entry{ + abiEntry := &abi.Entry{ Name: method.Name, Type: "function", Inputs: abiInputs, Outputs: abiOutputs, - }, nil + } + if method.Details != nil { + stateMutability, ok := method.Details["stateMutability"] + if ok { + stateMutabilityString, ok := stateMutability.(string) + if ok { + abiEntry.StateMutability = abi.StateMutability(stateMutabilityString) + } + } + if payable, ok := method.Details["payable"]; ok { + abiEntry.Payable = payable.(bool) + } + if constant, ok := method.Details["constant"]; ok { + abiEntry.Constant = constant.(bool) + } + } + return abiEntry, nil } func ABIArgumentToTypeString(typeName string, components abi.ParameterArray) string { @@ -850,13 +872,18 @@ func processField(name string, schema *jsonschema.Schema) *abi.Parameter { InternalType: details.InternalType, Indexed: details.Indexed, } - if len(schema.Types) > 0 && schema.Types[0] == objectType { - parameter.Components = buildABIArgumentArray(schema.Properties) + if len(schema.Types) > 0 { + switch schema.Types[0] { + case objectType: + parameter.Components = buildABIParameterArrayForObject(schema.Properties) + case arrayType: + parameter.Components = buildABIParameterArrayForObject(schema.Items2020.Properties) + } } return parameter } -func buildABIArgumentArray(properties map[string]*jsonschema.Schema) abi.ParameterArray { +func buildABIParameterArrayForObject(properties map[string]*jsonschema.Schema) abi.ParameterArray { parameters := make(abi.ParameterArray, len(properties)) for propertyName, propertySchema := range properties { details := getParamDetails(propertySchema) @@ -923,11 +950,10 @@ func (e *Ethereum) GenerateFFI(ctx context.Context, generationRequest *core.FFIG if len(*input.ABI) == 0 { return nil, i18n.NewError(ctx, coremsgs.MsgFFIGenerationFailed, "ABI is empty") } - ffi := e.convertABIToFFI(ctx, generationRequest.Namespace, generationRequest.Name, generationRequest.Version, generationRequest.Description, input.ABI) - return ffi, nil + return e.convertABIToFFI(ctx, generationRequest.Namespace, generationRequest.Name, generationRequest.Version, generationRequest.Description, input.ABI) } -func (e *Ethereum) convertABIToFFI(ctx context.Context, ns, name, version, description string, abi *abi.ABI) *core.FFI { +func (e *Ethereum) convertABIToFFI(ctx context.Context, ns, name, version, description string, abi *abi.ABI) (*core.FFI, error) { ffi := &core.FFI{ Namespace: ns, Name: name, @@ -938,118 +964,136 @@ func (e *Ethereum) convertABIToFFI(ctx context.Context, ns, name, version, descr } i := 0 for _, f := range abi.Functions() { - ffi.Methods[i] = e.convertABIFunctionToFFIMethod(ctx, f) + method, err := e.convertABIFunctionToFFIMethod(ctx, f) + if err != nil { + return nil, err + } + ffi.Methods[i] = method i++ } i = 0 for _, f := range abi.Events() { - ffi.Events[i] = e.convertABIEventToFFIEvent(ctx, f) + event, err := e.convertABIEventToFFIEvent(ctx, f) + if err != nil { + return nil, err + } + ffi.Events[i] = event i++ } - return ffi + return ffi, nil } -func (e *Ethereum) convertABIFunctionToFFIMethod(ctx context.Context, abiFunction *abi.Entry) *core.FFIMethod { +func (e *Ethereum) convertABIFunctionToFFIMethod(ctx context.Context, abiFunction *abi.Entry) (*core.FFIMethod, error) { params := make([]*core.FFIParam, len(abiFunction.Inputs)) returns := make([]*core.FFIParam, len(abiFunction.Outputs)) + details := map[string]interface{}{} for i, input := range abiFunction.Inputs { - schema := e.getSchemaForABIInput(ctx, input) + typeComponent, err := input.TypeComponentTreeCtx(ctx) + if err != nil { + return nil, err + } + schema := e.getSchemaForABIInput(ctx, typeComponent) param := &core.FFIParam{ Name: input.Name, Schema: fftypes.JSONAnyPtr(schema.ToJSON()), } params[i] = param } - for i, input := range abiFunction.Outputs { - schema := e.getSchemaForABIInput(ctx, input) + for i, output := range abiFunction.Outputs { + typeComponent, err := output.TypeComponentTreeCtx(ctx) + if err != nil { + return nil, err + } + schema := e.getSchemaForABIInput(ctx, typeComponent) param := &core.FFIParam{ - Name: input.Name, + Name: output.Name, Schema: fftypes.JSONAnyPtr(schema.ToJSON()), } returns[i] = param } + if abiFunction.StateMutability != "" { + details["stateMutability"] = string(abiFunction.StateMutability) + } + if abiFunction.Payable { + details["payable"] = true + } + if abiFunction.Constant { + details["constant"] = true + } return &core.FFIMethod{ Name: abiFunction.Name, Params: params, Returns: returns, - } + Details: details, + }, nil } -func (e *Ethereum) convertABIEventToFFIEvent(ctx context.Context, abiEvent *abi.Entry) *core.FFIEvent { +func (e *Ethereum) convertABIEventToFFIEvent(ctx context.Context, abiEvent *abi.Entry) (*core.FFIEvent, error) { params := make([]*core.FFIParam, len(abiEvent.Inputs)) - for i, input := range abiEvent.Inputs { - schema := e.getSchemaForABIInput(ctx, input) + details := map[string]interface{}{} + for i, output := range abiEvent.Inputs { + typeComponent, err := output.TypeComponentTreeCtx(ctx) + if err != nil { + return nil, err + } + schema := e.getSchemaForABIInput(ctx, typeComponent) param := &core.FFIParam{ - Name: input.Name, + Name: output.Name, Schema: fftypes.JSONAnyPtr(schema.ToJSON()), } params[i] = param } + if abiEvent.Anonymous { + details["anonymous"] = true + } return &core.FFIEvent{ FFIEventDefinition: core.FFIEventDefinition{ - Name: abiEvent.Name, - Params: params, + Name: abiEvent.Name, + Params: params, + Details: details, }, - } + }, nil } -func (e *Ethereum) getSchemaForABIInput(ctx context.Context, input *abi.Parameter) *Schema { - inputType := e.getFFIType(input.Type) +func (e *Ethereum) getSchemaForABIInput(ctx context.Context, typeComponent abi.TypeComponent) *Schema { schema := &Schema{ Details: ¶mDetails{ - Type: input.Type, - InternalType: input.InternalType, - Indexed: input.Indexed, + Type: typeComponent.Parameter().Type, + InternalType: typeComponent.Parameter().InternalType, + Indexed: typeComponent.Parameter().Indexed, }, } - if inputType == core.FFIInputTypeInteger { - schema.OneOf = []SchemaType{ - {Type: "string"}, - {Type: "integer"}, - } - schema.Description = i18n.Expand(ctx, coremsgs.APIIntegerDescription) - } else { - schema.Type = inputType.String() - } - - if inputType == core.FFIInputTypeArray { - levels := strings.Count(input.Type, "[]") - innerType := e.getFFIType(strings.ReplaceAll(input.Type, "[]", "")) - innerSchema := &Schema{} - if innerType == core.FFIInputTypeInteger { - innerSchema.OneOf = []SchemaType{ + switch typeComponent.ComponentType() { + case abi.ElementaryComponent: + t := e.getFFIType(typeComponent.ElementaryType().String()) + if t == core.FFIInputTypeInteger { + schema.OneOf = []SchemaType{ {Type: "string"}, {Type: "integer"}, } + schema.Description = i18n.Expand(ctx, coremsgs.APIIntegerDescription) } else { - innerSchema.Type = innerType.String() + schema.Type = t.String() } - if len(input.Components) > 0 { - innerSchema.Properties = e.getSchemaForABIComponents(ctx, input.Components) + case abi.FixedArrayComponent, abi.DynamicArrayComponent: + schema.Type = arrayType + childSchema := e.getSchemaForABIInput(ctx, typeComponent.ArrayChild()) + schema.Items = childSchema + schema.Details = childSchema.Details + childSchema.Details = nil + case abi.TupleComponent: + schema.Type = objectType + schema.Properties = make(map[string]*Schema, len(typeComponent.TupleChildren())) + for i, tupleChild := range typeComponent.TupleChildren() { + childSchema := e.getSchemaForABIInput(ctx, tupleChild) + childSchema.Details.Index = new(int) + *childSchema.Details.Index = i + schema.Properties[tupleChild.KeyName()] = childSchema } - for i := 1; i < levels; i++ { - innerSchema = &Schema{ - Type: core.FFIInputTypeArray.String(), - Items: innerSchema, - } - } - schema.Items = innerSchema - } else { - schema.Properties = e.getSchemaForABIComponents(ctx, input.Components) } return schema } -func (e *Ethereum) getSchemaForABIComponents(ctx context.Context, components abi.ParameterArray) map[string]*Schema { - schemas := make(map[string]*Schema, len(components)) - for i, component := range components { - schemas[component.Name] = e.getSchemaForABIInput(ctx, component) - schemas[component.Name].Details.Index = new(int) - *schemas[component.Name].Details.Index = i - } - return schemas -} - func (e *Ethereum) getFFIType(solidityType string) core.FFIInputType { switch solidityType { case stringType, "address": @@ -1060,8 +1104,6 @@ func (e *Ethereum) getFFIType(solidityType string) core.FFIInputType { return core.FFIInputTypeObject default: switch { - case strings.HasSuffix(solidityType, "[]"): - return core.FFIInputTypeArray case strings.Contains(solidityType, "byte"): return core.FFIInputTypeString case strings.Contains(solidityType, "int"): diff --git a/internal/blockchain/ethereum/ethereum_test.go b/internal/blockchain/ethereum/ethereum_test.go index 090c5869d..36a2dc640 100644 --- a/internal/blockchain/ethereum/ethereum_test.go +++ b/internal/blockchain/ethereum/ethereum_test.go @@ -2230,6 +2230,83 @@ func TestFFIMethodToABIObject(t *testing.T) { assert.ObjectsAreEqual(expectedABIElement, abi) } +func TestABIFFIConversionArrayOfObjects(t *testing.T) { + e, _ := newTestEthereum() + + abiJSON := `[ + { + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "uint256", + "name": "weight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "volume", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "enum ComplexStorage.Alignment", + "name": "alignment", + "type": "uint8" + } + ], + "internalType": "struct ComplexStorage.BoxContent[]", + "name": "contents", + "type": "tuple[]" + } + ], + "internalType": "struct ComplexStorage.Box[]", + "name": "newBox", + "type": "tuple[]" + } + ], + "name": "set", + "outputs": [], + "stateMutability": "payable", + "type": "function", + "payable": true, + "constant": true + } + ]` + + var abi *abi.ABI + json.Unmarshal([]byte(abiJSON), &abi) + abiFunction := abi.Functions()["set"] + + ffiMethod, err := e.convertABIFunctionToFFIMethod(context.Background(), abiFunction) + assert.NoError(t, err) + abiFunctionOut, err := e.FFIMethodToABI(context.Background(), ffiMethod, nil) + assert.NoError(t, err) + + expectedABIFunctionJSON, err := json.Marshal(abiFunction) + assert.NoError(t, err) + abiFunctionJSON, err := json.Marshal(abiFunctionOut) + assert.NoError(t, err) + assert.JSONEq(t, string(expectedABIFunctionJSON), string(abiFunctionJSON)) + +} + func TestFFIMethodToABINestedArray(t *testing.T) { e, _ := newTestEthereum() @@ -2272,7 +2349,11 @@ func TestFFIMethodToABINestedArray(t *testing.T) { abi, err := e.FFIMethodToABI(context.Background(), method, nil) assert.NoError(t, err) - assert.Equal(t, expectedABIElement, abi) + expectedABIJSON, err := json.Marshal(expectedABIElement) + assert.NoError(t, err) + abiJSON, err := json.Marshal(abi) + assert.NoError(t, err) + assert.JSONEq(t, string(expectedABIJSON), string(abiJSON)) } func TestFFIMethodToABIInvalidJSON(t *testing.T) { @@ -2423,7 +2504,8 @@ func TestConvertABIToFFI(t *testing.T) { }, } - actualFFI := e.convertABIToFFI(context.Background(), "default", "SimpleStorage", "v0.0.1", "desc", abi) + actualFFI, err := e.convertABIToFFI(context.Background(), "default", "SimpleStorage", "v0.0.1", "desc", abi) + assert.NoError(t, err) assert.NotNil(t, actualFFI) assert.ObjectsAreEqual(expectedFFI, actualFFI) } @@ -2476,14 +2558,22 @@ func TestConvertABIToFFIWithObject(t *testing.T) { }, }, Returns: core.FFIParams{}, + Details: map[string]interface{}{}, }, }, Events: []*core.FFIEvent{}, } - actualFFI := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) + actualFFI, err := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) + assert.NoError(t, err) assert.NotNil(t, actualFFI) - assert.Equal(t, expectedFFI, actualFFI) + + expectedFFIJSON, err := json.Marshal(expectedFFI) + assert.NoError(t, err) + actualFFIJSON, err := json.Marshal(actualFFI) + assert.NoError(t, err) + assert.JSONEq(t, string(expectedFFIJSON), string(actualFFIJSON)) + } func TestConvertABIToFFIWithArray(t *testing.T) { @@ -2521,14 +2611,21 @@ func TestConvertABIToFFIWithArray(t *testing.T) { }, }, Returns: core.FFIParams{}, + Details: map[string]interface{}{}, }, }, Events: []*core.FFIEvent{}, } - actualFFI := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) + actualFFI, err := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) + assert.NoError(t, err) assert.NotNil(t, actualFFI) - assert.Equal(t, expectedFFI, actualFFI) + + expectedFFIJSON, err := json.Marshal(expectedFFI) + assert.NoError(t, err) + actualFFIJSON, err := json.Marshal(actualFFI) + assert.NoError(t, err) + assert.JSONEq(t, string(expectedFFIJSON), string(actualFFIJSON)) } func TestConvertABIToFFIWithNestedArray(t *testing.T) { @@ -2549,7 +2646,7 @@ func TestConvertABIToFFIWithNestedArray(t *testing.T) { }, } - schema := fftypes.JSONAnyPtr(`{"type":"array","details":{"type":"uint256[][]","internalType":"uint256[][]"},"items":{"type":"array","items":{"oneOf":[{"type":"string"},{"type":"integer"}]}}}`) + schema := fftypes.JSONAnyPtr(`{"type":"array","details":{"type":"uint256[][]","internalType":"uint256[][]"},"items":{"type":"array","items":{"oneOf":[{"type":"string"},{"type":"integer"}],"description":"An integer. You are recommended to use a JSON string. A JSON number can be used for values up to the safe maximum."}}}`) expectedFFI := &core.FFI{ Name: "WidgetTest", Version: "v0.0.1", @@ -2565,14 +2662,20 @@ func TestConvertABIToFFIWithNestedArray(t *testing.T) { }, }, Returns: core.FFIParams{}, + Details: map[string]interface{}{}, }, }, Events: []*core.FFIEvent{}, } - actualFFI := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) + actualFFI, err := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) + assert.NoError(t, err) assert.NotNil(t, actualFFI) - assert.Equal(t, expectedFFI, actualFFI) + expectedFFIJSON, err := json.Marshal(expectedFFI) + assert.NoError(t, err) + actualFFIJSON, err := json.Marshal(actualFFI) + assert.NoError(t, err) + assert.JSONEq(t, string(expectedFFIJSON), string(actualFFIJSON)) } func TestConvertABIToFFIWithNestedArrayOfObjects(t *testing.T) { @@ -2627,14 +2730,20 @@ func TestConvertABIToFFIWithNestedArrayOfObjects(t *testing.T) { }, }, Returns: core.FFIParams{}, + Details: map[string]interface{}{}, }, }, Events: []*core.FFIEvent{}, } - actualFFI := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) + actualFFI, err := e.convertABIToFFI(context.Background(), "default", "WidgetTest", "v0.0.1", "desc", abi) + assert.NoError(t, err) assert.NotNil(t, actualFFI) - assert.Equal(t, expectedFFI, actualFFI) + expectedFFIJSON, err := json.Marshal(expectedFFI) + assert.NoError(t, err) + actualFFIJSON, err := json.Marshal(actualFFI) + assert.NoError(t, err) + assert.JSONEq(t, string(expectedFFIJSON), string(actualFFIJSON)) } func TestGenerateFFI(t *testing.T) { @@ -2690,7 +2799,6 @@ func TestGetFFIType(t *testing.T) { assert.Equal(t, core.FFIInputTypeString, e.getFFIType("byte")) assert.Equal(t, core.FFIInputTypeBoolean, e.getFFIType("bool")) assert.Equal(t, core.FFIInputTypeInteger, e.getFFIType("uint256")) - assert.Equal(t, core.FFIInputTypeArray, e.getFFIType("string[]")) assert.Equal(t, core.FFIInputTypeObject, e.getFFIType("tuple")) assert.Equal(t, core.FFEnum(""), e.getFFIType("foobar")) } @@ -2826,3 +2934,111 @@ func TestHandleNetworkAction(t *testing.T) { em.AssertExpectations(t) } + +func TestConvertABIToFFIBadInputType(t *testing.T) { + e, _ := newTestEthereum() + + abiJSON := `[ + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "foobar" + } + ], + "name": "set", + "outputs": [], + "stateMutability": "payable", + "type": "function", + "payable": true, + "constant": true + } + ]` + + var abi *abi.ABI + json.Unmarshal([]byte(abiJSON), &abi) + _, err := e.convertABIToFFI(context.Background(), "ns1", "name", "version", "description", abi) + assert.Regexp(t, "FF22025", err) +} + +func TestConvertABIToFFIBadOutputType(t *testing.T) { + e, _ := newTestEthereum() + + abiJSON := `[ + { + "outputs": [ + { + "internalType": "string", + "name": "name", + "type": "foobar" + } + ], + "name": "set", + "stateMutability": "viewable", + "type": "function" + } + ]` + + var abi *abi.ABI + json.Unmarshal([]byte(abiJSON), &abi) + _, err := e.convertABIToFFI(context.Background(), "ns1", "name", "version", "description", abi) + assert.Regexp(t, "FF22025", err) +} + +func TestConvertABIToFFIBadEventType(t *testing.T) { + e, _ := newTestEthereum() + + abiJSON := `[ + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "foobar" + } + ], + "name": "set", + "type": "event" + } + ]` + + var abi *abi.ABI + json.Unmarshal([]byte(abiJSON), &abi) + _, err := e.convertABIToFFI(context.Background(), "ns1", "name", "version", "description", abi) + assert.Regexp(t, "FF22025", err) +} + +func TestConvertABIEventFFIEvent(t *testing.T) { + e, _ := newTestEthereum() + + abiJSON := `[ + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + } + ], + "name": "set", + "type": "event", + "anonymous": true + } + ]` + + var abi *abi.ABI + json.Unmarshal([]byte(abiJSON), &abi) + ffi, err := e.convertABIToFFI(context.Background(), "ns1", "name", "version", "description", abi) + assert.NoError(t, err) + + actualABIEvent, err := e.FFIEventDefinitionToABI(context.Background(), &ffi.Events[0].FFIEventDefinition) + assert.NoError(t, err) + + expectedABIEventJSON, err := json.Marshal(abi.Events()["set"]) + assert.NoError(t, err) + actualABIEventJSON, err := json.Marshal(actualABIEvent) + assert.NoError(t, err) + + assert.JSONEq(t, string(expectedABIEventJSON), string(actualABIEventJSON)) +} diff --git a/internal/coremsgs/en_struct_descriptions.go b/internal/coremsgs/en_struct_descriptions.go index 8e7c62348..025894725 100644 --- a/internal/coremsgs/en_struct_descriptions.go +++ b/internal/coremsgs/en_struct_descriptions.go @@ -247,6 +247,7 @@ var ( FFIMethodDescription = ffm("FFIMethod.description", "A description of the smart contract method") FFIMethodParams = ffm("FFIMethod.params", "An array of method parameter/argument definitions") FFIMethodReturns = ffm("FFIMethod.returns", "An array of method return definitions") + FFIMethodDetails = ffm("FFIMethod.details", "Additional details about the smart contract function") // FFIEvent field descriptions FFIEventID = ffm("FFIEvent.id", "The UUID of the FFI event definition") @@ -257,6 +258,7 @@ var ( FFIEventDescription = ffm("FFIEvent.description", "A description of the smart contract event") FFIEventParams = ffm("FFIEvent.params", "An array of event parameter/argument definitions") FFIEventSignature = ffm("FFIEvent.signature", "The stringified signature of the event, as computed by the blockchain plugin") + FFIEventDetails = ffm("FFIEvent.details", "Additional details about the smart contract event") // FFIParam field descriptions FFIParamName = ffm("FFIParam.name", "The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract") diff --git a/internal/database/sqlcommon/ffi_events_sql.go b/internal/database/sqlcommon/ffi_events_sql.go index 83b7fdca4..f3baa90f6 100644 --- a/internal/database/sqlcommon/ffi_events_sql.go +++ b/internal/database/sqlcommon/ffi_events_sql.go @@ -38,6 +38,7 @@ var ( "pathname", "description", "params", + "details", } ffiEventFilterFieldMap = map[string]string{ "interface": "interface_id", @@ -87,6 +88,7 @@ func (s *SQLCommon) UpsertFFIEvent(ctx context.Context, event *core.FFIEvent) (e event.Pathname, event.Description, event.Params, + event.Details, ), func() { s.callbacks.UUIDCollectionNSEvent(database.CollectionFFIEvents, core.ChangeEventTypeCreated, event.Namespace, event.ID) @@ -109,6 +111,7 @@ func (s *SQLCommon) ffiEventResult(ctx context.Context, row *sql.Rows) (*core.FF &event.Pathname, &event.Description, &event.Params, + &event.Details, ) if err != nil { return nil, i18n.WrapError(ctx, err, coremsgs.MsgDBReadErr, ffieventsTable) diff --git a/internal/database/sqlcommon/ffi_events_sql_test.go b/internal/database/sqlcommon/ffi_events_sql_test.go index a0aef1293..4eefa6c0a 100644 --- a/internal/database/sqlcommon/ffi_events_sql_test.go +++ b/internal/database/sqlcommon/ffi_events_sql_test.go @@ -178,7 +178,7 @@ func TestGetFFIEvents(t *testing.T) { ) s, mock := newMockProvider().init() rows := sqlmock.NewRows(ffiEventsColumns). - AddRow(fftypes.NewUUID().String(), fftypes.NewUUID().String(), "ns1", "sum", "sum", "", []byte(`[]`)) + AddRow(fftypes.NewUUID().String(), fftypes.NewUUID().String(), "ns1", "sum", "sum", "", []byte(`[]`), []byte(`{}`)) mock.ExpectQuery("SELECT .*").WillReturnRows(rows) _, _, err := s.GetFFIEvents(context.Background(), filter) assert.NoError(t, err) @@ -222,7 +222,7 @@ func TestGetFFIEventsQueryResultFail(t *testing.T) { func TestGetFFIEvent(t *testing.T) { s, mock := newMockProvider().init() rows := sqlmock.NewRows(ffiEventsColumns). - AddRow(fftypes.NewUUID().String(), fftypes.NewUUID().String(), "ns1", "sum", "sum", "", []byte(`[]`)) + AddRow(fftypes.NewUUID().String(), fftypes.NewUUID().String(), "ns1", "sum", "sum", "", []byte(`[]`), []byte(`{}`)) mock.ExpectQuery("SELECT .*").WillReturnRows(rows) FFIEvent, err := s.GetFFIEvent(context.Background(), "ns1", fftypes.NewUUID(), "math") assert.NoError(t, err) diff --git a/internal/database/sqlcommon/ffi_methods_sql.go b/internal/database/sqlcommon/ffi_methods_sql.go index 219251695..7363a61a5 100644 --- a/internal/database/sqlcommon/ffi_methods_sql.go +++ b/internal/database/sqlcommon/ffi_methods_sql.go @@ -39,6 +39,7 @@ var ( "description", "params", "returns", + "details", } ffiMethodFilterFieldMap = map[string]string{ "interface": "interface_id", @@ -90,6 +91,7 @@ func (s *SQLCommon) UpsertFFIMethod(ctx context.Context, method *core.FFIMethod) method.Description, method.Params, method.Returns, + method.Details, ), func() { s.callbacks.UUIDCollectionNSEvent(database.CollectionFFIMethods, core.ChangeEventTypeCreated, method.Namespace, method.ID) @@ -113,6 +115,7 @@ func (s *SQLCommon) ffiMethodResult(ctx context.Context, row *sql.Rows) (*core.F &method.Description, &method.Params, &method.Returns, + &method.Details, ) if err != nil { return nil, i18n.WrapError(ctx, err, coremsgs.MsgDBReadErr, ffimethodsTable) diff --git a/internal/database/sqlcommon/ffi_methods_sql_test.go b/internal/database/sqlcommon/ffi_methods_sql_test.go index d96aa5328..236b3876f 100644 --- a/internal/database/sqlcommon/ffi_methods_sql_test.go +++ b/internal/database/sqlcommon/ffi_methods_sql_test.go @@ -182,7 +182,7 @@ func TestGetFFIMethods(t *testing.T) { ) s, mock := newMockProvider().init() rows := sqlmock.NewRows(ffiMethodsColumns). - AddRow(fftypes.NewUUID().String(), fftypes.NewUUID().String(), "ns1", "sum", "sum", "", []byte(`[]`), []byte(`[]`)) + AddRow(fftypes.NewUUID().String(), fftypes.NewUUID().String(), "ns1", "sum", "sum", "", []byte(`[]`), []byte(`[]`), []byte(`{}`)) mock.ExpectQuery("SELECT .*").WillReturnRows(rows) _, _, err := s.GetFFIMethods(context.Background(), filter) assert.NoError(t, err) @@ -226,7 +226,7 @@ func TestGetFFIMethodsQueryResultFail(t *testing.T) { func TestGetFFIMethod(t *testing.T) { s, mock := newMockProvider().init() rows := sqlmock.NewRows(ffiMethodsColumns). - AddRow(fftypes.NewUUID().String(), fftypes.NewUUID().String(), "ns1", "sum", "sum", "", []byte(`[]`), []byte(`[]`)) + AddRow(fftypes.NewUUID().String(), fftypes.NewUUID().String(), "ns1", "sum", "sum", "", []byte(`[]`), []byte(`[]`), []byte(`{}`)) mock.ExpectQuery("SELECT .*").WillReturnRows(rows) FFIMethod, err := s.GetFFIMethod(context.Background(), "ns1", fftypes.NewUUID(), "math") assert.NoError(t, err) diff --git a/internal/oapiffi/ffi2swagger.go b/internal/oapiffi/ffi2swagger.go index 43dfb1b03..4b6475629 100644 --- a/internal/oapiffi/ffi2swagger.go +++ b/internal/oapiffi/ffi2swagger.go @@ -21,6 +21,8 @@ import ( "encoding/json" "fmt" "net/http" + "sort" + "strings" "github.com/getkin/kin-openapi/openapi3" "github.com/hyperledger/firefly-common/pkg/fftypes" @@ -81,6 +83,10 @@ func (og *ffiSwaggerGen) Generate(ctx context.Context, baseURL string, api *core } func (og *ffiSwaggerGen) addMethod(routes []*oapispec.Route, method *core.FFIMethod, hasLocation bool) []*oapispec.Route { + description := method.Description + if method.Details != nil && len(method.Details) > 0 { + description = fmt.Sprintf("%s\n\nAdditional smart contract details:\n\n%s", description, buildDetailsTable(method.Details)) + } routes = append(routes, &oapispec.Route{ Name: fmt.Sprintf("invoke_%s", method.Pathname), Path: fmt.Sprintf("invoke/%s", method.Pathname), // must match a route defined in apiserver routes! @@ -88,6 +94,7 @@ func (og *ffiSwaggerGen) addMethod(routes []*oapispec.Route, method *core.FFIMet JSONInputSchema: func(ctx context.Context) string { return contractCallJSONSchema(&method.Params, hasLocation).String() }, JSONOutputSchema: func(ctx context.Context) string { return ffiParamsJSONSchema(&method.Returns).String() }, JSONOutputCodes: []int{http.StatusOK}, + Description: description, }) routes = append(routes, &oapispec.Route{ Name: fmt.Sprintf("query_%s", method.Pathname), @@ -96,11 +103,16 @@ func (og *ffiSwaggerGen) addMethod(routes []*oapispec.Route, method *core.FFIMet JSONInputSchema: func(ctx context.Context) string { return contractCallJSONSchema(&method.Params, hasLocation).String() }, JSONOutputSchema: func(ctx context.Context) string { return ffiParamsJSONSchema(&method.Returns).String() }, JSONOutputCodes: []int{http.StatusOK}, + Description: description, }) return routes } func (og *ffiSwaggerGen) addEvent(routes []*oapispec.Route, event *core.FFIEvent, hasLocation bool) []*oapispec.Route { + description := event.Description + if event.Details != nil && len(event.Details) > 0 { + description = fmt.Sprintf("%s\n\nAdditional smart contract details:\n\n%s", description, buildDetailsTable(event.Details)) + } routes = append(routes, &oapispec.Route{ Name: fmt.Sprintf("createlistener_%s", event.Pathname), Path: fmt.Sprintf("listeners/%s", event.Pathname), // must match a route defined in apiserver routes! @@ -122,6 +134,7 @@ func (og *ffiSwaggerGen) addEvent(routes []*oapispec.Route, event *core.FFIEvent JSONInputValue: nil, JSONOutputValue: func() interface{} { return []*core.ContractListener{} }, JSONOutputCodes: []int{http.StatusOK}, + Description: description, }) return routes } @@ -161,3 +174,18 @@ func ffiParamJSONSchema(param *core.FFIParam) *fftypes.JSONObject { } return nil } + +func buildDetailsTable(details map[string]interface{}) string { + var s strings.Builder + s.WriteString(`| | |\n-----`) + keys := make([]string, len(details)) + i := 0 + for key := range details { + keys[i] = key + } + sort.Strings(keys) + for _, key := range keys { + s.WriteString(fmt.Sprintf(`|%s|%s|\n`, key, details[key])) + } + return s.String() +} diff --git a/internal/oapispec/openapi3.go b/internal/oapispec/openapi3.go index a5b61d5f7..a0f317eed 100644 --- a/internal/oapispec/openapi3.go +++ b/internal/oapispec/openapi3.go @@ -294,7 +294,7 @@ func addParam(ctx context.Context, op *openapi3.Operation, in, name, def, exampl func addRoute(ctx context.Context, doc *openapi3.T, route *Route, conf *SwaggerGenConfig) { pi := getPathItem(doc, route.Path) - routeDescription := i18n.Expand(ctx, route.Description) + routeDescription := i18n.Expand(ctx, route.DescriptionKey) if routeDescription == "" && conf.PanicOnMissingDescription { log.Panicf(i18n.NewError(ctx, coremsgs.MsgRouteDescriptionMissing, route.Name).Error()) } diff --git a/internal/oapispec/openapi3_test.go b/internal/oapispec/openapi3_test.go index ff4bfc817..7961841e5 100644 --- a/internal/oapispec/openapi3_test.go +++ b/internal/oapispec/openapi3_test.go @@ -42,7 +42,7 @@ var testRoutes = []*Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewMessageBroadcast, + DescriptionKey: coremsgs.APIEndpointsPostNewMessageBroadcast, JSONInputValue: func() interface{} { return &core.MessageInOut{} }, JSONOutputValue: func() interface{} { return &core.Batch{} }, JSONOutputCodes: []int{http.StatusOK}, @@ -54,7 +54,7 @@ var testRoutes = []*Route{ PathParams: nil, QueryParams: nil, FilterFactory: database.MessageQueryFactory, - Description: coremsgs.APIEndpointsPostNewMessageBroadcast, + DescriptionKey: coremsgs.APIEndpointsPostNewMessageBroadcast, JSONInputValue: func() interface{} { return nil }, JSONInputSchema: func(ctx context.Context) string { return `{ @@ -89,7 +89,7 @@ var testRoutes = []*Route{ {Name: "myfield", Default: "val1", Description: coremsgs.APIParamsDataID}, }, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewMessageBroadcast, + DescriptionKey: coremsgs.APIEndpointsPostNewMessageBroadcast, JSONInputValue: func() interface{} { return &core.MessageInOut{} }, JSONOutputValue: func() interface{} { return nil }, JSONOutputCodes: []int{http.StatusNoContent}, @@ -107,7 +107,7 @@ var testRoutes = []*Route{ }, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewMessageBroadcast, + DescriptionKey: coremsgs.APIEndpointsPostNewMessageBroadcast, JSONInputValue: func() interface{} { return nil }, JSONOutputValue: func() interface{} { return nil }, JSONOutputCodes: []int{http.StatusNoContent}, @@ -119,7 +119,7 @@ var testRoutes = []*Route{ PathParams: nil, QueryParams: nil, FilterFactory: nil, - Description: coremsgs.APIEndpointsPostNewMessageBroadcast, + DescriptionKey: coremsgs.APIEndpointsPostNewMessageBroadcast, JSONInputValue: func() interface{} { return &core.Data{} }, JSONOutputValue: func() interface{} { return &core.Data{} }, JSONOutputCodes: []int{http.StatusOK}, @@ -298,7 +298,7 @@ func TestPanicOnMissingDescription(t *testing.T) { Name: "PostPanicOnMissingDescription", Path: "namespaces/{ns}/example1/test", Method: http.MethodPost, - Description: "this is fine", + DescriptionKey: "this is fine", JSONInputValue: func() interface{} { return &TestInOutType{} }, JSONOutputValue: func() interface{} { return &TestInOutType{} }, JSONOutputCodes: []int{http.StatusOK}, @@ -321,7 +321,7 @@ func TestPanicOnMissingFFStructTag(t *testing.T) { Name: "GetPanicOnMissingFFStructTag", Path: "namespaces/{ns}/example1/test", Method: http.MethodGet, - Description: "this is fine", + DescriptionKey: "this is fine", JSONOutputValue: func() interface{} { return &TestNonTaggedType{} }, JSONOutputCodes: []int{http.StatusOK}, }, diff --git a/internal/oapispec/routes.go b/internal/oapispec/routes.go index 5cfbca43a..d3d7caf08 100644 --- a/internal/oapispec/routes.go +++ b/internal/oapispec/routes.go @@ -43,8 +43,10 @@ type Route struct { FilterFactory database.QueryFactory // Method is the HTTP method Method string - // Description is a message key to a translatable description of the operation - Description i18n.MessageKey + // DescriptionKey is a message key to a translatable description of the operation + DescriptionKey i18n.MessageKey + // Description is a string description of the route. Can sometimes be used instead of DescriptionKey + Description string // JSONInputValue is a function that returns a pointer to a structure to take JSON input JSONInputValue func() interface{} // JSONInputMask are fields that aren't available for users to supply on input diff --git a/pkg/core/ffi.go b/pkg/core/ffi.go index 25501b50c..89fdf527f 100644 --- a/pkg/core/ffi.go +++ b/pkg/core/ffi.go @@ -66,20 +66,22 @@ type FFI struct { } type FFIMethod struct { - ID *fftypes.UUID `ffstruct:"FFIMethod" json:"id,omitempty" ffexcludeinput:"true"` - Interface *fftypes.UUID `ffstruct:"FFIMethod" json:"interface,omitempty" ffexcludeinput:"true"` - Name string `ffstruct:"FFIMethod" json:"name"` - Namespace string `ffstruct:"FFIMethod" json:"namespace,omitempty" ffexcludeinput:"true"` - Pathname string `ffstruct:"FFIMethod" json:"pathname" ffexcludeinput:"true"` - Description string `ffstruct:"FFIMethod" json:"description"` - Params FFIParams `ffstruct:"FFIMethod" json:"params"` - Returns FFIParams `ffstruct:"FFIMethod" json:"returns"` + ID *fftypes.UUID `ffstruct:"FFIMethod" json:"id,omitempty" ffexcludeinput:"true"` + Interface *fftypes.UUID `ffstruct:"FFIMethod" json:"interface,omitempty" ffexcludeinput:"true"` + Name string `ffstruct:"FFIMethod" json:"name"` + Namespace string `ffstruct:"FFIMethod" json:"namespace,omitempty" ffexcludeinput:"true"` + Pathname string `ffstruct:"FFIMethod" json:"pathname" ffexcludeinput:"true"` + Description string `ffstruct:"FFIMethod" json:"description"` + Params FFIParams `ffstruct:"FFIMethod" json:"params"` + Returns FFIParams `ffstruct:"FFIMethod" json:"returns"` + Details fftypes.JSONObject `ffstruct:"FFIMethod" json:"details,omitempty"` } type FFIEventDefinition struct { - Name string `ffstruct:"FFIEvent" json:"name"` - Description string `ffstruct:"FFIEvent" json:"description"` - Params FFIParams `ffstruct:"FFIEvent" json:"params"` + Name string `ffstruct:"FFIEvent" json:"name"` + Description string `ffstruct:"FFIEvent" json:"description"` + Params FFIParams `ffstruct:"FFIEvent" json:"params"` + Details fftypes.JSONObject `ffstruct:"FFIEvent" json:"details,omitempty"` } type FFIEvent struct { @@ -128,21 +130,21 @@ func (f *FFI) SetBroadcastMessage(msgID *fftypes.UUID) { } // Scan implements sql.Scanner -func (m *FFIParams) Scan(src interface{}) error { +func (p *FFIParams) Scan(src interface{}) error { switch src := src.(type) { case nil: - m = nil + p = nil return nil case string: - return json.Unmarshal([]byte(src), &m) + return json.Unmarshal([]byte(src), &p) case []byte: - return json.Unmarshal(src, &m) + return json.Unmarshal(src, &p) default: - return i18n.NewError(context.Background(), i18n.MsgTypeRestoreFailed, src, m) + return i18n.NewError(context.Background(), i18n.MsgTypeRestoreFailed, src, p) } } -func (m FFIParams) Value() (driver.Value, error) { - bytes, _ := json.Marshal(m) +func (p FFIParams) Value() (driver.Value, error) { + bytes, _ := json.Marshal(p) return bytes, nil } From fe3988c7ded99075f0df49308f5ebb912f2b95dc Mon Sep 17 00:00:00 2001 From: Peter Broadhurst Date: Mon, 13 Jun 2022 11:28:06 -0400 Subject: [PATCH 4/7] Remove redundant payloadRef field on Batch Pin Signed-off-by: Peter Broadhurst --- docs/swagger/swagger.yaml | 16 ---------------- pkg/core/batch.go | 9 ++++----- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 7de8df97b..48872a080 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -1510,10 +1510,6 @@ paths: description: The UUID of the node that generated the batch format: uuid type: string - payloadRef: - description: For broadcast batches, this is the reference to - the binary batch in shared storage - type: string tx: description: The FireFly transaction associated with this batch properties: @@ -1598,10 +1594,6 @@ paths: description: The UUID of the node that generated the batch format: uuid type: string - payloadRef: - description: For broadcast batches, this is the reference to the - binary batch in shared storage - type: string tx: description: The FireFly transaction associated with this batch properties: @@ -10512,10 +10504,6 @@ paths: description: The UUID of the node that generated the batch format: uuid type: string - payloadRef: - description: For broadcast batches, this is the reference to - the binary batch in shared storage - type: string tx: description: The FireFly transaction associated with this batch properties: @@ -10607,10 +10595,6 @@ paths: description: The UUID of the node that generated the batch format: uuid type: string - payloadRef: - description: For broadcast batches, this is the reference to the - binary batch in shared storage - type: string tx: description: The FireFly transaction associated with this batch properties: diff --git a/pkg/core/batch.go b/pkg/core/batch.go index 799166d8b..a8e187fb6 100644 --- a/pkg/core/batch.go +++ b/pkg/core/batch.go @@ -78,11 +78,10 @@ type Batch struct { // BatchPersisted is the structure written to the database type BatchPersisted struct { BatchHeader - Hash *fftypes.Bytes32 `ffstruct:"Batch" json:"hash"` - Manifest *fftypes.JSONAny `ffstruct:"Batch" json:"manifest"` - TX TransactionRef `ffstruct:"Batch" json:"tx"` - PayloadRef string `ffstruct:"Batch" json:"payloadRef,omitempty"` - Confirmed *fftypes.FFTime `ffstruct:"Batch" json:"confirmed"` + Hash *fftypes.Bytes32 `ffstruct:"Batch" json:"hash"` + Manifest *fftypes.JSONAny `ffstruct:"Batch" json:"manifest"` + TX TransactionRef `ffstruct:"Batch" json:"tx"` + Confirmed *fftypes.FFTime `ffstruct:"Batch" json:"confirmed"` } // BatchPayload contains the full JSON of the messages and data, but From 85ae9c8b4eda1752d2cb74a958102201bacc43d9 Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 13 Jun 2022 16:18:44 -0400 Subject: [PATCH 5/7] Update generated oas for custom contracts Signed-off-by: Nicko Guyer --- go.mod | 6 +- go.sum | 6 +- internal/apiserver/ffi2swagger.go | 99 ++++++++++++++------------ internal/apiserver/ffi2swagger_test.go | 7 ++ 4 files changed, 68 insertions(+), 50 deletions(-) diff --git a/go.mod b/go.mod index 568cab1ba..46d127585 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,8 @@ require ( github.com/golang-migrate/migrate/v4 v4.15.2 github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.5.0 - github.com/hyperledger/firefly-common v0.1.9 - github.com/hyperledger/firefly-signer v0.9.4 + github.com/hyperledger/firefly-common v0.1.10 + github.com/hyperledger/firefly-signer v0.9.10 github.com/jarcoal/httpmock v1.1.0 github.com/karlseguin/ccache v2.0.3+incompatible github.com/lib/pq v1.10.6 @@ -84,5 +84,3 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -replace github.com/hyperledger/firefly-signer => ../firefly-signer diff --git a/go.sum b/go.sum index 185c17dcd..758f8d0bc 100644 --- a/go.sum +++ b/go.sum @@ -728,8 +728,10 @@ github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpT github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hyperledger/firefly-common v0.1.5/go.mod h1:qGy7i8eWlE8Ed7jFn2Hpn8bYaflL204j4NJB1mAfTms= -github.com/hyperledger/firefly-common v0.1.9 h1:7QWaJ6WU5NrLp+lKqkWpLi/T+HAJn4tk84tq/cxpghk= -github.com/hyperledger/firefly-common v0.1.9/go.mod h1:MYL6Dbj3KqM/79IkS+mCzJ7wRguNbd/PKdVu8aXo5TI= +github.com/hyperledger/firefly-common v0.1.10 h1:BtP20uuPMP9+Q1+bRPJyBDCp5hObqd+JVMqoAoWBvVw= +github.com/hyperledger/firefly-common v0.1.10/go.mod h1:MYL6Dbj3KqM/79IkS+mCzJ7wRguNbd/PKdVu8aXo5TI= +github.com/hyperledger/firefly-signer v0.9.10 h1:pJgeuAH+q2qLuSSJ4sW3eZ9rd7oEyssCKDBNMj905As= +github.com/hyperledger/firefly-signer v0.9.10/go.mod h1:BjzIWMj4e1Em52liuyCV6dQhPeVc3WOuLOnEDGS4QK4= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= diff --git a/internal/apiserver/ffi2swagger.go b/internal/apiserver/ffi2swagger.go index 752ec65b6..3fe215ba6 100644 --- a/internal/apiserver/ffi2swagger.go +++ b/internal/apiserver/ffi2swagger.go @@ -21,10 +21,14 @@ import ( "encoding/json" "fmt" "net/http" + "sort" + "strings" "github.com/getkin/kin-openapi/openapi3" + "github.com/hyperledger/firefly-common/pkg/config" "github.com/hyperledger/firefly-common/pkg/ffapi" "github.com/hyperledger/firefly-common/pkg/fftypes" + "github.com/hyperledger/firefly/internal/coreconfig" "github.com/hyperledger/firefly/pkg/core" "github.com/hyperledger/firefly/pkg/database" ) @@ -73,42 +77,45 @@ func (og *ffiSwaggerGen) Generate(ctx context.Context, baseURL string, api *core } return ffapi.NewSwaggerGen(&ffapi.Options{ - Title: ffi.Name, - Version: ffi.Version, - Description: ffi.Description, - BaseURL: baseURL, + Title: ffi.Name, + Version: ffi.Version, + Description: ffi.Description, + BaseURL: baseURL, + DefaultRequestTimeout: config.GetDuration(coreconfig.APIRequestTimeout), }).Generate(ctx, routes) } func (og *ffiSwaggerGen) addMethod(routes []*ffapi.Route, method *core.FFIMethod, hasLocation bool) []*ffapi.Route { - // description := method.Description - // if method.Details != nil && len(method.Details) > 0 { - // description = fmt.Sprintf("%s\n\nAdditional smart contract details:\n\n%s", description, buildDetailsTable(method.Details)) - // } + description := method.Description + if method.Details != nil && len(method.Details) > 0 { + description = fmt.Sprintf("%s\n\nAdditional smart contract details:\n\n%s", description, buildDetailsTable(method.Details)) + } routes = append(routes, &ffapi.Route{ - Name: fmt.Sprintf("invoke_%s", method.Pathname), - Path: fmt.Sprintf("invoke/%s", method.Pathname), // must match a route defined in apiserver routes! - Method: http.MethodPost, - JSONInputSchema: func(ctx context.Context) string { return contractCallJSONSchema(&method.Params, hasLocation).String() }, - JSONOutputSchema: func(ctx context.Context) string { return ffiParamsJSONSchema(&method.Returns).String() }, - JSONOutputCodes: []int{http.StatusOK}, + Name: fmt.Sprintf("invoke_%s", method.Pathname), + Path: fmt.Sprintf("invoke/%s", method.Pathname), // must match a route defined in apiserver routes! + Method: http.MethodPost, + JSONInputSchema: func(ctx context.Context) string { return contractCallJSONSchema(&method.Params, hasLocation).String() }, + JSONOutputSchema: func(ctx context.Context) string { return ffiParamsJSONSchema(&method.Returns).String() }, + JSONOutputCodes: []int{http.StatusOK}, + PreTranslatedDescription: description, }) routes = append(routes, &ffapi.Route{ - Name: fmt.Sprintf("query_%s", method.Pathname), - Path: fmt.Sprintf("query/%s", method.Pathname), // must match a route defined in apiserver routes! - Method: http.MethodPost, - JSONInputSchema: func(ctx context.Context) string { return contractCallJSONSchema(&method.Params, hasLocation).String() }, - JSONOutputSchema: func(ctx context.Context) string { return ffiParamsJSONSchema(&method.Returns).String() }, - JSONOutputCodes: []int{http.StatusOK}, + Name: fmt.Sprintf("query_%s", method.Pathname), + Path: fmt.Sprintf("query/%s", method.Pathname), // must match a route defined in apiserver routes! + Method: http.MethodPost, + JSONInputSchema: func(ctx context.Context) string { return contractCallJSONSchema(&method.Params, hasLocation).String() }, + JSONOutputSchema: func(ctx context.Context) string { return ffiParamsJSONSchema(&method.Returns).String() }, + JSONOutputCodes: []int{http.StatusOK}, + PreTranslatedDescription: description, }) return routes } func (og *ffiSwaggerGen) addEvent(routes []*ffapi.Route, event *core.FFIEvent, hasLocation bool) []*ffapi.Route { - // description := event.Description - // if event.Details != nil && len(event.Details) > 0 { - // description = fmt.Sprintf("%s\n\nAdditional smart contract details:\n\n%s", description, buildDetailsTable(event.Details)) - // } + description := event.Description + if event.Details != nil && len(event.Details) > 0 { + description = fmt.Sprintf("%s\n\nAdditional smart contract details:\n\n%s", description, buildDetailsTable(event.Details)) + } routes = append(routes, &ffapi.Route{ Name: fmt.Sprintf("createlistener_%s", event.Pathname), Path: fmt.Sprintf("listeners/%s", event.Pathname), // must match a route defined in apiserver routes! @@ -119,8 +126,9 @@ func (og *ffiSwaggerGen) addEvent(routes []*ffapi.Route, event *core.FFIEvent, h } return &ContractListenerInputWithLocation{} }, - JSONOutputValue: func() interface{} { return &core.ContractListener{} }, - JSONOutputCodes: []int{http.StatusOK}, + JSONOutputValue: func() interface{} { return &core.ContractListener{} }, + JSONOutputCodes: []int{http.StatusOK}, + PreTranslatedDescription: description, }) routes = append(routes, &ffapi.Route{ Name: fmt.Sprintf("getlistener_%s", event.Pathname), @@ -141,15 +149,18 @@ func (og *ffiSwaggerGen) addEvent(routes []*ffapi.Route, event *core.FFIEvent, h * Returns the JSON Schema as an `fftypes.JSONObject`. */ func contractCallJSONSchema(params *core.FFIParams, hasLocation bool) *fftypes.JSONObject { - req := &core.ContractCallRequest{ - Input: *ffiParamsJSONSchema(params), + properties := fftypes.JSONObject{ + "input": ffiParamsJSONSchema(params), + "options": fftypes.JSONObject{ + "type": "object", + }, } if !hasLocation { - req.Location = fftypes.JSONAnyPtr(`{}`) + properties["location"] = fftypes.JSONAnyPtr(`{}`) } return &fftypes.JSONObject{ "type": "object", - "properties": req, + "properties": properties, } } @@ -172,17 +183,17 @@ func ffiParamJSONSchema(param *core.FFIParam) *fftypes.JSONObject { return nil } -// func buildDetailsTable(details map[string]interface{}) string { -// var s strings.Builder -// s.WriteString(`| | |\n-----`) -// keys := make([]string, len(details)) -// i := 0 -// for key := range details { -// keys[i] = key -// } -// sort.Strings(keys) -// for _, key := range keys { -// s.WriteString(fmt.Sprintf(`|%s|%s|\n`, key, details[key])) -// } -// return s.String() -// } +func buildDetailsTable(details map[string]interface{}) string { + var s strings.Builder + s.WriteString("| Key | Value |\n|-----|-------|\n") + keys := make([]string, len(details)) + i := 0 + for key := range details { + keys[i] = key + } + sort.Strings(keys) + for _, key := range keys { + s.WriteString(fmt.Sprintf("|%s|%s|\n", key, details[key])) + } + return s.String() +} diff --git a/internal/apiserver/ffi2swagger_test.go b/internal/apiserver/ffi2swagger_test.go index b85854c58..e6a862b12 100644 --- a/internal/apiserver/ffi2swagger_test.go +++ b/internal/apiserver/ffi2swagger_test.go @@ -65,6 +65,10 @@ func testFFI() *core.FFI { Schema: fftypes.JSONAnyPtr(`{"type": "boolean"}`), }, }, + Details: fftypes.JSONObject{ + "payable": true, + "stateMutability": "payable", + }, }, { Name: "method2", @@ -84,6 +88,9 @@ func testFFI() *core.FFI { Schema: fftypes.JSONAnyPtr(`{"type": "integer"}`), }, }, + Details: fftypes.JSONObject{ + "anonymous": true, + }, }, }, }, From e8419846ccd8c6e80791540a06881f3385ace2da Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Tue, 14 Jun 2022 11:16:01 -0400 Subject: [PATCH 6/7] Add string translations for FFI method details. Update custom contract docs. Signed-off-by: Nicko Guyer --- docs/reference/firefly_interface_format.md | 23 +- docs/reference/types/contractlistener.md | 2 +- docs/reference/types/ffi.md | 14 +- docs/swagger/swagger.yaml | 442 +++++++++++++------- docs/tutorials/custom_contracts/ethereum.md | 29 ++ internal/apiserver/ffi2swagger.go | 16 +- internal/coremsgs/en_api_translations.go | 4 + internal/coremsgs/en_struct_descriptions.go | 4 +- internal/reference/reference.go | 7 + 9 files changed, 363 insertions(+), 178 deletions(-) diff --git a/docs/reference/firefly_interface_format.md b/docs/reference/firefly_interface_format.md index 2daf90b87..7f77b506b 100644 --- a/docs/reference/firefly_interface_format.md +++ b/docs/reference/firefly_interface_format.md @@ -35,26 +35,28 @@ There are four required fields when broadcasting a contract interface in FireFly ## Method -Let's look at a what goes inside the `methods` array now. It is also a JSON object that has a `name`, a list of `params` which are the arguments the function will take and a list of `returns` which are the return values of the function. Optionally, it also has a `description` which can be helpful in OpenAPI Spec generation. +Let's look at a what goes inside the `methods` array now. It is also a JSON object that has a `name`, a list of `params` which are the arguments the function will take and a list of `returns` which are the return values of the function. It also has an optional `description` which can be helpful in OpenAPI Spec generation. Finally, it has an optional `details` object which wraps blockchain specific information about this method. This can be used by the blockchain plugin when invoking this function, and it is also used in documentation generation. ```json { "name": "add", "description": "Add two numbers together", "params": [], - "returns": [] + "returns": [], + "details": {} } ``` ## Event -What goes into the `events` array is very similar. It is also a JSON object that has a `name` and a list of `params`. The difference is that `events` don't have `returns`. Arguments that are passed to the event when it is emitted are in `params`. Optionally, it also has a `description` which can be helpful in OpenAPI Spec generation. +What goes into the `events` array is very similar. It is also a JSON object that has a `name` and a list of `params`. The difference is that `events` don't have `returns`. Arguments that are passed to the event when it is emitted are in `params`. It also has an optional `description` which can be helpful in OpenAPI Spec generation. Finally, it has an optional `details` object which wraps blockchain specific information about this event. This can be used by the blockchain plugin when invoking this function, and it is also used in documentation generation. ```json { "name": "added", "description": "An event that occurs when numbers have been added", - "params": [] + "params": [], + "details": {} } ``` @@ -137,7 +139,10 @@ Putting it all together, here is a full example of the FireFly Interface format } } } - ] + ], + "details": { + "stateMutability": "viewable" + } }, { "name": "set", @@ -154,7 +159,10 @@ Putting it all together, here is a full example of the FireFly Interface format } } ], - "returns": [] + "returns": [], + "details": { + "stateMutability": "payable" + } } ], "events": [ @@ -183,7 +191,8 @@ Putting it all together, here is a full example of the FireFly Interface format } } } - ] + ], + "details": {} } ] } diff --git a/docs/reference/types/contractlistener.md b/docs/reference/types/contractlistener.md index a3f77d92c..8fa0c318a 100644 --- a/docs/reference/types/contractlistener.md +++ b/docs/reference/types/contractlistener.md @@ -91,7 +91,7 @@ nav_order: 9 | `name` | The name of the event | `string` | | `description` | A description of the smart contract event | `string` | | `params` | An array of event parameter/argument definitions | [`FFIParam[]`](#ffiparam) | -| `details` | Additional details about the smart contract event | [`JSONObject`](simpletypes#jsonobject) | +| `details` | Additional blockchain specific fields about this event from the original smart contract. Used by the blockchain plugin and for documentation generation. | [`JSONObject`](simpletypes#jsonobject) | ## FFIParam diff --git a/docs/reference/types/ffi.md b/docs/reference/types/ffi.md index 9cd7dd91a..c188540aa 100644 --- a/docs/reference/types/ffi.md +++ b/docs/reference/types/ffi.md @@ -49,7 +49,10 @@ nav_order: 8 } } } - ] + ], + "details": { + "stateMutability": "viewable" + } }, { "id": "fc6f54ee-2e3c-4e56-b17c-4a1a0ae7394b", @@ -69,7 +72,10 @@ nav_order: 8 } } ], - "returns": [] + "returns": [], + "details": { + "stateMutability": "payable" + } } ], "events": [ @@ -132,7 +138,7 @@ nav_order: 8 | `description` | A description of the smart contract method | `string` | | `params` | An array of method parameter/argument definitions | [`FFIParam[]`](#ffiparam) | | `returns` | An array of method return definitions | [`FFIParam[]`](#ffiparam) | -| `details` | Additional details about the smart contract function | [`JSONObject`](simpletypes#jsonobject) | +| `details` | Additional blockchain specific fields about this method from the original smart contract. Used by the blockchain plugin and for documentation generation. | [`JSONObject`](simpletypes#jsonobject) | ## FFIParam @@ -155,7 +161,7 @@ nav_order: 8 | `name` | The name of the event | `string` | | `description` | A description of the smart contract event | `string` | | `params` | An array of event parameter/argument definitions | [`FFIParam[]`](#ffiparam) | -| `details` | Additional details about the smart contract event | [`JSONObject`](simpletypes#jsonobject) | +| `details` | Additional blockchain specific fields about this event from the original smart contract. Used by the blockchain plugin and for documentation generation. | [`JSONObject`](simpletypes#jsonobject) | ## FFIParam diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index ec7884b20..79e76dc47 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -406,10 +406,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -475,10 +477,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -900,10 +904,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object name: description: The name of the event @@ -1063,9 +1069,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the event @@ -2071,10 +2080,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used + by the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -2142,10 +2153,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used + by the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -2262,9 +2275,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the event @@ -2299,9 +2315,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the method @@ -2372,10 +2391,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -2441,10 +2462,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -2565,10 +2588,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -2634,10 +2659,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -2764,10 +2791,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -2833,10 +2862,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -2970,10 +3001,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -3039,10 +3072,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -3178,8 +3213,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract function - description: Additional details about the smart contract function + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the method @@ -3500,10 +3539,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object name: description: The name of the event @@ -3611,8 +3652,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract event - description: Additional details about the smart contract event + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the event @@ -3704,9 +3749,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the event @@ -3855,9 +3903,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the event @@ -3991,8 +4042,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract function - description: Additional details about the smart contract function + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the method @@ -9341,10 +9396,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -9410,10 +9467,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -9570,8 +9629,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract function - description: Additional details about the smart contract function + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the method @@ -9912,10 +9975,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object name: description: The name of the event @@ -10043,8 +10108,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract event - description: Additional details about the smart contract event + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the event @@ -10131,9 +10200,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the event @@ -10288,8 +10360,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract function - description: Additional details about the smart contract function + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the method @@ -11258,10 +11334,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used + by the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -11329,10 +11407,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used + by the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -11456,9 +11536,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the event @@ -11493,9 +11576,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the method @@ -11566,10 +11652,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -11635,10 +11723,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -11766,10 +11856,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -11835,10 +11927,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -11972,10 +12066,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -12041,10 +12137,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -12185,10 +12283,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI event definition @@ -12254,10 +12354,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - function - description: Additional details about the smart contract - function + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this method from the original smart contract. Used by + the blockchain plugin and for documentation generation. type: object id: description: The UUID of the FFI method definition @@ -12400,8 +12502,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract function - description: Additional details about the smart contract function + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the method @@ -12729,10 +12835,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract - event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by + the blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. type: object name: description: The name of the event @@ -12847,8 +12955,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract event - description: Additional details about the smart contract event + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the event @@ -12940,9 +13052,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the event @@ -13105,9 +13220,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract - event - description: Additional details about the smart contract event + description: Additional blockchain specific fields about + this event from the original smart contract. Used by the + blockchain plugin and for documentation generation. + description: Additional blockchain specific fields about this + event from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the event @@ -13248,8 +13366,12 @@ paths: type: string details: additionalProperties: - description: Additional details about the smart contract function - description: Additional details about the smart contract function + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. + description: Additional blockchain specific fields about this + method from the original smart contract. Used by the blockchain + plugin and for documentation generation. type: object name: description: The name of the method diff --git a/docs/tutorials/custom_contracts/ethereum.md b/docs/tutorials/custom_contracts/ethereum.md index cea0aa2e7..8e4d00061 100644 --- a/docs/tutorials/custom_contracts/ethereum.md +++ b/docs/tutorials/custom_contracts/ethereum.md @@ -517,6 +517,35 @@ To make a read-only request to the blockchain to check the current value of the > **NOTE:** Some contracts may have queries that require input parameters. That's why the query endpoint is a `POST`, rather than a `GET` so that parameters can be passed as JSON in the request body. This particular function does not have any parameters, so we just pass an empty JSON object. +## Passing additional options with a request + +Some smart contract functions may accept or require additional options to be passed with the request. For example, a Solidity function might be `payable`, meaning that a `value` field must be specified, indicating an amount of ETH to be transferred with the request. Each of your smart contract API's `/invoke` or `/query` endpoints support an `options` object in addition to the `input` arguments for the function itself. + +Here is an example of sending 100 wei with a transaction: + +### Request + +`POST` `http://localhost:5000/api/v1/namespaces/default/apis/simple-storage/invoke/set` + +```json +{ + "input": { + "newValue": 3 + }, + "options": { + "value": 100 + } +} +``` + +### Response + +```json +{ + "id": "41c67c63-52cf-47ce-8a59-895fe2ffdc86" +} +``` + ## Create a blockchain event listener Now that we've seen how to submit transactions and preform read-only queries to the blockchain, let's look at how to receive blockchain events so we know when things are happening in realtime. diff --git a/internal/apiserver/ffi2swagger.go b/internal/apiserver/ffi2swagger.go index 3fe215ba6..e69209bc0 100644 --- a/internal/apiserver/ffi2swagger.go +++ b/internal/apiserver/ffi2swagger.go @@ -28,7 +28,9 @@ import ( "github.com/hyperledger/firefly-common/pkg/config" "github.com/hyperledger/firefly-common/pkg/ffapi" "github.com/hyperledger/firefly-common/pkg/fftypes" + "github.com/hyperledger/firefly-common/pkg/i18n" "github.com/hyperledger/firefly/internal/coreconfig" + "github.com/hyperledger/firefly/internal/coremsgs" "github.com/hyperledger/firefly/pkg/core" "github.com/hyperledger/firefly/pkg/database" ) @@ -86,9 +88,11 @@ func (og *ffiSwaggerGen) Generate(ctx context.Context, baseURL string, api *core } func (og *ffiSwaggerGen) addMethod(routes []*ffapi.Route, method *core.FFIMethod, hasLocation bool) []*ffapi.Route { + ctx := context.Background() description := method.Description if method.Details != nil && len(method.Details) > 0 { - description = fmt.Sprintf("%s\n\nAdditional smart contract details:\n\n%s", description, buildDetailsTable(method.Details)) + additionalDetailsHeader := i18n.Expand(ctx, coremsgs.APISmartContractDetails) + description = fmt.Sprintf("%s\n\n%s:\n\n%s", description, additionalDetailsHeader, buildDetailsTable(ctx, method.Details)) } routes = append(routes, &ffapi.Route{ Name: fmt.Sprintf("invoke_%s", method.Pathname), @@ -112,9 +116,11 @@ func (og *ffiSwaggerGen) addMethod(routes []*ffapi.Route, method *core.FFIMethod } func (og *ffiSwaggerGen) addEvent(routes []*ffapi.Route, event *core.FFIEvent, hasLocation bool) []*ffapi.Route { + ctx := context.Background() description := event.Description if event.Details != nil && len(event.Details) > 0 { - description = fmt.Sprintf("%s\n\nAdditional smart contract details:\n\n%s", description, buildDetailsTable(event.Details)) + additionalDetailsHeader := i18n.Expand(ctx, coremsgs.APISmartContractDetails) + description = fmt.Sprintf("%s\n\n%s:\n\n%s", description, additionalDetailsHeader, buildDetailsTable(ctx, event.Details)) } routes = append(routes, &ffapi.Route{ Name: fmt.Sprintf("createlistener_%s", event.Pathname), @@ -183,9 +189,11 @@ func ffiParamJSONSchema(param *core.FFIParam) *fftypes.JSONObject { return nil } -func buildDetailsTable(details map[string]interface{}) string { +func buildDetailsTable(ctx context.Context, details map[string]interface{}) string { + keyHeader := i18n.Expand(ctx, coremsgs.APISmartContractDetailsKey) + valueHeader := i18n.Expand(ctx, coremsgs.APISmartContractDetailsKey) var s strings.Builder - s.WriteString("| Key | Value |\n|-----|-------|\n") + s.WriteString(fmt.Sprintf("| %s | %s |\n|-----|-------|\n", keyHeader, valueHeader)) keys := make([]string, len(details)) i := 0 for key := range details { diff --git a/internal/coremsgs/en_api_translations.go b/internal/coremsgs/en_api_translations.go index 5ca933dfc..df32b0580 100644 --- a/internal/coremsgs/en_api_translations.go +++ b/internal/coremsgs/en_api_translations.go @@ -190,4 +190,8 @@ var ( APIHistogramEndTimeParam = ffm("api.histogramEndTime", "End time of the data to be fetched") APIHistogramBucketsParam = ffm("api.histogramBuckets", "Number of buckets between start time and end time") APIIntegerDescription = ffm("api.integer", "An integer. You are recommended to use a JSON string. A JSON number can be used for values up to the safe maximum.") + + APISmartContractDetails = ffm("api.smartContractDetails", "Additional smart contract details") + APISmartContractDetailsKey = ffm("api.smartContractDetailsKey", "Key") + APISmartContractDetailsValue = ffm("api.smartContractDetailsValue", "Value") ) diff --git a/internal/coremsgs/en_struct_descriptions.go b/internal/coremsgs/en_struct_descriptions.go index 043176f17..f884bc79d 100644 --- a/internal/coremsgs/en_struct_descriptions.go +++ b/internal/coremsgs/en_struct_descriptions.go @@ -247,7 +247,7 @@ var ( FFIMethodDescription = ffm("FFIMethod.description", "A description of the smart contract method") FFIMethodParams = ffm("FFIMethod.params", "An array of method parameter/argument definitions") FFIMethodReturns = ffm("FFIMethod.returns", "An array of method return definitions") - FFIMethodDetails = ffm("FFIMethod.details", "Additional details about the smart contract function") + FFIMethodDetails = ffm("FFIMethod.details", "Additional blockchain specific fields about this method from the original smart contract. Used by the blockchain plugin and for documentation generation.") // FFIEvent field descriptions FFIEventID = ffm("FFIEvent.id", "The UUID of the FFI event definition") @@ -258,7 +258,7 @@ var ( FFIEventDescription = ffm("FFIEvent.description", "A description of the smart contract event") FFIEventParams = ffm("FFIEvent.params", "An array of event parameter/argument definitions") FFIEventSignature = ffm("FFIEvent.signature", "The stringified signature of the event, as computed by the blockchain plugin") - FFIEventDetails = ffm("FFIEvent.details", "Additional details about the smart contract event") + FFIEventDetails = ffm("FFIEvent.details", "Additional blockchain specific fields about this event from the original smart contract. Used by the blockchain plugin and for documentation generation.") // FFIParam field descriptions FFIParamName = ffm("FFIParam.name", "The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract") diff --git a/internal/reference/reference.go b/internal/reference/reference.go index cb5fa4f06..d53cc4a6a 100644 --- a/internal/reference/reference.go +++ b/internal/reference/reference.go @@ -184,6 +184,9 @@ func GenerateObjectsReferenceMarkdown(ctx context.Context) (map[string][]byte, e }`), }, }, + Details: fftypes.JSONObject{ + "stateMutability": "viewable", + }, }, { ID: fftypes.MustParseUUID("fc6f54ee-2e3c-4e56-b17c-4a1a0ae7394b"), @@ -204,6 +207,9 @@ func GenerateObjectsReferenceMarkdown(ctx context.Context) (map[string][]byte, e }, }, Returns: core.FFIParams{}, + Details: fftypes.JSONObject{ + "stateMutability": "payable", + }, }, }, Events: []*core.FFIEvent{ @@ -237,6 +243,7 @@ func GenerateObjectsReferenceMarkdown(ctx context.Context) (map[string][]byte, e }`), }, }, + Details: fftypes.JSONObject{}, }, }, }, From 9aca617ddc927443cc2a0e68ee046fdd2c85539a Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Tue, 14 Jun 2022 12:18:45 -0400 Subject: [PATCH 7/7] Improve FFI details parsing Signed-off-by: Nicko Guyer --- internal/blockchain/ethereum/ethereum.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/internal/blockchain/ethereum/ethereum.go b/internal/blockchain/ethereum/ethereum.go index d5a5d170e..4c6a57e9f 100644 --- a/internal/blockchain/ethereum/ethereum.go +++ b/internal/blockchain/ethereum/ethereum.go @@ -805,9 +805,7 @@ func (e *Ethereum) FFIEventDefinitionToABI(ctx context.Context, event *core.FFIE Inputs: abiInputs, } if event.Details != nil { - if anonymous, ok := event.Details["anonymous"]; ok { - abiEntry.Anonymous = anonymous.(bool) - } + abiEntry.Anonymous = event.Details.GetBool("anonymous") } return abiEntry, nil } @@ -829,19 +827,11 @@ func (e *Ethereum) FFIMethodToABI(ctx context.Context, method *core.FFIMethod, i Outputs: abiOutputs, } if method.Details != nil { - stateMutability, ok := method.Details["stateMutability"] - if ok { - stateMutabilityString, ok := stateMutability.(string) - if ok { - abiEntry.StateMutability = abi.StateMutability(stateMutabilityString) - } - } - if payable, ok := method.Details["payable"]; ok { - abiEntry.Payable = payable.(bool) - } - if constant, ok := method.Details["constant"]; ok { - abiEntry.Constant = constant.(bool) + if stateMutability, ok := method.Details.GetStringOk("stateMutability"); ok { + abiEntry.StateMutability = abi.StateMutability(stateMutability) } + abiEntry.Payable = method.Details.GetBool("payable") + abiEntry.Constant = method.Details.GetBool("constant") } return abiEntry, nil }