-
Notifications
You must be signed in to change notification settings - Fork 242
JSON Schema validation for FFIs #419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Nicko Guyer <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #419 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 277 278 +1
Lines 14958 14952 -6
=========================================
- Hits 14958 14952 -6
Continue to review full report at Codecov.
|
Signed-off-by: Nicko Guyer <[email protected]>
Signed-off-by: Nicko Guyer <[email protected]>
Signed-off-by: Nicko Guyer <[email protected]>
Signed-off-by: Nicko Guyer <[email protected]>
Signed-off-by: Nicko Guyer <[email protected]>
Signed-off-by: Nicko Guyer <[email protected]>
Signed-off-by: Nicko Guyer <[email protected]>
| github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= | ||
| github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= | ||
| github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= | ||
| github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder why a few refs to this old library stuck around. Transitive dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm not sure
| return true | ||
| } | ||
| i, err := strconv.ParseInt(matches[1], 10, 0) | ||
| if err == nil && i >= 1 && i <= 32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I learned something about Ethereum today. Didn't know they had fixed byte sizes 1-32. 👨🎓
|
|
||
| func (f *Fabric) GetFFIParamValidator(ctx context.Context) (fftypes.FFIParamValidator, error) { | ||
| // Fabconnect does not require any additional validation beyond "JSON Schema correctness" at this time | ||
| return nil, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
pkg/blockchain/plugin.go
Outdated
| ValidateContractLocation(ctx context.Context, location *fftypes.JSONAny) error | ||
|
|
||
| ValidateFFIParam(ctx context.Context, method *fftypes.FFIParam) error | ||
| // ValidateFFIParam(ctx context.Context, method *fftypes.FFIParam) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
awrichar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really really good. Nice work wrangling this into a (nearly) standard schema.
Signed-off-by: Nicko Guyer <[email protected]>
This PR introduces JSON Schema into FFIs for describing
FFIParams.FFIParams now have aSchemafield that encompasses the previously usedTypeandDetailsfields.The JSON Schema library used allows for extensions with custom compilers and validators to be added. So FireFly's JSON Schema for FFIs is a slightly more restrictive version of JSON Schema draft 2020-12 with the following requirements:
typefield is always requiredstringintegerbooleanarrayobjectThe
typefield is now only used for telling FireFly the input format of a field when a request is made to FireFly's API to invoke a smart contract.For more specialized fields such as bytes, the input format would be
stringand an additionalcontentEncodingproperty can be added to the schema to indicate how to treat the contents of that string.Additionally, blockchain plugins can expose a JSON Schema extension interface specific to that particular blockchain implementation. For example, the Ethereum plugin adds additional requirements (with another meta schema):
detailsfield is always required as an objectdetailsmust contain a property calledtypethat will always be a stringindexedboolean property is optional